FollowCameraController class Scene graph

A third-person camera that eases toward following followTarget, orbiting it at yaw / pitch / distance and looking at a point lookHeight above its origin. Drag orbits, scroll dollies.

Position and look point both ease each frame, so the camera trails a moving target smoothly instead of rigidly. Pitch is clamped so the view stays upright. The horizontal forward / right basis is exposed so movement input can stay camera-relative (pressing forward walks away from the camera whichever way it faces).

Attach it to a node that also carries a CameraComponent. Drive it with a CameraControls widget, or call orbitBy / dollyBy directly.

Inheritance

Constructors

FollowCameraController({Node? followTarget, double distance = 9.0, double lookHeight = 1.4, double yaw = 0.0, double pitch = 0.42, double minPitch = -0.15, double maxPitch = 1.3, double minDistance = 0.5, double maxDistance = double.infinity, double rotateSpeed = math.pi, double dollySpeed = 0.15, double scrollSensitivity = 1 / 120, double smoothing = 0.08})
Creates a follow controller trailing followTarget.

Properties

distance double
Distance from the look point to the camera.
getter/setter pair
dollySpeed double
Proportional dolly rate (see OrbitCameraController.dollySpeed).
getter/setter pair
enabled bool
Whether this component's update hook runs each frame.
getter/setter pairinherited
followTarget Node?
The node to follow. Its world-space position drives the camera; null parks the camera around the origin.
getter/setter pair
forward → Vector3
Unit horizontal direction the camera looks along (away from it).
no setter
hashCode int
The hash code for this object.
no setterinherited
isAttached bool
Whether this component is currently attached to a node.
no setterinherited
isLoaded bool
Whether onLoad has completed.
no setterinherited
isMounted bool
Whether the owning node is part of a live scene graph.
no setterinherited
lookHeight double
Height above the target's origin that the camera looks at.
getter/setter pair
maxDistance double
getter/setter pair
maxPitch double
getter/setter pair
minDistance double
Dolly distance clamp. minDistance must be > 0.
getter/setter pair
minPitch double
Pitch clamp (radians).
getter/setter pair
node Node
The node this component is attached to.
no setterinherited
pitch double
Orbit elevation (radians).
no setter
Unit horizontal direction to the camera's right.
no setter
rotateSpeed double
Radians of orbit per view-height of drag.
getter/setter pair
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
scrollSensitivity double
Dolly steps per unit of scroll delta.
getter/setter pair
smoothing double
Approximate time in seconds to settle after input stops (reach ~1% of the remaining offset). Zero moves instantly with no easing.
getter/setter pairinherited
viewportSize Size
The size of the view driving this controller, in logical pixels.
getter/setter pairinherited
yaw double
Orbit azimuth around the target (radians).
no setter

Methods

clampDeltaSeconds(double deltaSeconds) double
Clamps a frame delta so a stall or a paused view does not teleport the camera when it resumes.
inherited
cloneFor(Node cloneOwner) Component?
Returns a copy of this component for cloneOwner, the Node.clone counterpart of the owning node, or null to not carry the component to clones (the default).
inherited
dollyBy(double amount) → void
Dollies toward (amount > 0) or away from the target, proportional to the current distance and clamped to the distance limits.
fixedUpdate(double fixedDt) → void
Called once per fixed physics step while the component is mounted, enabled, and loaded. fixedDt is the fixed timestep of the surrounding PhysicsWorld, not the frame interval.
inherited
handleDragUpdate(Offset delta) → void
A primary drag (one finger, or a left-button mouse drag), in logical pixels. The default rotates/looks; override to remap.
override
handleKeyEvent(KeyEvent event) bool
A keyboard event; controllers that move on keys track held state here. Returns true when the key is consumed (so the driver can stop it propagating and the platform does not beep at a held movement key).
inherited
handleScaleUpdate(double scaleFactor, Offset focalDelta) → void
A two-plus finger gesture: scaleFactor is the incremental pinch factor since the last update (>1 spreading, <1 pinching) and focalDelta is the centroid movement in logical pixels.
inherited
handleScroll(double scrollDelta) → void
A scroll/wheel notch; scrollDelta follows the platform sign (positive scrolling down/away).
override
handleSecondaryDragUpdate(Offset delta) → void
A secondary drag (right-button mouse drag), in logical pixels. The default pans where the controller supports it.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
onAttach() → void
Called when this component is added to a node.
inherited
onDetach() → void
Called when this component is removed from a node.
inherited
onLoad() Future<void>
Optional asynchronous setup, such as loading an asset.
inherited
onMount() → void
Called when the owning node enters a live scene graph.
inherited
onUnmount() → void
Called when the owning node leaves a live scene graph.
inherited
orbitBy(double deltaYaw, double deltaPitch) → void
Rotates the orbit by deltaYaw and deltaPitch (radians); pitch clamps.
releaseInput() → void
Releases any held input (call when the driving view loses focus so keys released elsewhere do not stick).
inherited
settleResponse(double smoothingSeconds, double deltaSeconds) double
smoothingResponse for an explicit smoothingSeconds, so a controller can settle different quantities (look versus movement) at different rates.
inherited
smoothingResponse(double deltaSeconds) double
The fraction of the remaining offset to consume this frame for a frame-rate independent exponential settle. One when smoothing is zero.
inherited
toString() String
A string representation of this object.
inherited
update(double deltaSeconds) → void
Called once per frame while the component is mounted, enabled, and loaded. deltaSeconds is the elapsed time since the previous tick. A traversal visits each component at most once. Removing this component or an earlier sibling is safe. A component inserted before the current traversal position starts on the next frame. Reordering component or child lists during traversal is unsupported.
override

Operators

operator ==(Object other) bool
The equality operator.
inherited