Skip to content
Snippets Groups Projects
Commit 991aa639 authored by Amanda Ghassaei's avatar Amanda Ghassaei
Browse files

delete supercell

parent 0dc7dbd2
No related branches found
No related tags found
No related merge requests found
......@@ -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;
......
......@@ -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;
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment