Ok, let’s get real: VR in a Web Browser isn’t something new in 2017. Firefox shipped their support for everyone. HTC Vive, Oculus Rift and other hardware is being supported. You can create VR experiences using your browser and Javascript. New browser engines are powerful enough to be able to serve the experiences on a open and standardised platform. But what about AR? Or Mixed Realities (MR)? Join my session and learn how AR or better said MR is getting into your browsers, too. See how and what the platform is being able to offer and what you could expect in near future.
22. Get VR Displays
var frameData = new VRFrameData();
var vrDisplay;
navigator.getVRDisplays().then(function (displays) {
vrDisplay = displays[0];
console.log('Display found');
// Starting the presentation when the button
// is clicked: It can only be called in response to a user gesture
btn.addEventListener('click', function () {
vrDisplay.requestPresent([{ source: canvas }]).then(function () {
drawVRScene();
});
});
});
23. Draw your VR Scene
function drawVRScene() {
// WebVR: Request the next frame of the animation
vrSceneFrame = vrDisplay.requestAnimationFrame(drawVRScene);
// Populate frameData with the data of the next frame to display
vrDisplay.getFrameData(frameData);
// You can get the position, orientation, etc.
// of the display from the current frame's pose
// curFramePose is a VRPose object
var curFramePose = frameData.pose;
var curPos = curFramePose.position;
var curOrient = curFramePose.orientation;
// Here happens some WebGL Stuff!
// WebVR: Indicate that we are ready to present the rendered frame to the VR display
vrDisplay.submitFrame();
}
24. Import WebVR polyfill
Set up camera
Initialize sceneSet up lights
Declare and pass canvasInstall VREffect
Listen to window resize
Create render loop
Instantiate renderer
Figure out responsivenessPreload assets
Deal with metatags and mobile
50. WebXR
• is not backwards compatible with WebVR!
• AR is not in focus on start - „Coming soon!“
• Focused on tracking based AR (Phone-based)
51. WebXR
navigator.xr.requestDevice().then(device => {
// Resolves to an XRDevice if one is available, or to null otherwise.
if (device) {
onXRAvailable(device);
}
}).catch(error => {
// An error occurred while requesting an XRDevice.
console.error('Unable to request an XR device: ', error);
});
57. This is just the
beginning
• WebXR is not ready
• APIs are in flux and are
changing constantly
• The web is joining the
hype train!
https://twitter.com/LeapMotion/status/988749463215857664