Feature Library

Race car: a 3D driving controller for any racing game

0.46 GPU · 0.72 CPU ms
A still of the Race car: a 3D driving controller for any racing game demo
Still
The live demo starts when it’s in view.Click the course · W A S D or a gamepad · Space handbrake · C camera · drag to look round · R last checkpoint · F right the car

A car as a rigid body in 3D on four raycast springs, stepped at a fixed 120 Hz with no physics engine.

What it costs a frame

0.46 ms
0.72 ms
GPU
0.46 ms
CPU, median
0.72 ms
CPU, 95th pct
1.00 ms
Draw calls
50
Weight
Moderate

Measured 14 November 2026 on RTX 4060 Laptop, 13th Gen Intel(R) Core(TM) i9-13900H, Chrome 157, 1920×1080 at 1×. 600 frames × 3 rounds, median kept (rounds ranged GPU 0.44–0.46, CPU 0.70–1.02 ms). What ran: Measured driving itself: an autopilot laps the course in the rally car (jumps, the banked turn, gravel and the snow), with the chase camera, shadows and dust. The physics steps at 120 Hz on the CPU. Phones: tiers are being measured next.

On every machine it was measured on
MachineGPU msCPU msCPU p95
RTX 4060 Laptop · 13th Gen Intel(R) Core(TM) i9-13900Hreference · measuring tool0.460.721.00
apple · Apple A19 Proin a browser tab · 16 November 20262.420.380.58

Bars against one 16.7 ms frame. A browser-tab run is timed in a visible tab without the tool’s scripted input, so read it as close, not exact.

What it needs

Renders with
WebGPU or WebGLWebGPU where there is one, WebGL2 where there is not.
Your browser
Runs hereNo WebGPU needed
Depends on
three.js 0.187.0No other packages

What it’s for

  1. A kart, rally, circuit, drift, off-road or top-down racing game
  2. Cars on a mesh track with jumps over real gaps, banking, tunnels and walls
  3. Drivable vehicles in an open world, on a heightmap
  4. A car stepped on a server or in tests, the same every run
  5. Tuning panels and telemetry for car handling
  6. A chase, hood, cockpit or top-down driving camera

Pitfalls, in brief

  1. On a weaker GPU (harness tier medium or low) the demo draws a 1024 shadow map at low, fewer trees and fewer dust puffs; the car, its physics and its cameras are the same at every tier.
  2. The demo's coupé model (muscle-coupe.glb) is an original design made after references to a real car (a third-generation American pony car): it resembles one.
  3. retune takes a new spec live and keeps each strut where it is in the world (the body moves up or down by the change in ride height, then settles); the wheelbase, track and wheel size must stay the same.
  4. Step it with update(frameDt, …), never step with a frame's length: the springs and tyres are tuned at 120 Hz (step takes CAR_STEP, 1/120 s, and nothing longer) and the update splits any frame into those fixed steps, at most 0.25 s of them a frame (a longer stall is dropped; a negative or NaN frame advances nothing).
  5. Axes: y up, the nose toward -z at heading 0, positive steer turns left, a wheel's positive spin rolls it forward.
13 more in brief
  1. Ground casts are the whole world for the car: keep them cheap.
  2. A kerb or step is a contact, not a spring: past full travel the wheel is solid against the chassis (an inelastic push toward the wheel centre, with sideways friction, and an overlap pushed out at no more than 0.5 m/s), the bump stop acts only in its zone and is capped at four times the corner weight, and friction on a wall never lifts the car.
  3. The hull is checked along rays from the centre of mass: keep that centre inside open space.
  4. Place a car with placeOn(ground, x, z, heading), not place, anywhere that is not flat: place sets it level, and on a slope or banked turn the springs fire it off the ground on the first step.
  5. A preset of another shape needs a new RaceCar (wheel positions, springs and inertia come from the shape); assists can change at any time through car.assists.
  6. Weight forward does not make a car nose-dive off a jump on its own: off a lip the nose drops because the rear wheels are still on the ramp, most for a balanced car and a slow take-off.
  7. A real car keeps the spin it leaves the lip with: airStability (the auto-levelling) is 0 on the road cars, so jumps fly like cars, not darts.
  8. forceHeight cancels that share of the roll and pitch moments: 0 is honest (the road presets: they lean by their springs and bars, and a tall truck can roll in a fishhook); 0.5 and over kills the lean a player reads.
  9. bodyPose is drawing only: pose your body mesh (not the wheels) by it, on top of the chassis pose, and keep the wheels on the chassis, or they lean with the bodywork. bodyMotion scales it (0 none, 1 a real car, 2 an arcade one).
  10. Under 1.5 m/s slip is measured against 1.5 m/s, and each tyre's force is capped at what would reverse its own slide in one step: that is what keeps a stopped car still on a slope without creeping.
  11. Traction control feeds forward from the driven tyres' load (the torque they can put down) and trims further while they still spin: a traction value under 1 lets some wheelspin through on purpose.
  12. In the air, the throttle and brake keys pitch the car only when pressed after take-off (the input module does it), the way the wheels do: throttle lifts the nose, brake drops it.
  13. Sprites (dust, smoke, sparks) near a car can show inside it from a hood or cockpit camera: spawn them at the tyres' outer, trailing edge, and drop any fragment inside the car's box (the demo passes the box to a mask node).
18 pitfalls in full, the hook-up guide, the module source and its tests come with the part.

Where it comes from

From HaTac, and in the driving playground showcase. Fully custom code.

Möller–Trumbore ray–triangle intersection (1997): the mesh ground's triangle test, written from the published method

Amanatides & Woo, a fast voxel traversal (1987): the 2D cell walk under a ray in the mesh ground

vehiclecarracingdrivingrigid bodyraycast suspensiontyre modelfriction circledrivetraingearboxdifferentialtraction controlABSdriftjumpsair controlrolloverchase cameragamepadtouchfixed stepdeterministicpureserver-safe

Near it in the frame