-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
can I change the fps of the engine #79
Comments
There's currently no support for this in the built in runner, but it's possible if you create your own runner (which is highly recommended, see the wiki). Note that also it's not so straightforward to implement the logic for limiting the fps inside a requestAnimationFrame loop (which is locked to 60fps), but it can be done I think. I've experimented with it, but can't find a use case where you'd want less than 60fps. Because if you're using < 60fps for physics, you will need to start doing extra iterations (e.g. 2x per frame at 30fps) to maintain the same accuracy and stability (i.e. you won't gain any performance except a little from the reduced amount of rendering). |
thank you for you response, and I will try out you suggestion. In fact, I've found that sometimes the framerate is not stable when the bodies are moving fast with image rendering. Thank you for your response again, and also thank you for you wonderful work! |
Are you sure requestAnimationFrame is locked at 60? The mozilla docs state
|
Yeah that's true it does depend on the monitor refresh rate, but what I meant was you can't directly set a custom fps from code on the browser. It is however possible to use a lower refresh rate by frame skipping, but that comes with its own set of issues too. |
One catch I've encountered is that the default implementation of Runner sets the fps to 60 and a deltaMax and deltaMin are based on this. I had users with 144hz monitors whose simulations would run fast because the smallest delta (deltaMin) Runner would comprehend was 16ms, but it was happening a lot more than 60 times a second. Is there a reason to even specify an fps in Runner if it can vary due to the monitor refresh rate? |
same #1152 |
I try to change the _fps in matter.js to 30, theoretically, the _delta gets larger, but in fact, the engine seems to run faster.
Did I do wrong? Is there anyother way to limit the fps to a lower value?
The text was updated successfully, but these errors were encountered: