Methods
(static) appendGridTriangleIndices(indices, columnSegments, rowSegments, vertexOffsetopt, reverseopt)
Appends triangles for a rectangular vertex grid in row order.
Dimensions and offsets come from normalized geometry options.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
indices |
Array.<number> | Output triangle indexes. | ||
columnSegments |
number | Number of cells per row. | ||
rowSegments |
number | Number of cell rows. | ||
vertexOffset |
number |
<optional> |
0 | First vertex in the grid. |
reverse |
boolean |
<optional> |
false | Whether to reverse each triangle's winding. |
- Source:
(static) createColorsFromSpec(vertexCount, colors, expectedPerVertexLengthopt) → {Float32Array}
Creates a per-vertex RGB buffer from a uniform color or an existing color buffer.
A positive `expectedPerVertexLength` overrides the length derived from `vertexCount`.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
vertexCount |
number | Total vertex count. | ||
colors |
Float32Array | Uniform RGB color or per-vertex colors. | ||
expectedPerVertexLength |
number |
<optional> |
0 | Optional explicit expected buffer length. |
- Source:
Throws:
-
When colors have an unsupported type or length.
- Type
- TypeError
Returns:
- A new uniform-color buffer or the supplied per-vertex buffer.
- Type
- Float32Array
(static) createIndexArray(vertexCount, indices) → {Uint16Array|Uint32Array}
Creates an index buffer using the smallest type required by the vertex count.
The largest vertex index is `vertexCount - 1`.
Parameters:
| Name | Type | Description |
|---|---|---|
vertexCount |
number | Total vertex count. |
indices |
Array.<number> | Index list. |
- Source:
Throws:
-
When indices are not an ordinary array.
- Type
- TypeError
Returns:
- A new typed index buffer.
- Type
- Uint16Array | Uint32Array
(static) createSequentialIndexArray(vertexCount) → {Uint16Array|Uint32Array}
Creates a sequential index buffer without an intermediate JavaScript array.
The buffer contains every vertex index, from zero through `vertexCount - 1`.
Parameters:
| Name | Type | Description |
|---|---|---|
vertexCount |
number | Total vertex count. |
- Source:
Throws:
-
-
When `vertexCount` is not a finite number.
- Type
- TypeError
-
-
-
When `vertexCount` is negative or non-integer.
- Type
- RangeError
-
Returns:
- A new sequential index buffer.
- Type
- Uint16Array | Uint32Array
(static) createWireframeIndicesFromSolidIndices(vertexCount, triangleIndices) → {Uint16Array|Uint32Array}
Creates a wireframe line index buffer from a solid triangle index buffer.
Shared edges are included once, regardless of their direction in each triangle.
Parameters:
| Name | Type | Description |
|---|---|---|
vertexCount |
number | Total vertex count. |
triangleIndices |
Uint16Array | Uint32Array | Solid triangle indexes. |
- Source:
Throws:
-
When triangle indices have an unsupported type.
- Type
- TypeError
Returns:
- Wireframe indexes, with two indexes per edge.
- Type
- Uint16Array | Uint32Array
(static) normalizeSegmentCount(value, optionName, minimumValue, geometryName) → {number}
Floors a finite segment count and checks the minimum required by a geometry.
Parameters:
| Name | Type | Description |
|---|---|---|
value |
number | Requested segment count. |
optionName |
string | Option name included in errors. |
minimumValue |
number | Minimum supported count. |
geometryName |
string | Geometry class name included in errors. |
- Source:
Throws:
-
-
When the value is not a finite number.
- Type
- TypeError
-
-
-
When the rounded count is below the minimum.
- Type
- RangeError
-
Returns:
- Validated integer segment count.
- Type
- number