Options
All
  • Public
  • Public/Protected
  • All
Menu

Class PolygonBuilder

Class containing static functions to help procedurally build meshes

Hierarchy

  • PolygonBuilder

Index

Methods

Static CreatePolygonSearch playground for CreatePolygon

  • CreatePolygon(name: string, options: { backUVs?: Vector4; depth?: number; faceColors?: Color4[]; faceUV?: Vector4[]; frontUVs?: Vector4; holes?: Vector3[][]; shape: Vector3[]; sideOrientation?: number; updatable?: boolean; wrap?: boolean }, 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: { backUVs?: Vector4; depth?: number; faceColors?: Color4[]; faceUV?: Vector4[]; frontUVs?: Vector4; holes?: Vector3[][]; shape: Vector3[]; sideOrientation?: number; updatable?: boolean; wrap?: boolean }

      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 wrap?: 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 ExtrudePolygonSearch playground for ExtrudePolygon

  • ExtrudePolygon(name: string, options: { backUVs?: Vector4; depth?: number; faceColors?: Color4[]; faceUV?: Vector4[]; frontUVs?: Vector4; holes?: Vector3[][]; shape: Vector3[]; sideOrientation?: number; updatable?: boolean; wrap?: boolean }, 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: { backUVs?: Vector4; depth?: number; faceColors?: Color4[]; faceUV?: Vector4[]; frontUVs?: Vector4; holes?: Vector3[][]; shape: Vector3[]; sideOrientation?: number; updatable?: boolean; wrap?: boolean }

      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 wrap?: 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

Legend

  • Constructor
  • Property
  • Method
  • Property
  • Method
  • Inherited property
  • Inherited method
  • Static property
  • Static method