Access and modify material for different inspector channels

Hi everyone,
I am new to the whole Babylon.js universe and a little overwhelmed. I would like to build an inspector into an already existing viewer, with which you can display different renderings of a model (normal map, albedo, etc.). The viewer is programmed in typescript and uses tree shaking.
Now I would like to assign a material to the asset that is loaded into the scene (later I want to use shaders). Unfortunately, it still doesn’t work with my approaches:

//Loading the asset
const container: AssetContainer = await SceneLoader.LoadAssetContainerAsync(baseUrl, anyFile, this._scene);

var meshes = container.meshes;
var myMaterial = new StandardMaterial(“myMaterial”, this._scene);

myMaterial.diffuseColor = new Color3(1, 0, 0);
myMaterial.specularColor = new Color3(0.5, 0.6, 0.87);
myMaterial.emissiveColor = new Color3(1, 1, 1);
myMaterial.ambientColor = new Color3(0.23, 0.98, 0.53);

for (var i = 0; i < meshes.length; i++) {
container.meshes[i].material = myMaterial;

This does not change anything on the asset. Is there any solution on how I can implement my project? I would be very grateful for any help.

1 Like

Hello and welcome!

I think you just did something wrong in other part of your code.
Here is the PG with working material assignment -
I commented emissive color of your myMaterial, since it will always give just white emission color over all other colors.



Thank you this is a first hint and will help.