|
1 | 1 | <!DOCTYPE html><html><head><meta charset=utf-8><title>H3DU.BufferAccessor</title></head><body><h1> H3DU.BufferAccessor</h1><p><a href='index.html'>Back to documentation index.</a></p><a name='H3DU.BufferAccessor'></a> |
2 | 2 | <h3> H3DU.BufferAccessor(buffer, offset, countPerValue, [stride])</h3>A <b>vertex attribute object</b>.<h4> Parameters</h4><ul><li><code>buffer</code> (Type: Float32Array)<br>A buffer to store vertex attribute data; see <a href="H3DU.BufferAccessor.html#H3DU.BufferAccessor_buffer">H3DU.BufferAccessor#buffer</a>.<li><code>offset</code> (Type: number)<br>Offset to the first value; see <a href="H3DU.BufferAccessor.html#H3DU.BufferAccessor_offset">H3DU.BufferAccessor#offset</a>. Throws an error if less than 0.<li><code>countPerValue</code> (Type: number)<br>Number of elements per value; see <a href="H3DU.BufferAccessor.html#H3DU.BufferAccessor_countPerValue">H3DU.BufferAccessor#countPerValue</a>. Throws an error if 0 or less.<li><code>stride</code> (Type: number) (optional)<br>Number of elements from the start of one value to the start of the next; see <a href="H3DU.BufferAccessor.html#H3DU.BufferAccessor_stride">H3DU.BufferAccessor#stride</a>. If null, undefined, or omitted, has the same value as "countPerValue". Throws an error if 0 or less.</ul><h3> Members</h3><ul><li><a href='#H3DU.BufferAccessor_buffer'>buffer</a><br>A <i>buffer</i> of arbitrary size.<li><a href='#H3DU.BufferAccessor_countPerValue'>countPerValue</a><br>A count of the number of elements each value has.<li><a href='#H3DU.BufferAccessor_offset'>offset</a><br>An offset, which identifies the index, starting from 0, of the first value |
3 | 3 | of the attribute within the buffer.<li><a href='#H3DU.BufferAccessor_stride'>stride</a><br>A stride, which gives the number of elements from the start of one |
4 | | -value to the start of the next.</ul><h3> Methods</h3><ul><li><a href='#H3DU.BufferAccessor_copy'>copy</a><br>Copies the values of this accessor into a new vertex attribute object.<li><a href='#H3DU.BufferAccessor_count'>count</a><br>Gets the number of <a href="H3DU.BufferAccessor.html#H3DU.BufferAccessor_buffer">values</a> defined for this accessor.<li><a href='#H3DU.BufferAccessor_get'>get</a><br>Gets the first element of the attribute value with the given vertex index.<li><a href='#H3DU.BufferAccessor_getVec'>getVec</a><br>Gets the elements of a vertex attribute value.<li><a href='#H3DU.BufferAccessor.makeBlank'>makeBlank</a><br>Generates a vertex attribute buffer, with each value set to all zeros.<li><a href='#H3DU.BufferAccessor_set'>set</a><br>Sets the first element of the attribute value with the given vertex index.<li><a href='#H3DU.BufferAccessor_setVec'>setVec</a><br>Sets the elements of a vertex attribute value.</ul><a name='H3DU.BufferAccessor_buffer'></a> |
| 4 | +value to the start of the next.</ul><h3> Methods</h3><ul><li><a href='#H3DU.BufferAccessor_copy'>copy</a><br>Copies the values of this accessor into a new vertex attribute object.<li><a href='#H3DU.BufferAccessor_count'>count</a><br>Gets the number of <a href="H3DU.BufferAccessor.html#H3DU.BufferAccessor_buffer">values</a> defined for this accessor.<li><a href='#H3DU.BufferAccessor_get'>get</a><br>Gets the first element of the attribute value with the given vertex index.<li><a href='#H3DU.BufferAccessor_getVec'>getVec</a><br>Gets the elements of a vertex attribute value.<li><a href='#H3DU.BufferAccessor.makeBlank'>makeBlank</a><br>Generates a vertex attribute buffer, with each value set to all zeros.<li><a href='#H3DU.BufferAccessor.makeIndices'>makeIndices</a><br>Generates an array of increasing vertex indices.<li><a href='#H3DU.BufferAccessor.merge'>merge</a><br>Merges two vertex attributes, whose vertices can be indexed differently, into one |
| 5 | +combined vertex attribute.<li><a href='#H3DU.BufferAccessor_set'>set</a><br>Sets the first element of the attribute value with the given vertex index.<li><a href='#H3DU.BufferAccessor_setVec'>setVec</a><br>Sets the elements of a vertex attribute value.</ul><a name='H3DU.BufferAccessor_buffer'></a> |
5 | 6 | <h3> H3DU.BufferAccessor#buffer |
6 | 7 |
|
7 | 8 | </h3>A <i>buffer</i> of arbitrary size. This buffer |
@@ -45,7 +46,12 @@ <h3> H3DU.BufferAccessor#get(index)</h3>Gets the first element of the attribute |
45 | 46 | <h3> H3DU.BufferAccessor#getVec(index, vec)</h3>Gets the elements of a vertex attribute value.<p> |
46 | 47 | Note that currently, this method does no bounds checking beyond the |
47 | 48 | checking naturally done when accessing the attribute's buffer.<h4> Parameters</h4><ul><li><code>index</code> (Type: number)<br>A numeric index, starting from 0, that identifies a value stored in the attribute's buffer. For example, 0 identifies the first value, 1 identifies the second, and so on.<li><code>vec</code> (Type: Array.<number>)<br>An array whose elements will be set to those of the value at the given index. The number of elements copied to this array is the attribute's count per value (see <a href="H3DU.BufferAccessor.html#H3DU.BufferAccessor_countPerValue">H3DU.BufferAccessor#countPerValue</a>).</ul><h4> Return Value</h4>The parameter "vec". (Type: Array.<number>)<a name='H3DU.BufferAccessor.makeBlank'></a> |
48 | | -<h3> (static) H3DU.BufferAccessor.makeBlank(count, countPerValue)</h3>Generates a vertex attribute buffer, with each value set to all zeros.<h4> Parameters</h4><ul><li><code>count</code> (Type: number)<br>The number of <a href="H3DU.BufferAccessor.html#H3DU.BufferAccessor_buffer">values</a> the buffer will hold. For example, (10, 20, 5) is a 3-element value.<li><code>countPerValue</code> (Type: number)<br>The number of elements each value will take in the buffer.</ul><h4> Return Value</h4>A blank vertex attribute buffer. (Type: <a href="H3DU.BufferAccessor.html">H3DU.BufferAccessor</a>)<a name='H3DU.BufferAccessor_set'></a> |
| 49 | +<h3> (static) H3DU.BufferAccessor.makeBlank(count, countPerValue)</h3>Generates a vertex attribute buffer, with each value set to all zeros.<h4> Parameters</h4><ul><li><code>count</code> (Type: number)<br>The number of <a href="H3DU.BufferAccessor.html#H3DU.BufferAccessor_buffer">values</a> the buffer will hold. For example, (10, 20, 5) is a 3-element value.<li><code>countPerValue</code> (Type: number)<br>The number of elements each value will take in the buffer.</ul><h4> Return Value</h4>A blank vertex attribute buffer. (Type: <a href="H3DU.BufferAccessor.html">H3DU.BufferAccessor</a>)<a name='H3DU.BufferAccessor.makeIndices'></a> |
| 50 | +<h3> (static) H3DU.BufferAccessor.makeIndices(numIndices)</h3>Generates an array of increasing vertex indices.<h4> Parameters</h4><ul><li><code>numIndices</code> (Type: number)<br>The number of vertex indices to generate. The array will range from 0 to the number of vertex indices minus 1.</ul><h4> Return Value</h4>An array of vertex indices. (Type: Uint16Array | Uint32Array)<a name='H3DU.BufferAccessor.merge'></a> |
| 51 | +<h3> (static) H3DU.BufferAccessor.merge(attr1, indices1, attr2, indices2)</h3>Merges two vertex attributes, whose vertices can be indexed differently, into one |
| 52 | +combined vertex attribute.<h4> Parameters</h4><ul><li><code>attr1</code> (Type: <a href="H3DU.BufferAccessor.html">H3DU.BufferAccessor</a>)<br>A vertex buffer accessor for the first vertex attribute. Can be null, in which case it is assumed that the attribute contains as many values as the length of "indices1" and all the values are zeros.<li><code>indices1</code> (Type: Array.<number> | Uint16Array | Uint8Array | Uint32Array)<br>An array of vertex indices associated with the first vertex attribute.<li><code>attr2</code> (Type: <a href="H3DU.BufferAccessor.html">H3DU.BufferAccessor</a>)<br>A vertex buffer accessor for the second vertex attribute. Can be null, in which case it is assumed that the attribute contains as many values as the length of "indices2" and all the values are zeros.<li><code>indices2</code> (Type: Array.<number> | Uint16Array | Uint8Array | Uint32Array)<br>An array of vertex indices associated with the second vertex attribute.</ul><h4> Return Value</h4>The merged attribute, where the vertices from the first vertex |
| 53 | +attribute come before those from the second. The merged attribute will have as many |
| 54 | +values as the sum of the lengths of "indices1" and "indices2". (Type: <a href="H3DU.BufferAccessor.html">H3DU.BufferAccessor</a>)<a name='H3DU.BufferAccessor_set'></a> |
49 | 55 | <h3> H3DU.BufferAccessor#set(index, value)</h3>Sets the first element of the attribute value with the given vertex index.<p> |
50 | 56 | Note that currently, this method does no bounds checking beyond the |
51 | 57 | checking naturally done when writing to the attribute's buffer.<h4> Parameters</h4><ul><li><code>index</code> (Type: number)<br>A numeric index, starting from 0, that identifies a value stored in the attribute's buffer. For example, 0 identifies the first value, 1 identifies the second, and so on.<li><code>value</code> (Type: number)<br>The number to set the first element to.</ul><h4> Return Value</h4>This object. (Type: <a href="H3DU.BufferAccessor.html">H3DU.BufferAccessor</a>)<a name='H3DU.BufferAccessor_setVec'></a> |
|
0 commit comments