I’m facing an issue with my project that utilizes Three.js and orbitControls.js for handling the camera. The scene consists of a simple cube and the camera. By default, the camera zooms in/out towards the center of the screen when using the mouse wheel. However, I need to modify this behavior so that it zooms in/out towards the mouse position on the 3D object, similar to how it works in 3D editors like 3D Max or Blender.
The logic I’ve come up with involves capturing the initial mouse position from where the zooming starts, the desired zoom-in position, storing these values, and then calculating the offset between the two positions as the camera zooms in. However, despite implementing this logic, the functionality is not working as expected. I suspect the issue may lie in the coordinates of the camera and the target zoom-in position.
Below is a snippet of my code:
// Code snippet here
If anyone has encountered this issue before and successfully solved it, could you please share your solution or offer advice on how to tackle this problem effectively?
Thank you!