voxel-fun is a first-person voxel sandbox built with SvelteKit, TypeScript, and Three.js.
It is set up as a fast local building playground with mixed-size voxel blocks, in-editor tools,
and a dev-only world save flow that survives refreshes.
- Walk a small seeded voxel world in first person.
- Toggle into edit mode and add, remove, paint, or box-edit blocks.
- Place cubic voxel blocks at dynamic sizes from
0.5to8. - Use
4as the baseline build size, with0.5-3smaller and5-8larger. - Sample an existing block's material and size with middle mouse.
- Undo the last committed edit with
Ctrl+Z. - Persist your world locally during development and export/import JSON snapshots.
- Mixed-size voxel blocks are stored as block instances, not just single filled cells.
- Small voxel sizes can be placed side by side on larger surfaces without forced gaps.
- The base voxel world scale is smaller than the original prototype:
1internal voxel cell is0.125world meters. - The scene includes a tuned lighting pass with fog, tone mapping, and shadowed sunlight.
- The HUD is game-style rather than debug-first, while still exposing a field readout panel.
Click the viewport to capture the mouse. Press Tab or F1 to toggle edit mode.
W A S D: moveShift: sprintG: toggle fly modeCtrl: toggle crouchSpace: jump- While flying:
Spacerises andCtrldescends
Q: brush addE: brush removeR: brush paintY: face extrudeB: box fillH: box hollowC: box carveShift + drag: region drag with the active brush toolT: quick-arm the last nature preset- Hold
T: open the nature wheel for grass, flowers, bushes, and trees N: open the nature tuning panel
- Mouse wheel: change voxel size
-/=: step voxel size1-9: select material- Middle mouse: pick the looked-at block's material and size
Ctrl+Z: undo the last committed edit
The editor uses a discrete size ladder:
0.5-3: smaller than the default build scale4: default baseline size5-8: larger build steps
All blocks are cubic. A larger placed voxel occupies size x size x size internal grid cells,
with half-step detail now available at the smallest size.
In development mode, the world can persist between refreshes.
- Edits autosave locally after changes.
- The top-right dev panel exposes
Save,Reset,Export, andImport. Savewrites the current world to local browser storage.Resetrestores the seeded starter world and overwrites the local save.Exportdownloads the world as a JSON snapshot.Importloads a previously exported JSON snapshot.
Notes:
- Local persistence is intended for development only.
- Undo is in-memory for the current session and is separate from exported snapshots.
- Node.js 20+
pnpm
pnpm installpnpm devThen open the local Vite URL in your browser.
pnpm dev
pnpm check
pnpm lint
pnpm build
pnpm previewsrc/
App.svelte App shell and HUD
lib/
engine/ Game bootstrap, renderer, scene, input loop
editor/ Edit tools, targets, controller, interaction state
player/ First-person movement and collision
voxel/ World data, meshing, commands, persistence, palette
debug/ Field readout HUD
- Rendering uses Three.js with chunked voxel meshes.
- The world stores placed blocks with
origin,size, andmaterialId. - Chunk meshes are rebuilt only for dirty chunks after edits.
- World snapshots serialize from block data rather than raw dense voxel arrays.
- Undo currently supports only the last sequence of edits in the current session history and does not provide redo.
- Carve and paint operations affect whole touched blocks; they do not split large blocks into smaller fragments.
- Import/export is browser-driven and intended for local development workflows.
- SvelteKit
- Svelte 5
- TypeScript
- Three.js
- Vite
- ESLint
- Prettier