THREE.JS / FOUNDATIONS 197

Physics has a second world.

Three.js draws the room and bodies while Rapier advances rigid-body state. Spawn ordinary meshes, inspect their colliders, then apply impulses without hiding the synchronization boundary.

Initializing Preparing renderer

Preparing WebGLRenderer, room colliders, and RapierPhysics...

physics
-
bodies
-
grounded
-
impulses
-
colliders
-
draws
-
fps
-
Rigid-body fieldordinary meshes

Click a body in the scene to select it. Impulses are applied to the selected mesh through Rapier.

Physics contractscene + world
await RapierPhysics()create gravity world
physics.addScene(scene)register mass metadata
physics.addMesh(mesh, ...)create a rigid body
physics.applyImpulse(...)change body velocity
new RapierHelper(world)visualize colliders

The official addon runs a fixed-time Rapier world and copies body transforms back to Three.js meshes. The local fallback is intentionally labeled and only preserves gravity and room bounds when the CDN module cannot load.

Selected bodynone
shape-
mass-
restitution-
position-

Rapier is loading. Collider lines will appear only after the official helper has a live world.

Based on the official Rapier physics example. Orbit the room, click a body, and use the impulse controls to watch Three.js visuals respond to physics-owned transforms.

THREE.JS FOUNDATIONS LAB