I have a gltf model which has animation. I turn on the animation like this:
that.animatable = that.scene.beginAnimation(that.logoMesh, 0, that.logoMesh.animations[0]._keys.length, true);
Whenever the mouse is hovering over the model, I stop the animation. Whenever the mouse leave the model, I resume the animation:
//ON MOUSE ENTER
that.logoMesh.actionManager.registerAction(new window.BABYLON.ExecuteCodeAction(window.BABYLON.ActionManager.OnPointerOverTrigger, function (ev) {
that.stopAnimation();
}));
//ON MOUSE EXIT
that.logoMesh.actionManager.registerAction(new window.BABYLON.ExecuteCodeAction(window.BABYLON.ActionManager.OnPointerOutTrigger, function (ev) {
that.startAnimation();
}));
....
stopAnimation: function () {
var that = this;
that.scene.stopAnimation(that.logoMesh);
that.pausedFrame = that.animatable.getAnimations()[0].currentFrame;
console.log(that.pausedFrame);
},
startAnimation: function () {
var that = this;
console.log(that.animatable.getAnimations()[0].currentFrame);
that.scene.animationsEnabled = true;
that.animatable = that.scene.beginAnimation(that.logoMesh, 0, that.logoMesh.animations[0]._keys.length, true);
that.animatable.goToFrame(that.pausedFrame);
}
The paused frame from the stopAnimation()
is the same as the paused frame from startAnimation()
. The problem is when the animation resume from startAnimation()
it is somehow resuming from a wrong frame. It looks like jittering