@babylonjs/core
Version:
Getting started? Play directly with the Babylon.js API using our [playground](https://playground.babylonjs.com/). It also contains a lot of samples to learn how to use it.
184 lines (183 loc) • 8.92 kB
TypeScript
import { type Scene } from "../../scene.js";
import { Color3 } from "../../Maths/math.color.js";
import { Mesh } from "../mesh.js";
import { VertexData } from "../mesh.vertexData.js";
import { GroundMesh } from "../groundMesh.js";
import { type Nullable } from "../../types.js";
/**
* Creates the VertexData for a Ground
* @param options an object used to set the following optional parameters for the Ground, required but can be empty
* - `width` the width (x direction) of the ground, optional, default 1
* - `height` the height (z direction) of the ground, optional, default 1
* - `subdivisions` the number of subdivisions per side, optional, default 1
* - `subdivisionsX` the number of subdivisions in the x direction, overrides options.subdivisions, optional, default undefined
* - `subdivisionsY` the number of subdivisions in the y direction, overrides options.subdivisions, optional, default undefined
* @returns the VertexData of the Ground
*/
export declare function CreateGroundVertexData(options: {
size?: number;
width?: number;
height?: number;
subdivisions?: number;
subdivisionsX?: number;
subdivisionsY?: number;
}): VertexData;
/**
* Creates the VertexData for a TiledGround by subdividing the ground into tiles
* @param options an object used to set the following optional parameters for the Ground
* - `xmin` ground minimum X coordinate, default -1
* - `zmin` ground minimum Z coordinate, default -1
* - `xmax` ground maximum X coordinate, default 1
* - `zmax` ground maximum Z coordinate, default 1
* - `subdivisions` a javascript object `\{w: positive integer, h: positive integer\}`, `w` and `h` are the numbers of subdivisions on the ground width and height creating 'tiles', default `\{w: 6, h: 6\}`
* - `precision` a javascript object `\{w: positive integer, h: positive integer\}`, `w` and `h` are the numbers of subdivisions on the tile width and height, default `\{w: 2, h: 2\}`
* @returns the VertexData of the TiledGround
*/
export declare function CreateTiledGroundVertexData(options: {
xmin: number;
zmin: number;
xmax: number;
zmax: number;
subdivisions?: {
w: number;
h: number;
};
precision?: {
w: number;
h: number;
};
}): VertexData;
/**
* Creates the VertexData of the Ground designed from a heightmap
* @param options an object used to set the following parameters for the Ground, required and provided by CreateGroundFromHeightMap
* - `width` the width (x direction) of the ground
* - `height` the height (z direction) of the ground
* - `subdivisions` the number of subdivisions per side
* - `minHeight` the minimum altitude on the ground, optional, default 0
* - `maxHeight` the maximum altitude on the ground, optional default 1
* - `colorFilter` the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
* - `buffer` the array holding the image color data
* - `bufferWidth` the width of image
* - `bufferHeight` the height of image
* - `alphaFilter` Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
* - `heightBuffer` a array of floats where the height data can be saved, if its length is greater than zero.
* @returns the VertexData of the Ground designed from a heightmap
*/
export declare function CreateGroundFromHeightMapVertexData(options: {
width: number;
height: number;
subdivisions: number;
minHeight: number;
maxHeight: number;
colorFilter: Color3;
buffer: Uint8Array;
bufferWidth: number;
bufferHeight: number;
alphaFilter: number;
heightBuffer?: Float32Array;
}): VertexData;
/**
* Creates a ground mesh
* @param name defines the name of the mesh
* @param options defines the options used to create the mesh
* - `width` set the width size (float, default 1)
* - `height` set the height size (float, default 1)
* - `subdivisions` sets the number of subdivision per side (default 1)
* - `subdivisionsX` sets the number of subdivision on the X axis (overrides subdivisions)
* - `subdivisionsY` sets the number of subdivision on the Y axis (overrides subdivisions)
* - `updatable` defines if the mesh must be flagged as updatable (default false)
* @param scene defines the hosting scene
* @returns the ground mesh
* @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/set#ground
*/
export declare function CreateGround(name: string, options?: {
width?: number;
height?: number;
subdivisions?: number;
subdivisionsX?: number;
subdivisionsY?: number;
updatable?: boolean;
}, scene?: Scene): GroundMesh;
/**
* Creates a tiled ground mesh
* @param name defines the name of the mesh
* @param options defines the options used to create the mesh
* - `xmin` ground minimum X coordinate (float, default -1)
* - `zmin` ground minimum Z coordinate (float, default -1)
* - `xmax` ground maximum X coordinate (float, default 1)
* - `zmax` ground maximum Z coordinate (float, default 1)
* - `subdivisions` a javascript object `{w: positive integer, h: positive integer}` (default `{w: 6, h: 6}`). `w` and `h` are the numbers of subdivisions on the ground width and height. Each subdivision is called a tile
* - `subdivisions.w` positive integer, default 6
* - `subdivisions.h` positive integer, default 6
* - `precision` a javascript object `{w: positive integer, h: positive integer}` (default `{w: 2, h: 2}`). `w` and `h` are the numbers of subdivisions on the ground width and height of each tile
* - `precision.w` positive integer, default 2
* - `precision.h` positive integer, default 2
* - `updatable` boolean, default false, true if the mesh must be flagged as updatable
* @param scene defines the hosting scene
* @returns the tiled ground mesh
* @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/set#tiled-ground
*/
export declare function CreateTiledGround(name: string, options: {
xmin: number;
zmin: number;
xmax: number;
zmax: number;
subdivisions?: {
w: number;
h: number;
};
precision?: {
w: number;
h: number;
};
updatable?: boolean;
}, scene?: Nullable<Scene>): Mesh;
/**
* 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.
* @param name defines the name of the mesh
* @param url sets the URL of the height map image resource.
* @param options 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.
* @param scene defines the hosting scene
* @returns the ground mesh
* @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/set/height_map
* @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/set#ground-from-a-height-map
*/
export declare function CreateGroundFromHeightMap(name: string, url: string | {
data: Uint8Array;
width: number;
height: number;
}, options?: {
width?: number;
height?: number;
subdivisions?: number;
minHeight?: number;
maxHeight?: number;
colorFilter?: Color3;
alphaFilter?: number;
updatable?: boolean;
onReady?: (mesh: GroundMesh, heightBuffer?: Float32Array) => void;
onError?: (message?: string, exception?: any) => void;
passHeightBufferInCallback?: boolean;
}, scene?: Nullable<Scene>): GroundMesh;
/**
* Class containing static functions to help procedurally build meshes
* @deprecated use the functions directly from the module
*/
export declare const GroundBuilder: {
CreateGround: typeof CreateGround;
CreateGroundFromHeightMap: typeof CreateGroundFromHeightMap;
CreateTiledGround: typeof CreateTiledGround;
};