Browse Source

Merge pull request #5737 from sebavan/master

Break inputs dependencies
sebavan 6 years ago
parent
commit
b1b9bdbe06

+ 21 - 0
src/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput.ts

@@ -1,6 +1,27 @@
 import { Nullable } from "../../types";
 import { ArcRotateCamera } from "../../Cameras/arcRotateCamera";
 import { ICameraInput, CameraInputTypes } from "../../Cameras/cameraInputsManager";
+import { ArcRotateCameraInputsManager } from "../../Cameras/arcRotateCameraInputsManager";
+
+// Module augmentation to abstract orientation inputs from camera.
+declare module "../../Cameras/arcRotateCameraInputsManager" {
+    export interface ArcRotateCameraInputsManager {
+        /**
+         * Add orientation input support to the input manager.
+         * @returns the current input manager
+         */
+        addVRDeviceOrientation(): ArcRotateCameraInputsManager;
+    }
+}
+
+/**
+ * Add orientation input support to the input manager.
+ * @returns the current input manager
+ */
+ArcRotateCameraInputsManager.prototype.addVRDeviceOrientation = function(): ArcRotateCameraInputsManager {
+    this.add(new ArcRotateCameraVRDeviceOrientationInput());
+    return this;
+};
 
 /**
  * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.

+ 22 - 0
src/Cameras/Inputs/freeCameraDeviceOrientationInput.ts

@@ -3,6 +3,28 @@ import { ICameraInput, CameraInputTypes } from "../../Cameras/cameraInputsManage
 import { FreeCamera } from "../../Cameras/freeCamera";
 import { Quaternion } from "../../Maths/math";
 import { Tools } from "../../Misc/tools";
+import { FreeCameraInputsManager } from "../../Cameras/freeCameraInputsManager";
+
+// Module augmentation to abstract orientation inputs from camera.
+declare module "../../Cameras/freeCameraInputsManager" {
+    export interface FreeCameraInputsManager {
+        /**
+         * Add orientation input support to the input manager.
+         * @returns the current input manager
+         */
+        addDeviceOrientation(): FreeCameraInputsManager;
+    }
+}
+
+/**
+ * Add orientation input support to the input manager.
+ * @returns the current input manager
+ */
+FreeCameraInputsManager.prototype.addDeviceOrientation = function(): FreeCameraInputsManager {
+    this.add(new FreeCameraDeviceOrientationInput());
+    return this;
+};
+
 /**
  * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  * Screen rotation is taken into account.

+ 22 - 0
src/Cameras/Inputs/freeCameraVirtualJoystickInput.ts

@@ -3,6 +3,28 @@ import { Nullable } from "../../types";
 import { ICameraInput, CameraInputTypes } from "../../Cameras/cameraInputsManager";
 import { FreeCamera } from "../../Cameras/freeCamera";
 import { Matrix, Vector3 } from "../../Maths/math";
+import { FreeCameraInputsManager } from "../../Cameras/freeCameraInputsManager";
+
+// Module augmentation to abstract virtual joystick from camera.
+declare module "../../Cameras/freeCameraInputsManager" {
+    export interface FreeCameraInputsManager {
+        /**
+         * Add virtual joystick input support to the input manager.
+         * @returns the current input manager
+         */
+        addVirtualJoystick(): FreeCameraInputsManager;
+    }
+}
+
+/**
+* Add virtual joystick input support to the input manager.
+* @returns the current input manager
+*/
+FreeCameraInputsManager.prototype.addVirtualJoystick = function(): FreeCameraInputsManager {
+   this.add(new FreeCameraVirtualJoystickInput());
+   return this;
+};
+
 /**
  * Manage the Virtual Joystick inputs to control the movement of a free camera.
  * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs

+ 4 - 0
src/Cameras/RigModes/index.ts

@@ -0,0 +1,4 @@
+export * from "./stereoscopicAnaglyphRigMode";
+export * from "./stereoscopicRigMode";
+export * from "./vrRigMode";
+export * from "./webVRRigMode";

+ 8 - 0
src/Cameras/RigModes/stereoscopicAnaglyphRigMode.ts

@@ -0,0 +1,8 @@
+import { Camera } from "../camera";
+import { PassPostProcess } from "../../PostProcesses/passPostProcess";
+import { AnaglyphPostProcess } from "../../PostProcesses/anaglyphPostProcess";
+
+Camera._setStereoscopicAnaglyphRigMode = function(camera: Camera) {
+    camera._rigCameras[0]._rigPostProcess = new PassPostProcess(camera.name + "_passthru", 1.0, camera._rigCameras[0]);
+    camera._rigCameras[1]._rigPostProcess = new AnaglyphPostProcess(camera.name + "_anaglyph", 1.0, camera._rigCameras);
+};

+ 10 - 0
src/Cameras/RigModes/stereoscopicRigMode.ts

@@ -0,0 +1,10 @@
+import { Camera } from "../camera";
+import { PassPostProcess } from "../../PostProcesses/passPostProcess";
+import { StereoscopicInterlacePostProcess } from "../../PostProcesses/stereoscopicInterlacePostProcess";
+
+Camera._setStereoscopicRigMode = function(camera: Camera) {
+    var isStereoscopicHoriz = camera.cameraRigMode === Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL || camera.cameraRigMode === Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED;
+
+    camera._rigCameras[0]._rigPostProcess = new PassPostProcess(camera.name + "_passthru", 1.0, camera._rigCameras[0]);
+    camera._rigCameras[1]._rigPostProcess = new StereoscopicInterlacePostProcess(camera.name + "_stereoInterlace", camera._rigCameras, isStereoscopicHoriz);
+};

+ 27 - 0
src/Cameras/RigModes/vrRigMode.ts

@@ -0,0 +1,27 @@
+import { Camera } from "../camera";
+import { Matrix, Viewport } from "../../Maths/math";
+import { VRDistortionCorrectionPostProcess } from "../../PostProcesses/vrDistortionCorrectionPostProcess";
+import { VRCameraMetrics } from "../VR/vrCameraMetrics";
+
+Camera._setVRRigMode = function(camera: Camera, rigParams: any) {
+    var metrics = rigParams.vrCameraMetrics || VRCameraMetrics.GetDefault();
+
+    camera._rigCameras[0]._cameraRigParams.vrMetrics = metrics;
+    camera._rigCameras[0].viewport = new Viewport(0, 0, 0.5, 1.0);
+    camera._rigCameras[0]._cameraRigParams.vrWorkMatrix = new Matrix();
+    camera._rigCameras[0]._cameraRigParams.vrHMatrix = metrics.leftHMatrix;
+    camera._rigCameras[0]._cameraRigParams.vrPreViewMatrix = metrics.leftPreViewMatrix;
+    camera._rigCameras[0].getProjectionMatrix = camera._rigCameras[0]._getVRProjectionMatrix;
+
+    camera._rigCameras[1]._cameraRigParams.vrMetrics = metrics;
+    camera._rigCameras[1].viewport = new Viewport(0.5, 0, 0.5, 1.0);
+    camera._rigCameras[1]._cameraRigParams.vrWorkMatrix = new Matrix();
+    camera._rigCameras[1]._cameraRigParams.vrHMatrix = metrics.rightHMatrix;
+    camera._rigCameras[1]._cameraRigParams.vrPreViewMatrix = metrics.rightPreViewMatrix;
+    camera._rigCameras[1].getProjectionMatrix = camera._rigCameras[1]._getVRProjectionMatrix;
+
+    if (metrics.compensateDistortion) {
+        camera._rigCameras[0]._rigPostProcess = new VRDistortionCorrectionPostProcess("VR_Distort_Compensation_Left", camera._rigCameras[0], false, metrics);
+        camera._rigCameras[1]._rigPostProcess = new VRDistortionCorrectionPostProcess("VR_Distort_Compensation_Right", camera._rigCameras[1], true, metrics);
+    }
+};

+ 38 - 0
src/Cameras/RigModes/webVRRigMode.ts

@@ -0,0 +1,38 @@
+import { Camera } from "../camera";
+import { Matrix, Viewport } from "../../Maths/math";
+
+Camera._setWebVRRigMode = function(camera: Camera, rigParams: any) {
+    if (rigParams.vrDisplay) {
+        var leftEye = rigParams.vrDisplay.getEyeParameters('left');
+        var rightEye = rigParams.vrDisplay.getEyeParameters('right');
+
+        //Left eye
+        camera._rigCameras[0].viewport = new Viewport(0, 0, 0.5, 1.0);
+        camera._rigCameras[0].setCameraRigParameter("left", true);
+        //leaving this for future reference
+        camera._rigCameras[0].setCameraRigParameter("specs", rigParams.specs);
+        camera._rigCameras[0].setCameraRigParameter("eyeParameters", leftEye);
+        camera._rigCameras[0].setCameraRigParameter("frameData", rigParams.frameData);
+        camera._rigCameras[0].setCameraRigParameter("parentCamera", rigParams.parentCamera);
+        camera._rigCameras[0]._cameraRigParams.vrWorkMatrix = new Matrix();
+        camera._rigCameras[0].getProjectionMatrix = camera._getWebVRProjectionMatrix;
+        camera._rigCameras[0].parent = camera;
+        camera._rigCameras[0]._getViewMatrix = camera._getWebVRViewMatrix;
+
+        //Right eye
+        camera._rigCameras[1].viewport = new Viewport(0.5, 0, 0.5, 1.0);
+        camera._rigCameras[1].setCameraRigParameter('eyeParameters', rightEye);
+        camera._rigCameras[1].setCameraRigParameter("specs", rigParams.specs);
+        camera._rigCameras[1].setCameraRigParameter("frameData", rigParams.frameData);
+        camera._rigCameras[1].setCameraRigParameter("parentCamera", rigParams.parentCamera);
+        camera._rigCameras[1]._cameraRigParams.vrWorkMatrix = new Matrix();
+        camera._rigCameras[1].getProjectionMatrix = camera._getWebVRProjectionMatrix;
+        camera._rigCameras[1].parent = camera;
+        camera._rigCameras[1]._getViewMatrix = camera._getWebVRViewMatrix;
+
+        if (Camera.UseAlternateWebVRRendering) {
+            camera._rigCameras[1]._skipRendering = true;
+            camera._rigCameras[0]._alternateCamera = camera._rigCameras[1];
+        }
+    }
+};

+ 3 - 0
src/Cameras/Stereoscopic/anaglyphArcRotateCamera.ts

@@ -4,6 +4,9 @@ import { Scene } from "../../scene";
 import { Vector3 } from "../../Maths/math";
 import { Node } from "../../node";
 
+// Side effect import to define the stereoscopic mode.
+import "../RigModes/stereoscopicAnaglyphRigMode";
+
 Node.AddNodeConstructor("AnaglyphArcRotateCamera", (name, scene, options) => {
     return () => new AnaglyphArcRotateCamera(name, 0, 0, 1.0, Vector3.Zero(), options.interaxial_distance, scene);
 });

+ 3 - 0
src/Cameras/Stereoscopic/anaglyphFreeCamera.ts

@@ -4,6 +4,9 @@ import { Scene } from "../../scene";
 import { Vector3 } from "../../Maths/math";
 import { Node } from "../../node";
 
+// Side effect import to define the stereoscopic mode.
+import "../RigModes/stereoscopicAnaglyphRigMode";
+
 Node.AddNodeConstructor("AnaglyphFreeCamera", (name, scene, options) => {
     return () => new AnaglyphFreeCamera(name, Vector3.Zero(), options.interaxial_distance, scene);
 });

+ 3 - 0
src/Cameras/Stereoscopic/anaglyphGamepadCamera.ts

@@ -4,6 +4,9 @@ import { Scene } from "../../scene";
 import { Vector3 } from "../../Maths/math";
 import { Node } from "../../node";
 
+// Side effect import to define the stereoscopic mode.
+import "../RigModes/stereoscopicAnaglyphRigMode";
+
 Node.AddNodeConstructor("AnaglyphGamepadCamera", (name, scene, options) => {
     return () => new AnaglyphGamepadCamera(name, Vector3.Zero(), options.interaxial_distance, scene);
 });

+ 3 - 0
src/Cameras/Stereoscopic/anaglyphUniversalCamera.ts

@@ -4,6 +4,9 @@ import { Scene } from "../../scene";
 import { Vector3 } from "../../Maths/math";
 import { Node } from "../../node";
 
+// Side effect import to define the stereoscopic mode.
+import "../RigModes/stereoscopicAnaglyphRigMode";
+
 Node.AddNodeConstructor("AnaglyphUniversalCamera", (name, scene, options) => {
     return () => new AnaglyphUniversalCamera(name, Vector3.Zero(), options.interaxial_distance, scene);
 });

+ 3 - 0
src/Cameras/Stereoscopic/stereoscopicArcRotateCamera.ts

@@ -4,6 +4,9 @@ import { Scene } from "../../scene";
 import { Vector3 } from "../../Maths/math";
 import { Node } from "../../node";
 
+// Side effect import to define the stereoscopic mode.
+import "../RigModes/stereoscopicRigMode";
+
 Node.AddNodeConstructor("StereoscopicArcRotateCamera", (name, scene, options) => {
     return () => new StereoscopicArcRotateCamera(name, 0, 0, 1.0, Vector3.Zero(), options.interaxial_distance, options.isStereoscopicSideBySide, scene);
 });

+ 3 - 0
src/Cameras/Stereoscopic/stereoscopicFreeCamera.ts

@@ -4,6 +4,9 @@ import { Scene } from "../../scene";
 import { Vector3 } from "../../Maths/math";
 import { Node } from "../../node";
 
+// Side effect import to define the stereoscopic mode.
+import "../RigModes/stereoscopicRigMode";
+
 Node.AddNodeConstructor("StereoscopicFreeCamera", (name, scene, options) => {
     return () => new StereoscopicFreeCamera(name, Vector3.Zero(), options.interaxial_distance, options.isStereoscopicSideBySide, scene);
 });

+ 3 - 0
src/Cameras/Stereoscopic/stereoscopicGamepadCamera.ts

@@ -4,6 +4,9 @@ import { Scene } from "../../scene";
 import { Vector3 } from "../../Maths/math";
 import { Node } from "../../node";
 
+// Side effect import to define the stereoscopic mode.
+import "../RigModes/stereoscopicRigMode";
+
 Node.AddNodeConstructor("StereoscopicGamepadCamera", (name, scene, options) => {
     return () => new StereoscopicGamepadCamera(name, Vector3.Zero(), options.interaxial_distance, options.isStereoscopicSideBySide, scene);
 });

+ 3 - 0
src/Cameras/Stereoscopic/stereoscopicUniversalCamera.ts

@@ -4,6 +4,9 @@ import { Scene } from "../../scene";
 import { Vector3 } from "../../Maths/math";
 import { Node } from "../../node";
 
+// Side effect import to define the stereoscopic mode.
+import "../RigModes/stereoscopicRigMode";
+
 Node.AddNodeConstructor("StereoscopicFreeCamera", (name, scene, options) => {
     return () => new StereoscopicUniversalCamera(name, Vector3.Zero(), options.interaxial_distance, options.isStereoscopicSideBySide, scene);
 });

+ 5 - 0
src/Cameras/VR/vrDeviceOrientationArcRotateCamera.ts

@@ -5,6 +5,11 @@ import { Scene } from "../../scene";
 import { Vector3 } from "../../Maths/math";
 import { Node } from "../../node";
 
+import "../Inputs/arcRotateCameraVRDeviceOrientationInput";
+
+// Side effect import to define the stereoscopic mode.
+import "../RigModes/vrRigMode";
+
 Node.AddNodeConstructor("VRDeviceOrientationFreeCamera", (name, scene) => {
     return () => new VRDeviceOrientationArcRotateCamera(name, 0, 0, 1.0, Vector3.Zero(), scene);
 });

+ 3 - 0
src/Cameras/VR/vrDeviceOrientationFreeCamera.ts

@@ -5,6 +5,9 @@ import { Scene } from "../../scene";
 import { Vector3 } from "../../Maths/math";
 import { Node } from "../../node";
 
+// Side effect import to define the stereoscopic mode.
+import "../RigModes/vrRigMode";
+
 Node.AddNodeConstructor("VRDeviceOrientationFreeCamera", (name, scene) => {
     return () => new VRDeviceOrientationFreeCamera(name, Vector3.Zero(), scene);
 });

+ 8 - 2
src/Cameras/VR/webVRCamera.ts

@@ -13,6 +13,10 @@ import { Node } from "../../node";
 import { AbstractMesh } from "../../Meshes/abstractMesh";
 import { Ray } from "../../Culling/ray";
 import { HemisphericLight } from "../../Lights/hemisphericLight";
+
+// Side effect import to define the stereoscopic mode.
+import "../RigModes/webVRRigMode";
+
 Node.AddNodeConstructor("WebVRFreeCamera", (name, scene) => {
     return () => new WebVRFreeCamera(name, Vector3.Zero(), scene);
 });
@@ -634,8 +638,9 @@ export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
     /**
      * This function is called by the two RIG cameras.
      * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
+     * @hidden
      */
-    protected _getWebVRViewMatrix(): Matrix {
+    public _getWebVRViewMatrix(): Matrix {
         // Update the parent camera prior to using a child camera to avoid desynchronization
         let parentCamera: WebVRFreeCamera = this._cameraRigParams["parentCamera"];
         parentCamera._updateCache();
@@ -684,7 +689,8 @@ export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
         return this._webvrViewMatrix;
     }
 
-    protected _getWebVRProjectionMatrix(): Matrix {
+    /** @hidden */
+    public _getWebVRProjectionMatrix(): Matrix {
 
         let parentCamera = <WebVRFreeCamera>this.parent;
 

+ 0 - 10
src/Cameras/arcRotateCameraInputsManager.ts

@@ -1,5 +1,4 @@
 import { ArcRotateCamera } from "./arcRotateCamera";
-import { ArcRotateCameraVRDeviceOrientationInput } from "../Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
 import { ArcRotateCameraPointersInput } from "../Cameras/Inputs/arcRotateCameraPointersInput";
 import { ArcRotateCameraKeyboardMoveInput } from "../Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
 import { ArcRotateCameraMouseWheelInput } from "../Cameras/Inputs/arcRotateCameraMouseWheelInput";
@@ -45,13 +44,4 @@ export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateC
         this.add(new ArcRotateCameraKeyboardMoveInput());
         return this;
     }
-
-    /**
-     * Add orientation input support to the input manager.
-     * @returns the current input manager
-     */
-    public addVRDeviceOrientation(): ArcRotateCameraInputsManager {
-        this.add(new ArcRotateCameraVRDeviceOrientationInput());
-        return this;
-    }
 }

+ 36 - 75
src/Cameras/camera.ts

@@ -11,16 +11,12 @@ import { Mesh } from "../Meshes/mesh";
 import { AbstractMesh } from "../Meshes/abstractMesh";
 import { Ray } from "../Culling/ray";
 import { ICullable } from "../Culling/boundingInfo";
-import { RenderTargetTexture } from "../Materials/Textures/renderTargetTexture";
-import { PostProcess } from "../PostProcesses/postProcess";
-import { PassPostProcess } from "../PostProcesses/passPostProcess";
-import { AnaglyphPostProcess } from "../PostProcesses/anaglyphPostProcess";
-import { StereoscopicInterlacePostProcess } from "../PostProcesses/stereoscopicInterlacePostProcess";
-import { VRDistortionCorrectionPostProcess } from "../PostProcesses/vrDistortionCorrectionPostProcess";
-import { Animation } from "../Animations/animation";
-import { VRCameraMetrics } from "../Cameras/VR/vrCameraMetrics";
 import { Logger } from "../Misc/logger";
 
+import { Animation } from "../Animations/animation";
+
+declare type PostProcess = import("../PostProcesses/postProcess").PostProcess;
+declare type RenderTargetTexture = import("../Materials/Textures/renderTargetTexture").RenderTargetTexture;
 declare type FreeCamera = import("./freeCamera").FreeCamera;
 declare type TargetCamera = import("./targetCamera").TargetCamera;
 
@@ -563,7 +559,7 @@ export class Camera extends Node {
 
             // for VR rig, there does not have to be a post process
             if (rigPostProcess) {
-                var isPass = rigPostProcess instanceof PassPostProcess;
+                var isPass = rigPostProcess.getEffectName() === "pass";
                 if (isPass) {
                     // any rig which has a PassPostProcess for rig[0], cannot be isIntermediate when there are also user postProcesses
                     cam.isIntermediate = this._postProcesses.length === 0;
@@ -629,7 +625,7 @@ export class Camera extends Node {
     }
 
     /** @hidden */
-    protected _getViewMatrix(): Matrix {
+    public _getViewMatrix(): Matrix {
         return Matrix.Identity();
     }
 
@@ -968,84 +964,47 @@ export class Camera extends Node {
 
         switch (this.cameraRigMode) {
             case Camera.RIG_MODE_STEREOSCOPIC_ANAGLYPH:
-                this._rigCameras[0]._rigPostProcess = new PassPostProcess(this.name + "_passthru", 1.0, this._rigCameras[0]);
-                this._rigCameras[1]._rigPostProcess = new AnaglyphPostProcess(this.name + "_anaglyph", 1.0, this._rigCameras);
+                Camera._setStereoscopicAnaglyphRigMode(this);
                 break;
-
             case Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:
             case Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:
             case Camera.RIG_MODE_STEREOSCOPIC_OVERUNDER:
-                var isStereoscopicHoriz = this.cameraRigMode === Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL || this.cameraRigMode === Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED;
-
-                this._rigCameras[0]._rigPostProcess = new PassPostProcess(this.name + "_passthru", 1.0, this._rigCameras[0]);
-                this._rigCameras[1]._rigPostProcess = new StereoscopicInterlacePostProcess(this.name + "_stereoInterlace", this._rigCameras, isStereoscopicHoriz);
+                Camera._setStereoscopicRigMode(this);
                 break;
-
             case Camera.RIG_MODE_VR:
-                var metrics = rigParams.vrCameraMetrics || VRCameraMetrics.GetDefault();
-
-                this._rigCameras[0]._cameraRigParams.vrMetrics = metrics;
-                this._rigCameras[0].viewport = new Viewport(0, 0, 0.5, 1.0);
-                this._rigCameras[0]._cameraRigParams.vrWorkMatrix = new Matrix();
-                this._rigCameras[0]._cameraRigParams.vrHMatrix = metrics.leftHMatrix;
-                this._rigCameras[0]._cameraRigParams.vrPreViewMatrix = metrics.leftPreViewMatrix;
-                this._rigCameras[0].getProjectionMatrix = this._rigCameras[0]._getVRProjectionMatrix;
-
-                this._rigCameras[1]._cameraRigParams.vrMetrics = metrics;
-                this._rigCameras[1].viewport = new Viewport(0.5, 0, 0.5, 1.0);
-                this._rigCameras[1]._cameraRigParams.vrWorkMatrix = new Matrix();
-                this._rigCameras[1]._cameraRigParams.vrHMatrix = metrics.rightHMatrix;
-                this._rigCameras[1]._cameraRigParams.vrPreViewMatrix = metrics.rightPreViewMatrix;
-                this._rigCameras[1].getProjectionMatrix = this._rigCameras[1]._getVRProjectionMatrix;
-
-                if (metrics.compensateDistortion) {
-                    this._rigCameras[0]._rigPostProcess = new VRDistortionCorrectionPostProcess("VR_Distort_Compensation_Left", this._rigCameras[0], false, metrics);
-                    this._rigCameras[1]._rigPostProcess = new VRDistortionCorrectionPostProcess("VR_Distort_Compensation_Right", this._rigCameras[1], true, metrics);
-                }
+                Camera._setVRRigMode(this, rigParams);
                 break;
             case Camera.RIG_MODE_WEBVR:
-                if (rigParams.vrDisplay) {
-                    var leftEye = rigParams.vrDisplay.getEyeParameters('left');
-                    var rightEye = rigParams.vrDisplay.getEyeParameters('right');
-
-                    //Left eye
-                    this._rigCameras[0].viewport = new Viewport(0, 0, 0.5, 1.0);
-                    this._rigCameras[0].setCameraRigParameter("left", true);
-                    //leaving this for future reference
-                    this._rigCameras[0].setCameraRigParameter("specs", rigParams.specs);
-                    this._rigCameras[0].setCameraRigParameter("eyeParameters", leftEye);
-                    this._rigCameras[0].setCameraRigParameter("frameData", rigParams.frameData);
-                    this._rigCameras[0].setCameraRigParameter("parentCamera", rigParams.parentCamera);
-                    this._rigCameras[0]._cameraRigParams.vrWorkMatrix = new Matrix();
-                    this._rigCameras[0].getProjectionMatrix = this._getWebVRProjectionMatrix;
-                    this._rigCameras[0].parent = this;
-                    this._rigCameras[0]._getViewMatrix = this._getWebVRViewMatrix;
-
-                    //Right eye
-                    this._rigCameras[1].viewport = new Viewport(0.5, 0, 0.5, 1.0);
-                    this._rigCameras[1].setCameraRigParameter('eyeParameters', rightEye);
-                    this._rigCameras[1].setCameraRigParameter("specs", rigParams.specs);
-                    this._rigCameras[1].setCameraRigParameter("frameData", rigParams.frameData);
-                    this._rigCameras[1].setCameraRigParameter("parentCamera", rigParams.parentCamera);
-                    this._rigCameras[1]._cameraRigParams.vrWorkMatrix = new Matrix();
-                    this._rigCameras[1].getProjectionMatrix = this._getWebVRProjectionMatrix;
-                    this._rigCameras[1].parent = this;
-                    this._rigCameras[1]._getViewMatrix = this._getWebVRViewMatrix;
-
-                    if (Camera.UseAlternateWebVRRendering) {
-                        this._rigCameras[1]._skipRendering = true;
-                        this._rigCameras[0]._alternateCamera = this._rigCameras[1];
-                    }
-                }
+                Camera._setWebVRRigMode(this, rigParams);
                 break;
-
         }
 
         this._cascadePostProcessesToRigCams();
         this.update();
     }
 
-    private _getVRProjectionMatrix(): Matrix {
+    /** @hidden */
+    public static _setStereoscopicRigMode(camera: Camera) {
+        throw "Import Cameras/RigModes/stereoscopicRigMode before using stereoscopic rig mode";
+    }
+
+    /** @hidden */
+    public static _setStereoscopicAnaglyphRigMode(camera: Camera) {
+        throw "Import Cameras/RigModes/stereoscopicAnaglyphRigMode before using stereoscopic anaglyph rig mode";
+    }
+
+    /** @hidden */
+    public static _setVRRigMode(camera: Camera, rigParams: any) {
+        throw "Import Cameras/RigModes/vrRigMode before using VR rig mode";
+    }
+
+    /** @hidden */
+    public static _setWebVRRigMode(camera: Camera, rigParams: any) {
+        throw "Import Cameras/RigModes/WebVRRigMode before using Web VR rig mode";
+    }
+
+    /** @hidden */
+    public _getVRProjectionMatrix(): Matrix {
         Matrix.PerspectiveFovLHToRef(this._cameraRigParams.vrMetrics.aspectRatioFov, this._cameraRigParams.vrMetrics.aspectRatio, this.minZ, this.maxZ, this._cameraRigParams.vrWorkMatrix);
         this._cameraRigParams.vrWorkMatrix.multiplyToRef(this._cameraRigParams.vrHMatrix, this._projectionMatrix);
         return this._projectionMatrix;
@@ -1062,16 +1021,18 @@ export class Camera extends Node {
     /**
      * This function MUST be overwritten by the different WebVR cameras available.
      * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
+     * @hidden
      */
-    protected _getWebVRProjectionMatrix(): Matrix {
+    public _getWebVRProjectionMatrix(): Matrix {
         return Matrix.Identity();
     }
 
     /**
      * This function MUST be overwritten by the different WebVR cameras available.
      * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
+     * @hidden
      */
-    protected _getWebVRViewMatrix(): Matrix {
+    public _getWebVRViewMatrix(): Matrix {
         return Matrix.Identity();
     }
 

+ 2 - 0
src/Cameras/deviceOrientationCamera.ts

@@ -3,6 +3,8 @@ import { Scene } from "../scene";
 import { Quaternion, Vector3, Axis } from "../Maths/math";
 import { Node } from "../node";
 
+import "./Inputs/freeCameraDeviceOrientationInput";
+
 Node.AddNodeConstructor("DeviceOrientationCamera", (name, scene) => {
     return () => new DeviceOrientationCamera(name, Vector3.Zero(), scene);
 });

+ 0 - 20
src/Cameras/freeCameraInputsManager.ts

@@ -2,9 +2,7 @@ import { FreeCamera } from "./freeCamera";
 import { CameraInputsManager } from "./cameraInputsManager";
 import { FreeCameraKeyboardMoveInput } from "../Cameras/Inputs/freeCameraKeyboardMoveInput";
 import { FreeCameraMouseInput } from "../Cameras/Inputs/freeCameraMouseInput";
-import { FreeCameraDeviceOrientationInput } from "../Cameras/Inputs/freeCameraDeviceOrientationInput";
 import { FreeCameraTouchInput } from "../Cameras/Inputs/freeCameraTouchInput";
-import { FreeCameraVirtualJoystickInput } from "../Cameras/Inputs/freeCameraVirtualJoystickInput";
 
 /**
  * Default Inputs manager for the FreeCamera.
@@ -40,15 +38,6 @@ export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
     }
 
     /**
-     * Add orientation input support to the input manager.
-     * @returns the current input manager
-     */
-    addDeviceOrientation(): FreeCameraInputsManager {
-        this.add(new FreeCameraDeviceOrientationInput());
-        return this;
-    }
-
-    /**
      * Add touch input support to the input manager.
      * @returns the current input manager
      */
@@ -56,13 +45,4 @@ export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
         this.add(new FreeCameraTouchInput());
         return this;
     }
-
-    /**
-     * Add virtual joystick input support to the input manager.
-     * @returns the current input manager
-     */
-    addVirtualJoystick(): FreeCameraInputsManager {
-        this.add(new FreeCameraVirtualJoystickInput());
-        return this;
-    }
 }

+ 2 - 1
src/Cameras/index.ts

@@ -16,4 +16,5 @@ export * from "./Stereoscopic/index";
 export * from "./universalCamera";
 export * from "./virtualJoysticksCamera";
 export * from "./VR/index";
-export * from "./XR/index";
+export * from "./XR/index";
+export * from "./RigModes/index";

+ 3 - 0
src/Cameras/virtualJoysticksCamera.ts

@@ -2,6 +2,9 @@ import { FreeCamera } from "./freeCamera";
 import { Scene } from "../scene";
 import { Vector3 } from "../Maths/math";
 import { Node } from "../node";
+
+import "./Inputs/freeCameraVirtualJoystickInput";
+
 Node.AddNodeConstructor("VirtualJoysticksCamera", (name, scene) => {
     return () => new VirtualJoysticksCamera(name, Vector3.Zero(), scene);
 });

+ 8 - 0
src/PostProcesses/postProcess.ts

@@ -144,6 +144,14 @@ export class PostProcess {
     private _texelSize = Vector2.Zero();
     private _forcedOutputTexture: InternalTexture;
 
+    /**
+     * Returns the fragment url or shader name used in the post process.
+     * @returns the fragment url or name in the shader store.
+     */
+    public getEffectName(): string {
+        return this._fragmentUrl;
+    }
+
     // Events
 
     /**