ReadonlysceneThe Scene this engine drives.
ReadonlyworldThe Rapier World instance. Exposed for advanced users who want to
reach in and use Rapier directly (e.g. add joints, queries, sensors).
Applies an instantaneous impulse at the body's centre of mass. Wakes the body if it was sleeping. No-op for fixed / non-existent bodies.
Tears down event subscriptions and frees the Rapier world. After this call the engine is unusable.
Returns the underlying Rapier RigidBody, or null if there's none.
Use it to call Rapier APIs not surfaced here (joints, sleeping,
additional colliders, ...).
Removes the body for an object. No-op if there's no body.
Creates or replaces the body for one SceneObject. Returns the new
Rapier RigidBody, or null when the object isn't in the scene or
has no usable geometry.
Use this to upgrade a default-fixed body to dynamic, swap a cuboid for a ball, or attach friction/restitution to specific objects.
Advances the simulation one step and writes the new world transforms back to every dynamic / kinematic SceneMesh.
Lazy-creates default bodies for any SceneObject queued by event since the previous step. Fixed bodies are never written back — they don't move.
Optional dt overrides Rapier's integration timestep for this call;
use it when you want to drive the simulation at a fixed rate
independent of frame rate. Otherwise Rapier uses its default
1/60 s.
Optionaldt: number
High-performance physics engine bound to a Scene, backed by a caller-injected Rapier 3D world.
Mirrors the cached-singleton pattern of
SceneCollisionIndex— get one via getScenePhysics and the engine self-maintains: it watchesonSceneObjectCreated/onSceneObjectDestroyed/onSceneModelDestroyedand keeps Rapier rigid bodies in step with the Scene.Usage
Architecture
"ball"per-object when needed. Trimesh / convex hull is doable but not enabled here; AABB is enough for the demo cases this is built for.Setting
mesh.matrixper step firesonSceneMeshMatrixChanged(which triggers a re-render) but notonSceneMeshMoved, so the SceneCollisionIndex BVH is not invalidated by physics motion — BVH ray picks remain cheap during simulation.