浏览代码

expose the impostor for each controller

Raanan Weber 5 年之前
父节点
当前提交
479171ac62
共有 1 个文件被更改,包括 15 次插入0 次删除
  1. 15 0
      src/XR/features/WebXRControllerPhysics.ts

+ 15 - 0
src/XR/features/WebXRControllerPhysics.ts

@@ -8,6 +8,7 @@ import { AbstractMesh } from "../../Meshes/abstractMesh";
 import { SphereBuilder } from "../../Meshes/Builders/sphereBuilder";
 import { WebXRFeatureName, WebXRFeaturesManager } from "../webXRFeaturesManager";
 import { Logger } from '../../Misc/logger';
+import { Nullable } from '../../types';
 
 /**
  * Options for the controller physics feature
@@ -108,6 +109,20 @@ export class WebXRControllerPhysics extends WebXRAbstractFeature {
     }
 
     /**
+     * Get the physics impostor of a specific controller.
+     * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
+     * @param controller the controller or the controller id of which to get the impostor
+     */
+    public getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor> {
+        let id = typeof controller === "string" ? controller : controller.uniqueId;
+        if (this._controllers[id]) {
+            return this._controllers[id].impostor;
+        } else {
+            return null;
+        }
+    }
+
+    /**
      * attach this feature
      * Will usually be called by the features manager
      *