For anim channel that is constant in a AnimationClip, I expect it to have 2 key.
But sometimes I get 3 keys, and looking into it, it has redundant sample
I don’t think we create any key at load time, so if there are 3 keys in the animation, it means it was created/exported that way.
cc @bghgary to be sure.
It’s here:
Ah yes, thanks @kzhsw, we do babylonAnimationGroup.normalize(0);
after an animation has been created.
It was done as part of:
It simply adds a frame at #0 if it does not already exist.
@yangrui_zhang It should normally not be a problem(?)
I use an animation clip and turn it into a “poseAsset” at runtime. (In UE, you turn “animationSequence” into a “poseAsset” in Editor)
Skipping channel that is constant can avoid redundant calculation. And I decide if it’s constant by (key.length>2)
So maybe I should figure out my serialization/deserialization… I tried json, much bigger than glb. Have to figure out a binary format…
A channel could be not constant even if keys.length == 2
. To know if it’s constant, I would instead loop over all the keys and see if all the values are the same or not.
Not exactly, this code has been there for a long time. I just moved this code back to where it was originally after this PR moved it into an extension.
The reason why we need this code is to satisfy a requirement in the spec.
Normalizing the animation group will add keys to ensure this clamping happens.
You can use glTF-Transform to process the glb file and remove constant animation channel with code like this