matter-js
matter-js copied to clipboard
Improve Matter.Runner
This PR adds built-in Matter.Runner
support for:
- fixed timestep by default
- high refresh rate displays with fixed timestep
- sub-stepping for higher quality simulations
- performance budgets
- improved frame pacing
As before Matter.Runner
is still optional and a starting point for learning and developing with the engine. These changes should generally not affect those using their own runner or otherwise calling Engine.update
directly.
Usage
If you wish to try these beta changes out in your environment before release:
- get the pre-release build or runner-2 branch
- try this on a higher refresh rate display
- try setting
runner.delta
(see docs andExample.substep
)
These features are still experimental and helpful feedback on your results is welcome.
There may be some further changes to come on this PR before a general release is possible.
Changes
Matter.Runner
- changed the built-in runner to default to fixed timestep (see
runner.delta
) - removed non-fixed timestep support (removed redundant
runner.isFixed
) - added built-in support for fixed timestep on higher refresh rate displays
- added performance budgets
runner.maxFrameTime
andrunner.maxUpdates
- improved frame pacing with fixed timestep
- removed bundled
window.requestAnimationFrame
polyfills - changed and updated docs
Matter.Render
- added updates per frame ("upf") display to
render.options.showDebug
Migration
-
Matter.Runner
now defaults to a fixed deterministic timestep (support for non-fixed is removed) - if needed set your
runner.delta
and appropriaterunner.maxFrameTime
andrunner.maxUpdates
(see docs) - note that
Matter.Runner
can call zero, one, or multiple engine updates and events per display frame - see
Matter.Runner
updated docs throughout - if needed set up your polyfill for
window.requestAnimationFrame
- these steps may change or be updated before release
Related
#5, #500, #652, #702, #818, #820, #885, #971, #1152, #1164, #1167
This change would be highly appreciated, is there something I can do to help merge it?
Agreed with @davidreis97, we really would like to see this merged, and maybe some examples to demonstrate how this will fix issues associated with nondeterminism, and monitor framerates differing
Hi @liabru , are there any updates on the viability of getting this merged?
This is now released as of 0.20.0, thanks all!