Animations with ANIMATIONLOOPMODE_CONSTANT behave weird

Probably this is not really a bug, but a misleading documentation.
In either case, implemented behavior contradicts common sense.

The only line ever explaining the parameter is:

BABYLON.Animation.ANIMATIONLOOPMODE_CONSTANT - Pause the animation at the final value

at Babylon.js docs

So, when played:

  • scene.beginAnimation(target, startFrame, endFrame)
  • scene.beginDirectAnimation(target, animations, startFrame, endFrame, false)
  • animationgroup.start(false, 1.0, startFrame, endFrame)

Expected behavior after playing is that values in effect correspond to the values at the endFrame.

Instead, animations are reset to a value of the last frame defined, no matter how they played.

An easily constructed disaster is to combine animations of different length and try to play their common part.

The resetting does not happen when animations are of mode ANIMATIONLOOPMODE_CYCLE (but still played without loop)

The behavior of the reset is implemented at

The state.highLimitValue is apparently initialized to the value of the last keyframe in animation (or the first if it’s reversed).

If that is how designed, documentation should be more elaborative and say something like:

BABYLON.Animation.ANIMATIONLOOPMODE_CONSTANT - Reset the animation to a value of the last key frame defined.

(Also, animations are not actually /paused/ as it’s stated, but they are stopped instead, and their currentFrame / masterFrame get reset to 0)

And then it totally doesn’t make sense anyway.

I agree, it seems more like a bug to me.

Here’s the PR. Let’s wait and see what others think:

2 Likes