Commit 9f924aa3 authored by Amanda Ghassaei's avatar Amanda Ghassaei
Browse files

kind of crappy, but orbits around center of mass of lattice

parent c0f2b189
......@@ -130,6 +130,11 @@ THREE.OrbitControls = function ( object, domElement ) {
var startEvent = { type: 'start'};
var endEvent = { type: 'end'};
this.setTarget = function(target){//three vector
this.target = target;
// this.target0 = this.target.clone();
};
this.rotateLeft = function ( angle ) {
if ( angle === undefined ) {
......
......@@ -35,6 +35,7 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre
this.listenTo(this, "change:cellSeparation", this._updateCellSeparation);
this.listenTo(appState, "change:currentNav", this._navChanged);
this.listenTo(this, "change:cellsMin change:cellsMax", this._updateThreeViewControls);
this._updateLatticeType();
},
......@@ -104,6 +105,13 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre
if (globals.basePlane) globals.basePlane.set("zIndex", 0, {silent:silent});
},
_updateThreeViewControls: function(){
var cellsMin = this.get("cellsMin");
var cellsMax = this.get("cellsMax");
if (cellsMax === null || cellsMin === null) return;
if (globals.threeView) globals.threeView.setOrbitControlsFor(this.get("cellsMin").clone(), this.get("cellsMax").clone())
},
......
......@@ -250,12 +250,13 @@ require.config({
//};
//init stuff
require(['appState', 'lattice', 'navbar', 'threeModel', 'threeView', 'flatUI', 'bootstrapSlider', 'ribbon', 'menuWrapper', 'scriptView'],
function(appState, lattice, Navbar, three, ThreeView){
require(['appState', 'lattice', 'navbar', 'threeModel', 'threeView', 'globals', 'flatUI', 'bootstrapSlider', 'ribbon', 'menuWrapper', 'scriptView'],
function(appState, lattice, Navbar, three, ThreeView, globals){
new Navbar({model:appState});
new ThreeView({model:three});
var threeView = new ThreeView({model:three});
globals.threeView = threeView;//todo fix this
// if (lattice.get("connectionType") != "gik") lattice.getUItarget().addCellAtIndex({x:0,y:0,z:0});//add a cell
});
......@@ -60,6 +60,10 @@ define(['underscore', 'backbone', 'three', 'appState', 'globals', 'lattice', 'or
this.controls.reset();
},
setOrbitControlsFor: function(min, max){
this.controls.setTarget(max.sub(min).divideScalar(2).add(min));
},
////////////////////////////////////////////////////////////////////////////////
///////////////////////////////MOUSE EVENTS/////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment