matter-js icon indicating copy to clipboard operation
matter-js copied to clipboard

Improve Matter.Runner

Open liabru opened this issue 9 months ago • 2 comments

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:

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 and runner.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 appropriate runner.maxFrameTime and runner.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

liabru avatar Nov 12 '23 16:11 liabru

This change would be highly appreciated, is there something I can do to help merge it?

davidreis97 avatar Jan 22 '24 11:01 davidreis97

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

epurban avatar May 08 '24 04:05 epurban

Hi @liabru , are there any updates on the viability of getting this merged?

epurban avatar Jun 22 '24 15:06 epurban

This is now released as of 0.20.0, thanks all!

liabru avatar Jun 24 '24 20:06 liabru