PolygonBuilder

Class containing static functions to help procedurally build meshes

Hierarchy

  • PolygonBuilder

Index

Methods

Static CreatePolygon

Find examples in Playground
  • CreatePolygon(name: string, options: object, scene?: Nullable<Scene>, earcutInjection?: any): Mesh
  • Creates a polygon mesh The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh

    • The parameter shape is a required array of successive Vector3 representing the corners of the polygon in th XoZ plane, that is y = 0 for all vectors
    • You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
    • The mesh can be set to updatable with the boolean parameter updatable (default false) if its internal geometry is supposed to change once created
    • If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters frontUVs and backUVs (Vector4)
    • Remember you can only change the shape positions, not their number when updating a polygon

    Parameters

    • name: string

      defines the name of the mesh

    • options: object

      defines the options used to create the mesh

      • Optional backUVs?: Vector4
      • Optional depth?: number
      • Optional faceColors?: Color4[]
      • Optional faceUV?: Vector4[]
      • Optional frontUVs?: Vector4
      • Optional holes?: Vector3[][]
      • shape: Vector3[]
      • Optional sideOrientation?: number
      • Optional updatable?: boolean
    • Optional scene: Nullable<Scene>

      defines the hosting scene

    • Optional earcutInjection: any

      can be used to inject your own earcut reference

    Returns Mesh

    the polygon mesh

Static ExtrudePolygon

Find examples in Playground
  • ExtrudePolygon(name: string, options: object, scene?: Nullable<Scene>, earcutInjection?: any): Mesh
  • Creates an extruded polygon mesh, with depth in the Y direction.

    • You can set different colors and different images to the top, bottom and extruded side by using the parameters faceColors (an array of 3 Color3 elements) and faceUV (an array of 3 Vector4 elements)
    see

    https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors

    Parameters

    • name: string

      defines the name of the mesh

    • options: object

      defines the options used to create the mesh

      • Optional backUVs?: Vector4
      • Optional depth?: number
      • Optional faceColors?: Color4[]
      • Optional faceUV?: Vector4[]
      • Optional frontUVs?: Vector4
      • Optional holes?: Vector3[][]
      • shape: Vector3[]
      • Optional sideOrientation?: number
      • Optional updatable?: boolean
    • Optional scene: Nullable<Scene>

      defines the hosting scene

    • Optional earcutInjection: any

      can be used to inject your own earcut reference

    Returns Mesh

    the polygon mesh

Generated using TypeDoc