This demo shows how you can transform vertices of an object by adding operator.
Selected Vertices
Use single number for one vertex (ex. 1)
Two numbers with minus sign in between for a range of vertices (ex. 0-3)
Make sure they are separated by a comma
Translation Along Y
Clara.io demo resources:
Visit Base Scenevar sceneId = 'bed4613e-665d-4097-8944-2cf95cf99810';
var api = claraplayer('player');
var meshName = 'Box';
var selectVertices = document.getElementById('selectVertices');
var moveVertices = document.getElementById('moveVertices');
var index = 0;
var meshId;
var operatorIndex;
api.sceneIO.fetchAndUse(sceneId).then(function(){
selectVertices.oninput = inputHandler;
moveVertices.oninput = moveHandler;
meshId = api.scene.find({name:meshName});
inputHandler();
document.getElementById('baseScene').setAttribute('href','https://clara.io/view/'+sceneId);
});
function moveHandler(){
var translationPath = api.scene.find({name:meshName, plug:'PolyMesh', properties:{name:operatorIndex}, property:'translation'});
var translation = api.scene.get(translationPath);
translation.y = moveVertices.valueAsNumber;
api.scene.set(translationPath,translation);
};
function inputHandler(){
index++;
operatorIndex = 'operator'+index;
moveVertices.value = 0;
var selectedVertices = selectVertices.value;
api.scene.addOperator(meshId, 'PolyMesh', 'TransformVertices', {}, operatorIndex);
api.scene.set({name:meshName, plug:'PolyMesh', properties:{name:operatorIndex}, property:'vertexIndices'}, selectedVertices);
};