I was creating a JS script where a point follows the mouse pointer, by a given displacement PVector.
I implemented a self made PVector class, I tested it and it works well.
My question is: Is there any workaround to update the mouse position inside the requestAnimationFrame(animate())
For now I am updating my mouse position inside the event handler, and it is not working well:
window.addEventListener('mousemove' e =>{ updateMousePosition() });
I have searched about this and I couldn't find a solution or maybe I didn't understand it.