How to get current frame in useFrame? #554
Replies: 2 comments 2 replies
-
what is a "frame"? setAnimationLoop((timestamp, frame) seems undocumented, i dont see it mentioned anywhere. is this simply the delta perhaps? |
Beta Was this translation helpful? Give feedback.
-
The frame is an XRFrame that is passed into the So apparently this frame object is only available when an XRSession is running but I wasn't really able to find a lot of further information about it as there is generally not a lot of information about the WebXR API. |
Beta Was this translation helpful? Give feedback.
-
Hi I am currently trying to rebuild the threejs AR hit test example using react-three-fiber to build on top of it.
In the example they are doing something like this to run the hit test on every frame:
Now in react-three-fiber I am using a
Canvas
and settingvr={true}
so that it internally switches tosetAnimationLoop()
instead ofrequestAnimationFrame()
. To overwrite the animation loop I am usinguseFrame()
and want to pass it a function that handles the hit test.The problem is in
useFrame()
I only have access to the same state objects as inuseThree()
and a clock delta (API documentation). But I didn't find any way to access the current frame in the same way the threejs example does and I definitely need this frame to perform the hit testSo is there a way that I can get that same frame object in
useFrame()
that is accessible when passing a function directly intorenderer.setAnimationLoop()
?I hope someone can help me with this as I really want to use react-three-fiber instead of plain threejs.
Beta Was this translation helpful? Give feedback.
All reactions