fix rotation to world axis

This commit is contained in:
Stewart Allen 2021-12-31 16:12:37 -05:00
commit af6ae4ed32
2 changed files with 8 additions and 2 deletions

View file

@ -51,8 +51,7 @@ let selection = {
rotate(dx = 0, dy = 0, dz = 0) {
for (let s of selected) {
let { x, y, z } = s.rotation();
s.rotation(x + dx, y + dy, z + dz);
s.rotate(dx, dy, dz);
}
return selection;
},

View file

@ -57,6 +57,7 @@ mesh.object = class MeshObject {
moto.Space.update();
}
// use with caution. frames of reference interfere.
rotation() {
let rot = this.object().rotation;
if (arguments.length === 0) {
@ -66,6 +67,12 @@ mesh.object = class MeshObject {
moto.Space.update();
}
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);
}
position() {
let pos = this.object().position;
if (arguments.length === 0) {