# Ortho camera crashes with \`camera.zoomToMouseLocation = true\`

**URL:** <https://forum.babylonjs.com/t/ortho-camera-crashes-with-camera-zoomtomouselocation-true/21704>\
**Category:** Bugs\
**Created:** [June 15, 2021, 9:05pm UTC](https://forum.babylonjs.com/t/ortho-camera-crashes-with-camera-zoomtomouselocation-true/21704 "2021-06-15T21:05:11Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![zak](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/zak/32/7044_2.png) [@zak](https://forum.babylonjs.com/u/zak)\
**Post date:** [June 15, 2021, 9:05pm UTC](https://forum.babylonjs.com/t/ortho-camera-crashes-with-camera-zoomtomouselocation-true/21704/1 "2021-06-15T21:05:11Z")

</div>

I have an ortho camera but I want to have zoom to centre behaviour like many CAD packages (OnShape as an example). I spied the new zoomToMouseLocation in 5.0.0-alpha so thought I would try it out, but it causes this example to throw an error in the console and crash the camera (it gets stuck in position, no inputs can rescue it)

[https://www.babylonjs-playground.com/#KUM5WC#63](https://www.babylonjs-playground.com/#KUM5WC#63) (pan to cause the behavior)

I’m also guessing that it’s possibly unlikely to work out of the box for the orthocamera because we need to do pretty manual things to do scrolling with the orthocamera?

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [June 16, 2021, 8:27am UTC](https://forum.babylonjs.com/t/ortho-camera-crashes-with-camera-zoomtomouselocation-true/21704/2 "2021-06-16T08:27:20Z")

</div>

You should set the `zoomToMouseLocation` property before calling `attachControl` so that it does not crash.

However, I don’t know if this feature is supposed to work with orthographic cameras… Maybe @clovett will know as he did the PR to add the feature.

---

<div class="post-metadata">

**Author:** ![PolygonalSun](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/polygonalsun/32/2704_2.png) [@PolygonalSun](https://forum.babylonjs.com/u/PolygonalSun)\
**Post date:** [June 16, 2021, 8:47pm UTC](https://forum.babylonjs.com/t/ortho-camera-crashes-with-camera-zoomtomouselocation-true/21704/3 "2021-06-16T20:47:17Z")

</div>

Based on what I’m seeing, I think that there may be an issue with how zoomToMouseLocation works with the ortho camera.

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [June 18, 2021, 10:39pm UTC](https://forum.babylonjs.com/t/ortho-camera-crashes-with-camera-zoomtomouselocation-true/21704/4 "2021-06-18T22:39:29Z")

</div>

@clovett could you have a look into it?

---

<div class="post-metadata">

**Author:** ![clovett](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/clovett/32/12284_2.png) [@clovett](https://forum.babylonjs.com/u/clovett)\
**Post date:** [June 19, 2021, 4:05am UTC](https://forum.babylonjs.com/t/ortho-camera-crashes-with-camera-zoomtomouselocation-true/21704/5 "2021-06-19T04:05:17Z")

</div>

sure, I’ll take a look.

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [June 24, 2021, 3:53pm UTC](https://forum.babylonjs.com/t/ortho-camera-crashes-with-camera-zoomtomouselocation-true/21704/6 "2021-06-24T15:53:34Z")

</div>



---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [June 25, 2021, 9:08pm UTC](https://forum.babylonjs.com/t/ortho-camera-crashes-with-camera-zoomtomouselocation-true/21704/7 "2021-06-25T21:08:20Z")

</div>

Hey @clovett did you find time to take a look ?

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [July 20, 2021, 2:41pm UTC](https://forum.babylonjs.com/t/ortho-camera-crashes-with-camera-zoomtomouselocation-true/21704/8 "2021-07-20T14:41:49Z")

</div>

This will be fixed in the next nightly

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [July 20, 2021, 2:41pm UTC](https://forum.babylonjs.com/t/ortho-camera-crashes-with-camera-zoomtomouselocation-true/21704/9 "2021-07-20T14:41:50Z")

</div>


