Переглянути джерело

allow disabling the animation of the controller model

Raanan Weber 5 роки тому
батько
коміт
d50765d24b

+ 3 - 0
src/Cameras/XR/motionController/webXRAbstractController.ts

@@ -195,6 +195,9 @@ export abstract class WebXRAbstractMotionController implements IDisposable {
      */
     public rootMesh: Nullable<AbstractMesh>;
 
+    /**
+     * Disable the model's animation. Can be set at any time.
+     */
     public disableAnimation: boolean = false;
 
     private _modelReady: boolean = false;

+ 1 - 1
src/Cameras/XR/motionController/webXRHTCViveMotionController.ts

@@ -45,7 +45,7 @@ export class WebXRHTCViveMotionController extends WebXRAbstractMotionController
             if (comp) {
                 comp.onButtonStateChanged.add((component) => {
 
-                    if (!this.rootMesh) { return; }
+                    if (!this.rootMesh || this.disableAnimation) { return; }
 
                     switch (type) {
                         case "xr-standard-trigger":

+ 3 - 0
src/Cameras/XR/motionController/webXRMicrosoftMixedRealityController.ts

@@ -94,6 +94,9 @@ export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionCon
 
         // Button Meshes
         this.getComponentTypes().forEach((buttonName, i) => {
+            if (this.disableAnimation) {
+                return;
+            }
             if (buttonName && this.rootMesh) {
                 const buttonMap = (<any>this._mapping.buttons)[buttonName];
                 const buttonMeshName = buttonMap.rootNodeName;

+ 1 - 1
src/Cameras/XR/motionController/webXROculusTouchMotionController.ts

@@ -55,7 +55,7 @@ export class WebXROculusTouchMotionController extends WebXRAbstractMotionControl
             if (comp) {
                 comp.onButtonStateChanged.add((component) => {
 
-                    if (!this.rootMesh) { return; }
+                    if (!this.rootMesh || this.disableAnimation) { return; }
 
                     switch (buttonName) {
                         case "xr-standard-trigger": // index trigger

+ 10 - 1
src/Cameras/XR/webXRInput.ts

@@ -33,6 +33,11 @@ export interface IWebXRInputOptions {
      * A custom URL for the controllers repository
      */
     customControllersRepositoryURL?: string;
+
+    /**
+     * Should the controller model's components not move according to the user input
+     */
+    disableControllerAnimation?: boolean;
 }
 /**
  * XR input used to track XR inputs such as controllers/rays
@@ -109,7 +114,11 @@ export class WebXRInput implements IDisposable {
         let sources = this.controllers.map((c) => { return c.inputSource; });
         for (let input of addInputs) {
             if (sources.indexOf(input) === -1) {
-                let controller = new WebXRController(this.xrSessionManager.scene, input, { forceControllerProfile: this.options.forceInputProfile, doNotLoadControllerMesh: this.options.doNotLoadControllerMeshes });
+                let controller = new WebXRController(this.xrSessionManager.scene, input, {
+                    forceControllerProfile: this.options.forceInputProfile,
+                    doNotLoadControllerMesh: this.options.doNotLoadControllerMeshes,
+                    disableMotionControllerAnimation: this.options.disableControllerAnimation
+                });
                 this.controllers.push(controller);
                 this.onControllerAddedObservable.notifyObservers(controller);
             }