Accessing GLB custom properties

Hello all,

I have glb model that have some “custom properties”, named “Color_1” and “Color_2” that I verified are present in glb json file (exported from Blender).

I am trying to access them from Babylon with no luck.

What I did:

imported ExtrasAsMetadata:
import ‘@babylonjs/loaders/glTF/2.0/Extensions/ExtrasAsMetadata.js’

trying to access metadata from mesh that have them:
console.log(mesh.metadata?.gltf?.extras?.Color_1) (it logs: undefined)

I am loading glb with:
BABYLON.SceneLoader.ImportMesh(…

What am I doing wrong?

Thnx

Maybe have a look at this topic where @pjoe was trying to programmatically access some GLTF/GLB custom data as well :slight_smile:

++
Tricotou

So does it mean it is not supported as of now?

uto, 4. lip 2024. 12:34 Tricotou via Babylon.js <notifications@babylonjs.discoursemail.com> je napisao:

GLTF extras are the part of GLTF standard and are supported by Babylon.

The solution is in this PG - https://playground.babylonjs.com/#10D6YT#398

More info in this thread - How to Access extras Property of Loaded GLTF

And here is even more relevant PG example - https://playground.babylonjs.com/#MH5MCV#35

    for (const mesh of assetContainer.meshes) {
        mesh.metadata = {
            gltf: {
                extras: {},
            },
            ...mesh.metadata,
        }

and so on :slight_smile:
Note that one may have a look at metadata with the help of the Inspector:

1 Like

FWIW: Custom properties (glTF extras) have always been working for me on both meshes and materials. The other issue mentioned is related to custom vertex attributes (e.g. a second set of vertex colors), which is something else.