Back to the Shapespark home page

API - Changing Materials baseColor

Hi again,

is it possible to change the baseColor of a material via API?
I tried the following, but it has no effect:

// before scene loading
viewer.setMaterialEditable("Some Material");

// then
var material = viewer.findMaterial("Some Material");
var color = new THREE.Color("rgb(100, 50, 120)");
material.baseColor = color;



For baseColor and couple of other material properties, the material doesn’t detect the changes automatically and doesn’t automatically update uniforms that are passed to GPU. You need to call


for the changes to take effect.

Also make sure that material.baseColorTexture is not set, because it has priority over the material.baseColor.

Works like a charm, thank you!