A lightweight 3D car racing game built with Three.js
- 🎮 Immersive 3D gameplay – Race through a dynamic 3D environment
- 🏎️ Vehicle physics – Realistic car handling and acceleration
- 🎯 AI rivals – Compete against computer-controlled opponents
- ⚙️ Easy customization – Swap vehicle models or adjust game parameters
- 🚀 Lightweight – Minimal dependencies, pure Three.js rendering
- A modern web browser (Chrome, Firefox, Edge, Safari)
- Python 3+ or Node.js with
npx
-
Start a local web server:
# Using Python python -m http.server 8000 # Or using npx npx serve
-
Open your browser and navigate to
http://localhost:8000 -
Start racing! The game launches automatically. Use the controls below to drive.
| Key | Action |
|---|---|
| W / ↑ | Accelerate forward |
| S / ↓ | Accelerate backward (reverse) |
| A / ← | Steer left |
| D / → | Steer right |
- Right-click + drag – Rotate camera view
- Shift + right-click drag – Zoom in/out
- Right-click + middle-click – Pan camera
In src/Vehicle.js, replace the default box geometry with your own GLTF/OBJ model:
// Load a custom model instead of creating a box
const loader = new GLTFLoader();
loader.load('path/to/model.glb', (gltf) => {
vehicle.add(gltf.scene);
});Modify vehicle parameters in src/config/vehicleConfig.js:
acceleration– How quickly the car speeds upmaxSpeed– Maximum velocityturnSpeed– Steering sensitivity
src/
├── main.js # Entry point
├── Vehicle.js # Vehicle class and physics
├── scene.js # Scene setup and management
├── config/ # Configuration files
└── core/ # Core systems
├── gameLoop.js # Main game loop
├── cameraController.js # Camera management
├── collisionSystem.js # Collision detection
└── aiRivalsController.js # AI opponent logic
- Three.js – 3D rendering engine
- Kenney Assets – 3D car models and textures
- Vanilla JavaScript – No frameworks, pure ES6+
Enjoy the race! 🏁
