# Zoom According to Mesh's Local Coordinate

Hello to everyone.

I have a question that I believe is simple. Is Superman (Wingnut) around here?

Here’s what I want to do:

I have complex meshes. I want the camera to zoom with animation when the user clicks. The coordinates of the meshes are variable. So according to the local coordinates the camera needs to stand x units away from the z axis. But I failed. Is there anyone who can help?

I’m leaving a sample scene here: https://www.babylonjs-playground.com/#LXZPJK#127

is that help ?
https://www.babylonjs-playground.com/#LXZPJK#128

1 Like

You’re perfect

There’s a little missing. I want this to be animated

1 Like
2 Likes

Crazy. There’s an art here

Let me explain. When the user clicks on any of the 3 planes, this plane will be selected as the target and the camera will approach the plane slowly and stop at a certain distance. No matter what you click in the camera, you will approach the mesh with a zoom animation and stop in front of it.

The things you do are perfect and can help. But what I want is written above.

I’m grateful to you for trying to help me patiently.

2 Likes

for make animation i write wind function

for example when you wanna set position like this

``````a.position = target;
``````

you can use wind for do it by steps

1. change them to details number set value

a.position.x = target.x;
a.position.y = target.y;
a.position.z = target.z;

2. use wind for set

var wind_x = new wind( {
steps : 100 ,
fun : function(val) {
a.position.x = val;
}} );

wind_x.go(target.x);
// repeat that for y , z

1 Like

Not a genius solution like that of @nasimiasl but it is an alternative https://www.babylonjs-playground.com/#LXZPJK#127

1 Like

what I wanted to do was something like this. But he behaves differently in complex meshes. I was looking for another way

https://www.babylonjs-playground.com/#LXZPJK#133

I’m trying to get something out of the nasimiasl’s answers right now. As a different method.

1 Like

Sorry I forgot to post the PG along with my answer. Have added it now https://www.babylonjs-playground.com/#LXZPJK#127

Are there any method to create the same but with a gltf or obj file?