Browse Source

Merge pull request #7882 from Popov72/assertcontainer-gltf-camera

Get the list of cameras retrieved from a gLTF file when loaded throug…
David Catuhe 5 years ago
parent
commit
38f3799795
2 changed files with 6 additions and 0 deletions
  1. 1 0
      dist/preview release/what's new.md
  2. 5 0
      loaders/src/glTF/glTFFileLoader.ts

+ 1 - 0
dist/preview release/what's new.md

@@ -44,6 +44,7 @@
 ### Loaders
 
 - Added support for glTF mesh instancing extension ([#7521](https://github.com/BabylonJS/Babylon.js/issues/7521)) ([drigax](https://github.com/Drigax))
+- Get the list of cameras retrieved from a gLTF file when loaded through the asset container ([Popov72](https://github.com/Popov72))
 
 ### Navigation
 

+ 5 - 0
loaders/src/glTF/glTFFileLoader.ts

@@ -597,6 +597,10 @@ export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISc
             this.onTextureLoadedObservable.add((texture) => {
                 textures.push(texture);
             });
+            const cameras: Array<Camera> = [];
+            this.onCameraLoadedObservable.add((camera) => {
+                cameras.push(camera);
+            });
 
             return this._loader.importMeshAsync(null, scene, true, data, rootUrl, onProgress, fileName).then((result) => {
                 const container = new AssetContainer(scene);
@@ -608,6 +612,7 @@ export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISc
                 Array.prototype.push.apply(container.textures, textures);
                 Array.prototype.push.apply(container.lights, result.lights);
                 Array.prototype.push.apply(container.transformNodes, result.transformNodes);
+                Array.prototype.push.apply(container.cameras, cameras);
                 return container;
             });
         });