BufferAccessor

Back to documentation index.

### new BufferAccessor(buffer, countPerValue, [offset], [stride])

Deprecated: It is planned to render this class obsolete and rely on three.js’s BufferGeometry.

A vertex attribute object.

Parameters

Members

Methods

### 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

### 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

### 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

### 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

### 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)

### 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)

### 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)

### 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) 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) BufferAccessor.makeIndices(numIndices)

Generates an array of increasing vertex indices.

Parameters

Return Value

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

### (static) 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)

### 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)

### 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)

### BufferAccessor#setXy(index, x, y)

Sets the first and second 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)

### BufferAccessor#setXyz(index, x, y, z)

Sets the first, second, and third 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.