In InstancedMesh.clone(), it calls refreshBoundingInfo after the cloned instance constructed.
But createInstance , which internally called Mesh._instancedMeshFactory, which called the InstancedMesh constructor, where refreshBoundingInfo is called when needed.
Since refreshBoundingInfo is a heavy option that iterates every vertex from source mesh, this duplicated call should be avoided.
Also link the previous thread about this here:
A quick blame shows that this call origins 11 years ago where the InstancedMesh was created.
You propose to remove to call this.refreshBoundingInfo() at line 582 if I am right.
I’m not sure whether it’s not a safety call to prepare the BB before cloning the mesh/meshes. The vertex data might have been altered without calling this function on the source mesh. I’m also not sure whether removing it could affect the cloning process (with incorrect BB). @kzhsw did you do some tests already?
On the other hand clone was always considered as a CPU heavy operation, so the programmer should be aware of this.
Maybe you could add a parameter to the clone funtion called doNotRefreshBoundingInfo: boolean to give the programmer better control of the clone function.
EDIT: maybe this could be a better option so we don’t end up with too many parameters and we don’t break backwards compatibility: