Skip to main content

Launching a VR Session

Modern web browsers now come with a powerful new API called WebXR for interacting with VR and AR hardware.

This API enables the browser start a presentation using a VR Display that might be plugged into the computer, or a mobile device.

WebXR Enables developers to build web apps that can work on mobile devices like recent phones and tablets, or

const vrButton = document.querySelector('#vrbutton')vrButton.addEventListener('mouseup', () => {  vrButton.classList.add('invisible')
  const XRViewport = renderer.getXRViewport()
  XRViewport.then(xrViewport => {    xrViewport.startPresenting().then(() => {      xrViewport.presentingChanged.connect(() => {        vrButton.classList.remove('invisible')      })    })  }).catch(reason => {    console.warn('Unable to setup XR:' + reason)  })})