|
@@ -39,6 +39,15 @@ class VRButton {
|
|
|
|
|
|
button.textContent = 'ENTER VR';
|
|
|
|
|
|
+ // 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.)
|
|
|
+
|
|
|
+ const sessionInit = { optionalFeatures: [ 'local-floor', 'bounded-floor', 'hand-tracking', 'layers' ] };
|
|
|
+
|
|
|
button.onmouseenter = function () {
|
|
|
|
|
|
button.style.opacity = '1.0';
|
|
@@ -55,14 +64,6 @@ class VRButton {
|
|
|
|
|
|
if ( currentSession === null ) {
|
|
|
|
|
|
- // 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.)
|
|
|
-
|
|
|
- const sessionInit = { optionalFeatures: [ 'local-floor', 'bounded-floor', 'hand-tracking', 'layers' ] };
|
|
|
navigator.xr.requestSession( 'immersive-vr', sessionInit ).then( onSessionStarted );
|
|
|
|
|
|
} else {
|
|
@@ -73,6 +74,13 @@ class VRButton {
|
|
|
|
|
|
};
|
|
|
|
|
|
+ if ( navigator.xr.offerSession !== undefined ) {
|
|
|
+
|
|
|
+ navigator.xr.offerSession( 'immersive-vr', sessionInit )
|
|
|
+ .then( onSessionStarted );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
function disableButton() {
|