Advanced
Create a new instance of a geometry
The options for the geometry.
Readonly
attributesA record of the attributes of the geometry.
Readonly
buffersThe buffers that the attributes use
The index buffer of the geometry
the instance count of the geometry to draw
The topology of the geometry.
Readonly
uidThe unique id of the geometry.
Adds an attribute to the geometry.
The name of the attribute to add.
The attribute option to add.
Adds an index buffer to the geometry.
The index buffer to add. Can be a Buffer, TypedArray, or an array of numbers.
destroys the geometry.
destroy the buffers associated with this geometry
Returns the requested attribute.
The name of the attribute required
Returns the requested buffer.
The name of the buffer required.
Used to figure out how many vertices there are in this geometry
the number of vertices in the geometry
A Geometry is a low-level object that represents the structure of 2D shapes in terms of vertices and attributes. It's a crucial component for rendering as it describes the shape and format of the data that will go through the shaders. Essentially, a Geometry object holds the data you'd send to a GPU buffer.
A geometry is basically made of two components:
Attributes: These are essentially arrays that define properties of the vertices like position, color, texture coordinates, etc. They map directly to attributes in your vertex shaders.
Indices: An optional array that describes how the vertices are connected. If not provided, vertices will be interpreted in the sequence they're given.
Example