From 9b249145aabdd0ac6a4ea52fcb59eaa28cf51922 Mon Sep 17 00:00:00 2001 From: Amanda Ghassaei <amandaghassaei@gmail.com> Date: Fri, 5 Jun 2015 21:59:03 -0700 Subject: [PATCH] stacked octas --- js/cells/TetraStackedCell.js | 18 ++++++++++++++++-- js/lattice/TetraStackedLattice.js | 8 -------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/js/cells/TetraStackedCell.js b/js/cells/TetraStackedCell.js index e3fae8f4..29be42c5 100644 --- a/js/cells/TetraStackedCell.js +++ b/js/cells/TetraStackedCell.js @@ -9,7 +9,8 @@ define(['underscore', 'three', 'threeModel', 'lattice', 'appState', 'cell'], var unitGeo = new THREE.TetrahedronGeometry(Math.sqrt(3/8)); unitGeo.applyMatrix(new THREE.Matrix4().makeRotationZ(Math.PI/4)); unitGeo.applyMatrix(new THREE.Matrix4().makeRotationX((Math.PI-Math.atan(2*Math.sqrt(2)))/2)); - unitGeo.applyMatrix(new THREE.Matrix4().makeTranslation(0,0,Math.sqrt(3/8)-1/Math.sqrt(6))); + unitGeo.applyMatrix(new THREE.Matrix4().makeTranslation(0,0,Math.sqrt(3/8)-2/Math.sqrt(6))); + unitGeo.applyMatrix(new THREE.Matrix4().makeRotationZ(Math.PI)); function TetraStackedCell(index, superCell){ DMACell.call(this, index, superCell); @@ -21,9 +22,22 @@ define(['underscore', 'three', 'threeModel', 'lattice', 'appState', 'cell'], }; TetraStackedCell.prototype._rotateCell = function(object3D){ - if (this.index.z%2 != 0) object3D.rotateX(Math.PI); + var absIndex = this.getAbsoluteIndex(); + if (absIndex.z%2 != 0) object3D.rotateX(Math.PI); + var mod4 = absIndex.z%4; + if (mod4 > 1 || (mod4 < 0 && mod4 > -3)) object3D.rotateZ(Math.PI); return object3D; }; + TetraStackedCell.prototype.calcHighlighterParams = function(face){ + var direction = face.normal; + if (direction.z<-0.95) direction = new THREE.Vector3(0,0,-1); + else direction = new THREE.Vector3(0,0,1); + direction.applyQuaternion(this.getAbsoluteOrientation()); + var position = this.getAbsolutePosition(); + position.z += direction.z*this.zScale()/2; + return {position:position, direction: direction}; + }; + return TetraStackedCell; }); \ No newline at end of file diff --git a/js/lattice/TetraStackedLattice.js b/js/lattice/TetraStackedLattice.js index 1e4abb55..1bc435a0 100644 --- a/js/lattice/TetraStackedLattice.js +++ b/js/lattice/TetraStackedLattice.js @@ -16,14 +16,6 @@ define(['underscore', 'backbone', 'appState', 'lattice', 'globals', 'plist', 'th }); }, -// getIndexForPosition: function(absPosition){ -// return this._indexForPosition(absPosition); -// }, -// -// getPositionForIndex: function(index){ -// return this._positionForIndex(index); -// }, - getIndexForPosition: function(absPosition){ var yIndex = Math.floor(absPosition.y/this.yScale()); if (yIndex%2 != 0) absPosition.x += this.xScale()/2; -- GitLab