This demo shows how you can switch materials.
Clara.io demo resources:
Visit Base Scenevar sceneId = '065da178-cd3f-4fe9-bebb-91b663b16f92'
var api = claraplayer('player');
api.sceneIO.fetchAndUse(sceneId);
api.on('loaded', function() {
var materials = api.scene.getAll({ type: 'Material', property: 'name' });
for(var id in materials) {
var button = document.createElement('button');
button.innerText = materials[id];
button.onclick = onClick(id);
document.getElementById('buttons').appendChild(button);
}
document.getElementById('baseScene').setAttribute('href','https://clara.io/view/'+sceneId);
});
function onClick(id) {
return function(ev) {
return api.scene.set({ name: 'TorusKnot', plug: 'Material', property: 'reference' }, id)
}
}