Pārlūkot izejas kodu

New assetsManager

David Catuhe 11 gadi atpakaļ
vecāks
revīzija
619a17f520

+ 1 - 1
Babylon/Animations/babylon.animation.js

@@ -200,7 +200,7 @@
                         break;
 
                     case Animation.ANIMATIONTYPE_QUATERNION:
-                        offsetValue = new BABYLON.Quaternion();
+                        offsetValue = new BABYLON.Quaternion(0, 0, 0, 0);
                         break;
 
                     case Animation.ANIMATIONTYPE_VECTOR3:

+ 1 - 1
Babylon/Animations/babylon.animation.ts

@@ -203,7 +203,7 @@
                         break;
                     // Quaternion
                     case Animation.ANIMATIONTYPE_QUATERNION:
-                        offsetValue = new Quaternion();
+                        offsetValue = new Quaternion(0, 0, 0, 0);
                         break;
                     // Vector3
                     case Animation.ANIMATIONTYPE_VECTOR3:

+ 2 - 2
Babylon/Cameras/babylon.gamepadCamera.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;
@@ -46,7 +46,7 @@ var BABYLON;
             var cameraTransform = BABYLON.Matrix.RotationYawPitchRoll(this.rotation.y, this.rotation.x, 0);
             var deltaTransform = BABYLON.Vector3.TransformCoordinates(new BABYLON.Vector3(LSValues.x, 0, -LSValues.y), cameraTransform);
             this.cameraDirection = this.cameraDirection.add(deltaTransform);
-            this.cameraRotation = this.cameraRotation.add(new BABYLON.Vector3(RSValues.y, RSValues.x, 0));
+            this.cameraRotation = this.cameraRotation.add(new BABYLON.Vector2(RSValues.y, RSValues.x));
         };
 
         GamepadCamera.prototype.dispose = function () {

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

@@ -38,7 +38,7 @@ module BABYLON {
             var cameraTransform = BABYLON.Matrix.RotationYawPitchRoll(this.rotation.y, this.rotation.x, 0);
             var deltaTransform = BABYLON.Vector3.TransformCoordinates(new BABYLON.Vector3(LSValues.x, 0, -LSValues.y), cameraTransform);
             this.cameraDirection = this.cameraDirection.add(deltaTransform);
-            this.cameraRotation = this.cameraRotation.add(new BABYLON.Vector3(RSValues.y, RSValues.x, 0));
+            this.cameraRotation = this.cameraRotation.add(new BABYLON.Vector2(RSValues.y, RSValues.x));
         }
 
         public dispose(): void {

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

@@ -26,7 +26,7 @@ var BABYLON;
             var cameraTransform = BABYLON.Matrix.RotationYawPitchRoll(this.rotation.y, this.rotation.x, 0);
             var deltaTransform = BABYLON.Vector3.TransformCoordinates(this._leftjoystick.deltaPosition, cameraTransform);
             this.cameraDirection = this.cameraDirection.add(deltaTransform);
-            this.cameraRotation = this.cameraRotation.add(this._rightjoystick.deltaPosition);
+            this.cameraRotation = this.cameraRotation.addVector3(this._rightjoystick.deltaPosition);
             if (!this._leftjoystick.pressed) {
                 this._leftjoystick.deltaPosition = this._leftjoystick.deltaPosition.scale(0.9);
             }

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

@@ -22,7 +22,7 @@
             var cameraTransform = BABYLON.Matrix.RotationYawPitchRoll(this.rotation.y, this.rotation.x, 0);
             var deltaTransform = BABYLON.Vector3.TransformCoordinates(this._leftjoystick.deltaPosition, cameraTransform);
             this.cameraDirection = this.cameraDirection.add(deltaTransform);
-            this.cameraRotation = this.cameraRotation.add(this._rightjoystick.deltaPosition);
+            this.cameraRotation = this.cameraRotation.addVector3(this._rightjoystick.deltaPosition);
             if (!this._leftjoystick.pressed) {
                 this._leftjoystick.deltaPosition = this._leftjoystick.deltaPosition.scale(0.9);
             }

+ 17 - 4
Babylon/Loading/babylon.sceneLoader.js

@@ -1,4 +1,4 @@
-var BABYLON;
+var BABYLON;
 (function (BABYLON) {
     var SceneLoader = (function () {
         function SceneLoader() {
@@ -91,8 +91,9 @@ var BABYLON;
         * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
         * @param engine is the instance of BABYLON.Engine to use to create the scene
         */
-        SceneLoader.Load = function (rootUrl, sceneFilename, engine, onsuccess, progressCallBack, onerror) {
-            SceneLoader.Append(rootUrl, sceneFilename, new BABYLON.Scene(engine), onsuccess, progressCallBack, onerror);
+        SceneLoader.Load = function (rootUrl, sceneFilename, engine, onsuccess, progressCallBack, onerror, showLoadingScreen) {
+            if (typeof showLoadingScreen === "undefined") { showLoadingScreen = true; }
+            SceneLoader.Append(rootUrl, sceneFilename, new BABYLON.Scene(engine), onsuccess, progressCallBack, onerror, showLoadingScreen);
         };
 
         /**
@@ -101,10 +102,15 @@ var BABYLON;
         * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
         * @param scene is the instance of BABYLON.Scene to append to
         */
-        SceneLoader.Append = function (rootUrl, sceneFilename, scene, onsuccess, progressCallBack, onerror) {
+        SceneLoader.Append = function (rootUrl, sceneFilename, scene, onsuccess, progressCallBack, onerror, showLoadingScreen) {
+            if (typeof showLoadingScreen === "undefined") { showLoadingScreen = true; }
             var plugin = this._getPluginForFilename(sceneFilename.name || sceneFilename);
             var database;
 
+            if (showLoadingScreen) {
+                scene.getEngine().displayLoadingUI();
+            }
+
             var loadSceneFromData = function (data) {
                 scene.database = database;
 
@@ -113,12 +119,19 @@ var BABYLON;
                         onerror(scene);
                     }
 
+                    scene.getEngine().hideLoadingUI();
                     return;
                 }
 
                 if (onsuccess) {
                     onsuccess(scene);
                 }
+
+                if (showLoadingScreen) {
+                    scene.executeWhenReady(function () {
+                        scene.getEngine().hideLoadingUI();
+                    });
+                }
             };
 
             var manifestChecked = function (success) {

+ 22 - 1
Babylon/Loading/babylon.sceneLoader.ts

@@ -8,6 +8,7 @@
     export class SceneLoader {
         // Flags
         private static _ForceFullSceneLoadingForIncremental = false;
+        private static _ShowLoadingScreen = true;
 
         public static get ForceFullSceneLoadingForIncremental() {
             return SceneLoader._ForceFullSceneLoadingForIncremental;
@@ -17,6 +18,14 @@
             SceneLoader._ForceFullSceneLoadingForIncremental = value;
         }
 
+        public static get ShowLoadingScreen() {
+            return SceneLoader._ShowLoadingScreen;
+        }
+
+        public static set ShowLoadingScreen(value: boolean) {
+            SceneLoader._ShowLoadingScreen = value;
+        }
+
         // Members
         private static _registeredPlugins = new Array<ISceneLoaderPlugin>();
 
@@ -99,17 +108,22 @@
         public static Load(rootUrl: string, sceneFilename: any, engine: Engine, onsuccess?: (scene: Scene) => void, progressCallBack?: any, onerror?: (scene: Scene) => void): void {
             SceneLoader.Append(rootUrl, sceneFilename, new BABYLON.Scene(engine), onsuccess, progressCallBack, onerror);
         }
+
         /**
         * Append a scene
         * @param rootUrl a string that defines the root url for scene and resources
         * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
         * @param scene is the instance of BABYLON.Scene to append to
         */
-        public static Append(rootUrl: string, sceneFilename: any, scene : Scene, onsuccess?: (scene: Scene) => void, progressCallBack?: any, onerror?: (scene: Scene) => void): void {
+        public static Append(rootUrl: string, sceneFilename: any, scene: Scene, onsuccess?: (scene: Scene) => void, progressCallBack?: any, onerror?: (scene: Scene) => void): void {
 
             var plugin = this._getPluginForFilename(sceneFilename.name || sceneFilename);
             var database;
 
+            if (SceneLoader.ShowLoadingScreen) {
+                scene.getEngine().displayLoadingUI();
+            }
+
             var loadSceneFromData = data => {
                 scene.database = database;
 
@@ -118,12 +132,19 @@
                         onerror(scene);
                     }
 
+                    scene.getEngine().hideLoadingUI();
                     return;
                 }
 
                 if (onsuccess) {
                     onsuccess(scene);
                 }
+
+                if (SceneLoader.ShowLoadingScreen) {
+                    scene.executeWhenReady(() => {
+                        scene.getEngine().hideLoadingUI();
+                    });
+                }                
             };
 
             var manifestChecked = success => {

+ 51 - 9
Babylon/Materials/babylon.effect.js

@@ -1,7 +1,52 @@
 var BABYLON;
 (function (BABYLON) {
+    var EffectFallbacks = (function () {
+        function EffectFallbacks() {
+            this._defines = {};
+            this._currentRank = 32;
+            this._maxRank = -1;
+        }
+        EffectFallbacks.prototype.addFallback = function (rank, define) {
+            if (!this._defines[rank]) {
+                if (rank < this._currentRank) {
+                    this._currentRank = rank;
+                }
+
+                if (rank > this._maxRank) {
+                    this._maxRank = rank;
+                }
+
+                this._defines[rank] = new Array();
+            }
+
+            this._defines[rank].push(define);
+        };
+
+        Object.defineProperty(EffectFallbacks.prototype, "isMoreFallbacks", {
+            get: function () {
+                return this._currentRank <= this._maxRank;
+            },
+            enumerable: true,
+            configurable: true
+        });
+
+        EffectFallbacks.prototype.reduce = function (currentDefines) {
+            var currentFallbacks = this._defines[this._currentRank];
+
+            for (var index = 0; index < currentFallbacks.length; index++) {
+                currentDefines = currentDefines.replace("#define " + currentFallbacks[index], "");
+            }
+
+            this._currentRank++;
+
+            return currentDefines;
+        };
+        return EffectFallbacks;
+    })();
+    BABYLON.EffectFallbacks = EffectFallbacks;
+
     var Effect = (function () {
-        function Effect(baseName, attributesNames, uniformsNames, samplers, engine, defines, optionalDefines, onCompiled, onError) {
+        function Effect(baseName, attributesNames, uniformsNames, samplers, engine, defines, fallbacks, onCompiled, onError) {
             var _this = this;
             this._isReady = false;
             this._compilationError = "";
@@ -33,7 +78,7 @@
 
             this._loadVertexShader(vertexSource, function (vertexCode) {
                 _this._loadFragmentShader(fragmentSource, function (fragmentCode) {
-                    _this._prepareEffect(vertexCode, fragmentCode, attributesNames, defines, optionalDefines);
+                    _this._prepareEffect(vertexCode, fragmentCode, attributesNames, defines, fallbacks);
                 });
             });
         }
@@ -133,7 +178,7 @@
             BABYLON.Tools.LoadFile(fragmentShaderUrl + ".fragment.fx", callback);
         };
 
-        Effect.prototype._prepareEffect = function (vertexSourceCode, fragmentSourceCode, attributesNames, defines, optionalDefines, useFallback) {
+        Effect.prototype._prepareEffect = function (vertexSourceCode, fragmentSourceCode, attributesNames, defines, fallbacks) {
             try  {
                 var engine = this._engine;
                 this._program = engine.createShaderProgram(vertexSourceCode, fragmentSourceCode, defines);
@@ -157,15 +202,12 @@
                     this.onCompiled(this);
                 }
             } catch (e) {
-                if (!useFallback && optionalDefines) {
-                    for (index = 0; index < optionalDefines.length; index++) {
-                        defines = defines.replace(optionalDefines[index], "");
-                    }
-                    this._prepareEffect(vertexSourceCode, fragmentSourceCode, attributesNames, defines, optionalDefines, true);
+                if (fallbacks && fallbacks.isMoreFallbacks) {
+                    defines = fallbacks.reduce(defines);
+                    this._prepareEffect(vertexSourceCode, fragmentSourceCode, attributesNames, defines, fallbacks);
                 } else {
                     BABYLON.Tools.Error("Unable to compile effect: " + this.name);
                     BABYLON.Tools.Error("Defines: " + defines);
-                    BABYLON.Tools.Error("Optional defines: " + optionalDefines);
                     BABYLON.Tools.Error("Error: " + e.message);
                     this._compilationError = e.message;
 

+ 46 - 9
Babylon/Materials/babylon.effect.ts

@@ -1,4 +1,44 @@
 module BABYLON {
+    export class EffectFallbacks {
+        private _defines = {};
+
+        private _currentRank = 32;
+        private _maxRank = -1;
+
+        public addFallback(rank: number, define: string): void {
+            if (!this._defines[rank]) {
+                if (rank < this._currentRank) {
+                    this._currentRank = rank;
+                }
+
+                if (rank > this._maxRank) {
+                    this._maxRank = rank;
+                }
+
+                this._defines[rank] = new Array<String>();
+            }
+
+            this._defines[rank].push(define);
+        }
+
+        public get isMoreFallbacks(): boolean {
+            return this._currentRank <= this._maxRank;
+        }
+
+        public reduce(currentDefines: string): string {
+
+            var currentFallbacks = this._defines[this._currentRank];
+
+            for (var index = 0; index < currentFallbacks.length; index++) {
+                currentDefines = currentDefines.replace("#define " + currentFallbacks[index], "");
+            }
+
+            this._currentRank++;
+
+            return currentDefines;
+        }
+    }
+
     export class Effect {
         public name: any;
         public defines: string;
@@ -18,7 +58,7 @@
         private _program: WebGLProgram;
         private _valueCache = [];
 
-        constructor(baseName: any, attributesNames: string[], uniformsNames: string[], samplers: string[], engine, defines?: string, optionalDefines?: string[], onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void) {
+        constructor(baseName: any, attributesNames: string[], uniformsNames: string[], samplers: string[], engine, defines?: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void) {
             this._engine = engine;
             this.name = baseName;
             this.defines = defines;
@@ -46,7 +86,7 @@
 
             this._loadVertexShader(vertexSource, vertexCode => {
                 this._loadFragmentShader(fragmentSource, (fragmentCode) => {
-                    this._prepareEffect(vertexCode, fragmentCode, attributesNames, defines, optionalDefines);
+                    this._prepareEffect(vertexCode, fragmentCode, attributesNames, defines, fallbacks);
                 });
             });
         }
@@ -147,7 +187,7 @@
             BABYLON.Tools.LoadFile(fragmentShaderUrl + ".fragment.fx", callback);
         }
 
-        public _prepareEffect(vertexSourceCode: string, fragmentSourceCode: string, attributesNames: string[], defines: string, optionalDefines?: string[], useFallback?: boolean): void {
+        private _prepareEffect(vertexSourceCode: string, fragmentSourceCode: string, attributesNames: string[], defines: string, fallbacks?: EffectFallbacks): void {
             try {
                 var engine = this._engine;
                 this._program = engine.createShaderProgram(vertexSourceCode, fragmentSourceCode, defines);
@@ -171,15 +211,12 @@
                     this.onCompiled(this);
                 }
             } catch (e) {
-                if (!useFallback && optionalDefines) {
-                    for (index = 0; index < optionalDefines.length; index++) {
-                        defines = defines.replace(optionalDefines[index], "");
-                    }
-                    this._prepareEffect(vertexSourceCode, fragmentSourceCode, attributesNames, defines, optionalDefines, true);
+                if (fallbacks && fallbacks.isMoreFallbacks) {
+                    defines = fallbacks.reduce(defines);
+                    this._prepareEffect(vertexSourceCode, fragmentSourceCode, attributesNames, defines, fallbacks);
                 } else {
                     Tools.Error("Unable to compile effect: " + this.name);
                     Tools.Error("Defines: " + defines);
-                    Tools.Error("Optional defines: " + optionalDefines);
                     Tools.Error("Error: " + e.message);
                     this._compilationError = e.message;
 

+ 20 - 14
Babylon/Materials/babylon.standardMaterial.js

@@ -19,6 +19,7 @@ var BABYLON;
             this.specularPower = 64;
             this.emissiveColor = new BABYLON.Color3(0, 0, 0);
             this.useAlphaFromDiffuseTexture = false;
+            this.useFresnelForDiffuse = false;
             this._cachedDefines = null;
             this._renderTargets = new BABYLON.SmartArray(16);
             this._worldViewProjectionMatrix = BABYLON.Matrix.Zero();
@@ -71,7 +72,7 @@ var BABYLON;
 
             var engine = scene.getEngine();
             var defines = [];
-            var optionalDefines = new Array();
+            var fallbacks = new BABYLON.EffectFallbacks();
 
             // Textures
             if (scene.texturesEnabled) {
@@ -108,6 +109,7 @@ var BABYLON;
                         return false;
                     } else {
                         defines.push("#define REFLECTION");
+                        fallbacks.addFallback(0, "REFLECTION");
                     }
                 }
 
@@ -124,7 +126,7 @@ var BABYLON;
                         return false;
                     } else {
                         defines.push("#define SPECULAR");
-                        optionalDefines.push(defines[defines.length - 1]);
+                        fallbacks.addFallback(0, "SPECULAR");
                     }
                 }
             }
@@ -134,7 +136,7 @@ var BABYLON;
                     return false;
                 } else {
                     defines.push("#define BUMP");
-                    optionalDefines.push(defines[defines.length - 1]);
+                    fallbacks.addFallback(0, "BUMP");
                 }
             }
 
@@ -154,7 +156,7 @@ var BABYLON;
             // Fog
             if (scene.fogMode !== BABYLON.Scene.FOGMODE_NONE) {
                 defines.push("#define FOG");
-                optionalDefines.push(defines[defines.length - 1]);
+                fallbacks.addFallback(1, "FOG");
             }
 
             var shadowsActivated = false;
@@ -200,7 +202,7 @@ var BABYLON;
                     defines.push("#define LIGHT" + lightIndex);
 
                     if (lightIndex > 0) {
-                        optionalDefines.push(defines[defines.length - 1]);
+                        fallbacks.addFallback(lightIndex, "LIGHT" + lightIndex);
                     }
 
                     var type;
@@ -214,17 +216,14 @@ var BABYLON;
 
                     defines.push(type);
                     if (lightIndex > 0) {
-                        optionalDefines.push(defines[defines.length - 1]);
+                        fallbacks.addFallback(lightIndex, type.replace("#define ", ""));
                     }
 
                     // Shadows
                     var shadowGenerator = light.getShadowGenerator();
                     if (mesh && mesh.receiveShadows && shadowGenerator) {
                         defines.push("#define SHADOW" + lightIndex);
-
-                        if (lightIndex > 0) {
-                            optionalDefines.push(defines[defines.length - 1]);
-                        }
+                        fallbacks.addFallback(0, "SHADOW" + lightIndex);
 
                         if (!shadowsActivated) {
                             defines.push("#define SHADOWS");
@@ -234,14 +233,14 @@ var BABYLON;
                         if (shadowGenerator.useVarianceShadowMap) {
                             defines.push("#define SHADOWVSM" + lightIndex);
                             if (lightIndex > 0) {
-                                optionalDefines.push(defines[defines.length - 1]);
+                                fallbacks.addFallback(0, "SHADOWVSM" + lightIndex);
                             }
                         }
 
                         if (shadowGenerator.usePoissonSampling) {
                             defines.push("#define SHADOWPCF" + lightIndex);
                             if (lightIndex > 0) {
-                                optionalDefines.push(defines[defines.length - 1]);
+                                fallbacks.addFallback(0, "SHADOWPCF" + lightIndex);
                             }
                         }
                     }
@@ -252,6 +251,13 @@ var BABYLON;
                 }
             }
 
+            if (this.useFresnelForDiffuse) {
+                defines.push("#define FRESNEL");
+                defines.push("#define DIFFUSEFRESNEL");
+                fallbacks.addFallback(1, "FRESNEL");
+                fallbacks.addFallback(1, "DIFFUSEFRESNEL");
+            }
+
             var attribs = [BABYLON.VertexBuffer.PositionKind, BABYLON.VertexBuffer.NormalKind];
             if (mesh) {
                 if (mesh.isVerticesDataPresent(BABYLON.VertexBuffer.UVKind)) {
@@ -272,7 +278,7 @@ var BABYLON;
                     defines.push("#define BONES");
                     defines.push("#define BonesPerMesh " + (mesh.skeleton.bones.length + 1));
                     defines.push("#define BONES4");
-                    optionalDefines.push(defines[defines.length - 1]);
+                    fallbacks.addFallback(0, "BONES4");
                 }
 
                 // Instances
@@ -309,7 +315,7 @@ var BABYLON;
                     "darkness0", "darkness1", "darkness2", "darkness3"], [
                     "diffuseSampler", "ambientSampler", "opacitySampler", "reflectionCubeSampler", "reflection2DSampler", "emissiveSampler", "specularSampler", "bumpSampler",
                     "shadowSampler0", "shadowSampler1", "shadowSampler2", "shadowSampler3"
-                ], join, optionalDefines, this.onCompiled, this.onError);
+                ], join, fallbacks, this.onCompiled, this.onError);
             }
             if (!this._effect.isReady()) {
                 return false;

+ 21 - 14
Babylon/Materials/babylon.standardMaterial.ts

@@ -17,6 +17,8 @@
         public emissiveColor = new BABYLON.Color3(0, 0, 0);
         public useAlphaFromDiffuseTexture = false;
 
+        public useFresnelForDiffuse = false;
+
         private _cachedDefines = null;
         private _renderTargets = new BABYLON.SmartArray<RenderTargetTexture>(16);
         private _worldViewProjectionMatrix = BABYLON.Matrix.Zero();
@@ -74,7 +76,7 @@
 
             var engine = scene.getEngine();
             var defines = [];
-            var optionalDefines = new Array<string>();
+            var fallbacks = new EffectFallbacks();
 
             // Textures
             if (scene.texturesEnabled) {
@@ -111,6 +113,7 @@
                         return false;
                     } else {
                         defines.push("#define REFLECTION");
+                        fallbacks.addFallback(0, "REFLECTION");
                     }
                 }
 
@@ -127,7 +130,7 @@
                         return false;
                     } else {
                         defines.push("#define SPECULAR");
-                        optionalDefines.push(defines[defines.length - 1]);
+                        fallbacks.addFallback(0, "SPECULAR");
                     }
                 }
             }
@@ -137,7 +140,7 @@
                     return false;
                 } else {
                     defines.push("#define BUMP");
-                    optionalDefines.push(defines[defines.length - 1]);
+                    fallbacks.addFallback(0, "BUMP");
                 }
             }
 
@@ -157,7 +160,7 @@
             // Fog
             if (scene.fogMode !== BABYLON.Scene.FOGMODE_NONE) {
                 defines.push("#define FOG");
-                optionalDefines.push(defines[defines.length - 1]);
+                fallbacks.addFallback(1, "FOG");
             }
 
             var shadowsActivated = false;
@@ -203,7 +206,7 @@
                     defines.push("#define LIGHT" + lightIndex);
 
                     if (lightIndex > 0) {
-                        optionalDefines.push(defines[defines.length - 1]);
+                        fallbacks.addFallback(lightIndex, "LIGHT" + lightIndex);
                     }
 
                     var type;
@@ -217,17 +220,14 @@
 
                     defines.push(type);
                     if (lightIndex > 0) {
-                        optionalDefines.push(defines[defines.length - 1]);
+                        fallbacks.addFallback(lightIndex, type.replace("#define ", ""));
                     }
 
                     // Shadows
                     var shadowGenerator = light.getShadowGenerator();
                     if (mesh && mesh.receiveShadows && shadowGenerator) {
                         defines.push("#define SHADOW" + lightIndex);
-
-                        if (lightIndex > 0) {
-                            optionalDefines.push(defines[defines.length - 1]);
-                        }
+                        fallbacks.addFallback(0, "SHADOW" + lightIndex);
 
                         if (!shadowsActivated) {
                             defines.push("#define SHADOWS");
@@ -237,14 +237,14 @@
                         if (shadowGenerator.useVarianceShadowMap) {
                             defines.push("#define SHADOWVSM" + lightIndex);
                             if (lightIndex > 0) {
-                                optionalDefines.push(defines[defines.length - 1]);
+                                fallbacks.addFallback(0, "SHADOWVSM" + lightIndex);
                             }
                         }
 
                         if (shadowGenerator.usePoissonSampling) {
                             defines.push("#define SHADOWPCF" + lightIndex);
                             if (lightIndex > 0) {
-                                optionalDefines.push(defines[defines.length - 1]);
+                                fallbacks.addFallback(0, "SHADOWPCF" + lightIndex);
                             }
                         }
                     }
@@ -255,6 +255,13 @@
                 }
             }
 
+            if (this.useFresnelForDiffuse) {
+                defines.push("#define FRESNEL");
+                defines.push("#define DIFFUSEFRESNEL");
+                fallbacks.addFallback(1, "FRESNEL");
+                fallbacks.addFallback(1, "DIFFUSEFRESNEL");
+            }
+
             var attribs = [BABYLON.VertexBuffer.PositionKind, BABYLON.VertexBuffer.NormalKind];
             if (mesh) {
                 if (mesh.isVerticesDataPresent(BABYLON.VertexBuffer.UVKind)) {
@@ -275,7 +282,7 @@
                     defines.push("#define BONES");
                     defines.push("#define BonesPerMesh " + (mesh.skeleton.bones.length + 1));
                     defines.push("#define BONES4");
-                    optionalDefines.push(defines[defines.length - 1]);
+                    fallbacks.addFallback(0, "BONES4");
                 }
 
                 // Instances
@@ -314,7 +321,7 @@
                     ["diffuseSampler", "ambientSampler", "opacitySampler", "reflectionCubeSampler", "reflection2DSampler", "emissiveSampler", "specularSampler", "bumpSampler",
                         "shadowSampler0", "shadowSampler1", "shadowSampler2", "shadowSampler3"
                     ],
-                    join, optionalDefines, this.onCompiled, this.onError);
+                    join, fallbacks, this.onCompiled, this.onError);
             }
             if (!this._effect.isReady()) {
                 return false;

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

@@ -24,6 +24,11 @@
             array[index + 2] = this.b;
         };
 
+        Color3.prototype.toColor4 = function (alpha) {
+            if (typeof alpha === "undefined") { alpha = 1; }
+            return new Color4(this.r, this.g, this.b, alpha);
+        };
+
         Color3.prototype.asArray = function () {
             var result = [];
 
@@ -266,8 +271,8 @@
             this.x = source.x;
             this.y = source.y;
         };
-		
-		Vector2.prototype.copyFromFloats = function (x, y) {
+
+        Vector2.prototype.copyFromFloats = function (x, y) {
             this.x = x;
             this.y = y;
         };
@@ -276,6 +281,10 @@
             return new Vector2(this.x + otherVector.x, this.y + otherVector.y);
         };
 
+        Vector2.prototype.addVector3 = function (otherVector) {
+            return new Vector2(this.x + otherVector.x, this.y + otherVector.y);
+        };
+
         Vector2.prototype.subtract = function (otherVector) {
             return new Vector2(this.x - otherVector.x, this.y - otherVector.y);
         };

+ 14 - 6
Babylon/Math/babylon.math.ts

@@ -18,6 +18,10 @@
             array[index + 2] = this.b;
         }
 
+        public toColor4(alpha = 1): Color4 {
+            return new Color4(this.r, this.g, this.b, alpha);
+        }
+
         public asArray(): number[] {
             var result = [];
 
@@ -233,16 +237,20 @@
             this.x = source.x;
             this.y = source.y;
         }
-		
-		public copyFromFloats(x: number, y: number): void {
-			this.x = x;
-			this.y = y;
-		}
+
+        public copyFromFloats(x: number, y: number): void {
+            this.x = x;
+            this.y = y;
+        }
 
         public add(otherVector: Vector2): Vector2 {
             return new Vector2(this.x + otherVector.x, this.y + otherVector.y);
         }
 
+        public addVector3(otherVector: Vector3): Vector2 {
+            return new Vector2(this.x + otherVector.x, this.y + otherVector.y);
+        }
+
         public subtract(otherVector: Vector2): Vector2 {
             return new Vector2(this.x - otherVector.x, this.y - otherVector.y);
         }
@@ -494,7 +502,7 @@
         }
 
         public equalsWithEpsilon(otherVector: Vector3): boolean {
-            return  Math.abs(this.x - otherVector.x) < Engine.Epsilon &&
+            return Math.abs(this.x - otherVector.x) < Engine.Epsilon &&
                 Math.abs(this.y - otherVector.y) < Engine.Epsilon &&
                 Math.abs(this.z - otherVector.z) < Engine.Epsilon;
         }

+ 4 - 2
Babylon/Mesh/babylon.linesMesh.js

@@ -12,11 +12,13 @@ var BABYLON;
             if (typeof updatable === "undefined") { updatable = false; }
             _super.call(this, name, scene);
             this.color = new BABYLON.Color3(1, 1, 1);
+            this.alpha = 1;
             this._indices = new Array();
 
             this._colorShader = new BABYLON.ShaderMaterial("colorShader", scene, "color", {
                 attributes: ["position"],
-                uniforms: ["worldViewProjection", "color"]
+                uniforms: ["worldViewProjection", "color"],
+                needAlphaBlending: true
             });
         }
         Object.defineProperty(LinesMesh.prototype, "material", {
@@ -52,7 +54,7 @@ var BABYLON;
             engine.bindBuffers(this._geometry.getVertexBuffer(BABYLON.VertexBuffer.PositionKind).getBuffer(), indexToBind, [3], 3 * 4, this._colorShader.getEffect());
 
             // Color
-            this._colorShader.setColor3("color", this.color);
+            this._colorShader.setColor4("color", this.color.toColor4(this.alpha));
         };
 
         LinesMesh.prototype._draw = function (subMesh, useTriangles, instancesCount) {

+ 4 - 2
Babylon/Mesh/babylon.linesMesh.ts

@@ -1,6 +1,7 @@
 module BABYLON {
     export class LinesMesh extends Mesh {
         public color = new BABYLON.Color3(1, 1, 1);
+        public alpha = 1;
 
         private _colorShader: ShaderMaterial;
         private _ib: WebGLBuffer;
@@ -14,7 +15,8 @@
             this._colorShader = new ShaderMaterial("colorShader", scene, "color",
                 {
                     attributes: ["position"],
-                    uniforms: ["worldViewProjection", "color"]
+                    uniforms: ["worldViewProjection", "color"],
+                    needAlphaBlending: true
                 });
         }
 
@@ -39,7 +41,7 @@
             engine.bindBuffers(this._geometry.getVertexBuffer(VertexBuffer.PositionKind).getBuffer(), indexToBind, [3], 3 * 4, this._colorShader.getEffect());
 
             // Color
-            this._colorShader.setColor3("color", this.color);
+            this._colorShader.setColor4("color", this.color.toColor4(this.alpha));
         }
 
         public _draw(subMesh: SubMesh, useTriangles: boolean, instancesCount?: number): void {

+ 2 - 2
Babylon/Rendering/babylon.boundingBoxRenderer.js

@@ -44,7 +44,7 @@
                 if (this.showBackLines) {
                     // Back
                     engine.setDepthFunctionToGreaterOrEqual();
-                    this._colorShader.setColor3("color", this.backColor);
+                    this._colorShader.setColor4("color", this.backColor.toColor4());
                     this._colorShader.bind(worldMatrix);
 
                     // Draw order
@@ -53,7 +53,7 @@
 
                 // Front
                 engine.setDepthFunctionToLess();
-                this._colorShader.setColor3("color", this.frontColor);
+                this._colorShader.setColor4("color", this.frontColor.toColor4());
                 this._colorShader.bind(worldMatrix);
 
                 // Draw order

+ 2 - 2
Babylon/Rendering/babylon.boundingBoxRenderer.ts

@@ -55,7 +55,7 @@
                 if (this.showBackLines) {
                     // Back
                     engine.setDepthFunctionToGreaterOrEqual();
-                    this._colorShader.setColor3("color", this.backColor);
+                    this._colorShader.setColor4("color", this.backColor.toColor4());
                     this._colorShader.bind(worldMatrix);
 
                     // Draw order
@@ -64,7 +64,7 @@
 
                 // Front
                 engine.setDepthFunctionToLess();
-                this._colorShader.setColor3("color", this.frontColor);
+                this._colorShader.setColor4("color", this.frontColor.toColor4());
                 this._colorShader.bind(worldMatrix);
 
                 // Draw order

+ 2 - 2
Babylon/Shaders/color.fragment.fx

@@ -1,7 +1,7 @@
 precision mediump float;
 
-uniform vec3 color;
+uniform vec4 color;
 
 void main(void) {
-	gl_FragColor = vec4(color, 1.);
+	gl_FragColor = color;
 }

+ 14 - 0
Babylon/Shaders/default.fragment.fx

@@ -124,6 +124,15 @@ uniform vec2 vSpecularInfos;
 uniform sampler2D specularSampler;
 #endif
 
+// Fresnel
+#ifdef FRESNEL
+float computeFresnelTerm(vec3 viewDirection, vec3 worldNormal)
+{
+	float fresnelTerm = dot(viewDirection, worldNormal);
+	return clamp(1.0 - fresnelTerm, 0., 1.);
+}
+#endif
+
 // Reflection
 #ifdef REFLECTION
 varying vec3 vPositionUVW;
@@ -640,6 +649,11 @@ void main(void) {
 	specularColor = texture2D(specularSampler, vSpecularUV).rgb * vSpecularInfos.y;
 #endif
 
+	// Fresnel
+#ifdef DIFFUSEFRESNEL
+	diffuseBase *= computeFresnelTerm(viewDirectionW, normalW);
+#endif
+
 	// Composition
 	vec3 finalDiffuse = clamp(diffuseBase * diffuseColor + emissiveColor + vAmbientColor, 0.0, 1.0) * baseColor.rgb;
 	vec3 finalSpecular = specularBase * specularColor;

+ 171 - 2
Babylon/Tools/babylon.assetsManager.js

@@ -1,9 +1,178 @@
 var BABYLON;
 (function (BABYLON) {
+    var MeshAssetTask = (function () {
+        function MeshAssetTask(name, meshesNames, rootUrl, sceneFilename) {
+            this.name = name;
+            this.meshesNames = meshesNames;
+            this.rootUrl = rootUrl;
+            this.sceneFilename = sceneFilename;
+            this.isCompleted = false;
+        }
+        MeshAssetTask.prototype.run = function (scene, onSuccess, onError) {
+            var _this = this;
+            BABYLON.SceneLoader.ImportMesh(this.meshesNames, this.rootUrl, this.sceneFilename, scene, function (meshes, particleSystems, skeletons) {
+                _this.loadedMeshes = meshes;
+                _this.loadedParticleSystems = particleSystems;
+                _this.loadedSkeletons = skeletons;
+
+                _this.isCompleted = true;
+
+                if (_this.onSuccess) {
+                    _this.onSuccess(_this);
+                }
+
+                onSuccess();
+            }, null, function () {
+                if (_this.onError) {
+                    _this.onError(_this);
+                }
+
+                onError();
+            });
+        };
+        return MeshAssetTask;
+    })();
+    BABYLON.MeshAssetTask = MeshAssetTask;
+
+    var TextFileAssetTask = (function () {
+        function TextFileAssetTask(name, url) {
+            this.name = name;
+            this.url = url;
+            this.isCompleted = false;
+        }
+        TextFileAssetTask.prototype.run = function (scene, onSuccess, onError) {
+            var _this = this;
+            BABYLON.Tools.LoadFile(this.url, function (data) {
+                _this.text = data;
+                _this.isCompleted = true;
+
+                if (_this.onSuccess) {
+                    _this.onSuccess(_this);
+                }
+
+                onSuccess();
+            }, null, scene.database, false, function () {
+                if (_this.onError) {
+                    _this.onError(_this);
+                }
+
+                onError();
+            });
+        };
+        return TextFileAssetTask;
+    })();
+    BABYLON.TextFileAssetTask = TextFileAssetTask;
+
+    var BinaryFileAssetTask = (function () {
+        function BinaryFileAssetTask(name, url) {
+            this.name = name;
+            this.url = url;
+            this.isCompleted = false;
+        }
+        BinaryFileAssetTask.prototype.run = function (scene, onSuccess, onError) {
+            var _this = this;
+            BABYLON.Tools.LoadFile(this.url, function (data) {
+                _this.data = data;
+                _this.isCompleted = true;
+
+                if (_this.onSuccess) {
+                    _this.onSuccess(_this);
+                }
+
+                onSuccess();
+            }, null, scene.database, true, function () {
+                if (_this.onError) {
+                    _this.onError(_this);
+                }
+
+                onError();
+            });
+        };
+        return BinaryFileAssetTask;
+    })();
+    BABYLON.BinaryFileAssetTask = BinaryFileAssetTask;
+
     var AssetsManager = (function () {
-        function AssetsManager() {
-            this.tasks = [];
+        function AssetsManager(scene) {
+            this._tasks = new Array();
+            this._waitingTasksCount = 0;
+            this.useDefaultLoadingScreen = true;
+            this._scene = scene;
         }
+        AssetsManager.prototype.addMeshTask = function (taskName, meshesNames, rootUrl, sceneFilename) {
+            var task = new MeshAssetTask(taskName, meshesNames, rootUrl, sceneFilename);
+            this._tasks.push(task);
+
+            return task;
+        };
+
+        AssetsManager.prototype.addTextFileTask = function (taskName, url) {
+            var task = new TextFileAssetTask(taskName, url);
+            this._tasks.push(task);
+
+            return task;
+        };
+
+        AssetsManager.prototype.addBinaryFileTask = function (taskName, url) {
+            var task = new BinaryFileAssetTask(taskName, url);
+            this._tasks.push(task);
+
+            return task;
+        };
+
+        AssetsManager.prototype._decreaseWaitingTasksCount = function () {
+            this._waitingTasksCount--;
+
+            if (this._waitingTasksCount === 0) {
+                if (this.onFinish) {
+                    this.onFinish(this._tasks);
+                }
+
+                this._scene.getEngine().hideLoadingUI();
+            }
+        };
+
+        AssetsManager.prototype._runTask = function (task) {
+            var _this = this;
+            task.run(this._scene, function () {
+                if (_this.onTaskSuccess) {
+                    _this.onTaskSuccess(task);
+                }
+                _this._decreaseWaitingTasksCount();
+            }, function () {
+                if (_this.onTaskError) {
+                    _this.onTaskError(task);
+                }
+                _this._decreaseWaitingTasksCount();
+            });
+        };
+
+        AssetsManager.prototype.reset = function () {
+            this._tasks = new Array();
+            return this;
+        };
+
+        AssetsManager.prototype.load = function () {
+            this._waitingTasksCount = this._tasks.length;
+
+            if (this._waitingTasksCount === 0) {
+                if (this.onFinish) {
+                    this.onFinish(this._tasks);
+                }
+                return this;
+            }
+
+            if (this.useDefaultLoadingScreen) {
+                this._scene.getEngine().displayLoadingUI();
+            }
+
+            for (var index = 0; index < this._tasks.length; index++) {
+                var task = this._tasks[index];
+                this._runTask(task);
+            }
+
+            return this;
+        };
         return AssetsManager;
     })();
     BABYLON.AssetsManager = AssetsManager;

+ 194 - 3
Babylon/Tools/babylon.assetsManager.ts

@@ -1,9 +1,200 @@
 module BABYLON {
+    export interface IAssetTask {
+        onSuccess: (task: IAssetTask) => void;
+        onError: (task: IAssetTask) => void;
+        isCompleted: boolean;
+
+        run(scene: Scene, onSuccess: () => void, onError: () => void);
+    }
+
+    export class MeshAssetTask implements IAssetTask {
+        public loadedMeshes: Array<AbstractMesh>;
+        public loadedParticleSystems: Array<ParticleSystem>;
+        public loadedSkeletons: Array<Skeleton>;
+
+        public onSuccess: (task: IAssetTask) => void;
+        public onError: (task: IAssetTask) => void;
+
+        public isCompleted = false;
+
+        constructor(public name: string, public meshesNames: any, public rootUrl: string, public sceneFilename: string) {
+        }
+
+        public run(scene: Scene, onSuccess: () => void, onError: () => void) {
+            BABYLON.SceneLoader.ImportMesh(this.meshesNames, this.rootUrl, this.sceneFilename, scene,
+                (meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[]) => {
+                    this.loadedMeshes = meshes;
+                    this.loadedParticleSystems = particleSystems;
+                    this.loadedSkeletons = skeletons;
+
+                    this.isCompleted = true;
+
+                    if (this.onSuccess) {
+                        this.onSuccess(this);
+                    }
+
+                    onSuccess();
+                }, null, () => {
+                    if (this.onError) {
+                        this.onError(this);
+                    }
+
+                    onError();
+                }
+                );
+        }
+    }
+
+    export class TextFileAssetTask implements IAssetTask {
+        public onSuccess: (task: IAssetTask) => void;
+        public onError: (task: IAssetTask) => void;
+
+        public isCompleted = false;
+        public text: string;
+
+        constructor(public name: string, public url: string) {
+        }
+
+        public run(scene: Scene, onSuccess: () => void, onError: () => void) {
+            Tools.LoadFile(this.url, (data) => {
+
+                this.text = data;
+                this.isCompleted = true;
+
+                if (this.onSuccess) {
+                    this.onSuccess(this);
+                }
+
+                onSuccess();
+            }, null, scene.database, false, () => {
+                    if (this.onError) {
+                        this.onError(this);
+                    }
+
+                    onError();
+                });
+        }
+    }
+
+    export class BinaryFileAssetTask implements IAssetTask {
+        public onSuccess: (task: IAssetTask) => void;
+        public onError: (task: IAssetTask) => void;
+
+        public isCompleted = false;
+        public data: ArrayBuffer;
+
+        constructor(public name: string, public url: string) {
+        }
+
+        public run(scene: Scene, onSuccess: () => void, onError: () => void) {
+            Tools.LoadFile(this.url, (data) => {
+
+                this.data = data;
+                this.isCompleted = true;
+
+                if (this.onSuccess) {
+                    this.onSuccess(this);
+                }
+
+                onSuccess();
+            }, null, scene.database, true, () => {
+                    if (this.onError) {
+                        this.onError(this);
+                    }
+
+                    onError();
+                });
+        }
+    }
+
     export class AssetsManager {
-        private tasks = [];
+        private _tasks = new Array<IAssetTask>();
+        private _scene: Scene;
+
+        private _waitingTasksCount = 0;
+
+        public onFinish: (tasks: IAssetTask[]) => void;
+        public onTaskSuccess: (task: IAssetTask) => void;
+        public onTaskError: (task: IAssetTask) => void;
 
-        constructor() {
-            
+        public useDefaultLoadingScreen = true;
+
+        constructor(scene: Scene) {
+            this._scene = scene;
+        }
+
+        public addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): IAssetTask {
+            var task = new MeshAssetTask(taskName, meshesNames, rootUrl, sceneFilename);
+            this._tasks.push(task);
+
+            return task;
         }
+
+        public addTextFileTask(taskName: string, url: string): IAssetTask {
+            var task = new TextFileAssetTask(taskName, url);
+            this._tasks.push(task);
+
+            return task;
+        }
+
+        public addBinaryFileTask(taskName: string, url: string): IAssetTask {
+            var task = new BinaryFileAssetTask(taskName, url);
+            this._tasks.push(task);
+
+            return task;
+        }
+
+        private _decreaseWaitingTasksCount(): void {
+            this._waitingTasksCount--;
+
+            if (this._waitingTasksCount === 0) {
+                if (this.onFinish) {
+                    this.onFinish(this._tasks);
+                }
+
+                this._scene.getEngine().hideLoadingUI();
+            }
+        }
+
+        private _runTask(task: IAssetTask): void {
+            task.run(this._scene, () => {
+                if (this.onTaskSuccess) {
+                    this.onTaskSuccess(task);
+                }
+                this._decreaseWaitingTasksCount();
+            }, () => {
+                    if (this.onTaskError) {
+                        this.onTaskError(task);
+                    }
+                    this._decreaseWaitingTasksCount();
+                });
+        }
+
+        public reset(): AssetsManager {
+            this._tasks = new Array<IAssetTask>();
+            return this;
+        }
+
+        public load(): AssetsManager {
+            this._waitingTasksCount = this._tasks.length;
+
+            if (this._waitingTasksCount === 0) {
+                if (this.onFinish) {
+                    this.onFinish(this._tasks);
+                }
+                return this;
+            }
+
+            if (this.useDefaultLoadingScreen) {
+                this._scene.getEngine().displayLoadingUI();
+            }
+
+            for (var index = 0; index < this._tasks.length; index++) {
+                var task = this._tasks[index];
+                this._runTask(task);
+            }
+
+            return this;
+        }     
     }
 } 

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

@@ -1,7 +1,5 @@
 var BABYLON;
 (function (BABYLON) {
-    
-
     // Screenshots
     var screenshotCanvas;
 
@@ -208,7 +206,7 @@
         };
 
         //ANY
-        Tools.LoadFile = function (url, callback, progressCallBack, database, useArrayBuffer) {
+        Tools.LoadFile = function (url, callback, progressCallBack, database, useArrayBuffer, onError) {
             url = Tools.CleanUrl(url);
 
             var noIndexedDB = function () {
@@ -227,7 +225,11 @@
                         if (request.status == 200 || BABYLON.Tools.ValidateXHRData(request, !useArrayBuffer ? 1 : 6)) {
                             callback(!useArrayBuffer ? request.responseText : request.response);
                         } else {
-                            throw new Error("Error status: " + request.status + " - Unable to load " + loadUrl);
+                            if (onError) {
+                                onError();
+                            } else {
+                                throw new Error("Error status: " + request.status + " - Unable to load " + loadUrl);
+                            }
                         }
                     }
                 };

+ 8 - 8
Babylon/Tools/babylon.tools.ts

@@ -1,7 +1,4 @@
 module BABYLON {
-
-    //class FilesTextures { } //ANY
-
     export interface IAnimatable {
         animations: Array<Animation>;
     }
@@ -225,7 +222,7 @@
         }
 
         //ANY
-        public static LoadFile(url: string, callback: (data: any) => void, progressCallBack?: () => void, database?, useArrayBuffer?: boolean): void {
+        public static LoadFile(url: string, callback: (data: any) => void, progressCallBack?: () => void, database?, useArrayBuffer?: boolean, onError?: () => void): void {
             url = Tools.CleanUrl(url);
 
             var noIndexedDB = () => {
@@ -244,7 +241,12 @@
                         if (request.status == 200 || BABYLON.Tools.ValidateXHRData(request, !useArrayBuffer ? 1 : 6)) {
                             callback(!useArrayBuffer ? request.responseText : request.response);
                         } else { // Failed
-                            throw new Error("Error status: " + request.status + " - Unable to load " + loadUrl);
+                            if (onError) {
+                                onError();
+                            } else {
+
+                                throw new Error("Error status: " + request.status + " - Unable to load " + loadUrl);
+                            }
                         }
                     }
                 };
@@ -253,7 +255,6 @@
             };
 
             var loadFromIndexedDB = () => {
-                
                 database.loadFileFromDB(url, callback, progressCallBack, noIndexedDB, useArrayBuffer);
             };
 
@@ -264,8 +265,7 @@
             else {
                 // Caching all files
                 if (database && database.enableSceneOffline) {
-                    database.openAsync(loadFromIndexedDB, noIndexedDB);
-                    
+                    database.openAsync(loadFromIndexedDB, noIndexedDB);                    
                 }
                 else {
                     noIndexedDB();

+ 1 - 1
Babylon/Tools/babylon.virtualJoystick.ts

@@ -72,7 +72,7 @@ module BABYLON {
 
             // injecting a canvas element on top of the canvas 3D game
             if (!VirtualJoystick.vjCanvas) {
-                window.addEventListener("resize", function () {
+                window.addEventListener("resize", () => {
                     VirtualJoystick.vjCanvasWidth = window.innerWidth;
                     VirtualJoystick.vjCanvasHeight = window.innerHeight;
                     VirtualJoystick.vjCanvas.width = VirtualJoystick.vjCanvasWidth;

Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 114 - 2
Babylon/babylon.engine.js


Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 114 - 4
Babylon/babylon.engine.ts


+ 4 - 1
Babylon/babylon.scene.js

@@ -1088,7 +1088,10 @@
 
             // Remove from engine
             index = this._engine.scenes.indexOf(this);
-            this._engine.scenes.splice(index, 1);
+
+            if (index > -1) {
+                this._engine.scenes.splice(index, 1);
+            }
 
             this._engine.wipeCaches();
         };

+ 4 - 1
Babylon/babylon.scene.ts

@@ -1178,7 +1178,10 @@
 
             // Remove from engine
             index = this._engine.scenes.indexOf(this);
-            this._engine.scenes.splice(index, 1);
+
+            if (index > -1) {
+                this._engine.scenes.splice(index, 1);
+            }
 
             this._engine.wipeCaches();
         }

Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 4 - 4
babylon.1.14-beta-debug.js


Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 15 - 15
babylon.1.14-beta.js