MeshAttributeAccessor
MeshAttributeAccessor
An iterator over a mesh vertex attribute.
Usage:
|
|
- MeshAttributeAccessor
- .length: number
- .createArray(count) ⇒ InstanceType
- .get<T>(index, out) ⇒ T
- .set(i, v) ⇒ MeshAttributeAccessor
.length: number
Max number of elements.
.createArray(count: number) ⇒ InstanceType
Create a new TypedArray to hold this attribute’s values.
This method is useful to create a view to hold the data to pass to get and set
Example:
Returns: A TypedArray with the appropriate format to access the data
Param | Type | Description |
---|---|---|
count | number | The number of vertices expected. |
.get(index: number) ⇒ InstanceType
.get<T>(index: number, out: T) ⇒ T
Get attribute element.
Returns: The out
parameter
Param | Type | Description |
---|---|---|
index | number | Index |
out | T | Preallocated array to write into,
to avoid garbage, otherwise will allocate a new TypedArray.
out.length needs to be a multiple of the attributes component count, see
MeshAttribute. If out.length is more than one multiple, it will be
filled with the next n attribute elements, which can reduce overhead
of this call. |
Template Param | Type Definition |
---|---|
T | extends NumberArray |
.set(i: number, v: Readonly<NumberArray>) ⇒ MeshAttributeAccessor
Set attribute element.
Returns: Reference to self (for method chaining)
Param | Type | Description |
---|---|---|
i | number | Index |
v | Readonly<NumberArray> | Value to set the element to
v.length needs to be a multiple of the attributes component count, see
MeshAttribute. If v.length is more than one multiple, it will be
filled with the next n attribute elements, which can reduce overhead
of this call. |