From f2d54046e9bbbb939fd449a4b8c480e8a8c5a615 Mon Sep 17 00:00:00 2001 From: Amanda Ghassaei <amandaghassaei@gmail.com> Date: Wed, 28 Jan 2015 20:48:41 -0500 Subject: [PATCH] redraw base plane --- js/threeViews/threeView.js | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/js/threeViews/threeView.js b/js/threeViews/threeView.js index f9cc4b4f..d9799972 100644 --- a/js/threeViews/threeView.js +++ b/js/threeViews/threeView.js @@ -29,13 +29,12 @@ ThreeView = Backbone.View.extend({ this.lattice = options.lattice; - _.bindAll(this, "_animate", "_mouseMoved", "_handleKeyStroke"); + _.bindAll(this, "_animate", "_mouseMoved", "_handleKeyStroke", "_drawBasePlane"); //bind events $(document).bind('keydown', {state:true}, this._handleKeyStroke); $(document).bind('keyup', {state:false}, this._handleKeyStroke); - this.listenTo(this.lattice, "change:type", this.drawBasePlane); - this.listenTo(this.lattice, "change:scale", this.scaleBasePlane); + this.listenTo(this.lattice, "change:type, change:scale", this._drawBasePlane); this.controls = new THREE.OrbitControls(this.model.camera, this.$el.get(0)); this.controls.addEventListener('change', this.model.render); @@ -44,7 +43,7 @@ ThreeView = Backbone.View.extend({ this._animate(); - this.basePlane = this.drawBasePlane(); + this.basePlane = this._drawBasePlane(); //init highlighter var highlightGeometry = new THREE.Geometry(); @@ -182,9 +181,9 @@ ThreeView = Backbone.View.extend({ } }, - drawBasePlane: function(){ + _drawBasePlane: function(){ - this.lattice.clearCells(); + if (this.basePlane) window.three.sceneRemove(this.basePlane); var type = this.lattice.get("cellType"); var connectionType = this.lattice.get("connectionType"); @@ -248,14 +247,10 @@ ThreeView = Backbone.View.extend({ var basePlane = new THREE.Mesh(geometry, planeMaterial); window.three.sceneAdd(basePlane); + window.three.render(); + if (this.basePlane) this.basePlane = basePlane; return basePlane; - }, - - scaleBasePlane: function(){ - - console.log("scale base plane"); - } }); \ No newline at end of file -- GitLab