Selaa lähdekoodia

refactor to remove duplicated code

Trevor Baron 7 vuotta sitten
vanhempi
commit
0680c8843f
2 muutettua tiedostoa jossa 297 lisäystä ja 581 poistoa
  1. 291 577
      src/Loading/Plugins/babylon.babylonFileLoader.ts
  2. 6 4
      src/Loading/babylon.sceneLoader.ts

Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 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);
                 }