Просмотр исходного кода

Better alignement for promise polyfill when all was called with empty array

David Catuhe 7 лет назад
Родитель
Сommit
a419116d40
3 измененных файлов с 9 добавлено и 16 удалено
  1. 2 13
      src/Loading/babylon.sceneLoader.ts
  2. 1 1
      src/Tools/babylon.promise.ts
  3. 6 2
      src/Tools/babylon.tools.ts

+ 2 - 13
src/Loading/babylon.sceneLoader.ts

@@ -338,7 +338,7 @@
 
                 if (sceneFilename === "") {
                     if (sceneFilename === "") {
-                        rootUrl = this._StripFilenameFromRootUrl(rootUrl);
+                        rootUrl = Tools.GetFolderPath(rootUrl, true);
                     }
                 }
 
@@ -441,7 +441,7 @@
 
             return SceneLoader._loadData(rootUrl, sceneFilename, scene, (plugin, data, responseURL) => {
                 if (sceneFilename === "") {
-                    rootUrl = this._StripFilenameFromRootUrl(rootUrl);
+                    rootUrl = Tools.GetFolderPath(rootUrl, true);
                 }
 
                 if ((<any>plugin).load) {
@@ -467,17 +467,6 @@
                 }
             }, progressHandler, errorHandler, disposeHandler, pluginExtension);
         }
-
-        private static _StripFilenameFromRootUrl(rootUrl: string): string {
-            // We need to strip the filename off from the rootUrl
-            let lastSlash = rootUrl.lastIndexOf("/");
-
-            if (lastSlash > -1) {
-                rootUrl = rootUrl.substr(0, lastSlash + 1);
-            }
-
-            return rootUrl;
-        }
         
         public static LoadAssetContainer(
             rootUrl: string,

+ 1 - 1
src/Tools/babylon.promise.ts

@@ -205,7 +205,7 @@ module BABYLON {
                     InternalPromise._RegisterForFulfillment(promises[index], agregator, index);
                 }
             } else {
-                newPromise._resolve();
+                newPromise._resolve([]);
             }
 
 

+ 6 - 2
src/Tools/babylon.tools.ts

@@ -212,10 +212,14 @@
             return path.substring(index + 1);
         }
 
-        public static GetFolderPath(uri: string): string {
+        public static GetFolderPath(uri: string, returnUnchangedIfNoSlash = false): string {
             var index = uri.lastIndexOf("/");
-            if (index < 0)
+            if (index < 0) {
+                if (returnUnchangedIfNoSlash) {
+                    return uri;
+                }
                 return "";
+            }
 
             return uri.substring(0, index + 1);
         }