瀏覽代碼

Fix glTF loader return order

Gary Hsu 7 年之前
父節點
當前提交
570c140941
共有 1 個文件被更改,包括 7 次插入5 次删除
  1. 7 5
      loaders/src/glTF/2.0/babylon.glTFLoader.ts

+ 7 - 5
loaders/src/glTF/2.0/babylon.glTFLoader.ts

@@ -186,7 +186,7 @@ module BABYLON.GLTF2 {
                     });
                 }
 
-                return this._loadAsync(nodes).then(() => {
+                return this._loadAsync(nodes, () => {
                     return {
                         meshes: this._getMeshes(),
                         particleSystems: [],
@@ -204,11 +204,11 @@ module BABYLON.GLTF2 {
                 this._rootUrl = rootUrl;
                 this._progressCallback = onProgress;
                 this._loadData(data);
-                return this._loadAsync(null);
+                return this._loadAsync(null, () => undefined);
             });
         }
 
-        private _loadAsync(nodes: Nullable<Array<number>>): Promise<void> {
+        private _loadAsync<T>(nodes: Nullable<Array<number>>, resultFunc: () => T): Promise<T> {
             return Promise.resolve().then(() => {
                 this._loadExtensions();
                 this._checkExtensions();
@@ -245,6 +245,8 @@ module BABYLON.GLTF2 {
                     this._extensionsOnReady();
 
                     this._startAnimations();
+
+                    return resultFunc();
                 });
 
                 resultPromise.then(() => {
@@ -278,9 +280,9 @@ module BABYLON.GLTF2 {
                     this._parent.onErrorObservable.clear();
 
                     this.dispose();
-
-                    throw error;
                 }
+
+                throw error;
             });
         }