diff --git a/js/fea/DMASuperCell.js b/js/fea/DMASuperCell.js index 3f522246116a7a3625941458d96eed15cdbd57c8..29290b8cb301df18182d76cf9397f50882b5cfa1 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 709d0ff693fb13d29965be4adea1165659bac240..25a6980acc6c73076f4473022e7f8a57f9b951d5 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; };