# Is there an easy way to limit the zoom in/out on the camera for the viewer?

**URL:** <https://forum.techsoft3d.com/t/is-there-an-easy-way-to-limit-the-zoom-in-out-on-the-camera-for-the-viewer/5020>\
**Category:** HOOPS Visualize Web\
**Created:** [December 2, 2025, 3:23pm UTC](https://forum.techsoft3d.com/t/is-there-an-easy-way-to-limit-the-zoom-in-out-on-the-camera-for-the-viewer/5020 "2025-12-02T15:23:52Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mark.aronin](https://avatars.discourse-cdn.com/v4/letter/m/b782af/32.png) [@mark.aronin](https://forum.techsoft3d.com/u/mark.aronin)\
**Post date:** [December 2, 2025, 3:23pm UTC](https://forum.techsoft3d.com/t/is-there-an-easy-way-to-limit-the-zoom-in-out-on-the-camera-for-the-viewer/5020/1 "2025-12-02T15:23:52Z")

</div>

I tried looking for something simple in hoops but could not find anything. Do I have to like create a custom operator or something and capture mouse events and restrict zoom that way?

Seems like something simple that Hoops should provide for the camera or the view…

Thanks!

---

<div class="post-metadata">

**Author:** ![tino](https://avatars.discourse-cdn.com/v4/letter/t/9dc877/32.png) [@tino](https://forum.techsoft3d.com/u/tino)\
**Post date:** [December 2, 2025, 11:01pm UTC](https://forum.techsoft3d.com/t/is-there-an-easy-way-to-limit-the-zoom-in-out-on-the-camera-for-the-viewer/5020/2 "2025-12-02T23:01:52Z")

</div>

Hello @mark.aronin,

The camera behaves dynamically when zooming because its position, width and height adjust together. This coordinated change helps prevent artefacts such as extreme pincushion distortion. There isn’t a **built-in** setting to clamp zooming.

That said, I think it’s possible to leverage the [camera](https://docs.techsoft3d.com/hoops/visualize-web/api_ref/viewing/interfaces/CallbackMap.html#CallbackMap.camera) callback to limit the zoom based on the value of the camera width attribute. Below is a quick example:

```auto
let viewer = hwv;
let widthLimit, heightLimit;
let multiplier = 0.1; //some arbitrary limit based on the initial camera

let initialCam = viewer.view.getCamera();
widthLimit = initialCam.getWidth() * multiplier;

// holds the last good camera
let lastValidCamera = null;

function clampCameraZoom(camera, view) {
    const width = camera.getWidth();

    // Check camera width attribute
    if (width < widthLimit) {
        if (lastValidCamera) {
            let restoreCam = new Communicator.Camera();
            restoreCam = lastValidCamera.copy();
            view.setCamera(restoreCam);
        }
        return;
    }

    /// STore the last good camera
    let stored = new Communicator.Camera();
    stored = camera.copy();
    lastValidCamera = stored;
}

//set camera callback
hwv.setCallbacks({
    camera: clampCameraZoom
});

```
