Browse Source

Merge pull request #4041 from TrevorDev/vrControllerDocs

vr controller docs
David Catuhe 7 năm trước cách đây
mục cha
commit
acfbd76907

+ 2 - 509
dist/preview release/typedocValidationBaseline.json

@@ -1,7 +1,7 @@
 {
-  "errors": 5975,
+  "errors": 5886,
   "babylon.typedoc.json": {
-    "errors": 5975,
+    "errors": 5886,
     "AnimationKeyInterpolation": {
       "Enumeration": {
         "Comments": {
@@ -80,40 +80,6 @@
         }
       }
     },
-    "PoseEnabledControllerType": {
-      "Enumeration": {
-        "Comments": {
-          "MissingText": true
-        }
-      },
-      "Enumeration member": {
-        "GEAR_VR": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "GENERIC": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "OCULUS": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "VIVE": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "WINDOWS": {
-          "Comments": {
-            "MissingText": true
-          }
-        }
-      }
-    },
     "SimplificationType": {
       "Enumeration member": {
         "QUADRATIC": {
@@ -9988,49 +9954,6 @@
         }
       }
     },
-    "GearVRController": {
-      "Class": {
-        "Comments": {
-          "MissingText": true
-        }
-      },
-      "Property": {
-        "GAMEPAD_ID_PREFIX": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "MODEL_BASE_URL": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "MODEL_FILENAME": {
-          "Comments": {
-            "MissingText": true
-          }
-        }
-      }
-    },
-    "GenericController": {
-      "Class": {
-        "Comments": {
-          "MissingText": true
-        }
-      },
-      "Property": {
-        "MODEL_BASE_URL": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "MODEL_FILENAME": {
-          "Comments": {
-            "MissingText": true
-          }
-        }
-      }
-    },
     "GenericPad": {
       "Class": {
         "Comments": {
@@ -16120,60 +16043,6 @@
         }
       }
     },
-    "OculusTouchController": {
-      "Class": {
-        "Comments": {
-          "MissingText": true
-        }
-      },
-      "Property": {
-        "onAButtonStateChangedObservable": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "onBButtonStateChangedObservable": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "onSecondaryTriggerStateChangedObservable": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "onThumbRestChangedObservable": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "onXButtonStateChangedObservable": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "onYButtonStateChangedObservable": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "MODEL_BASE_URL": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "MODEL_LEFT_FILENAME": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "MODEL_RIGHT_FILENAME": {
-          "Comments": {
-            "MissingText": true
-          }
-        }
-      }
-    },
     "OimoJSPlugin": {
       "Class": {
         "Comments": {
@@ -18662,136 +18531,6 @@
         }
       }
     },
-    "PoseEnabledController": {
-      "Class": {
-        "Comments": {
-          "MissingText": true
-        }
-      },
-      "Property": {
-        "_deviceToWorld": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "_mesh": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "controllerType": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "devicePosition": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "deviceRotationQuaternion": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "deviceScaleFactor": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "mesh": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "position": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "rawPose": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "rotationQuaternion": {
-          "Comments": {
-            "MissingText": true
-          }
-        }
-      },
-      "Method": {
-        "attachToMesh": {
-          "Comments": {
-            "MissingText": true
-          },
-          "Parameter": {
-            "mesh": {
-              "Comments": {
-                "MissingText": true
-              }
-            }
-          }
-        },
-        "attachToPoseControlledCamera": {
-          "Comments": {
-            "MissingText": true
-          },
-          "Parameter": {
-            "camera": {
-              "Comments": {
-                "MissingText": true
-              }
-            }
-          }
-        },
-        "getForwardRay": {
-          "Comments": {
-            "MissingText": true
-          },
-          "Parameter": {
-            "length": {
-              "Comments": {
-                "MissingText": true
-              }
-            }
-          }
-        },
-        "updateFromDevice": {
-          "Comments": {
-            "MissingText": true
-          },
-          "Parameter": {
-            "poseData": {
-              "Comments": {
-                "MissingText": true
-              }
-            }
-          }
-        }
-      }
-    },
-    "PoseEnabledControllerHelper": {
-      "Class": {
-        "Comments": {
-          "MissingText": true
-        }
-      },
-      "Method": {
-        "InitiateController": {
-          "Comments": {
-            "MissingText": true
-          },
-          "Parameter": {
-            "vrGamepad": {
-              "Comments": {
-                "MissingText": true
-              }
-            }
-          }
-        }
-      }
-    },
     "PositionNormalTextureVertex": {
       "Class": {
         "Comments": {
@@ -30755,40 +30494,6 @@
         }
       }
     },
-    "ViveController": {
-      "Class": {
-        "Comments": {
-          "MissingText": true
-        }
-      },
-      "Property": {
-        "onLeftButtonStateChangedObservable": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "onMenuButtonStateChangedObservable": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "onRightButtonStateChangedObservable": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "MODEL_BASE_URL": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "MODEL_FILENAME": {
-          "Comments": {
-            "MissingText": true
-          }
-        }
-      }
-    },
     "VolumetricLightScatteringPostProcess": {
       "Class": {
         "Comments": {
@@ -30833,172 +30538,6 @@
         }
       }
     },
-    "WebVRController": {
-      "Class": {
-        "Comments": {
-          "MissingText": true
-        }
-      },
-      "Property": {
-        "defaultModel": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "hand": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "onMainButtonStateChangedObservable": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "onPadStateChangedObservable": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "onPadValuesChangedObservable": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "onSecondaryButtonStateChangedObservable": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "onTriggerStateChangedObservable": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "pad": {
-          "Comments": {
-            "MissingText": true
-          }
-        }
-      },
-      "Method": {
-        "initControllerMesh": {
-          "Comments": {
-            "MissingText": true
-          },
-          "Parameter": {
-            "scene": {
-              "Comments": {
-                "MissingText": true
-              }
-            },
-            "meshLoaded": {
-              "Comments": {
-                "MissingText": true
-              }
-            }
-          }
-        },
-        "onButtonStateChange": {
-          "Comments": {
-            "MissingText": true
-          },
-          "Parameter": {
-            "callback": {
-              "Comments": {
-                "MissingText": true
-              }
-            }
-          }
-        }
-      }
-    },
-    "WindowsMotionController": {
-      "Class": {
-        "Comments": {
-          "MissingText": true
-        }
-      },
-      "Property": {
-        "onGripButtonStateChangedObservable": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "onMenuButtonStateChangedObservable": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "onThumbstickButtonStateChangedObservable": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "onTouchpadButtonStateChangedObservable": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "onTouchpadValuesChangedObservable": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "onTrackpadChangedObservable": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "onTrackpadValuesChangedObservable": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "onTriggerButtonStateChangedObservable": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "trackpad": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "GAMEPAD_ID_PREFIX": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "MODEL_BASE_URL": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "MODEL_LEFT_FILENAME": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "MODEL_RIGHT_FILENAME": {
-          "Comments": {
-            "MissingText": true
-          }
-        }
-      },
-      "Method": {
-        "lerpAxisTransform": {
-          "Naming": {
-            "NotUnderscoreCamelCase": true
-          }
-        },
-        "lerpButtonTransform": {
-          "Naming": {
-            "NotUnderscoreCamelCase": true
-          }
-        }
-      }
-    },
     "Xbox360Pad": {
       "Class": {
         "Comments": {
@@ -31682,28 +31221,6 @@
         }
       }
     },
-    "ExtendedGamepadButton": {
-      "Interface": {
-        "Comments": {
-          "MissingText": true
-        }
-      },
-      "Property": {
-        "GamepadButton": {
-          "Naming": {
-            "NotCamelCase": true
-          },
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "touched": {
-          "Comments": {
-            "MissingText": true
-          }
-        }
-      }
-    },
     "GamepadButtonChanges": {
       "Interface": {
         "Comments": {
@@ -33134,30 +32651,6 @@
         }
       }
     },
-    "MutableGamepadButton": {
-      "Interface": {
-        "Comments": {
-          "MissingText": true
-        }
-      },
-      "Property": {
-        "pressed": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "touched": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "value": {
-          "Comments": {
-            "MissingText": true
-          }
-        }
-      }
-    },
     "PhysicsForceAndContactPoint": {
       "Property": {
         "contactPoint": {

+ 15 - 0
src/Gamepad/Controllers/babylon.daydreamController.ts

@@ -18,11 +18,20 @@ module BABYLON {
          */
         public static readonly GAMEPAD_ID_PREFIX: string = 'Daydream'; // id is 'Daydream Controller'
 
+        /**
+         * Creates a new DaydreamController from a gamepad
+         * @param vrGamepad the gamepad that the controller should be created from
+         */
         constructor(vrGamepad: any) {
             super(vrGamepad);
             this.controllerType = PoseEnabledControllerType.DAYDREAM;
         }
 
+        /**
+         * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
+         * @param scene scene in which to add meshes
+         * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
+         */
         public initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void) {
             SceneLoader.ImportMesh("", DaydreamController.MODEL_BASE_URL, DaydreamController.MODEL_FILENAME, scene, (newMeshes) => {
                 this._defaultModel = newMeshes[1];
@@ -34,6 +43,12 @@ module BABYLON {
             });
         }
 
+        /**
+         * Called once for each button that changed state since the last frame
+         * @param buttonIdx Which button index changed
+         * @param state New state of the button
+         * @param changes Which properties on the state changed since last frame
+         */
         protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges) {
             // Daydream controller only has 1 GamepadButton (on the trackpad).
             if (buttonIdx === 0) {

+ 27 - 1
src/Gamepad/Controllers/babylon.gearVRController.ts

@@ -1,9 +1,20 @@
 module BABYLON {
-    
+    /**
+     * Gear VR Controller
+     */
     export class GearVRController extends WebVRController {
+        /**
+         * Base Url for the controller model.
+         */
         public static MODEL_BASE_URL:string = 'https://controllers.babylonjs.com/generic/';
+        /**
+         * File name for the controller model.
+         */
         public static MODEL_FILENAME:string = 'generic.babylon';
 
+        /**
+         * Gamepad Id prefix used to identify this controller.
+         */
         public static readonly GAMEPAD_ID_PREFIX: string = 'Gear VR'; // id is 'Gear VR Controller'
 
         private readonly _buttonIndexToObservableNameMap = [
@@ -11,11 +22,20 @@ module BABYLON {
             'onTriggerStateChangedObservable' // Trigger
         ]
 
+        /**
+         * Creates a new GearVRController from a gamepad
+         * @param vrGamepad the gamepad that the controller should be created from
+         */
         constructor(vrGamepad: any) {
             super(vrGamepad);
             this.controllerType = PoseEnabledControllerType.GEAR_VR;
         }
 
+        /**
+         * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
+         * @param scene scene in which to add meshes
+         * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
+         */
         public initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void) {
             SceneLoader.ImportMesh("", GearVRController.MODEL_BASE_URL, GearVRController.MODEL_FILENAME, scene, (newMeshes) => {
                 this._defaultModel = newMeshes[1];
@@ -26,6 +46,12 @@ module BABYLON {
             });
         }
 
+        /**
+         * Called once for each button that changed state since the last frame
+         * @param buttonIdx Which button index changed
+         * @param state New state of the button
+         * @param changes Which properties on the state changed since last frame
+         */
         protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges) {
             if (buttonIdx < this._buttonIndexToObservableNameMap.length) {
                 const observableName : string = this._buttonIndexToObservableNameMap[buttonIdx];

+ 24 - 1
src/Gamepad/Controllers/babylon.genericController.ts

@@ -1,13 +1,30 @@
 module BABYLON {
-    
+    /**
+     * Generic Controller
+     */
     export class GenericController extends WebVRController {
+        /**
+         * Base Url for the controller model.
+         */
         public static readonly MODEL_BASE_URL:string = 'https://controllers.babylonjs.com/generic/';
+        /**
+         * File name for the controller model.
+         */
         public static readonly MODEL_FILENAME:string = 'generic.babylon';
 
+        /**
+         * Creates a new GenericController from a gamepad
+         * @param vrGamepad the gamepad that the controller should be created from
+         */
         constructor(vrGamepad: any) {
             super(vrGamepad);
         }
 
+        /**
+         * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
+         * @param scene scene in which to add meshes
+         * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
+         */
         public initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void) {
             SceneLoader.ImportMesh("", GenericController.MODEL_BASE_URL, GenericController.MODEL_FILENAME, scene, (newMeshes) => {
                 this._defaultModel = newMeshes[1];
@@ -18,6 +35,12 @@ module BABYLON {
             });
         }
 
+        /**
+         * Called once for each button that changed state since the last frame
+         * @param buttonIdx Which button index changed
+         * @param state New state of the button
+         * @param changes Which properties on the state changed since last frame
+         */
         protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges) {
             console.log("Button id: " + buttonIdx + "state: ");
             console.dir(state);

+ 51 - 10
src/Gamepad/Controllers/babylon.oculusTouchController.ts

@@ -1,19 +1,45 @@
 module BABYLON {
-
+    /**
+     * Oculus Touch Controller
+     */
     export class OculusTouchController extends WebVRController {
+        /**
+         * Base Url for the controller model.
+         */
         public static MODEL_BASE_URL: string = 'https://controllers.babylonjs.com/oculus/';
+        /**
+         * File name for the left controller model.
+         */
         public static MODEL_LEFT_FILENAME: string = 'left.babylon';
+        /**
+         * File name for the right controller model.
+         */
         public static MODEL_RIGHT_FILENAME: string = 'right.babylon';
 
+        /**
+         * Fired when the secondary trigger on this controller is modified
+         */
         public onSecondaryTriggerStateChangedObservable = new Observable<ExtendedGamepadButton>();
 
+        /**
+         * Fired when the thumb rest on this controller is modified
+         */
         public onThumbRestChangedObservable = new Observable<ExtendedGamepadButton>();
 
+        /**
+         * Creates a new OculusTouchController from a gamepad
+         * @param vrGamepad the gamepad that the controller should be created from
+         */
         constructor(vrGamepad: any) {
             super(vrGamepad);
             this.controllerType = PoseEnabledControllerType.OCULUS;
         }
 
+        /**
+         * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
+         * @param scene scene in which to add meshes
+         * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
+         */
         public initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void) {
             let meshName;
 
@@ -46,7 +72,9 @@ module BABYLON {
         }
 
 
-        // helper getters for left and right hand.
+        /**
+         * Fired when the A button on this controller is modified
+         */
         public get onAButtonStateChangedObservable() {
             if (this.hand === 'right') {
                 return this.onMainButtonStateChangedObservable;
@@ -55,6 +83,9 @@ module BABYLON {
             }
         }
 
+        /**
+         * Fired when the B button on this controller is modified
+         */
         public get onBButtonStateChangedObservable() {
             if (this.hand === 'right') {
                 return this.onSecondaryButtonStateChangedObservable;
@@ -63,6 +94,9 @@ module BABYLON {
             }
         }
 
+        /**
+         * Fired when the X button on this controller is modified
+         */
         public get onXButtonStateChangedObservable() {
             if (this.hand === 'left') {
                 return this.onMainButtonStateChangedObservable;
@@ -71,6 +105,9 @@ module BABYLON {
             }
         }
 
+        /**
+         * Fired when the Y button on this controller is modified
+         */
         public get onYButtonStateChangedObservable() {
             if (this.hand === 'left') {
                 return this.onSecondaryButtonStateChangedObservable;
@@ -79,14 +116,18 @@ module BABYLON {
             }
         }
 
-        /*
-         0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
-         1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
-         2) secondary trigger (same)
-         3) A (right) X (left), touch, pressed = value
-         4) B / Y 
-         5) thumb rest
-        */
+       /**
+         * Called once for each button that changed state since the last frame
+         * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
+         * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
+         * 2) secondary trigger (same)
+         * 3) A (right) X (left), touch, pressed = value
+         * 4) B / Y 
+         * 5) thumb rest
+         * @param buttonIdx Which button index changed
+         * @param state New state of the button
+         * @param changes Which properties on the state changed since last frame
+         */
         protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges) {
             let notifyObject = state; //{ state: state, changes: changes };
             let triggerDirection = this.hand === 'right' ? -1 : 1;

+ 112 - 7
src/Gamepad/Controllers/babylon.poseEnabledController.ts

@@ -1,30 +1,80 @@
 module BABYLON {
-
+    /**
+    * Defines the types of pose enabled controllers that are supported
+    */
     export enum PoseEnabledControllerType {
+        /**
+         * HTC Vive
+         */
         VIVE,
+        /**
+         * Oculus Rift
+         */
         OCULUS,
+        /**
+         * Windows mixed reality
+         */
         WINDOWS,
+        /**
+         * Samsung gear VR
+         */
         GEAR_VR,
         /**
          * Google Daydream
          */
         DAYDREAM,
+        /**
+         * Generic
+         */
         GENERIC
     }
 
+    /**
+     * Defines the MutableGamepadButton interface for the state of a gamepad button
+     */
     export interface MutableGamepadButton {
+        /**
+         * Value of the button/trigger
+         */
         value: number;
+        /**
+         * If the button/trigger is currently touched
+         */
         touched: boolean;
+        /**
+         * If the button/trigger is currently pressed
+         */
         pressed: boolean;
     }
 
+    /**
+     * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
+     * @ignore
+     */
     export interface ExtendedGamepadButton extends GamepadButton {
+        /**
+         * If the button/trigger is currently pressed
+         */
         readonly pressed: boolean;
+        /**
+         * If the button/trigger is currently touched
+         */
         readonly touched: boolean;
+        /**
+         * Value of the button/trigger
+         */
         readonly value: number;
     }
 
+    /**
+     * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
+     */
     export class PoseEnabledControllerHelper {
+        /**
+         * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
+         * @param vrGamepad the gamepad to initialized
+         * @returns a vr controller of the type the gamepad identified as
+         */
         public static InitiateController(vrGamepad: any) {
             // Oculus Touch
             if (vrGamepad.id.indexOf('Oculus Touch') !== -1) {
@@ -53,31 +103,59 @@ module BABYLON {
         }
     }
 
+    /**
+     * Defines the PoseEnabledController object that contains state of a vr capable controller
+     */
     export class PoseEnabledController extends Gamepad implements PoseControlled {
         // Represents device position and rotation in room space. Should only be used to help calculate babylon space values
         private _deviceRoomPosition = Vector3.Zero();
         private _deviceRoomRotationQuaternion = new Quaternion();
 
-        // Represents device position and rotation in babylon space
+        /**
+         * The device position in babylon space
+         */
         public devicePosition = Vector3.Zero();
+        /**
+         * The device rotation in babylon space
+         */
         public deviceRotationQuaternion = new Quaternion();
+        /**
+         * The scale factor of the device in babylon space
+         */
+        public deviceScaleFactor: number = 1;
 
-        deviceScaleFactor: number = 1;
-
+        /**
+         * (Likely devicePosition should be used instead) The device position in its room space
+         */
         public position: Vector3;
+        /**
+         * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
+         */
         public rotationQuaternion: Quaternion;
+        /**
+         * The type of controller (Eg. Windows mixed reality)
+         */
         public controllerType: PoseEnabledControllerType;
 
         private _calculatedPosition: Vector3;
         private _calculatedRotation: Quaternion;
 
+        /**
+         * The raw pose from the device
+         */
         public rawPose: DevicePose; //GamepadPose;
 
+        /**
+         * Internal, the mesh attached to the controller
+         */
         public _mesh: Nullable<AbstractMesh>; // a node that will be attached to this Gamepad
         private _poseControlledCamera: TargetCamera;
 
         private _leftHandSystemQuaternion: Quaternion = new Quaternion();
 
+        /**
+         * Internal, matrix used to convert room space to babylon space
+         */
         public _deviceToWorld = Matrix.Identity();
 
         /**
@@ -88,7 +166,10 @@ module BABYLON {
          * Name of the child mesh that can be used to cast a ray from the controller
          */
         public static readonly POINTING_POSE = "POINTING_POSE";
-
+        /**
+         * Creates a new PoseEnabledController from a gamepad
+         * @param browserGamepad the gamepad that the PoseEnabledController should be created from
+         */
         constructor(browserGamepad: any) {
             super(browserGamepad.id, browserGamepad.index, browserGamepad);
             this.type = Gamepad.POSE_ENABLED;
@@ -102,6 +183,9 @@ module BABYLON {
         }
 
         private _workingMatrix = Matrix.Identity();
+        /**
+         * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
+         */
         public update() {
             super.update();
             var pose: GamepadPose = this.browserGamepad.pose;
@@ -120,7 +204,10 @@ module BABYLON {
                 }
             }
         }
-
+        /**
+         * Updates the state of the pose enbaled controller based on the raw pose data from the device
+         * @param poseData raw pose fromthe device
+         */
         updateFromDevice(poseData: DevicePose) {
             if (poseData) {
                 this.rawPose = poseData;
@@ -151,7 +238,10 @@ module BABYLON {
             }
         }
 
-
+        /**
+         * Attaches a mesh to the controller
+         * @param mesh the mesh to be attached
+         */
         public attachToMesh(mesh: AbstractMesh) {
             if (this._mesh) {
                 this._mesh.parent = null;
@@ -165,6 +255,10 @@ module BABYLON {
             }
         }
 
+        /**
+         * Attaches the controllers mesh to a camera
+         * @param camera the camera the mesh should be attached to
+         */
         public attachToPoseControlledCamera(camera: TargetCamera) {
             this._poseControlledCamera = camera;
             if (this._mesh) {
@@ -172,6 +266,9 @@ module BABYLON {
             }
         }
 
+        /**
+         * Disposes of the controller
+         */
         public dispose() {
             if (this._mesh) {
                 this._mesh.dispose();
@@ -181,10 +278,18 @@ module BABYLON {
             super.dispose();
         }
 
+        /**
+         * The mesh that is attached to the controller
+         */
         public get mesh(): Nullable<AbstractMesh> {
             return this._mesh;
         }
 
+        /**
+         * Gets the ray of the controller in the direction the controller is pointing
+         * @param length the length the resulting ray should be
+         * @returns a ray in the direction the controller is pointing
+         */
         public getForwardRay(length = 100): Ray {
             if (!this.mesh) {
                 return new Ray(Vector3.Zero(), new Vector3(0, 0, 1), length);

+ 31 - 1
src/Gamepad/Controllers/babylon.viveController.ts

@@ -1,15 +1,32 @@
 module BABYLON {
-
+    /**
+     * Vive Controller
+     */
     export class ViveController extends WebVRController {
+        /**
+         * Base Url for the controller model.
+         */
         public static MODEL_BASE_URL: string = 'https://controllers.babylonjs.com/vive/';
+        /**
+         * File name for the controller model.
+         */
         public static MODEL_FILENAME: string = 'wand.babylon';
 
+        /**
+         * Creates a new ViveController from a gamepad
+         * @param vrGamepad the gamepad that the controller should be created from
+         */
         constructor(vrGamepad: any) {
             super(vrGamepad);
             this.controllerType = PoseEnabledControllerType.VIVE;
             this._invertLeftStickY = true;
         }
 
+        /**
+         * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
+         * @param scene scene in which to add meshes
+         * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
+         */
         public initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void) {
             SceneLoader.ImportMesh("", ViveController.MODEL_BASE_URL, ViveController.MODEL_FILENAME, scene, (newMeshes) => {
                 /*
@@ -31,24 +48,37 @@ module BABYLON {
             });
         }
 
+        /**
+         * Fired when the left button on this controller is modified
+         */
         public get onLeftButtonStateChangedObservable() {
             return this.onMainButtonStateChangedObservable;
         }
 
+        /**
+         * Fired when the right button on this controller is modified
+         */
         public get onRightButtonStateChangedObservable() {
             return this.onMainButtonStateChangedObservable;
         }
 
+        /**
+         * Fired when the menu button on this controller is modified
+         */
         public get onMenuButtonStateChangedObservable() {
             return this.onSecondaryButtonStateChangedObservable;
         }
 
         /**
+         * Called once for each button that changed state since the last frame
          * Vive mapping:
          * 0: touchpad
          * 1: trigger
          * 2: left AND right buttons
          * 3: menu button
+         * @param buttonIdx Which button index changed
+         * @param state New state of the button
+         * @param changes Which properties on the state changed since last frame
          */
         protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges) {
             let notifyObject = state; //{ state: state, changes: changes };

+ 56 - 3
src/Gamepad/Controllers/babylon.webVRController.ts

@@ -1,38 +1,80 @@
 module BABYLON {
-
+    /**
+     * Defines the WebVRController object that represents controllers tracked in 3D space
+     */
     export abstract class WebVRController extends PoseEnabledController {
-
+        /**
+         * Internal, the default controller model for the controller
+         */
         protected _defaultModel: AbstractMesh;
 
         // Observables
+        /**
+         * Fired when the trigger state has changed
+         */
         public onTriggerStateChangedObservable = new Observable<ExtendedGamepadButton>();
+        /**
+         * Fired when the main button state has changed
+         */
         public onMainButtonStateChangedObservable = new Observable<ExtendedGamepadButton>();
+        /**
+         * Fired when the secondary button state has changed
+         */
         public onSecondaryButtonStateChangedObservable = new Observable<ExtendedGamepadButton>();
+        /**
+         * Fired when the pad state has changed
+         */
         public onPadStateChangedObservable = new Observable<ExtendedGamepadButton>();
+        /**
+         * Fired when controllers stick values have changed
+         */
         public onPadValuesChangedObservable = new Observable<StickValues>();
 
+        /**
+         * Array of button availible on the controller
+         */
         protected _buttons: Array<MutableGamepadButton>;
 
         private _onButtonStateChange: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void;
 
+        /**
+         * Fired when a controller button's state has changed
+         * @param callback the callback containing the button that was modified
+         */
         public onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void) {
             this._onButtonStateChange = callback;
         }
 
+        /**
+         * X and Y axis corrisponding to the controllers joystick
+         */
         public pad: StickValues = { x: 0, y: 0 };
 
-        public hand: string; // 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
+        /**
+         * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
+         */
+        public hand: string;
 
+        /**
+         * The default controller model for the controller
+         */
         public get defaultModel(): AbstractMesh {
             return this._defaultModel;
         }
 
+        /**
+         * Creates a new WebVRController from a gamepad
+         * @param vrGamepad the gamepad that the WebVRController should be created from
+         */
         constructor(vrGamepad: any) {
             super(vrGamepad);
             this._buttons = new Array<ExtendedGamepadButton>(vrGamepad.buttons.length);
             this.hand = vrGamepad.hand;
         }
 
+        /**
+         * Updates the state of the controller and mesh based on the current position and rotation of the controller
+         */
         public update() {
             super.update();
             for (var index = 0; index < this._buttons.length; index++) {
@@ -45,8 +87,16 @@ module BABYLON {
             }
         }
 
+        /**
+         * Function to be called when a button is modified
+         */
         protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
 
+        /**
+         * Loads a mesh and attaches it to the controller
+         * @param scene the scene the mesh should be added to
+         * @param meshLoaded callback for when the mesh has been loaded
+         */
         public abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
 
         private _setButtonValue(newState: ExtendedGamepadButton, currentState: ExtendedGamepadButton, buttonIndex: number) {
@@ -93,6 +143,9 @@ module BABYLON {
             return this._changes;
         }
 
+        /**
+         * Disposes of th webVRCOntroller
+         */
         public dispose(): void {
             super.dispose();
 

+ 114 - 5
src/Gamepad/Controllers/babylon.windowsMotionController.ts

@@ -1,33 +1,92 @@
 module BABYLON {
-
+    /**
+     * Defines the LoadedMeshInfo object that describes information about the loaded webVR controller mesh
+     */
     class LoadedMeshInfo {
+        /**
+         * Root of the mesh
+         */
         public rootNode: AbstractMesh;
+        /**
+         * Node of the mesh corrisponding to the direction the ray should be cast from the controller
+         */
         public pointingPoseNode: AbstractMesh;
+        /**
+         * Map of the button meshes contained in the controller
+         */
         public buttonMeshes: { [id: string]: IButtonMeshInfo; } = {};
+        /**
+         * Map of the axis meshes contained in the controller
+         */
         public axisMeshes: { [id: number]: IAxisMeshInfo; } = {};
     }
 
+    /**
+     * Defines the IMeshInfo object that describes information a webvr controller mesh
+     */
     interface IMeshInfo {
+        /**
+         * Index of the mesh inside the root mesh
+         */
         index: number;
+        /**
+         * The mesh
+         */
         value: AbstractMesh;
     }
 
+    /**
+     * Defines the IButtonMeshInfo object that describes a button mesh
+     */
     interface IButtonMeshInfo extends IMeshInfo {
+        /**
+         * The mesh that should be displayed when pressed
+         */
         pressed: AbstractMesh;
+        /**
+         * The mesh that should be displayed when not pressed
+         */
         unpressed: AbstractMesh;
     }
 
+    /**
+     * Defines the IAxisMeshInfo object that describes an axis mesh
+     */
     interface IAxisMeshInfo extends IMeshInfo {
+        /**
+         * The mesh that should be set when at its min
+         */
         min: AbstractMesh;
+        /**
+         * The mesh that should be set when at its max
+         */
         max: AbstractMesh;
     }
 
+    /**
+     * Defines the WindowsMotionController object that the state of the windows motion controller
+     */
     export class WindowsMotionController extends WebVRController {
+        /**
+         * The base url used to load the left and right controller models
+         */
         public static MODEL_BASE_URL: string = 'https://controllers.babylonjs.com/microsoft/';
+        /**
+         * The name of the left controller model file
+         */
         public static MODEL_LEFT_FILENAME: string = 'left.glb';
+        /**
+         * The name of the right controller model file
+         */
         public static MODEL_RIGHT_FILENAME: string = 'right.glb';
 
+        /**
+         * The controller name prefix for this controller type
+         */
         public static readonly GAMEPAD_ID_PREFIX: string = 'Spatial Controller (Spatial Interaction Source) ';
+        /**
+         * The controller id pattern for this controller type
+         */
         private static readonly GAMEPAD_ID_PATTERN = /([0-9a-zA-Z]+-[0-9a-zA-Z]+)$/;
 
         private _loadedMeshInfo: Nullable<LoadedMeshInfo>;
@@ -65,36 +124,67 @@ module BABYLON {
             pointingPoseMeshName: PoseEnabledController.POINTING_POSE
         };
 
+        /**
+         * Fired when the trackpad on this controller is clicked
+         */
         public onTrackpadChangedObservable = new Observable<ExtendedGamepadButton>();
+        /**
+         * Fired when the trackpad on this controller is modified
+         */
         public onTrackpadValuesChangedObservable = new Observable<StickValues>();
+        /**
+         * The current x and y values of this controller's trackpad
+         */
         public trackpad: StickValues = { x: 0, y: 0 };
 
+        /**
+         * Creates a new WindowsMotionController from a gamepad
+         * @param vrGamepad the gamepad that the controller should be created from
+         */
         constructor(vrGamepad: any) {
             super(vrGamepad);
             this.controllerType = PoseEnabledControllerType.WINDOWS;
             this._loadedMeshInfo = null;
         }
 
+        /**
+         * Fired when the trigger on this controller is modified
+         */
         public get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton> {
             return this.onTriggerStateChangedObservable;
         }
 
+        /**
+         * Fired when the menu button on this controller is modified
+         */
         public get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton> {
             return this.onSecondaryButtonStateChangedObservable;
         }
 
+        /**
+         * Fired when the grip button on this controller is modified
+         */
         public get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton> {
             return this.onMainButtonStateChangedObservable;
         }
 
+        /**
+         * Fired when the thumbstick button on this controller is modified
+         */
         public get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton> {
             return this.onPadStateChangedObservable;
         }
 
+        /**
+         * Fired when the touchpad button on this controller is modified
+         */
         public get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton> {
             return this.onTrackpadChangedObservable;
         }
 
+        /**
+         * Fired when the touchpad values on this controller are modified
+         */
         public get onTouchpadValuesChangedObservable(): Observable<StickValues> {
             return this.onTrackpadValuesChangedObservable;
         }
@@ -113,7 +203,7 @@ module BABYLON {
                 // Only need to animate axes if there is a loaded mesh
                 if (this._loadedMeshInfo) {
                     for (let axis = 0; axis < this._mapping.axisMeshNames.length; axis++) {
-                        this.lerpAxisTransform(axis, this.browserGamepad.axes[axis]);
+                        this._lerpAxisTransform(axis, this.browserGamepad.axes[axis]);
                     }
                 }
             }
@@ -137,10 +227,15 @@ module BABYLON {
                 observable.notifyObservers(state);
             }
 
-            this.lerpButtonTransform(buttonName, state.value);
+            this._lerpButtonTransform(buttonName, state.value);
         }
 
-        protected lerpButtonTransform(buttonName: string, buttonValue: number) {
+        /**
+         * Moves the buttons on the controller mesh based on their current state
+         * @param buttonName the name of the button to move
+         * @param buttonValue the value of the button which determines the buttons new position
+         */
+        protected _lerpButtonTransform(buttonName: string, buttonValue: number) {
 
             // If there is no loaded mesh, there is nothing to transform.
             if (!this._loadedMeshInfo) {
@@ -165,7 +260,13 @@ module BABYLON {
                 meshInfo.value.position);
         }
 
-        protected lerpAxisTransform(axis: number, axisValue: number) {
+        /**
+         * Moves the axis on the controller mesh based on its current state
+         * @param axis the index of the axis
+         * @param axisValue the value of the axis which determines the meshes new position
+         * @ignore
+         */
+        protected _lerpAxisTransform(axis: number, axisValue: number) {
             if (!this._loadedMeshInfo) {
                 return;
             }
@@ -382,6 +483,11 @@ module BABYLON {
             }
         }
 
+        /**
+         * Gets the ray of the controller in the direction the controller is pointing
+         * @param length the length the resulting ray should be
+         * @returns a ray in the direction the controller is pointing
+         */
         public getForwardRay(length = 100): Ray {
             if (!(this._loadedMeshInfo && this._loadedMeshInfo.pointingPoseNode)) {
                 return super.getForwardRay(length);
@@ -398,6 +504,9 @@ module BABYLON {
             return new Ray(origin, direction, length);
         }
 
+         /**
+         * Disposes of the controller
+         */
         public dispose(): void {
             super.dispose();