|
@@ -132,6 +132,12 @@ class VRButton {
|
|
|
|
|
|
supported ? showEnterVR() : showWebXRNotFound();
|
|
supported ? showEnterVR() : showWebXRNotFound();
|
|
|
|
|
|
|
|
+ if ( supported && VRButton.xrSessionIsGranted ) {
|
|
|
|
+
|
|
|
|
+ button.click();
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
} );
|
|
} );
|
|
|
|
|
|
return button;
|
|
return button;
|
|
@@ -164,6 +170,24 @@ class VRButton {
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ static xrSessionIsGranted = false;
|
|
|
|
+
|
|
|
|
+ static registerSessionGrantedListener() {
|
|
|
|
+
|
|
|
|
+ if ( 'xr' in navigator ) {
|
|
|
|
+
|
|
|
|
+ navigator.xr.addEventListener( 'sessiongranted', () => {
|
|
|
|
+
|
|
|
|
+ VRButton.xrSessionIsGranted = true;
|
|
|
|
+
|
|
|
|
+ } );
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+VRButton.registerSessionGrantedListener();
|
|
|
|
+
|
|
export { VRButton };
|
|
export { VRButton };
|