Hi, so I managed to make a circle follow my mouse when I’m on my planeGeometry, unfortunately I encounter bugs and I don’t understand.
Sometimes when I go to make it disappear when I move the camera, and then it reappears, sometimes it appears shifted from my mouse, I have to move my mouse so that it refocuses, and I do not understand why? maybe the performance is bad and I miss frames?
Because I noticed that my gpu was at 7/8 ms while there is nothing on the scene? Maybe I misunderstood the use of UseFrame() ?
it’s just wasteful to go through react like that. if you need it in multiple places, use a vector, this is how you’d do it in vanilla as well so why deviate?
you have to understand that useFrame is a loop. at worst you are setStating 120 times per second, which re-renders the entire component 120 times per second, running through all the hooks again, diffing the view, looking for changes. it is no wonder you experience a slowdown.
Hi, thanks for your answer! Maybe I wasn’t clear but I just want it to disappear when I drag and reappear just when I move the mouse on my plane without dragging.
I’m pretty new to three js and react too , I still have a lot to learn, I will try to change the code and see what it gives, thank you very much for you’re advices!
What I was trying to do was when i move the camera I have the style of the mouse turns into drag, and that the circle disappears. But when im doing nothing i have the normal cursor.
But also when I’m not on my plane, the circle disappears. That’s why in my head i had to use several events in a Useframe() to know at each frame if the different events trigger but maybe i’m wrong.
And i have used a Show variable to Show/hide the cursor + the plane when i move the camera , but i have used a Setstate in a UseFrame() , and as you said earlier i can’t do this. But i really dont know how to proceed with an UseEffect.
And i have noticed a bug after hiding the cursor , when he show again , he is placed in offset, and i don’t understand why. Maybe because i have used a useState inside the loop?