BufferAttribute
This class stores data for an attribute associated with a
BufferGeometry. See that page for details and a usage example. This class is used to store builtin attributes such as vertex position, normals, color, etc., but can also be used in your code to store custom attributes in a
BufferGeometry.
Constructor
Instantiates this attribute with data from the associated buffer.
itemSize gives the number of values of the array that should be associated with a particular vertex. normalized indicates how the underlying data in the buffer maps to the values in the GLSL shader code.
Properties
Stores the data associated with this attribute. This element should have
itemSize * numVertices
elements, where numVertices is the number of vertices in the associated
geometry.
array can be an instance of UInt8Array, Int8Array, UInt16Array, Int16Array, or Float32Array.
Records how many items of the array are associated with a particular vertex. For instance, if this
attribute is storing a 3-component vector (such as a position, normal, or color), then itemSize should be 3.
Gives the total number of elements in the array.
Flag to indicate that this attribute has changed and should be re-send to the GPU. Set this to true when you modify the value of the array.
Indicates how the underlying data in the buffer maps to the values in the GLSL code. For instance, if
array is an instance of UInt16Array, and
normalized is true, the values 0 - +65535 in the array data will be mapped to 0.0f - +1.0f in the GLSL attribute. An Int16Array (signed) would map from -32767 - +32767 to -1.0f - +1.0f. If
normalized is false, the values will be converted to floats which contain the exact value, i.e. 32767 becomes 32767.0f.
A version number, incremented every time the needsUpdate property is set to true.
Methods
Copies itemSize values in the array from the vertex at index2 to the vertex at index1.
Sets the associated array with values from the passed array.
# .setX ( index, x )
Sets the value of the array at index * itemSize
to x
# .setY ( index, y )
Sets the value of the array at index * itemSize + 1
to y
# .setZ ( index, z )
Sets the value of the array at index * itemSize + 2
to z
# .setXY ( index, x, y )
Sets the value of the array at index * itemSize
to x and
sets the value of the array at index * itemSize + 1
to y
# .setXYZ ( index, x, y, z )
Sets the value of the array at index * itemSize
to x,
the value of the array at index * itemSize + 1
to y, and
the value of the array at index * itemSize + 2
to z.
# .setXYZW ( index, x, y, z, w )
Sets the value of the array at index * itemSize
to x,
the value of the array at index * itemSize + 1
to y,
the value of the array at index * itemSize + 2
to z, and
the value of the array at index * itemSize + 3
to w.
Copies this attribute.
Source
src/core/BufferAttribute.js
Edit