Capítulo 835 de 859
Every Mesh is a separate draw request; when a scene needs thousands of similar objects (like ~19,000 boxes on a data globe), merging them into one BufferGeometry turns thousands of draw calls into one, which can take a scene from under 20fps to 60fps.
Object3Ds (e.g. lonHelper → latHelper → positionHelper) computes a world position/orientation on a sphere via rotation, reused for every data point instead of creating 3 extra scene-graph nodes per box — avoiding tens of thousands of unnecessary node updates.geometry.applyMatrix4(helper.matrixWorld): bakes a computed transform directly into a geometry's vertices at creation time, so the resulting mesh doesn't need its own transform node to end up in the right place.color BufferAttribute: adding a color attribute to each box's geometry before merging lets every merged box keep an individual color (e.g. hue mapped from its data value) even though they're now one draw call.BufferGeometryUtils.mergeGeometries(): combines an array of individually-transformed geometries into a single geometry for one mesh/one draw call.lonHelper.rotation.y = THREE.MathUtils.degToRad(lonNdx) + lonFudge;
latHelper.rotation.x = THREE.MathUtils.degToRad(latNdx) + latFudge;
positionHelper.scale.set(0.005, 0.005, THREE.MathUtils.lerp(0.01, 0.5, amount));
originHelper.updateWorldMatrix(true, false);
geometry.applyMatrix4(originHelper.matrixWorld);
geometries.push(geometry);
// ...later: BufferGeometryUtils.mergeGeometries(geometries)
Object3D hierarchy to compute positions instead of creating one per object — this avoids a large, unnecessary scene-graph update cost.applyMatrix4() when you're about to merge many geometries and don't need each one to have its own live transform node.color attribute) preserve visual variation across a merged mesh that no longer has separate materials per object.