Model disapears on additive animation group (GLB export)

Hello community,

I’m trying to export a GLB file from a model i animated in babylon using additive animations

the animations works just fine until i export it into glb and open it in sandbox the model is completely hidden.

let me explain a test case i created into a playground

  • 2 animations groups : only one of them is additive
  • 1st one has a translate animation and the 2nd has a jump animation
  • in addition to the translate i have a quaternion and scaling animation (that i’m not really animating, same values in the 2 keyframes)

when i remove the scaling animation or enter 2 differents value keyframes, everything works as expected.

what i’m assuming is with the additive animations magic, something is transforming the scaling to 0,0,0 resulting the model to be hidden,

Can anyone help me figure out what’s happening noting that having the scale animation (whether with different keyframe values or similar) is a must.

here’s a link to the playground : https://playground.babylonjs.com/#MC2PGL#4

the model will automatically download on animation end.

cc @Cedric

I’m adding it to my todo list.

3 Likes

I’m debugging it ATM.
BTW, thank you @MeshSlayer for the invaluable playground.

1 Like

Thanks @Cedric for your time !
looking forward to hear from you, i’ll make sure to always provide you with any additional informations to help the debugging progress

2 Likes

PR Additive animation with scaling by CedricGuillemet · Pull Request #12513 · BabylonJS/Babylon.js · GitHub

EDIT: I’m closing the PR. I’m not happy with the result. I think the issue is in the gltf exporter instead.

2 Likes

ping @Guillaume_Pelletier

Hello,
just readed the thread.
My understanding of the additive animation under Babylon js is that

MakeAnimationAdditive(..)

is “just” baking the animation. Once done, it’ should be played and saved as it into gltf.

So if you have different behavior once exported and loaded into/from the GLTF, it may be the Serializer or the Loader.
We may have a look with another loader to see if it behave similar (i guess you already done this step)
Then we may using the Visual code tools to have a look into the GLTF data, seeing if the data are corrupted in a way or another. Using the animation editor into the SandBox is also very usefull for these case (what did you find there ?)
After that we can finally debug the code with a better idea of where to search :slight_smile:
let me know how i can help to speed up the process.
EDIT
What i believe is once baked, the scale animation is NOT played anymore (if you are looking into the animation curve editor, playing the scale make the sphere disapear, nothing to do with the export).
The export only highlight this by exporting the 3 animations separately without taking care of the

        animationGroup.isAdditive = true;

property or the fact the animation is one keyframe only.
So i’m agree it’s might be a missing feature into the exporter and a strange behavior into the MakeAnimationAdditive call which is changing the source animation scale to zero
(but i also think the exporter was written before the additive capabilities).
G.

1 Like

Thanks @Guillaume_Pelletier for your response,

i totaly agree.

after doing some investigations, if you take a look at the playground i provided and log the keyframes, you may notice that the scaling animation has Vector3.Zero already

so playing animations with an isAdditive flag maybe compute the keyframes in a way that we coudn’t notice the issue in the playground.

in conclusion i think the exporter doesn’t fully support additive animation.

also correct me if i’m wrong, isn’t multiple animationGroups are supposed to be exported as a single animation ? (based on the docs) it’s not the case here :thinking:

As far i readed the code (that I did not write), your assumption is right.
GLTFAnimation._CreateNodeAndMorphAnimationFromAnimationGroups
is the place where the export happen and it add every animation, one by one, to channels, which might be the normal behavior for an exporter. There is no generic reason to bake the animation prior to export.

hi there, I’m having the same issue here.
Is there some workaround to make the export work?
If not, is there any solution in mind to support this feature in the exporter?

Hello,
please share a sample in order to give us a better view of your issue.
G.

Hello @Guillaume_Pelletier ,
Sorry for my late reply.

I’m using babylon and my goal is to play the GLB embedded animations with some custom animation made by the application (mainly position, scale and rotation) simultaneously.

I searched and found that the solution is to use additive animations.

When tried to export the model I found two issue:

  • The additive animations are exported separately
  • the model disappears when playing them.

I didn’t really investigate the issue or implemented it in my app.
but I tested in the example playground of additive animations.

here’s the edited playground: https://playground.babylonjs.com/#6I67BL#270

to test the scenario: just click on the download button I added.
then investigate the model in sandbox. you can then try to switch the animations to see the problem.

Hello,
Understand. Unfortunately, there is today no way to store the desired animation behavior (such additive) into GLTF2.0 format.
Then once the animation is transformed by MakeAnimationAdditive the exporter export the transformed animations as it.
Solutions may be :

  • Adding Vendor specific extension, but out of scope of this thread.
  • Adding a way to bake these additive animation, but also not provided by the framework at this time - Baked texture Animation is not usefull here.

Knowing that, for short term dev, you may rethink your usage

  • keeping non additive animation aside for GLTF export and MakeAnimationAdditive only when used/loaded.
  • Make animation additive once and store the result, but start the animation with boolean value isAdditive set to true.

for export purpose.

var sadPoseAnim = BABYLON.AnimationGroup.MakeAnimationAdditive(scene.animationGroups.find(a => a.name === 'sad_pose'));
...
sadPoseAnim.start(true, 1, 0.03333333507180214, 0.03333333507180214);

After loading exported GLB

var sadPoseAnim = scene.animationGroups.find(a => a.name === 'sad_pose');
...
sadPoseAnim.start(true, 1, 0.03333333507180214, 0.03333333507180214, true);

Hello @Guillaume_Pelletier @Cedric ,

maybe we should take a deep look to what happens in the animation baking, I have written a system similar to the additive feature before, I think I might help