pmndrs / use-p2

👋💣 2d physics hooks for @react-three/fiber
https://p2.pmnd.rs
MIT License
149 stars 9 forks source link

A way to pause the world [enhancement] #3

Closed grndctrl closed 2 years ago

grndctrl commented 2 years ago

Maybe it can be achieved by exporting the state from Physics, something similar like useThree(), but then usePhysics() from there I could manipulate state.world.

Another idea is to expand the step prop from the Physics component so that it allowed the timeSinceLastCalled too, just like p2-es: http://schteppe.github.io/p2.js/docs/classes/World.html#method_step Then you would be able to pause and resume using step={[0, delta]} without the engine playing catch up if you resume with step={[1/60, delta]).

grndctrl commented 2 years ago

Opened a PR, which adds a paused paused prop.