pygfx.controllers.PanZoomController

class pygfx.controllers.PanZoomController(camera=None, *, enabled=True, damping=4, auto_update=True, register_events=None)

Bases: Controller

A controller to pan and zoom a camera in a 2D plane parallel to the screen.

Default controls:

  • Left mouse button: pan.

  • Right mouse button: zoom (if camera.maintain_aspect==False, zooms in both dimensions).

  • Fourth mouse button: quickzoom

  • wheel: zoom to point.

  • alt+wheel: adjust fov.

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

Pan the camera (move relative to its local coordinate frame).

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

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

Zoom the view with the given amount.

The delta can be either a scalar or 2-element tuple. The zoom multiplier is calculated using 2**delta. If the camera has maintain_aspect set to True, only the second value is used.

Note that the camera’s distance, width, and height are adjusted, not its zoom property.

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

zoom_to_point(delta: float, pos: Tuple, rect: Tuple, *, animate=False)

Zoom the view while panning to keep the position under the cursor fixed.

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