@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
@@ -1,3 +1,4 @@
1
+ import Buffer from "./Buffer.js";
1
2
  import Check from "../Core/Check.js";
2
3
  import Color from "../Core/Color.js";
3
4
  import ComponentDatatype from "../Core/ComponentDatatype.js";
@@ -356,7 +357,7 @@ function Context(canvas, options) {
356
357
  this._vertexAttribDivisors.push(0);
357
358
  }
358
359
 
359
- this._pickObjects = {};
360
+ this._pickObjects = new Map();
360
361
  this._nextPickColor = new Uint32Array(1);
361
362
 
362
363
  /**
@@ -1442,13 +1443,88 @@ Context.prototype.endFrame = function () {
1442
1443
  };
1443
1444
 
1444
1445
  /**
1446
+ * @typedef {object} ReadState
1447
+ *
1448
+ * Options defining a rectangle to read pixels from.
1449
+ *
1450
+ * @private
1451
+ * @property {number} [x=0] The x offset of the rectangle to read from.
1452
+ * @property {number} [y=0] The y offset of the rectangle to read from.
1453
+ * @property {number} [width=this.drawingBufferWidth] The width of the rectangle to read from.
1454
+ * @property {number} [height=this.drawingBufferHeight] The height of the rectangle to read from.
1455
+ * @property {FrameBuffer|undefined} [framebuffer] The framebuffer to read from. If undefined, the read will be from the default framebuffer.
1456
+ */
1457
+
1458
+ /**
1459
+ * Read pixels from a framebuffer into a Pixel Buffer Object (PBO).
1460
+ *
1445
1461
  * @private
1446
- * @param {object} readState An object with the following properties:
1447
- * @param {number} [readState.x=0] The x offset of the rectangle to read from.
1448
- * @param {number} [readState.y=0] The y offset of the rectangle to read from.
1449
- * @param {number} [readState.width=this.drawingBufferWidth] The width of the rectangle to read from.
1450
- * @param {number} [readState.height=this.drawingBufferHeight] The height of the rectangle to read from.
1451
- * @param {Framebuffer} [readState.framebuffer] The framebuffer to read from. If undefined, the read will be from the default framebuffer.
1462
+ * @param {ReadState} readState Options defining a rectangle to read pixels from.
1463
+ * @returns {Buffer} A PixelBuffer containing the pixels read from the specified rectangle.
1464
+ *
1465
+ * @exception {DeveloperError} A WebGL 2 context is required to read pixels using a PBO.
1466
+ */
1467
+ Context.prototype.readPixelsToPBO = function (readState) {
1468
+ const gl = this._gl;
1469
+
1470
+ readState = readState ?? Frozen.EMPTY_OBJECT;
1471
+ const x = Math.max(readState.x ?? 0, 0);
1472
+ const y = Math.max(readState.y ?? 0, 0);
1473
+ const width = readState.width ?? this.drawingBufferWidth;
1474
+ const height = readState.height ?? this.drawingBufferHeight;
1475
+ const framebuffer = readState.framebuffer;
1476
+
1477
+ if (!this._webgl2) {
1478
+ throw new DeveloperError(
1479
+ "A WebGL 2 context is required to read pixels using a PBO.",
1480
+ );
1481
+ }
1482
+
1483
+ //>>includeStart('debug', pragmas.debug);
1484
+ Check.typeOf.number.greaterThan("readState.width", width, 0);
1485
+ Check.typeOf.number.greaterThan("readState.height", height, 0);
1486
+ //>>includeEnd('debug');
1487
+
1488
+ let pixelDatatype = PixelDatatype.UNSIGNED_BYTE;
1489
+ let pixelFormat = PixelFormat.RGBA;
1490
+ if (defined(framebuffer) && framebuffer.numberOfColorAttachments > 0) {
1491
+ pixelDatatype = framebuffer.getColorTexture(0).pixelDatatype;
1492
+ pixelFormat = framebuffer.getColorTexture(0).pixelFormat;
1493
+ }
1494
+
1495
+ const pixels = Buffer.createPixelBuffer({
1496
+ context: this,
1497
+ sizeInBytes: PixelFormat.textureSizeInBytes(
1498
+ pixelFormat,
1499
+ pixelDatatype,
1500
+ width,
1501
+ height,
1502
+ ),
1503
+ usage: BufferUsage.DYNAMIC_READ,
1504
+ });
1505
+
1506
+ bindFramebuffer(this, framebuffer);
1507
+
1508
+ pixels._bind();
1509
+ gl.readPixels(
1510
+ x,
1511
+ y,
1512
+ width,
1513
+ height,
1514
+ pixelFormat,
1515
+ PixelDatatype.toWebGLConstant(pixelDatatype, this),
1516
+ 0,
1517
+ );
1518
+ pixels._unBind();
1519
+
1520
+ return pixels;
1521
+ };
1522
+
1523
+ /**
1524
+ * Read pixels from a framebuffer into a typed array.
1525
+ *
1526
+ * @private
1527
+ * @param {ReadState} readState Options defining a rectangle to read pixels from.
1452
1528
  * @returns {Uint8Array|Uint16Array|Float32Array|Uint32Array} The pixels in the specified rectangle.
1453
1529
  */
1454
1530
  Context.prototype.readPixels = function (readState) {
@@ -1467,12 +1543,14 @@ Context.prototype.readPixels = function (readState) {
1467
1543
  //>>includeEnd('debug');
1468
1544
 
1469
1545
  let pixelDatatype = PixelDatatype.UNSIGNED_BYTE;
1546
+ let pixelFormat = PixelFormat.RGBA;
1470
1547
  if (defined(framebuffer) && framebuffer.numberOfColorAttachments > 0) {
1471
1548
  pixelDatatype = framebuffer.getColorTexture(0).pixelDatatype;
1549
+ pixelFormat = framebuffer.getColorTexture(0).pixelFormat;
1472
1550
  }
1473
1551
 
1474
1552
  const pixels = PixelFormat.createTypedArray(
1475
- PixelFormat.RGBA,
1553
+ pixelFormat,
1476
1554
  pixelDatatype,
1477
1555
  width,
1478
1556
  height,
@@ -1562,7 +1640,7 @@ Context.prototype.createViewportQuadCommand = function (
1562
1640
  /**
1563
1641
  * Gets the object associated with a pick color.
1564
1642
  *
1565
- * @param {Color} pickColor The pick color.
1643
+ * @param {number} pickColor The unsigned 32-bit RGBA pick color
1566
1644
  * @returns {object} The object associated with the pick color, or undefined if no object is associated with that color.
1567
1645
  *
1568
1646
  * @example
@@ -1575,9 +1653,15 @@ Context.prototype.getObjectByPickColor = function (pickColor) {
1575
1653
  Check.defined("pickColor", pickColor);
1576
1654
  //>>includeEnd('debug');
1577
1655
 
1578
- return this._pickObjects[pickColor.toRgba()];
1656
+ return this._pickObjects.get(pickColor);
1579
1657
  };
1580
1658
 
1659
+ /**
1660
+ *
1661
+ * @param {Map<number, object>} pickObjects
1662
+ * @param {number} key
1663
+ * @param {Color} color
1664
+ */
1581
1665
  function PickId(pickObjects, key, color) {
1582
1666
  this._pickObjects = pickObjects;
1583
1667
  this.key = key;
@@ -1587,16 +1671,16 @@ function PickId(pickObjects, key, color) {
1587
1671
  Object.defineProperties(PickId.prototype, {
1588
1672
  object: {
1589
1673
  get: function () {
1590
- return this._pickObjects[this.key];
1674
+ return this._pickObjects.get(this.key);
1591
1675
  },
1592
1676
  set: function (value) {
1593
- this._pickObjects[this.key] = value;
1677
+ this._pickObjects.set(this.key, value);
1594
1678
  },
1595
1679
  },
1596
1680
  });
1597
1681
 
1598
1682
  PickId.prototype.destroy = function () {
1599
- delete this._pickObjects[this.key];
1683
+ this._pickObjects.delete(this.key);
1600
1684
  return undefined;
1601
1685
  };
1602
1686
 
@@ -1633,7 +1717,7 @@ Context.prototype.createPickId = function (object) {
1633
1717
  throw new RuntimeError("Out of unique Pick IDs.");
1634
1718
  }
1635
1719
 
1636
- this._pickObjects[key] = object;
1720
+ this._pickObjects.set(key, object);
1637
1721
  return new PickId(this._pickObjects, key, Color.fromRgba(key));
1638
1722
  };
1639
1723
 
@@ -15,14 +15,15 @@ const Pass = {
15
15
  COMPUTE: 1,
16
16
  GLOBE: 2,
17
17
  TERRAIN_CLASSIFICATION: 3,
18
- CESIUM_3D_TILE: 4,
19
- CESIUM_3D_TILE_CLASSIFICATION: 5,
20
- CESIUM_3D_TILE_CLASSIFICATION_IGNORE_SHOW: 6,
21
- OPAQUE: 7,
22
- TRANSLUCENT: 8,
23
- VOXELS: 9,
24
- GAUSSIAN_SPLATS: 10,
25
- OVERLAY: 11,
26
- NUMBER_OF_PASSES: 12,
18
+ CESIUM_3D_TILE_EDGES: 4,
19
+ CESIUM_3D_TILE: 5,
20
+ CESIUM_3D_TILE_CLASSIFICATION: 6,
21
+ CESIUM_3D_TILE_CLASSIFICATION_IGNORE_SHOW: 7,
22
+ OPAQUE: 8,
23
+ TRANSLUCENT: 9,
24
+ VOXELS: 10,
25
+ GAUSSIAN_SPLATS: 11,
26
+ OVERLAY: 12,
27
+ NUMBER_OF_PASSES: 13,
27
28
  };
28
29
  export default Object.freeze(Pass);
@@ -0,0 +1,104 @@
1
+ import Check from "../Core/Check.js";
2
+ import destroyObject from "../Core/destroyObject.js";
3
+ import DeveloperError from "../Core/DeveloperError.js";
4
+ import Frozen from "../Core/Frozen.js";
5
+ import RuntimeError from "../Core/RuntimeError.js";
6
+ import WebGLConstants from "../Core/WebGLConstants.js";
7
+
8
+ /**
9
+ * The WebGLSync interface is part of the WebGL 2 API and is used to synchronize activities between the GPU and the application.
10
+ *
11
+ * @param {object} options Object with the following properties:
12
+ * @param {Context} context
13
+ *
14
+ * @exception {DeveloperError} A WebGL 2 context is required to use Sync operations.
15
+ *
16
+ * @private
17
+ * @constructor
18
+ */
19
+ function Sync(options) {
20
+ options = options ?? Frozen.EMPTY_OBJECT;
21
+ const context = options.context;
22
+
23
+ //>>includeStart('debug', pragmas.debug);
24
+ Check.defined("options.context", context);
25
+ //>>includeEnd('debug');
26
+
27
+ if (!context._webgl2) {
28
+ throw new DeveloperError(
29
+ "A WebGL 2 context is required to use Sync operations.",
30
+ );
31
+ }
32
+
33
+ const gl = context._gl;
34
+ const sync = gl.fenceSync(WebGLConstants.SYNC_GPU_COMMANDS_COMPLETE, 0);
35
+
36
+ this._gl = gl;
37
+ this._sync = sync;
38
+ }
39
+ Sync.create = function (options) {
40
+ return new Sync(options);
41
+ };
42
+ /**
43
+ * Query the sync status of this Sync object.
44
+ *
45
+ * @returns {number} Returns a WebGLConstants indicating the status of the sync object (WebGLConstants.SIGNALED or WebGLConstants.UNSIGNALED).
46
+ *
47
+ * @private
48
+ */
49
+ Sync.prototype.getStatus = function () {
50
+ const status = this._gl.getSyncParameter(
51
+ this._sync,
52
+ WebGLConstants.SYNC_STATUS,
53
+ );
54
+ return status;
55
+ };
56
+ Sync.prototype.isDestroyed = function () {
57
+ return false;
58
+ };
59
+ Sync.prototype.destroy = function () {
60
+ this._gl.deleteSync(this._sync);
61
+ return destroyObject(this);
62
+ };
63
+
64
+ /**
65
+ * Incremantally polls the status of the Sync object until signaled then resolves.
66
+ * Usually polling should be done once per frame.
67
+ *
68
+ * @example
69
+ * try {
70
+ * await sync.waitForSignal(function (next) {
71
+ * setTimeout(next, 100);
72
+ * });
73
+ *} catch (e) {
74
+ * throw "Signal timeout";
75
+ *} finally {
76
+ * sync.destroy();
77
+ *}
78
+ *
79
+ * @param {function} scheduleFunction Function for scheduling the next poll. Receives a callback as its only parameter.
80
+ * @param {number} [ttl=10] Max number of iterations to poll until timeout.
81
+ *
82
+ * @exception {RuntimeError} Wait for signal timeout.
83
+ */
84
+ Sync.prototype.waitForSignal = async function (scheduleFunction, ttl) {
85
+ const self = this;
86
+ ttl = ttl ?? 10;
87
+ function waitForSignal0(resolve, reject, ttl) {
88
+ return () => {
89
+ const syncStatus = self.getStatus();
90
+ const signaled = syncStatus === WebGLConstants.SIGNALED;
91
+ if (signaled) {
92
+ resolve();
93
+ } else if (ttl <= 0) {
94
+ reject(new RuntimeError("Wait for signal timeout"));
95
+ } else {
96
+ scheduleFunction(waitForSignal0(resolve, reject, ttl - 1));
97
+ }
98
+ };
99
+ }
100
+ return new Promise((resolve, reject) => {
101
+ scheduleFunction(waitForSignal0(resolve, reject, ttl));
102
+ });
103
+ };
104
+ export default Sync;
@@ -59,12 +59,16 @@ function TextureAtlas(options) {
59
59
  this._initialSize = initialSize;
60
60
 
61
61
  this._texturePacker = undefined;
62
+ /** @type {BoundingRectangle[]} */
62
63
  this._rectangles = [];
64
+ /** @type {Map<number, number>} */
63
65
  this._subRegions = new Map();
64
66
  this._guid = createGuid();
65
67
 
66
68
  this._imagesToAddQueue = [];
69
+ /** @type {Map<string, number>} */
67
70
  this._indexById = new Map();
71
+ /** @type {Map<string, Promise<number>>} */
68
72
  this._indexPromiseById = new Map();
69
73
  this._nextIndex = 0;
70
74
  }
@@ -644,34 +648,51 @@ async function resolveImage(image, id) {
644
648
  * @param {string} id An identifier to detect whether the image already exists in the atlas.
645
649
  * @param {HTMLImageElement|HTMLCanvasElement|string|Resource|Promise|TextureAtlas.CreateImageCallback} image An image or canvas to add to the texture atlas,
646
650
  * or a URL to an Image, or a Promise for an image, or a function that creates an image.
647
- * @returns {Promise<number>} A Promise that resolves to the image region index. -1 is returned if resouces are in the process of being destroyed.
651
+ * @param {number} width A number specifying the width of the texture. If undefined, the image width will be used.
652
+ * @param {number} height A number specifying the height of the texture. If undefined, the image height will be used.
653
+ * @returns {Promise<number>} A Promise that resolves to the image region index, or -1 if resources are in the process of being destroyed.
648
654
  */
649
- TextureAtlas.prototype.addImage = function (id, image) {
655
+ TextureAtlas.prototype.addImage = function (id, image, width, height) {
650
656
  //>>includeStart('debug', pragmas.debug);
651
657
  Check.typeOf.string("id", id);
652
658
  Check.defined("image", image);
653
659
  //>>includeEnd('debug');
654
660
 
655
661
  let promise = this._indexPromiseById.get(id);
662
+ let index = this._indexById.get(id);
656
663
  if (defined(promise)) {
657
- // This image has already been added
664
+ // This image is already being added
658
665
  return promise;
659
666
  }
667
+ if (defined(index)) {
668
+ // This image has already been added and resolved
669
+ return Promise.resolve(index);
670
+ }
660
671
 
661
- const index = this._nextIndex++;
672
+ index = this._nextIndex++;
662
673
  this._indexById.set(id, index);
663
674
 
664
675
  const resolveAndAddImage = async () => {
665
- image = await resolveImage(image, id);
676
+ const resolvedImage = await resolveImage(image, id);
666
677
  //>>includeStart('debug', pragmas.debug);
667
- Check.defined("image", image);
678
+ Check.defined("image", resolvedImage);
668
679
  //>>includeEnd('debug');
669
680
 
670
- if (this.isDestroyed() || !defined(image)) {
681
+ if (this.isDestroyed() || !defined(resolvedImage)) {
682
+ this._indexPromiseById.delete(id);
671
683
  return -1;
672
684
  }
673
685
 
674
- return this._addImage(index, image);
686
+ if (defined(width)) {
687
+ resolvedImage.width = width;
688
+ }
689
+ if (defined(height)) {
690
+ resolvedImage.height = height;
691
+ }
692
+
693
+ const imageIndex = await this._addImage(index, resolvedImage);
694
+ this._indexPromiseById.delete(id);
695
+ return imageIndex;
675
696
  };
676
697
 
677
698
  promise = resolveAndAddImage();
@@ -679,46 +700,65 @@ TextureAtlas.prototype.addImage = function (id, image) {
679
700
  return promise;
680
701
  };
681
702
 
703
+ /**
704
+ * Get an existing sub-region of an existing atlas image as additional image indices.
705
+ * @private
706
+ * @param {string} id The identifier of the existing image.
707
+ * @param {BoundingRectangle} subRegion An {@link BoundingRectangle} defining a region of an existing image, measured in pixels from the bottom-left of the image.
708
+ * @param {number} imageIndex The index of the image.
709
+ * @returns {Promise<number> | number | undefined} The existing subRegion index, or undefined if not yet added.
710
+ */
711
+ TextureAtlas.prototype.getCachedImageSubRegion = function (
712
+ id,
713
+ subRegion,
714
+ imageIndex,
715
+ ) {
716
+ const imagePromise = this._indexPromiseById.get(id);
717
+ for (const [index, parentIndex] of this._subRegions.entries()) {
718
+ if (imageIndex === parentIndex) {
719
+ const boundingRegion = this._rectangles[index];
720
+ if (boundingRegion.equals(subRegion)) {
721
+ // The subregion is already being tracked
722
+ if (imagePromise) {
723
+ return imagePromise.then((resolvedImageIndex) =>
724
+ resolvedImageIndex === -1 ? -1 : index,
725
+ );
726
+ }
727
+ return index;
728
+ }
729
+ }
730
+ }
731
+ };
732
+
682
733
  /**
683
734
  * Add a sub-region of an existing atlas image as additional image indices.
684
735
  * @private
685
736
  * @param {string} id The identifier of the existing image.
686
737
  * @param {BoundingRectangle} subRegion An {@link BoundingRectangle} defining a region of an existing image, measured in pixels from the bottom-left of the image.
687
- * @returns {Promise<number>} A Promise that resolves to the image region index. -1 is returned if resouces are in the process of being destroyed.
738
+ * @returns {number | Promise<number>} The resolved image region index, or a Promise that resolves to it. -1 is returned if resources are in the process of being destroyed.
688
739
  */
689
740
  TextureAtlas.prototype.addImageSubRegion = function (id, subRegion) {
690
741
  //>>includeStart('debug', pragmas.debug);
691
742
  Check.typeOf.string("id", id);
692
743
  Check.defined("subRegion", subRegion);
693
744
  //>>includeEnd('debug');
694
-
695
745
  const imageIndex = this._indexById.get(id);
696
746
  if (!defined(imageIndex)) {
697
747
  throw new RuntimeError(`image with id "${id}" not found in the atlas.`);
698
748
  }
699
749
 
700
- const indexPromise = this._indexPromiseById.get(id);
701
- for (const [index, parentIndex] of this._subRegions.entries()) {
702
- if (imageIndex === parentIndex) {
703
- const boundingRegion = this._rectangles[index];
704
- if (boundingRegion.equals(subRegion)) {
705
- // The subregion is already being tracked
706
- return indexPromise.then((resolvedImageIndex) => {
707
- if (resolvedImageIndex === -1) {
708
- // The atlas has been destroyed
709
- return -1;
710
- }
711
-
712
- return index;
713
- });
714
- }
715
- }
750
+ let index = this.getCachedImageSubRegion(id, subRegion, imageIndex);
751
+ if (defined(index)) {
752
+ return index;
716
753
  }
717
754
 
718
- const index = this._nextIndex++;
755
+ index = this._nextIndex++;
719
756
  this._subRegions.set(index, imageIndex);
720
757
  this._rectangles[index] = subRegion.clone();
721
758
 
759
+ const indexPromise =
760
+ this._indexPromiseById.get(id) ?? Promise.resolve(imageIndex);
761
+
722
762
  return indexPromise.then((imageIndex) => {
723
763
  if (imageIndex === -1) {
724
764
  // The atlas has been destroyed
@@ -25,6 +25,18 @@ function UniformState() {
25
25
  * @type {Texture}
26
26
  */
27
27
  this.globeDepthTexture = undefined;
28
+ /**
29
+ * @type {Texture}
30
+ */
31
+ this.edgeIdTexture = undefined;
32
+ /**
33
+ * @type {Texture}
34
+ */
35
+ this.edgeColorTexture = undefined;
36
+ /**
37
+ * @type {Texture}
38
+ */
39
+ this.edgeDepthTexture = undefined; // packed depth color attachment from edge pass
28
40
  /**
29
41
  * @type {number}
30
42
  */
@@ -178,7 +178,7 @@ function bind(gl, attributes, indexBuffer) {
178
178
  *
179
179
  * @param {object} options Object with the following properties:
180
180
  * @param {Context} options.context The context in which the VertexArray gets created.
181
- * @param {Object[]} options.attributes An array of attributes.
181
+ * @param {object[]} options.attributes An array of attributes.
182
182
  * @param {IndexBuffer} [options.indexBuffer] An optional index buffer.
183
183
  *
184
184
  * @returns {VertexArray} The vertex array, ready for use with drawing.
@@ -681,7 +681,7 @@ Object.defineProperties(ArcGisMapServerImageryProvider.prototype, {
681
681
  * Creates an {@link ImageryProvider} which provides tiled imagery hosted by an ArcGIS MapServer. By default, the server's pre-cached tiles are
682
682
  * used, if available.
683
683
  *
684
- * @param {Resource|String} url The URL of the ArcGIS MapServer service.
684
+ * @param {Resource|string} url The URL of the ArcGIS MapServer service.
685
685
  * @param {ArcGisMapServerImageryProvider.ConstructorOptions} [options] Object describing initialization options.
686
686
  * @returns {Promise<ArcGisMapServerImageryProvider>} A promise that resolves to the created ArcGisMapServerImageryProvider.
687
687
  *
@@ -4,7 +4,7 @@ import Resource from "../Core/Resource.js";
4
4
 
5
5
  let defaultTokenCredit;
6
6
  const defaultAccessToken =
7
- "AAPTxy8BH1VEsoebNVZXo8HurEOF051kAEKlhkOhBEc9BmQqEeLjCLZBBnNm_y_K-Cs-tuPcsgUmlxDWvPdTmGIEhrihfZMTG77j2nmCeqeYCPAenHGG1YfJqJaeRLuy5YjARJcFLP2I_judomiDS-8A_LVZxWUObwIQNE5wcsQKxJl7RHiKm-81XRDuUJZXGqy9B4PwPxWkS-N9PZ7NmTT-sP6BOGn5ouiAN8dkxwNx3tA.AT1_BU0Co4D8";
7
+ "AAPTxy8BH1VEsoebNVZXo8HurEOF051kAEKlhkOhBEc9BmRA_-es9rk59JndtXxJExAf4pmezE6N8auY2oiYF7U6dXh7yRaT1sNQtBY9wlqlw0devC6v78rHPdmwJcUuC_MbH3liCP4RLfDGesom_8vT8bbbaPe8MoNz66fpwDaRk4lfCE9paNVC2Mx1K0Dgg7eJJ4TF14HaUnSgkHUcR7gLbj_277ZHX9P-QkLR9Tqcf_Y.AT1_7xNXmYif";
8
8
  /**
9
9
  * Default options for accessing the ArcGIS image tile service.
10
10
  *