Best way to efficiently use useFrame? #510
milenazuccarelli
started this conversation in
General
Replies: 1 comment 5 replies
-
it says useRef, but i assume you mean useFrame, there's nothing in there that would be expensive. if you want to animate something frame by frame, using mouse coordinates or whatever, this is the way to do it. btw, normalized (-1 / 0 / 1) mouse coords are inbuilt: useFrame(state => {
ref.current.rotation.z = state.mouse.y * Math.PI / 2
}) or if you wanna animate it: useFrame(state => {
ref.current.rotation.z = THREE.Math.lerp(
ref.current.rotation.z, state.mouse.y * Math.PI / 2, 0.1
)
}) |
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hey guys,
I'm using useFrame and need to check a few conditional statements something like this:
It seems like it would be hugely expensive to do this on every frame. What would be the best way to do this?
thanks!
Beta Was this translation helpful? Give feedback.
All reactions