diff --git a/js/main.js b/js/main.js index 94f2fb61d68553178a0bdd8da8f3d54ece2d0c56..8171a5ce532776c7a304b7b9fb2f131435d33440 100644 --- a/js/main.js +++ b/js/main.js @@ -25,7 +25,7 @@ $(function(){ new Ribbon({model:globals.appState}); //threeJS View - new ThreeView({model:globals.three, appState:globals.appState}); + new ThreeView({model:globals.three}); if (globals.lattice.get("connectionType") != "gik") globals.lattice.addCellAtIndex({x:0,y:0,z:0});//add a cell }); diff --git a/js/threeViews/ThreeView.js b/js/threeViews/ThreeView.js index 177c4b344c40d02d16b61f135e006e8c4dba3ae1..121aba5527b47606e19786f62aad354b81864f24 100644 --- a/js/threeViews/ThreeView.js +++ b/js/threeViews/ThreeView.js @@ -21,15 +21,12 @@ ThreeView = Backbone.View.extend({ controls: null, - initialize: function(options){ - - this.appState = options.appState; + initialize: function(){ _.bindAll(this, "_mouseMoved", "_animate"); //bind events - this.listenTo(this.appState, "change:deleteMode change:extrudeMode change:shift", this._setControlsEnabled); - this.listenTo(globals.lattice, "change:highlighter", this._saveHighlighter); + this.listenTo(globals.appState, "change:deleteMode change:extrudeMode change:shift", this._setControlsEnabled); this.controls = new THREE.OrbitControls(this.model.camera, this.$el.get(0)); this.controls.addEventListener('change', this.model.render); @@ -50,7 +47,7 @@ ThreeView = Backbone.View.extend({ }, _setControlsEnabled: function(){ - var state = this.appState.get("deleteMode") || this.appState.get("shift") || this.appState.get("extrudeMode"); + var state = globals.appState.get("deleteMode") || globals.appState.get("shift") || globals.appState.get("extrudeMode"); this.controls.noRotate = state; }, @@ -74,7 +71,7 @@ ThreeView = Backbone.View.extend({ } } if (this.currentIntersectedPart) this.currentIntersectedPart.removeFromCell(); - else globals.highlighter.addRemoveVoxel(!this.appState.get("deleteMode")); + else globals.highlighter.addRemoveVoxel(!globals.appState.get("deleteMode")); }, _mouseDown: function(){ @@ -109,14 +106,14 @@ ThreeView = Backbone.View.extend({ globals.highlighter.highlight(intersections[0]); if (this.mouseIsDown) { - if (this.appState.get("deleteMode")){ + if (globals.appState.get("deleteMode")){ globals.highlighter.addRemoveVoxel(false); - } else if (this.appState.get("shift")){ + } else if (globals.appState.get("shift")){ globals.highlighter.addRemoveVoxel(true); } } - if (this.appState.get("cellMode") == "part"){//additionally check for part intersections in part mode + if (globals.appState.get("cellMode") == "part"){//additionally check for part intersections in part mode var partIntersections = this.mouseProjection.intersectObjects(this.model.parts, false); if (partIntersections.length == 0) { this._setNoPartIntersections();