AssetContainer throwing warnings with InstancedMesh

I’m using SceneLoader.LoadAssetContainerAsync() to load assets (via GLTF loader), which I can then add and remove from the scene using container.addAllToScene(), etc. This works great!

…UNLESS the GLTF file uses instances. The GLTF loader faithfully creates InstancedMesh objects in that case, which causes many warnings to be thrown to the console due to InstancedMesh not being a recognized node type here: Babylon.js/packages/dev/core/src/assetContainer.ts at ff6116de83b5db8a87d5680d7156ce8ad647f093 · BabylonJS/Babylon.js · GitHub

Due to this, the _isValidHierarchy() fails upon calling addAllToScene(). Aside from that, it looks like InstancedMesh should be supported in an AssetContainer.

As a workaround I’m setting loader.createInstances = false in the GLTF loader. But it would be nice to take advantage of instancing AND have an AssetContainer.

Perhaps I’m missing something here. Thanks for any help you can give!

  • David

Seems to be working fine in this playground: https://playground.babylonjs.com/#H0ALVT.

I tried it with a glTF with gpu instances, too, and it worked fine.

What kind of instances are in the glTF model you’re using? Can you share the model?

Thanks for the quick reply! So the issue comes about when the parent of a node is an InstancedMesh. In your GLTF, node1 is indeed InstancedMesh, but its parent is root, which is a Mesh. To reproduce the issue, create a hierarchy so your node1 has a child object.

1 Like

Would you be able to reproduce this in the playground?

CC @bghgary

I have a playground reproducing it now and am making a PR.

1 Like

PR 14881 fixes this. Thanks for reporting it!

3 Likes

Thank you! Super impressed with the BabylonJS team once again.

2 Likes