Selaa lähdekoodia

refactor cameras

gleborgne 9 vuotta sitten
vanhempi
commit
fcbfd834ba

Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 21 - 22
dist/preview release/babylon.js


Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 516 - 459
dist/preview release/babylon.max.js


+ 65 - 61
src/Cameras/Inputs/babylon.freecamera.input.deviceorientation.js

@@ -6,66 +6,70 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
 };
 var BABYLON;
 (function (BABYLON) {
-    var FreeCameraDeviceOrientationInput = (function () {
-        function FreeCameraDeviceOrientationInput() {
-            this._offsetX = null;
-            this._offsetY = null;
-            this._orientationGamma = 0;
-            this._orientationBeta = 0;
-            this._initialOrientationGamma = 0;
-            this._initialOrientationBeta = 0;
-            this.angularSensibility = 10000.0;
-            this.moveSensibility = 50.0;
-            this._resetOrientationGamma = this.resetOrientationGamma.bind(this);
-            this._orientationChanged = this.orientationChanged.bind(this);
-        }
-        FreeCameraDeviceOrientationInput.prototype.attachCamera = function (camera) {
-            this.camera = camera;
-            window.addEventListener("resize", this._resetOrientationGamma, false);
-            window.addEventListener("deviceorientation", this._orientationChanged);
-        };
-        FreeCameraDeviceOrientationInput.prototype.resetOrientationGamma = function () {
-            this._initialOrientationGamma = null;
-        };
-        FreeCameraDeviceOrientationInput.prototype.orientationChanged = function (evt) {
-            if (!this._initialOrientationGamma) {
-                this._initialOrientationGamma = evt.gamma;
-                this._initialOrientationBeta = evt.beta;
+    var CameraInputs;
+    (function (CameraInputs) {
+        var FreeCameraDeviceOrientationInput = (function () {
+            function FreeCameraDeviceOrientationInput() {
+                this._offsetX = null;
+                this._offsetY = null;
+                this._orientationGamma = 0;
+                this._orientationBeta = 0;
+                this._initialOrientationGamma = 0;
+                this._initialOrientationBeta = 0;
+                this.angularSensibility = 10000.0;
+                this.moveSensibility = 50.0;
+                this._resetOrientationGamma = this.resetOrientationGamma.bind(this);
+                this._orientationChanged = this.orientationChanged.bind(this);
             }
-            this._orientationGamma = evt.gamma;
-            this._orientationBeta = evt.beta;
-            this._offsetY = (this._initialOrientationBeta - this._orientationBeta);
-            this._offsetX = (this._initialOrientationGamma - this._orientationGamma);
-        };
-        FreeCameraDeviceOrientationInput.prototype.detach = function () {
-            window.removeEventListener("resize", this._resetOrientationGamma);
-            window.removeEventListener("deviceorientation", this._orientationChanged);
-            this._orientationGamma = 0;
-            this._orientationBeta = 0;
-            this._initialOrientationGamma = 0;
-            this._initialOrientationBeta = 0;
-        };
-        FreeCameraDeviceOrientationInput.prototype.checkInputs = function () {
-            if (!this._offsetX) {
-                return;
-            }
-            var camera = this.camera;
-            camera.cameraRotation.y -= this._offsetX / this.angularSensibility;
-            var speed = camera._computeLocalCameraSpeed();
-            var direction = new BABYLON.Vector3(0, 0, speed * this._offsetY / this.moveSensibility);
-            BABYLON.Matrix.RotationYawPitchRollToRef(camera.rotation.y, camera.rotation.x, 0, camera._cameraRotationMatrix);
-            camera.cameraDirection.addInPlace(BABYLON.Vector3.TransformCoordinates(direction, camera._cameraRotationMatrix));
-        };
-        FreeCameraDeviceOrientationInput.prototype.getTypeName = function () {
-            return "deviceorientation";
-        };
-        __decorate([
-            BABYLON.serialize()
-        ], FreeCameraDeviceOrientationInput.prototype, "angularSensibility", void 0);
-        __decorate([
-            BABYLON.serialize()
-        ], FreeCameraDeviceOrientationInput.prototype, "moveSensibility", void 0);
-        return FreeCameraDeviceOrientationInput;
-    }());
-    BABYLON.FreeCameraDeviceOrientationInput = FreeCameraDeviceOrientationInput;
+            FreeCameraDeviceOrientationInput.prototype.attachCamera = function (camera) {
+                this.camera = camera;
+                window.addEventListener("resize", this._resetOrientationGamma, false);
+                window.addEventListener("deviceorientation", this._orientationChanged);
+            };
+            FreeCameraDeviceOrientationInput.prototype.resetOrientationGamma = function () {
+                this._initialOrientationGamma = null;
+            };
+            FreeCameraDeviceOrientationInput.prototype.orientationChanged = function (evt) {
+                if (!this._initialOrientationGamma) {
+                    this._initialOrientationGamma = evt.gamma;
+                    this._initialOrientationBeta = evt.beta;
+                }
+                this._orientationGamma = evt.gamma;
+                this._orientationBeta = evt.beta;
+                this._offsetY = (this._initialOrientationBeta - this._orientationBeta);
+                this._offsetX = (this._initialOrientationGamma - this._orientationGamma);
+            };
+            FreeCameraDeviceOrientationInput.prototype.detach = function () {
+                window.removeEventListener("resize", this._resetOrientationGamma);
+                window.removeEventListener("deviceorientation", this._orientationChanged);
+                this._orientationGamma = 0;
+                this._orientationBeta = 0;
+                this._initialOrientationGamma = 0;
+                this._initialOrientationBeta = 0;
+            };
+            FreeCameraDeviceOrientationInput.prototype.checkInputs = function () {
+                if (!this._offsetX) {
+                    return;
+                }
+                var camera = this.camera;
+                camera.cameraRotation.y -= this._offsetX / this.angularSensibility;
+                var speed = camera._computeLocalCameraSpeed();
+                var direction = new BABYLON.Vector3(0, 0, speed * this._offsetY / this.moveSensibility);
+                BABYLON.Matrix.RotationYawPitchRollToRef(camera.rotation.y, camera.rotation.x, 0, camera._cameraRotationMatrix);
+                camera.cameraDirection.addInPlace(BABYLON.Vector3.TransformCoordinates(direction, camera._cameraRotationMatrix));
+            };
+            FreeCameraDeviceOrientationInput.prototype.getTypeName = function () {
+                return "freecamera.deviceorientation";
+            };
+            __decorate([
+                BABYLON.serialize()
+            ], FreeCameraDeviceOrientationInput.prototype, "angularSensibility", void 0);
+            __decorate([
+                BABYLON.serialize()
+            ], FreeCameraDeviceOrientationInput.prototype, "moveSensibility", void 0);
+            return FreeCameraDeviceOrientationInput;
+        }());
+        CameraInputs.FreeCameraDeviceOrientationInput = FreeCameraDeviceOrientationInput;
+        CameraInputs.InputTypes["freecamera.deviceorientation"] = FreeCameraDeviceOrientationInput;
+    })(CameraInputs = BABYLON.CameraInputs || (BABYLON.CameraInputs = {}));
 })(BABYLON || (BABYLON = {}));

+ 4 - 2
src/Cameras/Inputs/babylon.freecamera.input.deviceorientation.ts

@@ -1,4 +1,4 @@
-module BABYLON {
+module BABYLON.CameraInputs {
     export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
         camera: FreeCamera;
 
@@ -72,7 +72,9 @@ module BABYLON {
         }
 
         getTypeName(): string {
-            return "deviceorientation";
+            return "freecamera.deviceorientation";
         }
     }
+    
+    InputTypes["freecamera.deviceorientation"] = FreeCameraDeviceOrientationInput;
 }

+ 53 - 49
src/Cameras/Inputs/babylon.freecamera.input.gamepad.js

@@ -6,54 +6,58 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
 };
 var BABYLON;
 (function (BABYLON) {
-    var FreeCameraGamepadInput = (function () {
-        function FreeCameraGamepadInput() {
-            var _this = this;
-            this.gamepadAngularSensibility = 200;
-            this.gamepadMoveSensibility = 40;
-            this._gamepads = new BABYLON.Gamepads(function (gamepad) { _this._onNewGameConnected(gamepad); });
-        }
-        FreeCameraGamepadInput.prototype.attachCamera = function (camera) {
-            this.camera = camera;
-        };
-        FreeCameraGamepadInput.prototype.detach = function () {
-        };
-        FreeCameraGamepadInput.prototype.checkInputs = function () {
-            if (this.gamepad) {
-                var camera = this.camera;
-                var LSValues = this.gamepad.leftStick;
-                var normalizedLX = LSValues.x / this.gamepadMoveSensibility;
-                var normalizedLY = LSValues.y / this.gamepadMoveSensibility;
-                LSValues.x = Math.abs(normalizedLX) > 0.005 ? 0 + normalizedLX : 0;
-                LSValues.y = Math.abs(normalizedLY) > 0.005 ? 0 + normalizedLY : 0;
-                var RSValues = this.gamepad.rightStick;
-                var normalizedRX = RSValues.x / this.gamepadAngularSensibility;
-                var normalizedRY = RSValues.y / this.gamepadAngularSensibility;
-                RSValues.x = Math.abs(normalizedRX) > 0.001 ? 0 + normalizedRX : 0;
-                RSValues.y = Math.abs(normalizedRY) > 0.001 ? 0 + normalizedRY : 0;
-                var cameraTransform = BABYLON.Matrix.RotationYawPitchRoll(camera.rotation.y, camera.rotation.x, 0);
-                var speed = camera._computeLocalCameraSpeed() * 50.0;
-                var deltaTransform = BABYLON.Vector3.TransformCoordinates(new BABYLON.Vector3(LSValues.x * speed, 0, -LSValues.y * speed), cameraTransform);
-                camera.cameraDirection = camera.cameraDirection.add(deltaTransform);
-                camera.cameraRotation = camera.cameraRotation.add(new BABYLON.Vector2(RSValues.y, RSValues.x));
+    var CameraInputs;
+    (function (CameraInputs) {
+        var FreeCameraGamepadInput = (function () {
+            function FreeCameraGamepadInput() {
+                var _this = this;
+                this.gamepadAngularSensibility = 200;
+                this.gamepadMoveSensibility = 40;
+                this._gamepads = new BABYLON.Gamepads(function (gamepad) { _this._onNewGameConnected(gamepad); });
             }
-        };
-        FreeCameraGamepadInput.prototype._onNewGameConnected = function (gamepad) {
-            // Only the first gamepad can control the camera
-            if (gamepad.index === 0) {
-                this.gamepad = gamepad;
-            }
-        };
-        FreeCameraGamepadInput.prototype.getTypeName = function () {
-            return "gamepad";
-        };
-        __decorate([
-            BABYLON.serialize()
-        ], FreeCameraGamepadInput.prototype, "gamepadAngularSensibility", void 0);
-        __decorate([
-            BABYLON.serialize()
-        ], FreeCameraGamepadInput.prototype, "gamepadMoveSensibility", void 0);
-        return FreeCameraGamepadInput;
-    }());
-    BABYLON.FreeCameraGamepadInput = FreeCameraGamepadInput;
+            FreeCameraGamepadInput.prototype.attachCamera = function (camera) {
+                this.camera = camera;
+            };
+            FreeCameraGamepadInput.prototype.detach = function () {
+            };
+            FreeCameraGamepadInput.prototype.checkInputs = function () {
+                if (this.gamepad) {
+                    var camera = this.camera;
+                    var LSValues = this.gamepad.leftStick;
+                    var normalizedLX = LSValues.x / this.gamepadMoveSensibility;
+                    var normalizedLY = LSValues.y / this.gamepadMoveSensibility;
+                    LSValues.x = Math.abs(normalizedLX) > 0.005 ? 0 + normalizedLX : 0;
+                    LSValues.y = Math.abs(normalizedLY) > 0.005 ? 0 + normalizedLY : 0;
+                    var RSValues = this.gamepad.rightStick;
+                    var normalizedRX = RSValues.x / this.gamepadAngularSensibility;
+                    var normalizedRY = RSValues.y / this.gamepadAngularSensibility;
+                    RSValues.x = Math.abs(normalizedRX) > 0.001 ? 0 + normalizedRX : 0;
+                    RSValues.y = Math.abs(normalizedRY) > 0.001 ? 0 + normalizedRY : 0;
+                    var cameraTransform = BABYLON.Matrix.RotationYawPitchRoll(camera.rotation.y, camera.rotation.x, 0);
+                    var speed = camera._computeLocalCameraSpeed() * 50.0;
+                    var deltaTransform = BABYLON.Vector3.TransformCoordinates(new BABYLON.Vector3(LSValues.x * speed, 0, -LSValues.y * speed), cameraTransform);
+                    camera.cameraDirection = camera.cameraDirection.add(deltaTransform);
+                    camera.cameraRotation = camera.cameraRotation.add(new BABYLON.Vector2(RSValues.y, RSValues.x));
+                }
+            };
+            FreeCameraGamepadInput.prototype._onNewGameConnected = function (gamepad) {
+                // Only the first gamepad can control the camera
+                if (gamepad.index === 0) {
+                    this.gamepad = gamepad;
+                }
+            };
+            FreeCameraGamepadInput.prototype.getTypeName = function () {
+                return "freecamera.gamepad";
+            };
+            __decorate([
+                BABYLON.serialize()
+            ], FreeCameraGamepadInput.prototype, "gamepadAngularSensibility", void 0);
+            __decorate([
+                BABYLON.serialize()
+            ], FreeCameraGamepadInput.prototype, "gamepadMoveSensibility", void 0);
+            return FreeCameraGamepadInput;
+        }());
+        CameraInputs.FreeCameraGamepadInput = FreeCameraGamepadInput;
+        CameraInputs.InputTypes["freecamera.gamepad"] = FreeCameraGamepadInput;
+    })(CameraInputs = BABYLON.CameraInputs || (BABYLON.CameraInputs = {}));
 })(BABYLON || (BABYLON = {}));

+ 4 - 2
src/Cameras/Inputs/babylon.freecamera.input.gamepad.ts

@@ -1,4 +1,4 @@
-module BABYLON {       
+module BABYLON.CameraInputs {       
     export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
         camera : FreeCamera;
         
@@ -55,7 +55,9 @@ module BABYLON {
         }
         
         getTypeName(): string{
-            return "gamepad";
+            return "freecamera.gamepad";
         }
     }
+    
+    InputTypes["freecamera.gamepad"] = FreeCameraGamepadInput;
 }

+ 95 - 91
src/Cameras/Inputs/babylon.freecamera.input.keyboard.js

@@ -6,102 +6,106 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
 };
 var BABYLON;
 (function (BABYLON) {
-    var FreeCameraKeyboardMoveInput = (function () {
-        function FreeCameraKeyboardMoveInput() {
-            this._keys = [];
-            this.keysUp = [38];
-            this.keysDown = [40];
-            this.keysLeft = [37];
-            this.keysRight = [39];
-        }
-        FreeCameraKeyboardMoveInput.prototype.attachCamera = function (camera) {
-            var _this = this;
-            this.camera = camera;
-            if (this._onKeyDown === undefined) {
-                this._onKeyDown = function (evt) {
-                    if (_this.keysUp.indexOf(evt.keyCode) !== -1 ||
-                        _this.keysDown.indexOf(evt.keyCode) !== -1 ||
-                        _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
-                        _this.keysRight.indexOf(evt.keyCode) !== -1) {
-                        var index = _this._keys.indexOf(evt.keyCode);
-                        if (index === -1) {
-                            _this._keys.push(evt.keyCode);
-                        }
-                        if (!camera._noPreventDefault) {
-                            evt.preventDefault();
-                        }
-                    }
-                };
-                this._onKeyUp = function (evt) {
-                    if (_this.keysUp.indexOf(evt.keyCode) !== -1 ||
-                        _this.keysDown.indexOf(evt.keyCode) !== -1 ||
-                        _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
-                        _this.keysRight.indexOf(evt.keyCode) !== -1) {
-                        var index = _this._keys.indexOf(evt.keyCode);
-                        if (index >= 0) {
-                            _this._keys.splice(index, 1);
+    var CameraInputs;
+    (function (CameraInputs) {
+        var FreeCameraKeyboardMoveInput = (function () {
+            function FreeCameraKeyboardMoveInput() {
+                this._keys = [];
+                this.keysUp = [38];
+                this.keysDown = [40];
+                this.keysLeft = [37];
+                this.keysRight = [39];
+            }
+            FreeCameraKeyboardMoveInput.prototype.attachCamera = function (camera) {
+                var _this = this;
+                this.camera = camera;
+                if (this._onKeyDown === undefined) {
+                    this._onKeyDown = function (evt) {
+                        if (_this.keysUp.indexOf(evt.keyCode) !== -1 ||
+                            _this.keysDown.indexOf(evt.keyCode) !== -1 ||
+                            _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
+                            _this.keysRight.indexOf(evt.keyCode) !== -1) {
+                            var index = _this._keys.indexOf(evt.keyCode);
+                            if (index === -1) {
+                                _this._keys.push(evt.keyCode);
+                            }
+                            if (!camera._noPreventDefault) {
+                                evt.preventDefault();
+                            }
                         }
-                        if (!camera._noPreventDefault) {
-                            evt.preventDefault();
+                    };
+                    this._onKeyUp = function (evt) {
+                        if (_this.keysUp.indexOf(evt.keyCode) !== -1 ||
+                            _this.keysDown.indexOf(evt.keyCode) !== -1 ||
+                            _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
+                            _this.keysRight.indexOf(evt.keyCode) !== -1) {
+                            var index = _this._keys.indexOf(evt.keyCode);
+                            if (index >= 0) {
+                                _this._keys.splice(index, 1);
+                            }
+                            if (!camera._noPreventDefault) {
+                                evt.preventDefault();
+                            }
                         }
-                    }
-                };
-                BABYLON.Tools.RegisterTopRootEvents([
+                    };
+                    BABYLON.Tools.RegisterTopRootEvents([
+                        { name: "keydown", handler: this._onKeyDown },
+                        { name: "keyup", handler: this._onKeyUp },
+                        { name: "blur", handler: this._onLostFocus }
+                    ]);
+                }
+            };
+            FreeCameraKeyboardMoveInput.prototype.detach = function () {
+                BABYLON.Tools.UnregisterTopRootEvents([
                     { name: "keydown", handler: this._onKeyDown },
                     { name: "keyup", handler: this._onKeyUp },
                     { name: "blur", handler: this._onLostFocus }
                 ]);
-            }
-        };
-        FreeCameraKeyboardMoveInput.prototype.detach = function () {
-            BABYLON.Tools.UnregisterTopRootEvents([
-                { name: "keydown", handler: this._onKeyDown },
-                { name: "keyup", handler: this._onKeyUp },
-                { name: "blur", handler: this._onLostFocus }
-            ]);
-        };
-        FreeCameraKeyboardMoveInput.prototype.checkInputs = function () {
-            var camera = this.camera;
-            // Keyboard
-            for (var index = 0; index < this._keys.length; index++) {
-                var keyCode = this._keys[index];
-                var speed = camera._computeLocalCameraSpeed();
-                if (this.keysLeft.indexOf(keyCode) !== -1) {
-                    camera._localDirection.copyFromFloats(-speed, 0, 0);
-                }
-                else if (this.keysUp.indexOf(keyCode) !== -1) {
-                    camera._localDirection.copyFromFloats(0, 0, speed);
-                }
-                else if (this.keysRight.indexOf(keyCode) !== -1) {
-                    camera._localDirection.copyFromFloats(speed, 0, 0);
-                }
-                else if (this.keysDown.indexOf(keyCode) !== -1) {
-                    camera._localDirection.copyFromFloats(0, 0, -speed);
+            };
+            FreeCameraKeyboardMoveInput.prototype.checkInputs = function () {
+                var camera = this.camera;
+                // Keyboard
+                for (var index = 0; index < this._keys.length; index++) {
+                    var keyCode = this._keys[index];
+                    var speed = camera._computeLocalCameraSpeed();
+                    if (this.keysLeft.indexOf(keyCode) !== -1) {
+                        camera._localDirection.copyFromFloats(-speed, 0, 0);
+                    }
+                    else if (this.keysUp.indexOf(keyCode) !== -1) {
+                        camera._localDirection.copyFromFloats(0, 0, speed);
+                    }
+                    else if (this.keysRight.indexOf(keyCode) !== -1) {
+                        camera._localDirection.copyFromFloats(speed, 0, 0);
+                    }
+                    else if (this.keysDown.indexOf(keyCode) !== -1) {
+                        camera._localDirection.copyFromFloats(0, 0, -speed);
+                    }
+                    camera.getViewMatrix().invertToRef(camera._cameraTransformMatrix);
+                    BABYLON.Vector3.TransformNormalToRef(camera._localDirection, camera._cameraTransformMatrix, camera._transformedDirection);
+                    camera.cameraDirection.addInPlace(camera._transformedDirection);
                 }
-                camera.getViewMatrix().invertToRef(camera._cameraTransformMatrix);
-                BABYLON.Vector3.TransformNormalToRef(camera._localDirection, camera._cameraTransformMatrix, camera._transformedDirection);
-                camera.cameraDirection.addInPlace(camera._transformedDirection);
-            }
-        };
-        FreeCameraKeyboardMoveInput.prototype.getTypeName = function () {
-            return "keyboardmove";
-        };
-        FreeCameraKeyboardMoveInput.prototype._onLostFocus = function (e) {
-            this._keys = [];
-        };
-        __decorate([
-            BABYLON.serialize()
-        ], FreeCameraKeyboardMoveInput.prototype, "keysUp", void 0);
-        __decorate([
-            BABYLON.serialize()
-        ], FreeCameraKeyboardMoveInput.prototype, "keysDown", void 0);
-        __decorate([
-            BABYLON.serialize()
-        ], FreeCameraKeyboardMoveInput.prototype, "keysLeft", void 0);
-        __decorate([
-            BABYLON.serialize()
-        ], FreeCameraKeyboardMoveInput.prototype, "keysRight", void 0);
-        return FreeCameraKeyboardMoveInput;
-    }());
-    BABYLON.FreeCameraKeyboardMoveInput = FreeCameraKeyboardMoveInput;
+            };
+            FreeCameraKeyboardMoveInput.prototype.getTypeName = function () {
+                return "freecamera.keyboardmove";
+            };
+            FreeCameraKeyboardMoveInput.prototype._onLostFocus = function (e) {
+                this._keys = [];
+            };
+            __decorate([
+                BABYLON.serialize()
+            ], FreeCameraKeyboardMoveInput.prototype, "keysUp", void 0);
+            __decorate([
+                BABYLON.serialize()
+            ], FreeCameraKeyboardMoveInput.prototype, "keysDown", void 0);
+            __decorate([
+                BABYLON.serialize()
+            ], FreeCameraKeyboardMoveInput.prototype, "keysLeft", void 0);
+            __decorate([
+                BABYLON.serialize()
+            ], FreeCameraKeyboardMoveInput.prototype, "keysRight", void 0);
+            return FreeCameraKeyboardMoveInput;
+        }());
+        CameraInputs.FreeCameraKeyboardMoveInput = FreeCameraKeyboardMoveInput;
+        CameraInputs.InputTypes["freecamera.keyboardmove"] = FreeCameraKeyboardMoveInput;
+    })(CameraInputs = BABYLON.CameraInputs || (BABYLON.CameraInputs = {}));
 })(BABYLON || (BABYLON = {}));

+ 4 - 2
src/Cameras/Inputs/babylon.freecamera.input.keyboard.ts

@@ -1,4 +1,4 @@
-module BABYLON {
+module BABYLON.CameraInputs {
     export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
         camera: FreeCamera;
         private _keys = [];
@@ -94,11 +94,13 @@ module BABYLON {
         }
 
         getTypeName(): string {
-            return "keyboardmove";
+            return "freecamera.keyboardmove";
         }
 
         public _onLostFocus(e: FocusEvent): void {
             this._keys = [];
         }
     }
+    
+    InputTypes["freecamera.keyboardmove"] = FreeCameraKeyboardMoveInput;
 }

+ 91 - 87
src/Cameras/Inputs/babylon.freecamera.input.mouse.js

@@ -6,93 +6,97 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
 };
 var BABYLON;
 (function (BABYLON) {
-    var FreeCameraMouseInput = (function () {
-        function FreeCameraMouseInput() {
-            this.angularSensibility = 2000.0;
-        }
-        FreeCameraMouseInput.prototype.attachCamera = function (camera) {
-            this.camera = camera;
-        };
-        FreeCameraMouseInput.prototype.attachElement = function (element, noPreventDefault) {
-            var _this = this;
-            var previousPosition;
-            this.attachedElement = element;
-            if (this._onMouseDown === undefined) {
-                var camera = this.camera;
-                var engine = this.camera.getEngine();
-                this._onMouseDown = function (evt) {
-                    previousPosition = {
-                        x: evt.clientX,
-                        y: evt.clientY
+    var CameraInputs;
+    (function (CameraInputs) {
+        var FreeCameraMouseInput = (function () {
+            function FreeCameraMouseInput() {
+                this.angularSensibility = 2000.0;
+            }
+            FreeCameraMouseInput.prototype.attachCamera = function (camera) {
+                this.camera = camera;
+            };
+            FreeCameraMouseInput.prototype.attachElement = function (element, noPreventDefault) {
+                var _this = this;
+                var previousPosition;
+                this.attachedElement = element;
+                if (this._onMouseDown === undefined) {
+                    var camera = this.camera;
+                    var engine = this.camera.getEngine();
+                    this._onMouseDown = function (evt) {
+                        previousPosition = {
+                            x: evt.clientX,
+                            y: evt.clientY
+                        };
+                        if (!noPreventDefault) {
+                            evt.preventDefault();
+                        }
                     };
-                    if (!noPreventDefault) {
-                        evt.preventDefault();
-                    }
-                };
-                this._onMouseUp = function (evt) {
-                    previousPosition = null;
-                    if (!noPreventDefault) {
-                        evt.preventDefault();
-                    }
-                };
-                this._onMouseOut = function (evt) {
-                    previousPosition = null;
-                    if (!noPreventDefault) {
-                        evt.preventDefault();
-                    }
-                };
-                this._onMouseMove = function (evt) {
-                    if (!previousPosition && !engine.isPointerLock) {
-                        return;
-                    }
-                    var offsetX;
-                    var offsetY;
-                    if (!engine.isPointerLock) {
-                        offsetX = evt.clientX - previousPosition.x;
-                        offsetY = evt.clientY - previousPosition.y;
-                    }
-                    else {
-                        offsetX = evt.movementX || evt.mozMovementX || evt.webkitMovementX || evt.msMovementX || 0;
-                        offsetY = evt.movementY || evt.mozMovementY || evt.webkitMovementY || evt.msMovementY || 0;
-                    }
-                    camera.cameraRotation.y += offsetX / _this.angularSensibility;
-                    camera.cameraRotation.x += offsetY / _this.angularSensibility;
-                    previousPosition = {
-                        x: evt.clientX,
-                        y: evt.clientY
+                    this._onMouseUp = function (evt) {
+                        previousPosition = null;
+                        if (!noPreventDefault) {
+                            evt.preventDefault();
+                        }
                     };
-                    if (!noPreventDefault) {
-                        evt.preventDefault();
-                    }
-                };
-            }
-            element.addEventListener("mousedown", this._onMouseDown, false);
-            element.addEventListener("mouseup", this._onMouseUp, false);
-            element.addEventListener("mouseout", this._onMouseOut, false);
-            element.addEventListener("mousemove", this._onMouseMove, false);
-        };
-        FreeCameraMouseInput.prototype.detachElement = function (element) {
-            if (this.attachedElement !== element) {
-                return;
-            }
-            element.removeEventListener("mousedown", this._onMouseDown);
-            element.removeEventListener("mouseup", this._onMouseUp);
-            element.removeEventListener("mouseout", this._onMouseOut);
-            element.removeEventListener("mousemove", this._onMouseMove);
-            this.attachedElement = null;
-        };
-        FreeCameraMouseInput.prototype.detach = function () {
-            if (this.attachedElement) {
-                this.detachElement(this.attachedElement);
-            }
-        };
-        FreeCameraMouseInput.prototype.getTypeName = function () {
-            return "mouse";
-        };
-        __decorate([
-            BABYLON.serialize()
-        ], FreeCameraMouseInput.prototype, "angularSensibility", void 0);
-        return FreeCameraMouseInput;
-    }());
-    BABYLON.FreeCameraMouseInput = FreeCameraMouseInput;
+                    this._onMouseOut = function (evt) {
+                        previousPosition = null;
+                        if (!noPreventDefault) {
+                            evt.preventDefault();
+                        }
+                    };
+                    this._onMouseMove = function (evt) {
+                        if (!previousPosition && !engine.isPointerLock) {
+                            return;
+                        }
+                        var offsetX;
+                        var offsetY;
+                        if (!engine.isPointerLock) {
+                            offsetX = evt.clientX - previousPosition.x;
+                            offsetY = evt.clientY - previousPosition.y;
+                        }
+                        else {
+                            offsetX = evt.movementX || evt.mozMovementX || evt.webkitMovementX || evt.msMovementX || 0;
+                            offsetY = evt.movementY || evt.mozMovementY || evt.webkitMovementY || evt.msMovementY || 0;
+                        }
+                        camera.cameraRotation.y += offsetX / _this.angularSensibility;
+                        camera.cameraRotation.x += offsetY / _this.angularSensibility;
+                        previousPosition = {
+                            x: evt.clientX,
+                            y: evt.clientY
+                        };
+                        if (!noPreventDefault) {
+                            evt.preventDefault();
+                        }
+                    };
+                }
+                element.addEventListener("mousedown", this._onMouseDown, false);
+                element.addEventListener("mouseup", this._onMouseUp, false);
+                element.addEventListener("mouseout", this._onMouseOut, false);
+                element.addEventListener("mousemove", this._onMouseMove, false);
+            };
+            FreeCameraMouseInput.prototype.detachElement = function (element) {
+                if (this.attachedElement !== element) {
+                    return;
+                }
+                element.removeEventListener("mousedown", this._onMouseDown);
+                element.removeEventListener("mouseup", this._onMouseUp);
+                element.removeEventListener("mouseout", this._onMouseOut);
+                element.removeEventListener("mousemove", this._onMouseMove);
+                this.attachedElement = null;
+            };
+            FreeCameraMouseInput.prototype.detach = function () {
+                if (this.attachedElement) {
+                    this.detachElement(this.attachedElement);
+                }
+            };
+            FreeCameraMouseInput.prototype.getTypeName = function () {
+                return "freecamera.mouse";
+            };
+            __decorate([
+                BABYLON.serialize()
+            ], FreeCameraMouseInput.prototype, "angularSensibility", void 0);
+            return FreeCameraMouseInput;
+        }());
+        CameraInputs.FreeCameraMouseInput = FreeCameraMouseInput;
+        CameraInputs.InputTypes["freecamera.mouse"] = FreeCameraMouseInput;
+    })(CameraInputs = BABYLON.CameraInputs || (BABYLON.CameraInputs = {}));
 })(BABYLON || (BABYLON = {}));

+ 4 - 2
src/Cameras/Inputs/babylon.freecamera.input.mouse.ts

@@ -1,4 +1,4 @@
-module BABYLON {       
+module BABYLON.CameraInputs {       
     export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
         camera : FreeCamera;
         attachedElement : HTMLElement;
@@ -105,7 +105,9 @@ module BABYLON {
         }
         
         getTypeName(): string{
-            return "mouse";
+            return "freecamera.mouse";
         }
     }
+    
+    InputTypes["freecamera.mouse"] = FreeCameraMouseInput;
 }

+ 124 - 120
src/Cameras/Inputs/babylon.freecamera.input.touch.js

@@ -6,130 +6,134 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
 };
 var BABYLON;
 (function (BABYLON) {
-    var FreeCameraTouchInput = (function () {
-        function FreeCameraTouchInput() {
-            this._offsetX = null;
-            this._offsetY = null;
-            this._pointerCount = 0;
-            this._pointerPressed = [];
-            this.touchAngularSensibility = 200000.0;
-            this.touchMoveSensibility = 250.0;
-        }
-        FreeCameraTouchInput.prototype.attachCamera = function (camera) {
-            this.camera = camera;
-        };
-        FreeCameraTouchInput.prototype.attachElement = function (element, noPreventDefault) {
-            var _this = this;
-            var previousPosition;
-            if (this._attachedElement) {
-                return;
+    var CameraInputs;
+    (function (CameraInputs) {
+        var FreeCameraTouchInput = (function () {
+            function FreeCameraTouchInput() {
+                this._offsetX = null;
+                this._offsetY = null;
+                this._pointerCount = 0;
+                this._pointerPressed = [];
+                this.touchAngularSensibility = 200000.0;
+                this.touchMoveSensibility = 250.0;
             }
-            this._attachedElement = element;
-            if (this._onPointerDown === undefined) {
-                this._onLostFocus = function (evt) {
-                    _this._offsetX = null;
-                    _this._offsetY = null;
-                };
-                this._onPointerDown = function (evt) {
-                    if (evt.pointerType === "mouse") {
-                        return;
-                    }
-                    if (!noPreventDefault) {
-                        evt.preventDefault();
-                    }
-                    _this._pointerPressed.push(evt.pointerId);
-                    if (_this._pointerPressed.length !== 1) {
-                        return;
-                    }
-                    previousPosition = {
-                        x: evt.clientX,
-                        y: evt.clientY
+            FreeCameraTouchInput.prototype.attachCamera = function (camera) {
+                this.camera = camera;
+            };
+            FreeCameraTouchInput.prototype.attachElement = function (element, noPreventDefault) {
+                var _this = this;
+                var previousPosition;
+                if (this._attachedElement) {
+                    return;
+                }
+                this._attachedElement = element;
+                if (this._onPointerDown === undefined) {
+                    this._onLostFocus = function (evt) {
+                        _this._offsetX = null;
+                        _this._offsetY = null;
                     };
-                };
-                this._onPointerUp = function (evt) {
-                    if (evt.pointerType === "mouse") {
-                        return;
-                    }
-                    if (!noPreventDefault) {
-                        evt.preventDefault();
-                    }
-                    var index = _this._pointerPressed.indexOf(evt.pointerId);
-                    if (index === -1) {
-                        return;
-                    }
-                    _this._pointerPressed.splice(index, 1);
-                    if (index != 0) {
-                        return;
-                    }
-                    previousPosition = null;
-                    _this._offsetX = null;
-                    _this._offsetY = null;
-                };
-                this._onPointerMove = function (evt) {
-                    if (evt.pointerType === "mouse") {
-                        return;
-                    }
-                    if (!noPreventDefault) {
-                        evt.preventDefault();
-                    }
-                    if (!previousPosition) {
-                        return;
+                    this._onPointerDown = function (evt) {
+                        if (evt.pointerType === "mouse") {
+                            return;
+                        }
+                        if (!noPreventDefault) {
+                            evt.preventDefault();
+                        }
+                        _this._pointerPressed.push(evt.pointerId);
+                        if (_this._pointerPressed.length !== 1) {
+                            return;
+                        }
+                        previousPosition = {
+                            x: evt.clientX,
+                            y: evt.clientY
+                        };
+                    };
+                    this._onPointerUp = function (evt) {
+                        if (evt.pointerType === "mouse") {
+                            return;
+                        }
+                        if (!noPreventDefault) {
+                            evt.preventDefault();
+                        }
+                        var index = _this._pointerPressed.indexOf(evt.pointerId);
+                        if (index === -1) {
+                            return;
+                        }
+                        _this._pointerPressed.splice(index, 1);
+                        if (index != 0) {
+                            return;
+                        }
+                        previousPosition = null;
+                        _this._offsetX = null;
+                        _this._offsetY = null;
+                    };
+                    this._onPointerMove = function (evt) {
+                        if (evt.pointerType === "mouse") {
+                            return;
+                        }
+                        if (!noPreventDefault) {
+                            evt.preventDefault();
+                        }
+                        if (!previousPosition) {
+                            return;
+                        }
+                        var index = _this._pointerPressed.indexOf(evt.pointerId);
+                        if (index != 0) {
+                            return;
+                        }
+                        _this._offsetX = evt.clientX - previousPosition.x;
+                        _this._offsetY = -(evt.clientY - previousPosition.y);
+                    };
+                }
+                element.addEventListener("blur", this._onLostFocus);
+                element.addEventListener("pointerdown", this._onPointerDown);
+                element.addEventListener("pointerup", this._onPointerUp);
+                element.addEventListener("pointerout", this._onPointerUp);
+                element.addEventListener("pointermove", this._onPointerMove);
+            };
+            FreeCameraTouchInput.prototype.detachElement = function (element) {
+                if (this._attachedElement !== element) {
+                    return;
+                }
+                element.removeEventListener("blur", this._onLostFocus);
+                element.removeEventListener("pointerdown", this._onPointerDown);
+                element.removeEventListener("pointerup", this._onPointerUp);
+                element.removeEventListener("pointerout", this._onPointerUp);
+                element.removeEventListener("pointermove", this._onPointerMove);
+                this._attachedElement = null;
+            };
+            FreeCameraTouchInput.prototype.checkInputs = function () {
+                if (this._offsetX) {
+                    var camera = this.camera;
+                    camera.cameraRotation.y += this._offsetX / this.touchAngularSensibility;
+                    if (this._pointerPressed.length > 1) {
+                        camera.cameraRotation.x += -this._offsetY / this.touchAngularSensibility;
                     }
-                    var index = _this._pointerPressed.indexOf(evt.pointerId);
-                    if (index != 0) {
-                        return;
+                    else {
+                        var speed = camera._computeLocalCameraSpeed();
+                        var direction = new BABYLON.Vector3(0, 0, speed * this._offsetY / this.touchMoveSensibility);
+                        BABYLON.Matrix.RotationYawPitchRollToRef(camera.rotation.y, camera.rotation.x, 0, camera._cameraRotationMatrix);
+                        camera.cameraDirection.addInPlace(BABYLON.Vector3.TransformCoordinates(direction, camera._cameraRotationMatrix));
                     }
-                    _this._offsetX = evt.clientX - previousPosition.x;
-                    _this._offsetY = -(evt.clientY - previousPosition.y);
-                };
-            }
-            element.addEventListener("blur", this._onLostFocus);
-            element.addEventListener("pointerdown", this._onPointerDown);
-            element.addEventListener("pointerup", this._onPointerUp);
-            element.addEventListener("pointerout", this._onPointerUp);
-            element.addEventListener("pointermove", this._onPointerMove);
-        };
-        FreeCameraTouchInput.prototype.detachElement = function (element) {
-            if (this._attachedElement !== element) {
-                return;
-            }
-            element.removeEventListener("blur", this._onLostFocus);
-            element.removeEventListener("pointerdown", this._onPointerDown);
-            element.removeEventListener("pointerup", this._onPointerUp);
-            element.removeEventListener("pointerout", this._onPointerUp);
-            element.removeEventListener("pointermove", this._onPointerMove);
-            this._attachedElement = null;
-        };
-        FreeCameraTouchInput.prototype.checkInputs = function () {
-            if (this._offsetX) {
-                var camera = this.camera;
-                camera.cameraRotation.y += this._offsetX / this.touchAngularSensibility;
-                if (this._pointerPressed.length > 1) {
-                    camera.cameraRotation.x += -this._offsetY / this.touchAngularSensibility;
                 }
-                else {
-                    var speed = camera._computeLocalCameraSpeed();
-                    var direction = new BABYLON.Vector3(0, 0, speed * this._offsetY / this.touchMoveSensibility);
-                    BABYLON.Matrix.RotationYawPitchRollToRef(camera.rotation.y, camera.rotation.x, 0, camera._cameraRotationMatrix);
-                    camera.cameraDirection.addInPlace(BABYLON.Vector3.TransformCoordinates(direction, camera._cameraRotationMatrix));
+            };
+            FreeCameraTouchInput.prototype.detach = function () {
+                if (this._attachedElement) {
+                    this.detachElement(this._attachedElement);
                 }
-            }
-        };
-        FreeCameraTouchInput.prototype.detach = function () {
-            if (this._attachedElement) {
-                this.detachElement(this._attachedElement);
-            }
-        };
-        FreeCameraTouchInput.prototype.getTypeName = function () {
-            return "touch";
-        };
-        __decorate([
-            BABYLON.serialize()
-        ], FreeCameraTouchInput.prototype, "touchAngularSensibility", void 0);
-        __decorate([
-            BABYLON.serialize()
-        ], FreeCameraTouchInput.prototype, "touchMoveSensibility", void 0);
-        return FreeCameraTouchInput;
-    }());
-    BABYLON.FreeCameraTouchInput = FreeCameraTouchInput;
+            };
+            FreeCameraTouchInput.prototype.getTypeName = function () {
+                return "freecamera.touch";
+            };
+            __decorate([
+                BABYLON.serialize()
+            ], FreeCameraTouchInput.prototype, "touchAngularSensibility", void 0);
+            __decorate([
+                BABYLON.serialize()
+            ], FreeCameraTouchInput.prototype, "touchMoveSensibility", void 0);
+            return FreeCameraTouchInput;
+        }());
+        CameraInputs.FreeCameraTouchInput = FreeCameraTouchInput;
+        CameraInputs.InputTypes["freecamera.touch"] = FreeCameraTouchInput;
+    })(CameraInputs = BABYLON.CameraInputs || (BABYLON.CameraInputs = {}));
 })(BABYLON || (BABYLON = {}));

+ 4 - 2
src/Cameras/Inputs/babylon.freecamera.input.touch.ts

@@ -1,4 +1,4 @@
-module BABYLON {
+module BABYLON.CameraInputs {
     export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
         camera: FreeCamera;
 
@@ -154,7 +154,9 @@ module BABYLON {
         }
 
         getTypeName(): string {
-            return "touch";
+            return "freecamera.touch";
         }
     }
+    
+    InputTypes["freecamera.touch"] = FreeCameraTouchInput;
 }

+ 48 - 44
src/Cameras/Inputs/babylon.freecamera.input.virtualjoystick.js

@@ -1,48 +1,52 @@
 var BABYLON;
 (function (BABYLON) {
-    var FreeCameraVirtualJoystickInput = (function () {
-        function FreeCameraVirtualJoystickInput() {
-        }
-        FreeCameraVirtualJoystickInput.prototype.getLeftJoystick = function () {
-            return this._leftjoystick;
-        };
-        FreeCameraVirtualJoystickInput.prototype.getRightJoystick = function () {
-            return this._rightjoystick;
-        };
-        FreeCameraVirtualJoystickInput.prototype.checkInputs = function () {
-            var camera = this.camera;
-            var speed = camera._computeLocalCameraSpeed() * 50;
-            var cameraTransform = BABYLON.Matrix.RotationYawPitchRoll(camera.rotation.y, camera.rotation.x, 0);
-            var deltaTransform = BABYLON.Vector3.TransformCoordinates(new BABYLON.Vector3(this._leftjoystick.deltaPosition.x * speed, this._leftjoystick.deltaPosition.y * speed, this._leftjoystick.deltaPosition.z * speed), cameraTransform);
-            camera.cameraDirection = camera.cameraDirection.add(deltaTransform);
-            camera.cameraRotation = camera.cameraRotation.addVector3(this._rightjoystick.deltaPosition);
-            if (!this._leftjoystick.pressed) {
-                this._leftjoystick.deltaPosition = this._leftjoystick.deltaPosition.scale(0.9);
+    var CameraInputs;
+    (function (CameraInputs) {
+        var FreeCameraVirtualJoystickInput = (function () {
+            function FreeCameraVirtualJoystickInput() {
             }
-            if (!this._rightjoystick.pressed) {
-                this._rightjoystick.deltaPosition = this._rightjoystick.deltaPosition.scale(0.9);
-            }
-        };
-        FreeCameraVirtualJoystickInput.prototype.attachCamera = function (camera) {
-            this.camera = camera;
-            this._leftjoystick = new BABYLON.VirtualJoystick(true);
-            this._leftjoystick.setAxisForUpDown(BABYLON.JoystickAxis.Z);
-            this._leftjoystick.setAxisForLeftRight(BABYLON.JoystickAxis.X);
-            this._leftjoystick.setJoystickSensibility(0.15);
-            this._rightjoystick = new BABYLON.VirtualJoystick(false);
-            this._rightjoystick.setAxisForUpDown(BABYLON.JoystickAxis.X);
-            this._rightjoystick.setAxisForLeftRight(BABYLON.JoystickAxis.Y);
-            this._rightjoystick.reverseUpDown = true;
-            this._rightjoystick.setJoystickSensibility(0.05);
-            this._rightjoystick.setJoystickColor("yellow");
-        };
-        FreeCameraVirtualJoystickInput.prototype.detach = function () {
-            this._leftjoystick.releaseCanvas();
-        };
-        FreeCameraVirtualJoystickInput.prototype.getTypeName = function () {
-            return "touch";
-        };
-        return FreeCameraVirtualJoystickInput;
-    }());
-    BABYLON.FreeCameraVirtualJoystickInput = FreeCameraVirtualJoystickInput;
+            FreeCameraVirtualJoystickInput.prototype.getLeftJoystick = function () {
+                return this._leftjoystick;
+            };
+            FreeCameraVirtualJoystickInput.prototype.getRightJoystick = function () {
+                return this._rightjoystick;
+            };
+            FreeCameraVirtualJoystickInput.prototype.checkInputs = function () {
+                var camera = this.camera;
+                var speed = camera._computeLocalCameraSpeed() * 50;
+                var cameraTransform = BABYLON.Matrix.RotationYawPitchRoll(camera.rotation.y, camera.rotation.x, 0);
+                var deltaTransform = BABYLON.Vector3.TransformCoordinates(new BABYLON.Vector3(this._leftjoystick.deltaPosition.x * speed, this._leftjoystick.deltaPosition.y * speed, this._leftjoystick.deltaPosition.z * speed), cameraTransform);
+                camera.cameraDirection = camera.cameraDirection.add(deltaTransform);
+                camera.cameraRotation = camera.cameraRotation.addVector3(this._rightjoystick.deltaPosition);
+                if (!this._leftjoystick.pressed) {
+                    this._leftjoystick.deltaPosition = this._leftjoystick.deltaPosition.scale(0.9);
+                }
+                if (!this._rightjoystick.pressed) {
+                    this._rightjoystick.deltaPosition = this._rightjoystick.deltaPosition.scale(0.9);
+                }
+            };
+            FreeCameraVirtualJoystickInput.prototype.attachCamera = function (camera) {
+                this.camera = camera;
+                this._leftjoystick = new BABYLON.VirtualJoystick(true);
+                this._leftjoystick.setAxisForUpDown(BABYLON.JoystickAxis.Z);
+                this._leftjoystick.setAxisForLeftRight(BABYLON.JoystickAxis.X);
+                this._leftjoystick.setJoystickSensibility(0.15);
+                this._rightjoystick = new BABYLON.VirtualJoystick(false);
+                this._rightjoystick.setAxisForUpDown(BABYLON.JoystickAxis.X);
+                this._rightjoystick.setAxisForLeftRight(BABYLON.JoystickAxis.Y);
+                this._rightjoystick.reverseUpDown = true;
+                this._rightjoystick.setJoystickSensibility(0.05);
+                this._rightjoystick.setJoystickColor("yellow");
+            };
+            FreeCameraVirtualJoystickInput.prototype.detach = function () {
+                this._leftjoystick.releaseCanvas();
+            };
+            FreeCameraVirtualJoystickInput.prototype.getTypeName = function () {
+                return "freecamera.virtualjoystick";
+            };
+            return FreeCameraVirtualJoystickInput;
+        }());
+        CameraInputs.FreeCameraVirtualJoystickInput = FreeCameraVirtualJoystickInput;
+        CameraInputs.InputTypes["freecamera.virtualjoystick"] = FreeCameraVirtualJoystickInput;
+    })(CameraInputs = BABYLON.CameraInputs || (BABYLON.CameraInputs = {}));
 })(BABYLON || (BABYLON = {}));

+ 3 - 2
src/Cameras/Inputs/babylon.freecamera.input.virtualjoystick.ts

@@ -1,4 +1,4 @@
-module BABYLON {
+module BABYLON.CameraInputs {
     export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
         camera: FreeCamera;
 
@@ -49,7 +49,8 @@ module BABYLON {
         }
 
         getTypeName(): string {
-            return "touch";
+            return "freecamera.virtualjoystick";
         }
     }
+    InputTypes["freecamera.virtualjoystick"] = FreeCameraVirtualJoystickInput;
 }

+ 7 - 0
src/Cameras/babylon.camera.js

@@ -460,6 +460,9 @@ var BABYLON;
             if (this.parent) {
                 serializationObject.parentId = this.parent.id;
             }
+            if (this.inputs) {
+                serializationObject.inputs = this.inputs.serialize();
+            }
             // Animations
             BABYLON.Animation.AppendSerializedAnimations(this, serializationObject);
             serializationObject.ranges = this.serializeAnimationRanges();
@@ -523,6 +526,10 @@ var BABYLON;
             if (parsedCamera.parentId) {
                 camera._waitingParentId = parsedCamera.parentId;
             }
+            //Input manager
+            if (parsedCamera.inputs) {
+                camera.inputs.parse(parsedCamera.inputs);
+            }
             // Target
             if (parsedCamera.target) {
                 if (camera.setTarget) {

+ 11 - 0
src/Cameras/babylon.camera.ts

@@ -1,5 +1,7 @@
 module BABYLON {
     export class Camera extends Node {
+        public inputs : CameraInputsManager<Camera>;
+        
         // Statics
         private static _PERSPECTIVE_CAMERA = 0;
         private static _ORTHOGRAPHIC_CAMERA = 1;
@@ -567,6 +569,10 @@
             if (this.parent) {
                 serializationObject.parentId = this.parent.id;
             }
+            
+            if (this.inputs){
+                serializationObject.inputs = this.inputs.serialize();
+            }
             // Animations
             Animation.AppendSerializedAnimations(this, serializationObject);
             serializationObject.ranges = this.serializeAnimationRanges();
@@ -635,6 +641,11 @@
             if (parsedCamera.parentId) {
                 camera._waitingParentId = parsedCamera.parentId;
             }
+            
+            //Input manager
+            if (parsedCamera.inputs){
+                camera.inputs.parse(parsedCamera.inputs);
+            }
 
             // Target
             if (parsedCamera.target) {

+ 26 - 0
src/Cameras/babylon.cameraInputsManager.js

@@ -1,5 +1,9 @@
 var BABYLON;
 (function (BABYLON) {
+    var CameraInputs;
+    (function (CameraInputs) {
+        CameraInputs.InputTypes = {};
+    })(CameraInputs = BABYLON.CameraInputs || (BABYLON.CameraInputs = {}));
     var CameraInputsManager = (function () {
         function CameraInputsManager(camera) {
             this.inputs = {};
@@ -57,6 +61,28 @@ var BABYLON;
             this.inputs = {};
             this.checkInputs = function () { };
         };
+        CameraInputsManager.prototype.serialize = function () {
+            var inputs = {};
+            for (var cam in this.inputs) {
+                var input = this.inputs[cam];
+                var res = BABYLON.SerializationHelper.Serialize(input);
+                inputs[input.getTypeName()] = res;
+            }
+            return inputs;
+        };
+        CameraInputsManager.prototype.parse = function (parsedInputs) {
+            if (parsedInputs) {
+                this.clear();
+                for (var n in parsedInputs) {
+                    var construct = CameraInputs.InputTypes[n];
+                    if (construct) {
+                        var parsedinput = parsedInputs[n];
+                        var input = BABYLON.SerializationHelper.Parse(function () { return new construct(); }, parsedinput, null);
+                        this.add(input);
+                    }
+                }
+            }
+        };
         return CameraInputsManager;
     }());
     BABYLON.CameraInputsManager = CameraInputsManager;

+ 33 - 0
src/Cameras/babylon.cameraInputsManager.ts

@@ -1,4 +1,8 @@
 module BABYLON {
+    export module CameraInputs{
+        export var InputTypes = {};
+    }
+    
     export interface ICameraInput<TCamera extends BABYLON.Camera> {
         camera: TCamera;
         attachCamera(camera: TCamera);
@@ -88,5 +92,34 @@ module BABYLON {
             this.inputs = {};
             this.checkInputs = () => { };
         }
+        
+        public serialize(){
+            var inputs = {};
+            for (var cam in this.inputs) {
+                var input = this.inputs[cam];
+                var res = SerializationHelper.Serialize(input);
+                inputs[input.getTypeName()] = res;
+            }
+            
+            return inputs;
+        }
+        
+        public parse(parsedInputs){
+            if (parsedInputs){
+                this.clear();
+                
+                for (var n in parsedInputs) {
+                    var construct = CameraInputs.InputTypes[n];
+                    if (construct){
+                        var parsedinput = parsedInputs[n];
+                        var input = SerializationHelper.Parse(() => { return new construct() }, parsedinput, null);
+                        this.add(input as any);
+                    }
+                }
+            }
+        }
+        
     }
+    
+    
 } 

+ 5 - 5
src/Cameras/babylon.freeCamera.js

@@ -132,23 +132,23 @@ var BABYLON;
             }
         };
         FreeCameraInputsManager.prototype.addKeyboard = function () {
-            this.add(new BABYLON.FreeCameraKeyboardMoveInput());
+            this.add(new BABYLON.CameraInputs.FreeCameraKeyboardMoveInput());
             return this;
         };
         FreeCameraInputsManager.prototype.addMouse = function () {
-            this.add(new BABYLON.FreeCameraMouseInput());
+            this.add(new BABYLON.CameraInputs.FreeCameraMouseInput());
             return this;
         };
         FreeCameraInputsManager.prototype.addGamepad = function () {
-            this.add(new BABYLON.FreeCameraGamepadInput());
+            this.add(new BABYLON.CameraInputs.FreeCameraGamepadInput());
             return this;
         };
         FreeCameraInputsManager.prototype.addDeviceOrientation = function () {
-            this.add(new BABYLON.FreeCameraDeviceOrientationInput());
+            this.add(new BABYLON.CameraInputs.FreeCameraDeviceOrientationInput());
             return this;
         };
         FreeCameraInputsManager.prototype.addTouch = function () {
-            this.add(new BABYLON.FreeCameraTouchInput());
+            this.add(new BABYLON.CameraInputs.FreeCameraTouchInput());
             return this;
         };
         return FreeCameraInputsManager;

+ 6 - 6
src/Cameras/babylon.freeCamera.ts

@@ -1,5 +1,5 @@
 module BABYLON {
-    export class FreeCamera extends TargetCamera {
+    export class FreeCamera extends TargetCamera {        
         @serializeAsVector3()
         public ellipsoid = new Vector3(0.5, 1, 0.5);
 
@@ -146,27 +146,27 @@
         }
         
         addKeyboard(){
-            this.add(new FreeCameraKeyboardMoveInput());
+            this.add(new CameraInputs.FreeCameraKeyboardMoveInput());
             return this;
         }
         
         addMouse(){
-            this.add(new FreeCameraMouseInput());
+            this.add(new CameraInputs.FreeCameraMouseInput());
             return this;
         }
         
         addGamepad(){
-            this.add(new FreeCameraGamepadInput());
+            this.add(new CameraInputs.FreeCameraGamepadInput());
             return this;
         }
         
         addDeviceOrientation(){
-            this.add(new FreeCameraDeviceOrientationInput());
+            this.add(new CameraInputs.FreeCameraDeviceOrientationInput());
             return this;
         }
         
         addTouch(){
-            this.add(new FreeCameraTouchInput());
+            this.add(new CameraInputs.FreeCameraTouchInput());
             return this;
         }
     }