TerrainMesh.js 6.2 KB

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