Inheritance: EventDispatcher → Node → InputNode →
In earlier three.js versions it was only possible to define attribute data on geometry level. With BufferAttributeNode, it is also possible to do this on the node level.
This new approach is especially interesting when geometry data are generated via compute shaders. The below line converts a storage buffer into an attribute node.
material.positionNode = positionBuffer.toAttribute();
const geometry = new THREE.PlaneGeometry();
const positionAttribute = geometry.getAttribute( 'position' );
const colors = [];
for ( let i = 0; i < position.count; i ++ ) {
colors.push( 1, 0, 0 );
}
material.colorNode = bufferAttribute( new THREE.Float32BufferAttribute( colors, 3 ) );
Constructs a new buffer attribute node.
value
The attribute data.
bufferType
The buffer type (e.g. 'vec3').
Default is null.
bufferStride
The buffer stride.
Default is 0.
bufferOffset
The buffer offset.
Default is 0.
A reference to the buffer attribute.
Default is null.
The buffer offset.
Default is 0.
The buffer stride.
Default is 0.
The buffer type (e.g. 'vec3').
Default is null.
BufferAttributeNode sets this property to true by default.
Default is true.
Overrides: InputNode#global
Whether the attribute is instanced or not.
Default is false.
This flag can be used for type testing.
Default is true.
The usage property. Set this to THREE.DynamicDrawUsage via .setUsage(), if you are planning to update the attribute data per frame.
Default is StaticDrawUsage.
Generates the code snippet of the buffer attribute node.
builder
The current node builder.
Overrides: InputNode#generate
Returns: The generated code snippet.
This method is overwritten since the attribute data might be shared and thus the hash should be shared as well.
builder
The current node builder.
Overrides: InputNode#getHash
Returns: The hash.
Overwrites the default implementation to return a fixed value 'bufferAttribute'.
builder
The current node builder.
Overrides: InputNode#getInputType
Returns: The input type.
This method is overwritten since the node type is inferred from the buffer attribute.
builder
The current node builder.
Overrides: InputNode#getNodeType
Returns: The node type.
Sets the instanced property to the given value.
value
The value to set.
Returns: A reference to this node.
Sets the usage property to the given value.
value
The usage to set.
Returns: A reference to this node.
Depending on which value was passed to the node, setup() behaves differently. If no instance of BufferAttribute was passed, the method creates an internal attribute and configures it respectively.
builder
The current node builder.
Overrides: InputNode#setup