BufferGeometry
Quick answer
BufferGeometry stores vertex positions, normals, UVs, colors, and indices as GPU buffers, and serves as the geometry container for every Mesh, Line, and Points. Assemble it manually for point clouds, terrain, or custom meshes, and call computeVertexNormals() and computeBoundingSphere() after changing vertices. Use setAttribute() and setIndex() to populate it.
new THREE.BufferGeometry () → BufferGeometry
Key points
- setAttribute('position', attribute) and setIndex() define the buffers; keys match shader attribute names.
- setDrawRange(start, count) renders only part of the geometry, useful for incremental trails.
- dispose() releases GPU memory, but only after the geometry is no longer used by any mesh.
Example
const geometry = new THREE.BufferGeometry();
const positions = new Float32Array([
-0.5, -0.5, 0,
0.5, -0.5, 0,
0.0, 0.5, 0
]);
geometry.setAttribute('position', new THREE.BufferAttribute(positions, 3));
geometry.computeVertexNormals();
geometry.computeBoundingSphere();const box = new THREE.BoxGeometry(1, 1, 1);
console.log(box.index !== null); // true
console.log(box.attributes.position.count); // 24
const flat = box.toNonIndexed();
console.log(flat.attributes.position.count); // 36
Notes
- After moving vertices you must recompute normals and bounding volumes, or lighting and culling go wrong.
- Leaving boundingBox and boundingSphere null disables reliable frustum culling and raycasting.
English edition written for Atlaslog. Code is taken from the original Chinese page and runs unchanged.
Atlaslog (2026). BufferGeometry. https://www.jingweizhi.com/en/three/api/buffer-geometry.html (accessed 2026-11-03).