pygfx.controllers.FlyController

class pygfx.controllers.FlyController(camera, *, speed=None, **kwargs)

Bases: Controller

A controller to fly around a scene as if it’s a flight simulator.

Default controls:

  • Left mouse button: rotate.

  • “wasd”: move forward, backwards, and strafe to the sides.

  • space/shift: move up/down.

  • “qe”: roll the camera/aircraft around it’s axis.

  • wheel: increase/decrease maximum speed.

  • Fourth mouse button: quickzoom

  • alt+wheel: adjust fov.

property speed

The (maximum) speed that the camera will move, in units per second. By default it’s based off the width and height of the camera.

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

Rotate the camera over two angles (pitch and yaw in radians).

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

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

Rotate the camera over the z-axis (roll, in radians).

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

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

Move the camera in the given (x, y, z) direction.

The delta is expressed in the camera’s local coordinate frame. Forward is in -z direction, because as (per the gltf spec) a camera looks down it’s negative Z-axis.

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