Преглед изворни кода

Added global name finder to ease searching for features

Raanan Weber пре 5 година
родитељ
комит
edf6e1ca13

+ 2 - 4
src/Cameras/XR/features/WebXRAnchorSystem.ts

@@ -1,4 +1,4 @@
-import { IWebXRFeature, WebXRFeaturesManager } from '../webXRFeaturesManager';
+import { IWebXRFeature, WebXRFeaturesManager, WebXRFeatureName } from '../webXRFeaturesManager';
 import { WebXRSessionManager } from '../webXRSessionManager';
 import { Observable } from '../../../Misc/observable';
 import { Matrix } from '../../../Maths/math.vector';
@@ -7,8 +7,6 @@ import { WebXRPlaneDetector } from './WebXRPlaneDetector';
 import { WebXRHitTestLegacy } from './WebXRHitTestLegacy';
 import { WebXRAbstractFeature } from './WebXRAbstractFeature';
 
-const Name = "xr-anchor-system";
-
 /**
  * Configuration options of the anchor system
  */
@@ -59,7 +57,7 @@ export class WebXRAnchorSystem extends WebXRAbstractFeature implements IWebXRFea
     /**
      * The module's name
      */
-    public static readonly Name = Name;
+    public static readonly Name = WebXRFeatureName.ANCHOR_SYSTEM;
     /**
      * The (Babylon) version of this module.
      * This is an integer representing the implementation version.

+ 2 - 4
src/Cameras/XR/features/WebXRBackgroundRemover.ts

@@ -1,11 +1,9 @@
-import { WebXRFeaturesManager, IWebXRFeature } from "../webXRFeaturesManager";
+import { WebXRFeaturesManager, IWebXRFeature, WebXRFeatureName } from "../webXRFeaturesManager";
 import { WebXRSessionManager } from '../webXRSessionManager';
 import { AbstractMesh } from '../../../Meshes/abstractMesh';
 import { Observable } from '../../../Misc/observable';
 import { WebXRAbstractFeature } from './WebXRAbstractFeature';
 
-const Name = "xr-background-remover";
-
 /**
  * Options interface for the background remover plugin
  */
@@ -42,7 +40,7 @@ export class WebXRBackgroundRemover extends WebXRAbstractFeature implements IWeb
     /**
      * The module's name
      */
-    public static readonly Name = Name;
+    public static readonly Name = WebXRFeatureName.BACKGROUND_REMOVER;
     /**
      * The (Babylon) version of this module.
      * This is an integer representing the implementation version.

+ 2 - 4
src/Cameras/XR/features/WebXRControllerPointerSelection.ts

@@ -1,4 +1,4 @@
-import { WebXRFeaturesManager, IWebXRFeature } from "../webXRFeaturesManager";
+import { WebXRFeaturesManager, IWebXRFeature, WebXRFeatureName } from "../webXRFeaturesManager";
 import { WebXRSessionManager } from '../webXRSessionManager';
 import { AbstractMesh } from '../../../Meshes/abstractMesh';
 import { Observer } from '../../../Misc/observable';
@@ -17,8 +17,6 @@ import { Ray } from '../../../Culling/ray';
 import { PickingInfo } from '../../../Collisions/pickingInfo';
 import { WebXRAbstractFeature } from './WebXRAbstractFeature';
 
-const Name = "xr-controller-pointer-selection";
-
 /**
  * Options interface for the pointer selection module
  */
@@ -67,7 +65,7 @@ export class WebXRControllerPointerSelection extends WebXRAbstractFeature implem
     /**
      * The module's name
      */
-    public static readonly Name = Name;
+    public static readonly Name = WebXRFeatureName.POINTER_SELECTION;
     /**
      * The (Babylon) version of this module.
      * This is an integer representing the implementation version.

+ 2 - 4
src/Cameras/XR/features/WebXRControllerTeleportation.ts

@@ -1,4 +1,4 @@
-import { IWebXRFeature, WebXRFeaturesManager } from '../webXRFeaturesManager';
+import { IWebXRFeature, WebXRFeaturesManager, WebXRFeatureName } from '../webXRFeaturesManager';
 import { Observer } from '../../../Misc/observable';
 import { WebXRSessionManager } from '../webXRSessionManager';
 import { Nullable } from '../../../types';
@@ -22,8 +22,6 @@ import { Curve3 } from '../../../Maths/math.path';
 import { LinesBuilder } from '../../../Meshes/Builders/linesBuilder';
 import { WebXRAbstractFeature } from './WebXRAbstractFeature';
 
-const Name = "xr-controller-teleportation";
-
 /**
  * The options container for the teleportation module
  */
@@ -89,7 +87,7 @@ export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature imp
     /**
      * The module's name
      */
-    public static readonly Name = Name;
+    public static readonly Name = WebXRFeatureName.TELEPORTATION;
     /**
      * The (Babylon) version of this module.
      * This is an integer representing the implementation version.

+ 2 - 7
src/Cameras/XR/features/WebXRHitTestLegacy.ts

@@ -1,15 +1,10 @@
-import { IWebXRFeature, WebXRFeaturesManager } from '../webXRFeaturesManager';
+import { IWebXRFeature, WebXRFeaturesManager, WebXRFeatureName } from '../webXRFeaturesManager';
 import { WebXRSessionManager } from '../webXRSessionManager';
 import { Observable } from '../../../Misc/observable';
 import { Vector3, Matrix } from '../../../Maths/math.vector';
 import { TransformNode } from '../../../Meshes/transformNode';
 import { WebXRAbstractFeature } from './WebXRAbstractFeature';
 
-/**
- * name of module (can be reused with other versions)
- */
-const WebXRHitTestModuleName = "xr-hit-test";
-
 // the plugin is registered at the end of the file
 
 /**
@@ -50,7 +45,7 @@ export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRFe
     /**
      * The module's name
      */
-    public static readonly Name = WebXRHitTestModuleName;
+    public static readonly Name = WebXRFeatureName.HIT_TEST;
     /**
      * The (Babylon) version of this module.
      * This is an integer representing the implementation version.

+ 2 - 4
src/Cameras/XR/features/WebXRPlaneDetector.ts

@@ -1,12 +1,10 @@
-import { WebXRFeaturesManager, IWebXRFeature } from '../webXRFeaturesManager';
+import { WebXRFeaturesManager, IWebXRFeature, WebXRFeatureName } from '../webXRFeaturesManager';
 import { TransformNode } from '../../../Meshes/transformNode';
 import { WebXRSessionManager } from '../webXRSessionManager';
 import { Observable } from '../../../Misc/observable';
 import { Vector3, Matrix } from '../../../Maths/math.vector';
 import { WebXRAbstractFeature } from './WebXRAbstractFeature';
 
-const Name = "xr-plane-detector";
-
 /**
  * Options used in the plane detector module
  */
@@ -52,7 +50,7 @@ export class WebXRPlaneDetector extends WebXRAbstractFeature implements IWebXRFe
     /**
      * The module's name
      */
-    public static readonly Name = Name;
+    public static readonly Name = WebXRFeatureName.PLANE_DETECTION;
     /**
      * The (Babylon) version of this module.
      * This is an integer representing the implementation version.

+ 12 - 0
src/Cameras/XR/webXRFeaturesManager.ts

@@ -26,6 +26,18 @@ export interface IWebXRFeature extends IDisposable {
 }
 
 /**
+ * A list of the currently available features without referencing them
+ */
+export const WebXRFeatureName: { [globalName: string]: string } = {
+    HIT_TEST: "xr-hit-test",
+    ANCHOR_SYSTEM: "xr-anchor-system",
+    BACKGROUND_REMOVER: "xr-background-remover",
+    POINTER_SELECTION: "xr-controller-pointer-selection",
+    TELEPORTATION: "xr-controller-teleportation",
+    PLANE_DETECTION: "xr-plane-detection"
+};
+
+/**
  * Defining the constructor of a feature. Used to register the modules.
  */
 export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);