# Zoom via Button?

**URL:** <https://forum.babylonjs.com/t/zoom-via-button/34377>\
**Category:** Questions\
**Tags:** react\
**Created:** [September 30, 2022, 3:20pm UTC](https://forum.babylonjs.com/t/zoom-via-button/34377 "2022-09-30T15:20:21Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![Takemura](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/takemura/32/25836_2.png) [@Takemura](https://forum.babylonjs.com/u/Takemura)\
**Post date:** [October 4, 2022, 12:51pm UTC](https://forum.babylonjs.com/t/zoom-via-button/34377/5 "2022-10-04T12:51:18Z")

</div>

I am not too much into react, but the smooth camera motion was solved here:

> [@How to change camera location and rotation smoothly](https://forum.babylonjs.com/t/how-to-change-camera-location-and-rotation-smoothly/26370/4):
>
> Looking up the starting value is a little trickier when the target property is nested (e.g. “rotation.x”). Here’s code to do it that I derived from the RuntimeAnimation’s [\_preparePath](https://github.com/BabylonJS/Babylon.js/blob/d9457c9f840a62c6fbdec32226ec80d18333608e/src/Animations/runtimeAnimation.ts#L253) function. slight_smile Edit: couldn’t resist simplifying it a little more. beers

If I understand your first problem correctly, you want to change 1 to distance between camera and mesh? Then you could simply use:

```auto
BABYLON.Vector3.Distance(camera.position, mesh.absolutePosition)

```

Regarding ArcRotate- and “other”-Cameras you might want to have a look at this, how position and rotation is set when you switch camera:

> [@Same camera on switch](https://forum.babylonjs.com/t/same-camera-on-switch/34373/4):
>
> Corresponding to your case, I would set target of arc camera as target of universal: universalCamera.setTarget(arcCamera.target) In case of switching from arc to universal: arcCamera.setTarget(universalCamera.getFrontPosition(arcCamera.radius)) The Playground: Note: There might be special edge case on arcCamera.beta === 0, so that arc camera flips, because it only has an upVector and no forwardVector.

---

_[View the full topic](https://forum.babylonjs.com/t/zoom-via-button/34377)._
