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

deallocation stuff

parent f0f4be06
No related branches found
No related tags found
No related merge requests found
...@@ -145,19 +145,21 @@ ...@@ -145,19 +145,21 @@
return this.scale;//I don't like this stored here 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(){ 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){ _.each(this.parts, function(part){
part.destroy(); part.destroy();
}); });
this.indices = null;
this.scale = null;
this.position = null;
this.parts = null; this.parts = null;
}; };
......
...@@ -91,12 +91,17 @@ ...@@ -91,12 +91,17 @@
if (this.mesh) this.mesh.visible = false; if (this.mesh) this.mesh.visible = false;
}; };
DMAPart.prototype.remove = function(){
if (this.mesh) window.three.sceneRemove(this.mesh);
};
DMAPart.prototype.destroy = function(){ 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.parentCell = null;
this.oddZFlag = null;
this.type = null;
}; };
self.DMAPart = DMAPart; self.DMAPart = DMAPart;
......
...@@ -154,8 +154,8 @@ Lattice = Backbone.Model.extend({ ...@@ -154,8 +154,8 @@ Lattice = Backbone.Model.extend({
var cell = object.parent.myCell; var cell = object.parent.myCell;
var index = this._subtract(cell.indices, this.get("cellsMin")); var index = this._subtract(cell.indices, this.get("cellsMin"));
var cells = this.get("cells"); var cells = this.get("cells");
cell.destroy();
cells[index.x][index.y][index.z] = null; cells[index.x][index.y][index.z] = null;
cell.remove();
//todo shrink cells matrix if needed //todo shrink cells matrix if needed
...@@ -165,9 +165,11 @@ Lattice = Backbone.Model.extend({ ...@@ -165,9 +165,11 @@ Lattice = Backbone.Model.extend({
clearCells: function(){ clearCells: function(){
this._iterCells(this.get("cells"), function(cell){ this._iterCells(this.get("cells"), function(cell){
if (cell) cell.remove(); if (cell) cell.destroy();
}); });
this.set("cells", this.defaults.cells); this.set("cells", this.defaults.cells);
this.set("cellsMax", this.defaults.cellsMax);
this.set("cellsMin", this.defaults.cellsMin);
this.set("numCells", 0); this.set("numCells", 0);
window.three.render(); window.three.render();
}, },
......
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