Class: Geometry

Geometry(webglContext, positions, colors, indicesSolid, indicesWireframe, uvsopt, normalsopt, optionsopt)

Geometry represents a set of `vertex buffers + index buffers`, grouped under a VAO.

Constructor

new Geometry(webglContext, positions, colors, indicesSolid, indicesWireframe, uvsopt, normalsopt, optionsopt)

Parameters:
Name Type Attributes Default Description
webglContext WebGL2RenderingContext WebGL2 rendering context used to create and manage the GPU resources.
positions Float32Array [x, y, z] triples.
colors Float32Array | null [red, green, blue] triples or null.
indicesSolid Uint16Array | Uint32Array Indices for solid triangles.
indicesWireframe Uint16Array | Uint32Array Indices for wireframe lines.
uvs Float32Array | null <optional>
null [u, v] pairs or null.
normals Float32Array | null <optional>
null [x, y, z] triples or null.
options GeometryPrimitiveOptions | null <optional>
null Primitive overrides.
Source:

Classes

Geometry

Methods

bind()

Binds the VAO of this geometry.
Source:

bindIndexBuffer(wireframe)

Binds the appropriate index buffer depending on the wireframe flag.
Parameters:
Name Type Description
wireframe boolean Flag indicating whether the geometry should be drawn in wireframe mode.
Source:

dispose()

Releases all GPU resources owned by this geometry (VAO and buffers). After calling dispose, this geometry instance must not be used for rendering.
Source:

getBoundingBoxMax() → {Float32Array}

Returns local-space AABB maximum.
Source:
Returns:
Type
Float32Array

getBoundingBoxMin() → {Float32Array}

Returns local-space AABB minimum.
Source:
Returns:
Type
Float32Array

getIndexComponentType(wireframe) → {number}

Returns index component type constant used by `drawElements()`. This depends on whether the index buffer is `Uint16Array` or `Uint32Array`.
Parameters:
Name Type Description
wireframe boolean When true, returns wireframe index component type.
Source:
Returns:
- WebGL component type constant.
Type
number

getIndexCount(wireframe) → {number}

Returns the index count depending on the wireframe flag.
Parameters:
Name Type Description
wireframe boolean Flag indicating whether the geometry should be drawn in wireframe mode.
Source:
Returns:
Type
number

getPrimitive(wireframe) → {string}

Returns the primitive type for solid or wireframe rendering.
Parameters:
Name Type Description
wireframe boolean When true, returns wireframe primitive type.
Source:
Returns:
Type
string