Accessing meshes' inherited properties


i tried to access properties like material, position and rotation on a mesh.
when i used Object.keys() or Object.getOwnPropertyNames() on BABYLON.Mesh(‘tmesh’) i learnt that i won’t be able to see inherited properties, as per dev.mozilla.

so i tried to go up the hierarchy, to find which class has property material originally.
i found that AbstractMesh has this prop inherited too, but its parent TransformNode doesn’t have property material at all. so where can i find it?

my use case is listing all the properties in a form to user while setting up a 3d model submitted by themselves.

  1. user picks mesh cover, accesses its material prop and changes alpha on the material to uncover the inner parts of 3d model.
  2. user picks mesh fan, accesses its rotation, adds value to y value of rotation prop.

thank you.

Actually, AbstractMesh does own the material property, but it is implemented as a getter / setter, that’s why you don’t get it.

Also, Object.getOwnPropertyNames will return all the properties, even if coming from inherited objects. For eg, doing it on the ground mesh of the default playground:

reserverDataStore is coming from the Node class, for eg., which is the top class of the Mesh hierarchy class.

1 Like

Oh, I understand, thank you.
Do you, please, have a suggestion how could I list the properties to the user?
I know I could simply get them manually, but I was looking for something more consistent when new features come with newer versions of babylon.js, those would theoretically be automatically listed.

See the getAllPropertyNames function from this stackoverflow answer:

I was maybe hoping for a little cleaner approach using some babylon API I don’t yet know about, but this sure works.
Thank you.