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