How to limit orthographic camera zoom

Hi,

I have followed this tread to be able to zoom with orthographic camera: Using orthographic camera mode with ArcRotateCamera - #4 by sebavan

But now I’m looking for a way to limit the zoom so that the camera wont go through the mesh.
Playground: https://www.babylonjs-playground.com/#KUM5WC#27
Thanks.

Hi tynail,

Does this achieve the effect you’re going for?

I added minZoomScale and maxZoomScale (lines 16 and 17) and a clamping mechanism (line 29) to prevent zoomScale from going outside of a predefined range. If you want to be able to zoom more or less, you should just be able to change those values to adjust the allowed range of zoom levels. Hope this helps, and best of luck!

7 Likes

Work like a charm!
Thank you very much as always, wonderful community!
Have a good day sir!

3 Likes

How to make the gizmo zooms when the mouse wheel is zooming.

I am not sure to understand the question, could you provide a repro of what you are trying to achieve in the playground ?

cc @Cedric

Maybe you need to set this property to false, so Gizmo will change size depending on the camera:

2 Likes

hi,

I made an improvement that i think it’s clearer : https://www.babylonjs-playground.com/#KUM5WC#71