I have an app with many many instances of an identically shaped and scale object so I am using THREE.InstancedMesh. It works fine.
Here is the code:
function doStuff() {
// canonical ball geometry
const geometry = new THREE.SphereBufferGeometry(1, 32, 16);
const mesh = new THREE.InstancedMesh(geometry, material, vertices.length);
// position and scale each ball instance
const ballProxy = new THREE.Object3D()
vertices.forEach((vertex, i) => {
const { x, y, z } = vertex
ballProxy.position.set(x, y, z)
ballProxy.scale.setScalar(ballRadius)
ballProxy.updateMatrix()
mesh.setMatrixAt(i++, ballProxy.matrix)
});
return mesh
}
I now need to be able to interactively adjust the ball radii to a larger of smaller value. All instances will have the identical value. I am unclear on how to go about this.