pixi.js
    Preparing search index...

    Class GeometryAdvanced

    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.

    const geometry = new Geometry({
    attributes: {
    aPosition: [ // add some positions
    0, 0,
    0, 100,
    100, 100,
    100, 0,
    ],
    aUv: [ // add some uvs
    0, 0,
    0, 1,
    1, 1,
    1, 0,
    ]
    }
    });

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    attributes: Record<string, Attribute>

    A record of the attributes of the geometry.

    buffers: Buffer[]

    The buffers that the attributes use

    indexBuffer: Buffer

    The index buffer of the geometry

    instanceCount: number = 1

    the instance count of the geometry to draw

    topology: Topology

    The topology of the geometry.

    uid: number = ...

    The unique id of the geometry.

    Accessors

    • get bounds(): Bounds

      Returns the bounds of the geometry.

      Returns Bounds

    Methods

    • Adds an attribute to the geometry.

      Parameters

      • name: string

        The name of the attribute to add.

      • attributeOption: AttributeOption

        The attribute option to add.

      Returns void

    • Adds an index buffer to the geometry.

      Parameters

      • indexBuffer: number[] | TypedArray | Buffer

        The index buffer to add. Can be a Buffer, TypedArray, or an array of numbers.

      Returns void

    • destroys the geometry.

      Parameters

      • destroyBuffers: boolean = false

        destroy the buffers associated with this geometry

      Returns void

    • Returns the requested attribute.

      Parameters

      • id: string

        The name of the attribute required

      Returns Attribute

      • The attribute requested.
    • Returns the requested buffer.

      Parameters

      • id: string

        The name of the buffer required.

      Returns Buffer

      • The buffer requested.
    • Returns the index buffer

      Returns Buffer

      • The index buffer.
    • Used to figure out how many vertices there are in this geometry

      Returns number

      the number of vertices in the geometry