Scene does not read metadata when loading from GLTF

Working with a scene and loading with gltf. The gltf contains a scene.extras but the loaded scene does not contain any of the metadata.

The scene is

"scene" : 0,
    "scenes" : [
        {
            "extras" : {
              "myKey" : "myValue" 
            },
            "name" : "Scene",
            "nodes" : [
                284
            ]
        }
    ],

When loaded, scene.metadata returns null. Is the BABYLON.Scene supposed to load the metadata in gltf extras?

Thanks.

pinging @bghgary

It doesn’t currently. IIRC, we weren’t sure what the right behavior should be if multiple glTF files were loaded. Maybe we can load the extras into the __root__ node that is created for each glTF?

Here is the code where other extras are being loaded: Babylon.js/ExtrasAsMetadata.ts at 4615e200806427600b831e47e773778d4602b363 · BabylonJS/Babylon.js · GitHub

Thanks.

Is there a place where we can plug in the loading process where we could make the decision what do to with the raw GLTF extras and how to handle them even when there are more than one GLTF involved?

I would generally merge them with new properties overriding existing once if there is an overlap. This is similar to what I would expect from deep merging of JS properties.

Yes, please read this blog post :wink:

1 Like

Thank you very much. I will try it. Would you like me to contribute it or you think this is something that should stay outside of Babylon?

I am asking as the project I am incorporating it in is in vanilla js compiled with Google Closure Compiler, packed and tested with tools different from what is used in BABYLON. So, based on whether you would like to have this extension in Babylon or outside of Babylon, I could develop it in different ways.

Thanks.

If the metadata loaded can be done in a way that works generically (i.e. the concern that I have with multiple glTF files being loaded), then sure. The extension that I pointed you to earlier (ExtrasAsMetadata) would be the right place to add it. You don’t need a separate extension.