I have a geometry (box) in the scene and a camera pointing to it.
I would like to have the view of the camera exactly fit the size of one face of the geometry.
How can I compute the distance the camera must have from that shape for the view to fit exaclty the size of the geometry’s face?
The example is depicted below:
example here
What I do now is using the setFrustumPerspective() and adapt the Aspect ratio to the aspect of the geometry and manually trying to set the distance to fit the size of the shape.