Browse Source

docdocdoc

Raanan Weber 5 years ago
parent
commit
9399577457

+ 52 - 1
src/Cameras/XR/motionController/webXRAbstractController.ts

@@ -18,6 +18,9 @@ export type MotionControllerHandness = "none" | "left" | "right";
  */
 export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
 
+/**
+ * The state of a controller component
+ */
 export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
 
 /**
@@ -42,27 +45,75 @@ export interface IMotionControllerLayout {
              * The type of input the component outputs
              */
             type: MotionControllerComponentType;
+            /**
+             * The indices of this component in the gamepad object
+             */
             gamepadIndices: {
+                /**
+                 * Index of button
+                 */
                 button?: number;
+                /**
+                 * If available, index of x-axis
+                 */
                 xAxis?: number;
+                /**
+                 * If available, index of y-axis
+                 */
                 yAxis?: number;
             };
+            /**
+             * The mesh's root node name
+             */
             rootNodeName: string;
+            /**
+             * Animation definitions for this model
+             */
             visualResponses: {
-                [state: string]: {
+                [stateKey: string]: {
+                    /**
+                     * What property will be animated
+                     */
                     componentProperty: "xAxis" | "yAxis" | "button" | "state";
+                    /**
+                     * What states influence this visual reponse
+                     */
                     states: MotionControllerComponentStateType[];
+                    /**
+                     * Type of animation - movement or visibility
+                     */
                     valueNodeProperty: "transform" | "visibility";
+                    /**
+                     * Base node name to move. Its position will be calculated according to the min and max nodes
+                     */
                     valueNodeName?: string;
+                    /**
+                     * Minimum movement node
+                     */
                     minNodeName?: string;
+                    /**
+                     * Max movement node
+                     */
                     maxNodeName?: string;
                 }
             }
+            /**
+             * If touch enabled, what is the name of node to display user feedback
+             */
             touchPointNodeName?: string;
         }
     };
+    /**
+     * Is it xr standard mapping or not
+     */
     gamepadMapping: "" | "xr-standard";
+    /**
+     * Base root node of this entire model
+     */
     rootNodeName: string;
+    /**
+     * Path to load the assets. Usually relative to the base path
+     */
     assetPath: string;
 }
 

+ 10 - 0
src/Cameras/XR/motionController/webXRMotionControllerManager.ts

@@ -20,8 +20,17 @@ export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene)
  * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  */
 export class WebXRMotionControllerManager {
+    /**
+     * The base URL of the online controller repository. Can be changed at any time.
+     */
     public static BaseRepositoryUrl = "https://immersive-web.github.io/webxr-input-profiles/packages/viewer/dist";
+    /**
+     * Use the online repository, or use only locally-defined controllers
+     */
     public static UseOnlineRepository: boolean = true;
+    /**
+     * Which repository gets priority - local or online
+     */
     public static PrioritizeOnlineRepository: boolean = true;
     private static _AvailableControllers: { [type: string]: MotionControllerConstructor } = {};
     private static _Fallbacks: { [profileId: string]: string[] } = {};
@@ -165,6 +174,7 @@ export class WebXRMotionControllerManager {
 
     /**
      * Will update the list of profiles available in the repository
+     * @return a promise that resolves to a map of profiles available online
      */
     public static UpdateProfilesList() {
         this._ProfilesList = Tools.LoadFileAsync(this.BaseRepositoryUrl + '/profiles/profilesList.json', false).then((data) => {

+ 7 - 41
src/Cameras/XR/motionController/webXRProfiledMotionController.ts

@@ -5,7 +5,14 @@ import { SceneLoader } from '../../../Loading/sceneLoader';
 import { Mesh } from '../../../Meshes/mesh';
 import { Axis, Space } from '../../../Maths/math.axis';
 
+/**
+ * A profiled motion controller has its profile loaded from an online repository.
+ * The class is responsible of loading the model, mapping the keys and enabling model-animations
+ */
 export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
+    /**
+     * The profile ID of this controller. Will be populated when the controller initializes.
+     */
     public profileId: string;
 
     private _buttonMeshMapping: {
@@ -70,49 +77,8 @@ export class WebXRProfiledMotionController extends WebXRAbstractMotionController
         if (rootMesh) {
             rootMesh.setParent(this.rootMesh);
         }
-        /*let min = {
-            x: 0,
-            y: 0,
-            z: 0
-        };
-        let max = {
-            x: 0,
-            y: 0,
-            z: 0
-        };
-        this.rootMesh.getChildMeshes().forEach((mesh) => {
-            var bi = mesh.getBoundingInfo();
-            var minimum = bi.boundingBox.minimumWorld;
-            var maximum = bi.boundingBox.maximumWorld;
-
-            if (minimum.x < min.x) {
-                min.x = minimum.x;
-            }
-            if (minimum.y < min.y) {
-                min.y = minimum.y;
-            }
-            if (minimum.z < min.z) {
-                min.z = minimum.z;
-            }
-
-            if (maximum.x > max.x) {
-                max.x = maximum.x;
-            }
-            if (maximum.y > max.y) {
-                max.y = maximum.y;
-            }
-            if (maximum.z > max.z) {
-                max.z = maximum.z;
-            }
-        });
-
-        console.log(min, max, { x: max.x + min.x, y: max.y + min.y, z: max.z + min.z });*/
-        // const center = Mesh.Center(this.rootMesh.getChildMeshes());
-        // this.rootMesh.position.subtractInPlace(center.scaleInPlace(2));
-        // this.rootMesh.position.z *= -1;
 
         this.rootMesh.rotate(Axis.Y, Math.PI, Space.WORLD);
-        // this.rootMesh.rotate(Axis.X, -Math.PI / 4, Space.WORLD);
     }
     protected _updateModel(_xrFrame: XRFrame): void {
         if (this.disableAnimation) {

+ 2 - 1
src/Misc/tools.ts

@@ -350,7 +350,8 @@ export class Tools {
     /**
      * Loads a file from a url
      * @param url the file url to load
-     * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
+     * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
+     * @returns a promise containing an ArrayBuffer corresponding to the loaded file
      */
     public static LoadFileAsync(url: string, useArrayBuffer: boolean = true): Promise<ArrayBuffer | string> {
         return new Promise((resolve, reject) => {