Bläddra i källkod

stay defensive when downloading the .json file

Raanan Weber 4 år sedan
förälder
incheckning
1d47a3cfe2
1 ändrade filer med 9 tillägg och 5 borttagningar
  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;
+            }
         }
     }