Selaa lähdekoodia

Add Doc to all inputs

sebastien 7 vuotta sitten
vanhempi
commit
e548cd7034

+ 2 - 2
src/Cameras/Inputs/babylon.arcRotateCameraKeyboardMoveInput.ts

@@ -1,6 +1,6 @@
 module BABYLON {
     /**
-     * Manage the keyboard inputs to control the movment of an arc rotate camera.
+     * Manage the keyboard inputs to control the movement of an arc rotate camera.
      * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
      */
     export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
@@ -55,7 +55,7 @@ module BABYLON {
         public zoomingSensibility: number = 25.0;
 
         /**
-         * Defines wether maintaining the alt key down switch the movment mode from
+         * Defines wether maintaining the alt key down switch the movement mode from
          * orientation to zoom.
          */
         @serialize()

+ 34 - 5
src/Cameras/Inputs/babylon.freeCameraDeviceOrientationInput.ts

@@ -2,6 +2,7 @@ module BABYLON {
     /**
      * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
      * Screen rotation is taken into account.
+     * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
      */
     export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
         private _camera: FreeCamera;
@@ -15,11 +16,18 @@ module BABYLON {
         private _beta: number = 0;
         private _gamma: number = 0;
 
+        /**
+         * Instantiates a new input
+         * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
+         */
         constructor() {
             this._constantTranform = new Quaternion(- Math.sqrt(0.5), 0, 0, Math.sqrt(0.5));
             this._orientationChanged();
         }
 
+        /**
+         * Define the camera controlled by the input.
+         */
         public get camera(): FreeCamera {
             return this._camera;
         }
@@ -31,7 +39,12 @@ module BABYLON {
             }
         }
 
-        attachControl(element: HTMLElement, noPreventDefault?: boolean) {
+        /**
+         * Attach the input controls to a specific dom element to get the input from.
+         * @param element Defines the element the controls should be listened from
+         * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
+         */
+        public attachControl(element: HTMLElement, noPreventDefault?: boolean): void {
             window.addEventListener("orientationchange", this._orientationChanged);
             window.addEventListener("deviceorientation", this._deviceOrientation);
             //In certain cases, the attach control is called AFTER orientation was changed,
@@ -51,12 +64,20 @@ module BABYLON {
             this._gamma = evt.gamma !== null ? evt.gamma : 0;
         }
 
-        detachControl(element: Nullable<HTMLElement>) {
+        /**
+         * Detach the current controls from the specified dom element.
+         * @param element Defines the element to stop listening the inputs from
+         */
+        public detachControl(element: Nullable<HTMLElement>): void {
             window.removeEventListener("orientationchange", this._orientationChanged);
             window.removeEventListener("deviceorientation", this._deviceOrientation);
         }
 
-        public checkInputs() {
+        /**
+         * Update the current camera state depending on the inputs that have been used this frame.
+         * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
+         */
+        public checkInputs(): void {
             //if no device orientation provided, don't update the rotation.
             //Only testing against alpha under the assumption thatnorientation will never be so exact when set.
             if (!this._alpha) return;
@@ -68,11 +89,19 @@ module BABYLON {
             this._camera.rotationQuaternion.w *= -1;
         }
 
-        getClassName(): string {
+        /**
+         * Gets the class name of the current intput.
+         * @returns the class name
+         */
+        public getClassName(): string {
             return "FreeCameraDeviceOrientationInput";
         }
 
-        getSimpleName() {
+        /**
+         * Get the friendly name associated with the input class.
+         * @returns the input friendly name
+         */
+        public getSimpleName(): string {
             return "deviceOrientation";
         }
     }

+ 49 - 10
src/Cameras/Inputs/babylon.freeCameraGamepadInput.ts

@@ -1,24 +1,47 @@
 module BABYLON {
+    /**
+     * Manage the gamepad inputs to control a free camera.
+     * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
+     */
     export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
-        camera: FreeCamera;
+        /**
+         * Define the camera the input is attached to.
+         */
+        public camera: FreeCamera;
 
-        public gamepad: Nullable<Gamepad>;        
-        private _onGamepadConnectedObserver : Nullable<Observer<Gamepad>>;
-        private _onGamepadDisconnectedObserver : Nullable<Observer<Gamepad>>;
+        /**
+         * Define the Gamepad controlling the input
+         */
+        public gamepad: Nullable<Gamepad>;
 
+        /**
+         * Defines the gamepad rotation sensiblity.
+         * This is the threshold from when rotation starts to be accounted for to prevent jittering.
+         */
         @serialize()
         public gamepadAngularSensibility = 200;
 
+        /**
+         * Defines the gamepad move sensiblity.
+         * This is the threshold from when moving starts to be accounted for for to prevent jittering.
+         */
         @serialize()
         public gamepadMoveSensibility = 40;
-
+        
         // private members
+        private _onGamepadConnectedObserver : Nullable<Observer<Gamepad>>;
+        private _onGamepadDisconnectedObserver : Nullable<Observer<Gamepad>>;
         private _cameraTransform: Matrix = Matrix.Identity();
         private _deltaTransform: Vector3 = Vector3.Zero();
         private _vector3: Vector3 = Vector3.Zero();
         private _vector2: Vector2 = Vector2.Zero();
 
-        attachControl(element: HTMLElement, noPreventDefault?: boolean) {
+        /**
+         * Attach the input controls to a specific dom element to get the input from.
+         * @param element Defines the element the controls should be listened from
+         * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
+         */
+        public attachControl(element: HTMLElement, noPreventDefault?: boolean): void {
             let manager = this.camera.getScene().gamepadManager;
             this._onGamepadConnectedObserver = manager.onGamepadConnectedObservable.add((gamepad) => {
                 if (gamepad.type !== Gamepad.POSE_ENABLED) {
@@ -38,13 +61,21 @@ module BABYLON {
             this.gamepad = manager.getGamepadByType(Gamepad.XBOX);
         }
 
-        detachControl(element: Nullable<HTMLElement>) {
+        /**
+         * Detach the current controls from the specified dom element.
+         * @param element Defines the element to stop listening the inputs from
+         */
+        public detachControl(element: Nullable<HTMLElement>): void {
             this.camera.getScene().gamepadManager.onGamepadConnectedObservable.remove(this._onGamepadConnectedObserver);
             this.camera.getScene().gamepadManager.onGamepadDisconnectedObservable.remove(this._onGamepadDisconnectedObserver);
             this.gamepad = null;
         }
 
-        checkInputs() {
+        /**
+         * Update the current camera state depending on the inputs that have been used this frame.
+         * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
+         */
+        public checkInputs(): void {
             if (this.gamepad && this.gamepad.leftStick) {
                 var camera = this.camera;
                 var LSValues = this.gamepad.leftStick;
@@ -80,11 +111,19 @@ module BABYLON {
             }
         }
 
-        getClassName(): string {
+        /**
+         * Gets the class name of the current intput.
+         * @returns the class name
+         */
+        public getClassName(): string {
             return "FreeCameraGamepadInput";
         }
 
-        getSimpleName() {
+        /**
+         * Get the friendly name associated with the input class.
+         * @returns the input friendly name
+         */
+        public getSimpleName(): string {
             return "gamepad";
         }
     }

+ 53 - 12
src/Cameras/Inputs/babylon.freeCameraKeyboardMoveInput.ts

@@ -1,25 +1,50 @@
 module BABYLON {
+    /**
+     * Manage the keyboard inputs to control the movement of a free camera.
+     * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
+     */
     export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
-        camera: FreeCamera;
-        private _keys = new Array<number>();
-        private _onCanvasBlurObserver: Nullable<Observer<Engine>>;
-        private _onKeyboardObserver: Nullable<Observer<KeyboardInfo>>;
-        private _engine: Engine;
-        private _scene: Scene;
-
+        /**
+         * Defines the camera the input is attached to.
+         */
+        public camera: FreeCamera;
+
+        /**
+         * Gets or Set the list of keyboard keys used to control the forward move of the camera.
+         */
         @serialize()
         public keysUp = [38];
 
+        /**
+         * Gets or Set the list of keyboard keys used to control the backward move of the camera.
+         */
         @serialize()
         public keysDown = [40];
 
+        /**
+         * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
+         */
         @serialize()
         public keysLeft = [37];
 
+        /**
+         * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
+         */
         @serialize()
         public keysRight = [39];
 
-        attachControl(element: HTMLElement, noPreventDefault?: boolean) {
+        private _keys = new Array<number>();
+        private _onCanvasBlurObserver: Nullable<Observer<Engine>>;
+        private _onKeyboardObserver: Nullable<Observer<KeyboardInfo>>;
+        private _engine: Engine;
+        private _scene: Scene;
+
+        /**
+         * Attach the input controls to a specific dom element to get the input from.
+         * @param element Defines the element the controls should be listened from
+         * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
+         */
+        public attachControl(element: HTMLElement, noPreventDefault?: boolean): void {
             if (this._onCanvasBlurObserver) {
                 return;
             }
@@ -66,7 +91,11 @@ module BABYLON {
             });
         }
 
-        detachControl(element: Nullable<HTMLElement>) {
+        /**
+         * Detach the current controls from the specified dom element.
+         * @param element Defines the element to stop listening the inputs from
+         */
+        public detachControl(element: Nullable<HTMLElement>): void {
             if (this._scene) {
                 if (this._onKeyboardObserver) {
                     this._scene.onKeyboardObservable.remove(this._onKeyboardObserver);
@@ -81,7 +110,11 @@ module BABYLON {
             this._keys = [];
         }
 
-        public checkInputs() {
+        /**
+         * Update the current camera state depending on the inputs that have been used this frame.
+         * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
+         */
+        public checkInputs(): void {
             if (this._onKeyboardObserver) {
                 var camera = this.camera;
                 // Keyboard
@@ -110,7 +143,11 @@ module BABYLON {
             }
         }
 
-        getClassName(): string {
+        /**
+         * Gets the class name of the current intput.
+         * @returns the class name
+         */
+        public getClassName(): string {
             return "FreeCameraKeyboardMoveInput";
         }
 
@@ -119,7 +156,11 @@ module BABYLON {
             this._keys = [];
         }
 
-        getSimpleName() {
+        /**
+         * Get the friendly name associated with the input class.
+         * @returns the input friendly name
+         */
+        public getSimpleName(): string {
             return "keyboard";
         }
     }

+ 46 - 8
src/Cameras/Inputs/babylon.freeCameraMouseInput.ts

@@ -1,23 +1,49 @@
 module BABYLON {
+    /**
+     * Manage the mouse inputs to control the movement of a free camera.
+     * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
+     */
     export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
-        camera: FreeCamera;
-
+        /**
+         * Defines the camera the input is attached to.
+         */
+        public camera: FreeCamera;
+
+        /**
+         * Defines the buttons associated with the input to handle camera move.
+         */
         @serialize()
         public buttons = [0, 1, 2];
 
+        /**
+         * Defines the pointer angular sensibility  along the X and Y axis or how fast is the camera rotating.
+         */
         @serialize()
         public angularSensibility = 2000.0;
 
         private _pointerInput: (p: PointerInfo, s: EventState) => void;
         private _onMouseMove: Nullable<(e: MouseEvent) => any>;
         private _observer: Nullable<Observer<PointerInfo>>;
-
         private previousPosition: Nullable<{ x: number, y: number }> = null;
 
-        constructor(public touchEnabled = true) {
+        /**
+         * Manage the mouse inputs to control the movement of a free camera.
+         * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
+         * @param touchEnabled Defines if touch is enabled or not
+         */
+        constructor(
+            /**
+             * Define if touch is enabled in the mouse input
+             */
+            public touchEnabled = true) {
         }
 
-        attachControl(element: HTMLElement, noPreventDefault?: boolean) {
+        /**
+         * Attach the input controls to a specific dom element to get the input from.
+         * @param element Defines the element the controls should be listened from
+         * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
+         */
+        public attachControl(element: HTMLElement, noPreventDefault?: boolean):void {
             var engine = this.camera.getEngine();
 
             if (!this._pointerInput) {
@@ -122,7 +148,11 @@ module BABYLON {
 
         }
 
-        detachControl(element: Nullable<HTMLElement>) {
+        /**
+         * Detach the current controls from the specified dom element.
+         * @param element Defines the element to stop listening the inputs from
+         */
+        public detachControl(element: Nullable<HTMLElement>):void {
             if (this._observer && element) {
                 this.camera.getScene().onPointerObservable.remove(this._observer);
 
@@ -136,11 +166,19 @@ module BABYLON {
             }
         }
 
-        getClassName(): string {
+        /**
+         * Gets the class name of the current intput.
+         * @returns the class name
+         */
+        public getClassName(): string {
             return "FreeCameraMouseInput";
         }
 
-        getSimpleName() {
+        /**
+         * Get the friendly name associated with the input class.
+         * @returns the input friendly name
+         */
+        public getSimpleName(): string {
             return "mouse";
         }
     }

+ 44 - 12
src/Cameras/Inputs/babylon.freeCameraTouchInput.ts

@@ -1,6 +1,27 @@
 module BABYLON {
+    /**
+     * Manage the touch inputs to control the movement of a free camera.
+     * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
+     */
     export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
-        camera: FreeCamera;
+        /**
+         * Defines the camera the input is attached to.
+         */
+        public camera: FreeCamera;
+
+        /**
+         * Defines the touch sensibility for rotation.
+         * The higher the faster.
+         */
+        @serialize()
+        public touchAngularSensibility: number = 200000.0;
+
+        /**
+         * Defines the touch sensibility for move.
+         * The higher the faster.
+         */
+        @serialize()
+        public touchMoveSensibility: number = 250.0;
 
         private _offsetX: Nullable<number> = null;
         private _offsetY: Nullable<number> = null;
@@ -10,13 +31,12 @@ module BABYLON {
         private _observer: Nullable<Observer<PointerInfo>>;
         private _onLostFocus: Nullable<(e: FocusEvent) => any>;
 
-        @serialize()
-        public touchAngularSensibility: number = 200000.0;
-
-        @serialize()
-        public touchMoveSensibility: number = 250.0;
-
-        attachControl(element: HTMLElement, noPreventDefault?: boolean) {
+        /**
+         * Attach the input controls to a specific dom element to get the input from.
+         * @param element Defines the element the controls should be listened from
+         * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
+         */
+        public attachControl(element: HTMLElement, noPreventDefault?: boolean): void {
             var previousPosition: Nullable<{ x: number, y: number }> = null;
 
             if (this._pointerInput === undefined) {
@@ -98,7 +118,11 @@ module BABYLON {
             }
         }
 
-        detachControl(element: Nullable<HTMLElement>) {
+        /**
+         * Detach the current controls from the specified dom element.
+         * @param element Defines the element to stop listening the inputs from
+         */
+        public detachControl(element: Nullable<HTMLElement>): void {
             if (this._pointerInput && element) {
                 if (this._observer) {
                     this.camera.getScene().onPointerObservable.remove(this._observer);
@@ -115,7 +139,7 @@ module BABYLON {
             }
         }
 
-        checkInputs() {
+        public checkInputs(): void {
             if (this._offsetX && this._offsetY) {
                 var camera = this.camera;
                 camera.cameraRotation.y += this._offsetX / this.touchAngularSensibility;
@@ -132,11 +156,19 @@ module BABYLON {
             }
         }
 
-        getClassName(): string {
+        /**
+         * Gets the class name of the current intput.
+         * @returns the class name
+         */
+        public getClassName(): string {
             return "FreeCameraTouchInput";
         }
 
-        getSimpleName() {
+        /**
+         * Get the friendly name associated with the input class.
+         * @returns the input friendly name
+         */
+        public getSimpleName(): string {
             return "touch";
         }
     }

+ 42 - 8
src/Cameras/Inputs/babylon.freeCameraVirtualJoystickInput.ts

@@ -1,18 +1,35 @@
 module BABYLON {
+    /**
+     * Manage the Virtual Joystick inputs to control the movement of a free camera.
+     * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
+     */
     export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
-        camera: FreeCamera;
+        /**
+         * Defines the camera the input is attached to.
+         */
+        public camera: FreeCamera;
 
         private _leftjoystick: VirtualJoystick;
         private _rightjoystick: VirtualJoystick;
-        
+
+        /**
+         * Gets the left stick of the virtual joystick.
+         */
         public getLeftJoystick(): VirtualJoystick {
             return this._leftjoystick;
         }
 
+        /**
+         * Gets the right stick of the virtual joystick.
+         */
         public getRightJoystick(): VirtualJoystick {
             return this._rightjoystick;
         }
 
+        /**
+         * Update the current camera state depending on the inputs that have been used this frame.
+         * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
+         */
         public checkInputs() {
             if (this._leftjoystick){
                 var camera = this.camera;
@@ -30,8 +47,13 @@ module BABYLON {
                 }
             }
         }
-        
-        attachControl(element : HTMLElement, noPreventDefault?: boolean) {
+
+        /**
+         * Attach the input controls to a specific dom element to get the input from.
+         * @param element Defines the element the controls should be listened from
+         * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
+         */
+        public attachControl(element : HTMLElement, noPreventDefault?: boolean): void {
             this._leftjoystick = new VirtualJoystick(true);
             this._leftjoystick.setAxisForUpDown(JoystickAxis.Z);
             this._leftjoystick.setAxisForLeftRight(JoystickAxis.X);
@@ -44,16 +66,28 @@ module BABYLON {
             this._rightjoystick.setJoystickColor("yellow");
         }
 
-        detachControl(element: Nullable<HTMLElement>) {
+        /**
+         * Detach the current controls from the specified dom element.
+         * @param element Defines the element to stop listening the inputs from
+         */
+        public detachControl(element: Nullable<HTMLElement>): void {
             this._leftjoystick.releaseCanvas();
             this._rightjoystick.releaseCanvas();
         }
 
-        getClassName(): string {
+        /**
+         * Gets the class name of the current intput.
+         * @returns the class name
+         */
+        public getClassName(): string {
             return "FreeCameraVirtualJoystickInput";
         }
-        
-        getSimpleName(){
+
+        /**
+         * Get the friendly name associated with the input class.
+         * @returns the input friendly name
+         */
+        public getSimpleName(): string {
             return "virtualJoystick";
         }
     }

+ 1 - 1
src/Cameras/babylon.camera.ts

@@ -138,7 +138,7 @@
 
         /**
          * Define the default inertia of the camera.
-         * This helps giving a smooth feeling to the camera movment.
+         * This helps giving a smooth feeling to the camera movement.
          */
         @serialize()
         public inertia = 0.9;