normalize util.bound to Box3 extensions
This commit is contained in:
parent
1cdfcab55f
commit
b8877f1225
4 changed files with 7 additions and 8 deletions
|
|
@ -75,9 +75,7 @@
|
||||||
this.boundingBox = null;
|
this.boundingBox = null;
|
||||||
this.computeBoundingBox();
|
this.computeBoundingBox();
|
||||||
}
|
}
|
||||||
let bbox = this.boundingBox;
|
return this.boundingBox;
|
||||||
// bbox.dim = bbox.max.clone().sub(bbox.min);
|
|
||||||
return bbox;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
BP.moveMesh = function(x = 0, y = 0, z = 0) {
|
BP.moveMesh = function(x = 0, y = 0, z = 0) {
|
||||||
|
|
|
||||||
|
|
@ -396,12 +396,12 @@ let util = mesh.util = {
|
||||||
z: box.max.y
|
z: box.max.y
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
bnd.size = {
|
bnd.size = bnd.dim = {
|
||||||
x: bnd.max.x - bnd.min.x,
|
x: bnd.max.x - bnd.min.x,
|
||||||
y: bnd.max.y - bnd.min.y,
|
y: bnd.max.y - bnd.min.y,
|
||||||
z: bnd.max.z - bnd.min.z
|
z: bnd.max.z - bnd.min.z
|
||||||
};
|
};
|
||||||
bnd.center = {
|
bnd.center = bnd.mid = {
|
||||||
x: (bnd.max.x + bnd.min.x) / 2,
|
x: (bnd.max.x + bnd.min.x) / 2,
|
||||||
y: -(bnd.max.y + bnd.min.y) / 2,
|
y: -(bnd.max.y + bnd.min.y) / 2,
|
||||||
z: (bnd.max.z + bnd.min.z) / 2
|
z: (bnd.max.z + bnd.min.z) / 2
|
||||||
|
|
|
||||||
|
|
@ -103,6 +103,7 @@ mesh.model = class MeshModel extends mesh.object {
|
||||||
meh.castShadow = true;
|
meh.castShadow = true;
|
||||||
meh.renderOrder = 1;
|
meh.renderOrder = 1;
|
||||||
// center vertices then restore mesh object position
|
// center vertices then restore mesh object position
|
||||||
|
// still this doesn't work. scale broken for bounding boxes
|
||||||
// let mid = meh.getBoundingBox().mid;
|
// let mid = meh.getBoundingBox().mid;
|
||||||
// geo.moveMesh(-mid.x, -mid.y, -mid.x);
|
// geo.moveMesh(-mid.x, -mid.y, -mid.x);
|
||||||
// this.move(mid.x, mid.y, mid.x);
|
// this.move(mid.x, mid.y, mid.x);
|
||||||
|
|
|
||||||
|
|
@ -145,10 +145,10 @@ mesh.object = class MeshObject {
|
||||||
world.remove(helper);
|
world.remove(helper);
|
||||||
}
|
}
|
||||||
if (this._showBounds) {
|
if (this._showBounds) {
|
||||||
let { center, size } = this.bounds;
|
let { mid, dim } = this.bounds;
|
||||||
let b3 = new THREE.Box3().setFromCenterAndSize(
|
let b3 = new THREE.Box3().setFromCenterAndSize(
|
||||||
new THREE.Vector3(center.x, center.y, center.z),
|
new THREE.Vector3(mid.x, mid.y, mid.z),
|
||||||
new THREE.Vector3(size.x, size.y, size.z)
|
new THREE.Vector3(dim.x, dim.y, dim.z)
|
||||||
);
|
);
|
||||||
let helper = this._boundsBox = new THREE.Box3Helper(b3, 0x555555);
|
let helper = this._boundsBox = new THREE.Box3Helper(b3, 0x555555);
|
||||||
world.add(helper);
|
world.add(helper);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue