Closed rmrbytes closed 7 months ago
The two ways I would do it are
ref.current.getWorldPosition(vec);
The reason for all this is updating react is annoying and slow. If it remounts a component it can cause multiple useless cycles and creations of things, and the traversing of the tree takes forever. Doing this at frame rate speeds is super CPU intense and will likely bog things down.
So either use a throttle and the default useFrame
loop, or create your own loop.
Thanks @DennisSmolek . I will probably follow option 2 that we would normally use in vanilla JS
Hello:
When a body is falling the world position of that body get continously updated. I have access to this using the
useFrame
hook. I need to display this updated value to be stored and available elsewhere. For the same I am using setState though it is not recommended to be used with useFrame. Is there a better way to get this value? My current code is:Thanks.