@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.
102 lines (101 loc) • 3.55 kB
TypeScript
import type { Scene } from "../scene.js";
import { Vector3 } from "../Maths/math.vector.js";
import { Mesh } from "../Meshes/mesh.js";
/**
* Mesh representing the ground
*/
export declare class GroundMesh extends Mesh {
/** If octree should be generated */
generateOctree: boolean;
private _heightQuads;
/** @internal */
_subdivisionsX: number;
/** @internal */
_subdivisionsY: number;
/** @internal */
_width: number;
/** @internal */
_height: number;
/** @internal */
_minX: number;
/** @internal */
_maxX: number;
/** @internal */
_minZ: number;
/** @internal */
_maxZ: number;
constructor(name: string, scene?: Scene);
/**
* "GroundMesh"
* @returns "GroundMesh"
*/
getClassName(): string;
/**
* The minimum of x and y subdivisions
*/
get subdivisions(): number;
/**
* X subdivisions
*/
get subdivisionsX(): number;
/**
* Y subdivisions
*/
get subdivisionsY(): number;
/**
* This function will divide the mesh into submeshes and update an octree to help to select the right submeshes
* for rendering, picking and collision computations. Please note that you must have a decent number of submeshes
* to get performance improvements when using an octree.
* @param chunksCount the number of submeshes the mesh will be divided into
* @param octreeBlocksSize the maximum size of the octree blocks (Default: 32)
*/
optimize(chunksCount: number, octreeBlocksSize?: number): void;
/**
* Returns a height (y) value in the World system :
* the ground altitude at the coordinates (x, z) expressed in the World system.
* @param x x coordinate
* @param z z coordinate
* @returns the ground y position if (x, z) are outside the ground surface.
*/
getHeightAtCoordinates(x: number, z: number): number;
/**
* Returns a normalized vector (Vector3) orthogonal to the ground
* at the ground coordinates (x, z) expressed in the World system.
* @param x x coordinate
* @param z z coordinate
* @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
*/
getNormalAtCoordinates(x: number, z: number): Vector3;
/**
* Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
* at the ground coordinates (x, z) expressed in the World system.
* Doesn't update the reference Vector3 if (x, z) are outside the ground surface.
* @param x x coordinate
* @param z z coordinate
* @param ref vector to store the result
* @returns the GroundMesh.
*/
getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
/**
* Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
* if the ground has been updated.
* This can be used in the render loop.
* @returns the GroundMesh.
*/
updateCoordinateHeights(): GroundMesh;
private _getFacetAt;
private _initHeightQuads;
private _computeHeightQuads;
/**
* Serializes this ground mesh
* @param serializationObject object to write serialization to
*/
serialize(serializationObject: any): void;
/**
* Parses a serialized ground mesh
* @param parsedMesh the serialized mesh
* @param scene the scene to create the ground mesh in
* @returns the created ground mesh
*/
static Parse(parsedMesh: any, scene: Scene): GroundMesh;
}