HAVOK Physics Playground — BabylonJS
Browser-based 3D car demo with Havok rigid-body physics. Drive a car around a walled arena, smash pillars and balls, skid marks, particle FX, and PBR materials.
Real-time 3D car playground running entirely in the browser. Havok WASM handles rigid-body simulation — the car, destructible pillars, and 100 spawnable physics balls all interact with full collision response.

Features
- Havok Physics — rigid-body simulation via
@babylonjs/havokWASM plugin - GLB Car Model — async-loaded, click to randomize paint color
- Keyboard & Virtual Joystick — WASD/arrows on desktop; touch joystick auto-activates on mobile
- Wheel Animation — front wheels steer, all wheels spin per velocity
- Tire Decals — skid marks stamped on ground during cornering
- Particle FX — smoke burst on sphere collision
- PBR Materials — ground, walls, pillars, spheres
- HDR Skybox — IBL from
.envcube texture - PCF Shadows — percentage-closer filtered shadow map
- FPS + Active Mesh counter — live stats overlay
Controls
Keyboard
| Key | Action |
|---|---|
W / ↑ | Forward |
S / ↓ | Reverse |
A / ← | Turn left |
D / → | Turn right |
Touch
| Joystick | Action |
|---|---|
| Left Y | Forward / Reverse |
| Right X | Steer |
Buttons
| Button | Action |
|---|---|
| DROP OBJECTS | Spawn 100 random physics balls |
| CLEAR | Remove spawned balls |
How It Works
BabylonJS Engine renders to a fullscreen canvas. HavokPhysics() loads async and enables gravity at -20 Y. Ground, 4 walls, and 10 random pillars are static PhysicsAggregate bodies (mass: 0). The car GLB wraps in an invisible physics box (mass: 100) with center of mass shifted down for stability. ArcRotateCamera tracks the car; WASD is intercepted so setLinearVelocity / setAngularVelocity drive the physics body directly. If the car falls below Y = -1, the page auto-reloads.
Tech Stack
| Library | Role |
|---|---|
| BabylonJS 9.10.x | 3D engine, scene, physics API |
| @babylonjs/havok 1.3.x | Havok WASM physics plugin |
| babylonjs-gui | Virtual joystick |
| babylonjs-loaders | GLB/GLTF loading |
| Bootstrap 5 | UI button styling |