API

Function CreatePolygon

  • 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
    • The smoothingThreshold option defines the dot product threshold for smoothing the normals of adjacent side faces. The default value of 2 disables smoothing

    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;
          smoothingThreshold?: number;
          updatable?: boolean;
          wrap?: boolean;
      }

      defines the options used to create the mesh

    • scene: Nullable<Scene> = null

      defines the hosting scene

    • earcutInjection: any = earcut

      can be used to inject your own earcut reference

    Returns Mesh

    the polygon mesh