ソースを参照

asset container root mesh, loading from file does not need to be split into 2 peices

Trevor Baron 7 年 前
コミット
2caceae37a
2 ファイル変更11 行追加4 行削除
  1. 8 3
      src/Loading/babylon.sceneLoader.ts
  2. 3 1
      src/babylon.assetContainer.ts

+ 8 - 3
src/Loading/babylon.sceneLoader.ts

@@ -659,8 +659,8 @@
         */
         public static LoadAssetContainer(
             rootUrl: string,
-            sceneFilename: any,
-            scene: Scene,
+            sceneFilename: any = "",
+            scene: Scene = BABYLON.Engine.LastCreatedScene!,
             onSuccess: Nullable<(assets: AssetContainer) => void> = null,
             onProgress: Nullable<(event: SceneLoaderProgressEvent) => void> = null,
             onError: Nullable<(scene: Scene, message: string, exception?: any) => void> = null,
@@ -671,6 +671,11 @@
                 return null;
             }
 
+            if(sceneFilename==""){
+                sceneFilename = rootUrl;
+                rootUrl = "";
+            }
+
             var loadingToken = {};
             scene._addPendingData(loadingToken);
 
@@ -751,7 +756,7 @@
         * @param pluginExtension the extension used to determine the plugin
         * @returns The loaded asset container
         */
-        public static LoadAssetContainerAsync(rootUrl: string, sceneFilename: any, scene: Scene, onProgress: Nullable<(event: SceneLoaderProgressEvent) => void> = null, pluginExtension: Nullable<string> = null): Promise<AssetContainer> {
+        public static LoadAssetContainerAsync(rootUrl: string, sceneFilename: any = "", scene: Scene=Engine.LastCreatedScene!, onProgress: Nullable<(event: SceneLoaderProgressEvent) => void> = null, pluginExtension: Nullable<string> = null): Promise<AssetContainer> {
             return new Promise((resolve, reject) => {
                 SceneLoader.LoadAssetContainer(rootUrl, sceneFilename, scene, assetContainer => {
                     resolve(assetContainer);

+ 3 - 1
src/babylon.assetContainer.ts

@@ -334,7 +334,8 @@ module BABYLON {
         }
 
         /**
-         * Adds all meshes in the asset container to a root mesh that can be used to position the entire assetContainer
+         * Adds all meshes in the asset container to a root mesh that can be used to position all the contained meshes. The root mesh is then added to the front of the meshes in the assetContainer.
+         * @returns the root mesh
          */
         public createRootMesh(){
             var rootMesh = new BABYLON.Mesh("assetContainerRootMesh", this.scene);
@@ -343,6 +344,7 @@ module BABYLON {
                     rootMesh.addChild(m);
                 }
             })
+            this.meshes.unshift(rootMesh);
             return rootMesh;
         }
     }