vispy.scene.cameras.base_camera module#

class vispy.scene.cameras.base_camera.BaseCamera(interactive=True, flip=None, up='+z', parent=None, name=None)#

Bases: Node

Base camera class.

The Camera describes the perspective from which a ViewBox views its subscene, and the way that user interaction affects that perspective.

Most functionality is implemented in subclasses. This base class has no user interaction and causes the subscene to use the same coordinate system as the ViewBox.


Whether the camera processes mouse and keyboard events.

fliptuple of bools

For each dimension, specify whether it is flipped.

up{‘+z’, ‘-z’, ‘+y’, ‘-y’, ‘+x’, ‘-x’}

The direction that is considered up. Default ‘+z’. Not all camera’s may support this (yet).


The parent of the camera.


Name used to identify the camera in the scene.

property center#

The center location for this camera

The exact meaning of this value differs per type of camera, but generally means the point of interest or the rotation point.

property depth_value#

The depth value to use in orthographic and perspective projection

For orthographic projections, depth_value is the distance between the near and far clipping planes. For perspective projections, it is the ratio between the near and far clipping plane distances.

GL has a fixed amount of precision in the depth buffer, and a fixed constant will not work for both a very large range and very high precision. This property provides the user a way to override the default value if necessary.

property flip#
property fov#

Field-of-view angle of the camera. If 0, the camera is in orthographic mode.


Get the current view state of the camera

Returns a dict of key-value pairs. The exact keys depend on the camera. Can be passed to set_state() (of this or another camera of the same type) to reproduce the state.

propslist of strings | None

List of properties to include in the returned dict. If None, all of camera state is returned.

property interactive#

Boolean describing whether the camera should enable or disable user interaction.

Link this camera with another camera of the same type

Linked camera’s keep each-others’ state in sync.

camerainstance of Camera

The other camera to link.

propslist of strings | tuple of strings | None

List of camera state properties to keep in sync between the two cameras. If None, all of camera state is kept in sync.

axis“x” | “y” | None

An axis to link between two PanZoomCamera instances. If not None, view limits in the selected axis only will be kept in sync between the cameras.


Canvas change event handler

eventinstance of Event

The event.

property pre_transform#

A transform to apply to the beginning of the scene transform, in addition to anything else provided by this Camera.


Reset the view to the default state.


Set the current state to be the default state to be applied when calling reset().

set_range(x=None, y=None, z=None, margin=0.05)#

Set the range of the view region for the camera

xtuple | None

X range.

ytuple | None

Y range.

ztuple | None

Z range.


Margin to use.


The view is set to the given range or to the scene boundaries if ranges are not specified. The ranges should be 2-element tuples specifying the min and max for each dimension.

For the PanZoomCamera the view is fully defined by the range. For e.g. the TurntableCamera the elevation and azimuth are not set. One should use reset() for that.

set_state(state=None, **kwargs)#

Set the view state of the camera

Should be a dict (or kwargs) as returned by get_state. It can be an incomlete dict, in which case only the specified properties are set.


The camera state.


Unused keyword arguments.

property up#

The dimension that is considered up.


Called when this camera is changes its view. Also called when its associated with a viewbox.

property viewbox#

The viewbox that this camera applies to.


The ViewBox key event handler

eventinstance of Event

The event.


Viewbox mouse event handler

eventinstance of Event

The event.


The ViewBox resize handler to update the transform

eventinstance of Event

The event.

zoom_factor = 0.007#
vispy.scene.cameras.base_camera.nested_getattr(obj, names)#
vispy.scene.cameras.base_camera.nested_setattr(obj, names, val)#