소스 검색

WebXR: request common reference spaces as features

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.)
Klaus Weidner 6 년 전
부모
커밋
80b6bb119d
2개의 변경된 파일18개의 추가작업 그리고 3개의 파일을 삭제
  1. 9 1
      examples/js/vr/WebVR.js
  2. 9 2
      examples/jsm/vr/WebVR.js

+ 9 - 1
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 {
 

+ 9 - 2
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 {