THREE.JS / FOUNDATIONS 204

Wheels are a constraint system.

This route turns Rapier's ray-cast vehicle controller into a small driving laboratory: the chassis is a dynamic rigid body, wheels raycast through suspension, and engine, steering, friction, and brake writes become measurable state.

Initializing Preparing renderer

Preparing the Rapier world, chassis, wheels, and vehicle controller...

physics
-
bodies
-
wheels
-
speed
-
steering
-
engine
-
brake
-
fps
-
Vehicle controlsidle chassis

Click a direction to toggle it; press the same button again to idle. Keyboard input mirrors the official WASD/arrow control path.

Vehicle controller contractofficial API boundary
await RapierPhysics()create gravity world
physics.addMesh(chassis, 10, ...)register dynamic chassis
world.createVehicleController(chassis)create ray-cast controller
vehicle.addWheel(...)define suspension ray
setWheelEngineForce(...)apply drive force
setWheelSteering(...)set steering angle
setWheelBrake(...)apply braking impulse
updateVehicle(dt)integrate vehicle forces
wheelSuspensionLength(...)sync visible wheel
new RapierHelper(world)inspect collider topology

The chassis remains a normal dynamic rigid body. The controller adds wheel raycasts and directly updates chassis velocity; wheel meshes are visual children whose suspension and rotation are read from controller telemetry.

Wheel telemetry0 / 4 contact
chassis position-
forward speed-
suspension-
wheel impulses-

Rapier is loading. Wheel contact, suspension, and impulse telemetry become available after the controller owns the chassis.

Based on the official Rapier vehicle-controller example and JavaScript ray-cast vehicle API. The CPU fallback preserves the interaction labels, but it does not claim suspension or wheel-contact parity.

THREE.JS FOUNDATIONS LAB