Set material paramter for certain material. There are different parameter names available for different types of materials. Here are all the available parameters and the corresponding types:
color: number[] e.g. [1, 0, 0]
opacity: number(0-1) e.g. 0.5
colorTexture: string | HTMLImageElement e.g. "https://modeloapp.com/colorMap.jpg"
roughness: number(0-1) e.g. 0.5
metallic: number(0-1) e.g. 0.5
metallicRoughnessTexture: string | HTMLImageElement e.g. "https://modeloapp.com/metallicRoughnessMap.jpg"
emissiveTexture: string | HTMLImageElement e.g. "https://modeloapp.com/emissiveMap.jpg"
normalTexture: string | HTMLImageElement e.g. "https://modeloapp.com/normalMap.jpg"
Signature:
setMaterialParameter(materialName: string, parameter: string, value: any): void;
Parameter | Description |
---|---|
materialName | The material name queried through api. |
parameter | The parameter name. |
value | The parameter value to set. |
Returns:
void
// Create a model viewer on mobile platform.
viewer.getScene().setMaterialParameter(materialName, "color", [1, 0, 0]);