jp_sun
August 14, 2025, 10:07am
1
When the page switches,particleSystem seems to be reset,
use visibilitychange paused , doesn’t resolve the issue
document.addEventListener("visibilitychange", () => {
if (document.hidden) {
this.scene.particleSystems.forEach(ps => ps.paused = true);
} else {
this.scene.particleSystems.forEach(ps => ps.paused = false);
}
});
Can you try with this:
window.addEventListener("blur", () => {
console.log("Window lost focus");
});
window.addEventListener("focus", () => {
console.log("Window gained focus");
});
jp_sun
August 15, 2025, 3:46am
3
when switch the chrome tab,issue still exists
ok the best way in your case is to do this:
engine._deterministicLockstep = true;
This is a hack for the PG. In your code, simply create your engine with this:
this.engine = new BABYLON.Engine(theCanvas, true, {
deterministicLockstep: true
});
2 Likes
jp_sun
August 17, 2025, 5:21am
5
Thanks, this fixed the tab switching problem!
But I noticed the particles move faster now.
I get the general reason, but how can I keep the particle speed the same as 60 FPS when running at higher frame rates?
In 170FPS it very fast
By default the timestep is 1/60 but you can control it with engine._timeStep
You could try using Animation Ratio
jp_sun
August 19, 2025, 2:33pm
8
engine._timeStep has no effect on particles …
jp_sun
August 19, 2025, 2:35pm
9
Could you please be more detailed? particleSystem has no “Animation Ratio” properties
Here we are:
Babylon.js Playground
I overloaded scene.getAnimationRatio so you can control the speed when tab is switching
1 Like