How to Access extras Property of Loaded GLTF

According to the GLTF specification, the extras property is for storing application specific data. How do we access the extra property of a loaded GLTF in BJS?

Adding @bghgary

2 Likes

Thanks @sebavan ! I really would like some clarity in this regard to find its way into the BJS documentation. @bghgary

1 Like

2 ways to do it:

https://playground.babylonjs.com/#10D6YT#398

or you can directly access extras of meshes and so on via mesh.metadata.gltf.extras for instance

Thanks @sebavan . I will check this out. To be clear, I am only referring to the top level extras attribute, as defined in the GLTF specification, not the extras attribute on a single mesh.

There are only a few extras being loaded right now by default with the ExtrasAsMetadata loader extension. Nodes, cameras, and materials.

Seb’s solution works. You can also create a custom loader extension to customize it to your liking or contribute more code to the ExtrasAsMetadata loader extension.

Getting this info into the documentation would be great! Please contribute if you can. :slight_smile:

2 Likes

Thank you @bghgary ! Have a great weekend.

2 Likes