Parcourir la source

allow entering xr in firefox reality

Raanan Weber il y a 5 ans
Parent
commit
5ac3ef4952
3 fichiers modifiés avec 11 ajouts et 6 suppressions
  1. 8 0
      src/Engines/thinEngine.ts
  2. 2 0
      src/XR/webXREnterExitUI.ts
  3. 1 6
      src/XR/webXRExperienceHelper.ts

+ 8 - 0
src/Engines/thinEngine.ts

@@ -106,6 +106,10 @@ export interface EngineOptions extends WebGLContextAttributes {
      * Defines that engine should compile shaders with high precision floats (if supported). True by default
      * Defines that engine should compile shaders with high precision floats (if supported). True by default
      */
      */
     useHighPrecisionFloats?: boolean;
     useHighPrecisionFloats?: boolean;
+    /**
+     * Make the canvas XR Compatible for XR sessions
+     */
+    xrCompatible?: boolean;
 }
 }
 
 
 /**
 /**
@@ -516,6 +520,10 @@ export class ThinEngine {
                 this.premultipliedAlpha = false;
                 this.premultipliedAlpha = false;
             }
             }
 
 
+            if (options.xrCompatible === undefined) {
+                options.xrCompatible = true;
+            }
+
             this._doNotHandleContextLost = options.doNotHandleContextLost ? true : false;
             this._doNotHandleContextLost = options.doNotHandleContextLost ? true : false;
 
 
             // Exceptions
             // Exceptions

+ 2 - 0
src/XR/webXREnterExitUI.ts

@@ -170,6 +170,8 @@ export class WebXREnterExitUI implements IDisposable {
                             }
                             }
                         }
                         }
                     };
                     };
+                } else {
+                    Tools.Warn(`Session mode "${ui._buttons[i].sessionMode}" not supported in browser`);
                 }
                 }
             });
             });
             return ui;
             return ui;

+ 1 - 6
src/XR/webXRExperienceHelper.ts

@@ -108,12 +108,7 @@ export class WebXRExperienceHelper implements IDisposable {
             Logger.Warn("We recommend using 'unbounded' reference space type when using 'immersive-ar' session mode");
             Logger.Warn("We recommend using 'unbounded' reference space type when using 'immersive-ar' session mode");
         }
         }
         // make sure that the session mode is supported
         // make sure that the session mode is supported
-        return this.sessionManager.isSessionSupportedAsync(sessionMode).then((supported) => {
-            if (!supported) {
-                throw new Error(`Session mode "${sessionMode}" not supported in browser`);
-            }
-            return this.sessionManager.initializeSessionAsync(sessionMode, sessionCreationOptions);
-        }).then(() => {
+        return this.sessionManager.initializeSessionAsync(sessionMode, sessionCreationOptions).then(() => {
             return this.sessionManager.setReferenceSpaceTypeAsync(referenceSpaceType);
             return this.sessionManager.setReferenceSpaceTypeAsync(referenceSpaceType);
         }).then(() => {
         }).then(() => {
             return renderTarget.initializeXRLayerAsync(this.sessionManager.session);
             return renderTarget.initializeXRLayerAsync(this.sessionManager.session);