A helper class used to construct triangulated polygon meshes Allow to add padding and a specific depth value.

Param: poly

Closed polygon to be processed and converted to a mesh (array of points or PIXI Polygon)

Param: options

Various options : normalizing, offsetting, add depth, ...

Properties

options: Record<string, number | boolean>

Contains options to apply during the meshing process

vertices: number[] = []

Polygon mesh vertices

indices: number[] = []

Polygon mesh indices

#scaled: Record<string, number> = {}

Contains some options values scaled by the constant factor

#geometry: Geometry = null

Polygon mesh geometry

#polygonNodeTree: {
    poly: number[];
    nPoly: number[];
    children: object[];
} = null

Contain the polygon tree node object, containing the main forms and its holes and sub-polygons

Type declaration

  • poly: number[]
  • nPoly: number[]
  • children: object[]
#nbPass: number

Contains the the number of offset passes required to compute the polygon

_defaultOptions: Record<string, number | boolean> = ...

Default options values

Methods

  • Execute the triangulation to create indices

    Parameters

    • geometry: Geometry

      A geometry to update

    Returns Geometry

    The resulting geometry

  • Private

    Create the polygon mesh

    Parameters

    • points: number[]

    Returns void

  • Private

    Update vertices and add depth

    Parameters

    • vertices: number[]

    Returns void

  • Private

    Create the polygon by generating the edges and the interior of the polygon if an offset != 0, and just activate a fast triangulation if offset = 0

    Returns true | void

  • Recursively create offset polygons in successive passes

    Parameters

    • offsetter: ClipperOffset

      ClipperLib offsetter

    • node: object

      A polygon node object to offset

    • Optional pass: number = 0

      The pass number (initialized with 0 for the first call)

    Returns void

  • Private

    Flatten a ClipperLib path to array of numbers

    Parameters

    • path: IntPoint[]

      path to convert

    • depth: number

      depth to add to the flattened vertices

    Returns number[]

    flattened array of points

  • Private

    Normalize polygon coordinates and put result into nPoly property.

    Parameters

    • poly: number[]

      the poly to normalize

    Returns number[]

    the normalized poly array

  • Private

    Fast triangulation of the polygon node tree

    Returns void

  • Private

    Recursive triangulation of the polygon node tree

    Returns void

  • Triangulate a node and its children recursively to compose a mesh with multiple levels of depth

    Parameters

    • node: object

      The polygon node tree to triangulate

    • Optional indices: number[] = []

      An optional array to receive indices (used for recursivity)

    Returns number[]

    An array of indices, result of the triangulation

  • Private

    Updating or creating the PIXI.Geometry that will be used by the mesh

    Returns Geometry

  • Private

    Empty the geometry, or if geometry is null, create an empty geometry.

    Returns any

  • Create a new Geometry from provided buffers

    Parameters

    • vertices: number[]

      provided vertices array (interleaved or not)

    • Optional depth: number[] = undefined

      provided depth array

    • Optional indices: number[] = ...

      provided indices array

    Returns Geometry

    the new PIXI.Geometry constructed from the provided buffers

  • Convert a flat points array into a 2 dimensional ClipperLib path

    Parameters

    • poly: number[] | Polygon

      PIXI.Polygon or points flat array.

    • Optional dimension: number = 2

      Dimension.

    Returns number[]

    The clipper lib path.