Explorar o código

stay defensive when downloading the .json file

Raanan Weber %!s(int64=4) %!d(string=hai) anos
pai
achega
1d47a3cfe2
Modificáronse 1 ficheiros con 9 adicións e 5 borrados
  1. 9 5
      src/XR/webXRInput.ts

+ 9 - 5
src/XR/webXRInput.ts

@@ -106,12 +106,16 @@ export class WebXRInput implements IDisposable {
             WebXRMotionControllerManager.BaseRepositoryUrl = this.options.customControllersRepositoryURL;
         }
 
-        if (!this.options.disableOnlineControllerRepository) {
-            WebXRMotionControllerManager.UseOnlineRepository = true;
+        WebXRMotionControllerManager.UseOnlineRepository = !this.options.disableOnlineControllerRepository;
+        if (WebXRMotionControllerManager.UseOnlineRepository) {
             // pre-load the profiles list to load the controllers quicker afterwards
-            WebXRMotionControllerManager.UpdateProfilesList();
-        } else {
-            WebXRMotionControllerManager.UseOnlineRepository = false;
+            try {
+                WebXRMotionControllerManager.UpdateProfilesList().catch(() => {
+                    WebXRMotionControllerManager.UseOnlineRepository = false;
+                });
+            } catch (e) {
+                WebXRMotionControllerManager.UseOnlineRepository = false;
+            }
         }
     }