-
hi, how can I make gltf object rotation with mouse position. to make it clear I mean for example move mouse cursor and object is looking at cursor, |
Beta Was this translation helpful? Give feedback.
Answered by
Achi00
Apr 6, 2022
Replies: 1 comment
-
ok i did it already if someone wonder how, here is how const { viewport } = useThree() and attach ref to my gltf object |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
Achi00
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ok i did it already if someone wonder how, here is how
const { viewport } = useThree()
const droneRef = useRef()
useFrame(({ mouse }) => {
const x = (mouse.x * viewport.width) / 12
const y = (mouse.y * viewport.height) / 8
droneRef.current.rotation.set(x, y, 0)
droneRef.current.rotation.set(y, x, 0)
})
and attach ref to my gltf object