Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebVR Support - THREE.js & WebVR boilerplate #827

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .idea/jsLibraryMappings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions .idea/noVNC2.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

312 changes: 312 additions & 0 deletions .idea/workspace.xml

Large diffs are not rendered by default.

40 changes: 40 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
## noVNC: HTML5 VNC Client
----

[![Build Status](https://travis-ci.org/novnc/noVNC.svg?branch=master)](https://travis-ci.org/novnc/noVNC)

Expand All @@ -16,6 +17,43 @@ Many companies, projects and products have integrated noVNC including
[the Projects and Companies wiki page](https://github.com/novnc/noVNC/wiki/Projects-and-companies-using-noVNC)
for a more complete list with additional info and links.

### Now with WebVR support
![vnc-vr](https://cloud.githubusercontent.com/assets/6830845/26262585/30d4b1a6-3ccd-11e7-9329-2197ddaa534e.png)
I have adapted the WebVR boilerplate with a basic Three.js scene to make this VNC client work in VR on a mobile device.
https://github.com/borismus/webvr-boilerplate

I Used tightvncserver on linux to host a display on vnc. I ran these commands on the terminal inside the root folder.

https://knowledgelayer.softlayer.com/learning/tightvnc-server-ubuntu-1604


```bash

# Install tight VNC
sudo apt-get install tightvncserver.

# Start VNC server on display :2
vncserver :2 -geometry 4096x1024

# Launch websockify in noVNC folder.
./utils/launch.sh --vnc localhost:5902 # 590X port number maps to display number on tight vnc.

```

Then connect to your laptop from your smart phone by opening a browser to your laptops IP.

```
http://<IP_OF_YOUR_LAPTOP>:6080/vnc_lite_vr.html
```

The password prompt will still appear at the top.

You can use large resolutions with the screen enlarged in VR and curved around you.
![recording 2](https://cloud.githubusercontent.com/assets/6830845/26530856/fda108b6-43d4-11e7-911d-0ea582cc21d8.gif)

TODO: add input??


### News/help/contact

Notable commits, announcements and news are posted to
Expand Down Expand Up @@ -102,6 +140,8 @@ WebSockets to TCP socket proxy. There is a python proxy included
Connect button and enjoy!




### Other Pages

* [Modules/API](https://github.com/novnc/noVNC/wiki/Modules-API) - The library
Expand Down
2 changes: 1 addition & 1 deletion core/rfb.js
Original file line number Diff line number Diff line change
Expand Up @@ -1009,7 +1009,7 @@ RFB.prototype = {
} else {
return this._fail("Authentication failure");
}
return false;
//return false; causes { [TypeScript error: novnc/core/rfb.js(1012,17): Error TS7027: Unreachable code detected.]
case 2:
return this._fail("Too many authentication attempts");
default:
Expand Down
173 changes: 173 additions & 0 deletions vendor/VRControls.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
/**
* @author dmarcos / https://github.com/dmarcos
* @author mrdoob / http://mrdoob.com
*/

THREE.VRControls = function ( object, onError ) {

var scope = this;

var vrDisplay, vrDisplays;

var standingMatrix = new THREE.Matrix4();

var frameData = null;

if ( 'VRFrameData' in window ) {

frameData = new VRFrameData();

}

function gotVRDisplays( displays ) {

vrDisplays = displays;

if ( displays.length > 0 ) {

vrDisplay = displays[ 0 ];

} else {

if ( onError ) onError( 'VR input not available.' );

}

}

if ( navigator.getVRDisplays ) {

navigator.getVRDisplays().then( gotVRDisplays ).catch ( function () {

console.warn( 'THREE.VRControls: Unable to get VR Displays' );

} );

}

// the Rift SDK returns the position in meters
// this scale factor allows the user to define how meters
// are converted to scene units.

this.scale = 1;

// If true will use "standing space" coordinate system where y=0 is the
// floor and x=0, z=0 is the center of the room.
this.standing = false;

// Distance from the users eyes to the floor in meters. Used when
// standing=true but the VRDisplay doesn't provide stageParameters.
this.userHeight = 1.6;

this.getVRDisplay = function () {

return vrDisplay;

};

this.setVRDisplay = function ( value ) {

vrDisplay = value;

};

this.getVRDisplays = function () {

console.warn( 'THREE.VRControls: getVRDisplays() is being deprecated.' );
return vrDisplays;

};

this.getStandingMatrix = function () {

return standingMatrix;

};

this.update = function () {

if ( vrDisplay ) {

var pose;

if ( vrDisplay.getFrameData ) {

vrDisplay.getFrameData( frameData );
pose = frameData.pose;

} else if ( vrDisplay.getPose ) {

pose = vrDisplay.getPose();

}

if ( pose.orientation !== null ) {

object.quaternion.fromArray( pose.orientation );

}

if ( pose.position !== null ) {

object.position.fromArray( pose.position );

} else {

object.position.set( 0, 0, 0 );

}

if ( this.standing ) {

if ( vrDisplay.stageParameters ) {

object.updateMatrix();

standingMatrix.fromArray( vrDisplay.stageParameters.sittingToStandingTransform );
object.applyMatrix( standingMatrix );

} else {

object.position.setY( object.position.y + this.userHeight );

}

}

object.position.multiplyScalar( scope.scale );

}

};

this.resetPose = function () {

if ( vrDisplay ) {

vrDisplay.resetPose();

}

};

this.resetSensor = function () {

console.warn( 'THREE.VRControls: .resetSensor() is now .resetPose().' );
this.resetPose();

};

this.zeroSensor = function () {

console.warn( 'THREE.VRControls: .zeroSensor() is now .resetPose().' );
this.resetPose();

};

this.dispose = function () {

vrDisplay = null;

};

};
Loading