pygfx.controllers.OrbitController

class pygfx.controllers.OrbitController(*args, target=None, **kwargs)

Bases: PanZoomController

A controller to move a camera in an orbit around a center position.

Supports panning parallel to the screen, zooming, orbiting.

Parameters:

target (tuple of float, optional) – The custom target position (x, y, z) that the camera orbits around. Default is None, which means the target is determined from the camera state.

Notes

The direction of rotation is defined such that it feels like you’re grabbing onto something in the foreground; if you move the mouse to the right, the objects in the foreground move to the right, and those in the background (on the opposite side of the center of rotation) move to the left.

Default controls:

  • Left mouse button: orbit / rotate.

  • Right mouse button: pan.

  • Fourth mouse button: quickzoom

  • wheel: zoom to point.

  • alt+wheel: adjust fov.

property target

The target position (x, y, z) that the camera orbits around.

Set to None to use an implicit target based on the camera state. This only works well in combination with camera.show_object() and camera.show_pos().

rotate(delta: Tuple, rect: Tuple, *, animate=False)

Rotate in an orbit around the target, using two angles (azimuth and elevation, in radians).

If animate is True, the motion is damped. This requires the controller to receive events from the renderer/viewport.