addOrEditMaterial
Adds or changes a current Material from a specific Object. Optionally sets it as active as well.
addOrEditMaterial(
objectName: string,
material: Material,
isActive = true,
): Promise<void>
Parameters
Description
Type
objectName
The name of the object we want to add/change.
string
material
A material object with all parameters to add/change. If a material with the same names exists, it will edit it, otherwise it will create a new one.
Usage:
const objectName = "Adjustable Headband";
// Change Gold material
const material = await modelApi.getActiveMaterial(objectName);
material.baseColor.color.x = 255;
await modelApi.addOrEditMaterial(objectName, material);
// Add new Red material
await modelApi.addOrEditMaterial(
objectName,
{
name: 'Red',
baseColor: {
color: {
x: 255
}
}
},
false
);
Last updated