The mesh and collider must agree.
This route turns Rapier's heightfield boundary into a terrain laboratory: one sampled function drives the visible grid and the physics matrix, profile edits rebuild the fixed collider, and falling bodies make the contact result visible.
Preparing the sampled terrain, heightfield body, and dynamic test bodies...
- physics
- -
- samples
- -
- bodies
- -
- terrain
- -
- profile
- -
- height
- -
- selected
- -
- fps
- -
Select a body to inspect its shared terrain height and physics lifecycle.
generateHeight(...)sample one terrain functionBufferGeometry.positionwrite visible row-major gridphysics.addHeightfield(...)register fixed colliderFloat32Array[column * n + row]write Rapier column-major matrixphysics.addMesh(...)register falling bodiesphysics.removeMesh(...)remove dynamic bodyworld.removeRigidBody(...)replace terrain bodynew RapierHelper(world)inspect collider topologyThe visible grid indexes samples as row then column. Rapier's 3D heightfield expects the same samples as a column-major matrix, so the lab writes both views from one function and makes profile rebuilds replace the fixed body.
Rapier is loading. The fixed heightfield and dynamic body map become available after WASM initialization.
Based on the official Rapier terrain example, RapierPhysics docs, and heightfield collider API. The CPU fallback approximates terrain contact and does not claim full heightfield parity.