How to read 'Custom Properties' from Blender in BabylonJS

Hello once again guys <3
I have a problem where I have to transfer predefined custom properties from blender and use it in babylon.

What is my logic ?
We have a entity which step on a plate, reads metadata of the plate, check if there is rotation or speed change and changes it depending on which plate it is stepped on.

Reading ‘extras’ from GLTF format
I already read that you can read GTLF format’s extras properties with ExtrasAsMetadata like so - https://playground.babylonjs.com/#10D6YT#398
But I do not see objects with ‘extras’ key to be exported neither my values coming with frose keys from custom properties field in blender when I view file in text format.

Parent theme: How to Access extras Property of Loaded GLTF

Reading ‘metadata’ from .babylon export
I have already read that you can export file as .babylon with Blender2Babylon exporter and access custom properties from blender as ‘metadata’ ( doesn’t work )
Using version of Blender - 3.2.2
Using version of Blender2Babylon:
3.3.-1 - error thrown - blender version is too old
2.93 - error thrown - Python: Traceback (most recent call last): File "/home/yordan/.config/blen - Pastebin.com

So… no luck for now.

Babylon tags
I have already read for babylon tags, which can serve as metadata, but you must declare it after you load the asset into the scene, which is what I don’t wanna to do.

There is what I have tried for the moment and after many head bangs and wasted time just decided to ask here, hopefully somebody would know what can I do in my case.

I am really gratefull for all responses !
Have a wondefrull day !

PS: Using Ubuntu 21.04

ccing @JCPalmer, do you have any advice for this?

1 Like

Guess its super hard, or super hidden feature, because I still cannot find right way to do it :frowning:

I’d work with same task some days before.
So, first you should check your gltf-file, find your extra-data in this json file. If the data not exist, then check export settings.
If data present, then in the code you should import (for es6)

import '@babylonjs/loaders/glTF/2.0/Extensions/ExtrasAsMetadata.js';

and read them by mesh.metadata?.gltf?.extras?.myPropertyNameHere.

2 Likes

Woah, thanks mate <3. By your suggestion i learned that gltf is json format of glb. I’ve been exporting my map into glb and wondering why there isn’t any custom properties in there. Its really confusing, because that blender **** have custom properties for almost each tab… for example
Scene properties, World properties, Object properties, Object Data properties and materia properties. The one that we need is Object properties.
So what have I done.

  1. I have exported the map in gltf to see if there are custom properties there and tried to add custom properties to all of tabs above that i mentioned.
  2. I opened exported file in text editor and saw that the properties are there.
  3. Exported map again as glb
  4. Acessed the properties as you mentioned.

Thank you mate, you solved 1 and a half week mystery for me <3

Nice!
And one note, if you using idea IDE, you can add gltf to json files format and read them as native json file

other editors should have same settings

1 Like