OrbitControls
[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.
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()
vglx::OrbitControls::OrbitControls(Camera *camera, const Parameters ¶ms)
Parameter | Description |
---|---|
camera | Pointer to the camera to orbit around. |
params | OrbitControls::Parameters |
Constructs a CameraOrbit object.
Factories preferred
OrbitControls::Create() auto
static auto vglx::OrbitControls::Create(Camera *camera, const Parameters ¶ms)
Parameter | Description |
---|---|
camera | Pointer to the camera to orbit around. |
params | OrbitControls::Parameters |
Creates a shared pointer to a OrbitCamera object.
Types
OrbitControls::Parameters struct
Parameters for constructing a CameraOrbit object.
Name | Type | Description |
---|---|---|
pitch | float | Pitch angle in radians, measured from the vertical axis. |
radius | float | Distance of the camera from the target point. |
yaw | float | Yaw angle in radians, measured from the horizontal axis. |
Properties
orbit_speed float
float orbit_speed { 3.5f }
Rate at which the camera orbits around the target point.
pan_speed float
float pan_speed { 0.5f }
Rate at which the camera pans around the target point.
zoom_speed float
float zoom_speed { 50.0f }
Rate at which the camera zooms in and out.
Functions
OnMouseEvent() void virtual
void vglx::OrbitControls::OnMouseEvent(MouseEvent *event) override
Parameter | Description |
---|---|
event | Pointer to the mouse event. |
Mouse event handler.
OnUpdate() void virtual
void vglx::OrbitControls::OnUpdate(float delta) override
Parameter | Description |
---|---|
delta | Time in seconds since the last update. |
Updates the camera control each frame.