API

Function CreateGroundFromHeightMap

  • Creates a ground mesh from a height map. The height map download can take some frames, so the mesh is not immediately ready. To wait for the mesh to be completely built, you should use the onReady callback option.

    Parameters

    • name: string

      defines the name of the mesh

    • url: string | { data: Uint8Array; height: number; width: number }

      sets the URL of the height map image resource.

    • options: {
          alphaFilter?: number;
          colorFilter?: Color3;
          height?: number;
          maxHeight?: number;
          minHeight?: number;
          onError?: (message?: string, exception?: any) => void;
          onReady?: (
              mesh: GroundMesh,
              heightBuffer?: Float32Array<ArrayBufferLike>,
          ) => void;
          passHeightBufferInCallback?: boolean;
          subdivisions?: number;
          updatable?: boolean;
          width?: number;
      } = {}

      defines the options used to create the mesh

      • width sets the ground width size (positive float, default 10)
      • height sets the ground height size (positive float, default 10)
      • subdivisions sets the number of subdivision per side (positive integer, default 1)
      • minHeight is the minimum altitude on the ground (float, default 0)
      • maxHeight is the maximum altitude on the ground (float, default 1)
      • colorFilter is the filter to apply to the image pixel colors to compute the height (optional Color3, default (0.3, 0.59, 0.11) )
      • alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
      • updatable defines if the mesh must be flagged as updatable
      • onReady is a javascript callback function that will be called once the mesh is just built (the height map download can last some time)
      • onError is a javascript callback function that will be called if there is an error
      • passHeightBufferInCallback a boolean that indicates if the calculated height data will be passed in the onReady callback. Useful if you need the height data for physics, for example.
    • scene: Nullable<Scene> = null

      defines the hosting scene

    Returns GroundMesh

    the ground mesh