diff --git a/js/cells/DMACell.js b/js/cells/DMACell.js index b77151f266da12551168ca063b1a5463e9ca1745..86243b2939782da2d631164d6dcdbfdbca237e59 100644 --- a/js/cells/DMACell.js +++ b/js/cells/DMACell.js @@ -285,7 +285,10 @@ define(['underscore', 'three', 'threeModel', 'lattice', 'appState', 'globals'], DMACell.prototype.destroy = function(){ if (this.object3D) { if (this.superCell) this.superCell.removeChildren(this.object3D); - else if (this.index) three.sceneRemove(this.object3D); + else if (this.index) { + three.sceneRemove(this.object3D); + if (!this.cells) three.removeCell(this.object3D.children[0]);//remove mesh as highlightable object + } this.object3D.myParent = null; // this.object3D.dispose(); // geometry.dispose(); diff --git a/js/three/ThreeModel.js b/js/three/ThreeModel.js index 9af042f070fcad6f9182d603f4a05f3af47adea6..6b8d94136cc0edfc26c01dfbe9c5c8cc05dc8758 100644 --- a/js/three/ThreeModel.js +++ b/js/three/ThreeModel.js @@ -69,6 +69,10 @@ define(['underscore', 'three'], function(_, THREE){ cells.push(cell); } + function removeCell(cell){ + cells.splice(cells.indexOf(cell), 1); + } + function getCells(){ return cells; } @@ -130,6 +134,7 @@ define(['underscore', 'three'], function(_, THREE){ camera: camera, getCells: getCells, addCell: addCell, + removeCell: removeCell, getBasePlane: getBasePlane, removeAllCells: removeAllCells }