From 991aa639df11f58ca641282c0a857ad6e4df989f Mon Sep 17 00:00:00 2001 From: Amanda Ghassaei <amandaghassaei@gmail.com> Date: Fri, 15 May 2015 19:36:26 -0400 Subject: [PATCH] delete supercell --- js/fea/DMASuperCell.js | 4 +++- js/fea/DmaCell.js | 7 ++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/js/fea/DMASuperCell.js b/js/fea/DMASuperCell.js index 3f522246..29290b8c 100644 --- a/js/fea/DMASuperCell.js +++ b/js/fea/DMASuperCell.js @@ -38,9 +38,11 @@ DMASuperCell.prototype.setScale = function(scale){ }; DMASuperCell.prototype.destroy = function(){ + if (this.destroyStarted) return;//prevents loop destroy from cells + this.destroyStarted = true; dmaGlobals.three.sceneRemove(this.mesh); _.each(this.cells, function(cell){ - if (cell) cell.destroy(); + if (cell && !cell.destroyStarted) dmaGlobals.lattice.removeCell(cell); }); this.cells = null; this.mesh = null; diff --git a/js/fea/DmaCell.js b/js/fea/DmaCell.js index 709d0ff6..25a6980a 100644 --- a/js/fea/DmaCell.js +++ b/js/fea/DmaCell.js @@ -239,6 +239,8 @@ DMACell.prototype._initBeams = function(nodes, faces){ }; DMACell.prototype.destroy = function(){ + if (this.destroyStarted) return; + this.destroyStarted = true; if (this.cellMesh) { dmaGlobals.three.sceneRemove(this.cellMesh, this._sceneType(this.indices)); this.cellMesh.myParent = null; @@ -251,7 +253,10 @@ DMACell.prototype.destroy = function(){ this.indices = null; this.nodes = null; this.beams = null; - this.superCell = null; + if (this.superCell) { + this.superCell.destroy(); + this.superCell = null; + } this.superCellIndex = null; this.superCellLength = null; }; -- GitLab