Zoom According to Mesh's Local Coordinate

Hello to everyone.

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

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 ?

1 Like

You’re perfect :slight_smile:

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

1 Like




https://www.babylonjs-playground.com/#LXZPJK#132 :smiley:


Crazy. There’s an art here :sweat_smile::sweat_smile::sweat_smile:

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. :hugs: But what I want is written above. :confused:

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


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;
    }} );

    // 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 :relaxed:


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

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?