Skip to content

Conversation

@marcofugaro
Copy link
Member

Some days ago a user reported that the world stepping is different in the Oculus browser.

image

This is because, as he pointed out, the requestAnimationFrame in the Oculus browser runs at 90fps instead of 60. Since world.step() was called in the requestAnimationFrame, the world stepping is a little bit faster.

This PR makes the world stepping framerate independent. Basically it takes into consideration the last time the step function was called and adapts otherwise.

The implementation was originally done by schteppe for cannon.js following the article Fix your timestep!, some bugs were fixed in cannon-es in pmndrs/cannon-es#40.

After this PR, the simulation should run at the same speed in both normal browsers and the Oculus browser.

@stockhuman stockhuman added the enhancement New feature or request label Feb 15, 2021
@stockhuman
Copy link
Member

Sweet and straightforward. I'd merge unless anyone objects.

@codynova
Copy link
Member

Definitely merge it - people have been wanting this for a long time. Great job Marco.

@stockhuman stockhuman merged commit 858df49 into master Feb 15, 2021
@stockhuman stockhuman deleted the framerate-independent branch February 16, 2021 15:45
@alex-shortt
Copy link
Contributor

much appreciated :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants