浏览代码

refactor to remove duplicated code

Trevor Baron 7 年之前
父节点
当前提交
0680c8843f
共有 2 个文件被更改,包括 297 次插入581 次删除
  1. 291 577
      src/Loading/Plugins/babylon.babylonFileLoader.ts
  2. 6 4
      src/Loading/babylon.sceneLoader.ts

文件差异内容过多而无法显示
+ 291 - 577
src/Loading/Plugins/babylon.babylonFileLoader.ts


+ 6 - 4
src/Loading/babylon.sceneLoader.ts

@@ -27,7 +27,7 @@
         load: (scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void) => boolean;
         canDirectLoad?: (data: string) => boolean;
         rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
-        loadAssets: (scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void) => AssetContainer;
+        loadAssets: (scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void) => Nullable<AssetContainer>;
     }
 
     export interface ISceneLoaderPluginAsync {
@@ -37,7 +37,7 @@
         loadAsync: (scene: Scene, data: string, rootUrl: string, onSuccess?: () => void, onProgress?: (event: SceneLoaderProgressEvent) => void, onError?: (message: string, exception?: any) => void) => void;
         canDirectLoad?: (data: string) => boolean;
         rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
-        loadAssetsAsync: (scene: Scene, data: string, rootUrl: string, onSuccess?: (assets: AssetContainer) => void, onProgress?: (event: SceneLoaderProgressEvent) => void, onError?: (message: string, exception?: any) => void) => void;
+        loadAssetsAsync: (scene: Scene, data: string, rootUrl: string, onSuccess?: (assets: Nullable<AssetContainer>) => void, onProgress?: (event: SceneLoaderProgressEvent) => void, onError?: (message: string, exception?: any) => void) => void;
     }
 
     interface IRegisteredPlugin {
@@ -526,8 +526,10 @@
                 } else {
                     var asyncedPlugin = <ISceneLoaderPluginAsync>plugin;
                     asyncedPlugin.loadAssetsAsync(scene, data, rootUrl, (assetContainer) => {
-                        scene.loadingPluginName = plugin.name;
-                        successHandler(assetContainer);
+                        if(assetContainer){
+                            scene.loadingPluginName = plugin.name;
+                            successHandler(assetContainer);
+                        }
                     }, progressHandler, errorHandler);
                 }