Преглед на файлове

Observable optimizations + nightly

David Catuhe преди 7 години
родител
ревизия
ab853ddc53
променени са 51 файла, в които са добавени 22403 реда и са изтрити 21648 реда
  1. 9948 9911
      Playground/babylon.d.txt
  2. 10579 10551
      dist/preview release/babylon.d.ts
  3. 60 59
      dist/preview release/babylon.js
  4. 146 52
      dist/preview release/babylon.max.js
  5. 146 52
      dist/preview release/babylon.no-module.max.js
  6. 60 59
      dist/preview release/babylon.worker.js
  7. 146 52
      dist/preview release/es6.js
  8. 1 1
      dist/preview release/gui/babylon.gui.min.js
  9. 1 1
      dist/preview release/gui/babylon.gui.min.js.map
  10. 1 1
      dist/preview release/inspector/babylon.inspector.bundle.js
  11. 1 1
      dist/preview release/inspector/babylon.inspector.bundle.js.map
  12. 45 34
      dist/preview release/loaders/babylon.glTF1FileLoader.d.ts
  13. 23 1
      dist/preview release/loaders/babylon.glTF1FileLoader.js
  14. 2 2
      dist/preview release/loaders/babylon.glTF1FileLoader.min.js
  15. 106 76
      dist/preview release/loaders/babylon.glTF2FileLoader.d.ts
  16. 146 94
      dist/preview release/loaders/babylon.glTF2FileLoader.js
  17. 3 3
      dist/preview release/loaders/babylon.glTF2FileLoader.min.js
  18. 123 93
      dist/preview release/loaders/babylon.glTFFileLoader.d.ts
  19. 146 94
      dist/preview release/loaders/babylon.glTFFileLoader.js
  20. 4 4
      dist/preview release/loaders/babylon.glTFFileLoader.min.js
  21. 3 3
      dist/preview release/loaders/babylon.objFileLoader.d.ts
  22. 3 3
      dist/preview release/loaders/babylon.stlFileLoader.d.ts
  23. 129 99
      dist/preview release/loaders/babylonjs.loaders.d.ts
  24. 146 94
      dist/preview release/loaders/babylonjs.loaders.js
  25. 4 4
      dist/preview release/loaders/babylonjs.loaders.min.js
  26. 129 99
      dist/preview release/loaders/babylonjs.loaders.module.d.ts
  27. 1 1
      dist/preview release/materialsLibrary/babylon.waterMaterial.d.ts
  28. 1 1
      dist/preview release/materialsLibrary/babylonjs.materials.d.ts
  29. 1 1
      dist/preview release/materialsLibrary/babylonjs.materials.module.d.ts
  30. 2 2
      dist/preview release/postProcessesLibrary/babylon.asciiArtPostProcess.d.ts
  31. 2 2
      dist/preview release/postProcessesLibrary/babylon.digitalRainPostProcess.d.ts
  32. 4 4
      dist/preview release/postProcessesLibrary/babylonjs.postProcess.d.ts
  33. 4 4
      dist/preview release/postProcessesLibrary/babylonjs.postProcess.module.d.ts
  34. 51 51
      dist/preview release/serializers/babylon.glTF2Serializer.d.ts
  35. 51 51
      dist/preview release/serializers/babylonjs.serializers.d.ts
  36. 51 51
      dist/preview release/serializers/babylonjs.serializers.module.d.ts
  37. 3 3
      dist/preview release/viewer/babylon.viewer.js
  38. 3 3
      dist/preview release/viewer/babylon.viewer.max.js
  39. 3 1
      src/Cameras/VR/babylon.vrExperienceHelper.ts
  40. 5 2
      src/Engine/babylon.engine.ts
  41. 3 1
      src/Engine/babylon.nullEngine.ts
  42. 3 1
      src/Gizmos/babylon.gizmo.ts
  43. 12 1
      src/Materials/babylon.effect.ts
  44. 29 8
      src/Materials/babylon.material.ts
  45. 1 1
      src/Materials/babylon.standardMaterial.ts
  46. 52 11
      src/Mesh/babylon.mesh.ts
  47. 5 1
      src/PostProcess/babylon.bloomMergePostProcess.ts
  48. 4 1
      src/PostProcess/babylon.blurPostProcess.ts
  49. 4 1
      src/PostProcess/babylon.convolutionPostProcess.ts
  50. 4 1
      src/PostProcess/babylon.postProcess.ts
  51. 3 1
      src/Rendering/babylon.utilityLayerRenderer.ts

Файловите разлики са ограничени, защото са твърде много
+ 9948 - 9911
Playground/babylon.d.txt


Файловите разлики са ограничени, защото са твърде много
+ 10579 - 10551
dist/preview release/babylon.d.ts


Файловите разлики са ограничени, защото са твърде много
+ 60 - 59
dist/preview release/babylon.js


+ 146 - 52
dist/preview release/babylon.max.js

@@ -188,10 +188,6 @@ var BABYLON;
              * Observable that will be called if an error occurs during shader compilation.
              */
             this.onErrorObservable = new BABYLON.Observable();
-            /**
-             * Observable that will be called when effect is bound.
-             */
-            this.onBindObservable = new BABYLON.Observable();
             /** @hidden */
             this._bonesComputationForcedToCPU = false;
             this._uniformBuffersNames = {};
@@ -272,6 +268,19 @@ var BABYLON;
                 });
             });
         }
+        Object.defineProperty(Effect.prototype, "onBindObservable", {
+            /**
+             * Observable that will be called when effect is bound.
+             */
+            get: function () {
+                if (!this._onBindObservable) {
+                    this._onBindObservable = new BABYLON.Observable();
+                }
+                return this._onBindObservable;
+            },
+            enumerable: true,
+            configurable: true
+        });
         Object.defineProperty(Effect.prototype, "key", {
             /**
              * Unique key for this effect
@@ -10482,6 +10491,7 @@ var BABYLON;
         };
         InternalPromise.prototype._moveChildren = function (children) {
             var _this = this;
+            var _a;
             (_a = this._children).push.apply(_a, children.splice(0, children.length));
             this._children.forEach(function (child) {
                 child._parent = _this;
@@ -10498,7 +10508,6 @@ var BABYLON;
                     child._reject(this._reason);
                 }
             }
-            var _a;
         };
         InternalPromise.prototype._resolve = function (value) {
             try {
@@ -13809,7 +13818,7 @@ var BABYLON;
          * @param effect defines the effect to activate
          */
         Engine.prototype.enableEffect = function (effect) {
-            if (!effect) {
+            if (!effect || effect === this._currentEffect) {
                 return;
             }
             // Use program
@@ -13818,7 +13827,9 @@ var BABYLON;
             if (effect.onBind) {
                 effect.onBind(effect);
             }
-            effect.onBindObservable.notifyObservers(effect);
+            if (effect._onBindObservable) {
+                effect._onBindObservable.notifyObservers(effect);
+            }
         };
         /**
          * Set the value of an uniform to an array of int32
@@ -31026,19 +31037,6 @@ var BABYLON;
             if (source === void 0) { source = null; }
             if (clonePhysicsImpostor === void 0) { clonePhysicsImpostor = true; }
             var _this = _super.call(this, name, scene) || this;
-            // Events 
-            /**
-             * An event triggered before rendering the mesh
-             */
-            _this.onBeforeRenderObservable = new BABYLON.Observable();
-            /**
-            * An event triggered after rendering the mesh
-            */
-            _this.onAfterRenderObservable = new BABYLON.Observable();
-            /**
-            * An event triggered before drawing the mesh
-            */
-            _this.onBeforeDrawObservable = new BABYLON.Observable();
             // Members
             _this.delayLoadState = BABYLON.Engine.DELAYLOADSTATE_NONE;
             _this.instances = new Array();
@@ -31061,7 +31059,9 @@ var BABYLON;
                 }
                 // Deep copy
                 BABYLON.Tools.DeepCopy(source, _this, ["name", "material", "skeleton", "instances", "parent", "uniqueId",
-                    "source", "metadata", "hasLODLevels", "geometry", "isBlocked", "areNormalsFrozen"], ["_poseMatrix"]);
+                    "source", "metadata", "hasLODLevels", "geometry", "isBlocked", "areNormalsFrozen",
+                    "onBeforeDrawObservable", "onBeforeRenderObservable", "onAfterRenderObservable", "onBeforeDraw"
+                ], ["_poseMatrix"]);
                 // Source mesh
                 _this._source = source;
                 // Metadata
@@ -31197,6 +31197,45 @@ var BABYLON;
             enumerable: true,
             configurable: true
         });
+        Object.defineProperty(Mesh.prototype, "onBeforeRenderObservable", {
+            /**
+             * An event triggered before rendering the mesh
+             */
+            get: function () {
+                if (!this._onBeforeRenderObservable) {
+                    this._onBeforeRenderObservable = new BABYLON.Observable();
+                }
+                return this._onBeforeRenderObservable;
+            },
+            enumerable: true,
+            configurable: true
+        });
+        Object.defineProperty(Mesh.prototype, "onAfterRenderObservable", {
+            /**
+            * An event triggered after rendering the mesh
+            */
+            get: function () {
+                if (!this._onAfterRenderObservable) {
+                    this._onAfterRenderObservable = new BABYLON.Observable();
+                }
+                return this._onAfterRenderObservable;
+            },
+            enumerable: true,
+            configurable: true
+        });
+        Object.defineProperty(Mesh.prototype, "onBeforeDrawObservable", {
+            /**
+            * An event triggered before drawing the mesh
+            */
+            get: function () {
+                if (!this._onBeforeDrawObservable) {
+                    this._onBeforeDrawObservable = new BABYLON.Observable();
+                }
+                return this._onBeforeDrawObservable;
+            },
+            enumerable: true,
+            configurable: true
+        });
         Object.defineProperty(Mesh.prototype, "onBeforeDraw", {
             set: function (callback) {
                 if (this._onBeforeDrawObserver) {
@@ -31983,7 +32022,9 @@ var BABYLON;
             if (!this._geometry || !this._geometry.getVertexBuffers() || (!this._unIndexed && !this._geometry.getIndexBuffer())) {
                 return this;
             }
-            this.onBeforeDrawObservable.notifyObservers(this);
+            if (this._onBeforeDrawObservable) {
+                this._onBeforeDrawObservable.notifyObservers(this);
+            }
             var scene = this.getScene();
             var engine = scene.getEngine();
             if (this._unIndexed || fillMode == BABYLON.Material.PointFillMode) {
@@ -32166,10 +32207,10 @@ var BABYLON;
          * @returns the current mesh
          */
         Mesh.prototype.render = function (subMesh, enableAlphaMode) {
-            this._checkOcclusionQuery();
-            if (this._isOccluded) {
-                return this;
-            }
+            // this._checkOcclusionQuery();
+            // if (this._isOccluded) {
+            //     return this;
+            // }
             var scene = this.getScene();
             // Managing instances
             var batch = this._getInstancesRenderList(subMesh._id);
@@ -32180,7 +32221,9 @@ var BABYLON;
             if (!this._geometry || !this._geometry.getVertexBuffers() || (!this._unIndexed && !this._geometry.getIndexBuffer())) {
                 return this;
             }
-            this.onBeforeRenderObservable.notifyObservers(this);
+            if (this._onBeforeRenderObservable) {
+                this._onBeforeRenderObservable.notifyObservers(this);
+            }
             var engine = scene.getEngine();
             var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null) && (batch.visibleInstances[subMesh._id] !== undefined);
             // Material
@@ -32264,7 +32307,9 @@ var BABYLON;
                 scene.getOutlineRenderer().render(subMesh, batch, true);
                 engine.setAlphaMode(currentMode);
             }
-            this.onAfterRenderObservable.notifyObservers(this);
+            if (this._onAfterRenderObservable) {
+                this._onAfterRenderObservable.notifyObservers(this);
+            }
             return this;
         };
         Mesh.prototype._onBeforeDraw = function (isInstance, world, effectiveMaterial) {
@@ -32560,6 +32605,15 @@ var BABYLON;
             if (this._geometry) {
                 this._geometry.releaseForMesh(this, true);
             }
+            if (this._onBeforeDrawObservable) {
+                this._onBeforeDrawObservable.clear();
+            }
+            if (this._onBeforeRenderObservable) {
+                this._onBeforeRenderObservable.clear();
+            }
+            if (this._onAfterRenderObservable) {
+                this._onAfterRenderObservable.clear();
+            }
             // Sources
             var meshes = this.getScene().meshes;
             meshes.forEach(function (abstractMesh) {
@@ -34656,14 +34710,6 @@ var BABYLON;
             */
             this.onDisposeObservable = new BABYLON.Observable();
             /**
-            * An event triggered when the material is bound
-            */
-            this.onBindObservable = new BABYLON.Observable();
-            /**
-            * An event triggered when the material is unbound
-            */
-            this.onUnBindObservable = new BABYLON.Observable();
-            /**
              * Stores the value of the alpha mode
              */
             this._alphaMode = BABYLON.Engine.ALPHA_COMBINE;
@@ -34932,6 +34978,19 @@ var BABYLON;
             enumerable: true,
             configurable: true
         });
+        Object.defineProperty(Material.prototype, "onBindObservable", {
+            /**
+            * An event triggered when the material is bound
+            */
+            get: function () {
+                if (!this._onBindObservable) {
+                    this._onBindObservable = new BABYLON.Observable();
+                }
+                return this._onBindObservable;
+            },
+            enumerable: true,
+            configurable: true
+        });
         Object.defineProperty(Material.prototype, "onBind", {
             /**
              * Called during a bind event
@@ -34945,6 +35004,19 @@ var BABYLON;
             enumerable: true,
             configurable: true
         });
+        Object.defineProperty(Material.prototype, "onUnBindObservable", {
+            /**
+            * An event triggered when the material is unbound
+            */
+            get: function () {
+                if (!this._onUnBindObservable) {
+                    this._onUnBindObservable = new BABYLON.Observable();
+                }
+                return this._onUnBindObservable;
+            },
+            enumerable: true,
+            configurable: true
+        });
         Object.defineProperty(Material.prototype, "alphaMode", {
             /**
              * Gets the value of the alpha mode
@@ -35276,8 +35348,8 @@ var BABYLON;
             else {
                 this._scene._cachedVisibility = 1;
             }
-            if (mesh) {
-                this.onBindObservable.notifyObservers(mesh);
+            if (this._onBindObservable && mesh) {
+                this._onBindObservable.notifyObservers(mesh);
             }
             if (this.disableDepthWrite) {
                 var engine = this._scene.getEngine();
@@ -35289,7 +35361,9 @@ var BABYLON;
          * Unbinds the material from the mesh
          */
         Material.prototype.unbind = function () {
-            this.onUnBindObservable.notifyObservers(this);
+            if (this._onUnBindObservable) {
+                this._onUnBindObservable.notifyObservers(this);
+            }
             if (this.disableDepthWrite) {
                 var engine = this._scene.getEngine();
                 engine.setDepthWrite(this._cachedDepthWriteState);
@@ -35539,8 +35613,12 @@ var BABYLON;
             // Callback
             this.onDisposeObservable.notifyObservers(this);
             this.onDisposeObservable.clear();
-            this.onBindObservable.clear();
-            this.onUnBindObservable.clear();
+            if (this._onBindObservable) {
+                this._onBindObservable.clear();
+            }
+            if (this._onUnBindObservable) {
+                this._onUnBindObservable.clear();
+            }
         };
         /**
          * Serializes this material
@@ -41800,7 +41878,7 @@ var BABYLON;
         StandardMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
             if (useInstances === void 0) { useInstances = false; }
             if (subMesh.effect && this.isFrozen) {
-                if (this._wasPreviouslyReady && subMesh.effect) {
+                if (this._wasPreviouslyReady) {
                     return true;
                 }
             }
@@ -67617,7 +67695,9 @@ var BABYLON;
          * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
          * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
          */
-        function PostProcess(/** Name of the PostProcess. */ name, fragmentUrl, parameters, samplers, options, camera, samplingMode, engine, reusable, defines, textureType, vertexUrl, indexParameters, blockCompilation) {
+        function PostProcess(
+        /** Name of the PostProcess. */
+        name, fragmentUrl, parameters, samplers, options, camera, samplingMode, engine, reusable, defines, textureType, vertexUrl, indexParameters, blockCompilation) {
             if (samplingMode === void 0) { samplingMode = BABYLON.Texture.NEAREST_SAMPLINGMODE; }
             if (defines === void 0) { defines = null; }
             if (textureType === void 0) { textureType = BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT; }
@@ -68696,6 +68776,7 @@ var BABYLON;
          */
         ShadowGenerator.prototype.addShadowCaster = function (mesh, includeDescendants) {
             if (includeDescendants === void 0) { includeDescendants = true; }
+            var _a;
             if (!this._shadowMap) {
                 return this;
             }
@@ -68707,7 +68788,6 @@ var BABYLON;
                 (_a = this._shadowMap.renderList).push.apply(_a, mesh.getChildMeshes());
             }
             return this;
-            var _a;
         };
         /**
          * Helper function to remove a mesh and its descendants from the list of shadow casters
@@ -72047,6 +72127,7 @@ var BABYLON;
             return this.subMaterials[index];
         };
         MultiMaterial.prototype.getActiveTextures = function () {
+            var _a;
             return (_a = _super.prototype.getActiveTextures.call(this)).concat.apply(_a, this.subMaterials.map(function (subMaterial) {
                 if (subMaterial) {
                     return subMaterial.getActiveTextures();
@@ -72055,7 +72136,6 @@ var BABYLON;
                     return [];
                 }
             }));
-            var _a;
         };
         // Methods
         MultiMaterial.prototype.getClassName = function () {
@@ -77718,7 +77798,9 @@ var BABYLON;
          * @param textureType Type of textures used when performing the post process. (default: 0)
          * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
          */
-        function BlurPostProcess(name, /** The direction in which to blur the image. */ direction, kernel, options, camera, samplingMode, engine, reusable, textureType, defines, blockCompilation) {
+        function BlurPostProcess(name, 
+        /** The direction in which to blur the image. */
+        direction, kernel, options, camera, samplingMode, engine, reusable, textureType, defines, blockCompilation) {
             if (samplingMode === void 0) { samplingMode = BABYLON.Texture.BILINEAR_SAMPLINGMODE; }
             if (textureType === void 0) { textureType = BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT; }
             if (defines === void 0) { defines = ""; }
@@ -78350,7 +78432,9 @@ var BABYLON;
          * @param textureType Type of textures used when performing the post process. (default: 0)
          * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
          */
-        function BloomMergePostProcess(name, originalFromInput, blurred, /** Weight of the bloom to be added to the original input. */ weight, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
+        function BloomMergePostProcess(name, originalFromInput, blurred, 
+        /** Weight of the bloom to be added to the original input. */
+        weight, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
             if (textureType === void 0) { textureType = BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT; }
             if (blockCompilation === void 0) { blockCompilation = false; }
             var _this = _super.call(this, name, "bloomMerge", ["bloomWeight"], ["circleOfConfusionSampler", "blurStep0", "blurStep1", "blurStep2", "bloomBlur"], options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, true) || this;
@@ -80812,7 +80896,9 @@ var BABYLON;
          * @param reusable If the post process can be reused on the same frame. (default: false)
          * @param textureType Type of textures used when performing the post process. (default: 0)
          */
-        function ConvolutionPostProcess(name, /** Array of 9 values corrisponding to the 3x3 kernel to be applied */ kernel, options, camera, samplingMode, engine, reusable, textureType) {
+        function ConvolutionPostProcess(name, 
+        /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
+        kernel, options, camera, samplingMode, engine, reusable, textureType) {
             if (textureType === void 0) { textureType = BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT; }
             var _this = _super.call(this, name, "convolution", ["kernel", "screenSize"], null, options, camera, samplingMode, engine, reusable, null, textureType) || this;
             _this.kernel = kernel;
@@ -90055,7 +90141,9 @@ var BABYLON;
          * Instantiates a UtilityLayerRenderer
          * @param originalScene the original scene that will be rendered on top of
          */
-        function UtilityLayerRenderer(/** the original scene that will be rendered on top of */ originalScene) {
+        function UtilityLayerRenderer(
+        /** the original scene that will be rendered on top of */
+        originalScene) {
             var _this = this;
             this.originalScene = originalScene;
             this._pointerCaptures = {};
@@ -91067,7 +91155,9 @@ var BABYLON;
          * Creates a gizmo
          * @param gizmoLayer The utility layer the gizmo will be added to
          */
-        function Gizmo(/** The utility layer the gizmo will be added to */ gizmoLayer) {
+        function Gizmo(
+        /** The utility layer the gizmo will be added to */
+        gizmoLayer) {
             if (gizmoLayer === void 0) { gizmoLayer = BABYLON.UtilityLayerRenderer.DefaultUtilityLayer; }
             var _this = this;
             this.gizmoLayer = gizmoLayer;
@@ -94572,7 +94662,9 @@ var BABYLON;
          * @param scene The scene the VRExperienceHelper belongs to.
          * @param webVROptions Options to modify the vr experience helper's behavior.
          */
-        function VRExperienceHelper(scene, /** Options to modify the vr experience helper's behavior. */ webVROptions) {
+        function VRExperienceHelper(scene, 
+        /** Options to modify the vr experience helper's behavior. */
+        webVROptions) {
             if (webVROptions === void 0) { webVROptions = {}; }
             var _this = this;
             this.webVROptions = webVROptions;
@@ -102546,7 +102638,9 @@ var BABYLON;
             if (effect.onBind) {
                 effect.onBind(effect);
             }
-            effect.onBindObservable.notifyObservers(effect);
+            if (effect._onBindObservable) {
+                effect._onBindObservable.notifyObservers(effect);
+            }
         };
         NullEngine.prototype.setState = function (culling, zOffset, force, reverseSide) {
             if (zOffset === void 0) { zOffset = 0; }

+ 146 - 52
dist/preview release/babylon.no-module.max.js

@@ -155,10 +155,6 @@ var BABYLON;
              * Observable that will be called if an error occurs during shader compilation.
              */
             this.onErrorObservable = new BABYLON.Observable();
-            /**
-             * Observable that will be called when effect is bound.
-             */
-            this.onBindObservable = new BABYLON.Observable();
             /** @hidden */
             this._bonesComputationForcedToCPU = false;
             this._uniformBuffersNames = {};
@@ -239,6 +235,19 @@ var BABYLON;
                 });
             });
         }
+        Object.defineProperty(Effect.prototype, "onBindObservable", {
+            /**
+             * Observable that will be called when effect is bound.
+             */
+            get: function () {
+                if (!this._onBindObservable) {
+                    this._onBindObservable = new BABYLON.Observable();
+                }
+                return this._onBindObservable;
+            },
+            enumerable: true,
+            configurable: true
+        });
         Object.defineProperty(Effect.prototype, "key", {
             /**
              * Unique key for this effect
@@ -10449,6 +10458,7 @@ var BABYLON;
         };
         InternalPromise.prototype._moveChildren = function (children) {
             var _this = this;
+            var _a;
             (_a = this._children).push.apply(_a, children.splice(0, children.length));
             this._children.forEach(function (child) {
                 child._parent = _this;
@@ -10465,7 +10475,6 @@ var BABYLON;
                     child._reject(this._reason);
                 }
             }
-            var _a;
         };
         InternalPromise.prototype._resolve = function (value) {
             try {
@@ -13776,7 +13785,7 @@ var BABYLON;
          * @param effect defines the effect to activate
          */
         Engine.prototype.enableEffect = function (effect) {
-            if (!effect) {
+            if (!effect || effect === this._currentEffect) {
                 return;
             }
             // Use program
@@ -13785,7 +13794,9 @@ var BABYLON;
             if (effect.onBind) {
                 effect.onBind(effect);
             }
-            effect.onBindObservable.notifyObservers(effect);
+            if (effect._onBindObservable) {
+                effect._onBindObservable.notifyObservers(effect);
+            }
         };
         /**
          * Set the value of an uniform to an array of int32
@@ -30993,19 +31004,6 @@ var BABYLON;
             if (source === void 0) { source = null; }
             if (clonePhysicsImpostor === void 0) { clonePhysicsImpostor = true; }
             var _this = _super.call(this, name, scene) || this;
-            // Events 
-            /**
-             * An event triggered before rendering the mesh
-             */
-            _this.onBeforeRenderObservable = new BABYLON.Observable();
-            /**
-            * An event triggered after rendering the mesh
-            */
-            _this.onAfterRenderObservable = new BABYLON.Observable();
-            /**
-            * An event triggered before drawing the mesh
-            */
-            _this.onBeforeDrawObservable = new BABYLON.Observable();
             // Members
             _this.delayLoadState = BABYLON.Engine.DELAYLOADSTATE_NONE;
             _this.instances = new Array();
@@ -31028,7 +31026,9 @@ var BABYLON;
                 }
                 // Deep copy
                 BABYLON.Tools.DeepCopy(source, _this, ["name", "material", "skeleton", "instances", "parent", "uniqueId",
-                    "source", "metadata", "hasLODLevels", "geometry", "isBlocked", "areNormalsFrozen"], ["_poseMatrix"]);
+                    "source", "metadata", "hasLODLevels", "geometry", "isBlocked", "areNormalsFrozen",
+                    "onBeforeDrawObservable", "onBeforeRenderObservable", "onAfterRenderObservable", "onBeforeDraw"
+                ], ["_poseMatrix"]);
                 // Source mesh
                 _this._source = source;
                 // Metadata
@@ -31164,6 +31164,45 @@ var BABYLON;
             enumerable: true,
             configurable: true
         });
+        Object.defineProperty(Mesh.prototype, "onBeforeRenderObservable", {
+            /**
+             * An event triggered before rendering the mesh
+             */
+            get: function () {
+                if (!this._onBeforeRenderObservable) {
+                    this._onBeforeRenderObservable = new BABYLON.Observable();
+                }
+                return this._onBeforeRenderObservable;
+            },
+            enumerable: true,
+            configurable: true
+        });
+        Object.defineProperty(Mesh.prototype, "onAfterRenderObservable", {
+            /**
+            * An event triggered after rendering the mesh
+            */
+            get: function () {
+                if (!this._onAfterRenderObservable) {
+                    this._onAfterRenderObservable = new BABYLON.Observable();
+                }
+                return this._onAfterRenderObservable;
+            },
+            enumerable: true,
+            configurable: true
+        });
+        Object.defineProperty(Mesh.prototype, "onBeforeDrawObservable", {
+            /**
+            * An event triggered before drawing the mesh
+            */
+            get: function () {
+                if (!this._onBeforeDrawObservable) {
+                    this._onBeforeDrawObservable = new BABYLON.Observable();
+                }
+                return this._onBeforeDrawObservable;
+            },
+            enumerable: true,
+            configurable: true
+        });
         Object.defineProperty(Mesh.prototype, "onBeforeDraw", {
             set: function (callback) {
                 if (this._onBeforeDrawObserver) {
@@ -31950,7 +31989,9 @@ var BABYLON;
             if (!this._geometry || !this._geometry.getVertexBuffers() || (!this._unIndexed && !this._geometry.getIndexBuffer())) {
                 return this;
             }
-            this.onBeforeDrawObservable.notifyObservers(this);
+            if (this._onBeforeDrawObservable) {
+                this._onBeforeDrawObservable.notifyObservers(this);
+            }
             var scene = this.getScene();
             var engine = scene.getEngine();
             if (this._unIndexed || fillMode == BABYLON.Material.PointFillMode) {
@@ -32133,10 +32174,10 @@ var BABYLON;
          * @returns the current mesh
          */
         Mesh.prototype.render = function (subMesh, enableAlphaMode) {
-            this._checkOcclusionQuery();
-            if (this._isOccluded) {
-                return this;
-            }
+            // this._checkOcclusionQuery();
+            // if (this._isOccluded) {
+            //     return this;
+            // }
             var scene = this.getScene();
             // Managing instances
             var batch = this._getInstancesRenderList(subMesh._id);
@@ -32147,7 +32188,9 @@ var BABYLON;
             if (!this._geometry || !this._geometry.getVertexBuffers() || (!this._unIndexed && !this._geometry.getIndexBuffer())) {
                 return this;
             }
-            this.onBeforeRenderObservable.notifyObservers(this);
+            if (this._onBeforeRenderObservable) {
+                this._onBeforeRenderObservable.notifyObservers(this);
+            }
             var engine = scene.getEngine();
             var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null) && (batch.visibleInstances[subMesh._id] !== undefined);
             // Material
@@ -32231,7 +32274,9 @@ var BABYLON;
                 scene.getOutlineRenderer().render(subMesh, batch, true);
                 engine.setAlphaMode(currentMode);
             }
-            this.onAfterRenderObservable.notifyObservers(this);
+            if (this._onAfterRenderObservable) {
+                this._onAfterRenderObservable.notifyObservers(this);
+            }
             return this;
         };
         Mesh.prototype._onBeforeDraw = function (isInstance, world, effectiveMaterial) {
@@ -32527,6 +32572,15 @@ var BABYLON;
             if (this._geometry) {
                 this._geometry.releaseForMesh(this, true);
             }
+            if (this._onBeforeDrawObservable) {
+                this._onBeforeDrawObservable.clear();
+            }
+            if (this._onBeforeRenderObservable) {
+                this._onBeforeRenderObservable.clear();
+            }
+            if (this._onAfterRenderObservable) {
+                this._onAfterRenderObservable.clear();
+            }
             // Sources
             var meshes = this.getScene().meshes;
             meshes.forEach(function (abstractMesh) {
@@ -34623,14 +34677,6 @@ var BABYLON;
             */
             this.onDisposeObservable = new BABYLON.Observable();
             /**
-            * An event triggered when the material is bound
-            */
-            this.onBindObservable = new BABYLON.Observable();
-            /**
-            * An event triggered when the material is unbound
-            */
-            this.onUnBindObservable = new BABYLON.Observable();
-            /**
              * Stores the value of the alpha mode
              */
             this._alphaMode = BABYLON.Engine.ALPHA_COMBINE;
@@ -34899,6 +34945,19 @@ var BABYLON;
             enumerable: true,
             configurable: true
         });
+        Object.defineProperty(Material.prototype, "onBindObservable", {
+            /**
+            * An event triggered when the material is bound
+            */
+            get: function () {
+                if (!this._onBindObservable) {
+                    this._onBindObservable = new BABYLON.Observable();
+                }
+                return this._onBindObservable;
+            },
+            enumerable: true,
+            configurable: true
+        });
         Object.defineProperty(Material.prototype, "onBind", {
             /**
              * Called during a bind event
@@ -34912,6 +34971,19 @@ var BABYLON;
             enumerable: true,
             configurable: true
         });
+        Object.defineProperty(Material.prototype, "onUnBindObservable", {
+            /**
+            * An event triggered when the material is unbound
+            */
+            get: function () {
+                if (!this._onUnBindObservable) {
+                    this._onUnBindObservable = new BABYLON.Observable();
+                }
+                return this._onUnBindObservable;
+            },
+            enumerable: true,
+            configurable: true
+        });
         Object.defineProperty(Material.prototype, "alphaMode", {
             /**
              * Gets the value of the alpha mode
@@ -35243,8 +35315,8 @@ var BABYLON;
             else {
                 this._scene._cachedVisibility = 1;
             }
-            if (mesh) {
-                this.onBindObservable.notifyObservers(mesh);
+            if (this._onBindObservable && mesh) {
+                this._onBindObservable.notifyObservers(mesh);
             }
             if (this.disableDepthWrite) {
                 var engine = this._scene.getEngine();
@@ -35256,7 +35328,9 @@ var BABYLON;
          * Unbinds the material from the mesh
          */
         Material.prototype.unbind = function () {
-            this.onUnBindObservable.notifyObservers(this);
+            if (this._onUnBindObservable) {
+                this._onUnBindObservable.notifyObservers(this);
+            }
             if (this.disableDepthWrite) {
                 var engine = this._scene.getEngine();
                 engine.setDepthWrite(this._cachedDepthWriteState);
@@ -35506,8 +35580,12 @@ var BABYLON;
             // Callback
             this.onDisposeObservable.notifyObservers(this);
             this.onDisposeObservable.clear();
-            this.onBindObservable.clear();
-            this.onUnBindObservable.clear();
+            if (this._onBindObservable) {
+                this._onBindObservable.clear();
+            }
+            if (this._onUnBindObservable) {
+                this._onUnBindObservable.clear();
+            }
         };
         /**
          * Serializes this material
@@ -41767,7 +41845,7 @@ var BABYLON;
         StandardMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
             if (useInstances === void 0) { useInstances = false; }
             if (subMesh.effect && this.isFrozen) {
-                if (this._wasPreviouslyReady && subMesh.effect) {
+                if (this._wasPreviouslyReady) {
                     return true;
                 }
             }
@@ -67584,7 +67662,9 @@ var BABYLON;
          * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
          * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
          */
-        function PostProcess(/** Name of the PostProcess. */ name, fragmentUrl, parameters, samplers, options, camera, samplingMode, engine, reusable, defines, textureType, vertexUrl, indexParameters, blockCompilation) {
+        function PostProcess(
+        /** Name of the PostProcess. */
+        name, fragmentUrl, parameters, samplers, options, camera, samplingMode, engine, reusable, defines, textureType, vertexUrl, indexParameters, blockCompilation) {
             if (samplingMode === void 0) { samplingMode = BABYLON.Texture.NEAREST_SAMPLINGMODE; }
             if (defines === void 0) { defines = null; }
             if (textureType === void 0) { textureType = BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT; }
@@ -68663,6 +68743,7 @@ var BABYLON;
          */
         ShadowGenerator.prototype.addShadowCaster = function (mesh, includeDescendants) {
             if (includeDescendants === void 0) { includeDescendants = true; }
+            var _a;
             if (!this._shadowMap) {
                 return this;
             }
@@ -68674,7 +68755,6 @@ var BABYLON;
                 (_a = this._shadowMap.renderList).push.apply(_a, mesh.getChildMeshes());
             }
             return this;
-            var _a;
         };
         /**
          * Helper function to remove a mesh and its descendants from the list of shadow casters
@@ -72014,6 +72094,7 @@ var BABYLON;
             return this.subMaterials[index];
         };
         MultiMaterial.prototype.getActiveTextures = function () {
+            var _a;
             return (_a = _super.prototype.getActiveTextures.call(this)).concat.apply(_a, this.subMaterials.map(function (subMaterial) {
                 if (subMaterial) {
                     return subMaterial.getActiveTextures();
@@ -72022,7 +72103,6 @@ var BABYLON;
                     return [];
                 }
             }));
-            var _a;
         };
         // Methods
         MultiMaterial.prototype.getClassName = function () {
@@ -77685,7 +77765,9 @@ var BABYLON;
          * @param textureType Type of textures used when performing the post process. (default: 0)
          * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
          */
-        function BlurPostProcess(name, /** The direction in which to blur the image. */ direction, kernel, options, camera, samplingMode, engine, reusable, textureType, defines, blockCompilation) {
+        function BlurPostProcess(name, 
+        /** The direction in which to blur the image. */
+        direction, kernel, options, camera, samplingMode, engine, reusable, textureType, defines, blockCompilation) {
             if (samplingMode === void 0) { samplingMode = BABYLON.Texture.BILINEAR_SAMPLINGMODE; }
             if (textureType === void 0) { textureType = BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT; }
             if (defines === void 0) { defines = ""; }
@@ -78317,7 +78399,9 @@ var BABYLON;
          * @param textureType Type of textures used when performing the post process. (default: 0)
          * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
          */
-        function BloomMergePostProcess(name, originalFromInput, blurred, /** Weight of the bloom to be added to the original input. */ weight, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
+        function BloomMergePostProcess(name, originalFromInput, blurred, 
+        /** Weight of the bloom to be added to the original input. */
+        weight, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
             if (textureType === void 0) { textureType = BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT; }
             if (blockCompilation === void 0) { blockCompilation = false; }
             var _this = _super.call(this, name, "bloomMerge", ["bloomWeight"], ["circleOfConfusionSampler", "blurStep0", "blurStep1", "blurStep2", "bloomBlur"], options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, true) || this;
@@ -80779,7 +80863,9 @@ var BABYLON;
          * @param reusable If the post process can be reused on the same frame. (default: false)
          * @param textureType Type of textures used when performing the post process. (default: 0)
          */
-        function ConvolutionPostProcess(name, /** Array of 9 values corrisponding to the 3x3 kernel to be applied */ kernel, options, camera, samplingMode, engine, reusable, textureType) {
+        function ConvolutionPostProcess(name, 
+        /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
+        kernel, options, camera, samplingMode, engine, reusable, textureType) {
             if (textureType === void 0) { textureType = BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT; }
             var _this = _super.call(this, name, "convolution", ["kernel", "screenSize"], null, options, camera, samplingMode, engine, reusable, null, textureType) || this;
             _this.kernel = kernel;
@@ -90022,7 +90108,9 @@ var BABYLON;
          * Instantiates a UtilityLayerRenderer
          * @param originalScene the original scene that will be rendered on top of
          */
-        function UtilityLayerRenderer(/** the original scene that will be rendered on top of */ originalScene) {
+        function UtilityLayerRenderer(
+        /** the original scene that will be rendered on top of */
+        originalScene) {
             var _this = this;
             this.originalScene = originalScene;
             this._pointerCaptures = {};
@@ -91034,7 +91122,9 @@ var BABYLON;
          * Creates a gizmo
          * @param gizmoLayer The utility layer the gizmo will be added to
          */
-        function Gizmo(/** The utility layer the gizmo will be added to */ gizmoLayer) {
+        function Gizmo(
+        /** The utility layer the gizmo will be added to */
+        gizmoLayer) {
             if (gizmoLayer === void 0) { gizmoLayer = BABYLON.UtilityLayerRenderer.DefaultUtilityLayer; }
             var _this = this;
             this.gizmoLayer = gizmoLayer;
@@ -94539,7 +94629,9 @@ var BABYLON;
          * @param scene The scene the VRExperienceHelper belongs to.
          * @param webVROptions Options to modify the vr experience helper's behavior.
          */
-        function VRExperienceHelper(scene, /** Options to modify the vr experience helper's behavior. */ webVROptions) {
+        function VRExperienceHelper(scene, 
+        /** Options to modify the vr experience helper's behavior. */
+        webVROptions) {
             if (webVROptions === void 0) { webVROptions = {}; }
             var _this = this;
             this.webVROptions = webVROptions;
@@ -102513,7 +102605,9 @@ var BABYLON;
             if (effect.onBind) {
                 effect.onBind(effect);
             }
-            effect.onBindObservable.notifyObservers(effect);
+            if (effect._onBindObservable) {
+                effect._onBindObservable.notifyObservers(effect);
+            }
         };
         NullEngine.prototype.setState = function (culling, zOffset, force, reverseSide) {
             if (zOffset === void 0) { zOffset = 0; }

Файловите разлики са ограничени, защото са твърде много
+ 60 - 59
dist/preview release/babylon.worker.js


+ 146 - 52
dist/preview release/es6.js

@@ -155,10 +155,6 @@ var BABYLON;
              * Observable that will be called if an error occurs during shader compilation.
              */
             this.onErrorObservable = new BABYLON.Observable();
-            /**
-             * Observable that will be called when effect is bound.
-             */
-            this.onBindObservable = new BABYLON.Observable();
             /** @hidden */
             this._bonesComputationForcedToCPU = false;
             this._uniformBuffersNames = {};
@@ -239,6 +235,19 @@ var BABYLON;
                 });
             });
         }
+        Object.defineProperty(Effect.prototype, "onBindObservable", {
+            /**
+             * Observable that will be called when effect is bound.
+             */
+            get: function () {
+                if (!this._onBindObservable) {
+                    this._onBindObservable = new BABYLON.Observable();
+                }
+                return this._onBindObservable;
+            },
+            enumerable: true,
+            configurable: true
+        });
         Object.defineProperty(Effect.prototype, "key", {
             /**
              * Unique key for this effect
@@ -10449,6 +10458,7 @@ var BABYLON;
         };
         InternalPromise.prototype._moveChildren = function (children) {
             var _this = this;
+            var _a;
             (_a = this._children).push.apply(_a, children.splice(0, children.length));
             this._children.forEach(function (child) {
                 child._parent = _this;
@@ -10465,7 +10475,6 @@ var BABYLON;
                     child._reject(this._reason);
                 }
             }
-            var _a;
         };
         InternalPromise.prototype._resolve = function (value) {
             try {
@@ -13776,7 +13785,7 @@ var BABYLON;
          * @param effect defines the effect to activate
          */
         Engine.prototype.enableEffect = function (effect) {
-            if (!effect) {
+            if (!effect || effect === this._currentEffect) {
                 return;
             }
             // Use program
@@ -13785,7 +13794,9 @@ var BABYLON;
             if (effect.onBind) {
                 effect.onBind(effect);
             }
-            effect.onBindObservable.notifyObservers(effect);
+            if (effect._onBindObservable) {
+                effect._onBindObservable.notifyObservers(effect);
+            }
         };
         /**
          * Set the value of an uniform to an array of int32
@@ -30993,19 +31004,6 @@ var BABYLON;
             if (source === void 0) { source = null; }
             if (clonePhysicsImpostor === void 0) { clonePhysicsImpostor = true; }
             var _this = _super.call(this, name, scene) || this;
-            // Events 
-            /**
-             * An event triggered before rendering the mesh
-             */
-            _this.onBeforeRenderObservable = new BABYLON.Observable();
-            /**
-            * An event triggered after rendering the mesh
-            */
-            _this.onAfterRenderObservable = new BABYLON.Observable();
-            /**
-            * An event triggered before drawing the mesh
-            */
-            _this.onBeforeDrawObservable = new BABYLON.Observable();
             // Members
             _this.delayLoadState = BABYLON.Engine.DELAYLOADSTATE_NONE;
             _this.instances = new Array();
@@ -31028,7 +31026,9 @@ var BABYLON;
                 }
                 // Deep copy
                 BABYLON.Tools.DeepCopy(source, _this, ["name", "material", "skeleton", "instances", "parent", "uniqueId",
-                    "source", "metadata", "hasLODLevels", "geometry", "isBlocked", "areNormalsFrozen"], ["_poseMatrix"]);
+                    "source", "metadata", "hasLODLevels", "geometry", "isBlocked", "areNormalsFrozen",
+                    "onBeforeDrawObservable", "onBeforeRenderObservable", "onAfterRenderObservable", "onBeforeDraw"
+                ], ["_poseMatrix"]);
                 // Source mesh
                 _this._source = source;
                 // Metadata
@@ -31164,6 +31164,45 @@ var BABYLON;
             enumerable: true,
             configurable: true
         });
+        Object.defineProperty(Mesh.prototype, "onBeforeRenderObservable", {
+            /**
+             * An event triggered before rendering the mesh
+             */
+            get: function () {
+                if (!this._onBeforeRenderObservable) {
+                    this._onBeforeRenderObservable = new BABYLON.Observable();
+                }
+                return this._onBeforeRenderObservable;
+            },
+            enumerable: true,
+            configurable: true
+        });
+        Object.defineProperty(Mesh.prototype, "onAfterRenderObservable", {
+            /**
+            * An event triggered after rendering the mesh
+            */
+            get: function () {
+                if (!this._onAfterRenderObservable) {
+                    this._onAfterRenderObservable = new BABYLON.Observable();
+                }
+                return this._onAfterRenderObservable;
+            },
+            enumerable: true,
+            configurable: true
+        });
+        Object.defineProperty(Mesh.prototype, "onBeforeDrawObservable", {
+            /**
+            * An event triggered before drawing the mesh
+            */
+            get: function () {
+                if (!this._onBeforeDrawObservable) {
+                    this._onBeforeDrawObservable = new BABYLON.Observable();
+                }
+                return this._onBeforeDrawObservable;
+            },
+            enumerable: true,
+            configurable: true
+        });
         Object.defineProperty(Mesh.prototype, "onBeforeDraw", {
             set: function (callback) {
                 if (this._onBeforeDrawObserver) {
@@ -31950,7 +31989,9 @@ var BABYLON;
             if (!this._geometry || !this._geometry.getVertexBuffers() || (!this._unIndexed && !this._geometry.getIndexBuffer())) {
                 return this;
             }
-            this.onBeforeDrawObservable.notifyObservers(this);
+            if (this._onBeforeDrawObservable) {
+                this._onBeforeDrawObservable.notifyObservers(this);
+            }
             var scene = this.getScene();
             var engine = scene.getEngine();
             if (this._unIndexed || fillMode == BABYLON.Material.PointFillMode) {
@@ -32133,10 +32174,10 @@ var BABYLON;
          * @returns the current mesh
          */
         Mesh.prototype.render = function (subMesh, enableAlphaMode) {
-            this._checkOcclusionQuery();
-            if (this._isOccluded) {
-                return this;
-            }
+            // this._checkOcclusionQuery();
+            // if (this._isOccluded) {
+            //     return this;
+            // }
             var scene = this.getScene();
             // Managing instances
             var batch = this._getInstancesRenderList(subMesh._id);
@@ -32147,7 +32188,9 @@ var BABYLON;
             if (!this._geometry || !this._geometry.getVertexBuffers() || (!this._unIndexed && !this._geometry.getIndexBuffer())) {
                 return this;
             }
-            this.onBeforeRenderObservable.notifyObservers(this);
+            if (this._onBeforeRenderObservable) {
+                this._onBeforeRenderObservable.notifyObservers(this);
+            }
             var engine = scene.getEngine();
             var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null) && (batch.visibleInstances[subMesh._id] !== undefined);
             // Material
@@ -32231,7 +32274,9 @@ var BABYLON;
                 scene.getOutlineRenderer().render(subMesh, batch, true);
                 engine.setAlphaMode(currentMode);
             }
-            this.onAfterRenderObservable.notifyObservers(this);
+            if (this._onAfterRenderObservable) {
+                this._onAfterRenderObservable.notifyObservers(this);
+            }
             return this;
         };
         Mesh.prototype._onBeforeDraw = function (isInstance, world, effectiveMaterial) {
@@ -32527,6 +32572,15 @@ var BABYLON;
             if (this._geometry) {
                 this._geometry.releaseForMesh(this, true);
             }
+            if (this._onBeforeDrawObservable) {
+                this._onBeforeDrawObservable.clear();
+            }
+            if (this._onBeforeRenderObservable) {
+                this._onBeforeRenderObservable.clear();
+            }
+            if (this._onAfterRenderObservable) {
+                this._onAfterRenderObservable.clear();
+            }
             // Sources
             var meshes = this.getScene().meshes;
             meshes.forEach(function (abstractMesh) {
@@ -34623,14 +34677,6 @@ var BABYLON;
             */
             this.onDisposeObservable = new BABYLON.Observable();
             /**
-            * An event triggered when the material is bound
-            */
-            this.onBindObservable = new BABYLON.Observable();
-            /**
-            * An event triggered when the material is unbound
-            */
-            this.onUnBindObservable = new BABYLON.Observable();
-            /**
              * Stores the value of the alpha mode
              */
             this._alphaMode = BABYLON.Engine.ALPHA_COMBINE;
@@ -34899,6 +34945,19 @@ var BABYLON;
             enumerable: true,
             configurable: true
         });
+        Object.defineProperty(Material.prototype, "onBindObservable", {
+            /**
+            * An event triggered when the material is bound
+            */
+            get: function () {
+                if (!this._onBindObservable) {
+                    this._onBindObservable = new BABYLON.Observable();
+                }
+                return this._onBindObservable;
+            },
+            enumerable: true,
+            configurable: true
+        });
         Object.defineProperty(Material.prototype, "onBind", {
             /**
              * Called during a bind event
@@ -34912,6 +34971,19 @@ var BABYLON;
             enumerable: true,
             configurable: true
         });
+        Object.defineProperty(Material.prototype, "onUnBindObservable", {
+            /**
+            * An event triggered when the material is unbound
+            */
+            get: function () {
+                if (!this._onUnBindObservable) {
+                    this._onUnBindObservable = new BABYLON.Observable();
+                }
+                return this._onUnBindObservable;
+            },
+            enumerable: true,
+            configurable: true
+        });
         Object.defineProperty(Material.prototype, "alphaMode", {
             /**
              * Gets the value of the alpha mode
@@ -35243,8 +35315,8 @@ var BABYLON;
             else {
                 this._scene._cachedVisibility = 1;
             }
-            if (mesh) {
-                this.onBindObservable.notifyObservers(mesh);
+            if (this._onBindObservable && mesh) {
+                this._onBindObservable.notifyObservers(mesh);
             }
             if (this.disableDepthWrite) {
                 var engine = this._scene.getEngine();
@@ -35256,7 +35328,9 @@ var BABYLON;
          * Unbinds the material from the mesh
          */
         Material.prototype.unbind = function () {
-            this.onUnBindObservable.notifyObservers(this);
+            if (this._onUnBindObservable) {
+                this._onUnBindObservable.notifyObservers(this);
+            }
             if (this.disableDepthWrite) {
                 var engine = this._scene.getEngine();
                 engine.setDepthWrite(this._cachedDepthWriteState);
@@ -35506,8 +35580,12 @@ var BABYLON;
             // Callback
             this.onDisposeObservable.notifyObservers(this);
             this.onDisposeObservable.clear();
-            this.onBindObservable.clear();
-            this.onUnBindObservable.clear();
+            if (this._onBindObservable) {
+                this._onBindObservable.clear();
+            }
+            if (this._onUnBindObservable) {
+                this._onUnBindObservable.clear();
+            }
         };
         /**
          * Serializes this material
@@ -41767,7 +41845,7 @@ var BABYLON;
         StandardMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
             if (useInstances === void 0) { useInstances = false; }
             if (subMesh.effect && this.isFrozen) {
-                if (this._wasPreviouslyReady && subMesh.effect) {
+                if (this._wasPreviouslyReady) {
                     return true;
                 }
             }
@@ -67584,7 +67662,9 @@ var BABYLON;
          * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
          * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
          */
-        function PostProcess(/** Name of the PostProcess. */ name, fragmentUrl, parameters, samplers, options, camera, samplingMode, engine, reusable, defines, textureType, vertexUrl, indexParameters, blockCompilation) {
+        function PostProcess(
+        /** Name of the PostProcess. */
+        name, fragmentUrl, parameters, samplers, options, camera, samplingMode, engine, reusable, defines, textureType, vertexUrl, indexParameters, blockCompilation) {
             if (samplingMode === void 0) { samplingMode = BABYLON.Texture.NEAREST_SAMPLINGMODE; }
             if (defines === void 0) { defines = null; }
             if (textureType === void 0) { textureType = BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT; }
@@ -68663,6 +68743,7 @@ var BABYLON;
          */
         ShadowGenerator.prototype.addShadowCaster = function (mesh, includeDescendants) {
             if (includeDescendants === void 0) { includeDescendants = true; }
+            var _a;
             if (!this._shadowMap) {
                 return this;
             }
@@ -68674,7 +68755,6 @@ var BABYLON;
                 (_a = this._shadowMap.renderList).push.apply(_a, mesh.getChildMeshes());
             }
             return this;
-            var _a;
         };
         /**
          * Helper function to remove a mesh and its descendants from the list of shadow casters
@@ -72014,6 +72094,7 @@ var BABYLON;
             return this.subMaterials[index];
         };
         MultiMaterial.prototype.getActiveTextures = function () {
+            var _a;
             return (_a = _super.prototype.getActiveTextures.call(this)).concat.apply(_a, this.subMaterials.map(function (subMaterial) {
                 if (subMaterial) {
                     return subMaterial.getActiveTextures();
@@ -72022,7 +72103,6 @@ var BABYLON;
                     return [];
                 }
             }));
-            var _a;
         };
         // Methods
         MultiMaterial.prototype.getClassName = function () {
@@ -77685,7 +77765,9 @@ var BABYLON;
          * @param textureType Type of textures used when performing the post process. (default: 0)
          * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
          */
-        function BlurPostProcess(name, /** The direction in which to blur the image. */ direction, kernel, options, camera, samplingMode, engine, reusable, textureType, defines, blockCompilation) {
+        function BlurPostProcess(name, 
+        /** The direction in which to blur the image. */
+        direction, kernel, options, camera, samplingMode, engine, reusable, textureType, defines, blockCompilation) {
             if (samplingMode === void 0) { samplingMode = BABYLON.Texture.BILINEAR_SAMPLINGMODE; }
             if (textureType === void 0) { textureType = BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT; }
             if (defines === void 0) { defines = ""; }
@@ -78317,7 +78399,9 @@ var BABYLON;
          * @param textureType Type of textures used when performing the post process. (default: 0)
          * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
          */
-        function BloomMergePostProcess(name, originalFromInput, blurred, /** Weight of the bloom to be added to the original input. */ weight, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
+        function BloomMergePostProcess(name, originalFromInput, blurred, 
+        /** Weight of the bloom to be added to the original input. */
+        weight, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
             if (textureType === void 0) { textureType = BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT; }
             if (blockCompilation === void 0) { blockCompilation = false; }
             var _this = _super.call(this, name, "bloomMerge", ["bloomWeight"], ["circleOfConfusionSampler", "blurStep0", "blurStep1", "blurStep2", "bloomBlur"], options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, true) || this;
@@ -80779,7 +80863,9 @@ var BABYLON;
          * @param reusable If the post process can be reused on the same frame. (default: false)
          * @param textureType Type of textures used when performing the post process. (default: 0)
          */
-        function ConvolutionPostProcess(name, /** Array of 9 values corrisponding to the 3x3 kernel to be applied */ kernel, options, camera, samplingMode, engine, reusable, textureType) {
+        function ConvolutionPostProcess(name, 
+        /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
+        kernel, options, camera, samplingMode, engine, reusable, textureType) {
             if (textureType === void 0) { textureType = BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT; }
             var _this = _super.call(this, name, "convolution", ["kernel", "screenSize"], null, options, camera, samplingMode, engine, reusable, null, textureType) || this;
             _this.kernel = kernel;
@@ -90022,7 +90108,9 @@ var BABYLON;
          * Instantiates a UtilityLayerRenderer
          * @param originalScene the original scene that will be rendered on top of
          */
-        function UtilityLayerRenderer(/** the original scene that will be rendered on top of */ originalScene) {
+        function UtilityLayerRenderer(
+        /** the original scene that will be rendered on top of */
+        originalScene) {
             var _this = this;
             this.originalScene = originalScene;
             this._pointerCaptures = {};
@@ -91034,7 +91122,9 @@ var BABYLON;
          * Creates a gizmo
          * @param gizmoLayer The utility layer the gizmo will be added to
          */
-        function Gizmo(/** The utility layer the gizmo will be added to */ gizmoLayer) {
+        function Gizmo(
+        /** The utility layer the gizmo will be added to */
+        gizmoLayer) {
             if (gizmoLayer === void 0) { gizmoLayer = BABYLON.UtilityLayerRenderer.DefaultUtilityLayer; }
             var _this = this;
             this.gizmoLayer = gizmoLayer;
@@ -94539,7 +94629,9 @@ var BABYLON;
          * @param scene The scene the VRExperienceHelper belongs to.
          * @param webVROptions Options to modify the vr experience helper's behavior.
          */
-        function VRExperienceHelper(scene, /** Options to modify the vr experience helper's behavior. */ webVROptions) {
+        function VRExperienceHelper(scene, 
+        /** Options to modify the vr experience helper's behavior. */
+        webVROptions) {
             if (webVROptions === void 0) { webVROptions = {}; }
             var _this = this;
             this.webVROptions = webVROptions;
@@ -102513,7 +102605,9 @@ var BABYLON;
             if (effect.onBind) {
                 effect.onBind(effect);
             }
-            effect.onBindObservable.notifyObservers(effect);
+            if (effect._onBindObservable) {
+                effect._onBindObservable.notifyObservers(effect);
+            }
         };
         NullEngine.prototype.setState = function (culling, zOffset, force, reverseSide) {
             if (zOffset === void 0) { zOffset = 0; }

Файловите разлики са ограничени, защото са твърде много
+ 1 - 1
dist/preview release/gui/babylon.gui.min.js


Файловите разлики са ограничени, защото са твърде много
+ 1 - 1
dist/preview release/gui/babylon.gui.min.js.map


Файловите разлики са ограничени, защото са твърде много
+ 1 - 1
dist/preview release/inspector/babylon.inspector.bundle.js


Файловите разлики са ограничени, защото са твърде много
+ 1 - 1
dist/preview release/inspector/babylon.inspector.bundle.js.map


+ 45 - 34
dist/preview release/loaders/babylon.glTF1FileLoader.d.ts

@@ -11,7 +11,7 @@ declare module BABYLON {
         /**
          * Sets the useRightHandedSystem flag on the scene.
          */
-        FORCE_RIGHT_HANDED = 1,
+        FORCE_RIGHT_HANDED = 1
     }
     /**
      * Mode that determines what animations will start.
@@ -28,7 +28,7 @@ declare module BABYLON {
         /**
          * All animations will start.
          */
-        ALL = 2,
+        ALL = 2
     }
     /**
      * Interface that contains the data for the glTF asset.
@@ -71,7 +71,7 @@ declare module BABYLON {
         /**
          * The asset is completely loaded.
          */
-        COMPLETE = 2,
+        COMPLETE = 2
     }
     /** @hidden */
     interface IGLTFLoader extends IDisposable {
@@ -191,9 +191,20 @@ declare module BABYLON {
         private _onCompleteObserver;
         /**
          * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
+         * For assets with LODs, raised when all of the LODs are complete.
+         * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
          */
         onComplete: () => void;
         /**
+         * Observable raised when an error occurs.
+         */
+        readonly onErrorObservable: Observable<any>;
+        private _onErrorObserver;
+        /**
+         * Callback raised when an error occurs.
+         */
+        onError: (reason: any) => void;
+        /**
          * Observable raised after the loader is disposed.
          */
         readonly onDisposeObservable: Observable<void>;
@@ -292,14 +303,14 @@ declare module BABYLON {
          * @returns the created plugin
          */
         createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
-        private _parse(data);
-        private _getLoader(loaderData);
-        private _parseBinary(data);
-        private _parseV1(binaryReader);
-        private _parseV2(binaryReader);
-        private static _parseVersion(version);
-        private static _compareVersion(a, b);
-        private static _decodeBufferToText(buffer);
+        private _parse;
+        private _getLoader;
+        private _parseBinary;
+        private _parseV1;
+        private _parseV2;
+        private static _parseVersion;
+        private static _compareVersion;
+        private static _decodeBufferToText;
         private static readonly _logSpaces;
         private _logIndentLevel;
         private _loggingEnabled;
@@ -309,17 +320,17 @@ declare module BABYLON {
         _logOpen(message: string): void;
         /** @hidden */
         _logClose(): void;
-        private _logEnabled(message);
-        private _logDisabled(message);
+        private _logEnabled;
+        private _logDisabled;
         private _capturePerformanceCounters;
         /** @hidden */
         _startPerformanceCounter: (counterName: string) => void;
         /** @hidden */
         _endPerformanceCounter: (counterName: string) => void;
-        private _startPerformanceCounterEnabled(counterName);
-        private _startPerformanceCounterDisabled(counterName);
-        private _endPerformanceCounterEnabled(counterName);
-        private _endPerformanceCounterDisabled(counterName);
+        private _startPerformanceCounterEnabled;
+        private _startPerformanceCounterDisabled;
+        private _endPerformanceCounterEnabled;
+        private _endPerformanceCounterDisabled;
     }
 }
 
@@ -333,11 +344,11 @@ declare module BABYLON.GLTF1 {
         UNSIGNED_BYTE = 5121,
         SHORT = 5122,
         UNSIGNED_SHORT = 5123,
-        FLOAT = 5126,
+        FLOAT = 5126
     }
     enum EShaderType {
         FRAGMENT = 35632,
-        VERTEX = 35633,
+        VERTEX = 35633
     }
     enum EParameterType {
         BYTE = 5120,
@@ -360,12 +371,12 @@ declare module BABYLON.GLTF1 {
         FLOAT_MAT2 = 35674,
         FLOAT_MAT3 = 35675,
         FLOAT_MAT4 = 35676,
-        SAMPLER_2D = 35678,
+        SAMPLER_2D = 35678
     }
     enum ETextureWrapMode {
         CLAMP_TO_EDGE = 33071,
         MIRRORED_REPEAT = 33648,
-        REPEAT = 10497,
+        REPEAT = 10497
     }
     enum ETextureFilterType {
         NEAREST = 9728,
@@ -373,19 +384,19 @@ declare module BABYLON.GLTF1 {
         NEAREST_MIPMAP_NEAREST = 9984,
         LINEAR_MIPMAP_NEAREST = 9985,
         NEAREST_MIPMAP_LINEAR = 9986,
-        LINEAR_MIPMAP_LINEAR = 9987,
+        LINEAR_MIPMAP_LINEAR = 9987
     }
     enum ETextureFormat {
         ALPHA = 6406,
         RGB = 6407,
         RGBA = 6408,
         LUMINANCE = 6409,
-        LUMINANCE_ALPHA = 6410,
+        LUMINANCE_ALPHA = 6410
     }
     enum ECullingType {
         FRONT = 1028,
         BACK = 1029,
-        FRONT_AND_BACK = 1032,
+        FRONT_AND_BACK = 1032
     }
     enum EBlendingFunction {
         ZERO = 0,
@@ -402,7 +413,7 @@ declare module BABYLON.GLTF1 {
         ONE_MINUS_CONSTANT_COLOR = 32770,
         CONSTANT_ALPHA = 32771,
         ONE_MINUS_CONSTANT_ALPHA = 32772,
-        SRC_ALPHA_SATURATE = 776,
+        SRC_ALPHA_SATURATE = 776
     }
     /**
     * Interfaces
@@ -718,7 +729,7 @@ declare module BABYLON.GLTF1 {
         static RegisterExtension(extension: GLTFLoaderExtension): void;
         state: Nullable<GLTFLoaderState>;
         dispose(): void;
-        private _importMeshAsync(meshesNames, scene, data, rootUrl, onSuccess, onProgress?, onError?);
+        private _importMeshAsync;
         /**
         * Imports one or more meshes from a loaded gltf file and adds them to the scene
         * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
@@ -734,7 +745,7 @@ declare module BABYLON.GLTF1 {
             skeletons: Skeleton[];
             animationGroups: AnimationGroup[];
         }>;
-        private _loadAsync(scene, data, rootUrl, onSuccess, onProgress?, onError?);
+        private _loadAsync;
         /**
         * Imports all objects from a loaded gltf file and adds them to the scene
         * @param scene the scene the objects should be added to
@@ -744,9 +755,9 @@ declare module BABYLON.GLTF1 {
         * @returns a promise which completes when objects have been loaded to the scene
         */
         loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
-        private _loadShadersAsync(gltfRuntime, onload);
-        private _loadBuffersAsync(gltfRuntime, onLoad, onProgress?);
-        private _createNodes(gltfRuntime);
+        private _loadShadersAsync;
+        private _loadBuffersAsync;
+        private _createNodes;
     }
 }
 
@@ -857,9 +868,9 @@ declare module BABYLON.GLTF1 {
         static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
         static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
         static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
-        private static LoadTextureBufferAsync(gltfRuntime, id, onSuccess, onError);
-        private static CreateTextureAsync(gltfRuntime, id, buffer, onSuccess, onError);
-        private static ApplyExtensions(func, defaultFunc);
+        private static LoadTextureBufferAsync;
+        private static CreateTextureAsync;
+        private static ApplyExtensions;
     }
 }
 
@@ -881,6 +892,6 @@ declare module BABYLON.GLTF1 {
         constructor();
         loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
         loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
-        private _loadTexture(gltfRuntime, id, material, propertyPath, onError);
+        private _loadTexture;
     }
 }

+ 23 - 1
dist/preview release/loaders/babylon.glTF1FileLoader.js

@@ -118,6 +118,10 @@ var BABYLON;
              */
             this.onCompleteObservable = new BABYLON.Observable();
             /**
+             * Observable raised when an error occurs.
+             */
+            this.onErrorObservable = new BABYLON.Observable();
+            /**
              * Observable raised after the loader is disposed.
              */
             this.onDisposeObservable = new BABYLON.Observable();
@@ -217,6 +221,8 @@ var BABYLON;
         Object.defineProperty(GLTFFileLoader.prototype, "onComplete", {
             /**
              * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
+             * For assets with LODs, raised when all of the LODs are complete.
+             * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
              */
             set: function (callback) {
                 if (this._onCompleteObserver) {
@@ -227,6 +233,19 @@ var BABYLON;
             enumerable: true,
             configurable: true
         });
+        Object.defineProperty(GLTFFileLoader.prototype, "onError", {
+            /**
+             * Callback raised when an error occurs.
+             */
+            set: function (callback) {
+                if (this._onErrorObserver) {
+                    this.onErrorObservable.remove(this._onErrorObserver);
+                }
+                this._onErrorObserver = this.onErrorObservable.add(callback);
+            },
+            enumerable: true,
+            configurable: true
+        });
         Object.defineProperty(GLTFFileLoader.prototype, "onDispose", {
             /**
              * Callback raised after the loader is disposed.
@@ -259,10 +278,13 @@ var BABYLON;
          */
         GLTFFileLoader.prototype.whenCompleteAsync = function () {
             var _this = this;
-            return new Promise(function (resolve) {
+            return new Promise(function (resolve, reject) {
                 _this.onCompleteObservable.addOnce(function () {
                     resolve();
                 });
+                _this.onErrorObservable.addOnce(function (reason) {
+                    reject(reason);
+                });
             });
         };
         Object.defineProperty(GLTFFileLoader.prototype, "loaderState", {

Файловите разлики са ограничени, защото са твърде много
+ 2 - 2
dist/preview release/loaders/babylon.glTF1FileLoader.min.js


+ 106 - 76
dist/preview release/loaders/babylon.glTF2FileLoader.d.ts

@@ -11,7 +11,7 @@ declare module BABYLON {
         /**
          * Sets the useRightHandedSystem flag on the scene.
          */
-        FORCE_RIGHT_HANDED = 1,
+        FORCE_RIGHT_HANDED = 1
     }
     /**
      * Mode that determines what animations will start.
@@ -28,7 +28,7 @@ declare module BABYLON {
         /**
          * All animations will start.
          */
-        ALL = 2,
+        ALL = 2
     }
     /**
      * Interface that contains the data for the glTF asset.
@@ -71,7 +71,7 @@ declare module BABYLON {
         /**
          * The asset is completely loaded.
          */
-        COMPLETE = 2,
+        COMPLETE = 2
     }
     /** @hidden */
     interface IGLTFLoader extends IDisposable {
@@ -191,9 +191,20 @@ declare module BABYLON {
         private _onCompleteObserver;
         /**
          * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
+         * For assets with LODs, raised when all of the LODs are complete.
+         * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
          */
         onComplete: () => void;
         /**
+         * Observable raised when an error occurs.
+         */
+        readonly onErrorObservable: Observable<any>;
+        private _onErrorObserver;
+        /**
+         * Callback raised when an error occurs.
+         */
+        onError: (reason: any) => void;
+        /**
          * Observable raised after the loader is disposed.
          */
         readonly onDisposeObservable: Observable<void>;
@@ -292,14 +303,14 @@ declare module BABYLON {
          * @returns the created plugin
          */
         createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
-        private _parse(data);
-        private _getLoader(loaderData);
-        private _parseBinary(data);
-        private _parseV1(binaryReader);
-        private _parseV2(binaryReader);
-        private static _parseVersion(version);
-        private static _compareVersion(a, b);
-        private static _decodeBufferToText(buffer);
+        private _parse;
+        private _getLoader;
+        private _parseBinary;
+        private _parseV1;
+        private _parseV2;
+        private static _parseVersion;
+        private static _compareVersion;
+        private static _decodeBufferToText;
         private static readonly _logSpaces;
         private _logIndentLevel;
         private _loggingEnabled;
@@ -309,17 +320,17 @@ declare module BABYLON {
         _logOpen(message: string): void;
         /** @hidden */
         _logClose(): void;
-        private _logEnabled(message);
-        private _logDisabled(message);
+        private _logEnabled;
+        private _logDisabled;
         private _capturePerformanceCounters;
         /** @hidden */
         _startPerformanceCounter: (counterName: string) => void;
         /** @hidden */
         _endPerformanceCounter: (counterName: string) => void;
-        private _startPerformanceCounterEnabled(counterName);
-        private _startPerformanceCounterDisabled(counterName);
-        private _endPerformanceCounterEnabled(counterName);
-        private _endPerformanceCounterDisabled(counterName);
+        private _startPerformanceCounterEnabled;
+        private _startPerformanceCounterDisabled;
+        private _endPerformanceCounterEnabled;
+        private _endPerformanceCounterDisabled;
     }
 }
 
@@ -449,7 +460,6 @@ declare module BABYLON.GLTF2 {
         _parent: GLTFFileLoader;
         _gltf: _ILoaderGLTF;
         _babylonScene: Scene;
-        _readyPromise: Promise<void>;
         _completePromises: Promise<void>[];
         private _disposed;
         private _state;
@@ -463,9 +473,6 @@ declare module BABYLON.GLTF2 {
         private static _ExtensionNames;
         private static _ExtensionFactories;
         static _Register(name: string, factory: (loader: GLTFLoader) => GLTFLoaderExtension): void;
-        /**
-         * Loader state or null if the loader is not active.
-         */
         readonly state: Nullable<GLTFLoaderState>;
         constructor(parent: GLTFFileLoader);
         dispose(): void;
@@ -476,45 +483,46 @@ declare module BABYLON.GLTF2 {
             animationGroups: AnimationGroup[];
         }>;
         loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
-        private _loadAsync(nodes);
-        private _loadData(data);
-        private _setupData();
-        private _loadExtensions();
-        private _checkExtensions();
-        private _createRootNode();
+        private _loadAsync;
+        private _loadData;
+        private _setupData;
+        private _loadExtensions;
+        private _checkExtensions;
+        private _setState;
+        private _createRootNode;
         _loadSceneAsync(context: string, scene: _ILoaderScene): Promise<void>;
-        private _forEachPrimitive(node, callback);
-        private _getMeshes();
-        private _getSkeletons();
-        private _getAnimationGroups();
-        private _startAnimations();
+        private _forEachPrimitive;
+        private _getMeshes;
+        private _getSkeletons;
+        private _getAnimationGroups;
+        private _startAnimations;
         _loadNodeAsync(context: string, node: _ILoaderNode): Promise<void>;
-        private _loadMeshAsync(context, node, mesh, babylonMesh);
-        private _loadPrimitiveAsync(context, node, mesh, primitive, babylonMesh);
-        private _loadVertexDataAsync(context, primitive, babylonMesh);
-        private _createMorphTargets(context, node, mesh, primitive, babylonMesh);
-        private _loadMorphTargetsAsync(context, primitive, babylonMesh, babylonGeometry);
-        private _loadMorphTargetVertexDataAsync(context, babylonGeometry, attributes, babylonMorphTarget);
-        private static _LoadTransform(node, babylonNode);
-        private _loadSkinAsync(context, node, mesh, skin);
-        private _loadBones(context, skin);
-        private _loadBone(node, skin, babylonBones);
-        private _loadSkinInverseBindMatricesDataAsync(context, skin);
-        private _updateBoneMatrices(babylonSkeleton, inverseBindMatricesData);
-        private _getNodeMatrix(node);
-        private _loadCamera(context, camera, babylonMesh);
-        private _loadAnimationsAsync();
-        private _loadAnimationAsync(context, animation);
-        private _loadAnimationChannelAsync(context, animationContext, animation, channel, babylonAnimationGroup);
-        private _loadAnimationSamplerAsync(context, sampler);
-        private _loadBufferAsync(context, buffer);
+        private _loadMeshAsync;
+        private _loadPrimitiveAsync;
+        private _loadVertexDataAsync;
+        private _createMorphTargets;
+        private _loadMorphTargetsAsync;
+        private _loadMorphTargetVertexDataAsync;
+        private static _LoadTransform;
+        private _loadSkinAsync;
+        private _loadBones;
+        private _loadBone;
+        private _loadSkinInverseBindMatricesDataAsync;
+        private _updateBoneMatrices;
+        private _getNodeMatrix;
+        private _loadCamera;
+        private _loadAnimationsAsync;
+        private _loadAnimationAsync;
+        private _loadAnimationChannelAsync;
+        private _loadAnimationSamplerAsync;
+        private _loadBufferAsync;
         _loadBufferViewAsync(context: string, bufferView: _ILoaderBufferView): Promise<ArrayBufferView>;
-        private _loadIndicesAccessorAsync(context, accessor);
-        private _loadFloatAccessorAsync(context, accessor);
+        private _loadIndicesAccessorAsync;
+        private _loadFloatAccessorAsync;
         _loadVertexBufferViewAsync(context: string, bufferView: _ILoaderBufferView, kind: string): Promise<Buffer>;
-        private _loadVertexAccessorAsync(context, accessor, kind);
-        private _getDefaultMaterial(drawMode);
-        private _loadMaterialMetallicRoughnessPropertiesAsync(context, material, babylonMaterial);
+        private _loadVertexAccessorAsync;
+        private _getDefaultMaterial;
+        private _loadMaterialMetallicRoughnessPropertiesAsync;
         _loadMaterialAsync(context: string, material: _ILoaderMaterial, mesh: _ILoaderMesh, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Promise<void>;
         _loadMaterialPropertiesAsync(context: string, material: _ILoaderMaterial, babylonMaterial: Material): Promise<void>;
         _createMaterial(name: string, drawMode: number): PBRMaterial;
@@ -522,20 +530,21 @@ declare module BABYLON.GLTF2 {
         _loadMaterialAlphaProperties(context: string, material: _ILoaderMaterial, babylonMaterial: PBRMaterial): void;
         _loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: Texture) => void): Promise<void>;
         _loadTextureAsync(context: string, texture: _ILoaderTexture, assign: (babylonTexture: Texture) => void): Promise<void>;
-        private _loadSampler(context, sampler);
+        private _loadSampler;
         _loadImageAsync(context: string, image: _ILoaderImage): Promise<ArrayBufferView>;
         _loadUriAsync(context: string, uri: string): Promise<ArrayBufferView>;
-        private _onProgress();
+        private _onProgress;
         static _GetProperty<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
-        private static _GetTextureWrapMode(context, mode);
-        private static _GetTextureSamplingMode(context, magFilter?, minFilter?);
-        private static _GetTypedArray(context, componentType, bufferView, byteOffset, length);
-        private static _GetNumComponents(context, type);
-        private static _ValidateUri(uri);
-        private static _GetDrawMode(context, mode);
-        private _compileMaterialsAsync();
-        private _compileShadowGeneratorsAsync();
+        private static _GetTextureWrapMode;
+        private static _GetTextureSamplingMode;
+        private static _GetTypedArray;
+        private static _GetNumComponents;
+        private static _ValidateUri;
+        private static _GetDrawMode;
+        private _compileMaterialsAsync;
+        private _compileShadowGeneratorsAsync;
         _applyExtensions<T>(actionAsync: (extension: GLTFLoaderExtension) => Nullable<Promise<T>>): Nullable<Promise<T>>;
+        _forEachExtensions(action: (extension: GLTFLoaderExtension) => void): void;
     }
 }
 
@@ -552,7 +561,7 @@ declare module BABYLON.GLTF2 {
         /**
          * Gets or sets extension name
          */
-        readonly abstract name: string;
+        abstract readonly name: string;
         protected _loader: GLTFLoader;
         /**
          * Creates new GLTFLoaderExtension
@@ -564,6 +573,14 @@ declare module BABYLON.GLTF2 {
          */
         dispose(): void;
         /**
+         * Override this method to do work after the state changes to LOADING.
+         */
+        protected _onLoading(): void;
+        /**
+         * Override this method to do work after the state changes to READY.
+         */
+        protected _onReady(): void;
+        /**
          * Override this method to modify the default behavior for loading scenes.
          * @hidden
          */
@@ -614,6 +631,16 @@ declare module BABYLON.GLTF2 {
          */
         protected _loadExtrasValueAsync<TProperty, TResult = void>(context: string, property: IProperty, actionAsync: (extensionContext: string, value: TProperty) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
         /**
+         * Helper method called by the loader after the state changes to LOADING.
+         * @hidden
+         */
+        static _OnLoading(loader: GLTFLoader): void;
+        /**
+         * Helper method called by the loader after the state changes to READY.
+         * @hidden
+         */
+        static _OnReady(loader: GLTFLoader): void;
+        /**
          * Helper method called by the loader to allow extensions to override loading scenes.
          * @hidden
          */
@@ -690,16 +717,16 @@ declare module BABYLON.GLTF2.Extensions {
         private _materialIndexLOD;
         private _materialSignalLODs;
         private _materialPromiseLODs;
-        constructor(loader: GLTFLoader);
         dispose(): void;
+        protected _onReady(): void;
         protected _loadNodeAsync(context: string, node: _ILoaderNode): Nullable<Promise<void>>;
         protected _loadMaterialAsync(context: string, material: _ILoaderMaterial, mesh: _ILoaderMesh, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<void>>;
         protected _loadUriAsync(context: string, uri: string): Nullable<Promise<ArrayBufferView>>;
         /**
          * Gets an array of LOD properties from lowest to highest.
          */
-        private _getLODs<T>(context, property, array, ids);
-        private _disposeUnusedMaterials();
+        private _getLODs;
+        private _disposeUnusedMaterials;
     }
 }
 
@@ -717,7 +744,8 @@ declare module BABYLON.GLTF2.Extensions {
     /** @hidden */
     class MSFT_sRGBFactors extends GLTFLoaderExtension {
         readonly name: string;
-        protected _loadMaterialAsync(context: string, material: _ILoaderMaterial, mesh: _ILoaderMesh, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<void>>;
+        protected _loadMaterialPropertiesAsync(context: string, material: _ILoaderMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
+        private _convertColorsToLinear;
     }
 }
 
@@ -743,7 +771,7 @@ declare module BABYLON.GLTF2.Extensions {
     class KHR_materials_pbrSpecularGlossiness extends GLTFLoaderExtension {
         readonly name: string;
         protected _loadMaterialPropertiesAsync(context: string, material: _ILoaderMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
-        private _loadSpecularGlossinessPropertiesAsync(context, material, properties, babylonMaterial);
+        private _loadSpecularGlossinessPropertiesAsync;
     }
 }
 
@@ -755,7 +783,7 @@ declare module BABYLON.GLTF2.Extensions {
     class KHR_materials_unlit extends GLTFLoaderExtension {
         readonly name: string;
         protected _loadMaterialPropertiesAsync(context: string, material: _ILoaderMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
-        private _loadUnlitPropertiesAsync(context, material, babylonMaterial);
+        private _loadUnlitPropertiesAsync;
     }
 }
 
@@ -766,9 +794,10 @@ declare module BABYLON.GLTF2.Extensions {
      */
     class KHR_lights extends GLTFLoaderExtension {
         readonly name: string;
+        private _lights?;
+        protected _onLoading(): void;
         protected _loadSceneAsync(context: string, scene: _ILoaderScene): Nullable<Promise<void>>;
         protected _loadNodeAsync(context: string, node: _ILoaderNode): Nullable<Promise<void>>;
-        private readonly _lights;
     }
 }
 
@@ -790,8 +819,9 @@ declare module BABYLON.GLTF2.Extensions {
      */
     class EXT_lights_imageBased extends GLTFLoaderExtension {
         readonly name: string;
+        private _lights?;
+        protected _onLoading(): void;
         protected _loadSceneAsync(context: string, scene: _ILoaderScene): Nullable<Promise<void>>;
-        private _loadLightAsync(context, light);
-        private readonly _lights;
+        private _loadLightAsync;
     }
 }

+ 146 - 94
dist/preview release/loaders/babylon.glTF2FileLoader.js

@@ -118,6 +118,10 @@ var BABYLON;
              */
             this.onCompleteObservable = new BABYLON.Observable();
             /**
+             * Observable raised when an error occurs.
+             */
+            this.onErrorObservable = new BABYLON.Observable();
+            /**
              * Observable raised after the loader is disposed.
              */
             this.onDisposeObservable = new BABYLON.Observable();
@@ -217,6 +221,8 @@ var BABYLON;
         Object.defineProperty(GLTFFileLoader.prototype, "onComplete", {
             /**
              * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
+             * For assets with LODs, raised when all of the LODs are complete.
+             * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
              */
             set: function (callback) {
                 if (this._onCompleteObserver) {
@@ -227,6 +233,19 @@ var BABYLON;
             enumerable: true,
             configurable: true
         });
+        Object.defineProperty(GLTFFileLoader.prototype, "onError", {
+            /**
+             * Callback raised when an error occurs.
+             */
+            set: function (callback) {
+                if (this._onErrorObserver) {
+                    this.onErrorObservable.remove(this._onErrorObserver);
+                }
+                this._onErrorObserver = this.onErrorObservable.add(callback);
+            },
+            enumerable: true,
+            configurable: true
+        });
         Object.defineProperty(GLTFFileLoader.prototype, "onDispose", {
             /**
              * Callback raised after the loader is disposed.
@@ -259,10 +278,13 @@ var BABYLON;
          */
         GLTFFileLoader.prototype.whenCompleteAsync = function () {
             var _this = this;
-            return new Promise(function (resolve) {
+            return new Promise(function (resolve, reject) {
                 _this.onCompleteObservable.addOnce(function () {
                     resolve();
                 });
+                _this.onErrorObservable.addOnce(function (reason) {
+                    reject(reason);
+                });
             });
         };
         Object.defineProperty(GLTFFileLoader.prototype, "loaderState", {
@@ -713,9 +735,6 @@ var BABYLON;
                 GLTFLoader._ExtensionNames.push(name);
             };
             Object.defineProperty(GLTFLoader.prototype, "state", {
-                /**
-                 * Loader state or null if the loader is not active.
-                 */
                 get: function () {
                     return this._state;
                 },
@@ -734,7 +753,6 @@ var BABYLON;
                 this._requests.length = 0;
                 delete this._gltf;
                 delete this._babylonScene;
-                delete this._readyPromise;
                 this._completePromises.length = 0;
                 for (var name_1 in this._extensions) {
                     this._extensions[name_1].dispose();
@@ -794,14 +812,14 @@ var BABYLON;
             GLTFLoader.prototype._loadAsync = function (nodes) {
                 var _this = this;
                 return Promise.resolve().then(function () {
-                    _this._parent._startPerformanceCounter("Loading => Ready");
-                    _this._parent._startPerformanceCounter("Loading => Complete");
-                    _this._state = BABYLON.GLTFLoaderState.LOADING;
-                    _this._parent._log("Loading");
-                    var readyDeferred = new BABYLON.Deferred();
-                    _this._readyPromise = readyDeferred.promise;
                     _this._loadExtensions();
                     _this._checkExtensions();
+                    var loadingToReadyCounterName = BABYLON.GLTFLoaderState[BABYLON.GLTFLoaderState.LOADING] + " => " + BABYLON.GLTFLoaderState[BABYLON.GLTFLoaderState.READY];
+                    var loadingToCompleteCounterName = BABYLON.GLTFLoaderState[BABYLON.GLTFLoaderState.LOADING] + " => " + BABYLON.GLTFLoaderState[BABYLON.GLTFLoaderState.COMPLETE];
+                    _this._parent._startPerformanceCounter(loadingToReadyCounterName);
+                    _this._parent._startPerformanceCounter(loadingToCompleteCounterName);
+                    _this._setState(BABYLON.GLTFLoaderState.LOADING);
+                    GLTF2.GLTFLoaderExtension._OnLoading(_this);
                     var promises = new Array();
                     if (nodes) {
                         promises.push(_this._loadSceneAsync("#/nodes", { nodes: nodes, _index: -1 }));
@@ -817,33 +835,33 @@ var BABYLON;
                         promises.push(_this._compileShadowGeneratorsAsync());
                     }
                     var resultPromise = Promise.all(promises).then(function () {
-                        _this._state = BABYLON.GLTFLoaderState.READY;
-                        _this._parent._log("Ready");
-                        readyDeferred.resolve();
+                        _this._setState(BABYLON.GLTFLoaderState.READY);
+                        GLTF2.GLTFLoaderExtension._OnReady(_this);
                         _this._startAnimations();
                     });
                     resultPromise.then(function () {
-                        _this._parent._endPerformanceCounter("Loading => Ready");
+                        _this._parent._endPerformanceCounter(loadingToReadyCounterName);
                         BABYLON.Tools.SetImmediate(function () {
                             if (!_this._disposed) {
                                 Promise.all(_this._completePromises).then(function () {
-                                    _this._parent._endPerformanceCounter("Loading => Complete");
-                                    _this._state = BABYLON.GLTFLoaderState.COMPLETE;
-                                    _this._parent._log("Complete");
+                                    _this._parent._endPerformanceCounter(loadingToCompleteCounterName);
+                                    _this._setState(BABYLON.GLTFLoaderState.COMPLETE);
                                     _this._parent.onCompleteObservable.notifyObservers(undefined);
                                     _this._parent.onCompleteObservable.clear();
                                     _this.dispose();
-                                }).catch(function (error) {
-                                    BABYLON.Tools.Error("glTF Loader: " + error.message);
+                                }, function (error) {
+                                    _this._parent.onErrorObservable.notifyObservers(error);
+                                    _this._parent.onErrorObservable.clear();
                                     _this.dispose();
                                 });
                             }
                         });
                     });
                     return resultPromise;
-                }).catch(function (error) {
+                }, function (error) {
                     if (!_this._disposed) {
-                        BABYLON.Tools.Error("glTF Loader: " + error.message);
+                        _this._parent.onErrorObservable.notifyObservers(error);
+                        _this._parent.onErrorObservable.clear();
                         _this.dispose();
                         throw error;
                     }
@@ -919,6 +937,10 @@ var BABYLON;
                     }
                 }
             };
+            GLTFLoader.prototype._setState = function (state) {
+                this._state = state;
+                this._parent._log(BABYLON.GLTFLoaderState[this._state]);
+            };
             GLTFLoader.prototype._createRootNode = function () {
                 this._rootBabylonMesh = new BABYLON.Mesh("__root__", this._babylonScene);
                 var rootNode = { _babylonMesh: this._rootBabylonMesh };
@@ -2173,6 +2195,15 @@ var BABYLON;
                 }
                 return null;
             };
+            GLTFLoader.prototype._forEachExtensions = function (action) {
+                for (var _i = 0, _a = GLTFLoader._ExtensionNames; _i < _a.length; _i++) {
+                    var name_6 = _a[_i];
+                    var extension = this._extensions[name_6];
+                    if (extension.enabled) {
+                        action(extension);
+                    }
+                }
+            };
             GLTFLoader._ExtensionNames = new Array();
             GLTFLoader._ExtensionFactories = {};
             return GLTFLoader;
@@ -2212,6 +2243,14 @@ var BABYLON;
             };
             // #region Overridable Methods
             /**
+             * Override this method to do work after the state changes to LOADING.
+             */
+            GLTFLoaderExtension.prototype._onLoading = function () { };
+            /**
+             * Override this method to do work after the state changes to READY.
+             */
+            GLTFLoaderExtension.prototype._onReady = function () { };
+            /**
              * Override this method to modify the default behavior for loading scenes.
              * @hidden
              */
@@ -2299,6 +2338,20 @@ var BABYLON;
                 }
             };
             /**
+             * Helper method called by the loader after the state changes to LOADING.
+             * @hidden
+             */
+            GLTFLoaderExtension._OnLoading = function (loader) {
+                loader._forEachExtensions(function (extension) { return extension._onLoading(); });
+            };
+            /**
+             * Helper method called by the loader after the state changes to READY.
+             * @hidden
+             */
+            GLTFLoaderExtension._OnReady = function (loader) {
+                loader._forEachExtensions(function (extension) { return extension._onReady(); });
+            };
+            /**
              * Helper method called by the loader to allow extensions to override loading scenes.
              * @hidden
              */
@@ -2385,8 +2438,8 @@ var BABYLON;
              */
             var MSFT_lod = /** @class */ (function (_super) {
                 __extends(MSFT_lod, _super);
-                function MSFT_lod(loader) {
-                    var _this = _super.call(this, loader) || this;
+                function MSFT_lod() {
+                    var _this = _super !== null && _super.apply(this, arguments) || this;
                     _this.name = NAME;
                     /**
                      * Maximum number of LODs to load, starting from the lowest LOD.
@@ -2410,42 +2463,6 @@ var BABYLON;
                     _this._materialIndexLOD = null;
                     _this._materialSignalLODs = new Array();
                     _this._materialPromiseLODs = new Array();
-                    _this._loader._readyPromise.then(function () {
-                        var _loop_1 = function (indexLOD) {
-                            var promise = Promise.all(_this._nodePromiseLODs[indexLOD]).then(function () {
-                                if (indexLOD !== 0) {
-                                    _this._loader._parent._endPerformanceCounter("Node LOD " + indexLOD);
-                                }
-                                _this._loader._parent._log("Loaded node LOD " + indexLOD);
-                                _this.onNodeLODsLoadedObservable.notifyObservers(indexLOD);
-                                if (indexLOD !== _this._nodePromiseLODs.length - 1) {
-                                    _this._loader._parent._startPerformanceCounter("Node LOD " + (indexLOD + 1));
-                                    _this._nodeSignalLODs[indexLOD].resolve();
-                                }
-                            });
-                            _this._loader._completePromises.push(promise);
-                        };
-                        for (var indexLOD = 0; indexLOD < _this._nodePromiseLODs.length; indexLOD++) {
-                            _loop_1(indexLOD);
-                        }
-                        var _loop_2 = function (indexLOD) {
-                            var promise = Promise.all(_this._materialPromiseLODs[indexLOD]).then(function () {
-                                if (indexLOD !== 0) {
-                                    _this._loader._parent._endPerformanceCounter("Material LOD " + indexLOD);
-                                }
-                                _this._loader._parent._log("Loaded material LOD " + indexLOD);
-                                _this.onMaterialLODsLoadedObservable.notifyObservers(indexLOD);
-                                if (indexLOD !== _this._materialPromiseLODs.length - 1) {
-                                    _this._loader._parent._startPerformanceCounter("Material LOD " + (indexLOD + 1));
-                                    _this._materialSignalLODs[indexLOD].resolve();
-                                }
-                            });
-                            _this._loader._completePromises.push(promise);
-                        };
-                        for (var indexLOD = 0; indexLOD < _this._materialPromiseLODs.length; indexLOD++) {
-                            _loop_2(indexLOD);
-                        }
-                    });
                     return _this;
                 }
                 MSFT_lod.prototype.dispose = function () {
@@ -2459,6 +2476,49 @@ var BABYLON;
                     this.onMaterialLODsLoadedObservable.clear();
                     this.onNodeLODsLoadedObservable.clear();
                 };
+                MSFT_lod.prototype._onReady = function () {
+                    var _this = this;
+                    var _loop_1 = function (indexLOD) {
+                        var promise = Promise.all(this_1._nodePromiseLODs[indexLOD]).then(function () {
+                            if (indexLOD !== 0) {
+                                _this._loader._parent._endPerformanceCounter("Node LOD " + indexLOD);
+                            }
+                            _this._loader._parent._log("Loaded node LOD " + indexLOD);
+                            _this.onNodeLODsLoadedObservable.notifyObservers(indexLOD);
+                            if (indexLOD !== _this._nodePromiseLODs.length - 1) {
+                                _this._loader._parent._startPerformanceCounter("Node LOD " + (indexLOD + 1));
+                                if (_this._nodeSignalLODs[indexLOD]) {
+                                    _this._nodeSignalLODs[indexLOD].resolve();
+                                }
+                            }
+                        });
+                        this_1._loader._completePromises.push(promise);
+                    };
+                    var this_1 = this;
+                    for (var indexLOD = 0; indexLOD < this._nodePromiseLODs.length; indexLOD++) {
+                        _loop_1(indexLOD);
+                    }
+                    var _loop_2 = function (indexLOD) {
+                        var promise = Promise.all(this_2._materialPromiseLODs[indexLOD]).then(function () {
+                            if (indexLOD !== 0) {
+                                _this._loader._parent._endPerformanceCounter("Material LOD " + indexLOD);
+                            }
+                            _this._loader._parent._log("Loaded material LOD " + indexLOD);
+                            _this.onMaterialLODsLoadedObservable.notifyObservers(indexLOD);
+                            if (indexLOD !== _this._materialPromiseLODs.length - 1) {
+                                _this._loader._parent._startPerformanceCounter("Material LOD " + (indexLOD + 1));
+                                if (_this._materialSignalLODs[indexLOD]) {
+                                    _this._materialSignalLODs[indexLOD].resolve();
+                                }
+                            }
+                        });
+                        this_2._loader._completePromises.push(promise);
+                    };
+                    var this_2 = this;
+                    for (var indexLOD = 0; indexLOD < this._materialPromiseLODs.length; indexLOD++) {
+                        _loop_2(indexLOD);
+                    }
+                };
                 MSFT_lod.prototype._loadNodeAsync = function (context, node) {
                     var _this = this;
                     return this._loadExtensionAsync(context, node, function (extensionContext, extension) {
@@ -2683,23 +2743,25 @@ var BABYLON;
                     _this.name = NAME;
                     return _this;
                 }
-                MSFT_sRGBFactors.prototype._loadMaterialAsync = function (context, material, mesh, babylonMesh, babylonDrawMode, assign) {
+                MSFT_sRGBFactors.prototype._loadMaterialPropertiesAsync = function (context, material, babylonMaterial) {
                     var _this = this;
                     return this._loadExtrasValueAsync(context, material, function (extensionContext, value) {
                         if (value) {
-                            return _this._loader._loadMaterialAsync(context, material, mesh, babylonMesh, babylonDrawMode, function (babylonMaterial) {
-                                if (!babylonMaterial.albedoTexture) {
-                                    babylonMaterial.albedoColor.toLinearSpaceToRef(babylonMaterial.albedoColor);
-                                }
-                                if (!babylonMaterial.reflectivityTexture) {
-                                    babylonMaterial.reflectivityColor.toLinearSpaceToRef(babylonMaterial.reflectivityColor);
-                                }
-                                assign(babylonMaterial);
-                            });
+                            var promise = _this._loader._loadMaterialPropertiesAsync(context, material, babylonMaterial);
+                            _this._convertColorsToLinear(babylonMaterial);
+                            return promise;
                         }
                         return null;
                     });
                 };
+                MSFT_sRGBFactors.prototype._convertColorsToLinear = function (babylonMaterial) {
+                    if (!babylonMaterial.albedoTexture) {
+                        babylonMaterial.albedoColor.toLinearSpaceToRef(babylonMaterial.albedoColor);
+                    }
+                    if (!babylonMaterial.reflectivityTexture) {
+                        babylonMaterial.reflectivityColor.toLinearSpaceToRef(babylonMaterial.reflectivityColor);
+                    }
+                };
                 return MSFT_sRGBFactors;
             }(GLTF2.GLTFLoaderExtension));
             Extensions.MSFT_sRGBFactors = MSFT_sRGBFactors;
@@ -2990,6 +3052,13 @@ var BABYLON;
                     _this.name = NAME;
                     return _this;
                 }
+                KHR_lights.prototype._onLoading = function () {
+                    var extensions = this._loader._gltf.extensions;
+                    if (extensions && extensions[this.name]) {
+                        var extension = extensions[this.name];
+                        this._lights = extension.lights;
+                    }
+                };
                 KHR_lights.prototype._loadSceneAsync = function (context, scene) {
                     var _this = this;
                     return this._loadExtensionAsync(context, scene, function (extensionContext, extension) {
@@ -3038,18 +3107,6 @@ var BABYLON;
                         return promise;
                     });
                 };
-                Object.defineProperty(KHR_lights.prototype, "_lights", {
-                    get: function () {
-                        var extensions = this._loader._gltf.extensions;
-                        if (!extensions || !extensions[this.name]) {
-                            throw new Error("#/extensions: '" + this.name + "' not found");
-                        }
-                        var extension = extensions[this.name];
-                        return extension.lights;
-                    },
-                    enumerable: true,
-                    configurable: true
-                });
                 return KHR_lights;
             }(GLTF2.GLTFLoaderExtension));
             Extensions.KHR_lights = KHR_lights;
@@ -3151,6 +3208,13 @@ var BABYLON;
                     _this.name = NAME;
                     return _this;
                 }
+                EXT_lights_imageBased.prototype._onLoading = function () {
+                    var extensions = this._loader._gltf.extensions;
+                    if (extensions && extensions[this.name]) {
+                        var extension = extensions[this.name];
+                        this._lights = extension.lights;
+                    }
+                };
                 EXT_lights_imageBased.prototype._loadSceneAsync = function (context, scene) {
                     var _this = this;
                     return this._loadExtensionAsync(context, scene, function (extensionContext, extension) {
@@ -3220,18 +3284,6 @@ var BABYLON;
                         return light._babylonTexture;
                     });
                 };
-                Object.defineProperty(EXT_lights_imageBased.prototype, "_lights", {
-                    get: function () {
-                        var extensions = this._loader._gltf.extensions;
-                        if (!extensions || !extensions[this.name]) {
-                            throw new Error("#/extensions: '" + this.name + "' not found");
-                        }
-                        var extension = extensions[this.name];
-                        return extension.lights;
-                    },
-                    enumerable: true,
-                    configurable: true
-                });
                 return EXT_lights_imageBased;
             }(GLTF2.GLTFLoaderExtension));
             Extensions.EXT_lights_imageBased = EXT_lights_imageBased;

Файловите разлики са ограничени, защото са твърде много
+ 3 - 3
dist/preview release/loaders/babylon.glTF2FileLoader.min.js


+ 123 - 93
dist/preview release/loaders/babylon.glTFFileLoader.d.ts

@@ -11,7 +11,7 @@ declare module BABYLON {
         /**
          * Sets the useRightHandedSystem flag on the scene.
          */
-        FORCE_RIGHT_HANDED = 1,
+        FORCE_RIGHT_HANDED = 1
     }
     /**
      * Mode that determines what animations will start.
@@ -28,7 +28,7 @@ declare module BABYLON {
         /**
          * All animations will start.
          */
-        ALL = 2,
+        ALL = 2
     }
     /**
      * Interface that contains the data for the glTF asset.
@@ -71,7 +71,7 @@ declare module BABYLON {
         /**
          * The asset is completely loaded.
          */
-        COMPLETE = 2,
+        COMPLETE = 2
     }
     /** @hidden */
     interface IGLTFLoader extends IDisposable {
@@ -191,9 +191,20 @@ declare module BABYLON {
         private _onCompleteObserver;
         /**
          * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
+         * For assets with LODs, raised when all of the LODs are complete.
+         * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
          */
         onComplete: () => void;
         /**
+         * Observable raised when an error occurs.
+         */
+        readonly onErrorObservable: Observable<any>;
+        private _onErrorObserver;
+        /**
+         * Callback raised when an error occurs.
+         */
+        onError: (reason: any) => void;
+        /**
          * Observable raised after the loader is disposed.
          */
         readonly onDisposeObservable: Observable<void>;
@@ -292,14 +303,14 @@ declare module BABYLON {
          * @returns the created plugin
          */
         createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
-        private _parse(data);
-        private _getLoader(loaderData);
-        private _parseBinary(data);
-        private _parseV1(binaryReader);
-        private _parseV2(binaryReader);
-        private static _parseVersion(version);
-        private static _compareVersion(a, b);
-        private static _decodeBufferToText(buffer);
+        private _parse;
+        private _getLoader;
+        private _parseBinary;
+        private _parseV1;
+        private _parseV2;
+        private static _parseVersion;
+        private static _compareVersion;
+        private static _decodeBufferToText;
         private static readonly _logSpaces;
         private _logIndentLevel;
         private _loggingEnabled;
@@ -309,17 +320,17 @@ declare module BABYLON {
         _logOpen(message: string): void;
         /** @hidden */
         _logClose(): void;
-        private _logEnabled(message);
-        private _logDisabled(message);
+        private _logEnabled;
+        private _logDisabled;
         private _capturePerformanceCounters;
         /** @hidden */
         _startPerformanceCounter: (counterName: string) => void;
         /** @hidden */
         _endPerformanceCounter: (counterName: string) => void;
-        private _startPerformanceCounterEnabled(counterName);
-        private _startPerformanceCounterDisabled(counterName);
-        private _endPerformanceCounterEnabled(counterName);
-        private _endPerformanceCounterDisabled(counterName);
+        private _startPerformanceCounterEnabled;
+        private _startPerformanceCounterDisabled;
+        private _endPerformanceCounterEnabled;
+        private _endPerformanceCounterDisabled;
     }
 }
 
@@ -333,11 +344,11 @@ declare module BABYLON.GLTF1 {
         UNSIGNED_BYTE = 5121,
         SHORT = 5122,
         UNSIGNED_SHORT = 5123,
-        FLOAT = 5126,
+        FLOAT = 5126
     }
     enum EShaderType {
         FRAGMENT = 35632,
-        VERTEX = 35633,
+        VERTEX = 35633
     }
     enum EParameterType {
         BYTE = 5120,
@@ -360,12 +371,12 @@ declare module BABYLON.GLTF1 {
         FLOAT_MAT2 = 35674,
         FLOAT_MAT3 = 35675,
         FLOAT_MAT4 = 35676,
-        SAMPLER_2D = 35678,
+        SAMPLER_2D = 35678
     }
     enum ETextureWrapMode {
         CLAMP_TO_EDGE = 33071,
         MIRRORED_REPEAT = 33648,
-        REPEAT = 10497,
+        REPEAT = 10497
     }
     enum ETextureFilterType {
         NEAREST = 9728,
@@ -373,19 +384,19 @@ declare module BABYLON.GLTF1 {
         NEAREST_MIPMAP_NEAREST = 9984,
         LINEAR_MIPMAP_NEAREST = 9985,
         NEAREST_MIPMAP_LINEAR = 9986,
-        LINEAR_MIPMAP_LINEAR = 9987,
+        LINEAR_MIPMAP_LINEAR = 9987
     }
     enum ETextureFormat {
         ALPHA = 6406,
         RGB = 6407,
         RGBA = 6408,
         LUMINANCE = 6409,
-        LUMINANCE_ALPHA = 6410,
+        LUMINANCE_ALPHA = 6410
     }
     enum ECullingType {
         FRONT = 1028,
         BACK = 1029,
-        FRONT_AND_BACK = 1032,
+        FRONT_AND_BACK = 1032
     }
     enum EBlendingFunction {
         ZERO = 0,
@@ -402,7 +413,7 @@ declare module BABYLON.GLTF1 {
         ONE_MINUS_CONSTANT_COLOR = 32770,
         CONSTANT_ALPHA = 32771,
         ONE_MINUS_CONSTANT_ALPHA = 32772,
-        SRC_ALPHA_SATURATE = 776,
+        SRC_ALPHA_SATURATE = 776
     }
     /**
     * Interfaces
@@ -718,7 +729,7 @@ declare module BABYLON.GLTF1 {
         static RegisterExtension(extension: GLTFLoaderExtension): void;
         state: Nullable<GLTFLoaderState>;
         dispose(): void;
-        private _importMeshAsync(meshesNames, scene, data, rootUrl, onSuccess, onProgress?, onError?);
+        private _importMeshAsync;
         /**
         * Imports one or more meshes from a loaded gltf file and adds them to the scene
         * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
@@ -734,7 +745,7 @@ declare module BABYLON.GLTF1 {
             skeletons: Skeleton[];
             animationGroups: AnimationGroup[];
         }>;
-        private _loadAsync(scene, data, rootUrl, onSuccess, onProgress?, onError?);
+        private _loadAsync;
         /**
         * Imports all objects from a loaded gltf file and adds them to the scene
         * @param scene the scene the objects should be added to
@@ -744,9 +755,9 @@ declare module BABYLON.GLTF1 {
         * @returns a promise which completes when objects have been loaded to the scene
         */
         loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
-        private _loadShadersAsync(gltfRuntime, onload);
-        private _loadBuffersAsync(gltfRuntime, onLoad, onProgress?);
-        private _createNodes(gltfRuntime);
+        private _loadShadersAsync;
+        private _loadBuffersAsync;
+        private _createNodes;
     }
 }
 
@@ -857,9 +868,9 @@ declare module BABYLON.GLTF1 {
         static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
         static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
         static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
-        private static LoadTextureBufferAsync(gltfRuntime, id, onSuccess, onError);
-        private static CreateTextureAsync(gltfRuntime, id, buffer, onSuccess, onError);
-        private static ApplyExtensions(func, defaultFunc);
+        private static LoadTextureBufferAsync;
+        private static CreateTextureAsync;
+        private static ApplyExtensions;
     }
 }
 
@@ -881,7 +892,7 @@ declare module BABYLON.GLTF1 {
         constructor();
         loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
         loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
-        private _loadTexture(gltfRuntime, id, material, propertyPath, onError);
+        private _loadTexture;
     }
 }
 
@@ -1011,7 +1022,6 @@ declare module BABYLON.GLTF2 {
         _parent: GLTFFileLoader;
         _gltf: _ILoaderGLTF;
         _babylonScene: Scene;
-        _readyPromise: Promise<void>;
         _completePromises: Promise<void>[];
         private _disposed;
         private _state;
@@ -1025,9 +1035,6 @@ declare module BABYLON.GLTF2 {
         private static _ExtensionNames;
         private static _ExtensionFactories;
         static _Register(name: string, factory: (loader: GLTFLoader) => GLTFLoaderExtension): void;
-        /**
-         * Loader state or null if the loader is not active.
-         */
         readonly state: Nullable<GLTFLoaderState>;
         constructor(parent: GLTFFileLoader);
         dispose(): void;
@@ -1038,45 +1045,46 @@ declare module BABYLON.GLTF2 {
             animationGroups: AnimationGroup[];
         }>;
         loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
-        private _loadAsync(nodes);
-        private _loadData(data);
-        private _setupData();
-        private _loadExtensions();
-        private _checkExtensions();
-        private _createRootNode();
+        private _loadAsync;
+        private _loadData;
+        private _setupData;
+        private _loadExtensions;
+        private _checkExtensions;
+        private _setState;
+        private _createRootNode;
         _loadSceneAsync(context: string, scene: _ILoaderScene): Promise<void>;
-        private _forEachPrimitive(node, callback);
-        private _getMeshes();
-        private _getSkeletons();
-        private _getAnimationGroups();
-        private _startAnimations();
+        private _forEachPrimitive;
+        private _getMeshes;
+        private _getSkeletons;
+        private _getAnimationGroups;
+        private _startAnimations;
         _loadNodeAsync(context: string, node: _ILoaderNode): Promise<void>;
-        private _loadMeshAsync(context, node, mesh, babylonMesh);
-        private _loadPrimitiveAsync(context, node, mesh, primitive, babylonMesh);
-        private _loadVertexDataAsync(context, primitive, babylonMesh);
-        private _createMorphTargets(context, node, mesh, primitive, babylonMesh);
-        private _loadMorphTargetsAsync(context, primitive, babylonMesh, babylonGeometry);
-        private _loadMorphTargetVertexDataAsync(context, babylonGeometry, attributes, babylonMorphTarget);
-        private static _LoadTransform(node, babylonNode);
-        private _loadSkinAsync(context, node, mesh, skin);
-        private _loadBones(context, skin);
-        private _loadBone(node, skin, babylonBones);
-        private _loadSkinInverseBindMatricesDataAsync(context, skin);
-        private _updateBoneMatrices(babylonSkeleton, inverseBindMatricesData);
-        private _getNodeMatrix(node);
-        private _loadCamera(context, camera, babylonMesh);
-        private _loadAnimationsAsync();
-        private _loadAnimationAsync(context, animation);
-        private _loadAnimationChannelAsync(context, animationContext, animation, channel, babylonAnimationGroup);
-        private _loadAnimationSamplerAsync(context, sampler);
-        private _loadBufferAsync(context, buffer);
+        private _loadMeshAsync;
+        private _loadPrimitiveAsync;
+        private _loadVertexDataAsync;
+        private _createMorphTargets;
+        private _loadMorphTargetsAsync;
+        private _loadMorphTargetVertexDataAsync;
+        private static _LoadTransform;
+        private _loadSkinAsync;
+        private _loadBones;
+        private _loadBone;
+        private _loadSkinInverseBindMatricesDataAsync;
+        private _updateBoneMatrices;
+        private _getNodeMatrix;
+        private _loadCamera;
+        private _loadAnimationsAsync;
+        private _loadAnimationAsync;
+        private _loadAnimationChannelAsync;
+        private _loadAnimationSamplerAsync;
+        private _loadBufferAsync;
         _loadBufferViewAsync(context: string, bufferView: _ILoaderBufferView): Promise<ArrayBufferView>;
-        private _loadIndicesAccessorAsync(context, accessor);
-        private _loadFloatAccessorAsync(context, accessor);
+        private _loadIndicesAccessorAsync;
+        private _loadFloatAccessorAsync;
         _loadVertexBufferViewAsync(context: string, bufferView: _ILoaderBufferView, kind: string): Promise<Buffer>;
-        private _loadVertexAccessorAsync(context, accessor, kind);
-        private _getDefaultMaterial(drawMode);
-        private _loadMaterialMetallicRoughnessPropertiesAsync(context, material, babylonMaterial);
+        private _loadVertexAccessorAsync;
+        private _getDefaultMaterial;
+        private _loadMaterialMetallicRoughnessPropertiesAsync;
         _loadMaterialAsync(context: string, material: _ILoaderMaterial, mesh: _ILoaderMesh, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Promise<void>;
         _loadMaterialPropertiesAsync(context: string, material: _ILoaderMaterial, babylonMaterial: Material): Promise<void>;
         _createMaterial(name: string, drawMode: number): PBRMaterial;
@@ -1084,20 +1092,21 @@ declare module BABYLON.GLTF2 {
         _loadMaterialAlphaProperties(context: string, material: _ILoaderMaterial, babylonMaterial: PBRMaterial): void;
         _loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: Texture) => void): Promise<void>;
         _loadTextureAsync(context: string, texture: _ILoaderTexture, assign: (babylonTexture: Texture) => void): Promise<void>;
-        private _loadSampler(context, sampler);
+        private _loadSampler;
         _loadImageAsync(context: string, image: _ILoaderImage): Promise<ArrayBufferView>;
         _loadUriAsync(context: string, uri: string): Promise<ArrayBufferView>;
-        private _onProgress();
+        private _onProgress;
         static _GetProperty<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
-        private static _GetTextureWrapMode(context, mode);
-        private static _GetTextureSamplingMode(context, magFilter?, minFilter?);
-        private static _GetTypedArray(context, componentType, bufferView, byteOffset, length);
-        private static _GetNumComponents(context, type);
-        private static _ValidateUri(uri);
-        private static _GetDrawMode(context, mode);
-        private _compileMaterialsAsync();
-        private _compileShadowGeneratorsAsync();
+        private static _GetTextureWrapMode;
+        private static _GetTextureSamplingMode;
+        private static _GetTypedArray;
+        private static _GetNumComponents;
+        private static _ValidateUri;
+        private static _GetDrawMode;
+        private _compileMaterialsAsync;
+        private _compileShadowGeneratorsAsync;
         _applyExtensions<T>(actionAsync: (extension: GLTFLoaderExtension) => Nullable<Promise<T>>): Nullable<Promise<T>>;
+        _forEachExtensions(action: (extension: GLTFLoaderExtension) => void): void;
     }
 }
 
@@ -1114,7 +1123,7 @@ declare module BABYLON.GLTF2 {
         /**
          * Gets or sets extension name
          */
-        readonly abstract name: string;
+        abstract readonly name: string;
         protected _loader: GLTFLoader;
         /**
          * Creates new GLTFLoaderExtension
@@ -1126,6 +1135,14 @@ declare module BABYLON.GLTF2 {
          */
         dispose(): void;
         /**
+         * Override this method to do work after the state changes to LOADING.
+         */
+        protected _onLoading(): void;
+        /**
+         * Override this method to do work after the state changes to READY.
+         */
+        protected _onReady(): void;
+        /**
          * Override this method to modify the default behavior for loading scenes.
          * @hidden
          */
@@ -1176,6 +1193,16 @@ declare module BABYLON.GLTF2 {
          */
         protected _loadExtrasValueAsync<TProperty, TResult = void>(context: string, property: IProperty, actionAsync: (extensionContext: string, value: TProperty) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
         /**
+         * Helper method called by the loader after the state changes to LOADING.
+         * @hidden
+         */
+        static _OnLoading(loader: GLTFLoader): void;
+        /**
+         * Helper method called by the loader after the state changes to READY.
+         * @hidden
+         */
+        static _OnReady(loader: GLTFLoader): void;
+        /**
          * Helper method called by the loader to allow extensions to override loading scenes.
          * @hidden
          */
@@ -1252,16 +1279,16 @@ declare module BABYLON.GLTF2.Extensions {
         private _materialIndexLOD;
         private _materialSignalLODs;
         private _materialPromiseLODs;
-        constructor(loader: GLTFLoader);
         dispose(): void;
+        protected _onReady(): void;
         protected _loadNodeAsync(context: string, node: _ILoaderNode): Nullable<Promise<void>>;
         protected _loadMaterialAsync(context: string, material: _ILoaderMaterial, mesh: _ILoaderMesh, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<void>>;
         protected _loadUriAsync(context: string, uri: string): Nullable<Promise<ArrayBufferView>>;
         /**
          * Gets an array of LOD properties from lowest to highest.
          */
-        private _getLODs<T>(context, property, array, ids);
-        private _disposeUnusedMaterials();
+        private _getLODs;
+        private _disposeUnusedMaterials;
     }
 }
 
@@ -1279,7 +1306,8 @@ declare module BABYLON.GLTF2.Extensions {
     /** @hidden */
     class MSFT_sRGBFactors extends GLTFLoaderExtension {
         readonly name: string;
-        protected _loadMaterialAsync(context: string, material: _ILoaderMaterial, mesh: _ILoaderMesh, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<void>>;
+        protected _loadMaterialPropertiesAsync(context: string, material: _ILoaderMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
+        private _convertColorsToLinear;
     }
 }
 
@@ -1305,7 +1333,7 @@ declare module BABYLON.GLTF2.Extensions {
     class KHR_materials_pbrSpecularGlossiness extends GLTFLoaderExtension {
         readonly name: string;
         protected _loadMaterialPropertiesAsync(context: string, material: _ILoaderMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
-        private _loadSpecularGlossinessPropertiesAsync(context, material, properties, babylonMaterial);
+        private _loadSpecularGlossinessPropertiesAsync;
     }
 }
 
@@ -1317,7 +1345,7 @@ declare module BABYLON.GLTF2.Extensions {
     class KHR_materials_unlit extends GLTFLoaderExtension {
         readonly name: string;
         protected _loadMaterialPropertiesAsync(context: string, material: _ILoaderMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
-        private _loadUnlitPropertiesAsync(context, material, babylonMaterial);
+        private _loadUnlitPropertiesAsync;
     }
 }
 
@@ -1328,9 +1356,10 @@ declare module BABYLON.GLTF2.Extensions {
      */
     class KHR_lights extends GLTFLoaderExtension {
         readonly name: string;
+        private _lights?;
+        protected _onLoading(): void;
         protected _loadSceneAsync(context: string, scene: _ILoaderScene): Nullable<Promise<void>>;
         protected _loadNodeAsync(context: string, node: _ILoaderNode): Nullable<Promise<void>>;
-        private readonly _lights;
     }
 }
 
@@ -1352,8 +1381,9 @@ declare module BABYLON.GLTF2.Extensions {
      */
     class EXT_lights_imageBased extends GLTFLoaderExtension {
         readonly name: string;
+        private _lights?;
+        protected _onLoading(): void;
         protected _loadSceneAsync(context: string, scene: _ILoaderScene): Nullable<Promise<void>>;
-        private _loadLightAsync(context, light);
-        private readonly _lights;
+        private _loadLightAsync;
     }
 }

+ 146 - 94
dist/preview release/loaders/babylon.glTFFileLoader.js

@@ -118,6 +118,10 @@ var BABYLON;
              */
             this.onCompleteObservable = new BABYLON.Observable();
             /**
+             * Observable raised when an error occurs.
+             */
+            this.onErrorObservable = new BABYLON.Observable();
+            /**
              * Observable raised after the loader is disposed.
              */
             this.onDisposeObservable = new BABYLON.Observable();
@@ -217,6 +221,8 @@ var BABYLON;
         Object.defineProperty(GLTFFileLoader.prototype, "onComplete", {
             /**
              * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
+             * For assets with LODs, raised when all of the LODs are complete.
+             * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
              */
             set: function (callback) {
                 if (this._onCompleteObserver) {
@@ -227,6 +233,19 @@ var BABYLON;
             enumerable: true,
             configurable: true
         });
+        Object.defineProperty(GLTFFileLoader.prototype, "onError", {
+            /**
+             * Callback raised when an error occurs.
+             */
+            set: function (callback) {
+                if (this._onErrorObserver) {
+                    this.onErrorObservable.remove(this._onErrorObserver);
+                }
+                this._onErrorObserver = this.onErrorObservable.add(callback);
+            },
+            enumerable: true,
+            configurable: true
+        });
         Object.defineProperty(GLTFFileLoader.prototype, "onDispose", {
             /**
              * Callback raised after the loader is disposed.
@@ -259,10 +278,13 @@ var BABYLON;
          */
         GLTFFileLoader.prototype.whenCompleteAsync = function () {
             var _this = this;
-            return new Promise(function (resolve) {
+            return new Promise(function (resolve, reject) {
                 _this.onCompleteObservable.addOnce(function () {
                     resolve();
                 });
+                _this.onErrorObservable.addOnce(function (reason) {
+                    reject(reason);
+                });
             });
         };
         Object.defineProperty(GLTFFileLoader.prototype, "loaderState", {
@@ -2914,9 +2936,6 @@ var BABYLON;
                 GLTFLoader._ExtensionNames.push(name);
             };
             Object.defineProperty(GLTFLoader.prototype, "state", {
-                /**
-                 * Loader state or null if the loader is not active.
-                 */
                 get: function () {
                     return this._state;
                 },
@@ -2935,7 +2954,6 @@ var BABYLON;
                 this._requests.length = 0;
                 delete this._gltf;
                 delete this._babylonScene;
-                delete this._readyPromise;
                 this._completePromises.length = 0;
                 for (var name_1 in this._extensions) {
                     this._extensions[name_1].dispose();
@@ -2995,14 +3013,14 @@ var BABYLON;
             GLTFLoader.prototype._loadAsync = function (nodes) {
                 var _this = this;
                 return Promise.resolve().then(function () {
-                    _this._parent._startPerformanceCounter("Loading => Ready");
-                    _this._parent._startPerformanceCounter("Loading => Complete");
-                    _this._state = BABYLON.GLTFLoaderState.LOADING;
-                    _this._parent._log("Loading");
-                    var readyDeferred = new BABYLON.Deferred();
-                    _this._readyPromise = readyDeferred.promise;
                     _this._loadExtensions();
                     _this._checkExtensions();
+                    var loadingToReadyCounterName = BABYLON.GLTFLoaderState[BABYLON.GLTFLoaderState.LOADING] + " => " + BABYLON.GLTFLoaderState[BABYLON.GLTFLoaderState.READY];
+                    var loadingToCompleteCounterName = BABYLON.GLTFLoaderState[BABYLON.GLTFLoaderState.LOADING] + " => " + BABYLON.GLTFLoaderState[BABYLON.GLTFLoaderState.COMPLETE];
+                    _this._parent._startPerformanceCounter(loadingToReadyCounterName);
+                    _this._parent._startPerformanceCounter(loadingToCompleteCounterName);
+                    _this._setState(BABYLON.GLTFLoaderState.LOADING);
+                    GLTF2.GLTFLoaderExtension._OnLoading(_this);
                     var promises = new Array();
                     if (nodes) {
                         promises.push(_this._loadSceneAsync("#/nodes", { nodes: nodes, _index: -1 }));
@@ -3018,33 +3036,33 @@ var BABYLON;
                         promises.push(_this._compileShadowGeneratorsAsync());
                     }
                     var resultPromise = Promise.all(promises).then(function () {
-                        _this._state = BABYLON.GLTFLoaderState.READY;
-                        _this._parent._log("Ready");
-                        readyDeferred.resolve();
+                        _this._setState(BABYLON.GLTFLoaderState.READY);
+                        GLTF2.GLTFLoaderExtension._OnReady(_this);
                         _this._startAnimations();
                     });
                     resultPromise.then(function () {
-                        _this._parent._endPerformanceCounter("Loading => Ready");
+                        _this._parent._endPerformanceCounter(loadingToReadyCounterName);
                         BABYLON.Tools.SetImmediate(function () {
                             if (!_this._disposed) {
                                 Promise.all(_this._completePromises).then(function () {
-                                    _this._parent._endPerformanceCounter("Loading => Complete");
-                                    _this._state = BABYLON.GLTFLoaderState.COMPLETE;
-                                    _this._parent._log("Complete");
+                                    _this._parent._endPerformanceCounter(loadingToCompleteCounterName);
+                                    _this._setState(BABYLON.GLTFLoaderState.COMPLETE);
                                     _this._parent.onCompleteObservable.notifyObservers(undefined);
                                     _this._parent.onCompleteObservable.clear();
                                     _this.dispose();
-                                }).catch(function (error) {
-                                    BABYLON.Tools.Error("glTF Loader: " + error.message);
+                                }, function (error) {
+                                    _this._parent.onErrorObservable.notifyObservers(error);
+                                    _this._parent.onErrorObservable.clear();
                                     _this.dispose();
                                 });
                             }
                         });
                     });
                     return resultPromise;
-                }).catch(function (error) {
+                }, function (error) {
                     if (!_this._disposed) {
-                        BABYLON.Tools.Error("glTF Loader: " + error.message);
+                        _this._parent.onErrorObservable.notifyObservers(error);
+                        _this._parent.onErrorObservable.clear();
                         _this.dispose();
                         throw error;
                     }
@@ -3120,6 +3138,10 @@ var BABYLON;
                     }
                 }
             };
+            GLTFLoader.prototype._setState = function (state) {
+                this._state = state;
+                this._parent._log(BABYLON.GLTFLoaderState[this._state]);
+            };
             GLTFLoader.prototype._createRootNode = function () {
                 this._rootBabylonMesh = new BABYLON.Mesh("__root__", this._babylonScene);
                 var rootNode = { _babylonMesh: this._rootBabylonMesh };
@@ -4374,6 +4396,15 @@ var BABYLON;
                 }
                 return null;
             };
+            GLTFLoader.prototype._forEachExtensions = function (action) {
+                for (var _i = 0, _a = GLTFLoader._ExtensionNames; _i < _a.length; _i++) {
+                    var name_6 = _a[_i];
+                    var extension = this._extensions[name_6];
+                    if (extension.enabled) {
+                        action(extension);
+                    }
+                }
+            };
             GLTFLoader._ExtensionNames = new Array();
             GLTFLoader._ExtensionFactories = {};
             return GLTFLoader;
@@ -4413,6 +4444,14 @@ var BABYLON;
             };
             // #region Overridable Methods
             /**
+             * Override this method to do work after the state changes to LOADING.
+             */
+            GLTFLoaderExtension.prototype._onLoading = function () { };
+            /**
+             * Override this method to do work after the state changes to READY.
+             */
+            GLTFLoaderExtension.prototype._onReady = function () { };
+            /**
              * Override this method to modify the default behavior for loading scenes.
              * @hidden
              */
@@ -4500,6 +4539,20 @@ var BABYLON;
                 }
             };
             /**
+             * Helper method called by the loader after the state changes to LOADING.
+             * @hidden
+             */
+            GLTFLoaderExtension._OnLoading = function (loader) {
+                loader._forEachExtensions(function (extension) { return extension._onLoading(); });
+            };
+            /**
+             * Helper method called by the loader after the state changes to READY.
+             * @hidden
+             */
+            GLTFLoaderExtension._OnReady = function (loader) {
+                loader._forEachExtensions(function (extension) { return extension._onReady(); });
+            };
+            /**
              * Helper method called by the loader to allow extensions to override loading scenes.
              * @hidden
              */
@@ -4586,8 +4639,8 @@ var BABYLON;
              */
             var MSFT_lod = /** @class */ (function (_super) {
                 __extends(MSFT_lod, _super);
-                function MSFT_lod(loader) {
-                    var _this = _super.call(this, loader) || this;
+                function MSFT_lod() {
+                    var _this = _super !== null && _super.apply(this, arguments) || this;
                     _this.name = NAME;
                     /**
                      * Maximum number of LODs to load, starting from the lowest LOD.
@@ -4611,42 +4664,6 @@ var BABYLON;
                     _this._materialIndexLOD = null;
                     _this._materialSignalLODs = new Array();
                     _this._materialPromiseLODs = new Array();
-                    _this._loader._readyPromise.then(function () {
-                        var _loop_1 = function (indexLOD) {
-                            var promise = Promise.all(_this._nodePromiseLODs[indexLOD]).then(function () {
-                                if (indexLOD !== 0) {
-                                    _this._loader._parent._endPerformanceCounter("Node LOD " + indexLOD);
-                                }
-                                _this._loader._parent._log("Loaded node LOD " + indexLOD);
-                                _this.onNodeLODsLoadedObservable.notifyObservers(indexLOD);
-                                if (indexLOD !== _this._nodePromiseLODs.length - 1) {
-                                    _this._loader._parent._startPerformanceCounter("Node LOD " + (indexLOD + 1));
-                                    _this._nodeSignalLODs[indexLOD].resolve();
-                                }
-                            });
-                            _this._loader._completePromises.push(promise);
-                        };
-                        for (var indexLOD = 0; indexLOD < _this._nodePromiseLODs.length; indexLOD++) {
-                            _loop_1(indexLOD);
-                        }
-                        var _loop_2 = function (indexLOD) {
-                            var promise = Promise.all(_this._materialPromiseLODs[indexLOD]).then(function () {
-                                if (indexLOD !== 0) {
-                                    _this._loader._parent._endPerformanceCounter("Material LOD " + indexLOD);
-                                }
-                                _this._loader._parent._log("Loaded material LOD " + indexLOD);
-                                _this.onMaterialLODsLoadedObservable.notifyObservers(indexLOD);
-                                if (indexLOD !== _this._materialPromiseLODs.length - 1) {
-                                    _this._loader._parent._startPerformanceCounter("Material LOD " + (indexLOD + 1));
-                                    _this._materialSignalLODs[indexLOD].resolve();
-                                }
-                            });
-                            _this._loader._completePromises.push(promise);
-                        };
-                        for (var indexLOD = 0; indexLOD < _this._materialPromiseLODs.length; indexLOD++) {
-                            _loop_2(indexLOD);
-                        }
-                    });
                     return _this;
                 }
                 MSFT_lod.prototype.dispose = function () {
@@ -4660,6 +4677,49 @@ var BABYLON;
                     this.onMaterialLODsLoadedObservable.clear();
                     this.onNodeLODsLoadedObservable.clear();
                 };
+                MSFT_lod.prototype._onReady = function () {
+                    var _this = this;
+                    var _loop_1 = function (indexLOD) {
+                        var promise = Promise.all(this_1._nodePromiseLODs[indexLOD]).then(function () {
+                            if (indexLOD !== 0) {
+                                _this._loader._parent._endPerformanceCounter("Node LOD " + indexLOD);
+                            }
+                            _this._loader._parent._log("Loaded node LOD " + indexLOD);
+                            _this.onNodeLODsLoadedObservable.notifyObservers(indexLOD);
+                            if (indexLOD !== _this._nodePromiseLODs.length - 1) {
+                                _this._loader._parent._startPerformanceCounter("Node LOD " + (indexLOD + 1));
+                                if (_this._nodeSignalLODs[indexLOD]) {
+                                    _this._nodeSignalLODs[indexLOD].resolve();
+                                }
+                            }
+                        });
+                        this_1._loader._completePromises.push(promise);
+                    };
+                    var this_1 = this;
+                    for (var indexLOD = 0; indexLOD < this._nodePromiseLODs.length; indexLOD++) {
+                        _loop_1(indexLOD);
+                    }
+                    var _loop_2 = function (indexLOD) {
+                        var promise = Promise.all(this_2._materialPromiseLODs[indexLOD]).then(function () {
+                            if (indexLOD !== 0) {
+                                _this._loader._parent._endPerformanceCounter("Material LOD " + indexLOD);
+                            }
+                            _this._loader._parent._log("Loaded material LOD " + indexLOD);
+                            _this.onMaterialLODsLoadedObservable.notifyObservers(indexLOD);
+                            if (indexLOD !== _this._materialPromiseLODs.length - 1) {
+                                _this._loader._parent._startPerformanceCounter("Material LOD " + (indexLOD + 1));
+                                if (_this._materialSignalLODs[indexLOD]) {
+                                    _this._materialSignalLODs[indexLOD].resolve();
+                                }
+                            }
+                        });
+                        this_2._loader._completePromises.push(promise);
+                    };
+                    var this_2 = this;
+                    for (var indexLOD = 0; indexLOD < this._materialPromiseLODs.length; indexLOD++) {
+                        _loop_2(indexLOD);
+                    }
+                };
                 MSFT_lod.prototype._loadNodeAsync = function (context, node) {
                     var _this = this;
                     return this._loadExtensionAsync(context, node, function (extensionContext, extension) {
@@ -4884,23 +4944,25 @@ var BABYLON;
                     _this.name = NAME;
                     return _this;
                 }
-                MSFT_sRGBFactors.prototype._loadMaterialAsync = function (context, material, mesh, babylonMesh, babylonDrawMode, assign) {
+                MSFT_sRGBFactors.prototype._loadMaterialPropertiesAsync = function (context, material, babylonMaterial) {
                     var _this = this;
                     return this._loadExtrasValueAsync(context, material, function (extensionContext, value) {
                         if (value) {
-                            return _this._loader._loadMaterialAsync(context, material, mesh, babylonMesh, babylonDrawMode, function (babylonMaterial) {
-                                if (!babylonMaterial.albedoTexture) {
-                                    babylonMaterial.albedoColor.toLinearSpaceToRef(babylonMaterial.albedoColor);
-                                }
-                                if (!babylonMaterial.reflectivityTexture) {
-                                    babylonMaterial.reflectivityColor.toLinearSpaceToRef(babylonMaterial.reflectivityColor);
-                                }
-                                assign(babylonMaterial);
-                            });
+                            var promise = _this._loader._loadMaterialPropertiesAsync(context, material, babylonMaterial);
+                            _this._convertColorsToLinear(babylonMaterial);
+                            return promise;
                         }
                         return null;
                     });
                 };
+                MSFT_sRGBFactors.prototype._convertColorsToLinear = function (babylonMaterial) {
+                    if (!babylonMaterial.albedoTexture) {
+                        babylonMaterial.albedoColor.toLinearSpaceToRef(babylonMaterial.albedoColor);
+                    }
+                    if (!babylonMaterial.reflectivityTexture) {
+                        babylonMaterial.reflectivityColor.toLinearSpaceToRef(babylonMaterial.reflectivityColor);
+                    }
+                };
                 return MSFT_sRGBFactors;
             }(GLTF2.GLTFLoaderExtension));
             Extensions.MSFT_sRGBFactors = MSFT_sRGBFactors;
@@ -5191,6 +5253,13 @@ var BABYLON;
                     _this.name = NAME;
                     return _this;
                 }
+                KHR_lights.prototype._onLoading = function () {
+                    var extensions = this._loader._gltf.extensions;
+                    if (extensions && extensions[this.name]) {
+                        var extension = extensions[this.name];
+                        this._lights = extension.lights;
+                    }
+                };
                 KHR_lights.prototype._loadSceneAsync = function (context, scene) {
                     var _this = this;
                     return this._loadExtensionAsync(context, scene, function (extensionContext, extension) {
@@ -5239,18 +5308,6 @@ var BABYLON;
                         return promise;
                     });
                 };
-                Object.defineProperty(KHR_lights.prototype, "_lights", {
-                    get: function () {
-                        var extensions = this._loader._gltf.extensions;
-                        if (!extensions || !extensions[this.name]) {
-                            throw new Error("#/extensions: '" + this.name + "' not found");
-                        }
-                        var extension = extensions[this.name];
-                        return extension.lights;
-                    },
-                    enumerable: true,
-                    configurable: true
-                });
                 return KHR_lights;
             }(GLTF2.GLTFLoaderExtension));
             Extensions.KHR_lights = KHR_lights;
@@ -5348,6 +5405,13 @@ var BABYLON;
                     _this.name = NAME;
                     return _this;
                 }
+                EXT_lights_imageBased.prototype._onLoading = function () {
+                    var extensions = this._loader._gltf.extensions;
+                    if (extensions && extensions[this.name]) {
+                        var extension = extensions[this.name];
+                        this._lights = extension.lights;
+                    }
+                };
                 EXT_lights_imageBased.prototype._loadSceneAsync = function (context, scene) {
                     var _this = this;
                     return this._loadExtensionAsync(context, scene, function (extensionContext, extension) {
@@ -5417,18 +5481,6 @@ var BABYLON;
                         return light._babylonTexture;
                     });
                 };
-                Object.defineProperty(EXT_lights_imageBased.prototype, "_lights", {
-                    get: function () {
-                        var extensions = this._loader._gltf.extensions;
-                        if (!extensions || !extensions[this.name]) {
-                            throw new Error("#/extensions: '" + this.name + "' not found");
-                        }
-                        var extension = extensions[this.name];
-                        return extension.lights;
-                    },
-                    enumerable: true,
-                    configurable: true
-                });
                 return EXT_lights_imageBased;
             }(GLTF2.GLTFLoaderExtension));
             Extensions.EXT_lights_imageBased = EXT_lights_imageBased;

Файловите разлики са ограничени, защото са твърде много
+ 4 - 4
dist/preview release/loaders/babylon.glTFFileLoader.min.js


+ 3 - 3
dist/preview release/loaders/babylon.objFileLoader.d.ts

@@ -26,7 +26,7 @@ declare module BABYLON {
          * @param value The value stored in the mtl
          * @return The Texture
          */
-        private static _getTexture(rootUrl, value, scene);
+        private static _getTexture;
     }
     class OBJFileLoader implements ISceneLoaderPluginAsync {
         static OPTIMIZE_WITH_UV: boolean;
@@ -57,7 +57,7 @@ declare module BABYLON {
          * @param onSuccess Callback function to be called when the MTL file is loaded
          * @private
          */
-        private _loadMTL(url, rootUrl, onSuccess);
+        private _loadMTL;
         importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
             meshes: AbstractMesh[];
             particleSystems: IParticleSystem[];
@@ -78,6 +78,6 @@ declare module BABYLON {
          * @returns Array<AbstractMesh>
          * @private
          */
-        private _parseSolid(meshesNames, scene, data, rootUrl);
+        private _parseSolid;
     }
 }

+ 3 - 3
dist/preview release/loaders/babylon.stlFileLoader.d.ts

@@ -10,8 +10,8 @@ declare module BABYLON {
         importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
         load(scene: Scene, data: any, rootUrl: string): boolean;
         loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
-        private isBinary(data);
-        private parseBinary(mesh, data);
-        private parseASCII(mesh, solidData);
+        private isBinary;
+        private parseBinary;
+        private parseASCII;
     }
 }

+ 129 - 99
dist/preview release/loaders/babylonjs.loaders.d.ts

@@ -10,9 +10,9 @@ declare module BABYLON {
         importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
         load(scene: Scene, data: any, rootUrl: string): boolean;
         loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
-        private isBinary(data);
-        private parseBinary(mesh, data);
-        private parseASCII(mesh, solidData);
+        private isBinary;
+        private parseBinary;
+        private parseASCII;
     }
 }
 
@@ -44,7 +44,7 @@ declare module BABYLON {
          * @param value The value stored in the mtl
          * @return The Texture
          */
-        private static _getTexture(rootUrl, value, scene);
+        private static _getTexture;
     }
     class OBJFileLoader implements ISceneLoaderPluginAsync {
         static OPTIMIZE_WITH_UV: boolean;
@@ -75,7 +75,7 @@ declare module BABYLON {
          * @param onSuccess Callback function to be called when the MTL file is loaded
          * @private
          */
-        private _loadMTL(url, rootUrl, onSuccess);
+        private _loadMTL;
         importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
             meshes: AbstractMesh[];
             particleSystems: IParticleSystem[];
@@ -96,7 +96,7 @@ declare module BABYLON {
          * @returns Array<AbstractMesh>
          * @private
          */
-        private _parseSolid(meshesNames, scene, data, rootUrl);
+        private _parseSolid;
     }
 }
 
@@ -113,7 +113,7 @@ declare module BABYLON {
         /**
          * Sets the useRightHandedSystem flag on the scene.
          */
-        FORCE_RIGHT_HANDED = 1,
+        FORCE_RIGHT_HANDED = 1
     }
     /**
      * Mode that determines what animations will start.
@@ -130,7 +130,7 @@ declare module BABYLON {
         /**
          * All animations will start.
          */
-        ALL = 2,
+        ALL = 2
     }
     /**
      * Interface that contains the data for the glTF asset.
@@ -173,7 +173,7 @@ declare module BABYLON {
         /**
          * The asset is completely loaded.
          */
-        COMPLETE = 2,
+        COMPLETE = 2
     }
     /** @hidden */
     interface IGLTFLoader extends IDisposable {
@@ -293,9 +293,20 @@ declare module BABYLON {
         private _onCompleteObserver;
         /**
          * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
+         * For assets with LODs, raised when all of the LODs are complete.
+         * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
          */
         onComplete: () => void;
         /**
+         * Observable raised when an error occurs.
+         */
+        readonly onErrorObservable: Observable<any>;
+        private _onErrorObserver;
+        /**
+         * Callback raised when an error occurs.
+         */
+        onError: (reason: any) => void;
+        /**
          * Observable raised after the loader is disposed.
          */
         readonly onDisposeObservable: Observable<void>;
@@ -394,14 +405,14 @@ declare module BABYLON {
          * @returns the created plugin
          */
         createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
-        private _parse(data);
-        private _getLoader(loaderData);
-        private _parseBinary(data);
-        private _parseV1(binaryReader);
-        private _parseV2(binaryReader);
-        private static _parseVersion(version);
-        private static _compareVersion(a, b);
-        private static _decodeBufferToText(buffer);
+        private _parse;
+        private _getLoader;
+        private _parseBinary;
+        private _parseV1;
+        private _parseV2;
+        private static _parseVersion;
+        private static _compareVersion;
+        private static _decodeBufferToText;
         private static readonly _logSpaces;
         private _logIndentLevel;
         private _loggingEnabled;
@@ -411,17 +422,17 @@ declare module BABYLON {
         _logOpen(message: string): void;
         /** @hidden */
         _logClose(): void;
-        private _logEnabled(message);
-        private _logDisabled(message);
+        private _logEnabled;
+        private _logDisabled;
         private _capturePerformanceCounters;
         /** @hidden */
         _startPerformanceCounter: (counterName: string) => void;
         /** @hidden */
         _endPerformanceCounter: (counterName: string) => void;
-        private _startPerformanceCounterEnabled(counterName);
-        private _startPerformanceCounterDisabled(counterName);
-        private _endPerformanceCounterEnabled(counterName);
-        private _endPerformanceCounterDisabled(counterName);
+        private _startPerformanceCounterEnabled;
+        private _startPerformanceCounterDisabled;
+        private _endPerformanceCounterEnabled;
+        private _endPerformanceCounterDisabled;
     }
 }
 
@@ -435,11 +446,11 @@ declare module BABYLON.GLTF1 {
         UNSIGNED_BYTE = 5121,
         SHORT = 5122,
         UNSIGNED_SHORT = 5123,
-        FLOAT = 5126,
+        FLOAT = 5126
     }
     enum EShaderType {
         FRAGMENT = 35632,
-        VERTEX = 35633,
+        VERTEX = 35633
     }
     enum EParameterType {
         BYTE = 5120,
@@ -462,12 +473,12 @@ declare module BABYLON.GLTF1 {
         FLOAT_MAT2 = 35674,
         FLOAT_MAT3 = 35675,
         FLOAT_MAT4 = 35676,
-        SAMPLER_2D = 35678,
+        SAMPLER_2D = 35678
     }
     enum ETextureWrapMode {
         CLAMP_TO_EDGE = 33071,
         MIRRORED_REPEAT = 33648,
-        REPEAT = 10497,
+        REPEAT = 10497
     }
     enum ETextureFilterType {
         NEAREST = 9728,
@@ -475,19 +486,19 @@ declare module BABYLON.GLTF1 {
         NEAREST_MIPMAP_NEAREST = 9984,
         LINEAR_MIPMAP_NEAREST = 9985,
         NEAREST_MIPMAP_LINEAR = 9986,
-        LINEAR_MIPMAP_LINEAR = 9987,
+        LINEAR_MIPMAP_LINEAR = 9987
     }
     enum ETextureFormat {
         ALPHA = 6406,
         RGB = 6407,
         RGBA = 6408,
         LUMINANCE = 6409,
-        LUMINANCE_ALPHA = 6410,
+        LUMINANCE_ALPHA = 6410
     }
     enum ECullingType {
         FRONT = 1028,
         BACK = 1029,
-        FRONT_AND_BACK = 1032,
+        FRONT_AND_BACK = 1032
     }
     enum EBlendingFunction {
         ZERO = 0,
@@ -504,7 +515,7 @@ declare module BABYLON.GLTF1 {
         ONE_MINUS_CONSTANT_COLOR = 32770,
         CONSTANT_ALPHA = 32771,
         ONE_MINUS_CONSTANT_ALPHA = 32772,
-        SRC_ALPHA_SATURATE = 776,
+        SRC_ALPHA_SATURATE = 776
     }
     /**
     * Interfaces
@@ -820,7 +831,7 @@ declare module BABYLON.GLTF1 {
         static RegisterExtension(extension: GLTFLoaderExtension): void;
         state: Nullable<GLTFLoaderState>;
         dispose(): void;
-        private _importMeshAsync(meshesNames, scene, data, rootUrl, onSuccess, onProgress?, onError?);
+        private _importMeshAsync;
         /**
         * Imports one or more meshes from a loaded gltf file and adds them to the scene
         * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
@@ -836,7 +847,7 @@ declare module BABYLON.GLTF1 {
             skeletons: Skeleton[];
             animationGroups: AnimationGroup[];
         }>;
-        private _loadAsync(scene, data, rootUrl, onSuccess, onProgress?, onError?);
+        private _loadAsync;
         /**
         * Imports all objects from a loaded gltf file and adds them to the scene
         * @param scene the scene the objects should be added to
@@ -846,9 +857,9 @@ declare module BABYLON.GLTF1 {
         * @returns a promise which completes when objects have been loaded to the scene
         */
         loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
-        private _loadShadersAsync(gltfRuntime, onload);
-        private _loadBuffersAsync(gltfRuntime, onLoad, onProgress?);
-        private _createNodes(gltfRuntime);
+        private _loadShadersAsync;
+        private _loadBuffersAsync;
+        private _createNodes;
     }
 }
 
@@ -959,9 +970,9 @@ declare module BABYLON.GLTF1 {
         static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
         static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
         static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
-        private static LoadTextureBufferAsync(gltfRuntime, id, onSuccess, onError);
-        private static CreateTextureAsync(gltfRuntime, id, buffer, onSuccess, onError);
-        private static ApplyExtensions(func, defaultFunc);
+        private static LoadTextureBufferAsync;
+        private static CreateTextureAsync;
+        private static ApplyExtensions;
     }
 }
 
@@ -983,7 +994,7 @@ declare module BABYLON.GLTF1 {
         constructor();
         loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
         loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
-        private _loadTexture(gltfRuntime, id, material, propertyPath, onError);
+        private _loadTexture;
     }
 }
 
@@ -1113,7 +1124,6 @@ declare module BABYLON.GLTF2 {
         _parent: GLTFFileLoader;
         _gltf: _ILoaderGLTF;
         _babylonScene: Scene;
-        _readyPromise: Promise<void>;
         _completePromises: Promise<void>[];
         private _disposed;
         private _state;
@@ -1127,9 +1137,6 @@ declare module BABYLON.GLTF2 {
         private static _ExtensionNames;
         private static _ExtensionFactories;
         static _Register(name: string, factory: (loader: GLTFLoader) => GLTFLoaderExtension): void;
-        /**
-         * Loader state or null if the loader is not active.
-         */
         readonly state: Nullable<GLTFLoaderState>;
         constructor(parent: GLTFFileLoader);
         dispose(): void;
@@ -1140,45 +1147,46 @@ declare module BABYLON.GLTF2 {
             animationGroups: AnimationGroup[];
         }>;
         loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
-        private _loadAsync(nodes);
-        private _loadData(data);
-        private _setupData();
-        private _loadExtensions();
-        private _checkExtensions();
-        private _createRootNode();
+        private _loadAsync;
+        private _loadData;
+        private _setupData;
+        private _loadExtensions;
+        private _checkExtensions;
+        private _setState;
+        private _createRootNode;
         _loadSceneAsync(context: string, scene: _ILoaderScene): Promise<void>;
-        private _forEachPrimitive(node, callback);
-        private _getMeshes();
-        private _getSkeletons();
-        private _getAnimationGroups();
-        private _startAnimations();
+        private _forEachPrimitive;
+        private _getMeshes;
+        private _getSkeletons;
+        private _getAnimationGroups;
+        private _startAnimations;
         _loadNodeAsync(context: string, node: _ILoaderNode): Promise<void>;
-        private _loadMeshAsync(context, node, mesh, babylonMesh);
-        private _loadPrimitiveAsync(context, node, mesh, primitive, babylonMesh);
-        private _loadVertexDataAsync(context, primitive, babylonMesh);
-        private _createMorphTargets(context, node, mesh, primitive, babylonMesh);
-        private _loadMorphTargetsAsync(context, primitive, babylonMesh, babylonGeometry);
-        private _loadMorphTargetVertexDataAsync(context, babylonGeometry, attributes, babylonMorphTarget);
-        private static _LoadTransform(node, babylonNode);
-        private _loadSkinAsync(context, node, mesh, skin);
-        private _loadBones(context, skin);
-        private _loadBone(node, skin, babylonBones);
-        private _loadSkinInverseBindMatricesDataAsync(context, skin);
-        private _updateBoneMatrices(babylonSkeleton, inverseBindMatricesData);
-        private _getNodeMatrix(node);
-        private _loadCamera(context, camera, babylonMesh);
-        private _loadAnimationsAsync();
-        private _loadAnimationAsync(context, animation);
-        private _loadAnimationChannelAsync(context, animationContext, animation, channel, babylonAnimationGroup);
-        private _loadAnimationSamplerAsync(context, sampler);
-        private _loadBufferAsync(context, buffer);
+        private _loadMeshAsync;
+        private _loadPrimitiveAsync;
+        private _loadVertexDataAsync;
+        private _createMorphTargets;
+        private _loadMorphTargetsAsync;
+        private _loadMorphTargetVertexDataAsync;
+        private static _LoadTransform;
+        private _loadSkinAsync;
+        private _loadBones;
+        private _loadBone;
+        private _loadSkinInverseBindMatricesDataAsync;
+        private _updateBoneMatrices;
+        private _getNodeMatrix;
+        private _loadCamera;
+        private _loadAnimationsAsync;
+        private _loadAnimationAsync;
+        private _loadAnimationChannelAsync;
+        private _loadAnimationSamplerAsync;
+        private _loadBufferAsync;
         _loadBufferViewAsync(context: string, bufferView: _ILoaderBufferView): Promise<ArrayBufferView>;
-        private _loadIndicesAccessorAsync(context, accessor);
-        private _loadFloatAccessorAsync(context, accessor);
+        private _loadIndicesAccessorAsync;
+        private _loadFloatAccessorAsync;
         _loadVertexBufferViewAsync(context: string, bufferView: _ILoaderBufferView, kind: string): Promise<Buffer>;
-        private _loadVertexAccessorAsync(context, accessor, kind);
-        private _getDefaultMaterial(drawMode);
-        private _loadMaterialMetallicRoughnessPropertiesAsync(context, material, babylonMaterial);
+        private _loadVertexAccessorAsync;
+        private _getDefaultMaterial;
+        private _loadMaterialMetallicRoughnessPropertiesAsync;
         _loadMaterialAsync(context: string, material: _ILoaderMaterial, mesh: _ILoaderMesh, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Promise<void>;
         _loadMaterialPropertiesAsync(context: string, material: _ILoaderMaterial, babylonMaterial: Material): Promise<void>;
         _createMaterial(name: string, drawMode: number): PBRMaterial;
@@ -1186,20 +1194,21 @@ declare module BABYLON.GLTF2 {
         _loadMaterialAlphaProperties(context: string, material: _ILoaderMaterial, babylonMaterial: PBRMaterial): void;
         _loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: Texture) => void): Promise<void>;
         _loadTextureAsync(context: string, texture: _ILoaderTexture, assign: (babylonTexture: Texture) => void): Promise<void>;
-        private _loadSampler(context, sampler);
+        private _loadSampler;
         _loadImageAsync(context: string, image: _ILoaderImage): Promise<ArrayBufferView>;
         _loadUriAsync(context: string, uri: string): Promise<ArrayBufferView>;
-        private _onProgress();
+        private _onProgress;
         static _GetProperty<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
-        private static _GetTextureWrapMode(context, mode);
-        private static _GetTextureSamplingMode(context, magFilter?, minFilter?);
-        private static _GetTypedArray(context, componentType, bufferView, byteOffset, length);
-        private static _GetNumComponents(context, type);
-        private static _ValidateUri(uri);
-        private static _GetDrawMode(context, mode);
-        private _compileMaterialsAsync();
-        private _compileShadowGeneratorsAsync();
+        private static _GetTextureWrapMode;
+        private static _GetTextureSamplingMode;
+        private static _GetTypedArray;
+        private static _GetNumComponents;
+        private static _ValidateUri;
+        private static _GetDrawMode;
+        private _compileMaterialsAsync;
+        private _compileShadowGeneratorsAsync;
         _applyExtensions<T>(actionAsync: (extension: GLTFLoaderExtension) => Nullable<Promise<T>>): Nullable<Promise<T>>;
+        _forEachExtensions(action: (extension: GLTFLoaderExtension) => void): void;
     }
 }
 
@@ -1216,7 +1225,7 @@ declare module BABYLON.GLTF2 {
         /**
          * Gets or sets extension name
          */
-        readonly abstract name: string;
+        abstract readonly name: string;
         protected _loader: GLTFLoader;
         /**
          * Creates new GLTFLoaderExtension
@@ -1228,6 +1237,14 @@ declare module BABYLON.GLTF2 {
          */
         dispose(): void;
         /**
+         * Override this method to do work after the state changes to LOADING.
+         */
+        protected _onLoading(): void;
+        /**
+         * Override this method to do work after the state changes to READY.
+         */
+        protected _onReady(): void;
+        /**
          * Override this method to modify the default behavior for loading scenes.
          * @hidden
          */
@@ -1278,6 +1295,16 @@ declare module BABYLON.GLTF2 {
          */
         protected _loadExtrasValueAsync<TProperty, TResult = void>(context: string, property: IProperty, actionAsync: (extensionContext: string, value: TProperty) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
         /**
+         * Helper method called by the loader after the state changes to LOADING.
+         * @hidden
+         */
+        static _OnLoading(loader: GLTFLoader): void;
+        /**
+         * Helper method called by the loader after the state changes to READY.
+         * @hidden
+         */
+        static _OnReady(loader: GLTFLoader): void;
+        /**
          * Helper method called by the loader to allow extensions to override loading scenes.
          * @hidden
          */
@@ -1354,16 +1381,16 @@ declare module BABYLON.GLTF2.Extensions {
         private _materialIndexLOD;
         private _materialSignalLODs;
         private _materialPromiseLODs;
-        constructor(loader: GLTFLoader);
         dispose(): void;
+        protected _onReady(): void;
         protected _loadNodeAsync(context: string, node: _ILoaderNode): Nullable<Promise<void>>;
         protected _loadMaterialAsync(context: string, material: _ILoaderMaterial, mesh: _ILoaderMesh, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<void>>;
         protected _loadUriAsync(context: string, uri: string): Nullable<Promise<ArrayBufferView>>;
         /**
          * Gets an array of LOD properties from lowest to highest.
          */
-        private _getLODs<T>(context, property, array, ids);
-        private _disposeUnusedMaterials();
+        private _getLODs;
+        private _disposeUnusedMaterials;
     }
 }
 
@@ -1381,7 +1408,8 @@ declare module BABYLON.GLTF2.Extensions {
     /** @hidden */
     class MSFT_sRGBFactors extends GLTFLoaderExtension {
         readonly name: string;
-        protected _loadMaterialAsync(context: string, material: _ILoaderMaterial, mesh: _ILoaderMesh, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<void>>;
+        protected _loadMaterialPropertiesAsync(context: string, material: _ILoaderMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
+        private _convertColorsToLinear;
     }
 }
 
@@ -1407,7 +1435,7 @@ declare module BABYLON.GLTF2.Extensions {
     class KHR_materials_pbrSpecularGlossiness extends GLTFLoaderExtension {
         readonly name: string;
         protected _loadMaterialPropertiesAsync(context: string, material: _ILoaderMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
-        private _loadSpecularGlossinessPropertiesAsync(context, material, properties, babylonMaterial);
+        private _loadSpecularGlossinessPropertiesAsync;
     }
 }
 
@@ -1419,7 +1447,7 @@ declare module BABYLON.GLTF2.Extensions {
     class KHR_materials_unlit extends GLTFLoaderExtension {
         readonly name: string;
         protected _loadMaterialPropertiesAsync(context: string, material: _ILoaderMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
-        private _loadUnlitPropertiesAsync(context, material, babylonMaterial);
+        private _loadUnlitPropertiesAsync;
     }
 }
 
@@ -1430,9 +1458,10 @@ declare module BABYLON.GLTF2.Extensions {
      */
     class KHR_lights extends GLTFLoaderExtension {
         readonly name: string;
+        private _lights?;
+        protected _onLoading(): void;
         protected _loadSceneAsync(context: string, scene: _ILoaderScene): Nullable<Promise<void>>;
         protected _loadNodeAsync(context: string, node: _ILoaderNode): Nullable<Promise<void>>;
-        private readonly _lights;
     }
 }
 
@@ -1454,8 +1483,9 @@ declare module BABYLON.GLTF2.Extensions {
      */
     class EXT_lights_imageBased extends GLTFLoaderExtension {
         readonly name: string;
+        private _lights?;
+        protected _onLoading(): void;
         protected _loadSceneAsync(context: string, scene: _ILoaderScene): Nullable<Promise<void>>;
-        private _loadLightAsync(context, light);
-        private readonly _lights;
+        private _loadLightAsync;
     }
 }

+ 146 - 94
dist/preview release/loaders/babylonjs.loaders.js

@@ -1173,6 +1173,10 @@ var BABYLON;
              */
             this.onCompleteObservable = new BABYLON.Observable();
             /**
+             * Observable raised when an error occurs.
+             */
+            this.onErrorObservable = new BABYLON.Observable();
+            /**
              * Observable raised after the loader is disposed.
              */
             this.onDisposeObservable = new BABYLON.Observable();
@@ -1272,6 +1276,8 @@ var BABYLON;
         Object.defineProperty(GLTFFileLoader.prototype, "onComplete", {
             /**
              * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
+             * For assets with LODs, raised when all of the LODs are complete.
+             * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
              */
             set: function (callback) {
                 if (this._onCompleteObserver) {
@@ -1282,6 +1288,19 @@ var BABYLON;
             enumerable: true,
             configurable: true
         });
+        Object.defineProperty(GLTFFileLoader.prototype, "onError", {
+            /**
+             * Callback raised when an error occurs.
+             */
+            set: function (callback) {
+                if (this._onErrorObserver) {
+                    this.onErrorObservable.remove(this._onErrorObserver);
+                }
+                this._onErrorObserver = this.onErrorObservable.add(callback);
+            },
+            enumerable: true,
+            configurable: true
+        });
         Object.defineProperty(GLTFFileLoader.prototype, "onDispose", {
             /**
              * Callback raised after the loader is disposed.
@@ -1314,10 +1333,13 @@ var BABYLON;
          */
         GLTFFileLoader.prototype.whenCompleteAsync = function () {
             var _this = this;
-            return new Promise(function (resolve) {
+            return new Promise(function (resolve, reject) {
                 _this.onCompleteObservable.addOnce(function () {
                     resolve();
                 });
+                _this.onErrorObservable.addOnce(function (reason) {
+                    reject(reason);
+                });
             });
         };
         Object.defineProperty(GLTFFileLoader.prototype, "loaderState", {
@@ -3951,9 +3973,6 @@ var BABYLON;
                 GLTFLoader._ExtensionNames.push(name);
             };
             Object.defineProperty(GLTFLoader.prototype, "state", {
-                /**
-                 * Loader state or null if the loader is not active.
-                 */
                 get: function () {
                     return this._state;
                 },
@@ -3972,7 +3991,6 @@ var BABYLON;
                 this._requests.length = 0;
                 delete this._gltf;
                 delete this._babylonScene;
-                delete this._readyPromise;
                 this._completePromises.length = 0;
                 for (var name_1 in this._extensions) {
                     this._extensions[name_1].dispose();
@@ -4032,14 +4050,14 @@ var BABYLON;
             GLTFLoader.prototype._loadAsync = function (nodes) {
                 var _this = this;
                 return Promise.resolve().then(function () {
-                    _this._parent._startPerformanceCounter("Loading => Ready");
-                    _this._parent._startPerformanceCounter("Loading => Complete");
-                    _this._state = BABYLON.GLTFLoaderState.LOADING;
-                    _this._parent._log("Loading");
-                    var readyDeferred = new BABYLON.Deferred();
-                    _this._readyPromise = readyDeferred.promise;
                     _this._loadExtensions();
                     _this._checkExtensions();
+                    var loadingToReadyCounterName = BABYLON.GLTFLoaderState[BABYLON.GLTFLoaderState.LOADING] + " => " + BABYLON.GLTFLoaderState[BABYLON.GLTFLoaderState.READY];
+                    var loadingToCompleteCounterName = BABYLON.GLTFLoaderState[BABYLON.GLTFLoaderState.LOADING] + " => " + BABYLON.GLTFLoaderState[BABYLON.GLTFLoaderState.COMPLETE];
+                    _this._parent._startPerformanceCounter(loadingToReadyCounterName);
+                    _this._parent._startPerformanceCounter(loadingToCompleteCounterName);
+                    _this._setState(BABYLON.GLTFLoaderState.LOADING);
+                    GLTF2.GLTFLoaderExtension._OnLoading(_this);
                     var promises = new Array();
                     if (nodes) {
                         promises.push(_this._loadSceneAsync("#/nodes", { nodes: nodes, _index: -1 }));
@@ -4055,33 +4073,33 @@ var BABYLON;
                         promises.push(_this._compileShadowGeneratorsAsync());
                     }
                     var resultPromise = Promise.all(promises).then(function () {
-                        _this._state = BABYLON.GLTFLoaderState.READY;
-                        _this._parent._log("Ready");
-                        readyDeferred.resolve();
+                        _this._setState(BABYLON.GLTFLoaderState.READY);
+                        GLTF2.GLTFLoaderExtension._OnReady(_this);
                         _this._startAnimations();
                     });
                     resultPromise.then(function () {
-                        _this._parent._endPerformanceCounter("Loading => Ready");
+                        _this._parent._endPerformanceCounter(loadingToReadyCounterName);
                         BABYLON.Tools.SetImmediate(function () {
                             if (!_this._disposed) {
                                 Promise.all(_this._completePromises).then(function () {
-                                    _this._parent._endPerformanceCounter("Loading => Complete");
-                                    _this._state = BABYLON.GLTFLoaderState.COMPLETE;
-                                    _this._parent._log("Complete");
+                                    _this._parent._endPerformanceCounter(loadingToCompleteCounterName);
+                                    _this._setState(BABYLON.GLTFLoaderState.COMPLETE);
                                     _this._parent.onCompleteObservable.notifyObservers(undefined);
                                     _this._parent.onCompleteObservable.clear();
                                     _this.dispose();
-                                }).catch(function (error) {
-                                    BABYLON.Tools.Error("glTF Loader: " + error.message);
+                                }, function (error) {
+                                    _this._parent.onErrorObservable.notifyObservers(error);
+                                    _this._parent.onErrorObservable.clear();
                                     _this.dispose();
                                 });
                             }
                         });
                     });
                     return resultPromise;
-                }).catch(function (error) {
+                }, function (error) {
                     if (!_this._disposed) {
-                        BABYLON.Tools.Error("glTF Loader: " + error.message);
+                        _this._parent.onErrorObservable.notifyObservers(error);
+                        _this._parent.onErrorObservable.clear();
                         _this.dispose();
                         throw error;
                     }
@@ -4157,6 +4175,10 @@ var BABYLON;
                     }
                 }
             };
+            GLTFLoader.prototype._setState = function (state) {
+                this._state = state;
+                this._parent._log(BABYLON.GLTFLoaderState[this._state]);
+            };
             GLTFLoader.prototype._createRootNode = function () {
                 this._rootBabylonMesh = new BABYLON.Mesh("__root__", this._babylonScene);
                 var rootNode = { _babylonMesh: this._rootBabylonMesh };
@@ -5411,6 +5433,15 @@ var BABYLON;
                 }
                 return null;
             };
+            GLTFLoader.prototype._forEachExtensions = function (action) {
+                for (var _i = 0, _a = GLTFLoader._ExtensionNames; _i < _a.length; _i++) {
+                    var name_6 = _a[_i];
+                    var extension = this._extensions[name_6];
+                    if (extension.enabled) {
+                        action(extension);
+                    }
+                }
+            };
             GLTFLoader._ExtensionNames = new Array();
             GLTFLoader._ExtensionFactories = {};
             return GLTFLoader;
@@ -5450,6 +5481,14 @@ var BABYLON;
             };
             // #region Overridable Methods
             /**
+             * Override this method to do work after the state changes to LOADING.
+             */
+            GLTFLoaderExtension.prototype._onLoading = function () { };
+            /**
+             * Override this method to do work after the state changes to READY.
+             */
+            GLTFLoaderExtension.prototype._onReady = function () { };
+            /**
              * Override this method to modify the default behavior for loading scenes.
              * @hidden
              */
@@ -5537,6 +5576,20 @@ var BABYLON;
                 }
             };
             /**
+             * Helper method called by the loader after the state changes to LOADING.
+             * @hidden
+             */
+            GLTFLoaderExtension._OnLoading = function (loader) {
+                loader._forEachExtensions(function (extension) { return extension._onLoading(); });
+            };
+            /**
+             * Helper method called by the loader after the state changes to READY.
+             * @hidden
+             */
+            GLTFLoaderExtension._OnReady = function (loader) {
+                loader._forEachExtensions(function (extension) { return extension._onReady(); });
+            };
+            /**
              * Helper method called by the loader to allow extensions to override loading scenes.
              * @hidden
              */
@@ -5614,8 +5667,8 @@ var BABYLON;
              */
             var MSFT_lod = /** @class */ (function (_super) {
                 __extends(MSFT_lod, _super);
-                function MSFT_lod(loader) {
-                    var _this = _super.call(this, loader) || this;
+                function MSFT_lod() {
+                    var _this = _super !== null && _super.apply(this, arguments) || this;
                     _this.name = NAME;
                     /**
                      * Maximum number of LODs to load, starting from the lowest LOD.
@@ -5639,42 +5692,6 @@ var BABYLON;
                     _this._materialIndexLOD = null;
                     _this._materialSignalLODs = new Array();
                     _this._materialPromiseLODs = new Array();
-                    _this._loader._readyPromise.then(function () {
-                        var _loop_1 = function (indexLOD) {
-                            var promise = Promise.all(_this._nodePromiseLODs[indexLOD]).then(function () {
-                                if (indexLOD !== 0) {
-                                    _this._loader._parent._endPerformanceCounter("Node LOD " + indexLOD);
-                                }
-                                _this._loader._parent._log("Loaded node LOD " + indexLOD);
-                                _this.onNodeLODsLoadedObservable.notifyObservers(indexLOD);
-                                if (indexLOD !== _this._nodePromiseLODs.length - 1) {
-                                    _this._loader._parent._startPerformanceCounter("Node LOD " + (indexLOD + 1));
-                                    _this._nodeSignalLODs[indexLOD].resolve();
-                                }
-                            });
-                            _this._loader._completePromises.push(promise);
-                        };
-                        for (var indexLOD = 0; indexLOD < _this._nodePromiseLODs.length; indexLOD++) {
-                            _loop_1(indexLOD);
-                        }
-                        var _loop_2 = function (indexLOD) {
-                            var promise = Promise.all(_this._materialPromiseLODs[indexLOD]).then(function () {
-                                if (indexLOD !== 0) {
-                                    _this._loader._parent._endPerformanceCounter("Material LOD " + indexLOD);
-                                }
-                                _this._loader._parent._log("Loaded material LOD " + indexLOD);
-                                _this.onMaterialLODsLoadedObservable.notifyObservers(indexLOD);
-                                if (indexLOD !== _this._materialPromiseLODs.length - 1) {
-                                    _this._loader._parent._startPerformanceCounter("Material LOD " + (indexLOD + 1));
-                                    _this._materialSignalLODs[indexLOD].resolve();
-                                }
-                            });
-                            _this._loader._completePromises.push(promise);
-                        };
-                        for (var indexLOD = 0; indexLOD < _this._materialPromiseLODs.length; indexLOD++) {
-                            _loop_2(indexLOD);
-                        }
-                    });
                     return _this;
                 }
                 MSFT_lod.prototype.dispose = function () {
@@ -5688,6 +5705,49 @@ var BABYLON;
                     this.onMaterialLODsLoadedObservable.clear();
                     this.onNodeLODsLoadedObservable.clear();
                 };
+                MSFT_lod.prototype._onReady = function () {
+                    var _this = this;
+                    var _loop_1 = function (indexLOD) {
+                        var promise = Promise.all(this_1._nodePromiseLODs[indexLOD]).then(function () {
+                            if (indexLOD !== 0) {
+                                _this._loader._parent._endPerformanceCounter("Node LOD " + indexLOD);
+                            }
+                            _this._loader._parent._log("Loaded node LOD " + indexLOD);
+                            _this.onNodeLODsLoadedObservable.notifyObservers(indexLOD);
+                            if (indexLOD !== _this._nodePromiseLODs.length - 1) {
+                                _this._loader._parent._startPerformanceCounter("Node LOD " + (indexLOD + 1));
+                                if (_this._nodeSignalLODs[indexLOD]) {
+                                    _this._nodeSignalLODs[indexLOD].resolve();
+                                }
+                            }
+                        });
+                        this_1._loader._completePromises.push(promise);
+                    };
+                    var this_1 = this;
+                    for (var indexLOD = 0; indexLOD < this._nodePromiseLODs.length; indexLOD++) {
+                        _loop_1(indexLOD);
+                    }
+                    var _loop_2 = function (indexLOD) {
+                        var promise = Promise.all(this_2._materialPromiseLODs[indexLOD]).then(function () {
+                            if (indexLOD !== 0) {
+                                _this._loader._parent._endPerformanceCounter("Material LOD " + indexLOD);
+                            }
+                            _this._loader._parent._log("Loaded material LOD " + indexLOD);
+                            _this.onMaterialLODsLoadedObservable.notifyObservers(indexLOD);
+                            if (indexLOD !== _this._materialPromiseLODs.length - 1) {
+                                _this._loader._parent._startPerformanceCounter("Material LOD " + (indexLOD + 1));
+                                if (_this._materialSignalLODs[indexLOD]) {
+                                    _this._materialSignalLODs[indexLOD].resolve();
+                                }
+                            }
+                        });
+                        this_2._loader._completePromises.push(promise);
+                    };
+                    var this_2 = this;
+                    for (var indexLOD = 0; indexLOD < this._materialPromiseLODs.length; indexLOD++) {
+                        _loop_2(indexLOD);
+                    }
+                };
                 MSFT_lod.prototype._loadNodeAsync = function (context, node) {
                     var _this = this;
                     return this._loadExtensionAsync(context, node, function (extensionContext, extension) {
@@ -5894,23 +5954,25 @@ var BABYLON;
                     _this.name = NAME;
                     return _this;
                 }
-                MSFT_sRGBFactors.prototype._loadMaterialAsync = function (context, material, mesh, babylonMesh, babylonDrawMode, assign) {
+                MSFT_sRGBFactors.prototype._loadMaterialPropertiesAsync = function (context, material, babylonMaterial) {
                     var _this = this;
                     return this._loadExtrasValueAsync(context, material, function (extensionContext, value) {
                         if (value) {
-                            return _this._loader._loadMaterialAsync(context, material, mesh, babylonMesh, babylonDrawMode, function (babylonMaterial) {
-                                if (!babylonMaterial.albedoTexture) {
-                                    babylonMaterial.albedoColor.toLinearSpaceToRef(babylonMaterial.albedoColor);
-                                }
-                                if (!babylonMaterial.reflectivityTexture) {
-                                    babylonMaterial.reflectivityColor.toLinearSpaceToRef(babylonMaterial.reflectivityColor);
-                                }
-                                assign(babylonMaterial);
-                            });
+                            var promise = _this._loader._loadMaterialPropertiesAsync(context, material, babylonMaterial);
+                            _this._convertColorsToLinear(babylonMaterial);
+                            return promise;
                         }
                         return null;
                     });
                 };
+                MSFT_sRGBFactors.prototype._convertColorsToLinear = function (babylonMaterial) {
+                    if (!babylonMaterial.albedoTexture) {
+                        babylonMaterial.albedoColor.toLinearSpaceToRef(babylonMaterial.albedoColor);
+                    }
+                    if (!babylonMaterial.reflectivityTexture) {
+                        babylonMaterial.reflectivityColor.toLinearSpaceToRef(babylonMaterial.reflectivityColor);
+                    }
+                };
                 return MSFT_sRGBFactors;
             }(GLTF2.GLTFLoaderExtension));
             Extensions.MSFT_sRGBFactors = MSFT_sRGBFactors;
@@ -6165,6 +6227,13 @@ var BABYLON;
                     _this.name = NAME;
                     return _this;
                 }
+                KHR_lights.prototype._onLoading = function () {
+                    var extensions = this._loader._gltf.extensions;
+                    if (extensions && extensions[this.name]) {
+                        var extension = extensions[this.name];
+                        this._lights = extension.lights;
+                    }
+                };
                 KHR_lights.prototype._loadSceneAsync = function (context, scene) {
                     var _this = this;
                     return this._loadExtensionAsync(context, scene, function (extensionContext, extension) {
@@ -6213,18 +6282,6 @@ var BABYLON;
                         return promise;
                     });
                 };
-                Object.defineProperty(KHR_lights.prototype, "_lights", {
-                    get: function () {
-                        var extensions = this._loader._gltf.extensions;
-                        if (!extensions || !extensions[this.name]) {
-                            throw new Error("#/extensions: '" + this.name + "' not found");
-                        }
-                        var extension = extensions[this.name];
-                        return extension.lights;
-                    },
-                    enumerable: true,
-                    configurable: true
-                });
                 return KHR_lights;
             }(GLTF2.GLTFLoaderExtension));
             Extensions.KHR_lights = KHR_lights;
@@ -6304,6 +6361,13 @@ var BABYLON;
                     _this.name = NAME;
                     return _this;
                 }
+                EXT_lights_imageBased.prototype._onLoading = function () {
+                    var extensions = this._loader._gltf.extensions;
+                    if (extensions && extensions[this.name]) {
+                        var extension = extensions[this.name];
+                        this._lights = extension.lights;
+                    }
+                };
                 EXT_lights_imageBased.prototype._loadSceneAsync = function (context, scene) {
                     var _this = this;
                     return this._loadExtensionAsync(context, scene, function (extensionContext, extension) {
@@ -6373,18 +6437,6 @@ var BABYLON;
                         return light._babylonTexture;
                     });
                 };
-                Object.defineProperty(EXT_lights_imageBased.prototype, "_lights", {
-                    get: function () {
-                        var extensions = this._loader._gltf.extensions;
-                        if (!extensions || !extensions[this.name]) {
-                            throw new Error("#/extensions: '" + this.name + "' not found");
-                        }
-                        var extension = extensions[this.name];
-                        return extension.lights;
-                    },
-                    enumerable: true,
-                    configurable: true
-                });
                 return EXT_lights_imageBased;
             }(GLTF2.GLTFLoaderExtension));
             Extensions.EXT_lights_imageBased = EXT_lights_imageBased;

Файловите разлики са ограничени, защото са твърде много
+ 4 - 4
dist/preview release/loaders/babylonjs.loaders.min.js


+ 129 - 99
dist/preview release/loaders/babylonjs.loaders.module.d.ts

@@ -17,9 +17,9 @@ declare module BABYLON {
         importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
         load(scene: Scene, data: any, rootUrl: string): boolean;
         loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
-        private isBinary(data);
-        private parseBinary(mesh, data);
-        private parseASCII(mesh, solidData);
+        private isBinary;
+        private parseBinary;
+        private parseASCII;
     }
 }
 
@@ -51,7 +51,7 @@ declare module BABYLON {
          * @param value The value stored in the mtl
          * @return The Texture
          */
-        private static _getTexture(rootUrl, value, scene);
+        private static _getTexture;
     }
     class OBJFileLoader implements ISceneLoaderPluginAsync {
         static OPTIMIZE_WITH_UV: boolean;
@@ -82,7 +82,7 @@ declare module BABYLON {
          * @param onSuccess Callback function to be called when the MTL file is loaded
          * @private
          */
-        private _loadMTL(url, rootUrl, onSuccess);
+        private _loadMTL;
         importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
             meshes: AbstractMesh[];
             particleSystems: IParticleSystem[];
@@ -103,7 +103,7 @@ declare module BABYLON {
          * @returns Array<AbstractMesh>
          * @private
          */
-        private _parseSolid(meshesNames, scene, data, rootUrl);
+        private _parseSolid;
     }
 }
 
@@ -120,7 +120,7 @@ declare module BABYLON {
         /**
          * Sets the useRightHandedSystem flag on the scene.
          */
-        FORCE_RIGHT_HANDED = 1,
+        FORCE_RIGHT_HANDED = 1
     }
     /**
      * Mode that determines what animations will start.
@@ -137,7 +137,7 @@ declare module BABYLON {
         /**
          * All animations will start.
          */
-        ALL = 2,
+        ALL = 2
     }
     /**
      * Interface that contains the data for the glTF asset.
@@ -180,7 +180,7 @@ declare module BABYLON {
         /**
          * The asset is completely loaded.
          */
-        COMPLETE = 2,
+        COMPLETE = 2
     }
     /** @hidden */
     interface IGLTFLoader extends IDisposable {
@@ -300,9 +300,20 @@ declare module BABYLON {
         private _onCompleteObserver;
         /**
          * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
+         * For assets with LODs, raised when all of the LODs are complete.
+         * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
          */
         onComplete: () => void;
         /**
+         * Observable raised when an error occurs.
+         */
+        readonly onErrorObservable: Observable<any>;
+        private _onErrorObserver;
+        /**
+         * Callback raised when an error occurs.
+         */
+        onError: (reason: any) => void;
+        /**
          * Observable raised after the loader is disposed.
          */
         readonly onDisposeObservable: Observable<void>;
@@ -401,14 +412,14 @@ declare module BABYLON {
          * @returns the created plugin
          */
         createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
-        private _parse(data);
-        private _getLoader(loaderData);
-        private _parseBinary(data);
-        private _parseV1(binaryReader);
-        private _parseV2(binaryReader);
-        private static _parseVersion(version);
-        private static _compareVersion(a, b);
-        private static _decodeBufferToText(buffer);
+        private _parse;
+        private _getLoader;
+        private _parseBinary;
+        private _parseV1;
+        private _parseV2;
+        private static _parseVersion;
+        private static _compareVersion;
+        private static _decodeBufferToText;
         private static readonly _logSpaces;
         private _logIndentLevel;
         private _loggingEnabled;
@@ -418,17 +429,17 @@ declare module BABYLON {
         _logOpen(message: string): void;
         /** @hidden */
         _logClose(): void;
-        private _logEnabled(message);
-        private _logDisabled(message);
+        private _logEnabled;
+        private _logDisabled;
         private _capturePerformanceCounters;
         /** @hidden */
         _startPerformanceCounter: (counterName: string) => void;
         /** @hidden */
         _endPerformanceCounter: (counterName: string) => void;
-        private _startPerformanceCounterEnabled(counterName);
-        private _startPerformanceCounterDisabled(counterName);
-        private _endPerformanceCounterEnabled(counterName);
-        private _endPerformanceCounterDisabled(counterName);
+        private _startPerformanceCounterEnabled;
+        private _startPerformanceCounterDisabled;
+        private _endPerformanceCounterEnabled;
+        private _endPerformanceCounterDisabled;
     }
 }
 
@@ -442,11 +453,11 @@ declare module BABYLON.GLTF1 {
         UNSIGNED_BYTE = 5121,
         SHORT = 5122,
         UNSIGNED_SHORT = 5123,
-        FLOAT = 5126,
+        FLOAT = 5126
     }
     enum EShaderType {
         FRAGMENT = 35632,
-        VERTEX = 35633,
+        VERTEX = 35633
     }
     enum EParameterType {
         BYTE = 5120,
@@ -469,12 +480,12 @@ declare module BABYLON.GLTF1 {
         FLOAT_MAT2 = 35674,
         FLOAT_MAT3 = 35675,
         FLOAT_MAT4 = 35676,
-        SAMPLER_2D = 35678,
+        SAMPLER_2D = 35678
     }
     enum ETextureWrapMode {
         CLAMP_TO_EDGE = 33071,
         MIRRORED_REPEAT = 33648,
-        REPEAT = 10497,
+        REPEAT = 10497
     }
     enum ETextureFilterType {
         NEAREST = 9728,
@@ -482,19 +493,19 @@ declare module BABYLON.GLTF1 {
         NEAREST_MIPMAP_NEAREST = 9984,
         LINEAR_MIPMAP_NEAREST = 9985,
         NEAREST_MIPMAP_LINEAR = 9986,
-        LINEAR_MIPMAP_LINEAR = 9987,
+        LINEAR_MIPMAP_LINEAR = 9987
     }
     enum ETextureFormat {
         ALPHA = 6406,
         RGB = 6407,
         RGBA = 6408,
         LUMINANCE = 6409,
-        LUMINANCE_ALPHA = 6410,
+        LUMINANCE_ALPHA = 6410
     }
     enum ECullingType {
         FRONT = 1028,
         BACK = 1029,
-        FRONT_AND_BACK = 1032,
+        FRONT_AND_BACK = 1032
     }
     enum EBlendingFunction {
         ZERO = 0,
@@ -511,7 +522,7 @@ declare module BABYLON.GLTF1 {
         ONE_MINUS_CONSTANT_COLOR = 32770,
         CONSTANT_ALPHA = 32771,
         ONE_MINUS_CONSTANT_ALPHA = 32772,
-        SRC_ALPHA_SATURATE = 776,
+        SRC_ALPHA_SATURATE = 776
     }
     /**
     * Interfaces
@@ -827,7 +838,7 @@ declare module BABYLON.GLTF1 {
         static RegisterExtension(extension: GLTFLoaderExtension): void;
         state: Nullable<GLTFLoaderState>;
         dispose(): void;
-        private _importMeshAsync(meshesNames, scene, data, rootUrl, onSuccess, onProgress?, onError?);
+        private _importMeshAsync;
         /**
         * Imports one or more meshes from a loaded gltf file and adds them to the scene
         * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
@@ -843,7 +854,7 @@ declare module BABYLON.GLTF1 {
             skeletons: Skeleton[];
             animationGroups: AnimationGroup[];
         }>;
-        private _loadAsync(scene, data, rootUrl, onSuccess, onProgress?, onError?);
+        private _loadAsync;
         /**
         * Imports all objects from a loaded gltf file and adds them to the scene
         * @param scene the scene the objects should be added to
@@ -853,9 +864,9 @@ declare module BABYLON.GLTF1 {
         * @returns a promise which completes when objects have been loaded to the scene
         */
         loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
-        private _loadShadersAsync(gltfRuntime, onload);
-        private _loadBuffersAsync(gltfRuntime, onLoad, onProgress?);
-        private _createNodes(gltfRuntime);
+        private _loadShadersAsync;
+        private _loadBuffersAsync;
+        private _createNodes;
     }
 }
 
@@ -966,9 +977,9 @@ declare module BABYLON.GLTF1 {
         static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
         static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
         static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
-        private static LoadTextureBufferAsync(gltfRuntime, id, onSuccess, onError);
-        private static CreateTextureAsync(gltfRuntime, id, buffer, onSuccess, onError);
-        private static ApplyExtensions(func, defaultFunc);
+        private static LoadTextureBufferAsync;
+        private static CreateTextureAsync;
+        private static ApplyExtensions;
     }
 }
 
@@ -990,7 +1001,7 @@ declare module BABYLON.GLTF1 {
         constructor();
         loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
         loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
-        private _loadTexture(gltfRuntime, id, material, propertyPath, onError);
+        private _loadTexture;
     }
 }
 
@@ -1120,7 +1131,6 @@ declare module BABYLON.GLTF2 {
         _parent: GLTFFileLoader;
         _gltf: _ILoaderGLTF;
         _babylonScene: Scene;
-        _readyPromise: Promise<void>;
         _completePromises: Promise<void>[];
         private _disposed;
         private _state;
@@ -1134,9 +1144,6 @@ declare module BABYLON.GLTF2 {
         private static _ExtensionNames;
         private static _ExtensionFactories;
         static _Register(name: string, factory: (loader: GLTFLoader) => GLTFLoaderExtension): void;
-        /**
-         * Loader state or null if the loader is not active.
-         */
         readonly state: Nullable<GLTFLoaderState>;
         constructor(parent: GLTFFileLoader);
         dispose(): void;
@@ -1147,45 +1154,46 @@ declare module BABYLON.GLTF2 {
             animationGroups: AnimationGroup[];
         }>;
         loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
-        private _loadAsync(nodes);
-        private _loadData(data);
-        private _setupData();
-        private _loadExtensions();
-        private _checkExtensions();
-        private _createRootNode();
+        private _loadAsync;
+        private _loadData;
+        private _setupData;
+        private _loadExtensions;
+        private _checkExtensions;
+        private _setState;
+        private _createRootNode;
         _loadSceneAsync(context: string, scene: _ILoaderScene): Promise<void>;
-        private _forEachPrimitive(node, callback);
-        private _getMeshes();
-        private _getSkeletons();
-        private _getAnimationGroups();
-        private _startAnimations();
+        private _forEachPrimitive;
+        private _getMeshes;
+        private _getSkeletons;
+        private _getAnimationGroups;
+        private _startAnimations;
         _loadNodeAsync(context: string, node: _ILoaderNode): Promise<void>;
-        private _loadMeshAsync(context, node, mesh, babylonMesh);
-        private _loadPrimitiveAsync(context, node, mesh, primitive, babylonMesh);
-        private _loadVertexDataAsync(context, primitive, babylonMesh);
-        private _createMorphTargets(context, node, mesh, primitive, babylonMesh);
-        private _loadMorphTargetsAsync(context, primitive, babylonMesh, babylonGeometry);
-        private _loadMorphTargetVertexDataAsync(context, babylonGeometry, attributes, babylonMorphTarget);
-        private static _LoadTransform(node, babylonNode);
-        private _loadSkinAsync(context, node, mesh, skin);
-        private _loadBones(context, skin);
-        private _loadBone(node, skin, babylonBones);
-        private _loadSkinInverseBindMatricesDataAsync(context, skin);
-        private _updateBoneMatrices(babylonSkeleton, inverseBindMatricesData);
-        private _getNodeMatrix(node);
-        private _loadCamera(context, camera, babylonMesh);
-        private _loadAnimationsAsync();
-        private _loadAnimationAsync(context, animation);
-        private _loadAnimationChannelAsync(context, animationContext, animation, channel, babylonAnimationGroup);
-        private _loadAnimationSamplerAsync(context, sampler);
-        private _loadBufferAsync(context, buffer);
+        private _loadMeshAsync;
+        private _loadPrimitiveAsync;
+        private _loadVertexDataAsync;
+        private _createMorphTargets;
+        private _loadMorphTargetsAsync;
+        private _loadMorphTargetVertexDataAsync;
+        private static _LoadTransform;
+        private _loadSkinAsync;
+        private _loadBones;
+        private _loadBone;
+        private _loadSkinInverseBindMatricesDataAsync;
+        private _updateBoneMatrices;
+        private _getNodeMatrix;
+        private _loadCamera;
+        private _loadAnimationsAsync;
+        private _loadAnimationAsync;
+        private _loadAnimationChannelAsync;
+        private _loadAnimationSamplerAsync;
+        private _loadBufferAsync;
         _loadBufferViewAsync(context: string, bufferView: _ILoaderBufferView): Promise<ArrayBufferView>;
-        private _loadIndicesAccessorAsync(context, accessor);
-        private _loadFloatAccessorAsync(context, accessor);
+        private _loadIndicesAccessorAsync;
+        private _loadFloatAccessorAsync;
         _loadVertexBufferViewAsync(context: string, bufferView: _ILoaderBufferView, kind: string): Promise<Buffer>;
-        private _loadVertexAccessorAsync(context, accessor, kind);
-        private _getDefaultMaterial(drawMode);
-        private _loadMaterialMetallicRoughnessPropertiesAsync(context, material, babylonMaterial);
+        private _loadVertexAccessorAsync;
+        private _getDefaultMaterial;
+        private _loadMaterialMetallicRoughnessPropertiesAsync;
         _loadMaterialAsync(context: string, material: _ILoaderMaterial, mesh: _ILoaderMesh, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Promise<void>;
         _loadMaterialPropertiesAsync(context: string, material: _ILoaderMaterial, babylonMaterial: Material): Promise<void>;
         _createMaterial(name: string, drawMode: number): PBRMaterial;
@@ -1193,20 +1201,21 @@ declare module BABYLON.GLTF2 {
         _loadMaterialAlphaProperties(context: string, material: _ILoaderMaterial, babylonMaterial: PBRMaterial): void;
         _loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: Texture) => void): Promise<void>;
         _loadTextureAsync(context: string, texture: _ILoaderTexture, assign: (babylonTexture: Texture) => void): Promise<void>;
-        private _loadSampler(context, sampler);
+        private _loadSampler;
         _loadImageAsync(context: string, image: _ILoaderImage): Promise<ArrayBufferView>;
         _loadUriAsync(context: string, uri: string): Promise<ArrayBufferView>;
-        private _onProgress();
+        private _onProgress;
         static _GetProperty<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
-        private static _GetTextureWrapMode(context, mode);
-        private static _GetTextureSamplingMode(context, magFilter?, minFilter?);
-        private static _GetTypedArray(context, componentType, bufferView, byteOffset, length);
-        private static _GetNumComponents(context, type);
-        private static _ValidateUri(uri);
-        private static _GetDrawMode(context, mode);
-        private _compileMaterialsAsync();
-        private _compileShadowGeneratorsAsync();
+        private static _GetTextureWrapMode;
+        private static _GetTextureSamplingMode;
+        private static _GetTypedArray;
+        private static _GetNumComponents;
+        private static _ValidateUri;
+        private static _GetDrawMode;
+        private _compileMaterialsAsync;
+        private _compileShadowGeneratorsAsync;
         _applyExtensions<T>(actionAsync: (extension: GLTFLoaderExtension) => Nullable<Promise<T>>): Nullable<Promise<T>>;
+        _forEachExtensions(action: (extension: GLTFLoaderExtension) => void): void;
     }
 }
 
@@ -1223,7 +1232,7 @@ declare module BABYLON.GLTF2 {
         /**
          * Gets or sets extension name
          */
-        readonly abstract name: string;
+        abstract readonly name: string;
         protected _loader: GLTFLoader;
         /**
          * Creates new GLTFLoaderExtension
@@ -1235,6 +1244,14 @@ declare module BABYLON.GLTF2 {
          */
         dispose(): void;
         /**
+         * Override this method to do work after the state changes to LOADING.
+         */
+        protected _onLoading(): void;
+        /**
+         * Override this method to do work after the state changes to READY.
+         */
+        protected _onReady(): void;
+        /**
          * Override this method to modify the default behavior for loading scenes.
          * @hidden
          */
@@ -1285,6 +1302,16 @@ declare module BABYLON.GLTF2 {
          */
         protected _loadExtrasValueAsync<TProperty, TResult = void>(context: string, property: IProperty, actionAsync: (extensionContext: string, value: TProperty) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
         /**
+         * Helper method called by the loader after the state changes to LOADING.
+         * @hidden
+         */
+        static _OnLoading(loader: GLTFLoader): void;
+        /**
+         * Helper method called by the loader after the state changes to READY.
+         * @hidden
+         */
+        static _OnReady(loader: GLTFLoader): void;
+        /**
          * Helper method called by the loader to allow extensions to override loading scenes.
          * @hidden
          */
@@ -1361,16 +1388,16 @@ declare module BABYLON.GLTF2.Extensions {
         private _materialIndexLOD;
         private _materialSignalLODs;
         private _materialPromiseLODs;
-        constructor(loader: GLTFLoader);
         dispose(): void;
+        protected _onReady(): void;
         protected _loadNodeAsync(context: string, node: _ILoaderNode): Nullable<Promise<void>>;
         protected _loadMaterialAsync(context: string, material: _ILoaderMaterial, mesh: _ILoaderMesh, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<void>>;
         protected _loadUriAsync(context: string, uri: string): Nullable<Promise<ArrayBufferView>>;
         /**
          * Gets an array of LOD properties from lowest to highest.
          */
-        private _getLODs<T>(context, property, array, ids);
-        private _disposeUnusedMaterials();
+        private _getLODs;
+        private _disposeUnusedMaterials;
     }
 }
 
@@ -1388,7 +1415,8 @@ declare module BABYLON.GLTF2.Extensions {
     /** @hidden */
     class MSFT_sRGBFactors extends GLTFLoaderExtension {
         readonly name: string;
-        protected _loadMaterialAsync(context: string, material: _ILoaderMaterial, mesh: _ILoaderMesh, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<void>>;
+        protected _loadMaterialPropertiesAsync(context: string, material: _ILoaderMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
+        private _convertColorsToLinear;
     }
 }
 
@@ -1414,7 +1442,7 @@ declare module BABYLON.GLTF2.Extensions {
     class KHR_materials_pbrSpecularGlossiness extends GLTFLoaderExtension {
         readonly name: string;
         protected _loadMaterialPropertiesAsync(context: string, material: _ILoaderMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
-        private _loadSpecularGlossinessPropertiesAsync(context, material, properties, babylonMaterial);
+        private _loadSpecularGlossinessPropertiesAsync;
     }
 }
 
@@ -1426,7 +1454,7 @@ declare module BABYLON.GLTF2.Extensions {
     class KHR_materials_unlit extends GLTFLoaderExtension {
         readonly name: string;
         protected _loadMaterialPropertiesAsync(context: string, material: _ILoaderMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
-        private _loadUnlitPropertiesAsync(context, material, babylonMaterial);
+        private _loadUnlitPropertiesAsync;
     }
 }
 
@@ -1437,9 +1465,10 @@ declare module BABYLON.GLTF2.Extensions {
      */
     class KHR_lights extends GLTFLoaderExtension {
         readonly name: string;
+        private _lights?;
+        protected _onLoading(): void;
         protected _loadSceneAsync(context: string, scene: _ILoaderScene): Nullable<Promise<void>>;
         protected _loadNodeAsync(context: string, node: _ILoaderNode): Nullable<Promise<void>>;
-        private readonly _lights;
     }
 }
 
@@ -1461,8 +1490,9 @@ declare module BABYLON.GLTF2.Extensions {
      */
     class EXT_lights_imageBased extends GLTFLoaderExtension {
         readonly name: string;
+        private _lights?;
+        protected _onLoading(): void;
         protected _loadSceneAsync(context: string, scene: _ILoaderScene): Nullable<Promise<void>>;
-        private _loadLightAsync(context, light);
-        private readonly _lights;
+        private _loadLightAsync;
     }
 }

+ 1 - 1
dist/preview release/materialsLibrary/babylon.waterMaterial.d.ts

@@ -92,7 +92,7 @@ declare module BABYLON {
         getAlphaTestTexture(): Nullable<BaseTexture>;
         isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
         bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
-        private _createRenderTargets(scene, renderTargetSize);
+        private _createRenderTargets;
         getAnimatables(): IAnimatable[];
         getActiveTextures(): BaseTexture[];
         hasTexture(texture: BaseTexture): boolean;

+ 1 - 1
dist/preview release/materialsLibrary/babylonjs.materials.d.ts

@@ -234,7 +234,7 @@ declare module BABYLON {
         getAlphaTestTexture(): Nullable<BaseTexture>;
         isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
         bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
-        private _createRenderTargets(scene, renderTargetSize);
+        private _createRenderTargets;
         getAnimatables(): IAnimatable[];
         getActiveTextures(): BaseTexture[];
         hasTexture(texture: BaseTexture): boolean;

+ 1 - 1
dist/preview release/materialsLibrary/babylonjs.materials.module.d.ts

@@ -239,7 +239,7 @@ declare module BABYLON {
         getAlphaTestTexture(): Nullable<BaseTexture>;
         isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
         bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
-        private _createRenderTargets(scene, renderTargetSize);
+        private _createRenderTargets;
         getAnimatables(): IAnimatable[];
         getActiveTextures(): BaseTexture[];
         hasTexture(texture: BaseTexture): boolean;

+ 2 - 2
dist/preview release/postProcessesLibrary/babylon.asciiArtPostProcess.d.ts

@@ -27,13 +27,13 @@ declare module BABYLON {
          * @param font the font to use, use the W3C CSS notation
          * @return the max char width
          */
-        private getFontWidth(font);
+        private getFontWidth;
         /**
          * Gets the max char height of a font.
          * @param font the font to use, use the W3C CSS notation
          * @return the max char height
          */
-        private getFontHeight(font);
+        private getFontHeight;
         /**
          * Clones the current AsciiArtTexture.
          * @return the clone of the texture.

+ 2 - 2
dist/preview release/postProcessesLibrary/babylon.digitalRainPostProcess.d.ts

@@ -27,13 +27,13 @@ declare module BABYLON {
          * @param font the font to use, use the W3C CSS notation
          * @return the max char width
          */
-        private getFontWidth(font);
+        private getFontWidth;
         /**
          * Gets the max char height of a font.
          * @param font the font to use, use the W3C CSS notation
          * @return the max char height
          */
-        private getFontHeight(font);
+        private getFontHeight;
         /**
          * Clones the current DigitalRainFontTexture.
          * @return the clone of the texture.

+ 4 - 4
dist/preview release/postProcessesLibrary/babylonjs.postProcess.d.ts

@@ -27,13 +27,13 @@ declare module BABYLON {
          * @param font the font to use, use the W3C CSS notation
          * @return the max char width
          */
-        private getFontWidth(font);
+        private getFontWidth;
         /**
          * Gets the max char height of a font.
          * @param font the font to use, use the W3C CSS notation
          * @return the max char height
          */
-        private getFontHeight(font);
+        private getFontHeight;
         /**
          * Clones the current AsciiArtTexture.
          * @return the clone of the texture.
@@ -130,13 +130,13 @@ declare module BABYLON {
          * @param font the font to use, use the W3C CSS notation
          * @return the max char width
          */
-        private getFontWidth(font);
+        private getFontWidth;
         /**
          * Gets the max char height of a font.
          * @param font the font to use, use the W3C CSS notation
          * @return the max char height
          */
-        private getFontHeight(font);
+        private getFontHeight;
         /**
          * Clones the current DigitalRainFontTexture.
          * @return the clone of the texture.

+ 4 - 4
dist/preview release/postProcessesLibrary/babylonjs.postProcess.module.d.ts

@@ -32,13 +32,13 @@ declare module BABYLON {
          * @param font the font to use, use the W3C CSS notation
          * @return the max char width
          */
-        private getFontWidth(font);
+        private getFontWidth;
         /**
          * Gets the max char height of a font.
          * @param font the font to use, use the W3C CSS notation
          * @return the max char height
          */
-        private getFontHeight(font);
+        private getFontHeight;
         /**
          * Clones the current AsciiArtTexture.
          * @return the clone of the texture.
@@ -135,13 +135,13 @@ declare module BABYLON {
          * @param font the font to use, use the W3C CSS notation
          * @return the max char width
          */
-        private getFontWidth(font);
+        private getFontWidth;
         /**
          * Gets the max char height of a font.
          * @param font the font to use, use the W3C CSS notation
          * @return the max char height
          */
-        private getFontHeight(font);
+        private getFontHeight;
         /**
          * Clones the current DigitalRainFontTexture.
          * @return the clone of the texture.

+ 51 - 51
dist/preview release/serializers/babylon.glTF2Serializer.d.ts

@@ -142,7 +142,7 @@ declare module BABYLON.GLTF2 {
          * Lazy load a local engine with premultiplied alpha set to false
          */
         _getLocalEngine(): Engine;
-        private reorderIndicesBasedOnPrimitiveMode(submesh, primitiveMode, babylonIndices, byteOffset, binaryWriter);
+        private reorderIndicesBasedOnPrimitiveMode;
         /**
          * Reorders the vertex attribute data based on the primitive mode.  This is necessary when indices are not available and the winding order is
          * clock-wise during export to glTF
@@ -154,7 +154,7 @@ declare module BABYLON.GLTF2 {
          * @param byteOffset The offset to the binary data
          * @param binaryWriter The binary data for the glTF file
          */
-        private reorderVertexAttributeDataBasedOnPrimitiveMode(submesh, primitiveMode, sideOrientation, vertexBufferKind, meshAttributeArray, byteOffset, binaryWriter);
+        private reorderVertexAttributeDataBasedOnPrimitiveMode;
         /**
          * Reorders the vertex attributes in the correct triangle mode order .  This is necessary when indices are not available and the winding order is
          * clock-wise during export to glTF
@@ -166,7 +166,7 @@ declare module BABYLON.GLTF2 {
          * @param byteOffset The offset to the binary data
          * @param binaryWriter The binary data for the glTF file
          */
-        private reorderTriangleFillMode(submesh, primitiveMode, sideOrientation, vertexBufferKind, meshAttributeArray, byteOffset, binaryWriter);
+        private reorderTriangleFillMode;
         /**
          * Reorders the vertex attributes in the correct triangle strip order.  This is necessary when indices are not available and the winding order is
          * clock-wise during export to glTF
@@ -178,7 +178,7 @@ declare module BABYLON.GLTF2 {
          * @param byteOffset The offset to the binary data
          * @param binaryWriter The binary data for the glTF file
          */
-        private reorderTriangleStripDrawMode(submesh, primitiveMode, sideOrientation, vertexBufferKind, meshAttributeArray, byteOffset, binaryWriter);
+        private reorderTriangleStripDrawMode;
         /**
          * Reorders the vertex attributes in the correct triangle fan order.  This is necessary when indices are not available and the winding order is
          * clock-wise during export to glTF
@@ -190,7 +190,7 @@ declare module BABYLON.GLTF2 {
          * @param byteOffset The offset to the binary data
          * @param binaryWriter The binary data for the glTF file
          */
-        private reorderTriangleFanMode(submesh, primitiveMode, sideOrientation, vertexBufferKind, meshAttributeArray, byteOffset, binaryWriter);
+        private reorderTriangleFanMode;
         /**
          * Writes the vertex attribute data to binary
          * @param vertices The vertices to write to the binary writer
@@ -199,7 +199,7 @@ declare module BABYLON.GLTF2 {
          * @param meshAttributeArray The vertex attribute data
          * @param binaryWriter The writer containing the binary data
          */
-        private writeVertexAttributeData(vertices, byteOffset, vertexAttributeKind, meshAttributeArray, binaryWriter);
+        private writeVertexAttributeData;
         /**
          * Writes mesh attribute data to a data buffer
          * Returns the bytelength of the data
@@ -208,7 +208,7 @@ declare module BABYLON.GLTF2 {
          * @param binaryWriter The buffer to write the binary data to
          * @param indices Used to specify the order of the vertex data
          */
-        private writeAttributeData(vertexBufferKind, meshAttributeArray, byteStride, binaryWriter);
+        private writeAttributeData;
         /**
          * Generates glTF json data
          * @param shouldUseGlb Indicates whether the json should be written for a glb file
@@ -216,7 +216,7 @@ declare module BABYLON.GLTF2 {
          * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
          * @returns json data as string
          */
-        private generateJSON(shouldUseGlb, glTFPrefix?, prettyPrint?);
+        private generateJSON;
         /**
          * Generates data for .gltf and .bin files based on the glTF prefix string
          * @param glTFPrefix Text to use when prefixing a glTF file
@@ -227,13 +227,13 @@ declare module BABYLON.GLTF2 {
          * Creates a binary buffer for glTF
          * @returns array buffer for binary data
          */
-        private _generateBinaryAsync();
+        private _generateBinaryAsync;
         /**
          * Pads the number to a multiple of 4
          * @param num number to pad
          * @returns padded number
          */
-        private _getPadding(num);
+        private _getPadding;
         /**
          * Generates a glb file from the json and binary data
          * Returns an object with the glb file name as the key and data as the value
@@ -246,47 +246,47 @@ declare module BABYLON.GLTF2 {
          * @param node glTF Node for storing the transformation data
          * @param babylonTransformNode Babylon mesh used as the source for the transformation data
          */
-        private setNodeTransformation(node, babylonTransformNode);
-        private getVertexBufferFromMesh(attributeKind, bufferMesh);
+        private setNodeTransformation;
+        private getVertexBufferFromMesh;
         /**
          * Creates a bufferview based on the vertices type for the Babylon mesh
          * @param kind Indicates the type of vertices data
          * @param babylonTransformNode The Babylon mesh to get the vertices data from
          * @param binaryWriter The buffer to write the bufferview data to
          */
-        private createBufferViewKind(kind, babylonTransformNode, binaryWriter, byteStride);
+        private createBufferViewKind;
         /**
          * The primitive mode of the Babylon mesh
          * @param babylonMesh The BabylonJS mesh
          */
-        private getMeshPrimitiveMode(babylonMesh);
+        private getMeshPrimitiveMode;
         /**
          * Sets the primitive mode of the glTF mesh primitive
          * @param meshPrimitive glTF mesh primitive
          * @param primitiveMode The primitive mode
          */
-        private setPrimitiveMode(meshPrimitive, primitiveMode);
+        private setPrimitiveMode;
         /**
          * Sets the vertex attribute accessor based of the glTF mesh primitive
          * @param meshPrimitive glTF mesh primitive
          * @param attributeKind vertex attribute
          * @returns boolean specifying if uv coordinates are present
          */
-        private setAttributeKind(meshPrimitive, attributeKind);
+        private setAttributeKind;
         /**
          * Sets data for the primitive attributes of each submesh
          * @param mesh glTF Mesh object to store the primitive attribute information
          * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
          * @param binaryWriter Buffer to write the attribute data to
          */
-        private setPrimitiveAttributes(mesh, babylonTransformNode, binaryWriter);
+        private setPrimitiveAttributes;
         /**
          * Creates a glTF scene based on the array of meshes
          * Returns the the total byte offset
          * @param babylonScene Babylon scene to get the mesh data from
          * @param binaryWriter Buffer to write binary data to
          */
-        private createSceneAsync(babylonScene, binaryWriter);
+        private createSceneAsync;
         /**
          * Creates a mapping of Node unique id to node index and handles animations
          * @param babylonScene Babylon Scene
@@ -295,14 +295,14 @@ declare module BABYLON.GLTF2 {
          * @param binaryWriter Buffer to write binary data to
          * @returns Node mapping of unique id to index
          */
-        private createNodeMapAndAnimations(babylonScene, nodes, shouldExportTransformNode, binaryWriter);
+        private createNodeMapAndAnimations;
         /**
          * Creates a glTF node from a Babylon mesh
          * @param babylonMesh Source Babylon mesh
          * @param binaryWriter Buffer for storing geometry data
          * @returns glTF node
          */
-        private createNode(babylonTransformNode, binaryWriter);
+        private createNode;
     }
     /**
      * @hidden
@@ -331,7 +331,7 @@ declare module BABYLON.GLTF2 {
          * Resize the array buffer to the specified byte length
          * @param byteLength
          */
-        private resizeBuffer(byteLength);
+        private resizeBuffer;
         /**
          * Get an array buffer with the length of the byte offset
          * @returns ArrayBuffer resized to the byte offset
@@ -429,7 +429,7 @@ declare module BABYLON.GLTF2 {
          * @param color2 second color to compare to
          * @param epsilon threshold value
          */
-        private static FuzzyEquals(color1, color2, epsilon);
+        private static FuzzyEquals;
         /**
          * Gets the materials from a Babylon scene and converts them to glTF materials
          * @param scene babylonjs scene
@@ -503,7 +503,7 @@ declare module BABYLON.GLTF2 {
          * @param mimeType mimetype of the image
          * @returns base64 image string
          */
-        private _createBase64FromCanvasAsync(buffer, width, height, mimeType);
+        private _createBase64FromCanvasAsync;
         /**
          * Generates a white texture based on the specified width and height
          * @param width width of the texture in pixels
@@ -511,7 +511,7 @@ declare module BABYLON.GLTF2 {
          * @param scene babylonjs scene
          * @returns white texture
          */
-        private _createWhiteTexture(width, height, scene);
+        private _createWhiteTexture;
         /**
          * Resizes the two source textures to the same dimensions.  If a texture is null, a default white texture is generated.  If both textures are null, returns null
          * @param texture1 first texture to resize
@@ -519,14 +519,14 @@ declare module BABYLON.GLTF2 {
          * @param scene babylonjs scene
          * @returns resized textures or null
          */
-        private _resizeTexturesToSameDimensions(texture1, texture2, scene);
+        private _resizeTexturesToSameDimensions;
         /**
          * Converts an array of pixels to a Float32Array
          * Throws an error if the pixel format is not supported
          * @param pixels - array buffer containing pixel values
          * @returns Float32 of pixels
          */
-        private _convertPixelArrayToFloat32(pixels);
+        private _convertPixelArrayToFloat32;
         /**
          * Convert Specular Glossiness Textures to Metallic Roughness
          * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
@@ -537,25 +537,25 @@ declare module BABYLON.GLTF2 {
          * @param mimeType the mime type to use for the texture
          * @returns pbr metallic roughness interface or null
          */
-        private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync(diffuseTexture, specularGlossinessTexture, factors, mimeType);
+        private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
         /**
          * Converts specular glossiness material properties to metallic roughness
          * @param specularGlossiness interface with specular glossiness material properties
          * @returns interface with metallic roughness material properties
          */
-        private _convertSpecularGlossinessToMetallicRoughness(specularGlossiness);
+        private _convertSpecularGlossinessToMetallicRoughness;
         /**
          * Calculates the surface reflectance, independent of lighting conditions
          * @param color Color source to calculate brightness from
          * @returns number representing the perceived brightness, or zero if color is undefined
          */
-        private _getPerceivedBrightness(color);
+        private _getPerceivedBrightness;
         /**
          * Returns the maximum color component value
          * @param color
          * @returns maximum color component value, or zero if color is null or undefined
          */
-        private _getMaxComponent(color);
+        private _getMaxComponent;
         /**
          * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
          * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
@@ -567,10 +567,10 @@ declare module BABYLON.GLTF2 {
          * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
          * @returns glTF PBR Metallic Roughness factors
          */
-        private _convertMetalRoughFactorsToMetallicRoughnessAsync(babylonPBRMaterial, mimeType, glTFPbrMetallicRoughness, hasTextureCoords);
-        private _getGLTFTextureSampler(texture);
-        private _getGLTFTextureWrapMode(wrapMode);
-        private _getGLTFTextureWrapModesSampler(texture);
+        private _convertMetalRoughFactorsToMetallicRoughnessAsync;
+        private _getGLTFTextureSampler;
+        private _getGLTFTextureWrapMode;
+        private _getGLTFTextureWrapModesSampler;
         /**
          * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
          * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
@@ -582,7 +582,7 @@ declare module BABYLON.GLTF2 {
          * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
          * @returns glTF PBR Metallic Roughness factors
          */
-        private _convertSpecGlossFactorsToMetallicRoughnessAsync(babylonPBRMaterial, mimeType, glTFPbrMetallicRoughness, hasTextureCoords);
+        private _convertSpecGlossFactorsToMetallicRoughnessAsync;
         /**
          * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
          * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
@@ -594,8 +594,8 @@ declare module BABYLON.GLTF2 {
          * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
          */
         _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
-        private setMetallicRoughnessPbrMaterial(metallicRoughness, babylonPBRMaterial, glTFMaterial, glTFPbrMetallicRoughness, mimeType, hasTextureCoords);
-        private getPixelsFromTexture(babylonTexture);
+        private setMetallicRoughnessPbrMaterial;
+        private getPixelsFromTexture;
         /**
          * Extracts a texture from a Babylon texture into file data and glTF data
          * @param babylonTexture Babylon texture to extract
@@ -605,7 +605,7 @@ declare module BABYLON.GLTF2 {
          * @param imageData map of image file name and data
          * @return glTF texture info, or null if the texture format is not supported
          */
-        private _exportTextureAsync(babylonTexture, mimeType);
+        private _exportTextureAsync;
         /**
          * Builds a texture from base64 string
          * @param base64Texture base64 texture string
@@ -616,7 +616,7 @@ declare module BABYLON.GLTF2 {
          * @param imageData map of image data
          * @returns glTF texture info, or null if the texture format is not supported
          */
-        private _getTextureInfoFromBase64(base64Texture, baseTextureName, mimeType, texCoordIndex, samplerIndex);
+        private _getTextureInfoFromBase64;
     }
 }
 
@@ -682,7 +682,7 @@ declare module BABYLON.GLTF2 {
          * @returns nullable IAnimationData
          */
         static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
-        private static _DeduceAnimationInfo(animation);
+        private static _DeduceAnimationInfo;
         /**
          * @ignore
          * Create node animations from the transform node animations
@@ -714,7 +714,7 @@ declare module BABYLON.GLTF2 {
         static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
             [key: number]: number;
         }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
-        private static AddAnimation(name, glTFAnimation, babylonTransformNode, animation, dataAccessorType, animationChannelTargetPath, nodeMap, binaryWriter, bufferViews, accessors, convertToRightHandedSystem, useQuaternion, animationSampleRate);
+        private static AddAnimation;
         /**
          * Create a baked animation
          * @param babylonTransformNode BabylonJS mesh
@@ -728,9 +728,9 @@ declare module BABYLON.GLTF2 {
          * @param convertToRightHandedSystem converts the values to right-handed
          * @param useQuaternion specifies if quaternions should be used
          */
-        private static _CreateBakedAnimation(babylonTransformNode, animation, animationChannelTargetPath, minFrame, maxFrame, fps, sampleRate, inputs, outputs, minMaxFrames, convertToRightHandedSystem, useQuaternion);
-        private static _ConvertFactorToVector3OrQuaternion(factor, babylonTransformNode, animation, animationType, animationChannelTargetPath, convertToRightHandedSystem, useQuaternion);
-        private static _SetInterpolatedValue(babylonTransformNode, value, time, animation, animationChannelTargetPath, quaternionCache, inputs, outputs, convertToRightHandedSystem, useQuaternion);
+        private static _CreateBakedAnimation;
+        private static _ConvertFactorToVector3OrQuaternion;
+        private static _SetInterpolatedValue;
         /**
          * Creates linear animation from the animation key frames
          * @param babylonTransformNode BabylonJS mesh
@@ -742,7 +742,7 @@ declare module BABYLON.GLTF2 {
          * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
          * @param useQuaternion Specifies if quaternions are used in the animation
          */
-        private static _CreateLinearOrStepAnimation(babylonTransformNode, animation, animationChannelTargetPath, frameDelta, inputs, outputs, convertToRightHandedSystem, useQuaternion);
+        private static _CreateLinearOrStepAnimation;
         /**
          * Creates cubic spline animation from the animation key frames
          * @param babylonTransformNode BabylonJS mesh
@@ -754,8 +754,8 @@ declare module BABYLON.GLTF2 {
          * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
          * @param useQuaternion Specifies if quaternions are used in the animation
          */
-        private static _CreateCubicSplineAnimation(babylonTransformNode, animation, animationChannelTargetPath, frameDelta, inputs, outputs, convertToRightHandedSystem, useQuaternion);
-        private static _GetBasePositionRotationOrScale(babylonTransformNode, animationChannelTargetPath, convertToRightHandedSystem, useQuaternion);
+        private static _CreateCubicSplineAnimation;
+        private static _GetBasePositionRotationOrScale;
         /**
          * Adds a key frame value
          * @param keyFrame
@@ -766,14 +766,14 @@ declare module BABYLON.GLTF2 {
          * @param convertToRightHandedSystem
          * @param useQuaternion
          */
-        private static _AddKeyframeValue(keyFrame, animation, outputs, animationChannelTargetPath, babylonTransformNode, convertToRightHandedSystem, useQuaternion);
+        private static _AddKeyframeValue;
         /**
          * Determine the interpolation based on the key frames
          * @param keyFrames
          * @param animationChannelTargetPath
          * @param useQuaternion
          */
-        private static _DeduceInterpolation(keyFrames, animationChannelTargetPath, useQuaternion);
+        private static _DeduceInterpolation;
         /**
          * Adds an input tangent or output tangent to the output data
          * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
@@ -786,13 +786,13 @@ declare module BABYLON.GLTF2 {
          * @param useQuaternion Specifies if quaternions are used
          * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
          */
-        private static AddSplineTangent(babylonTransformNode, tangentType, outputs, animationChannelTargetPath, interpolation, keyFrame, frameDelta, useQuaternion, convertToRightHandedSystem);
+        private static AddSplineTangent;
         /**
          * Get the minimum and maximum key frames' frame values
          * @param keyFrames animation key frames
          * @returns the minimum and maximum key frame value
          */
-        private static calculateMinMaxKeyFrames(keyFrames);
+        private static calculateMinMaxKeyFrames;
     }
 }
 

+ 51 - 51
dist/preview release/serializers/babylonjs.serializers.d.ts

@@ -150,7 +150,7 @@ declare module BABYLON.GLTF2 {
          * Lazy load a local engine with premultiplied alpha set to false
          */
         _getLocalEngine(): Engine;
-        private reorderIndicesBasedOnPrimitiveMode(submesh, primitiveMode, babylonIndices, byteOffset, binaryWriter);
+        private reorderIndicesBasedOnPrimitiveMode;
         /**
          * Reorders the vertex attribute data based on the primitive mode.  This is necessary when indices are not available and the winding order is
          * clock-wise during export to glTF
@@ -162,7 +162,7 @@ declare module BABYLON.GLTF2 {
          * @param byteOffset The offset to the binary data
          * @param binaryWriter The binary data for the glTF file
          */
-        private reorderVertexAttributeDataBasedOnPrimitiveMode(submesh, primitiveMode, sideOrientation, vertexBufferKind, meshAttributeArray, byteOffset, binaryWriter);
+        private reorderVertexAttributeDataBasedOnPrimitiveMode;
         /**
          * Reorders the vertex attributes in the correct triangle mode order .  This is necessary when indices are not available and the winding order is
          * clock-wise during export to glTF
@@ -174,7 +174,7 @@ declare module BABYLON.GLTF2 {
          * @param byteOffset The offset to the binary data
          * @param binaryWriter The binary data for the glTF file
          */
-        private reorderTriangleFillMode(submesh, primitiveMode, sideOrientation, vertexBufferKind, meshAttributeArray, byteOffset, binaryWriter);
+        private reorderTriangleFillMode;
         /**
          * Reorders the vertex attributes in the correct triangle strip order.  This is necessary when indices are not available and the winding order is
          * clock-wise during export to glTF
@@ -186,7 +186,7 @@ declare module BABYLON.GLTF2 {
          * @param byteOffset The offset to the binary data
          * @param binaryWriter The binary data for the glTF file
          */
-        private reorderTriangleStripDrawMode(submesh, primitiveMode, sideOrientation, vertexBufferKind, meshAttributeArray, byteOffset, binaryWriter);
+        private reorderTriangleStripDrawMode;
         /**
          * Reorders the vertex attributes in the correct triangle fan order.  This is necessary when indices are not available and the winding order is
          * clock-wise during export to glTF
@@ -198,7 +198,7 @@ declare module BABYLON.GLTF2 {
          * @param byteOffset The offset to the binary data
          * @param binaryWriter The binary data for the glTF file
          */
-        private reorderTriangleFanMode(submesh, primitiveMode, sideOrientation, vertexBufferKind, meshAttributeArray, byteOffset, binaryWriter);
+        private reorderTriangleFanMode;
         /**
          * Writes the vertex attribute data to binary
          * @param vertices The vertices to write to the binary writer
@@ -207,7 +207,7 @@ declare module BABYLON.GLTF2 {
          * @param meshAttributeArray The vertex attribute data
          * @param binaryWriter The writer containing the binary data
          */
-        private writeVertexAttributeData(vertices, byteOffset, vertexAttributeKind, meshAttributeArray, binaryWriter);
+        private writeVertexAttributeData;
         /**
          * Writes mesh attribute data to a data buffer
          * Returns the bytelength of the data
@@ -216,7 +216,7 @@ declare module BABYLON.GLTF2 {
          * @param binaryWriter The buffer to write the binary data to
          * @param indices Used to specify the order of the vertex data
          */
-        private writeAttributeData(vertexBufferKind, meshAttributeArray, byteStride, binaryWriter);
+        private writeAttributeData;
         /**
          * Generates glTF json data
          * @param shouldUseGlb Indicates whether the json should be written for a glb file
@@ -224,7 +224,7 @@ declare module BABYLON.GLTF2 {
          * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
          * @returns json data as string
          */
-        private generateJSON(shouldUseGlb, glTFPrefix?, prettyPrint?);
+        private generateJSON;
         /**
          * Generates data for .gltf and .bin files based on the glTF prefix string
          * @param glTFPrefix Text to use when prefixing a glTF file
@@ -235,13 +235,13 @@ declare module BABYLON.GLTF2 {
          * Creates a binary buffer for glTF
          * @returns array buffer for binary data
          */
-        private _generateBinaryAsync();
+        private _generateBinaryAsync;
         /**
          * Pads the number to a multiple of 4
          * @param num number to pad
          * @returns padded number
          */
-        private _getPadding(num);
+        private _getPadding;
         /**
          * Generates a glb file from the json and binary data
          * Returns an object with the glb file name as the key and data as the value
@@ -254,47 +254,47 @@ declare module BABYLON.GLTF2 {
          * @param node glTF Node for storing the transformation data
          * @param babylonTransformNode Babylon mesh used as the source for the transformation data
          */
-        private setNodeTransformation(node, babylonTransformNode);
-        private getVertexBufferFromMesh(attributeKind, bufferMesh);
+        private setNodeTransformation;
+        private getVertexBufferFromMesh;
         /**
          * Creates a bufferview based on the vertices type for the Babylon mesh
          * @param kind Indicates the type of vertices data
          * @param babylonTransformNode The Babylon mesh to get the vertices data from
          * @param binaryWriter The buffer to write the bufferview data to
          */
-        private createBufferViewKind(kind, babylonTransformNode, binaryWriter, byteStride);
+        private createBufferViewKind;
         /**
          * The primitive mode of the Babylon mesh
          * @param babylonMesh The BabylonJS mesh
          */
-        private getMeshPrimitiveMode(babylonMesh);
+        private getMeshPrimitiveMode;
         /**
          * Sets the primitive mode of the glTF mesh primitive
          * @param meshPrimitive glTF mesh primitive
          * @param primitiveMode The primitive mode
          */
-        private setPrimitiveMode(meshPrimitive, primitiveMode);
+        private setPrimitiveMode;
         /**
          * Sets the vertex attribute accessor based of the glTF mesh primitive
          * @param meshPrimitive glTF mesh primitive
          * @param attributeKind vertex attribute
          * @returns boolean specifying if uv coordinates are present
          */
-        private setAttributeKind(meshPrimitive, attributeKind);
+        private setAttributeKind;
         /**
          * Sets data for the primitive attributes of each submesh
          * @param mesh glTF Mesh object to store the primitive attribute information
          * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
          * @param binaryWriter Buffer to write the attribute data to
          */
-        private setPrimitiveAttributes(mesh, babylonTransformNode, binaryWriter);
+        private setPrimitiveAttributes;
         /**
          * Creates a glTF scene based on the array of meshes
          * Returns the the total byte offset
          * @param babylonScene Babylon scene to get the mesh data from
          * @param binaryWriter Buffer to write binary data to
          */
-        private createSceneAsync(babylonScene, binaryWriter);
+        private createSceneAsync;
         /**
          * Creates a mapping of Node unique id to node index and handles animations
          * @param babylonScene Babylon Scene
@@ -303,14 +303,14 @@ declare module BABYLON.GLTF2 {
          * @param binaryWriter Buffer to write binary data to
          * @returns Node mapping of unique id to index
          */
-        private createNodeMapAndAnimations(babylonScene, nodes, shouldExportTransformNode, binaryWriter);
+        private createNodeMapAndAnimations;
         /**
          * Creates a glTF node from a Babylon mesh
          * @param babylonMesh Source Babylon mesh
          * @param binaryWriter Buffer for storing geometry data
          * @returns glTF node
          */
-        private createNode(babylonTransformNode, binaryWriter);
+        private createNode;
     }
     /**
      * @hidden
@@ -339,7 +339,7 @@ declare module BABYLON.GLTF2 {
          * Resize the array buffer to the specified byte length
          * @param byteLength
          */
-        private resizeBuffer(byteLength);
+        private resizeBuffer;
         /**
          * Get an array buffer with the length of the byte offset
          * @returns ArrayBuffer resized to the byte offset
@@ -437,7 +437,7 @@ declare module BABYLON.GLTF2 {
          * @param color2 second color to compare to
          * @param epsilon threshold value
          */
-        private static FuzzyEquals(color1, color2, epsilon);
+        private static FuzzyEquals;
         /**
          * Gets the materials from a Babylon scene and converts them to glTF materials
          * @param scene babylonjs scene
@@ -511,7 +511,7 @@ declare module BABYLON.GLTF2 {
          * @param mimeType mimetype of the image
          * @returns base64 image string
          */
-        private _createBase64FromCanvasAsync(buffer, width, height, mimeType);
+        private _createBase64FromCanvasAsync;
         /**
          * Generates a white texture based on the specified width and height
          * @param width width of the texture in pixels
@@ -519,7 +519,7 @@ declare module BABYLON.GLTF2 {
          * @param scene babylonjs scene
          * @returns white texture
          */
-        private _createWhiteTexture(width, height, scene);
+        private _createWhiteTexture;
         /**
          * Resizes the two source textures to the same dimensions.  If a texture is null, a default white texture is generated.  If both textures are null, returns null
          * @param texture1 first texture to resize
@@ -527,14 +527,14 @@ declare module BABYLON.GLTF2 {
          * @param scene babylonjs scene
          * @returns resized textures or null
          */
-        private _resizeTexturesToSameDimensions(texture1, texture2, scene);
+        private _resizeTexturesToSameDimensions;
         /**
          * Converts an array of pixels to a Float32Array
          * Throws an error if the pixel format is not supported
          * @param pixels - array buffer containing pixel values
          * @returns Float32 of pixels
          */
-        private _convertPixelArrayToFloat32(pixels);
+        private _convertPixelArrayToFloat32;
         /**
          * Convert Specular Glossiness Textures to Metallic Roughness
          * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
@@ -545,25 +545,25 @@ declare module BABYLON.GLTF2 {
          * @param mimeType the mime type to use for the texture
          * @returns pbr metallic roughness interface or null
          */
-        private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync(diffuseTexture, specularGlossinessTexture, factors, mimeType);
+        private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
         /**
          * Converts specular glossiness material properties to metallic roughness
          * @param specularGlossiness interface with specular glossiness material properties
          * @returns interface with metallic roughness material properties
          */
-        private _convertSpecularGlossinessToMetallicRoughness(specularGlossiness);
+        private _convertSpecularGlossinessToMetallicRoughness;
         /**
          * Calculates the surface reflectance, independent of lighting conditions
          * @param color Color source to calculate brightness from
          * @returns number representing the perceived brightness, or zero if color is undefined
          */
-        private _getPerceivedBrightness(color);
+        private _getPerceivedBrightness;
         /**
          * Returns the maximum color component value
          * @param color
          * @returns maximum color component value, or zero if color is null or undefined
          */
-        private _getMaxComponent(color);
+        private _getMaxComponent;
         /**
          * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
          * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
@@ -575,10 +575,10 @@ declare module BABYLON.GLTF2 {
          * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
          * @returns glTF PBR Metallic Roughness factors
          */
-        private _convertMetalRoughFactorsToMetallicRoughnessAsync(babylonPBRMaterial, mimeType, glTFPbrMetallicRoughness, hasTextureCoords);
-        private _getGLTFTextureSampler(texture);
-        private _getGLTFTextureWrapMode(wrapMode);
-        private _getGLTFTextureWrapModesSampler(texture);
+        private _convertMetalRoughFactorsToMetallicRoughnessAsync;
+        private _getGLTFTextureSampler;
+        private _getGLTFTextureWrapMode;
+        private _getGLTFTextureWrapModesSampler;
         /**
          * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
          * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
@@ -590,7 +590,7 @@ declare module BABYLON.GLTF2 {
          * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
          * @returns glTF PBR Metallic Roughness factors
          */
-        private _convertSpecGlossFactorsToMetallicRoughnessAsync(babylonPBRMaterial, mimeType, glTFPbrMetallicRoughness, hasTextureCoords);
+        private _convertSpecGlossFactorsToMetallicRoughnessAsync;
         /**
          * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
          * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
@@ -602,8 +602,8 @@ declare module BABYLON.GLTF2 {
          * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
          */
         _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
-        private setMetallicRoughnessPbrMaterial(metallicRoughness, babylonPBRMaterial, glTFMaterial, glTFPbrMetallicRoughness, mimeType, hasTextureCoords);
-        private getPixelsFromTexture(babylonTexture);
+        private setMetallicRoughnessPbrMaterial;
+        private getPixelsFromTexture;
         /**
          * Extracts a texture from a Babylon texture into file data and glTF data
          * @param babylonTexture Babylon texture to extract
@@ -613,7 +613,7 @@ declare module BABYLON.GLTF2 {
          * @param imageData map of image file name and data
          * @return glTF texture info, or null if the texture format is not supported
          */
-        private _exportTextureAsync(babylonTexture, mimeType);
+        private _exportTextureAsync;
         /**
          * Builds a texture from base64 string
          * @param base64Texture base64 texture string
@@ -624,7 +624,7 @@ declare module BABYLON.GLTF2 {
          * @param imageData map of image data
          * @returns glTF texture info, or null if the texture format is not supported
          */
-        private _getTextureInfoFromBase64(base64Texture, baseTextureName, mimeType, texCoordIndex, samplerIndex);
+        private _getTextureInfoFromBase64;
     }
 }
 
@@ -690,7 +690,7 @@ declare module BABYLON.GLTF2 {
          * @returns nullable IAnimationData
          */
         static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
-        private static _DeduceAnimationInfo(animation);
+        private static _DeduceAnimationInfo;
         /**
          * @ignore
          * Create node animations from the transform node animations
@@ -722,7 +722,7 @@ declare module BABYLON.GLTF2 {
         static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
             [key: number]: number;
         }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
-        private static AddAnimation(name, glTFAnimation, babylonTransformNode, animation, dataAccessorType, animationChannelTargetPath, nodeMap, binaryWriter, bufferViews, accessors, convertToRightHandedSystem, useQuaternion, animationSampleRate);
+        private static AddAnimation;
         /**
          * Create a baked animation
          * @param babylonTransformNode BabylonJS mesh
@@ -736,9 +736,9 @@ declare module BABYLON.GLTF2 {
          * @param convertToRightHandedSystem converts the values to right-handed
          * @param useQuaternion specifies if quaternions should be used
          */
-        private static _CreateBakedAnimation(babylonTransformNode, animation, animationChannelTargetPath, minFrame, maxFrame, fps, sampleRate, inputs, outputs, minMaxFrames, convertToRightHandedSystem, useQuaternion);
-        private static _ConvertFactorToVector3OrQuaternion(factor, babylonTransformNode, animation, animationType, animationChannelTargetPath, convertToRightHandedSystem, useQuaternion);
-        private static _SetInterpolatedValue(babylonTransformNode, value, time, animation, animationChannelTargetPath, quaternionCache, inputs, outputs, convertToRightHandedSystem, useQuaternion);
+        private static _CreateBakedAnimation;
+        private static _ConvertFactorToVector3OrQuaternion;
+        private static _SetInterpolatedValue;
         /**
          * Creates linear animation from the animation key frames
          * @param babylonTransformNode BabylonJS mesh
@@ -750,7 +750,7 @@ declare module BABYLON.GLTF2 {
          * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
          * @param useQuaternion Specifies if quaternions are used in the animation
          */
-        private static _CreateLinearOrStepAnimation(babylonTransformNode, animation, animationChannelTargetPath, frameDelta, inputs, outputs, convertToRightHandedSystem, useQuaternion);
+        private static _CreateLinearOrStepAnimation;
         /**
          * Creates cubic spline animation from the animation key frames
          * @param babylonTransformNode BabylonJS mesh
@@ -762,8 +762,8 @@ declare module BABYLON.GLTF2 {
          * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
          * @param useQuaternion Specifies if quaternions are used in the animation
          */
-        private static _CreateCubicSplineAnimation(babylonTransformNode, animation, animationChannelTargetPath, frameDelta, inputs, outputs, convertToRightHandedSystem, useQuaternion);
-        private static _GetBasePositionRotationOrScale(babylonTransformNode, animationChannelTargetPath, convertToRightHandedSystem, useQuaternion);
+        private static _CreateCubicSplineAnimation;
+        private static _GetBasePositionRotationOrScale;
         /**
          * Adds a key frame value
          * @param keyFrame
@@ -774,14 +774,14 @@ declare module BABYLON.GLTF2 {
          * @param convertToRightHandedSystem
          * @param useQuaternion
          */
-        private static _AddKeyframeValue(keyFrame, animation, outputs, animationChannelTargetPath, babylonTransformNode, convertToRightHandedSystem, useQuaternion);
+        private static _AddKeyframeValue;
         /**
          * Determine the interpolation based on the key frames
          * @param keyFrames
          * @param animationChannelTargetPath
          * @param useQuaternion
          */
-        private static _DeduceInterpolation(keyFrames, animationChannelTargetPath, useQuaternion);
+        private static _DeduceInterpolation;
         /**
          * Adds an input tangent or output tangent to the output data
          * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
@@ -794,13 +794,13 @@ declare module BABYLON.GLTF2 {
          * @param useQuaternion Specifies if quaternions are used
          * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
          */
-        private static AddSplineTangent(babylonTransformNode, tangentType, outputs, animationChannelTargetPath, interpolation, keyFrame, frameDelta, useQuaternion, convertToRightHandedSystem);
+        private static AddSplineTangent;
         /**
          * Get the minimum and maximum key frames' frame values
          * @param keyFrames animation key frames
          * @returns the minimum and maximum key frame value
          */
-        private static calculateMinMaxKeyFrames(keyFrames);
+        private static calculateMinMaxKeyFrames;
     }
 }
 

+ 51 - 51
dist/preview release/serializers/babylonjs.serializers.module.d.ts

@@ -157,7 +157,7 @@ declare module BABYLON.GLTF2 {
          * Lazy load a local engine with premultiplied alpha set to false
          */
         _getLocalEngine(): Engine;
-        private reorderIndicesBasedOnPrimitiveMode(submesh, primitiveMode, babylonIndices, byteOffset, binaryWriter);
+        private reorderIndicesBasedOnPrimitiveMode;
         /**
          * Reorders the vertex attribute data based on the primitive mode.  This is necessary when indices are not available and the winding order is
          * clock-wise during export to glTF
@@ -169,7 +169,7 @@ declare module BABYLON.GLTF2 {
          * @param byteOffset The offset to the binary data
          * @param binaryWriter The binary data for the glTF file
          */
-        private reorderVertexAttributeDataBasedOnPrimitiveMode(submesh, primitiveMode, sideOrientation, vertexBufferKind, meshAttributeArray, byteOffset, binaryWriter);
+        private reorderVertexAttributeDataBasedOnPrimitiveMode;
         /**
          * Reorders the vertex attributes in the correct triangle mode order .  This is necessary when indices are not available and the winding order is
          * clock-wise during export to glTF
@@ -181,7 +181,7 @@ declare module BABYLON.GLTF2 {
          * @param byteOffset The offset to the binary data
          * @param binaryWriter The binary data for the glTF file
          */
-        private reorderTriangleFillMode(submesh, primitiveMode, sideOrientation, vertexBufferKind, meshAttributeArray, byteOffset, binaryWriter);
+        private reorderTriangleFillMode;
         /**
          * Reorders the vertex attributes in the correct triangle strip order.  This is necessary when indices are not available and the winding order is
          * clock-wise during export to glTF
@@ -193,7 +193,7 @@ declare module BABYLON.GLTF2 {
          * @param byteOffset The offset to the binary data
          * @param binaryWriter The binary data for the glTF file
          */
-        private reorderTriangleStripDrawMode(submesh, primitiveMode, sideOrientation, vertexBufferKind, meshAttributeArray, byteOffset, binaryWriter);
+        private reorderTriangleStripDrawMode;
         /**
          * Reorders the vertex attributes in the correct triangle fan order.  This is necessary when indices are not available and the winding order is
          * clock-wise during export to glTF
@@ -205,7 +205,7 @@ declare module BABYLON.GLTF2 {
          * @param byteOffset The offset to the binary data
          * @param binaryWriter The binary data for the glTF file
          */
-        private reorderTriangleFanMode(submesh, primitiveMode, sideOrientation, vertexBufferKind, meshAttributeArray, byteOffset, binaryWriter);
+        private reorderTriangleFanMode;
         /**
          * Writes the vertex attribute data to binary
          * @param vertices The vertices to write to the binary writer
@@ -214,7 +214,7 @@ declare module BABYLON.GLTF2 {
          * @param meshAttributeArray The vertex attribute data
          * @param binaryWriter The writer containing the binary data
          */
-        private writeVertexAttributeData(vertices, byteOffset, vertexAttributeKind, meshAttributeArray, binaryWriter);
+        private writeVertexAttributeData;
         /**
          * Writes mesh attribute data to a data buffer
          * Returns the bytelength of the data
@@ -223,7 +223,7 @@ declare module BABYLON.GLTF2 {
          * @param binaryWriter The buffer to write the binary data to
          * @param indices Used to specify the order of the vertex data
          */
-        private writeAttributeData(vertexBufferKind, meshAttributeArray, byteStride, binaryWriter);
+        private writeAttributeData;
         /**
          * Generates glTF json data
          * @param shouldUseGlb Indicates whether the json should be written for a glb file
@@ -231,7 +231,7 @@ declare module BABYLON.GLTF2 {
          * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
          * @returns json data as string
          */
-        private generateJSON(shouldUseGlb, glTFPrefix?, prettyPrint?);
+        private generateJSON;
         /**
          * Generates data for .gltf and .bin files based on the glTF prefix string
          * @param glTFPrefix Text to use when prefixing a glTF file
@@ -242,13 +242,13 @@ declare module BABYLON.GLTF2 {
          * Creates a binary buffer for glTF
          * @returns array buffer for binary data
          */
-        private _generateBinaryAsync();
+        private _generateBinaryAsync;
         /**
          * Pads the number to a multiple of 4
          * @param num number to pad
          * @returns padded number
          */
-        private _getPadding(num);
+        private _getPadding;
         /**
          * Generates a glb file from the json and binary data
          * Returns an object with the glb file name as the key and data as the value
@@ -261,47 +261,47 @@ declare module BABYLON.GLTF2 {
          * @param node glTF Node for storing the transformation data
          * @param babylonTransformNode Babylon mesh used as the source for the transformation data
          */
-        private setNodeTransformation(node, babylonTransformNode);
-        private getVertexBufferFromMesh(attributeKind, bufferMesh);
+        private setNodeTransformation;
+        private getVertexBufferFromMesh;
         /**
          * Creates a bufferview based on the vertices type for the Babylon mesh
          * @param kind Indicates the type of vertices data
          * @param babylonTransformNode The Babylon mesh to get the vertices data from
          * @param binaryWriter The buffer to write the bufferview data to
          */
-        private createBufferViewKind(kind, babylonTransformNode, binaryWriter, byteStride);
+        private createBufferViewKind;
         /**
          * The primitive mode of the Babylon mesh
          * @param babylonMesh The BabylonJS mesh
          */
-        private getMeshPrimitiveMode(babylonMesh);
+        private getMeshPrimitiveMode;
         /**
          * Sets the primitive mode of the glTF mesh primitive
          * @param meshPrimitive glTF mesh primitive
          * @param primitiveMode The primitive mode
          */
-        private setPrimitiveMode(meshPrimitive, primitiveMode);
+        private setPrimitiveMode;
         /**
          * Sets the vertex attribute accessor based of the glTF mesh primitive
          * @param meshPrimitive glTF mesh primitive
          * @param attributeKind vertex attribute
          * @returns boolean specifying if uv coordinates are present
          */
-        private setAttributeKind(meshPrimitive, attributeKind);
+        private setAttributeKind;
         /**
          * Sets data for the primitive attributes of each submesh
          * @param mesh glTF Mesh object to store the primitive attribute information
          * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
          * @param binaryWriter Buffer to write the attribute data to
          */
-        private setPrimitiveAttributes(mesh, babylonTransformNode, binaryWriter);
+        private setPrimitiveAttributes;
         /**
          * Creates a glTF scene based on the array of meshes
          * Returns the the total byte offset
          * @param babylonScene Babylon scene to get the mesh data from
          * @param binaryWriter Buffer to write binary data to
          */
-        private createSceneAsync(babylonScene, binaryWriter);
+        private createSceneAsync;
         /**
          * Creates a mapping of Node unique id to node index and handles animations
          * @param babylonScene Babylon Scene
@@ -310,14 +310,14 @@ declare module BABYLON.GLTF2 {
          * @param binaryWriter Buffer to write binary data to
          * @returns Node mapping of unique id to index
          */
-        private createNodeMapAndAnimations(babylonScene, nodes, shouldExportTransformNode, binaryWriter);
+        private createNodeMapAndAnimations;
         /**
          * Creates a glTF node from a Babylon mesh
          * @param babylonMesh Source Babylon mesh
          * @param binaryWriter Buffer for storing geometry data
          * @returns glTF node
          */
-        private createNode(babylonTransformNode, binaryWriter);
+        private createNode;
     }
     /**
      * @hidden
@@ -346,7 +346,7 @@ declare module BABYLON.GLTF2 {
          * Resize the array buffer to the specified byte length
          * @param byteLength
          */
-        private resizeBuffer(byteLength);
+        private resizeBuffer;
         /**
          * Get an array buffer with the length of the byte offset
          * @returns ArrayBuffer resized to the byte offset
@@ -444,7 +444,7 @@ declare module BABYLON.GLTF2 {
          * @param color2 second color to compare to
          * @param epsilon threshold value
          */
-        private static FuzzyEquals(color1, color2, epsilon);
+        private static FuzzyEquals;
         /**
          * Gets the materials from a Babylon scene and converts them to glTF materials
          * @param scene babylonjs scene
@@ -518,7 +518,7 @@ declare module BABYLON.GLTF2 {
          * @param mimeType mimetype of the image
          * @returns base64 image string
          */
-        private _createBase64FromCanvasAsync(buffer, width, height, mimeType);
+        private _createBase64FromCanvasAsync;
         /**
          * Generates a white texture based on the specified width and height
          * @param width width of the texture in pixels
@@ -526,7 +526,7 @@ declare module BABYLON.GLTF2 {
          * @param scene babylonjs scene
          * @returns white texture
          */
-        private _createWhiteTexture(width, height, scene);
+        private _createWhiteTexture;
         /**
          * Resizes the two source textures to the same dimensions.  If a texture is null, a default white texture is generated.  If both textures are null, returns null
          * @param texture1 first texture to resize
@@ -534,14 +534,14 @@ declare module BABYLON.GLTF2 {
          * @param scene babylonjs scene
          * @returns resized textures or null
          */
-        private _resizeTexturesToSameDimensions(texture1, texture2, scene);
+        private _resizeTexturesToSameDimensions;
         /**
          * Converts an array of pixels to a Float32Array
          * Throws an error if the pixel format is not supported
          * @param pixels - array buffer containing pixel values
          * @returns Float32 of pixels
          */
-        private _convertPixelArrayToFloat32(pixels);
+        private _convertPixelArrayToFloat32;
         /**
          * Convert Specular Glossiness Textures to Metallic Roughness
          * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
@@ -552,25 +552,25 @@ declare module BABYLON.GLTF2 {
          * @param mimeType the mime type to use for the texture
          * @returns pbr metallic roughness interface or null
          */
-        private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync(diffuseTexture, specularGlossinessTexture, factors, mimeType);
+        private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
         /**
          * Converts specular glossiness material properties to metallic roughness
          * @param specularGlossiness interface with specular glossiness material properties
          * @returns interface with metallic roughness material properties
          */
-        private _convertSpecularGlossinessToMetallicRoughness(specularGlossiness);
+        private _convertSpecularGlossinessToMetallicRoughness;
         /**
          * Calculates the surface reflectance, independent of lighting conditions
          * @param color Color source to calculate brightness from
          * @returns number representing the perceived brightness, or zero if color is undefined
          */
-        private _getPerceivedBrightness(color);
+        private _getPerceivedBrightness;
         /**
          * Returns the maximum color component value
          * @param color
          * @returns maximum color component value, or zero if color is null or undefined
          */
-        private _getMaxComponent(color);
+        private _getMaxComponent;
         /**
          * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
          * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
@@ -582,10 +582,10 @@ declare module BABYLON.GLTF2 {
          * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
          * @returns glTF PBR Metallic Roughness factors
          */
-        private _convertMetalRoughFactorsToMetallicRoughnessAsync(babylonPBRMaterial, mimeType, glTFPbrMetallicRoughness, hasTextureCoords);
-        private _getGLTFTextureSampler(texture);
-        private _getGLTFTextureWrapMode(wrapMode);
-        private _getGLTFTextureWrapModesSampler(texture);
+        private _convertMetalRoughFactorsToMetallicRoughnessAsync;
+        private _getGLTFTextureSampler;
+        private _getGLTFTextureWrapMode;
+        private _getGLTFTextureWrapModesSampler;
         /**
          * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
          * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
@@ -597,7 +597,7 @@ declare module BABYLON.GLTF2 {
          * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
          * @returns glTF PBR Metallic Roughness factors
          */
-        private _convertSpecGlossFactorsToMetallicRoughnessAsync(babylonPBRMaterial, mimeType, glTFPbrMetallicRoughness, hasTextureCoords);
+        private _convertSpecGlossFactorsToMetallicRoughnessAsync;
         /**
          * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
          * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
@@ -609,8 +609,8 @@ declare module BABYLON.GLTF2 {
          * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
          */
         _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
-        private setMetallicRoughnessPbrMaterial(metallicRoughness, babylonPBRMaterial, glTFMaterial, glTFPbrMetallicRoughness, mimeType, hasTextureCoords);
-        private getPixelsFromTexture(babylonTexture);
+        private setMetallicRoughnessPbrMaterial;
+        private getPixelsFromTexture;
         /**
          * Extracts a texture from a Babylon texture into file data and glTF data
          * @param babylonTexture Babylon texture to extract
@@ -620,7 +620,7 @@ declare module BABYLON.GLTF2 {
          * @param imageData map of image file name and data
          * @return glTF texture info, or null if the texture format is not supported
          */
-        private _exportTextureAsync(babylonTexture, mimeType);
+        private _exportTextureAsync;
         /**
          * Builds a texture from base64 string
          * @param base64Texture base64 texture string
@@ -631,7 +631,7 @@ declare module BABYLON.GLTF2 {
          * @param imageData map of image data
          * @returns glTF texture info, or null if the texture format is not supported
          */
-        private _getTextureInfoFromBase64(base64Texture, baseTextureName, mimeType, texCoordIndex, samplerIndex);
+        private _getTextureInfoFromBase64;
     }
 }
 
@@ -697,7 +697,7 @@ declare module BABYLON.GLTF2 {
          * @returns nullable IAnimationData
          */
         static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
-        private static _DeduceAnimationInfo(animation);
+        private static _DeduceAnimationInfo;
         /**
          * @ignore
          * Create node animations from the transform node animations
@@ -729,7 +729,7 @@ declare module BABYLON.GLTF2 {
         static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
             [key: number]: number;
         }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
-        private static AddAnimation(name, glTFAnimation, babylonTransformNode, animation, dataAccessorType, animationChannelTargetPath, nodeMap, binaryWriter, bufferViews, accessors, convertToRightHandedSystem, useQuaternion, animationSampleRate);
+        private static AddAnimation;
         /**
          * Create a baked animation
          * @param babylonTransformNode BabylonJS mesh
@@ -743,9 +743,9 @@ declare module BABYLON.GLTF2 {
          * @param convertToRightHandedSystem converts the values to right-handed
          * @param useQuaternion specifies if quaternions should be used
          */
-        private static _CreateBakedAnimation(babylonTransformNode, animation, animationChannelTargetPath, minFrame, maxFrame, fps, sampleRate, inputs, outputs, minMaxFrames, convertToRightHandedSystem, useQuaternion);
-        private static _ConvertFactorToVector3OrQuaternion(factor, babylonTransformNode, animation, animationType, animationChannelTargetPath, convertToRightHandedSystem, useQuaternion);
-        private static _SetInterpolatedValue(babylonTransformNode, value, time, animation, animationChannelTargetPath, quaternionCache, inputs, outputs, convertToRightHandedSystem, useQuaternion);
+        private static _CreateBakedAnimation;
+        private static _ConvertFactorToVector3OrQuaternion;
+        private static _SetInterpolatedValue;
         /**
          * Creates linear animation from the animation key frames
          * @param babylonTransformNode BabylonJS mesh
@@ -757,7 +757,7 @@ declare module BABYLON.GLTF2 {
          * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
          * @param useQuaternion Specifies if quaternions are used in the animation
          */
-        private static _CreateLinearOrStepAnimation(babylonTransformNode, animation, animationChannelTargetPath, frameDelta, inputs, outputs, convertToRightHandedSystem, useQuaternion);
+        private static _CreateLinearOrStepAnimation;
         /**
          * Creates cubic spline animation from the animation key frames
          * @param babylonTransformNode BabylonJS mesh
@@ -769,8 +769,8 @@ declare module BABYLON.GLTF2 {
          * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
          * @param useQuaternion Specifies if quaternions are used in the animation
          */
-        private static _CreateCubicSplineAnimation(babylonTransformNode, animation, animationChannelTargetPath, frameDelta, inputs, outputs, convertToRightHandedSystem, useQuaternion);
-        private static _GetBasePositionRotationOrScale(babylonTransformNode, animationChannelTargetPath, convertToRightHandedSystem, useQuaternion);
+        private static _CreateCubicSplineAnimation;
+        private static _GetBasePositionRotationOrScale;
         /**
          * Adds a key frame value
          * @param keyFrame
@@ -781,14 +781,14 @@ declare module BABYLON.GLTF2 {
          * @param convertToRightHandedSystem
          * @param useQuaternion
          */
-        private static _AddKeyframeValue(keyFrame, animation, outputs, animationChannelTargetPath, babylonTransformNode, convertToRightHandedSystem, useQuaternion);
+        private static _AddKeyframeValue;
         /**
          * Determine the interpolation based on the key frames
          * @param keyFrames
          * @param animationChannelTargetPath
          * @param useQuaternion
          */
-        private static _DeduceInterpolation(keyFrames, animationChannelTargetPath, useQuaternion);
+        private static _DeduceInterpolation;
         /**
          * Adds an input tangent or output tangent to the output data
          * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
@@ -801,13 +801,13 @@ declare module BABYLON.GLTF2 {
          * @param useQuaternion Specifies if quaternions are used
          * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
          */
-        private static AddSplineTangent(babylonTransformNode, tangentType, outputs, animationChannelTargetPath, interpolation, keyFrame, frameDelta, useQuaternion, convertToRightHandedSystem);
+        private static AddSplineTangent;
         /**
          * Get the minimum and maximum key frames' frame values
          * @param keyFrames animation key frames
          * @returns the minimum and maximum key frame value
          */
-        private static calculateMinMaxKeyFrames(keyFrames);
+        private static calculateMinMaxKeyFrames;
     }
 }
 

Файловите разлики са ограничени, защото са твърде много
+ 3 - 3
dist/preview release/viewer/babylon.viewer.js


Файловите разлики са ограничени, защото са твърде много
+ 3 - 3
dist/preview release/viewer/babylon.viewer.max.js


+ 3 - 1
src/Cameras/VR/babylon.vrExperienceHelper.ts

@@ -507,7 +507,9 @@ module BABYLON {
          * @param scene The scene the VRExperienceHelper belongs to.
          * @param webVROptions Options to modify the vr experience helper's behavior.
          */
-        constructor(scene: Scene, /** Options to modify the vr experience helper's behavior. */public webVROptions: VRExperienceHelperOptions = {}) {
+        constructor(scene: Scene, 
+            /** Options to modify the vr experience helper's behavior. */
+            public webVROptions: VRExperienceHelperOptions = {}) {
             this._scene = scene;
             this._canvas = scene.getEngine().getRenderingCanvas();
 

+ 5 - 2
src/Engine/babylon.engine.ts

@@ -3321,9 +3321,10 @@
          * @param effect defines the effect to activate
          */
         public enableEffect(effect: Nullable<Effect>): void {
-            if (!effect) {
+            if (!effect || effect === this._currentEffect) {
                 return;
             }
+
             // Use program
             this.bindSamplers(effect);
 
@@ -3332,7 +3333,9 @@
             if (effect.onBind) {
                 effect.onBind(effect);
             }
-            effect.onBindObservable.notifyObservers(effect);
+            if (effect._onBindObservable) {
+                effect._onBindObservable.notifyObservers(effect);
+            }
         }
 
         /**

+ 3 - 1
src/Engine/babylon.nullEngine.ts

@@ -166,7 +166,9 @@
             if (effect.onBind) {
                 effect.onBind(effect);
             }
-            effect.onBindObservable.notifyObservers(effect);
+            if (effect._onBindObservable) {
+                effect._onBindObservable.notifyObservers(effect);
+            }
         }
 
         public setState(culling: boolean, zOffset: number = 0, force?: boolean, reverseSide = false): void {

+ 3 - 1
src/Gizmos/babylon.gizmo.ts

@@ -64,7 +64,9 @@ module BABYLON {
          * Creates a gizmo
          * @param gizmoLayer The utility layer the gizmo will be added to
          */
-        constructor(/** The utility layer the gizmo will be added to */ public gizmoLayer:UtilityLayerRenderer=UtilityLayerRenderer.DefaultUtilityLayer){
+        constructor(
+            /** The utility layer the gizmo will be added to */ 
+            public gizmoLayer: UtilityLayerRenderer = UtilityLayerRenderer.DefaultUtilityLayer){
             this._rootMesh = new BABYLON.Mesh("gizmoRootNode",gizmoLayer.utilityLayerScene);
             this._beforeRenderObserver = this.gizmoLayer.utilityLayerScene.onBeforeRenderObservable.add(()=>{
                 this._update();

+ 12 - 1
src/Materials/babylon.effect.ts

@@ -202,10 +202,21 @@
          * Observable that will be called if an error occurs during shader compilation.
          */
         public onErrorObservable = new Observable<Effect>();
+
+
+        /** @hidden */
+        public _onBindObservable: Nullable<Observable<Effect>>;
+
         /**
          * Observable that will be called when effect is bound.
          */
-        public onBindObservable = new Observable<Effect>();
+        public get onBindObservable(): Observable<Effect> {
+            if (!this._onBindObservable) {
+                this._onBindObservable = new Observable<Effect>();
+            }
+
+            return this._onBindObservable;
+        }
 
 
         /** @hidden */

+ 29 - 8
src/Materials/babylon.material.ts

@@ -517,6 +517,7 @@
          * An observer which watches for dispose events
          */
         private _onDisposeObserver: Nullable<Observer<Material>>;
+        private _onUnBindObservable: Nullable<Observable<Material>>;
 
         /**
          * Called during a dispose event
@@ -527,11 +528,19 @@
             }
             this._onDisposeObserver = this.onDisposeObservable.add(callback);
         }
+        
+        private _onBindObservable: Nullable<Observable<AbstractMesh>>;
 
         /**
         * An event triggered when the material is bound
         */
-        public onBindObservable = new Observable<AbstractMesh>();
+        public get onBindObservable(): Observable<AbstractMesh> {
+            if (!this._onBindObservable) {
+                this._onBindObservable = new Observable<AbstractMesh>();
+            }
+
+            return this._onBindObservable;
+        }
 
         /**
          * An observer which watches for bind events
@@ -551,7 +560,13 @@
         /**
         * An event triggered when the material is unbound
         */
-        public onUnBindObservable = new Observable<Material>();
+        public get onUnBindObservable(): Observable<Material> {
+            if (!this._onUnBindObservable) {
+                this._onUnBindObservable = new Observable<Material>();
+            }
+
+            return this._onUnBindObservable;
+        }
 
         /**
          * Stores the value of the alpha mode
@@ -1006,8 +1021,8 @@
                 this._scene._cachedVisibility = 1;
             }
 
-            if (mesh) {
-                this.onBindObservable.notifyObservers(mesh);
+            if (this._onBindObservable && mesh) {
+                this._onBindObservable.notifyObservers(mesh);
             }
 
             if (this.disableDepthWrite) {
@@ -1021,8 +1036,9 @@
          * Unbinds the material from the mesh
          */
         public unbind(): void {
-
-            this.onUnBindObservable.notifyObservers(this);
+            if (this._onUnBindObservable) {
+                this._onUnBindObservable.notifyObservers(this);
+            }
 
             if (this.disableDepthWrite) {
                 var engine = this._scene.getEngine();
@@ -1314,8 +1330,13 @@
             this.onDisposeObservable.notifyObservers(this);
 
             this.onDisposeObservable.clear();
-            this.onBindObservable.clear();
-            this.onUnBindObservable.clear();
+            if (this._onBindObservable) {
+                this._onBindObservable.clear();
+            }
+            
+            if (this._onUnBindObservable) {
+                this._onUnBindObservable.clear();
+            }
         }
 
         /**

+ 1 - 1
src/Materials/babylon.standardMaterial.ts

@@ -544,7 +544,7 @@ module BABYLON {
          */
         public isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances: boolean = false): boolean {
             if (subMesh.effect && this.isFrozen) {
-                if (this._wasPreviouslyReady && subMesh.effect) {
+                if (this._wasPreviouslyReady) {
                     return true;
                 }
             }

+ 52 - 11
src/Mesh/babylon.mesh.ts

@@ -68,21 +68,42 @@
         }
 
         // Events 
+        private _onBeforeRenderObservable: Nullable<Observable<Mesh>>;
+        private _onAfterRenderObservable: Nullable<Observable<Mesh>>;
+        private _onBeforeDrawObservable: Nullable<Observable<Mesh>>;
 
         /**
          * An event triggered before rendering the mesh
          */
-        public onBeforeRenderObservable = new Observable<Mesh>();
+        public get onBeforeRenderObservable(): Observable<Mesh> {
+            if (!this._onBeforeRenderObservable) {
+                this._onBeforeRenderObservable = new Observable<Mesh>();
+            }
+
+            return this._onBeforeRenderObservable;
+        }
 
         /**
         * An event triggered after rendering the mesh
         */
-        public onAfterRenderObservable = new Observable<Mesh>();
+        public get onAfterRenderObservable(): Observable<Mesh> {
+            if (!this._onAfterRenderObservable) {
+                this._onAfterRenderObservable = new Observable<Mesh>();
+            }
+
+            return this._onAfterRenderObservable;
+        }
 
         /**
         * An event triggered before drawing the mesh
         */
-        public onBeforeDrawObservable = new Observable<Mesh>();
+        public get onBeforeDrawObservable(): Observable<Mesh> {
+            if (!this._onBeforeDrawObservable) {
+                this._onBeforeDrawObservable = new Observable<Mesh>();
+            }
+
+            return this._onBeforeDrawObservable;
+        }
 
         private _onBeforeDrawObserver: Nullable<Observer<Mesh>>;
         public set onBeforeDraw(callback: () => void) {
@@ -184,7 +205,9 @@
 
                 // Deep copy
                 Tools.DeepCopy(source, this, ["name", "material", "skeleton", "instances", "parent", "uniqueId", 
-                                              "source", "metadata", "hasLODLevels", "geometry", "isBlocked", "areNormalsFrozen"], 
+                                              "source", "metadata", "hasLODLevels", "geometry", "isBlocked", "areNormalsFrozen",
+                                              "onBeforeDrawObservable", "onBeforeRenderObservable", "onAfterRenderObservable", "onBeforeDraw"
+                                            ], 
                                               ["_poseMatrix"]);
 
                 // Source mesh
@@ -1076,7 +1099,9 @@
                 return this;
             }
 
-            this.onBeforeDrawObservable.notifyObservers(this);
+            if (this._onBeforeDrawObservable) {
+                this._onBeforeDrawObservable.notifyObservers(this);
+            }
 
             let scene = this.getScene();
             let engine = scene.getEngine();
@@ -1294,10 +1319,10 @@
          */
         public render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh {
 
-            this._checkOcclusionQuery();
-            if (this._isOccluded) {
-                return this;
-            }
+            // this._checkOcclusionQuery();
+            // if (this._isOccluded) {
+            //     return this;
+            // }
 
             var scene = this.getScene();
             // Managing instances
@@ -1312,7 +1337,9 @@
                 return this;
             }
 
-            this.onBeforeRenderObservable.notifyObservers(this);
+            if (this._onBeforeRenderObservable) {
+                this._onBeforeRenderObservable.notifyObservers(this);
+            }
 
             var engine = scene.getEngine();
             var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null) && (batch.visibleInstances[subMesh._id] !== undefined);
@@ -1415,7 +1442,9 @@
                 engine.setAlphaMode(currentMode);
             }
 
-            this.onAfterRenderObservable.notifyObservers(this);
+            if (this._onAfterRenderObservable) {
+                this._onAfterRenderObservable.notifyObservers(this);
+            }
             return this;
         }
 
@@ -1748,6 +1777,18 @@
                 this._geometry.releaseForMesh(this, true);
             }
 
+            if (this._onBeforeDrawObservable) {
+                this._onBeforeDrawObservable.clear();
+            }
+
+            if (this._onBeforeRenderObservable) {
+                this._onBeforeRenderObservable.clear();
+            }
+
+            if (this._onAfterRenderObservable) {
+                this._onAfterRenderObservable.clear();
+            }            
+
             // Sources
             var meshes = this.getScene().meshes;
             meshes.forEach((abstractMesh: AbstractMesh) => {

+ 5 - 1
src/PostProcess/babylon.bloomMergePostProcess.ts

@@ -17,7 +17,11 @@ module BABYLON {
          * @param textureType Type of textures used when performing the post process. (default: 0)
          * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
          */
-        constructor(name: string, originalFromInput:PostProcess, blurred:PostProcess, /** Weight of the bloom to be added to the original input. */ public weight:number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType: number = Engine.TEXTURETYPE_UNSIGNED_INT, blockCompilation = false) {
+        constructor(name: string, originalFromInput:PostProcess, blurred:PostProcess, 
+            /** Weight of the bloom to be added to the original input. */ 
+            public weight:number, 
+            options: number | PostProcessOptions, 
+            camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType: number = Engine.TEXTURETYPE_UNSIGNED_INT, blockCompilation = false) {
             super(name, "bloomMerge", ["bloomWeight"], ["circleOfConfusionSampler", "blurStep0", "blurStep1", "blurStep2", "bloomBlur"], options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, true);
             this.onApplyObservable.add((effect: Effect) => {
                 effect.setTextureFromPostProcess("textureSampler", originalFromInput);

+ 4 - 1
src/PostProcess/babylon.blurPostProcess.ts

@@ -64,7 +64,10 @@
          * @param textureType Type of textures used when performing the post process. (default: 0)
          * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
          */
-        constructor(name: string, /** The direction in which to blur the image. */ public direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode: number = Texture.BILINEAR_SAMPLINGMODE, engine?: Engine, reusable?: boolean, textureType: number = Engine.TEXTURETYPE_UNSIGNED_INT, defines = "", private blockCompilation = false) {
+        constructor(name: string, 
+            /** The direction in which to blur the image. */ 
+            public direction: Vector2, 
+            kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode: number = Texture.BILINEAR_SAMPLINGMODE, engine?: Engine, reusable?: boolean, textureType: number = Engine.TEXTURETYPE_UNSIGNED_INT, defines = "", private blockCompilation = false) {
             super(name, "kernelBlur", ["delta", "direction", "cameraMinMaxZ"], ["circleOfConfusionSampler"], options, camera, samplingMode, engine, reusable, null, textureType, "kernelBlur", {varyingCount: 0, depCount: 0}, true);
             this._staticDefines = defines;
             this.onApplyObservable.add((effect: Effect) => {

+ 4 - 1
src/PostProcess/babylon.convolutionPostProcess.ts

@@ -16,7 +16,10 @@
          * @param reusable If the post process can be reused on the same frame. (default: false)
          * @param textureType Type of textures used when performing the post process. (default: 0)
          */
-        constructor(name: string, /** Array of 9 values corrisponding to the 3x3 kernel to be applied */ public kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType: number = Engine.TEXTURETYPE_UNSIGNED_INT) {
+        constructor(name: string, 
+            /** Array of 9 values corrisponding to the 3x3 kernel to be applied */ 
+            public kernel: number[], 
+            options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType: number = Engine.TEXTURETYPE_UNSIGNED_INT) {
             super(name, "convolution", ["kernel", "screenSize"], null, options, camera, samplingMode, engine, reusable, null, textureType);
 
             this.onApply = (effect: Effect) => {

+ 4 - 1
src/PostProcess/babylon.postProcess.ts

@@ -244,7 +244,10 @@
          * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
          * @param blockCompilation If the shader should not be compiled imediatly. (default: false) 
          */
-        constructor(/** Name of the PostProcess. */public name: string, fragmentUrl: string, parameters: Nullable<string[]>, samplers: Nullable<string[]>, options: number | PostProcessOptions, camera: Nullable<Camera>,
+        constructor(
+            /** Name of the PostProcess. */
+            public name: string, 
+            fragmentUrl: string, parameters: Nullable<string[]>, samplers: Nullable<string[]>, options: number | PostProcessOptions, camera: Nullable<Camera>,
             samplingMode: number = Texture.NEAREST_SAMPLINGMODE, engine?: Engine, reusable?: boolean, defines: Nullable<string> = null, textureType: number = Engine.TEXTURETYPE_UNSIGNED_INT, vertexUrl: string = "postprocess", indexParameters?: any, blockCompilation = false) {
             if (camera != null) {
                 this._camera = camera;

+ 3 - 1
src/Rendering/babylon.utilityLayerRenderer.ts

@@ -67,7 +67,9 @@ module BABYLON {
          * Instantiates a UtilityLayerRenderer
          * @param originalScene the original scene that will be rendered on top of
          */
-        constructor(/** the original scene that will be rendered on top of */ public originalScene:Scene){
+        constructor(
+            /** the original scene that will be rendered on top of */ 
+            public originalScene: Scene){
             // Create scene which will be rendered in the foreground and remove it from being referenced by engine to avoid interfering with existing app
             this.utilityLayerScene = new BABYLON.Scene(originalScene.getEngine());
             this.utilityLayerScene._allowPostProcessClear = false;