A browser-based 3D Snake game built with Three.js, HTML, and JavaScript. The classic Snake gameplay is reimagined in a 3D WebGL environment — the snake grows as it eats food, and the game ends if the head collides with the body or the boundary walls.
No frameworks, no dependencies beyond Three.js — runs directly in the browser.
- The snake moves continuously across a 3D grid
- Eating food increases the snake's length
- Food spawns at a random position within the grid after each eat
- Game over if the snake's head touches:
- Its own body
- The edge of the arena
snakeGame/
│
├── SnakeGame.html # Entry point — loads Three.js and game script
└── SnakeGame.js # Full game logic — snake, food, grid, movement, collision
- Open
SnakeGame.htmlin any modern browser - Use arrow keys to control the snake's direction
- Eat the food to grow longer
- Avoid hitting the walls or yourself
No installation or build step required.
| Feature | Detail |
|---|---|
| 3D rendering | Three.js WebGL renderer with perspective camera |
| Grid system | 10×10 grid mapped to 3D coordinate space |
| Snake movement | Timer-driven forward movement at 250ms intervals |
| Food placement | Random grid position, collision-checked against snake body |
| Collision detection | Head vs. body and head vs. boundary checks each tick |
| 3D scene | GridHelper for floor · BoxGeometry for snake & food segments |
| Component | Technology |
|---|---|
| 3D Engine | Three.js |
| Language | JavaScript (ES6) |
| Markup | HTML5 |
| Renderer | WebGL |