Skip to content

OrbitControls

Interactive camera controller for orbiting around a target point.

[OrbitControls](/reference/nodes/orbit_controls) enables intuitive camera manipulation using spherical coordinates, allowing users to orbit, zoom, and pan around a fixed target. It is typically attached to a scene node and linked to a [Camera](/reference/cameras/camera) instance, responding to mouse input and updating camera transforms each frame.

This controller is useful for editor views, previews, and navigation interfaces.

cpp
auto MyScene::OnAttached(SharedContextPointer context) -> void override {
  Add(vglx::OrbitControls::Create(
    context->camera, {
      .radius = 5.0f,
      .pitch = math::DegToRad(25.0f),
      .yaw = math::DegToRad(45.0f)
    }
  ));
}

INFO

Derives from Node and inherits all public properties and methods.

Construction

Constructors


OrbitControls()

cpp
vglx::OrbitControls::OrbitControls(Camera *camera, const Parameters &params)
ParameterDescription
cameraPointer to the camera to orbit around.
paramsOrbitControls::Parameters

Constructs a CameraOrbit object.

Factories preferred


OrbitControls::Create() auto

cpp
static auto vglx::OrbitControls::Create(Camera *camera, const Parameters &params)
ParameterDescription
cameraPointer to the camera to orbit around.
paramsOrbitControls::Parameters

Creates a shared pointer to a OrbitCamera object.

Types

OrbitControls::Parameters struct

Parameters for constructing a CameraOrbit object.

NameTypeDescription
pitchfloatPitch angle in radians, measured from the vertical axis.
radiusfloatDistance of the camera from the target point.
yawfloatYaw angle in radians, measured from the horizontal axis.

Properties

orbit_speed float

cpp
float orbit_speed { 3.5f }

Rate at which the camera orbits around the target point.

pan_speed float

cpp
float pan_speed { 0.5f }

Rate at which the camera pans around the target point.

zoom_speed float

cpp
float zoom_speed { 50.0f }

Rate at which the camera zooms in and out.

Functions

OnMouseEvent() void virtual

cpp
void vglx::OrbitControls::OnMouseEvent(MouseEvent *event) override
ParameterDescription
eventPointer to the mouse event.

Mouse event handler.

OnUpdate() void virtual

cpp
void vglx::OrbitControls::OnUpdate(float delta) override
ParameterDescription
deltaTime in seconds since the last update.

Updates the camera control each frame.

Released under the MIT License.