From eb9937529cbc4e164d57811dccf0a0f56d77ca62 Mon Sep 17 00:00:00 2001 From: Amanda Ghassaei <amandaghassaei@gmail.com> Date: Wed, 25 Feb 2015 16:17:50 -0500 Subject: [PATCH] debungging inv cells and baseplane --- js/fea/DmaCell.js | 2 +- js/models/BasePlane.js | 1 + js/models/Lattice.js | 12 ++++++++++-- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/js/fea/DmaCell.js b/js/fea/DmaCell.js index 1c9f0b07..ade16c1f 100644 --- a/js/fea/DmaCell.js +++ b/js/fea/DmaCell.js @@ -163,7 +163,7 @@ DMACell.prototype.destroy = function(){ if (zIndex%2!=0) mesh.rotation.set(Math.PI,0,0); mesh.myParent = this;//we need a reference to this instance from the mesh for intersection selection stuff - dmaGlobals.three.sceneAdd(mesh, "inverseCell"); +// dmaGlobals.three.sceneAdd(mesh, "inverseCell"); mesh.visible = false; return mesh; }; diff --git a/js/models/BasePlane.js b/js/models/BasePlane.js index 9bfd3633..81990ccc 100644 --- a/js/models/BasePlane.js +++ b/js/models/BasePlane.js @@ -181,6 +181,7 @@ OctaBasePlane = BasePlane.extend({ calcHighlighterPosition: function(face, position){ var index = dmaGlobals.lattice.getIndexForPosition(position); + if (index.z%2 != 0) index.x -= 1; index.z = this.get("zIndex") - 1;//pretend we're on the top of the cell underneath the baseplane var position = dmaGlobals.lattice.getPositionForIndex(index); position.z += dmaGlobals.lattice.zScale()/2; diff --git a/js/models/Lattice.js b/js/models/Lattice.js index 8bf03b4f..3e806f73 100644 --- a/js/models/Lattice.js +++ b/js/models/Lattice.js @@ -399,7 +399,7 @@ Lattice = Backbone.Model.extend({ getIndexForPosition: function(absPosition){ var scale = this.get("scale"); var yIndex = Math.floor(absPosition.y/this.yScale(scale)); - if (Math.abs(yIndex%2) == 1) absPosition.x += this.xScale(scale)/2; + if (yIndex%2 != 0) absPosition.x += this.xScale(scale)/2; var index = this._indexForPosition(absPosition); if (index.z%2 == 1) index.y += 1; return index; @@ -434,7 +434,15 @@ Lattice = Backbone.Model.extend({ position.y = (position.y)*this.yScale(scale)-scale/Math.sqrt(3)/2; position.z = (position.z)*this.zScale(scale); } - if ((index.y%2) != 0) position.x -= this.xScale()/2; + if ((index.y%2) != 0) { + if (Math.round((index.y/2)%2) != 0) { + position.x -= this.xScale()/2; + } + } else { + if (Math.round((index.y/2)%2) != 0) { + position.x -= this.xScale(); + } + } return position; }, -- GitLab