From 796999cdee47acff064c0383956ebeb9d9749163 Mon Sep 17 00:00:00 2001 From: Amanda Ghassaei <amandaghassaei@gmail.com> Date: Tue, 24 Mar 2015 21:35:10 -0400 Subject: [PATCH] can change cell mode during animation --- js/fea/DmaCell.js | 4 +++- js/models/Lattice.js | 15 ++++++++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/js/fea/DmaCell.js b/js/fea/DmaCell.js index dea48475..09d4e388 100644 --- a/js/fea/DmaCell.js +++ b/js/fea/DmaCell.js @@ -19,6 +19,7 @@ function DMACell(indices, scale, cellMode, partType) { this.draw(scale, cellMode, partType); + this.hideForStockSimulation = false; } DMACell.prototype._sceneType = function(indices){ @@ -27,6 +28,7 @@ DMACell.prototype._sceneType = function(indices){ }; DMACell.prototype.draw = function(scale, cellMode, partType){ + if (this.hideForStockSimulation) return; if (!scale) scale = dmaGlobals.lattice.get("scale"); if (!cellMode) cellMode = dmaGlobals.appState.get("cellMode"); if (!partType) partType = dmaGlobals.lattice.get("partType"); @@ -54,7 +56,7 @@ DMACell.prototype.draw = function(scale, cellMode, partType){ }); }; -DMACell.prototype.hide = function(){ +DMACell.prototype.hide = function(){//only used in the context of stock simulation this._setCellMeshVisibility(false); _.each(this.parts, function(part){ if (part) part.setVisibility(false); diff --git a/js/models/Lattice.js b/js/models/Lattice.js index 5785a5a3..5dee5b0d 100644 --- a/js/models/Lattice.js +++ b/js/models/Lattice.js @@ -353,14 +353,20 @@ Lattice = Backbone.Model.extend({ //hide show cells during stock simulation hideCells: function(){ this._iterCells(this.get("cells"), function(cell){ - if (cell) cell.hide(); + if (cell) { + cell.hide(); + cell.hideForStockSimulation = true; + } }); dmaGlobals.three.render(); }, showCells: function(){ this._iterCells(this.get("cells"), function(cell){ - if (cell) cell.draw(); + if (cell) { + cell.hideForStockSimulation = false; + cell.draw(); + } }); dmaGlobals.three.render(); }, @@ -368,7 +374,10 @@ Lattice = Backbone.Model.extend({ showCellAtIndex: function(index){ var latticeIndex = this._subtract(index, this.get("cellsMin")); var cell = this.get("cells")[latticeIndex.x][latticeIndex.y][latticeIndex.z]; - if (cell) cell.draw(); + if (cell) { + cell.hideForStockSimulation = false; + cell.draw(); + } else console.warn("placing a cell that does not exist"); }, -- GitLab