@threlte/rapier
usePhysicsTask
This hook acts just like the useTask hook, but automatically adds the handler
to the simulation stage and always runs before the simulationTask, so
before the physics world is stepped.
Depending on your choice of framerate the provided callback will be called differently:
Varying Framerate
When you’re using a varying framerate for your physics simulation, the hook
essentially behaves like a regular useTask with the benefit that it’s added to
the physics stage automatically and is guaranteed to run before the physics
world is stepped.
<World framerate="varying">
usePhysicsTask((delta) => {
console.log(delta) // ~0.016
})
Fixed Framerate
When you’re using a fixed framerate for your physics simulation, the callback will be called with the fixed delta time between frames.
<World framerate={200}>
usePhysicsTask((delta) => {
console.log(delta) // 0.005
})