diff --git a/js/fea/DmaCellOcta.js b/js/fea/DmaCellOcta.js index 7671d90578b5cd847c81b0bb7290d34a450e319d..919c4edcd49e03ee03028c9278a3ca708fb2256c 100644 --- a/js/fea/DmaCellOcta.js +++ b/js/fea/DmaCellOcta.js @@ -81,7 +81,7 @@ DMAFreeFormOctaCell.prototype.calcHighlighterPosition = function(face){ direction.applyQuaternion(this.cellMesh.quaternion); var position = this.getPosition(); - var zScale = dmaGlobals.lattice.zScale(); + var zScale = this.zScale(); position.x += direction.x*zScale/2; position.y += direction.y*zScale/2; position.z += direction.z*zScale/2; @@ -101,6 +101,11 @@ DMAFreeFormOctaCell.prototype.getType = function(){ return "octa"; }; +DMAFreeFormOctaCell.prototype.zScale = function(scale){ + if (!scale) scale = dmaGlobals.lattice.get("scale"); + return 2*scale/Math.sqrt(6); +}; + /////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////EDGE CONNECTED///////////////////////////////////////////////////////// @@ -129,12 +134,65 @@ DMAEdgeOctaCell.prototype.calcHighlighterPosition = function(face){ /////////////////////////////////////////////////////////////////////////////////////////////// -////////////////////////VERTEX CONNECTED/////////////////////////////////////////////////////// +////////////////////////ROTATED EDGE CONNECTED///////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////// var unitVertexOcta = new THREE.OctahedronGeometry(1/Math.sqrt(2)); +function DMARotatedEdgeCell(indices, scale){ + DMACell.call(this, indices, scale); +} +DMARotatedEdgeCell.prototype = Object.create(DMACell.prototype); + +DMARotatedEdgeCell.prototype._buildCellMesh = function(){//abstract mesh representation of cell + return DMACell.prototype._buildCellMesh.call(this, unitVertexOcta); +}; + +DMARotatedEdgeCell.prototype.calcHighlighterPosition = function(face, point){ + + var position = this.getPosition(); + var direction = null; + + var xScale = dmaGlobals.lattice.xScale(); + if (point.x < position.x+xScale/4 && point.x > position.x-xScale/4){ + if (point.y > position.y-xScale/4 && point.y < position.y+xScale/4){ + if (face.normal.z > 0) { + direction = new THREE.Vector3(0,0,1); + position.z += dmaGlobals.lattice.zScale()/2; + } + else { + direction = new THREE.Vector3(0,0,-1); + position.z -= dmaGlobals.lattice.zScale()/2; + } + } else { + if (point.y < position.y-xScale/4){ + direction = new THREE.Vector3(0,-1,0); + position.y -= xScale/2; + } else { + direction = new THREE.Vector3(0,1,0); + position.y += xScale/2; + } + } + } else { + if (point.x < position.x-xScale/4){ + direction = new THREE.Vector3(-1,0,0); + position.x -= xScale/2; + } else { + direction = new THREE.Vector3(1,0,0); + position.x += xScale/2; + } + } + + return {index: _.clone(this.indices), direction:direction, position:position}; +}; + + +/////////////////////////////////////////////////////////////////////////////////////////////// +////////////////////////VERTEX CONNECTED/////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////////////////////////////// + + function DMAVertexOctaCell(indices, scale){ DMACell.call(this, indices, scale); } @@ -180,4 +238,4 @@ DMAVertexOctaCell.prototype.calcHighlighterPosition = function(face, point){ } return {index: _.clone(this.indices), direction:direction, position:position}; -}; +}; \ No newline at end of file diff --git a/js/fea/DmaCellTetra.js b/js/fea/DmaCellTetra.js index d3bbee9527e653be3e8e8e34094f81265b961fb1..79a92daeafc8d813782764698fce73687b90bda3 100644 --- a/js/fea/DmaCellTetra.js +++ b/js/fea/DmaCellTetra.js @@ -85,7 +85,7 @@ DMAFreeFormTetraCell.prototype.calcHighlighterPosition = function(face){ direction.applyQuaternion(this.cellMesh.quaternion); var position = this.getPosition(); - var zScale = dmaGlobals.lattice.zScale(); + var zScale = this.zScale(); position.x += direction.x*zScale/2; position.y += direction.y*zScale/2; position.z += direction.z*zScale/2; @@ -97,9 +97,9 @@ DMAFreeFormTetraCell.prototype.getType = function(){ return "tetra"; }; -//DMAFreeFormTetraCell.prototype.zScale = function(scale){ -// if (!scale) scale = dmaGlobals.lattice.get("scale"); -// return 2*scale/Math.sqrt(24); -//}; +DMAFreeFormTetraCell.prototype.zScale = function(scale){ + if (!scale) scale = dmaGlobals.lattice.get("scale"); + return 2*scale/Math.sqrt(24); +}; diff --git a/js/models/LatticeOcta.js b/js/models/LatticeOcta.js index d207510e9f72339af2703da309ca480c84f35b31..30269f8e72b29bdb5d37033e837c0bfef29169b9 100644 --- a/js/models/LatticeOcta.js +++ b/js/models/LatticeOcta.js @@ -186,7 +186,7 @@ OctaLatticeSubclasses = { zScale: function(scale){ if (!scale) scale = this.get("scale"); -// if (this.get("freeformCellType") == "octa") return 2*scale/Math.sqrt(6); + if (this.get("freeformCellType") == "octa") return 2*scale/Math.sqrt(6); return 2*scale/Math.sqrt(24); }, @@ -331,10 +331,6 @@ OctaLatticeSubclasses = { return this._positionForIndex(index); }, - _makeCellForLatticeType: function(indices, scale){ - return new DMAVertexOctaCell(indices, scale); - }, - xScale: function(scale){ if (!scale) scale = this.get("scale"); return scale*Math.sqrt(2); @@ -348,6 +344,10 @@ OctaLatticeSubclasses = { return this.xScale(scale); }, + _makeCellForLatticeType: function(indices, scale){ + return new DMARotatedEdgeCell(indices, scale); + }, + _undo: function(){//remove all the mixins, this will help with debugging later var self = this; _.each(_.keys(this.OctaRotEdgeLattice), function(key){