explore rotation and bounds

This commit is contained in:
Stewart Allen 2022-01-01 10:44:06 -05:00
commit 8cd2a22a54
3 changed files with 22 additions and 2 deletions

View file

@ -127,7 +127,12 @@ broker.subscribe('space_init', data => {
let q = new THREE.Quaternion();
// find intersecting point, look "up" on Z and rotate to face that
q.setFromUnitVectors(int.face.normal, new THREE.Vector3(0,0,-1));
// let e = new THREE.Euler().setFromQuaternion(q);
// let n = int.face.normal;
// console.log({n,q,e});
// group.rotation(e.x, e.y, e.z);
group.qrotate(q);
group.floor();
} else {
api.selection.toggle(model.group);
}

View file

@ -78,6 +78,13 @@ let selection = {
return selection;
},
qrotate(q) {
for (let s of selected) {
s.qrotate(q);
}
return selection;
},
scale(dx = 0, dy = 0, dz = 0) {
for (let s of selected) {
let { x, y, z } = s.scale();
@ -192,9 +199,12 @@ let util = mesh.util = {
let box = new THREE.Box3();
if (Array.isArray(object)) {
for (let o of object) {
box.union(new THREE.Box3().setFromObject(
box.expandByObject(
o instanceof mesh.object ? o.object() : o
));
);
// box.union(new THREE.Box3().setFromObject(
// o instanceof mesh.object ? o.object() : o
// ));
}
} else if (object) {
box.setFromObject(

View file

@ -69,16 +69,21 @@ mesh.object = class MeshObject {
}
rot.set(...arguments);
moto.Space.update();
return this;
}
rotate(x = 0, y = 0, z = 0) {
if (x) this.object().rotateOnWorldAxis(new THREE.Vector3(1,0,0), x);
if (y) this.object().rotateOnWorldAxis(new THREE.Vector3(0,1,0), y);
if (z) this.object().rotateOnWorldAxis(new THREE.Vector3(0,0,1), z);
moto.Space.update();
return this;
}
qrotate(quaternion) {
this.object().setRotationFromQuaternion(quaternion);
moto.Space.update();
return this;
}
position() {