container.instantiateModelsToScene() fails when container.createRootMesh() node is parented to another node

After loading a resource into a container and creating a root node through container.createRootMesh(), the call to container.instantiateModelsToScene() will fail with the error “can’t access property “skeleton”, r[n[u.uniqueId]] is undefined” when the root node has been parented to another TransformNode.

I’ve reproduce the bug in this playground.

The instantiateModelsToScene method will instantiate the hierarchy of loaded meshes only for meshes that don’t have a parent: there’s no such mesh after you parent the root mesh to the transformNode, leading to a bug when skeletons are processed by instantiateModelsToScene.

You should parent to the transformNode after you call instantiateModelsToScene.