Browse Source

OculusCamera renamed to VRCamera

David Catuhe 10 years ago
parent
commit
2ec4b9fc4f
82 changed files with 1178 additions and 1594 deletions
  1. 2 1
      Babylon/Actions/babylon.actionManager.js
  2. 1 2
      Babylon/Actions/babylon.interpolateValueAction.js
  3. 17 0
      Babylon/Animations/babylon.animation.js
  4. 1 0
      Babylon/Audio/babylon.analyser.js
  5. 3 9
      Babylon/Audio/babylon.sound.js
  6. 0 144
      Babylon/Cameras/VR/babylon.oculusGamepadCamera.js
  7. 0 175
      Babylon/Cameras/VR/babylon.oculusGamepadCamera.ts
  8. 27 27
      Babylon/Cameras/VR/babylon.oculusCamera.js
  9. 14 14
      Babylon/Cameras/VR/babylon.oculusCamera.ts
  10. 1 1
      Babylon/Cameras/VR/babylon.vrDeviceOrientationCamera.js
  11. 1 1
      Babylon/Cameras/VR/babylon.vrDeviceOrientationCamera.ts
  12. 2 1
      Babylon/Cameras/VR/babylon.webVRCamera.js
  13. 1 1
      Babylon/Cameras/VR/babylon.webVRCamera.ts
  14. 14 3
      Babylon/Cameras/babylon.arcRotateCamera.js
  15. 15 4
      Babylon/Cameras/babylon.camera.js
  16. 9 2
      Babylon/Cameras/babylon.freeCamera.js
  17. 1 3
      Babylon/Cameras/babylon.gamepadCamera.js
  18. 2 1
      Babylon/Cameras/babylon.targetCamera.js
  19. 4 4
      Babylon/Cameras/babylon.virtualJoysticksCamera.js
  20. 14 19
      Babylon/Collisions/babylon.collisionCoordinator.js
  21. 10 9
      Babylon/Collisions/babylon.collisionWorker.js
  22. 1 0
      Babylon/Culling/Octrees/babylon.octree.js
  23. 1 0
      Babylon/Culling/babylon.boundingBox.js
  24. 69 88
      Babylon/Debug/babylon.debugLayer.js
  25. 1 1
      Babylon/Debug/babylon.debugLayer.js.map
  26. 1 0
      Babylon/LensFlare/babylon.lensFlareSystem.js
  27. 3 1
      Babylon/Lights/Shadows/babylon.shadowGenerator.js
  28. 1 0
      Babylon/Lights/babylon.directionalLight.js
  29. 11 14
      Babylon/Loading/Plugins/babylon.babylonFileLoader.js
  30. 0 6
      Babylon/Loading/Plugins/babylon.babylonFileLoader.ts
  31. 8 0
      Babylon/Materials/Textures/Procedurals/babylon.proceduralTexture.js
  32. 12 2
      Babylon/Materials/Textures/babylon.texture.js
  33. 8 0
      Babylon/Materials/babylon.shaderMaterial.js
  34. 18 2
      Babylon/Materials/babylon.standardMaterial.js
  35. 52 50
      Babylon/Math/babylon.math.js
  36. 6 2
      Babylon/Mesh/babylon.abstractMesh.js
  37. 1 0
      Babylon/Mesh/babylon.abstractMesh.ts
  38. 9 7
      Babylon/Mesh/babylon.csg.js
  39. 2 2
      Babylon/Mesh/babylon.geometry.js
  40. 1 0
      Babylon/Mesh/babylon.instancedMesh.js
  41. 17 14
      Babylon/Mesh/babylon.mesh.js
  42. 15 0
      Babylon/Mesh/babylon.mesh.vertexData.js
  43. 8 7
      Babylon/Mesh/babylon.meshSimplification.js
  44. 1 0
      Babylon/Mesh/babylon.subMesh.js
  45. 1 0
      Babylon/Mesh/babylon.vertexBuffer.js
  46. 2 0
      Babylon/Physics/Plugins/babylon.cannonJSPlugin.js
  47. 2 0
      Babylon/Physics/Plugins/babylon.oimoJSPlugin.js
  48. 2 6
      Babylon/PostProcess/RenderPipeline/babylon.postProcessRenderPipeline.js
  49. 20 66
      Babylon/PostProcess/babylon.lensRenderingPipeline.js
  50. 21 63
      Babylon/PostProcess/babylon.ssaoRenderingPipeline.js
  51. 1 0
      Babylon/PostProcess/babylon.volumetricLightScatteringPostProcess.js
  52. 7 7
      Babylon/PostProcess/babylon.oculusDistortionCorrectionPostProcess.js
  53. 2 2
      Babylon/PostProcess/babylon.oculusDistortionCorrectionPostProcess.ts
  54. 3 1
      Babylon/Rendering/babylon.boundingBoxRenderer.js
  55. 1 3
      Babylon/Rendering/babylon.outlineRenderer.js
  56. 1 0
      Babylon/Rendering/babylon.renderingGroup.js
  57. 0 0
      Babylon/Shaders/vrDistortionCorrection.fragment.fx
  58. 4 6
      Babylon/Tools/babylon.database.js
  59. 7 13
      Babylon/Tools/babylon.filesInput.js
  60. 20 24
      Babylon/Tools/babylon.gamepads.js
  61. 1 0
      Babylon/Tools/babylon.sceneOptimizer.js
  62. 0 6
      Babylon/Tools/babylon.sceneSerializer.js
  63. 0 4
      Babylon/Tools/babylon.sceneSerializer.ts
  64. 1 0
      Babylon/Tools/babylon.smartCollection.js
  65. 4 1
      Babylon/Tools/babylon.tools.dds.js
  66. 1 0
      Babylon/Tools/babylon.tools.js
  67. 3 0
      Babylon/Tools/babylon.tools.tga.js
  68. 18 22
      Babylon/Tools/babylon.virtualJoystick.js
  69. 19 9
      Babylon/babylon.engine.js
  70. 12 3
      Babylon/babylon.scene.js
  71. 0 1
      Exporters/3ds Max/Max2Babylon/Forms/ActionsBuilderForm.Designer.cs
  72. 12 3
      Exporters/3ds Max/Max2Babylon/Forms/ActionsBuilderForm.cs
  73. 30 32
      Exporters/3ds Max/Max2Babylon/Forms/CameraPropertiesForm.Designer.cs
  74. 1 4
      Exporters/Blender/io_export_babylon.py
  75. 2 3
      Tools/Gulp/config.json
  76. BIN
      Tools/Visual Studio Extensions/Babylon.VSIX
  77. 511 647
      babylon.2.1-beta.debug.js
  78. 25 23
      babylon.2.1-beta.js
  79. 25 23
      babylon.2.1-beta.noworker.js
  80. 30 2
      babylon.2.1.d.ts
  81. 2 3
      bower.json
  82. 2 0
      what's new - 2.1 - proposal.md

+ 2 - 1
Babylon/Actions/babylon.actionManager.js

@@ -242,7 +242,8 @@ var BABYLON;
             for (var index = 0; index < this.actions.length; index++) {
                 var action = this.actions[index];
                 if (action.trigger === trigger) {
-                    if (trigger === ActionManager.OnKeyUpTrigger || trigger === ActionManager.OnKeyDownTrigger) {
+                    if (trigger === ActionManager.OnKeyUpTrigger
+                        || trigger === ActionManager.OnKeyDownTrigger) {
                         var parameter = action.getTriggerParameter();
                         if (parameter) {
                             var unicode = evt.sourceEvent.charCode ? evt.sourceEvent.charCode : evt.sourceEvent.keyCode;

+ 1 - 2
Babylon/Actions/babylon.interpolateValueAction.js

@@ -27,8 +27,7 @@ var BABYLON;
                 {
                     frame: 0,
                     value: this._target[this._property]
-                },
-                {
+                }, {
                     frame: 100,
                     value: this.value
                 }

+ 17 - 0
Babylon/Animations/babylon.animation.js

@@ -124,6 +124,7 @@ var BABYLON;
                         gradient = this._easingFunction.ease(gradient);
                     }
                     switch (this.dataType) {
+                        // Float
                         case Animation.ANIMATIONTYPE_FLOAT:
                             switch (loopMode) {
                                 case Animation.ANIMATIONLOOPMODE_CYCLE:
@@ -133,6 +134,7 @@ var BABYLON;
                                     return offsetValue * repeatCount + this.floatInterpolateFunction(startValue, endValue, gradient);
                             }
                             break;
+                        // Quaternion
                         case Animation.ANIMATIONTYPE_QUATERNION:
                             var quaternion = null;
                             switch (loopMode) {
@@ -145,6 +147,7 @@ var BABYLON;
                                     break;
                             }
                             return quaternion;
+                        // Vector3
                         case Animation.ANIMATIONTYPE_VECTOR3:
                             switch (loopMode) {
                                 case Animation.ANIMATIONLOOPMODE_CYCLE:
@@ -153,6 +156,7 @@ var BABYLON;
                                 case Animation.ANIMATIONLOOPMODE_RELATIVE:
                                     return this.vector3InterpolateFunction(startValue, endValue, gradient).add(offsetValue.scale(repeatCount));
                             }
+                        // Vector2
                         case Animation.ANIMATIONTYPE_VECTOR2:
                             switch (loopMode) {
                                 case Animation.ANIMATIONLOOPMODE_CYCLE:
@@ -161,6 +165,7 @@ var BABYLON;
                                 case Animation.ANIMATIONLOOPMODE_RELATIVE:
                                     return this.vector2InterpolateFunction(startValue, endValue, gradient).add(offsetValue.scale(repeatCount));
                             }
+                        // Color3
                         case Animation.ANIMATIONTYPE_COLOR3:
                             switch (loopMode) {
                                 case Animation.ANIMATIONLOOPMODE_CYCLE:
@@ -169,10 +174,12 @@ var BABYLON;
                                 case Animation.ANIMATIONLOOPMODE_RELATIVE:
                                     return this.color3InterpolateFunction(startValue, endValue, gradient).add(offsetValue.scale(repeatCount));
                             }
+                        // Matrix
                         case Animation.ANIMATIONTYPE_MATRIX:
                             switch (loopMode) {
                                 case Animation.ANIMATIONLOOPMODE_CYCLE:
                                 case Animation.ANIMATIONLOOPMODE_CONSTANT:
+                                // return this.matrixInterpolateFunction(startValue, endValue, gradient);
                                 case Animation.ANIMATIONLOOPMODE_RELATIVE:
                                     return startValue;
                             }
@@ -220,16 +227,21 @@ var BABYLON;
                         var fromValue = this._interpolate(from, 0, Animation.ANIMATIONLOOPMODE_CYCLE);
                         var toValue = this._interpolate(to, 0, Animation.ANIMATIONLOOPMODE_CYCLE);
                         switch (this.dataType) {
+                            // Float
                             case Animation.ANIMATIONTYPE_FLOAT:
                                 this._offsetsCache[keyOffset] = toValue - fromValue;
                                 break;
+                            // Quaternion
                             case Animation.ANIMATIONTYPE_QUATERNION:
                                 this._offsetsCache[keyOffset] = toValue.subtract(fromValue);
                                 break;
+                            // Vector3
                             case Animation.ANIMATIONTYPE_VECTOR3:
                                 this._offsetsCache[keyOffset] = toValue.subtract(fromValue);
+                            // Vector2
                             case Animation.ANIMATIONTYPE_VECTOR2:
                                 this._offsetsCache[keyOffset] = toValue.subtract(fromValue);
+                            // Color3
                             case Animation.ANIMATIONTYPE_COLOR3:
                                 this._offsetsCache[keyOffset] = toValue.subtract(fromValue);
                             default:
@@ -243,18 +255,23 @@ var BABYLON;
             }
             if (offsetValue === undefined) {
                 switch (this.dataType) {
+                    // Float
                     case Animation.ANIMATIONTYPE_FLOAT:
                         offsetValue = 0;
                         break;
+                    // Quaternion
                     case Animation.ANIMATIONTYPE_QUATERNION:
                         offsetValue = new BABYLON.Quaternion(0, 0, 0, 0);
                         break;
+                    // Vector3
                     case Animation.ANIMATIONTYPE_VECTOR3:
                         offsetValue = BABYLON.Vector3.Zero();
                         break;
+                    // Vector2
                     case Animation.ANIMATIONTYPE_VECTOR2:
                         offsetValue = BABYLON.Vector2.Zero();
                         break;
+                    // Color3
                     case Animation.ANIMATIONTYPE_COLOR3:
                         offsetValue = BABYLON.Color3.Black();
                 }

+ 1 - 0
Babylon/Audio/babylon.analyser.js

@@ -71,6 +71,7 @@ var BABYLON;
                     var workingArray = this.getByteFrequencyData();
                     this._debugCanvasContext.fillStyle = 'rgb(0, 0, 0)';
                     this._debugCanvasContext.fillRect(0, 0, this.DEBUGCANVASSIZE.width, this.DEBUGCANVASSIZE.height);
+                    // Draw the frequency domain chart.
                     for (var i = 0; i < this.getFrequencyBinCount(); i++) {
                         var value = workingArray[i];
                         var percent = value / this.BARGRAPHAMPLITUDE;

+ 3 - 9
Babylon/Audio/babylon.sound.js

@@ -75,9 +75,7 @@ var BABYLON;
                 if (urlOrArrayBuffer) {
                     // If it's an URL
                     if (typeof (urlOrArrayBuffer) === "string") {
-                        BABYLON.Tools.LoadFile(urlOrArrayBuffer, function (data) {
-                            _this._soundLoaded(data);
-                        }, null, null, true);
+                        BABYLON.Tools.LoadFile(urlOrArrayBuffer, function (data) { _this._soundLoaded(data); }, null, null, true);
                     }
                     else {
                         if (urlOrArrayBuffer instanceof ArrayBuffer) {
@@ -147,9 +145,7 @@ var BABYLON;
                 if (_this._readyToPlayCallback) {
                     _this._readyToPlayCallback();
                 }
-            }, function (error) {
-                BABYLON.Tools.Error("Error while decoding audio data: " + error.err);
-            });
+            }, function (error) { BABYLON.Tools.Error("Error while decoding audio data: " + error.err); });
         };
         Sound.prototype.setAudioBuffer = function (audioBuffer) {
             if (BABYLON.Engine.audioEngine.canUseWebAudio) {
@@ -290,9 +286,7 @@ var BABYLON;
                     this._soundSource.loop = this.loop;
                     this._soundSource.playbackRate.value = this._playbackRate;
                     this._startTime = startTime;
-                    this._soundSource.onended = function () {
-                        _this._onended();
-                    };
+                    this._soundSource.onended = function () { _this._onended(); };
                     this._soundSource.start(this._startTime, this.isPaused ? this._startOffset % this._soundSource.buffer.duration : 0);
                     this.isPlaying = true;
                     this.isPaused = false;

+ 0 - 144
Babylon/Cameras/VR/babylon.oculusGamepadCamera.js

@@ -1,144 +0,0 @@
-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 _OculusInnerGamepadCamera = (function (_super) {
-        __extends(_OculusInnerGamepadCamera, _super);
-        function _OculusInnerGamepadCamera(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);
-        }
-        _OculusInnerGamepadCamera.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;
-        };
-        _OculusInnerGamepadCamera.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 _OculusInnerGamepadCamera;
-    })(BABYLON.FreeCamera);
-    var OculusGamepadCamera = (function (_super) {
-        __extends(OculusGamepadCamera, _super);
-        function OculusGamepadCamera(name, position, scene) {
-            var _this = this;
-            _super.call(this, name, position, scene);
-            this.angularSensibility = 200;
-            this.moveSensibility = 75;
-            this._leftCamera = new _OculusInnerGamepadCamera(name + "_left", position.clone(), scene, true);
-            this._rightCamera = new _OculusInnerGamepadCamera(name + "_right", position.clone(), scene, false);
-            this.subCameras.push(this._leftCamera);
-            this.subCameras.push(this._rightCamera);
-            this._deviceOrientationHandler = this._onOrientationEvent.bind(this);
-            this._gamepads = new BABYLON.Gamepads(function (gamepad) {
-                _this._onNewGameConnected(gamepad);
-            });
-        }
-        OculusGamepadCamera.prototype._onNewGameConnected = function (gamepad) {
-            // Only the first gamepad can control the camera
-            if (gamepad.index === 0) {
-                this._gamepad = gamepad;
-            }
-        };
-        OculusGamepadCamera.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);
-        };
-        OculusGamepadCamera.prototype._checkInputs = function () {
-            if (!this._gamepad) {
-                return;
-            }
-            var LSValues = this._gamepad.leftStick;
-            var normalizedLX = LSValues.x / this.moveSensibility;
-            var normalizedLY = LSValues.y / this.moveSensibility;
-            LSValues.x = Math.abs(normalizedLX) > 0.005 ? 0 + normalizedLX : 0;
-            LSValues.y = Math.abs(normalizedLY) > 0.005 ? 0 + normalizedLY : 0;
-            var cameraTransform = BABYLON.Matrix.RotationYawPitchRoll(this.rotation.y, this.rotation.x, 0);
-            var deltaTransform = BABYLON.Vector3.TransformCoordinates(new BABYLON.Vector3(LSValues.x, 0, -LSValues.y), cameraTransform);
-            this.cameraDirection = this.cameraDirection.add(deltaTransform);
-        };
-        OculusGamepadCamera.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
-        OculusGamepadCamera.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;
-            }
-        };
-        OculusGamepadCamera.prototype.attachControl = function (element, noPreventDefault) {
-            _super.prototype.attachControl.call(this, element, noPreventDefault);
-            window.addEventListener("deviceorientation", this._deviceOrientationHandler);
-        };
-        OculusGamepadCamera.prototype.detachControl = function (element) {
-            _super.prototype.detachControl.call(this, element);
-            window.removeEventListener("deviceorientation", this._deviceOrientationHandler);
-        };
-        OculusGamepadCamera.prototype.dispose = function () {
-            this._gamepads.dispose();
-            _super.prototype.dispose.call(this);
-        };
-        return OculusGamepadCamera;
-    })(BABYLON.FreeCamera);
-    BABYLON.OculusGamepadCamera = OculusGamepadCamera;
-})(BABYLON || (BABYLON = {}));
-//# sourceMappingURL=babylon.oculusGamepadCamera.js.map

+ 0 - 175
Babylon/Cameras/VR/babylon.oculusGamepadCamera.ts

@@ -1,175 +0,0 @@
-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 _OculusInnerGamepadCamera 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 OculusGamepadCamera extends FreeCamera {
-        private _leftCamera: _OculusInnerGamepadCamera;
-        private _rightCamera: _OculusInnerGamepadCamera;
-        private _offsetOrientation: { yaw: number; pitch: number; roll: number };
-        private _deviceOrientationHandler;
-        private _gamepad: BABYLON.Gamepad;
-        private _gamepads: BABYLON.Gamepads;
-        public angularSensibility = 200;
-        public moveSensibility = 75;
-
-        constructor(name: string, position: Vector3, scene: Scene) {
-            super(name, position, scene);
-
-            this._leftCamera = new _OculusInnerGamepadCamera(name + "_left", position.clone(), scene, true);
-            this._rightCamera = new _OculusInnerGamepadCamera(name + "_right", position.clone(), scene, false);
-
-            this.subCameras.push(this._leftCamera);
-            this.subCameras.push(this._rightCamera);
-
-            this._deviceOrientationHandler = this._onOrientationEvent.bind(this);
-            this._gamepads = new BABYLON.Gamepads((gamepad: BABYLON.Gamepad) => { this._onNewGameConnected(gamepad); });
-        }
-
-        private _onNewGameConnected(gamepad: BABYLON.Gamepad) {
-            // Only the first gamepad can control the camera
-            if (gamepad.index === 0) {
-                this._gamepad = gamepad;
-            }
-        }
-
-        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 _checkInputs(): void {
-            if (!this._gamepad) {
-                return;
-            }
-
-            var LSValues = this._gamepad.leftStick;
-            var normalizedLX = LSValues.x / this.moveSensibility;
-            var normalizedLY = LSValues.y / this.moveSensibility;
-            LSValues.x = Math.abs(normalizedLX) > 0.005 ? 0 + normalizedLX : 0;
-            LSValues.y = Math.abs(normalizedLY) > 0.005 ? 0 + normalizedLY : 0;
-
-            var cameraTransform = BABYLON.Matrix.RotationYawPitchRoll(this.rotation.y, this.rotation.x, 0);
-            var deltaTransform = BABYLON.Vector3.TransformCoordinates(new BABYLON.Vector3(LSValues.x, 0, -LSValues.y), cameraTransform);
-            this.cameraDirection = this.cameraDirection.add(deltaTransform);
-        }
-
-        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
-        public _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);
-        }
-
-        public dispose(): void {
-            this._gamepads.dispose();
-            super.dispose();
-        }
-    }
-} 

+ 27 - 27
Babylon/Cameras/VR/babylon.oculusCamera.js

@@ -6,7 +6,7 @@ var __extends = this.__extends || function (d, b) {
 };
 var BABYLON;
 (function (BABYLON) {
-    var OculusRiftDevKit2013_Metric = {
+    var DefaultVRConstants = {
         HResolution: 1280,
         VResolution: 800,
         HScreenSize: 0.149759993,
@@ -20,29 +20,29 @@ var BABYLON;
         PostProcessScaleFactor: 1.714605507808412,
         LensCenterOffset: 0.151976421
     };
-    var _OculusInnerCamera = (function (_super) {
-        __extends(_OculusInnerCamera, _super);
-        function _OculusInnerCamera(name, position, scene, isLeftEye) {
+    var _VRInnerCamera = (function (_super) {
+        __extends(_VRInnerCamera, _super);
+        function _VRInnerCamera(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._aspectRatioAspectRatio = DefaultVRConstants.HResolution / (2 * DefaultVRConstants.VResolution);
+            this._aspectRatioFov = (2 * Math.atan((DefaultVRConstants.PostProcessScaleFactor * DefaultVRConstants.VScreenSize) / (2 * DefaultVRConstants.EyeToScreenDistance)));
+            var hMeters = (DefaultVRConstants.HScreenSize / 4) - (DefaultVRConstants.LensSeparationDistance / 2);
+            var h = (4 * hMeters) / DefaultVRConstants.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);
+            this._preViewMatrix = BABYLON.Matrix.Translation(isLeftEye ? .5 * DefaultVRConstants.InterpupillaryDistance : -.5 * DefaultVRConstants.InterpupillaryDistance, 0, 0);
             // Postprocess
-            var postProcess = new BABYLON.OculusDistortionCorrectionPostProcess("Oculus Distortion", this, !isLeftEye, OculusRiftDevKit2013_Metric);
+            var postProcess = new BABYLON.VRDistortionCorrectionPostProcess("VR Distortion", this, !isLeftEye, DefaultVRConstants);
         }
-        _OculusInnerCamera.prototype.getProjectionMatrix = function () {
+        _VRInnerCamera.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 () {
+        _VRInnerCamera.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);
@@ -52,34 +52,34 @@ var BABYLON;
             this._workMatrix.multiplyToRef(this._preViewMatrix, this._viewMatrix);
             return this._viewMatrix;
         };
-        return _OculusInnerCamera;
+        return _VRInnerCamera;
     })(BABYLON.FreeCamera);
-    var OculusCamera = (function (_super) {
-        __extends(OculusCamera, _super);
-        function OculusCamera(name, position, scene) {
+    var VRCamera = (function (_super) {
+        __extends(VRCamera, _super);
+        function VRCamera(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._leftCamera = new _VRInnerCamera(name + "_left", position.clone(), scene, true);
+            this._rightCamera = new _VRInnerCamera(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 () {
+        VRCamera.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) {
+        VRCamera.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) {
+        // Orientation events
+        VRCamera.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;
@@ -100,16 +100,16 @@ var BABYLON;
                 this._offsetOrientation.roll = roll;
             }
         };
-        OculusCamera.prototype.attachControl = function (element, noPreventDefault) {
+        VRCamera.prototype.attachControl = function (element, noPreventDefault) {
             _super.prototype.attachControl.call(this, element, noPreventDefault);
             window.addEventListener("deviceorientation", this._deviceOrientationHandler);
         };
-        OculusCamera.prototype.detachControl = function (element) {
+        VRCamera.prototype.detachControl = function (element) {
             _super.prototype.detachControl.call(this, element);
             window.removeEventListener("deviceorientation", this._deviceOrientationHandler);
         };
-        return OculusCamera;
+        return VRCamera;
     })(BABYLON.FreeCamera);
-    BABYLON.OculusCamera = OculusCamera;
+    BABYLON.VRCamera = VRCamera;
 })(BABYLON || (BABYLON = {}));
-//# sourceMappingURL=babylon.oculusCamera.js.map
+//# sourceMappingURL=babylon.vrCamera.js.map

+ 14 - 14
Babylon/Cameras/VR/babylon.oculusCamera.ts

@@ -1,6 +1,6 @@
 module BABYLON {
 
-    var OculusRiftDevKit2013_Metric = {
+    var DefaultVRConstants = {
         HResolution: 1280,
         VResolution: 800,
         HScreenSize: 0.149759993,
@@ -15,7 +15,7 @@
         LensCenterOffset: 0.151976421
     };
 
-    class _OculusInnerCamera extends FreeCamera {
+    class _VRInnerCamera extends FreeCamera {
         private _aspectRatioAspectRatio: number;
         private _aspectRatioFov: number;
         private _hMatrix: Matrix;
@@ -27,20 +27,20 @@
             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)));
+            this._aspectRatioAspectRatio = DefaultVRConstants.HResolution / (2 * DefaultVRConstants.VResolution);
+            this._aspectRatioFov = (2 * Math.atan((DefaultVRConstants.PostProcessScaleFactor * DefaultVRConstants.VScreenSize) / (2 * DefaultVRConstants.EyeToScreenDistance)));
 
-            var hMeters = (OculusRiftDevKit2013_Metric.HScreenSize / 4) - (OculusRiftDevKit2013_Metric.LensSeparationDistance / 2);
-            var h = (4 * hMeters) / OculusRiftDevKit2013_Metric.HScreenSize;
+            var hMeters = (DefaultVRConstants.HScreenSize / 4) - (DefaultVRConstants.LensSeparationDistance / 2);
+            var h = (4 * hMeters) / DefaultVRConstants.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);
+            this._preViewMatrix = BABYLON.Matrix.Translation(isLeftEye ? .5 * DefaultVRConstants.InterpupillaryDistance : -.5 * DefaultVRConstants.InterpupillaryDistance, 0, 0);
 
             // Postprocess
-            var postProcess = new BABYLON.OculusDistortionCorrectionPostProcess("Oculus Distortion", this, !isLeftEye, OculusRiftDevKit2013_Metric);
+            var postProcess = new BABYLON.VRDistortionCorrectionPostProcess("VR Distortion", this, !isLeftEye, DefaultVRConstants);
         }
 
         public getProjectionMatrix(): Matrix {
@@ -65,17 +65,17 @@
         }
     }
 
-    export class OculusCamera extends FreeCamera {
-        private _leftCamera: _OculusInnerCamera;
-        private _rightCamera: _OculusInnerCamera;
+    export class VRCamera extends FreeCamera {
+        private _leftCamera: _VRInnerCamera;
+        private _rightCamera: _VRInnerCamera;
         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._leftCamera = new _VRInnerCamera(name + "_left", position.clone(), scene, true);
+            this._rightCamera = new _VRInnerCamera(name + "_right", position.clone(), scene, false);
 
             this.subCameras.push(this._leftCamera);
             this.subCameras.push(this._rightCamera);
@@ -102,7 +102,7 @@
             camera.rotation.z = this.rotation.z;
         }
 
-        // Oculus events
+        // Orientation events
         public _onOrientationEvent(evt: DeviceOrientationEvent): void {
             var yaw = evt.alpha / 180 * Math.PI;
             var pitch = evt.beta / 180 * Math.PI;

+ 1 - 1
Babylon/Cameras/VR/babylon.vrDeviceOrientationCamera.js

@@ -30,7 +30,7 @@ var BABYLON;
             this.rotation.z = this._beta / 180.0 * Math.PI;
         };
         return VRDeviceOrientationCamera;
-    })(BABYLON.OculusCamera);
+    })(BABYLON.VRCamera);
     BABYLON.VRDeviceOrientationCamera = VRDeviceOrientationCamera;
 })(BABYLON || (BABYLON = {}));
 //# sourceMappingURL=babylon.vrDeviceOrientationCamera.js.map

+ 1 - 1
Babylon/Cameras/VR/babylon.vrDeviceOrientationCamera.ts

@@ -1,5 +1,5 @@
 module BABYLON {
-	export class VRDeviceOrientationCamera extends BABYLON.OculusCamera {
+    export class VRDeviceOrientationCamera extends BABYLON.VRCamera {
 		public _alpha = 0;
 		public _beta = 0;
 		public _gamma = 0;

+ 2 - 1
Babylon/Cameras/VR/babylon.webVRCamera.js

@@ -24,6 +24,7 @@ var BABYLON;
             // Reset devices.
             this._sensorDevice = null;
             this._hmdDevice = null;
+            // Search for a HmdDevice.
             while (i < size && this._hmdDevice === null) {
                 if (devices[i] instanceof HMDVRDevice) {
                     this._hmdDevice = devices[i];
@@ -64,7 +65,7 @@ var BABYLON;
             this._vrEnabled = false;
         };
         return WebVRCamera;
-    })(BABYLON.OculusCamera);
+    })(BABYLON.VRCamera);
     BABYLON.WebVRCamera = WebVRCamera;
 })(BABYLON || (BABYLON = {}));
 //# sourceMappingURL=babylon.webVRCamera.js.map

+ 1 - 1
Babylon/Cameras/VR/babylon.webVRCamera.ts

@@ -2,7 +2,7 @@ declare var HMDVRDevice;
 declare var PositionSensorVRDevice;
 
 module BABYLON {
-    export class WebVRCamera extends BABYLON.OculusCamera {
+    export class WebVRCamera extends BABYLON.VRCamera {
         public _hmdDevice = null;
         public _sensorDevice = null;
         public _cacheState = null;

+ 14 - 3
Babylon/Cameras/babylon.arcRotateCamera.js

@@ -89,7 +89,11 @@ var BABYLON;
         ArcRotateCamera.prototype._isSynchronizedViewMatrix = function () {
             if (!_super.prototype._isSynchronizedViewMatrix.call(this))
                 return false;
-            return this._cache.target.equals(this._getTargetPosition()) && this._cache.alpha === this.alpha && this._cache.beta === this.beta && this._cache.radius === this.radius && this._cache.targetScreenOffset.equals(this.targetScreenOffset);
+            return this._cache.target.equals(this._getTargetPosition())
+                && this._cache.alpha === this.alpha
+                && this._cache.beta === this.beta
+                && this._cache.radius === this.radius
+                && this._cache.targetScreenOffset.equals(this.targetScreenOffset);
         };
         // Methods
         ArcRotateCamera.prototype.attachControl = function (element, noPreventDefault) {
@@ -188,7 +192,10 @@ var BABYLON;
                     }
                 };
                 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) {
+                    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);
@@ -201,7 +208,10 @@ var BABYLON;
                     }
                 };
                 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) {
+                    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);
@@ -292,6 +302,7 @@ var BABYLON;
             if (this._collisionTriggered) {
                 return;
             }
+            // Keyboard
             for (var index = 0; index < this._keys.length; index++) {
                 var keyCode = this._keys[index];
                 if (this.keysLeft.indexOf(keyCode) !== -1) {

+ 15 - 4
Babylon/Cameras/babylon.camera.js

@@ -126,19 +126,29 @@ var BABYLON;
         Camera.prototype._isSynchronizedViewMatrix = function () {
             if (!_super.prototype._isSynchronized.call(this))
                 return false;
-            return this._cache.position.equals(this.position) && this._cache.upVector.equals(this.upVector) && this.isSynchronizedWithParent();
+            return this._cache.position.equals(this.position)
+                && this._cache.upVector.equals(this.upVector)
+                && this.isSynchronizedWithParent();
         };
         Camera.prototype._isSynchronizedProjectionMatrix = function () {
-            var check = this._cache.mode === this.mode && this._cache.minZ === this.minZ && this._cache.maxZ === this.maxZ;
+            var check = this._cache.mode === this.mode
+                && this._cache.minZ === this.minZ
+                && this._cache.maxZ === this.maxZ;
             if (!check) {
                 return false;
             }
             var engine = this.getEngine();
             if (this.mode === Camera.PERSPECTIVE_CAMERA) {
-                check = this._cache.fov === this.fov && this._cache.aspectRatio === engine.getAspectRatio(this);
+                check = this._cache.fov === this.fov
+                    && this._cache.aspectRatio === engine.getAspectRatio(this);
             }
             else {
-                check = this._cache.orthoLeft === this.orthoLeft && this._cache.orthoRight === this.orthoRight && this._cache.orthoBottom === this.orthoBottom && this._cache.orthoTop === this.orthoTop && this._cache.renderWidth === engine.getRenderWidth() && this._cache.renderHeight === engine.getRenderHeight();
+                check = this._cache.orthoLeft === this.orthoLeft
+                    && this._cache.orthoRight === this.orthoRight
+                    && this._cache.orthoBottom === this.orthoBottom
+                    && this._cache.orthoTop === this.orthoTop
+                    && this._cache.renderWidth === engine.getRenderWidth()
+                    && this._cache.renderHeight === engine.getRenderHeight();
             }
             return check;
         };
@@ -275,6 +285,7 @@ var BABYLON;
         Camera.prototype.dispose = function () {
             // Remove from scene
             this.getScene().removeCamera(this);
+            // Postprocesses
             for (var i = 0; i < this._postProcessesTakenIndices.length; ++i) {
                 this._postProcesses[this._postProcessesTakenIndices[i]].dispose(this);
             }

+ 9 - 2
Babylon/Cameras/babylon.freeCamera.js

@@ -101,7 +101,10 @@ var BABYLON;
                     }
                 };
                 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) {
+                    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);
@@ -112,7 +115,10 @@ var BABYLON;
                     }
                 };
                 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) {
+                    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);
@@ -181,6 +187,7 @@ var BABYLON;
                 this._localDirection = BABYLON.Vector3.Zero();
                 this._transformedDirection = BABYLON.Vector3.Zero();
             }
+            // Keyboard
             for (var index = 0; index < this._keys.length; index++) {
                 var keyCode = this._keys[index];
                 var speed = this._computeLocalCameraSpeed();

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

@@ -14,9 +14,7 @@ var BABYLON;
             _super.call(this, name, position, scene);
             this.angularSensibility = 200;
             this.moveSensibility = 75;
-            this._gamepads = new BABYLON.Gamepads(function (gamepad) {
-                _this._onNewGameConnected(gamepad);
-            });
+            this._gamepads = new BABYLON.Gamepads(function (gamepad) { _this._onNewGameConnected(gamepad); });
         }
         GamepadCamera.prototype._onNewGameConnected = function (gamepad) {
             // Only the first gamepad can control the camera

+ 2 - 1
Babylon/Cameras/babylon.targetCamera.js

@@ -62,7 +62,8 @@ var BABYLON;
                 return false;
             }
             var lockedTargetPosition = this._getLockedTargetPosition();
-            return (this._cache.lockedTarget ? this._cache.lockedTarget.equals(lockedTargetPosition) : !lockedTargetPosition) && this._cache.rotation.equals(this.rotation);
+            return (this._cache.lockedTarget ? this._cache.lockedTarget.equals(lockedTargetPosition) : !lockedTargetPosition)
+                && this._cache.rotation.equals(this.rotation);
         };
         // Methods
         TargetCamera.prototype._computeLocalCameraSpeed = function () {

+ 4 - 4
Babylon/Cameras/babylon.virtualJoysticksCamera.js

@@ -12,12 +12,12 @@ var BABYLON;
         function VirtualJoysticksCamera(name, position, scene) {
             _super.call(this, name, position, scene);
             this._leftjoystick = new BABYLON.VirtualJoystick(true);
-            this._leftjoystick.setAxisForUpDown(2 /* Z */);
-            this._leftjoystick.setAxisForLeftRight(0 /* X */);
+            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(0 /* X */);
-            this._rightjoystick.setAxisForLeftRight(1 /* Y */);
+            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");

+ 14 - 19
Babylon/Collisions/babylon.collisionCoordinator.js

@@ -44,7 +44,7 @@ var BABYLON;
                 };
                 var message = {
                     payload: payload,
-                    taskType: 1 /* UPDATE */
+                    taskType: WorkerTaskType.UPDATE
                 };
                 var serializable = [];
                 for (var id in payload.updatedGeometries) {
@@ -63,13 +63,13 @@ var BABYLON;
             };
             this._onMessageFromWorker = function (e) {
                 var returnData = e.data;
-                if (returnData.error != 0 /* SUCCESS */) {
+                if (returnData.error != WorkerReplyType.SUCCESS) {
                     //TODO what errors can be returned from the worker?
                     BABYLON.Tools.Warn("error returned from worker!");
                     return;
                 }
                 switch (returnData.taskType) {
-                    case 0 /* INIT */:
+                    case WorkerTaskType.INIT:
                         _this._init = true;
                         //Update the worked with ALL of the scene's current state
                         _this._scene.meshes.forEach(function (mesh) {
@@ -79,10 +79,10 @@ var BABYLON;
                             _this.onGeometryAdded(geometry);
                         });
                         break;
-                    case 1 /* UPDATE */:
+                    case WorkerTaskType.UPDATE:
                         _this._runningUpdated--;
                         break;
-                    case 2 /* COLLIDE */:
+                    case WorkerTaskType.COLLIDE:
                         _this._runningCollisionTask = false;
                         var returnPayload = returnData.payload;
                         if (!_this._collisionsCallbackArray[returnPayload.collisionId])
@@ -122,7 +122,7 @@ var BABYLON;
             };
             var message = {
                 payload: payload,
-                taskType: 2 /* COLLIDE */
+                taskType: WorkerTaskType.COLLIDE
             };
             this._worker.postMessage(message);
         };
@@ -134,7 +134,7 @@ var BABYLON;
             this._worker.onmessage = this._onMessageFromWorker;
             var message = {
                 payload: {},
-                taskType: 0 /* INIT */
+                taskType: WorkerTaskType.INIT
             };
             this._worker.postMessage(message);
         };
@@ -225,18 +225,12 @@ var BABYLON;
             //Legacy need no destruction method.
         };
         //No update in legacy mode
-        CollisionCoordinatorLegacy.prototype.onMeshAdded = function (mesh) {
-        };
-        CollisionCoordinatorLegacy.prototype.onMeshUpdated = function (mesh) {
-        };
-        CollisionCoordinatorLegacy.prototype.onMeshRemoved = function (mesh) {
-        };
-        CollisionCoordinatorLegacy.prototype.onGeometryAdded = function (geometry) {
-        };
-        CollisionCoordinatorLegacy.prototype.onGeometryUpdated = function (geometry) {
-        };
-        CollisionCoordinatorLegacy.prototype.onGeometryDeleted = function (geometry) {
-        };
+        CollisionCoordinatorLegacy.prototype.onMeshAdded = function (mesh) { };
+        CollisionCoordinatorLegacy.prototype.onMeshUpdated = function (mesh) { };
+        CollisionCoordinatorLegacy.prototype.onMeshRemoved = function (mesh) { };
+        CollisionCoordinatorLegacy.prototype.onGeometryAdded = function (geometry) { };
+        CollisionCoordinatorLegacy.prototype.onGeometryUpdated = function (geometry) { };
+        CollisionCoordinatorLegacy.prototype.onGeometryDeleted = function (geometry) { };
         CollisionCoordinatorLegacy.prototype._collideWithWorld = function (position, velocity, collider, maximumRetry, finalPosition, excludedMesh) {
             if (excludedMesh === void 0) { excludedMesh = null; }
             var closeDistance = BABYLON.Engine.CollisionsEpsilon * 10.0;
@@ -245,6 +239,7 @@ var BABYLON;
                 return;
             }
             collider._initialize(position, velocity, closeDistance);
+            // Check all meshes
             for (var index = 0; index < this._scene.meshes.length; index++) {
                 var mesh = this._scene.meshes[index];
                 if (mesh.isEnabled() && mesh.checkCollisions && mesh.subMeshes && mesh !== excludedMesh) {

+ 10 - 9
Babylon/Collisions/babylon.collisionWorker.js

@@ -147,8 +147,8 @@ var BABYLON;
         CollisionDetectorTransferable.prototype.onInit = function (payload) {
             this._collisionCache = new CollisionCache();
             var reply = {
-                error: 0 /* SUCCESS */,
-                taskType: 0 /* INIT */
+                error: BABYLON.WorkerReplyType.SUCCESS,
+                taskType: BABYLON.WorkerTaskType.INIT
             };
             postMessage(reply, undefined);
         };
@@ -164,8 +164,8 @@ var BABYLON;
                 }
             }
             var replay = {
-                error: 0 /* SUCCESS */,
-                taskType: 1 /* UPDATE */
+                error: BABYLON.WorkerReplyType.SUCCESS,
+                taskType: BABYLON.WorkerTaskType.UPDATE
             };
             postMessage(replay, undefined);
         };
@@ -182,8 +182,8 @@ var BABYLON;
                 newPosition: finalPosition.asArray()
             };
             var reply = {
-                error: 0 /* SUCCESS */,
-                taskType: 2 /* COLLIDE */,
+                error: BABYLON.WorkerReplyType.SUCCESS,
+                taskType: BABYLON.WorkerTaskType.COLLIDE,
                 payload: replyPayload
             };
             postMessage(reply, undefined);
@@ -191,6 +191,7 @@ var BABYLON;
         return CollisionDetectorTransferable;
     })();
     BABYLON.CollisionDetectorTransferable = CollisionDetectorTransferable;
+    //check if we are in a web worker, as this code should NOT run on the main UI thread
     try {
         if (self && self instanceof WorkerGlobalScope) {
             //Window hack to allow including babylonjs native code. the <any> is for typescript.
@@ -205,13 +206,13 @@ var BABYLON;
             var onNewMessage = function (event) {
                 var message = event.data;
                 switch (message.taskType) {
-                    case 0 /* INIT */:
+                    case BABYLON.WorkerTaskType.INIT:
                         collisionDetector.onInit(message.payload);
                         break;
-                    case 2 /* COLLIDE */:
+                    case BABYLON.WorkerTaskType.COLLIDE:
                         collisionDetector.onCollision(message.payload);
                         break;
-                    case 1 /* UPDATE */:
+                    case BABYLON.WorkerTaskType.UPDATE:
                         collisionDetector.onUpdate(message.payload);
                         break;
                 }

+ 1 - 0
Babylon/Culling/Octrees/babylon.octree.js

@@ -59,6 +59,7 @@ var BABYLON;
         Octree._CreateBlocks = function (worldMin, worldMax, entries, maxBlockCapacity, currentDepth, maxDepth, target, creationFunc) {
             target.blocks = new Array();
             var blockSize = new BABYLON.Vector3((worldMax.x - worldMin.x) / 2, (worldMax.y - worldMin.y) / 2, (worldMax.z - worldMin.z) / 2);
+            // Segmenting space
             for (var x = 0; x < 2; x++) {
                 for (var y = 0; y < 2; y++) {
                     for (var z = 0; z < 2; z++) {

+ 1 - 0
Babylon/Culling/babylon.boundingBox.js

@@ -25,6 +25,7 @@ var BABYLON;
             this.center = this.maximum.add(this.minimum).scale(0.5);
             this.extendSize = this.maximum.subtract(this.minimum).scale(0.5);
             this.directions = [BABYLON.Vector3.Zero(), BABYLON.Vector3.Zero(), BABYLON.Vector3.Zero()];
+            // World
             for (var index = 0; index < this.vectors.length; index++) {
                 this.vectorsWorld[index] = BABYLON.Vector3.Zero();
             }

File diff suppressed because it is too large
+ 69 - 88
Babylon/Debug/babylon.debugLayer.js


File diff suppressed because it is too large
+ 1 - 1
Babylon/Debug/babylon.debugLayer.js.map


+ 1 - 0
Babylon/LensFlare/babylon.lensFlareSystem.js

@@ -134,6 +134,7 @@ var BABYLON;
             engine.setAlphaMode(BABYLON.Engine.ALPHA_ADD);
             // VBOs
             engine.bindBuffers(this._vertexBuffer, this._indexBuffer, this._vertexDeclaration, this._vertexStrideSize, this._effect);
+            // Flares
             for (var index = 0; index < this.lensFlares.length; index++) {
                 var flare = this.lensFlares[index];
                 var x = centerX - (distX * flare.position);

+ 3 - 1
Babylon/Lights/Shadows/babylon.shadowGenerator.js

@@ -194,7 +194,9 @@ var BABYLON;
         });
         Object.defineProperty(ShadowGenerator.prototype, "usePoissonSampling", {
             get: function () {
-                return this.filter === ShadowGenerator.FILTER_POISSONSAMPLING || (!this._light.supportsVSM() && (this.filter === ShadowGenerator.FILTER_VARIANCESHADOWMAP || this.filter === ShadowGenerator.FILTER_BLURVARIANCESHADOWMAP));
+                return this.filter === ShadowGenerator.FILTER_POISSONSAMPLING ||
+                    (!this._light.supportsVSM() && (this.filter === ShadowGenerator.FILTER_VARIANCESHADOWMAP ||
+                        this.filter === ShadowGenerator.FILTER_BLURVARIANCESHADOWMAP));
             },
             set: function (value) {
                 this.filter = (value ? ShadowGenerator.FILTER_POISSONSAMPLING : ShadowGenerator.FILTER_NONE);

+ 1 - 0
Babylon/Lights/babylon.directionalLight.js

@@ -28,6 +28,7 @@ var BABYLON;
             var orthoBottom = Number.MAX_VALUE;
             var tempVector3 = BABYLON.Vector3.Zero();
             var activeCamera = this.getScene().activeCamera;
+            // Check extends
             for (var meshIndex = 0; meshIndex < renderList.length; meshIndex++) {
                 var mesh = renderList[meshIndex];
                 if (!mesh) {

+ 11 - 14
Babylon/Loading/Plugins/babylon.babylonFileLoader.js

@@ -345,12 +345,6 @@ var BABYLON;
             else if (parsedCamera.type === "GamepadCamera") {
                 camera = new BABYLON.GamepadCamera(parsedCamera.name, position, scene);
             }
-            else if (parsedCamera.type === "OculusCamera") {
-                camera = new BABYLON.OculusCamera(parsedCamera.name, position, scene);
-            }
-            else if (parsedCamera.type === "OculusGamepadCamera") {
-                camera = new BABYLON.OculusGamepadCamera(parsedCamera.name, position, scene);
-            }
             else if (parsedCamera.type === "TouchCamera") {
                 camera = new BABYLON.TouchCamera(parsedCamera.name, position, scene);
             }
@@ -683,6 +677,7 @@ var BABYLON;
                 }
                 var effectiveTarget = propertyPath.split(".");
                 var values = value.split(",");
+                // Get effective Target
                 for (var i = 0; i < effectiveTarget.length; i++) {
                     target = target[effectiveTarget[i]];
                 }
@@ -785,6 +780,7 @@ var BABYLON;
                 for (var i = 0; i < parsedAction.children.length; i++)
                     traverse(parsedAction.children[i], trigger, condition, newAction, null);
             };
+            // triggers
             for (var i = 0; i < parsedActions.children.length; i++) {
                 var triggerParams;
                 var trigger = parsedActions.children[i];
@@ -805,19 +801,14 @@ var BABYLON;
             var soundName = parsedSound.name;
             var soundUrl = rootUrl + soundName;
             var options = {
-                autoplay: parsedSound.autoplay,
-                loop: parsedSound.loop,
-                volume: parsedSound.volume,
-                spatialSound: parsedSound.spatialSound,
-                maxDistance: parsedSound.maxDistance,
+                autoplay: parsedSound.autoplay, loop: parsedSound.loop, volume: parsedSound.volume,
+                spatialSound: parsedSound.spatialSound, maxDistance: parsedSound.maxDistance,
                 rolloffFactor: parsedSound.rolloffFactor,
                 refDistance: parsedSound.refDistance,
                 distanceModel: parsedSound.distanceModel,
                 playbackRate: parsedSound.playbackRate
             };
-            var newSound = new BABYLON.Sound(soundName, soundUrl, scene, function () {
-                scene._removePendingData(newSound);
-            }, options);
+            var newSound = new BABYLON.Sound(soundName, soundUrl, scene, function () { scene._removePendingData(newSound); }, options);
             scene._addPendingData(newSound);
             if (parsedSound.position) {
                 var soundPosition = BABYLON.Vector3.FromArray(parsedSound.position);
@@ -1061,6 +1052,7 @@ var BABYLON;
                         meshes.push(mesh);
                     }
                 }
+                // Connecting parents
                 for (index = 0; index < scene.meshes.length; index++) {
                     var currentMesh = scene.meshes[index];
                     if (currentMesh._waitingParentId) {
@@ -1095,6 +1087,7 @@ var BABYLON;
                     scene.fogEnd = parsedData.fogEnd;
                     scene.fogDensity = parsedData.fogDensity;
                 }
+                // Lights
                 for (var index = 0; index < parsedData.lights.length; index++) {
                     var parsedLight = parsedData.lights[index];
                     parseLight(parsedLight, scene);
@@ -1187,10 +1180,12 @@ var BABYLON;
                         }
                     }
                 }
+                // Meshes
                 for (index = 0; index < parsedData.meshes.length; index++) {
                     var parsedMesh = parsedData.meshes[index];
                     parseMesh(parsedMesh, scene, rootUrl);
                 }
+                // Cameras
                 for (index = 0; index < parsedData.cameras.length; index++) {
                     var parsedCamera = parsedData.cameras[index];
                     parseCamera(parsedCamera, scene);
@@ -1198,6 +1193,7 @@ var BABYLON;
                 if (parsedData.activeCameraID) {
                     scene.setActiveCameraByID(parsedData.activeCameraID);
                 }
+                // Browsing all the graph to connect the dots
                 for (index = 0; index < scene.cameras.length; index++) {
                     var camera = scene.cameras[index];
                     if (camera._waitingParentId) {
@@ -1224,6 +1220,7 @@ var BABYLON;
                         }
                     }
                 }
+                // Connect parents & children and parse actions
                 for (index = 0; index < scene.meshes.length; index++) {
                     var mesh = scene.meshes[index];
                     if (mesh._waitingParentId) {

+ 0 - 6
Babylon/Loading/Plugins/babylon.babylonFileLoader.ts

@@ -423,12 +423,6 @@
         } else if (parsedCamera.type === "GamepadCamera") {
             camera = new GamepadCamera(parsedCamera.name, position, scene);
 
-        } else if (parsedCamera.type === "OculusCamera") {
-            camera = new OculusCamera(parsedCamera.name, position, scene);
-
-        } else if (parsedCamera.type === "OculusGamepadCamera") {
-            camera = new OculusGamepadCamera(parsedCamera.name, position, scene);
-
         } else if (parsedCamera.type === "TouchCamera") {
             camera = new TouchCamera(parsedCamera.name, position, scene);
 

+ 8 - 0
Babylon/Materials/Textures/Procedurals/babylon.proceduralTexture.js

@@ -186,28 +186,36 @@ var BABYLON;
             // Render
             engine.enableEffect(this._effect);
             engine.setState(false);
+            // Texture
             for (var name in this._textures) {
                 this._effect.setTexture(name, this._textures[name]);
             }
+            // Float    
             for (name in this._floats) {
                 this._effect.setFloat(name, this._floats[name]);
             }
+            // Floats   
             for (name in this._floatsArrays) {
                 this._effect.setArray(name, this._floatsArrays[name]);
             }
+            // Color3        
             for (name in this._colors3) {
                 this._effect.setColor3(name, this._colors3[name]);
             }
+            // Color4      
             for (name in this._colors4) {
                 var color = this._colors4[name];
                 this._effect.setFloat4(name, color.r, color.g, color.b, color.a);
             }
+            // Vector2        
             for (name in this._vectors2) {
                 this._effect.setVector2(name, this._vectors2[name]);
             }
+            // Vector3        
             for (name in this._vectors3) {
                 this._effect.setVector3(name, this._vectors3[name]);
             }
+            // Matrix      
             for (name in this._matrices) {
                 this._effect.setMatrix(name, this._matrices[name]);
             }

+ 12 - 2
Babylon/Materials/Textures/babylon.texture.js

@@ -83,7 +83,13 @@ var BABYLON;
             t.z += 0.5;
         };
         Texture.prototype.getTextureMatrix = function () {
-            if (this.uOffset === this._cachedUOffset && this.vOffset === this._cachedVOffset && this.uScale === this._cachedUScale && this.vScale === this._cachedVScale && this.uAng === this._cachedUAng && this.vAng === this._cachedVAng && this.wAng === this._cachedWAng) {
+            if (this.uOffset === this._cachedUOffset &&
+                this.vOffset === this._cachedVOffset &&
+                this.uScale === this._cachedUScale &&
+                this.vScale === this._cachedVScale &&
+                this.uAng === this._cachedUAng &&
+                this.vAng === this._cachedVAng &&
+                this.wAng === this._cachedWAng) {
                 return this._cachedTextureMatrix;
             }
             this._cachedUOffset = this.uOffset;
@@ -119,7 +125,11 @@ var BABYLON;
             return this._cachedTextureMatrix;
         };
         Texture.prototype.getReflectionTextureMatrix = function () {
-            if (this.uOffset === this._cachedUOffset && this.vOffset === this._cachedVOffset && this.uScale === this._cachedUScale && this.vScale === this._cachedVScale && this.coordinatesMode === this._cachedCoordinatesMode) {
+            if (this.uOffset === this._cachedUOffset &&
+                this.vOffset === this._cachedVOffset &&
+                this.uScale === this._cachedUScale &&
+                this.vScale === this._cachedVScale &&
+                this.coordinatesMode === this._cachedCoordinatesMode) {
                 return this._cachedTextureMatrix;
             }
             if (!this._cachedTextureMatrix) {

+ 8 - 0
Babylon/Materials/babylon.shaderMaterial.js

@@ -147,28 +147,36 @@ var BABYLON;
                 if (mesh && mesh.useBones) {
                     this._effect.setMatrices("mBones", mesh.skeleton.getTransformMatrices());
                 }
+                // Texture
                 for (var name in this._textures) {
                     this._effect.setTexture(name, this._textures[name]);
                 }
+                // Float    
                 for (name in this._floats) {
                     this._effect.setFloat(name, this._floats[name]);
                 }
+                // Float s   
                 for (name in this._floatsArrays) {
                     this._effect.setArray(name, this._floatsArrays[name]);
                 }
+                // Color3        
                 for (name in this._colors3) {
                     this._effect.setColor3(name, this._colors3[name]);
                 }
+                // Color4      
                 for (name in this._colors4) {
                     var color = this._colors4[name];
                     this._effect.setFloat4(name, color.r, color.g, color.b, color.a);
                 }
+                // Vector2        
                 for (name in this._vectors2) {
                     this._effect.setVector2(name, this._vectors2[name]);
                 }
+                // Vector3        
                 for (name in this._vectors3) {
                     this._effect.setVector3(name, this._vectors3[name]);
                 }
+                // Matrix      
                 for (name in this._matrices) {
                     this._effect.setMatrix(name, this._matrices[name]);
                 }

File diff suppressed because it is too large
+ 18 - 2
Babylon/Materials/babylon.standardMaterial.js


+ 52 - 50
Babylon/Math/babylon.math.js

@@ -102,33 +102,15 @@ var BABYLON;
             var b = start.b + ((end.b - start.b) * amount);
             return new Color3(r, g, b);
         };
-        Color3.Red = function () {
-            return new Color3(1, 0, 0);
-        };
-        Color3.Green = function () {
-            return new Color3(0, 1, 0);
-        };
-        Color3.Blue = function () {
-            return new Color3(0, 0, 1);
-        };
-        Color3.Black = function () {
-            return new Color3(0, 0, 0);
-        };
-        Color3.White = function () {
-            return new Color3(1, 1, 1);
-        };
-        Color3.Purple = function () {
-            return new Color3(0.5, 0, 0.5);
-        };
-        Color3.Magenta = function () {
-            return new Color3(1, 0, 1);
-        };
-        Color3.Yellow = function () {
-            return new Color3(1, 1, 0);
-        };
-        Color3.Gray = function () {
-            return new Color3(0.5, 0.5, 0.5);
-        };
+        Color3.Red = function () { return new Color3(1, 0, 0); };
+        Color3.Green = function () { return new Color3(0, 1, 0); };
+        Color3.Blue = function () { return new Color3(0, 0, 1); };
+        Color3.Black = function () { return new Color3(0, 0, 0); };
+        Color3.White = function () { return new Color3(1, 1, 1); };
+        Color3.Purple = function () { return new Color3(0.5, 0, 0.5); };
+        Color3.Magenta = function () { return new Color3(1, 0, 1); };
+        Color3.Yellow = function () { return new Color3(1, 1, 0); };
+        Color3.Gray = function () { return new Color3(0.5, 0.5, 0.5); };
         return Color3;
     })();
     BABYLON.Color3 = Color3;
@@ -337,8 +319,12 @@ var BABYLON;
         Vector2.CatmullRom = function (value1, value2, value3, value4, amount) {
             var squared = amount * amount;
             var cubed = amount * squared;
-            var x = 0.5 * ((((2.0 * value2.x) + ((-value1.x + value3.x) * amount)) + (((((2.0 * value1.x) - (5.0 * value2.x)) + (4.0 * value3.x)) - value4.x) * squared)) + ((((-value1.x + (3.0 * value2.x)) - (3.0 * value3.x)) + value4.x) * cubed));
-            var y = 0.5 * ((((2.0 * value2.y) + ((-value1.y + value3.y) * amount)) + (((((2.0 * value1.y) - (5.0 * value2.y)) + (4.0 * value3.y)) - value4.y) * squared)) + ((((-value1.y + (3.0 * value2.y)) - (3.0 * value3.y)) + value4.y) * cubed));
+            var x = 0.5 * ((((2.0 * value2.x) + ((-value1.x + value3.x) * amount)) +
+                (((((2.0 * value1.x) - (5.0 * value2.x)) + (4.0 * value3.x)) - value4.x) * squared)) +
+                ((((-value1.x + (3.0 * value2.x)) - (3.0 * value3.x)) + value4.x) * cubed));
+            var y = 0.5 * ((((2.0 * value2.y) + ((-value1.y + value3.y) * amount)) +
+                (((((2.0 * value1.y) - (5.0 * value2.y)) + (4.0 * value3.y)) - value4.y) * squared)) +
+                ((((-value1.y + (3.0 * value2.y)) - (3.0 * value3.y)) + value4.y) * cubed));
             return new Vector2(x, y);
         };
         Vector2.Clamp = function (value, min, max) {
@@ -496,7 +482,9 @@ var BABYLON;
             return otherVector && this.x === otherVector.x && this.y === otherVector.y && this.z === otherVector.z;
         };
         Vector3.prototype.equalsWithEpsilon = function (otherVector) {
-            return Math.abs(this.x - otherVector.x) < BABYLON.Engine.Epsilon && Math.abs(this.y - otherVector.y) < BABYLON.Engine.Epsilon && Math.abs(this.z - otherVector.z) < BABYLON.Engine.Epsilon;
+            return Math.abs(this.x - otherVector.x) < BABYLON.Engine.Epsilon &&
+                Math.abs(this.y - otherVector.y) < BABYLON.Engine.Epsilon &&
+                Math.abs(this.z - otherVector.z) < BABYLON.Engine.Epsilon;
         };
         Vector3.prototype.equalsToFloats = function (x, y, z) {
             return this.x === x && this.y === y && this.z === z;
@@ -676,9 +664,15 @@ var BABYLON;
         Vector3.CatmullRom = function (value1, value2, value3, value4, amount) {
             var squared = amount * amount;
             var cubed = amount * squared;
-            var x = 0.5 * ((((2.0 * value2.x) + ((-value1.x + value3.x) * amount)) + (((((2.0 * value1.x) - (5.0 * value2.x)) + (4.0 * value3.x)) - value4.x) * squared)) + ((((-value1.x + (3.0 * value2.x)) - (3.0 * value3.x)) + value4.x) * cubed));
-            var y = 0.5 * ((((2.0 * value2.y) + ((-value1.y + value3.y) * amount)) + (((((2.0 * value1.y) - (5.0 * value2.y)) + (4.0 * value3.y)) - value4.y) * squared)) + ((((-value1.y + (3.0 * value2.y)) - (3.0 * value3.y)) + value4.y) * cubed));
-            var z = 0.5 * ((((2.0 * value2.z) + ((-value1.z + value3.z) * amount)) + (((((2.0 * value1.z) - (5.0 * value2.z)) + (4.0 * value3.z)) - value4.z) * squared)) + ((((-value1.z + (3.0 * value2.z)) - (3.0 * value3.z)) + value4.z) * cubed));
+            var x = 0.5 * ((((2.0 * value2.x) + ((-value1.x + value3.x) * amount)) +
+                (((((2.0 * value1.x) - (5.0 * value2.x)) + (4.0 * value3.x)) - value4.x) * squared)) +
+                ((((-value1.x + (3.0 * value2.x)) - (3.0 * value3.x)) + value4.x) * cubed));
+            var y = 0.5 * ((((2.0 * value2.y) + ((-value1.y + value3.y) * amount)) +
+                (((((2.0 * value1.y) - (5.0 * value2.y)) + (4.0 * value3.y)) - value4.y) * squared)) +
+                ((((-value1.y + (3.0 * value2.y)) - (3.0 * value3.y)) + value4.y) * cubed));
+            var z = 0.5 * ((((2.0 * value2.z) + ((-value1.z + value3.z) * amount)) +
+                (((((2.0 * value1.z) - (5.0 * value2.z)) + (4.0 * value3.z)) - value4.z) * squared)) +
+                ((((-value1.z + (3.0 * value2.z)) - (3.0 * value3.z)) + value4.z) * cubed));
             return new Vector3(x, y, z);
         };
         Vector3.Clamp = function (value, min, max) {
@@ -887,7 +881,10 @@ var BABYLON;
             return otherVector && this.x === otherVector.x && this.y === otherVector.y && this.z === otherVector.z && this.w === otherVector.w;
         };
         Vector4.prototype.equalsWithEpsilon = function (otherVector) {
-            return Math.abs(this.x - otherVector.x) < BABYLON.Engine.Epsilon && Math.abs(this.y - otherVector.y) < BABYLON.Engine.Epsilon && Math.abs(this.z - otherVector.z) < BABYLON.Engine.Epsilon && Math.abs(this.w - otherVector.w) < BABYLON.Engine.Epsilon;
+            return Math.abs(this.x - otherVector.x) < BABYLON.Engine.Epsilon &&
+                Math.abs(this.y - otherVector.y) < BABYLON.Engine.Epsilon &&
+                Math.abs(this.z - otherVector.z) < BABYLON.Engine.Epsilon &&
+                Math.abs(this.w - otherVector.w) < BABYLON.Engine.Epsilon;
         };
         Vector4.prototype.equalsToFloats = function (x, y, z, w) {
             return this.x === x && this.y === y && this.z === z && this.w === w;
@@ -1317,7 +1314,10 @@ var BABYLON;
         Matrix.prototype.isIdentity = function () {
             if (this.m[0] !== 1.0 || this.m[5] !== 1.0 || this.m[10] !== 1.0 || this.m[15] !== 1.0)
                 return false;
-            if (this.m[1] !== 0.0 || this.m[2] !== 0.0 || this.m[3] !== 0.0 || this.m[4] !== 0.0 || this.m[6] !== 0.0 || this.m[7] !== 0.0 || this.m[8] !== 0.0 || this.m[9] !== 0.0 || this.m[11] !== 0.0 || this.m[12] !== 0.0 || this.m[13] !== 0.0 || this.m[14] !== 0.0)
+            if (this.m[1] !== 0.0 || this.m[2] !== 0.0 || this.m[3] !== 0.0 ||
+                this.m[4] !== 0.0 || this.m[6] !== 0.0 || this.m[7] !== 0.0 ||
+                this.m[8] !== 0.0 || this.m[9] !== 0.0 || this.m[11] !== 0.0 ||
+                this.m[12] !== 0.0 || this.m[13] !== 0.0 || this.m[14] !== 0.0)
                 return false;
             return true;
         };
@@ -1328,7 +1328,9 @@ var BABYLON;
             var temp4 = (this.m[8] * this.m[15]) - (this.m[11] * this.m[12]);
             var temp5 = (this.m[8] * this.m[14]) - (this.m[10] * this.m[12]);
             var temp6 = (this.m[8] * this.m[13]) - (this.m[9] * this.m[12]);
-            return ((((this.m[0] * (((this.m[5] * temp1) - (this.m[6] * temp2)) + (this.m[7] * temp3))) - (this.m[1] * (((this.m[4] * temp1) - (this.m[6] * temp4)) + (this.m[7] * temp5)))) + (this.m[2] * (((this.m[4] * temp2) - (this.m[5] * temp4)) + (this.m[7] * temp6)))) - (this.m[3] * (((this.m[4] * temp3) - (this.m[5] * temp5)) + (this.m[6] * temp6))));
+            return ((((this.m[0] * (((this.m[5] * temp1) - (this.m[6] * temp2)) + (this.m[7] * temp3))) - (this.m[1] * (((this.m[4] * temp1) -
+                (this.m[6] * temp4)) + (this.m[7] * temp5)))) + (this.m[2] * (((this.m[4] * temp2) - (this.m[5] * temp4)) + (this.m[7] * temp6)))) -
+                (this.m[3] * (((this.m[4] * temp3) - (this.m[5] * temp5)) + (this.m[6] * temp6))));
         };
         // Methods
         Matrix.prototype.toArray = function () {
@@ -1602,7 +1604,11 @@ var BABYLON;
             SIMD.float32x4.store(result, offset + 12, SIMD.float32x4.add(SIMD.float32x4.mul(SIMD.float32x4.swizzle(tm3, 0, 0, 0, 0), om0), SIMD.float32x4.add(SIMD.float32x4.mul(SIMD.float32x4.swizzle(tm3, 1, 1, 1, 1), om1), SIMD.float32x4.add(SIMD.float32x4.mul(SIMD.float32x4.swizzle(tm3, 2, 2, 2, 2), om2), SIMD.float32x4.mul(SIMD.float32x4.swizzle(tm3, 3, 3, 3, 3), om3)))));
         };
         Matrix.prototype.equals = function (value) {
-            return value && (this.m[0] === value.m[0] && this.m[1] === value.m[1] && this.m[2] === value.m[2] && this.m[3] === value.m[3] && this.m[4] === value.m[4] && this.m[5] === value.m[5] && this.m[6] === value.m[6] && this.m[7] === value.m[7] && this.m[8] === value.m[8] && this.m[9] === value.m[9] && this.m[10] === value.m[10] && this.m[11] === value.m[11] && this.m[12] === value.m[12] && this.m[13] === value.m[13] && this.m[14] === value.m[14] && this.m[15] === value.m[15]);
+            return value &&
+                (this.m[0] === value.m[0] && this.m[1] === value.m[1] && this.m[2] === value.m[2] && this.m[3] === value.m[3] &&
+                    this.m[4] === value.m[4] && this.m[5] === value.m[5] && this.m[6] === value.m[6] && this.m[7] === value.m[7] &&
+                    this.m[8] === value.m[8] && this.m[9] === value.m[9] && this.m[10] === value.m[10] && this.m[11] === value.m[11] &&
+                    this.m[12] === value.m[12] && this.m[13] === value.m[13] && this.m[14] === value.m[14] && this.m[15] === value.m[15]);
         };
         Matrix.prototype.clone = function () {
             return Matrix.FromValues(this.m[0], this.m[1], this.m[2], this.m[3], this.m[4], this.m[5], this.m[6], this.m[7], this.m[8], this.m[9], this.m[10], this.m[11], this.m[12], this.m[13], this.m[14], this.m[15]);
@@ -2400,7 +2406,9 @@ var BABYLON;
                 refinedT = Math.min(1, Math.max(0, refinedT));
             }
             // Resolve cubic bezier for the given x
-            return 3 * Math.pow(1 - refinedT, 2) * refinedT * y1 + 3 * (1 - refinedT) * Math.pow(refinedT, 2) * y2 + Math.pow(refinedT, 3);
+            return 3 * Math.pow(1 - refinedT, 2) * refinedT * y1 +
+                3 * (1 - refinedT) * Math.pow(refinedT, 2) * y2 +
+                Math.pow(refinedT, 3);
         };
         return BezierCurve;
     })();
@@ -2457,8 +2465,8 @@ var BABYLON;
                 a3 -= 360.0;
             if (a3 - a2 < -180.0)
                 a3 += 360.0;
-            this.orientation = (a2 - a1) < 0 ? 0 /* CW */ : 1 /* CCW */;
-            this.angle = Angle.FromDegrees(this.orientation === 0 /* CW */ ? a1 - a3 : a3 - a1);
+            this.orientation = (a2 - a1) < 0 ? Orientation.CW : Orientation.CCW;
+            this.angle = Angle.FromDegrees(this.orientation === Orientation.CW ? a1 - a3 : a3 - a1);
         }
         return Arc2;
     })();
@@ -2549,7 +2557,7 @@ var BABYLON;
             var endPoint = new Vector2(endX, endY);
             var arc = new Arc2(startPoint, midPoint, endPoint);
             var increment = arc.angle.radians() / numberOfSegments;
-            if (arc.orientation === 0 /* CW */)
+            if (arc.orientation === Orientation.CW)
                 increment *= -1;
             var currentAngle = arc.startAngle.radians() + increment;
             for (var i = 0; i < numberOfSegments; i++) {
@@ -2866,9 +2874,7 @@ var BABYLON;
             Vector3.TransformCoordinatesToRef = Vector3.TransformCoordinatesToRefSIMD;
             Vector3.TransformCoordinatesFromFloatsToRef = Vector3.TransformCoordinatesFromFloatsToRefSIMD;
             Object.defineProperty(BABYLON.Vector3.prototype, "x", {
-                get: function () {
-                    return this._data[0];
-                },
+                get: function () { return this._data[0]; },
                 set: function (value) {
                     if (!this._data) {
                         this._data = new Float32Array(3);
@@ -2877,17 +2883,13 @@ var BABYLON;
                 }
             });
             Object.defineProperty(BABYLON.Vector3.prototype, "y", {
-                get: function () {
-                    return this._data[1];
-                },
+                get: function () { return this._data[1]; },
                 set: function (value) {
                     this._data[1] = value;
                 }
             });
             Object.defineProperty(BABYLON.Vector3.prototype, "z", {
-                get: function () {
-                    return this._data[2];
-                },
+                get: function () { return this._data[2]; },
                 set: function (value) {
                     this._data[2] = value;
                 }

+ 6 - 2
Babylon/Mesh/babylon.abstractMesh.js

@@ -207,7 +207,7 @@ var BABYLON;
                 this.rotationQuaternion = BABYLON.Quaternion.RotationYawPitchRoll(this.rotation.y, this.rotation.x, this.rotation.z);
                 this.rotation = BABYLON.Vector3.Zero();
             }
-            if (!space || space === 0 /* LOCAL */) {
+            if (!space || space === BABYLON.Space.LOCAL) {
                 var rotationQuaternion = BABYLON.Quaternion.RotationAxis(axis, amount);
                 this.rotationQuaternion = this.rotationQuaternion.multiply(rotationQuaternion);
             }
@@ -223,7 +223,7 @@ var BABYLON;
         };
         AbstractMesh.prototype.translate = function (axis, distance, space) {
             var displacementVector = axis.scale(distance);
-            if (!space || space === 0 /* LOCAL */) {
+            if (!space || space === BABYLON.Space.LOCAL) {
                 var tempV3 = this.getPositionExpressedInLocalSpace().add(displacementVector);
                 this.setPositionWithLocalVector(tempV3);
             }
@@ -452,6 +452,7 @@ var BABYLON;
             this._updateBoundingInfo();
             // Absolute position
             this._absolutePosition.copyFromFloats(this._worldMatrix.m[12], this._worldMatrix.m[13], this._worldMatrix.m[14]);
+            // Callbacks
             for (var callbackIndex = 0; callbackIndex < this._onAfterWorldMatrixUpdate.length; callbackIndex++) {
                 this._onAfterWorldMatrixUpdate[callbackIndex](this);
             }
@@ -770,6 +771,7 @@ var BABYLON;
             if (this.getPhysicsImpostor() !== BABYLON.PhysicsEngine.NoImpostor) {
                 this.setPhysicsState(BABYLON.PhysicsEngine.NoImpostor);
             }
+            // Intersections in progress
             for (index = 0; index < this._intersectionsInProgress.length; index++) {
                 var other = this._intersectionsInProgress[index];
                 var pos = other._intersectionsInProgress.indexOf(this);
@@ -781,6 +783,7 @@ var BABYLON;
             // Remove from scene
             this.getScene().removeMesh(this);
             if (!doNotRecurse) {
+                // Particles
                 for (index = 0; index < this.getScene().particleSystems.length; index++) {
                     if (this.getScene().particleSystems[index].emitter === this) {
                         this.getScene().particleSystems[index].dispose();
@@ -821,3 +824,4 @@ var BABYLON;
     })(BABYLON.Node);
     BABYLON.AbstractMesh = AbstractMesh;
 })(BABYLON || (BABYLON = {}));
+//# sourceMappingURL=babylon.abstractMesh.js.map

+ 1 - 0
Babylon/Mesh/babylon.abstractMesh.ts

@@ -964,3 +964,4 @@
         }
     }
 }
+

+ 9 - 7
Babylon/Mesh/babylon.csg.js

@@ -76,6 +76,7 @@ var BABYLON;
                 polygonType |= type;
                 types.push(type);
             }
+            // Put the polygon in the correct list, splitting it when necessary.
             switch (polygonType) {
                 case COPLANAR:
                     (BABYLON.Vector3.Dot(this.normal, polygon.plane.normal) > 0 ? coplanarFront : coplanarBack).push(polygon);
@@ -139,9 +140,7 @@ var BABYLON;
             return new Polygon(vertices, this.shared);
         };
         Polygon.prototype.flip = function () {
-            this.vertices.reverse().map(function (v) {
-                v.flip();
-            });
+            this.vertices.reverse().map(function (v) { v.flip(); });
             this.plane.flip();
         };
         return Polygon;
@@ -393,9 +392,7 @@ var BABYLON;
             return csg;
         };
         CSG.prototype.inverseInPlace = function () {
-            this.polygons.map(function (p) {
-                p.flip();
-            });
+            this.polygons.map(function (p) { p.flip(); });
         };
         // This is used to keep meshes transformations so they can be restored
         // when we build back a Babylon Mesh
@@ -450,7 +447,12 @@ var BABYLON;
                         var localNormal = BABYLON.Vector3.TransformNormal(normal, matrix);
                         vertex_idx = vertice_dict[localVertex.x + ',' + localVertex.y + ',' + localVertex.z];
                         // Check if 2 points can be merged
-                        if (!(typeof vertex_idx !== 'undefined' && normals[vertex_idx * 3] === localNormal.x && normals[vertex_idx * 3 + 1] === localNormal.y && normals[vertex_idx * 3 + 2] === localNormal.z && uvs[vertex_idx * 2] === uv.x && uvs[vertex_idx * 2 + 1] === uv.y)) {
+                        if (!(typeof vertex_idx !== 'undefined' &&
+                            normals[vertex_idx * 3] === localNormal.x &&
+                            normals[vertex_idx * 3 + 1] === localNormal.y &&
+                            normals[vertex_idx * 3 + 2] === localNormal.z &&
+                            uvs[vertex_idx * 2] === uv.x &&
+                            uvs[vertex_idx * 2 + 1] === uv.y)) {
                             vertices.push(localVertex.x, localVertex.y, localVertex.z);
                             uvs.push(uv.x, uv.y);
                             normals.push(normal.x, normal.y, normal.z);

+ 2 - 2
Babylon/Mesh/babylon.geometry.js

@@ -248,6 +248,7 @@ var BABYLON;
         };
         Geometry.prototype._applyToMesh = function (mesh) {
             var numOfMeshes = this._meshes.length;
+            // vertexBuffers
             for (var kind in this._vertexBuffers) {
                 if (numOfMeshes === 1) {
                     this._vertexBuffers[kind].create();
@@ -301,8 +302,7 @@ var BABYLON;
                 if (onLoaded) {
                     onLoaded();
                 }
-            }, function () {
-            }, scene.database);
+            }, function () { }, scene.database);
         };
         Geometry.prototype.isDisposed = function () {
             return this._isDisposed;

+ 1 - 0
Babylon/Mesh/babylon.instancedMesh.js

@@ -129,6 +129,7 @@ var BABYLON;
                 result.parent = newParent;
             }
             if (!doNotCloneChildren) {
+                // Children
                 for (var index = 0; index < this.getScene().meshes.length; index++) {
                     var mesh = this.getScene().meshes[index];
                     if (mesh.parent === this) {

+ 17 - 14
Babylon/Mesh/babylon.mesh.js

@@ -52,6 +52,7 @@ var BABYLON;
                 // Material
                 this.material = source.material;
                 if (!doNotCloneChildren) {
+                    // Children
                     for (var index = 0; index < scene.meshes.length; index++) {
                         var mesh = scene.meshes[index];
                         if (mesh.parent === source) {
@@ -60,6 +61,7 @@ var BABYLON;
                         }
                     }
                 }
+                // Particles
                 for (index = 0; index < scene.particleSystems.length; index++) {
                     var system = scene.particleSystems[index];
                     if (system.emitter === source) {
@@ -369,6 +371,7 @@ var BABYLON;
             var totalIndices = this.getTotalIndices();
             var subdivisionSize = (totalIndices / count) | 0;
             var offset = 0;
+            // Ensure that subdivisionSize is a multiple of 3
             while (subdivisionSize % 3 !== 0) {
                 subdivisionSize++;
             }
@@ -481,6 +484,7 @@ var BABYLON;
                 return;
             }
             var engine = this.getScene().getEngine();
+            // Draw order
             switch (fillMode) {
                 case BABYLON.Material.PointFillMode:
                     engine.drawPointClouds(subMesh.verticesStart, subMesh.verticesCount, instancesCount);
@@ -717,8 +721,7 @@ var BABYLON;
                     }
                     _this.delayLoadState = BABYLON.Engine.DELAYLOADSTATE_LOADED;
                     scene._removePendingData(_this);
-                }, function () {
-                }, scene.database, getBinaryData);
+                }, function () { }, scene.database, getBinaryData);
             }
         };
         Mesh.prototype.isInFrustum = function (frustumPlanes) {
@@ -840,11 +843,12 @@ var BABYLON;
                     onSuccess(_this);
                 }
             };
-            BABYLON.Tools.LoadImage(url, onload, function () {
-            }, scene.database);
+            BABYLON.Tools.LoadImage(url, onload, function () { }, scene.database);
         };
         Mesh.prototype.applyDisplacementMapFromBuffer = function (buffer, heightMapWidth, heightMapHeight, minHeight, maxHeight) {
-            if (!this.isVerticesDataPresent(BABYLON.VertexBuffer.PositionKind) || !this.isVerticesDataPresent(BABYLON.VertexBuffer.NormalKind) || !this.isVerticesDataPresent(BABYLON.VertexBuffer.UVKind)) {
+            if (!this.isVerticesDataPresent(BABYLON.VertexBuffer.PositionKind)
+                || !this.isVerticesDataPresent(BABYLON.VertexBuffer.NormalKind)
+                || !this.isVerticesDataPresent(BABYLON.VertexBuffer.UVKind)) {
                 BABYLON.Tools.Warn("Cannot call applyDisplacementMap: Given mesh is not complete. Position, Normal or UV are missing");
                 return;
             }
@@ -900,6 +904,7 @@ var BABYLON;
             var previousSubmeshes = this.subMeshes.slice(0);
             var indices = this.getIndices();
             var totalIndices = this.getTotalIndices();
+            // Generating unique vertices per face
             for (var index = 0; index < totalIndices; index++) {
                 var vertexIndex = indices[index];
                 for (kindIndex = 0; kindIndex < kinds.length; kindIndex++) {
@@ -923,6 +928,7 @@ var BABYLON;
                 var p1p2 = p1.subtract(p2);
                 var p3p2 = p3.subtract(p2);
                 var normal = BABYLON.Vector3.Normalize(BABYLON.Vector3.Cross(p1p2, p3p2));
+                // Store same normals for every vertex
                 for (var localIndex = 0; localIndex < 3; localIndex++) {
                     normals.push(normal.x);
                     normals.push(normal.y);
@@ -931,6 +937,7 @@ var BABYLON;
             }
             this.setIndices(indices);
             this.setVerticesData(BABYLON.VertexBuffer.NormalKind, normals, updatableNormals);
+            // Updating vertex buffers
             for (kindIndex = 0; kindIndex < kinds.length; kindIndex++) {
                 kind = kinds[kindIndex];
                 this.setVerticesData(kind, newdata[kind], vbs[kind].isUpdatable());
@@ -963,7 +970,7 @@ var BABYLON;
          */
         Mesh.prototype.simplify = function (settings, parallelProcessing, simplificationType, successCallback) {
             if (parallelProcessing === void 0) { parallelProcessing = true; }
-            if (simplificationType === void 0) { simplificationType = 0 /* QUADRATIC */; }
+            if (simplificationType === void 0) { simplificationType = BABYLON.SimplificationType.QUADRATIC; }
             this.getScene().simplificationQueue.addTask({
                 settings: settings,
                 parallelProcessing: parallelProcessing,
@@ -1155,12 +1162,8 @@ var BABYLON;
                 var binormals = path3D.getBinormals();
                 var distances = path3D.getDistances();
                 var angle = 0;
-                var returnScale = function (i, distance) {
-                    return scale;
-                };
-                var returnRotation = function (i, distance) {
-                    return rotation;
-                };
+                var returnScale = function (i, distance) { return scale; };
+                var returnRotation = function (i, distance) { return rotation; };
                 var rotate = custom ? rotateFunction : returnRotation;
                 var scl = custom ? scaleFunction : returnScale;
                 var index = 0;
@@ -1274,8 +1277,7 @@ var BABYLON;
                     onReady(ground);
                 }
             };
-            BABYLON.Tools.LoadImage(url, onload, function () {
-            }, scene.database);
+            BABYLON.Tools.LoadImage(url, onload, function () { }, scene.database);
             return ground;
         };
         Mesh.CreateTube = function (name, path, radius, tessellation, radiusFunction, cap, scene, updatable, sideOrientation, tubeInstance) {
@@ -1554,6 +1556,7 @@ var BABYLON;
             if (disposeSource === void 0) { disposeSource = true; }
             if (!allow32BitsIndices) {
                 var totalVertices = 0;
+                // Counting vertices
                 for (var index = 0; index < meshes.length; index++) {
                     if (meshes[index]) {
                         totalVertices += meshes[index].getTotalVertices();

+ 15 - 0
Babylon/Mesh/babylon.mesh.vertexData.js

@@ -275,6 +275,7 @@ var BABYLON;
                 }
                 idc += l;
             }
+            // vertical distances (v)
             for (i = 0; i < minlg; i++) {
                 vTotalDistance[i] = 0;
                 vs[i] = [0];
@@ -376,6 +377,7 @@ var BABYLON;
             var normals = [];
             var uvs = [];
             size = size || 1;
+            // Create each face in turn.
             for (var index = 0; index < normalsSource.length; index++) {
                 var normal = normalsSource[index];
                 // Get two vectors perpendicular to the face normal and to each other.
@@ -499,6 +501,7 @@ var BABYLON;
                     offset.scaleInPlace(-1);
                     textureScale.x = -textureScale.x;
                 }
+                // Positions, normals & uvs
                 for (var i = 0; i < tessellation; i++) {
                     var circleVector = getCircleVector(i);
                     var position = circleVector.scale(radius).add(offset);
@@ -506,6 +509,7 @@ var BABYLON;
                     positions.push(position.x, position.y, position.z);
                     uvs.push(textureCoordinate.x, textureCoordinate.y);
                 }
+                // Indices
                 for (i = 0; i < tessellation - 2; i++) {
                     if (!isTop) {
                         indices.push(vbase);
@@ -522,6 +526,7 @@ var BABYLON;
             var base = new BABYLON.Vector3(0, -1, 0).scale(height / 2);
             var offset = new BABYLON.Vector3(0, 1, 0).scale(height / subdivisions);
             var stride = tessellation + 1;
+            // Positions, normals & uvs
             for (var i = 0; i <= tessellation; i++) {
                 var circleVector = getCircleVector(i);
                 var textureCoordinate = new BABYLON.Vector2(i / tessellation, 0);
@@ -538,6 +543,7 @@ var BABYLON;
                 }
             }
             subdivisions += 1;
+            // Indices
             for (s = 0; s < subdivisions - 1; s++) {
                 for (i = 0; i <= tessellation; i++) {
                     indices.push(i * subdivisions + s);
@@ -733,6 +739,7 @@ var BABYLON;
             var normals = [];
             var uvs = [];
             var row, col;
+            // Vertices
             for (row = 0; row <= subdivisions; row++) {
                 for (col = 0; col <= subdivisions; col++) {
                     var position = new BABYLON.Vector3((col * width) / subdivisions - (width / 2.0), 0, ((subdivisions - row) * height) / subdivisions - (height / 2.0));
@@ -751,6 +758,7 @@ var BABYLON;
                     uvs.push(col / subdivisions, 1.0 - row / subdivisions);
                 }
             }
+            // Indices
             for (row = 0; row < subdivisions; row++) {
                 for (col = 0; col < subdivisions; col++) {
                     indices.push(col + 1 + (row + 1) * (subdivisions + 1));
@@ -868,6 +876,7 @@ var BABYLON;
                 var tz = radius * Math.sin(quOverP) * 0.5;
                 return new BABYLON.Vector3(tx, ty, tz);
             };
+            // Vertices
             for (var i = 0; i <= radialSegments; i++) {
                 var modI = i % radialSegments;
                 var u = modI / radialSegments * 2 * p * Math.PI;
@@ -980,6 +989,7 @@ var BABYLON;
                 normals[i3 * 3 + 1] = vertexNormali3.y;
                 normals[i3 * 3 + 2] = vertexNormali3.z;
             }
+            // last normalization
             for (index = 0; index < normals.length / 3; index++) {
                 BABYLON.Vector3.FromFloatsToRef(normals[index * 3], normals[index * 3 + 1], normals[index * 3 + 2], vertexNormali1);
                 vertexNormali1.normalize();
@@ -996,14 +1006,17 @@ var BABYLON;
             sideOrientation = sideOrientation || BABYLON.Mesh.DEFAULTSIDE;
             switch (sideOrientation) {
                 case BABYLON.Mesh.FRONTSIDE:
+                    // nothing changed
                     break;
                 case BABYLON.Mesh.BACKSIDE:
                     var tmp;
+                    // indices
                     for (i = 0; i < li; i += 3) {
                         tmp = indices[i];
                         indices[i] = indices[i + 2];
                         indices[i + 2] = tmp;
                     }
+                    // normals
                     for (n = 0; n < ln; n++) {
                         normals[n] = -normals[n];
                     }
@@ -1015,11 +1028,13 @@ var BABYLON;
                     for (var p = 0; p < lp; p++) {
                         positions[lp + p] = positions[p];
                     }
+                    // indices
                     for (i = 0; i < li; i += 3) {
                         indices[i + li] = indices[i + 2] + l;
                         indices[i + 1 + li] = indices[i + 1] + l;
                         indices[i + 2 + li] = indices[i] + l;
                     }
+                    // normals
                     for (n = 0; n < ln; n++) {
                         normals[ln + n] = -normals[n];
                     }

+ 8 - 7
Babylon/Mesh/babylon.meshSimplification.js

@@ -71,7 +71,7 @@ var BABYLON;
         };
         SimplificationQueue.prototype.getSimplifier = function (task) {
             switch (task.simplificationType) {
-                case 0 /* QUADRATIC */:
+                case SimplificationType.QUADRATIC:
                 default:
                     return new QuadraticErrorSimplification(task.mesh);
             }
@@ -128,7 +128,9 @@ var BABYLON;
             }
         }
         QuadraticMatrix.prototype.det = function (a11, a12, a13, a21, a22, a23, a31, a32, a33) {
-            var det = this.data[a11] * this.data[a22] * this.data[a33] + this.data[a13] * this.data[a21] * this.data[a32] + this.data[a12] * this.data[a23] * this.data[a31] - this.data[a13] * this.data[a22] * this.data[a31] - this.data[a11] * this.data[a23] * this.data[a32] - this.data[a12] * this.data[a21] * this.data[a33];
+            var det = this.data[a11] * this.data[a22] * this.data[a33] + this.data[a13] * this.data[a21] * this.data[a32] +
+                this.data[a12] * this.data[a23] * this.data[a31] - this.data[a13] * this.data[a22] * this.data[a31] -
+                this.data[a11] * this.data[a23] * this.data[a32] - this.data[a12] * this.data[a21] * this.data[a33];
             return det;
         };
         QuadraticMatrix.prototype.addInPlace = function (matrix) {
@@ -293,9 +295,7 @@ var BABYLON;
                             }
                         }
                     };
-                    BABYLON.AsyncLoop.SyncAsyncForLoop(_this.triangles.length, _this.syncIterations, trianglesIterator, callback, function () {
-                        return (triangleCount - deletedTriangles <= targetCount);
-                    });
+                    BABYLON.AsyncLoop.SyncAsyncForLoop(_this.triangles.length, _this.syncIterations, trianglesIterator, callback, function () { return (triangleCount - deletedTriangles <= targetCount); });
                 }, 0);
             };
             BABYLON.AsyncLoop.Run(this.decimationIterations, function (loop) {
@@ -485,7 +485,7 @@ var BABYLON;
                 var s = this.references[vertex1.triangleStart + i].vertexId;
                 var v1 = t.vertices[(s + 1) % 3];
                 var v2 = t.vertices[(s + 2) % 3];
-                if ((v1 === vertex2 || v2 === vertex2)) {
+                if ((v1 === vertex2 || v2 === vertex2) /* && !this.isTriangleOnBoundingBox(t)*/) {
                     deletedArray[i] = true;
                     delTr.push(t);
                     continue;
@@ -610,7 +610,8 @@ var BABYLON;
             var x = point.x;
             var y = point.y;
             var z = point.z;
-            return q.data[0] * x * x + 2 * q.data[1] * x * y + 2 * q.data[2] * x * z + 2 * q.data[3] * x + q.data[4] * y * y + 2 * q.data[5] * y * z + 2 * q.data[6] * y + q.data[7] * z * z + 2 * q.data[8] * z + q.data[9];
+            return q.data[0] * x * x + 2 * q.data[1] * x * y + 2 * q.data[2] * x * z + 2 * q.data[3] * x + q.data[4] * y * y
+                + 2 * q.data[5] * y * z + 2 * q.data[6] * y + q.data[7] * z * z + 2 * q.data[8] * z + q.data[9];
         };
         QuadraticErrorSimplification.prototype.calculateError = function (vertex1, vertex2, pointResult, normalResult, uvResult, colorResult) {
             var q = vertex1.q.add(vertex2.q);

+ 1 - 0
Babylon/Mesh/babylon.subMesh.js

@@ -87,6 +87,7 @@ var BABYLON;
         };
         SubMesh.prototype.intersects = function (ray, positions, indices, fastCheck) {
             var intersectInfo = null;
+            // Triangles test
             for (var index = this.indexStart; index < this.indexStart + this.indexCount; index += 3) {
                 var p0 = positions[indices[index]];
                 var p1 = positions[indices[index + 1]];

+ 1 - 0
Babylon/Mesh/babylon.vertexBuffer.js

@@ -18,6 +18,7 @@ var BABYLON;
                 this._strideSize = stride;
                 return;
             }
+            // Deduce stride from kind
             switch (kind) {
                 case VertexBuffer.PositionKind:
                     this._strideSize = 3;

+ 2 - 0
Babylon/Physics/Plugins/babylon.cannonJSPlugin.js

@@ -110,11 +110,13 @@ var BABYLON;
         CannonJSPlugin.prototype._createConvexPolyhedron = function (rawVerts, rawFaces, mesh, options) {
             var verts = [], faces = [];
             mesh.computeWorldMatrix(true);
+            // Get vertices
             for (var i = 0; i < rawVerts.length; i += 3) {
                 var transformed = BABYLON.Vector3.Zero();
                 BABYLON.Vector3.TransformNormalFromFloatsToRef(rawVerts[i], rawVerts[i + 1], rawVerts[i + 2], mesh.getWorldMatrix(), transformed);
                 verts.push(new CANNON.Vec3(transformed.x, transformed.z, transformed.y));
             }
+            // Get faces
             for (var j = 0; j < rawFaces.length; j += 3) {
                 faces.push([rawFaces[j], rawFaces[j + 2], rawFaces[j + 1]]);
             }

+ 2 - 0
Babylon/Physics/Plugins/babylon.oimoJSPlugin.js

@@ -63,6 +63,7 @@ var BABYLON;
                 initialRotation.toRotationMatrix(m);
                 deltaPosition = BABYLON.Vector3.TransformCoordinates(deltaPosition, m);
             }
+            // register mesh
             switch (impostor) {
                 case BABYLON.PhysicsEngine.SphereImpostor:
                     var radiusX = bbox.maximumWorld.x - bbox.minimumWorld.x;
@@ -80,6 +81,7 @@ var BABYLON;
                     });
                     break;
                 case BABYLON.PhysicsEngine.PlaneImpostor:
+                //Oimo "fakes" a cylinder as a box, so why don't we!
                 case BABYLON.PhysicsEngine.CylinderImpostor:
                 case BABYLON.PhysicsEngine.BoxImpostor:
                     var min = bbox.minimumWorld;

+ 2 - 6
Babylon/PostProcess/RenderPipeline/babylon.postProcessRenderPipeline.js

@@ -74,9 +74,7 @@ var BABYLON;
             for (var i = 0; i < _cam.length; i++) {
                 var camera = _cam[i];
                 var cameraName = camera.name;
-                this._renderEffectsForIsolatedPass[cameraName] = this._renderEffectsForIsolatedPass[cameraName] || new BABYLON.PostProcessRenderEffect(this._engine, PostProcessRenderPipeline.PASS_EFFECT_NAME, function () {
-                    return new BABYLON.DisplayPassPostProcess(PostProcessRenderPipeline.PASS_EFFECT_NAME, 1.0, null, null, _this._engine, true);
-                });
+                this._renderEffectsForIsolatedPass[cameraName] = this._renderEffectsForIsolatedPass[cameraName] || new BABYLON.PostProcessRenderEffect(this._engine, PostProcessRenderPipeline.PASS_EFFECT_NAME, function () { return new BABYLON.DisplayPassPostProcess(PostProcessRenderPipeline.PASS_EFFECT_NAME, 1.0, null, null, _this._engine, true); });
                 this._renderEffectsForIsolatedPass[cameraName].emptyPasses();
                 this._renderEffectsForIsolatedPass[cameraName].addPass(pass);
                 this._renderEffectsForIsolatedPass[cameraName]._attachCameras(camera);
@@ -88,9 +86,7 @@ var BABYLON;
             for (var i = 0; i < _cam.length; i++) {
                 var camera = _cam[i];
                 var cameraName = camera.name;
-                this._renderEffectsForIsolatedPass[cameraName] = this._renderEffectsForIsolatedPass[cameraName] || new BABYLON.PostProcessRenderEffect(this._engine, PostProcessRenderPipeline.PASS_EFFECT_NAME, function () {
-                    return new BABYLON.DisplayPassPostProcess(PostProcessRenderPipeline.PASS_EFFECT_NAME, 1.0, null, null, _this._engine, true);
-                });
+                this._renderEffectsForIsolatedPass[cameraName] = this._renderEffectsForIsolatedPass[cameraName] || new BABYLON.PostProcessRenderEffect(this._engine, PostProcessRenderPipeline.PASS_EFFECT_NAME, function () { return new BABYLON.DisplayPassPostProcess(PostProcessRenderPipeline.PASS_EFFECT_NAME, 1.0, null, null, _this._engine, true); });
                 this._renderEffectsForIsolatedPass[cameraName]._disable(camera);
             }
             for (var renderEffectName in this._renderEffects) {

+ 20 - 66
Babylon/PostProcess/babylon.lensRenderingPipeline.js

@@ -87,15 +87,9 @@ var BABYLON;
             this._createHighlightsPostProcess(ratio);
             this._createDepthOfFieldPostProcess(ratio);
             // Set up pipeline
-            this.addEffect(new BABYLON.PostProcessRenderEffect(scene.getEngine(), this.LensChromaticAberrationEffect, function () {
-                return _this._chromaticAberrationPostProcess;
-            }, true));
-            this.addEffect(new BABYLON.PostProcessRenderEffect(scene.getEngine(), this.HighlightsEnhancingEffect, function () {
-                return _this._highlightsPostProcess;
-            }, true));
-            this.addEffect(new BABYLON.PostProcessRenderEffect(scene.getEngine(), this.LensDepthOfFieldEffect, function () {
-                return _this._depthOfFieldPostProcess;
-            }, true));
+            this.addEffect(new BABYLON.PostProcessRenderEffect(scene.getEngine(), this.LensChromaticAberrationEffect, function () { return _this._chromaticAberrationPostProcess; }, true));
+            this.addEffect(new BABYLON.PostProcessRenderEffect(scene.getEngine(), this.HighlightsEnhancingEffect, function () { return _this._highlightsPostProcess; }, true));
+            this.addEffect(new BABYLON.PostProcessRenderEffect(scene.getEngine(), this.LensDepthOfFieldEffect, function () { return _this._depthOfFieldPostProcess; }, true));
             if (this._highlightsGain == -1) {
                 this._disableEffect(this.HighlightsEnhancingEffect, null);
             }
@@ -106,51 +100,21 @@ var BABYLON;
             }
         }
         // public methods (self explanatory)
-        LensRenderingPipeline.prototype.setEdgeBlur = function (amount) {
-            this._edgeBlur = amount;
-        };
-        LensRenderingPipeline.prototype.disableEdgeBlur = function () {
-            this._edgeBlur = 0;
-        };
-        LensRenderingPipeline.prototype.setGrainAmount = function (amount) {
-            this._grainAmount = amount;
-        };
-        LensRenderingPipeline.prototype.disableGrain = function () {
-            this._grainAmount = 0;
-        };
-        LensRenderingPipeline.prototype.setChromaticAberration = function (amount) {
-            this._chromaticAberration = amount;
-        };
-        LensRenderingPipeline.prototype.disableChromaticAberration = function () {
-            this._chromaticAberration = 0;
-        };
-        LensRenderingPipeline.prototype.setEdgeDistortion = function (amount) {
-            this._distortion = amount;
-        };
-        LensRenderingPipeline.prototype.disableEdgeDistortion = function () {
-            this._distortion = 0;
-        };
-        LensRenderingPipeline.prototype.setFocusDepth = function (amount) {
-            this._dofDepth = amount;
-        };
-        LensRenderingPipeline.prototype.disableDepthOfField = function () {
-            this._dofDepth = -1;
-        };
-        LensRenderingPipeline.prototype.setAperture = function (amount) {
-            this._dofAperture = amount;
-        };
-        LensRenderingPipeline.prototype.enablePentagonBokeh = function () {
-            this._dofPentagon = true;
-        };
-        LensRenderingPipeline.prototype.disablePentagonBokeh = function () {
-            this._dofPentagon = false;
-        };
-        LensRenderingPipeline.prototype.enableNoiseBlur = function () {
-            this._blurNoise = true;
-        };
-        LensRenderingPipeline.prototype.disableNoiseBlur = function () {
-            this._blurNoise = false;
-        };
+        LensRenderingPipeline.prototype.setEdgeBlur = function (amount) { this._edgeBlur = amount; };
+        LensRenderingPipeline.prototype.disableEdgeBlur = function () { this._edgeBlur = 0; };
+        LensRenderingPipeline.prototype.setGrainAmount = function (amount) { this._grainAmount = amount; };
+        LensRenderingPipeline.prototype.disableGrain = function () { this._grainAmount = 0; };
+        LensRenderingPipeline.prototype.setChromaticAberration = function (amount) { this._chromaticAberration = amount; };
+        LensRenderingPipeline.prototype.disableChromaticAberration = function () { this._chromaticAberration = 0; };
+        LensRenderingPipeline.prototype.setEdgeDistortion = function (amount) { this._distortion = amount; };
+        LensRenderingPipeline.prototype.disableEdgeDistortion = function () { this._distortion = 0; };
+        LensRenderingPipeline.prototype.setFocusDepth = function (amount) { this._dofDepth = amount; };
+        LensRenderingPipeline.prototype.disableDepthOfField = function () { this._dofDepth = -1; };
+        LensRenderingPipeline.prototype.setAperture = function (amount) { this._dofAperture = amount; };
+        LensRenderingPipeline.prototype.enablePentagonBokeh = function () { this._dofPentagon = true; };
+        LensRenderingPipeline.prototype.disablePentagonBokeh = function () { this._dofPentagon = false; };
+        LensRenderingPipeline.prototype.enableNoiseBlur = function () { this._blurNoise = true; };
+        LensRenderingPipeline.prototype.disableNoiseBlur = function () { this._blurNoise = false; };
         LensRenderingPipeline.prototype.setHighlightsGain = function (amount) {
             this._highlightsGain = amount;
         };
@@ -203,18 +167,8 @@ var BABYLON;
         LensRenderingPipeline.prototype._createDepthOfFieldPostProcess = function (ratio) {
             var _this = this;
             this._depthOfFieldPostProcess = new BABYLON.PostProcess("LensDepthOfField", "depthOfField", [
-                "focus_depth",
-                "aperture",
-                "pentagon",
-                "maxZ",
-                "edge_blur",
-                "chromatic_aberration",
-                "distortion",
-                "blur_noise",
-                "grain_amount",
-                "screen_width",
-                "screen_height",
-                "highlights"
+                "focus_depth", "aperture", "pentagon", "maxZ", "edge_blur", "chromatic_aberration",
+                "distortion", "blur_noise", "grain_amount", "screen_width", "screen_height", "highlights"
             ], ["depthSampler", "grainSampler", "highlightsSampler"], ratio, null, BABYLON.Texture.TRILINEAR_SAMPLINGMODE, this._scene.getEngine(), false);
             this._depthOfFieldPostProcess.onApply = function (effect) {
                 effect.setBool('blur_noise', _this._blurNoise);

+ 21 - 63
Babylon/PostProcess/babylon.ssaoRenderingPipeline.js

@@ -81,21 +81,11 @@ var BABYLON;
             this._blurVPostProcess = new BABYLON.BlurPostProcess("SSAOBlurV", new BABYLON.Vector2(0.0, 2.0), 2.0, ssaoRatio, null, BABYLON.Texture.BILINEAR_SAMPLINGMODE, scene.getEngine(), false);
             this._createSSAOCombinePostProcess(combineRatio);
             // Set up pipeline
-            this.addEffect(new BABYLON.PostProcessRenderEffect(scene.getEngine(), this.SSAOOriginalSceneColorEffect, function () {
-                return _this._originalColorPostProcess;
-            }, true));
-            this.addEffect(new BABYLON.PostProcessRenderEffect(scene.getEngine(), this.SSAORenderEffect, function () {
-                return _this._ssaoPostProcess;
-            }, true));
-            this.addEffect(new BABYLON.PostProcessRenderEffect(scene.getEngine(), this.SSAOBlurHRenderEffect, function () {
-                return _this._blurHPostProcess;
-            }, true));
-            this.addEffect(new BABYLON.PostProcessRenderEffect(scene.getEngine(), this.SSAOBlurVRenderEffect, function () {
-                return _this._blurVPostProcess;
-            }, true));
-            this.addEffect(new BABYLON.PostProcessRenderEffect(scene.getEngine(), this.SSAOCombineRenderEffect, function () {
-                return _this._ssaoCombinePostProcess;
-            }, true));
+            this.addEffect(new BABYLON.PostProcessRenderEffect(scene.getEngine(), this.SSAOOriginalSceneColorEffect, function () { return _this._originalColorPostProcess; }, true));
+            this.addEffect(new BABYLON.PostProcessRenderEffect(scene.getEngine(), this.SSAORenderEffect, function () { return _this._ssaoPostProcess; }, true));
+            this.addEffect(new BABYLON.PostProcessRenderEffect(scene.getEngine(), this.SSAOBlurHRenderEffect, function () { return _this._blurHPostProcess; }, true));
+            this.addEffect(new BABYLON.PostProcessRenderEffect(scene.getEngine(), this.SSAOBlurVRenderEffect, function () { return _this._blurVPostProcess; }, true));
+            this.addEffect(new BABYLON.PostProcessRenderEffect(scene.getEngine(), this.SSAOCombineRenderEffect, function () { return _this._ssaoCombinePostProcess; }, true));
             // Finish
             scene.postProcessRenderPipelineManager.addPipeline(this);
             if (cameras)
@@ -135,54 +125,22 @@ var BABYLON;
         SSAORenderingPipeline.prototype._createSSAOPostProcess = function (ratio) {
             var _this = this;
             var sampleSphere = [
-                0.5381,
-                0.1856,
-                -0.4319,
-                0.1379,
-                0.2486,
-                0.4430,
-                0.3371,
-                0.5679,
-                -0.0057,
-                -0.6999,
-                -0.0451,
-                -0.0019,
-                0.0689,
-                -0.1598,
-                -0.8547,
-                0.0560,
-                0.0069,
-                -0.1843,
-                -0.0146,
-                0.1402,
-                0.0762,
-                0.0100,
-                -0.1924,
-                -0.0344,
-                -0.3577,
-                -0.5301,
-                -0.4358,
-                -0.3169,
-                0.1063,
-                0.0158,
-                0.0103,
-                -0.5869,
-                0.0046,
-                -0.0897,
-                -0.4940,
-                0.3287,
-                0.7119,
-                -0.0154,
-                -0.0918,
-                -0.0533,
-                0.0596,
-                -0.5411,
-                0.0352,
-                -0.0631,
-                0.5460,
-                -0.4776,
-                0.2847,
-                -0.0271
+                0.5381, 0.1856, -0.4319,
+                0.1379, 0.2486, 0.4430,
+                0.3371, 0.5679, -0.0057,
+                -0.6999, -0.0451, -0.0019,
+                0.0689, -0.1598, -0.8547,
+                0.0560, 0.0069, -0.1843,
+                -0.0146, 0.1402, 0.0762,
+                0.0100, -0.1924, -0.0344,
+                -0.3577, -0.5301, -0.4358,
+                -0.3169, 0.1063, 0.0158,
+                0.0103, -0.5869, 0.0046,
+                -0.0897, -0.4940, 0.3287,
+                0.7119, -0.0154, -0.0918,
+                -0.0533, 0.0596, -0.5411,
+                0.0352, -0.0631, 0.5460,
+                -0.4776, 0.2847, -0.0271
             ];
             var samplesFactor = 1.0 / 16.0;
             this._ssaoPostProcess = new BABYLON.PostProcess("ssao", "ssao", ["sampleSphere", "samplesFactor", "randTextureTiles", "totalStrength", "radius", "area", "fallOff"], ["randomSampler"], ratio, null, BABYLON.Texture.BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false);

+ 1 - 0
Babylon/PostProcess/babylon.volumetricLightScatteringPostProcess.js

@@ -226,6 +226,7 @@ var BABYLON;
                 }
                 engine.setAlphaTesting(false);
                 if (transparentSubMeshes.length) {
+                    // Sort sub meshes
                     for (index = 0; index < transparentSubMeshes.length; index++) {
                         var submesh = transparentSubMeshes.data[index];
                         submesh._alphaIndex = submesh.getMesh().alphaIndex;

+ 7 - 7
Babylon/PostProcess/babylon.oculusDistortionCorrectionPostProcess.js

@@ -6,12 +6,12 @@ var __extends = this.__extends || function (d, b) {
 };
 var BABYLON;
 (function (BABYLON) {
-    var OculusDistortionCorrectionPostProcess = (function (_super) {
-        __extends(OculusDistortionCorrectionPostProcess, _super);
+    var VRDistortionCorrectionPostProcess = (function (_super) {
+        __extends(VRDistortionCorrectionPostProcess, _super);
         //ANY
-        function OculusDistortionCorrectionPostProcess(name, camera, isRightEye, cameraSettings) {
+        function VRDistortionCorrectionPostProcess(name, camera, isRightEye, cameraSettings) {
             var _this = this;
-            _super.call(this, name, "oculusDistortionCorrection", [
+            _super.call(this, name, "vrDistortionCorrection", [
                 'LensCenter',
                 'Scale',
                 'ScaleIn',
@@ -34,8 +34,8 @@ var BABYLON;
                 effect.setFloat4("HmdWarpParam", _this._distortionFactors[0], _this._distortionFactors[1], _this._distortionFactors[2], _this._distortionFactors[3]);
             };
         }
-        return OculusDistortionCorrectionPostProcess;
+        return VRDistortionCorrectionPostProcess;
     })(BABYLON.PostProcess);
-    BABYLON.OculusDistortionCorrectionPostProcess = OculusDistortionCorrectionPostProcess;
+    BABYLON.VRDistortionCorrectionPostProcess = VRDistortionCorrectionPostProcess;
 })(BABYLON || (BABYLON = {}));
-//# sourceMappingURL=babylon.oculusDistortionCorrectionPostProcess.js.map
+//# sourceMappingURL=babylon.vrDistortionCorrectionPostProcess.js.map

+ 2 - 2
Babylon/PostProcess/babylon.oculusDistortionCorrectionPostProcess.ts

@@ -1,5 +1,5 @@
 module BABYLON {
-    export class OculusDistortionCorrectionPostProcess extends PostProcess {
+    export class VRDistortionCorrectionPostProcess extends PostProcess {
         public aspectRatio: number;
 
         private _isRightEye: boolean;
@@ -12,7 +12,7 @@
 
         //ANY
         constructor(name: string, camera: Camera, isRightEye: boolean, cameraSettings: any) {
-            super(name, "oculusDistortionCorrection", [
+            super(name, "vrDistortionCorrection", [
                 'LensCenter',
                 'Scale',
                 'ScaleIn',

+ 3 - 1
Babylon/Rendering/babylon.boundingBoxRenderer.js

@@ -41,7 +41,9 @@ var BABYLON;
                 var max = boundingBox.maximum;
                 var diff = max.subtract(min);
                 var median = min.add(diff.scale(0.5));
-                var worldMatrix = BABYLON.Matrix.Scaling(diff.x, diff.y, diff.z).multiply(BABYLON.Matrix.Translation(median.x, median.y, median.z)).multiply(boundingBox.getWorldMatrix());
+                var worldMatrix = BABYLON.Matrix.Scaling(diff.x, diff.y, diff.z)
+                    .multiply(BABYLON.Matrix.Translation(median.x, median.y, median.z))
+                    .multiply(boundingBox.getWorldMatrix());
                 // VBOs
                 engine.bindBuffers(this._vb.getBuffer(), this._ib, [3], 3 * 4, this._colorShader.getEffect());
                 if (this.showBackLines) {

+ 1 - 3
Babylon/Rendering/babylon.outlineRenderer.js

@@ -30,9 +30,7 @@ var BABYLON;
                 this._effect.setTexture("diffuseSampler", alphaTexture);
                 this._effect.setMatrix("diffuseMatrix", alphaTexture.getTextureMatrix());
             }
-            mesh._processRendering(subMesh, this._effect, BABYLON.Material.TriangleFillMode, batch, hardwareInstancedRendering, function (isInstance, world) {
-                _this._effect.setMatrix("world", world);
-            });
+            mesh._processRendering(subMesh, this._effect, BABYLON.Material.TriangleFillMode, batch, hardwareInstancedRendering, function (isInstance, world) { _this._effect.setMatrix("world", world); });
         };
         OutlineRenderer.prototype.isReady = function (subMesh, useInstances) {
             var defines = [];

+ 1 - 0
Babylon/Rendering/babylon.renderingGroup.js

@@ -33,6 +33,7 @@ var BABYLON;
             engine.setAlphaTesting(false);
             // Transparent
             if (this._transparentSubMeshes.length) {
+                // Sorting
                 for (subIndex = 0; subIndex < this._transparentSubMeshes.length; subIndex++) {
                     submesh = this._transparentSubMeshes.data[subIndex];
                     submesh._alphaIndex = submesh.getMesh().alphaIndex;

Babylon/Shaders/oculusDistortionCorrection.fragment.fx → Babylon/Shaders/vrDistortionCorrection.fragment.fx


+ 4 - 6
Babylon/Tools/babylon.database.js

@@ -179,6 +179,7 @@ var BABYLON;
                         try {
                             blobTextureURL = URL.createObjectURL(blob, { oneTimeOnly: true });
                         }
+                        // Chrome is raising a type error if we're setting the oneTimeOnly parameter
                         catch (ex) {
                             blobTextureURL = URL.createObjectURL(blob);
                         }
@@ -202,8 +203,7 @@ var BABYLON;
                                         this.hasReachedQuota = true;
                                     }
                                 }
-                                catch (ex) {
-                                }
+                                catch (ex) { }
                                 generateBlobUrl();
                             };
                             transaction.oncomplete = function (event) {
@@ -311,8 +311,7 @@ var BABYLON;
                                 _this.hasReachedQuota = true;
                             }
                         }
-                        catch (ex) {
-                        }
+                        catch (ex) { }
                         callback(-1);
                     };
                     transaction.oncomplete = function (event) {
@@ -426,8 +425,7 @@ var BABYLON;
                                         this.hasReachedQuota = true;
                                     }
                                 }
-                                catch (ex) {
-                                }
+                                catch (ex) { }
                                 callback(fileData);
                             };
                             transaction.oncomplete = function (event) {

+ 7 - 13
Babylon/Tools/babylon.filesInput.js

@@ -17,15 +17,9 @@ var BABYLON;
             var _this = this;
             if (p_elementToMonitor) {
                 this._elementToMonitor = p_elementToMonitor;
-                this._elementToMonitor.addEventListener("dragenter", function (e) {
-                    _this.drag(e);
-                }, false);
-                this._elementToMonitor.addEventListener("dragover", function (e) {
-                    _this.drag(e);
-                }, false);
-                this._elementToMonitor.addEventListener("drop", function (e) {
-                    _this.drop(e);
-                }, false);
+                this._elementToMonitor.addEventListener("dragenter", function (e) { _this.drag(e); }, false);
+                this._elementToMonitor.addEventListener("dragover", function (e) { _this.drag(e); }, false);
+                this._elementToMonitor.addEventListener("drop", function (e) { _this.drop(e); }, false);
             }
         };
         FilesInput.prototype.renderFunction = function () {
@@ -82,7 +76,9 @@ var BABYLON;
                             FilesInput.FilesToLoad[this._filesToLoad[i].name] = this._filesToLoad[i];
                             break;
                         default:
-                            if (this._filesToLoad[i].name.indexOf(".babylon") !== -1 && this._filesToLoad[i].name.indexOf(".manifest") === -1 && this._filesToLoad[i].name.indexOf(".incremental") === -1 && this._filesToLoad[i].name.indexOf(".babylonmeshdata") === -1 && this._filesToLoad[i].name.indexOf(".babylongeometrydata") === -1) {
+                            if (this._filesToLoad[i].name.indexOf(".babylon") !== -1 && this._filesToLoad[i].name.indexOf(".manifest") === -1
+                                && this._filesToLoad[i].name.indexOf(".incremental") === -1 && this._filesToLoad[i].name.indexOf(".babylonmeshdata") === -1
+                                && this._filesToLoad[i].name.indexOf(".babylongeometrydata") === -1) {
                                 this._sceneFileToLoad = this._filesToLoad[i];
                             }
                             break;
@@ -112,9 +108,7 @@ var BABYLON;
                         if (that._sceneLoadedCallback) {
                             that._sceneLoadedCallback(_this._sceneFileToLoad, that._currentScene);
                         }
-                        that._engine.runRenderLoop(function () {
-                            that.renderFunction();
-                        });
+                        that._engine.runRenderLoop(function () { that.renderFunction(); });
                     });
                 }, function (progress) {
                     if (_this._progressCallback) {

File diff suppressed because it is too large
+ 20 - 24
Babylon/Tools/babylon.gamepads.js


+ 1 - 0
Babylon/Tools/babylon.sceneOptimizer.js

@@ -158,6 +158,7 @@ var BABYLON;
                         continue;
                     }
                     currentPool.push(current);
+                    // Find compatible meshes
                     for (var subIndex = index + 1; subIndex < globalLength; subIndex++) {
                         var otherMesh = globalPool[subIndex];
                         if (!_this._canBeMerged(otherMesh)) {

+ 0 - 6
Babylon/Tools/babylon.sceneSerializer.js

@@ -91,12 +91,6 @@ var BABYLON;
         else if (camera instanceof BABYLON.FollowCamera) {
             serializationObject.type = "FollowCamera";
         }
-        else if (camera instanceof BABYLON.OculusCamera) {
-            serializationObject.type = "OculusCamera";
-        }
-        else if (camera instanceof BABYLON.OculusGamepadCamera) {
-            serializationObject.type = "OculusGamepadCamera";
-        }
         else if (camera instanceof BABYLON.TouchCamera) {
             serializationObject.type = "TouchCamera";
         }

+ 0 - 4
Babylon/Tools/babylon.sceneSerializer.ts

@@ -96,10 +96,6 @@
             serializationObject.type = "DeviceOrientationCamera";
         } else if (camera instanceof FollowCamera) {
             serializationObject.type = "FollowCamera";
-        } else if (camera instanceof OculusCamera) {
-            serializationObject.type = "OculusCamera";
-        } else if (camera instanceof OculusGamepadCamera) {
-            serializationObject.type = "OculusGamepadCamera";
         } else if (camera instanceof TouchCamera) {
             serializationObject.type = "TouchCamera";
         } else if (camera instanceof VirtualJoysticksCamera) {

+ 1 - 0
Babylon/Tools/babylon.smartCollection.js

@@ -29,6 +29,7 @@ var BABYLON;
         SmartCollection.prototype.removeItemOfIndex = function (index) {
             if (index < this.count && index > -1) {
                 delete this.items[this._keys[index]];
+                //here, shifting by hand is better optimised than .splice
                 while (index < this.count) {
                     this._keys[index] = this._keys[index + 1];
                     index++;

+ 4 - 1
Babylon/Tools/babylon.tools.dds.js

@@ -11,7 +11,10 @@ var BABYLON;
         var DDSCAPS2_CUBEMAP = 0x200, DDSCAPS2_CUBEMAP_POSITIVEX = 0x400, DDSCAPS2_CUBEMAP_NEGATIVEX = 0x800, DDSCAPS2_CUBEMAP_POSITIVEY = 0x1000, DDSCAPS2_CUBEMAP_NEGATIVEY = 0x2000, DDSCAPS2_CUBEMAP_POSITIVEZ = 0x4000, DDSCAPS2_CUBEMAP_NEGATIVEZ = 0x8000, DDSCAPS2_VOLUME = 0x200000;
         var DDPF_ALPHAPIXELS = 0x1, DDPF_ALPHA = 0x2, DDPF_FOURCC = 0x4, DDPF_RGB = 0x40, DDPF_YUV = 0x200, DDPF_LUMINANCE = 0x20000;
         function FourCCToInt32(value) {
-            return value.charCodeAt(0) + (value.charCodeAt(1) << 8) + (value.charCodeAt(2) << 16) + (value.charCodeAt(3) << 24);
+            return value.charCodeAt(0) +
+                (value.charCodeAt(1) << 8) +
+                (value.charCodeAt(2) << 16) +
+                (value.charCodeAt(3) << 24);
         }
         function Int32ToFourCC(value) {
             return String.fromCharCode(value & 0xff, (value >> 8) & 0xff, (value >> 16) & 0xff, (value >> 24) & 0xff);

+ 1 - 0
Babylon/Tools/babylon.tools.js

@@ -367,6 +367,7 @@ var BABYLON;
             var halfHeight = height / 2;
             //Reading datas from WebGL
             var data = engine.readPixels(0, 0, width, height);
+            //To flip image on Y axis.
             for (var i = 0; i < halfHeight; i++) {
                 for (var j = 0; j < numberOfChannelsByLine; j++) {
                     var currentCell = j + i * numberOfChannelsByLine;

+ 3 - 0
Babylon/Tools/babylon.tools.tga.js

@@ -50,6 +50,7 @@ var BABYLON;
                 var use_pal = false;
                 var use_rgb = false;
                 var use_grey = false;
+                // Get some informations.
                 switch (header.image_type) {
                     case TGATools._TYPE_RLE_INDEXED:
                         use_rle = true;
@@ -87,9 +88,11 @@ var BABYLON;
                         count = (c & 0x7f) + 1;
                         // RLE pixels
                         if (c & 0x80) {
+                            // Bind pixel tmp array
                             for (i = 0; i < pixel_size; ++i) {
                                 pixels[i] = data[offset++];
                             }
+                            // Copy pixel array
                             for (i = 0; i < count; ++i) {
                                 pixel_data.set(pixels, localOffset + i * pixel_size);
                             }

+ 18 - 22
Babylon/Tools/babylon.virtualJoystick.js

@@ -22,8 +22,8 @@ var BABYLON;
             VirtualJoystick._globalJoystickIndex++;
             // By default left & right arrow keys are moving the X
             // and up & down keys are moving the Y
-            this._axisTargetedByLeftAndRight = 0 /* X */;
-            this._axisTargetedByUpAndDown = 1 /* Y */;
+            this._axisTargetedByLeftAndRight = JoystickAxis.X;
+            this._axisTargetedByUpAndDown = JoystickAxis.Y;
             this.reverseLeftRight = false;
             this.reverseUpDown = false;
             // collections of pointers
@@ -88,9 +88,7 @@ var BABYLON;
             VirtualJoystick.vjCanvas.addEventListener("contextmenu", function (evt) {
                 evt.preventDefault(); // Disables system menu
             }, false);
-            requestAnimationFrame(function () {
-                _this._drawVirtualJoystick();
-            });
+            requestAnimationFrame(function () { _this._drawVirtualJoystick(); });
         }
         VirtualJoystick.prototype.setJoystickSensibility = function (newJoystickSensibility) {
             this._joystickSensibility = newJoystickSensibility;
@@ -134,26 +132,26 @@ var BABYLON;
                 var directionLeftRight = this.reverseLeftRight ? -1 : 1;
                 var deltaJoystickX = directionLeftRight * this._deltaJoystickVector.x / this._inversedSensibility;
                 switch (this._axisTargetedByLeftAndRight) {
-                    case 0 /* X */:
+                    case JoystickAxis.X:
                         this.deltaPosition.x = Math.min(1, Math.max(-1, deltaJoystickX));
                         break;
-                    case 1 /* Y */:
+                    case JoystickAxis.Y:
                         this.deltaPosition.y = Math.min(1, Math.max(-1, deltaJoystickX));
                         break;
-                    case 2 /* Z */:
+                    case JoystickAxis.Z:
                         this.deltaPosition.z = Math.min(1, Math.max(-1, deltaJoystickX));
                         break;
                 }
                 var directionUpDown = this.reverseUpDown ? 1 : -1;
                 var deltaJoystickY = directionUpDown * this._deltaJoystickVector.y / this._inversedSensibility;
                 switch (this._axisTargetedByUpAndDown) {
-                    case 0 /* X */:
+                    case JoystickAxis.X:
                         this.deltaPosition.x = Math.min(1, Math.max(-1, deltaJoystickY));
                         break;
-                    case 1 /* Y */:
+                    case JoystickAxis.Y:
                         this.deltaPosition.y = Math.min(1, Math.max(-1, deltaJoystickY));
                         break;
-                    case 2 /* Z */:
+                    case JoystickAxis.Z:
                         this.deltaPosition.z = Math.min(1, Math.max(-1, deltaJoystickY));
                         break;
                 }
@@ -188,26 +186,26 @@ var BABYLON;
         // Define which axis you'd like to control for left & right 
         VirtualJoystick.prototype.setAxisForLeftRight = function (axis) {
             switch (axis) {
-                case 0 /* X */:
-                case 1 /* Y */:
-                case 2 /* Z */:
+                case JoystickAxis.X:
+                case JoystickAxis.Y:
+                case JoystickAxis.Z:
                     this._axisTargetedByLeftAndRight = axis;
                     break;
                 default:
-                    this._axisTargetedByLeftAndRight = 0 /* X */;
+                    this._axisTargetedByLeftAndRight = JoystickAxis.X;
                     break;
             }
         };
         // Define which axis you'd like to control for up & down 
         VirtualJoystick.prototype.setAxisForUpDown = function (axis) {
             switch (axis) {
-                case 0 /* X */:
-                case 1 /* Y */:
-                case 2 /* Z */:
+                case JoystickAxis.X:
+                case JoystickAxis.Y:
+                case JoystickAxis.Z:
                     this._axisTargetedByUpAndDown = axis;
                     break;
                 default:
-                    this._axisTargetedByUpAndDown = 1 /* Y */;
+                    this._axisTargetedByUpAndDown = JoystickAxis.Y;
                     break;
             }
         };
@@ -252,9 +250,7 @@ var BABYLON;
                     ;
                 });
             }
-            requestAnimationFrame(function () {
-                _this._drawVirtualJoystick();
-            });
+            requestAnimationFrame(function () { _this._drawVirtualJoystick(); });
         };
         VirtualJoystick.prototype.releaseCanvas = function () {
             if (VirtualJoystick.vjCanvas) {

+ 19 - 9
Babylon/babylon.engine.js

@@ -197,7 +197,10 @@ var BABYLON;
             configurable: true
         });
         _AlphaState.prototype.setAlphaBlendFunctionParameters = function (value0, value1, value2, value3) {
-            if (this._blendFunctionParameters[0] === value0 && this._blendFunctionParameters[1] === value1 && this._blendFunctionParameters[2] === value2 && this._blendFunctionParameters[3] === value3) {
+            if (this._blendFunctionParameters[0] === value0 &&
+                this._blendFunctionParameters[1] === value1 &&
+                this._blendFunctionParameters[2] === value2 &&
+                this._blendFunctionParameters[3] === value3) {
                 return;
             }
             this._blendFunctionParameters[0] = value0;
@@ -380,6 +383,7 @@ var BABYLON;
             this._canvasClientRect = this._renderingCanvas.getBoundingClientRect();
             options = options || {};
             options.antialias = antialias;
+            // GL
             try {
                 this._gl = canvas.getContext("webgl", options) || canvas.getContext("experimental-webgl", options);
             }
@@ -452,7 +456,10 @@ var BABYLON;
                 }
                 // Pointer lock
                 if (_this.isFullscreen && _this._pointerLockRequested) {
-                    canvas.requestPointerLock = canvas.requestPointerLock || canvas.msRequestPointerLock || canvas.mozRequestPointerLock || canvas.webkitRequestPointerLock;
+                    canvas.requestPointerLock = canvas.requestPointerLock ||
+                        canvas.msRequestPointerLock ||
+                        canvas.mozRequestPointerLock ||
+                        canvas.webkitRequestPointerLock;
                     if (canvas.requestPointerLock) {
                         canvas.requestPointerLock();
                     }
@@ -464,7 +471,10 @@ var BABYLON;
             document.addEventListener("msfullscreenchange", this._onFullscreenChange, false);
             // Pointer lock
             this._onPointerLockChange = function () {
-                _this.isPointerLock = (document.mozPointerLockElement === canvas || document.webkitPointerLockElement === canvas || document.msPointerLockElement === canvas || document.pointerLockElement === canvas);
+                _this.isPointerLock = (document.mozPointerLockElement === canvas ||
+                    document.webkitPointerLockElement === canvas ||
+                    document.msPointerLockElement === canvas ||
+                    document.pointerLockElement === canvas);
             };
             document.addEventListener("pointerlockchange", this._onPointerLockChange, false);
             document.addEventListener("mspointerlockchange", this._onPointerLockChange, false);
@@ -1549,12 +1559,8 @@ var BABYLON;
                     _this._workingCanvas.width = width;
                     _this._workingCanvas.height = height;
                     var faces = [
-                        gl.TEXTURE_CUBE_MAP_POSITIVE_X,
-                        gl.TEXTURE_CUBE_MAP_POSITIVE_Y,
-                        gl.TEXTURE_CUBE_MAP_POSITIVE_Z,
-                        gl.TEXTURE_CUBE_MAP_NEGATIVE_X,
-                        gl.TEXTURE_CUBE_MAP_NEGATIVE_Y,
-                        gl.TEXTURE_CUBE_MAP_NEGATIVE_Z
+                        gl.TEXTURE_CUBE_MAP_POSITIVE_X, gl.TEXTURE_CUBE_MAP_POSITIVE_Y, gl.TEXTURE_CUBE_MAP_POSITIVE_Z,
+                        gl.TEXTURE_CUBE_MAP_NEGATIVE_X, gl.TEXTURE_CUBE_MAP_NEGATIVE_Y, gl.TEXTURE_CUBE_MAP_NEGATIVE_Z
                     ];
                     gl.bindTexture(gl.TEXTURE_CUBE_MAP, texture);
                     gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, 0);
@@ -1587,6 +1593,7 @@ var BABYLON;
                 gl.deleteRenderbuffer(texture._depthBuffer);
             }
             gl.deleteTexture(texture);
+            // Unbind channels
             for (var channel = 0; channel < this._caps.maxTexturesImageUnits; channel++) {
                 this._gl.activeTexture(this._gl["TEXTURE" + channel]);
                 this._gl.bindTexture(this._gl.TEXTURE_2D, null);
@@ -1709,14 +1716,17 @@ var BABYLON;
         Engine.prototype.dispose = function () {
             this.hideLoadingUI();
             this.stopRenderLoop();
+            // Release scenes
             while (this.scenes.length) {
                 this.scenes[0].dispose();
             }
             // Release audio engine
             Engine.audioEngine.dispose();
+            // Release effects
             for (var name in this._compiledEffects) {
                 this._gl.deleteProgram(this._compiledEffects[name]._program);
             }
+            // Unbind
             for (var i in this._vertexAttribArrays) {
                 if (i > this._gl.VERTEX_ATTRIB_ARRAY_ENABLED || !this._vertexAttribArrays[i]) {
                     continue;

+ 12 - 3
Babylon/babylon.scene.js

@@ -1074,6 +1074,7 @@ var BABYLON;
             this._evaluateActiveMeshes();
             this._evaluateActiveMeshesDuration += BABYLON.Tools.Now - beforeEvaluateActiveMeshesDate;
             BABYLON.Tools.EndPerformanceCounter("Active meshes evaluation");
+            // Skeletons
             for (var skeletonIndex = 0; skeletonIndex < this._activeSkeletons.length; skeletonIndex++) {
                 var skeleton = this._activeSkeletons.data[skeletonIndex];
                 skeleton.prepare();
@@ -1155,6 +1156,7 @@ var BABYLON;
                 this._renderForCamera(camera);
                 return;
             }
+            // Sub-cameras
             for (var index = 0; index < camera.subCameras.length; index++) {
                 this._renderForCamera(camera.subCameras[index]);
             }
@@ -1319,6 +1321,7 @@ var BABYLON;
             for (callbackIndex = 0; callbackIndex < this._onAfterRenderCallbacks.length; callbackIndex++) {
                 this._onAfterRenderCallbacks[callbackIndex]();
             }
+            // Cleaning
             for (var index = 0; index < this._toBeDisposed.length; index++) {
                 this._toBeDisposed.data[index].dispose();
                 this._toBeDisposed[index] = null;
@@ -1472,27 +1475,35 @@ var BABYLON;
             for (index = 0; index < this.cameras.length; index++) {
                 this.cameras[index].detachControl(canvas);
             }
+            // Release lights
             while (this.lights.length) {
                 this.lights[0].dispose();
             }
+            // Release meshes
             while (this.meshes.length) {
                 this.meshes[0].dispose(true);
             }
+            // Release cameras
             while (this.cameras.length) {
                 this.cameras[0].dispose();
             }
+            // Release materials
             while (this.materials.length) {
                 this.materials[0].dispose();
             }
+            // Release particles
             while (this.particleSystems.length) {
                 this.particleSystems[0].dispose();
             }
+            // Release sprites
             while (this.spriteManagers.length) {
                 this.spriteManagers[0].dispose();
             }
+            // Release layers
             while (this.layers.length) {
                 this.layers[0].dispose();
             }
+            // Release textures
             while (this.textures.length) {
                 this.textures[0].dispose();
             }
@@ -1701,9 +1712,7 @@ var BABYLON;
                 return list;
             }
             var listByTags = [];
-            forEach = forEach || (function (item) {
-                return;
-            });
+            forEach = forEach || (function (item) { return; });
             for (var i in list) {
                 var item = list[i];
                 if (BABYLON.Tags.MatchesQuery(item, tagsQuery)) {

+ 0 - 1
Exporters/3ds Max/Max2Babylon/Forms/ActionsBuilderForm.Designer.cs

@@ -82,7 +82,6 @@
             this.Controls.Add(this.ActionsBuilderWebView);
             this.Name = "ActionsBuilderForm";
             this.Text = "Babylon.js Actions Builder";
-            this.TopMost = true;
             this.Activated += new System.EventHandler(this.ActionsBuilderForm_Activated);
             this.Deactivate += new System.EventHandler(this.ActionsBuilderForm_Deactivate);
             this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.ActionsBuilderForm_FormClosed);

+ 12 - 3
Exporters/3ds Max/Max2Babylon/Forms/ActionsBuilderForm.cs

@@ -82,19 +82,25 @@ namespace Max2Babylon
         {
             // Set common properties (name, is scene or object, etc.)
             _document = ActionsBuilderWebView.Document;
+
+            // Update screen
+            _document.InvokeScript("hideButtons");
+
+            // Set object name
             _document.GetElementById("ActionsBuilderObjectName").SetAttribute("value", _objectName);
+            _document.InvokeScript("updateObjectName");
 
             if (isRootNode)
                 _document.InvokeScript("setIsScene");
             else
                 _document.InvokeScript("setIsObject");
 
-            _document.InvokeScript("updateObjectName");
+            //_document.InvokeScript("updateObjectName");
 
             if (getProperty())
             {
                 _document.GetElementById("ActionsBuilderJSON").SetAttribute("value", _jsonResult);
-                _document.InvokeScript("updateGraphFromJSON");
+                _document.InvokeScript("loadFromJSON");
             }
 
             // Set lists of meshes, lights, cameras etc.
@@ -112,13 +118,16 @@ namespace Max2Babylon
 
             fillSoundsList(meshes, "setSoundsNames");
 
+            // Finish
+            _document.InvokeScript("resetList");
+
             // Need to subclass this, then allow 3ds Max usage 
             //Win32.SubClass(this.ActionsBuilderWebView.Handle);
         }
 
         private void butOK_Click(object sender, EventArgs e)
         {
-            _document.InvokeScript("updateJSONFromGraph");
+            _document.InvokeScript("createJSON");
             _jsonResult = _document.GetElementById("ActionsBuilderJSON").GetAttribute("value");
 
             setProperty();

+ 30 - 32
Exporters/3ds Max/Max2Babylon/Forms/CameraPropertiesForm.Designer.cs

@@ -29,6 +29,7 @@
         private void InitializeComponent()
         {
             this.groupBox1 = new System.Windows.Forms.GroupBox();
+            this.ellipsoidControl = new Max2Babylon.Vector3Control();
             this.label3 = new System.Windows.Forms.Label();
             this.chkGravity = new System.Windows.Forms.CheckBox();
             this.chkCollisions = new System.Windows.Forms.CheckBox();
@@ -48,10 +49,9 @@
             this.label5 = new System.Windows.Forms.Label();
             this.chkAutoAnimate = new System.Windows.Forms.CheckBox();
             this.groupBox4 = new System.Windows.Forms.GroupBox();
-            this.chkNoExport = new System.Windows.Forms.CheckBox();
-            this.cbCameraType = new System.Windows.Forms.ComboBox();
             this.label6 = new System.Windows.Forms.Label();
-            this.ellipsoidControl = new Max2Babylon.Vector3Control();
+            this.cbCameraType = new System.Windows.Forms.ComboBox();
+            this.chkNoExport = new System.Windows.Forms.CheckBox();
             this.groupBox1.SuspendLayout();
             this.groupBox2.SuspendLayout();
             ((System.ComponentModel.ISupportInitialize)(this.nupInertia)).BeginInit();
@@ -77,6 +77,16 @@
             this.groupBox1.TabStop = false;
             this.groupBox1.Text = "Collisions";
             // 
+            // ellipsoidControl
+            // 
+            this.ellipsoidControl.Location = new System.Drawing.Point(21, 95);
+            this.ellipsoidControl.Name = "ellipsoidControl";
+            this.ellipsoidControl.Size = new System.Drawing.Size(294, 28);
+            this.ellipsoidControl.TabIndex = 3;
+            this.ellipsoidControl.X = 0F;
+            this.ellipsoidControl.Y = 0F;
+            this.ellipsoidControl.Z = 0F;
+            // 
             // label3
             // 
             this.label3.AutoSize = true;
@@ -297,17 +307,14 @@
             this.groupBox4.TabStop = false;
             this.groupBox4.Text = "Misc.";
             // 
-            // chkNoExport
+            // label6
             // 
-            this.chkNoExport.AutoSize = true;
-            this.chkNoExport.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
-            this.chkNoExport.Location = new System.Drawing.Point(21, 28);
-            this.chkNoExport.Name = "chkNoExport";
-            this.chkNoExport.Size = new System.Drawing.Size(87, 17);
-            this.chkNoExport.TabIndex = 4;
-            this.chkNoExport.Text = "Do not export";
-            this.chkNoExport.ThreeState = true;
-            this.chkNoExport.UseVisualStyleBackColor = true;
+            this.label6.AutoSize = true;
+            this.label6.Location = new System.Drawing.Point(16, 58);
+            this.label6.Name = "label6";
+            this.label6.Size = new System.Drawing.Size(34, 13);
+            this.label6.TabIndex = 6;
+            this.label6.Text = "Type:";
             // 
             // cbCameraType
             // 
@@ -322,8 +329,6 @@
             "FollowCamera",
             "FreeCamera",
             "GamepadCamera",
-            "OculusCamera",
-            "OculusGamepadCamera",
             "TouchCamera",
             "VirtualJoysticksCamera",
             "WebVRCamera",
@@ -333,24 +338,17 @@
             this.cbCameraType.Size = new System.Drawing.Size(290, 21);
             this.cbCameraType.TabIndex = 5;
             // 
-            // label6
-            // 
-            this.label6.AutoSize = true;
-            this.label6.Location = new System.Drawing.Point(16, 58);
-            this.label6.Name = "label6";
-            this.label6.Size = new System.Drawing.Size(34, 13);
-            this.label6.TabIndex = 6;
-            this.label6.Text = "Type:";
-            // 
-            // ellipsoidControl
+            // chkNoExport
             // 
-            this.ellipsoidControl.Location = new System.Drawing.Point(21, 95);
-            this.ellipsoidControl.Name = "ellipsoidControl";
-            this.ellipsoidControl.Size = new System.Drawing.Size(294, 28);
-            this.ellipsoidControl.TabIndex = 3;
-            this.ellipsoidControl.X = 0F;
-            this.ellipsoidControl.Y = 0F;
-            this.ellipsoidControl.Z = 0F;
+            this.chkNoExport.AutoSize = true;
+            this.chkNoExport.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
+            this.chkNoExport.Location = new System.Drawing.Point(21, 28);
+            this.chkNoExport.Name = "chkNoExport";
+            this.chkNoExport.Size = new System.Drawing.Size(87, 17);
+            this.chkNoExport.TabIndex = 4;
+            this.chkNoExport.Text = "Do not export";
+            this.chkNoExport.ThreeState = true;
+            this.chkNoExport.UseVisualStyleBackColor = true;
             // 
             // CameraPropertiesForm
             // 

+ 1 - 4
Exporters/Blender/io_export_babylon.py

@@ -85,10 +85,8 @@ DEV_ORIENT_CAM = 'DeviceOrientationCamera'
 FOLLOW_CAM = 'FollowCamera'
 FREE_CAM = 'FreeCamera' 
 GAMEPAD_CAM = 'GamepadCamera'
-OCULUS_CAM = 'OculusCamera'
 TOUCH_CAM = 'TouchCamera'
 V_JOYSTICKS_CAM = 'VirtualJoysticksCamera'
-OCULUS_GAMEPAD_CAM = 'OculusGamepadCamera'
 VR_DEV_ORIENT_CAM ='VRDeviceOrientationCamera'
 WEB_VR_CAM = 'WebVRCamera'
 
@@ -1734,7 +1732,6 @@ bpy.types.Camera.CameraType = bpy.props.EnumProperty(
     items = ( 
              (V_JOYSTICKS_CAM   , 'Virtual Joysticks'  , 'Use Virtual Joysticks Camera'),
              (TOUCH_CAM         , 'Touch'              , 'Use Touch Camera'),
-             (OCULUS_CAM        , 'Oculus'             , 'Use Oculus Camera'),
              (GAMEPAD_CAM       , 'Gamepad'            , 'Use Gamepad Camera'),
              (FREE_CAM          , 'Free'               , 'Use Free Camera'),
              (FOLLOW_CAM        , 'Follow'             , 'Use Follow Camera'),
@@ -1742,7 +1739,6 @@ bpy.types.Camera.CameraType = bpy.props.EnumProperty(
              (ARC_ROTATE_CAM    , 'Arc Rotate'         , 'Use Arc Rotate Camera'),
              (ANAGLYPH_FREE_CAM , 'Anaglyph Free'      , 'Use Anaglyph Free Camera'), 
              (ANAGLYPH_ARC_CAM  , 'Anaglyph Arc Rotate', 'Use Anaglyph Arc Rotate Camera'),
-             (OCULUS_GAMEPAD_CAM, 'Oculus Gampad'      , 'Use Oculus Gamepad Camera'),
              (VR_DEV_ORIENT_CAM , 'VR Dev Orientation' , 'Use VR Dev Orientation Camera'),
              (WEB_VR_CAM        , 'Web VR'             , 'Use Web VR Camera')
             ),
@@ -1839,3 +1835,4 @@ class ObjectPanel(bpy.types.Panel):
             layout.separator()
 
             layout.prop(ob.data, 'autoAnimate')   
+

+ 2 - 3
Tools/Gulp/config.json

@@ -95,10 +95,9 @@
             "../../Babylon/Physics/babylon.physicsEngine.js",
             "../../Babylon/Tools/babylon.sceneSerializer.js",
             "../../Babylon/Mesh/babylon.csg.js",
-            "../../Babylon/PostProcess/babylon.oculusDistortionCorrectionPostProcess.js",
+            "../../Babylon/PostProcess/babylon.vrDistortionCorrectionPostProcess.js",
             "../../Babylon/Tools/babylon.virtualJoystick.js",
-            "../../Babylon/Cameras/VR/babylon.oculusCamera.js",
-            "../../Babylon/Cameras/VR/babylon.oculusGamepadCamera.js",
+            "../../Babylon/Cameras/VR/babylon.vrCamera.js",
             "../../Babylon/Cameras/babylon.virtualJoysticksCamera.js",
             "../../Babylon/Materials/babylon.shaderMaterial.js",
             "../../Babylon/Mesh/babylon.mesh.vertexData.js",

BIN
Tools/Visual Studio Extensions/Babylon.VSIX


File diff suppressed because it is too large
+ 511 - 647
babylon.2.1-beta.debug.js


File diff suppressed because it is too large
+ 25 - 23
babylon.2.1-beta.js


File diff suppressed because it is too large
+ 25 - 23
babylon.2.1-beta.noworker.js


+ 30 - 2
babylon.2.1.d.ts

@@ -1802,7 +1802,21 @@ declare module BABYLON {
     }
 }
 declare module BABYLON {
-    class VRDeviceOrientationCamera extends BABYLON.OculusCamera {
+    class VRCamera extends FreeCamera {
+        private _leftCamera;
+        private _rightCamera;
+        private _offsetOrientation;
+        private _deviceOrientationHandler;
+        constructor(name: string, position: Vector3, scene: Scene);
+        _update(): void;
+        _updateCamera(camera: FreeCamera): void;
+        _onOrientationEvent(evt: DeviceOrientationEvent): void;
+        attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
+        detachControl(element: HTMLElement): void;
+    }
+}
+declare module BABYLON {
+    class VRDeviceOrientationCamera extends BABYLON.VRCamera {
         _alpha: number;
         _beta: number;
         _gamma: number;
@@ -1813,7 +1827,7 @@ declare module BABYLON {
 declare var HMDVRDevice: any;
 declare var PositionSensorVRDevice: any;
 declare module BABYLON {
-    class WebVRCamera extends BABYLON.OculusCamera {
+    class WebVRCamera extends BABYLON.VRCamera {
         _hmdDevice: any;
         _sensorDevice: any;
         _cacheState: any;
@@ -4912,6 +4926,19 @@ declare module BABYLON {
     }
 }
 declare module BABYLON {
+    class VRDistortionCorrectionPostProcess extends PostProcess {
+        aspectRatio: number;
+        private _isRightEye;
+        private _distortionFactors;
+        private _postProcessScaleFactor;
+        private _lensCenterOffset;
+        private _scaleIn;
+        private _scaleFactor;
+        private _lensCenter;
+        constructor(name: string, camera: Camera, isRightEye: boolean, cameraSettings: any);
+    }
+}
+declare module BABYLON {
     class PostProcessRenderEffect {
         private _engine;
         private _postProcesses;
@@ -5521,6 +5548,7 @@ declare module BABYLON {
     }
     class Tools {
         static BaseUrl: string;
+        static SetImmediate(action: () => void): void;
         static GetExponantOfTwo: (value: number, max: number) => number;
         static GetFilename(path: string): string;
         static GetDOMTextContent(element: HTMLElement): string;

+ 2 - 3
bower.json

@@ -1,8 +1,8 @@
 {
   "name": "babylonjs",
-  "version": "2.1.0",
+  "version": "2.0.0",
   "description": "Babylon.js is a complete JavaScript framework for building 3D games with HTML 5 and WebGL",
-  "main": "babylon.2.1-beta.js",
+  "main": "babylon.2.0.js",
   "homepage": "https://www.babylonjs.com",
   "repository": {
     "type": "git",
@@ -27,7 +27,6 @@
     "Exporters",
     "Loaders",
     "Previous releases",
-    "References",
     "Tools",
     "gulpfile.js",
     "package.json",

+ 2 - 0
what's new - 2.1 - proposal.md

@@ -52,3 +52,5 @@
  - useCameraPostProcess whenever there is a special camera in use ([m0ppers](https://github.com/m0ppers))
  - delta in BoundingBox's intersectsPoint is now calculated correctly ([raananw](http://www.github.com/raananw)) 
  - textures cache fixed ([deltakosh](http://www.github.com/deltakosh))
+ - **Breaking changes**
+ - OculusCamera was renamed to VRCamera ([deltakosh](http://www.github.com/deltakosh))