Fit rotated object to a window

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

Screen Shot 2022-02-04 at 9.19.26 PM
Hope this helps