Say, you would like to replace a material on meshes of type ‘wall’, to be ‘brick’.
First, before the scene is loaded, mark all materials and nodes that you need to use via API as editable:
var viewer = WALK.getViewer();
viewer.setNodeTypeEditable('wall');
viewer.setMaterialEditable('brick');
Then, at any time, but after the scene is loaded, find the required material and nodes and apply the change:
var brickMaterial = viewer.findMaterial('brick');
var nodes = viewer.findNodesOfType('wall');
for (var i = 0; i < nodes.length; ++i) {
viewer.setMaterialForMesh(brickMaterial, nodes[i].mesh);
}