BoxGeometry
Quick answer
BoxGeometry generates a rectangular cuboid from width, height, and depth, with position, normal, uv, index, and six material groups. It is the standard choice for building blocks, equipment housings, and placeholder volumes in a scene. Increase segment counts only when you need subdivision for displacement or per-face deformation.
new THREE.BoxGeometry ( width , height , depth , widthSegments , heightSegments , depthSegments )
Key points
- Pass width, height, depth, then widthSegments, heightSegments, depthSegments; segments default to 1.
- groups split faces for six materials in right, left, top, bottom, front, back order.
- The box is centered on its geometry origin, so mesh.position sets the center directly.
Example
const geometry = new THREE.BoxGeometry(16, 36, 12);
const wall = new THREE.MeshStandardMaterial({ color: 0xa8b2bd, roughness: 0.85 });
const roof = new THREE.MeshStandardMaterial({ color: 0x3f4a55, roughness: 0.6 });
const mesh = new THREE.Mesh(geometry, [wall, wall, roof, wall, wall, wall]);
mesh.position.set(80, 18, -20);
mesh.castShadow = true;
mesh.receiveShadow = true;
scene.add(mesh);
Notes
- Each face owns separate vertices, so edges are not shared and vertex counts exceed eight.
- Setting segments high on thousands of blocks wastes memory; use InstancedMesh instead.
English edition written for Atlaslog. Code is taken from the original Chinese page and runs unchanged.
Atlaslog (2026). BoxGeometry. https://www.jingweizhi.com/en/three/api/box-geometry.html (accessed 2026-11-03).