From c11c1076a64cbccd799c8483e9c4a9e60892aa3f Mon Sep 17 00:00:00 2001 From: Amanda Ghassaei <amandaghassaei@gmail.com> Date: Thu, 11 Jun 2015 22:12:14 -0700 Subject: [PATCH] render on lattice change working --- js/lattice/Lattice.js | 11 +++++++++++ js/lattice/LatticeBase.js | 1 - 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/js/lattice/Lattice.js b/js/lattice/Lattice.js index 68a2561c..634a7632 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 98700709..1d33b1b3 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(){ -- GitLab