Rotating a 3D Object towards the mouse position
I'm trying to draw a 3D cube that rotates towards the user's mouse with perspective projection. I have managed to draw the cube, but I can't figured out how to rotate the cube. Maybe I should "unproject" the current mouse position, convert it to cartesian coordinates, figure out the offset and rotate it by that?
( @xxpertHacker help)
I think you both might be able to help each other better than I could.
programmeruser's post: https://replit.com/talk/ask/Rotating-a-3D-Object-towards-the-mouse-position/132521 (here)
@programmeruser I was thinking about the last time that I've worked with anything 3D... I haven't done a 3D graph in over a year, I haven't written any code that manipulates 3D objects in forever either.
Then I thought about your current problem: moving a 3D cube to the mouse's position.
First off, how are you getting the mouse's position via GLSL?
Second, I remembered that someone literally did this with P5.js on Repl... https://replit.com/talk/share/Real-3D-3D-But-its-actually-not-fake/80965.
Hopefully you can understand their math, and apply it here?