threejs求物体在目标坐标系下的包围盒

2019独角兽企业重金招聘Python工程师标准>>> hot3.png

求object1在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;
}

转载于:https://my.oschina.net/u/3407699/blog/1618847

你可能感兴趣的:(threejs求物体在目标坐标系下的包围盒)