Orthographic camera zoom closer to mesh

Hi,

I use an arc rotate camera in orthographic mode, I have already created a function that adjusts the ortho values to fit the size of the canvas so that the meshes don’t get distorted. You can see that by this PG

I know that is possible to “zoom” on the target by divide the otho values, e.g. with this PG, but i need the zoom factor to be calculated to depend of the mesh size to make the camera fit to it.

Did someone have any idea ?
Thanks by advance

why not simply setting the ortho values close to the bounding info of your mesh ?

why not simply setting the ortho values close to the bounding info of your mesh ?

I use my autoResize function to keep the shapes proportional.

But I took notes of your suggestion and I get a solution :

  • I use framing behavior to zoomOnMesh
  • Then i get the size of the mesh by it’s bounding info to start the zoomFactor (so at this step the mesh is fully displayed)
  • I apply a zoom out value to the ortho values by a multiplcation instead

It does this : https://playground.babylonjs.com/#9GTD0W#11

Then, for my personal needs, i did this PG were the zoom takes effect on an enclosing mesh of the 2 others

EDIT (26/09/22) :
I made some corrections on the zoom factor calculation to really made it depend of the target : https://playground.babylonjs.com/#9GTD0W#15