PhysicsWorld class abstract Physics
The simulation world for a subtree of the scene graph.
Attach a concrete PhysicsWorld subclass (from a backend package, or the built-in basic backend once that ships) to a node, typically the scene root. Descendant RigidBody and Collider components register with the nearest ancestor world on mount.
A scene may contain more than one world. Multiple worlds are independent simulations and do not collide with each other.
The scene's per-frame driver runs the world on a fixed timestep,
substepping to keep up when the frame interval exceeds
fixedTimestep and interpolating transforms for the rendered frame.
Concrete subclasses implement step and interpolateTransforms.
- Inheritance
- Implementers
Constructors
Properties
- backendName → String
-
Identifier of the concrete backend, suitable for logging
(for example
"basic").no setter -
collisions
→ Stream<
CollisionEvent> -
Stream of collision lifecycle events for every body in this world.
no setter
- enabled ↔ bool
-
Whether this component's update hook runs each frame.
getter/setter pairinherited
- fixedTimestep ↔ double
-
Length of one physics step, in seconds. Defaults to
1/60.getter/setter pair - gravity ↔ Vector3
-
World-space acceleration applied to every dynamic body each step.
getter/setter pair
- 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
- maxSubsteps ↔ int
-
Maximum number of fixed steps consumed per frame. When the frame
interval falls behind this many steps, remaining accumulated time
is dropped to keep simulation from spiralling.
getter/setter pair
- node → Node
-
The node this component is attached to.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
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 -
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
-
overlapBox(
Vector3 center, Vector3 halfExtents, Quaternion rotation, {int layerMask = 0xFFFFFFFF, bool includeFixed = true, bool includeKinematic = true, bool includeDynamic = true, bool includeTriggers = false}) → List< OverlapHit> -
overlapSphere(
Vector3 center, double radius, {int layerMask = 0xFFFFFFFF, bool includeFixed = true, bool includeKinematic = true, bool includeDynamic = true, bool includeTriggers = false}) → List< OverlapHit> -
raycast(
Ray ray, {double maxDistance = double.infinity, int layerMask = 0xFFFFFFFF, bool includeFixed = true, bool includeKinematic = true, bool includeDynamic = true, bool includeTriggers = false}) → RaycastHit? -
raycastAll(
Ray ray, {double maxDistance = double.infinity, int layerMask = 0xFFFFFFFF, bool includeFixed = true, bool includeKinematic = true, bool includeDynamic = true, bool includeTriggers = false}) → List< RaycastHit> -
shapeCast(
Shape shape, Matrix4 from, Vector3 direction, double distance, {int layerMask = 0xFFFFFFFF, bool includeFixed = true, bool includeKinematic = true, bool includeDynamic = true, bool includeTriggers = false}) → ShapeCastHit? -
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.inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited