Edit materials on imported meshes?

I’ve got an exported .babylon file from 3ds Max which I’ve tried importing the meshes from using SceneLoaded and AssetsManager but am struggling to edit the existing materials on the meshes that are loaded as they are null when I am trying to access them.

I get that this is down to the async nature of this process but cannot for the life of me work out how to tie into a callback to set additional material properties once the buggers have loaded.

All of the tutorials I can find always seem to be about creating new materials - how can I edit existing ones… once loaded???

The only real trick is getting a reference of the Material object. Once you have that you can set properties just as the creation docs show.

You might get the material from mesh.material by getting the mesh from scene.getMeshByName, scene.getMeshByTag or scene.getMeshByID.

If you know the name, tag, or ID of the material, you might get it directly from scene.getMaterialByName, scene.getMaterialByTag, or scene.getMaterialByID.

I am not really familiar with 3ds Max, but think their ID’s are some sort of generation. Also, do not know if they have a tag. That, I guess, is your job to figure out.

Well I can get a reference to where it should be when I import the mesh but its a question of timing. It’s null when I am trying to access it as it hasn’t loaded at that point in time. God I hate JS sometimes. I’m afraid I’m a lowly artist trying to support the developer here lol

Must be in the callback of Scene.Append. It will exist then. Do not know about Asset Manager, but if it has a callback, that would be a good guess.