How can I set a custom FPS?

I found something that works for my needs. It does not actually modify the engine’s framerate. Instead, it syncs game updates with the user’s framerate so that game logic updates look smooth. For example, you can drive movement of objects in your scene as if they were running at a certain fps, while all the renderings happen as fast as they can. I did notice hitching sometimes with mouse clicks. Not sure what that is all about.
https://playground.babylonjs.com/#3U49SI#3

I got the code from this discussion. There is a comment about tolerance that might be worth experimenting with, but I didn’t implement it.
https://gist.github.com/addyosmani/5434533

3 Likes