I have read a few comments here that simply ‘stopping the render loop’ is enough to pause the game - if the code to start it exists outside of the babylon context - however i ran into an issue when i restarted the render loop again. My issue was that any animatables currently in a scene will instantly jump as if they had been running for the entire time it is paused.
I found a workaround for it using:
engine._performanceMonitor.reset(); //may not be needed
scene._animationTimeLast = performance.now
prior to calling runRenderLoop with my render function.
My concern here is that i am using an internal tracking variable which has no reason to be maintained across version changes. I’m wondering if there is a correct way to reset the timing for the animatable module, or if this should be tracked as a bug.
This is a scenario where the developer needs to take action in order to get that to work correctly. Babylon doesn’t know in what state your scene is at or if you want to keep the behavior as is or not. In some cases you would want this behavior to stay the same (for example when you stop the render loop when moving to a different tab and coming back, you would expect the animation to “run in the background”).