diff --git a/examples/js/vr/WebVR.js b/examples/js/vr/WebVR.js index 076228143e0cf0c17b89cafe67d12685654f2217..301e35f9b209be68589cb2d4b823cc5d3f85ec44 100644 --- a/examples/js/vr/WebVR.js +++ b/examples/js/vr/WebVR.js @@ -99,7 +99,15 @@ THREE.WEBVR = { if ( currentSession === null ) { - navigator.xr.requestSession( 'immersive-vr' ).then( onSessionStarted ); + // WebXR's requestReferenceSpace only works if the corresponding feature + // was requested at session creation time. For simplicity, just ask for + // the interesting ones as optional features, but be aware that the + // requestReferenceSpace call will fail if it turns out to be unavailable. + // ('local' is always available for immersive sessions and doesn't need to + // be requested separately.) + + var sessionInit = { optionalFeatures: [ 'local-floor', 'bounded-floor' ] }; + navigator.xr.requestSession( 'immersive-vr', sessionInit ).then( onSessionStarted ); } else { diff --git a/examples/jsm/vr/WebVR.js b/examples/jsm/vr/WebVR.js index 1b93855157bb5a0b98e91a7d4f0c9ea36910f780..db8ef0bcad6ad8cdd477cb83f0cf830adc73b27c 100644 --- a/examples/jsm/vr/WebVR.js +++ b/examples/jsm/vr/WebVR.js @@ -14,7 +14,6 @@ var WEBVR = { if ( options && options.referenceSpaceType ) { renderer.vr.setReferenceSpaceType( options.referenceSpaceType ); - } function showEnterVR( device ) { @@ -101,7 +100,15 @@ var WEBVR = { if ( currentSession === null ) { - navigator.xr.requestSession( 'immersive-vr' ).then( onSessionStarted ); + // WebXR's requestReferenceSpace only works if the corresponding feature + // was requested at session creation time. For simplicity, just ask for + // the interesting ones as optional features, but be aware that the + // requestReferenceSpace call will fail if it turns out to be unavailable. + // ('local' is always available for immersive sessions and doesn't need to + // be requested separately.) + + var sessionInit = { optionalFeatures: [ 'local-floor', 'bounded-floor' ] }; + navigator.xr.requestSession( 'immersive-vr', sessionInit ).then( onSessionStarted ); } else {