Back to Demos

This demo shows how you can add an operator to an existing node.

Clara.io demo resources:

Visit Base Scene


var sceneId = 'aecb8d82-6bf3-4552-8ca7-ea2d39ea29a4';
var polyMeshOperatorTypes = ['MeshSmooth', 'Skin', 'SortFacesByAxis', 'TransformVertices', 'UVMap', 'UVTransform'];

var typeSelect = document.getElementById('type');
for (var i = 0; i < polyMeshOperatorTypes.length; i++)
  typeSelect.options[i] = new Option(polyMeshOperatorTypes[i], polyMeshOperatorTypes[i]);

var api = claraplayer('player');
api.sceneIO.fetchAndUse(sceneId).then(function() {
  document.getElementById('add').onclick = addOperator;
  document.getElementById('baseScene').setAttribute('href','https://clara.io/view/'+sceneId);
});

function addOperator() {
  var id = api.scene.find({name:'TorusKnot'});
  var operatorType = typeSelect.options[typeSelect.selectedIndex].value;
  api.scene.addOperator(id, 'PolyMesh', operatorType, {});
}