Slide 1

Slide 1 text

WebVR Declarative Virtual Reality in your browsers with a-frame Carsten Sandtner (@casarock)

Slide 2

Slide 2 text

about:me Carsten Sandtner @casarock Technical Director mediaman //

Slide 3

Slide 3 text

Short History Of VR

Slide 4

Slide 4 text

View Master ~1939 https://flic.kr/p/hkLi6g

Slide 5

Slide 5 text

Project Headsight 1961

Slide 6

Slide 6 text

https://www.youtube.com/watch?v=ISJWZpFIAlQ

Slide 7

Slide 7 text

Sensorama ~1962 https://upload.wikimedia.org/wikipedia/commons/d/dc/Sensorama-morton-heilig-virtual-reality-headset.jpg

Slide 8

Slide 8 text

Virtual Boy 1995 https://flic.kr/p/6Vn8WN

Slide 9

Slide 9 text

VR Today

Slide 10

Slide 10 text

Oculus Rift DK1: 2013 DK2: 2014 Consumer Version: 2016 Image by Oculus VR, LLC

Slide 11

Slide 11 text

Google Cardboard 2014 By Evan-Amos https://commons.wikimedia.org/w/index.php?curid=45580283

Slide 12

Slide 12 text

HTC Vive 2016 Image © by HTC Corporation

Slide 13

Slide 13 text

Playstation VR Oct. 2016 Image © by Sony Computer Entertainment Inc.

Slide 14

Slide 14 text

Microsoft Hololens More AR, not really VR DevKit: 2016

Slide 15

Slide 15 text

VR In A Nutshell

Slide 16

Slide 16 text

https://twitter.com/guystufff/status/713075541738393600/video/1

Slide 17

Slide 17 text

No content

Slide 18

Slide 18 text

Mobile Based Setup https://developer.mozilla.org/en-US/docs/Web/API/WebVR_API/WebVR_concepts

Slide 19

Slide 19 text

Computer Based Setup https://developer.mozilla.org/en-US/docs/Web/API/WebVR_API/WebVR_concepts

Slide 20

Slide 20 text

Sensors https://developer.mozilla.org/en-US/docs/Web/API/WebVR_API/WebVR_concepts

Slide 21

Slide 21 text

Field Of View https://developer.mozilla.org/en-US/docs/Web/API/WebVR_API/WebVR_concepts

Slide 22

Slide 22 text

Concepts For VR Apps https://developer.mozilla.org/en-US/docs/Web/API/WebVR_API/WebVR_concepts

Slide 23

Slide 23 text

Concepts For VR Apps • Eye strain • Motion Sickness • Latency • FPS • Degrees of Freedom ( DoF ) • Cone of focus • 3D Positional Audio -> Web Audio API! https://media.giphy.com/media/3o6gaVAxUrXlEFYpWw/giphy.gif

Slide 24

Slide 24 text

What Is WebVR?

Slide 25

Slide 25 text

Disclaimer Currently an Editors Draft! (V1.0 since Sptember, 1st 2016) https://mozvr.github.io/webvr-spec/

Slide 26

Slide 26 text

Available APIs • Navigator.getVRDevices • VRDevice/HMDVRDevice • PositionSensorVRDevice • VRPositionState • VREyeParameters • VRFieldOfView/VRFieldOfViewReadOnly

Slide 27

Slide 27 text

Get VR Devices navigator.getVRDevices().then(function(devices) { // Handle found Devices here... });

Slide 28

Slide 28 text

(HMD) VR Device for (var i = 0; i < devices.length; ++i) { if (devices[i] instanceof HMDVRDevice) { gHMD = devices[i]; break; } }

Slide 29

Slide 29 text

Position Sensor // If device found, get Position Sensor. if (gHMD) { for (var i = 0; i < devices.length; ++i) { if (devices[i] instanceof PositionSensorVRDevice && devices[i].hardwareUnitId === gHMD.hardwareUnitId) { gPositionSensor = devices[i]; break; } } }

Slide 30

Slide 30 text

Position State var posState = gPositionSensor.getState(); if (posState.hasPosition) { posPara.textContent = 'Position: x' + (posState.position.x) + ' y' + (posState.position.y) + ' z' + (posState.position.z); } if (posState.hasOrientation) { orientPara.textContent = 'Orientation: x' + (posState.orientation.x) + ' y' + (posState.orientation.y) + ' z' + (posState.orientation.z); }

Slide 31

Slide 31 text

„Learn WebGL And Start Creating VR …“

Slide 32

Slide 32 text

Stereoscopic Rendering in WebGL /* https://hacks.mozilla.org/2015/09/stereoscopic-rendering-in-webvr/ */ function update() { // ... other stuff happens here ... // left eye gl.viewport(0, 0, canvas.width / 2, canvas.height); mat4.multiply(mvpMatrix, leftEyeProjectionMatrix, leftEyeViewMatrix); gl.uniformMatrix4fv(uniforms.uMVPMatrixLocation, false, mvpMatrix); gl.drawElements(mode, count, type, offset); // right eye gl.viewport(canvas.width / 2, 0, canvas.width / 2, canvas.height); mat4.multiply(mvpMatrix, rightEyeProjectionMatrix, rightEyeViewMatrix); gl.uniformMatrix4fv(uniforms.uMVPMatrixLocation, false, mvpMatrix); gl.drawElements(gl.TRIANGLES, n, gl.UNSIGNED_SHORT, 0); requestAnimationFrame(update); }

Slide 33

Slide 33 text

„… or use a Boilerplate or Frameworks!“

Slide 34

Slide 34 text

three.js WebVR Renderer ... var effect = new THREE.VREffect( renderer ); ... effect.render( scene, camera );

Slide 35

Slide 35 text

„Don’t reinvent the squared wheel!“

Slide 36

Slide 36 text

WebVR Boilerplate three.js + webVRControls https://github.com/borismus/webvr-boilerplate

Slide 37

Slide 37 text

But: „declarative“?

Slide 38

Slide 38 text

Mozilla A-Frame Building blocks for the virtual reality web

Slide 39

Slide 39 text

– https://aframe.io/ „Use markup to create VR experiences that work across desktop, iOS, Android, and the Oculus Rift.“

Slide 40

Slide 40 text

Hello World Hello, World!

Slide 41

Slide 41 text

No content

Slide 42

Slide 42 text

Animated Box . . .

Slide 43

Slide 43 text

No content

Slide 44

Slide 44 text

Pointer . . .

Slide 45

Slide 45 text

No content

Slide 46

Slide 46 text

Add Events . . .

Slide 47

Slide 47 text

Add Events (Pure JS) var box = document.querySelector('#mybox'); box.addEventListener('mouseenter', function () { box.setAttribute('material', {color: '#ff0000'}); }); box.addEventListener('mouseleave', function() { box.setAttribute('material', {color: '#6173F4'}); });

Slide 48

Slide 48 text

No content

Slide 49

Slide 49 text

No content

Slide 50

Slide 50 text

Input Devices?

Slide 51

Slide 51 text

Image © 2015 Microsoft

Slide 52

Slide 52 text

Image by Oculus VR, LLC

Slide 53

Slide 53 text

Image © by HTC Corporation

Slide 54

Slide 54 text

No content

Slide 55

Slide 55 text

By Evan-Amos - Own work, CC BY-SA 3.0, https://commons.wikimedia.org/w/index.php?curid=18936731

Slide 56

Slide 56 text

Why WebVR?

Slide 57

Slide 57 text

–Internet „VR is just for Gaming!“

Slide 58

Slide 58 text

–Internet „Using WebGL is complicated.“

Slide 59

Slide 59 text

Some use cases • Immersive reportages • 3D Handbooks/Instructions • Panorama view without stupid plugins • Marketing instrument. (Supplements in magazines)

Slide 60

Slide 60 text

Some great examples

Slide 61

Slide 61 text

http://www.360syria.com/

Slide 62

Slide 62 text

https://www.washingtonpost.com/video/mars/public/

Slide 63

Slide 63 text

https://s3.amazonaws.com/vr-asset-repo/heart_demo_slack.html

Slide 64

Slide 64 text

APainter - https://aframe.io/a-painter/

Slide 65

Slide 65 text

Resources

Slide 66

Slide 66 text

• https://webvr.rocks/ • https://aframe.io/ • https://developer.mozilla.org/de/docs/Web/API/WebVR_API

Slide 67

Slide 67 text

Conclusion

Slide 68

Slide 68 text

VR is amazing

Slide 69

Slide 69 text

WebVR is amazing… … but it’s not ready 
 (Editors Draft, Browser support) … and has high Hardware Requirements! … HMD Devices are not cheap. 
 (Except: Google Cardboard) … and it’s a pleasure to create content!

Slide 70

Slide 70 text

WebVR is amazing Carsten Sandtner @casarock [email protected]