Within my scene, there are numerous Object3D entities housing various blocks, cylinders, and meshes. Alongside this, I utilize a perspective camera along with trackball controls. What I am seeking is a method to adjust the camera's position without altering the FOV or angle, while ensuring all objects remain visible on the screen. Although I've managed to achieve this by utilizing predefined views (top, bottom, left, right) based on the scene's bounding box, I require a solution that works irrespective of the camera's angle due to potential user rotations using trackball controls.
If only there was a way to calculate a 2D boundary rectangle taking into account the camera's position, target, and the object list - then I believe it could be implemented. Alas, I'm struggling to find resources detailing how to accomplish this task.
The desired functionality would operate as follows: With an assortment of objects within the scene, the user manipulates the camera angle via mouse movements and subsequently clicks on a "Zoom All" button. At this point, the camera would adjust, either zooming in or out (keeping FOV constant), to accommodate all objects on the screen.