Skip to content

Commit b64ff29

Browse files
authored
Merge pull request #17429 from klausw/webxr-spacefeatures
WebXR: request common reference spaces as features
2 parents 938f4a7 + 80b6bb1 commit b64ff29

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

examples/js/vr/WebVR.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,15 @@ THREE.WEBVR = {
9999

100100
if ( currentSession === null ) {
101101

102-
navigator.xr.requestSession( 'immersive-vr' ).then( onSessionStarted );
102+
// WebXR's requestReferenceSpace only works if the corresponding feature
103+
// was requested at session creation time. For simplicity, just ask for
104+
// the interesting ones as optional features, but be aware that the
105+
// requestReferenceSpace call will fail if it turns out to be unavailable.
106+
// ('local' is always available for immersive sessions and doesn't need to
107+
// be requested separately.)
108+
109+
var sessionInit = { optionalFeatures: [ 'local-floor', 'bounded-floor' ] };
110+
navigator.xr.requestSession( 'immersive-vr', sessionInit ).then( onSessionStarted );
103111

104112
} else {
105113

examples/jsm/vr/WebVR.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ var WEBVR = {
1414
if ( options && options.referenceSpaceType ) {
1515

1616
renderer.vr.setReferenceSpaceType( options.referenceSpaceType );
17-
1817
}
1918

2019
function showEnterVR( device ) {
@@ -101,7 +100,15 @@ var WEBVR = {
101100

102101
if ( currentSession === null ) {
103102

104-
navigator.xr.requestSession( 'immersive-vr' ).then( onSessionStarted );
103+
// WebXR's requestReferenceSpace only works if the corresponding feature
104+
// was requested at session creation time. For simplicity, just ask for
105+
// the interesting ones as optional features, but be aware that the
106+
// requestReferenceSpace call will fail if it turns out to be unavailable.
107+
// ('local' is always available for immersive sessions and doesn't need to
108+
// be requested separately.)
109+
110+
var sessionInit = { optionalFeatures: [ 'local-floor', 'bounded-floor' ] };
111+
navigator.xr.requestSession( 'immersive-vr', sessionInit ).then( onSessionStarted );
105112

106113
} else {
107114

0 commit comments

Comments
 (0)