API Reference

Class List

pc.VertexIteratorAccessor

Helps with accessing a specific vertex attribute.

Summary

Methods

get

Get a attribute component at the iterator's current index.

getToArray

Read attribute components to an output array.

set

Set all the attribute components at the iterator's current index.

setFromArray

Write attribute components from an input array.

Details

Constructor

VertexIteratorAccessor(buffer, vertexElement, vertexFormat)

Returns a new pc.VertexIteratorAccessor object.

Parameters

bufferArrayBuffer

The vertex buffer containing the attribute to be accessed.

vertexElementobject

The vertex attribute to be accessed.

vertexElement.namestring

The meaning of the vertex element. This is used to link the vertex data to a shader input. Can be:

If vertex data has a meaning other that one of those listed above, use the user-defined semantics: pc.SEMANTIC_ATTR0 to pc.SEMANTIC_ATTR15.

vertexElement.numComponentsnumber

The number of components of the vertex attribute. Can be 1, 2, 3 or 4.

vertexElement.dataTypenumber

The data type of the attribute. Can be:

vertexElement.normalizeboolean

If true, vertex attribute data will be mapped from a 0 to 255 range down to 0 to 1 when fed to a shader. If false, vertex attribute data is left unchanged. If this property is unspecified, false is assumed.

vertexElement.offsetnumber

The number of initial bytes at the start of a vertex that are not relevant to this attribute.

vertexElement.stridenumber

The number of total bytes that are between the start of one vertex, and the start of the next.

vertexElement.scopeIdpc.ScopeId

The shader input variable corresponding to the attribute.

vertexElement.sizenumber

The size of the attribute in bytes.

vertexFormatpc.VertexFormat

A vertex format that defines the layout of vertex data inside the buffer.

Methods

get(offset)

Get a attribute component at the iterator's current index.

Parameters

offsetnumber

The component offset. Should be either 0, 1, 2, or 3.

Returns

number

The value of a attribute component.

getToArray(offset, outputArray, outputIndex)

Read attribute components to an output array.

Parameters

offsetnumber

The component offset at which to read data from the buffer. Will be used instead of the iterator's current index.

outputArraynumber[], Int8Array, Uint8Array, Uint8ClampedArray, Int16Array, Uint16Array, Int32Array, Uint32Array, Float32Array

The output array to write data into.

outputIndexnumber

The output index at which to write into the output array.

set(a, [b], [c], [d])

Set all the attribute components at the iterator's current index.

Parameters

anumber

The first component value.

bnumber

The second component value (if applicable).

cnumber

The third component value (if applicable).

dnumber

The fourth component value (if applicable).

setFromArray(index, inputArray, inputIndex)

Write attribute components from an input array.

Parameters

indexnumber

The starting index at which to write data into the buffer. Will be used instead of the iterator's current index.

inputArraynumber[], Int8Array, Uint8Array, Uint8ClampedArray, Int16Array, Uint16Array, Int32Array, Uint32Array, Float32Array

The input array to read data from.

inputIndexnumber

The input index at which to read from the input array.