Skip to content
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

Closed
elcarim5efil opened this issue Apr 1, 2015 · 6 comments
Closed

can I change the fps of the engine #79

elcarim5efil opened this issue Apr 1, 2015 · 6 comments

Comments

@elcarim5efil
Copy link

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?

@liabru
Copy link
Owner

liabru commented Apr 1, 2015

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.
Is it for performance reasons?

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).

@elcarim5efil
Copy link
Author

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!

@liabru liabru closed this as completed May 12, 2015
@wmike1987
Copy link

Are you sure requestAnimationFrame is locked at 60? The mozilla docs state

The number of callbacks is usually 60 times per second, but will generally match the display refresh rate in most web browsers as per W3C recommendation.

@liabru
Copy link
Owner

liabru commented Apr 20, 2018

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.

@wmike1987
Copy link

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?

@lafkpages
Copy link

I had users with 144hz monitors whose simulations would run fast

same #1152

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants