Skip to content

OrbitControls

Interactive camera controller for orbiting around a target point.

OrbitControls 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 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()

Constructs a CameraOrbit object.

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

Factories preferred


OrbitControls::Create() auto

Creates a shared pointer to a OrbitCamera object.

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

Types

OrbitControls::Parameters struct

Parameters for constructing a CameraOrbit object.

ParameterDescription
radius floatDistance of the camera from the target point.
pitch floatPitch angle in radians, measured from the vertical axis.
yaw floatYaw angle in radians, measured from the horizontal axis.
orbit_speed floatRate at which the camera orbits around the target point.
pan_speed floatRate at which the camera pans around the target point.
zoom_speed floatRate at which the camera zooms in and out.

Functions

OnMouseEvent() void virtual

Mouse event handler.

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

OnUpdate() void virtual

Updates the camera control each frame.

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

Released under the MIT License.