diff --git a/js/fea/DmaCell.js b/js/fea/DmaCell.js index 6b532fb7507ddfbf843e354d8852286f9b5595d1..7787b70485d93e6432228de790173336cec0ce68 100644 --- a/js/fea/DmaCell.js +++ b/js/fea/DmaCell.js @@ -13,9 +13,11 @@ function DMACell(indices, scale, lattice, inverse) { this.lattice = lattice;//need ref back to lattice this.cellMesh = this._buildCellMesh(indices.z); this.parts = this._initParts(indices.z); - this.updateForScale(scale); - this.drawForMode(dmaGlobals.appState.get("cellMode"), dmaGlobals.appState.get("inverseMode")); + var cellMode = dmaGlobals.appState.get("cellMode"); + var inverseMode = dmaGlobals.appState.get("inverseMode"); + + this.drawForMode(scale, cellMode, inverseMode); } DMACell.prototype.removePart = function(index){ @@ -34,7 +36,8 @@ DMACell.prototype._setMeshPosition = function(mesh, position){ mesh.position.z = position.z; }; -DMACell.prototype.drawForMode = function(cellMode, inverseMode){ +DMACell.prototype.drawForMode = function(scale, cellMode, inverseMode){ + this.updateForScale(scale, cellMode); this._setCellMeshVisibility(cellMode == "cell" && inverseMode==this.isInverse);//only show if in the correct inverseMode _.each(this.parts, function(part){ if (part) part.setVisibility(cellMode == "part"); @@ -46,13 +49,17 @@ DMACell.prototype._setCellMeshVisibility = function(visibility){ this.cellMesh.visible = visibility; }; -DMACell.prototype.updateForScale = function(scale){ - this.cellMesh.scale.set(scale, scale, scale); +DMACell.prototype.updateForScale = function(scale, cellMode){ + //only update visible object to scale var position = this.getPosition(); - this._setMeshPosition(this.cellMesh, position); - _.each(this.parts, function(part){ - if (part) part.updateForScale(scale, position); - }); + if (cellMode == "cell"){ + this.cellMesh.scale.set(scale, scale, scale); + this._setMeshPosition(this.cellMesh, position); + } else if (cellMode == "part"){ + _.each(this.parts, function(part){ + if (part) part.updateForScale(scale, position); + }); + } }; DMACell.prototype.getScale = function(){//need for part relay diff --git a/js/models/Lattice.js b/js/models/Lattice.js index efbe50271f8c9e31ce31a1c0e0d67b2f5d5fe955..34722ed097ef3c6cc9ba7f857db6f9012798fd74 100644 --- a/js/models/Lattice.js +++ b/js/models/Lattice.js @@ -311,11 +311,12 @@ Lattice = Backbone.Model.extend({ _updateForMode: function(){ var cellMode = this.get("cellMode"); var inverseMode = this.get("inverseMode"); + var scale = this.get("scale"); this._iterCells(this.get("cells"), function(cell){ - if (cell) cell.drawForMode(cellMode, inverseMode); + if (cell) cell.drawForMode(scale, cellMode, inverseMode); }); this._iterCells(this.get("inverseCells"), function(cell){ - if (cell) cell.drawForMode(cellMode, inverseMode); + if (cell) cell.drawForMode(scale, cellMode, inverseMode); }); dmaGlobals.three.render(); }, @@ -326,12 +327,14 @@ Lattice = Backbone.Model.extend({ this.get("highlighter").updateScale(scale); //only update visible cells - this._iterCells(this.get("cells"), function(cell){ - if (cell) cell.updateForScale(scale); - }); + var cellMode = this.get("cellMode"); if (this.get("inverseMode")){ this._iterCells(this.get("inverseCells"), function(cell){ - if (cell) cell.updateForScale(scale); + if (cell) cell.updateForScale(scale, cellMode); + }); + } else { + this._iterCells(this.get("cells"), function(cell){ + if (cell) cell.updateForScale(scale, cellMode); }); } dmaGlobals.three.render(); @@ -428,9 +431,10 @@ Lattice = Backbone.Model.extend({ _changeColSeparation: function(){ var colSep = this.get("columnSeparation"); var scale = this.get("scale"); + var cellMode = this.get("cellMode"); this.get("basePlane").updateColSeparation(colSep); this._iterCells(this.get("cells"), function(cell){ - if (cell) cell.updateForScale(scale); + if (cell) cell.updateForScale(scale, cellMode); }); dmaGlobals.three.render(); },