Bläddra i källkod

Better scope internal error handler for texture load, expose cascaded file load to subclasses

Scott Ramsby 7 år sedan
förälder
incheckning
6cf1889fea
1 ändrade filer med 14 tillägg och 14 borttagningar
  1. 14 14
      src/Engine/babylon.engine.ts

+ 14 - 14
src/Engine/babylon.engine.ts

@@ -5563,19 +5563,6 @@
                 }
             }
 
-            let onInternalError = (request?: XMLHttpRequest, exception?: any) => {
-                if (loader) {
-                    const fallbackUrl = loader.getFallbackTextureUrl(rootUrl, this._textureFormatInUse);
-                    if (fallbackUrl) {
-                        this.createCubeTexture(fallbackUrl, scene, files, noMipmap, onLoad, onError, format, extension, createPolynomials, lodScale, lodOffset, texture);
-                    }
-                }
-
-                if (onError && request) {
-                    onError(request.status + " " + request.statusText, exception);
-                }
-            }
-
             if (loader) {
                 rootUrl = loader.transformUrl(rootUrl, this._textureFormatInUse);
 
@@ -5592,6 +5579,19 @@
                     }
                 }
                 else {
+                    let onInternalError = (request?: XMLHttpRequest, exception?: any) => {
+                        if (loader) {
+                            const fallbackUrl = loader.getFallbackTextureUrl(rootUrl, this._textureFormatInUse);
+                            if (fallbackUrl) {
+                                this.createCubeTexture(fallbackUrl, scene, files, noMipmap, onLoad, onError, format, extension, createPolynomials, lodScale, lodOffset, texture);
+                            }
+                        }
+        
+                        if (onError && request) {
+                            onError(request.status + " " + request.statusText, exception);
+                        }
+                    }
+
                     this._loadFile(rootUrl, onloaddata, undefined, undefined, true, onInternalError);
                 }
             }
@@ -7389,7 +7389,7 @@
             this._loadFile(url, onload, undefined, undefined, true, onerror);
         }
 
-        private _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void> = null): void {
+        protected _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void> = null): void {
             var loadedFiles: (string | ArrayBuffer)[] = [];
             (<any>loadedFiles)._internalCount = 0;