@cesium/engine 21.0.1 → 22.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (267) hide show
  1. package/Build/ThirdParty/Workers/zip-web-worker.js +10 -7
  2. package/Build/Workers/chunk-23T2IPHV.js +55 -0
  3. package/Build/Workers/{chunk-TGJQMEL4.js → chunk-2AM4E2WD.js} +2 -2
  4. package/Build/Workers/{chunk-4CORGH7N.js → chunk-2MWF4IES.js} +16 -14
  5. package/Build/Workers/{chunk-3RKX3UFI.js → chunk-2RCIRXNI.js} +1 -1
  6. package/Build/Workers/{chunk-LV3G32QE.js → chunk-3YTMGEXW.js} +5 -1424
  7. package/Build/Workers/{chunk-PJAA7QSC.js → chunk-4BHWJWS3.js} +6 -6
  8. package/Build/Workers/{chunk-FE565QHX.js → chunk-5JKH4AMT.js} +2 -2
  9. package/Build/Workers/{chunk-KZ7GDSAJ.js → chunk-6HKAPCSO.js} +1 -1
  10. package/Build/Workers/{chunk-VVALNLSH.js → chunk-A53R2F2L.js} +4 -4
  11. package/Build/Workers/{chunk-KVB73ECP.js → chunk-A6YFUGJO.js} +7 -7
  12. package/Build/Workers/{chunk-QNOIRRJK.js → chunk-AJYWXC6I.js} +4 -4
  13. package/Build/Workers/{chunk-UKA7OISV.js → chunk-AOIO5VUS.js} +282 -2284
  14. package/Build/Workers/{chunk-OBS5EMZ6.js → chunk-B7JRBTT6.js} +10 -10
  15. package/Build/Workers/{chunk-5YXA47QD.js → chunk-CHNDJRYA.js} +20 -18
  16. package/Build/Workers/{chunk-X3ZV3XNO.js → chunk-CJOV55CW.js} +20 -18
  17. package/Build/Workers/{chunk-W6I3LNPF.js → chunk-COGPE5Z2.js} +10 -8
  18. package/Build/Workers/{chunk-2QPH5QDK.js → chunk-CW7W27IZ.js} +14 -10
  19. package/Build/Workers/{chunk-MXOGBWMP.js → chunk-DICY26ID.js} +20 -16
  20. package/Build/Workers/{chunk-W6KMV4F5.js → chunk-DMEFNTUV.js} +69 -7
  21. package/Build/Workers/{chunk-T7HU6E7G.js → chunk-DQSJEOZY.js} +1 -1
  22. package/Build/Workers/{chunk-ASVODZNK.js → chunk-GDU4RZSZ.js} +16 -36
  23. package/Build/Workers/{chunk-MQPDOWGH.js → chunk-GKWOUMYA.js} +1 -1
  24. package/Build/Workers/{chunk-A2SP2EJZ.js → chunk-GTY4K4IA.js} +9 -7
  25. package/Build/Workers/{chunk-KEPPNSBL.js → chunk-H6Q7E4BQ.js} +8 -6
  26. package/Build/Workers/{chunk-JG3C3LPY.js → chunk-HHGOFZVQ.js} +7 -5
  27. package/Build/Workers/chunk-HXKUEOOD.js +352 -0
  28. package/Build/Workers/{chunk-UFSYRVC5.js → chunk-I4REFVXB.js} +4 -4
  29. package/Build/Workers/{chunk-LU7DLY2L.js → chunk-IL5F6WEE.js} +3 -3
  30. package/Build/Workers/{chunk-RVRN4KDB.js → chunk-JKXPC5HD.js} +2 -2
  31. package/Build/Workers/{chunk-CBPNIEGH.js → chunk-KKGD7HAW.js} +13 -11
  32. package/Build/Workers/{chunk-DTKSVIH5.js → chunk-KROSQJUA.js} +2 -2
  33. package/Build/Workers/{chunk-42EJCSIV.js → chunk-L4JLDVCM.js} +5 -5
  34. package/Build/Workers/{chunk-LPKJSIMD.js → chunk-LIYMRHGR.js} +15 -13
  35. package/Build/Workers/{chunk-J2XQVKVH.js → chunk-MKMZHRB3.js} +74 -35
  36. package/Build/Workers/{chunk-CSDYSXBI.js → chunk-MO25ZQ2I.js} +14 -12
  37. package/Build/Workers/{chunk-3YNW5K6O.js → chunk-O6RZEKHZ.js} +12 -12
  38. package/Build/Workers/{chunk-RR3NCT4R.js → chunk-OOCGX2OD.js} +4 -4
  39. package/Build/Workers/{chunk-XG54SG4O.js → chunk-OXFU5HNU.js} +13 -5
  40. package/Build/Workers/{chunk-P2UKEFCK.js → chunk-P5CGIJUY.js} +2 -2
  41. package/Build/Workers/{chunk-DBHL2UVG.js → chunk-QEANVUGT.js} +2 -2
  42. package/Build/Workers/{chunk-2SI7DEW5.js → chunk-QFBCIX7J.js} +8 -6
  43. package/Build/Workers/{chunk-DDXI6UYW.js → chunk-QUAH3XOT.js} +4 -4
  44. package/Build/Workers/{chunk-PZUZCAX3.js → chunk-RXZDTDIY.js} +13 -9
  45. package/Build/Workers/{chunk-YZ3RCE45.js → chunk-SPA2KPH3.js} +14 -12
  46. package/Build/Workers/chunk-TDSVSW5A.js +1460 -0
  47. package/Build/Workers/{chunk-G3CKZ34K.js → chunk-UG2DPFOL.js} +8 -6
  48. package/Build/Workers/{chunk-IKUOV6DO.js → chunk-URGEDZBS.js} +7 -7
  49. package/Build/Workers/{chunk-U2GR5FDL.js → chunk-V35NQOJC.js} +21 -11
  50. package/Build/Workers/chunk-W4XUEDU5.js +2058 -0
  51. package/Build/Workers/chunk-WB4TSSBQ.js +3514 -0
  52. package/Build/Workers/{chunk-EBDZDBJN.js → chunk-WTLYD4FE.js} +19 -15
  53. package/Build/Workers/{chunk-WQZL6CA2.js → chunk-Y4ALZ4SS.js} +9 -7
  54. package/Build/Workers/{chunk-DAJKOQW6.js → chunk-YF2NVO5B.js} +19 -13
  55. package/Build/Workers/{chunk-XJVRYJVZ.js → chunk-YSYSXSHF.js} +1 -1
  56. package/Build/Workers/{chunk-YNOVMSUX.js → chunk-YX562XOB.js} +15 -11
  57. package/Build/Workers/{chunk-J3KPR6DJ.js → chunk-YZWA5B4R.js} +15 -13
  58. package/Build/Workers/{chunk-NYYQZ3LH.js → chunk-Z6DFT4D3.js} +15 -11
  59. package/Build/Workers/combineGeometry.js +24 -21
  60. package/Build/Workers/createBoxGeometry.js +18 -15
  61. package/Build/Workers/createBoxOutlineGeometry.js +16 -13
  62. package/Build/Workers/createCircleGeometry.js +28 -24
  63. package/Build/Workers/createCircleOutlineGeometry.js +21 -17
  64. package/Build/Workers/createCoplanarPolygonGeometry.js +35 -31
  65. package/Build/Workers/createCoplanarPolygonOutlineGeometry.js +33 -29
  66. package/Build/Workers/createCorridorGeometry.js +32 -28
  67. package/Build/Workers/createCorridorOutlineGeometry.js +30 -26
  68. package/Build/Workers/createCylinderGeometry.js +20 -17
  69. package/Build/Workers/createCylinderOutlineGeometry.js +20 -16
  70. package/Build/Workers/createEllipseGeometry.js +28 -24
  71. package/Build/Workers/createEllipseOutlineGeometry.js +21 -17
  72. package/Build/Workers/createEllipsoidGeometry.js +19 -16
  73. package/Build/Workers/createEllipsoidOutlineGeometry.js +18 -15
  74. package/Build/Workers/createFrustumGeometry.js +18 -15
  75. package/Build/Workers/createFrustumOutlineGeometry.js +18 -15
  76. package/Build/Workers/createGeometry.js +28 -22
  77. package/Build/Workers/createGroundPolylineGeometry.js +25 -21
  78. package/Build/Workers/createPlaneGeometry.js +16 -13
  79. package/Build/Workers/createPlaneOutlineGeometry.js +15 -12
  80. package/Build/Workers/createPolygonGeometry.js +35 -31
  81. package/Build/Workers/createPolygonOutlineGeometry.js +32 -28
  82. package/Build/Workers/createPolylineGeometry.js +27 -23
  83. package/Build/Workers/createPolylineVolumeGeometry.js +33 -29
  84. package/Build/Workers/createPolylineVolumeOutlineGeometry.js +29 -25
  85. package/Build/Workers/createRectangleGeometry.js +30 -26
  86. package/Build/Workers/createRectangleOutlineGeometry.js +23 -19
  87. package/Build/Workers/createSimplePolylineGeometry.js +25 -21
  88. package/Build/Workers/createSphereGeometry.js +19 -16
  89. package/Build/Workers/createSphereOutlineGeometry.js +18 -15
  90. package/Build/Workers/createTaskProcessorWorker.js +3 -3
  91. package/Build/Workers/createVectorTileClampedPolylines.js +16 -13
  92. package/Build/Workers/createVectorTileGeometries.js +24 -21
  93. package/Build/Workers/createVectorTilePoints.js +15 -12
  94. package/Build/Workers/createVectorTilePolygons.js +24 -20
  95. package/Build/Workers/createVectorTilePolylines.js +16 -13
  96. package/Build/Workers/createVerticesFromCesium3DTilesTerrain.js +91 -0
  97. package/Build/Workers/createVerticesFromGoogleEarthEnterpriseBuffer.js +28 -23
  98. package/Build/Workers/createVerticesFromHeightmap.js +28 -23
  99. package/Build/Workers/createVerticesFromQuantizedTerrainMesh.js +26 -279
  100. package/Build/Workers/createWallGeometry.js +26 -22
  101. package/Build/Workers/createWallOutlineGeometry.js +25 -21
  102. package/Build/Workers/decodeDraco.js +10 -10
  103. package/Build/Workers/decodeGoogleEarthEnterprisePacket.js +5 -5
  104. package/Build/Workers/decodeI3S.js +13 -11
  105. package/Build/Workers/gaussianSplatSorter.js +4 -4
  106. package/Build/Workers/gaussianSplatTextureGenerator.js +4 -4
  107. package/Build/Workers/incrementallyBuildTerrainPicker.js +121 -0
  108. package/Build/Workers/transcodeKTX2.js +6 -6
  109. package/Build/Workers/transferTypedArrayTest.js +1 -1
  110. package/Build/Workers/upsampleQuantizedTerrainMesh.js +24 -20
  111. package/Build/Workers/upsampleVerticesFromCesium3DTilesTerrain.js +95 -0
  112. package/Source/Core/ArcGISTiledElevationTerrainProvider.js +2 -2
  113. package/Source/Core/AxisAlignedBoundingBox.js +36 -0
  114. package/Source/Core/Cesium3DTilesTerrainData.js +932 -0
  115. package/Source/Core/Cesium3DTilesTerrainGeometryProcessor.js +1868 -0
  116. package/Source/Core/Cesium3DTilesTerrainProvider.js +1052 -0
  117. package/Source/Core/CesiumTerrainProvider.js +2 -2
  118. package/Source/Core/Color.js +23 -6
  119. package/Source/Core/EllipsoidalOccluder.js +2 -2
  120. package/Source/Core/FeatureDetection.js +0 -2
  121. package/Source/Core/GoogleEarthEnterpriseMetadata.js +1 -1
  122. package/Source/Core/GoogleEarthEnterpriseTerrainData.js +2 -1
  123. package/Source/Core/GoogleEarthEnterpriseTerrainProvider.js +1 -1
  124. package/Source/Core/HeightmapTerrainData.js +12 -22
  125. package/Source/Core/HilbertOrder.js +0 -6
  126. package/Source/Core/ITwinPlatform.js +6 -6
  127. package/Source/Core/IntersectionTests.js +80 -0
  128. package/Source/Core/Ion.js +1 -1
  129. package/Source/Core/IonResource.js +35 -27
  130. package/Source/Core/PixelFormat.js +2 -2
  131. package/Source/Core/QuantizedMeshTerrainData.js +24 -57
  132. package/Source/Core/Resource.js +15 -11
  133. package/Source/Core/S2Cell.js +6 -18
  134. package/Source/Core/TaskProcessor.js +1 -1
  135. package/Source/Core/TerrainData.js +2 -1
  136. package/Source/Core/TerrainEncoding.js +215 -38
  137. package/Source/Core/TerrainMesh.js +215 -8
  138. package/Source/Core/TerrainPicker.js +607 -0
  139. package/Source/Core/TerrainProvider.js +151 -0
  140. package/Source/Core/TexturePacker.js +27 -12
  141. package/Source/Core/Transforms.js +28 -19
  142. package/Source/Core/VRTheWorldTerrainProvider.js +2 -2
  143. package/Source/Core/binarySearch.js +1 -1
  144. package/Source/Core/createWorldBathymetryAsync.js +2 -2
  145. package/Source/Core/createWorldTerrainAsync.js +3 -3
  146. package/Source/Core/loadImageFromTypedArray.js +9 -3
  147. package/Source/Core/mergeSort.js +1 -1
  148. package/Source/DataSources/BillboardGraphics.js +1 -1
  149. package/Source/DataSources/BillboardVisualizer.js +7 -4
  150. package/Source/DataSources/PropertyArray.js +2 -2
  151. package/Source/Renderer/AutomaticUniforms.js +61 -0
  152. package/Source/Renderer/Buffer.js +32 -0
  153. package/Source/Renderer/BufferUsage.js +3 -1
  154. package/Source/Renderer/Context.js +98 -14
  155. package/Source/Renderer/Pass.js +10 -9
  156. package/Source/Renderer/Sync.js +104 -0
  157. package/Source/Renderer/TextureAtlas.js +67 -27
  158. package/Source/Renderer/UniformState.js +12 -0
  159. package/Source/Renderer/VertexArray.js +1 -1
  160. package/Source/Scene/ArcGisMapServerImageryProvider.js +1 -1
  161. package/Source/Scene/ArcGisMapService.js +1 -1
  162. package/Source/Scene/Azure2DImageryProvider.js +99 -13
  163. package/Source/Scene/BatchTable.js +2 -2
  164. package/Source/Scene/Billboard.js +75 -28
  165. package/Source/Scene/BillboardCollection.js +24 -15
  166. package/Source/Scene/BillboardTexture.js +56 -7
  167. package/Source/Scene/BingMapsImageryProvider.js +1 -1
  168. package/Source/Scene/BoundingVolumeSemantics.js +54 -62
  169. package/Source/Scene/Cesium3DTile.js +3 -3
  170. package/Source/Scene/Cesium3DTilesVoxelProvider.js +1 -1
  171. package/Source/Scene/Cesium3DTileset.js +1 -1
  172. package/Source/Scene/EdgeFramebuffer.js +245 -0
  173. package/Source/Scene/FrameState.js +12 -0
  174. package/Source/Scene/GaussianSplat3DTileContent.js +12 -16
  175. package/Source/Scene/GaussianSplatPrimitive.js +12 -8
  176. package/Source/Scene/GaussianSplatSorter.js +2 -2
  177. package/Source/Scene/Globe.js +4 -2
  178. package/Source/Scene/GlobeSurfaceTile.js +28 -70
  179. package/Source/Scene/GlobeSurfaceTileProvider.js +11 -0
  180. package/Source/Scene/GltfBufferViewLoader.js +18 -0
  181. package/Source/Scene/GltfLoader.js +46 -8
  182. package/Source/Scene/Google2DImageryProvider.js +48 -41
  183. package/Source/Scene/GoogleEarthEnterpriseMapsProvider.js +1 -1
  184. package/Source/Scene/I3SDataProvider.js +1 -1
  185. package/Source/Scene/I3SDecoder.js +3 -3
  186. package/Source/Scene/ITwinData.js +4 -4
  187. package/Source/Scene/ImageryLayer.js +1 -1
  188. package/Source/Scene/Implicit3DTileContent.js +18 -7
  189. package/Source/Scene/ImplicitSubtree.js +3 -3
  190. package/Source/Scene/ImplicitTileset.js +2 -2
  191. package/Source/Scene/IonImageryProvider.js +15 -84
  192. package/Source/Scene/IonImageryProviderFactory.js +194 -0
  193. package/Source/Scene/LabelCollection.js +54 -36
  194. package/Source/Scene/MetadataComponentType.js +5 -5
  195. package/Source/Scene/MetadataTableProperty.js +3 -9
  196. package/Source/Scene/Model/EdgeDetectionPipelineStage.js +42 -0
  197. package/Source/Scene/Model/EdgeVisibilityPipelineStage.js +800 -0
  198. package/Source/Scene/Model/MetadataPipelineStage.js +7 -7
  199. package/Source/Scene/Model/ModelDrawCommand.js +69 -0
  200. package/Source/Scene/Model/ModelImagery.js +4 -0
  201. package/Source/Scene/Model/ModelRuntimeNode.js +2 -2
  202. package/Source/Scene/Model/ModelRuntimePrimitive.js +13 -2
  203. package/Source/Scene/Model/ModelSceneGraph.js +15 -3
  204. package/Source/Scene/Model/ModelUtility.js +0 -1
  205. package/Source/Scene/Model/NodeRenderResources.js +1 -1
  206. package/Source/Scene/Model/PrimitiveRenderResources.js +1 -1
  207. package/Source/Scene/OIT.js +11 -1
  208. package/Source/Scene/PickFramebuffer.js +134 -50
  209. package/Source/Scene/Picking.js +195 -89
  210. package/Source/Scene/QuadtreePrimitive.js +34 -26
  211. package/Source/Scene/QuadtreeTile.js +66 -46
  212. package/Source/Scene/ResourceLoaderState.js +1 -1
  213. package/Source/Scene/Scene.js +160 -16
  214. package/Source/Scene/ScreenSpaceCameraController.js +1 -1
  215. package/Source/Scene/SensorVolumePortionToDisplay.js +6 -6
  216. package/Source/Scene/SingleTileImageryProvider.js +3 -3
  217. package/Source/Scene/Terrain.js +5 -5
  218. package/Source/Scene/TerrainFillMesh.js +1 -0
  219. package/Source/Scene/TileMapServiceImageryProvider.js +2 -2
  220. package/Source/Scene/UrlTemplateImageryProvider.js +1 -1
  221. package/Source/Scene/View.js +3 -0
  222. package/Source/Scene/VoxelPrimitive.js +196 -189
  223. package/Source/Scene/VoxelShape.js +2 -0
  224. package/Source/Scene/createWorldImageryAsync.js +1 -1
  225. package/Source/Shaders/BillboardCollectionFS.glsl +115 -62
  226. package/Source/Shaders/BillboardCollectionFS.js +115 -63
  227. package/Source/Shaders/BillboardCollectionVS.glsl +44 -37
  228. package/Source/Shaders/BillboardCollectionVS.js +45 -38
  229. package/Source/Shaders/Builtin/Constants/passCesium3DTile.glsl +1 -1
  230. package/Source/Shaders/Builtin/Constants/passCesium3DTile.js +1 -1
  231. package/Source/Shaders/Builtin/Constants/passCesium3DTileClassification.glsl +1 -1
  232. package/Source/Shaders/Builtin/Constants/passCesium3DTileClassification.js +1 -1
  233. package/Source/Shaders/Builtin/Constants/passCesium3DTileClassificationIgnoreShow.glsl +1 -1
  234. package/Source/Shaders/Builtin/Constants/passCesium3DTileClassificationIgnoreShow.js +1 -1
  235. package/Source/Shaders/Builtin/Constants/passCesium3DTileEdges.glsl +10 -0
  236. package/Source/Shaders/Builtin/Constants/passCesium3DTileEdges.js +12 -0
  237. package/Source/Shaders/Builtin/Constants/passGaussianSplats.glsl +1 -1
  238. package/Source/Shaders/Builtin/Constants/passGaussianSplats.js +1 -1
  239. package/Source/Shaders/Builtin/Constants/passOpaque.glsl +1 -1
  240. package/Source/Shaders/Builtin/Constants/passOpaque.js +1 -1
  241. package/Source/Shaders/Builtin/Constants/passOverlay.glsl +1 -1
  242. package/Source/Shaders/Builtin/Constants/passOverlay.js +1 -1
  243. package/Source/Shaders/Builtin/Constants/passTranslucent.glsl +1 -1
  244. package/Source/Shaders/Builtin/Constants/passTranslucent.js +1 -1
  245. package/Source/Shaders/Builtin/Constants/passVoxels.glsl +1 -1
  246. package/Source/Shaders/Builtin/Constants/passVoxels.js +1 -1
  247. package/Source/Shaders/Builtin/CzmBuiltins.js +2 -0
  248. package/Source/Shaders/GlobeVS.glsl +1 -1
  249. package/Source/Shaders/GlobeVS.js +1 -1
  250. package/Source/Shaders/Model/EdgeDetectionStageFS.glsl +58 -0
  251. package/Source/Shaders/Model/EdgeDetectionStageFS.js +60 -0
  252. package/Source/Shaders/Model/EdgeVisibilityStageFS.glsl +83 -0
  253. package/Source/Shaders/Model/EdgeVisibilityStageFS.js +85 -0
  254. package/Source/Shaders/Model/ModelFS.glsl +5 -0
  255. package/Source/Shaders/Model/ModelFS.js +5 -0
  256. package/Source/Shaders/Model/PrimitiveOutlineStageFS.glsl +0 -1
  257. package/Source/Shaders/Model/PrimitiveOutlineStageFS.js +0 -1
  258. package/Source/Shaders/ShadowVolumeAppearanceFS.glsl +7 -15
  259. package/Source/Shaders/ShadowVolumeAppearanceFS.js +7 -15
  260. package/Source/ThirdParty/Workers/zip-web-worker.js +1 -1
  261. package/Source/ThirdParty/zip-module.wasm +0 -0
  262. package/Source/Workers/createVerticesFromCesium3DTilesTerrain.js +46 -0
  263. package/Source/Workers/incrementallyBuildTerrainPicker.js +108 -0
  264. package/Source/Workers/upsampleVerticesFromCesium3DTilesTerrain.js +55 -0
  265. package/index.d.ts +488 -31
  266. package/index.js +202 -190
  267. package/package.json +3 -2
@@ -917,7 +917,7 @@ Resource.prototype.fetchImage = function (options) {
917
917
  this.isBlobUri ||
918
918
  (!this.hasHeaders && !preferBlob)
919
919
  ) {
920
- return fetchImage({
920
+ return this._fetchImage({
921
921
  resource: this,
922
922
  flipY: flipY,
923
923
  skipColorSpaceConversion: skipColorSpaceConversion,
@@ -957,8 +957,7 @@ Resource.prototype.fetchImage = function (options) {
957
957
  url: blobUrl,
958
958
  });
959
959
 
960
- return fetchImage({
961
- resource: generatedBlobResource,
960
+ return generatedBlobResource._fetchImage({
962
961
  flipY: flipY,
963
962
  skipColorSpaceConversion: skipColorSpaceConversion,
964
963
  preferImageBitmap: false,
@@ -997,16 +996,15 @@ Resource.prototype.fetchImage = function (options) {
997
996
 
998
997
  /**
999
998
  * Fetches an image and returns a promise to it.
1000
- *
1001
999
  * @param {object} [options] An object with the following properties.
1002
- * @param {Resource} [options.resource] Resource object that points to an image to fetch.
1003
1000
  * @param {boolean} [options.preferImageBitmap] If true, image will be decoded during fetch and an <code>ImageBitmap</code> is returned.
1004
1001
  * @param {boolean} [options.flipY] If true, image will be vertically flipped during decode. Only applies if the browser supports <code>createImageBitmap</code>.
1005
1002
  * @param {boolean} [options.skipColorSpaceConversion=false] If true, any custom gamma or color profiles in the image will be ignored. Only applies if the browser supports <code>createImageBitmap</code>.
1003
+ * @returns {Promise<ImageBitmap|HTMLImageElement>|undefined} a promise that will resolve to the requested data when loaded. Returns undefined if the request has been throttled and cannot be made at this time.
1006
1004
  * @private
1007
1005
  */
1008
- function fetchImage(options) {
1009
- const resource = options.resource;
1006
+ Resource.prototype._fetchImage = function (options) {
1007
+ const resource = this;
1010
1008
  const flipY = options.flipY;
1011
1009
  const skipColorSpaceConversion = options.skipColorSpaceConversion;
1012
1010
  const preferImageBitmap = options.preferImageBitmap;
@@ -1050,8 +1048,7 @@ function fetchImage(options) {
1050
1048
  request.state = RequestState.UNISSUED;
1051
1049
  request.deferred = undefined;
1052
1050
 
1053
- return fetchImage({
1054
- resource: resource,
1051
+ return resource._fetchImage({
1055
1052
  flipY: flipY,
1056
1053
  skipColorSpaceConversion: skipColorSpaceConversion,
1057
1054
  preferImageBitmap: preferImageBitmap,
@@ -1060,7 +1057,7 @@ function fetchImage(options) {
1060
1057
  return Promise.reject(e);
1061
1058
  });
1062
1059
  });
1063
- }
1060
+ };
1064
1061
 
1065
1062
  /**
1066
1063
  * Creates a Resource and calls fetchImage() on it.
@@ -1962,6 +1959,7 @@ Resource._Implementations.createImage = function (
1962
1959
  flipY,
1963
1960
  skipColorSpaceConversion,
1964
1961
  preferImageBitmap,
1962
+ headers,
1965
1963
  ) {
1966
1964
  const url = request.url;
1967
1965
  // Passing an Image to createImageBitmap will force it to run on the main thread
@@ -1985,7 +1983,7 @@ Resource._Implementations.createImage = function (
1985
1983
  responseType,
1986
1984
  method,
1987
1985
  undefined,
1988
- undefined,
1986
+ headers,
1989
1987
  xhrDeferred,
1990
1988
  undefined,
1991
1989
  undefined,
@@ -2027,6 +2025,12 @@ Resource._Implementations.createImage = function (
2027
2025
  * Wrapper for createImageBitmap
2028
2026
  *
2029
2027
  * @private
2028
+ * @param {Blob} blob The image blob.
2029
+ * @param {object} options An object containing the following properties:
2030
+ * @param {boolean} options.flipY Whether to flip the image Y axis.
2031
+ * @param {boolean} options.premultiplyAlpha Whether to premultiply the alpha channel.
2032
+ * @param {boolean} options.skipColorSpaceConversion Whether to skip color space conversion.
2033
+ * @returns {Promise<ImageBitmap>} A promise that resolves to the created image bitmap.
2030
2034
  */
2031
2035
  Resource.createImageBitmapFromBlob = function (blob, options) {
2032
2036
  Check.defined("options", options);
@@ -1,4 +1,3 @@
1
- /* eslint-disable new-cap */
2
1
  import Cartesian3 from "./Cartesian3.js";
3
2
  import Cartographic from "./Cartographic.js";
4
3
  import Check from "./Check.js";
@@ -209,15 +208,12 @@ S2Cell.isValidId = function (cellId) {
209
208
  }
210
209
 
211
210
  // Check if face bits indicate a valid value, in range [0-5].
212
- // eslint-disable-next-line
213
211
  if (cellId >> BigInt(S2_POSITION_BITS) > 5) {
214
212
  return false;
215
213
  }
216
214
 
217
215
  // Check trailing 1 bit is in one of the even bit positions allowed for the 30 levels, using a bitmask.
218
- // eslint-disable-next-line no-undef
219
216
  const lowestSetBit = cellId & (~cellId + BigInt(1));
220
- // eslint-disable-next-line
221
217
  if (!(lowestSetBit & BigInt("0x1555555555555555"))) {
222
218
  return false;
223
219
  }
@@ -296,14 +292,12 @@ S2Cell.getLevel = function (cellId) {
296
292
  //>>includeEnd('debug');
297
293
 
298
294
  let lsbPosition = 0;
299
- // eslint-disable-next-line
300
295
  while (cellId !== BigInt(0)) {
301
- // eslint-disable-next-line
302
296
  if (cellId & BigInt(1)) {
303
297
  break;
304
298
  }
305
299
  lsbPosition++;
306
- cellId = cellId >> BigInt(1); // eslint-disable-line
300
+ cellId = cellId >> BigInt(1);
307
301
  }
308
302
 
309
303
  // We use (>> 1) because there are 2 bits per level.
@@ -329,10 +323,8 @@ S2Cell.prototype.getChild = function (index) {
329
323
  //>>includeEnd('debug');
330
324
 
331
325
  // Shift sentinel bit 2 positions to the right.
332
- // eslint-disable-next-line no-undef
333
326
  const newLsb = lsb(this._cellId) >> BigInt(2);
334
327
  // Insert child index before the sentinel bit.
335
- // eslint-disable-next-line no-undef
336
328
  const childCellId = this._cellId + BigInt(2 * index + 1 - 4) * newLsb;
337
329
  return new S2Cell(childCellId);
338
330
  };
@@ -350,10 +342,8 @@ S2Cell.prototype.getParent = function () {
350
342
  }
351
343
  //>>includeEnd('debug');
352
344
  // Shift the sentinel bit 2 positions to the left.
353
- // eslint-disable-next-line no-undef
354
345
  const newLsb = lsb(this._cellId) << BigInt(2);
355
346
  // Erase the left over bits to the right of the sentinel bit.
356
- // eslint-disable-next-line no-undef
357
347
  return new S2Cell((this._cellId & (~newLsb + BigInt(1))) | newLsb);
358
348
  };
359
349
 
@@ -455,7 +445,6 @@ S2Cell.fromFacePositionLevel = function (face, position, level) {
455
445
  ).join("0");
456
446
  const positionSuffixPadding = Array(S2_POSITION_BITS - 2 * level).join("0");
457
447
 
458
- // eslint-disable-next-line no-undef
459
448
  const cellId = BigInt(
460
449
  `0b${faceBitString}${positionPrefixPadding}${positionBitString}1${
461
450
  // Adding the sentinel bit that always follows the position bits.
@@ -500,7 +489,7 @@ function convertCellIdToFaceSiTi(cellId, level) {
500
489
  // that represent the parent cell center.
501
490
  const isLeaf = level === 30;
502
491
  const shouldCorrect =
503
- !isLeaf && (BigInt(i) ^ (cellId >> BigInt(2))) & BigInt(1); // eslint-disable-line
492
+ !isLeaf && (BigInt(i) ^ (cellId >> BigInt(2))) & BigInt(1);
504
493
  const correction = isLeaf ? 1 : shouldCorrect ? 2 : 0;
505
494
  const si = (i << 1) + correction;
506
495
  const ti = (j << 1) + correction;
@@ -515,7 +504,6 @@ function convertCellIdToFaceIJ(cellId) {
515
504
  generateLookupTable();
516
505
  }
517
506
 
518
- // eslint-disable-next-line no-undef
519
507
  const face = Number(cellId >> BigInt(S2_POSITION_BITS));
520
508
  let bits = face & S2_SWAP_MASK;
521
509
  const lookupMask = (1 << S2_LOOKUP_BITS) - 1;
@@ -529,7 +517,7 @@ function convertCellIdToFaceIJ(cellId) {
529
517
  const extractMask = (1 << (2 * numberOfBits)) - 1;
530
518
  bits +=
531
519
  Number(
532
- (cellId >> BigInt(k * 2 * S2_LOOKUP_BITS + 1)) & BigInt(extractMask), // eslint-disable-line
520
+ (cellId >> BigInt(k * 2 * S2_LOOKUP_BITS + 1)) & BigInt(extractMask),
533
521
  ) << 2;
534
522
 
535
523
  bits = S2_LOOKUP_IJ[bits];
@@ -715,7 +703,7 @@ function generateLookupTable() {
715
703
  * @private
716
704
  */
717
705
  function lsb(cellId) {
718
- return cellId & (~cellId + BigInt(1)); // eslint-disable-line
706
+ return cellId & (~cellId + BigInt(1));
719
707
  }
720
708
 
721
709
  /**
@@ -723,7 +711,7 @@ function lsb(cellId) {
723
711
  * @private
724
712
  */
725
713
  function lsbForLevel(level) {
726
- return BigInt(1) << BigInt(2 * (S2_MAX_LEVEL - level)); // eslint-disable-line
714
+ return BigInt(1) << BigInt(2 * (S2_MAX_LEVEL - level));
727
715
  }
728
716
 
729
717
  // Lookup table for getting trailing zero bits.
@@ -740,7 +728,7 @@ const Mod67BitPosition = [
740
728
  * @private
741
729
  */
742
730
  function countTrailingZeroBits(x) {
743
- return Mod67BitPosition[(-x & x) % BigInt(67)]; // eslint-disable-line
731
+ return Mod67BitPosition[(-x & x) % BigInt(67)];
744
732
  }
745
733
 
746
734
  export default S2Cell;
@@ -267,7 +267,7 @@ async function scheduleTask(processor, parameters, transferableObjects) {
267
267
  * finished.
268
268
  *
269
269
  * @param {object} parameters Any input data that will be posted to the worker.
270
- * @param {Object[]} [transferableObjects] An array of objects contained in parameters that should be
270
+ * @param {object[]} [transferableObjects] An array of objects contained in parameters that should be
271
271
  * transferred to the worker instead of copied.
272
272
  * @returns {Promise<object>|undefined} Either a promise that will resolve to the result when available, or undefined
273
273
  * if there are too many active tasks,
@@ -10,6 +10,7 @@ import DeveloperError from "./DeveloperError.js";
10
10
  * @see HeightmapTerrainData
11
11
  * @see QuantizedMeshTerrainData
12
12
  * @see GoogleEarthEnterpriseTerrainData
13
+ * @see Cesium3DTilesTerrainData
13
14
  */
14
15
  function TerrainData() {
15
16
  DeveloperError.throwInstantiationError();
@@ -29,7 +30,7 @@ Object.defineProperties(TerrainData.prototype, {
29
30
  * Uint8Array or image where a value of 255 indicates water and a value of 0 indicates land.
30
31
  * Values in between 0 and 255 are allowed as well to smoothly blend between land and water.
31
32
  * @memberof TerrainData.prototype
32
- * @type {Uint8Array|HTMLImageElement|HTMLCanvasElement|undefined}
33
+ * @type {Uint8Array|HTMLImageElement|HTMLCanvasElement|ImageBitmap|undefined}
33
34
  */
34
35
  waterMask: {
35
36
  get: DeveloperError.throwInstantiationError,
@@ -1,6 +1,7 @@
1
1
  import AttributeCompression from "./AttributeCompression.js";
2
2
  import Cartesian2 from "./Cartesian2.js";
3
3
  import Cartesian3 from "./Cartesian3.js";
4
+ import Check from "./Check.js";
4
5
  import ComponentDatatype from "./ComponentDatatype.js";
5
6
  import defined from "./defined.js";
6
7
  import CesiumMath from "./Math.js";
@@ -24,11 +25,11 @@ const SHIFT_LEFT_12 = Math.pow(2.0, 12.0);
24
25
  * @constructor
25
26
  *
26
27
  * @param {Cartesian3} center The center point of the vertices.
27
- * @param {AxisAlignedBoundingBox} axisAlignedBoundingBox The bounds of the tile in the east-north-up coordinates at the tiles center.
28
- * @param {number} minimumHeight The minimum height.
29
- * @param {number} maximumHeight The maximum height.
30
- * @param {Matrix4} fromENU The east-north-up to fixed frame matrix at the center of the terrain mesh.
31
- * @param {boolean} hasVertexNormals If the mesh has vertex normals.
28
+ * @param {AxisAlignedBoundingBox} [axisAlignedBoundingBox] The bounds of the tile in the east-north-up coordinates at the tiles center.
29
+ * @param {number} [minimumHeight] The minimum height.
30
+ * @param {number} [maximumHeight] The maximum height.
31
+ * @param {Matrix4} [fromENU] The east-north-up to fixed frame matrix at the center of the terrain mesh.
32
+ * @param {boolean} [hasVertexNormals=false] If the mesh has vertex normals.
32
33
  * @param {boolean} [hasWebMercatorT=false] true if the terrain data includes a Web Mercator texture coordinate; otherwise, false.
33
34
  * @param {boolean} [hasGeodeticSurfaceNormals=false] true if the terrain data includes geodetic surface normals; otherwise, false.
34
35
  * @param {number} [exaggeration=1.0] A scalar used to exaggerate terrain.
@@ -75,32 +76,36 @@ function TerrainEncoding(
75
76
  quantization = TerrainQuantization.NONE;
76
77
  }
77
78
 
78
- toENU = Matrix4.inverseTransformation(fromENU, new Matrix4());
79
-
80
- const translation = Cartesian3.negate(minimum, cartesian3Scratch);
81
- Matrix4.multiply(
82
- Matrix4.fromTranslation(translation, matrix4Scratch),
83
- toENU,
84
- toENU,
79
+ // Scale and bias from [0,1] to [ENU min, ENU max]
80
+ // Also compute the inverse of the scale and bias
81
+ let st = Matrix4.fromScale(dimensions, matrix4Scratch);
82
+ st = Matrix4.setTranslation(st, minimum, st);
83
+
84
+ let invSt = Matrix4.fromScale(
85
+ Cartesian3.fromElements(
86
+ 1.0 / dimensions.x,
87
+ 1.0 / dimensions.y,
88
+ 1.0 / dimensions.z,
89
+ cartesian3Scratch,
90
+ ),
91
+ matrix4Scratch2,
92
+ );
93
+ invSt = Matrix4.multiplyByTranslation(
94
+ invSt,
95
+ Cartesian3.negate(minimum, cartesian3Scratch),
96
+ invSt,
85
97
  );
86
98
 
87
- const scale = cartesian3Scratch;
88
- scale.x = 1.0 / dimensions.x;
89
- scale.y = 1.0 / dimensions.y;
90
- scale.z = 1.0 / dimensions.z;
91
- Matrix4.multiply(Matrix4.fromScale(scale, matrix4Scratch), toENU, toENU);
92
-
93
- matrix = Matrix4.clone(fromENU);
94
- Matrix4.setTranslation(matrix, Cartesian3.ZERO, matrix);
95
-
96
- fromENU = Matrix4.clone(fromENU, new Matrix4());
99
+ matrix = Matrix4.clone(fromENU, new Matrix4());
100
+ let rtcOffset = Matrix4.getTranslation(fromENU, cartesian3Scratch);
101
+ rtcOffset = Cartesian3.subtract(rtcOffset, center, cartesian3Scratch);
102
+ matrix = Matrix4.setTranslation(matrix, rtcOffset, matrix);
103
+ matrix = Matrix4.multiply(matrix, st, matrix);
97
104
 
98
- const translationMatrix = Matrix4.fromTranslation(minimum, matrix4Scratch);
99
- const scaleMatrix = Matrix4.fromScale(dimensions, matrix4Scratch2);
100
- const st = Matrix4.multiply(translationMatrix, scaleMatrix, matrix4Scratch);
105
+ toENU = Matrix4.inverseTransformation(fromENU, new Matrix4());
106
+ toENU = Matrix4.multiply(invSt, toENU, toENU);
101
107
 
102
- Matrix4.multiply(fromENU, st, fromENU);
103
- Matrix4.multiply(matrix, st, matrix);
108
+ fromENU = Matrix4.multiply(fromENU, st, new Matrix4());
104
109
  }
105
110
 
106
111
  /**
@@ -111,13 +116,13 @@ function TerrainEncoding(
111
116
 
112
117
  /**
113
118
  * The minimum height of the tile including the skirts.
114
- * @type {number}
119
+ * @type {number|undefined}
115
120
  */
116
121
  this.minimumHeight = minimumHeight;
117
122
 
118
123
  /**
119
124
  * The maximum height of the tile.
120
- * @type {number}
125
+ * @type {number|undefined}
121
126
  */
122
127
  this.maximumHeight = maximumHeight;
123
128
 
@@ -130,19 +135,19 @@ function TerrainEncoding(
130
135
  /**
131
136
  * A matrix that takes a vertex from the tile, transforms it to east-north-up at the center and scales
132
137
  * it so each component is in the [0, 1] range.
133
- * @type {Matrix4}
138
+ * @type {Matrix4|undefined}
134
139
  */
135
140
  this.toScaledENU = toENU;
136
141
 
137
142
  /**
138
143
  * A matrix that restores a vertex transformed with toScaledENU back to the earth fixed reference frame
139
- * @type {Matrix4}
144
+ * @type {Matrix4|undefined}
140
145
  */
141
146
  this.fromScaledENU = fromENU;
142
147
 
143
148
  /**
144
149
  * The matrix used to decompress the terrain vertices in the shader for RTE rendering.
145
- * @type {Matrix4}
150
+ * @type {Matrix4|undefined}
146
151
  */
147
152
  this.matrix = matrix;
148
153
 
@@ -150,7 +155,7 @@ function TerrainEncoding(
150
155
  * The terrain mesh contains normals.
151
156
  * @type {boolean}
152
157
  */
153
- this.hasVertexNormals = hasVertexNormals;
158
+ this.hasVertexNormals = hasVertexNormals ?? false;
154
159
 
155
160
  /**
156
161
  * The terrain mesh contains a vertical texture coordinate following the Web Mercator projection.
@@ -188,6 +193,20 @@ function TerrainEncoding(
188
193
  this._calculateStrideAndOffsets();
189
194
  }
190
195
 
196
+ /**
197
+ * Encode information about the terrain at a given position into the vertex buffer.
198
+ * Position, texture coordinates, height, and (optionally) normal, projection information,
199
+ * and geodetic surface normal are all packed into the same buffer.
200
+ *
201
+ * @param {Float32Array} vertexBuffer The buffer to write to.
202
+ * @param {number} bufferIndex The index into the buffer to start writing at.
203
+ * @param {Cartesian3} position The position of the vertex.
204
+ * @param {Cartesian2} uv The texture coordinates of the vertex.
205
+ * @param {number} height The height of the vertex.
206
+ * @param {Cartesian2} [normalToPack] The normal vector of the vertex.
207
+ * @param {number} [webMercatorT] The Web Mercator texture coordinate of the vertex.
208
+ * @param {Cartesian3} [geodeticSurfaceNormal] The geodetic surface normal of the vertex.
209
+ */
191
210
  TerrainEncoding.prototype.encode = function (
192
211
  vertexBuffer,
193
212
  bufferIndex,
@@ -198,6 +217,14 @@ TerrainEncoding.prototype.encode = function (
198
217
  webMercatorT,
199
218
  geodeticSurfaceNormal,
200
219
  ) {
220
+ //>>includeStart('debug', pragmas.debug);
221
+ Check.typeOf.object("vertexBuffer", vertexBuffer);
222
+ Check.typeOf.number("bufferIndex", bufferIndex);
223
+ Check.typeOf.object("position", position);
224
+ Check.typeOf.object("uv", uv);
225
+ Check.typeOf.number("height", height);
226
+ //>>includeEnd('debug');
227
+
201
228
  const u = uv.x;
202
229
  const v = uv.y;
203
230
 
@@ -238,11 +265,9 @@ TerrainEncoding.prototype.encode = function (
238
265
  vertexBuffer[bufferIndex++] = compressed3;
239
266
  }
240
267
  } else {
241
- Cartesian3.subtract(position, this.center, cartesian3Scratch);
242
-
243
- vertexBuffer[bufferIndex++] = cartesian3Scratch.x;
244
- vertexBuffer[bufferIndex++] = cartesian3Scratch.y;
245
- vertexBuffer[bufferIndex++] = cartesian3Scratch.z;
268
+ vertexBuffer[bufferIndex++] = position.x - this.center.x;
269
+ vertexBuffer[bufferIndex++] = position.y - this.center.y;
270
+ vertexBuffer[bufferIndex++] = position.z - this.center.z;
246
271
  vertexBuffer[bufferIndex++] = height;
247
272
  vertexBuffer[bufferIndex++] = u;
248
273
  vertexBuffer[bufferIndex++] = v;
@@ -269,11 +294,25 @@ TerrainEncoding.prototype.encode = function (
269
294
  const scratchPosition = new Cartesian3();
270
295
  const scratchGeodeticSurfaceNormal = new Cartesian3();
271
296
 
297
+ /**
298
+ * Add geodetic surface normals to a terrain vertex buffer.
299
+ * The new buffer will be larger than the old buffer.
300
+ *
301
+ * @param {Float32Array} oldBuffer The buffer without geodetic surface normals.
302
+ * @param {Float32Array} newBuffer The buffer with geodetic surface normals.
303
+ * @param {Ellipsoid} ellipsoid The ellipsoid to use to compute the geodetic surface normals.
304
+ */
272
305
  TerrainEncoding.prototype.addGeodeticSurfaceNormals = function (
273
306
  oldBuffer,
274
307
  newBuffer,
275
308
  ellipsoid,
276
309
  ) {
310
+ //>>includeStart('debug', pragmas.debug);
311
+ Check.typeOf.object("oldBuffer", oldBuffer);
312
+ Check.typeOf.object("newBuffer", newBuffer);
313
+ Check.typeOf.object("ellipsoid", ellipsoid);
314
+ //>>includeEnd('debug');
315
+
277
316
  if (this.hasGeodeticSurfaceNormals) {
278
317
  return;
279
318
  }
@@ -303,10 +342,21 @@ TerrainEncoding.prototype.addGeodeticSurfaceNormals = function (
303
342
  }
304
343
  };
305
344
 
345
+ /**
346
+ * Remove geodetic surface normals from a terrain vertex buffer.
347
+ *
348
+ * @param {Float32Array} oldBuffer The buffer with geodetic surface normals.
349
+ * @param {Float32Array} newBuffer The buffer without geodetic surface normals.
350
+ */
306
351
  TerrainEncoding.prototype.removeGeodeticSurfaceNormals = function (
307
352
  oldBuffer,
308
353
  newBuffer,
309
354
  ) {
355
+ //>>includeStart('debug', pragmas.debug);
356
+ Check.typeOf.object("oldBuffer", oldBuffer);
357
+ Check.typeOf.object("newBuffer", newBuffer);
358
+ //>>includeEnd('debug');
359
+
310
360
  if (!this.hasGeodeticSurfaceNormals) {
311
361
  return;
312
362
  }
@@ -326,7 +376,20 @@ TerrainEncoding.prototype.removeGeodeticSurfaceNormals = function (
326
376
  }
327
377
  };
328
378
 
379
+ /**
380
+ * Decode a position from the vertex buffer.
381
+ *
382
+ * @param {Float32Array} buffer The buffer to decode from.
383
+ * @param {number} index The index of the vertex to decode.
384
+ * @param {Cartesian3} [result] The object to store the result in.
385
+ * @returns {Cartesian3} The decoded position.
386
+ */
329
387
  TerrainEncoding.prototype.decodePosition = function (buffer, index, result) {
388
+ //>>includeStart('debug', pragmas.debug);
389
+ Check.typeOf.object("buffer", buffer);
390
+ Check.typeOf.number("index", index);
391
+ //>>includeEnd('debug');
392
+
330
393
  if (!defined(result)) {
331
394
  result = new Cartesian3();
332
395
  }
@@ -356,6 +419,14 @@ TerrainEncoding.prototype.decodePosition = function (buffer, index, result) {
356
419
  return Cartesian3.add(result, this.center, result);
357
420
  };
358
421
 
422
+ /**
423
+ * Decode a position from the vertex buffer and apply vertical exaggeration.
424
+ *
425
+ * @param {Float32Array} buffer
426
+ * @param {number} index
427
+ * @param {Cartesian3} [result]
428
+ * @returns {Cartesian3} The exaggerated position.
429
+ */
359
430
  TerrainEncoding.prototype.getExaggeratedPosition = function (
360
431
  buffer,
361
432
  index,
@@ -389,11 +460,24 @@ TerrainEncoding.prototype.getExaggeratedPosition = function (
389
460
  return result;
390
461
  };
391
462
 
463
+ /**
464
+ * Decode texture coordinates from the vertex buffer.
465
+ *
466
+ * @param {Float32Array} buffer The buffer to decode from.
467
+ * @param {number} index The index of the vertex to decode.
468
+ * @param {Cartesian2} [result] The object to store the result in.
469
+ * @returns {Cartesian2} The decoded texture coordinates.
470
+ */
392
471
  TerrainEncoding.prototype.decodeTextureCoordinates = function (
393
472
  buffer,
394
473
  index,
395
474
  result,
396
475
  ) {
476
+ //>>includeStart('debug', pragmas.debug);
477
+ Check.typeOf.object("buffer", buffer);
478
+ Check.typeOf.number("index", index);
479
+ //>>includeEnd('debug');
480
+
397
481
  if (!defined(result)) {
398
482
  result = new Cartesian2();
399
483
  }
@@ -410,7 +494,19 @@ TerrainEncoding.prototype.decodeTextureCoordinates = function (
410
494
  return Cartesian2.fromElements(buffer[index + 4], buffer[index + 5], result);
411
495
  };
412
496
 
497
+ /**
498
+ * Decode a height from the vertex buffer.
499
+ *
500
+ * @param {Float32Array} buffer The buffer to decode from.
501
+ * @param {number} index The index of the vertex to decode.
502
+ * @returns {number} The decoded height.
503
+ */
413
504
  TerrainEncoding.prototype.decodeHeight = function (buffer, index) {
505
+ //>>includeStart('debug', pragmas.debug);
506
+ Check.typeOf.object("buffer", buffer);
507
+ Check.typeOf.number("index", index);
508
+ //>>includeEnd('debug');
509
+
414
510
  index *= this.stride;
415
511
 
416
512
  if (this.quantization === TerrainQuantization.BITS12) {
@@ -426,7 +522,19 @@ TerrainEncoding.prototype.decodeHeight = function (buffer, index) {
426
522
  return buffer[index + 3];
427
523
  };
428
524
 
525
+ /**
526
+ * Decode a web mercator T coordinate from the vertex buffer.
527
+ *
528
+ * @param {Float32Array} buffer The buffer to decode from.
529
+ * @param {number} index The index of the vertex to decode.
530
+ * @returns {number} The decoded web mercator T coordinate.
531
+ */
429
532
  TerrainEncoding.prototype.decodeWebMercatorT = function (buffer, index) {
533
+ //>>includeStart('debug', pragmas.debug);
534
+ Check.typeOf.object("buffer", buffer);
535
+ Check.typeOf.number("index", index);
536
+ //>>includeEnd('debug');
537
+
430
538
  index *= this.stride;
431
539
 
432
540
  if (this.quantization === TerrainQuantization.BITS12) {
@@ -439,11 +547,24 @@ TerrainEncoding.prototype.decodeWebMercatorT = function (buffer, index) {
439
547
  return buffer[index + 6];
440
548
  };
441
549
 
550
+ /**
551
+ * Decode an oct-encoded normal from the vertex buffer.
552
+ *
553
+ * @param {Float32Array} buffer The buffer to decode from.
554
+ * @param {number} index The index of the vertex to decode.
555
+ * @param {Cartesian2} [result] The object to store the result in.
556
+ * @returns {Cartesian2} The decoded oct-encoded normal.
557
+ */
442
558
  TerrainEncoding.prototype.getOctEncodedNormal = function (
443
559
  buffer,
444
560
  index,
445
561
  result,
446
562
  ) {
563
+ //>>includeStart('debug', pragmas.debug);
564
+ Check.typeOf.object("buffer", buffer);
565
+ Check.typeOf.number("index", index);
566
+ //>>includeEnd('debug');
567
+
447
568
  index = index * this.stride + this._offsetVertexNormal;
448
569
 
449
570
  const temp = buffer[index] / 256.0;
@@ -453,11 +574,42 @@ TerrainEncoding.prototype.getOctEncodedNormal = function (
453
574
  return Cartesian2.fromElements(x, y, result);
454
575
  };
455
576
 
577
+ /**
578
+ * @param {Float32Array} buffer
579
+ * @param {number} index
580
+ * @param {Cartesian3} result
581
+ * @returns {Cartesian3}
582
+ */
583
+ TerrainEncoding.prototype.decodeNormal = function (buffer, index, result) {
584
+ //>>includeStart('debug', pragmas.debug);
585
+ Check.typeOf.object("buffer", buffer);
586
+ Check.typeOf.number("index", index);
587
+ Check.typeOf.object("result", result);
588
+ //>>includeEnd('debug');
589
+
590
+ const bufferIndex = (index = index * this.stride + this._offsetVertexNormal);
591
+ return AttributeCompression.octDecodeFloat(buffer[bufferIndex], result);
592
+ };
593
+
594
+ /**
595
+ * Decode a geodetic surface normal from the vertex buffer.
596
+ *
597
+ * @param {Float32Array} buffer The buffer to decode from.
598
+ * @param {number} index The index of the vertex to decode.
599
+ * @param {Cartesian3} result The object to store the result in.
600
+ * @returns {Cartesian3} The decoded geodetic surface normal.
601
+ */
456
602
  TerrainEncoding.prototype.decodeGeodeticSurfaceNormal = function (
457
603
  buffer,
458
604
  index,
459
605
  result,
460
606
  ) {
607
+ //>>includeStart('debug', pragmas.debug);
608
+ Check.typeOf.object("buffer", buffer);
609
+ Check.typeOf.number("index", index);
610
+ Check.typeOf.object("result", result);
611
+ //>>includeEnd('debug');
612
+
461
613
  index = index * this.stride + this._offsetGeodeticSurfaceNormal;
462
614
 
463
615
  result.x = buffer[index];
@@ -466,6 +618,9 @@ TerrainEncoding.prototype.decodeGeodeticSurfaceNormal = function (
466
618
  return result;
467
619
  };
468
620
 
621
+ /**
622
+ * Calculate the stride and offsets for sampling the vertex buffer.
623
+ */
469
624
  TerrainEncoding.prototype._calculateStrideAndOffsets = function () {
470
625
  let vertexStride = 0;
471
626
 
@@ -502,7 +657,17 @@ const attributesIndicesBits12 = {
502
657
  geodeticSurfaceNormal: 2,
503
658
  };
504
659
 
660
+ /**
661
+ * Get descriptors of the attributes stored in the vertex buffer.
662
+ *
663
+ * @param {Float32Array} buffer The vertex buffer.
664
+ * @returns {object[]} The attributes.
665
+ */
505
666
  TerrainEncoding.prototype.getAttributes = function (buffer) {
667
+ //>>includeStart('debug', pragmas.debug);
668
+ Check.typeOf.object("buffer", buffer);
669
+ //>>includeEnd('debug');
670
+
506
671
  const datatype = ComponentDatatype.FLOAT;
507
672
  const sizeInBytes = ComponentDatatype.getSizeInBytes(datatype);
508
673
  const strideInBytes = this.stride * sizeInBytes;
@@ -560,6 +725,11 @@ TerrainEncoding.prototype.getAttributes = function (buffer) {
560
725
  return attributes;
561
726
  };
562
727
 
728
+ /**
729
+ * Get indices pointing to the attribute locations in the vertex buffer.
730
+ *
731
+ * @returns {object} The attribute indices.
732
+ */
563
733
  TerrainEncoding.prototype.getAttributeLocations = function () {
564
734
  if (this.quantization === TerrainQuantization.NONE) {
565
735
  return attributesIndicesNone;
@@ -567,6 +737,13 @@ TerrainEncoding.prototype.getAttributeLocations = function () {
567
737
  return attributesIndicesBits12;
568
738
  };
569
739
 
740
+ /**
741
+ * Clones a TerrainEncoding object.
742
+ *
743
+ * @param {TerrainEncoding} [encoding] The encoding to clone.
744
+ * @param {TerrainEncoding} [result] The object to store the cloned encoding.
745
+ * @returns {TerrainEncoding|undefined} The cloned encoding.
746
+ */
570
747
  TerrainEncoding.clone = function (encoding, result) {
571
748
  if (!defined(encoding)) {
572
749
  return undefined;