-
In this example, I have 2 boxes. When I hover to a box, this will change the color to be pink. My question is: How to fix that? How can I trigger the mouse event when I'm moving? My Code: https://codesandbox.io/s/bold-elion-xvy5j I've researched it for 2 weeks but still not find out any answers. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
you can fire events imperatively: https://codesandbox.io/s/scrolling-cursor-issue-forked-4mvo7?file=/src/App.js:395-426 const events = useThree((state) => state.events)
...
events.handlers.onPointerMove(e) pointermove for instance will take care of hover/unhover etc, but it needs an event to go on, you must give it eiter a real or a fake event. the problem in general is that r3f gives you an event layer, when events happen it reacts. you moving the camera will not trigger anything, no pointer has moved or changed. so you can force it to cast. |
Beta Was this translation helpful? Give feedback.
you can fire events imperatively: https://codesandbox.io/s/scrolling-cursor-issue-forked-4mvo7?file=/src/App.js:395-426
pointermove for instance will take care of hover/unhover etc, but it needs an event to go on, you must give it eiter a real or a fake event.
the problem in general is that r3f gives you an event layer, when events happen it reacts. you moving the camera will not trigger anything, no pointer has moved or changed. so you can force it to cast.