Load camera from glTF file

What is the proper way to load a camera from the same glTF file that also contains meshes that I am loading?

I have a scene that contains meshes and a camera.
I am loading that with SceneLoader.LoadAssetContainerAsync. But the resulting AssetContainer has 0 cameras.

With 4.1.0-beta.23 I was depending on a likely bug - the camera was added to scene.cameras. But starting from beta.24 that is not happening anymore. I assume this is because of _blockEntityCollection introduced in https://github.com/BabylonJS/Babylon.js/compare/4.1.0-beta.23...4.1.0-beta.24#diff-eac330d55639a852b84268f1d9121e49R2376

Could you provide a PG showing the problem (or a gltf file with a camera defined in)?

Note that you can use the onCameraLoadedObservable property of the gltf file loader to be notified when a camera has been parsed, but it may be possible to retrieve the list of cameras through another mean…

@Evgeni_Popov Please see Babylon.js Playground that showcases my current workaround - it uses onCameraLoadedObservable. See the console logs. I hope there is a cleaner solution as this feels fragile.

I made a PR for this:

But I’m no expert in asset / gLTF loading, so let’s wait and see where that will take us.

All good
Building the nightly with it

1 Like

Thanks a lot!