TerrainMesh.js 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. import defaultValue from "./defaultValue.js";
  2. /**
  3. * A mesh plus related metadata for a single tile of terrain. Instances of this type are
  4. * usually created from raw {@link TerrainData}.
  5. *
  6. * @alias TerrainMesh
  7. * @constructor
  8. *
  9. * @param {Cartesian3} center The center of the tile. Vertex positions are specified relative to this center.
  10. * @param {Float32Array} vertices The vertex data, including positions, texture coordinates, and heights.
  11. * The vertex data is in the order [X, Y, Z, H, U, V], where X, Y, and Z represent
  12. * the Cartesian position of the vertex, H is the height above the ellipsoid, and
  13. * U and V are the texture coordinates.
  14. * @param {Uint8Array|Uint16Array|Uint32Array} indices The indices describing how the vertices are connected to form triangles.
  15. * @param {Number} indexCountWithoutSkirts The index count of the mesh not including skirts.
  16. * @param {Number} vertexCountWithoutSkirts The vertex count of the mesh not including skirts.
  17. * @param {Number} minimumHeight The lowest height in the tile, in meters above the ellipsoid.
  18. * @param {Number} maximumHeight The highest height in the tile, in meters above the ellipsoid.
  19. * @param {BoundingSphere} boundingSphere3D A bounding sphere that completely contains the tile.
  20. * @param {Cartesian3} occludeePointInScaledSpace The occludee point of the tile, represented in ellipsoid-
  21. * scaled space, and used for horizon culling. If this point is below the horizon,
  22. * the tile is considered to be entirely below the horizon.
  23. * @param {Number} [vertexStride=6] The number of components in each vertex.
  24. * @param {OrientedBoundingBox} [orientedBoundingBox] A bounding box that completely contains the tile.
  25. * @param {TerrainEncoding} encoding Information used to decode the mesh.
  26. * @param {Number[]} westIndicesSouthToNorth The indices of the vertices on the Western edge of the tile, ordered from South to North (clockwise).
  27. * @param {Number[]} southIndicesEastToWest The indices of the vertices on the Southern edge of the tile, ordered from East to West (clockwise).
  28. * @param {Number[]} eastIndicesNorthToSouth The indices of the vertices on the Eastern edge of the tile, ordered from North to South (clockwise).
  29. * @param {Number[]} northIndicesWestToEast The indices of the vertices on the Northern edge of the tile, ordered from West to East (clockwise).
  30. *
  31. * @private
  32. */
  33. function TerrainMesh(
  34. center,
  35. vertices,
  36. indices,
  37. indexCountWithoutSkirts,
  38. vertexCountWithoutSkirts,
  39. minimumHeight,
  40. maximumHeight,
  41. boundingSphere3D,
  42. occludeePointInScaledSpace,
  43. vertexStride,
  44. orientedBoundingBox,
  45. encoding,
  46. westIndicesSouthToNorth,
  47. southIndicesEastToWest,
  48. eastIndicesNorthToSouth,
  49. northIndicesWestToEast
  50. ) {
  51. /**
  52. * The center of the tile. Vertex positions are specified relative to this center.
  53. * @type {Cartesian3}
  54. */
  55. this.center = center;
  56. /**
  57. * The vertex data, including positions, texture coordinates, and heights.
  58. * The vertex data is in the order [X, Y, Z, H, U, V], where X, Y, and Z represent
  59. * the Cartesian position of the vertex, H is the height above the ellipsoid, and
  60. * U and V are the texture coordinates. The vertex data may have additional attributes after those
  61. * mentioned above when the {@link TerrainMesh#stride} is greater than 6.
  62. * @type {Float32Array}
  63. */
  64. this.vertices = vertices;
  65. /**
  66. * The number of components in each vertex. Typically this is 6 for the 6 components
  67. * [X, Y, Z, H, U, V], but if each vertex has additional data (such as a vertex normal), this value
  68. * may be higher.
  69. * @type {Number}
  70. */
  71. this.stride = defaultValue(vertexStride, 6);
  72. /**
  73. * The indices describing how the vertices are connected to form triangles.
  74. * @type {Uint8Array|Uint16Array|Uint32Array}
  75. */
  76. this.indices = indices;
  77. /**
  78. * The index count of the mesh not including skirts.
  79. * @type {Number}
  80. */
  81. this.indexCountWithoutSkirts = indexCountWithoutSkirts;
  82. /**
  83. * The vertex count of the mesh not including skirts.
  84. * @type {Number}
  85. */
  86. this.vertexCountWithoutSkirts = vertexCountWithoutSkirts;
  87. /**
  88. * The lowest height in the tile, in meters above the ellipsoid.
  89. * @type {Number}
  90. */
  91. this.minimumHeight = minimumHeight;
  92. /**
  93. * The highest height in the tile, in meters above the ellipsoid.
  94. * @type {Number}
  95. */
  96. this.maximumHeight = maximumHeight;
  97. /**
  98. * A bounding sphere that completely contains the tile.
  99. * @type {BoundingSphere}
  100. */
  101. this.boundingSphere3D = boundingSphere3D;
  102. /**
  103. * The occludee point of the tile, represented in ellipsoid-
  104. * scaled space, and used for horizon culling. If this point is below the horizon,
  105. * the tile is considered to be entirely below the horizon.
  106. * @type {Cartesian3}
  107. */
  108. this.occludeePointInScaledSpace = occludeePointInScaledSpace;
  109. /**
  110. * A bounding box that completely contains the tile.
  111. * @type {OrientedBoundingBox}
  112. */
  113. this.orientedBoundingBox = orientedBoundingBox;
  114. /**
  115. * Information for decoding the mesh vertices.
  116. * @type {TerrainEncoding}
  117. */
  118. this.encoding = encoding;
  119. /**
  120. * The indices of the vertices on the Western edge of the tile, ordered from South to North (clockwise).
  121. * @type {Number[]}
  122. */
  123. this.westIndicesSouthToNorth = westIndicesSouthToNorth;
  124. /**
  125. * The indices of the vertices on the Southern edge of the tile, ordered from East to West (clockwise).
  126. * @type {Number[]}
  127. */
  128. this.southIndicesEastToWest = southIndicesEastToWest;
  129. /**
  130. * The indices of the vertices on the Eastern edge of the tile, ordered from North to South (clockwise).
  131. * @type {Number[]}
  132. */
  133. this.eastIndicesNorthToSouth = eastIndicesNorthToSouth;
  134. /**
  135. * The indices of the vertices on the Northern edge of the tile, ordered from West to East (clockwise).
  136. * @type {Number[]}
  137. */
  138. this.northIndicesWestToEast = northIndicesWestToEast;
  139. }
  140. export default TerrainMesh;