Doc > Nodes > SOP > AttribCopy

Doc > Nodes > SOP > AttribCopy

Copies an attribute from one geometry to another.

Description

This copies an attribute from the right input geometry to the left input geometry. Note that you can copy attributes that have different sizes. For instance:

  • to copy only the y component of the position to a float attribute, set it as such:
    • srcOffset = 1
    • destOffset = 0
  • to copy the y component to the z component of another attribute:
    • srcOffset = 1
    • destOffset = 2
  • if you copy from a float to a float:
    • srcOffset = 0
    • destOffset = 0

Parameters

Name Type Description
name string name of the attribute to copy
tnewName boolean toggle if you want to copy to another name
newName string the new name of the attribute
srcOffset integer this defines which component the copy starts from. If you want to copy the whole attribute, leave it at 0. If you want to copy only the y component, set it to 1. If you want to copy the z component, set it to 2. Note that this only makes sense if you copy from an attribute that has enough components to copy from. So setting it to 2 (for z) to copy from a vector2 attribute will raise an error.
destOffset integer this defines which component the attribute is copied to

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 sphere
const sphere = geo.createNode('sphere');
sphere.p.radius.set(0.5);
sphere.p.center.set([0.5, 0.5, 0]);

// copy the uv to the position
const attribCopy = geo.createNode('attribCopy');
attribCopy.setInput(0, sphere);
attribCopy.p.name.set('uv');
attribCopy.p.tnewName.set(true);
attribCopy.p.newName.set('position');

// flatten the resulting geo
const transform = geo.createNode('transform');
transform.setInput(0, attribCopy);
transform.p.t.z.set(0);

// create a blend node to blend from the sphere and its uv projected version
const blend = geo.createNode('blend');
blend.setInput(0, sphere);
blend.setInput(1, transform);
blend.flags.display.set(true);

// add a light
root.createNode('hemisphereLight');

// 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');
perspectiveCamera1.p.controls.setNode(orbitsControls);

// mount the viewer
const element = document.getElementById('app');
perspectiveCamera1.createViewer(element);