How can I set a custom FPS?

Is there a way to set a target fps for Babylon.js? I want to change to a low fps to do some testing.

You can try something like this:

@Evgeni_Popov Thanks for the answer, but on further examination this isn’t going to work for my needs. If things are actually moving in the scene, they will have a jumpy motion. I made a playground to demonstrate, which is pretty much the same as the scene you linked, except now the ball is moving. You can see that it looks like the ball is almost skipping frames.

I think the solution I really need is to fire off engine.runRenderLoop and let requestAnimationFrame do its thing, but have my game logic run somewhere else at a constant 60fps because my game logic is dependent on the number of ticks/frames that have passed. However, I don’t need any fancy physics plugin, and I can’t tie the physics to an object. I’m currently investigating an alternative solution.

edit: I also tried an example using delta time, but it’s still jumpy.

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.

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.