H3DU.BufferAccessor

Back to documentation index.

new H3DU.BufferAccessor(buffer, countPerValue, [offset], [stride])

A vertex attribute object.

Parameters

Members

Methods

H3DU.BufferAccessor#buffer

A buffer of arbitrary size. This buffer is made up of values, one for each vertex, and each value takes up one or more elements in the buffer, which are numbers such as X coordinates or red components, depending on the attribute's semantic. Each value has the same number of elements. An example of a value is (10, 20, 5), which can take up three consecutive elements in a Float32Array buffer such as the one given in this property.

Type: Float32Array

H3DU.BufferAccessor#countPerValue

A count of the number of elements each value has. For example, 3-dimensional positions will have 3 elements, one for each coordinate.

Type: number

H3DU.BufferAccessor#offset

An offset, which identifies the index, starting from 0, of the first value of the attribute within the buffer. The offset counts the number of elements in the buffer to the first value. For example, if this property is 6, then the first element of the first value in the buffer is found at acc.buffer[acc.offset] (assuming the buffer is more than 6 elements long).

Type: number

H3DU.BufferAccessor#stride

A stride, which gives the number of elements from the start of one value to the start of the next. A "packed" buffer will have a stride equal to the count per value.

Type: number

H3DU.BufferAccessor#copy()

Copies the values of this accessor into a new vertex attribute object.

Return Value

A copy of the vertex attribute object. (Type: BufferAccessor)

H3DU.BufferAccessor#count()

Gets the number of values defined for this accessor.

Return Value

The number of values defined in this accessor's buffer. (Type: number)

H3DU.BufferAccessor#get(index)

Gets the first element of the attribute value with the given vertex index.

Note that currently, this method does no bounds checking beyond the checking naturally done when accessing the attribute's buffer.

Parameters

Return Value

The first element of the given attribute value. (Type: number)

H3DU.BufferAccessor#getVec(index, vec)

Gets the elements of a vertex attribute value.

Note that currently, this method does no bounds checking beyond the checking naturally done when accessing the attribute's buffer.

Parameters

Return Value

The parameter "vec". (Type: Array.<number>)

(static) H3DU.BufferAccessor.makeBlank(count, countPerValue)

Generates a vertex attribute buffer, with each value set to all zeros.

Parameters

Return Value

A blank vertex attribute buffer. (Type: BufferAccessor)

(static) H3DU.BufferAccessor.makeIndices(numIndices)

Generates an array of increasing vertex indices.

Parameters

Return Value

An array of vertex indices. (Type: Uint16Array | Uint32Array)

(static) H3DU.BufferAccessor.merge(attr1, indices1, attr2, indices2)

Merges two vertex attributes, whose vertices can be indexed differently, into one combined vertex attribute.

Parameters

Return Value

The merged attribute, where the vertices from the first vertex attribute come before those from the second. The merged attribute will have as many values as the sum of the lengths of "indices1" and "indices2". (Type: BufferAccessor)

H3DU.BufferAccessor#set(index, value)

Sets the first element of the attribute value with the given vertex index.

Note that currently, this method does no bounds checking beyond the checking naturally done when writing to the attribute's buffer.

Parameters

Return Value

This object. (Type: BufferAccessor)

H3DU.BufferAccessor#setVec(index, vec)

Sets the elements of a vertex attribute value.

Note that currently, this method does no bounds checking beyond the checking naturally done when writing to the attribute's buffer, except where noted otherwise.

Parameters

Return Value

This object. (Type: BufferAccessor)

Back to documentation index.