Camera positions and buttons

Hello everyone (exuse me for my english) and i’m newbie in babylon :slight_smile:

I want to move camera (Arch rotate) from one model to another, models are external files in the same position (merged into one gltf file) . Models are changing, when i press button (i made this by filtering mesh name) and pointerClickObservable.

I need to keep same camera view and navigate to the front face of the object. I tried with Framing behavior, but if i click on button, camera restart every time to the same position (again in need to keep camera movement with previous camera position) and navigate to the another model (to the front face) - models are in different sizes.

Simmilar example:

I have anoter subquestion: how to focus camera radius on mesh size. Because if I use object position (X,Y,Z) camera don’t now how to scale radius to the object size?

Thank you very much!

Hey @pantrej

Welcome to the Babylon Family!!! It’s sincerely great to have you here!

So if I understand your question correctly, you want to move an arcRotate camera to a new location, without changing it’s rotations.

This document should help: Camera Introduction | Babylon.js Documentation

The simple way to tackle this is to change the target of the arcRotate camera, while preserving the alpha and beta rotations.

The target will move what the camera is aimed at, the alpha and beta rotations will control where in space the camera is located to point at the target. So you would want to change the target to be in the same position as your new model, but the alpha and beta rotations will need to be figured out to ensure the camera is facing the front face of the model you want to look at.

Furthermore (we’re getting a little more advanced here) you’ll likely want to animate the target of the arc rotate camera over time so that it is a nice smooth transition.

Here is a small playground example that you can reference.

Notice that when pressing the “space” bar, 3 different animations will be simultaneously created and executed. 1 that animated the target of the arcRotate camera, 1 that animates the alpha angle, and 1 that animates the beta angle.

I hope this is somewhat helpful to get you to where you’re going.


Thank you very much! I’ll try your idea :slight_smile: