Jump to content

skeleton animation serialization issue


Recommended Posts

I have a .babylon file containing a mesh and a skeleton (with animation)

I load the mesh and skeleton into a scene, twice, using the SceneLoader ImportMesh() function.

So now if I have a scene with two mesh and two skeleton.

If I play animation on one skeleton it only animates the mesh it is attached to.

So far so good

Now I serialize the scene and save it to a file.

I load the scene using the SceneLoader Load function.

I play animation on one skeleton.

Both the meshes are animated. !!


I think the issue is that, unlike mesh and bones, skeletons do not have a uniqueId.

In a serialized scene, meshes have references to skeleton ids and that skeleton id not unique.

I think we should  have uniqueId for each skeleton instance and when the scene is serialized the mesh should be serialized referencing their skeletons uniqueId.





Link to comment
Share on other sites

For now to get around this issue, just before I serialize the scene, I set the value of each skeleton id to a unique  string. 

Another thing I notice is that the engine does not remove artifacts which are no longer required. For example if I dispose off a mesh, the skeleton referenced by that mesh is still retained even though it is not referenced by any other mesh. Same thing with textures , material etc. It might be a good idea to provide an serialization option  to cleanup  or "garbage collect" any orphaned , unreferenced item. 

Link to comment
Share on other sites

Please contribute :D this is an open source framework

Regarding skeletons, they do have an id:https://github.com/BabylonJS/Babylon.js/blob/master/src/Bones/babylon.skeleton.ts#L16

It is supposed to be unique. Can you check what value do you have in your serialized scene for this id?

For auto-disposing, this is on purpose as Babylon.js cannot know if you want (or know) to later reuse the skeleton. But I agree with you this could be great to check it at serialization time



Link to comment
Share on other sites

I will definitely look into contributing. Right now I am just enjoying using Babylon. :)

Skeletons have "Id" but they do not have "uniqueId" . "Id"s can assigned by user and can be duplicate. "uniqueId", I think, are internally generated.

AbstractMesh, Bone, Camera and Light all have "uniqueId" which they inherit from Node. http://doc.babylonjs.com/classes/2.3/Node#uniqueid-number.


I could look into adding an option for serialization.

Cleaning up skeleton should be easy , as they are only referenced by mesh - right ?

What about textures ? They are referenced just by materials ? and materials themselves ? mesh, particles ...?





Link to comment
Share on other sites


Cleaning up skeleton should be easy , as they are only referenced by mesh - right ?


Textures should be already deleted (because of memory pressure) when not referenced.

Materials are only referenced by meshes


Regarding your bug: if the scene was loaded from a .Babylon then skeleton.id should be already unique.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...