Table of Contents

Class Basic3DOrbitCameraController

Namespace
Stride.CommunityToolkit.Scripts
Assembly
Stride.CommunityToolkit.dll

An orbit camera controller: the camera circles a target point instead of flying freely - the natural way to inspect one object, a scene centrepiece or a 3D chart. Dragging with OrbitButton orbits, the mouse wheel moves closer or further, dragging with PanButton pans the target, and 'H' returns to the starting view.

public class Basic3DOrbitCameraController : SyncScript, IIdentifiable, ICollectorHolder
Inheritance
Basic3DOrbitCameraController
Implements
Inherited Members
Extension Methods

Remarks

Attach it to an entity with a CameraComponent; the entity's starting position relative to Target provides the initial distance and angles, so framing the camera before this script starts (for example with a chart's FrameCamera) also frames the orbit.

Yaw is unconstrained; pitch is clamped between MinPitch and MaxPitch so the camera cannot flip over the top. Zoom is multiplicative - every wheel notch changes the distance by the same fraction - and clamped between MinDistance and MaxDistance. While the middle button is both PanButton and held down, wheel input is ignored, the same guard Basic2DCameraController uses against the wheel-press-rolls-a-notch problem.

The 'F2' help section is shared with the other controllers through DebugOverlay and shows the live target, distance and angles.

Properties

HelpCollapsed

Gets or sets whether the help section starts collapsed. Defaults to true.

public bool HelpCollapsed { get; set; }

Property Value

bool

HelpToggleKey

Gets or sets the key that collapses and expands the help section. Defaults to F2.

public Keys HelpToggleKey { get; set; }

Property Value

Keys

MaxDistance

Gets or sets the furthest the camera can dolly out, in world units. Defaults to 500.

public float MaxDistance { get; set; }

Property Value

float

MaxPitch

Gets or sets the highest pitch in radians - how far above the target the camera may climb. Defaults to about 85°.

public float MaxPitch { get; set; }

Property Value

float

MinDistance

Gets or sets the closest the camera can dolly in, in world units. Defaults to 0.5.

public float MinDistance { get; set; }

Property Value

float

MinPitch

Gets or sets the lowest pitch in radians - how far below the target the camera may sink. Defaults to about −85°.

public float MinPitch { get; set; }

Property Value

float

OrbitButton

Gets or sets the mouse button that orbits while held. Defaults to the left button.

public MouseButton OrbitButton { get; set; }

Property Value

MouseButton

OrbitSensitivity

Gets or sets how far a drag orbits, in radians per full window of mouse travel. Defaults to 4 - dragging across the whole window turns the camera roughly two thirds of a full circle.

public float OrbitSensitivity { get; set; }

Property Value

float

PanButton

Gets or sets the mouse button that pans the target while held. Defaults to the middle button.

public MouseButton PanButton { get; set; }

Property Value

MouseButton

SpeedFactor

Gets or sets the multiplier applied to zoom and pan while a shift key is held. Defaults to 5.

public float SpeedFactor { get; set; }

Property Value

float

Target

Gets or sets the point the camera orbits and looks at. Move it to follow something; the camera keeps its angles and distance.

public Vector3 Target { get; set; }

Property Value

Vector3

ZoomStep

Gets or sets the fraction the distance changes per mouse-wheel notch. Defaults to 0.1 (10 %).

public float ZoomStep { get; set; }

Property Value

float

Methods

Start()

Reads the starting pose - distance and angles come from the entity's position relative to Target - and registers the shared help section.

public override void Start()

Update()

Processes orbit, pan, zoom and reset input, then places the camera on its orbit.

public override void Update()