diff --git a/js/lattice/Lattice.js b/js/lattice/Lattice.js index 68a2561c15fa7e03606b33b387d7f5a3abb691c6..634a76326adffbfc82e875223b0d232e5aff47c1 100644 --- a/js/lattice/Lattice.js +++ b/js/lattice/Lattice.js @@ -62,6 +62,7 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre var cellsMin = this.get("cellsMin"); var cellsMax = this.get("cellsMax"); + this._bindRenderToNumCells(this.get("numCells")); this.clearCells(); if (this._undo) this._undo(); @@ -77,6 +78,16 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre }); }, + _bindRenderToNumCells: function(numCells){ + var self = this; + if (numCells > 0) this.listenTo(this, "change:numCells", function(){ + if (self.get("numCells") >= numCells){ + self.stopListening(self, "change:numCells"); + three.render(); + } + }); + }, + _setToDefaultsSilently: function(){ var newCellType = this.get("cellType"); var newConnectionType = this.get("connectionType"); diff --git a/js/lattice/LatticeBase.js b/js/lattice/LatticeBase.js index 9870070903796d4339e74b6426a28a2cc1317e65..1d33b1b3c551de5cc6ee5c60e8c84d31858bc260 100644 --- a/js/lattice/LatticeBase.js +++ b/js/lattice/LatticeBase.js @@ -341,7 +341,6 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre this._loopCells(sparseCells, function(cell, x, y, z, self){ if (cell) self.addCellAtIndex((new THREE.Vector3(x, y, z)).add(cellsMin), true, true, cell.material); }); - three.render();//todo in callback }, getSaveJSON: function(){