# Orthographic Camera -- Zoom at Cursor

**URL:** <https://discourse.threejs.org/t/orthographic-camera-zoom-at-cursor/4959>\
**Category:** Questions\
**Tags:** orthographic-camera, zoom\
**Created:** [November 16, 2018, 4:27pm UTC](https://discourse.threejs.org/t/orthographic-camera-zoom-at-cursor/4959 "2018-11-16T16:27:54Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ps111](https://avatars.discourse-cdn.com/v4/letter/p/df705f/32.png) [@ps111](https://discourse.threejs.org/u/ps111)\
**Post date:** [November 16, 2018, 4:27pm UTC](https://discourse.threejs.org/t/orthographic-camera-zoom-at-cursor/4959/1 "2018-11-16T16:27:54Z")

</div>

I’m trying to implement zoom to cursor with an OrthographicCamera and OrthographicTrackballControls. I disable zoom in OrthographicTrackballControls and use the following function on mousewheel:

```
zoomDirection = new THREE.Vector3();
function mousewheel(event) {
            event.preventDefault();
            var amount = event.deltaY / 100;
            var zoom = camera.zoom - amount;
            var factor = 1;
            var offset = el.offset()
            ;
            var mX = amount > 0 ? 0 : ((event.clientX - offset.left) / renderer.domElement.clientWidth) * 2 - 1;
            var mY = amount > 0 ? 0 : -((event.clientY - offset.top) / renderer.domElement.clientHeight) * 2 + 1;

           zoomDirection.set(mX, mY, 0.5)
                .unproject(camera)
                .sub(camera.position)
                .multiplyScalar(amount / zoom)
            ;

            camera.position.subVectors(camera.position,zoomDirection);

            orthographictrackBallControls.target.subVectors(orthographictrackBallControls.target,zoomDirection);
           camera.zoom = zoom;
           camera.updateProjectionMatrix();
        }

```

This seems to work at first: the camera zooms into the mouse point, but then the camera starts to “jump” around after a bit of zooming, with the mesh no longer visible on screen.

Something that might help: I have an axis helper in the screen as well that “flips” when it stops working as expected. When the scene is loaded, the X-axis helper point due left, but when I get to the point where the camera jumps and I no longer see the mesh, the X-axis helper sometimes (but not always) flips to point due right.

Also, if I zoom OUT first, I can zoom in further before the mesh disappears. I’m not sure what this all adds up to but I would appreciate any help.

---

<div class="post-metadata">

**Author:** ![Mugen87](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/mugen87/32/5645_2.png) [@Mugen87](https://discourse.threejs.org/u/Mugen87)\
**Post date:** [November 17, 2018, 10:52am UTC](https://discourse.threejs.org/t/orthographic-camera-zoom-at-cursor/4959/2 "2018-11-17T10:52:58Z")

</div>

It’s hard to help you based on the information you’ve provided so far. Please add a [live example](https://jsfiddle.net/f2Lommf5/) that demonstrates the issue.
