Ver código fonte

Fixing small issues

David Catuhe 10 anos atrás
pai
commit
f158465131

+ 2 - 0
Babylon/Audio/babylon.sound.ts

@@ -102,6 +102,8 @@
                 }
             }
             else {
+                // Adding an empty sound to avoid breaking audio calls for non Web Audio browsers
+                this._scene.mainSoundTrack.AddSound(this);
                 if (!Engine.audioEngine.WarnedWebAudioUnsupported) {
                     BABYLON.Tools.Error("Web Audio is not supported by your browser.");
                     Engine.audioEngine.WarnedWebAudioUnsupported = true;

+ 4 - 1
Babylon/Audio/babylon.soundtrack.ts

@@ -42,7 +42,9 @@
         }
 
         public AddSound(sound: BABYLON.Sound) {
-            sound.connectToSoundTrackAudioNode(this._trackGain);
+            if (Engine.audioEngine.canUseWebAudio) {
+                sound.connectToSoundTrackAudioNode(this._trackGain);
+            }
             if (sound.soundTrackId) {
                 if (sound.soundTrackId === -1) {
                     this._scene.mainSoundTrack.RemoveSound(sound);
@@ -51,6 +53,7 @@
                     this._scene.soundTracks[sound.soundTrackId].RemoveSound(sound);
                 }
             }
+
             this.soundCollection.push(sound);
             sound.soundTrackId = this.id;
         }

+ 9 - 9
Babylon/Culling/babylon.BoundingBox.ts

@@ -36,16 +36,16 @@
             // OBB
             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()];
+            this.directions = [Vector3.Zero(), Vector3.Zero(), Vector3.Zero()];
 
             // World
             for (var index = 0; index < this.vectors.length; index++) {
-                this.vectorsWorld[index] = BABYLON.Vector3.Zero();
+                this.vectorsWorld[index] = Vector3.Zero();
             }
-            this.minimumWorld = BABYLON.Vector3.Zero();
-            this.maximumWorld = BABYLON.Vector3.Zero();
+            this.minimumWorld = Vector3.Zero();
+            this.maximumWorld = Vector3.Zero();
 
-            this._update(BABYLON.Matrix.Identity());
+            this._update(Matrix.Identity());
         }
 
         // Methods
@@ -59,7 +59,7 @@
 
             for (var index = 0; index < this.vectors.length; index++) {
                 var v = this.vectorsWorld[index];
-                BABYLON.Vector3.TransformCoordinatesToRef(this.vectors[index], world, v);
+                Vector3.TransformCoordinatesToRef(this.vectors[index], world, v);
 
                 if (v.x < this.minimumWorld.x)
                     this.minimumWorld.x = v.x;
@@ -142,8 +142,8 @@
         }
 
         public static IntersectsSphere(minPoint: Vector3, maxPoint: Vector3, sphereCenter: Vector3, sphereRadius: number): boolean {
-            var vector = BABYLON.Vector3.Clamp(sphereCenter, minPoint, maxPoint);
-            var num = BABYLON.Vector3.DistanceSquared(sphereCenter, vector);
+            var vector = Vector3.Clamp(sphereCenter, minPoint, maxPoint);
+            var num = Vector3.DistanceSquared(sphereCenter, vector);
             return (num <= (sphereRadius * sphereRadius));
         }
 
@@ -169,7 +169,7 @@
                         break;
                     }
                 }
-                if (inCount == 0)
+                if (inCount === 0)
                     return false;
             }
             return true;

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

@@ -4,7 +4,7 @@ var BABYLON;
         function ShadowGenerator(mapSize, light) {
             var _this = this;
             // Members
-            this.filter = ShadowGenerator.FILTER_NONE;
+            this.filter = ShadowGenerator.FILTER_VARIANCESHADOWMAP;
             this._darkness = 0;
             this._transparencyShadow = false;
             this._viewMatrix = BABYLON.Matrix.Zero();

+ 7 - 2
Babylon/Loading/Plugins/babylon.babylonFileLoader.ts

@@ -1434,10 +1434,15 @@
             }
 
             // Sounds
-            if (parsedData.sounds && Engine.audioEngine.canUseWebAudio) {
+            if (parsedData.sounds) {
                 for (index = 0; index < parsedData.sounds.length; index++) {
                     var parsedSound = parsedData.sounds[index];
-                    parseSound(parsedSound, scene, rootUrl);
+                    if (Engine.audioEngine.canUseWebAudio) {
+                        parseSound(parsedSound, scene, rootUrl);
+                    }
+                    else {
+                        var emptySound = new BABYLON.Sound(parsedSound.name, null, scene);
+                    }
                 }
             }
 

+ 2 - 2
Babylon/Materials/Textures/Procedurals/babylon.customProceduralTexture.js

@@ -21,7 +21,7 @@ var BABYLON;
             var _this = this;
             var that = this;
             function noConfigFile() {
-                BABYLON.Tools.Log("No config file found in " + jsonUrl + " trying to use ShadersStore or DOM element");
+                BABYLON.Tools.Log("No config file found in " + jsonUrl + " trying to use ShaderStore or DOM element");
                 try {
                     that.setFragment(that._texturePath);
                 }
@@ -50,7 +50,7 @@ var BABYLON;
                     noConfigFile();
                 }
             }, false);
-            xhr.addEventListener("error", function () {
+            xhr.addEventListener("error", function (event) {
                 noConfigFile();
             }, false);
             try {

+ 5 - 5
Babylon/Materials/Textures/babylon.renderTargetTexture.js

@@ -99,6 +99,8 @@ var BABYLON;
             if (!useCameraPostProcess || !scene.postProcessManager._prepareFrame(this._texture)) {
                 engine.bindFramebuffer(this._texture);
             }
+            // Clear
+            engine.clear(scene.clearColor, true, true);
             this._renderingManager.reset();
             var currentRenderList = this.renderList ? this.renderList : scene.getActiveMeshes().data;
             for (var meshIndex = 0; meshIndex < currentRenderList.length; meshIndex++) {
@@ -119,14 +121,12 @@ var BABYLON;
                     }
                 }
             }
-            if (this.onBeforeRender) {
-                this.onBeforeRender();
-            }
-            // Clear
-            engine.clear(scene.clearColor, true, true);
             if (!this._doNotChangeAspectRatio) {
                 scene.updateTransformMatrix(true);
             }
+            if (this.onBeforeRender) {
+                this.onBeforeRender();
+            }
             // Render
             this._renderingManager.render(this.customRenderFunction, currentRenderList, this.renderParticles, this.renderSprites);
             if (useCameraPostProcess) {

+ 4 - 5
Babylon/Materials/Textures/babylon.renderTargetTexture.ts

@@ -147,7 +147,6 @@
             // Clear
             engine.clear(scene.clearColor, true, true);
 
-
             if (!this._doNotChangeAspectRatio) {
                 scene.updateTransformMatrix(true);
             }
@@ -159,16 +158,16 @@
                 scene.postProcessManager._finalizeFrame(false, this._texture);
             }
 
+            if (!this._doNotChangeAspectRatio) {
+                scene.updateTransformMatrix(true);
+            }
+
             if (this.onAfterRender) {
                 this.onAfterRender();
             }
 
             // Unbind
             engine.unBindFramebuffer(this._texture);
-
-            if (!this._doNotChangeAspectRatio) {
-                scene.updateTransformMatrix(true);
-            }
         }
 
         public clone(): RenderTargetTexture {

+ 33 - 119
Babylon/Math/babylon.math.js

@@ -20,7 +20,6 @@ var BABYLON;
             array[index] = this.r;
             array[index + 1] = this.g;
             array[index + 2] = this.b;
-            return this;
         };
         Color3.prototype.toColor4 = function (alpha) {
             if (alpha === void 0) { alpha = 1; }
@@ -41,7 +40,6 @@ var BABYLON;
             result.r = this.r * otherColor.r;
             result.g = this.g * otherColor.g;
             result.b = this.b * otherColor.b;
-            return this;
         };
         Color3.prototype.equals = function (otherColor) {
             return otherColor && this.r === otherColor.r && this.g === otherColor.g && this.b === otherColor.b;
@@ -53,7 +51,6 @@ var BABYLON;
             result.r = this.r * scale;
             result.g = this.g * scale;
             result.b = this.b * scale;
-            return this;
         };
         Color3.prototype.add = function (otherColor) {
             return new Color3(this.r + otherColor.r, this.g + otherColor.g, this.b + otherColor.b);
@@ -62,7 +59,6 @@ var BABYLON;
             result.r = this.r + otherColor.r;
             result.g = this.g + otherColor.g;
             result.b = this.b + otherColor.b;
-            return this;
         };
         Color3.prototype.subtract = function (otherColor) {
             return new Color3(this.r - otherColor.r, this.g - otherColor.g, this.b - otherColor.b);
@@ -71,7 +67,6 @@ var BABYLON;
             result.r = this.r - otherColor.r;
             result.g = this.g - otherColor.g;
             result.b = this.b - otherColor.b;
-            return this;
         };
         Color3.prototype.clone = function () {
             return new Color3(this.r, this.g, this.b);
@@ -80,13 +75,11 @@ var BABYLON;
             this.r = source.r;
             this.g = source.g;
             this.b = source.b;
-            return this;
         };
         Color3.prototype.copyFromFloats = function (r, g, b) {
             this.r = r;
             this.g = g;
             this.b = b;
-            return this;
         };
         // Statics
         Color3.FromArray = function (array, offset) {
@@ -145,7 +138,6 @@ var BABYLON;
             this.g += right.g;
             this.b += right.b;
             this.a += right.a;
-            return this;
         };
         Color4.prototype.asArray = function () {
             var result = [];
@@ -160,7 +152,6 @@ var BABYLON;
             array[index + 1] = this.g;
             array[index + 2] = this.b;
             array[index + 3] = this.a;
-            return this;
         };
         Color4.prototype.add = function (right) {
             return new Color4(this.r + right.r, this.g + right.g, this.b + right.b, this.a + right.a);
@@ -173,7 +164,6 @@ var BABYLON;
             result.g = this.g - right.g;
             result.b = this.b - right.b;
             result.a = this.a - right.a;
-            return this;
         };
         Color4.prototype.scale = function (scale) {
             return new Color4(this.r * scale, this.g * scale, this.b * scale, this.a * scale);
@@ -183,7 +173,6 @@ var BABYLON;
             result.g = this.g * scale;
             result.b = this.b * scale;
             result.a = this.a * scale;
-            return this;
         };
         Color4.prototype.toString = function () {
             return "{R: " + this.r + " G:" + this.g + " B:" + this.b + " A:" + this.a + "}";
@@ -196,7 +185,6 @@ var BABYLON;
             this.g = source.g;
             this.b = source.b;
             this.a = source.a;
-            return this;
         };
         // Statics
         Color4.Lerp = function (left, right, amount) {
@@ -230,10 +218,11 @@ var BABYLON;
         };
         // Operators
         Vector2.prototype.toArray = function (array, index) {
-            if (index === void 0) { index = 0; }
+            if (index === undefined) {
+                index = 0;
+            }
             array[index] = this.x;
             array[index + 1] = this.y;
-            return this;
         };
         Vector2.prototype.asArray = function () {
             var result = [];
@@ -243,12 +232,10 @@ var BABYLON;
         Vector2.prototype.copyFrom = function (source) {
             this.x = source.x;
             this.y = source.y;
-            return this;
         };
         Vector2.prototype.copyFromFloats = function (x, y) {
             this.x = x;
             this.y = y;
-            return this;
         };
         Vector2.prototype.add = function (otherVector) {
             return new Vector2(this.x + otherVector.x, this.y + otherVector.y);
@@ -262,12 +249,10 @@ var BABYLON;
         Vector2.prototype.subtractInPlace = function (otherVector) {
             this.x -= otherVector.x;
             this.y -= otherVector.y;
-            return this;
         };
         Vector2.prototype.multiplyInPlace = function (otherVector) {
             this.x *= otherVector.x;
             this.y *= otherVector.y;
-            return this;
         };
         Vector2.prototype.multiply = function (otherVector) {
             return new Vector2(this.x * otherVector.x, this.y * otherVector.y);
@@ -275,7 +260,6 @@ var BABYLON;
         Vector2.prototype.multiplyToRef = function (otherVector, result) {
             result.x = this.x * otherVector.x;
             result.y = this.y * otherVector.y;
-            return this;
         };
         Vector2.prototype.multiplyByFloats = function (x, y) {
             return new Vector2(this.x * x, this.y * y);
@@ -286,7 +270,6 @@ var BABYLON;
         Vector2.prototype.divideToRef = function (otherVector, result) {
             result.x = this.x / otherVector.x;
             result.y = this.y / otherVector.y;
-            return this;
         };
         Vector2.prototype.negate = function () {
             return new Vector2(-this.x, -this.y);
@@ -416,31 +399,17 @@ var BABYLON;
             return result;
         };
         Vector3.prototype.toArray = function (array, index) {
-            if (index === void 0) { index = 0; }
+            if (index === undefined) {
+                index = 0;
+            }
             array[index] = this.x;
             array[index + 1] = this.y;
             array[index + 2] = this.z;
-            return this;
-        };
-        Vector3.prototype.toQuaternion = function () {
-            var result = new Quaternion(0, 0, 0, 1);
-            var cosxPlusz = Math.cos((this.x + this.z) * 0.5);
-            var sinxPlusz = Math.sin((this.x + this.z) * 0.5);
-            var coszMinusx = Math.cos((this.z - this.x) * 0.5);
-            var sinzMinusx = Math.sin((this.z - this.x) * 0.5);
-            var cosy = Math.cos(this.y * 0.5);
-            var siny = Math.sin(this.y * 0.5);
-            result.x = coszMinusx * siny;
-            result.y = -sinzMinusx * siny;
-            result.z = sinxPlusz * cosy;
-            result.w = cosxPlusz * cosy;
-            return result;
         };
         Vector3.prototype.addInPlace = function (otherVector) {
             this.x += otherVector.x;
             this.y += otherVector.y;
             this.z += otherVector.z;
-            return this;
         };
         Vector3.prototype.add = function (otherVector) {
             return new Vector3(this.x + otherVector.x, this.y + otherVector.y, this.z + otherVector.z);
@@ -449,13 +418,11 @@ var BABYLON;
             result.x = this.x + otherVector.x;
             result.y = this.y + otherVector.y;
             result.z = this.z + otherVector.z;
-            return this;
         };
         Vector3.prototype.subtractInPlace = function (otherVector) {
             this.x -= otherVector.x;
             this.y -= otherVector.y;
             this.z -= otherVector.z;
-            return this;
         };
         Vector3.prototype.subtract = function (otherVector) {
             return new Vector3(this.x - otherVector.x, this.y - otherVector.y, this.z - otherVector.z);
@@ -464,7 +431,6 @@ var BABYLON;
             result.x = this.x - otherVector.x;
             result.y = this.y - otherVector.y;
             result.z = this.z - otherVector.z;
-            return this;
         };
         Vector3.prototype.subtractFromFloats = function (x, y, z) {
             return new Vector3(this.x - x, this.y - y, this.z - z);
@@ -473,7 +439,6 @@ var BABYLON;
             result.x = this.x - x;
             result.y = this.y - y;
             result.z = this.z - z;
-            return this;
         };
         Vector3.prototype.negate = function () {
             return new Vector3(-this.x, -this.y, -this.z);
@@ -505,7 +470,6 @@ var BABYLON;
             this.x *= otherVector.x;
             this.y *= otherVector.y;
             this.z *= otherVector.z;
-            return this;
         };
         Vector3.prototype.multiply = function (otherVector) {
             return new Vector3(this.x * otherVector.x, this.y * otherVector.y, this.z * otherVector.z);
@@ -514,7 +478,6 @@ var BABYLON;
             result.x = this.x * otherVector.x;
             result.y = this.y * otherVector.y;
             result.z = this.z * otherVector.z;
-            return this;
         };
         Vector3.prototype.multiplyByFloats = function (x, y, z) {
             return new Vector3(this.x * x, this.y * y, this.z * z);
@@ -526,7 +489,6 @@ var BABYLON;
             result.x = this.x / otherVector.x;
             result.y = this.y / otherVector.y;
             result.z = this.z / otherVector.z;
-            return this;
         };
         Vector3.prototype.MinimizeInPlace = function (other) {
             if (other.x < this.x)
@@ -535,7 +497,6 @@ var BABYLON;
                 this.y = other.y;
             if (other.z < this.z)
                 this.z = other.z;
-            return this;
         };
         Vector3.prototype.MaximizeInPlace = function (other) {
             if (other.x > this.x)
@@ -544,7 +505,6 @@ var BABYLON;
                 this.y = other.y;
             if (other.z > this.z)
                 this.z = other.z;
-            return this;
         };
         // Properties
         Vector3.prototype.length = function () {
@@ -571,13 +531,11 @@ var BABYLON;
             this.x = source.x;
             this.y = source.y;
             this.z = source.z;
-            return this;
         };
         Vector3.prototype.copyFromFloats = function (x, y, z) {
             this.x = x;
             this.y = y;
             this.z = z;
-            return this;
         };
         // Statics
         Vector3.FromArray = function (array, offset) {
@@ -790,14 +748,12 @@ var BABYLON;
             array[index + 1] = this.y;
             array[index + 2] = this.z;
             array[index + 3] = this.w;
-            return this;
         };
         Vector4.prototype.addInPlace = function (otherVector) {
             this.x += otherVector.x;
             this.y += otherVector.y;
             this.z += otherVector.z;
             this.w += otherVector.w;
-            return this;
         };
         Vector4.prototype.add = function (otherVector) {
             return new Vector4(this.x + otherVector.x, this.y + otherVector.y, this.z + otherVector.z, this.w + otherVector.w);
@@ -807,14 +763,12 @@ var BABYLON;
             result.y = this.y + otherVector.y;
             result.z = this.z + otherVector.z;
             result.w = this.w + otherVector.w;
-            return this;
         };
         Vector4.prototype.subtractInPlace = function (otherVector) {
             this.x -= otherVector.x;
             this.y -= otherVector.y;
             this.z -= otherVector.z;
             this.w -= otherVector.w;
-            return this;
         };
         Vector4.prototype.subtract = function (otherVector) {
             return new Vector4(this.x - otherVector.x, this.y - otherVector.y, this.z - otherVector.z, this.w - otherVector.w);
@@ -824,7 +778,6 @@ var BABYLON;
             result.y = this.y - otherVector.y;
             result.z = this.z - otherVector.z;
             result.w = this.w - otherVector.w;
-            return this;
         };
         Vector4.prototype.subtractFromFloats = function (x, y, z, w) {
             return new Vector4(this.x - x, this.y - y, this.z - z, this.w - w);
@@ -834,7 +787,6 @@ var BABYLON;
             result.y = this.y - y;
             result.z = this.z - z;
             result.w = this.w - w;
-            return this;
         };
         Vector4.prototype.negate = function () {
             return new Vector4(-this.x, -this.y, -this.z, -this.w);
@@ -869,7 +821,6 @@ var BABYLON;
             this.y *= otherVector.y;
             this.z *= otherVector.z;
             this.w *= otherVector.w;
-            return this;
         };
         Vector4.prototype.multiply = function (otherVector) {
             return new Vector4(this.x * otherVector.x, this.y * otherVector.y, this.z * otherVector.z, this.w * otherVector.w);
@@ -879,7 +830,6 @@ var BABYLON;
             result.y = this.y * otherVector.y;
             result.z = this.z * otherVector.z;
             result.w = this.w * otherVector.w;
-            return this;
         };
         Vector4.prototype.multiplyByFloats = function (x, y, z, w) {
             return new Vector4(this.x * x, this.y * y, this.z * z, this.w * w);
@@ -892,7 +842,6 @@ var BABYLON;
             result.y = this.y / otherVector.y;
             result.z = this.z / otherVector.z;
             result.w = this.w / otherVector.w;
-            return this;
         };
         Vector4.prototype.MinimizeInPlace = function (other) {
             if (other.x < this.x)
@@ -903,7 +852,6 @@ var BABYLON;
                 this.z = other.z;
             if (other.w < this.w)
                 this.w = other.w;
-            return this;
         };
         Vector4.prototype.MaximizeInPlace = function (other) {
             if (other.x > this.x)
@@ -914,7 +862,6 @@ var BABYLON;
                 this.z = other.z;
             if (other.w > this.w)
                 this.w = other.w;
-            return this;
         };
         // Properties
         Vector4.prototype.length = function () {
@@ -943,14 +890,12 @@ var BABYLON;
             this.y = source.y;
             this.z = source.z;
             this.w = source.w;
-            return this;
         };
         Vector4.prototype.copyFromFloats = function (x, y, z, w) {
             this.x = x;
             this.y = y;
             this.z = z;
             this.w = w;
-            return this;
         };
         // Statics
         Vector4.FromArray = function (array, offset) {
@@ -1045,14 +990,12 @@ var BABYLON;
             this.y = other.y;
             this.z = other.z;
             this.w = other.w;
-            return this;
         };
         Quaternion.prototype.copyFromFloats = function (x, y, z, w) {
             this.x = x;
             this.y = y;
             this.z = z;
             this.w = w;
-            return this;
         };
         Quaternion.prototype.add = function (other) {
             return new Quaternion(this.x + other.x, this.y + other.y, this.z + other.z, this.w + other.w);
@@ -1073,7 +1016,6 @@ var BABYLON;
             result.y = -this.x * q1.z + this.y * q1.w + this.z * q1.x + this.w * q1.y;
             result.z = this.x * q1.y - this.y * q1.x + this.z * q1.w + this.w * q1.z;
             result.w = -this.x * q1.x - this.y * q1.y - this.z * q1.z + this.w * q1.w;
-            return this;
         };
         Quaternion.prototype.length = function () {
             return Math.sqrt((this.x * this.x) + (this.y * this.y) + (this.z * this.z) + (this.w * this.w));
@@ -1084,7 +1026,6 @@ var BABYLON;
             this.y *= length;
             this.z *= length;
             this.w *= length;
-            return this;
         };
         Quaternion.prototype.toEulerAngles = function () {
             var result = Vector3.Zero();
@@ -1123,7 +1064,6 @@ var BABYLON;
                     result.z = 0.0;
                 }
             }
-            return this;
         };
         Quaternion.prototype.toRotationMatrix = function (result) {
             var xx = this.x * this.x;
@@ -1151,19 +1091,8 @@ var BABYLON;
             result.m[13] = 0;
             result.m[14] = 0;
             result.m[15] = 1.0;
-            return this;
         };
         Quaternion.prototype.fromRotationMatrix = function (matrix) {
-            Quaternion.FromRotationMatrixToRef(matrix, this);
-            return this;
-        };
-        // Statics
-        Quaternion.FromRotationMatrix = function (matrix) {
-            var result = new Quaternion();
-            Quaternion.FromRotationMatrixToRef(matrix, result);
-            return result;
-        };
-        Quaternion.FromRotationMatrixToRef = function (matrix, result) {
             var data = matrix.m;
             var m11 = data[0], m12 = data[4], m13 = data[8];
             var m21 = data[1], m22 = data[5], m23 = data[9];
@@ -1172,33 +1101,35 @@ var BABYLON;
             var s;
             if (trace > 0) {
                 s = 0.5 / Math.sqrt(trace + 1.0);
-                result.w = 0.25 / s;
-                result.x = (m32 - m23) * s;
-                result.y = (m13 - m31) * s;
-                result.z = (m21 - m12) * s;
+                this.w = 0.25 / s;
+                this.x = (m32 - m23) * s;
+                this.y = (m13 - m31) * s;
+                this.z = (m21 - m12) * s;
+                return;
             }
-            else if (m11 > m22 && m11 > m33) {
+            if (m11 > m22 && m11 > m33) {
                 s = 2.0 * Math.sqrt(1.0 + m11 - m22 - m33);
-                result.w = (m32 - m23) / s;
-                result.x = 0.25 * s;
-                result.y = (m12 + m21) / s;
-                result.z = (m13 + m31) / s;
+                this.w = (m32 - m23) / s;
+                this.x = 0.25 * s;
+                this.y = (m12 + m21) / s;
+                this.z = (m13 + m31) / s;
+                return;
             }
-            else if (m22 > m33) {
+            if (m22 > m33) {
                 s = 2.0 * Math.sqrt(1.0 + m22 - m11 - m33);
-                result.w = (m13 - m31) / s;
-                result.x = (m12 + m21) / s;
-                result.y = 0.25 * s;
-                result.z = (m23 + m32) / s;
-            }
-            else {
-                s = 2.0 * Math.sqrt(1.0 + m33 - m11 - m22);
-                result.w = (m21 - m12) / s;
-                result.x = (m13 + m31) / s;
-                result.y = (m23 + m32) / s;
-                result.z = 0.25 * s;
+                this.w = (m13 - m31) / s;
+                this.x = (m12 + m21) / s;
+                this.y = 0.25 * s;
+                this.z = (m23 + m32) / s;
+                return;
             }
+            s = 2.0 * Math.sqrt(1.0 + m33 - m11 - m22);
+            this.w = (m21 - m12) / s;
+            this.x = (m13 + m31) / s;
+            this.y = (m23 + m32) / s;
+            this.z = 0.25 * s;
         };
+        // Statics
         Quaternion.Inverse = function (q) {
             return new Quaternion(-q.x, -q.y, -q.z, q.w);
         };
@@ -1295,7 +1226,6 @@ var BABYLON;
         };
         Matrix.prototype.invert = function () {
             this.invertToRef(this);
-            return this;
         };
         Matrix.prototype.invertToRef = function (other) {
             var l1 = this.m[0];
@@ -1353,13 +1283,11 @@ var BABYLON;
             other.m[7] = (((l1 * l34) - (l3 * l37)) + (l4 * l38)) * l27;
             other.m[11] = -(((l1 * l35) - (l2 * l37)) + (l4 * l39)) * l27;
             other.m[15] = (((l1 * l36) - (l2 * l38)) + (l3 * l39)) * l27;
-            return this;
         };
         Matrix.prototype.setTranslation = function (vector3) {
             this.m[12] = vector3.x;
             this.m[13] = vector3.y;
             this.m[14] = vector3.z;
-            return this;
         };
         Matrix.prototype.multiply = function (other) {
             var result = new Matrix();
@@ -1370,18 +1298,15 @@ var BABYLON;
             for (var index = 0; index < 16; index++) {
                 this.m[index] = other.m[index];
             }
-            return this;
         };
         Matrix.prototype.copyToArray = function (array, offset) {
             if (offset === void 0) { offset = 0; }
             for (var index = 0; index < 16; index++) {
                 array[offset + index] = this.m[index];
             }
-            return this;
         };
         Matrix.prototype.multiplyToRef = function (other, result) {
             this.multiplyToArray(other, result.m, 0);
-            return this;
         };
         Matrix.prototype.multiplyToArray = function (other, result, offset) {
             var tm0 = this.m[0];
@@ -1432,7 +1357,6 @@ var BABYLON;
             result[offset + 13] = tm12 * om1 + tm13 * om5 + tm14 * om9 + tm15 * om13;
             result[offset + 14] = tm12 * om2 + tm13 * om6 + tm14 * om10 + tm15 * om14;
             result[offset + 15] = tm12 * om3 + tm13 * om7 + tm14 * om11 + tm15 * om15;
-            return this;
         };
         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]);
@@ -1450,15 +1374,15 @@ var BABYLON;
             scale.x = xs * Math.sqrt(this.m[0] * this.m[0] + this.m[1] * this.m[1] + this.m[2] * this.m[2]);
             scale.y = ys * Math.sqrt(this.m[4] * this.m[4] + this.m[5] * this.m[5] + this.m[6] * this.m[6]);
             scale.z = zs * Math.sqrt(this.m[8] * this.m[8] + this.m[9] * this.m[9] + this.m[10] * this.m[10]);
-            if (scale.x === 0 || scale.y === 0 || scale.z === 0) {
+            if (scale.x == 0 || scale.y == 0 || scale.z == 0) {
                 rotation.x = 0;
                 rotation.y = 0;
                 rotation.z = 0;
                 rotation.w = 1;
                 return false;
             }
-            var rotationMatrix = Matrix.FromValues(this.m[0] / scale.x, this.m[1] / scale.x, this.m[2] / scale.x, 0, this.m[4] / scale.y, this.m[5] / scale.y, this.m[6] / scale.y, 0, this.m[8] / scale.z, this.m[9] / scale.z, this.m[10] / scale.z, 0, 0, 0, 0, 1);
-            Quaternion.FromRotationMatrixToRef(rotationMatrix, rotation);
+            var rotationMatrix = BABYLON.Matrix.FromValues(this.m[0] / scale.x, this.m[1] / scale.x, this.m[2] / scale.x, 0, this.m[4] / scale.y, this.m[5] / scale.y, this.m[6] / scale.y, 0, this.m[8] / scale.z, this.m[9] / scale.z, this.m[10] / scale.z, 0, 0, 0, 0, 1);
+            rotation.fromRotationMatrix(rotationMatrix);
             return true;
         };
         // Statics
@@ -1845,7 +1769,6 @@ var BABYLON;
             this.normal.y *= magnitude;
             this.normal.z *= magnitude;
             this.d *= magnitude;
-            return this;
         };
         Plane.prototype.transform = function (transformation) {
             var transposedMatrix = Matrix.Transpose(transformation);
@@ -1884,7 +1807,6 @@ var BABYLON;
             this.normal.y = xz * invPyth;
             this.normal.z = xy * invPyth;
             this.d = -((this.normal.x * point1.x) + (this.normal.y * point1.y) + (this.normal.z * point1.z));
-            return this;
         };
         Plane.prototype.isFrontFacingTo = function (direction, epsilon) {
             var dot = Vector3.Dot(this.normal, direction);
@@ -2257,12 +2179,10 @@ var BABYLON;
         PathCursor.prototype.moveAhead = function (step) {
             if (step === void 0) { step = 0.002; }
             this.move(step);
-            return this;
         };
         PathCursor.prototype.moveBack = function (step) {
             if (step === void 0) { step = 0.002; }
             this.move(-step);
-            return this;
         };
         PathCursor.prototype.move = function (step) {
             if (Math.abs(step) > 1) {
@@ -2271,7 +2191,6 @@ var BABYLON;
             this.value += step;
             this.ensureLimits();
             this.raiseOnChange();
-            return this;
         };
         PathCursor.prototype.ensureLimits = function () {
             while (this.value > 1) {
@@ -2280,22 +2199,18 @@ var BABYLON;
             while (this.value < 0) {
                 this.value += 1;
             }
-            return this;
         };
         // used by animation engine
         PathCursor.prototype.markAsDirty = function (propertyName) {
             this.ensureLimits();
             this.raiseOnChange();
-            return this;
         };
         PathCursor.prototype.raiseOnChange = function () {
             var _this = this;
             this._onchange.forEach(function (f) { return f(_this); });
-            return this;
         };
         PathCursor.prototype.onchange = function (f) {
             this._onchange.push(f);
-            return this;
         };
         return PathCursor;
     })();
@@ -2359,7 +2274,7 @@ var BABYLON;
         Path2.prototype.getPointAtLengthPosition = function (normalizedLengthPosition) {
             if (normalizedLengthPosition < 0 || normalizedLengthPosition > 1) {
                 BABYLON.Tools.Error("normalized length position should be between 0 and 1.");
-                return Vector2.Zero();
+                return;
             }
             var lengthPosition = normalizedLengthPosition * this.length();
             var previousOffset = 0;
@@ -2377,7 +2292,6 @@ var BABYLON;
                 previousOffset = nextOffset;
             }
             BABYLON.Tools.Error("internal error");
-            return Vector2.Zero();
         };
         Path2.StartingAt = function (x, y) {
             return new Path2(x, y);

+ 64 - 226
Babylon/Mesh/babylon.abstractMesh.js

@@ -1,4 +1,4 @@
-var __extends = this.__extends || function (d, b) {
+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;
@@ -11,7 +11,7 @@ var BABYLON;
         function AbstractMesh(name, scene) {
             _super.call(this, name, scene);
             // Properties
-            this.definedFacingForward = true;
+            this.definedFacingForward = true; // orientation for POV movement & rotation
             this.position = new BABYLON.Vector3(0, 0, 0);
             this.rotation = new BABYLON.Vector3(0, 0, 0);
             this.scaling = new BABYLON.Vector3(1, 1, 1);
@@ -69,7 +69,6 @@ var BABYLON;
             this._renderId = 0;
             this._intersectionsInProgress = new Array();
             this._onAfterWorldMatrixUpdate = new Array();
-
             scene.meshes.push(this);
         }
         Object.defineProperty(AbstractMesh, "BILLBOARDMODE_NONE", {
@@ -79,7 +78,6 @@ var BABYLON;
             enumerable: true,
             configurable: true
         });
-
         Object.defineProperty(AbstractMesh, "BILLBOARDMODE_X", {
             get: function () {
                 return AbstractMesh._BILLBOARDMODE_X;
@@ -87,7 +85,6 @@ var BABYLON;
             enumerable: true,
             configurable: true
         });
-
         Object.defineProperty(AbstractMesh, "BILLBOARDMODE_Y", {
             get: function () {
                 return AbstractMesh._BILLBOARDMODE_Y;
@@ -95,7 +92,6 @@ var BABYLON;
             enumerable: true,
             configurable: true
         });
-
         Object.defineProperty(AbstractMesh, "BILLBOARDMODE_Z", {
             get: function () {
                 return AbstractMesh._BILLBOARDMODE_Z;
@@ -103,7 +99,6 @@ var BABYLON;
             enumerable: true,
             configurable: true
         });
-
         Object.defineProperty(AbstractMesh, "BILLBOARDMODE_ALL", {
             get: function () {
                 return AbstractMesh._BILLBOARDMODE_ALL;
@@ -111,7 +106,6 @@ var BABYLON;
             enumerable: true,
             configurable: true
         });
-
         Object.defineProperty(AbstractMesh.prototype, "isBlocked", {
             // Methods
             get: function () {
@@ -120,38 +114,30 @@ var BABYLON;
             enumerable: true,
             configurable: true
         });
-
         AbstractMesh.prototype.getLOD = function (camera) {
             return this;
         };
-
         AbstractMesh.prototype.getTotalVertices = function () {
             return 0;
         };
-
         AbstractMesh.prototype.getIndices = function () {
             return null;
         };
-
         AbstractMesh.prototype.getVerticesData = function (kind) {
             return null;
         };
-
         AbstractMesh.prototype.isVerticesDataPresent = function (kind) {
             return false;
         };
-
         AbstractMesh.prototype.getBoundingInfo = function () {
             if (this._masterMesh) {
                 return this._masterMesh.getBoundingInfo();
             }
-
             if (!this._boundingInfo) {
                 this._updateBoundingInfo();
             }
             return this._boundingInfo;
         };
-
         Object.defineProperty(AbstractMesh.prototype, "useBones", {
             get: function () {
                 return this.skeleton && this.getScene().skeletonsEnabled && this.isVerticesDataPresent(BABYLON.VertexBuffer.MatricesIndicesKind) && this.isVerticesDataPresent(BABYLON.VertexBuffer.MatricesWeightsKind);
@@ -159,25 +145,20 @@ var BABYLON;
             enumerable: true,
             configurable: true
         });
-
         AbstractMesh.prototype._preActivate = function () {
         };
-
         AbstractMesh.prototype._activate = function (renderId) {
             this._renderId = renderId;
         };
-
         AbstractMesh.prototype.getWorldMatrix = function () {
             if (this._masterMesh) {
                 return this._masterMesh.getWorldMatrix();
             }
-
             if (this._currentRenderId !== this.getScene().getRenderId()) {
                 this.computeWorldMatrix();
             }
             return this._worldMatrix;
         };
-
         Object.defineProperty(AbstractMesh.prototype, "worldMatrixFromCache", {
             get: function () {
                 return this._worldMatrix;
@@ -185,7 +166,6 @@ var BABYLON;
             enumerable: true,
             configurable: true
         });
-
         Object.defineProperty(AbstractMesh.prototype, "absolutePosition", {
             get: function () {
                 return this._absolutePosition;
@@ -193,53 +173,46 @@ var BABYLON;
             enumerable: true,
             configurable: true
         });
-
         AbstractMesh.prototype.rotate = function (axis, amount, space) {
             if (!this.rotationQuaternion) {
                 this.rotationQuaternion = BABYLON.Quaternion.RotationYawPitchRoll(this.rotation.y, this.rotation.x, this.rotation.z);
                 this.rotation = BABYLON.Vector3.Zero();
             }
-
             if (!space || space == 0 /* LOCAL */) {
                 var rotationQuaternion = BABYLON.Quaternion.RotationAxis(axis, amount);
                 this.rotationQuaternion = this.rotationQuaternion.multiply(rotationQuaternion);
-            } else {
+            }
+            else {
                 if (this.parent) {
                     var invertParentWorldMatrix = this.parent.getWorldMatrix().clone();
                     invertParentWorldMatrix.invert();
-
                     axis = BABYLON.Vector3.TransformNormal(axis, invertParentWorldMatrix);
                 }
                 rotationQuaternion = BABYLON.Quaternion.RotationAxis(axis, amount);
                 this.rotationQuaternion = rotationQuaternion.multiply(this.rotationQuaternion);
             }
         };
-
         AbstractMesh.prototype.translate = function (axis, distance, space) {
             var displacementVector = axis.scale(distance);
-
             if (!space || space == 0 /* LOCAL */) {
                 var tempV3 = this.getPositionExpressedInLocalSpace().add(displacementVector);
                 this.setPositionWithLocalVector(tempV3);
-            } else {
+            }
+            else {
                 this.setAbsolutePosition(this.getAbsolutePosition().add(displacementVector));
             }
         };
-
         AbstractMesh.prototype.getAbsolutePosition = function () {
             this.computeWorldMatrix();
             return this._absolutePosition;
         };
-
         AbstractMesh.prototype.setAbsolutePosition = function (absolutePosition) {
             if (!absolutePosition) {
                 return;
             }
-
             var absolutePositionX;
             var absolutePositionY;
             var absolutePositionZ;
-
             if (absolutePosition.x === undefined) {
                 if (arguments.length < 3) {
                     return;
@@ -247,134 +220,116 @@ var BABYLON;
                 absolutePositionX = arguments[0];
                 absolutePositionY = arguments[1];
                 absolutePositionZ = arguments[2];
-            } else {
+            }
+            else {
                 absolutePositionX = absolutePosition.x;
                 absolutePositionY = absolutePosition.y;
                 absolutePositionZ = absolutePosition.z;
             }
-
             if (this.parent) {
                 var invertParentWorldMatrix = this.parent.getWorldMatrix().clone();
                 invertParentWorldMatrix.invert();
-
                 var worldPosition = new BABYLON.Vector3(absolutePositionX, absolutePositionY, absolutePositionZ);
-
                 this.position = BABYLON.Vector3.TransformCoordinates(worldPosition, invertParentWorldMatrix);
-            } else {
+            }
+            else {
                 this.position.x = absolutePositionX;
                 this.position.y = absolutePositionY;
                 this.position.z = absolutePositionZ;
             }
         };
-
         // ================================== Point of View Movement =================================
         /**
-        * Perform relative position change from the point of view of behind the front of the mesh.
-        * This is performed taking into account the meshes current rotation, so you do not have to care.
-        * Supports definition of mesh facing forward or backward.
-        * @param {number} amountRight
-        * @param {number} amountUp
-        * @param {number} amountForward
-        */
+         * Perform relative position change from the point of view of behind the front of the mesh.
+         * This is performed taking into account the meshes current rotation, so you do not have to care.
+         * Supports definition of mesh facing forward or backward.
+         * @param {number} amountRight
+         * @param {number} amountUp
+         * @param {number} amountForward
+         */
         AbstractMesh.prototype.movePOV = function (amountRight, amountUp, amountForward) {
             this.position.addInPlace(this.calcMovePOV(amountRight, amountUp, amountForward));
         };
-
         /**
-        * Calculate relative position change from the point of view of behind the front of the mesh.
-        * This is performed taking into account the meshes current rotation, so you do not have to care.
-        * Supports definition of mesh facing forward or backward.
-        * @param {number} amountRight
-        * @param {number} amountUp
-        * @param {number} amountForward
-        */
+         * Calculate relative position change from the point of view of behind the front of the mesh.
+         * This is performed taking into account the meshes current rotation, so you do not have to care.
+         * Supports definition of mesh facing forward or backward.
+         * @param {number} amountRight
+         * @param {number} amountUp
+         * @param {number} amountForward
+         */
         AbstractMesh.prototype.calcMovePOV = function (amountRight, amountUp, amountForward) {
             var rotMatrix = new BABYLON.Matrix();
             var rotQuaternion = (this.rotationQuaternion) ? this.rotationQuaternion : BABYLON.Quaternion.RotationYawPitchRoll(this.rotation.y, this.rotation.x, this.rotation.z);
             rotQuaternion.toRotationMatrix(rotMatrix);
-
             var translationDelta = BABYLON.Vector3.Zero();
             var defForwardMult = this.definedFacingForward ? -1 : 1;
             BABYLON.Vector3.TransformCoordinatesFromFloatsToRef(amountRight * defForwardMult, amountUp, amountForward * defForwardMult, rotMatrix, translationDelta);
             return translationDelta;
         };
-
         // ================================== Point of View Rotation =================================
         /**
-        * Perform relative rotation change from the point of view of behind the front of the mesh.
-        * Supports definition of mesh facing forward or backward.
-        * @param {number} flipBack
-        * @param {number} twirlClockwise
-        * @param {number} tiltRight
-        */
+         * Perform relative rotation change from the point of view of behind the front of the mesh.
+         * Supports definition of mesh facing forward or backward.
+         * @param {number} flipBack
+         * @param {number} twirlClockwise
+         * @param {number} tiltRight
+         */
         AbstractMesh.prototype.rotatePOV = function (flipBack, twirlClockwise, tiltRight) {
             this.rotation.addInPlace(this.calcRotatePOV(flipBack, twirlClockwise, tiltRight));
         };
-
         /**
-        * Calculate relative rotation change from the point of view of behind the front of the mesh.
-        * Supports definition of mesh facing forward or backward.
-        * @param {number} flipBack
-        * @param {number} twirlClockwise
-        * @param {number} tiltRight
-        */
+         * Calculate relative rotation change from the point of view of behind the front of the mesh.
+         * Supports definition of mesh facing forward or backward.
+         * @param {number} flipBack
+         * @param {number} twirlClockwise
+         * @param {number} tiltRight
+         */
         AbstractMesh.prototype.calcRotatePOV = function (flipBack, twirlClockwise, tiltRight) {
             var defForwardMult = this.definedFacingForward ? 1 : -1;
             return new BABYLON.Vector3(flipBack * defForwardMult, twirlClockwise, tiltRight * defForwardMult);
         };
-
         AbstractMesh.prototype.setPivotMatrix = function (matrix) {
             this._pivotMatrix = matrix;
             this._cache.pivotMatrixUpdated = true;
         };
-
         AbstractMesh.prototype.getPivotMatrix = function () {
             return this._pivotMatrix;
         };
-
         AbstractMesh.prototype._isSynchronized = function () {
             if (this._isDirty) {
                 return false;
             }
-
             if (this.billboardMode !== AbstractMesh.BILLBOARDMODE_NONE)
                 return false;
-
             if (this._cache.pivotMatrixUpdated) {
                 return false;
             }
-
             if (this.infiniteDistance) {
                 return false;
             }
-
             if (!this._cache.position.equals(this.position))
                 return false;
-
             if (this.rotationQuaternion) {
                 if (!this._cache.rotationQuaternion.equals(this.rotationQuaternion))
                     return false;
-            } else {
+            }
+            else {
                 if (!this._cache.rotation.equals(this.rotation))
                     return false;
             }
-
             if (!this._cache.scaling.equals(this.scaling))
                 return false;
-
             return true;
         };
-
         AbstractMesh.prototype._initCache = function () {
             _super.prototype._initCache.call(this);
-
             this._cache.localMatrixUpdated = false;
             this._cache.position = BABYLON.Vector3.Zero();
             this._cache.scaling = BABYLON.Vector3.Zero();
             this._cache.rotation = BABYLON.Vector3.Zero();
             this._cache.rotationQuaternion = new BABYLON.Quaternion(0, 0, 0, 0);
         };
-
         AbstractMesh.prototype.markAsDirty = function (property) {
             if (property === "rotation") {
                 this.rotationQuaternion = null;
@@ -382,79 +337,65 @@ var BABYLON;
             this._currentRenderId = Number.MAX_VALUE;
             this._isDirty = true;
         };
-
         AbstractMesh.prototype._updateBoundingInfo = function () {
             this._boundingInfo = this._boundingInfo || new BABYLON.BoundingInfo(this.absolutePosition, this.absolutePosition);
-
             this._boundingInfo._update(this.worldMatrixFromCache);
-
             this._updateSubMeshesBoundingInfo(this.worldMatrixFromCache);
         };
-
         AbstractMesh.prototype._updateSubMeshesBoundingInfo = function (matrix) {
             if (!this.subMeshes) {
                 return;
             }
-
             for (var subIndex = 0; subIndex < this.subMeshes.length; subIndex++) {
                 var subMesh = this.subMeshes[subIndex];
-
                 subMesh.updateBoundingInfo(matrix);
             }
         };
-
         AbstractMesh.prototype.computeWorldMatrix = function (force) {
             if (!force && (this._currentRenderId == this.getScene().getRenderId() || this.isSynchronized(true))) {
                 return this._worldMatrix;
             }
-
             this._cache.position.copyFrom(this.position);
             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);
-
             // Rotation
             if (this.rotationQuaternion) {
                 this.rotationQuaternion.toRotationMatrix(this._localRotation);
                 this._cache.rotationQuaternion.copyFrom(this.rotationQuaternion);
-            } else {
+            }
+            else {
                 BABYLON.Matrix.RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, this._localRotation);
                 this._cache.rotation.copyFrom(this.rotation);
             }
-
             // Translation
             if (this.infiniteDistance && !this.parent) {
                 var camera = this.getScene().activeCamera;
                 var cameraWorldMatrix = camera.getWorldMatrix();
-
                 var cameraGlobalPosition = new BABYLON.Vector3(cameraWorldMatrix.m[12], cameraWorldMatrix.m[13], cameraWorldMatrix.m[14]);
-
                 BABYLON.Matrix.TranslationToRef(this.position.x + cameraGlobalPosition.x, this.position.y + cameraGlobalPosition.y, this.position.z + cameraGlobalPosition.z, this._localTranslation);
-            } else {
+            }
+            else {
                 BABYLON.Matrix.TranslationToRef(this.position.x, this.position.y, this.position.z, this._localTranslation);
             }
-
             // Composing transformations
             this._pivotMatrix.multiplyToRef(this._localScaling, this._localPivotScaling);
             this._localPivotScaling.multiplyToRef(this._localRotation, this._localPivotScalingRotation);
-
             // Billboarding
             if (this.billboardMode !== AbstractMesh.BILLBOARDMODE_NONE && this.getScene().activeCamera) {
                 var localPosition = this.position.clone();
                 var zero = this.getScene().activeCamera.position.clone();
-
                 if (this.parent && this.parent.position) {
                     localPosition.addInPlace(this.parent.position);
                     BABYLON.Matrix.TranslationToRef(localPosition.x, localPosition.y, localPosition.z, this._localTranslation);
                 }
-
                 if ((this.billboardMode & AbstractMesh.BILLBOARDMODE_ALL) === AbstractMesh.BILLBOARDMODE_ALL) {
                     zero = this.getScene().activeCamera.position;
-                } else {
+                }
+                else {
                     if (this.billboardMode & BABYLON.AbstractMesh.BILLBOARDMODE_X)
                         zero.x = localPosition.x + BABYLON.Engine.Epsilon;
                     if (this.billboardMode & BABYLON.AbstractMesh.BILLBOARDMODE_Y)
@@ -462,39 +403,30 @@ var BABYLON;
                     if (this.billboardMode & BABYLON.AbstractMesh.BILLBOARDMODE_Z)
                         zero.z = localPosition.z + 0.001;
                 }
-
                 BABYLON.Matrix.LookAtLHToRef(localPosition, zero, BABYLON.Vector3.Up(), this._localBillboard);
                 this._localBillboard.m[12] = this._localBillboard.m[13] = this._localBillboard.m[14] = 0;
-
                 this._localBillboard.invert();
-
                 this._localPivotScalingRotation.multiplyToRef(this._localBillboard, this._localWorld);
                 this._rotateYByPI.multiplyToRef(this._localWorld, this._localPivotScalingRotation);
             }
-
             // Local world
             this._localPivotScalingRotation.multiplyToRef(this._localTranslation, this._localWorld);
-
             // Parent
             if (this.parent && this.parent.getWorldMatrix && this.billboardMode === BABYLON.AbstractMesh.BILLBOARDMODE_NONE) {
                 this._localWorld.multiplyToRef(this.parent.getWorldMatrix(), this._worldMatrix);
-            } else {
+            }
+            else {
                 this._worldMatrix.copyFrom(this._localWorld);
             }
-
             // Bounding info
             this._updateBoundingInfo();
-
             // Absolute position
             this._absolutePosition.copyFromFloats(this._worldMatrix.m[12], this._worldMatrix.m[13], this._worldMatrix.m[14]);
-
             for (var callbackIndex = 0; callbackIndex < this._onAfterWorldMatrixUpdate.length; callbackIndex++) {
                 this._onAfterWorldMatrixUpdate[callbackIndex](this);
             }
-
             return this._worldMatrix;
         };
-
         /**
         * If you'd like to be callbacked after the mesh position, rotation or scaling has been updated
         * @param func: callback function to add
@@ -502,35 +434,26 @@ var BABYLON;
         AbstractMesh.prototype.registerAfterWorldMatrixUpdate = function (func) {
             this._onAfterWorldMatrixUpdate.push(func);
         };
-
         AbstractMesh.prototype.unregisterAfterWorldMatrixUpdate = function (func) {
             var index = this._onAfterWorldMatrixUpdate.indexOf(func);
-
             if (index > -1) {
                 this._onAfterWorldMatrixUpdate.splice(index, 1);
             }
         };
-
         AbstractMesh.prototype.setPositionWithLocalVector = function (vector3) {
             this.computeWorldMatrix();
-
             this.position = BABYLON.Vector3.TransformNormal(vector3, this._localWorld);
         };
-
         AbstractMesh.prototype.getPositionExpressedInLocalSpace = function () {
             this.computeWorldMatrix();
             var invLocalWorldMatrix = this._localWorld.clone();
             invLocalWorldMatrix.invert();
-
             return BABYLON.Vector3.TransformNormal(this.position, invLocalWorldMatrix);
         };
-
         AbstractMesh.prototype.locallyTranslate = function (vector3) {
             this.computeWorldMatrix();
-
             this.position = BABYLON.Vector3.TransformCoordinates(vector3, this._localWorld);
         };
-
         AbstractMesh.prototype.lookAt = function (targetPoint, yawCor, pitchCor, rollCor) {
             /// <summary>Orients a mesh towards a target point. Mesh must be drawn facing user.</summary>
             /// <param name="targetPoint" type="BABYLON.Vector3">The position (must be in same space as current mesh) to look at</param>
@@ -538,204 +461,154 @@ var BABYLON;
             /// <param name="pitchCor" type="Number">optional pitch (x-axis) correction in radians</param>
             /// <param name="rollCor" type="Number">optional roll (z-axis) correction in radians</param>
             /// <returns>Mesh oriented towards targetMesh</returns>
-            yawCor = yawCor || 0; // default to zero if undefined
+            yawCor = yawCor || 0; // default to zero if undefined 
             pitchCor = pitchCor || 0;
             rollCor = rollCor || 0;
-
             var dv = targetPoint.subtract(this.position);
             var yaw = -Math.atan2(dv.z, dv.x) - Math.PI / 2;
             var len = Math.sqrt(dv.x * dv.x + dv.z * dv.z);
             var pitch = Math.atan2(dv.y, len);
             this.rotationQuaternion = BABYLON.Quaternion.RotationYawPitchRoll(yaw + yawCor, pitch + pitchCor, rollCor);
         };
-
         AbstractMesh.prototype.isInFrustum = function (frustumPlanes) {
             if (!this._boundingInfo.isInFrustum(frustumPlanes)) {
                 return false;
             }
-
             return true;
         };
-
         AbstractMesh.prototype.isCompletelyInFrustum = function (camera) {
             if (!camera) {
                 camera = this.getScene().activeCamera;
             }
-
             var transformMatrix = camera.getViewMatrix().multiply(camera.getProjectionMatrix());
-
             if (!this._boundingInfo.isCompletelyInFrustum(BABYLON.Frustum.GetPlanes(transformMatrix))) {
                 return false;
             }
-
             return true;
         };
-
         AbstractMesh.prototype.intersectsMesh = function (mesh, precise) {
             if (!this._boundingInfo || !mesh._boundingInfo) {
                 return false;
             }
-
             return this._boundingInfo.intersects(mesh._boundingInfo, precise);
         };
-
         AbstractMesh.prototype.intersectsPoint = function (point) {
             if (!this._boundingInfo) {
                 return false;
             }
-
             return this._boundingInfo.intersectsPoint(point);
         };
-
         // Physics
         AbstractMesh.prototype.setPhysicsState = function (impostor, options) {
             var physicsEngine = this.getScene().getPhysicsEngine();
-
             if (!physicsEngine) {
                 return;
             }
-
-            impostor = impostor || BABYLON.PhysicsEngine.NoImpostor;
-
             if (impostor.impostor) {
                 // Old API
                 options = impostor;
                 impostor = impostor.impostor;
             }
-
+            impostor = impostor || BABYLON.PhysicsEngine.NoImpostor;
             if (impostor === BABYLON.PhysicsEngine.NoImpostor) {
                 physicsEngine._unregisterMesh(this);
                 return;
             }
-
-            if (!options) {
-                options = { mass: 0, friction: 0.2, restitution: 0.2 };
-            } else {
-                options.mass = options.mass || 0;
-                options.friction = options.friction || 0.2;
-                options.restitution = options.restitution || 0.2;
-            }
-
+            options.mass = options.mass || 0;
+            options.friction = options.friction || 0.2;
+            options.restitution = options.restitution || 0.2;
             this._physicImpostor = impostor;
             this._physicsMass = options.mass;
             this._physicsFriction = options.friction;
             this._physicRestitution = options.restitution;
-
             return physicsEngine._registerMesh(this, impostor, options);
         };
-
         AbstractMesh.prototype.getPhysicsImpostor = function () {
             if (!this._physicImpostor) {
                 return BABYLON.PhysicsEngine.NoImpostor;
             }
-
             return this._physicImpostor;
         };
-
         AbstractMesh.prototype.getPhysicsMass = function () {
             if (!this._physicsMass) {
                 return 0;
             }
-
             return this._physicsMass;
         };
-
         AbstractMesh.prototype.getPhysicsFriction = function () {
             if (!this._physicsFriction) {
                 return 0;
             }
-
             return this._physicsFriction;
         };
-
         AbstractMesh.prototype.getPhysicsRestitution = function () {
             if (!this._physicRestitution) {
                 return 0;
             }
-
             return this._physicRestitution;
         };
-
         AbstractMesh.prototype.getPositionInCameraSpace = function (camera) {
             if (!camera) {
                 camera = this.getScene().activeCamera;
             }
-
             return BABYLON.Vector3.TransformCoordinates(this.absolutePosition, camera.getViewMatrix());
         };
-
         AbstractMesh.prototype.getDistanceToCamera = function (camera) {
             if (!camera) {
                 camera = this.getScene().activeCamera;
             }
-
             return this.absolutePosition.subtract(camera.position).length();
         };
-
         AbstractMesh.prototype.applyImpulse = function (force, contactPoint) {
             if (!this._physicImpostor) {
                 return;
             }
-
             this.getScene().getPhysicsEngine()._applyImpulse(this, force, contactPoint);
         };
-
         AbstractMesh.prototype.setPhysicsLinkWith = function (otherMesh, pivot1, pivot2, options) {
             if (!this._physicImpostor) {
                 return;
             }
-
             this.getScene().getPhysicsEngine()._createLink(this, otherMesh, pivot1, pivot2, options);
         };
-
         AbstractMesh.prototype.updatePhysicsBodyPosition = function () {
             if (!this._physicImpostor) {
                 return;
             }
             this.getScene().getPhysicsEngine()._updateBodyPosition(this);
         };
-
         // Collisions
         AbstractMesh.prototype.moveWithCollisions = function (velocity) {
             var globalPosition = this.getAbsolutePosition();
-
             globalPosition.subtractFromFloatsToRef(0, this.ellipsoid.y, 0, this._oldPositionForCollisions);
             this._oldPositionForCollisions.addInPlace(this.ellipsoidOffset);
             this._collider.radius = this.ellipsoid;
-
             this.getScene()._getNewPosition(this._oldPositionForCollisions, velocity, this._collider, 3, this._newPositionForCollisions, this);
             this._newPositionForCollisions.subtractToRef(this._oldPositionForCollisions, this._diffPositionForCollisions);
-
             if (this._diffPositionForCollisions.length() > BABYLON.Engine.CollisionsEpsilon) {
                 this.position.addInPlace(this._diffPositionForCollisions);
             }
         };
-
         // Submeshes octree
         /**
         * This function will create an octree to help select the right submeshes for rendering, picking and collisions
         * Please note that you must have a decent number of submeshes to get performance improvements when using octree
         */
         AbstractMesh.prototype.createOrUpdateSubmeshesOctree = function (maxCapacity, maxDepth) {
-            if (typeof maxCapacity === "undefined") { maxCapacity = 64; }
-            if (typeof maxDepth === "undefined") { maxDepth = 2; }
+            if (maxCapacity === void 0) { maxCapacity = 64; }
+            if (maxDepth === void 0) { maxDepth = 2; }
             if (!this._submeshesOctree) {
                 this._submeshesOctree = new BABYLON.Octree(BABYLON.Octree.CreationFuncForSubMeshes, maxCapacity, maxDepth);
             }
-
             this.computeWorldMatrix(true);
-
             // Update octree
             var bbox = this.getBoundingInfo().boundingBox;
             this._submeshesOctree.update(bbox.minimumWorld, bbox.maximumWorld, this.subMeshes);
-
             return this._submeshesOctree;
         };
-
         // Collisions
         AbstractMesh.prototype._collideForSubMesh = function (subMesh, transformMatrix, collider) {
             this._generatePointsArray();
-
             // Transformation
             if (!subMesh._lastColliderWorldVertices || !subMesh._lastColliderTransformMatrix.equals(transformMatrix)) {
                 subMesh._lastColliderTransformMatrix = transformMatrix.clone();
@@ -747,103 +620,81 @@ var BABYLON;
                     subMesh._lastColliderWorldVertices.push(BABYLON.Vector3.TransformCoordinates(this._positions[i], transformMatrix));
                 }
             }
-
             // Collide
             collider._collide(subMesh, subMesh._lastColliderWorldVertices, this.getIndices(), subMesh.indexStart, subMesh.indexStart + subMesh.indexCount, subMesh.verticesStart);
         };
-
         AbstractMesh.prototype._processCollisionsForSubMeshes = function (collider, transformMatrix) {
             var subMeshes;
             var len;
-
             // Octrees
             if (this._submeshesOctree && this.useOctreeForCollisions) {
                 var radius = collider.velocityWorldLength + Math.max(collider.radius.x, collider.radius.y, collider.radius.z);
                 var intersections = this._submeshesOctree.intersects(collider.basePointWorld, radius);
-
                 len = intersections.length;
                 subMeshes = intersections.data;
-            } else {
+            }
+            else {
                 subMeshes = this.subMeshes;
                 len = subMeshes.length;
             }
-
             for (var index = 0; index < len; index++) {
                 var subMesh = subMeshes[index];
-
                 // Bounding test
                 if (len > 1 && !subMesh._checkCollision(collider))
                     continue;
-
                 this._collideForSubMesh(subMesh, transformMatrix, collider);
             }
         };
-
         AbstractMesh.prototype._checkCollision = function (collider) {
             // Bounding box test
             if (!this._boundingInfo._checkCollision(collider))
                 return;
-
             // Transformation matrix
             BABYLON.Matrix.ScalingToRef(1.0 / collider.radius.x, 1.0 / collider.radius.y, 1.0 / collider.radius.z, this._collisionsScalingMatrix);
             this.worldMatrixFromCache.multiplyToRef(this._collisionsScalingMatrix, this._collisionsTransformMatrix);
-
             this._processCollisionsForSubMeshes(collider, this._collisionsTransformMatrix);
         };
-
         // Picking
         AbstractMesh.prototype._generatePointsArray = function () {
             return false;
         };
-
         AbstractMesh.prototype.intersects = function (ray, fastCheck) {
             var pickingInfo = new BABYLON.PickingInfo();
-
             if (!this.subMeshes || !this._boundingInfo || !ray.intersectsSphere(this._boundingInfo.boundingSphere) || !ray.intersectsBox(this._boundingInfo.boundingBox)) {
                 return pickingInfo;
             }
-
             if (!this._generatePointsArray()) {
                 return pickingInfo;
             }
-
             var intersectInfo = null;
-
             // Octrees
             var subMeshes;
             var len;
-
             if (this._submeshesOctree && this.useOctreeForPicking) {
                 var worldRay = BABYLON.Ray.Transform(ray, this.getWorldMatrix());
                 var intersections = this._submeshesOctree.intersectsRay(worldRay);
-
                 len = intersections.length;
                 subMeshes = intersections.data;
-            } else {
+            }
+            else {
                 subMeshes = this.subMeshes;
                 len = subMeshes.length;
             }
-
             for (var index = 0; index < len; index++) {
                 var subMesh = subMeshes[index];
-
                 // Bounding test
                 if (len > 1 && !subMesh.canIntersects(ray))
                     continue;
-
                 var currentIntersectInfo = subMesh.intersects(ray, this._positions, this.getIndices(), fastCheck);
-
                 if (currentIntersectInfo) {
                     if (fastCheck || !intersectInfo || currentIntersectInfo.distance < intersectInfo.distance) {
                         intersectInfo = currentIntersectInfo;
-
                         if (fastCheck) {
                             break;
                         }
                     }
                 }
             }
-
             if (intersectInfo) {
                 // Get picked point
                 var world = this.getWorldMatrix();
@@ -851,9 +702,7 @@ var BABYLON;
                 var direction = ray.direction.clone();
                 direction = direction.scale(intersectInfo.distance);
                 var worldDirection = BABYLON.Vector3.TransformNormal(direction, world);
-
                 var pickedPoint = worldOrigin.add(worldDirection);
-
                 // Return result
                 pickingInfo.hit = true;
                 pickingInfo.distance = BABYLON.Vector3.Distance(worldOrigin, pickedPoint);
@@ -864,49 +713,40 @@ var BABYLON;
                 pickingInfo.faceId = intersectInfo.faceId;
                 return pickingInfo;
             }
-
             return pickingInfo;
         };
-
         AbstractMesh.prototype.clone = function (name, newParent, doNotCloneChildren) {
             return null;
         };
-
         AbstractMesh.prototype.releaseSubMeshes = function () {
             if (this.subMeshes) {
                 while (this.subMeshes.length) {
                     this.subMeshes[0].dispose();
                 }
-            } else {
+            }
+            else {
                 this.subMeshes = new Array();
             }
         };
-
         AbstractMesh.prototype.dispose = function (doNotRecurse) {
             // Physics
             if (this.getPhysicsImpostor() != BABYLON.PhysicsEngine.NoImpostor) {
                 this.setPhysicsState(BABYLON.PhysicsEngine.NoImpostor);
             }
-
             for (index = 0; index < this._intersectionsInProgress.length; index++) {
                 var other = this._intersectionsInProgress[index];
-
                 var pos = other._intersectionsInProgress.indexOf(this);
                 other._intersectionsInProgress.splice(pos, 1);
             }
-
             this._intersectionsInProgress = [];
-
             // SubMeshes
             this.releaseSubMeshes();
-
             // Remove from scene
             var index = this.getScene().meshes.indexOf(this);
             if (index != -1) {
-                // Remove from the scene if mesh found
+                // Remove from the scene if mesh found 
                 this.getScene().meshes.splice(index, 1);
             }
-
             if (!doNotRecurse) {
                 for (index = 0; index < this.getScene().particleSystems.length; index++) {
                     if (this.getScene().particleSystems[index].emitter == this) {
@@ -914,7 +754,6 @@ var BABYLON;
                         index--;
                     }
                 }
-
                 // Children
                 var objects = this.getScene().meshes.slice(0);
                 for (index = 0; index < objects.length; index++) {
@@ -922,7 +761,8 @@ var BABYLON;
                         objects[index].dispose();
                     }
                 }
-            } else {
+            }
+            else {
                 for (index = 0; index < this.getScene().meshes.length; index++) {
                     var obj = this.getScene().meshes[index];
                     if (obj.parent === this) {
@@ -931,16 +771,14 @@ var BABYLON;
                     }
                 }
             }
-
             this._onAfterWorldMatrixUpdate = [];
-
             this._isDisposed = true;
-
             // Callback
             if (this.onDispose) {
                 this.onDispose();
             }
         };
+        // Statics
         AbstractMesh._BILLBOARDMODE_NONE = 0;
         AbstractMesh._BILLBOARDMODE_X = 1;
         AbstractMesh._BILLBOARDMODE_Y = 2;
@@ -950,4 +788,4 @@ var BABYLON;
     })(BABYLON.Node);
     BABYLON.AbstractMesh = AbstractMesh;
 })(BABYLON || (BABYLON = {}));
-//# sourceMappingURL=babylon.abstractMesh.js.map
+//# sourceMappingURL=babylon.abstractMesh.js.map

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

@@ -935,4 +935,4 @@
             }
         }
     }
-}
+}

+ 5 - 42
Babylon/PostProcess/babylon.ssaoRenderingPipeline.js

@@ -8,42 +8,15 @@ var BABYLON;
 (function (BABYLON) {
     var SSAORenderingPipeline = (function (_super) {
         __extends(SSAORenderingPipeline, _super);
-        /**
-         * @constructor
-         * @param {string} name - The rendering pipeline name
-         * @param {BABYLON.Scene} scene - The scene linked to this pipeline
-         * @param {number} ratio - The size of the postprocesses (0.5 means that your postprocess will have a width = canvas.width 0.5 and a height = canvas.height 0.5)
-         * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
-         */
         function SSAORenderingPipeline(name, scene, ratio, cameras) {
             var _this = this;
             if (ratio === void 0) { ratio = 1.0; }
             _super.call(this, scene.getEngine(), name);
             // Members
-            /**
-            * The PassPostProcess id in the pipeline that contains the original scene color
-            * @type {string}
-            */
             this.SSAOOriginalSceneColorEffect = "SSAOOriginalSceneColorEffect";
-            /**
-            * The SSAO PostProcess id in the pipeline
-            * @type {string}
-            */
             this.SSAORenderEffect = "SSAORenderEffect";
-            /**
-            * The horizontal blur PostProcess id in the pipeline
-            * @type {string}
-            */
             this.SSAOBlurHRenderEffect = "SSAOBlurHRenderEffect";
-            /**
-            * The vertical blur PostProcess id in the pipeline
-            * @type {string}
-            */
             this.SSAOBlurVRenderEffect = "SSAOBlurVRenderEffect";
-            /**
-            * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
-            * @type {string}
-            */
             this.SSAOCombineRenderEffect = "SSAOCombineRenderEffect";
             this._firstUpdate = true;
             this._scene = scene;
@@ -52,8 +25,8 @@ var BABYLON;
             this._depthTexture = scene.enableDepthRenderer().getDepthMap(); // Force depth renderer "on"
             this._originalColorPostProcess = new BABYLON.PassPostProcess("SSAOOriginalSceneColor", 1.0, null, BABYLON.Texture.BILINEAR_SAMPLINGMODE, scene.getEngine(), false);
             this._createSSAOPostProcess(ratio);
-            this._blurHPostProcess = new BABYLON.BlurPostProcess("SSAOBlurH", new BABYLON.Vector2(2.0, 0.0), 1.3, ratio, null, BABYLON.Texture.BILINEAR_SAMPLINGMODE, scene.getEngine(), false);
-            this._blurVPostProcess = new BABYLON.BlurPostProcess("SSAOBlurV", new BABYLON.Vector2(0.0, 2.0), 1.3, ratio, null, BABYLON.Texture.BILINEAR_SAMPLINGMODE, scene.getEngine(), false);
+            this._blurHPostProcess = new BABYLON.BlurPostProcess("SSAOBlurH", new BABYLON.Vector2(2.0, 0.0), 2.0, ratio, null, BABYLON.Texture.BILINEAR_SAMPLINGMODE, scene.getEngine(), false);
+            this._blurVPostProcess = new BABYLON.BlurPostProcess("SSAOBlurV", new BABYLON.Vector2(0.0, 2.0), 2.0, ratio, null, BABYLON.Texture.BILINEAR_SAMPLINGMODE, scene.getEngine(), false);
             this._createSSAOCombinePostProcess();
             // Set up pipeline
             this.addEffect(new BABYLON.PostProcessRenderEffect(scene.getEngine(), this.SSAOOriginalSceneColorEffect, function () {
@@ -77,25 +50,15 @@ var BABYLON;
                 scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(name, cameras);
         }
         // Public Methods
-        /**
-         * Returns the horizontal blur PostProcess
-         * @return {BABYLON.BlurPostProcess} The horizontal blur post-process
-         */
         SSAORenderingPipeline.prototype.getBlurHPostProcess = function () {
             return this._blurHPostProcess;
         };
-        /**
-         * Returns the vertical blur PostProcess
-         * @return {BABYLON.BlurPostProcess} The vertical blur post-process
-         */
         SSAORenderingPipeline.prototype.getBlurVPostProcess = function () {
             return this._blurVPostProcess;
         };
-        /**
-         * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
-         */
-        SSAORenderingPipeline.prototype.dispose = function () {
-            this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._scene.cameras);
+        SSAORenderingPipeline.prototype.dispose = function (cameras) {
+            if (cameras !== undefined)
+                this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, cameras);
             this._originalColorPostProcess = undefined;
             this._ssaoPostProcess = undefined;
             this._blurHPostProcess = undefined;

+ 15 - 66
Babylon/PostProcess/babylon.volumetricLightScatteringPostProcess.js

@@ -6,36 +6,19 @@ var __extends = this.__extends || function (d, b) {
 };
 var BABYLON;
 (function (BABYLON) {
-    var VolumetricLightScatteringPostProcess = (function (_super) {
-        __extends(VolumetricLightScatteringPostProcess, _super);
-        /**
-         * @constructor
-         * @param {string} name - The post-process name
-         * @param {number} ratio - The size of the postprocesses (0.5 means that your postprocess will have a width = canvas.width 0.5 and a height = canvas.height 0.5)
-         * @param {BABYLON.Camera} camera - The camera that the post-process will be attached to
-         * @param {BABYLON.Mesh} mesh - The mesh used to create the light scattering
-         * @param {number} samplingMode - The post-process filtering mode
-         * @param {BABYLON.Engine} engine - The babylon engine
-         * @param {boolean} reusable - If the post-process is reusable
-         */
-        function VolumetricLightScatteringPostProcess(name, ratio, camera, mesh, samplingMode, engine, reusable) {
+    var GodRaysPostProcess = (function (_super) {
+        __extends(GodRaysPostProcess, _super);
+        function GodRaysPostProcess(name, ratio, camera, samplingMode, engine, reusable) {
             var _this = this;
             _super.call(this, name, "volumetricLightScattering", ["lightPositionOnScreen"], ["lightScatteringSampler"], ratio, camera, samplingMode, engine, reusable);
             this._screenCoordinates = BABYLON.Vector2.Zero();
-            /**
-            * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
-            * @type {boolean}
-            */
-            this.useCustomLightPosition = false;
-            /**
-            * If the post-process should inverse the light scattering direction
-            * @type {boolean}
-            */
             this.invert = true;
             var scene = camera.getScene();
             this._viewPort = new BABYLON.Viewport(0, 0, 1, 1).toGlobal(scene.getEngine());
-            // Configure mesh
-            this.mesh = (mesh !== null) ? mesh : VolumetricLightScatteringPostProcess.CreateDefaultMesh("VolumetricLightScatteringMesh", scene);
+            // Create billboard
+            this.mesh = BABYLON.Mesh.CreatePlane("VolumetricLightScatteringMesh", 2, scene);
+            this.mesh.billboardMode = BABYLON.AbstractMesh.BILLBOARDMODE_ALL;
+            this.mesh.material = new BABYLON.StandardMaterial('VolumetricLightScatteringMaterial', scene);
             // Configure
             this._createPass(scene);
             this.onApply = function (effect) {
@@ -44,7 +27,7 @@ var BABYLON;
                 effect.setVector2("lightPositionOnScreen", _this._screenCoordinates);
             };
         }
-        VolumetricLightScatteringPostProcess.prototype.isReady = function (subMesh, useInstances) {
+        GodRaysPostProcess.prototype.isReady = function (subMesh, useInstances) {
             var mesh = subMesh.getMesh();
             var scene = mesh.getScene();
             var defines = [];
@@ -89,36 +72,15 @@ var BABYLON;
             }
             return this._godRaysPass.isReady();
         };
-        /**
-         * Sets the new light position for light scattering effect
-         * @param {BABYLON.Vector3} The new custom light position
-         */
-        VolumetricLightScatteringPostProcess.prototype.setLightPosition = function (position) {
-            this._customLightPosition = position;
-        };
-        /**
-         * Returns the light position for light scattering effect
-         * @return {BABYLON.Vector3} The custom light position
-         */
-        VolumetricLightScatteringPostProcess.prototype.getLightPosition = function () {
-            return this._customLightPosition;
-        };
-        /**
-         * Disposes the internal assets and detaches the post-process from the camera
-         */
-        VolumetricLightScatteringPostProcess.prototype.dispose = function (camera) {
+        GodRaysPostProcess.prototype.dispose = function (camera) {
             this._godRaysRTT.dispose();
             _super.prototype.dispose.call(this, camera);
         };
-        /**
-         * Returns the render target texture used by the post-process
-         * @return {BABYLON.RenderTargetTexture} The render target texture used by the post-process
-         */
-        VolumetricLightScatteringPostProcess.prototype.getPass = function () {
+        GodRaysPostProcess.prototype.getPass = function () {
             return this._godRaysRTT;
         };
         // Private methods
-        VolumetricLightScatteringPostProcess.prototype._createPass = function (scene) {
+        GodRaysPostProcess.prototype._createPass = function (scene) {
             var _this = this;
             var engine = scene.getEngine();
             this._godRaysRTT = new BABYLON.RenderTargetTexture("volumetricLightScatteringMap", { width: engine.getRenderWidth(), height: engine.getRenderHeight() }, scene, false, true, BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT);
@@ -179,29 +141,16 @@ var BABYLON;
                 }
             };
         };
-        VolumetricLightScatteringPostProcess.prototype._updateScreenCoordinates = function (scene) {
+        GodRaysPostProcess.prototype._updateScreenCoordinates = function (scene) {
             var transform = scene.getTransformMatrix();
-            var pos = BABYLON.Vector3.Project(this.useCustomLightPosition ? this._customLightPosition : this.mesh.position, BABYLON.Matrix.Identity(), transform, this._viewPort);
+            var pos = BABYLON.Vector3.Project(this.mesh.position, BABYLON.Matrix.Identity(), transform, this._viewPort);
             this._screenCoordinates.x = pos.x / this._viewPort.width;
             this._screenCoordinates.y = pos.y / this._viewPort.height;
             if (this.invert)
                 this._screenCoordinates.y = 1.0 - this._screenCoordinates.y;
         };
-        // Static methods
-        /**
-        * Creates a default mesh for the Volumeric Light Scattering post-process
-        * @param {string} The mesh name
-        * @param {BABYLON.Scene} The scene where to create the mesh
-        * @return {BABYLON.Mesh} the default mesh
-        */
-        VolumetricLightScatteringPostProcess.CreateDefaultMesh = function (name, scene) {
-            var mesh = BABYLON.Mesh.CreatePlane(name, 1, scene);
-            mesh.billboardMode = BABYLON.AbstractMesh.BILLBOARDMODE_ALL;
-            mesh.material = new BABYLON.StandardMaterial(name + "Material", scene);
-            return mesh;
-        };
-        return VolumetricLightScatteringPostProcess;
+        return GodRaysPostProcess;
     })(BABYLON.PostProcess);
-    BABYLON.VolumetricLightScatteringPostProcess = VolumetricLightScatteringPostProcess;
+    BABYLON.GodRaysPostProcess = GodRaysPostProcess;
 })(BABYLON || (BABYLON = {}));
 //# sourceMappingURL=babylon.volumetricLightScatteringPostProcess.js.map

+ 3 - 3
Babylon/PostProcess/babylon.volumetricLightScatteringPostProcess.ts

@@ -56,15 +56,15 @@
 
         public isReady(subMesh: SubMesh, useInstances: boolean): boolean {
             var mesh = subMesh.getMesh();
-            var scene = mesh.getScene();
 
             var defines = [];
             var attribs = [VertexBuffer.PositionKind];
             var material = subMesh.getMaterial();
 
             // Render this.mesh as default
-            if (mesh === this.mesh)
+            if (mesh === this.mesh) {
                 defines.push("#define BASIC_RENDER");
+            }
 
             // Alpha test
             if (material) {
@@ -243,7 +243,7 @@
         * @return {BABYLON.Mesh} the default mesh
         */
         public static CreateDefaultMesh(name: string, scene: Scene): Mesh {
-            var mesh = BABYLON.Mesh.CreatePlane(name, 1, scene);
+            var mesh = Mesh.CreatePlane(name, 1, scene);
             mesh.billboardMode = AbstractMesh.BILLBOARDMODE_ALL;
             mesh.material = new StandardMaterial(name + "Material", scene);
 

+ 1 - 0
Babylon/Tools/babylon.filesInput.ts

@@ -92,6 +92,7 @@
                         case "image/vnd.ms-dds":
                         case "audio/wav":
                         case "audio/x-wav":
+                        case "audio/mp3":
                         case "audio/mpeg":
                         case "audio/mpeg3":
                         case "audio/x-mpeg-3":

+ 17 - 18
Babylon/Tools/babylon.tools.ts

@@ -56,7 +56,7 @@
             var child = element.firstChild;
 
             while (child) {
-                if (child.nodeType == 3) {
+                if (child.nodeType === 3) {
                     result += child.textContent;
                 }
                 child = child.nextSibling;
@@ -80,8 +80,8 @@
             for (var index = indexStart; index < indexStart + indexCount; index++) {
                 var current = new Vector3(positions[indices[index] * 3], positions[indices[index] * 3 + 1], positions[indices[index] * 3 + 2]);
 
-                minimum = BABYLON.Vector3.Minimize(current, minimum);
-                maximum = BABYLON.Vector3.Maximize(current, maximum);
+                minimum = Vector3.Minimize(current, minimum);
+                maximum = Vector3.Maximize(current, maximum);
             }
 
             return {
@@ -97,8 +97,8 @@
             for (var index = start; index < start + count; index++) {
                 var current = new Vector3(positions[index * 3], positions[index * 3 + 1], positions[index * 3 + 2]);
 
-                minimum = BABYLON.Vector3.Minimize(current, minimum);
-                maximum = BABYLON.Vector3.Maximize(current, maximum);
+                minimum = Vector3.Minimize(current, minimum);
+                maximum = Vector3.Maximize(current, maximum);
             }
 
             return {
@@ -179,7 +179,7 @@
 
             var img = new Image();
 
-            if (url.substr(0, 5) != "data:")
+            if (url.substr(0, 5) !== "data:")
                 img.crossOrigin = 'anonymous';
 
             img.onload = () => {
@@ -200,7 +200,7 @@
 
 
             //ANY database to do!
-            if (database && database.enableTexturesOffline && BABYLON.Database.isUASupportingBlobStorage) {
+            if (database && database.enableTexturesOffline && Database.isUASupportingBlobStorage) {
                 database.openAsync(loadFromIndexedDB, noIndexedDB);
             }
             else {
@@ -212,11 +212,11 @@
                         var textureName = url.substring(5);
                         var blobURL;
                         try {
-                            blobURL = URL.createObjectURL(BABYLON.FilesInput.FilesTextures[textureName], { oneTimeOnly: true });
+                            blobURL = URL.createObjectURL(FilesInput.FilesTextures[textureName], { oneTimeOnly: true });
                         }
                         catch (ex) {
                             // Chrome doesn't support oneTimeOnly parameter
-                            blobURL = URL.createObjectURL(BABYLON.FilesInput.FilesTextures[textureName]);
+                            blobURL = URL.createObjectURL(FilesInput.FilesTextures[textureName]);
                         }
                         img.src = blobURL;
                     }
@@ -246,8 +246,8 @@
                 request.onprogress = progressCallBack;
 
                 request.onreadystatechange = () => {
-                    if (request.readyState == 4) {
-                        if (request.status == 200 || BABYLON.Tools.ValidateXHRData(request, !useArrayBuffer ? 1 : 6)) {
+                    if (request.readyState === 4) {
+                        if (request.status === 200 || Tools.ValidateXHRData(request, !useArrayBuffer ? 1 : 6)) {
                             callback(!useArrayBuffer ? request.responseText : request.response);
                         } else { // Failed
                             if (onError) {
@@ -269,7 +269,7 @@
 
             if (url.indexOf("file:") !== -1) {
                 var fileName = url.substring(5);
-                BABYLON.Tools.ReadFile(BABYLON.FilesInput.FilesToLoad[fileName], callback, progressCallBack, true);
+                Tools.ReadFile(FilesInput.FilesToLoad[fileName], callback, progressCallBack, true);
             }
             else {
                 // Caching all files
@@ -319,7 +319,7 @@
             if (value === 0 || isNaN(value))
                 return value;
 
-            return value > 0 ? 1 : -1
+            return value > 0 ? 1 : -1;
         }
 
         public static Format(value: number, decimals: number = 2): string {
@@ -360,11 +360,11 @@
                 var sourceValue = source[prop];
                 var typeOfSourceValue = typeof sourceValue;
 
-                if (typeOfSourceValue == "function") {
+                if (typeOfSourceValue === "function") {
                     continue;
                 }
 
-                if (typeOfSourceValue == "object") {
+                if (typeOfSourceValue === "object") {
                     if (sourceValue instanceof Array) {
                         destination[prop] = [];
 
@@ -483,7 +483,6 @@
                 //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++) {
@@ -561,7 +560,7 @@
 
                 if (dataType & 2) {
                     // Check header width and height since there is no "TGA" magic number
-                    var tgaHeader = BABYLON.Internals.TGATools.GetTGAHeader(xhr.response);
+                    var tgaHeader = Internals.TGATools.GetTGAHeader(xhr.response);
 
                     if (tgaHeader.width && tgaHeader.height && tgaHeader.width > 0 && tgaHeader.height > 0) {
                         return true;
@@ -574,7 +573,7 @@
                     // Check for the "DDS" magic number
                     var ddsHeader = new Uint8Array(xhr.response, 0, 3);
 
-                    if (ddsHeader[0] == 68 && ddsHeader[1] == 68 && ddsHeader[2] == 83) {
+                    if (ddsHeader[0] === 68 && ddsHeader[1] === 68 && ddsHeader[2] === 83) {
                         return true;
                     } else {
                         return false;

+ 2 - 2
Babylon/babylon.engine.ts

@@ -846,7 +846,7 @@
         }
 
         public endFrame(): void {
-            this.flushFramebuffer();
+            //this.flushFramebuffer();
         }
 
         /**
@@ -895,7 +895,7 @@
         }
 
         public flushFramebuffer(): void {
-            //   this._gl.flush();
+            this._gl.flush();
         }
 
         public restoreDefaultFramebuffer(): void {

+ 17 - 16
babylon.2.0-beta.debug.js

@@ -2422,7 +2422,7 @@ var __extends = this.__extends || function (d, b) {
             var result = "";
             var child = element.firstChild;
             while (child) {
-                if (child.nodeType == 3) {
+                if (child.nodeType === 3) {
                     result += child.textContent;
                 }
                 child = child.nextSibling;
@@ -2522,7 +2522,7 @@ var __extends = this.__extends || function (d, b) {
         Tools.LoadImage = function (url, onload, onerror, database) {
             url = Tools.CleanUrl(url);
             var img = new Image();
-            if (url.substr(0, 5) != "data:")
+            if (url.substr(0, 5) !== "data:")
                 img.crossOrigin = 'anonymous';
             img.onload = function () {
                 onload(img);
@@ -2577,8 +2577,8 @@ var __extends = this.__extends || function (d, b) {
                 }
                 request.onprogress = progressCallBack;
                 request.onreadystatechange = function () {
-                    if (request.readyState == 4) {
-                        if (request.status == 200 || BABYLON.Tools.ValidateXHRData(request, !useArrayBuffer ? 1 : 6)) {
+                    if (request.readyState === 4) {
+                        if (request.status === 200 || Tools.ValidateXHRData(request, !useArrayBuffer ? 1 : 6)) {
                             callback(!useArrayBuffer ? request.responseText : request.response);
                         }
                         else {
@@ -2598,7 +2598,7 @@ var __extends = this.__extends || function (d, b) {
             };
             if (url.indexOf("file:") !== -1) {
                 var fileName = url.substring(5);
-                BABYLON.Tools.ReadFile(BABYLON.FilesInput.FilesToLoad[fileName], callback, progressCallBack, true);
+                Tools.ReadFile(BABYLON.FilesInput.FilesToLoad[fileName], callback, progressCallBack, true);
             }
             else {
                 // Caching all files
@@ -2679,10 +2679,10 @@ var __extends = this.__extends || function (d, b) {
                 }
                 var sourceValue = source[prop];
                 var typeOfSourceValue = typeof sourceValue;
-                if (typeOfSourceValue == "function") {
+                if (typeOfSourceValue === "function") {
                     continue;
                 }
-                if (typeOfSourceValue == "object") {
+                if (typeOfSourceValue === "object") {
                     if (sourceValue instanceof Array) {
                         destination[prop] = [];
                         if (sourceValue.length > 0) {
@@ -2861,7 +2861,7 @@ var __extends = this.__extends || function (d, b) {
                 if (dataType & 4) {
                     // Check for the "DDS" magic number
                     var ddsHeader = new Uint8Array(xhr.response, 0, 3);
-                    if (ddsHeader[0] == 68 && ddsHeader[1] == 68 && ddsHeader[2] == 83) {
+                    if (ddsHeader[0] === 68 && ddsHeader[1] === 68 && ddsHeader[2] === 83) {
                         return true;
                     }
                     else {
@@ -3911,7 +3911,7 @@ var __extends = this.__extends || function (d, b) {
             this._measureFps();
         };
         Engine.prototype.endFrame = function () {
-            this.flushFramebuffer();
+            //this.flushFramebuffer();
         };
         /**
          * resize the view according to the canvas' size.
@@ -3951,7 +3951,7 @@ var __extends = this.__extends || function (d, b) {
             this._gl.bindFramebuffer(this._gl.FRAMEBUFFER, null);
         };
         Engine.prototype.flushFramebuffer = function () {
-            //   this._gl.flush();
+            this._gl.flush();
         };
         Engine.prototype.restoreDefaultFramebuffer = function () {
             this._currentRenderTarget = null;
@@ -5362,7 +5362,7 @@ var __extends = this.__extends || function (d, b) {
                         break;
                     }
                 }
-                if (inCount == 0)
+                if (inCount === 0)
                     return false;
             }
             return true;
@@ -11998,14 +11998,14 @@ var BABYLON;
             if (useCameraPostProcess) {
                 scene.postProcessManager._finalizeFrame(false, this._texture);
             }
+            if (!this._doNotChangeAspectRatio) {
+                scene.updateTransformMatrix(true);
+            }
             if (this.onAfterRender) {
                 this.onAfterRender();
             }
             // Unbind
             engine.unBindFramebuffer(this._texture);
-            if (!this._doNotChangeAspectRatio) {
-                scene.updateTransformMatrix(true);
-            }
         };
         RenderTargetTexture.prototype.clone = function () {
             var textureSize = this.getSize();
@@ -16953,6 +16953,7 @@ var BABYLON;
                         case "image/vnd.ms-dds":
                         case "audio/wav":
                         case "audio/x-wav":
+                        case "audio/mp3":
                         case "audio/mpeg":
                         case "audio/mpeg3":
                         case "audio/x-mpeg-3":
@@ -27778,13 +27779,13 @@ var BABYLON;
         }
         VolumetricLightScatteringPostProcess.prototype.isReady = function (subMesh, useInstances) {
             var mesh = subMesh.getMesh();
-            var scene = mesh.getScene();
             var defines = [];
             var attribs = [BABYLON.VertexBuffer.PositionKind];
             var material = subMesh.getMaterial();
             // Render this.mesh as default
-            if (mesh === this.mesh)
+            if (mesh === this.mesh) {
                 defines.push("#define BASIC_RENDER");
+            }
             // Alpha test
             if (material) {
                 if (material.needAlphaTesting() || mesh === this.mesh)

Diferenças do arquivo suprimidas por serem muito extensas
+ 7 - 7
babylon.2.0-beta.js