diff --git a/src/mesh/api.js b/src/mesh/api.js index 2dfa4407..9c615224 100644 --- a/src/mesh/api.js +++ b/src/mesh/api.js @@ -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; }, diff --git a/src/mesh/object.js b/src/mesh/object.js index a49458a1..94f2976b 100644 --- a/src/mesh/object.js +++ b/src/mesh/object.js @@ -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) {