Commit 5a98239a authored by Amanda Ghassaei's avatar Amanda Ghassaei
Browse files

reset navigation

parent 3f02c43f
......@@ -10,7 +10,7 @@ define(['jquery', 'underscore', 'backbone', 'plist', 'text!navViewMenuTemplate']
el: "#navViewMenu",
events: {
"click a": "_makeSelection",
"click a.boolProperty": "_makeSelection",
"click #reset3DView": "_reset3DNavigation"
},
......@@ -40,8 +40,9 @@ define(['jquery', 'underscore', 'backbone', 'plist', 'text!navViewMenuTemplate']
return null;
},
_reset3DNavigation: function(){
_reset3DNavigation: function(e){
e.preventDefault();
this.model.reset3DNavigation();
},
render: function(){
......
......@@ -158,6 +158,10 @@ define(['underscore', 'backbone', 'threeModel', 'three', 'plist', 'globals'], fu
})
},
reset3DNavigation: function(){
three.resetCameraPosition();
},
///////////////////////////////////////////////////////////////////////////////
/////////////////////KEY BINDINGS//////////////////////////////////////////////
......
......@@ -25,13 +25,15 @@ define(['underscore', 'three'], function(_, THREE){
var shouldRender = false;
var initialCameraPosition = new THREE.Vector3(-15, -12, 12);
var threeView = null;
initialize();
function initialize(){
camera.position.x = -15;
camera.position.y = -12;
camera.position.z = 12;
resetCameraPosition();
camera.up.set(0,0,1);//set z axis as "up"
var fogColor = 0xcccccc;
......@@ -65,6 +67,14 @@ define(['underscore', 'three'], function(_, THREE){
window.addEventListener('resize', onWindowResize, false);
}
function resetCameraPosition(){
camera.position.x = initialCameraPosition.x;
camera.position.y = initialCameraPosition.y;
camera.position.z = initialCameraPosition.z;
if (threeView) threeView.reset3DNavigation();
render();
}
function onWindowResize(){
camera.aspect = window.innerWidth/window.innerHeight;
camera.updateProjectionMatrix();
......@@ -72,6 +82,10 @@ define(['underscore', 'three'], function(_, THREE){
render();
}
function setThreeView(view){
threeView = view;
}
function sceneAdd(object){
scene.add(object);
}
......@@ -187,7 +201,9 @@ define(['underscore', 'three'], function(_, THREE){
removeCompositeCell: removeCompositeCell,
getBasePlane: getBasePlane,
removeAllCells: removeAllCells,
removeAllCompositeCells: removeAllCompositeCells
removeAllCompositeCells: removeAllCompositeCells,
resetCameraPosition: resetCameraPosition,
setThreeView: setThreeView
}
});
\ No newline at end of file
......@@ -36,6 +36,8 @@ define(['underscore', 'backbone', 'three', 'appState', 'globals', 'lattice', 'or
this.$el.append(this.model.domElement);//render only once
this.model.setThreeView(this);
this.model.render();
// this._animate();
},
......@@ -54,6 +56,10 @@ define(['underscore', 'backbone', 'three', 'appState', 'globals', 'lattice', 'or
this.controls.noRotate = state;
},
reset3DNavigation: function(){
this.controls.reset();
},
////////////////////////////////////////////////////////////////////////////////
///////////////////////////////MOUSE EVENTS/////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
......
Supports Markdown
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