diff --git a/js/cells/TetraStackedCell.js b/js/cells/TetraStackedCell.js index e3fae8f4410499021ce16811944bb3407365a13e..29be42c53f2365b6f029e2b94a0854430e50a882 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 1e4abb55aaf85beb9d73d7b107566df4caf07859..1bc435a0cbe9093bcd3ab8a6f415061b1ab23c6a 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;