Function CreateGroundFromHeightMap
-
CreateGroundFromHeightMap(
name: string,
url: string | { data: Uint8Array; height: number; width: number },
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;
},
scene?: Nullable<Scene>,
): GroundMeshParameters
- 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
widthsets the ground width size (positive float, default 10)heightsets the ground height size (positive float, default 10)subdivisionssets the number of subdivision per side (positive integer, default 1)minHeightis the minimum altitude on the ground (float, default 0)maxHeightis the maximum altitude on the ground (float, default 1)colorFilteris the filter to apply to the image pixel colors to compute the height (optional Color3, default (0.3, 0.59, 0.11) )alphaFilterwill filter any data where the alpha channel is below this value, defaults 0 (all data visible)updatabledefines if the mesh must be flagged as updatableonReadyis a javascript callback function that will be called once the mesh is just built (the height map download can last some time)onErroris a javascript callback function that will be called if there is an errorpassHeightBufferInCallbacka 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
- name: string
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
onReadycallback option.