# Correctly zoom camera in and out of layer texture

**URL:** <https://forum.babylonjs.com/t/correctly-zoom-camera-in-and-out-of-layer-texture/54275>\
**Category:** Questions\
**Created:** [October 21, 2024, 8:35pm UTC](https://forum.babylonjs.com/t/correctly-zoom-camera-in-and-out-of-layer-texture/54275 "2024-10-21T20:35:04Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![chris.wolff](https://avatars.discourse-cdn.com/v4/letter/c/4bbf92/32.png) [@chris.wolff](https://forum.babylonjs.com/u/chris.wolff)\
**Post date:** [October 21, 2024, 8:35pm UTC](https://forum.babylonjs.com/t/correctly-zoom-camera-in-and-out-of-layer-texture/54275/1 "2024-10-21T20:35:04Z")

</div>

Currently trying to scale a layer’s texture in and out with the camera but don’t know the correct math to do so. See [https://playground.babylonjs.com/#K9MWF6#58](https://playground.babylonjs.com/#K9MWF6#58)

```auto
//zoom
scene.activeCamera.onProjectionMatrixChangedObservable.add(function() {
    const newWidth = camera.orthoRight - camera.orthoLeft;
    const widthScale = newWidth / width;
    layer.scale.x = widthScale;

    const newHeight = camera.orthoTop - camera.orthoBottom;
    const heightScale = newHeight / height;

    layer.scale.y = heightScale;

    // what is the correct way to scale the layer's texture?
    layer.texture.uScale = 1/ widthScale;
    layer.texture.vScale = 1/ heightScale;
});

```

---

<div class="post-metadata">

**Author:** ![roland](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/roland/32/38940_2.png) [@roland](https://forum.babylonjs.com/u/roland)\
**Post date:** [October 22, 2024, 12:48am UTC](https://forum.babylonjs.com/t/correctly-zoom-camera-in-and-out-of-layer-texture/54275/2 "2024-10-22T00:48:35Z")

</div>

> [@Orthographic camera zooming](https://forum.babylonjs.com/t/orthographic-camera-zooming/34629):
>
> Hi! I needed to add an orthographic view to my project with zoom support. I am using an ArcRotateCamera. It is known that the orthographic mode doesn’t honor the arc camera’s radius property and one needs to alter the orthoXXX properties of the camera to zoom in or out the view. I’ve found some solutions on the forum. All of these solutions uses mouse scroll-wheel events to mimic the zooming functionality of the arc camera. I didn’t find these solutions good. You may alter the radius property…

This might help you!

Added to your PG: [https://playground.babylonjs.com/#K9MWF6#59](https://playground.babylonjs.com/#K9MWF6#59)
