GLB blend animations and meshes in different files

Hello :smiley:
I am trying to blend loaded file animations like in this PG:
Additive animation blending | Babylon.js Playground (babylonjs.com)

With the function “LoadAssetContainer” I figured I could dup them after loading. Am I complicating my code too much?

I am also separating animations and skeletons in different .glb files.
This might be a bad idea too I am not sure.

My code:

Code
function loadModel(path, meshFile, scene) {
  BABYLON.SceneLoader.LoadAssetContainer(path, meshFile, scene, (meshContainer) => {
    meshContainer.addAllToScene();

After loading the animation file, it will be all in the scene, then I should I process it?

When I prepare the models files .glb should I put the mesh not separate then ?

Let me add @PatrickRyan to the thread :slight_smile:

@Enkyia, my apologies for the delay in my response, I just got back from holiday and am catching back up. Thinking about how you manage your assets is an important step for your experience. Especially if you have many assets to load and unload from the scene. The asset manager makes bringing assets in and out of the scene much easier as they are loaded into the scene, but not rendered. This means you can quickly swap assets in and out without the need to load more.

You want to be careful here, though, not to load more assets than you need or you will incur more download time for your user and require more resources to keep them in memory. Using the asset container for a scene that does not require swapping assets or instantiating assets on demand may indeed be more complicated than it’s worth. To determine if it would be good for you, ask yourself if you need to quickly swap assets or if you need assets ready for reactions or effects in your scene. In this case, it may be smart to use an asset container to help manage your assets.

In terms of splitting mesh from animations, you will often find that studios will load a mesh only file and an animation only file. This is so they can have multiple people working on the individual assets simultaneously with a modeler working on the mesh and an animator working on the animation clips. The other reason you will see this is so that if a change is made to either mesh or animation, you aren’t affecting the entire asset group. Changing one animation clip that is separated out won’t affect the mesh, skinning, textures, materials, or the possibly dozens of other animation clips your asset may require. This reduces the possibilities of cascading bugs if one change to an animation could potentially affect many other assets.

There is one more step when you bring your skinned mesh and animations in separately, however, and that is a retargeting step. Basically, you need to tell the animation that it is targeting the bones in your mesh skeleton for the animation to affect the correct skeleton. You can see the process of retargeting an animation from an identical skeleton in this playground. The key here is that the skeletons are identical, so I can take the target of every targeted animation in an animation group and find the same bone by name in the mesh I am targeting to replace the target of the targeted animation. However, you don’t need to have identically named skeletons to retarget. You would need to create an abstraction layer so that you know how a bone is named in each skeleton and retarget between the bone pair naming conventions. Something like this could be necessary if you are using assets purchased from a library where the bone hierarchies may match, but the bone names do not. You can also run into this if your skeleton is imported into a package that adds prefixes to the node names to prevent conflicts. Maya is notorious for adding prefixes to node names, and can make you need to either rename all the skeleton bones or handle the prefixes in code.

I hope this helps unblock you with your project, but please feel free to ping me back with more questions.

3 Likes

Thank you for your well describe respond!

Figured the skeletons didn’t match and stopped working on the project by I am checking to pick it back up. I have too many idea/projects

I was trying to make it easy to create many entities with different texture but same skeleton with Blender.

Used assets from this website if that can help:
Mixamo

1 Like