Camera

Cameras have all the basic properties described in Object Instructions, e.g. their position. The server always adds a camera with the identifier default-camera, configured from its environment variables (see the configuration example). Further cameras can be added with add_camera. Exactly one camera is active at a time, and the web client renders the scene through it.

Field of View

The vertical field of view in degrees can be updated with fov:

visu.update(camera.fov(35))
connection.update(vec![camera.fov(35.0)])?;

Orbit Controls

The orbit controls let the user rotate, zoom and pan the camera around its orbit target. Each camera has its own settings, which can be updated with the properties of controls:

  • target: The point the camera orbits around and looks at.

  • distance_min: The minimum distance between the camera and the target.

  • distance_max: The maximum distance between the camera and the target.

  • screen_space_panning: Whether panning moves in screen space instead of the plane orthogonal to the camera’s up direction.

visu.update(
    camera.controls.target.xyz(1, 0, 0.25),
    camera.controls.distance_min(0.5),
    camera.controls.distance_max(30),
    camera.controls.screen_space_panning(True),
)
let controls = camera.controls();
connection.update(vec![
    controls.target().xyz(1.0, 0.0, 0.25),
    controls.distance_min(0.5),
    controls.distance_max(30.0),
    controls.screen_space_panning(true),
])?;

The settings of an inactive camera are kept and take effect once it becomes active.

Active Camera

The active camera is selected by its camera object or the identifier of one, e.g. "default-camera":

visu.update(visu.config.scene.active_camera(camera))
connection.update(vec![config.scene().active_camera(&camera)])?;

A camera can also be activated when it is added (active option of add_camera), or by a URL hash to switch between perspectives in a single web client, see Hash Instructions.