fix matrix cache corruption during reload. center models on import

This commit is contained in:
Stewart Allen 2022-01-11 10:54:31 -05:00
commit f53a9752f8
4 changed files with 34 additions and 19 deletions

View file

@ -103,10 +103,10 @@ mesh.model = class MeshModel extends mesh.object {
meh.renderOrder = 1;
// center vertices then restore mesh object position
// still this doesn't work. scale broken for bounding boxes
// let mid = meh.getBoundingBox().mid;
// geo.moveMesh(-mid.x, -mid.y, -mid.x);
// geo.computeBoundingBox();
// this.move(mid.x, mid.y, mid.x);
let { mid } = meh.getBoundingBox();
geo.moveMesh(-mid.x, -mid.y, -mid.z);
geo.computeBoundingBox();
this.move(mid.x, mid.y, mid.z);
// sets fallback opacity for wireframe toggle
this.opacity(1);
// this ref allows clicks to be traced to models and groups

View file

@ -66,21 +66,23 @@ mesh.object = class MeshObject {
return this;
}
floor() {
let b = this.bounds;
this.move(0, 0, -b.min.z);
floor(clazz) {
if (!clazz || this instanceof clazz) {
let b = this.bounds;
this.move(0, 0, -b.min.z);
}
return this;
}
center(bounds) {
let b = bounds || this.bounds;
this.move(-b.center.x, -b.center.y, -b.center.z);
this.move(-b.mid.x, -b.mid.y, -b.mid.z);
return this;
}
centerXY(bounds) {
let b = bounds || this.bounds;
this.move(-b.center.x, -b.center.y, 0);
this.move(-b.mid.x, -b.mid.y, 0);
return this;
}