David Catuhe 7 years ago
parent
commit
793a2827ce

File diff suppressed because it is too large
+ 4754 - 4749
Playground/babylon.d.txt


File diff suppressed because it is too large
+ 3970 - 3965
dist/preview release/babylon.d.ts


File diff suppressed because it is too large
+ 44 - 44
dist/preview release/babylon.js


+ 43 - 11
dist/preview release/babylon.max.js

@@ -5808,6 +5808,22 @@ var BABYLON;
         return LoadFileError;
     }(Error));
     BABYLON.LoadFileError = LoadFileError;
+    var RetryStrategy = /** @class */ (function () {
+        function RetryStrategy() {
+        }
+        RetryStrategy.ExponentialBackoff = function (maxRetries, baseInterval) {
+            if (maxRetries === void 0) { maxRetries = 3; }
+            if (baseInterval === void 0) { baseInterval = 500; }
+            return function (url, request, retryIndex) {
+                if (request.status !== 0 || retryIndex >= maxRetries || url.indexOf("file:") !== -1) {
+                    return -1;
+                }
+                return Math.pow(2, retryIndex) * baseInterval;
+            };
+        };
+        return RetryStrategy;
+    }());
+    BABYLON.RetryStrategy = RetryStrategy;
     // Screenshots
     var screenshotCanvas;
     var cloneValue = function (source, destinationObject) {
@@ -6198,11 +6214,13 @@ var BABYLON;
             }
             return img;
         };
-        Tools.LoadFile = function (url, callback, progressCallBack, database, useArrayBuffer, onError) {
+        Tools.LoadFile = function (url, callback, progressCallBack, database, useArrayBuffer, onError, onRetry, retryStrategy) {
+            if (retryStrategy === void 0) { retryStrategy = null; }
             url = Tools.CleanUrl(url);
             url = Tools.PreprocessUrl(url);
             var request = null;
-            var noIndexedDB = function () {
+            var noIndexedDB = function (retryIndex) {
+                var oldRequest = request;
                 request = new XMLHttpRequest();
                 var loadUrl = Tools.BaseUrl + url;
                 request.open('GET', loadUrl, true);
@@ -6219,19 +6237,29 @@ var BABYLON;
                         req.onreadystatechange = function () { }; //some browsers have issues where onreadystatechange can be called multiple times with the same value
                         if (req.status >= 200 && req.status < 300 || (!Tools.IsWindowObjectExist() && (req.status === 0))) {
                             callback(!useArrayBuffer ? req.responseText : req.response, req.responseURL);
+                            return;
                         }
-                        else {
-                            var e = new LoadFileError("Error status: " + req.status + " - Unable to load " + loadUrl, req);
-                            if (onError) {
-                                onError(req, e);
-                            }
-                            else {
-                                throw e;
+                        retryStrategy = retryStrategy || Tools.DefaultRetryStrategy;
+                        if (retryStrategy) {
+                            var waitTime = retryStrategy(loadUrl, req, retryIndex || 0);
+                            if (waitTime !== -1) {
+                                setTimeout(function () { return noIndexedDB((retryIndex || 0) + 1); }, waitTime);
+                                return;
                             }
                         }
+                        var e = new Error("Error status: " + req.status + " - Unable to load " + loadUrl);
+                        if (onError) {
+                            onError(req, e);
+                        }
+                        else {
+                            throw e;
+                        }
                     }
                 };
-                request.send(null);
+                request.send();
+                if (oldRequest && onRetry) {
+                    onRetry(oldRequest, request);
+                }
             };
             var loadFromIndexedDB = function () {
                 if (database) {
@@ -6962,6 +6990,7 @@ var BABYLON;
             return hash;
         };
         Tools.BaseUrl = "";
+        Tools.DefaultRetryStrategy = RetryStrategy.ExponentialBackoff();
         /**
          * Default behaviour for cors in the application.
          * It can be a string if the expected behavior is identical in the entire app.
@@ -53736,6 +53765,9 @@ var BABYLON;
         SceneLoader.GetPluginForExtension = function (extension) {
             return SceneLoader._getPluginForExtension(extension).plugin;
         };
+        SceneLoader.IsPluginForExtensionAvailable = function (extension) {
+            return !!SceneLoader._registeredPlugins[extension];
+        };
         SceneLoader.RegisterPlugin = function (plugin) {
             if (typeof plugin.extensions === "string") {
                 var extension = plugin.extensions;
@@ -57982,7 +58014,7 @@ var BABYLON;
             var path;
             var filename;
             // Checking if GLB loader is present
-            if (BABYLON.SceneLoader.GetPluginForExtension("glb")) {
+            if (BABYLON.SceneLoader.IsPluginForExtensionAvailable("glb")) {
                 // Determine the device specific folder based on the ID suffix
                 var device = 'default';
                 if (this.id && !forceDefault) {

File diff suppressed because it is too large
+ 44 - 44
dist/preview release/babylon.worker.js


File diff suppressed because it is too large
+ 47 - 47
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.js


+ 64 - 35
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.max.js

@@ -5808,6 +5808,22 @@ var BABYLON;
         return LoadFileError;
     }(Error));
     BABYLON.LoadFileError = LoadFileError;
+    var RetryStrategy = /** @class */ (function () {
+        function RetryStrategy() {
+        }
+        RetryStrategy.ExponentialBackoff = function (maxRetries, baseInterval) {
+            if (maxRetries === void 0) { maxRetries = 3; }
+            if (baseInterval === void 0) { baseInterval = 500; }
+            return function (url, request, retryIndex) {
+                if (request.status !== 0 || retryIndex >= maxRetries || url.indexOf("file:") !== -1) {
+                    return -1;
+                }
+                return Math.pow(2, retryIndex) * baseInterval;
+            };
+        };
+        return RetryStrategy;
+    }());
+    BABYLON.RetryStrategy = RetryStrategy;
     // Screenshots
     var screenshotCanvas;
     var cloneValue = function (source, destinationObject) {
@@ -6198,11 +6214,13 @@ var BABYLON;
             }
             return img;
         };
-        Tools.LoadFile = function (url, callback, progressCallBack, database, useArrayBuffer, onError) {
+        Tools.LoadFile = function (url, callback, progressCallBack, database, useArrayBuffer, onError, onRetry, retryStrategy) {
+            if (retryStrategy === void 0) { retryStrategy = null; }
             url = Tools.CleanUrl(url);
             url = Tools.PreprocessUrl(url);
             var request = null;
-            var noIndexedDB = function () {
+            var noIndexedDB = function (retryIndex) {
+                var oldRequest = request;
                 request = new XMLHttpRequest();
                 var loadUrl = Tools.BaseUrl + url;
                 request.open('GET', loadUrl, true);
@@ -6219,19 +6237,29 @@ var BABYLON;
                         req.onreadystatechange = function () { }; //some browsers have issues where onreadystatechange can be called multiple times with the same value
                         if (req.status >= 200 && req.status < 300 || (!Tools.IsWindowObjectExist() && (req.status === 0))) {
                             callback(!useArrayBuffer ? req.responseText : req.response, req.responseURL);
+                            return;
                         }
-                        else {
-                            var e = new LoadFileError("Error status: " + req.status + " - Unable to load " + loadUrl, req);
-                            if (onError) {
-                                onError(req, e);
-                            }
-                            else {
-                                throw e;
+                        retryStrategy = retryStrategy || Tools.DefaultRetryStrategy;
+                        if (retryStrategy) {
+                            var waitTime = retryStrategy(loadUrl, req, retryIndex || 0);
+                            if (waitTime !== -1) {
+                                setTimeout(function () { return noIndexedDB((retryIndex || 0) + 1); }, waitTime);
+                                return;
                             }
                         }
+                        var e = new Error("Error status: " + req.status + " - Unable to load " + loadUrl);
+                        if (onError) {
+                            onError(req, e);
+                        }
+                        else {
+                            throw e;
+                        }
                     }
                 };
-                request.send(null);
+                request.send();
+                if (oldRequest && onRetry) {
+                    onRetry(oldRequest, request);
+                }
             };
             var loadFromIndexedDB = function () {
                 if (database) {
@@ -6962,6 +6990,7 @@ var BABYLON;
             return hash;
         };
         Tools.BaseUrl = "";
+        Tools.DefaultRetryStrategy = RetryStrategy.ExponentialBackoff();
         /**
          * Default behaviour for cors in the application.
          * It can be a string if the expected behavior is identical in the entire app.
@@ -53582,6 +53611,9 @@ var BABYLON;
         SceneLoader.GetPluginForExtension = function (extension) {
             return SceneLoader._getPluginForExtension(extension).plugin;
         };
+        SceneLoader.IsPluginForExtensionAvailable = function (extension) {
+            return !!SceneLoader._registeredPlugins[extension];
+        };
         SceneLoader.RegisterPlugin = function (plugin) {
             if (typeof plugin.extensions === "string") {
                 var extension = plugin.extensions;
@@ -57828,7 +57860,7 @@ var BABYLON;
             var path;
             var filename;
             // Checking if GLB loader is present
-            if (BABYLON.SceneLoader.GetPluginForExtension("glb")) {
+            if (BABYLON.SceneLoader.IsPluginForExtensionAvailable("glb")) {
                 // Determine the device specific folder based on the ID suffix
                 var device = 'default';
                 if (this.id && !forceDefault) {
@@ -82703,14 +82735,6 @@ var BABYLON;
                 this._loaderPendingCount = 0;
                 this._loaderTrackers = new Array();
                 this._parent = parent;
-                if (!GLTFLoader._progressEventFactory) {
-                    if (typeof window["ProgressEvent"] === "function") {
-                        GLTFLoader._progressEventFactory = GLTFLoader._createProgressEventByConstructor;
-                    }
-                    else {
-                        GLTFLoader._progressEventFactory = GLTFLoader._createProgressEventByDocument;
-                    }
-                }
             }
             GLTFLoader.RegisterExtension = function (extension) {
                 if (GLTFLoader.Extensions[extension.name]) {
@@ -82721,14 +82745,6 @@ var BABYLON;
                 // Keep the order of registration so that extensions registered first are called first.
                 GLTF2.GLTFLoaderExtension._Extensions.push(extension);
             };
-            GLTFLoader._createProgressEventByConstructor = function (name, data) {
-                return new ProgressEvent(name, data);
-            };
-            GLTFLoader._createProgressEventByDocument = function (name, data) {
-                var event = document.createEvent("ProgressEvent");
-                event.initProgressEvent(name, false, false, data.lengthComputable, data.loaded, data.total);
-                return event;
-            };
             GLTFLoader.prototype.dispose = function () {
                 if (this._disposed) {
                     return;
@@ -82781,21 +82797,19 @@ var BABYLON;
                 if (!this._progressCallback) {
                     return;
                 }
+                var lengthComputable = true;
                 var loaded = 0;
                 var total = 0;
                 for (var _i = 0, _a = this._requests; _i < _a.length; _i++) {
                     var request = _a[_i];
-                    if (!request._loaded || !request._total) {
+                    if (request._lengthComputable === undefined || request._loaded === undefined || request._total === undefined) {
                         return;
                     }
+                    lengthComputable = lengthComputable && request._lengthComputable;
                     loaded += request._loaded;
                     total += request._total;
                 }
-                this._progressCallback(GLTFLoader._progressEventFactory("GLTFLoaderProgress", {
-                    lengthComputable: true,
-                    loaded: loaded,
-                    total: total
-                }));
+                this._progressCallback(GLTFLoader._createProgressEvent(lengthComputable, loaded, lengthComputable ? total : 0));
             };
             GLTFLoader.prototype._executeWhenRenderReady = function (func) {
                 if (this._renderReady) {
@@ -84083,6 +84097,7 @@ var BABYLON;
                 }, function (event) {
                     _this._tryCatchOnError(function () {
                         if (request && !_this._renderReady) {
+                            request._lengthComputable = event.lengthComputable;
                             request._loaded = event.loaded;
                             request._total = event.total;
                             _this._onProgress();
@@ -84092,10 +84107,10 @@ var BABYLON;
                     _this._tryCatchOnError(function () {
                         throw new BABYLON.LoadFileError(context + ": Failed to load '" + uri + "'" + (request ? ": " + request.status + " " + request.statusText : ""), request);
                     });
+                }, function (oldRequest, newRequest) {
+                    _this._requests.splice(_this._requests.indexOf(oldRequest), 1, newRequest);
                 });
                 if (request) {
-                    request._loaded = null;
-                    request._total = null;
                     this._requests.push(request);
                 }
             };
@@ -84280,6 +84295,20 @@ var BABYLON;
                 }
             };
             GLTFLoader.Extensions = {};
+            // IE 11 Compatibility.
+            GLTFLoader._createProgressEvent = (typeof window["ProgressEvent"] === "function")
+                ? function (lengthComputable, loaded, total) {
+                    return new ProgressEvent("GLTFLoaderProgress", {
+                        lengthComputable: lengthComputable,
+                        loaded: loaded,
+                        total: total
+                    });
+                }
+                : function (lengthComputable, loaded, total) {
+                    var event = document.createEvent("ProgressEvent");
+                    event.initProgressEvent("GLTFLoaderProgress", false, false, lengthComputable, loaded, total);
+                    return event;
+                };
             return GLTFLoader;
         }());
         GLTF2.GLTFLoader = GLTFLoader;

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

@@ -379,9 +379,7 @@ declare module BABYLON.GLTF2 {
             [name: string]: GLTFLoaderExtension;
         };
         static RegisterExtension(extension: GLTFLoaderExtension): void;
-        private static _progressEventFactory;
-        private static _createProgressEventByConstructor(name, data);
-        private static _createProgressEventByDocument(name, data);
+        private static _createProgressEvent;
         constructor(parent: GLTFFileLoader);
         dispose(): void;
         importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[]) => void, onProgress?: (event: ProgressEvent) => void, onError?: (message: string, exception?: any) => void): void;

+ 21 - 24
dist/preview release/loaders/babylon.glTF2FileLoader.js

@@ -387,14 +387,6 @@ var BABYLON;
                 this._loaderPendingCount = 0;
                 this._loaderTrackers = new Array();
                 this._parent = parent;
-                if (!GLTFLoader._progressEventFactory) {
-                    if (typeof window["ProgressEvent"] === "function") {
-                        GLTFLoader._progressEventFactory = GLTFLoader._createProgressEventByConstructor;
-                    }
-                    else {
-                        GLTFLoader._progressEventFactory = GLTFLoader._createProgressEventByDocument;
-                    }
-                }
             }
             GLTFLoader.RegisterExtension = function (extension) {
                 if (GLTFLoader.Extensions[extension.name]) {
@@ -405,14 +397,6 @@ var BABYLON;
                 // Keep the order of registration so that extensions registered first are called first.
                 GLTF2.GLTFLoaderExtension._Extensions.push(extension);
             };
-            GLTFLoader._createProgressEventByConstructor = function (name, data) {
-                return new ProgressEvent(name, data);
-            };
-            GLTFLoader._createProgressEventByDocument = function (name, data) {
-                var event = document.createEvent("ProgressEvent");
-                event.initProgressEvent(name, false, false, data.lengthComputable, data.loaded, data.total);
-                return event;
-            };
             GLTFLoader.prototype.dispose = function () {
                 if (this._disposed) {
                     return;
@@ -465,21 +449,19 @@ var BABYLON;
                 if (!this._progressCallback) {
                     return;
                 }
+                var lengthComputable = true;
                 var loaded = 0;
                 var total = 0;
                 for (var _i = 0, _a = this._requests; _i < _a.length; _i++) {
                     var request = _a[_i];
-                    if (!request._loaded || !request._total) {
+                    if (request._lengthComputable === undefined || request._loaded === undefined || request._total === undefined) {
                         return;
                     }
+                    lengthComputable = lengthComputable && request._lengthComputable;
                     loaded += request._loaded;
                     total += request._total;
                 }
-                this._progressCallback(GLTFLoader._progressEventFactory("GLTFLoaderProgress", {
-                    lengthComputable: true,
-                    loaded: loaded,
-                    total: total
-                }));
+                this._progressCallback(GLTFLoader._createProgressEvent(lengthComputable, loaded, lengthComputable ? total : 0));
             };
             GLTFLoader.prototype._executeWhenRenderReady = function (func) {
                 if (this._renderReady) {
@@ -1767,6 +1749,7 @@ var BABYLON;
                 }, function (event) {
                     _this._tryCatchOnError(function () {
                         if (request && !_this._renderReady) {
+                            request._lengthComputable = event.lengthComputable;
                             request._loaded = event.loaded;
                             request._total = event.total;
                             _this._onProgress();
@@ -1776,10 +1759,10 @@ var BABYLON;
                     _this._tryCatchOnError(function () {
                         throw new BABYLON.LoadFileError(context + ": Failed to load '" + uri + "'" + (request ? ": " + request.status + " " + request.statusText : ""), request);
                     });
+                }, function (oldRequest, newRequest) {
+                    _this._requests.splice(_this._requests.indexOf(oldRequest), 1, newRequest);
                 });
                 if (request) {
-                    request._loaded = null;
-                    request._total = null;
                     this._requests.push(request);
                 }
             };
@@ -1964,6 +1947,20 @@ var BABYLON;
                 }
             };
             GLTFLoader.Extensions = {};
+            // IE 11 Compatibility.
+            GLTFLoader._createProgressEvent = (typeof window["ProgressEvent"] === "function")
+                ? function (lengthComputable, loaded, total) {
+                    return new ProgressEvent("GLTFLoaderProgress", {
+                        lengthComputable: lengthComputable,
+                        loaded: loaded,
+                        total: total
+                    });
+                }
+                : function (lengthComputable, loaded, total) {
+                    var event = document.createEvent("ProgressEvent");
+                    event.initProgressEvent("GLTFLoaderProgress", false, false, lengthComputable, loaded, total);
+                    return event;
+                };
             return GLTFLoader;
         }());
         GLTF2.GLTFLoader = GLTFLoader;

File diff suppressed because it is too large
+ 2 - 2
dist/preview release/loaders/babylon.glTF2FileLoader.min.js


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

@@ -926,9 +926,7 @@ declare module BABYLON.GLTF2 {
             [name: string]: GLTFLoaderExtension;
         };
         static RegisterExtension(extension: GLTFLoaderExtension): void;
-        private static _progressEventFactory;
-        private static _createProgressEventByConstructor(name, data);
-        private static _createProgressEventByDocument(name, data);
+        private static _createProgressEvent;
         constructor(parent: GLTFFileLoader);
         dispose(): void;
         importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[]) => void, onProgress?: (event: ProgressEvent) => void, onError?: (message: string, exception?: any) => void): void;

+ 21 - 24
dist/preview release/loaders/babylon.glTFFileLoader.js

@@ -2543,14 +2543,6 @@ var BABYLON;
                 this._loaderPendingCount = 0;
                 this._loaderTrackers = new Array();
                 this._parent = parent;
-                if (!GLTFLoader._progressEventFactory) {
-                    if (typeof window["ProgressEvent"] === "function") {
-                        GLTFLoader._progressEventFactory = GLTFLoader._createProgressEventByConstructor;
-                    }
-                    else {
-                        GLTFLoader._progressEventFactory = GLTFLoader._createProgressEventByDocument;
-                    }
-                }
             }
             GLTFLoader.RegisterExtension = function (extension) {
                 if (GLTFLoader.Extensions[extension.name]) {
@@ -2561,14 +2553,6 @@ var BABYLON;
                 // Keep the order of registration so that extensions registered first are called first.
                 GLTF2.GLTFLoaderExtension._Extensions.push(extension);
             };
-            GLTFLoader._createProgressEventByConstructor = function (name, data) {
-                return new ProgressEvent(name, data);
-            };
-            GLTFLoader._createProgressEventByDocument = function (name, data) {
-                var event = document.createEvent("ProgressEvent");
-                event.initProgressEvent(name, false, false, data.lengthComputable, data.loaded, data.total);
-                return event;
-            };
             GLTFLoader.prototype.dispose = function () {
                 if (this._disposed) {
                     return;
@@ -2621,21 +2605,19 @@ var BABYLON;
                 if (!this._progressCallback) {
                     return;
                 }
+                var lengthComputable = true;
                 var loaded = 0;
                 var total = 0;
                 for (var _i = 0, _a = this._requests; _i < _a.length; _i++) {
                     var request = _a[_i];
-                    if (!request._loaded || !request._total) {
+                    if (request._lengthComputable === undefined || request._loaded === undefined || request._total === undefined) {
                         return;
                     }
+                    lengthComputable = lengthComputable && request._lengthComputable;
                     loaded += request._loaded;
                     total += request._total;
                 }
-                this._progressCallback(GLTFLoader._progressEventFactory("GLTFLoaderProgress", {
-                    lengthComputable: true,
-                    loaded: loaded,
-                    total: total
-                }));
+                this._progressCallback(GLTFLoader._createProgressEvent(lengthComputable, loaded, lengthComputable ? total : 0));
             };
             GLTFLoader.prototype._executeWhenRenderReady = function (func) {
                 if (this._renderReady) {
@@ -3923,6 +3905,7 @@ var BABYLON;
                 }, function (event) {
                     _this._tryCatchOnError(function () {
                         if (request && !_this._renderReady) {
+                            request._lengthComputable = event.lengthComputable;
                             request._loaded = event.loaded;
                             request._total = event.total;
                             _this._onProgress();
@@ -3932,10 +3915,10 @@ var BABYLON;
                     _this._tryCatchOnError(function () {
                         throw new BABYLON.LoadFileError(context + ": Failed to load '" + uri + "'" + (request ? ": " + request.status + " " + request.statusText : ""), request);
                     });
+                }, function (oldRequest, newRequest) {
+                    _this._requests.splice(_this._requests.indexOf(oldRequest), 1, newRequest);
                 });
                 if (request) {
-                    request._loaded = null;
-                    request._total = null;
                     this._requests.push(request);
                 }
             };
@@ -4120,6 +4103,20 @@ var BABYLON;
                 }
             };
             GLTFLoader.Extensions = {};
+            // IE 11 Compatibility.
+            GLTFLoader._createProgressEvent = (typeof window["ProgressEvent"] === "function")
+                ? function (lengthComputable, loaded, total) {
+                    return new ProgressEvent("GLTFLoaderProgress", {
+                        lengthComputable: lengthComputable,
+                        loaded: loaded,
+                        total: total
+                    });
+                }
+                : function (lengthComputable, loaded, total) {
+                    var event = document.createEvent("ProgressEvent");
+                    event.initProgressEvent("GLTFLoaderProgress", false, false, lengthComputable, loaded, total);
+                    return event;
+                };
             return GLTFLoader;
         }());
         GLTF2.GLTFLoader = GLTFLoader;

File diff suppressed because it is too large
+ 3 - 3
dist/preview release/loaders/babylon.glTFFileLoader.min.js


+ 21 - 24
dist/preview release/loaders/babylonjs.loaders.js

@@ -3499,14 +3499,6 @@ var BABYLON;
                 this._loaderPendingCount = 0;
                 this._loaderTrackers = new Array();
                 this._parent = parent;
-                if (!GLTFLoader._progressEventFactory) {
-                    if (typeof window["ProgressEvent"] === "function") {
-                        GLTFLoader._progressEventFactory = GLTFLoader._createProgressEventByConstructor;
-                    }
-                    else {
-                        GLTFLoader._progressEventFactory = GLTFLoader._createProgressEventByDocument;
-                    }
-                }
             }
             GLTFLoader.RegisterExtension = function (extension) {
                 if (GLTFLoader.Extensions[extension.name]) {
@@ -3517,14 +3509,6 @@ var BABYLON;
                 // Keep the order of registration so that extensions registered first are called first.
                 GLTF2.GLTFLoaderExtension._Extensions.push(extension);
             };
-            GLTFLoader._createProgressEventByConstructor = function (name, data) {
-                return new ProgressEvent(name, data);
-            };
-            GLTFLoader._createProgressEventByDocument = function (name, data) {
-                var event = document.createEvent("ProgressEvent");
-                event.initProgressEvent(name, false, false, data.lengthComputable, data.loaded, data.total);
-                return event;
-            };
             GLTFLoader.prototype.dispose = function () {
                 if (this._disposed) {
                     return;
@@ -3577,21 +3561,19 @@ var BABYLON;
                 if (!this._progressCallback) {
                     return;
                 }
+                var lengthComputable = true;
                 var loaded = 0;
                 var total = 0;
                 for (var _i = 0, _a = this._requests; _i < _a.length; _i++) {
                     var request = _a[_i];
-                    if (!request._loaded || !request._total) {
+                    if (request._lengthComputable === undefined || request._loaded === undefined || request._total === undefined) {
                         return;
                     }
+                    lengthComputable = lengthComputable && request._lengthComputable;
                     loaded += request._loaded;
                     total += request._total;
                 }
-                this._progressCallback(GLTFLoader._progressEventFactory("GLTFLoaderProgress", {
-                    lengthComputable: true,
-                    loaded: loaded,
-                    total: total
-                }));
+                this._progressCallback(GLTFLoader._createProgressEvent(lengthComputable, loaded, lengthComputable ? total : 0));
             };
             GLTFLoader.prototype._executeWhenRenderReady = function (func) {
                 if (this._renderReady) {
@@ -4879,6 +4861,7 @@ var BABYLON;
                 }, function (event) {
                     _this._tryCatchOnError(function () {
                         if (request && !_this._renderReady) {
+                            request._lengthComputable = event.lengthComputable;
                             request._loaded = event.loaded;
                             request._total = event.total;
                             _this._onProgress();
@@ -4888,10 +4871,10 @@ var BABYLON;
                     _this._tryCatchOnError(function () {
                         throw new BABYLON.LoadFileError(context + ": Failed to load '" + uri + "'" + (request ? ": " + request.status + " " + request.statusText : ""), request);
                     });
+                }, function (oldRequest, newRequest) {
+                    _this._requests.splice(_this._requests.indexOf(oldRequest), 1, newRequest);
                 });
                 if (request) {
-                    request._loaded = null;
-                    request._total = null;
                     this._requests.push(request);
                 }
             };
@@ -5076,6 +5059,20 @@ var BABYLON;
                 }
             };
             GLTFLoader.Extensions = {};
+            // IE 11 Compatibility.
+            GLTFLoader._createProgressEvent = (typeof window["ProgressEvent"] === "function")
+                ? function (lengthComputable, loaded, total) {
+                    return new ProgressEvent("GLTFLoaderProgress", {
+                        lengthComputable: lengthComputable,
+                        loaded: loaded,
+                        total: total
+                    });
+                }
+                : function (lengthComputable, loaded, total) {
+                    var event = document.createEvent("ProgressEvent");
+                    event.initProgressEvent("GLTFLoaderProgress", false, false, lengthComputable, loaded, total);
+                    return event;
+                };
             return GLTFLoader;
         }());
         GLTF2.GLTFLoader = GLTFLoader;

File diff suppressed because it is too large
+ 3 - 3
dist/preview release/loaders/babylonjs.loaders.min.js


+ 1 - 3
dist/preview release/loaders/babylonjs.loaders.module.d.ts

@@ -1024,9 +1024,7 @@ declare module BABYLON.GLTF2 {
             [name: string]: GLTFLoaderExtension;
         };
         static RegisterExtension(extension: GLTFLoaderExtension): void;
-        private static _progressEventFactory;
-        private static _createProgressEventByConstructor(name, data);
-        private static _createProgressEventByDocument(name, data);
+        private static _createProgressEvent;
         constructor(parent: GLTFFileLoader);
         dispose(): void;
         importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[]) => void, onProgress?: (event: ProgressEvent) => void, onError?: (message: string, exception?: any) => void): void;

File diff suppressed because it is too large
+ 44 - 44
dist/preview release/viewer/babylon.viewer.js