Doc > Nodes > SOP > AttribCreate

Doc > Nodes > SOP > AttribCreate

Creates an attribute on the geometry or object.


This allows you to create an attribute and define the following: - the group this applies to - the name - the type (numeric or string) - the size (float, vector2, vector3 or vector4) - the class (geometry or object attribute) - the value

Note that you can also given an expression to set the value of the attribute, such as sin(2*@P.z)


Name Type Description
group string the group this applies to
class integer the attribute class (geometry or object)
type integer the attribute type (numeric or string)
name string the attribute name
size integer the attribute size (1 for float, 2 for vector2, 3 for vector3, 4 for vector4)
value1 float the value for a float attribute
value2 vector2 the value for a vector2
value3 vector3 the value for a vector3
value4 vector4 the value for a vector4
string string the value for a string attribute

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();

const geo = root.createNode('geo');
// create a line
const line = geo.createNode('line');

// add an attribute 'amp'
// which we can later use in a noise SOP
// by giving an expression to set its value
// the amp value will be:
// - 0 for the first point
// - 1 for the last point
// - and a smooth gradient in between
const attribCreate = geo.createNode('attribCreate');
attribCreate.setInput(0, line);'amp');
attribCreate.p.value1.set('@ptnum / (pointsCount(0)-1)');

// create a noise SOP
const noise = geo.createNode('noise');
noise.setInput(0, attribCreate);
// init with a non-zero offset to better see the noise
noise.p.offset.set([4.3, 0, 0]);

// add a material to see the line
const materials = root.createNode('materialsNetwork');
const lineBasic = materials.createNode('lineBasic');
lineBasic.p.color.set([0, 0, 1]);
// assign the material
const material = geo.createNode('material');
material.setInput(0, noise);

// 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');