Skip to content

Commit

Permalink
Add getCameraPosition
Browse files Browse the repository at this point in the history
  • Loading branch information
natacha-beck committed Apr 5, 2016
1 parent 8541610 commit c3cb753
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/brainbrowser/surface-viewer/modules/rendering.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,19 @@ BrainBrowser.SurfaceViewer.modules.rendering = function(viewer) {
viewer.updated = true;
};

/**
* @doc function
* @name viewer.rendering:getCameraPosition
* @description
* Get the camera position.
* ```js
* viewer.getCameraPosition();
* ```
*/
viewer.getCameraPosition = function() {
return camera.position;
};

/**
* @doc function
* @name viewer.rendering:resetView
Expand All @@ -179,15 +192,15 @@ BrainBrowser.SurfaceViewer.modules.rendering = function(viewer) {
*/
viewer.resetView = function() {
var model = viewer.model;
var inv = new THREE.Matrix4();
var inv = new THREE.Matrix4();
inv.getInverse(model.matrix);

model.applyMatrix(inv);
camera.position.set(0, 0, default_camera_distance);
light.position.set(0, 0, default_camera_distance);

model.children.forEach(function(shape) {
var centroid = shape.userData.centroid;
var centroid = shape.userData.centroid;
var recentered = shape.userData.recentered;

// The check for original_data tells us
Expand All @@ -208,6 +221,7 @@ BrainBrowser.SurfaceViewer.modules.rendering = function(viewer) {
}
});

model.rotation.set(0, 0, 0);
viewer.zoom = 1;

viewer.updated = true;
Expand Down

0 comments on commit c3cb753

Please sign in to comment.