PhysicsWorld class Physics

The simulation world for a subtree of the scene graph.

Wraps any sim.PhysicsSimulation backend, BasicSimulation for queries and triggers, or a solver backend package. Attach to a node, typically the scene root; descendant RigidBody, Collider, and joint components register with the nearest ancestor world on mount.

A scene may contain more than one world; they are independent simulations. The scene's per-frame driver steps the world on a fixed timestep and interpolates dynamic-body transforms for rendering.

The generic components cover the shared contract, not every backend's full surface. For a feature only one backend exposes, downcast simulation to that backend and drive it by handle, (world.simulation as RapierWorld).someRapierFeature(body.handle!), using RigidBody.handle, Collider.handles, or Joint.handle. The components are not final, so a backend companion library (or your own code) can subclass them to wrap backend-specific features in typed components, keeping the pure backend package headless. This is how backends with capabilities beyond the contract stay first-class without widening it.

Inheritance

Constructors

PhysicsWorld(PhysicsSimulation simulation)

Properties

backendName String
Identifier of the wrapped backend, suitable for logging.
no setter
collisions Stream<CollisionEvent>
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.
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
interpolationAlpha double
The most recent interpolation fraction between physics steps, for components smoothing their own rendering the way dynamic bodies do.
no setter
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 fixed steps consumed per frame before time is dropped.
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
simulation PhysicsSimulation
The backend this world drives.
final

Methods

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. fixedDt is 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.
override
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. deltaSeconds is the elapsed time since the previous tick.
inherited

Operators

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