Command Palette

Search for a command to run...

Hectal
Back to the lesson: Topic 16.1 — Physics Engines
3D Web · Example 2 of 2

Three crates on the stand

One physics step per frame for 240 frames, then it stops stepping. Watch the scene tree: the meshes are ordinary three.js objects.

A physics engine keeps its own world of bodies (things with mass and motion) and colliders (their shapes), applies gravity and contacts, and moves everything forward one step at a time. Rapier runs as WebAssembly: you must await RAPIER.init() before using it.

Change the code and press Run (Ctrl+Enter). Predict what will happen first, then break it on purpose and read what changes. Your edits are saved and match the lesson page.

Ready for more? This phase has 4 hands-on exercises with automatic checks.

Practice questions

Write the code in the editor, run it, then open the model answer to compare.

01

Add a second ball with restitution 0 next to the first, and print both heights.

02

Make the floor a fixed body explicitly, instead of a collider without a body.

Explain it without notes

01

What is the difference between a rigid body and a collider?

02

Why must you await RAPIER.init(), and what happens if you don't?

Three crates on the stand
Press Run to see the page.
idle

Console

Nothing logged yet.

Expected console output

after 240 steps (4 s of physics):
  crate 1: y 0.20, asleep: true
  crate 2: y 0.20, asleep: true
  crate 3: y 0.44, asleep: true