BabylonJS / Editor

Community managed visual editor for Babylon.js
http://editor.babylonjs.com/
813 stars 232 forks source link

Fix: bones fail to link transformNodes #368

Closed JuliaABurch closed 2 years ago

JuliaABurch commented 2 years ago

This PR switches the processing order in the project importer so that transformation nodes are loaded into the scene before meshes. This fixes an issue where a GLTF model imported into the editor can play animations from a GLB file, but those same animations will fail to load/play correctly after the model is converted to a .babylon file and the project is reloaded.

This is because the transformationNodes property on a skeleton's bones will fail to be set -- when loading a mesh, the babylon file loader will query the scene for transformation nodes, which will not exist as the project has not yet loaded them.

Testing

  1. Create a new project, import a GLTF model into the scene
  2. Using a script set on the GLTF mesh, load and play an animation on the mesh. Hit "play" in the editor, or "Run -> Open in a web browser" to see the animation playing. This should work, as the mesh's bones will be linked to the proper transformation nodes.
  3. Save and reload the project. Now, when you hit "play", the animation will fail to run. If you use the debugger to inspect the scene, you'll see that the bones associated with the mesh will no longer be linked to transformation nodes.
julien-moreau commented 2 years ago

Nice catch @JuliaABurch !! Thanks a lot !

JuliaABurch commented 2 years ago

@julien-moreau Will this fix only be available in the next minor version release of the editor?

julien-moreau commented 2 years ago

@JuliaABurch sure! I’m just adding some scene importer tools for you as well to configure imported meshes etc and I deploy the next minor