Capítulo 810 de 859
How BufferGeometry represents mesh data as parallel named BufferAttributes (position, normal, uv, color) per vertex, and how to build one by hand — including using indices so shared vertices aren't duplicated.
BufferAttribute: a typed array holding one property (position, normal, uv, color…), with one entry per vertex.BufferGeometry.setIndex(): references shared vertices by index instead of repeating identical vertex data.computeVertexNormals(): auto-generates normals, but produces visible seams on geometry meant to wrap seamlessly (spheres, cylinders) because it can't smooth across vertices that aren't actually shared.Float32Array-backed attributes from the start and set attribute.needsUpdate = true after each change.function makeSpherePositions(segmentsAround, segmentsDown) {
const numVertices = segmentsAround * segmentsDown * 6;
const positions = new Float32Array(numVertices * 3);
const indices = [];
// ...compute lat/long positions per quad, push 4 unique verts + 6 indices per quad
return { positions, indices };
}
BufferGeometry is a set of named parallel BufferAttributes, one entry per vertex.setIndex() lets you reference shared vertices instead of repeating identical vertex data.computeVertexNormals() can't smooth across a seam where positions aren't shared, so supply your own normals for geometry that must wrap seamlessly.needsUpdate = true on the changed attribute each frame.