I intend to stick an object to the base after rotation, here’s how I achieve that in R106,
function meshControlChange() {
console.log('mesh rotation:', mesh.rotation);
let meshBox3 = new THREE.Box3().setFromObject(mesh)
const posZ = (meshBox3.max.z - meshBox3.min.z) / 2 // calculate the distance that is equal to the half of the model height
mesh.position.z = posZ //move the model by the distance
meshBox3 = new THREE.Box3().setFromObject(mesh)
const center = meshBox3.getCenter(new THREE.Vector3()) // get the center of the model
const errorVal = center.z - posZ // get the offset value
mesh.position.z = mesh.position.z - errorVal // move the model by the offset value to stick it to the bed
console.log('maxZ:', meshBox3.max.z);
console.log('minZ:', meshBox3.min.z);
console.log('centerZ:', center.z);
render();
}
The problem is, it works in R106 (the picture on the right), however, when I apply the exact code snippet to the version R135, there is still a gap between the model and the bed (the picture on the left).
Any idea would be appreciated.