This documentation covers the key components and optimizations implemented in our voxel game engine using Three.js. The engine focuses on efficient terrain generation, chunk management, and rendering techniques to create a performant and scalable voxel world.
We use THREE.TextureLoader()
to efficiently load and manage textures for our voxel blocks.
const textureLoader = new THREE.TextureLoader();
const blockTextures = {
grass: {
top: textureLoader.load('./texture-pack/grass-top.png'),
bottom: textureLoader.load('./texture-pack/dirt.webp'),
side: textureLoader.load('./texture-pack/grass-side.webp')
},
dirt: textureLoader.load('./texture-pack/dirt.webp'),
stone: textureLoader.load('./texture-pack/stone.webp'),
// ... other textures ...
};
We use THREE.InstancedMesh
for rendering multiple instances of the same geometry with different transformations, significantly reducing draw calls and improving performance.