Hello,
AnimationGroup.gotoFrame() will not work correctly for additive animations: this will also apply the animation (as it were NOT additive) to all targets.
I think this should not be done for additive animations, but I’ve not tested.
I figured out by trying to optimize my previous method, which was consuming A LOT of CPU (I need to apply an additive animation at a calculated animation frame each render call):
group.stop();
group.start(true, 1, frame, frame);
As gotoFrame is not working as expected, my current working workaround is this
for (const animatable of group.animatables) {
animatable.fromFrame = frame;
animatable.toFrame = frame;
}
I tried to reproduce the problem, but couldn’t:
https://playground.babylonjs.com/#EJBTLO
The sphere is at the right location after we call goToFrame(300) on the base and additive animations (comment lines 75-76 and 79-82 to see the full animation).
Are you able to setup a repro in the Playground, to let us investigate?
Ok, I’ll try with your base playground, as my case is more complex (that’s a full animated human armature and the additive animation is for turning the head any chosen direction, with an animation from 90° left to 90° right)
I’ve set it up so that the additive animation is controlling the ball height, from Y=0 (first frame) to Y=5 (last frame)
Here is the case with gotoFrame() : the base animation is not applied anymore
https://playground.babylonjs.com/#EJBTLO#3
And here is it with my workaround
https://playground.babylonjs.com/#EJBTLO#4
Edit: I also tried to pause the offset animation and change the frame but it did not work, the additive animation will not be applied when paused.
Your playground is working because you are letting another frame run before pausing. If you pause right after gotoFrame(), you will see only the additive animation is applied https://playground.babylonjs.com/#EJBTLO#5