I'll build a Minecraft-style voxel game with Three.js. Let me start by exploring the project structure.
Let me check the remaining files to understand the setup.
The project uses Tailwind v4. Now let me install Three.js and its TypeScript types.
Now I'll create the game files. First, the core types and constants:
Now the noise/PRNG module (seeded Perlin noise for terrain and deterministic hashing):
Now the procedural pixel-art texture atlas generator:
Now the World class — procedural terrain generation with trees, caves, and edit tracking:
Now the chunk mesh builder with face culling and a texture atlas:
Now the Player class with physics, gravity, and AABB collision:
Now the main Game engine that ties everything together — rendering, chunk streaming, day/night cycle, raycasting, and input:
Let me fix those TypeScript unused-variable errors:
Now let me fix the markDirtyAt signature — the wy parameter isn't needed:
Engine is clean now. Let me create the React UI — App.tsx with the HUD, hotbar, crosshair, and menu overlays:
Now let me update the CSS with the pixel font and base styles, plus the HTML title:
Now let's build the project to verify everything compiles:
The build succeeded. Now let me review a potential collision bug — when a player moves against a wall with multiple overlapping blocks, the per-block early exit on zeroing velocity can cause sticking. Let me check main.tsx first, then fix the collision resolver:
StrictMode is fine since my effect properly disposes. Now let me fix the collision resolver to handle multiple overlapping blocks robustly:
Let me add height/tree memoization to the World class to keep chunk generation smooth (many redundant height computations across chunk borders):
Now let me rebuild to verify the changes compile:
The build works. Let me make two polish fixes: a safer spawn point (avoid tree trunks) and ensure the camera matrix is fresh before raycasting each frame:
Let me fix the directional light so it tracks the player (otherwise the sun appears to move with the player when wandering far from the origin):
Build is clean. Let me do a final review of the engine to verify the complete flow:
I spotted a UI bug: the hotbar container has pointer-events-none, which would block clicks on the slot buttons. Let me fix that:
Final build to confirm everything is working:
The build is successful. I've created VoxelCraft, a complete Minecraft-style voxel game. Here's what was built:
Architecture
Game engine (src/game/) — a modular Three.js engine:
types.ts — Block enum (grass, dirt, stone, cobblestone, sand, log, leaves, planks, glass, bedrock), physics constants, and hotbar definition
noise.ts — Seeded Perlin noise (2D/3D) with a permutation table, plus a fast deterministic integer hash
world.ts — Procedural terrain: fractal-height rolling hills + ridged mountains, sand beaches at sea level, 3D-noise caves, and deterministic oak trees with canopy blobs that spill across chunk borders. Includes memoized heights/trees and a persistent edit map so your builds survive chunk unloads
textures.ts — A 256×256 pixel-art texture atlas (grass, dirt, stone, cobble, sand, bark, log rings, leaves, planks, glass, bedrock) drawn procedurally on a canvas with nearest-neighbor filtering for that crisp Minecraft look
mesh.ts — Optimized chunk meshing that only emits faces exposed to air/transparency, with per-face baked directional shading, subtle per-block tint variation, and atlas UVs
player.ts — First-person controller: WASD + mouse look, jumping with gravity, sprint, fly mode (F), and per-axis AABB collision that handles multi-block walls cleanly
engine.ts — The main loop: circular chunk streaming with distance-prioritized build queue and unload recycling (infinite-feeling world), voxel DDA raycasting for block targeting, break/place/pick, a 4-minute day/night cycle (orbiting sun that tracks the player, sky/fog color blending through dawn/dusk, stars, sun & moon), and head-bob
UI (src/App.tsx) — React overlay with a pixel-font aesthetic: crosshair, 9-slot hotbar with live texture icons (click, 1–9 keys, or scroll wheel), debug HUD (FPS/XYZ/time/chunks/mode), a start screen with control list and seed input for regenerating worlds, and a pause screen.
How to play
- Click to play → pointer-locked first-person mode
- Left click break, right click place, middle click pick block
- Space jump, Shift sprint (or descend while flying), F toggles flight
- Esc pauses; the day/night cycle keeps running behind the menu
Files built: src/game/types.ts, src/game/noise.ts, src/game/textures.ts, src/game/world.ts, src/game/mesh.ts, src/game/player.ts, src/game/engine.ts, src/App.tsx, src/index.css, index.html