Serializing a scene and importing back using ImportMesh data:${jsonScene} losing skeletons and animationGroups

Hi,
I am trying to serialize a scene and then importing back using ImportMesh(“”,“”, data:${jsonScene}, scene, (newMeshes, particleSystems, skeletons, animationGroups) =>{ }). However, skeletons and animationGroups are coming null while the original scene had them. This is happening with both the NullEngine’s scene and Non-Null ( Regular) Engine’s scene. Interestingly, if I export and download the scene as .babylon and drop this exported .babylon file on the babylon sandbox, skeletons and animationGroups both show up!
Playground link - https://playground.babylonjs.com/#V4VX3D
Can someone pls explain what is going on here?
Thanks in advance.

1 Like

Also just noted, ImportMesh is failing to restore the original hierarchy - it has dropped TransformNodes.
Correct hierarchy-

Hello!

About why it’s different on the Sandbox, it’s because that uses the SceneLoader.Append method instead of ImportMesh. It seems that the code used by append looks for animations: Babylon.js/packages/dev/core/src/Loading/Plugins/babylonFileLoader.ts at master · BabylonJS/Babylon.js (github.com), while there’s no equivalent code for importMesh. I’m checking with @sebavan to see if this is proposital or an oversight. If you change the Playground to use the Append method, we see the skeletons and animations got through: ImportMesh data:${jsonScene} is losing skeletons and animationGroups | Babylon.js Playground (babylonjs.com)

importMesh does have code to load skeletons, but there’s a check there that’s failing for the exported mesh, so I’m also conferring about why it was coded like this :slight_smile:

1 Like

Append working is a good news!
That said, I don’t want to this asset to be rendered immediately. I can set theme disabled. But let me see if I can move away this asset into an AssetContainer using a predicate restricting to only these meshes.

@carolhmj My bad, moveAllFromScene AssetContainer | Babylon.js Documentation doesn’t take a predicate. Any suggestion, please?
Also, Append’s success callback is function(scene){ … }. How can I identify the just appended meshes only?

Hmm considering your needs, I think the best path would be to use the AssetsManager’s addContainerTask, which loads everything to a, well, container, and gives you the loaded objects information: ImportMesh data:${jsonScene} is losing skeletons and animationGroups | Babylon.js Playground (babylonjs.com). Then, you can use that container’s addToScene with a predicate to select which objects you want to add to the scene: AssetContainer | Babylon.js Documentation (babylonjs.com)

1 Like

Perfect! Thank you!