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

more cleaning up

parent e47a7638
No related branches found
No related tags found
No related merge requests found
......@@ -7,13 +7,15 @@ $(function(){
window.workers = persistentWorkers(8);
//init threeJS view
var threeModel = new ThreeModel();
var three = new ThreeView({model:threeModel});//singleton, my threejs view
var three = new ThreeView({model:threeModel});
//init models and views
//backbone models and views
var fillGeometry = new FillGeometry();//singleton, mesh to fill with lattice
new ImportView({model: fillGeometry});
three.setFillGeometry(fillGeometry);
new FillGeometryView({model: fillGeometry, three:threeModel});
lattice = new Lattice();
......
/**
* Created by aghassaei on 1/16/15.
*/
FillGeometryView = Backbone.View.extend({
events: {
},
initialize: function(options){
this.three = options.three;
//bind events
this.listenTo(this.model, "change:geometry", this.replaceFillGeometry);
this.listenTo(this.model, "change:orientation", this.render);
this.replaceFillGeometry();
},
replaceFillGeometry: function(){
if (this.model.previous("mesh")) this.three.sceneRemove(this.model.previous("mesh"));
this.three.sceneAdd(this.model.get("mesh"));
this.three.render();
},
render: function(){
this.three.render();
}
});
\ No newline at end of file
......@@ -20,19 +20,6 @@ ThreeView = Backbone.View.extend({
this.animate();
},
setFillGeometry: function(fillGeometry){//call this once
this.fillGeometry = fillGeometry;
this.listenTo(fillGeometry, "change:geometry", this.replaceFillGeometry);
this.listenTo(fillGeometry, "change:orientation", this.model.render);
this.replaceFillGeometry();
},
replaceFillGeometry: function(){
if (this.fillGeometry.previous("mesh")) this.model.sceneRemove(this.fillGeometry.previous("mesh"));
this.model.sceneAdd(this.fillGeometry.get("mesh"));
this.model.render();
},
animate: function(){
requestAnimationFrame(this.animate);
this.controls.update();
......
......@@ -47,6 +47,7 @@
<!--views-->
<script src="js/views/threeView.js"></script>
<script src="js/views/importView.js"></script>
<script src="js/views/fillGeometryView.js"></script>
<script src="js/main.js"></script>
......
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