CameraController class abstract Scene graph
Drives a camera node's transform from continuous input.
A camera controller is a Component you attach to the node that carries a CameraComponent. It owns the camera's state (where it is, what it looks at) and eases toward that state every frame, writing the owning node's transform through Node.lookAtFrom. Input arrives as device-agnostic intent (drag, scroll, keys) which the concrete controllers map to their own motion; the CameraControls widget forwards raw Flutter input here, and application code can call the same hooks (or the higher-level intent methods on each subclass) directly.
Smoothing is frame-rate independent: smoothing is the approximate time in seconds the camera takes to settle after input stops, so the feel is the same at any frame rate. Concrete controllers: OrbitCameraController, FlyCameraController, FollowCameraController.
- Inheritance
- Implementers
Constructors
- CameraController({double smoothing = 0.12})
-
Creates a controller with the given
smoothingsettle time in seconds.
Properties
- enabled ↔ bool
-
Whether this component's update hook runs each frame.
getter/setter pairinherited
- 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
- node → Node
-
The node this component is attached to.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- 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 pair
- viewportSize ↔ Size
-
The size of the view driving this controller, in logical pixels.
getter/setter pair
Methods
-
clampDeltaSeconds(
double deltaSeconds) → double - Clamps a frame delta so a stall or a paused view does not teleport the camera when it resumes.
-
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 -
fixedUpdate(
double fixedDt) → void -
Called once per fixed physics step while the component is mounted,
enabled, and loaded.
fixedDtis 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.
-
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).
-
handleScaleUpdate(
double scaleFactor, Offset focalDelta) → void -
A two-plus finger gesture:
scaleFactoris the incremental pinch factor since the last update (>1 spreading, <1 pinching) andfocalDeltais the centroid movement in logical pixels. -
handleScroll(
double scrollDelta) → void -
A scroll/wheel notch;
scrollDeltafollows the platform sign (positive scrolling down/away). -
handleSecondaryDragUpdate(
Offset delta) → void - A secondary drag (right-button mouse drag), in logical pixels. The default pans where the controller supports it.
-
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
-
releaseInput(
) → void - Releases any held input (call when the driving view loses focus so keys released elsewhere do not stick).
-
settleResponse(
double smoothingSeconds, double deltaSeconds) → double -
smoothingResponse for an explicit
smoothingSeconds, so a controller can settle different quantities (look versus movement) at different rates. -
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.
-
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.
deltaSecondsis 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.inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited