# How can I prevent zooming in/out using an interactor style?

**URL:** https://discourse.vtk.org/t/how-can-i-prevent-zooming-in-out-using-an-interactor-style/5315
**Category:** Web
**Created:** [March 4, 2021, 1:17pm UTC](https://discourse.vtk.org/t/how-can-i-prevent-zooming-in-out-using-an-interactor-style/5315 "2021-03-04T13:17:34Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![joel](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/j/b9bd4f/32.png) [@joel](https://discourse.vtk.org/u/joel)
#### Post date: [March 4, 2021, 1:17pm UTC](https://discourse.vtk.org/t/how-can-i-prevent-zooming-in-out-using-an-interactor-style/5315/1 "2021-03-04T13:17:34Z")

</div>

I need to set min and max zoom levels for the application that I work on. It uses the InteractorStyleTrackballCamera and I’d like to be able to stop the zooming in and out once a certain min/max zoom level is reached.

Is there a way to do that?

I realize that the interactor has some events\* that I subscribe to, but it doesn’t seem that there is an option to stop the zooming (dolly?).

\* I am aware of these events triggering on user navigation:  
interactor.onStartMouseWheel(mapChange),  
interactor.onEndMouseWheel(mapChange),  
interactor.onMouseWheel(mapChange),  
interactor.onPinch(mapChange),  
interactor.onPan(mapChange),  
interactor.onMouseMove(mapChange),

---

<div class="post-metadata">

### Author: ![joel](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/j/b9bd4f/32.png) [@joel](https://discourse.vtk.org/u/joel)
#### Post date: [March 10, 2021, 7:26am UTC](https://discourse.vtk.org/t/how-can-i-prevent-zooming-in-out-using-an-interactor-style/5315/2 "2021-03-10T07:26:44Z")

</div>

I figure that there is no such thing as “zoom level” in 3D. The solution I am looking for above is for our app’s 2D mode, where the VTK.js viewer is locked to only move along a vertical axis towards a 2D projected map (kept in sync with OpenLayers 2D map view) thus simulating a 2D viewer. OpenLayers is kept in sync with the event subscriptions mentioned above by a previous developer who left the team and I struggle to wrap my head around VTK.js.

I want to stop VTK.js from moving the camera any closer to the 2D map than a certain limit. IE the distance from the camera to the 2D plane will determine that.

---

<div class="post-metadata">

### Author: ![Forrest](https://discourse.vtk.org/user_avatar/discourse.vtk.org/forrest/32/300_2.png) [@Forrest](https://discourse.vtk.org/u/Forrest)
#### Post date: [March 17, 2021, 7:00pm UTC](https://discourse.vtk.org/t/how-can-i-prevent-zooming-in-out-using-an-interactor-style/5315/3 "2021-03-17T19:00:32Z")

</div>

You will likely have to modify/extend the InteractorStyleTrackballCamera to include a property for maximum zoom, where 2D zoom (using orthographic projection) should depend on the value of the camera’s parallel scale (`camera.getParallelScale()`).

---

<div class="post-metadata">

### Author: ![joel](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/j/b9bd4f/32.png) [@joel](https://discourse.vtk.org/u/joel)
#### Post date: [March 18, 2021, 5:10am UTC](https://discourse.vtk.org/t/how-can-i-prevent-zooming-in-out-using-an-interactor-style/5315/4 "2021-03-18T05:10:21Z")

</div>

Thanks. I was hoping not to “copy and modify” existing modules in VTK.js. We already have a few of those and they are harder to maintain and could break with future updates of VTK.js. When I read through such copied & modified modules by our previous team member, I struggle to wrap my head around it.
