instantiateHierarchy throws errors for empty meshes

Hello, community!

I’ve noticed strange regression while trying to update my project from Babylon 5.20.0 to 5.46.0.

Previously I had something like this and it was working fine.

Now I see that 1 sphere is lost. In the Babylon inspector, I can see that instanced sphere doesn’t have a source (It is called “Clone of instance of sphere” in inspector). And there are a lot of warnings “Instances should only be created for meshes with geometry” in console. Any ideas? Is it forbidden to use meshes without geometry now?

I put a single triangle in it with no bounds and it seems to fix your issue

Likely the lack of vertexData is the issue and why WebGL is throwing warnings.

2 Likes

cc @carolhmj as we did some changes lately to instantiateHierarchy.

2 Likes

Yep, but it looks like a workaround for me. Since instantiateHierarchy should “instantiate (when possible) or clone that node with its hierarchy”. When I change table.instantiateHierarchy() to table.clone() it works fine.

1 Like

Yep. I have encountered the same recently. I found the only solution was to use clone or else your instanced children don’t come along.
In fine, I cloned the lightest mesh with all instances parented to the object group. In some cases, I created an abstractMesh as a parent to clone the object group. As a side note, it also seems that in the process of cloning the hierarchy with all instances, some parameters of the cloned children instances are not kept when mirroring the cloned parent/group. In this case, Instances seem to loose their information of alphaIndex (not sure it this is new or has always been this way).

1 Like

I think I found it.

Here we assume that the current mesh is always a source for instancedMesh but this assumption is not always correct. It requires the same fix as it was done here.

Thank you very much for the report and investigation, I’ve added a fix here! Fix to instantiate hierarchy by carolhmj · Pull Request #13524 · BabylonJS/Babylon.js (github.com)

4 Likes

Thanks a lot! Have wonderful weekend!

2 Likes