Blender, export gltf animations issue

Hi!

The very simplified blend:
issue_stash.zip (110.0 KB)

Reading the whole animation section of BJS.

I have a cube that goes from one side to another in the above blend.
I am trying to have my groups out of Blender to put import them directly in BJS as glb files.

So anim1 is the cube rotating in one direction, anim2 in the other one.

So I stashed my animations with different names anim1 and anim2 but when imported, anim 2 has the same range as anim1 and will never start when I stop the anim1 group.

The other way around is to export a single animation out of Blender and recreate them in BJS with the proper ranges… I feel like it is a duplicate of work though…

May someone correct my file, so I would learn something?


To make my question clear: how do we separate animations (groups) directly in Blender to import them directly in BJS, with clearly defined ranges? (without having to recreate them completety in BJS)

Thanks!

Reading this : https://doc.babylonjs.com/guidedLearning/createAGame/animations

I am not sure but it seems that we need to recreate the animation groups in BJS (?), maybe implying that groups cannot be prepared in Blender directly (?)

:face_with_monocle:

cc @bghgary

No expert on the gtlf format as I always use the babylon blender exporter. That said, what happens if you just export a single animation with the first part (0-40 frames) your anim1, and the second part (50-90) your anim2. Then when you want to play anim1 just chose frames 0-40 to play, and when you want anim2 chose frames 50-90 to play. No need for ranges then.

Merry Christmas, gryff :slight_smile:

Best method i’ve found is to use the NLA in Blender - name each track and then export as GLB. When it comes into bablyon, it’ll have those tracks as addressable animation groups.

See Combining Mixamo animations in Blender 2.8 for BabylonJS - YouTube, just for reference to how to setup the NLA tracks.

Yes that is the backup plan, because it forces to have a json section updated whenever there is a change in an animation. That’s double work and error prone, but sure, it will work!

Merry Christmas as well :wink:

This is exactly what i am trying to achieve, because the groups are created automatically.

But the issue is that when I export from Blender, BJS reads the anims and put each animation group target to the mesh that must receive it. I expected my receiving mesh to have 2 animations, instead I have 6, because it is not the group being added to my mesh but each target separately.

The imported groups:

The anims pushed to my cube:

How do I play nice with that? I expected the following:

mesh.start("anim1");
mesh.stop("anim2");

I thought that doing groups in the Blender NLA would help from recreating animations in BJS.

BTW, stopping anim1 with
importResult.animationGroups[0].stop() will stop even anim2…

There is really something here.
Please note: my concern is just with animation groups created in Blender and imported in BJS. For animations created directly in BJS, everything is smooth as butter. But that implies double work.

:thinking: (I am sure I am missing something)

Ok,
this section
put me on the right track and now everything is working as expected.

For the record:
create your animations in Blender, name them in the NLA but play them at the beginning for each (what I missed), not in a sequential fashion.

Export, and do exactly like it’s told on the link.

Done.

Thanks to everyone, and for those who celebrate it, Merry Christmas, for the others, I wish you a great day :+1: :+1:

1 Like

Yes, you got it! The NLA is non-linear! So you can line them up right next to each other - as you can play them independently - just by saying anim1.start() for example. Glad you got it sorted.

2 Likes