question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add support for pre-step and post-step logic

See original GitHub issue

Hi!

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:open
  • Created 10 months ago
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
krispyacommented, Dec 4, 2022

I think both useBeforePhysicsStep and useAfterPhysicsStep should 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 useFrame with a lower priority than the <Physics /> updatePriority.

(Correct me if you don’t think this is right)

Makes perfect sense to me.

1reaction
isaac-masoncommented, Dec 4, 2022

I think both useBeforePhysicsStep and useAfterPhysicsStep should 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 useFrame with a lower priority than the <Physics /> updatePriority.

(Correct me if you don’t think this is right)

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found