diff --git a/js/fea/dmaCell.js b/js/fea/dmaCell.js index 7c988a2cf6a80cdb94995af8abfd6562e3cb2e20..7ff26b32a33067b4629607f03462d73fcd24c580 100644 --- a/js/fea/dmaCell.js +++ b/js/fea/dmaCell.js @@ -145,19 +145,21 @@ return this.scale;//I don't like this stored here }; - DMACell.prototype.remove = function(){ - if (this.cellMesh) window.three.sceneRemove(this.cellMesh); - _.each(this.parts, function(part){ - part.remove(); - }); - this.destroy(); - }; - DMACell.prototype.destroy = function(){ - if (this.cellMesh) this.cellMesh.myCell = null; + if (this.cellMesh) { + window.three.sceneRemove(this.cellMesh); + this.cellMesh.myCell = null; + this.cellMesh.dispose(); +// geometry.dispose(); +// material.dispose(); + this.cellMesh = null; + } _.each(this.parts, function(part){ part.destroy(); }); + this.indices = null; + this.scale = null; + this.position = null; this.parts = null; }; diff --git a/js/fea/dmaPart.js b/js/fea/dmaPart.js index 865ae6f9fd693878b6a9d59c80ce1327abfad07c..a28c86e44a780dbf45356cb7f872fb42a4049302 100644 --- a/js/fea/dmaPart.js +++ b/js/fea/dmaPart.js @@ -91,12 +91,17 @@ if (this.mesh) this.mesh.visible = false; }; - DMAPart.prototype.remove = function(){ - if (this.mesh) window.three.sceneRemove(this.mesh); - }; - DMAPart.prototype.destroy = function(){ + if (this.mesh) { + window.three.sceneRemove(this.mesh); + this.mesh.dispose(); +// geometry.dispose(); +// material.dispose(); + this.mesh = null; + } this.parentCell = null; + this.oddZFlag = null; + this.type = null; }; self.DMAPart = DMAPart; diff --git a/js/models/lattice.js b/js/models/lattice.js index 9ea75162e33de53c1b4c3460c76a95467ac7ecdb..b184cc0894382e903ce413a833710c5db68115b8 100644 --- a/js/models/lattice.js +++ b/js/models/lattice.js @@ -154,8 +154,8 @@ Lattice = Backbone.Model.extend({ var cell = object.parent.myCell; var index = this._subtract(cell.indices, this.get("cellsMin")); var cells = this.get("cells"); + cell.destroy(); cells[index.x][index.y][index.z] = null; - cell.remove(); //todo shrink cells matrix if needed @@ -165,9 +165,11 @@ Lattice = Backbone.Model.extend({ clearCells: function(){ this._iterCells(this.get("cells"), function(cell){ - if (cell) cell.remove(); + if (cell) cell.destroy(); }); this.set("cells", this.defaults.cells); + this.set("cellsMax", this.defaults.cellsMax); + this.set("cellsMin", this.defaults.cellsMin); this.set("numCells", 0); window.three.render(); },