checkpoint
This commit is contained in:
parent
7ff172f5f3
commit
b6097be0e2
3 changed files with 29 additions and 19 deletions
|
|
@ -308,18 +308,14 @@ const pattern = {
|
||||||
let models = selection.models();
|
let models = selection.models();
|
||||||
let [ cx, cy ] = center;
|
let [ cx, cy ] = center;
|
||||||
for (let model of models) {
|
for (let model of models) {
|
||||||
await api.tool.regroup([ model ]);
|
let pos = model.world_bounds.mid;
|
||||||
let pos = model.group.position().clone();
|
|
||||||
let stepr = (Math.PI * 2) / count;
|
let stepr = (Math.PI * 2) / count;
|
||||||
let modnu = [ model ];
|
let modnu = [ model ];
|
||||||
for (let i=1; i<count; i++) {
|
for (let i=1; i<count; i++) {
|
||||||
let clone = await model.duplicate();
|
let clone = model.duplicate().centerTo({ x:cx, y:cy, z:pos.z });
|
||||||
let [x, y] = base.util.rotate(pos.x - cx, pos.y - cy, stepr * i);
|
clone.rotate(0, 0, stepr * i);
|
||||||
clone.group.centerModels().position(0,0,0);
|
clone.reCenter();
|
||||||
clone.group.rotate(0, 0, stepr * i);
|
|
||||||
clone.group.move(x + cx, y + cy, pos.z);
|
|
||||||
modnu.push(clone);
|
modnu.push(clone);
|
||||||
// pos.z += zdelta;
|
|
||||||
}
|
}
|
||||||
await api.tool.regroup(modnu);
|
await api.tool.regroup(modnu);
|
||||||
}
|
}
|
||||||
|
|
@ -351,14 +347,12 @@ const pattern = {
|
||||||
api.modal.hide();
|
api.modal.hide();
|
||||||
let models = selection.models();
|
let models = selection.models();
|
||||||
for (let model of models) {
|
for (let model of models) {
|
||||||
await api.tool.regroup([ model ]);
|
|
||||||
let pos = model.group.position().clone();
|
|
||||||
let modnu = [ model ];
|
let modnu = [ model ];
|
||||||
for (let i=0; i<x; i++) {
|
for (let i=0; i<x; i++) {
|
||||||
for (let j=0; j<y; j++) {
|
for (let j=0; j<y; j++) {
|
||||||
if (i === 0 && j === 0) continue;
|
if (i === 0 && j === 0) continue;
|
||||||
let clone = await model.duplicate();
|
let clone = await model.duplicate().reCenter();
|
||||||
clone.group.centerModels().position(i * xs + pos.x, -j * ys + pos.y, pos.z);
|
clone.move(i * xs, -j * ys, 0);
|
||||||
modnu.push(clone);
|
modnu.push(clone);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ mesh.group = class MeshGroup extends mesh.object {
|
||||||
get bounds() {
|
get bounds() {
|
||||||
let box3 = new Box3();
|
let box3 = new Box3();
|
||||||
for (let model of this.models) {
|
for (let model of this.models) {
|
||||||
box3.union(model.bounds.translate(model.position()));
|
box3.union(model.world_bounds);
|
||||||
}
|
}
|
||||||
return box3;
|
return box3;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -128,6 +128,10 @@ mesh.model = class MeshModel extends mesh.object {
|
||||||
return this.geometry.boundingBox.clone();
|
return this.geometry.boundingBox.clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get world_bounds() {
|
||||||
|
return this.bounds.translate(this.position());
|
||||||
|
}
|
||||||
|
|
||||||
get matrix() {
|
get matrix() {
|
||||||
return this.mesh.matrixWorld.elements;
|
return this.mesh.matrixWorld.elements;
|
||||||
}
|
}
|
||||||
|
|
@ -218,19 +222,31 @@ mesh.model = class MeshModel extends mesh.object {
|
||||||
// moves mesh center to 0,0,0 via translation then
|
// moves mesh center to 0,0,0 via translation then
|
||||||
// moves mesh object to former bounds center
|
// moves mesh object to former bounds center
|
||||||
reCenter() {
|
reCenter() {
|
||||||
this.log('model-center');
|
this.log('model-recenter');
|
||||||
let pos = this.position();
|
let pos = this.position();
|
||||||
let { mid } = this.bounds;
|
let { mid } = this.bounds;
|
||||||
let moveTo = mid.clone().add(pos);
|
// let moveTo = mid.clone().add(pos);
|
||||||
this.translate(-mid.x, -mid.y, -mid.z);
|
this.translate(-mid.x, -mid.y, -mid.z);
|
||||||
this.position(moveTo.x, moveTo.y, moveTo.z);
|
// this.position(moveTo.x, moveTo.y, moveTo.z);
|
||||||
|
this.position(mid.x + pos.x, mid.y + pos.y, mid.z + pos.z);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
// preserves world location while updating mesh for rotation and scaling
|
// preserves world location while updating mesh for rotation and scaling
|
||||||
// moves mesh center to x,y,z via translation then
|
// moves mesh center to current target offset via translation then
|
||||||
// moves mesh object to former bounds center
|
// moves mesh object center to target
|
||||||
centerTo(pos) {
|
centerTo(to) {
|
||||||
|
this.log('model-centerto', to);
|
||||||
|
let pos = this.position();
|
||||||
|
let { mid } = this.bounds;
|
||||||
|
let abs = this.world_bounds.mid;//mid.clone().add(pos);
|
||||||
|
this.translate(
|
||||||
|
-mid.x + (abs.x - to.x),
|
||||||
|
-mid.y + (abs.y - to.y),
|
||||||
|
-mid.z + (abs.z - to.z),
|
||||||
|
);
|
||||||
|
this.position(to.x, to.y, to.z);
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
updateBounds() {
|
updateBounds() {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue