SlideShare a Scribd company logo
1 of 127
Download to read offline
Getting Started in VR with JS
Getting Started in VR with JS
The Dream of the 90s is Alive!
#empirejs2015
MARRY ME, ALICIA!
GO SARNIA BEES!
20 years later …
Why would this time be any
different?
VR SHE WROTE
JavaScript FTW
WebVR allows us to work in JS “native” browser
environment.
What’s a headset?
WOAH!
your app renders
1. delivers position data to
2. surface to display
stereoscopic image
.js
A device that gives positional
data & a surface to draw on?
Sounds awful like a smart phone!
google.com/get/cardboard/
I’ll be giving these out
Come see me in the Q&A lounge after this and
throughout the conference.
Forgiveness
please …
I AM A (DEMO) GOD HERE
Demos available at c5vr.com
And also in the Q&A Lounge after.
Download ALL THE THINGS!
Drivers and SDK from developer.oculus.com
Firefox WebVR Browser from mozvr.com/downloads
Chromium WebVR Browser from bit.ly/1DPjgDQ
What is WebVR?
What it's not!
Not a Virtual Reality DOM
Not a WebGL replacement
WebGL is a framework to build your own 3D graphics
rendering pipeline.
Math is HARD
Computing per pixel transform and coloring takes a lot
of work.
Use three.js
Provides a higher level abstraction that is easier to work
with.
c5vr.com/no_vr.html
no_vr.html
<!DOCTYPE html>
<html lang="en">
<head>
<title>No VR</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<meta name="mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
<style>
body {
background-color: #000;
color: #fff;
margin: 0px;
padding: 0;
overflow: hidden;
}
</style>
</head>
<body>
<script src="js/three.js"></script>
<script src="js/no_vr.js"></script>
</body>
</html>
no_vr.html
</style>
</head>
<body>
<script src="js/three.js"></script>
<script src="js/no_vr.js"></script>
</body>
</html>
no_vr.js - Create a Renderer
var renderer = new THREE.WebGLRenderer({antialias: true});
renderer.setPixelRatio(window.devicePixelRatio);
renderer.setSize(window.innerWidth, window.innerHeight);
document.body.appendChild(renderer.domElement);
var scene = new THREE.Scene();
var camera = new THREE.PerspectiveCamera(
75, window.innerWidth / window.innerHeight, 0.3, 10000
);
var light = new THREE.PointLight(0xffffff, 1.0, 0);
light.position.set(0,0,0);
scene.add(light);
var bitGeometry = new THREE.DodecahedronGeometry(0.5);
no_vr.js - Let Your Scene be Seen
var renderer = new THREE.WebGLRenderer({antialias: true});
renderer.setPixelRatio(window.devicePixelRatio);
renderer.setSize(window.innerWidth, window.innerHeight);
document.body.appendChild(renderer.domElement);
var scene = new THREE.Scene();
var camera = new THREE.PerspectiveCamera(
75, window.innerWidth / window.innerHeight, 0.3, 10000
);
var light = new THREE.PointLight(0xffffff, 1.0, 0);
light.position.set(0,0,0);
scene.add(light);
var bitGeometry = new THREE.DodecahedronGeometry(0.5);
no_vr.js - Let there be light!
var renderer = new THREE.WebGLRenderer({antialias: true});
renderer.setPixelRatio(window.devicePixelRatio);
renderer.setSize(window.innerWidth, window.innerHeight);
document.body.appendChild(renderer.domElement);
var scene = new THREE.Scene();
var camera = new THREE.PerspectiveCamera(
75, window.innerWidth / window.innerHeight, 0.3, 10000
);
var light = new THREE.PointLight(0xffffff, 1.0, 0);
light.position.set(0,0,0);
scene.add(light);
var bitGeometry = new THREE.DodecahedronGeometry(0.5);
no_vr.js - Have Something to See
var light = new THREE.PointLight(0xffffff, 1.0, 0);
light.position.set(0,0,0);
scene.add(light);
var bitGeometry = new THREE.DodecahedronGeometry(0.5);
var bitMaterial = new THREE.MeshLambertMaterial({
color: 0x00ffff, shading: THREE.FlatShading
});
var bit = new THREE.Mesh(bitGeometry, bitMaterial);
bit.position.z = -2;
scene.add(bit);
var planeGeometry =
new THREE.PlaneBufferGeometry(1000, 1000, 1000);
var planeMaterial = new THREE.MeshPhongMaterial({
no_vr.js - Get Animated
scene.add(plane);
function animate(time) {
bit.position.x = Math.sin(time/1000) * 2;
bit.position.y = Math.sin(time/2000);
bit.rotation.y += 0.01;
bit.rotation.z += 0.01;
renderer.render(scene, camera);
requestAnimationFrame( animate );
}
animate();
no_vr.js - Get Animated
scene.add(plane);
function animate(time) {
bit.position.x = Math.sin(time/1000) * 2;
bit.position.y = Math.sin(time/2000);
bit.rotation.y += 0.01;
bit.rotation.z += 0.01;
renderer.render(scene, camera);
requestAnimationFrame( animate );
}
animate();
no_vr.js - Get Animated
scene.add(plane);
function animate(time) {
bit.position.x = Math.sin(time/1000) * 2;
bit.position.y = Math.sin(time/2000);
bit.rotation.y += 0.01;
bit.rotation.z += 0.01;
renderer.render(scene, camera);
requestAnimationFrame( animate );
}
animate();
no_vr.js - Get Animated
scene.add(plane);
function animate(time) {
bit.position.x = Math.sin(time/1000) * 2;
bit.position.y = Math.sin(time/2000);
bit.rotation.y += 0.01;
bit.rotation.z += 0.01;
renderer.render(scene, camera);
requestAnimationFrame( animate );
}
animate();
no_vr.js - Get Animated
scene.add(plane);
function animate(time) {
bit.position.x = Math.sin(time/1000) * 2;
bit.position.y = Math.sin(time/2000);
bit.rotation.y += 0.01;
bit.rotation.z += 0.01;
renderer.render(scene, camera);
requestAnimationFrame( animate );
}
animate();
Apply some
WebVR and …
c5vr.com/basic_vr.html
What is WebVR?
WebVR is a device interface
Detect and poll Head Mounted Displays (HMDs) and
other position reporting devices.
navigator.getVRDevices()
Through callback or promise returns a list of VR devices
of two types …
PositionSensorVRDevice
Information about position and orientation
HMDVRDevice
Informs you have a surface to render on and
information about the eyes.
Math is HARD
Translating all this is difficult, but luckily three.js comes
to the rescue.
Nearly all WebVR demos use
VRControls and VREffect
Found in three.js examples alongside other great
utilities.
github.com/mrdoob/three.js/tree/master/examples/js
basic_vr.html
<!DOCTYPE html>
<html lang="en">
<head>
<title>Basic VR</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<meta name="mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
<style>
body {
background-color: #000;
color: #fff;
margin: 0px;
padding: 0;
overflow: hidden;
}
</style>
</head>
<body>
<script src="js/three.js"></script>
<script src="js/VRControls.js"></script>
<script src="js/VREffect.js"></script>
<script src="js/basic_vr.js"></script>
</body>
</html>
basic_vr.html
</style>
</head>
<body>
<script src="js/three.js"></script>
<script src="js/VRControls.js"></script>
<script src="js/VREffect.js"></script>
<script src="js/basic_vr.js"></script>
</body>
</html>
basic_vr.js - Introduce VRControls
var renderer = new THREE.WebGLRenderer({antialias: true});
renderer.setPixelRatio(window.devicePixelRatio);
document.body.appendChild(renderer.domElement);
var scene = new THREE.Scene();
var camera = new THREE.PerspectiveCamera(
75, window.innerWidth / window.innerHeight, 0.3, 10000
);
var controls = new THREE.VRControls(camera);
var effect = new THREE.VREffect(renderer);
effect.setSize(window.innerWidth, window.innerHeight);
var light = new THREE.PointLight(0xffffff, 1.0, 15);
light.position.set(0,0,0);
VRControls
Handles PositionSensorDevice and manipulates the
camera orientation.
VRControl.js - Initialization
function gotVRDevices( devices )
devices = filterInvalidDevices( devices );
for ( var i = 0; i < devices.length; i ++ ) {
if ( devices[ i ] instanceof PositionSensorVRDevice ) {
vrInputs.push( devices[ i ] );
}
}
if ( onError ) onError( 'HMD not available' );
}
if ( navigator.getVRDevices ) {
navigator.getVRDevices().then( gotVRDevices );
}
basic_vr.js - Introduce VREffect
var renderer = new THREE.WebGLRenderer({antialias: true});
renderer.setPixelRatio(window.devicePixelRatio);
document.body.appendChild(renderer.domElement);
var scene = new THREE.Scene();
var camera = new THREE.PerspectiveCamera(
75, window.innerWidth / window.innerHeight, 0.3, 10000
);
var controls = new THREE.VRControls(camera);
var effect = new THREE.VREffect(renderer);
effect.setSize(window.innerWidth, window.innerHeight);
var light = new THREE.PointLight(0xffffff, 1.0, 15);
light.position.set(0,0,0);
VREffect
Handles HMDVRDevice and uses it to render a
stereoscopic view
VREffect.js - Initialization
function gotVRDevices( devices ) {
for ( var i = 0; i < devices.length; i ++ ) {
if ( devices[ i ] instanceof HMDVRDevice ) {
///…
}
if ( vrHMD === undefined ) {
if ( onError ) onError( 'HMD not available' );
}
}
VREffect.js - Remember the "..."
var eyeParamsL = vrHMD.getEyeParameters( 'left' );
var eyeParamsR = vrHMD.getEyeParameters( 'right' );
eyeTranslationL = eyeParamsL.eyeTranslation;
eyeTranslationR = eyeParamsR.eyeTranslation;
eyeFOVL = eyeParamsL.recommendedFieldOfView;
eyeFOVR = eyeParamsR.recommendedFieldOfView;
basic_vr.js - Go Full Screen
var vrMode = false;
function enterVR() {
effect.setFullScreen(true);
vrMode = true;
}
function exitVR() {
effect.setFullScreen(false);
vrMode = false;
};
function toggleVR() {
if (!vrMode) {
enterVR();
VREffect - Full Screen VR display
this.setFullScreen = function ( boolean ) {
if ( vrHMD === undefined ) return;
if ( isFullscreen === boolean ) return;
if ( canvas.mozRequestFullScreen ) {
canvas.mozRequestFullScreen( { vrDisplay: vrHMD } );
} else if ( canvas.webkitRequestFullscreen ) {
canvas.webkitRequestFullscreen( { vrDisplay: vrHMD } );
}
};
basic_vr.js - Let Reality Take Control
function animate(time) {
bit.position.x = Math.sin(time/1000) * 2;
bit.position.y = Math.sin(time/2000);
bit.rotation.y += 0.01;
bit.rotation.z += 0.01;
controls.update();
effect.render(scene, camera);
requestAnimationFrame( animate );
}
animate();
VRControls.js - Get State from VR Device
this.update = function () {
for ( var i = 0; i < vrInputs.length; i ++ ) {
var vrInput = vrInputs[ i ];
var state = vrInput.getState();
if ( state.orientation !== null ) {
object.quaternion.copy( state.orientation );
}
if ( state.position !== null ) {
object.position.copy( state.position )
.multiplyScalar( scope.scale );
}
}
};
basic_vr.js - The Full VR Effect
function animate(time) {
bit.position.x = Math.sin(time/1000) * 2;
bit.position.y = Math.sin(time/2000);
bit.rotation.y += 0.01;
bit.rotation.z += 0.01;
controls.update();
effect.render(scene, camera);
requestAnimationFrame( animate );
}
animate();
Two Cameras for the price of
ONE!
It creates a camera for each eye, shifts them from the
main camera location based on HMDVRDevice eye
information, then renders the view for each!
Confession
This doesn’t work on mobile
browsers!
WebVR is still in development.
webvr-polyfill
Supplies Mobile device gyroscope as
PositionSensorVRDevice, screen as HMDDevice.
github.com/borismus/webvr-polyfill
webvr-boilerplate
A very basic skeleton much like you’ve seen here today.
github.com/borismus/webvr-boilerplate
basic_vr_mobile.html - Drop It In
<!DOCTYPE html>
<html lang="en">
<head>
<title>Basic VR Mobile</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<meta name="mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
<style>
body {
background-color: #000;
color: #fff;
margin: 0px;
padding: 0;
overflow: hidden;
}
</style>
</head>
<body>
<script src="js/three.js"></script>
<script src="js/VRControls.js"></script>
<script src="js/VREffect.js"></script>
<script src="js/webvr-polyfill.js"></script>
<script src="js/basic_vr.js"></script>
</body>
</html>
basic_vr_mobile.html - Drop It In
</style>
</head>
<body>
<script src="js/three.js"></script>
<script src="js/VRControls.js"></script>
<script src="js/VREffect.js"></script>
<script src="js/webvr-polyfill.js"></script>
<script src="js/basic_vr.js"></script>
</body>
</html>
I know what
you’re thinking …
Simulator Sickness is Real …
Need to hit 60-90 fps.
Motion data already laggy.
Additional disadvantage of being in browser.
More graphics you push the harder this gets.
Consider 360 Video
Spherically map videos
around each camera/eye
Again, math is HARD!
See three.js vr_video or eleVR-Web-Player for example.
Interaction
All the HTML5 Things
Keyboard, mouse, gamepad …
Leap Motion is Strongly
Embracing WebVR
Works directly with three.js
leapmotion.com/product/vr
c5vr.com/leap_motion.html
leap_motion.html
<!DOCTYPE html>
<html lang="en">
<head>
<title>Leap Motion VR</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<meta name="mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
<style>
body {
background-color: #000;
color: #fff;
margin: 0px;
padding: 0;
overflow: hidden;
}
</style>
</head>
<body>
<script src="js/three.js"></script>
<script src="js/VRControls.js"></script>
<script src="js/VREffect.js"></script>
<script src="js/webvr-polyfill.js"></script>
<script src="//js.leapmotion.com/leap-0.6.3.min.js"></script>
<script src="//js.leapmotion.com/leap-plugins-0.1.9.min.js"></script>
<script src="//js.leapmotion.com/leap.rigged-hand-0.1.7.min.js"></script>
<script src="js/leap_motion.js"></script>
</body>
</html>
leap_motion.html
</style>
</head>
<body>
<script src="js/three.js"></script>
<script src="js/VRControls.js"></script>
<script src="js/VREffect.js"></script>
<script src="js/webvr-polyfill.js"></script>
<script src="//js.leapmotion.com/leap-0.6.3.min.js"></script>
<script src="//js.leapmotion.com/leap-plugins-0.1.9.min.js"></
script>
<script src="//js.leapmotion.com/leap.rigged-hand-0.1.7.min.js"
script>
<script src="js/leap_motion.js"></script>
</body>
</html>
leap_motion.js
Leap.loop();
Leap.loopController.use('transform', {
vr: true,
effectiveParent: camera
});
Leap.loopController.use('riggedHand', {
parent: scene,
renderer: renderer,
materialOptions: {
emissive: new THREE.Color(0x00aaaa)
}
});
animate();
Confession 2.0
This doesn’t work on mobile*
* without hacks
One interaction
to rule them all
Gaze
Where you are looking can trigger changes, from
environment to storyline.
c5vr.com/raycast_vr.html
raycast.js - Gaze
var raycaster = new THREE.Raycaster();
var center = new THREE.Vector2();
function gaze() {
if(!audioPlaying) {
raycaster.setFromCamera(center, camera);
var intersects = raycaster.intersectObjects([bit]);
if (intersects.length > 0) {
audioPlaying = true;
if (Math.random() < 0.5) {
switchBitTo(1);
yes.play();
} else {
switchBitTo(0);
no.play();
Responsive VR
For “simple” devices, it’s a roller coaster ride.
More complex, more interactions.
Math is HARD
Collision detection, physics, etc.
Unity publishes to multiple
platforms
Plugins for VR available. Support directly baked in 5.1
#pragma strict
var center : GameObject;
var axis : Vector3;
function Start () {
}
function Update () {
transform.RotateAround(
center.transform.position, axis,30 * Time.deltaTime
);
}
Orbit.js
Cores.js
function beingLookedAt() {
var hit : RaycastHit;
var ray = new Ray(Camera.main.transform.position,
Camera.main.transform.forward);
return GetComponent
.<Collider>()
.Raycast(ray, hit, Mathf.Infinity);
}
Unity now exports to WebGL
An idea …
Build a WebVR Unity plugin
Bridges when publishing to WebGL.
Design once, distribute everywhere, run anywhere.
NOW YOU’RE PLAYING WITH POWER
Gotchas
Again, Simulator Sickness is
Real …
It’ll get better, but start with easy motions
3D Modelling is Hard
Spent most of my time on it.
Develop interactions first!
Then find a friend.
The ground is constantly
changing
Beta Software running on Beta Hardware.
Things break constantly.
So that’s it …
Except for one thing …?
Why would this time be any
different?
Answer: Because of you …
Thanks!
e: rudy@carbonfive.com
t: @rudy

More Related Content

What's hot

The next frontier: WebGL and WebVR
The next frontier: WebGL and WebVRThe next frontier: WebGL and WebVR
The next frontier: WebGL and WebVRCodemotion
 
Introduction to WebVR Autodesk Forge 2016
Introduction to WebVR Autodesk Forge 2016Introduction to WebVR Autodesk Forge 2016
Introduction to WebVR Autodesk Forge 2016Tony Parisi
 
Introduction to A-Frame
Introduction to A-FrameIntroduction to A-Frame
Introduction to A-FrameDaosheng Mu
 
Getting Started with Web VR
Getting Started with Web VR Getting Started with Web VR
Getting Started with Web VR Saurabh Badhwar
 
A-Frame: VR for Web Developers
A-Frame: VR for Web DevelopersA-Frame: VR for Web Developers
A-Frame: VR for Web DevelopersKevin Ngo
 
A frame beginner lesson
A frame beginner lessonA frame beginner lesson
A frame beginner lessonDaosheng Mu
 
Writing Virtual And Augmented Reality Apps With Web Technology
Writing Virtual And Augmented Reality Apps With Web TechnologyWriting Virtual And Augmented Reality Apps With Web Technology
Writing Virtual And Augmented Reality Apps With Web TechnologyMichaela Lehr
 
Augmented Reality in JavaScript
Augmented Reality in JavaScriptAugmented Reality in JavaScript
Augmented Reality in JavaScriptZeno Rocha
 
AI x WebXR: フェイストラッキングを用いた擬似3D表現を解説!
AI x WebXR: フェイストラッキングを用いた擬似3D表現を解説!AI x WebXR: フェイストラッキングを用いた擬似3D表現を解説!
AI x WebXR: フェイストラッキングを用いた擬似3D表現を解説!Takashi Yoshinaga
 
Javascript Memory leaks and Performance & Angular
Javascript Memory leaks and Performance & AngularJavascript Memory leaks and Performance & Angular
Javascript Memory leaks and Performance & AngularErik Guzman
 
AngularJS - Overcoming performance issues. Limits.
AngularJS - Overcoming performance issues. Limits.AngularJS - Overcoming performance issues. Limits.
AngularJS - Overcoming performance issues. Limits.Dragos Mihai Rusu
 
React & The Art of Managing Complexity
React &  The Art of Managing ComplexityReact &  The Art of Managing Complexity
React & The Art of Managing ComplexityRyan Anklam
 
Developing for Mobile
Developing for MobileDeveloping for Mobile
Developing for MobileRemy Sharp
 
Going Node At Netflix
Going Node At NetflixGoing Node At Netflix
Going Node At NetflixRyan Anklam
 
Web Standards for AR workshop at ISMAR13
Web Standards for AR workshop at ISMAR13Web Standards for AR workshop at ISMAR13
Web Standards for AR workshop at ISMAR13Rob Manson
 
Puppeteer can automate that! - Frontmania
Puppeteer can automate that! - FrontmaniaPuppeteer can automate that! - Frontmania
Puppeteer can automate that! - FrontmaniaÖnder Ceylan
 

What's hot (20)

The next frontier: WebGL and WebVR
The next frontier: WebGL and WebVRThe next frontier: WebGL and WebVR
The next frontier: WebGL and WebVR
 
Introduction to WebVR Autodesk Forge 2016
Introduction to WebVR Autodesk Forge 2016Introduction to WebVR Autodesk Forge 2016
Introduction to WebVR Autodesk Forge 2016
 
Web vr creative_vr
Web vr creative_vrWeb vr creative_vr
Web vr creative_vr
 
Introduction to A-Frame
Introduction to A-FrameIntroduction to A-Frame
Introduction to A-Frame
 
Getting Started with Web VR
Getting Started with Web VR Getting Started with Web VR
Getting Started with Web VR
 
A-Frame: VR for Web Developers
A-Frame: VR for Web DevelopersA-Frame: VR for Web Developers
A-Frame: VR for Web Developers
 
Maze VR
Maze VRMaze VR
Maze VR
 
Webrender 1.0
Webrender 1.0Webrender 1.0
Webrender 1.0
 
A frame beginner lesson
A frame beginner lessonA frame beginner lesson
A frame beginner lesson
 
Writing Virtual And Augmented Reality Apps With Web Technology
Writing Virtual And Augmented Reality Apps With Web TechnologyWriting Virtual And Augmented Reality Apps With Web Technology
Writing Virtual And Augmented Reality Apps With Web Technology
 
WebVR
WebVRWebVR
WebVR
 
Augmented Reality in JavaScript
Augmented Reality in JavaScriptAugmented Reality in JavaScript
Augmented Reality in JavaScript
 
AI x WebXR: フェイストラッキングを用いた擬似3D表現を解説!
AI x WebXR: フェイストラッキングを用いた擬似3D表現を解説!AI x WebXR: フェイストラッキングを用いた擬似3D表現を解説!
AI x WebXR: フェイストラッキングを用いた擬似3D表現を解説!
 
Javascript Memory leaks and Performance & Angular
Javascript Memory leaks and Performance & AngularJavascript Memory leaks and Performance & Angular
Javascript Memory leaks and Performance & Angular
 
AngularJS - Overcoming performance issues. Limits.
AngularJS - Overcoming performance issues. Limits.AngularJS - Overcoming performance issues. Limits.
AngularJS - Overcoming performance issues. Limits.
 
React & The Art of Managing Complexity
React &  The Art of Managing ComplexityReact &  The Art of Managing Complexity
React & The Art of Managing Complexity
 
Developing for Mobile
Developing for MobileDeveloping for Mobile
Developing for Mobile
 
Going Node At Netflix
Going Node At NetflixGoing Node At Netflix
Going Node At Netflix
 
Web Standards for AR workshop at ISMAR13
Web Standards for AR workshop at ISMAR13Web Standards for AR workshop at ISMAR13
Web Standards for AR workshop at ISMAR13
 
Puppeteer can automate that! - Frontmania
Puppeteer can automate that! - FrontmaniaPuppeteer can automate that! - Frontmania
Puppeteer can automate that! - Frontmania
 

Viewers also liked

VR Development with JavaScript
VR Development with JavaScriptVR Development with JavaScript
VR Development with JavaScriptSchezarnie Racip
 
iOSDevCamp 2011 - Getting "Test"-y: Test Driven Development & Automated Deplo...
iOSDevCamp 2011 - Getting "Test"-y: Test Driven Development & Automated Deplo...iOSDevCamp 2011 - Getting "Test"-y: Test Driven Development & Automated Deplo...
iOSDevCamp 2011 - Getting "Test"-y: Test Driven Development & Automated Deplo...Rudy Jahchan
 
Philipp Nagele (Wikitude) Wikitude SDK Tutorial
Philipp Nagele (Wikitude) Wikitude SDK Tutorial Philipp Nagele (Wikitude) Wikitude SDK Tutorial
Philipp Nagele (Wikitude) Wikitude SDK Tutorial AugmentedWorldExpo
 
PlacifyMe - Location-based Mobile Application
PlacifyMe - Location-based Mobile ApplicationPlacifyMe - Location-based Mobile Application
PlacifyMe - Location-based Mobile ApplicationShady El Mansoury
 
Wally Young (DAQRI) The Path to ARToolKit 6
Wally Young (DAQRI) The Path to ARToolKit 6Wally Young (DAQRI) The Path to ARToolKit 6
Wally Young (DAQRI) The Path to ARToolKit 6AugmentedWorldExpo
 
Augmented Reality Using The Wikitude API
Augmented Reality Using The Wikitude APIAugmented Reality Using The Wikitude API
Augmented Reality Using The Wikitude APIjgilfelt
 
Layar code examples for developers
Layar code examples for developersLayar code examples for developers
Layar code examples for developersLayar
 
Layar introduction for developers
Layar introduction for developersLayar introduction for developers
Layar introduction for developersLayar
 
Augmented Reality Application Tutorial for Education 1
Augmented  Reality Application Tutorial for Education 1Augmented  Reality Application Tutorial for Education 1
Augmented Reality Application Tutorial for Education 1Isidro Navarro
 
Augmented Reality Fieldtrips
Augmented Reality FieldtripsAugmented Reality Fieldtrips
Augmented Reality FieldtripsMark Rollins
 

Viewers also liked (11)

VR Development with JavaScript
VR Development with JavaScriptVR Development with JavaScript
VR Development with JavaScript
 
iOSDevCamp 2011 - Getting "Test"-y: Test Driven Development & Automated Deplo...
iOSDevCamp 2011 - Getting "Test"-y: Test Driven Development & Automated Deplo...iOSDevCamp 2011 - Getting "Test"-y: Test Driven Development & Automated Deplo...
iOSDevCamp 2011 - Getting "Test"-y: Test Driven Development & Automated Deplo...
 
Philipp Nagele (Wikitude) Wikitude SDK Tutorial
Philipp Nagele (Wikitude) Wikitude SDK Tutorial Philipp Nagele (Wikitude) Wikitude SDK Tutorial
Philipp Nagele (Wikitude) Wikitude SDK Tutorial
 
PlacifyMe - Location-based Mobile Application
PlacifyMe - Location-based Mobile ApplicationPlacifyMe - Location-based Mobile Application
PlacifyMe - Location-based Mobile Application
 
Mobile AR Tutorial
Mobile AR TutorialMobile AR Tutorial
Mobile AR Tutorial
 
Wally Young (DAQRI) The Path to ARToolKit 6
Wally Young (DAQRI) The Path to ARToolKit 6Wally Young (DAQRI) The Path to ARToolKit 6
Wally Young (DAQRI) The Path to ARToolKit 6
 
Augmented Reality Using The Wikitude API
Augmented Reality Using The Wikitude APIAugmented Reality Using The Wikitude API
Augmented Reality Using The Wikitude API
 
Layar code examples for developers
Layar code examples for developersLayar code examples for developers
Layar code examples for developers
 
Layar introduction for developers
Layar introduction for developersLayar introduction for developers
Layar introduction for developers
 
Augmented Reality Application Tutorial for Education 1
Augmented  Reality Application Tutorial for Education 1Augmented  Reality Application Tutorial for Education 1
Augmented Reality Application Tutorial for Education 1
 
Augmented Reality Fieldtrips
Augmented Reality FieldtripsAugmented Reality Fieldtrips
Augmented Reality Fieldtrips
 

Similar to Getting Started in VR with JS

How to Make Your Users Sick in 60 Seconds – About UX Design, WebVR and React VR
How to Make Your Users Sick in 60 Seconds – About UX Design, WebVR and React VRHow to Make Your Users Sick in 60 Seconds – About UX Design, WebVR and React VR
How to Make Your Users Sick in 60 Seconds – About UX Design, WebVR and React VRGeilDanke
 
Migrating your Web app to Virtual Reality
Migrating your Web app to Virtual RealityMigrating your Web app to Virtual Reality
Migrating your Web app to Virtual RealityDenis Radin
 
Leaving Flatland: getting started with WebGL
Leaving Flatland: getting started with WebGLLeaving Flatland: getting started with WebGL
Leaving Flatland: getting started with WebGLgerbille
 
Goodbye, Flatland! An introduction to WebVR and what it means for web developers
Goodbye, Flatland! An introduction to WebVR and what it means for web developersGoodbye, Flatland! An introduction to WebVR and what it means for web developers
Goodbye, Flatland! An introduction to WebVR and what it means for web developersGeilDanke
 
Creating the interfaces of the future with the APIs of today
Creating the interfaces of the future with the APIs of todayCreating the interfaces of the future with the APIs of today
Creating the interfaces of the future with the APIs of todaygerbille
 
Портируем существующее Web-приложение в виртуальную реальность / Денис Радин ...
Портируем существующее Web-приложение в виртуальную реальность / Денис Радин ...Портируем существующее Web-приложение в виртуальную реальность / Денис Радин ...
Портируем существующее Web-приложение в виртуальную реальность / Денис Радин ...Ontico
 
Augmented reality in web rtc browser
Augmented reality in web rtc browserAugmented reality in web rtc browser
Augmented reality in web rtc browserALTANAI BISHT
 
Webgl para JavaScripters
Webgl para JavaScriptersWebgl para JavaScripters
Webgl para JavaScriptersgerbille
 
Android Camera Architecture
Android Camera ArchitectureAndroid Camera Architecture
Android Camera ArchitecturePicker Weng
 
Begin three.js.key
Begin three.js.keyBegin three.js.key
Begin three.js.keyYi-Fan Liao
 
Android Wear Essentials
Android Wear EssentialsAndroid Wear Essentials
Android Wear EssentialsNilhcem
 
Useful Tools for Making Video Games - XNA (2008)
Useful Tools for Making Video Games - XNA (2008)Useful Tools for Making Video Games - XNA (2008)
Useful Tools for Making Video Games - XNA (2008)Korhan Bircan
 
Writing Virtual And Augmented Reality Apps With Web Technology
Writing Virtual And Augmented Reality Apps With Web TechnologyWriting Virtual And Augmented Reality Apps With Web Technology
Writing Virtual And Augmented Reality Apps With Web TechnologyGeilDanke
 
Developing AIR for Android with Flash Professional
Developing AIR for Android with Flash ProfessionalDeveloping AIR for Android with Flash Professional
Developing AIR for Android with Flash ProfessionalChris Griffith
 
Enhance your world with ARKit. UA Mobile 2017.
Enhance your world with ARKit. UA Mobile 2017.Enhance your world with ARKit. UA Mobile 2017.
Enhance your world with ARKit. UA Mobile 2017.UA Mobile
 
Giovanni Laquidara - Hello ARCore - Codemotion Milan 2017
Giovanni Laquidara - Hello ARCore - Codemotion Milan 2017Giovanni Laquidara - Hello ARCore - Codemotion Milan 2017
Giovanni Laquidara - Hello ARCore - Codemotion Milan 2017Codemotion
 
From Hello World to the Interactive Web with Three.js: Workshop at FutureJS 2014
From Hello World to the Interactive Web with Three.js: Workshop at FutureJS 2014From Hello World to the Interactive Web with Three.js: Workshop at FutureJS 2014
From Hello World to the Interactive Web with Three.js: Workshop at FutureJS 2014Verold
 
Capture image on eye blink
Capture image on eye blinkCapture image on eye blink
Capture image on eye blinkInnovationM
 
Android design and Custom views
Android design and Custom views Android design and Custom views
Android design and Custom views Lars Vogel
 
Marionette: the Backbone framework
Marionette: the Backbone frameworkMarionette: the Backbone framework
Marionette: the Backbone frameworkfrontendne
 

Similar to Getting Started in VR with JS (20)

How to Make Your Users Sick in 60 Seconds – About UX Design, WebVR and React VR
How to Make Your Users Sick in 60 Seconds – About UX Design, WebVR and React VRHow to Make Your Users Sick in 60 Seconds – About UX Design, WebVR and React VR
How to Make Your Users Sick in 60 Seconds – About UX Design, WebVR and React VR
 
Migrating your Web app to Virtual Reality
Migrating your Web app to Virtual RealityMigrating your Web app to Virtual Reality
Migrating your Web app to Virtual Reality
 
Leaving Flatland: getting started with WebGL
Leaving Flatland: getting started with WebGLLeaving Flatland: getting started with WebGL
Leaving Flatland: getting started with WebGL
 
Goodbye, Flatland! An introduction to WebVR and what it means for web developers
Goodbye, Flatland! An introduction to WebVR and what it means for web developersGoodbye, Flatland! An introduction to WebVR and what it means for web developers
Goodbye, Flatland! An introduction to WebVR and what it means for web developers
 
Creating the interfaces of the future with the APIs of today
Creating the interfaces of the future with the APIs of todayCreating the interfaces of the future with the APIs of today
Creating the interfaces of the future with the APIs of today
 
Портируем существующее Web-приложение в виртуальную реальность / Денис Радин ...
Портируем существующее Web-приложение в виртуальную реальность / Денис Радин ...Портируем существующее Web-приложение в виртуальную реальность / Денис Радин ...
Портируем существующее Web-приложение в виртуальную реальность / Денис Радин ...
 
Augmented reality in web rtc browser
Augmented reality in web rtc browserAugmented reality in web rtc browser
Augmented reality in web rtc browser
 
Webgl para JavaScripters
Webgl para JavaScriptersWebgl para JavaScripters
Webgl para JavaScripters
 
Android Camera Architecture
Android Camera ArchitectureAndroid Camera Architecture
Android Camera Architecture
 
Begin three.js.key
Begin three.js.keyBegin three.js.key
Begin three.js.key
 
Android Wear Essentials
Android Wear EssentialsAndroid Wear Essentials
Android Wear Essentials
 
Useful Tools for Making Video Games - XNA (2008)
Useful Tools for Making Video Games - XNA (2008)Useful Tools for Making Video Games - XNA (2008)
Useful Tools for Making Video Games - XNA (2008)
 
Writing Virtual And Augmented Reality Apps With Web Technology
Writing Virtual And Augmented Reality Apps With Web TechnologyWriting Virtual And Augmented Reality Apps With Web Technology
Writing Virtual And Augmented Reality Apps With Web Technology
 
Developing AIR for Android with Flash Professional
Developing AIR for Android with Flash ProfessionalDeveloping AIR for Android with Flash Professional
Developing AIR for Android with Flash Professional
 
Enhance your world with ARKit. UA Mobile 2017.
Enhance your world with ARKit. UA Mobile 2017.Enhance your world with ARKit. UA Mobile 2017.
Enhance your world with ARKit. UA Mobile 2017.
 
Giovanni Laquidara - Hello ARCore - Codemotion Milan 2017
Giovanni Laquidara - Hello ARCore - Codemotion Milan 2017Giovanni Laquidara - Hello ARCore - Codemotion Milan 2017
Giovanni Laquidara - Hello ARCore - Codemotion Milan 2017
 
From Hello World to the Interactive Web with Three.js: Workshop at FutureJS 2014
From Hello World to the Interactive Web with Three.js: Workshop at FutureJS 2014From Hello World to the Interactive Web with Three.js: Workshop at FutureJS 2014
From Hello World to the Interactive Web with Three.js: Workshop at FutureJS 2014
 
Capture image on eye blink
Capture image on eye blinkCapture image on eye blink
Capture image on eye blink
 
Android design and Custom views
Android design and Custom views Android design and Custom views
Android design and Custom views
 
Marionette: the Backbone framework
Marionette: the Backbone frameworkMarionette: the Backbone framework
Marionette: the Backbone framework
 

Recently uploaded

Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDGMarianaLemus7
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Science&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfScience&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfjimielynbastida
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 

Recently uploaded (20)

Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDG
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Science&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfScience&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdf
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 

Getting Started in VR with JS

  • 1. Getting Started in VR with JS
  • 2. Getting Started in VR with JS The Dream of the 90s is Alive! #empirejs2015
  • 3.
  • 4.
  • 5.
  • 6.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 15.
  • 16.
  • 17.
  • 18. Why would this time be any different?
  • 20. JavaScript FTW WebVR allows us to work in JS “native” browser environment.
  • 21.
  • 22.
  • 23.
  • 24. What’s a headset? WOAH! your app renders 1. delivers position data to 2. surface to display stereoscopic image .js
  • 25. A device that gives positional data & a surface to draw on? Sounds awful like a smart phone!
  • 26.
  • 28. I’ll be giving these out Come see me in the Q&A lounge after this and throughout the conference.
  • 30. I AM A (DEMO) GOD HERE
  • 31. Demos available at c5vr.com And also in the Q&A Lounge after.
  • 32. Download ALL THE THINGS! Drivers and SDK from developer.oculus.com Firefox WebVR Browser from mozvr.com/downloads Chromium WebVR Browser from bit.ly/1DPjgDQ
  • 35. Not a Virtual Reality DOM
  • 36.
  • 37.
  • 38.
  • 39. Not a WebGL replacement WebGL is a framework to build your own 3D graphics rendering pipeline.
  • 40. Math is HARD Computing per pixel transform and coloring takes a lot of work.
  • 41.
  • 42. Use three.js Provides a higher level abstraction that is easier to work with.
  • 44. no_vr.html <!DOCTYPE html> <html lang="en"> <head> <title>No VR</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0"> <meta name="mobile-web-app-capable" content="yes"> <meta name="apple-mobile-web-app-capable" content="yes" /> <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" /> <style> body { background-color: #000; color: #fff; margin: 0px; padding: 0; overflow: hidden; } </style> </head> <body> <script src="js/three.js"></script> <script src="js/no_vr.js"></script> </body> </html>
  • 46. no_vr.js - Create a Renderer var renderer = new THREE.WebGLRenderer({antialias: true}); renderer.setPixelRatio(window.devicePixelRatio); renderer.setSize(window.innerWidth, window.innerHeight); document.body.appendChild(renderer.domElement); var scene = new THREE.Scene(); var camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 0.3, 10000 ); var light = new THREE.PointLight(0xffffff, 1.0, 0); light.position.set(0,0,0); scene.add(light); var bitGeometry = new THREE.DodecahedronGeometry(0.5);
  • 47. no_vr.js - Let Your Scene be Seen var renderer = new THREE.WebGLRenderer({antialias: true}); renderer.setPixelRatio(window.devicePixelRatio); renderer.setSize(window.innerWidth, window.innerHeight); document.body.appendChild(renderer.domElement); var scene = new THREE.Scene(); var camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 0.3, 10000 ); var light = new THREE.PointLight(0xffffff, 1.0, 0); light.position.set(0,0,0); scene.add(light); var bitGeometry = new THREE.DodecahedronGeometry(0.5);
  • 48. no_vr.js - Let there be light! var renderer = new THREE.WebGLRenderer({antialias: true}); renderer.setPixelRatio(window.devicePixelRatio); renderer.setSize(window.innerWidth, window.innerHeight); document.body.appendChild(renderer.domElement); var scene = new THREE.Scene(); var camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 0.3, 10000 ); var light = new THREE.PointLight(0xffffff, 1.0, 0); light.position.set(0,0,0); scene.add(light); var bitGeometry = new THREE.DodecahedronGeometry(0.5);
  • 49. no_vr.js - Have Something to See var light = new THREE.PointLight(0xffffff, 1.0, 0); light.position.set(0,0,0); scene.add(light); var bitGeometry = new THREE.DodecahedronGeometry(0.5); var bitMaterial = new THREE.MeshLambertMaterial({ color: 0x00ffff, shading: THREE.FlatShading }); var bit = new THREE.Mesh(bitGeometry, bitMaterial); bit.position.z = -2; scene.add(bit); var planeGeometry = new THREE.PlaneBufferGeometry(1000, 1000, 1000); var planeMaterial = new THREE.MeshPhongMaterial({
  • 50. no_vr.js - Get Animated scene.add(plane); function animate(time) { bit.position.x = Math.sin(time/1000) * 2; bit.position.y = Math.sin(time/2000); bit.rotation.y += 0.01; bit.rotation.z += 0.01; renderer.render(scene, camera); requestAnimationFrame( animate ); } animate();
  • 51. no_vr.js - Get Animated scene.add(plane); function animate(time) { bit.position.x = Math.sin(time/1000) * 2; bit.position.y = Math.sin(time/2000); bit.rotation.y += 0.01; bit.rotation.z += 0.01; renderer.render(scene, camera); requestAnimationFrame( animate ); } animate();
  • 52. no_vr.js - Get Animated scene.add(plane); function animate(time) { bit.position.x = Math.sin(time/1000) * 2; bit.position.y = Math.sin(time/2000); bit.rotation.y += 0.01; bit.rotation.z += 0.01; renderer.render(scene, camera); requestAnimationFrame( animate ); } animate();
  • 53. no_vr.js - Get Animated scene.add(plane); function animate(time) { bit.position.x = Math.sin(time/1000) * 2; bit.position.y = Math.sin(time/2000); bit.rotation.y += 0.01; bit.rotation.z += 0.01; renderer.render(scene, camera); requestAnimationFrame( animate ); } animate();
  • 54. no_vr.js - Get Animated scene.add(plane); function animate(time) { bit.position.x = Math.sin(time/1000) * 2; bit.position.y = Math.sin(time/2000); bit.rotation.y += 0.01; bit.rotation.z += 0.01; renderer.render(scene, camera); requestAnimationFrame( animate ); } animate();
  • 58.
  • 59. WebVR is a device interface Detect and poll Head Mounted Displays (HMDs) and other position reporting devices.
  • 60. navigator.getVRDevices() Through callback or promise returns a list of VR devices of two types …
  • 62. HMDVRDevice Informs you have a surface to render on and information about the eyes.
  • 63. Math is HARD Translating all this is difficult, but luckily three.js comes to the rescue.
  • 64. Nearly all WebVR demos use VRControls and VREffect Found in three.js examples alongside other great utilities. github.com/mrdoob/three.js/tree/master/examples/js
  • 65. basic_vr.html <!DOCTYPE html> <html lang="en"> <head> <title>Basic VR</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0"> <meta name="mobile-web-app-capable" content="yes"> <meta name="apple-mobile-web-app-capable" content="yes" /> <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" /> <style> body { background-color: #000; color: #fff; margin: 0px; padding: 0; overflow: hidden; } </style> </head> <body> <script src="js/three.js"></script> <script src="js/VRControls.js"></script> <script src="js/VREffect.js"></script> <script src="js/basic_vr.js"></script> </body> </html>
  • 66. basic_vr.html </style> </head> <body> <script src="js/three.js"></script> <script src="js/VRControls.js"></script> <script src="js/VREffect.js"></script> <script src="js/basic_vr.js"></script> </body> </html>
  • 67. basic_vr.js - Introduce VRControls var renderer = new THREE.WebGLRenderer({antialias: true}); renderer.setPixelRatio(window.devicePixelRatio); document.body.appendChild(renderer.domElement); var scene = new THREE.Scene(); var camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 0.3, 10000 ); var controls = new THREE.VRControls(camera); var effect = new THREE.VREffect(renderer); effect.setSize(window.innerWidth, window.innerHeight); var light = new THREE.PointLight(0xffffff, 1.0, 15); light.position.set(0,0,0);
  • 68. VRControls Handles PositionSensorDevice and manipulates the camera orientation.
  • 69. VRControl.js - Initialization function gotVRDevices( devices ) devices = filterInvalidDevices( devices ); for ( var i = 0; i < devices.length; i ++ ) { if ( devices[ i ] instanceof PositionSensorVRDevice ) { vrInputs.push( devices[ i ] ); } } if ( onError ) onError( 'HMD not available' ); } if ( navigator.getVRDevices ) { navigator.getVRDevices().then( gotVRDevices ); }
  • 70. basic_vr.js - Introduce VREffect var renderer = new THREE.WebGLRenderer({antialias: true}); renderer.setPixelRatio(window.devicePixelRatio); document.body.appendChild(renderer.domElement); var scene = new THREE.Scene(); var camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 0.3, 10000 ); var controls = new THREE.VRControls(camera); var effect = new THREE.VREffect(renderer); effect.setSize(window.innerWidth, window.innerHeight); var light = new THREE.PointLight(0xffffff, 1.0, 15); light.position.set(0,0,0);
  • 71. VREffect Handles HMDVRDevice and uses it to render a stereoscopic view
  • 72. VREffect.js - Initialization function gotVRDevices( devices ) { for ( var i = 0; i < devices.length; i ++ ) { if ( devices[ i ] instanceof HMDVRDevice ) { ///… } if ( vrHMD === undefined ) { if ( onError ) onError( 'HMD not available' ); } }
  • 73. VREffect.js - Remember the "..." var eyeParamsL = vrHMD.getEyeParameters( 'left' ); var eyeParamsR = vrHMD.getEyeParameters( 'right' ); eyeTranslationL = eyeParamsL.eyeTranslation; eyeTranslationR = eyeParamsR.eyeTranslation; eyeFOVL = eyeParamsL.recommendedFieldOfView; eyeFOVR = eyeParamsR.recommendedFieldOfView;
  • 74. basic_vr.js - Go Full Screen var vrMode = false; function enterVR() { effect.setFullScreen(true); vrMode = true; } function exitVR() { effect.setFullScreen(false); vrMode = false; }; function toggleVR() { if (!vrMode) { enterVR();
  • 75. VREffect - Full Screen VR display this.setFullScreen = function ( boolean ) { if ( vrHMD === undefined ) return; if ( isFullscreen === boolean ) return; if ( canvas.mozRequestFullScreen ) { canvas.mozRequestFullScreen( { vrDisplay: vrHMD } ); } else if ( canvas.webkitRequestFullscreen ) { canvas.webkitRequestFullscreen( { vrDisplay: vrHMD } ); } };
  • 76. basic_vr.js - Let Reality Take Control function animate(time) { bit.position.x = Math.sin(time/1000) * 2; bit.position.y = Math.sin(time/2000); bit.rotation.y += 0.01; bit.rotation.z += 0.01; controls.update(); effect.render(scene, camera); requestAnimationFrame( animate ); } animate();
  • 77. VRControls.js - Get State from VR Device this.update = function () { for ( var i = 0; i < vrInputs.length; i ++ ) { var vrInput = vrInputs[ i ]; var state = vrInput.getState(); if ( state.orientation !== null ) { object.quaternion.copy( state.orientation ); } if ( state.position !== null ) { object.position.copy( state.position ) .multiplyScalar( scope.scale ); } } };
  • 78. basic_vr.js - The Full VR Effect function animate(time) { bit.position.x = Math.sin(time/1000) * 2; bit.position.y = Math.sin(time/2000); bit.rotation.y += 0.01; bit.rotation.z += 0.01; controls.update(); effect.render(scene, camera); requestAnimationFrame( animate ); } animate();
  • 79. Two Cameras for the price of ONE! It creates a camera for each eye, shifts them from the main camera location based on HMDVRDevice eye information, then renders the view for each!
  • 81. This doesn’t work on mobile browsers! WebVR is still in development.
  • 82.
  • 83. webvr-polyfill Supplies Mobile device gyroscope as PositionSensorVRDevice, screen as HMDDevice. github.com/borismus/webvr-polyfill
  • 84. webvr-boilerplate A very basic skeleton much like you’ve seen here today. github.com/borismus/webvr-boilerplate
  • 85. basic_vr_mobile.html - Drop It In <!DOCTYPE html> <html lang="en"> <head> <title>Basic VR Mobile</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0"> <meta name="mobile-web-app-capable" content="yes"> <meta name="apple-mobile-web-app-capable" content="yes" /> <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" /> <style> body { background-color: #000; color: #fff; margin: 0px; padding: 0; overflow: hidden; } </style> </head> <body> <script src="js/three.js"></script> <script src="js/VRControls.js"></script> <script src="js/VREffect.js"></script> <script src="js/webvr-polyfill.js"></script> <script src="js/basic_vr.js"></script> </body> </html>
  • 86. basic_vr_mobile.html - Drop It In </style> </head> <body> <script src="js/three.js"></script> <script src="js/VRControls.js"></script> <script src="js/VREffect.js"></script> <script src="js/webvr-polyfill.js"></script> <script src="js/basic_vr.js"></script> </body> </html>
  • 87. I know what you’re thinking …
  • 88.
  • 89.
  • 90. Simulator Sickness is Real … Need to hit 60-90 fps. Motion data already laggy. Additional disadvantage of being in browser. More graphics you push the harder this gets.
  • 92. Spherically map videos around each camera/eye Again, math is HARD! See three.js vr_video or eleVR-Web-Player for example.
  • 94. All the HTML5 Things Keyboard, mouse, gamepad …
  • 95.
  • 96. Leap Motion is Strongly Embracing WebVR Works directly with three.js leapmotion.com/product/vr
  • 98. leap_motion.html <!DOCTYPE html> <html lang="en"> <head> <title>Leap Motion VR</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0"> <meta name="mobile-web-app-capable" content="yes"> <meta name="apple-mobile-web-app-capable" content="yes" /> <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" /> <style> body { background-color: #000; color: #fff; margin: 0px; padding: 0; overflow: hidden; } </style> </head> <body> <script src="js/three.js"></script> <script src="js/VRControls.js"></script> <script src="js/VREffect.js"></script> <script src="js/webvr-polyfill.js"></script> <script src="//js.leapmotion.com/leap-0.6.3.min.js"></script> <script src="//js.leapmotion.com/leap-plugins-0.1.9.min.js"></script> <script src="//js.leapmotion.com/leap.rigged-hand-0.1.7.min.js"></script> <script src="js/leap_motion.js"></script> </body> </html>
  • 99. leap_motion.html </style> </head> <body> <script src="js/three.js"></script> <script src="js/VRControls.js"></script> <script src="js/VREffect.js"></script> <script src="js/webvr-polyfill.js"></script> <script src="//js.leapmotion.com/leap-0.6.3.min.js"></script> <script src="//js.leapmotion.com/leap-plugins-0.1.9.min.js"></ script> <script src="//js.leapmotion.com/leap.rigged-hand-0.1.7.min.js" script> <script src="js/leap_motion.js"></script> </body> </html>
  • 100. leap_motion.js Leap.loop(); Leap.loopController.use('transform', { vr: true, effectiveParent: camera }); Leap.loopController.use('riggedHand', { parent: scene, renderer: renderer, materialOptions: { emissive: new THREE.Color(0x00aaaa) } }); animate();
  • 102. This doesn’t work on mobile* * without hacks
  • 104. Gaze Where you are looking can trigger changes, from environment to storyline.
  • 105.
  • 107. raycast.js - Gaze var raycaster = new THREE.Raycaster(); var center = new THREE.Vector2(); function gaze() { if(!audioPlaying) { raycaster.setFromCamera(center, camera); var intersects = raycaster.intersectObjects([bit]); if (intersects.length > 0) { audioPlaying = true; if (Math.random() < 0.5) { switchBitTo(1); yes.play(); } else { switchBitTo(0); no.play();
  • 108. Responsive VR For “simple” devices, it’s a roller coaster ride. More complex, more interactions.
  • 109. Math is HARD Collision detection, physics, etc.
  • 110.
  • 111. Unity publishes to multiple platforms Plugins for VR available. Support directly baked in 5.1
  • 112.
  • 113.
  • 114. #pragma strict var center : GameObject; var axis : Vector3; function Start () { } function Update () { transform.RotateAround( center.transform.position, axis,30 * Time.deltaTime ); } Orbit.js
  • 115. Cores.js function beingLookedAt() { var hit : RaycastHit; var ray = new Ray(Camera.main.transform.position, Camera.main.transform.forward); return GetComponent .<Collider>() .Raycast(ray, hit, Mathf.Infinity); }
  • 116. Unity now exports to WebGL An idea …
  • 117. Build a WebVR Unity plugin Bridges when publishing to WebGL. Design once, distribute everywhere, run anywhere. NOW YOU’RE PLAYING WITH POWER
  • 119. Again, Simulator Sickness is Real … It’ll get better, but start with easy motions
  • 120. 3D Modelling is Hard Spent most of my time on it. Develop interactions first! Then find a friend.
  • 121. The ground is constantly changing Beta Software running on Beta Hardware. Things break constantly.
  • 123.
  • 124. Except for one thing …?
  • 125. Why would this time be any different?
  • 126. Answer: Because of you …