浏览代码

callback in case the UI delivered an error

Raanan Weber 4 年之前
父节点
当前提交
33d6bd3900
共有 1 个文件被更改,包括 8 次插入0 次删除
  1. 8 0
      src/XR/webXREnterExitUI.ts

+ 8 - 0
src/XR/webXREnterExitUI.ts

@@ -62,6 +62,11 @@ export class WebXREnterExitUIOptions {
      * A list of optional features to init the session with
      * A list of optional features to init the session with
      */
      */
     requiredFeatures?: string[];
     requiredFeatures?: string[];
+
+    /**
+     * If defined, this function will be executed if the UI encounters an error when entering XR
+     */
+    onError?: (error: any) => void;
 }
 }
 /**
 /**
  * UI to allow the user to enter/exit XR mode
  * UI to allow the user to enter/exit XR mode
@@ -180,6 +185,9 @@ export class WebXREnterExitUI implements IDisposable {
                                     const prevTitle = element.title;
                                     const prevTitle = element.title;
                                     element.title = "Error entering XR session : " + prevTitle;
                                     element.title = "Error entering XR session : " + prevTitle;
                                     element.classList.add("xr-error");
                                     element.classList.add("xr-error");
+                                    if(options.onError) {
+                                        options.onError(e);
+                                    }
                                 }
                                 }
                             }
                             }
                         }
                         }