SlideShare a Scribd company logo
HACKING REALITY: 
HTML5 AND 
JAVASCRIPT 
FOR CROSS-PLATFORM 
VR 
TONY PARISI 
OCTOBER, 2014
ABOUT ME 
CREDS 
Co-creator, VRML and X3D 
http://www.tonyparisi.com 10/21/2014 
CONTACT 
tony@vizi.gl 
skype: auradeluxe 
http://twitter.com/auradeluxe 
http://www.tonyparisi.com/ 
http://www.learningwebgl.com/ 
GET VIZI 
https://github.com/tparisi/Vizi 
GET THE BOOKS! 
WebGL: Up and Running 
http://www.amazon.com/dp/144932357X 
Programming 3D Applications with HTML and WebGL 
http://www.amazon.com/Programming-Applications-HTML5-WebGL-Visualization/ 
dp/1449362966 
MEETUPS 
http://www.meetup.com/WebGL-Developers-Meetup/ 
http://www.meetup.com/Web-VR/ 
BOOK CODE 
https://github.com/tparisi/WebGLBook 
https://github.com/tparisi/Programming3DApplications 
GET GLAM 
http://www.glamjs.org/ 
https://github.com/tparisi/glam/ 
WORK 
http://www.vizi.gl/
THE PROMISED LAND! 
CONSUMER VR 
http://www.tonyparisi.com 10/21/2014
VR TODAY 
http://www.tonyparisi.com 10/21/2014 
GIANT DOWNLOADS 
SILO EXPERIENCES 
CUMBERSOME NATIVE APPS AND INSTALLS 
PROPRIETARY PLATFORMS AND 
DEVELOPMENT STACKS 
VR DOTH BE 
HARD!
WHY I LOVE THE WEB 
 INSTANT PUBLISHING 
 INSTANT ACCESS TO INFORMATION 
 NO TOLLS 
 NOBODY CONTROLS IT 
 CULTURE OF COLLABORATION 
 VIEW SOURCE 
…THE WEB WILL NEVER CLOSE UP SHOP. 
image: Mark Surman 
http://commonspace.wordpress.com/2014/03/12/happybirthday/ 
http://www.tonyparisi.com 10/21/2014
THE THREE D’S OF THE 
WEB 
http://www.tonyparisi.com 10/21/2014 
 DEVELOPMENT 
 CROSS-PLATFORM 
 VENDOR-NEUTRAL 
 OPEN SOURCE 
 DEPLOYMENT 
 CLOUD 
 PUSH-BUTTON UPDATE AND PUBLISH 
 DISTRIBUTION AND DISCOVERY 
 EMBED IN OTHER PAGES 
 SHARE WITH A HYPERLINK 
 NO APP TO DOWNLOAD
VR AND THE WEB: 
TWO GREAT TASTES… ? 
http://www.tonyparisi.com 10/21/2014
WEB VR 
FAST, CHEAP, AND TOTALLY 
DEMOCRATIZED. 
 BROWSER-BASED VIRTUAL 
REALITY 
 WEBGL 
 CSS3 
 VR SUPPORT NOW IN 
BROWSER DEV BUILDS!!! 
 NO BIG APP DOWNLOADS 
AND INSTALLS!!! 
http://www.tonyparisi.com 10/21/2014 
 JUST ADD SMART PHONE 
 “SMARTVR” USING 
GOOGLE CARDBOARD 
$25 CHEAP!
AN EXAMPLE 
http://www.tonyparisi.com 10/21/2014 
INFORMATION DIVING SHOWCASE 
http://mozvr.github.io/infodive/ 
POWERED BY FIREFOX BUILT WITH VIZI 
https://github.com/tparisi/Vizi
THE WEBVR API 
1. QUERY FOR VR DEVICE(S) TO RENDER 
// polyfill 
var getVRDevices = navigator.mozGetVRDevices /* FF */ || 
navigator.getVRDevices; /* webkit */ 
http://www.tonyparisi.com 10/21/2014 
var self = this; 
getVRDevices().then( gotVRDevices ); 
function gotVRDevices( devices ) { 
var vrHMD; 
var error; 
for ( var i = 0; i < devices.length; ++i ) { 
if ( devices[i] instanceof HMDVRDevice ) { 
vrHMD = devices[i]; 
self._vrHMD = vrHMD; 
self.leftEyeTranslation = vrHMD.getEyeTranslation( "left" ); 
self.rightEyeTranslation = vrHMD.getEyeTranslation( "right" ); 
self.leftEyeFOV = vrHMD.getRecommendedEyeFieldOfView( "left" ); 
self.rightEyeFOV = vrHMD.getRecommendedEyeFieldOfView( "right" ); 
break; // We keep the first we encounter 
} 
} 
} 
get left/right eye 
(camera) positions 
get per-eye camera field of view; use 
WebGL to render scene from two cameras
THE WEBVR API 
2. GO FULLSCREEN (VR MODE) 
fullscreen mode requires a DOM 
element 
http://www.tonyparisi.com 10/21/2014 
var self = this; 
var renderer = this._renderer; 
var vrHMD = this._vrHMD; 
var canvas = renderer.domElement; 
var fullScreenChange = 
canvas.mozRequestFullScreen? 'mozfullscreenchange' : 'webkitfullscreenchange'; 
document.addEventListener( fullScreenChange, onFullScreenChanged, false ); 
function onFullScreenChanged() { 
if ( !document.mozFullScreenElement 
&& !document.webkitFullScreenElement ) { 
self.setFullScreen( false ); 
} 
} 
if ( canvas.mozRequestFullScreen ) { 
canvas.mozRequestFullScreen( { vrDisplay: vrHMD } ); 
} else { 
canvas.webkitRequestFullscreen( { vrDisplay: vrHMD } ); 
} 
handle exiting fullscreen 
mode 
request fullscreen mode 
for this VR device
THE WEBVR API 
3. HEAD TRACKING 
query HMD device state 
http://www.tonyparisi.com 10/21/2014 
// polyfill 
var getVRDevices = navigator.mozGetVRDevices /* FF */ || 
navigator.getVRDevices; /* webkit */ 
var self = this; 
getVRDevices().then( gotVRDevices ); 
function gotVRDevices( devices ) { 
var vrInput; 
var error; 
for ( var i = 0; i < devices.length; ++i ) { 
if ( devices[i] instanceof PositionSensorVRDevice ) { 
vrInput = devices[i] 
self._vrInput = vrInput; 
break; // We keep the first we encounter 
} 
} 
} 
… 
// called once per tick from requestAnimationFrame() 
var update = function() { 
var vrState = this.getVRState(); 
if ( !vrState ) { 
return; 
} 
// vrState.hmd.rotation contains four floats, quaternion x,y,z,w 
setCameraRotation(vrState.hmd.rotation); 
}; 
get head-tracking VR device 
update camera to match HMD 
device orientation
WEBVR AND CARDBOARD 
 GOOGLE CARDBOARD SHOWCASE 
 Mobile Chrome http://g.co/chromevr 
 Desktop Chrome http://vr.chromeexperiments.com/ 
 EVEN EASIER 
 RENDER WEBGL SIDE-BY-SIDE STEREO (NO NEED TO QUERY 
DEVICES) 
 USE BROWSER DEVICE ORIENTATION API FOR HEAD TRACKING 
http://www.tonyparisi.com 10/21/2014
WEBVR AND THREE.JS 
 THE MOST POPULAR WEBGL LIBRARY 
 http://threejs.org/ 
 LATEST STABLE VERSION (r68) INCLUDES STEREO 
RENDERING AND HEAD TRACKING 
 RENDERING 
examples/js/effects/StereoEffect.js (Cardboard) 
examples/js/effects/VREffect.js (Rift) 
 HEAD TRACKING 
examples/js/controls/DeviceOrientationControls.js (Cardboard) 
examples/js/controls/VRControls.js (Rift) 
http://www.tonyparisi.com 10/21/2014
VIZI: A FRAMEWORK FOR 
WEBVR APPLICATIONS 
 GOAL: MAKE IT EASY TO QUICKLY BUILD INTERESTING 3D 
APPLICATIONS 
 ARCHITECTURE INSPIRED INSPIRED BY MODERN GAME ENGINE 
DESIGN 
 COMPONENT-BASED DESIGN – EASILY PLUG NEW FEATURES INTO OBJECTS 
 APPLICATION OBJECT – HANDLES EVENT LOOP, THREE.JS CREATION, PAGE RESIZE, 
ROUTING EVENTS TO OBJECTS 
 INTERACTIONS – MAKE IT EASY TO PUT MOUSE AND TOUCH INTERACTION ON OBJECTS 
 BEHAVIORS – PREBUILT BEHAVIORS AUTOMATICALLY ROTATE, MOVE ETC. 
 PRE-BUILT OBJECTS – FOR COMMONLY USED DESIGN PATTERNS 
 SIMILAR IN DESIGN TO UNITY3D 
 USES THREE.JS FOR ALL GRAPHICS 
 ENHANCES THREE.JS VR RENDERING AND CONTROLLERS 
http://www.tonyparisi.com 10/21/2014
OPEN TOOLS 
FOR CROSS-PLATFORM VR 
http://www.tonyparisi.com 10/21/2014 
game engines/IDEs 
Goo Enginehttp://www.gootechnologies.com/ 
Verold http://verold.com/ 
Turbulenz https://turbulenz.com/ 
PlayCanvas http://www.playcanvas.com/ 
Artillery Engine 
https://artillery.com/ 
Sketchfab https://sketchfab.com/ 
Unreal https://www.unrealengine.com/ 
Unity http://unity3d.com/#unity-5 
scene graph libraries/page frameworks 
Three.js 
http://threejs.org/ 
SceneJS 
http://scenejs.org/ 
BabylonJS 
http://www.babylonjs.com/ 
Vizi 
https://github.com/tparisi/Vizi 
Voodoo.js 
http://www.voodoojs.com/ 
PhiloGL 
http://www.senchalabs.org/philogl/ 
tQuery 
http://jeromeetienne.github.io/tquery/
PRO TOOLS FOR WEB VR 
Unreal 4 in WebGL 
https://www.youtube.com/watch?v=c2uNDlP4RiE#t=42 
60FPS 
ported in 5 days 
Unreal native C++ engine -> JavaScript 
Emscripten + asm.js 
http://www.tonyparisi.com 10/21/2014 
EMSCRIPTEN - 
THE COOLEST HACK 
EVER! 
https://github.com/kripken/ems 
cripten 
 CROSS-COMPILE C++ 
NATIVE CODE TO 
JAVASCRIPT 
 asm.js- LOW-LEVEL 
OPTIMIZED JAVASCRIPT 
 UNITY, UNREAL ENGINES 
USE THIS TO DEPLOY ON 
THE WEB 
 WATCH OUT: HUGE 
DOWNLOADS AND HARD TO 
DEBUG…. !
WEBVR AND CSS 
http://www.tonyparisi.com 10/21/2014 
MOZILLA VR CSS SHOWCASE 
http://mozvr.github.io/vr-web-examples/domvr-birds/
WEBVR AND CSS 
http://www.tonyparisi.com 10/21/2014 
<script type="text/javascript" src="js/vrutils.js"></script> 
<script> 
/* VR Headset and its associated orientation/position sensor */ 
var vrHMD, vrSensor; 
/* Element that will serve as our camera, moving the rest of the scene around */ 
var cssCamera = document.getElementById("camera"); 
/* the camera's position, as a css transform string. For right now, we want it just in the middle. */ 
var cssCameraPositionTransform = "translate3d(0, 0, 0)"; 
/* Request animation frame loop. */ 
function animate() { 
/* Acquire positional data from VR headset and convert into a transformation that can be applied to CSS. */ 
if (vrSensor !== undefined) { 
var state = vrSensor.getState(); 
var cssOrientationMatrix = cssMatrixFromOrientation(state.orientation, true); 
} 
/* Apply positional data to camera element */ 
cssCamera.style.transform = cssOrientationMatrix + " " + cssCameraPositionTransform; 
window.requestAnimationFrame(animate); 
} 
query HMD device state 
calculate “camera” orientation 
update “camera’s” CSS 3D transform
VR + ML 
A MARKUP LANGUAGE FOR THE 
METAVERSE? 
http://www.tonyparisi.com 10/21/2014 
 GLAM (GL AND MARKUP) - A 
DECLARATIVE LANGUAGE FOR 3D 
WEB CONTENT 
https://github.com/tparisi/glam/ 
 DEFINE 3D SCENE CONTENT IN 
MARKUP; STYLE IT IN CSS 
THE MARKUP 
<glam> 
<renderer type="rift"></renderer> 
<scene> 
<controller type="rift"></controller> 
<background id="sb1" class="skybox"> 
</background> 
<group y ='1' z='-3'> 
<sphere class="bubble skybox”> 
</sphere> 
<sphere class="bubble skybox”> 
</sphere> 
</group> 
… 
THE CSS 
<style> 
.skybox { 
envmap-right:url(../images/Park2/posx.jpg); 
… 
} 
.bubble { 
radius:.5; 
shader-vertex:url(../shaders/fresnel.vs); 
shader-fragment:url(../shaders/fresnel.fs); 
shader-uniforms:mRefractionRatio f 1.02 
mFresnelBias f 0.1 mFresnelPower f 2.0 mFresnelScale 
f 1.0 tCube t null; 
} 
#sb1 { 
background-type:box; 
} 
</style>
CHALLENGES 
 WEBVR ON OCULUS IS NOT READY FOR PRIME TIME 
 (THAT’S OK NEITHER IS OCULUS!) 
 LATENCY IS THE BIGGEST ISSUE – BROWSER NEEDS TO UN-THROTTLE 
AT 60FPS 
 BUT WE’RE GOOD TO GO ON CARDBOARD! 
 60FPS WORKS GREAT 
 NEARLY 2 BILLION VR DEVICES ALREADY DEPLOYED! 
 FRAMEWORKS AND TOOLS ARE TYPICALLY WEB-ISH: UNDER 
DEVELOPMENT, ALWAYS IN FLUX, PRETTY MUCH OUT OF 
CONTROL 
 BUT OPEN SOURCE SO WE CAN LIVE WITH IT 
http://www.tonyparisi.com 10/21/2014
LINKS 
 BROWSER DEV BUILDS 
Firefox http://blog.bitops.com/blog/2014/08/20/updated-firefox-vr-builds/ 
Chrome https://drive.google.com/folderview?id=0BzudLt22BqGRbW9WTHMtOWMzNjQ 
 MOZILLA NEXT STEPS FOR VR (THURSDAY 23 OCT 2014) 
https://air.mozilla.org/virtual-reality-the-web-next-steps/ 
 SAN FRANCISCO WEBVR MEETUP 
http://www.meetup.com/Web-VR/ 
 WEBVR MAILING LIST 
web-vr-discuss@mozilla.org 
 CARDBOARD VR SHOWCASE 
http://vr.chromeexperiments.com/ 
http://www.tonyparisi.com 10/21/2014
KEEP IN TOUCH 
CREDS 
Co-creator, VRML and X3D 
http://www.tonyparisi.com 10/21/2014 
CONTACT 
tony@vizi.gl 
skype: auradeluxe 
http://twitter.com/auradeluxe 
http://www.tonyparisi.com/ 
http://www.learningwebgl.com/ 
GET VIZI 
https://github.com/tparisi/Vizi 
GET THE BOOKS! 
WebGL: Up and Running 
http://www.amazon.com/dp/144932357X 
Programming 3D Applications with HTML and WebGL 
http://www.amazon.com/Programming-Applications-HTML5-WebGL-Visualization/ 
dp/1449362966 
MEETUPS 
http://www.meetup.com/WebGL-Developers-Meetup/ 
http://www.meetup.com/Web-VR/ 
BOOK CODE 
https://github.com/tparisi/WebGLBook 
https://github.com/tparisi/Programming3DApplications 
GET GLAM 
http://www.glamjs.org/ 
https://github.com/tparisi/glam/ 
WORK 
http://www.vizi.gl/
HACKING REALITY: 
HTML5 AND 
JAVASCRIPT 
FOR CROSS-PLATFORM 
VR 
TONY PARISI 
OCTOBER, 2014

More Related Content

PDF
WebVR: Developing for the Immersive Web
PPTX
React-VR: An Early Experiment with React and WebGL for VR Development
PPTX
An Introduction to Web VR January 2015
PPTX
WebGL: The Next Generation
PDF
Introduction to WebVR Autodesk Forge 2016
PDF
Virtually Anyone
PDF
Getting Started in VR with JS
PPTX
WebGL, HTML5 and How the Mobile Web Was Won
WebVR: Developing for the Immersive Web
React-VR: An Early Experiment with React and WebGL for VR Development
An Introduction to Web VR January 2015
WebGL: The Next Generation
Introduction to WebVR Autodesk Forge 2016
Virtually Anyone
Getting Started in VR with JS
WebGL, HTML5 and How the Mobile Web Was Won

What's hot (20)

PPTX
WebGL, WebVR and the Metaverse
PDF
The Immersive Web
PPTX
PDF
Foundations of the Immersive Web
PPTX
WebVR Ecosystem and API Update
PDF
WebXR: A New Dimension For The Web Writing Virtual and Augmented Reality Apps...
PPT
Standards.Next: Canvas
PPTX
And Who Shall Control the Metaverse?
PPTX
WebGL Crash Course
PDF
HTML5 for Web Designers
PDF
TechEvent BASTA von WPF nach Angular in 60 Minuten
PPTX
How to create 360 Image/panorama & share with WebVR?
PPTX
Accessibility in Canvas 3D
PDF
[peachpit] Adaptive Images in Responsive Web Design
PPTX
Managing Responsive Design Projects
PPTX
Powering the VR/AR Ecosystem 2017-01-17
KEY
Tools that help and speed up RWD dev
PDF
[psuweb] Adaptive Images in Responsive Web Design
PPTX
GermaniumWeb training for CXA2010
PDF
Droids, java script and web connected hardware
WebGL, WebVR and the Metaverse
The Immersive Web
Foundations of the Immersive Web
WebVR Ecosystem and API Update
WebXR: A New Dimension For The Web Writing Virtual and Augmented Reality Apps...
Standards.Next: Canvas
And Who Shall Control the Metaverse?
WebGL Crash Course
HTML5 for Web Designers
TechEvent BASTA von WPF nach Angular in 60 Minuten
How to create 360 Image/panorama & share with WebVR?
Accessibility in Canvas 3D
[peachpit] Adaptive Images in Responsive Web Design
Managing Responsive Design Projects
Powering the VR/AR Ecosystem 2017-01-17
Tools that help and speed up RWD dev
[psuweb] Adaptive Images in Responsive Web Design
GermaniumWeb training for CXA2010
Droids, java script and web connected hardware

Viewers also liked (19)

PDF
WebVR - MobileTechCon Berlin 2016
PPTX
Developing Web Graphics with WebGL
PDF
Bringing Virtual Reality to the Web: VR, WebGL and CSS – Together At Last!
PDF
JavaCro'15 - Service Discovery in OSGi Beyond the JVM using Docker and Consul...
PPTX
The Long Game: It’s Not Prime Time for VR… Yet | Clive Downie
PPTX
AR Gamers – The Next Generation | Mark Shovman
PDF
Integrating Angular js & three.js
PPTX
Location Based VR: VR Internet Cafe & VR Arcade | Jikhan Jung
PDF
PDF
A-Frame: VR for Web Developers
PPTX
WebGL and three.js - Web 3D Graphics
PDF
Build the Virtual Reality Web with A-Frame
PDF
Cordova: APIs and instruments
PDF
Introduction to WebGL and WebVR
PDF
The next frontier: WebGL and WebVR
PPTX
From Players to Leaders with Quizizz
PDF
Roxar sand-monitor -pig-detector brochure
PPTX
Bringing VR to the Masses | Yannis Bolman
PDF
An Introduction to WebVR – or How to make your user sick in 60 seconds
WebVR - MobileTechCon Berlin 2016
Developing Web Graphics with WebGL
Bringing Virtual Reality to the Web: VR, WebGL and CSS – Together At Last!
JavaCro'15 - Service Discovery in OSGi Beyond the JVM using Docker and Consul...
The Long Game: It’s Not Prime Time for VR… Yet | Clive Downie
AR Gamers – The Next Generation | Mark Shovman
Integrating Angular js & three.js
Location Based VR: VR Internet Cafe & VR Arcade | Jikhan Jung
A-Frame: VR for Web Developers
WebGL and three.js - Web 3D Graphics
Build the Virtual Reality Web with A-Frame
Cordova: APIs and instruments
Introduction to WebGL and WebVR
The next frontier: WebGL and WebVR
From Players to Leaders with Quizizz
Roxar sand-monitor -pig-detector brochure
Bringing VR to the Masses | Yannis Bolman
An Introduction to WebVR – or How to make your user sick in 60 seconds

Similar to Hacking Reality: Browser-Based VR with HTML5 (20)

PPTX
Browser-Based Virtual Reality April 2015
PPTX
Up And Running With Web VR Fall 2014
PPTX
VR Without Borders RIVER WebVR April 2015
PDF
WebVR - JAX 2016
PDF
Quick dive into WebVR
PPTX
Getting Started with Web VR
PDF
Ferguson VR Hackathon - May 6, 2017
PDF
Портируем существующее Web-приложение в виртуальную реальность / Денис Радин ...
PPTX
Introduction to The VR Web
PDF
Migrating your Web app to Virtual Reality
PPTX
Scotland JS 2016 Keynote: The VR Web and the Future of the Browser
PDF
Goodbye, Flatland! An introduction to WebVR and what it means for web developers
PPTX
Building AR and VR Experiences for Web Apps with JavaScript
PDF
Keynote: The Immersive web
PDF
SEARIS 2014 Keynote - MiddleVR - Philosophy and architecture
PPTX
JSConfBP JavaScript for VR
PPTX
WebXR - Introduction and Workshop
PPTX
Building the Matrix: Your First VR App (SVCC 2016)
PDF
Tony Parisi (VP Platform, Wevr) The Immersive Web
PDF
Building a game with WebVR
Browser-Based Virtual Reality April 2015
Up And Running With Web VR Fall 2014
VR Without Borders RIVER WebVR April 2015
WebVR - JAX 2016
Quick dive into WebVR
Getting Started with Web VR
Ferguson VR Hackathon - May 6, 2017
Портируем существующее Web-приложение в виртуальную реальность / Денис Радин ...
Introduction to The VR Web
Migrating your Web app to Virtual Reality
Scotland JS 2016 Keynote: The VR Web and the Future of the Browser
Goodbye, Flatland! An introduction to WebVR and what it means for web developers
Building AR and VR Experiences for Web Apps with JavaScript
Keynote: The Immersive web
SEARIS 2014 Keynote - MiddleVR - Philosophy and architecture
JSConfBP JavaScript for VR
WebXR - Introduction and Workshop
Building the Matrix: Your First VR App (SVCC 2016)
Tony Parisi (VP Platform, Wevr) The Immersive Web
Building a game with WebVR

More from Tony Parisi (13)

PDF
The New Fine Arts
PPTX
Face the Future: Computing in an Augmented World
PPTX
Vrml, or There and Back Again
PPTX
The Coming Distribution War
PPTX
glTF and the WebGL Art Pipeline March 2015
PPTX
The Web Eats Everything In Its Path Fall 2014
PPTX
WebGL Primetime!
PPTX
Virtually Anywhere
PPTX
The Browser As Console - HTML5 and WebGL for Game Development
PPTX
WebGL - It's GO Time
PPTX
glTF Update with Tony Parisi WebGL Meetup August 2013
PPTX
Building Rich Internet Applications with HTML5 and WebGL
PPTX
Artists Only
The New Fine Arts
Face the Future: Computing in an Augmented World
Vrml, or There and Back Again
The Coming Distribution War
glTF and the WebGL Art Pipeline March 2015
The Web Eats Everything In Its Path Fall 2014
WebGL Primetime!
Virtually Anywhere
The Browser As Console - HTML5 and WebGL for Game Development
WebGL - It's GO Time
glTF Update with Tony Parisi WebGL Meetup August 2013
Building Rich Internet Applications with HTML5 and WebGL
Artists Only

Recently uploaded (20)

PDF
Per capita expenditure prediction using model stacking based on satellite ima...
DOCX
The AUB Centre for AI in Media Proposal.docx
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Electronic commerce courselecture one. Pdf
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PPTX
Cloud computing and distributed systems.
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Encapsulation theory and applications.pdf
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PPTX
sap open course for s4hana steps from ECC to s4
PPTX
Spectroscopy.pptx food analysis technology
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Per capita expenditure prediction using model stacking based on satellite ima...
The AUB Centre for AI in Media Proposal.docx
MYSQL Presentation for SQL database connectivity
Electronic commerce courselecture one. Pdf
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Cloud computing and distributed systems.
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
NewMind AI Weekly Chronicles - August'25 Week I
Encapsulation theory and applications.pdf
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Diabetes mellitus diagnosis method based random forest with bat algorithm
sap open course for s4hana steps from ECC to s4
Spectroscopy.pptx food analysis technology
Building Integrated photovoltaic BIPV_UPV.pdf
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx

Hacking Reality: Browser-Based VR with HTML5

  • 1. HACKING REALITY: HTML5 AND JAVASCRIPT FOR CROSS-PLATFORM VR TONY PARISI OCTOBER, 2014
  • 2. ABOUT ME CREDS Co-creator, VRML and X3D http://www.tonyparisi.com 10/21/2014 CONTACT tony@vizi.gl skype: auradeluxe http://twitter.com/auradeluxe http://www.tonyparisi.com/ http://www.learningwebgl.com/ GET VIZI https://github.com/tparisi/Vizi GET THE BOOKS! WebGL: Up and Running http://www.amazon.com/dp/144932357X Programming 3D Applications with HTML and WebGL http://www.amazon.com/Programming-Applications-HTML5-WebGL-Visualization/ dp/1449362966 MEETUPS http://www.meetup.com/WebGL-Developers-Meetup/ http://www.meetup.com/Web-VR/ BOOK CODE https://github.com/tparisi/WebGLBook https://github.com/tparisi/Programming3DApplications GET GLAM http://www.glamjs.org/ https://github.com/tparisi/glam/ WORK http://www.vizi.gl/
  • 3. THE PROMISED LAND! CONSUMER VR http://www.tonyparisi.com 10/21/2014
  • 4. VR TODAY http://www.tonyparisi.com 10/21/2014 GIANT DOWNLOADS SILO EXPERIENCES CUMBERSOME NATIVE APPS AND INSTALLS PROPRIETARY PLATFORMS AND DEVELOPMENT STACKS VR DOTH BE HARD!
  • 5. WHY I LOVE THE WEB  INSTANT PUBLISHING  INSTANT ACCESS TO INFORMATION  NO TOLLS  NOBODY CONTROLS IT  CULTURE OF COLLABORATION  VIEW SOURCE …THE WEB WILL NEVER CLOSE UP SHOP. image: Mark Surman http://commonspace.wordpress.com/2014/03/12/happybirthday/ http://www.tonyparisi.com 10/21/2014
  • 6. THE THREE D’S OF THE WEB http://www.tonyparisi.com 10/21/2014  DEVELOPMENT  CROSS-PLATFORM  VENDOR-NEUTRAL  OPEN SOURCE  DEPLOYMENT  CLOUD  PUSH-BUTTON UPDATE AND PUBLISH  DISTRIBUTION AND DISCOVERY  EMBED IN OTHER PAGES  SHARE WITH A HYPERLINK  NO APP TO DOWNLOAD
  • 7. VR AND THE WEB: TWO GREAT TASTES… ? http://www.tonyparisi.com 10/21/2014
  • 8. WEB VR FAST, CHEAP, AND TOTALLY DEMOCRATIZED.  BROWSER-BASED VIRTUAL REALITY  WEBGL  CSS3  VR SUPPORT NOW IN BROWSER DEV BUILDS!!!  NO BIG APP DOWNLOADS AND INSTALLS!!! http://www.tonyparisi.com 10/21/2014  JUST ADD SMART PHONE  “SMARTVR” USING GOOGLE CARDBOARD $25 CHEAP!
  • 9. AN EXAMPLE http://www.tonyparisi.com 10/21/2014 INFORMATION DIVING SHOWCASE http://mozvr.github.io/infodive/ POWERED BY FIREFOX BUILT WITH VIZI https://github.com/tparisi/Vizi
  • 10. THE WEBVR API 1. QUERY FOR VR DEVICE(S) TO RENDER // polyfill var getVRDevices = navigator.mozGetVRDevices /* FF */ || navigator.getVRDevices; /* webkit */ http://www.tonyparisi.com 10/21/2014 var self = this; getVRDevices().then( gotVRDevices ); function gotVRDevices( devices ) { var vrHMD; var error; for ( var i = 0; i < devices.length; ++i ) { if ( devices[i] instanceof HMDVRDevice ) { vrHMD = devices[i]; self._vrHMD = vrHMD; self.leftEyeTranslation = vrHMD.getEyeTranslation( "left" ); self.rightEyeTranslation = vrHMD.getEyeTranslation( "right" ); self.leftEyeFOV = vrHMD.getRecommendedEyeFieldOfView( "left" ); self.rightEyeFOV = vrHMD.getRecommendedEyeFieldOfView( "right" ); break; // We keep the first we encounter } } } get left/right eye (camera) positions get per-eye camera field of view; use WebGL to render scene from two cameras
  • 11. THE WEBVR API 2. GO FULLSCREEN (VR MODE) fullscreen mode requires a DOM element http://www.tonyparisi.com 10/21/2014 var self = this; var renderer = this._renderer; var vrHMD = this._vrHMD; var canvas = renderer.domElement; var fullScreenChange = canvas.mozRequestFullScreen? 'mozfullscreenchange' : 'webkitfullscreenchange'; document.addEventListener( fullScreenChange, onFullScreenChanged, false ); function onFullScreenChanged() { if ( !document.mozFullScreenElement && !document.webkitFullScreenElement ) { self.setFullScreen( false ); } } if ( canvas.mozRequestFullScreen ) { canvas.mozRequestFullScreen( { vrDisplay: vrHMD } ); } else { canvas.webkitRequestFullscreen( { vrDisplay: vrHMD } ); } handle exiting fullscreen mode request fullscreen mode for this VR device
  • 12. THE WEBVR API 3. HEAD TRACKING query HMD device state http://www.tonyparisi.com 10/21/2014 // polyfill var getVRDevices = navigator.mozGetVRDevices /* FF */ || navigator.getVRDevices; /* webkit */ var self = this; getVRDevices().then( gotVRDevices ); function gotVRDevices( devices ) { var vrInput; var error; for ( var i = 0; i < devices.length; ++i ) { if ( devices[i] instanceof PositionSensorVRDevice ) { vrInput = devices[i] self._vrInput = vrInput; break; // We keep the first we encounter } } } … // called once per tick from requestAnimationFrame() var update = function() { var vrState = this.getVRState(); if ( !vrState ) { return; } // vrState.hmd.rotation contains four floats, quaternion x,y,z,w setCameraRotation(vrState.hmd.rotation); }; get head-tracking VR device update camera to match HMD device orientation
  • 13. WEBVR AND CARDBOARD  GOOGLE CARDBOARD SHOWCASE  Mobile Chrome http://g.co/chromevr  Desktop Chrome http://vr.chromeexperiments.com/  EVEN EASIER  RENDER WEBGL SIDE-BY-SIDE STEREO (NO NEED TO QUERY DEVICES)  USE BROWSER DEVICE ORIENTATION API FOR HEAD TRACKING http://www.tonyparisi.com 10/21/2014
  • 14. WEBVR AND THREE.JS  THE MOST POPULAR WEBGL LIBRARY  http://threejs.org/  LATEST STABLE VERSION (r68) INCLUDES STEREO RENDERING AND HEAD TRACKING  RENDERING examples/js/effects/StereoEffect.js (Cardboard) examples/js/effects/VREffect.js (Rift)  HEAD TRACKING examples/js/controls/DeviceOrientationControls.js (Cardboard) examples/js/controls/VRControls.js (Rift) http://www.tonyparisi.com 10/21/2014
  • 15. VIZI: A FRAMEWORK FOR WEBVR APPLICATIONS  GOAL: MAKE IT EASY TO QUICKLY BUILD INTERESTING 3D APPLICATIONS  ARCHITECTURE INSPIRED INSPIRED BY MODERN GAME ENGINE DESIGN  COMPONENT-BASED DESIGN – EASILY PLUG NEW FEATURES INTO OBJECTS  APPLICATION OBJECT – HANDLES EVENT LOOP, THREE.JS CREATION, PAGE RESIZE, ROUTING EVENTS TO OBJECTS  INTERACTIONS – MAKE IT EASY TO PUT MOUSE AND TOUCH INTERACTION ON OBJECTS  BEHAVIORS – PREBUILT BEHAVIORS AUTOMATICALLY ROTATE, MOVE ETC.  PRE-BUILT OBJECTS – FOR COMMONLY USED DESIGN PATTERNS  SIMILAR IN DESIGN TO UNITY3D  USES THREE.JS FOR ALL GRAPHICS  ENHANCES THREE.JS VR RENDERING AND CONTROLLERS http://www.tonyparisi.com 10/21/2014
  • 16. OPEN TOOLS FOR CROSS-PLATFORM VR http://www.tonyparisi.com 10/21/2014 game engines/IDEs Goo Enginehttp://www.gootechnologies.com/ Verold http://verold.com/ Turbulenz https://turbulenz.com/ PlayCanvas http://www.playcanvas.com/ Artillery Engine https://artillery.com/ Sketchfab https://sketchfab.com/ Unreal https://www.unrealengine.com/ Unity http://unity3d.com/#unity-5 scene graph libraries/page frameworks Three.js http://threejs.org/ SceneJS http://scenejs.org/ BabylonJS http://www.babylonjs.com/ Vizi https://github.com/tparisi/Vizi Voodoo.js http://www.voodoojs.com/ PhiloGL http://www.senchalabs.org/philogl/ tQuery http://jeromeetienne.github.io/tquery/
  • 17. PRO TOOLS FOR WEB VR Unreal 4 in WebGL https://www.youtube.com/watch?v=c2uNDlP4RiE#t=42 60FPS ported in 5 days Unreal native C++ engine -> JavaScript Emscripten + asm.js http://www.tonyparisi.com 10/21/2014 EMSCRIPTEN - THE COOLEST HACK EVER! https://github.com/kripken/ems cripten  CROSS-COMPILE C++ NATIVE CODE TO JAVASCRIPT  asm.js- LOW-LEVEL OPTIMIZED JAVASCRIPT  UNITY, UNREAL ENGINES USE THIS TO DEPLOY ON THE WEB  WATCH OUT: HUGE DOWNLOADS AND HARD TO DEBUG…. !
  • 18. WEBVR AND CSS http://www.tonyparisi.com 10/21/2014 MOZILLA VR CSS SHOWCASE http://mozvr.github.io/vr-web-examples/domvr-birds/
  • 19. WEBVR AND CSS http://www.tonyparisi.com 10/21/2014 <script type="text/javascript" src="js/vrutils.js"></script> <script> /* VR Headset and its associated orientation/position sensor */ var vrHMD, vrSensor; /* Element that will serve as our camera, moving the rest of the scene around */ var cssCamera = document.getElementById("camera"); /* the camera's position, as a css transform string. For right now, we want it just in the middle. */ var cssCameraPositionTransform = "translate3d(0, 0, 0)"; /* Request animation frame loop. */ function animate() { /* Acquire positional data from VR headset and convert into a transformation that can be applied to CSS. */ if (vrSensor !== undefined) { var state = vrSensor.getState(); var cssOrientationMatrix = cssMatrixFromOrientation(state.orientation, true); } /* Apply positional data to camera element */ cssCamera.style.transform = cssOrientationMatrix + " " + cssCameraPositionTransform; window.requestAnimationFrame(animate); } query HMD device state calculate “camera” orientation update “camera’s” CSS 3D transform
  • 20. VR + ML A MARKUP LANGUAGE FOR THE METAVERSE? http://www.tonyparisi.com 10/21/2014  GLAM (GL AND MARKUP) - A DECLARATIVE LANGUAGE FOR 3D WEB CONTENT https://github.com/tparisi/glam/  DEFINE 3D SCENE CONTENT IN MARKUP; STYLE IT IN CSS THE MARKUP <glam> <renderer type="rift"></renderer> <scene> <controller type="rift"></controller> <background id="sb1" class="skybox"> </background> <group y ='1' z='-3'> <sphere class="bubble skybox”> </sphere> <sphere class="bubble skybox”> </sphere> </group> … THE CSS <style> .skybox { envmap-right:url(../images/Park2/posx.jpg); … } .bubble { radius:.5; shader-vertex:url(../shaders/fresnel.vs); shader-fragment:url(../shaders/fresnel.fs); shader-uniforms:mRefractionRatio f 1.02 mFresnelBias f 0.1 mFresnelPower f 2.0 mFresnelScale f 1.0 tCube t null; } #sb1 { background-type:box; } </style>
  • 21. CHALLENGES  WEBVR ON OCULUS IS NOT READY FOR PRIME TIME  (THAT’S OK NEITHER IS OCULUS!)  LATENCY IS THE BIGGEST ISSUE – BROWSER NEEDS TO UN-THROTTLE AT 60FPS  BUT WE’RE GOOD TO GO ON CARDBOARD!  60FPS WORKS GREAT  NEARLY 2 BILLION VR DEVICES ALREADY DEPLOYED!  FRAMEWORKS AND TOOLS ARE TYPICALLY WEB-ISH: UNDER DEVELOPMENT, ALWAYS IN FLUX, PRETTY MUCH OUT OF CONTROL  BUT OPEN SOURCE SO WE CAN LIVE WITH IT http://www.tonyparisi.com 10/21/2014
  • 22. LINKS  BROWSER DEV BUILDS Firefox http://blog.bitops.com/blog/2014/08/20/updated-firefox-vr-builds/ Chrome https://drive.google.com/folderview?id=0BzudLt22BqGRbW9WTHMtOWMzNjQ  MOZILLA NEXT STEPS FOR VR (THURSDAY 23 OCT 2014) https://air.mozilla.org/virtual-reality-the-web-next-steps/  SAN FRANCISCO WEBVR MEETUP http://www.meetup.com/Web-VR/  WEBVR MAILING LIST web-vr-discuss@mozilla.org  CARDBOARD VR SHOWCASE http://vr.chromeexperiments.com/ http://www.tonyparisi.com 10/21/2014
  • 23. KEEP IN TOUCH CREDS Co-creator, VRML and X3D http://www.tonyparisi.com 10/21/2014 CONTACT tony@vizi.gl skype: auradeluxe http://twitter.com/auradeluxe http://www.tonyparisi.com/ http://www.learningwebgl.com/ GET VIZI https://github.com/tparisi/Vizi GET THE BOOKS! WebGL: Up and Running http://www.amazon.com/dp/144932357X Programming 3D Applications with HTML and WebGL http://www.amazon.com/Programming-Applications-HTML5-WebGL-Visualization/ dp/1449362966 MEETUPS http://www.meetup.com/WebGL-Developers-Meetup/ http://www.meetup.com/Web-VR/ BOOK CODE https://github.com/tparisi/WebGLBook https://github.com/tparisi/Programming3DApplications GET GLAM http://www.glamjs.org/ https://github.com/tparisi/glam/ WORK http://www.vizi.gl/
  • 24. HACKING REALITY: HTML5 AND JAVASCRIPT FOR CROSS-PLATFORM VR TONY PARISI OCTOBER, 2014