Using the scene graph API to get materials

Hi,
I would like advice on using the scene graph API to get at materials and set their properties. Here is a very simple example. I have a scene with one object called “box”. Box has a material called “my_material”. my_material has a diffuse value of blue.


I want to write a query that gets the material that is attached to “box”. I tried:
playerApi.scene.get({name: 'Box', plugs: 'Material'})
But that only return a reference to box.
Thanks in advance

Hey Jeremy - I got some details from product and can hopefully get us going in the right direction. The approach I have been suggested is below:

await playerApi.enableApi('player').getAssetInstance([yourNodeId, 'plugs', 'Material', 0, 'reference'])

A few things to note -

  • Ensure playerApi matches whatever your client-side API is called.
  • enableApi(api-name) will enable APIs that are not directly publicized. This particular API has become fairly widely used.
  • This will return an ID of the material you are querying for. This ID may not match the ID you see when you run player.scene.getAll(). This is because we clone an asset each time it is used but should resolve to the material you expect.

Let me know if this is helpful or not.