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)
Create a new VertexIteratorAccessor instance.
Parameters
buffer | ArrayBuffer | The vertex buffer containing the attribute to be accessed. |
vertexElement | object | The vertex attribute to be accessed. |
vertexElement.name | string | 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: SEMANTIC_ATTR0 to SEMANTIC_ATTR15. |
vertexElement.numComponents | number | The number of components of the vertex attribute. Can be 1, 2, 3 or 4. |
vertexElement.dataType | number | The data type of the attribute. Can be: |
vertexElement.normalize | boolean | 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.offset | number | The number of initial bytes at the start of a vertex that are not relevant to this attribute. |
vertexElement.stride | number | The number of total bytes that are between the start of one vertex, and the start of the next. |
vertexElement.scopeId | ScopeId | The shader input variable corresponding to the attribute. |
vertexElement.size | number | The size of the attribute in bytes. |
vertexFormat | 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
offset | number | The component offset. Should be either 0, 1, 2, or 3. |
Returns
numberThe value of a attribute component.
getToArray(offset, outputArray, outputIndex)
Read attribute components to an output array.
Parameters
offset | number | The component offset at which to read data from the buffer. Will be used instead of the iterator's current index. |
outputArray | number[], Int8Array, Uint8Array, Uint8ClampedArray, Int16Array, Uint16Array, Int32Array, Uint32Array, Float32Array | The output array to write data into. |
outputIndex | number | 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
a | number | The first component value. |
b | number | The second component value (if applicable). |
c | number | The third component value (if applicable). |
d | number | The fourth component value (if applicable). |
setFromArray(index, inputArray, inputIndex)
Write attribute components from an input array.
Parameters
index | number | The starting index at which to write data into the buffer. Will be used instead of the iterator's current index. |
inputArray | number[], Int8Array, Uint8Array, Uint8ClampedArray, Int16Array, Uint16Array, Int32Array, Uint32Array, Float32Array | The input array to read data from. |
inputIndex | number | The input index at which to read from the input array. |