Doc > Nodes > SOP > Switch

Doc > Nodes > SOP > Switch

Allows to switch between different inputs.


no description


Name Type Description
input integer sets which input is used

Edit code in JsFiddle , Codepen , view in a new tab or Open in the Editor

	// create a scene
const scene = new PolyScene();
const root = scene.root();

// create objects
const geo = root.createNode('geo');
const sphere = geo.createNode('sphere');
const box = geo.createNode('box');
const tube = geo.createNode('tube');

// create a switch
const switch1 = geo.createNode('switch');
switch1.setInput(0, sphere);
switch1.setInput(1, box);
switch1.setInput(2, tube);

// create a copy node to instanciate
// the result of the switch to the points
// of a plane
const plane = geo.createNode('plane');
const attribCreate = geo.createNode('attribCreate');
const copy = geo.createNode('copy');
plane.p.size.set([4, 4]);
copy.setInput(0, switch1);
copy.setInput(1, attribCreate);
attribCreate.setInput(0, plane);
// with a pscale attribute we can vary the scale of the instances'pscale');
// this expression will give a random value for each point

// add a light

// create a camera
const perspectiveCamera1 = root.createNode('perspectiveCamera');
perspectiveCamera1.p.t.set([5, 5, 5]);
// add orbitControls
const events1 = perspectiveCamera1.createNode('eventsNetwork');
const orbitsControls = events1.createNode('cameraOrbitControls');

// mount the viewer
const element = document.getElementById('app');
Is this doc helpful/not helpful? Is there any information you would like that is not available? Don't hesitate to get in touch with any question or feedback, either by email, on Discord or the forum.