properly test if vr supported (#135)

This commit is contained in:
Karang 2021-03-22 00:21:48 +01:00 committed by GitHub
parent 119fb046a6
commit ebf0fa0766
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -5,8 +5,12 @@ const { GLTFLoader } = require('three/examples/jsm/loaders/GLTFLoader.js')
const { XRControllerModelFactory } = require('three/examples/jsm/webxr/XRControllerModelFactory.js')
const TWEEN = require('@tweenjs/tween.js')
function initVR (bot, renderer, viewer) {
async function initVR (bot, renderer, viewer) {
if (!('xr' in navigator)) return
const supported = await navigator.xr.isSessionSupported( 'immersive-vr' )
if (!supported) return
// VR
document.body.appendChild(VRButton.createButton(renderer))
renderer.xr.enabled = true