explore rotation and bounds
This commit is contained in:
parent
d42db44009
commit
8cd2a22a54
3 changed files with 22 additions and 2 deletions
|
|
@ -127,7 +127,12 @@ broker.subscribe('space_init', data => {
|
||||||
let q = new THREE.Quaternion();
|
let q = new THREE.Quaternion();
|
||||||
// find intersecting point, look "up" on Z and rotate to face that
|
// find intersecting point, look "up" on Z and rotate to face that
|
||||||
q.setFromUnitVectors(int.face.normal, new THREE.Vector3(0,0,-1));
|
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.qrotate(q);
|
||||||
|
group.floor();
|
||||||
} else {
|
} else {
|
||||||
api.selection.toggle(model.group);
|
api.selection.toggle(model.group);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -78,6 +78,13 @@ let selection = {
|
||||||
return selection;
|
return selection;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
qrotate(q) {
|
||||||
|
for (let s of selected) {
|
||||||
|
s.qrotate(q);
|
||||||
|
}
|
||||||
|
return selection;
|
||||||
|
},
|
||||||
|
|
||||||
scale(dx = 0, dy = 0, dz = 0) {
|
scale(dx = 0, dy = 0, dz = 0) {
|
||||||
for (let s of selected) {
|
for (let s of selected) {
|
||||||
let { x, y, z } = s.scale();
|
let { x, y, z } = s.scale();
|
||||||
|
|
@ -192,9 +199,12 @@ let util = mesh.util = {
|
||||||
let box = new THREE.Box3();
|
let box = new THREE.Box3();
|
||||||
if (Array.isArray(object)) {
|
if (Array.isArray(object)) {
|
||||||
for (let o of object) {
|
for (let o of object) {
|
||||||
box.union(new THREE.Box3().setFromObject(
|
box.expandByObject(
|
||||||
o instanceof mesh.object ? o.object() : o
|
o instanceof mesh.object ? o.object() : o
|
||||||
));
|
);
|
||||||
|
// box.union(new THREE.Box3().setFromObject(
|
||||||
|
// o instanceof mesh.object ? o.object() : o
|
||||||
|
// ));
|
||||||
}
|
}
|
||||||
} else if (object) {
|
} else if (object) {
|
||||||
box.setFromObject(
|
box.setFromObject(
|
||||||
|
|
|
||||||
|
|
@ -69,16 +69,21 @@ mesh.object = class MeshObject {
|
||||||
}
|
}
|
||||||
rot.set(...arguments);
|
rot.set(...arguments);
|
||||||
moto.Space.update();
|
moto.Space.update();
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
rotate(x = 0, y = 0, z = 0) {
|
rotate(x = 0, y = 0, z = 0) {
|
||||||
if (x) this.object().rotateOnWorldAxis(new THREE.Vector3(1,0,0), x);
|
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 (y) this.object().rotateOnWorldAxis(new THREE.Vector3(0,1,0), y);
|
||||||
if (z) this.object().rotateOnWorldAxis(new THREE.Vector3(0,0,1), z);
|
if (z) this.object().rotateOnWorldAxis(new THREE.Vector3(0,0,1), z);
|
||||||
|
moto.Space.update();
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
qrotate(quaternion) {
|
qrotate(quaternion) {
|
||||||
this.object().setRotationFromQuaternion(quaternion);
|
this.object().setRotationFromQuaternion(quaternion);
|
||||||
|
moto.Space.update();
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
position() {
|
position() {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue