Bladeren bron

More TS files converted

David Catuhe 11 jaren geleden
bovenliggende
commit
545a68ac0a
28 gewijzigde bestanden met toevoegingen van 436 en 209 verwijderingen
  1. 9 1
      Babylon/Cameras/babylon.freeCamera.js
  2. 9 1
      Babylon/Cameras/babylon.freeCamera.ts
  3. 2 2
      Babylon/Math/babylon.math.js
  4. 3 3
      Babylon/Math/babylon.math.ts
  5. 7 0
      Babylon/Mesh/babylon.mesh.js
  6. 7 0
      Babylon/Mesh/babylon.mesh.ts
  7. 18 12
      Babylon/PostProcess/babylon.blackAndWhitePostProcess.js
  8. 7 0
      Babylon/PostProcess/babylon.blackAndWhitePostProcess.ts
  9. 26 25
      Babylon/PostProcess/babylon.blurPostProcess.js
  10. 13 0
      Babylon/PostProcess/babylon.blurPostProcess.ts
  11. 30 26
      Babylon/PostProcess/babylon.convolutionPostProcess.js
  12. 21 0
      Babylon/PostProcess/babylon.convolutionPostProcess.ts
  13. 18 11
      Babylon/PostProcess/babylon.displayPassPostProcess.js
  14. 7 0
      Babylon/PostProcess/babylon.displayPassPostProcess.ts
  15. 23 17
      Babylon/PostProcess/babylon.filterPostProcess.js
  16. 11 0
      Babylon/PostProcess/babylon.filterPostProcess.ts
  17. 26 17
      Babylon/PostProcess/babylon.fxaaPostProcess.js
  18. 18 0
      Babylon/PostProcess/babylon.fxaaPostProcess.ts
  19. 41 30
      Babylon/PostProcess/babylon.oculusDistortionCorrectionPostProcess.js
  20. 42 0
      Babylon/PostProcess/babylon.oculusDistortionCorrectionPostProcess.ts
  21. 2 9
      Babylon/PostProcess/babylon.postProcess.js
  22. 5 9
      Babylon/PostProcess/babylon.postProcess.ts
  23. 37 33
      Babylon/PostProcess/babylon.refractionPostProcess.js
  24. 29 0
      Babylon/PostProcess/babylon.refractionPostProcess.ts
  25. 8 8
      Babylon/Shaders/default.fragment.fx
  26. 7 1
      Babylon/babylon.engine.js
  27. 7 1
      Babylon/babylon.engine.ts
  28. 3 3
      babylon.1.12-beta.js

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

@@ -260,7 +260,15 @@ var BABYLON;
         };
 
         FreeCamera.prototype._collideWithWorld = function (velocity) {
-            this.position.subtractFromFloatsToRef(0, this.ellipsoid.y, 0, this._oldPosition);
+            var globalPosition;
+
+            if (this.parent) {
+                globalPosition = BABYLON.Vector3.TransformCoordinates(this.position, this.parent.getWorldMatrix());
+            } else {
+                globalPosition = this.position;
+            }
+
+            globalPosition.subtractFromFloatsToRef(0, this.ellipsoid.y, 0, this._oldPosition);
             this._collider.radius = this.ellipsoid;
 
             this.getScene()._getNewPosition(this._oldPosition, velocity, this._collider, 3, this._newPosition);

+ 9 - 1
Babylon/Cameras/babylon.freeCamera.ts

@@ -275,7 +275,15 @@
         }
 
         public _collideWithWorld(velocity: Vector3): void {
-            this.position.subtractFromFloatsToRef(0, this.ellipsoid.y, 0, this._oldPosition);
+            var globalPosition: Vector3;
+
+            if (this.parent) {
+                globalPosition = BABYLON.Vector3.TransformCoordinates(this.position, this.parent.getWorldMatrix());
+            } else {
+                globalPosition = this.position;
+            }
+
+            globalPosition.subtractFromFloatsToRef(0, this.ellipsoid.y, 0, this._oldPosition);
             this._collider.radius = this.ellipsoid;
 
             this.getScene()._getNewPosition(this._oldPosition, velocity, this._collider, 3, this._newPosition);

+ 2 - 2
Babylon/Math/babylon.math.js

@@ -757,10 +757,10 @@
             matrix.invert();
             source.x = source.x / viewportWidth * 2 - 1;
             source.y = -(source.y / viewportHeight * 2 - 1);
-            var vector = Vector3.TransformCoordinates(source, matrix);
+            var vector = BABYLON.Vector3.TransformCoordinates(source, matrix);
             var num = source.x * matrix.m[3] + source.y * matrix.m[7] + source.z * matrix.m[11] + matrix.m[15];
 
-            if (Math.abs(num) < 1.0) {
+            if (BABYLON.Tools.WithinEpsilon(num, 1.0)) {
                 vector = vector.scale(1.0 / num);
             }
 

+ 3 - 3
Babylon/Math/babylon.math.ts

@@ -748,10 +748,10 @@
             matrix.invert();
             source.x = source.x / viewportWidth * 2 - 1;
             source.y = -(source.y / viewportHeight * 2 - 1);
-            var vector = Vector3.TransformCoordinates(source, matrix);
+            var vector = BABYLON.Vector3.TransformCoordinates(source, matrix);
             var num = source.x * matrix.m[3] + source.y * matrix.m[7] + source.z * matrix.m[11] + matrix.m[15];
 
-            if (Math.abs(num) < 1.0) {
+            if (BABYLON.Tools.WithinEpsilon(num, 1.0)) {
                 vector = vector.scale(1.0 / num);
             }
 
@@ -1833,7 +1833,7 @@
         }
 
         // Methods
-        public intersectsBox(box): boolean {
+        public intersectsBox(box: BoundingBox): boolean {
             var d = 0.0;
             var maxValue = Number.MAX_VALUE;
 

+ 7 - 0
Babylon/Mesh/babylon.mesh.js

@@ -43,6 +43,7 @@ var BABYLON;
             this._collisionsTransformMatrix = BABYLON.Matrix.Zero();
             this._collisionsScalingMatrix = BABYLON.Matrix.Zero();
             this._absolutePosition = BABYLON.Vector3.Zero();
+            this._isDirty = false;
             // Physics
             this._physicImpostor = BABYLON.PhysicsEngine.NoImpostor;
             this._totalVertices = 0;
@@ -198,6 +199,10 @@ var BABYLON;
         };
 
         Mesh.prototype._isSynchronized = function () {
+            if (this._isDirty) {
+                return false;
+            }
+
             if (this.billboardMode !== Mesh.BILLBOARDMODE_NONE)
                 return false;
 
@@ -254,6 +259,7 @@ var BABYLON;
                 this.rotationQuaternion = null;
             }
             this._currentRenderId = Number.MAX_VALUE;
+            this._isDirty = true;
         };
 
         Mesh.prototype.refreshBoundingInfo = function () {
@@ -298,6 +304,7 @@ var BABYLON;
             this._cache.scaling.copyFrom(this.scaling);
             this._cache.pivotMatrixUpdated = false;
             this._currentRenderId = this.getScene().getRenderId();
+            this._isDirty = false;
 
             // Scaling
             BABYLON.Matrix.ScalingToRef(this.scaling.x, this.scaling.y, this.scaling.z, this._localScaling);

+ 7 - 0
Babylon/Mesh/babylon.mesh.ts

@@ -44,6 +44,7 @@
         private _collisionsTransformMatrix = BABYLON.Matrix.Zero();
         private _collisionsScalingMatrix = BABYLON.Matrix.Zero();
         private _absolutePosition = BABYLON.Vector3.Zero();
+        private _isDirty = false;
 
         // Physics
         public _physicImpostor = PhysicsEngine.NoImpostor;
@@ -217,6 +218,10 @@
         }
 
         public _isSynchronized(): boolean {
+            if (this._isDirty) {
+                return false;
+            }
+
             if (this.billboardMode !== Mesh.BILLBOARDMODE_NONE)
                 return false;
 
@@ -273,6 +278,7 @@
                 this.rotationQuaternion = null;
             }
             this._currentRenderId = Number.MAX_VALUE;
+            this._isDirty = true;
         }
 
         public refreshBoundingInfo(): void {
@@ -317,6 +323,7 @@
             this._cache.scaling.copyFrom(this.scaling);
             this._cache.pivotMatrixUpdated = false;
             this._currentRenderId = this.getScene().getRenderId();
+            this._isDirty = false;
 
             // Scaling
             BABYLON.Matrix.ScalingToRef(this.scaling.x, this.scaling.y, this.scaling.z, this._localScaling);

+ 18 - 12
Babylon/PostProcess/babylon.blackAndWhitePostProcess.js

@@ -1,12 +1,18 @@
-"use strict";
-
-var BABYLON = BABYLON || {};
-
-(function () {
-    BABYLON.BlackAndWhitePostProcess = function (name, ratio, camera, samplingMode, engine, reusable) {
-        BABYLON.PostProcess.call(this, name, "blackAndWhite", null, null, ratio, camera, samplingMode, engine, reusable);
-    };
-    
-    BABYLON.BlackAndWhitePostProcess.prototype = Object.create(BABYLON.PostProcess.prototype);
-
-})();
+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 BlackAndWhitePostProcess = (function (_super) {
+        __extends(BlackAndWhitePostProcess, _super);
+        function BlackAndWhitePostProcess(name, ratio, camera, samplingMode, engine, reusable) {
+            _super.call(this, name, "blackAndWhite", null, null, ratio, camera, samplingMode, engine, reusable);
+        }
+        return BlackAndWhitePostProcess;
+    })(BABYLON.PostProcess);
+    BABYLON.BlackAndWhitePostProcess = BlackAndWhitePostProcess;
+})(BABYLON || (BABYLON = {}));
+//# sourceMappingURL=babylon.blackAndWhitePostProcess.js.map

+ 7 - 0
Babylon/PostProcess/babylon.blackAndWhitePostProcess.ts

@@ -0,0 +1,7 @@
+module BABYLON {
+    export class BlackAndWhitePostProcess extends PostProcess {
+        constructor(name: string, ratio: number, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean) {
+            super(name, "blackAndWhite", null, null, ratio, camera, samplingMode, engine, reusable);
+        }
+    }
+} 

+ 26 - 25
Babylon/PostProcess/babylon.blurPostProcess.js

@@ -1,26 +1,27 @@
-"use strict";
-
-var BABYLON = BABYLON || {};
-
-(function () {
-    BABYLON.BlurPostProcess = function (name, direction, blurWidth, ratio, camera, samplingMode, engine, reusable) {
-        
-        if (samplingMode === undefined) {
-            samplingMode = BABYLON.Texture.BILINEAR_SAMPLINGMODE;
+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 BlurPostProcess = (function (_super) {
+        __extends(BlurPostProcess, _super);
+        function BlurPostProcess(name, direction, blurWidth, ratio, camera, samplingMode, engine, reusable) {
+            if (typeof samplingMode === "undefined") { samplingMode = BABYLON.Texture.BILINEAR_SAMPLINGMODE; }
+            var _this = this;
+            _super.call(this, name, "blur", ["screenSize", "direction", "blurWidth"], null, ratio, camera, samplingMode, engine, reusable);
+            this.direction = direction;
+            this.blurWidth = blurWidth;
+            this.onApply = function (effect) {
+                effect.setFloat2("screenSize", _this.width, _this.height);
+                effect.setVector2("direction", _this.direction);
+                effect.setFloat("blurWidth", _this.blurWidth);
+            };
         }
-
-        BABYLON.PostProcess.call(this, name, "blur", ["screenSize", "direction", "blurWidth"], null, ratio, camera, samplingMode, engine, reusable);
-
-        this.direction = direction;
-        this.blurWidth = blurWidth;
-        var that = this;
-        this.onApply = function (effect) {
-            effect.setFloat2("screenSize", that.width, that.height);
-            effect.setVector2("direction", that.direction);
-            effect.setFloat("blurWidth", that.blurWidth);
-        };
-    };
-    
-    BABYLON.BlurPostProcess.prototype = Object.create(BABYLON.PostProcess.prototype);
-
-})();
+        return BlurPostProcess;
+    })(BABYLON.PostProcess);
+    BABYLON.BlurPostProcess = BlurPostProcess;
+})(BABYLON || (BABYLON = {}));
+//# sourceMappingURL=babylon.blurPostProcess.js.map

+ 13 - 0
Babylon/PostProcess/babylon.blurPostProcess.ts

@@ -0,0 +1,13 @@
+module BABYLON {
+    export class BlurPostProcess extends PostProcess {
+        constructor(name: string, public direction: Vector2, public blurWidth: number, ratio: number, camera: Camera, samplingMode: number = BABYLON.Texture.BILINEAR_SAMPLINGMODE, engine?: Engine, reusable?: boolean) {
+            super(name, "blur", ["screenSize", "direction", "blurWidth"], null, ratio, camera, samplingMode, engine, reusable);
+            this.onApply = (effect: Effect) => {
+                effect.setFloat2("screenSize", this.width, this.height);
+                effect.setVector2("direction", this.direction);
+                effect.setFloat("blurWidth", this.blurWidth);
+            };
+        }
+    
+    }
+} 

+ 30 - 26
Babylon/PostProcess/babylon.convolutionPostProcess.js

@@ -1,27 +1,31 @@
-"use strict";
+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 ConvolutionPostProcess = (function (_super) {
+        __extends(ConvolutionPostProcess, _super);
+        function ConvolutionPostProcess(name, kernel, ratio, camera, samplingMode, engine, reusable) {
+            var _this = this;
+            _super.call(this, name, "convolution", ["kernel", "screenSize"], null, ratio, camera, samplingMode, engine, reusable);
+            this.kernel = kernel;
 
-var BABYLON = BABYLON || {};
-
-(function () {
-    BABYLON.ConvolutionPostProcess = function (name, kernel, ratio, camera, samplingMode, engine, reusable) {
-        BABYLON.PostProcess.call(this, name, "convolution", ["kernel", "screenSize"], null, ratio, camera, samplingMode, engine, reusable);
-        
-        this.kernel = kernel;
-        var that = this;
-        this.onApply = function (effect) {
-            effect.setFloat2("screenSize", that.width, that.height);
-            effect.setArray("kernel", that.kernel);
-        };
-    };
-    
-    BABYLON.ConvolutionPostProcess.prototype = Object.create(BABYLON.PostProcess.prototype);
-    
-    // Based on http://en.wikipedia.org/wiki/Kernel_(image_processing)
-    BABYLON.ConvolutionPostProcess.EdgeDetect0Kernel = [1, 0, -1, 0, 0, 0, -1, 0, 1];
-    BABYLON.ConvolutionPostProcess.EdgeDetect1Kernel = [0, 1, 0, 1, -4, 1, 0, 1, 0];
-    BABYLON.ConvolutionPostProcess.EdgeDetect2Kernel = [-1, -1, -1, -1, 8, -1, -1, -1, -1];
-    BABYLON.ConvolutionPostProcess.SharpenKernel = [0, -1, 0, -1, 5, -1, 0, -1, 0];
-    BABYLON.ConvolutionPostProcess.EmbossKernel = [-2, -1, 0, -1, 1, 1, 0, 1, 2];
-    BABYLON.ConvolutionPostProcess.GaussianKernel = [0, 1, 0, 1, 1, 1, 0, 1, 0];
-
-})();
+            this.onApply = function (effect) {
+                effect.setFloat2("screenSize", _this.width, _this.height);
+                effect.setArray("kernel", _this.kernel);
+            };
+        }
+        ConvolutionPostProcess.EdgeDetect0Kernel = [1, 0, -1, 0, 0, 0, -1, 0, 1];
+        ConvolutionPostProcess.EdgeDetect1Kernel = [0, 1, 0, 1, -4, 1, 0, 1, 0];
+        ConvolutionPostProcess.EdgeDetect2Kernel = [-1, -1, -1, -1, 8, -1, -1, -1, -1];
+        ConvolutionPostProcess.SharpenKernel = [0, -1, 0, -1, 5, -1, 0, -1, 0];
+        ConvolutionPostProcess.EmbossKernel = [-2, -1, 0, -1, 1, 1, 0, 1, 2];
+        ConvolutionPostProcess.GaussianKernel = [0, 1, 0, 1, 1, 1, 0, 1, 0];
+        return ConvolutionPostProcess;
+    })(BABYLON.PostProcess);
+    BABYLON.ConvolutionPostProcess = ConvolutionPostProcess;
+})(BABYLON || (BABYLON = {}));
+//# sourceMappingURL=babylon.convolutionPostProcess.js.map

+ 21 - 0
Babylon/PostProcess/babylon.convolutionPostProcess.ts

@@ -0,0 +1,21 @@
+module BABYLON {
+    export class ConvolutionPostProcess extends PostProcess{
+        constructor(name: string, public kernel: number[], ratio: number, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean) {
+            super(name, "convolution", ["kernel", "screenSize"], null, ratio, camera, samplingMode, engine, reusable);
+
+            this.onApply = (effect: Effect) => {
+                effect.setFloat2("screenSize", this.width, this.height);
+                effect.setArray("kernel", this.kernel);
+            };
+        }
+
+    // Statics
+    // Based on http://en.wikipedia.org/wiki/Kernel_(image_processing)
+    public static EdgeDetect0Kernel = [1, 0, -1, 0, 0, 0, -1, 0, 1];
+    public static EdgeDetect1Kernel = [0, 1, 0, 1, -4, 1, 0, 1, 0];
+    public static EdgeDetect2Kernel = [-1, -1, -1, -1, 8, -1, -1, -1, -1];
+    public static SharpenKernel = [0, -1, 0, -1, 5, -1, 0, -1, 0];
+    public static EmbossKernel = [-2, -1, 0, -1, 1, 1, 0, 1, 2];
+    public static GaussianKernel = [0, 1, 0, 1, 1, 1, 0, 1, 0];
+    }
+}

+ 18 - 11
Babylon/PostProcess/babylon.displayPassPostProcess.js

@@ -1,11 +1,18 @@
-"use strict";
-
-var BABYLON = BABYLON || {};
-
-(function () {
-    BABYLON.DisplayPassPostProcess = function (name, ratio, camera, samplingMode, engine, reusable) {
-        BABYLON.PostProcess.call(this, name, "displayPass", ["passSampler"], ["passSampler"], ratio, camera, samplingMode, engine, reusable);
-    };
-
-    BABYLON.DisplayPassPostProcess.prototype = Object.create(BABYLON.PostProcess.prototype);
-})();
+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 DisplayPassPostProcess = (function (_super) {
+        __extends(DisplayPassPostProcess, _super);
+        function DisplayPassPostProcess(name, ratio, camera, samplingMode, engine, reusable) {
+            _super.call(this, name, "displayPass", ["passSampler"], ["passSampler"], ratio, camera, samplingMode, engine, reusable);
+        }
+        return DisplayPassPostProcess;
+    })(BABYLON.PostProcess);
+    BABYLON.DisplayPassPostProcess = DisplayPassPostProcess;
+})(BABYLON || (BABYLON = {}));
+//# sourceMappingURL=babylon.displayPassPostProcess.js.map

+ 7 - 0
Babylon/PostProcess/babylon.displayPassPostProcess.ts

@@ -0,0 +1,7 @@
+module BABYLON {
+    export class DisplayPassPostProcess extends PostProcess {
+        constructor(name: string, ratio: number, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean) {
+            super(name, "displayPass", ["passSampler"], ["passSampler"], ratio, camera, samplingMode, engine, reusable);
+        }
+    }
+}

+ 23 - 17
Babylon/PostProcess/babylon.filterPostProcess.js

@@ -1,18 +1,24 @@
-"use strict";
+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 FilterPostProcess = (function (_super) {
+        __extends(FilterPostProcess, _super);
+        function FilterPostProcess(name, kernelMatrix, ratio, camera, samplingMode, engine, reusable) {
+            var _this = this;
+            _super.call(this, name, "filter", ["kernelMatrix"], null, ratio, camera, samplingMode, engine, reusable);
+            this.kernelMatrix = kernelMatrix;
 
-var BABYLON = BABYLON || {};
-
-(function () {
-    BABYLON.FilterPostProcess = function (name, kernelMatrix, ratio, camera, samplingMode, engine, reusable) {
-        BABYLON.PostProcess.call(this, name, "filter", ["kernelMatrix"], null, ratio, camera, samplingMode, engine, reusable);
-        
-        this.kernelMatrix = kernelMatrix;
-        var that = this;
-        this.onApply = function (effect) {
-            effect.setMatrix("kernelMatrix", that.kernelMatrix);
-        };
-    };
-    
-    BABYLON.FilterPostProcess.prototype = Object.create(BABYLON.PostProcess.prototype);
-
-})();
+            this.onApply = function (effect) {
+                effect.setMatrix("kernelMatrix", _this.kernelMatrix);
+            };
+        }
+        return FilterPostProcess;
+    })(BABYLON.PostProcess);
+    BABYLON.FilterPostProcess = FilterPostProcess;
+})(BABYLON || (BABYLON = {}));
+//# sourceMappingURL=babylon.filterPostProcess.js.map

+ 11 - 0
Babylon/PostProcess/babylon.filterPostProcess.ts

@@ -0,0 +1,11 @@
+module BABYLON {
+    export class FilterPostProcess extends PostProcess {
+        constructor(name: string, public kernelMatrix: Matrix, ratio: number, camera?: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean) {
+            super(name, "filter", ["kernelMatrix"], null, ratio, camera, samplingMode, engine, reusable);
+
+            this.onApply = (effect: Effect) => {
+                effect.setMatrix("kernelMatrix", this.kernelMatrix);
+            }
+        }
+    }
+}

+ 26 - 17
Babylon/PostProcess/babylon.fxaaPostProcess.js

@@ -1,18 +1,27 @@
-"use strict";
+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 FxaaPostProcess = (function (_super) {
+        __extends(FxaaPostProcess, _super);
+        function FxaaPostProcess(name, ratio, camera, samplingMode, engine, reusable) {
+            var _this = this;
+            _super.call(this, name, "fxaa", ["texelSize"], null, ratio, camera, samplingMode, engine, reusable);
 
-var BABYLON = BABYLON || {};
-
-(function () {
-    BABYLON.FxaaPostProcess = function (name, ratio, camera, samplingMode, engine, reusable) {
-        BABYLON.PostProcess.call(this, name, "fxaa", ["texelSize"], null, ratio, camera, samplingMode, engine, reusable);
-    };
-    
-    BABYLON.FxaaPostProcess.prototype = Object.create(BABYLON.PostProcess.prototype);
-    BABYLON.FxaaPostProcess.prototype.onSizeChanged = function () {
-        this.texelWidth = 1.0 / this.width;
-        this.texelHeight = 1.0 / this.height;
-    };
-    BABYLON.FxaaPostProcess.prototype.onApply = function (effect) {
-        effect.setFloat2("texelSize", this.texelWidth, this.texelHeight);
-    };
-})();
+            this.onSizeChanged = function () {
+                _this.texelWidth = 1.0 / _this.width;
+                _this.texelHeight = 1.0 / _this.height;
+            };
+            this.onApply = function (effect) {
+                effect.setFloat2("texelSize", _this.texelWidth, _this.texelHeight);
+            };
+        }
+        return FxaaPostProcess;
+    })(BABYLON.PostProcess);
+    BABYLON.FxaaPostProcess = FxaaPostProcess;
+})(BABYLON || (BABYLON = {}));
+//# sourceMappingURL=babylon.fxaaPostProcess.js.map

+ 18 - 0
Babylon/PostProcess/babylon.fxaaPostProcess.ts

@@ -0,0 +1,18 @@
+module BABYLON {
+    export class FxaaPostProcess extends PostProcess {
+        public texelWidth: number;
+        public texelHeight: number;
+
+        constructor(name: string, ratio: number, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean) {
+            super(name, "fxaa", ["texelSize"], null, ratio, camera, samplingMode, engine, reusable);
+
+            this.onSizeChanged = () => {
+                this.texelWidth = 1.0 / this.width;
+                this.texelHeight = 1.0 / this.height;
+            };
+            this.onApply = (effect: Effect) => {
+                effect.setFloat2("texelSize", this.texelWidth, this.texelHeight);
+            }
+        }
+    }
+}

+ 41 - 30
Babylon/PostProcess/babylon.oculusDistortionCorrectionPostProcess.js

@@ -1,32 +1,43 @@
-"use strict";
+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 OculusDistortionCorrectionPostProcess = (function (_super) {
+        __extends(OculusDistortionCorrectionPostProcess, _super);
+        //ANY
+        function OculusDistortionCorrectionPostProcess(name, camera, isRightEye, cameraSettings) {
+            var _this = this;
+            _super.call(this, name, "oculusDistortionCorrection", [
+                'LensCenter',
+                'Scale',
+                'ScaleIn',
+                'HmdWarpParam'
+            ], null, cameraSettings.PostProcessScaleFactor, camera, BABYLON.Texture.BILINEAR_SAMPLINGMODE, null, null);
 
-var BABYLON = BABYLON || {};
+            this._isRightEye = isRightEye;
+            this._distortionFactors = cameraSettings.DistortionK;
+            this._postProcessScaleFactor = cameraSettings.PostProcessScaleFactor;
+            this._lensCenterOffset = cameraSettings.LensCenterOffset;
 
-(function () {
-    BABYLON.OculusDistortionCorrectionPostProcess = function (name, camera, isRightEye, cameraSettings) {
-        BABYLON.PostProcess.call(this, name, "oculusDistortionCorrection", [
-			'LensCenter',
-		    'Scale',
-		    'ScaleIn',
-		    'HmdWarpParam'
-        ], null, cameraSettings.PostProcessScaleFactor, camera, BABYLON.Texture.BILINEAR_SAMPLINGMODE, null, null);
-        this._isRightEye = isRightEye;
-        this._distortionFactors = cameraSettings.DistortionK;
-        this._postProcessScaleFactor = cameraSettings.PostProcessScaleFactor;
-        this._lensCenterOffset = cameraSettings.LensCenterOffset;
-    };
-
-    BABYLON.OculusDistortionCorrectionPostProcess.prototype = Object.create(BABYLON.PostProcess.prototype);
-    BABYLON.OculusDistortionCorrectionPostProcess.prototype.onSizeChanged = function () {
-        this.aspectRatio = this.width * .5 / this.height;
-        this._scaleIn = new BABYLON.Vector2(2, 2 / this.aspectRatio);
-        this._scaleFactor = new BABYLON.Vector2(.5 * (1/this._postProcessScaleFactor), .5 * (1/this._postProcessScaleFactor) * this.aspectRatio);
-        this._lensCenter = new BABYLON.Vector2(this._isRightEye ? 0.5 - this._lensCenterOffset * 0.5 : 0.5 + this._lensCenterOffset * 0.5, 0.5);
-    };
-    BABYLON.OculusDistortionCorrectionPostProcess.prototype.onApply = function (effect) {
-        effect.setFloat2("LensCenter", this._lensCenter.x, this._lensCenter.y);
-        effect.setFloat2("Scale", this._scaleFactor.x, this._scaleFactor.y);
-        effect.setFloat2("ScaleIn", this._scaleIn.x, this._scaleIn.y);
-        effect.setFloat4("HmdWarpParam", this._distortionFactors[0], this._distortionFactors[1], this._distortionFactors[2], this._distortionFactors[3]);
-    };
-})();
+            this.onSizeChanged = function () {
+                _this.aspectRatio = _this.width * .5 / _this.height;
+                _this._scaleIn = new BABYLON.Vector2(2, 2 / _this.aspectRatio);
+                _this._scaleFactor = new BABYLON.Vector2(.5 * (1 / _this._postProcessScaleFactor), .5 * (1 / _this._postProcessScaleFactor) * _this.aspectRatio);
+                _this._lensCenter = new BABYLON.Vector2(_this._isRightEye ? 0.5 - _this._lensCenterOffset * 0.5 : 0.5 + _this._lensCenterOffset * 0.5, 0.5);
+            };
+            this.onApply = function (effect) {
+                effect.setFloat2("LensCenter", _this._lensCenter.x, _this._lensCenter.y);
+                effect.setFloat2("Scale", _this._scaleFactor.x, _this._scaleFactor.y);
+                effect.setFloat2("ScaleIn", _this._scaleIn.x, _this._scaleIn.y);
+                effect.setFloat4("HmdWarpParam", _this._distortionFactors[0], _this._distortionFactors[1], _this._distortionFactors[2], _this._distortionFactors[3]);
+            };
+        }
+        return OculusDistortionCorrectionPostProcess;
+    })(BABYLON.PostProcess);
+    BABYLON.OculusDistortionCorrectionPostProcess = OculusDistortionCorrectionPostProcess;
+})(BABYLON || (BABYLON = {}));
+//# sourceMappingURL=babylon.oculusDistortionCorrectionPostProcess.js.map

+ 42 - 0
Babylon/PostProcess/babylon.oculusDistortionCorrectionPostProcess.ts

@@ -0,0 +1,42 @@
+module BABYLON {
+    export class OculusDistortionCorrectionPostProcess extends PostProcess {
+        public aspectRatio: number;
+
+        private _isRightEye: boolean;
+        private _distortionFactors: number[];
+        private _postProcessScaleFactor: number;
+        private _lensCenterOffset: number;
+        private _scaleIn: Vector2;
+        private _scaleFactor: Vector2;
+        private _lensCenter: Vector2;
+
+        //ANY
+        constructor(name: string, camera: Camera, isRightEye: boolean, cameraSettings: any) {
+            super(name, "oculusDistortionCorrection", [
+                'LensCenter',
+                'Scale',
+                'ScaleIn',
+                'HmdWarpParam'
+            ], null, cameraSettings.PostProcessScaleFactor, camera, BABYLON.Texture.BILINEAR_SAMPLINGMODE, null, null);
+
+            this._isRightEye = isRightEye;
+            this._distortionFactors = cameraSettings.DistortionK;
+            this._postProcessScaleFactor = cameraSettings.PostProcessScaleFactor;
+            this._lensCenterOffset = cameraSettings.LensCenterOffset;
+
+
+           this.onSizeChanged = () => {
+                this.aspectRatio = this.width * .5 / this.height;
+                this._scaleIn = new BABYLON.Vector2(2, 2 / this.aspectRatio);
+                this._scaleFactor = new BABYLON.Vector2(.5 * (1 / this._postProcessScaleFactor), .5 * (1 / this._postProcessScaleFactor) * this.aspectRatio);
+                this._lensCenter = new BABYLON.Vector2(this._isRightEye ? 0.5 - this._lensCenterOffset * 0.5 : 0.5 + this._lensCenterOffset * 0.5, 0.5);
+            };
+            this.onApply = (effect: Effect) => {
+                effect.setFloat2("LensCenter", this._lensCenter.x, this._lensCenter.y);
+                effect.setFloat2("Scale", this._scaleFactor.x, this._scaleFactor.y);
+                effect.setFloat2("ScaleIn", this._scaleIn.x, this._scaleIn.y);
+                effect.setFloat4("HmdWarpParam", this._distortionFactors[0], this._distortionFactors[1], this._distortionFactors[2], this._distortionFactors[3]);
+            };
+        }
+    }
+}

+ 2 - 9
Babylon/PostProcess/babylon.postProcess.js

@@ -3,12 +3,8 @@
     var PostProcess = (function () {
         function PostProcess(name, fragmentUrl, parameters, samplers, ratio, camera, samplingMode, engine, reusable) {
             this.name = name;
-            this.onApply = null;
-            this.onSizeChanged = null;
-            this.onActivate = null;
             this.width = -1;
             this.height = -1;
-            this._onDispose = null;
             this._reusable = false;
             this._textures = new BABYLON.SmartArray(2);
             this._currentRenderTextureInd = 0;
@@ -38,8 +34,8 @@
             camera = camera || this._camera;
 
             var scene = camera.getScene();
-            var desiredWidth = this._engine.getRenderWidth() * this._renderRatio;
-            var desiredHeight = this._engine.getRenderHeight() * this._renderRatio;
+            var desiredWidth = this._engine.getRenderingCanvas().width * this._renderRatio;
+            var desiredHeight = this._engine.getRenderingCanvas().height * this._renderRatio;
             if (this.width !== desiredWidth || this.height !== desiredHeight) {
                 if (this._textures.length > 0) {
                     for (var i = 0; i < this._textures.length; i++) {
@@ -100,9 +96,6 @@
         PostProcess.prototype.dispose = function (camera) {
             camera = camera || this._camera;
 
-            if (this._onDispose) {
-                this._onDispose();
-            }
             if (this._textures.length > 0) {
                 for (var i = 0; i < this._textures.length; i++) {
                     this._engine._releaseTexture(this._textures.data[i]);

+ 5 - 9
Babylon/PostProcess/babylon.postProcess.ts

@@ -1,13 +1,12 @@
 module BABYLON {
     export class PostProcess {
-        public onApply = null;
-        public onSizeChanged = null;
-        public onActivate = null;
+        public onApply: (Effect) => void;
+        public onSizeChanged: () => void;
+        public onActivate: (Camera) => void;
         public width = -1;
         public height = -1;
         public renderTargetSamplingMode: number;
 
-        private _onDispose = null;
         private _camera: Camera;
         private _scene: Scene;
         private _engine: Engine;
@@ -49,8 +48,8 @@
             camera = camera || this._camera;
 
             var scene = camera.getScene();
-            var desiredWidth = this._engine.getRenderWidth() * this._renderRatio;
-            var desiredHeight = this._engine.getRenderHeight() * this._renderRatio;
+            var desiredWidth = this._engine.getRenderingCanvas().width * this._renderRatio;
+            var desiredHeight = this._engine.getRenderingCanvas().height * this._renderRatio;
             if (this.width !== desiredWidth || this.height !== desiredHeight) {
                 if (this._textures.length > 0) {
                     for (var i = 0; i < this._textures.length; i++) {
@@ -112,9 +111,6 @@
         public dispose(camera: Camera): void {
             camera = camera || this._camera;
 
-            if (this._onDispose) {
-                this._onDispose();
-            }
             if (this._textures.length > 0) {
                 for (var i = 0; i < this._textures.length; i++) {
                     this._engine._releaseTexture(this._textures.data[i]);

+ 37 - 33
Babylon/PostProcess/babylon.refractionPostProcess.js

@@ -1,38 +1,42 @@
-"use strict";
+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 RefractionPostProcess = (function (_super) {
+        __extends(RefractionPostProcess, _super);
+        function RefractionPostProcess(name, refractionTextureUrl, color, depth, colorLevel, ratio, camera, samplingMode, engine, reusable) {
+            var _this = this;
+            _super.call(this, name, "refraction", ["baseColor", "depth", "colorLevel"], ["refractionSampler"], ratio, camera, samplingMode, engine, reusable);
+            this.color = color;
+            this.depth = depth;
+            this.colorLevel = colorLevel;
 
-var BABYLON = BABYLON || {};
+            this.onActivate = function (cam) {
+                _this._refRexture = _this._refRexture || new BABYLON.Texture(refractionTextureUrl, cam.getScene());
+            };
 
-(function () {
-    BABYLON.RefractionPostProcess = function (name, refractionTextureUrl, color, depth, colorLevel, ratio, camera, samplingMode, engine, reusable) {
-        BABYLON.PostProcess.call(this, name, "refraction", ["baseColor", "depth", "colorLevel"], ["refractionSampler"], ratio, camera, samplingMode, engine, reusable);
+            this.onApply = function (effect) {
+                effect.setColor3("baseColor", _this.color);
+                effect.setFloat("depth", _this.depth);
+                effect.setFloat("colorLevel", _this.colorLevel);
 
-        this.color = color;
-        this.depth = depth;
-        this.colorLevel = colorLevel;
-        this._refRexture = null;
-        
-        var that = this;
-
-        this.onActivate = function (camera) {
-            that._refRexture = this._refRexture || new BABYLON.Texture(refractionTextureUrl, camera.getScene());
-        };
-
-        this.onApply = function (effect) {
-            effect.setColor3("baseColor", that.color);
-            effect.setFloat("depth", that.depth);
-            effect.setFloat("colorLevel", that.colorLevel);
-
-            effect.setTexture("refractionSampler", that._refRexture);
-        };
-    };
-    
-    BABYLON.RefractionPostProcess.prototype = Object.create(BABYLON.PostProcess.prototype);
-    
-    // Methods
-    BABYLON.RefractionPostProcess.prototype._onDispose = function () {
-        if (this._refRexture) {
-            this._refRexture.dispose();
+                effect.setTexture("refractionSampler", _this._refRexture);
+            };
         }
-    };
+        // Methods
+        RefractionPostProcess.prototype.dispose = function (camera) {
+            if (this._refRexture) {
+                this._refRexture.dispose();
+            }
 
-})();
+            _super.prototype.dispose.call(this, camera);
+        };
+        return RefractionPostProcess;
+    })(BABYLON.PostProcess);
+    BABYLON.RefractionPostProcess = RefractionPostProcess;
+})(BABYLON || (BABYLON = {}));
+//# sourceMappingURL=babylon.refractionPostProcess.js.map

+ 29 - 0
Babylon/PostProcess/babylon.refractionPostProcess.ts

@@ -0,0 +1,29 @@
+module BABYLON {
+    export class RefractionPostProcess extends PostProcess {
+        private _refRexture: Texture;
+        constructor(name: string, refractionTextureUrl: string, public color: Color3, public depth: number, public colorLevel: number, ratio: number, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean) {
+            super(name, "refraction", ["baseColor", "depth", "colorLevel"], ["refractionSampler"], ratio, camera, samplingMode, engine, reusable);
+
+            this.onActivate = (cam: Camera) => {
+                this._refRexture = this._refRexture || new BABYLON.Texture(refractionTextureUrl, cam.getScene());
+            };
+
+            this.onApply = (effect: Effect) => {
+                effect.setColor3("baseColor", this.color);
+                effect.setFloat("depth", this.depth);
+                effect.setFloat("colorLevel", this.colorLevel);
+
+                effect.setTexture("refractionSampler", this._refRexture);
+            };
+        }
+
+        // Methods
+        public dispose(camera: Camera): void {
+            if (this._refRexture) {
+                this._refRexture.dispose();
+            }
+
+            super.dispose(camera);
+        }
+    }
+}

+ 8 - 8
Babylon/Shaders/default.fragment.fx

@@ -450,10 +450,10 @@ void main(void) {
 
 #ifdef LIGHT0
 #ifdef SPOTLIGHT0
-	lightingInfo info = computeSpotLighting(viewDirectionW, normalW, vLightData0, vLightDirection0, vLightDiffuse0, vLightSpecular0);
+	lightingInfo info = computeSpotLighting(viewDirectionW, normalW, vLightData0, vLightDirection0, vLightDiffuse0.rgb, vLightSpecular0);
 #endif
 #ifdef HEMILIGHT0
-	lightingInfo info = computeHemisphericLighting(viewDirectionW, normalW, vLightData0, vLightDiffuse0, vLightSpecular0, vLightGround0);
+	lightingInfo info = computeHemisphericLighting(viewDirectionW, normalW, vLightData0, vLightDiffuse0.rgb, vLightSpecular0, vLightGround0);
 #endif
 #ifdef POINTDIRLIGHT0
 	lightingInfo info = computeLighting(viewDirectionW, normalW, vLightData0, vLightDiffuse0.rgb, vLightSpecular0, vLightDiffuse0.a);
@@ -473,10 +473,10 @@ void main(void) {
 
 #ifdef LIGHT1
 #ifdef SPOTLIGHT1
-	info = computeSpotLighting(viewDirectionW, normalW, vLightData1, vLightDirection1, vLightDiffuse1, vLightSpecular1);
+	info = computeSpotLighting(viewDirectionW, normalW, vLightData1, vLightDirection1, vLightDiffuse1.rgb, vLightSpecular1);
 #endif
 #ifdef HEMILIGHT1
-	info = computeHemisphericLighting(viewDirectionW, normalW, vLightData1, vLightDiffuse1, vLightSpecular1, vLightGround1);
+	info = computeHemisphericLighting(viewDirectionW, normalW, vLightData1, vLightDiffuse1.rgb, vLightSpecular1, vLightGround1);
 #endif
 #ifdef POINTDIRLIGHT1
 	info = computeLighting(viewDirectionW, normalW, vLightData1, vLightDiffuse1.rgb, vLightSpecular1, vLightDiffuse1.a);
@@ -496,10 +496,10 @@ void main(void) {
 
 #ifdef LIGHT2
 #ifdef SPOTLIGHT2
-	info = computeSpotLighting(viewDirectionW, normalW, vLightData2, vLightDirection2, vLightDiffuse2, vLightSpecular2);
+	info = computeSpotLighting(viewDirectionW, normalW, vLightData2, vLightDirection2, vLightDiffuse2.rgb, vLightSpecular2);
 #endif
 #ifdef HEMILIGHT2
-	info = computeHemisphericLighting(viewDirectionW, normalW, vLightData2, vLightDiffuse2, vLightSpecular2, vLightGround2);
+	info = computeHemisphericLighting(viewDirectionW, normalW, vLightData2, vLightDiffuse2.rgb, vLightSpecular2, vLightGround2);
 #endif
 #ifdef POINTDIRLIGHT2
 	info = computeLighting(viewDirectionW, normalW, vLightData2, vLightDiffuse2.rgb, vLightSpecular2, vLightDiffuse2.a);
@@ -519,10 +519,10 @@ void main(void) {
 
 #ifdef LIGHT3
 #ifdef SPOTLIGHT3
-	info = computeSpotLighting(viewDirectionW, normalW, vLightData3, vLightDirection3, vLightDiffuse3, vLightSpecular3);
+	info = computeSpotLighting(viewDirectionW, normalW, vLightData3, vLightDirection3, vLightDiffuse3.rgb, vLightSpecular3);
 #endif
 #ifdef HEMILIGHT3
-	info = computeHemisphericLighting(viewDirectionW, normalW, vLightData3, vLightDiffuse3, vLightSpecular3, vLightGround3);
+	info = computeHemisphericLighting(viewDirectionW, normalW, vLightData3, vLightDiffuse3.rgb, vLightSpecular3, vLightGround3);
 #endif
 #ifdef POINTDIRLIGHT3
 	info = computeLighting(viewDirectionW, normalW, vLightData3, vLightDiffuse3.rgb, vLightSpecular3, vLightDiffuse3.a);

+ 7 - 1
Babylon/babylon.engine.js

@@ -486,6 +486,12 @@
 
         Engine.prototype.draw = function (useTriangles, indexStart, indexCount) {
             this._gl.drawElements(useTriangles ? this._gl.TRIANGLES : this._gl.LINES, indexCount, this._gl.UNSIGNED_SHORT, indexStart * 2);
+
+            var error = this._gl.getError();
+
+            if (error) {
+                console.log(error);
+            }
         };
 
         // Shaders
@@ -724,7 +730,7 @@
             this._cullingState = null;
 
             this._cachedVertexBuffers = null;
-            this._cachedVertexBuffers = null;
+            this._cachedIndexBuffer = null;
             this._cachedEffectForVertexBuffers = null;
         };
 

+ 7 - 1
Babylon/babylon.engine.ts

@@ -543,6 +543,12 @@
 
         public draw(useTriangles: boolean, indexStart: number, indexCount: number): void {
             this._gl.drawElements(useTriangles ? this._gl.TRIANGLES : this._gl.LINES, indexCount, this._gl.UNSIGNED_SHORT, indexStart * 2);
+
+            var error = this._gl.getError();
+
+            if (error) {
+                console.log(error);
+            }
         }
 
         // Shaders
@@ -782,7 +788,7 @@
             this._cullingState = null;
 
             this._cachedVertexBuffers = null;
-            this._cachedVertexBuffers = null;
+            this._cachedIndexBuffer = null;
             this._cachedEffectForVertexBuffers = null;
         }
 

File diff suppressed because it is too large
+ 3 - 3
babylon.1.12-beta.js