Orbit

The orbit() function sets up a camera controller that orbits around a target point. In addition, auto-rotation can be enabled to continuously rotate the camera around the target.

textElement(
    "Use mouse to orbit, zoom and pan the camera"
);

grid();
sphere(32);

orbit({ autoRotate: 0.25 });

Configuration

Additional configuration can be passed to the orbit() function to customize its behavior.

  • target: The point in 3D space that the camera orbits around. Default is (0, 0, 0)
  • autoRotate: Enables automatic rotation around the target point. The value defines the speed of rotation in radians per second.
  • enableRotate: Enables or disables user-controlled rotation via mouse dragging. Default is true.
  • enableZoom: Enables or disables zooming via mouse wheel. Default is true.
  • enablePan: Enables or disables panning via mouse dragging with RMB or shift + LMB. Default is true.
orbit({
    target: [50, 0, 0],
    autoRotate: 0.25,
    enableRotate: false,
    enableZoom: true,
    enablePan: true,
});