Hi there!
I am working on a project where I am loading a mesh with animations, and stopping all animations during initialization (because I want nothing animated at the beginning) using scene.stopAllAnimations(). But when this is done, the callbacks added to onAnimationGroupEndObservable are never called again.
You can see this here - https://playground.babylonjs.com/#CBGEQX#1522.
Steps -
Working scenario -
- Click the ‘Play’ button.
- Click the ‘Stop’ button. → The onAnimationGroupEndObservable callback is called and the first cube changes colour. All good!
Faulty scenario -
- Click the ‘Play’ button
- Click the ‘Stop All’. → The onAnimationGroupEndObservable callback is not called again.
- Click the ‘Play’ button.
- Click the ‘Stop’ button. → The onAnimationGroupEndObservable callback is not called.
I explored this a little, and it looks like the issue lies in the [src/Animations/animatable.ts] file in the Scene.prototype.stopAllAnimations method, where the for-loop to call this._activeAnimatables[i].stop(); should be reversed, since the animatable’s stop function splices the scene._activeAnimatables array.
At the moment, some of the _activeAnimatables are not stopped and their onAnimationEnd method is never raised using the stopAllAnimations method. This causes the onAnimationGroupEndObservable callback to never be called even after the animations have ended.
Thank you in advance
…