Commit 7f2f119c authored by amandaghassaei's avatar amandaghassaei
Browse files

camera controls

parent e592a80d
...@@ -211,6 +211,7 @@ THREE.TrackballControls = function ( object, domElement ) { ...@@ -211,6 +211,7 @@ THREE.TrackballControls = function ( object, domElement ) {
_touchZoomDistanceStart = _touchZoomDistanceEnd; _touchZoomDistanceStart = _touchZoomDistanceEnd;
_eye.multiplyScalar( factor ); _eye.multiplyScalar( factor );
} else { } else {
factor = 1.0 + ( _zoomEnd.y - _zoomStart.y ) * _this.zoomSpeed; factor = 1.0 + ( _zoomEnd.y - _zoomStart.y ) * _this.zoomSpeed;
...@@ -331,13 +332,15 @@ THREE.TrackballControls = function ( object, domElement ) { ...@@ -331,13 +332,15 @@ THREE.TrackballControls = function ( object, domElement ) {
}; };
this.reset = function () { this.reset = function (position) {
_state = STATE.NONE; _state = STATE.NONE;
_prevState = STATE.NONE; _prevState = STATE.NONE;
_this.target.copy( _this.target0 ); _this.target.copy( _this.target0 );
_this.object.position.copy( _this.position0 ); if (position === undefined) position = _this.position0;
else position.normalize().multiplyScalar(_this.object.position.length());
_this.object.position.copy( position );
_this.object.up.copy( _this.up0 ); _this.object.up.copy( _this.up0 );
_eye.subVectors( _this.object.position, _this.target ); _eye.subVectors( _this.object.position, _this.target );
......
...@@ -619,6 +619,13 @@ ...@@ -619,6 +619,13 @@
<div id="VRoptions"> <div id="VRoptions">
</div> </div>
</div><br/>
View Angle:<br/>
<div class="indent">
<a href="#" id="cameraX" class="btn btn-lg btn-default">X</a>
<a href="#" id="cameraY" class="btn btn-lg btn-default">Y</a>
<a href="#" id="cameraZ" class="btn btn-lg btn-default">Z</a>
<a href="#" id="cameraOrtho" class="btn btn-lg btn-default">Ortho</a>
</div> </div>
</div> </div>
</div> </div>
......
...@@ -24,6 +24,19 @@ function initControls(globals){ ...@@ -24,6 +24,19 @@ function initControls(globals){
$('#aboutAnimationModal').modal('show'); $('#aboutAnimationModal').modal('show');
}); });
setLink("#cameraX", function(){
globals.threeView.setCameraX();
});
setLink("#cameraY", function(){
globals.threeView.setCameraY();
});
setLink("#cameraZ", function(){
globals.threeView.setCameraZ();
});
setLink("#cameraOrtho", function(){
globals.threeView.setCameraOrtho();
});
setLink("#exportFOLD", function(){ setLink("#exportFOLD", function(){
updateDimensions(); updateDimensions();
$("#foldFilename").val(globals.filename + " : " + parseInt(globals.creasePercent*100) + "PercentFolded"); $("#foldFilename").val(globals.filename + " : " + parseInt(globals.creasePercent*100) + "PercentFolded");
......
...@@ -95,6 +95,26 @@ function initThreeView(globals) { ...@@ -95,6 +95,26 @@ function initThreeView(globals) {
// effectComposer.addPass( ssaoPass ); // effectComposer.addPass( ssaoPass );
} }
function setCameraX(){
controls.reset(new THREE.Vector3(1,0,0));
manuallySetCamera();
}
function setCameraY(){
controls.reset(new THREE.Vector3(0,1,0));
manuallySetCamera();
}
function setCameraZ(){
controls.reset(new THREE.Vector3(0,0,1));
manuallySetCamera();
}
function setCameraOrtho(){
controls.reset(new THREE.Vector3(1,1,1));
manuallySetCamera();
}
function manuallySetCamera(){
render();
}
function render() { function render() {
if (!animationRunning) { if (!animationRunning) {
console.log("render"); console.log("render");
...@@ -249,6 +269,10 @@ function initThreeView(globals) { ...@@ -249,6 +269,10 @@ function initThreeView(globals) {
modelWrapper:modelWrapper, modelWrapper:modelWrapper,
running: running, running: running,
setScale:setScale, setScale:setScale,
saveSVG: saveSVG saveSVG: saveSVG,
setCameraX:setCameraX,
setCameraY: setCameraY,
setCameraZ: setCameraZ,
setCameraOrtho: setCameraOrtho
} }
} }
\ No newline at end of file
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