How to keep everything in view

A Quick Question…

How would I go about setting up a camera that keeps say a stack of boxes within view?

Ie, how do i know how far the camera needs to be put back to see the whole - random - stack ?

i guess i also need to keep the aspect ratio in mind. Can we even set aspect ratio’s for camera’s? i’d want a taller rectangle rendertarget.

I would think maybe i can put a scene root ( or just get the z coordinate) at the bottom and top of the stack, then trace from these with an angle (half the view frustum ) toward each other, where they meet is my camera location… But how to set up the blueprint for this, can i even get the camera frustum angle ?

Any Idea’s ?

Well to address one of the things you mention: Yes, you can set aspect ratio on a perspective camera.