TerrainMesh.js 6.1 KB

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