I know that there is a PR for this here WIP: OrbitControls: added support for zoom to cursor by WestLangley · Pull Request #17145 · mrdoob/three.js · GitHub
and a sample on how it works: three.js webgl - map controls
I viewed the changes and the code and i just want to understand one line.
I understood the part from line 634 to a portion of line 643, where it the mouse position is converted to world coordinates get and get its direction vector from the camera position.
But the part i dont understand is for v1, after getting the direction vector between the current scope.target and the camera position (scope.object.position), why is it that v1 direction vector is then DOT product against the camera up vector (scope.object.up)
and again divided against the dot product of the direction vector of the new position and the camera up vector to compute the distance?
const distance = v1.copy( scope.target ).sub( scope.object.position ).**dot( scope.object.up )** / **v.dot( scope.object.up )**;
anyone can explain the math behind it? im just trying to understand the solution.