Skip to content

How to sync @react-three/rapier RigidBody with scroll #50

Answered by ffdead
emilianoglucero asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @emilianoglucero - that's a fun challenge and I believe there might be different ways to achieve it.

I did some hacking with this setup a few years ago and this is the best I came up with: https://xiz6zy.csb.app/

Basically you should not wrap your physics scene in a ScrollScene because that will move the whole physics world.

Instead, wrap your canvas children in the physics world - and then when scrolling you need to manually move the rigid body using impulses or translations. So the scrolling itself becomes part of the physics simulation.

In this example the balls are all free falling, but the Cup objects are moved with setNextKinematicTranslation to sync with the scroll.

Here are the…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by ffdead
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #49 on January 09, 2025 18:21.