From d893b26834e4dc5ec0e3908ea8dd4ac19305d3e0 Mon Sep 17 00:00:00 2001 From: Amanda Ghassaei <amandaghassaei@gmail.com> Date: Tue, 3 Mar 2015 18:23:25 -0500 Subject: [PATCH] inverse cell debugging --- js/fea/DmaCell.js | 25 ++++++++++++++++--------- js/models/Lattice.js | 18 +++++++++++------- 2 files changed, 27 insertions(+), 16 deletions(-) diff --git a/js/fea/DmaCell.js b/js/fea/DmaCell.js index 6b532fb7..7787b704 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 efbe5027..34722ed0 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(); }, -- GitLab