A browser-based Minecraft-inspired voxel game built with Three.js.
Because the game uses ES Modules (import/export), you must serve it via a local HTTP server — you can't just open index.html directly in a browser.
# Option 1 – Python (built into most computers)
cd mineclone
python3 -m http.server 8080
# Then open: http://localhost:8080
# Option 2 – Node.js
npx serve .
# Option 3 – VS Code
# Install the "Live Server" extension and click "Go Live"mineclone/
├── index.html ← Entry point + all CSS + UI HTML
├── src/
│ ├── main.js ← Game loop, boot sequence, wires everything together
│ │
│ ├── world/
│ │ ├── blocks.js ← Block registry (add new block types here)
│ │ ├── world.js ← World data array, chunk dirty tracking
│ │ └── worldgen.js ← Procedural terrain generation (noise, trees)
│ │
│ ├── render/
│ │ ├── renderer.js ← Three.js setup, lighting, day/night, highlight
│ │ ├── mesher.js ← Chunk mesh building (InstancedMesh per block type)
│ │ └── textures.js ← Procedural pixel textures + material cache
│ │
│ ├── player/
│ │ ├── physics.js ← Player state, AABB collision, walk/swim/fly
│ │ ├── raycast.js ← DDA raycast for block targeting
│ │ ├── input.js ← Keyboard, mouse, scroll wheel handlers
│ │ └── breaking.js ← Progressive block breaking with hardness
│ │
│ └── ui/
│ └── hud.js ← Hotbar, health/food bars, toasts, death screen
│
└── assets/
└── textures/ ← Put PNG textures here when you add them
Edit src/world/blocks.js — add an entry to BD and optionally add the ID to PLACE_IDS.
In src/world/world.js, increase WSIZ (keep it a multiple of 16) and/or WMAXH.
Edit the fbm() function in src/world/worldgen.js — change octave weights or frequencies.
In worldgen.js, check the fbm value range per column and switch block types accordingly.
Replace mkTex() in src/render/textures.js with a THREE.TextureLoader call per block.
Add localStorage read/write to src/world/world.js — serialize wdata as a base64 string.
Refactor src/world/world.js to use a Map keyed by "cx,cz" instead of a fixed array, and stream chunks in/out as the player moves.
| Key | Action |
|---|---|
| WASD | Move |
| Space | Jump |
| Shift | Sprint |
| LMB (hold) | Break block |
| RMB | Place block |
| Scroll / 1–8 | Select hotbar slot |
| F | Toggle fly mode |
| Q | Eat (restore food) |
| R | Respawn (when dead) |
| Tab | Toggle debug info |
| Esc | Pause |