Hi all,
I noticed that if I pause the scene, for example, like this: How to pause the game correctly while in the game menu? - Questions - Babylon.js then all BABYLON.Animation
that I started actually continue to play in background. When I resume the rendering of the scene, then those animations are far away already. This means that BABYLON.Animation
doesn’t listen the gaming loop and probably relies on setInterval
, setTimeout
, which is a trouble in terms of game state managment.
Is there a way to make these animations to be synchronized with a rendering loop? Or at least magic methods like BABYLON.Animation.pauseAll()
, BABYLON.Animation.resumeAll()
probably exist?
Of course as the last chance I can compute all my animations on my own using:
let framesPassed = 0;
let fps = 60;
scene.onBeforeRenderObservable.add(function(e) {
framesPassed++
if (framesPassed >= fps * 1 && framesPassed < fps * 2) {
// DIY
}
else if (framesPassed >= fps * 2 && framesPassed < fps * 3) {
// DIY
}
// ....
});
But the BABYLON.Animation
has a convenient mechanism of binding values to keyframes. It would be sad if I will need to create my own animation engine only because the original one is not synchronized with a rendering loop.