Welcome to Voxel Sandbox! This is a simple block-building game prototype built with JavaScript and Three.js, running right in your web browser. Explore a basic world, break blocks, and place new ones to build whatever you imagine!
- Install Dependencies:
Make sure you have Node.js and npm installed. Then, open your terminal in the project directory and run:
npm install
- Start the Development Server:
Run the following command to start a local web server (this assumes you have
viteinstalled or a similar dev server configured inpackage.json):(If you don't have anpm run dev
devscript, you might need to installvite(npm install --save-dev vite) and add"dev": "vite"to the"scripts"section inpackage.json) - Open in Browser:
Open your web browser and navigate to the local address provided by the development server (usually something like
http://localhost:5173).
To run the automated tests for the project's modules, use:
npm testThe project is structured into several key modules:
main.js: The main entry point. Initializes Three.js, the world, player, controls, and starts the game loop.src/World.js: Manages the collection ofChunkobjects, handles block getting/setting at world coordinates, and updates chunk meshes.src/Chunk.js: Represents a 16x256x16 section of the world. Stores block data and manages its 3D mesh.src/Player.js: Handles player movement physics, collision detection, interaction (breaking/placing blocks), and camera attachment.src/Controls.js: Manages user input (keyboard for movement/hotbar, mouse for looking/interaction) using Pointer Lock controls.src/BlockRegistry.js: Defines the properties (like solidity and textures) for different block types.src/TextureAtlas.js: Loads the texture atlas image and creates the material used for rendering blocks.src/Chunk.test.js/src/dummy.test.js: Unit tests for various modules.