How to create material and assign to the meshes imported to the scene based on its MaterialName or MeshName

How to create material and assign to the meshes imported to the scene based on its MaterialName or MeshName on load of the file. How to get it by name. And
What is the use of giving name of everything created (mesh,material,camera, engine, scene)?

Use scene.getMeshByName(name) or scene.getMaterialByName(name). You also have variants using the id or uniqueId of the mesh/material (see the docs).

To be able to do the above code :slight_smile:

2 Likes

Thanks a lot @Evgeni_Popov . And How to give value to reflection for a PBR Material . I need to create a material like chrome parts of car.

I think these docs should help you:

1 Like

I already went through it @Evgeni_Popov . But I couldn’t find

This sample should be a good starting point (from the doc):

https://playground.babylonjs.com/#2FDQT5#11

You can adjust the metallic/roughness properties if it’s too reflective and change the base color to make it more chrome-like (use a more greyish color - chromium is something like (0.550, 0.556, 0.554) in linearspace):

https://playground.babylonjs.com/#2FDQT5#669