浏览代码

Fix ProgressEvent on IE

Sebastien Vandenberghe 7 年之前
父节点
当前提交
73cc6ac509

文件差异内容过多而无法显示
+ 3574 - 3574
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.d.ts


文件差异内容过多而无法显示
+ 5 - 5
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.js


+ 21 - 5
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.max.js

@@ -52834,12 +52834,12 @@ var BABYLON;
             if (sceneFilename.name) {
                 sceneFilename = sceneFilename.name;
             }
-            var dotPosition = sceneFilename.lastIndexOf(".");
             var queryStringPosition = sceneFilename.indexOf("?");
-            if (queryStringPosition === -1) {
-                queryStringPosition = sceneFilename.length;
+            if (queryStringPosition !== -1) {
+                sceneFilename = sceneFilename.substring(0, queryStringPosition);
             }
-            var extension = sceneFilename.substring(dotPosition, queryStringPosition).toLowerCase();
+            var dotPosition = sceneFilename.lastIndexOf(".");
+            var extension = sceneFilename.substring(dotPosition, sceneFilename.length).toLowerCase();
             return SceneLoader._getPluginForExtension(extension);
         };
         // use babylon file loader directly if sceneFilename is prefixed with "data:"
@@ -80386,6 +80386,14 @@ 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]) {
@@ -80396,6 +80404,14 @@ 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;
@@ -80456,7 +80472,7 @@ var BABYLON;
                     loaded += request._loaded;
                     total += request._total;
                 }
-                this._progressCallback(new ProgressEvent("GLTFLoaderProgress", {
+                this._progressCallback(GLTFLoader._progressEventFactory("GLTFLoaderProgress", {
                     lengthComputable: true,
                     loaded: loaded,
                     total: total

文件差异内容过多而无法显示
+ 3574 - 3574
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.module.d.ts


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

@@ -324,6 +324,9 @@ 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);
         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) => void): void;

+ 17 - 1
dist/preview release/loaders/babylon.glTF2FileLoader.js

@@ -333,6 +333,14 @@ 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]) {
@@ -343,6 +351,14 @@ 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;
@@ -403,7 +419,7 @@ var BABYLON;
                     loaded += request._loaded;
                     total += request._total;
                 }
-                this._progressCallback(new ProgressEvent("GLTFLoaderProgress", {
+                this._progressCallback(GLTFLoader._progressEventFactory("GLTFLoaderProgress", {
                     lengthComputable: true,
                     loaded: loaded,
                     total: total

文件差异内容过多而无法显示
+ 2 - 2
dist/preview release/loaders/babylon.glTF2FileLoader.min.js


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

@@ -871,6 +871,9 @@ 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);
         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) => void): void;

+ 17 - 1
dist/preview release/loaders/babylon.glTFFileLoader.js

@@ -2478,6 +2478,14 @@ 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]) {
@@ -2488,6 +2496,14 @@ 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;
@@ -2548,7 +2564,7 @@ var BABYLON;
                     loaded += request._loaded;
                     total += request._total;
                 }
-                this._progressCallback(new ProgressEvent("GLTFLoaderProgress", {
+                this._progressCallback(GLTFLoader._progressEventFactory("GLTFLoaderProgress", {
                     lengthComputable: true,
                     loaded: loaded,
                     total: total

文件差异内容过多而无法显示
+ 3 - 3
dist/preview release/loaders/babylon.glTFFileLoader.min.js


文件差异内容过多而无法显示
+ 1 - 1
dist/preview release/loaders/babylon.objFileLoader.min.js


+ 28 - 1
loaders/src/glTF/2.0/babylon.glTFLoader.ts

@@ -38,6 +38,12 @@ module BABYLON.GLTF2 {
         _total: Nullable<number>;
     }
 
+    interface IProgressEventData {
+        lengthComputable: boolean;
+        loaded: number;
+        total: number;
+    }
+
     export class GLTFLoader implements IGLTFLoader {
         public _gltf: IGLTF;
         public _babylonScene: Scene;
@@ -77,8 +83,29 @@ module BABYLON.GLTF2 {
             GLTFLoaderExtension._Extensions.push(extension);
         }
 
+        // IE 11 Compatibility.
+        private static _progressEventFactory: (name: string, data: IProgressEventData) => ProgressEvent;
+        
+        private static _createProgressEventByConstructor(name: string, data: IProgressEventData): ProgressEvent {
+            return new ProgressEvent(name, data);
+        }
+
+        private static _createProgressEventByDocument(name: string, data: IProgressEventData): ProgressEvent {
+            const event = document.createEvent("ProgressEvent");
+            event.initProgressEvent(name, false, false, data.lengthComputable, data.loaded, data.total);
+            return event;
+        }
+
         public constructor(parent: GLTFFileLoader) {
             this._parent = parent;
+            if (!GLTFLoader._progressEventFactory) {
+                if (typeof (<any>window)["ProgressEvent"] === "function") {
+                    GLTFLoader._progressEventFactory = GLTFLoader._createProgressEventByConstructor;
+                }
+                else {
+                    GLTFLoader._progressEventFactory = GLTFLoader._createProgressEventByDocument;
+                }
+            }
         }
 
         public dispose(): void {
@@ -148,7 +175,7 @@ module BABYLON.GLTF2 {
                 total += request._total;
             }
 
-            this._progressCallback(new ProgressEvent("GLTFLoaderProgress", {
+            this._progressCallback(GLTFLoader._progressEventFactory("GLTFLoaderProgress", {
                 lengthComputable: true,
                 loaded: loaded,
                 total: total