How can I place Camera to show all objects?

It’s actually not that hard. And it gets easier when you make a little sketch first:

Let’s assume you have computed the bounding sphere “BS” of your collective geometry, having a radius of “r”. Here’s how to do that.

Two cases to consider:

  1. find the minimum Radius “R” for a given “fov”
  2. find the minimum “fov” for a given radius “R”

which are guaranteed to show all that’s inside of the bounding sphere silhouette.

The respective “minimum” is given by the requirement, that the frustum emanating from the camera just barely touches (tangent condition!) the bounding sphere “BS”. The tangent condition implies a right angle between the red BS-sphere radius “r” and the ray “L” touching the sphere.

It’s required, that the bounding sphere “BS” radius “r” is always known.

We can infer, that L * L + r * r = R * R
We can also infer, that R * sin ( fov / 2 ) = r

That’s two equations having two unknows, so it’s not hopeless. :wink:

Solving for case 1:

R ≥ r / sin( fov / 2 )

Solving for case 2:

fov ≥ 2 * asin( r / R )

That’s about it.