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

Add world.fixedStep() #127

Merged
merged 2 commits into from
Jan 6, 2022
Merged

Add world.fixedStep() #127

merged 2 commits into from
Jan 6, 2022

Conversation

marcofugaro
Copy link
Member

@marcofugaro marcofugaro commented Jan 6, 2022

Closes #126

We can simplify the world stepping for the user quite a bit by keeping track of lastCallTime internally:

-  const timeStep = 1 / 60
-  const time = performance.now() / 1000
-  if (!lastCallTime) {
-    world.step(timeStep)
-  } else {
-    const dt = time - lastCallTime
-    world.step(timeStep, dt)
-  }
-  lastCallTime = time
+  world.fixedStep()

This PR adds a new method for the world, fixedStep(). Look at the getting started guide for updated documentation.

@marcofugaro marcofugaro merged commit fbba069 into master Jan 6, 2022
@marcofugaro marcofugaro deleted the fixedstep branch January 6, 2022 15:48
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

Successfully merging this pull request may close these issues.

Simplify world stepping
1 participant