react-xr icon indicating copy to clipboard operation
react-xr copied to clipboard

GSAP and framer-motion-3d animations don't work

Open meesrutten opened this issue 3 years ago • 2 comments

We've been building a VR game with @react-three/vr which is an absolute blast. We have found some issues where GSAP and framer-motion-3d don't work. That may be because they use requestAnimationFrame, but we're not sure.

Does anyone know why this doesn't work and can we help to fix this? :)

meesrutten avatar Aug 31 '22 13:08 meesrutten

The problem is most certainly the rAF. When browser enters an immersive session it will (I don't remember if all of them do or the certain ones, like Oculus Browser) stop the rAF (in workers also) and you'll have to rely on session frame callback to do stuff. Animation frameworks and libs usually have a safehatch to trigger the update from the outside, that's were you need to dig. For instance here how it's done in @react-spring/three, https://github.com/pmndrs/react-spring/blob/master/targets/three/src/index.ts#L18 For a vr session you can use useFrame for r3f 8+ or useXREvent for older ones

saitonakamura avatar Sep 06 '22 18:09 saitonakamura

@meesrutten does that ^ helps?

saitonakamura avatar Sep 26 '22 15:09 saitonakamura