groundMesh.d.ts 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. import type { Scene } from "../scene";
  2. import { Vector3 } from "../Maths/math.vector";
  3. import { Mesh } from "../Meshes/mesh";
  4. /**
  5. * Mesh representing the ground
  6. */
  7. export declare class GroundMesh extends Mesh {
  8. /** If octree should be generated */
  9. generateOctree: boolean;
  10. private _heightQuads;
  11. /** @internal */
  12. _subdivisionsX: number;
  13. /** @internal */
  14. _subdivisionsY: number;
  15. /** @internal */
  16. _width: number;
  17. /** @internal */
  18. _height: number;
  19. /** @internal */
  20. _minX: number;
  21. /** @internal */
  22. _maxX: number;
  23. /** @internal */
  24. _minZ: number;
  25. /** @internal */
  26. _maxZ: number;
  27. constructor(name: string, scene?: Scene);
  28. /**
  29. * "GroundMesh"
  30. * @returns "GroundMesh"
  31. */
  32. getClassName(): string;
  33. /**
  34. * The minimum of x and y subdivisions
  35. */
  36. get subdivisions(): number;
  37. /**
  38. * X subdivisions
  39. */
  40. get subdivisionsX(): number;
  41. /**
  42. * Y subdivisions
  43. */
  44. get subdivisionsY(): number;
  45. /**
  46. * This function will divide the mesh into submeshes and update an octree to help to select the right submeshes
  47. * for rendering, picking and collision computations. Please note that you must have a decent number of submeshes
  48. * to get performance improvements when using an octree.
  49. * @param chunksCount the number of submeshes the mesh will be divided into
  50. * @param octreeBlocksSize the maximum size of the octree blocks (Default: 32)
  51. */
  52. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  53. /**
  54. * Returns a height (y) value in the World system :
  55. * the ground altitude at the coordinates (x, z) expressed in the World system.
  56. * @param x x coordinate
  57. * @param z z coordinate
  58. * @returns the ground y position if (x, z) are outside the ground surface.
  59. */
  60. getHeightAtCoordinates(x: number, z: number): number;
  61. /**
  62. * Returns a normalized vector (Vector3) orthogonal to the ground
  63. * at the ground coordinates (x, z) expressed in the World system.
  64. * @param x x coordinate
  65. * @param z z coordinate
  66. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  67. */
  68. getNormalAtCoordinates(x: number, z: number): Vector3;
  69. /**
  70. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  71. * at the ground coordinates (x, z) expressed in the World system.
  72. * Doesn't update the reference Vector3 if (x, z) are outside the ground surface.
  73. * @param x x coordinate
  74. * @param z z coordinate
  75. * @param ref vector to store the result
  76. * @returns the GroundMesh.
  77. */
  78. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  79. /**
  80. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  81. * if the ground has been updated.
  82. * This can be used in the render loop.
  83. * @returns the GroundMesh.
  84. */
  85. updateCoordinateHeights(): GroundMesh;
  86. private _getFacetAt;
  87. private _initHeightQuads;
  88. private _computeHeightQuads;
  89. /**
  90. * Serializes this ground mesh
  91. * @param serializationObject object to write serialization to
  92. */
  93. serialize(serializationObject: any): void;
  94. /**
  95. * Parses a serialized ground mesh
  96. * @param parsedMesh the serialized mesh
  97. * @param scene the scene to create the ground mesh in
  98. * @returns the created ground mesh
  99. */
  100. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  101. }