Bladeren bron

Merge pull request #8901 from RaananW/noWindowInXR

[XR] Remove all window references from XR classes
David Catuhe 5 jaren geleden
bovenliggende
commit
ff17851426
3 gewijzigde bestanden met toevoegingen van 10 en 7 verwijderingen
  1. 3 1
      src/XR/features/WebXRHandTracking.ts
  2. 5 4
      src/XR/webXREnterExitUI.ts
  3. 2 2
      src/XR/webXRSessionManager.ts

+ 3 - 1
src/XR/features/WebXRHandTracking.ts

@@ -13,6 +13,8 @@ import { WebXRFeaturesManager } from "../webXRFeaturesManager";
 import { IDisposable } from "../../scene";
 import { Observable } from "../../Misc/observable";
 
+declare const XRHand: XRHand;
+
 /**
  * Configuration interface for the hand tracking feature
  */
@@ -233,7 +235,7 @@ export class WebXRHandTracking extends WebXRAbstractFeature {
      * This does not mean that the feature is enabled, but that the objects needed are well defined.
      */
     public isCompatible(): boolean {
-        return (globalThis && typeof ((<any>globalThis)['XRHand']) !== 'undefined');
+        return (typeof XRHand !== 'undefined');
     }
 
     /**

File diff suppressed because it is too large
+ 5 - 4
src/XR/webXREnterExitUI.ts


+ 2 - 2
src/XR/webXRSessionManager.ts

@@ -244,7 +244,7 @@ export class WebXRSessionManager implements IDisposable {
         }
 
         // Stop window's animation frame and trigger sessions animation frame
-        if (window.cancelAnimationFrame) {
+        if (typeof window !== "undefined" && window.cancelAnimationFrame) {
             window.cancelAnimationFrame(engine._frameHandler);
         }
         engine._renderLoop();
@@ -274,7 +274,7 @@ export class WebXRSessionManager implements IDisposable {
                         },
                         (rejectionReason) => {
                             Logger.Error(rejectionReason);
-                            throw "XR initialization failed: required \"viewer\" reference space type not supported.";
+                            throw 'XR initialization failed: required "viewer" reference space type not supported.';
                         }
                     );
                 }