-
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
Simulation speed too fast #795
Comments
Or am I the only one experiencing this vierd issue? |
A little update: |
Last time I used it, Matter was bad at dealing with monitors > 60Hz. Observed behaviour was a very fast simulation on 144Hz monitors. Is your monitor refresh rate higher than 60Hz? |
Sorry for late response! Did check so you can apparently use window.requestAnimationFrame together with some code to get fps. Found the information here on stackoverflow. I'll try at some point if this would work. Thank you for the info @nfernand ! |
@ZpeedTube , I think this can easily be fixed, feel free to have a look at the solution I linked to this tikcet. requestAnimationFrame( animate ); this function should be in sync with the refresh rate, and the solution I suggested adjust the time parameters by itself so no hardware specific configuration is needed. |
Haven't had time to try it until now. @wassfila Took a moment to understand how to implement your idea, but I have it in my code now and it seems like it runs much more consistent across different browsers! Thank you a lot!! |
@ZpeedTube |
Exactly, the issue is that the built in runner is pretty simplistic and assumes a 60hz monitor, but now that monitors are coming with higher refresh rates this is becoming a problem. I've actually already been working on some improvements to the runner which will solve this, but for now go with a fixed timestep or a custom runner. Thanks for reporting but closing this one as it's a known issue. |
Tried to look but could not see anyone else talking about this issue.
So I have noticed that at least in Chrome 77/78 and Firefox 70 Mater js simulation runs roughly double the speed than in older browsers. If I run same code in Chrome 74 (happened to be the version OBS Browser uses atm) it runs like normal.
So I don't know what, but something has changed in newer browsers that make Mater js run faster.
But I have come up with an temporary fix, at least for Chrome.
In setup I put
and use these functions to get browser version
Would not take much adjustment to make temporary fix for other browsers but I mainly need/use chrome.
Biggest problem I see with this issue is that when people update to newer versions of browsers (at least Chrome 77 and newer) is that games on the web that use Mater js is going to run too fast.
EDIT:
Forgot to mention that I don't use the render part of Matter js in case that could affect the speed?
I have built my own system to "attach" html elements to Matter js object body. Just reads the body position and move the element with js/css.
The text was updated successfully, but these errors were encountered: