threejs finds the bounding box of the object in the target coordinate system

Find the bounding box of object1 in the coordinate system of object2

function utils_getBox(object1,object2) {
    var matrix = new THREE.Matrix4().compose(object2.position, object2.quaternion, object2.scale);
    var scale = object2.scale.clone();
    var rotation = object2.rotation.clone();
    new THREE.Matrix4().decompose(object2.position, object2.quaternion, object2.scale);
    var parent = object2.parent;
    object2.parent = null;
    object2.updateMatrixWorld(true);
    var box = new THREE.Box3().setFromObject(object1);
    object2.parent = parent;
    matrix.decompose(object2.position, object2.quaternion, object2.scale);
    object2.updateMatrixWorld(true);
    return box;
}

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324441727&siteId=291194637