BufferPolygon

open external class BufferPolygon : BufferPrimitive(source)

View bound to the underlying buffer data of a BufferPolygonCollection.

BufferPolygon instances are flyweights: a single BufferPolygon instance can be temporarily bound to any conceptual "polygon" in a BufferPolygonCollection, allowing very large collections to be iterated and updated with a minimal memory footprint.

Represented as one (1) external linear ring of three (3) or more positions. May optionally define one or more internal linear rings ("holes") within the polygon. Each hole is represented as a single index into the positions array, where the vertex at that index is the start of an internal linear ring that continues along the following vertices until reaching either the vertex index of the next hole, or the end of the vertex list. Stores a precomputed triangulation, represented as three vertex indices per triangle.

See also

Constructors

Link copied to clipboard
constructor()

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

Feature ID associated with the primitive; not required to be unique.

Link copied to clipboard

Count of holes (indices) in this polygon.

Link copied to clipboard

Count of positions (vertices) in this polygon's outer linear ring, number of VEC3 elements.

Link copied to clipboard

Offset in collection position array to first vertex in polygon's outer linear ring, number of VEC3 elements.

Link copied to clipboard
var show: JsAny

Whether primitive is shown.

Link copied to clipboard

Count of triangles in this polygon, number of VEC3 elements.

Link copied to clipboard

Count of positions (vertices) in this polygon, including both outer ring and internal rings (holes), number of VEC3 elements.

Functions

Link copied to clipboard
fun getHolePositions(holeIndex: Int, result: TypedArray<*, *, *, *>? = definedExternally)

Returns an array view of the inner linear ring vertex positions for the specified hole. If 'result' argument is given, vertex positions are written to that array and returned. Otherwise, returns an ArrayView on collection memory — changes to this array will not trigger render updates, which requires .setPositions().

Link copied to clipboard
fun getHoles(result: TypedArray<*, *, *, *>? = definedExternally): TypedArray<*, *, *, *>

Gets this polygon's hole indices, with each hole represented as a single offset into this polygon's positions array. Each hole implicitly continues along an internal linear ring from that vertex offset until reaching either the end of the positions array, or the next hole offset.

Link copied to clipboard
fun getHoleVertexCount(holeIndex: Int): Double

Returns the number of (VEC3) vertices in the specified hole.

Link copied to clipboard
fun getOuterPositions(result: TypedArray<*, *, *, *>? = definedExternally): TypedArray<*, *, *, *>

Returns an array view of this polygon's outer linear ring vertex positions. If 'result' argument is given, vertex positions are written to that array and returned. Otherwise, returns an ArrayView on collection memory — changes to this array will not trigger render updates, which requires .setPositions().

Link copied to clipboard
fun getPositions(result: JsAny? = definedExternally)

Returns an array view of this polygon's vertex positions. If 'result' argument is given, vertex positions are written to that array and returned. Otherwise, returns an ArrayView on collection memory — changes to this array will not trigger render updates, which requires .setPositions().

Link copied to clipboard
fun getTriangles(result: TypedArray<*, *, *, *>? = definedExternally): TypedArray<*, *, *, *>

Returns an array view of this polygon's triangle indices, represented as three vertex indices per triangle.

Link copied to clipboard
fun setHoles(holes: TypedArray<*, *, *, *>)

Sets this polygon's hole indices, with holes represented as a single offset into this polygon's positions array. Each hole implicitly continues along an internal linear ring from that vertex offset until reaching either the end of the positions array, or the next hole offset.

Link copied to clipboard
fun setTriangles(indices: TypedArray<*, *, *, *>)

Sets this polygon's triangle indices, represented as three vertex indices per triangle.

Link copied to clipboard
open override fun toJSON(): JsAny

Returns a JSON-serializable object representing the polygon. This encoding is not memory-efficient, and should generally be used for debugging and testing.