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

listento insted of bind, simplifying code

parent df631ee6
No related branches found
No related tags found
No related merge requests found
......@@ -5,22 +5,23 @@
$(function(){
window.workers = persistentWorkers(8);
three = new ThreeView();
//init models and views
var fillGeometry = new FillGeometry();//singleton
three.setFillGeometry(fillGeometry);
new ImportView({model: fillGeometry});
lattice = new Lattice();
three.setFillGeometry(fillGeometry);
//window.fillGeometry.set({geometry:"stuff"});
setupNavBar();
workers = persistentWorkers(8);
......
......@@ -48,7 +48,7 @@ FillGeometry = Backbone.Model.extend({
var helper = new THREE.BoundingBoxHelper(this.get("mesh"), 0x000000);
this.set("boundingBoxHelper", helper);
helper.update();
three.scene.add(helper.object);
// three.scene.add(helper.object);
this.trigger("change:boundingBoxHelper");
},
......
......@@ -105,5 +105,4 @@ function persistentWorkers(numWorkers){
}
return {map:map, allWorkers:allWorkers};//return all public methods and vars
}
\ No newline at end of file
......@@ -17,7 +17,7 @@ ImportView = Backbone.View.extend({
initialize: function(){
_.bindAll(this, "render", "onMeshLoad");
this.model.bind("change:filename change:boundingBoxHelper", this.render);//boundingBoxHelper covers orientation
this.listenTo(this.model, "change:filename change:boundingBoxHelper", this.render);//boundingBoxHelper covers orientation
this.render();
},
......
/**
* Created by aghassaei on 1/16/15.
*/
ThreeView = Backbone.View.extend({
......@@ -10,7 +12,7 @@ ThreeView = Backbone.View.extend({
initialize: function(){
_.bindAll(this, "render", "animate", "onWindowResize");
_.bindAll(this, "render", "animate", "onWindowResize", "clearAll");
this.camera.position.z = 500;
this.scene.fog = new THREE.FogExp2( 0xcccccc, 0.002);
......@@ -55,14 +57,16 @@ ThreeView = Backbone.View.extend({
}
},
setFillGeometry: function(fillGeometry){
var self = this;
fillGeometry.bind("change:geometry", function(){
if (fillGeometry.previous("mesh")) self.scene.remove(fillGeometry.previous("mesh"));
self.render();
});
this.scene.add(fillGeometry.get("mesh"));
fillGeometry.bind("change:mesh change:orientation", this.render);
setFillGeometry: function(fillGeometry){//call this once
this.fillGeometry = fillGeometry;
this.listenTo(fillGeometry, "change:geometry", this.replaceFillGeometry);
this.listenTo(fillGeometry, "change:orientation", this.render);
this.replaceFillGeometry();
},
replaceFillGeometry: function(){
if (this.fillGeometry.previous("mesh")) this.scene.remove(this.fillGeometry.previous("mesh"));
this.scene.add(this.fillGeometry.get("mesh"));
this.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