Orthographic Camera Zoom to Mouse Position


I was wondering if anyone could help me figure out how to zoom to mouse position using an orthographic camera. I can’t get it quite right. It seems the position is off.

Sample here: https://stackblitz.com/edit/three-orthographic-zoom-to-mouse

Any help will be appreciated.



You might wanna use this code for your own project.

Thank for this.

I have an issue with this line: https://github.com/mrdoob/three.js/blob/70294c4461c5b20d5fe23c01228a3b6769d8ae4c/examples/jsm/controls/OrbitControls.js#L623

It seems that when the camera’s up is (0, 1, 0), v1 dot is 0, I don’t know why.