Commit 66045dee authored by Amanda Ghassaei's avatar Amanda Ghassaei

cleaning up vive interface

parent 7d54496e
......@@ -1204,7 +1204,7 @@
<a href="#" class="seeMore closed" data-id="virtualReality"><span class="fui-triangle-down"></span>Virtual Reality:</a><a class="about floatRight" href="#" id="aboutVR"><span class="fui-question-circle"></span></a>
</div>
<div id="virtualReality" class="hide indent smallTxt">
Status: &nbsp;<span id="VRstatus"></span>
<b>Status:</b> &nbsp;<span id="VRstatus"></span>
<div id="VRoptions"><br/>
<a href="#" id="enterVR" class="displayBlock btn btn-lg btn-inverse"></a>
</div><br/><br/>
......@@ -1294,7 +1294,10 @@
<p><b>VIRTUAL REALITY</b><br/><br/>
This tool currently supports an interactive Virtual Reality mode using the Vive headset and controllers.
For this to work, you must first use a <a href="https://webvr.info/" target="_blank">WebVR enabled browser</a>:
currently only <a href="https://webvr.rocks/firefox" target="_blank">Firefox Nightly</a> is supported by this app.
currently only <a href="https://webvr.rocks/firefox" target="_blank">the latest Firefox for Windows </a> and
<a href="https://webvr.info/get-chrome/" target="_blank">an experimental build of Chromium (with enable-webvr and
-enable-gamepad-extensions flags)</a> are supported by this app. Note - in Chromium, you have to click the System button on the
Vive controllers for them to start tracking.
<br/><br/>
When you open this page with the appropriate browser and a Vive connected through Steam VR, you will see a button that says "Enter VR". Clicking this will
put the app into an interactive VR mode. The hand controllers will allow you to grab the origami mesh and pull on it.
......
......@@ -8,7 +8,7 @@ function initViveInterface(globals){
var $status = $("#VRstatus");
if ( WEBVR.isAvailable() === false ) {
$status.html("WebVR not supported by this browser<br/>see <a href='https://webvr.info/' target='_blank'>webvr.info</a> for more info.");
$status.html("WebVR not supported by this browser<br/>see <a href='https://webvr.info/' target='_blank'>webvr.info</a> for more information.");
$("#VRoptions").hide();
return;
}
......@@ -34,6 +34,7 @@ function initViveInterface(globals){
controller1.add(mesh.clone());
controller2.add(mesh.clone());
var controllersConnected = false;
var controllers = [controller1, controller2];
var controllerStates = [false, false];
......@@ -57,27 +58,43 @@ function initViveInterface(globals){
function connect(){
WEBVR.getVRDisplay( function ( display ) {
if (!display) return;
$status.html("VR device detected. Check that you are connected to Steam VR and your Vive has the latest firmware updates.");
var $link = $("#enterVR");
if (!display) {
$status.html("No VR device detected. Check that you are connected to Steam VR and your HMD has the latest firmware updates, then refresh this page.");
$link.hide();
return;
}
$status.html("VR device detected. Hit the button below to enter VR. If you have problems, check that you are connected to Steam VR and your HMD has the latest firmware updates.");
$("#VRoptions").show();
var button = WEBVR.getButton( display, globals.threeView.renderer.domElement );
var $link = $("#enterVR");
$link.html(button.textContent);
$link.show();
$link.html("ENTER VR");
var callback = button.onclick;
$link.click(function(e){
e.preventDefault();
globals.vrEnabled = !display.isPresenting;
var y = 0;
if (globals.vrEnabled) y = yOffset;
globals.threeView.modelWrapper.scale.set(scale, scale, scale);
var vrScale = 1;
if (globals.vrEnabled) {
y = yOffset;
vrScale = scale;
$link.html("EXIT VR");
} else {
globals.threeView.resetCamera();
$link.html("ENTER VR");
}
globals.threeView.modelWrapper.scale.set(vrScale, vrScale, vrScale);
globals.threeView.modelWrapper.position.set(0,y,0);
_.each(controller1.children, function(child){
child.visible = true;
child.visible = globals.vrEnabled;
});
_.each(controller2.children, function(child){
child.visible = true;
child.visible = globals.vrEnabled;
});
setControllerEvents();
if (!controllersConnected && globals.vrEnabled) {
setControllerEvents();
controllersConnected = true;
}
if (callback) callback();
});
} );
......
......@@ -49,11 +49,7 @@ function initThreeView(globals) {
scene.add(camera);
camera.zoom = 7;
camera.updateProjectionMatrix();
camera.position.x = 5;
camera.position.y = 5;
camera.position.z = 5;
resetCamera();
controls = new THREE.TrackballControls(camera, renderer.domElement);
controls.rotateSpeed = 4.0;
......@@ -67,6 +63,15 @@ function initThreeView(globals) {
}
function resetCamera(){
camera.zoom = 7;
camera.updateProjectionMatrix();
camera.position.x = 5;
camera.position.y = 5;
camera.position.z = 5;
if (controls) setCameraIso();
}
function setCameraX(sign){
controls.reset(new THREE.Vector3(sign,0,0));
}
......@@ -228,6 +233,7 @@ function initThreeView(globals) {
setCameraIso: setCameraIso,
resetModel: resetModel,//reset model orientation
resetCamera:resetCamera,
setBackgroundColor: setBackgroundColor
}
}
\ No newline at end of file
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