Adjust camera Z dynamically with canvas updates

Hey community,

Just wondering, is there a way to change camera Z translation (or arcRotateCamera radius equivalently) dynamically based on canvas size?

For example:

I have an animated camera imported from a gltf file. I hope except for the close-up shot, the entire teapot should be always inside of canvas framing.

Otherwise, if I change the canvas width and height, the render will look like this:


You can see the left and right are cropped and out of canvas frames.

What I want is very similar to this feature:
https://doc.babylonjs.com/features/featuresDeepDive/behaviors/cameraBehaviors#framing-behavior

Just a way to keep mesh always inside of frame.

Many thanks,
Tawibox

You could take model on how it is done in framing behavior?

@Evgeni_Popov

Ah thats a great point. Thank you! I will look into it!!