Geometry utilities
Geometry typesโ
GeometryInput is the minimal indexed or non-indexed geometry shape accepted by this module.
Store number-backed typed arrays in value. The utility input also accepts the legacy
values field. If both fields are present, value takes precedence.
isGeometry(value)โ
Checks topology, attribute storage, and optional index storage. Each operation checks the attributes and element counts it needs.
Primitive iterationโ
makeAttributeIterator(values, size)โ
Iterates over fixed-size typed-array elements.
makePrimitiveIterator(geometry, {start?, end?})โ
Iterates over points, lines, or triangles and dereferences optional
indices. Accepted input topologies are 'point-list', 'line-list', 'line-strip',
'line-loop', 'triangle-list', 'triangle-strip', and 'triangle-fan'. Each yielded
primitive has a type of 'point-list', 'line-list', or 'triangle-list'.
The optional range is zero-based and end-exclusive. By default it spans the index buffer for indexed geometry or the position attribute for non-indexed geometry.
Vertex normalsโ
computeVertexNormals(geometry)โ
Calculates smooth, area-weighted normals for indexed or non-indexed triangle geometry. Triangle strips and triangle fans are supported.
Typed arraysโ
concatTypedArrays(arrays)โ
Concatenates the visible bytes of typed-array views.
Packed attributesโ
interpolatePackedAttributes reconstructs interleaved
vertex records from original-vertex provenance. It preserves storage encodings, handles offset
views, and requires explicit linear or flat policies for every declared field.
encodeRGB565(rgb)โ
Converts 8-bit RGB components to a packed RGB565 number.
decodeRGB565(rgb565, target?)โ
Decodes a packed RGB565 number into 8-bit RGB components, writing into target when supplied.
octEncodeInRange(vector, rangeMaximum, result)โ
Octahedrally encodes a normalized vector into two unsigned components in the requested range.
octEncode(vector, result)โ
Encodes a normalized vector into two components in the range 0โ255.
octEncodeToVector4(vector, result)โ
Encodes a normalized vector into four 8-bit octahedral components.
octDecodeInRange(x, y, rangeMaximum, result)โ
Decodes two unsigned octahedral components from the requested range into a normalized vector.
octDecode(x, y, result)โ
Decodes two components in the range 0โ255 into a normalized vector.
octDecodeFromVector4(encoded, result)โ
Decodes four 8-bit octahedral components into a normalized vector.
octPackFloat(encoded)โ
Packs two 8-bit components into one number.
octEncodeFloat(vector)โ
Encodes a normalized vector into a packed number.
octDecodeFloat(value, result)โ
Decodes a packed number into a normalized vector.
octPack(v1, v2, v3, result)โ
Packs three normalized vectors into two numbers.
octUnpack(packed, v1, v2, v3)โ
Unpacks two numbers into three normalized vectors.
compressTextureCoordinates(textureCoordinates)โ
Packs normalized UV coordinates into one number.
decompressTextureCoordinates(compressed, result)โ
Unpacks UV coordinates into the supplied result.
zigZagDeltaDecode(uBuffer, vBuffer, heightBuffer?)โ
Decodes quantized zigzag delta buffers in place. The height buffer is optional.