Add support for pre-step and post-step logic
See original GitHub issueHi!
Looking for thoughts on adding pre-step and post-step events.
Use cases for this include creating custom character and vehicle controllers, where forces should only be applied once per physics step. When not using timestep="vary", applying forces on each frame isn’t desirable, as not every frame will step the physics world, some will just interpolate.
This could come in the form of hooks, e.g.
import { usePreStep, usePostStep } from "@react-three/rapier"
usePreStep(() => { /* called before stepping the world */ })
usePostStep(() => { /* called after stepping the world */ })
Or via signals/event handlers on the wrapped rapier World, e.g.
world.onPreStep.add(() => { /* called before stepping the world */ })
world.onPostStep.add(() => { /* called after stepping the world */ })
Or maybe a combination of both.
Keen to hear thoughts, and as usual, happy to help implement 🙂
Issue Analytics
- State:
- Created 10 months ago
- Comments:9 (9 by maintainers)
Top Results From Across the Web
Issue #67 · pmndrs/use-cannon - PreStep support - GitHub
My goal is to recreate gravity towards a point in space, so I'm trying to apply a constant force through that point in...
Read more >Using pre-step callbacks to setup test conditions - NI Community
Solved: I am trying to setup a pre-step callback to verify test conditions and correct them if they do not match the needs...
Read more >About Interceptors and Custom Hooks - Documentation
MarkLogic Data Hub provides two mechanisms to add custom processing to a step. ... Flow of step with interceptor and pre-step and post-step...
Read more >TS_RK enhancements
One potential way of doing this without >> adding yet another flag would be to break ... More of that: prestep() and poststep()...
Read more >GEANT4 : overview - CERN Indico
G4 is a toolkit that will help you with the following problem: ... Concepts of: Solid, Logical - , Physical - volume ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Makes perfect sense to me.
I think both
useBeforePhysicsStepanduseAfterPhysicsStepshould be within the same loop as the physics step - running only once for a rapier physics step.To get interpolated values, you could already use
useFramewith a lower priority than the<Physics />updatePriority.(Correct me if you don’t think this is right)