K, let me try and make that a bit more clear.

1) You evaluate the overall 3D bounding box of the container having all your
objects.
2) From this box you extract 8 3D points corresponding to the corners of the
bounding box.
3) You project these corners to screen coordinates.
4) Of all the projected coordinates, you extract the max Y and min Y values,
and then calculate the distance between them, the yRange.
5) Now calculate a ratio, something like yRange/stage.stageHeight.
6) Use the ratio to calculate how much to move the camera from or towards
the target, something like targetCameraDistanceToObject =
1.5*currentCameraDistanceToObject*ratio.

Note that the apparently arbitrary 1.5 value has to do with the camera's
zoom and focus values.
There might be a simpler way, but this worked like a charm for me.

hth!

Reply via email to