Change material of one object by clicking another? #4379
-
Hi All, |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
You use that to define the material you are trying to change. Than you need to create textures from the images you wish to use. Than you need to apply those textures to the material. Or change the baseColor of the material. And so on. Hope this helps you a little. |
Beta Was this translation helpful? Give feedback.
You use that to define the material you are trying to change.
const mat1 = modelViewer.model.getMaterialByName('name');
Than you need to create textures from the images you wish to use.
const createTextures = async () => {
texture1 = await modelViewer.createTexture("assets/mat1_Base_Color2.jpg");
texture2 = await modelViewer.createTexture("assets/mat2_Base_Color1.jpg");
}
Than you need to apply those textures to the material.
mat1.pbrMetallicRoughness.baseColorTexture.setTexture(texture1);
Or change the baseColor of the material.
mat1.pbrMetallicRoughness.setBaseColorFactor([0.5,0.065,0.043,1]);
And so on. Hope this helps you a little.