I know how to fit an object to the window if it is axis aligned. Say for example you are looking directly at a playing card.
If the object is rotated about the Y axis - say 45 degrees. The “footprint or silhouette” of the object has changed - is there a similar formula to take account of that?
Hey, I think you can use axis aligned bounding box (AABB), then frame the object by using min, max point of the bounds. I’ve done something similar in unity3d, which dynamically frame a target object with their bounds to fill the screen, but I haven’t done it in threejs so the following info might not be correct.
There seems a BufferGeometry.boundingBox attribute at geometry level but it seems not updated or at least I was not able to get the updated the bounds by calling BufferGeometry.computeBoundingBox as the documentation suggested after I transform the mesh.
I did a get around to get the bounding box value by using Box3, something like this:
// afetr you transform your mesh
const bounds = new Box3().setFromObject(mesh);
// use bounds.min & bounds.max to compute frustum