瀏覽代碼

BABYLON.OculusOrientedCamera was replaced by BABYLON.OculusCamera for better integration into camera system

David Catuhe 11 年之前
父節點
當前提交
b6a2789961

+ 0 - 24
Babylon/Cameras/Controllers/babylon.globalAxisFactorsFilter.js

@@ -1,24 +0,0 @@
-"use strict";
-
-var BABYLON = BABYLON || {};
-
-(function () {
-	BABYLON.GlobalAxisFactorsFilter = function (scene, target, xFactor, yFactor, zFactor) {
-		BABYLON.inputFilter.call(this, scene,target);
-		this.xFactor = xFactor;
-		this.yFactor = yFactor;
-		this.zFactor = zFactor;
-
-		this._globalMovement = new BABYLON.Vector3(0, 0, 0);
-	};
-	BABYLON.GlobalAxisFactorsFilter.prototype = Object.create(BABYLON.inputFilter.prototype);
-	BABYLON.GlobalAxisFactorsFilter.prototype.moveRelative = function (relativeMovement) {
-		var orientation = this.getOrientation();
-		BABYLON.Vector3.TransformNormalToRef(relativeMovement, this.getOrientationMatrix(), this._globalMovement);
-		this._globalMovement.x *= this.xFactor;
-		this._globalMovement.y *= this.yFactor;
-		this._globalMovement.z *= this.zFactor;
-		BABYLON.Vector3.TransformNormalToRef(this._globalMovement, this.getInvertOrientationMatrix(), relativeMovement);
-		this.target.moveRelative(relativeMovement);
-	};
-})();

+ 0 - 20
Babylon/Cameras/Controllers/babylon.gravityInputController.js

@@ -1,20 +0,0 @@
-"use strict";
-
-var BABYLON = BABYLON || {};
-
-(function () {
-    BABYLON.GravityInputController = function (scene, target) {
-        BABYLON.InputController.call(this, scene, target);
-        this._moveVectorGlobal = new BABYLON.Vector3(0, 0, 0);
-        this._moveVectorLocal = new BABYLON.Vector3(0, 0, 0);
-        this._fallSpeed = 2;
-    };
-    BABYLON.GravityInputController.prototype = Object.create(BABYLON.InputController.prototype);
-    BABYLON.GravityInputController.prototype.update = function () {
-        this._moveVectorGlobal.x = 0;
-        this._moveVectorGlobal.y = -this._fallSpeed * BABYLON.Tools.GetDeltaTime() / 1000.0;
-        this._moveVectorGlobal.z = 0;
-        BABYLON.Vector3.TransformNormalToRef(this._moveVectorGlobal, this.target.getInvertOrientationMatrix(), this._moveVectorLocal);
-        this.target.moveRelative(this._moveVectorLocal);
-    };
-})();

+ 0 - 41
Babylon/Cameras/Controllers/babylon.inputCollisionFilter.js

@@ -1,41 +0,0 @@
-"use strict";
-
-var BABYLON = BABYLON || {};
-
-(function () {
-	BABYLON.InputCollisionFilter = function (scene, target, ellipsoid) {
-		BABYLON.inputFilter.call(this, scene, target);
-		this._transformedDirection = new BABYLON.Vector3();
-		this._tempNewPosition = new BABYLON.Vector3();
-		this._tempNewPosition2 = new BABYLON.Vector3();
-		this._ellipsoid = ellipsoid || new BABYLON.Vector3(.2,.855,.2);
-		this._collider = new BABYLON.Collider();
-		this._collidedPosition = new BABYLON.Vector3(0, 0, 0);
-		this._cameraHeight = 1.7;
-		this._positionBottom = new BABYLON.Vector3(0, 0, 0);
-	};
-	BABYLON.InputCollisionFilter.prototype = Object.create(BABYLON.inputFilter.prototype);
-	BABYLON.InputCollisionFilter.prototype.moveRelative = function (relativeMovement) {
-		var rotation = this.getOrientation();
-		BABYLON.Vector3.TransformNormalToRef(relativeMovement, this.getOrientationMatrix(), this._transformedDirection);
-		this.getPosition().addToRef(this._transformedDirection, this._tempNewPosition);
-		//this._tempNewPosition.y -= this._ellipsoid.y;
-		this._collider.radius = this._ellipsoid;
-		var p = this.getPosition();
-		this._positionBottom.x = p.x;
-		this._positionBottom.y = p.y;
-		this._positionBottom.z = p.z;
-		this._positionBottom.y +=  this._ellipsoid.y - this._cameraHeight;
-
-		this.scene._getNewPosition(this._positionBottom, this._transformedDirection, this._collider, 3, this._collidedPosition);
-
-
-		this._collidedPosition.subtractToRef(this._positionBottom, this._tempNewPosition2);
-		if (this._tempNewPosition2.length() > BABYLON.Engine.collisionsEpsilon * 2) {
-
-		    BABYLON.Vector3.TransformNormalToRef(this._tempNewPosition2, this.getInvertOrientationMatrix(), this._tempNewPosition);
-		    this.target.moveRelative(this._tempNewPosition);
-		} 
-
-	};
-})();

+ 0 - 119
Babylon/Cameras/Controllers/babylon.inputController.js

@@ -1,119 +0,0 @@
-"use strict";
-
-var BABYLON = BABYLON || {};
-
-(function () {
-
-	BABYLON.InputControllerTarget = function () {
-		this._position = new BABYLON.Vector3(0, 0, 0);
-		this._orientation = { yaw: 0.0, pitch: 0.0, roll: 0.0 };
-	};
-
-	BABYLON.InputControllerTarget.prototype.getPosition = function () {
-		return this._position;
-	};
-	BABYLON.InputControllerTarget.prototype.getOrientation = function () {
-		return this._orientation;
-	};
-	BABYLON.InputControllerTarget.prototype.moveRelative = function (movementVector) {
-
-	};
-	
-	BABYLON.InputControllerTarget.prototype.rotateRelative = function (relativeOrientation) {
-
-	};
-	BABYLON.InputControllerTarget.prototype.getOrientationMatrix = function () { return new BABYLON.Matrix(); };
-	BABYLON.InputControllerTarget.prototype.getInvertOrientationMatrix = function () { return new BABYLON.Matrix(); };
-
-	BABYLON.InputControllerMultiTarget = function (targets) {
-	    this.targets = targets;
-	    var mainTarget = this.targets[0];
-	    if (!mainTarget.controllers) {
-	        mainTarget.controllers = [this];
-	    } else {
-	        mainTarget.controllers.push(this);
-	    }
-	};
-
-	BABYLON.InputControllerMultiTarget.prototype.getPosition = function () {
-		return this.targets[0].getPosition();
-	};
-	BABYLON.InputControllerMultiTarget.prototype.getOrientation = function () {
-		return this.targets[0].getOrientation();
-	};
-
-
-	BABYLON.InputControllerMultiTarget.prototype.getOrientationMatrix = function () { return this.targets[0].getOrientationMatrix(); };
-	BABYLON.InputControllerMultiTarget.prototype.getInvertOrientationMatrix = function () { return this.targets[0].getInvertOrientationMatrix(); };
-
-	BABYLON.InputControllerMultiTarget.prototype.moveRelative = function (movementVector) {
-		for (var i = 0; i < this.targets.length; ++i) {
-			this.targets[i].moveRelative(movementVector);
-		}
-	};
-
-	BABYLON.InputControllerMultiTarget.prototype.rotateRelative = function (relativeOrientation) {
-		for (var i = 0; i < this.targets.length; ++i) {
-			this.targets[i].rotateRelative(relativeOrientation);
-		}
-	};
-
-	BABYLON.InputControllerMultiTarget.prototype.update = function () {
-		if (this.controllers) {
-			for (var i = 0; i < this.controllers.length; ++i) {
-				this.controllers[i].update();
-			}
-		}
-	};
-	
-	BABYLON.InputController = function (scene, target) {
-		this.scene = scene;
-		this.target = target;
-		if (!this.target.controllers) {
-			this.target.controllers = [this];
-		} else {
-			this.target.controllers.push(this);
-		}
-	};
-	BABYLON.InputController.prototype.attachToCanvas = function (canvas) {
-
-	};
-	BABYLON.InputController.prototype.detachFromCanvas = function (canvas) {
-
-	};
-	BABYLON.InputController.prototype.update = function () {
-
-	};
-
-	BABYLON.InputController.prototype.dispose = function () {
-
-	};
-
-	BABYLON.inputFilter = function (scene, target) {
-	    BABYLON.InputController.call(this, scene, target);
-	};
-	BABYLON.inputFilter.prototype = Object.create(BABYLON.InputController.prototype);
-	BABYLON.inputFilter.prototype.update = function () {
-	    if (this.controllers) {
-	        for (var i = 0; i < this.controllers.length; ++i) {
-	            this.controllers[i].update();
-	        }
-	    }
-	};
-
-	BABYLON.inputFilter.prototype.getPosition = function () {
-	    return this.target.getPosition();
-	};
-	BABYLON.inputFilter.prototype.getOrientation = function () {
-	    return this.target.getOrientation();
-	};
-	BABYLON.inputFilter.prototype.getOrientationMatrix = function () { return this.target.getOrientationMatrix(); };
-	BABYLON.inputFilter.prototype.getInvertOrientationMatrix = function () { return this.target.getInvertOrientationMatrix(); };
-	BABYLON.inputFilter.prototype.moveRelative = function (movementVector) {
-	    this.target.moveRelative(movementVector);
-	};
-
-	BABYLON.inputFilter.prototype.rotateRelative = function (relativeOrientation) {
-	    this.target.rotateRelative(relativeOrientation);
-	};
-})();

+ 0 - 133
Babylon/Cameras/Controllers/babylon.keyboardMoveController.js

@@ -1,133 +0,0 @@
-"use strict";
-
-var BABYLON = BABYLON || {};
-
-(function () {
-	BABYLON.KeyboardMoveController = function (scene, target) {
-		BABYLON.InputController.call(this, scene, target);
-		this._keys = [];
-		this.keysUp = [38];
-		this.keysDown = [40];
-		this.keysLeft = [37];
-		this.keysRight = [39];
-		this._currentSpeed = new BABYLON.Vector3(0, 0, 0);
-		this._lastFrameSpeed = new BABYLON.Vector3(0, 0, 0);
-		this._currentAcceleration = new BABYLON.Vector3(0, 0, 0);
-		this._tempSpeed = new BABYLON.Vector3(0, 0, 0);
-		this._tempSpeed2 = new BABYLON.Vector3(0, 0, 0);
-		this.maxAbsoluteSpeed = 2; // 2 meters per second
-		this.maxAbsoluteAcceleration = 5; // 2 meters per second²
-		this._targetSpeed = new BABYLON.Vector3(0, 0, 0);
-	};
-	BABYLON.KeyboardMoveController.prototype = Object.create(BABYLON.InputController.prototype);
-	BABYLON.KeyboardMoveController.prototype.attachToCanvas = function (canvas) {
-		var that = this;
-		this._canvas = canvas;
-
-		this._onKeyDown = function (evt) {
-			if (that.keysUp.indexOf(evt.keyCode) !== -1 ||
-				that.keysDown.indexOf(evt.keyCode) !== -1 ||
-				that.keysLeft.indexOf(evt.keyCode) !== -1 ||
-				that.keysRight.indexOf(evt.keyCode) !== -1) {
-				var index = that._keys.indexOf(evt.keyCode);
-
-				if (index === -1) {
-					that._keys.push(evt.keyCode);
-				}
-			}
-		};
-
-		this._onKeyUp = function (evt) {
-			if (that.keysUp.indexOf(evt.keyCode) !== -1 ||
-				that.keysDown.indexOf(evt.keyCode) !== -1 ||
-				that.keysLeft.indexOf(evt.keyCode) !== -1 ||
-				that.keysRight.indexOf(evt.keyCode) !== -1) {
-				var index = that._keys.indexOf(evt.keyCode);
-
-				if (index >= 0) {
-					that._keys.splice(index, 1);
-				}
-			}
-		};
-
-		this._onLostFocus = function () {
-			that._keys = [];
-		};
-
-		window.addEventListener("keydown", this._onKeyDown, false);
-		window.addEventListener("keyup", this._onKeyUp, false);
-		window.addEventListener("blur", this._onLostFocus, false);
-	};
-	BABYLON.KeyboardMoveController.prototype.detachFromCanvas = function (canvas) {
-		window.removeEventListener("keydown", this._onKeyDown, false);
-		window.removeEventListener("keyup", this._onKeyUp, false);
-		window.removeEventListener("blur", this._onLostFocus, false);
-	};
-	BABYLON.KeyboardMoveController.prototype.updateCurrentSpeed = function () {
-		this._lastFrameSpeed.x = this._currentSpeed.x;
-		this._lastFrameSpeed.y = this._currentSpeed.y;
-		this._lastFrameSpeed.z = this._currentSpeed.z;
-		if (this._currentSpeed.equals(this._targetSpeed)) {
-			this._currentAcceleration.x = 0;
-			this._currentAcceleration.y = 0;
-			this._currentAcceleration.z = 0;
-			return;
-		}
-		var dt = BABYLON.Tools.GetDeltaTime()/1000.0;
-		
-		var dv = this._tempSpeed;
-		this._targetSpeed.subtractToRef(this._lastFrameSpeed, dv);
-		var absoluteAccToTarget = dv.length() / dt;
-		if (absoluteAccToTarget < this.maxAbsoluteAcceleration) {
-			this._currentSpeed.x = this._targetSpeed.x;
-			this._currentSpeed.y = this._targetSpeed.y;
-			this._currentSpeed.z = this._targetSpeed.z;
-			dv.normalize();
-			dv.scaleToRef(absoluteAccToTarget, this._currentAcceleration);
-		} else {
-			dv.normalize();
-			dv.scaleToRef(this.maxAbsoluteAcceleration, this._currentAcceleration);
-			dv.scaleInPlace(this.maxAbsoluteAcceleration * dt);
-		
-			this._currentSpeed.addInPlace(dv);
-		}
-	};
-	BABYLON.KeyboardMoveController.prototype.update = function () {
-		this._targetSpeed.x = 0;
-		this._targetSpeed.y = 0;
-		this._targetSpeed.z = 0;
-		// update target speed from input
-		for (var index = 0; index < this._keys.length; index++) {
-			var keyCode = this._keys[index];
-			if (this.keysLeft.indexOf(keyCode) !== -1) {
-				this._targetSpeed.x -= 1;
-			} else if (this.keysUp.indexOf(keyCode) !== -1) {
-				this._targetSpeed.z += 1;
-			} else if (this.keysRight.indexOf(keyCode) !== -1) {
-				this._targetSpeed.x += 1;
-			} else if (this.keysDown.indexOf(keyCode) !== -1) {
-				this._targetSpeed.z -= 1;
-			}
-		}
-		if (this._targetSpeed.x != 0 || this._targetSpeed.z != 0) {
-			this._targetSpeed.normalize();
-			this._targetSpeed.scaleInPlace(this.maxAbsoluteSpeed);
-		}
-
-		this.updateCurrentSpeed();
-
-		if (this._lastFrameSpeed.x == 0 && this._lastFrameSpeed.z == 0 && this._currentAcceleration.x == 0 && this._currentAcceleration.z == 0) {
-			return;
-		}
-
-		// dv = (dt * v0) + 1/2 * dt² * a
-
-		var dt = BABYLON.Tools.GetDeltaTime() / 1000.0;
-		this._lastFrameSpeed.scaleToRef(dt, this._tempSpeed);
-		this._currentAcceleration.scaleToRef(dt * dt * 0.5, this._tempSpeed2);
-		this._tempSpeed.addInPlace(this._tempSpeed2);
-		if (this._tempSpeed.x != 0 || this._tempSpeed.z != 0) {
-			this.target.moveRelative(this._tempSpeed);
-		}
-	};
-})();

+ 0 - 53
Babylon/Cameras/Controllers/babylon.oculusController.js

@@ -1,53 +0,0 @@
-"use strict";
-
-var BABYLON = BABYLON || {};
-
-(function () {
-    BABYLON.OculusController = function (scene, target) {
-        BABYLON.InputController.call(this, scene, target);
-        this._deviceOrientationHandler = this.onOrientationEvent.bind(this);
-        this._tempOrientation = { yaw: 0.0, pitch: 0.0, roll: 0.0 };
-        this._relativeOrientation = { yaw: 0.0, pitch: 0.0, roll: 0.0 };
-        window.addEventListener("deviceorientation", this._deviceOrientationHandler);
-    };
-
-    BABYLON.OculusController.prototype = Object.create(BABYLON.InputController.prototype);
-
-    BABYLON.OculusController.prototype.onOrientationEvent = function (ev) {
-        this._tempOrientation.yaw = ev.alpha / 180 * Math.PI;
-        this._tempOrientation.pitch = ev.beta / 180 * Math.PI;
-        this._tempOrientation.roll = ev.gamma / 180 * Math.PI;
-
-        if (!this._lastOrientation) {
-            this._lastOrientation = Object.create(this._tempOrientation);
-        }
-        else {
-            this._relativeOrientation.yaw = this._tempOrientation.yaw - this._lastOrientation.yaw;
-            this._relativeOrientation.pitch = this._tempOrientation.pitch - this._lastOrientation.pitch;
-            this._relativeOrientation.roll = this._tempOrientation.roll - this._lastOrientation.roll;
-
-            var temp = this._tempOrientation;
-            this._tempOrientation = this._lastOrientation;
-            this._lastOrientation = temp;
-            this.target.rotateRelative(this._relativeOrientation);
-        }
-    };
-    BABYLON.OculusController.prototype.dispose = function () {
-        window.removeEventListener("deviceorientation", this._deviceOrientationHandler);
-    };
-
-    BABYLON.OculusController.CameraSettings_OculusRiftDevKit2013_Metric = {
-        HResolution: 1280,
-        VResolution: 800,
-        HScreenSize: 0.149759993,
-        VScreenSize: 0.0935999975,
-        VScreenCenter: 0.0467999987,
-        EyeToScreenDistance: 0.0410000011,
-        LensSeparationDistance: 0.0635000020,
-        InterpupillaryDistance: 0.0640000030,
-        DistortionK: [1.0, 0.219999999, 0.239999995, 0.0],
-        ChromaAbCorrection: [0.995999992, -0.00400000019, 1.01400006, 0.0],
-        PostProcessScaleFactor: 1.714605507808412,
-        LensCenterOffset: 0.151976421
-    };
-})();

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

@@ -21,7 +21,7 @@
         public layerMask: number = 0xFFFFFFFF;
 
         private _computedViewMatrix = BABYLON.Matrix.Identity();
-        private _projectionMatrix = new BABYLON.Matrix();
+        public _projectionMatrix = new BABYLON.Matrix();
         private _worldMatrix: Matrix;
         public _postProcesses = new Array<PostProcess>();
         public _postProcessesTakenIndices = [];

+ 95 - 76
Babylon/Cameras/babylon.deviceOrientationCamera.js

@@ -1,77 +1,96 @@
-"use strict";
-
-var BABYLON = BABYLON || {};
-
-(function () {
-    BABYLON.DeviceOrientationCamera = function (name, position, scene) {
-        BABYLON.FreeCamera.call(this, name, position, scene);
-
-        // Offset
-        this._offsetX = null;
-        this._offsetY = null;
-        this._orientationGamma = 0;
-        this._orientationBeta = 0;
-        this._initialOrientationGamma = 0;
-        this._initialOrientationBeta = 0;
-    };
-
-    BABYLON.DeviceOrientationCamera.prototype = Object.create(BABYLON.FreeCamera.prototype);
-    
-    // Members
-    BABYLON.DeviceOrientationCamera.prototype.angularSensibility = 10000.0;
-    BABYLON.DeviceOrientationCamera.prototype.moveSensibility = 50.0;
-
-    // Controls
-    BABYLON.DeviceOrientationCamera.prototype.attachControl = function (canvas, noPreventDefault) {
-        if (this._attachedCanvas) {
-            return;
-        }
-        this._attachedCanvas = canvas;
-
-        var that = this;
-        if (!this._orientationChanged) {
-            this._orientationChanged = function (evt) {
-
-                if (!that._initialOrientationGamma) {
-                    that._initialOrientationGamma = evt.gamma;
-                    that._initialOrientationBeta = evt.beta;
-                }
-
-                that._orientationGamma = evt.gamma;
-                that._orientationBeta = evt.beta;
-
-                that._offsetY = (that._initialOrientationBeta - that._orientationBeta);
-                that._offsetX = (that._initialOrientationGamma - that._orientationGamma);
-            };
+var __extends = this.__extends || function (d, b) {
+    for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
+    function __() { this.constructor = d; }
+    __.prototype = b.prototype;
+    d.prototype = new __();
+};
+var BABYLON;
+(function (BABYLON) {
+    // We're mainly based on the logic defined into the FreeCamera code
+    var DeviceOrientationCamera = (function (_super) {
+        __extends(DeviceOrientationCamera, _super);
+        function DeviceOrientationCamera(name, position, scene) {
+            var _this = this;
+            _super.call(this, name, position, scene);
+            this._offsetX = null;
+            this._offsetY = null;
+            this._orientationGamma = 0;
+            this._orientationBeta = 0;
+            this._initialOrientationGamma = 0;
+            this._initialOrientationBeta = 0;
+            this._isLandscape = true;
+            this.angularSensibility = 10000.0;
+            this.moveSensibility = 50.0;
+
+            http:
+            window.addEventListener("resize", function () {
+                _this._isLandscape = (window.innerWidth > window.innerHeight) ? true : false;
+                _this._initialOrientationGamma = null;
+            }, false);
         }
-
-        window.addEventListener("deviceorientation", this._orientationChanged);
-    };
-
-    BABYLON.DeviceOrientationCamera.prototype.detachControl = function (canvas) {
-        if (this._attachedCanvas != canvas) {
-            return;
-        }
-
-        window.removeEventListener("deviceorientation", this._orientationChanged);
-
-        this._attachedCanvas = null;
-        this._orientationGamma = 0;
-        this._orientationBeta = 0;
-        this._initialOrientationGamma = 0;
-        this._initialOrientationBeta = 0;
-    };
-
-    BABYLON.DeviceOrientationCamera.prototype._checkInputs = function () {
-        if (!this._offsetX) {
-            return;
-        }
-        this.cameraRotation.y -= this._offsetX / this.angularSensibility;
-
-        var speed = this._computeLocalCameraSpeed();
-        var direction = new BABYLON.Vector3(0, 0, speed * this._offsetY / this.moveSensibility);
-
-        BABYLON.Matrix.RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, 0, this._cameraRotationMatrix);
-        this.cameraDirection.addInPlace(BABYLON.Vector3.TransformCoordinates(direction, this._cameraRotationMatrix));
-    };
-})();
+        DeviceOrientationCamera.prototype.attachControl = function (canvas, noPreventDefault) {
+            if (this._attachedCanvas) {
+                return;
+            }
+            this._attachedCanvas = canvas;
+
+            var that = this;
+            if (!this._orientationChanged) {
+                this._orientationChanged = function (evt) {
+                    if (!that._initialOrientationGamma) {
+                        if (!this._isLandscape) {
+                            that._initialOrientationGamma = evt.gamma;
+                            that._initialOrientationBeta = evt.beta;
+                        } else {
+                            that._initialOrientationGamma = evt.beta;
+                            that._initialOrientationBeta = evt.gamma;
+                        }
+                    }
+
+                    if (!this._isLandscape) {
+                        that._orientationGamma = evt.gamma;
+                        that._orientationBeta = evt.beta;
+                    } else {
+                        that._orientationGamma = evt.beta;
+                        that._orientationBeta = evt.gamma;
+                    }
+
+                    that._offsetY = (that._initialOrientationBeta - that._orientationBeta);
+                    that._offsetX = (that._initialOrientationGamma - that._orientationGamma);
+                };
+            }
+
+            window.addEventListener("deviceorientation", this._orientationChanged);
+        };
+
+        DeviceOrientationCamera.prototype.detachControl = function (canvas) {
+            if (this._attachedCanvas != canvas) {
+                return;
+            }
+
+            window.removeEventListener("deviceorientation", this._orientationChanged);
+
+            this._attachedCanvas = null;
+            this._orientationGamma = 0;
+            this._orientationBeta = 0;
+            this._initialOrientationGamma = 0;
+            this._initialOrientationBeta = 0;
+        };
+
+        DeviceOrientationCamera.prototype._checkInputs = function () {
+            if (!this._offsetX) {
+                return;
+            }
+            this.cameraRotation.y -= this._offsetX / this.angularSensibility;
+
+            var speed = this._computeLocalCameraSpeed();
+            var direction = new BABYLON.Vector3(0, 0, speed * this._offsetY / this.moveSensibility);
+
+            BABYLON.Matrix.RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, 0, this._cameraRotationMatrix);
+            this.cameraDirection.addInPlace(BABYLON.Vector3.TransformCoordinates(direction, this._cameraRotationMatrix));
+        };
+        return DeviceOrientationCamera;
+    })(BABYLON.FreeCamera);
+    BABYLON.DeviceOrientationCamera = DeviceOrientationCamera;
+})(BABYLON || (BABYLON = {}));
+//# sourceMappingURL=babylon.deviceOrientationCamera.js.map

+ 93 - 0
Babylon/Cameras/babylon.deviceOrientationCamera.ts

@@ -0,0 +1,93 @@
+module BABYLON {
+    // We're mainly based on the logic defined into the FreeCamera code
+    export class DeviceOrientationCamera extends FreeCamera {
+        private _offsetX: number = null;
+        private _offsetY: number = null;
+        private _orientationGamma: number = 0;
+        private _orientationBeta: number = 0;
+        private _initialOrientationGamma: number = 0;
+        private _initialOrientationBeta: number = 0;
+        private _attachedCanvas: HTMLCanvasElement;
+        private _orientationChanged: (e: DeviceOrientationEvent) => any;
+        private _isLandscape: boolean = true;
+
+        public angularSensibility: number = 10000.0;
+        public moveSensibility: number = 50.0;
+
+        constructor(name: string, position: Vector3, scene: Scene) {
+            super(name, position, scene);
+
+            http://david.blob.core.windows.net/videos/BabylonJSWinStoreLaunchSequence.mp4 = (window.innerWidth > window.innerHeight) ? true : false;
+
+            window.addEventListener("resize", () => {
+                this._isLandscape = (window.innerWidth > window.innerHeight) ? true : false;
+                this._initialOrientationGamma = null;
+            }, false);
+        }
+
+        public attachControl(canvas: HTMLCanvasElement, noPreventDefault: boolean): void {
+            if (this._attachedCanvas) {
+                return;
+            }
+            this._attachedCanvas = canvas;
+
+            var that = this;
+            if (!this._orientationChanged) {
+                this._orientationChanged = function (evt) {
+
+                    if (!that._initialOrientationGamma) {
+                        if (!this._isLandscape) {
+                            that._initialOrientationGamma = evt.gamma;
+                            that._initialOrientationBeta = evt.beta;
+                        }
+                        else {
+                            that._initialOrientationGamma = evt.beta;
+                            that._initialOrientationBeta = evt.gamma;
+                        }
+                    }
+
+                    if (!this._isLandscape) {
+                        that._orientationGamma = evt.gamma;
+                        that._orientationBeta = evt.beta;
+                    }
+                    else {
+                        that._orientationGamma = evt.beta;
+                        that._orientationBeta = evt.gamma;
+                    }
+
+                    that._offsetY = (that._initialOrientationBeta - that._orientationBeta);
+                    that._offsetX = (that._initialOrientationGamma - that._orientationGamma);
+                };
+            }
+
+            window.addEventListener("deviceorientation", this._orientationChanged);
+        }
+
+        public detachControl(canvas: HTMLCanvasElement): void {
+            if (this._attachedCanvas != canvas) {
+                return;
+            }
+
+            window.removeEventListener("deviceorientation", this._orientationChanged);
+
+            this._attachedCanvas = null;
+            this._orientationGamma = 0;
+            this._orientationBeta = 0;
+            this._initialOrientationGamma = 0;
+            this._initialOrientationBeta = 0;
+        }
+
+        public _checkInputs(): void {
+            if (!this._offsetX) {
+                return;
+            }
+            this.cameraRotation.y -= this._offsetX / this.angularSensibility;
+
+            var speed = this._computeLocalCameraSpeed();
+            var direction = new BABYLON.Vector3(0, 0, speed * this._offsetY / this.moveSensibility);
+
+            BABYLON.Matrix.RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, 0, this._cameraRotationMatrix);
+            this.cameraDirection.addInPlace(BABYLON.Vector3.TransformCoordinates(direction, this._cameraRotationMatrix));
+        }
+    }
+}

+ 1 - 3
Babylon/Cameras/babylon.freeCamera.js

@@ -33,7 +33,7 @@ var BABYLON;
             this._camMatrix = BABYLON.Matrix.Zero();
             this._cameraTransformMatrix = BABYLON.Matrix.Zero();
             this._cameraRotationMatrix = BABYLON.Matrix.Zero();
-            this._referencePoint = BABYLON.Vector3.Zero();
+            this._referencePoint = new BABYLON.Vector3(0, 0, 1);
             this._transformedReferencePoint = BABYLON.Vector3.Zero();
             this._oldPosition = BABYLON.Vector3.Zero();
             this._diffPosition = BABYLON.Vector3.Zero();
@@ -379,8 +379,6 @@ var BABYLON;
         };
 
         FreeCamera.prototype._getViewMatrix = function () {
-            BABYLON.Vector3.FromFloatsToRef(0, 0, 1, this._referencePoint);
-
             if (!this.lockedTarget) {
                 // Compute
                 if (this.upVector.x != 0 || this.upVector.y != 1.0 || this.upVector.z != 0) {

+ 4 - 6
Babylon/Cameras/babylon.freeCamera.ts

@@ -19,13 +19,13 @@
         private _keys = [];
         private _collider = new Collider();
         private _needMoveForGravity = true;
-        private _currentTarget = BABYLON.Vector3.Zero();
-        private _viewMatrix = BABYLON.Matrix.Zero();
+        public _currentTarget = BABYLON.Vector3.Zero();
+        public _viewMatrix = BABYLON.Matrix.Zero();
         private _camMatrix = BABYLON.Matrix.Zero();
         private _cameraTransformMatrix = BABYLON.Matrix.Zero();
         public _cameraRotationMatrix = BABYLON.Matrix.Zero();
-        private _referencePoint = BABYLON.Vector3.Zero();
-        private _transformedReferencePoint = BABYLON.Vector3.Zero();
+        public _referencePoint = new BABYLON.Vector3(0, 0, 1);
+        public _transformedReferencePoint = BABYLON.Vector3.Zero();
         private _oldPosition = BABYLON.Vector3.Zero();
         private _diffPosition = BABYLON.Vector3.Zero();
         private _newPosition = BABYLON.Vector3.Zero();
@@ -398,8 +398,6 @@
         }
 
         public _getViewMatrix(): Matrix {
-            BABYLON.Vector3.FromFloatsToRef(0, 0, 1, this._referencePoint);
-
             if (!this.lockedTarget) {
                 // Compute
                 if (this.upVector.x != 0 || this.upVector.y != 1.0 || this.upVector.z != 0) {

+ 141 - 0
Babylon/Cameras/babylon.oculusCamera.js

@@ -0,0 +1,141 @@
+var __extends = this.__extends || function (d, b) {
+    for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
+    function __() { this.constructor = d; }
+    __.prototype = b.prototype;
+    d.prototype = new __();
+};
+var BABYLON;
+(function (BABYLON) {
+    var OculusRiftDevKit2013_Metric = {
+        HResolution: 1280,
+        VResolution: 800,
+        HScreenSize: 0.149759993,
+        VScreenSize: 0.0935999975,
+        VScreenCenter: 0.0467999987,
+        EyeToScreenDistance: 0.0410000011,
+        LensSeparationDistance: 0.0635000020,
+        InterpupillaryDistance: 0.0640000030,
+        DistortionK: [1.0, 0.219999999, 0.239999995, 0.0],
+        ChromaAbCorrection: [0.995999992, -0.00400000019, 1.01400006, 0.0],
+        PostProcessScaleFactor: 1.714605507808412,
+        LensCenterOffset: 0.151976421
+    };
+
+    var _OculusInnerCamera = (function (_super) {
+        __extends(_OculusInnerCamera, _super);
+        function _OculusInnerCamera(name, position, scene, isLeftEye) {
+            _super.call(this, name, position, scene);
+            this._workMatrix = new BABYLON.Matrix();
+            this._actualUp = new BABYLON.Vector3(0, 0, 0);
+
+            // Constants
+            this._aspectRatioAspectRatio = OculusRiftDevKit2013_Metric.HResolution / (2 * OculusRiftDevKit2013_Metric.VResolution);
+            this._aspectRatioFov = (2 * Math.atan((OculusRiftDevKit2013_Metric.PostProcessScaleFactor * OculusRiftDevKit2013_Metric.VScreenSize) / (2 * OculusRiftDevKit2013_Metric.EyeToScreenDistance)));
+
+            var hMeters = (OculusRiftDevKit2013_Metric.HScreenSize / 4) - (OculusRiftDevKit2013_Metric.LensSeparationDistance / 2);
+            var h = (4 * hMeters) / OculusRiftDevKit2013_Metric.HScreenSize;
+
+            this._hMatrix = BABYLON.Matrix.Translation(isLeftEye ? h : -h, 0, 0);
+
+            this.viewport = new BABYLON.Viewport(isLeftEye ? 0 : 0.5, 0, 0.5, 1.0);
+
+            this._preViewMatrix = BABYLON.Matrix.Translation(isLeftEye ? .5 * OculusRiftDevKit2013_Metric.InterpupillaryDistance : -.5 * OculusRiftDevKit2013_Metric.InterpupillaryDistance, 0, 0);
+
+            // Postprocess
+            var postProcess = new BABYLON.OculusDistortionCorrectionPostProcess("Oculus Distortion", this, !isLeftEye, OculusRiftDevKit2013_Metric);
+        }
+        _OculusInnerCamera.prototype.getProjectionMatrix = function () {
+            BABYLON.Matrix.PerspectiveFovLHToRef(this._aspectRatioFov, this._aspectRatioAspectRatio, this.minZ, this.maxZ, this._workMatrix);
+            this._workMatrix.multiplyToRef(this._hMatrix, this._projectionMatrix);
+            return this._projectionMatrix;
+        };
+
+        _OculusInnerCamera.prototype._getViewMatrix = function () {
+            BABYLON.Matrix.RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, this._cameraRotationMatrix);
+
+            BABYLON.Vector3.TransformCoordinatesToRef(this._referencePoint, this._cameraRotationMatrix, this._transformedReferencePoint);
+            BABYLON.Vector3.TransformNormalToRef(this.upVector, this._cameraRotationMatrix, this._actualUp);
+
+            // Computing target and final matrix
+            this.position.addToRef(this._transformedReferencePoint, this._currentTarget);
+
+            BABYLON.Matrix.LookAtLHToRef(this.position, this._currentTarget, this._actualUp, this._workMatrix);
+
+            this._workMatrix.multiplyToRef(this._preViewMatrix, this._viewMatrix);
+            return this._viewMatrix;
+        };
+        return _OculusInnerCamera;
+    })(BABYLON.FreeCamera);
+
+    var OculusCamera = (function (_super) {
+        __extends(OculusCamera, _super);
+        function OculusCamera(name, position, scene) {
+            _super.call(this, name, position, scene);
+
+            this._leftCamera = new _OculusInnerCamera(name + "_left", position.clone(), scene, true);
+            this._rightCamera = new _OculusInnerCamera(name + "_right", position.clone(), scene, false);
+
+            this.subCameras.push(this._leftCamera);
+            this.subCameras.push(this._rightCamera);
+
+            this._deviceOrientationHandler = this._onOrientationEvent.bind(this);
+        }
+        OculusCamera.prototype._update = function () {
+            this._leftCamera.position.copyFrom(this.position);
+            this._rightCamera.position.copyFrom(this.position);
+
+            this._updateCamera(this._leftCamera);
+            this._updateCamera(this._rightCamera);
+
+            _super.prototype._update.call(this);
+        };
+
+        OculusCamera.prototype._updateCamera = function (camera) {
+            camera.minZ = this.minZ;
+            camera.maxZ = this.maxZ;
+
+            camera.rotation.x = this.rotation.x;
+            camera.rotation.y = this.rotation.y;
+            camera.rotation.z = this.rotation.z;
+        };
+
+        // Oculus events
+        OculusCamera.prototype._onOrientationEvent = function (evt) {
+            var yaw = evt.alpha / 180 * Math.PI;
+            var pitch = evt.beta / 180 * Math.PI;
+            var roll = evt.gamma / 180 * Math.PI;
+
+            if (!this._offsetOrientation) {
+                this._offsetOrientation = {
+                    yaw: yaw,
+                    pitch: pitch,
+                    roll: roll
+                };
+                return;
+            } else {
+                this.rotation.y += yaw - this._offsetOrientation.yaw;
+                this.rotation.x += pitch - this._offsetOrientation.pitch;
+                this.rotation.z += this._offsetOrientation.roll - roll;
+
+                this._offsetOrientation.yaw = yaw;
+                this._offsetOrientation.pitch = pitch;
+                this._offsetOrientation.roll = roll;
+            }
+        };
+
+        OculusCamera.prototype.attachControl = function (element, noPreventDefault) {
+            _super.prototype.attachControl.call(this, element, noPreventDefault);
+
+            window.addEventListener("deviceorientation", this._deviceOrientationHandler);
+        };
+
+        OculusCamera.prototype.detachControl = function (element) {
+            _super.prototype.detachControl.call(this, element);
+
+            window.removeEventListener("deviceorientation", this._deviceOrientationHandler);
+        };
+        return OculusCamera;
+    })(BABYLON.FreeCamera);
+    BABYLON.OculusCamera = OculusCamera;
+})(BABYLON || (BABYLON = {}));
+//# sourceMappingURL=babylon.oculusCamera.js.map

+ 142 - 0
Babylon/Cameras/babylon.oculusCamera.ts

@@ -0,0 +1,142 @@
+module BABYLON {
+
+    var OculusRiftDevKit2013_Metric = {
+        HResolution: 1280,
+        VResolution: 800,
+        HScreenSize: 0.149759993,
+        VScreenSize: 0.0935999975,
+        VScreenCenter: 0.0467999987,
+        EyeToScreenDistance: 0.0410000011,
+        LensSeparationDistance: 0.0635000020,
+        InterpupillaryDistance: 0.0640000030,
+        DistortionK: [1.0, 0.219999999, 0.239999995, 0.0],
+        ChromaAbCorrection: [0.995999992, -0.00400000019, 1.01400006, 0.0],
+        PostProcessScaleFactor: 1.714605507808412,
+        LensCenterOffset: 0.151976421
+    };
+
+    class _OculusInnerCamera extends FreeCamera {
+        private _aspectRatioAspectRatio: number;
+        private _aspectRatioFov: number;
+        private _hMatrix: Matrix;
+        private _workMatrix = new BABYLON.Matrix();
+        private _preViewMatrix: Matrix;
+        private _actualUp = new BABYLON.Vector3(0, 0, 0);
+
+        constructor(name: string, position: Vector3, scene: Scene, isLeftEye: boolean) {
+            super(name, position, scene);
+
+            // Constants
+            this._aspectRatioAspectRatio = OculusRiftDevKit2013_Metric.HResolution / (2 * OculusRiftDevKit2013_Metric.VResolution);
+            this._aspectRatioFov = (2 * Math.atan((OculusRiftDevKit2013_Metric.PostProcessScaleFactor * OculusRiftDevKit2013_Metric.VScreenSize) / (2 * OculusRiftDevKit2013_Metric.EyeToScreenDistance)));
+
+            var hMeters = (OculusRiftDevKit2013_Metric.HScreenSize / 4) - (OculusRiftDevKit2013_Metric.LensSeparationDistance / 2);
+            var h = (4 * hMeters) / OculusRiftDevKit2013_Metric.HScreenSize;
+
+            this._hMatrix = BABYLON.Matrix.Translation(isLeftEye ? h : -h, 0, 0);
+
+            this.viewport = new BABYLON.Viewport(isLeftEye ? 0 : 0.5, 0, 0.5, 1.0);
+
+            this._preViewMatrix = BABYLON.Matrix.Translation(isLeftEye ? .5 * OculusRiftDevKit2013_Metric.InterpupillaryDistance : -.5 * OculusRiftDevKit2013_Metric.InterpupillaryDistance, 0, 0);
+
+            // Postprocess
+            var postProcess = new BABYLON.OculusDistortionCorrectionPostProcess("Oculus Distortion", this, !isLeftEye, OculusRiftDevKit2013_Metric);
+        }
+
+        public getProjectionMatrix(): Matrix {
+            BABYLON.Matrix.PerspectiveFovLHToRef(this._aspectRatioFov, this._aspectRatioAspectRatio, this.minZ, this.maxZ, this._workMatrix);
+            this._workMatrix.multiplyToRef(this._hMatrix, this._projectionMatrix);
+            return this._projectionMatrix;
+        }
+
+        public _getViewMatrix(): Matrix {
+            BABYLON.Matrix.RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, this._cameraRotationMatrix);
+
+            BABYLON.Vector3.TransformCoordinatesToRef(this._referencePoint, this._cameraRotationMatrix, this._transformedReferencePoint);
+            BABYLON.Vector3.TransformNormalToRef(this.upVector, this._cameraRotationMatrix, this._actualUp);
+
+            // Computing target and final matrix
+            this.position.addToRef(this._transformedReferencePoint, this._currentTarget);
+
+            BABYLON.Matrix.LookAtLHToRef(this.position, this._currentTarget, this._actualUp, this._workMatrix);
+
+            this._workMatrix.multiplyToRef(this._preViewMatrix, this._viewMatrix);
+            return this._viewMatrix;
+        }
+    }
+
+    export class OculusCamera extends FreeCamera {
+        private _leftCamera: _OculusInnerCamera;
+        private _rightCamera: _OculusInnerCamera;
+        private _offsetOrientation: { yaw: number; pitch: number; roll: number };
+        private _deviceOrientationHandler;
+
+        constructor(name: string, position: Vector3, scene: Scene) {
+            super(name, position, scene);
+
+            this._leftCamera = new _OculusInnerCamera(name + "_left", position.clone(), scene, true);
+            this._rightCamera = new _OculusInnerCamera(name + "_right", position.clone(), scene, false);
+
+            this.subCameras.push(this._leftCamera);
+            this.subCameras.push(this._rightCamera);
+
+            this._deviceOrientationHandler = this._onOrientationEvent.bind(this);
+        }
+
+        public _update(): void {
+            this._leftCamera.position.copyFrom(this.position);
+            this._rightCamera.position.copyFrom(this.position);
+
+            this._updateCamera(this._leftCamera);
+            this._updateCamera(this._rightCamera);
+
+            super._update();
+        }
+
+        public _updateCamera(camera: FreeCamera): void {
+            camera.minZ = this.minZ;
+            camera.maxZ = this.maxZ;
+
+            camera.rotation.x = this.rotation.x;
+            camera.rotation.y = this.rotation.y;
+            camera.rotation.z = this.rotation.z;
+        }
+
+        // Oculus events
+        private _onOrientationEvent(evt: DeviceOrientationEvent): void {
+            var yaw = evt.alpha / 180 * Math.PI;
+            var pitch = evt.beta / 180 * Math.PI;
+            var roll = evt.gamma / 180 * Math.PI;
+
+            if (!this._offsetOrientation) {
+                this._offsetOrientation = {
+                    yaw: yaw,
+                    pitch: pitch,
+                    roll: roll
+                };
+                return;
+            }
+            else {
+                this.rotation.y += yaw - this._offsetOrientation.yaw;
+                this.rotation.x += pitch - this._offsetOrientation.pitch;
+                this.rotation.z += this._offsetOrientation.roll - roll;
+
+                this._offsetOrientation.yaw = yaw;
+                this._offsetOrientation.pitch = pitch;
+                this._offsetOrientation.roll = roll;
+            }
+        }
+
+        public attachControl(element: HTMLElement, noPreventDefault?: boolean): void {
+            super.attachControl(element, noPreventDefault);
+
+            window.addEventListener("deviceorientation", this._deviceOrientationHandler);
+        }
+
+        public detachControl(element: HTMLElement): void {
+            super.detachControl(element);
+
+            window.removeEventListener("deviceorientation", this._deviceOrientationHandler);
+        }
+    }
+} 

+ 0 - 168
Babylon/Cameras/babylon.oculusOrientedCamera.js

@@ -1,168 +0,0 @@
-"use strict";
-
-var BABYLON = BABYLON || {};
-
-(function () {
-    BABYLON.OculusOrientedCamera = function (name, position, scene, isLeftEye, ovrSettings, neutralOrientation) {
-        // OculusOrientedCamera is usually built 2 times using the same position
-        // So I duplicate the position to avoid errors from physics system (which could manipulate it twice per frame)
-        position = position ? new BABYLON.Vector3(position.x, position.y, position.z) : null;
-        BABYLON.Camera.call(this, name, position, scene);
-        this._referenceDirection = new BABYLON.Vector3(0, 0, 1);
-        this._referenceUp = new BABYLON.Vector3(0, 1, 0);
-        this._actualDirection = new BABYLON.Vector3(1, 0, 0);
-        this._actualUp = new BABYLON.Vector3(0, 1, 0);
-        this._currentTargetPoint = new BABYLON.Vector3(0, 0, 0);
-        this._currentOrientation = Object.create(neutralOrientation || { yaw: 0.0, pitch: 0.0, roll: 0.0 });
-        this._currentViewMatrix = new BABYLON.Matrix();
-        this._currentOrientationMatrix = new BABYLON.Matrix();
-        this._currentInvertOrientationMatrix = new BABYLON.Matrix();
-        this._tempMatrix = new BABYLON.Matrix();
-        
-        if (isLeftEye) {
-            this.viewport = new BABYLON.Viewport(0, 0, 0.5, 1.0);
-        } else {
-            this.viewport = new BABYLON.Viewport(0.5, 0, 0.5, 1.0);
-        }
-
-        this._aspectRatioAspectRatio = ovrSettings.HResolution / (2 * ovrSettings.VResolution);
-        this._aspectRatioFov = (2 * Math.atan((ovrSettings.PostProcessScaleFactor * ovrSettings.VScreenSize) / (2 * ovrSettings.EyeToScreenDistance)));
-        var hMeters = (ovrSettings.HScreenSize / 4) - (ovrSettings.LensSeparationDistance / 2);
-        var h = (4 * hMeters) / ovrSettings.HScreenSize;
-        this._hMatrix = BABYLON.Matrix.Translation(isLeftEye ? h : -h, 0, 0);
-
-        this._projectionMatrix = new BABYLON.Matrix();
-        this._preViewMatrix = BABYLON.Matrix.Translation(isLeftEye ? .5 * ovrSettings.InterpupillaryDistance : -.5 * ovrSettings.InterpupillaryDistance, 0, 0);
-        new BABYLON.OculusDistortionCorrectionPostProcess("Oculus Distortion", this, !isLeftEye, ovrSettings);
-        this.resetProjectionMatrix();
-        this.resetViewMatrix();
-    };
-    
-    BABYLON.OculusOrientedCamera.BuildOculusStereoCamera = function (scene, name, minZ, maxZ, position, neutralOrientation, useFXAA, disableGravity, disableCollisions, collisionEllipsoid, ovrSettings) {
-        var canvas = scene.getEngine().getRenderingCanvas();
-        position = position || BABYLON.Vector3.Zero(0, 0, 0);
-        neutralOrientation = neutralOrientation || { yaw: 0.0, pitch: 0.0, roll: 0.0 };
-        //var controller =  new BABYLON.OculusController();
-        ovrSettings = ovrSettings || BABYLON.OculusController.CameraSettings_OculusRiftDevKit2013_Metric;
-
-        var leftCamera = new BABYLON.OculusOrientedCamera(name + "_left", position, scene, true, ovrSettings, neutralOrientation);
-        leftCamera.minZ = minZ;
-        leftCamera.maxZ = maxZ;
-        if (useFXAA) {
-            new BABYLON.FxaaPostProcess("fxaa_left", 1.0, leftCamera);
-        }
-
-        var rightCamera = new BABYLON.OculusOrientedCamera(name + "_right", position.clone(), scene, false, ovrSettings, neutralOrientation);
-        rightCamera.minZ = minZ;
-        rightCamera.maxZ = maxZ;
-        if (useFXAA) {
-            new BABYLON.FxaaPostProcess("fxaa_right", 1.0, rightCamera);
-        }
-        scene.activeCameras = [];
-        scene.activeCameras.push(leftCamera);
-        scene.activeCameras.push(rightCamera);
-        leftCamera.attachControl(canvas);
-        rightCamera.attachControl(canvas);
-        var multiTarget = new BABYLON.InputControllerMultiTarget([leftCamera, rightCamera]);
-        var controller = new BABYLON.OculusController(scene, multiTarget);
-        var moveTarget = multiTarget;
-        if (!disableCollisions) {
-            var collisionFilter = new BABYLON.InputCollisionFilter(scene, multiTarget, collisionEllipsoid);
-            moveTarget = collisionFilter;
-        }
-        if (!disableGravity) {
-
-            var globalAxisFactorFilter = new BABYLON.GlobalAxisFactorsFilter(scene, moveTarget, 1, 0, 1);
-            var gravityController = new BABYLON.GravityInputController(scene, moveTarget);
-            moveTarget = globalAxisFactorFilter;
-        }
-        var moveController = new BABYLON.KeyboardMoveController(scene, moveTarget);
-        moveController.attachToCanvas(canvas);
-        var result = {
-            leftCamera: leftCamera, rightCamera: rightCamera, intermediateControllerTarget: multiTarget,
-            oculusController: controller,
-            keyboardController: moveController
-        };
-        result.dispose = function () {
-            this.leftCamera.detachControl(canvas);
-            this.rightCamera.detachControl(canvas);
-            this.leftCamera.dispose();
-            this.rightCamera.dispose();
-            this.oculusController.dispose();
-            this.keyboardController.detachFromCanvas(canvas);
-            this.keyboardController.dispose();
-        }.bind(result);
-        return result;
-    };
-    
-    BABYLON.OculusOrientedCamera.prototype = Object.create(BABYLON.Camera.prototype);
-
-    BABYLON.OculusOrientedCamera.prototype.resetViewMatrix = function () {
-        BABYLON.Matrix.RotationYawPitchRollToRef(
-            this._currentOrientation.yaw,
-            this._currentOrientation.pitch,
-            -this._currentOrientation.roll
-            , this._currentOrientationMatrix);
-        this._currentOrientationMatrix.invertToRef(this._currentInvertOrientationMatrix);
-
-        BABYLON.Vector3.TransformNormalToRef(this._referenceDirection, this._currentOrientationMatrix, this._actualDirection);
-        BABYLON.Vector3.TransformNormalToRef(this._referenceUp, this._currentOrientationMatrix, this._actualUp);
-
-        BABYLON.Vector3.FromFloatsToRef(this.position.x + this._actualDirection.x, this.position.y + this._actualDirection.y, this.position.z + this._actualDirection.z, this._currentTargetPoint);
-        BABYLON.Matrix.LookAtLHToRef(this.position, this._currentTargetPoint, this._actualUp, this._tempMatrix);
-        this._tempMatrix.multiplyToRef(this._preViewMatrix, this._currentViewMatrix);
-        return this._currentViewMatrix;
-    };
-    BABYLON.OculusOrientedCamera.prototype.getViewMatrix = function () {
-
-        return this._currentViewMatrix;
-    };
-
-    BABYLON.OculusOrientedCamera.prototype._update = function () {
-        if (this.controllers) {
-            for (var i = 0; i < this.controllers.length; ++i) {
-                this.controllers[i].update();
-            }
-        }
-    };
-
-    BABYLON.OculusOrientedCamera.prototype.getOrientationMatrix = function () {
-        return this._currentOrientationMatrix;
-    };
-
-    BABYLON.OculusOrientedCamera.prototype.getInvertOrientationMatrix = function () {
-        return this._currentInvertOrientationMatrix;
-    };
-
-    BABYLON.OculusOrientedCamera.prototype.resetProjectionMatrix = function () {
-        BABYLON.Matrix.PerspectiveFovLHToRef(this._aspectRatioFov, this._aspectRatioAspectRatio, this.minZ, this.maxZ, this._tempMatrix);
-        this._tempMatrix.multiplyToRef(this._hMatrix, this._projectionMatrix);
-        return this._projectionMatrix;
-    };
-
-    BABYLON.OculusOrientedCamera.prototype.getProjectionMatrix = function (force) {
-        return this._projectionMatrix;
-    };
-
-    // implementation of InputControllerTarget
-    BABYLON.OculusOrientedCamera.prototype.getOrientation = function () {
-        return this._currentOrientation;
-    };
-    BABYLON.OculusOrientedCamera.prototype.getPosition = function () {
-        return this.position;
-    };
-    BABYLON.OculusOrientedCamera.prototype.moveRelative = function (movementVector) {
-        if (!this._tempMoveVector) {
-            this._tempMoveVector = new BABYLON.Vector3(0, 0, 0);
-        }
-        BABYLON.Vector3.TransformNormalToRef(movementVector, this._currentOrientationMatrix, this._tempMoveVector);
-        this.position.addInPlace(this._tempMoveVector);
-        this.resetViewMatrix();
-    };
-    BABYLON.OculusOrientedCamera.prototype.rotateRelative = function (rotation) {
-        this._currentOrientation.yaw += rotation.yaw;
-        this._currentOrientation.pitch += rotation.pitch;
-        this._currentOrientation.roll += rotation.roll;
-        this.resetViewMatrix();
-    };
-})();

+ 1 - 1
Babylon/babylon.scene.ts

@@ -29,7 +29,7 @@
         private _onPointerMove: (evt: PointerEvent) => void;
         private _onPointerDown: (evt: PointerEvent) => void;
         public onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo) => void;
-        public cameraToUseForPointers: Camera; // Define this parameter if you are using multiple cameras and you want to specify which one should be sued for pointer position
+        public cameraToUseForPointers: Camera; // Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position
         private _pointerX: number;
         private _pointerY: number;
         private _meshUnderPointer: AbstractMesh;

+ 1 - 7
Tools/BuildOurOwnBabylonJS/BuildOurOwnBabylonJS/babylonJS.xml

@@ -22,13 +22,8 @@
   <script src="Babylon/Cameras/babylon.anaglyphCamera.js"></script>
   <script src="Babylon/Mesh/babylon.mesh.vertexData.js"></script>
   <script src="Babylon/Materials/babylon.shaderMaterial.js"></script>
-  <script src="Babylon/Cameras/Controllers/babylon.globalAxisFactorsFilter.js"></script>
-  <script src="Babylon/Cameras/Controllers/babylon.gravityInputController.js"></script>
-  <script src="Babylon/Cameras/Controllers/babylon.inputCollisionFilter.js"></script>
-  <script src="Babylon/Cameras/Controllers/babylon.keyboardMoveController.js"></script>
   <script src="Babylon/Cameras/babylon.virtualJoysticksCamera.js"></script>
-  <script src="Babylon/Cameras/babylon.oculusOrientedCamera.js"></script>
-  <script src="Babylon/Cameras/Controllers/babylon.oculusController.js"></script>
+  <script src="Babylon/Cameras/babylon.oculusCamera.js"></script>
   <script src="Babylon/Tools/babylon.virtualJoystick.js"></script>
   <script src="Babylon/PostProcess/babylon.oculusDistortionCorrectionPostProcess.js"></script>
   <script src="Babylon/Mesh/babylon.csg.js"></script>
@@ -82,7 +77,6 @@
   <script src="Babylon/Cameras/babylon.touchCamera.js"></script>
   <script src="Babylon/Cameras/babylon.freeCamera.js"></script>
   <script src="Babylon/Cameras/babylon.camera.js"></script>
-  <script src="Babylon/Cameras/Controllers/babylon.inputController.js"></script>
   <script src="Babylon/Collisions/babylon.collider.js"></script>
   <script src="Babylon/Lights//Shadows/babylon.shadowGenerator.js"></script>
   <script src="Babylon/Lights/babylon.directionalLight.js"></script>

+ 1 - 7
Tools/Gulp/gulpfile.js

@@ -68,7 +68,6 @@ gulp.task('scripts', ['shaders'] ,function() {
       '../../Babylon/Lights/babylon.directionalLight.js',
       '../../Babylon/Lights/Shadows/babylon.shadowGenerator.js',
       '../../Babylon/Collisions/babylon.collider.js',
-      '../../Babylon/Cameras/Controllers/babylon.inputController.js',
       '../../Babylon/Cameras/babylon.camera.js',
       '../../Babylon/Cameras/babylon.freeCamera.js',
       '../../Babylon/Cameras/babylon.touchCamera.js',
@@ -124,13 +123,8 @@ gulp.task('scripts', ['shaders'] ,function() {
       '../../Babylon/Mesh/babylon.csg.js',
       '../../Babylon/PostProcess/babylon.oculusDistortionCorrectionPostProcess.js',
       '../../Babylon/Tools/babylon.virtualJoystick.js',
-      '../../Babylon/Cameras/Controllers/babylon.oculusController.js',
-      '../../Babylon/Cameras/babylon.oculusOrientedCamera.js',
+      '../../Babylon/Cameras/babylon.oculusCamera.js',
       '../../Babylon/Cameras/babylon.virtualJoysticksCamera.js',
-      '../../Babylon/Cameras/Controllers/babylon.keyboardMoveController.js',
-      '../../Babylon/Cameras/Controllers/babylon.inputCollisionFilter.js',
-      '../../Babylon/Cameras/Controllers/babylon.gravityInputController.js',
-      '../../Babylon/Cameras/Controllers/babylon.globalAxisFactorsFilter.js',
       '../../Babylon/Materials/babylon.shaderMaterial.js',
       '../../Babylon/Mesh/babylon.mesh.vertexData.js',
       '../../Babylon/Cameras/babylon.anaglyphCamera.js',

文件差異過大導致無法顯示
+ 2 - 2
babylon.1.13-beta-debug.js


文件差異過大導致無法顯示
+ 9 - 9
babylon.1.13-beta.js