Invalid bounds generated for some orientations

I’m using Box3.setFromObject() to compute bounding boxes for objects. The returned bounds are correct for some orientations and incorrect for others. I’ve been chasing this for two days and not making any progress. Any ideas or help greatly appreciated.

Box3.setFromObject() and Box3.expandByObject() both say in the function description:

The function may result in a larger box than strictly necessary.

What are the circumstances that cause this? It’s not obvious to me from reading Box3’s code.

Is there a way to get a strictly accurate bounding box for an object?

for my own purposes, I’ve modified the code from this forum post and encapsulated it into a standalone function that computes a proper bounding box.

the proposed code in the post also clones the position attribute, so it’s expensive and slow for larger meshes. I hope a proper fix can make it back into the project at some point. I regret that I don’t know the code (or math behind it) well enough to take a stab at this.