Attribute

The Attribute add structural information to Buffer. This class stores data for an attribute (such as vertex positions, face indices, normals, colors, UVs, and any custom attributes ) associated with a Geometry, which allows for more efficient passing of data to the GPU. Data is stored as vectors of any length (defined by size).

Constructor

new Attribute(buffer, sizeopt, offsetopt, normalizedopt)

Parameters:
NameTypeAttributesDefaultDescription
bufferBuffer

The Buffer instance passed in the constructor.

sizenumber<optional>
buffer.stride

The number of values of the array that should be associated with a particular vertex. For instance, if this attribute is storing a 3-component vector (such as a position, normal, or color), then size should be 3.

offsetnumber<optional>
0

The offset in the underlying array buffer where an item starts.

normalizedboolean<optional>
false

Indicates how the underlying data in the buffer maps to the values in the GLSL shader code.

Members

buffer :Buffer

The Buffer instance passed in the constructor.

Type:

divisor :number

Instance cadence, the number of instances drawn for each vertex in the buffer, non-instance attributes must be 0.

Type:
  • number
Default Value
  • 0

normalized :boolean

Indicates how the underlying data in the buffer maps to the values in the GLSL shader code.

Type:
  • boolean
Default Value
  • false

offset :number

The offset in the underlying buffer where an item starts.

Type:
  • number
Default Value
  • 0

size :number

The number of values of the buffer that should be associated with the attribute.

Type:
  • number
Default Value
  • buffer.stride

Methods

clone(buffers) → {Attribute}

Return a new attribute with the same parameters as this attribute.

Parameters:
NameTypeDescription
buffersobject

A WeakMap to save shared buffers.

Returns:
Type: 
Attribute

copy(source) → {Attribute}

Copy the parameters from the passed attribute.

Parameters:
NameTypeDescription
sourceAttribute

The attribute to be copied.

Returns:
Type: 
Attribute