diff --git a/js/fea/DmaCell.js b/js/fea/DmaCell.js index dea48475b8bae118302acf29d012b1fa89daf4a9..09d4e388b9289b4231b49af7c550f092d02c63cc 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 5785a5a3a51dc5d7eed6deb15f2dc7508a6cf984..5dee5b0d19b8c46e499ab62dd8ed885d9d667948 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"); },