Place object on the "floor" after rotate it

In our project, we have a tool to place the object on the “floor” which simply does the following.

let size = new THREE.Vector3();
let box = new THREE.Box3().setFromObject(selected_obj, true);
selected_obj.position.z = box.getSize(size).z * 0.5;
// (In our project axis are changed, the default UP is Z axis ( THREE.Object3D.DefaultUp.set(0, 0, 1) ) )

This feature seems to be not accurate after a rotation is made but I don’t know if I’m doing something wrong or I’m lefting some code after rotate.

In the following video I show you the real case. After doing the rotation, if I call the “floor” action, then is not correctly placed.

Which would be the best way to do this?

The video doesn’t seem to load.

Box3 is axis-aligned (ie. cannot be rotated, with an exception of OBB.), so rotation does indeed break the measurements. You may want to unset the rotation for the measurement, then set it back again afterwards.

Thank you, I’ve fixed the video.

So, if an object is rotated, then the use of the object.position is not correct anymore?

I can’t unset the rotation due sizes will not be correct once the rotation is done.