Adapt camera near plane dimension

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.

Sorry for the question: I have the solution with a little help of basic trigonometry is just computing the distance of one side of a triangle knowing on of its side and one of it angle :wink:

1 Like

Sounds like a good approach :slight_smile: