From bd2181ebce1472d85ed9e96d5c51f1cef1b2d4d0 Mon Sep 17 00:00:00 2001 From: Amanda Ghassaei <amandaghassaei@gmail.com> Date: Fri, 6 Mar 2015 21:03:45 -0500 Subject: [PATCH] freeform working --- js/fea/DmaCell.js | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/js/fea/DmaCell.js b/js/fea/DmaCell.js index 8c22bb7c..4a296de7 100644 --- a/js/fea/DmaCell.js +++ b/js/fea/DmaCell.js @@ -185,22 +185,18 @@ DMACell.prototype.destroy = function(){ DMAFreeFormOctaCell.prototype._doMeshTransformations = function(mesh){ - var quaternion = new THREE.Quaternion(); var direction = this.parentDirection.clone(); var zAxis = new THREE.Vector3(0,0,1); - quaternion.setFromUnitVectors(zAxis, direction); - - -// direction.sub(zAxis); -// if (direction.length() < 0.1){ -// console.log("here"); -// zAxis.applyQuaternion(this.parentQuaternion); -// var zRot = new THREE.Quaternion().setFromAxisAngle(new THREE.Vector3(0,0,1), Math.PI); -// quaternion = new THREE.Quaternion().multiplyQuaternions(quaternion, zRot); -// } - + zAxis.applyQuaternion(this.parentQuaternion); + var quaternion = new THREE.Quaternion().setFromUnitVectors(zAxis, direction); + quaternion.multiply(this.parentQuaternion); + + if (direction.sub(zAxis).length() < 0.1){ + var zRot = new THREE.Quaternion().setFromAxisAngle(zAxis, Math.PI); + zRot.multiply(quaternion); + quaternion = zRot; + } -// mesh.rotation.order = 'YZX'; var eulerRot = new THREE.Euler().setFromQuaternion(quaternion); mesh.rotation.set(eulerRot.x, eulerRot.y, eulerRot.z); }; -- GitLab