@cesium/engine 26.2.0 → 26.3.1-wasm.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 (393) hide show
  1. package/Build/ThirdParty/Workers/zip-web-worker.js +707 -600
  2. package/Build/Workers/chunk-2P3WKV6V.js +290 -0
  3. package/Build/Workers/{chunk-M6QKXVAU.js → chunk-2U5272QU.js} +17 -17
  4. package/Build/Workers/{chunk-NEFDMMLY.js → chunk-4KCOC6OZ.js} +8 -10
  5. package/Build/Workers/{chunk-SJYSIOEM.js → chunk-5FULJNWY.js} +11 -13
  6. package/Build/Workers/{chunk-NCL22ZUX.js → chunk-65ZF23AQ.js} +1 -1
  7. package/Build/Workers/{chunk-KP5QD7WU.js → chunk-6D5534B7.js} +10 -12
  8. package/Build/Workers/{chunk-FX3VEAIU.js → chunk-6GFMBHBD.js} +19 -19
  9. package/Build/Workers/{chunk-A62YI6S6.js → chunk-6VRGQF3D.js} +4 -4
  10. package/Build/Workers/{chunk-DSGLDRTI.js → chunk-6XUIECFB.js} +4 -6
  11. package/Build/Workers/{chunk-HDL4HOXZ.js → chunk-7KWUH6RK.js} +14 -14
  12. package/Build/Workers/{chunk-UAZUP4I5.js → chunk-7ZBJRQQT.js} +7 -7
  13. package/Build/Workers/{chunk-CRCGE4J4.js → chunk-AEHANE5A.js} +991 -5612
  14. package/Build/Workers/chunk-AUU74SIZ.js +2420 -0
  15. package/Build/Workers/{chunk-ARZICEEP.js → chunk-B6V5NMIE.js} +13 -11
  16. package/Build/Workers/{chunk-76FDC45O.js → chunk-BRQ52ASU.js} +15 -17
  17. package/Build/Workers/{chunk-SA2A2AN5.js → chunk-FVLSQBPH.js} +7 -14
  18. package/Build/Workers/{chunk-CUTRKXUQ.js → chunk-IFKM2GZR.js} +12 -12
  19. package/Build/Workers/{chunk-NSKZ6SBK.js → chunk-KF6OEWVT.js} +17 -17
  20. package/Build/Workers/{chunk-O3DKEX7Q.js → chunk-KOAXSU77.js} +5 -7
  21. package/Build/Workers/{chunk-2Z4ZLVOD.js → chunk-KRVYCMGN.js} +6 -6
  22. package/Build/Workers/{chunk-SXSP3JHS.js → chunk-LTZRLNQP.js} +1 -1
  23. package/Build/Workers/{chunk-6FZDPMTO.js → chunk-M7WEAGWT.js} +8 -8
  24. package/Build/Workers/{chunk-NXGQBQWE.js → chunk-MJTLGN63.js} +14 -14
  25. package/Build/Workers/{chunk-XCBZVTIV.js → chunk-MUNZ77KV.js} +1 -1
  26. package/Build/Workers/{chunk-NLLCQBX3.js → chunk-NC5BUJEF.js} +2 -2
  27. package/Build/Workers/chunk-NYKURYFR.js +2131 -0
  28. package/Build/Workers/{chunk-5LSOO2KD.js → chunk-NZAQG57U.js} +7 -7
  29. package/Build/Workers/{chunk-DZUFEE4L.js → chunk-O5GUOP2G.js} +5 -7
  30. package/Build/Workers/{chunk-D6AY775A.js → chunk-OQUOLQTN.js} +8 -10
  31. package/Build/Workers/{chunk-CDJDJ5LK.js → chunk-OUG5JB2K.js} +16 -14
  32. package/Build/Workers/{chunk-ACTVJHSP.js → chunk-P4SDLSGF.js} +13 -6
  33. package/Build/Workers/{chunk-MAAHFYPC.js → chunk-P6PC2OIM.js} +7 -7
  34. package/Build/Workers/{chunk-6YR6JBMY.js → chunk-PPRK3XQU.js} +31 -35
  35. package/Build/Workers/{chunk-IMBVP57H.js → chunk-QGTYLWOT.js} +2 -2
  36. package/Build/Workers/{chunk-FCP2QY4G.js → chunk-QHTLIQUH.js} +5 -7
  37. package/Build/Workers/{chunk-EZGQPOIG.js → chunk-ROHWZQZ5.js} +5 -5
  38. package/Build/Workers/{chunk-B3QHNA4A.js → chunk-SNUWISJO.js} +6 -8
  39. package/Build/Workers/{chunk-XDWCTQCZ.js → chunk-T67YY3KP.js} +4 -2
  40. package/Build/Workers/{chunk-IJZJMIUY.js → chunk-TF5473GK.js} +13 -13
  41. package/Build/Workers/{chunk-OZGPS7FB.js → chunk-THHFTMAL.js} +4 -6
  42. package/Build/Workers/{chunk-PRWUMCXF.js → chunk-UFCZ62WM.js} +15 -13
  43. package/Build/Workers/{chunk-27FWRTJI.js → chunk-UV2YC2Q5.js} +11 -11
  44. package/Build/Workers/{chunk-N7CCOFLX.js → chunk-V4ICCWYA.js} +1 -1
  45. package/Build/Workers/{chunk-GHXVQVUM.js → chunk-VC6XXI2Z.js} +9 -9
  46. package/Build/Workers/{chunk-I74ZH5LK.js → chunk-VXJ6P4UI.js} +10 -10
  47. package/Build/Workers/{chunk-KGXSYGBG.js → chunk-W2BKP7G7.js} +15 -17
  48. package/Build/Workers/{chunk-LDRQSYBN.js → chunk-WMVGNBSH.js} +2 -2
  49. package/Build/Workers/{chunk-SMTGMFBL.js → chunk-XFZMQZSZ.js} +4 -4
  50. package/Build/Workers/{chunk-7MM3N2VE.js → chunk-XJ532R6R.js} +20 -20
  51. package/Build/Workers/{chunk-NJVBJG63.js → chunk-YJNU4SM4.js} +5 -5
  52. package/Build/Workers/{chunk-DIGUUD6G.js → chunk-YJRDTEHQ.js} +8 -8
  53. package/Build/Workers/chunk-YUICDZKO.js +2660 -0
  54. package/Build/Workers/{chunk-O3XFXGPZ.js → chunk-Z3DEVGJV.js} +7 -7
  55. package/Build/Workers/{chunk-3PSS3T43.js → chunk-ZECGI7UZ.js} +4 -4
  56. package/Build/Workers/{chunk-QFSSCLLZ.js → chunk-ZFLPVPUJ.js} +6 -8
  57. package/Build/Workers/{chunk-2RGJPWQX.js → chunk-ZIM5H2DB.js} +11 -11
  58. package/Build/Workers/{chunk-GVA7XQI2.js → chunk-ZSQMGGSB.js} +14 -16
  59. package/Build/Workers/{chunk-FU4BGABC.js → chunk-ZWYRGMBK.js} +16 -18
  60. package/Build/Workers/{chunk-JKXV6PG5.js → chunk-ZY733NZA.js} +1 -1
  61. package/Build/Workers/combineGeometry.js +24 -24
  62. package/Build/Workers/createBoxGeometry.js +18 -18
  63. package/Build/Workers/createBoxOutlineGeometry.js +20 -19
  64. package/Build/Workers/createCircleGeometry.js +28 -27
  65. package/Build/Workers/createCircleOutlineGeometry.js +21 -20
  66. package/Build/Workers/createCoplanarPolygonGeometry.js +34 -34
  67. package/Build/Workers/createCoplanarPolygonOutlineGeometry.js +33 -32
  68. package/Build/Workers/createCorridorGeometry.js +31 -31
  69. package/Build/Workers/createCorridorOutlineGeometry.js +30 -30
  70. package/Build/Workers/createCylinderGeometry.js +20 -20
  71. package/Build/Workers/createCylinderOutlineGeometry.js +22 -21
  72. package/Build/Workers/createEllipseGeometry.js +26 -26
  73. package/Build/Workers/createEllipseOutlineGeometry.js +19 -19
  74. package/Build/Workers/createEllipsoidGeometry.js +19 -19
  75. package/Build/Workers/createEllipsoidOutlineGeometry.js +18 -18
  76. package/Build/Workers/createFrustumGeometry.js +18 -18
  77. package/Build/Workers/createFrustumOutlineGeometry.js +18 -18
  78. package/Build/Workers/createGeometry.js +27 -26
  79. package/Build/Workers/createGroundPolylineGeometry.js +27 -26
  80. package/Build/Workers/createPlaneGeometry.js +18 -17
  81. package/Build/Workers/createPlaneOutlineGeometry.js +15 -15
  82. package/Build/Workers/createPolygonGeometry.js +35 -35
  83. package/Build/Workers/createPolygonOutlineGeometry.js +34 -34
  84. package/Build/Workers/createPolylineGeometry.js +28 -29
  85. package/Build/Workers/createPolylineVolumeGeometry.js +34 -35
  86. package/Build/Workers/createPolylineVolumeOutlineGeometry.js +30 -31
  87. package/Build/Workers/createRectangleGeometry.js +30 -30
  88. package/Build/Workers/createRectangleOutlineGeometry.js +23 -24
  89. package/Build/Workers/createSimplePolylineGeometry.js +26 -27
  90. package/Build/Workers/createSphereGeometry.js +19 -19
  91. package/Build/Workers/createSphereOutlineGeometry.js +18 -18
  92. package/Build/Workers/createTaskProcessorWorker.js +3 -3
  93. package/Build/Workers/createVectorTileClampedPolylines.js +17 -16
  94. package/Build/Workers/createVectorTileGeometries.js +24 -24
  95. package/Build/Workers/createVectorTilePoints.js +13 -13
  96. package/Build/Workers/createVectorTilePolygons.js +22 -22
  97. package/Build/Workers/createVectorTilePolylines.js +17 -16
  98. package/Build/Workers/createVerticesFromCesium3DTilesTerrain.js +36 -26
  99. package/Build/Workers/createVerticesFromGoogleEarthEnterpriseBuffer.js +24 -24
  100. package/Build/Workers/createVerticesFromHeightmap.js +24 -25
  101. package/Build/Workers/createVerticesFromQuantizedTerrainMesh.js +20 -20
  102. package/Build/Workers/createWallGeometry.js +27 -28
  103. package/Build/Workers/createWallOutlineGeometry.js +26 -27
  104. package/Build/Workers/decodeDraco.js +16 -12
  105. package/Build/Workers/decodeGoogleEarthEnterprisePacket.js +336 -337
  106. package/Build/Workers/decodeI3S.js +17 -12
  107. package/Build/Workers/{chunk-GXWQZBAI.js → decodeMeshopt.js} +23 -29
  108. package/Build/Workers/decodeSpz.js +1960 -0
  109. package/Build/Workers/gaussianSplatSorter.js +13 -6
  110. package/Build/Workers/gaussianSplatTextureGenerator.js +13 -6
  111. package/Build/Workers/incrementallyBuildTerrainPicker.js +9 -10
  112. package/Build/Workers/transcodeKTX2.js +26 -12
  113. package/Build/Workers/transferTypedArrayTest.js +1 -1
  114. package/Build/Workers/upsampleQuantizedTerrainMesh.js +24 -24
  115. package/Build/Workers/upsampleVerticesFromCesium3DTilesTerrain.js +25 -25
  116. package/Source/Core/Cesium3DTilesTerrainData.js +11 -1
  117. package/Source/Core/Cesium3DTilesTerrainGeometryProcessor.js +33 -23
  118. package/Source/Core/Ion.js +1 -1
  119. package/Source/Core/IonResource.js +5 -0
  120. package/Source/Core/IonSnapGeometryType.js +59 -0
  121. package/Source/Core/IonSnapHeat.js +33 -0
  122. package/Source/Core/IonSnapMode.js +45 -0
  123. package/Source/Core/IonSnapParentGeometryType.js +52 -0
  124. package/Source/Core/IonSnapService.js +369 -0
  125. package/Source/Core/KTX2Transcoder.js +99 -5
  126. package/Source/Core/Resource.js +2 -0
  127. package/Source/Core/SnapService.js +63 -0
  128. package/Source/Core/TaskProcessor.js +249 -129
  129. package/Source/Core/TrustedServers.js +34 -1
  130. package/Source/Core/VectorPipeline.js +139 -45
  131. package/Source/Core/VectorProvider.js +311 -71
  132. package/Source/Core/WebAssemblyWorkerInitializer.js +125 -0
  133. package/Source/Core/fetchWebAssemblyBinary.js +52 -0
  134. package/Source/Renderer/AutomaticUniforms.js +44 -2
  135. package/Source/Renderer/ShaderBuilder.js +1 -1
  136. package/Source/Renderer/UniformState.js +47 -1
  137. package/Source/Scene/ArcGisMapService.js +1 -1
  138. package/Source/Scene/BufferPointCollection.js +4 -7
  139. package/Source/Scene/BufferPolygonCollection.js +56 -27
  140. package/Source/Scene/BufferPolylineCollection.js +61 -8
  141. package/Source/Scene/BufferPolylineMaterial.js +6 -5
  142. package/Source/Scene/BufferPrimitiveCollection.js +199 -29
  143. package/Source/Scene/Cesium3DTile.js +12 -0
  144. package/Source/Scene/Cesium3DTileset.js +61 -8
  145. package/Source/Scene/Cesium3DTilesetBaseTraversal.js +15 -3
  146. package/Source/Scene/Cesium3DTilesetCache.js +15 -0
  147. package/Source/Scene/ClippingPolygon.js +154 -100
  148. package/Source/Scene/ClippingPolygonCollection.js +352 -694
  149. package/Source/Scene/CreditDisplay.js +62 -0
  150. package/Source/Scene/GaussianSplatPrimitive.js +153 -66
  151. package/Source/Scene/GeoJsonPrimitive.js +114 -24
  152. package/Source/Scene/GlobeSurfaceShaderSet.js +33 -54
  153. package/Source/Scene/GlobeSurfaceTile.js +14 -1
  154. package/Source/Scene/GlobeSurfaceTileProvider.js +232 -25
  155. package/Source/Scene/GltfBufferViewLoader.js +25 -13
  156. package/Source/Scene/GltfLoader.js +56 -6
  157. package/Source/Scene/GltfSpzLoader.js +5 -4
  158. package/Source/Scene/HeightReference.js +1 -1
  159. package/Source/Scene/MVTDataProvider.js +9 -0
  160. package/Source/Scene/Model/Model.js +242 -16
  161. package/Source/Scene/Model/Model3DTileContent.js +5 -0
  162. package/Source/Scene/Model/ModelClippingPolygonsPipelineStage.js +54 -19
  163. package/Source/Scene/Model/ModelRenderResources.js +2 -3
  164. package/Source/Scene/Model/ModelSceneGraph.js +10 -1
  165. package/Source/Scene/Model/ModelVectorLookupPipelineStage.js +205 -0
  166. package/Source/Scene/Model/PickingPipelineStage.js +4 -0
  167. package/Source/Scene/PostProcessStage.js +22 -3
  168. package/Source/Scene/Scene.js +56 -1
  169. package/Source/Scene/Snapping.js +57 -0
  170. package/Source/Scene/SpzDecoder.js +106 -0
  171. package/Source/Scene/UrlTemplate3DTilesDataProvider.js +12 -1
  172. package/Source/Scene/VectorGltf3DTileContent.js +10 -2
  173. package/Source/Scene/WebMapServiceImageryProvider.js +5 -1
  174. package/Source/Scene/WebMapTileServiceImageryProvider.js +6 -1
  175. package/Source/Scene/renderBufferPolylineCollection.js +5 -1
  176. package/Source/Shaders/BufferPolylineMaterialVS.glsl +14 -2
  177. package/Source/Shaders/BufferPolylineMaterialVS.js +14 -2
  178. package/Source/Shaders/Builtin/CzmBuiltins.js +2 -4
  179. package/Source/Shaders/Builtin/Functions/eyeToCartographicDelta.glsl +74 -0
  180. package/Source/Shaders/Builtin/Functions/eyeToCartographicDelta.js +76 -0
  181. package/Source/Shaders/GlobeFS.glsl +10 -9
  182. package/Source/Shaders/GlobeFS.js +11 -9
  183. package/Source/Shaders/GlobeVS.glsl +0 -32
  184. package/Source/Shaders/GlobeVS.js +0 -32
  185. package/Source/Shaders/Model/ModelClippingPolygonsStageFS.glsl +15 -3
  186. package/Source/Shaders/Model/ModelClippingPolygonsStageFS.js +15 -3
  187. package/Source/Shaders/Model/ModelClippingPolygonsStageVS.glsl +20 -24
  188. package/Source/Shaders/Model/ModelClippingPolygonsStageVS.js +20 -24
  189. package/Source/Shaders/Model/ModelFS.glsl +4 -0
  190. package/Source/Shaders/Model/ModelFS.js +4 -0
  191. package/Source/Shaders/Model/ModelVS.glsl +7 -2
  192. package/Source/Shaders/Model/ModelVS.js +7 -2
  193. package/Source/Shaders/Model/ModelVectorLookupStageFS.glsl +6 -0
  194. package/Source/Shaders/Model/ModelVectorLookupStageFS.js +8 -0
  195. package/Source/Shaders/Model/ModelVectorLookupStageVS.glsl +15 -0
  196. package/Source/Shaders/Model/ModelVectorLookupStageVS.js +17 -0
  197. package/Source/Shaders/Model/VerticalExaggerationStageVS.glsl +9 -10
  198. package/Source/Shaders/Model/VerticalExaggerationStageVS.js +9 -11
  199. package/Source/Shaders/VectorCommon.glsl +177 -50
  200. package/Source/Shaders/VectorCommon.js +251 -19
  201. package/Source/ThirdParty/Workers/zip-web-worker.js +1 -1
  202. package/Source/ThirdParty/zip-module.wasm +0 -0
  203. package/Source/Workers/createTaskProcessorWorker.js +2 -0
  204. package/Source/Workers/createVerticesFromCesium3DTilesTerrain.js +13 -1
  205. package/Source/Workers/decodeDraco.js +7 -3
  206. package/Source/Workers/decodeI3S.js +7 -3
  207. package/Source/Workers/decodeMeshopt.js +21 -0
  208. package/Source/Workers/decodeSpz.js +20 -0
  209. package/Source/Workers/gaussianSplatSorter.js +7 -3
  210. package/Source/Workers/gaussianSplatTextureGenerator.js +7 -3
  211. package/Source/Workers/transcodeKTX2.js +22 -5
  212. package/index.d.ts +649 -55
  213. package/index.js +23 -13
  214. package/package.json +6 -6
  215. package/Build/Workers/chunk-2EFYUSUY.js +0 -1483
  216. package/Build/Workers/chunk-2H5264K7.js +0 -1284
  217. package/Build/Workers/chunk-2H73KDBM.js +0 -511
  218. package/Build/Workers/chunk-2ZKH2QZB.js +0 -387
  219. package/Build/Workers/chunk-36NI5E6W.js +0 -3820
  220. package/Build/Workers/chunk-37SW7SYS.js +0 -778
  221. package/Build/Workers/chunk-3GHVJ3SO.js +0 -455
  222. package/Build/Workers/chunk-3LB4UVPU.js +0 -387
  223. package/Build/Workers/chunk-3PONLKEL.js +0 -778
  224. package/Build/Workers/chunk-3QR662HH.js +0 -3820
  225. package/Build/Workers/chunk-3SX2WYSO.js +0 -973
  226. package/Build/Workers/chunk-3UDN6LYX.js +0 -476
  227. package/Build/Workers/chunk-47MCBSXI.js +0 -9237
  228. package/Build/Workers/chunk-4E626OCE.js +0 -1067
  229. package/Build/Workers/chunk-4NW2MJKH.js +0 -455
  230. package/Build/Workers/chunk-52YK5BSN.js +0 -198
  231. package/Build/Workers/chunk-5RNAQZK6.js +0 -9234
  232. package/Build/Workers/chunk-5YPQBFRD.js +0 -519
  233. package/Build/Workers/chunk-6FHT43QR.js +0 -140
  234. package/Build/Workers/chunk-6HK6IXK2.js +0 -138
  235. package/Build/Workers/chunk-6R5X2GUA.js +0 -1284
  236. package/Build/Workers/chunk-7A2OGDHT.js +0 -305
  237. package/Build/Workers/chunk-7CGEQUM2.js +0 -305
  238. package/Build/Workers/chunk-7D2HZKH7.js +0 -455
  239. package/Build/Workers/chunk-7I325HV6.js +0 -1344
  240. package/Build/Workers/chunk-7KVKHY7O.js +0 -147
  241. package/Build/Workers/chunk-7TKLTCZW.js +0 -219
  242. package/Build/Workers/chunk-7UUKBDH6.js +0 -1054
  243. package/Build/Workers/chunk-7W6DUHAB.js +0 -693
  244. package/Build/Workers/chunk-7XM5JK5F.js +0 -162
  245. package/Build/Workers/chunk-7YG3ND3P.js +0 -454
  246. package/Build/Workers/chunk-A3O6EDBK.js +0 -73
  247. package/Build/Workers/chunk-A6X24AZI.js +0 -1992
  248. package/Build/Workers/chunk-A7TTWVTF.js +0 -2719
  249. package/Build/Workers/chunk-ADX3CBKD.js +0 -9234
  250. package/Build/Workers/chunk-AF7DTMJ7.js +0 -398
  251. package/Build/Workers/chunk-AHWAZRBV.js +0 -82
  252. package/Build/Workers/chunk-AJSFRY4U.js +0 -1344
  253. package/Build/Workers/chunk-B4CQSLZJ.js +0 -305
  254. package/Build/Workers/chunk-BKPQFCXH.js +0 -511
  255. package/Build/Workers/chunk-BSPCI2LO.js +0 -959
  256. package/Build/Workers/chunk-BUJWSX5S.js +0 -301
  257. package/Build/Workers/chunk-C7JQVRLM.js +0 -497
  258. package/Build/Workers/chunk-C7QDUNI3.js +0 -138
  259. package/Build/Workers/chunk-CEEZE3YZ.js +0 -476
  260. package/Build/Workers/chunk-CIV5DJOQ.js +0 -778
  261. package/Build/Workers/chunk-CLCTQVVL.js +0 -241
  262. package/Build/Workers/chunk-CQNFIAZU.js +0 -56
  263. package/Build/Workers/chunk-DBD5WWG2.js +0 -959
  264. package/Build/Workers/chunk-DZBQUULR.js +0 -138
  265. package/Build/Workers/chunk-E2NKV5YT.js +0 -3820
  266. package/Build/Workers/chunk-E7NZJOK7.js +0 -3792
  267. package/Build/Workers/chunk-EB3Y5P3A.js +0 -368
  268. package/Build/Workers/chunk-EHTS2YPT.js +0 -2719
  269. package/Build/Workers/chunk-ELE6SC2C.js +0 -837
  270. package/Build/Workers/chunk-ENNFMWDW.js +0 -789
  271. package/Build/Workers/chunk-EOWDZN5S.js +0 -288
  272. package/Build/Workers/chunk-ERKUET22.js +0 -3201
  273. package/Build/Workers/chunk-F2IMBMZY.js +0 -241
  274. package/Build/Workers/chunk-F4CSNRZO.js +0 -219
  275. package/Build/Workers/chunk-FBP4DUQJ.js +0 -693
  276. package/Build/Workers/chunk-FDK4K5IA.js +0 -280
  277. package/Build/Workers/chunk-FGQFQHN5.js +0 -1054
  278. package/Build/Workers/chunk-FJWZMGOQ.js +0 -1992
  279. package/Build/Workers/chunk-FQ42MT7M.js +0 -58
  280. package/Build/Workers/chunk-GGNWQWSB.js +0 -301
  281. package/Build/Workers/chunk-GNKXEN4C.js +0 -682
  282. package/Build/Workers/chunk-GSWMAFTE.js +0 -9230
  283. package/Build/Workers/chunk-GXDHRC4J.js +0 -1344
  284. package/Build/Workers/chunk-GYSYP6PC.js +0 -1067
  285. package/Build/Workers/chunk-H2WCFXLP.js +0 -241
  286. package/Build/Workers/chunk-HHV3MCGV.js +0 -162
  287. package/Build/Workers/chunk-HLW2ZRVK.js +0 -368
  288. package/Build/Workers/chunk-HS6AD4P2.js +0 -398
  289. package/Build/Workers/chunk-HT6FASOT.js +0 -973
  290. package/Build/Workers/chunk-IDVHUDZT.js +0 -352
  291. package/Build/Workers/chunk-IGAZBTFZ.js +0 -3201
  292. package/Build/Workers/chunk-ILME5BXA.js +0 -301
  293. package/Build/Workers/chunk-IOO7Z2AV.js +0 -57
  294. package/Build/Workers/chunk-IUIFLOYO.js +0 -44
  295. package/Build/Workers/chunk-J73T2VOY.js +0 -171
  296. package/Build/Workers/chunk-JALGQYDY.js +0 -288
  297. package/Build/Workers/chunk-JW6OZT4R.js +0 -288
  298. package/Build/Workers/chunk-JXYLJCTC.js +0 -124
  299. package/Build/Workers/chunk-K27QOAW6.js +0 -97
  300. package/Build/Workers/chunk-KMV25A63.js +0 -789
  301. package/Build/Workers/chunk-KZWFWJML.js +0 -2719
  302. package/Build/Workers/chunk-LCXRRALY.js +0 -387
  303. package/Build/Workers/chunk-LD64RPYV.js +0 -368
  304. package/Build/Workers/chunk-LGNDTZVX.js +0 -97
  305. package/Build/Workers/chunk-LNSQVXFH.js +0 -1800
  306. package/Build/Workers/chunk-M4JZ6TSZ.js +0 -959
  307. package/Build/Workers/chunk-MCJDRDJQ.js +0 -102
  308. package/Build/Workers/chunk-MEENMEAH.js +0 -198
  309. package/Build/Workers/chunk-NAWU5RF4.js +0 -162
  310. package/Build/Workers/chunk-NIWITKQK.js +0 -693
  311. package/Build/Workers/chunk-OA6MYL2C.js +0 -837
  312. package/Build/Workers/chunk-OBEU25PI.js +0 -1067
  313. package/Build/Workers/chunk-OHP4ELS7.js +0 -198
  314. package/Build/Workers/chunk-PCL3Y7H5.js +0 -82
  315. package/Build/Workers/chunk-PD4GK4EM.js +0 -57
  316. package/Build/Workers/chunk-PEDU33QG.js +0 -2342
  317. package/Build/Workers/chunk-PVTSNNVI.js +0 -288
  318. package/Build/Workers/chunk-QHPZH22L.js +0 -241
  319. package/Build/Workers/chunk-QIZDWZK6.js +0 -301
  320. package/Build/Workers/chunk-QV6DG2YX.js +0 -1483
  321. package/Build/Workers/chunk-QVLAFFJY.js +0 -56
  322. package/Build/Workers/chunk-R4FPNAZ2.js +0 -352
  323. package/Build/Workers/chunk-R4K7EHOU.js +0 -171
  324. package/Build/Workers/chunk-R7JGHDD6.js +0 -789
  325. package/Build/Workers/chunk-RASQEYD4.js +0 -1483
  326. package/Build/Workers/chunk-RG4F5R57.js +0 -454
  327. package/Build/Workers/chunk-RW6ITX7Q.js +0 -3820
  328. package/Build/Workers/chunk-RYSQVJR6.js +0 -398
  329. package/Build/Workers/chunk-S6RJU5NM.js +0 -1054
  330. package/Build/Workers/chunk-SDFHDNS4.js +0 -147
  331. package/Build/Workers/chunk-SF6K72D7.js +0 -124
  332. package/Build/Workers/chunk-SGRGNDOD.js +0 -682
  333. package/Build/Workers/chunk-SM2CDCYF.js +0 -198
  334. package/Build/Workers/chunk-SS5ABQGY.js +0 -102
  335. package/Build/Workers/chunk-T5QBPLE3.js +0 -414
  336. package/Build/Workers/chunk-TN35HP5B.js +0 -1067
  337. package/Build/Workers/chunk-TNWKJNUZ.js +0 -454
  338. package/Build/Workers/chunk-TOAF47AQ.js +0 -102
  339. package/Build/Workers/chunk-TQ4QCOXT.js +0 -2719
  340. package/Build/Workers/chunk-TSDSILQB.js +0 -124
  341. package/Build/Workers/chunk-TVZD72WJ.js +0 -778
  342. package/Build/Workers/chunk-U5LV3F3Z.js +0 -1054
  343. package/Build/Workers/chunk-UEY73NRN.js +0 -38
  344. package/Build/Workers/chunk-UF46SZEZ.js +0 -789
  345. package/Build/Workers/chunk-UNRTMCET.js +0 -398
  346. package/Build/Workers/chunk-UTB7U3O6.js +0 -1992
  347. package/Build/Workers/chunk-UVO6COT2.js +0 -352
  348. package/Build/Workers/chunk-V46YGZE6.js +0 -352
  349. package/Build/Workers/chunk-VAL7DYNR.js +0 -278
  350. package/Build/Workers/chunk-VDGOCROW.js +0 -57
  351. package/Build/Workers/chunk-VFWSSBPT.js +0 -511
  352. package/Build/Workers/chunk-VVYMXI3I.js +0 -1284
  353. package/Build/Workers/chunk-VXWHPYQM.js +0 -837
  354. package/Build/Workers/chunk-VXYUBRSB.js +0 -219
  355. package/Build/Workers/chunk-VZLDLEWI.js +0 -387
  356. package/Build/Workers/chunk-W5OCKMPJ.js +0 -101
  357. package/Build/Workers/chunk-WBSY7HDY.js +0 -837
  358. package/Build/Workers/chunk-WN3F4CVG.js +0 -3201
  359. package/Build/Workers/chunk-WPRUWXGV.js +0 -693
  360. package/Build/Workers/chunk-WTO2ERBP.js +0 -414
  361. package/Build/Workers/chunk-WVHMDVG4.js +0 -959
  362. package/Build/Workers/chunk-XGA23TAX.js +0 -73
  363. package/Build/Workers/chunk-XLQZNQ4Z.js +0 -163
  364. package/Build/Workers/chunk-XLXSDIP5.js +0 -973
  365. package/Build/Workers/chunk-XQ3SKCMM.js +0 -140
  366. package/Build/Workers/chunk-XQH66YJC.js +0 -147
  367. package/Build/Workers/chunk-XTA7BXJG.js +0 -682
  368. package/Build/Workers/chunk-XTIDAFRS.js +0 -476
  369. package/Build/Workers/chunk-XUEDWBUD.js +0 -682
  370. package/Build/Workers/chunk-XYFLRH3H.js +0 -124
  371. package/Build/Workers/chunk-Y7JRTRTO.js +0 -305
  372. package/Build/Workers/chunk-Y7QSMDCJ.js +0 -352
  373. package/Build/Workers/chunk-YCB5TYTR.js +0 -1483
  374. package/Build/Workers/chunk-YEYOSTJX.js +0 -219
  375. package/Build/Workers/chunk-YGFVAGYF.js +0 -630
  376. package/Build/Workers/chunk-YIIACKQO.js +0 -368
  377. package/Build/Workers/chunk-YJGSP6PE.js +0 -511
  378. package/Build/Workers/chunk-YKU2Q3A2.js +0 -1287
  379. package/Build/Workers/chunk-Z4LR5EHE.js +0 -454
  380. package/Build/Workers/chunk-Z66EVE2A.js +0 -44
  381. package/Build/Workers/chunk-ZHIHHHTB.js +0 -414
  382. package/Build/Workers/chunk-ZMBHFYOX.js +0 -1344
  383. package/Build/Workers/chunk-ZNWHFSLE.js +0 -171
  384. package/Build/Workers/chunk-ZQLZG4IN.js +0 -2342
  385. package/Build/Workers/chunk-ZRTSMUZ2.js +0 -414
  386. package/Build/Workers/chunk-ZSGUV73H.js +0 -2342
  387. package/Build/Workers/chunk-ZZUVT5BM.js +0 -476
  388. package/Source/Shaders/Builtin/Functions/clipPolygons.glsl +0 -37
  389. package/Source/Shaders/Builtin/Functions/clipPolygons.js +0 -39
  390. package/Source/Shaders/Builtin/Functions/unpackClippingExtents.glsl +0 -14
  391. package/Source/Shaders/Builtin/Functions/unpackClippingExtents.js +0 -15
  392. package/Source/Shaders/PolygonSignedDistanceFS.glsl +0 -131
  393. package/Source/Shaders/PolygonSignedDistanceFS.js +0 -132
@@ -1,26 +1,43 @@
1
- import Cartesian2 from "../Core/Cartesian2.js";
2
- import CesiumMath from "../Core/Math.js";
1
+ import Cartesian3 from "../Core/Cartesian3.js";
3
2
  import Check from "../Core/Check.js";
3
+ import deprecationWarning from "../Core/deprecationWarning.js";
4
4
  import Frozen from "../Core/Frozen.js";
5
5
  import defined from "../Core/defined.js";
6
6
  import destroyObject from "../Core/destroyObject.js";
7
7
  import DeveloperError from "../Core/DeveloperError.js";
8
8
  import Event from "../Core/Event.js";
9
9
  import Intersect from "../Core/Intersect.js";
10
- import PixelFormat from "../Core/PixelFormat.js";
11
10
  import Rectangle from "../Core/Rectangle.js";
12
- import ContextLimits from "../Renderer/ContextLimits.js";
13
- import PixelDatatype from "../Renderer/PixelDatatype.js";
14
11
  import RuntimeError from "../Core/RuntimeError.js";
15
- import Sampler from "../Renderer/Sampler.js";
16
- import Texture from "../Renderer/Texture.js";
17
- import TextureMagnificationFilter from "../Renderer/TextureMagnificationFilter.js";
18
- import TextureMinificationFilter from "../Renderer/TextureMinificationFilter.js";
19
- import TextureWrap from "../Renderer/TextureWrap.js";
20
12
  import ClippingPolygon from "./ClippingPolygon.js";
21
- import ComputeCommand from "../Renderer/ComputeCommand.js";
22
- import PolygonSignedDistanceFS from "../Shaders/PolygonSignedDistanceFS.js";
23
- import Pass from "../Renderer/Pass.js";
13
+ import BufferPolygonCollection from "./BufferPolygonCollection.js";
14
+ import BufferPolygon from "./BufferPolygon.js";
15
+ import Ellipsoid from "../Core/Ellipsoid.js";
16
+ import VectorPipeline from "../Core/VectorPipeline.js";
17
+ import CesiumMath from "../Core/Math.js";
18
+
19
+ /** @import { VectorCollectionData } from "../Core/VectorPipeline.js" */
20
+
21
+ // Reused flyweight for reading/writing individual BufferPolygons.
22
+ const bufferPolygonScratch = new BufferPolygon();
23
+
24
+ const qualityDeprecationMessage =
25
+ "ClippingPolygonCollection.quality is deprecated as of CesiumJS 1.145 and will be removed in 1.147. Signed distance field clipping was replaced with vector clipping, so this property no longer has any effect.";
26
+ const debugShowDistanceTextureDeprecationMessage =
27
+ "ClippingPolygonCollection.debugShowDistanceTexture is deprecated as of CesiumJS 1.145 and will be removed in 1.147. Signed distance field clipping was replaced with vector clipping, so this property no longer has any effect.";
28
+ const isDestroyedDeprecationMessage =
29
+ "ClippingPolygonCollection.isDestroyed is deprecated as of CesiumJS 1.145 and will be removed in 1.147. The collection no longer holds any GPU resources of its own, so it does not need to be destroyed.";
30
+ const destroyDeprecationMessage =
31
+ "ClippingPolygonCollection.destroy is deprecated as of CesiumJS 1.145 and will be removed in 1.147. The collection no longer holds any GPU resources of its own, so it does not need to be destroyed.";
32
+
33
+ /**
34
+ * A ClippingPolygon paired with the index of its mirrored primitive in a collection's BufferPolygonCollection.
35
+ *
36
+ * @typedef {object} ClippingPolygonEntry
37
+ * @property {ClippingPolygon} clippingPolygon
38
+ * @property {number} bufferIndex
39
+ * @private
40
+ */
24
41
 
25
42
  /**
26
43
  * Specifies a set of clipping polygons. Clipping polygons selectively disable rendering in a region
@@ -35,7 +52,8 @@ import Pass from "../Renderer/Pass.js";
35
52
  * @param {ClippingPolygon[]} [options.polygons=[]] An array of {@link ClippingPolygon} objects used to selectively disable rendering on the inside of each polygon.
36
53
  * @param {boolean} [options.enabled=true] Determines whether the clipping polygons are active.
37
54
  * @param {boolean} [options.inverse=false] If true, a region will be clipped if it is outside of every polygon in the collection. Otherwise, a region will only be clipped if it is on the inside of any polygon.
38
- * @param {number} [options.quality=1.0] A scalar that controls the resolution of the signed distance texture used for clipping. Values greater than 1.0 increase quality, values less than 1.0 decrease it. Must be greater than 0.0.
55
+ * @param {number} [options.quality=1.0] A scalar that controls the resolution of the signed distance texture used for clipping. Values greater than 1.0 increase quality, values less than 1.0 decrease it. Must be greater than 0.0. <p>Deprecated in CesiumJS 1.145 and will be removed in 1.147. Signed distance field clipping was replaced with vector clipping, so this option no longer has any effect.</p>
56
+ * @param {Ellipsoid} [options.ellipsoid=Ellipsoid.default] The ellipsoid to use to project the clipping polygons onto the globe.
39
57
  *
40
58
  * @example
41
59
  * const positions = Cesium.Cartesian3.fromRadiansArray([
@@ -62,10 +80,58 @@ import Pass from "../Renderer/Pass.js";
62
80
  function ClippingPolygonCollection(options) {
63
81
  options = options ?? Frozen.EMPTY_OBJECT;
64
82
 
83
+ /**
84
+ * @type {ClippingPolygonEntry[]}
85
+ * @private
86
+ */
65
87
  this._polygons = [];
66
- this._totalPositions = 0;
67
88
 
68
- this.debugShowDistanceTexture = options.debugShowDistanceTexture ?? false;
89
+ const polygons = options.polygons ?? [];
90
+ let numVertices = 0;
91
+ let numHoles = 0;
92
+ for (let i = 0; i < polygons.length; ++i) {
93
+ numVertices += polygons[i].length;
94
+ numHoles += polygons[i].holes.length;
95
+ }
96
+
97
+ // Marks the packed vector data as stale.
98
+ this._dirty = false;
99
+
100
+ // For now: this is a write-through mirror of the polygons array. In upcoming work,
101
+ // this will be the source of truth. To maintain backwards compatibility, though, we will still
102
+ // have to wrap BufferPolygons in ClippingPolygons for the public API.
103
+ this._bufferPolygonCollection = new BufferPolygonCollection({
104
+ // We just need it as a data structure, set show to false to prevent unnecessary render buffer allocations.
105
+ show: false,
106
+ // Clipping polygons are never picked, so skip allocating pick ids for them.
107
+ allowPicking: false,
108
+ // Preallocate double the initial data.
109
+ primitiveCountMax: 2 * polygons.length,
110
+ vertexCountMax: 2 * numVertices,
111
+ holeCountMax: numHoles > 0 ? 2 * numHoles : 0,
112
+ // This may be fine to stay as 0: we do not need the triangulation for Vector-based clipping.
113
+ triangleCountMax: 0,
114
+ });
115
+
116
+ for (let i = 0; i < polygons.length; ++i) {
117
+ const bufferIndex = this._bufferPolygonCollection.primitiveCount;
118
+ this._bufferPolygonCollection.add(
119
+ packClippingPolygon(polygons[i]),
120
+ bufferPolygonScratch,
121
+ );
122
+ this._polygons.push({
123
+ clippingPolygon: polygons[i],
124
+ bufferIndex: bufferIndex,
125
+ });
126
+ }
127
+
128
+ if (defined(options.debugShowDistanceTexture)) {
129
+ deprecationWarning(
130
+ "ClippingPolygonCollection.debugShowDistanceTexture",
131
+ debugShowDistanceTextureDeprecationMessage,
132
+ );
133
+ }
134
+ this._debugShowDistanceTexture = options.debugShowDistanceTexture ?? false;
69
135
 
70
136
  /**
71
137
  * If true, clipping will be enabled.
@@ -85,14 +151,13 @@ function ClippingPolygonCollection(options) {
85
151
  */
86
152
  this.inverse = options.inverse ?? false;
87
153
 
88
- /**
89
- * A scalar that controls the resolution of the signed distance texture used for clipping.
90
- * Values greater than 1.0 increase quality, values less than 1.0 decrease it. Must be greater than 0.0.
91
- *
92
- * @type {number}
93
- * @default 1.0
94
- */
95
- this.quality = options.quality ?? 1.0;
154
+ if (defined(options.quality)) {
155
+ deprecationWarning(
156
+ "ClippingPolygonCollection.quality",
157
+ qualityDeprecationMessage,
158
+ );
159
+ }
160
+ this._quality = options.quality ?? 1.0;
96
161
 
97
162
  /**
98
163
  * An event triggered when a new clipping polygon is added to the collection. Event handlers
@@ -110,28 +175,25 @@ function ClippingPolygonCollection(options) {
110
175
  */
111
176
  this.polygonRemoved = new Event();
112
177
 
178
+ /**
179
+ * The ellipsoid to use to project the clipping polygons onto the globe.
180
+ * @type {Ellipsoid}
181
+ * @default Ellipsoid.default
182
+ */
183
+ this.ellipsoid = options.ellipsoid ?? Ellipsoid.default;
184
+
113
185
  // If this ClippingPolygonCollection has an owner, only its owner should update or destroy it.
114
186
  // This is because in a Cesium3DTileset multiple models may reference the tileset's ClippingPolygonCollection.
115
187
  this._owner = undefined;
116
188
 
117
- this._float32View = undefined;
118
- this._extentsFloat32View = undefined;
119
- this._extentsCount = 0;
120
-
121
- this._polygonsTexture = undefined;
122
- this._extentsTexture = undefined;
123
- this._signedDistanceTexture = undefined;
124
-
125
- this._signedDistanceComputeCommand = undefined;
126
-
127
- // Add each ClippingPolygon object.
128
- const polygons = options.polygons;
129
- if (defined(polygons)) {
130
- const polygonsLength = polygons.length;
131
- for (let i = 0; i < polygonsLength; ++i) {
132
- this._polygons.push(polygons[i]);
133
- }
134
- }
189
+ /**
190
+ * @type {VectorCollectionData}
191
+ * @private
192
+ */
193
+ this._vectorCollectionData = VectorPipeline.packPolygonCollectionData(
194
+ this._bufferPolygonCollection,
195
+ this.ellipsoid,
196
+ );
135
197
  }
136
198
 
137
199
  Object.defineProperties(ClippingPolygonCollection.prototype, {
@@ -151,88 +213,52 @@ Object.defineProperties(ClippingPolygonCollection.prototype, {
151
213
  },
152
214
 
153
215
  /**
154
- * Returns the total number of positions in all polygons in the collection.
155
- *
156
- * @memberof ClippingPolygonCollection.prototype
157
- * @type {number}
158
- * @readonly
159
- * @private
160
- */
161
- totalPositions: {
162
- get: function () {
163
- return this._totalPositions;
164
- },
165
- },
166
-
167
- /**
168
- * Returns a texture containing the packed computed spherical extents for each polygon
169
- *
170
- * @memberof ClippingPolygonCollection.prototype
171
- * @type {Texture}
172
- * @readonly
173
- * @private
174
- */
175
- extentsTexture: {
176
- get: function () {
177
- return this._extentsTexture;
178
- },
179
- },
180
-
181
- /**
182
- * Returns the number of packed extents, which can be fewer than the number of polygons.
216
+ * If true, a debug texture visualizing the signed distance field is shown.
183
217
  *
184
218
  * @memberof ClippingPolygonCollection.prototype
185
- * @type {number}
186
- * @readonly
187
- * @private
219
+ * @type {boolean}
220
+ * @default false
221
+ * @deprecated This property was deprecated in CesiumJS 1.145 and will be removed in 1.147. Signed distance field clipping was replaced with vector clipping, so this property no longer has any effect.
188
222
  */
189
- extentsCount: {
223
+ debugShowDistanceTexture: {
190
224
  get: function () {
191
- return this._extentsCount;
225
+ deprecationWarning(
226
+ "ClippingPolygonCollection.debugShowDistanceTexture",
227
+ debugShowDistanceTextureDeprecationMessage,
228
+ );
229
+ return this._debugShowDistanceTexture;
192
230
  },
193
- },
194
-
195
- /**
196
- * Returns the number of pixels needed in the texture containing the packed computed spherical extents for each polygon.
197
- *
198
- * @memberof ClippingPolygonCollection.prototype
199
- * @type {number}
200
- * @readonly
201
- * @private
202
- */
203
- pixelsNeededForExtents: {
204
- get: function () {
205
- return this.length; // With an RGBA texture, each pixel contains min/max latitude and longitude.
231
+ set: function (value) {
232
+ deprecationWarning(
233
+ "ClippingPolygonCollection.debugShowDistanceTexture",
234
+ debugShowDistanceTextureDeprecationMessage,
235
+ );
236
+ this._debugShowDistanceTexture = value;
206
237
  },
207
238
  },
208
239
 
209
240
  /**
210
- * Returns the number of pixels needed in the texture containing the packed polygon positions.
241
+ * A scalar that controlled the resolution of the signed distance texture used for clipping.
211
242
  *
212
243
  * @memberof ClippingPolygonCollection.prototype
213
244
  * @type {number}
214
- * @readonly
215
- * @private
245
+ * @default 1.0
246
+ * @deprecated This property was deprecated in CesiumJS 1.145 and will be removed in 1.147. Signed distance field clipping was replaced with vector clipping, so this property no longer has any effect.
216
247
  */
217
- pixelsNeededForPolygonPositions: {
248
+ quality: {
218
249
  get: function () {
219
- // In an RG FLOAT texture, each polygon position is 2 floats packed to a RG.
220
- // Each polygon has a 1-pixel header + 2 pixels for individual extents + the list of positions
221
- return this.totalPositions + 3 * this.length;
250
+ deprecationWarning(
251
+ "ClippingPolygonCollection.quality",
252
+ qualityDeprecationMessage,
253
+ );
254
+ return this._quality;
222
255
  },
223
- },
224
-
225
- /**
226
- * Returns a texture containing the computed signed distance of each polygon.
227
- *
228
- * @memberof ClippingPolygonCollection.prototype
229
- * @type {Texture}
230
- * @readonly
231
- * @private
232
- */
233
- clippingTexture: {
234
- get: function () {
235
- return this._signedDistanceTexture;
256
+ set: function (value) {
257
+ deprecationWarning(
258
+ "ClippingPolygonCollection.quality",
259
+ qualityDeprecationMessage,
260
+ );
261
+ this._quality = value;
236
262
  },
237
263
  },
238
264
 
@@ -252,8 +278,9 @@ Object.defineProperties(ClippingPolygonCollection.prototype, {
252
278
  /**
253
279
  * Returns a number encapsulating the state for this ClippingPolygonCollection.
254
280
  *
255
- * Clipping mode is encoded in the sign of the number, which is just the total position count.
256
- * If this value changes, then shader regeneration is necessary.
281
+ * The value is 0 when clipping is inactive (disabled or empty), 1 for regular
282
+ * clipping, and -1 for inverse clipping. If this value changes, then shader
283
+ * regeneration is necessary.
257
284
  *
258
285
  * @memberof ClippingPolygonCollection.prototype
259
286
  * @returns {number} A Number that describes the ClippingPolygonCollection's state.
@@ -262,11 +289,117 @@ Object.defineProperties(ClippingPolygonCollection.prototype, {
262
289
  */
263
290
  clippingPolygonsState: {
264
291
  get: function () {
265
- return this.inverse ? -this.extentsCount : this.extentsCount;
292
+ if (!this.enabled || this.length === 0) {
293
+ return 0;
294
+ }
295
+ return this.inverse ? -1 : 1;
266
296
  },
267
297
  },
268
298
  });
269
299
 
300
+ /**
301
+ * Flattens a ClippingPolygon's outer ring and holes into the position and
302
+ * hole-offset arrays used by BufferPolygonCollection.add.
303
+ *
304
+ * @param {ClippingPolygon} polygon
305
+ * @returns {{positions: Float64Array, holes: (Uint32Array|undefined)}}
306
+ * @private
307
+ */
308
+ function packClippingPolygon(polygon) {
309
+ const outer = polygon.positions;
310
+ const holeRings = polygon.holes;
311
+ const positions = new Float64Array(polygon.length * 3);
312
+
313
+ let vertexOffset = 0;
314
+ for (let i = 0; i < outer.length; i++) {
315
+ Cartesian3.pack(outer[i], positions, vertexOffset * 3);
316
+ vertexOffset++;
317
+ }
318
+
319
+ if (holeRings.length === 0) {
320
+ return { positions, holes: undefined };
321
+ }
322
+
323
+ // Each hole offset marks the vertex where that ring begins in positions.
324
+ const holes = new Uint32Array(holeRings.length);
325
+ for (let i = 0; i < holeRings.length; i++) {
326
+ const ring = holeRings[i];
327
+ holes[i] = vertexOffset;
328
+ for (let j = 0; j < ring.length; j++) {
329
+ Cartesian3.pack(ring[j], positions, vertexOffset * 3);
330
+ vertexOffset++;
331
+ }
332
+ }
333
+ return { positions, holes };
334
+ }
335
+
336
+ /**
337
+ * Grows the backing BufferPolygonCollection if one more polygon of the given
338
+ * vertex and hole count would exceed capacity, returning the collection to add into.
339
+ *
340
+ * @param {ClippingPolygonCollection} collection
341
+ * @param {number} addedVertexCount
342
+ * @param {number} addedHoleCount
343
+ * @returns {BufferPolygonCollection}
344
+ * @private
345
+ */
346
+ function reserveBufferCapacity(collection, addedVertexCount, addedHoleCount) {
347
+ const buffer = collection._bufferPolygonCollection;
348
+
349
+ const neededPrimitives = buffer.primitiveCount + 1;
350
+ const neededVertices = buffer.vertexCount + addedVertexCount;
351
+ const neededHoles = buffer.holeCount + addedHoleCount;
352
+
353
+ if (
354
+ neededPrimitives <= buffer.primitiveCountMax &&
355
+ neededVertices <= buffer.vertexCountMax &&
356
+ neededHoles <= buffer.holeCountMax
357
+ ) {
358
+ return buffer;
359
+ }
360
+
361
+ const hasHiddenPolygons =
362
+ collection._polygons.length !== buffer.primitiveCount;
363
+
364
+ const grown = BufferPolygonCollection.fromCollection(
365
+ buffer,
366
+ {
367
+ primitiveCountMax: CesiumMath.nextPowerOfTwo(neededPrimitives),
368
+ vertexCountMax: CesiumMath.nextPowerOfTwo(neededVertices),
369
+ holeCountMax: CesiumMath.nextPowerOfTwo(neededHoles),
370
+ },
371
+ hasHiddenPolygons ? (polygon) => polygon.show : undefined,
372
+ );
373
+
374
+ buffer.destroy();
375
+ collection._bufferPolygonCollection = grown;
376
+
377
+ if (hasHiddenPolygons) {
378
+ // Reassign indices after compaction (note that this assumes compaction keeps order contiguous)
379
+ const polygons = collection._polygons;
380
+ for (let i = 0; i < polygons.length; ++i) {
381
+ polygons[i].bufferIndex = i;
382
+ }
383
+ }
384
+
385
+ return grown;
386
+ }
387
+
388
+ /**
389
+ * Hides the mirrored BufferPolygon for the given entry and clears its buffer index, since BufferPolygonCollection does not support removal.
390
+ *
391
+ * @param {ClippingPolygonCollection} collection
392
+ * @param {ClippingPolygonEntry} entry
393
+ * @private
394
+ */
395
+ function hideBufferPolygon(collection, entry) {
396
+ collection._bufferPolygonCollection.get(
397
+ entry.bufferIndex,
398
+ bufferPolygonScratch,
399
+ ).show = false;
400
+ entry.bufferIndex = -1;
401
+ }
402
+
270
403
  /**
271
404
  * Adds the specified {@link ClippingPolygon} to the collection to be used to selectively disable rendering
272
405
  * on the inside of each polygon. Use {@link ClippingPolygonCollection#unionClippingRegions} to modify
@@ -306,7 +439,22 @@ ClippingPolygonCollection.prototype.add = function (polygon) {
306
439
  //>>includeEnd('debug');
307
440
 
308
441
  const newPlaneIndex = this._polygons.length;
309
- this._polygons.push(polygon);
442
+
443
+ const bufferPolygonCollection = reserveBufferCapacity(
444
+ this,
445
+ polygon.length,
446
+ polygon.holes.length,
447
+ );
448
+ this._polygons.push({
449
+ clippingPolygon: polygon,
450
+ bufferIndex: bufferPolygonCollection.primitiveCount,
451
+ });
452
+ bufferPolygonCollection.add(
453
+ packClippingPolygon(polygon),
454
+ bufferPolygonScratch,
455
+ );
456
+
457
+ this._dirty = true;
310
458
  this.polygonAdded.raiseEvent(polygon, newPlaneIndex);
311
459
  return polygon;
312
460
  };
@@ -328,7 +476,7 @@ ClippingPolygonCollection.prototype.get = function (index) {
328
476
  Check.typeOf.number("index", index);
329
477
  //>>includeEnd('debug');
330
478
 
331
- return this._polygons[index];
479
+ return this._polygons[index]?.clippingPolygon;
332
480
  };
333
481
 
334
482
  /**
@@ -344,7 +492,9 @@ ClippingPolygonCollection.prototype.contains = function (polygon) {
344
492
  Check.typeOf.object("polygon", polygon);
345
493
  //>>includeEnd('debug');
346
494
 
347
- return this._polygons.some((p) => ClippingPolygon.equals(p, polygon));
495
+ return this._polygons.some((entry) =>
496
+ ClippingPolygon.equals(entry.clippingPolygon, polygon),
497
+ );
348
498
  };
349
499
 
350
500
  /**
@@ -363,174 +513,23 @@ ClippingPolygonCollection.prototype.remove = function (polygon) {
363
513
  //>>includeEnd('debug');
364
514
 
365
515
  const polygons = this._polygons;
366
- const index = polygons.findIndex((p) => ClippingPolygon.equals(p, polygon));
516
+ const index = polygons.findIndex((entry) =>
517
+ ClippingPolygon.equals(entry.clippingPolygon, polygon),
518
+ );
367
519
 
368
520
  if (index === -1) {
369
521
  return false;
370
522
  }
371
523
 
372
- polygons.splice(index, 1);
524
+ const [entry] = polygons.splice(index, 1);
525
+
526
+ hideBufferPolygon(this, entry);
373
527
 
374
- this.polygonRemoved.raiseEvent(polygon, index);
528
+ this._dirty = true;
529
+ this.polygonRemoved.raiseEvent(entry.clippingPolygon, index);
375
530
  return true;
376
531
  };
377
532
 
378
- /**
379
- * Computes padded extents for a polygon's bounding rectangle, clamped to valid spherical ranges.
380
- *
381
- * @param {Rectangle} extents The original spherical extents to pad.
382
- * @param {number} padding A multiplier applied to the extents' width and height to determine the padding amount.
383
- * @param {Rectangle} [result] An optional rectangle to store the result in.
384
- * @returns {Rectangle} The padded and clamped rectangle.
385
- *
386
- * @private
387
- */
388
- function computePaddedExtents(extents, padding, result) {
389
- const height = Math.max(extents.height * padding, 0);
390
- const width = Math.max(extents.width * padding, 0);
391
- const paddedExtents = Rectangle.clone(extents, result);
392
-
393
- // Pad
394
- paddedExtents.south -= height;
395
- paddedExtents.west -= width;
396
- paddedExtents.north += height;
397
- paddedExtents.east += width;
398
-
399
- // Clamp
400
- paddedExtents.south = Math.max(paddedExtents.south, -Math.PI);
401
- paddedExtents.west = Math.max(paddedExtents.west, -Math.PI);
402
- paddedExtents.north = Math.min(paddedExtents.north, Math.PI);
403
- paddedExtents.east = Math.min(paddedExtents.east, Math.PI);
404
-
405
- return paddedExtents;
406
- }
407
-
408
- /**
409
- * @typedef {object} ExtentsResult
410
- * @property {Rectangle[]} extentsList The list of merged padded extents, one per group.
411
- * @property {Map<number, number>} extentsIndexByPolygon A map from polygon index to the index of its group in extentsList.
412
- * @private
413
- */
414
-
415
- /**
416
- * Groups nearby ClippingPolygons based on their spherical extents. Overlapping extents will be merged
417
- * into a single encompassing extent. Each Extent will later map into one region in the SignedDistanceTexture (atlas).
418
- *
419
- * Definitions:
420
- * n = number of polygons
421
- * g = number of resulting extents (merged) (g <= n)
422
- * absorb = merge two extents into one
423
- * restart = redo intersection check with previous groups
424
- *
425
- * Algorithm:
426
- * For each polygon we scan existing groups for a first overlap (O(g)),
427
- * then on each subsequent overlap we absorb the group and restart the
428
- * inner scan. Each group can be absorbed at most once per polygon, and
429
- * each restart reduces the group count by one, so the absorb-loop does
430
- * at most O(g) restarts per polygon. Overall: O(n * g) where g ≤ n,
431
- * giving O(n²) worst case when all polygons overlap transitively, but
432
- * typically much better when groups are few and disjoint.
433
- *
434
- * Note: Restarts are required because the new merged bounding box might
435
- * be larger than the two individual that were merged and introduce new
436
- * collisions. Example:
437
- *
438
- * Before merging A and B:
439
- *
440
- * ┌─────────┐
441
- * │ A │
442
- * │ ┌┼────────┐
443
- * └─────────┘│ B │
444
- * ┌────┐ │ │
445
- * │ C │ └────────┘
446
- * └────┘
447
- *
448
- * A overlaps B ✓
449
- * A overlaps C ✗
450
- * B overlaps C ✗
451
- *
452
- * After merging A ∪ B into one extent:
453
- *
454
- * ┌───────────────────┐
455
- * │ │
456
- * │ A ∪ B │
457
- * ├────┐ │
458
- * │ C │ │
459
- * └────┘──────────────┘
460
- *
461
- * (A ∪ B) overlaps C ✓ ← new collision!
462
- *
463
- * @param {ClippingPolygon[]} polygons The array of clipping polygons to compute extents for.
464
- * @param {Rectangle[]} polygonExtentsCache An array of pre-computed spherical extents for each polygon, indexed by polygon index.
465
- * @returns {ExtentsResult} The merged extents and a mapping from polygon indices to their extent group indices.
466
- *
467
- * @private
468
- */
469
- function getExtents(polygons, polygonExtentsCache) {
470
- // Pad extents to avoid floating point error when fragment culling at edges.
471
- const PADDING = 2.5;
472
-
473
- // Each group: { extent: padded Rectangle, polygonIndices: number[] }
474
- const groups = [];
475
-
476
- const length = polygons.length;
477
- for (let polygonIndex = 0; polygonIndex < length; ++polygonIndex) {
478
- const paddedExtent = computePaddedExtents(
479
- polygonExtentsCache[polygonIndex],
480
- PADDING,
481
- );
482
-
483
- // Pass 1: Find the first overlapping group
484
- let targetIdx = -1;
485
- for (let g = 0; g < groups.length; ++g) {
486
- if (
487
- defined(Rectangle.simpleIntersection(groups[g].extent, paddedExtent))
488
- ) {
489
- targetIdx = g;
490
- break;
491
- }
492
- }
493
-
494
- if (targetIdx === -1) {
495
- // No overlap — start a new group
496
- groups.push({ extent: paddedExtent, polygonIndices: [polygonIndex] });
497
- } else {
498
- // Overlap - Merge the polygon into the target group
499
- const target = groups[targetIdx];
500
- target.polygonIndices.push(polygonIndex);
501
- Rectangle.union(target.extent, paddedExtent, target.extent);
502
-
503
- // Pass 2: Absorb all other groups that overlap the (growing) target
504
- // extent. After each absorption the target grows, so restart the scan
505
- // to catch groups that now transitively overlap.
506
- for (let g = 0; g < groups.length; ++g) {
507
- if (g === targetIdx) {
508
- continue;
509
- }
510
- if (
511
- defined(Rectangle.simpleIntersection(groups[g].extent, target.extent))
512
- ) {
513
- target.polygonIndices.push(...groups[g].polygonIndices);
514
- Rectangle.union(target.extent, groups[g].extent, target.extent);
515
- groups.splice(g, 1);
516
- if (g < targetIdx) {
517
- targetIdx--;
518
- }
519
- g = -1; // restart (loop increment brings it to 0)
520
- }
521
- }
522
- }
523
- }
524
-
525
- const extentsList = groups.map((g) => g.extent);
526
- const extentsIndexByPolygon = new Map();
527
- groups.forEach((g, extentIndex) =>
528
- g.polygonIndices.forEach((p) => extentsIndexByPolygon.set(p, extentIndex)),
529
- );
530
-
531
- return { extentsList, extentsIndexByPolygon };
532
- }
533
-
534
533
  /**
535
534
  * Removes all polygons from the collection.
536
535
  *
@@ -538,113 +537,21 @@ function getExtents(polygons, polygonExtentsCache) {
538
537
  * @see ClippingPolygonCollection#remove
539
538
  */
540
539
  ClippingPolygonCollection.prototype.removeAll = function () {
541
- // Dereference this ClippingPolygonCollection from all ClippingPolygons
542
540
  const polygons = this._polygons;
543
541
  const polygonsCount = polygons.length;
544
542
  for (let i = 0; i < polygonsCount; ++i) {
545
- const polygon = polygons[i];
546
- this.polygonRemoved.raiseEvent(polygon, i);
543
+ const entry = polygons[i];
544
+ hideBufferPolygon(this, entry);
545
+ this.polygonRemoved.raiseEvent(entry.clippingPolygon, i);
547
546
  }
547
+ this._dirty = true;
548
548
  this._polygons = [];
549
549
  };
550
550
 
551
- function packPolygonsAsFloats(clippingPolygonCollection) {
552
- const polygonsFloat32View = clippingPolygonCollection._float32View;
553
- const extentsFloat32View = clippingPolygonCollection._extentsFloat32View;
554
- const polygons = clippingPolygonCollection._polygons;
555
-
556
- /**
557
- * Pre-calculate all polygon spherical extents as it an expensive operation
558
- * @type {ReadonlyArray<Rectangle>}
559
- * */
560
- const polygonExtentsCache = polygons.map((polygon) =>
561
- polygon.computeSphericalExtents(),
562
- );
563
-
564
- const { extentsList, extentsIndexByPolygon } = getExtents(
565
- polygons,
566
- polygonExtentsCache,
567
- );
568
-
569
- // Polygons are packed sequentially (ordered by extentsIndex) into polygonsFloat32View as follows:
570
- // For each polygon:
571
- // [0] vertexCount - the number of vertices in the polygon
572
- // [1] extentsIndex - index into the extents texture for this polygon's bounding rectangle
573
- // [2] south - southern boundary of the individual polygon extent (radians)
574
- // [3] west - western boundary of the individual polygon extent (radians)
575
- // [4] latitudeRange - (north - south) for the individual polygon extent
576
- // [5] longitudeRange - (east - west) for the individual polygon extent
577
- // [6..6+2*vertexCount-1] pairs of (latitude, longitude) for each vertex,
578
- // computed as fastApproximateAtan2 values to match the shader
579
-
580
- // Sort polygon indices by extentsIndex so polygons sharing the same extent are packed together
581
- // Can enable optimizations in the shader
582
- const sortedPolygonIndices = Array.from(polygons.keys()).sort(
583
- (a, b) => extentsIndexByPolygon.get(a) - extentsIndexByPolygon.get(b),
584
- );
585
-
586
- let floatIndex = 0;
587
- for (const polygonIndex of sortedPolygonIndices) {
588
- const polygon = polygons[polygonIndex];
589
- // Pack the length of the polygon into the polygon texture array buffer
590
- const length = polygon.length;
591
- polygonsFloat32View[floatIndex++] = length;
592
- polygonsFloat32View[floatIndex++] = extentsIndexByPolygon.get(polygonIndex);
593
-
594
- // Pack the individual polygon extent
595
- const polygonExtent = polygonExtentsCache[polygonIndex];
596
- polygonsFloat32View[floatIndex++] = polygonExtent.south;
597
- polygonsFloat32View[floatIndex++] = polygonExtent.west;
598
- polygonsFloat32View[floatIndex++] =
599
- polygonExtent.north - polygonExtent.south;
600
- polygonsFloat32View[floatIndex++] = polygonExtent.east - polygonExtent.west;
601
-
602
- // Pack the polygon positions into the polygon texture array buffer
603
- for (let i = 0; i < length; ++i) {
604
- const spherePoint = polygon.positions[i];
605
-
606
- // Project into plane with vertical for latitude
607
- const magXY = Math.hypot(spherePoint.x, spherePoint.y);
608
-
609
- // Use fastApproximateAtan2 for alignment with shader
610
- const latitudeApproximation = CesiumMath.fastApproximateAtan2(
611
- magXY,
612
- spherePoint.z,
613
- );
614
- const longitudeApproximation = CesiumMath.fastApproximateAtan2(
615
- spherePoint.x,
616
- spherePoint.y,
617
- );
618
-
619
- polygonsFloat32View[floatIndex++] = latitudeApproximation;
620
- polygonsFloat32View[floatIndex++] = longitudeApproximation;
621
- }
622
- }
623
-
624
- // Extents are packed sequentially into extentsFloat32View as follows:
625
- // For each extent (maps to one RGBA pixel in the extents texture):
626
- // [0] south - the southern boundary of the bounding rectangle (radians)
627
- // [1] west - the western boundary of the bounding rectangle (radians)
628
- // [2] latitudeRangeInverse - 1.0 / (north - south)
629
- // [3] longitudeRangeInverse - 1.0 / (east - west)
630
- let extentsFloatIndex = 0;
631
- for (const extents of extentsList) {
632
- const longitudeRangeInverse = 1.0 / (extents.east - extents.west);
633
- const latitudeRangeInverse = 1.0 / (extents.north - extents.south);
634
-
635
- extentsFloat32View[extentsFloatIndex++] = extents.south;
636
- extentsFloat32View[extentsFloatIndex++] = extents.west;
637
- extentsFloat32View[extentsFloatIndex++] = latitudeRangeInverse;
638
- extentsFloat32View[extentsFloatIndex++] = longitudeRangeInverse;
639
- }
640
-
641
- clippingPolygonCollection._extentsCount = extentsList.length;
642
- }
643
-
644
- const textureResolutionScratch = new Cartesian2();
645
551
  /**
646
- * Called when {@link Viewer} or {@link CesiumWidget} render the scene to
647
- * build the resources for clipping polygons.
552
+ * Called by the collection's owner (a {@link Cesium3DTileset}, {@link Model}, or
553
+ * the globe surface tile provider) during the scene update to build the
554
+ * resources for clipping polygons.
648
555
  * <p>
649
556
  * Do not call this function directly.
650
557
  * </p>
@@ -652,249 +559,32 @@ const textureResolutionScratch = new Cartesian2();
652
559
  * @throws {RuntimeError} ClippingPolygonCollections are only supported for WebGL 2
653
560
  */
654
561
  ClippingPolygonCollection.prototype.update = function (frameState) {
655
- const context = frameState.context;
656
-
657
562
  if (!ClippingPolygonCollection.isSupported(frameState)) {
658
563
  throw new RuntimeError(
659
564
  "ClippingPolygonCollections are only supported for WebGL 2.",
660
565
  );
661
566
  }
662
567
 
663
- if (this.debugShowDistanceTexture && defined(this._signedDistanceTexture)) {
664
- if (!defined(this.debugCommand)) {
665
- this.debugCommand = createDebugCommand(
666
- this._signedDistanceTexture,
667
- frameState.context,
668
- );
669
- }
670
- frameState.commandList.push(this.debugCommand);
671
- }
672
-
673
- // It'd be expensive to validate any individual position has changed. Instead verify if the list of polygon positions has had elements added or removed, which should be good enough for most cases.
674
- const totalPositions = this._polygons.reduce(
675
- (totalPositions, polygon) => totalPositions + polygon.length,
676
- 0,
677
- );
678
-
679
- if (totalPositions === this.totalPositions) {
568
+ if (!this._dirty) {
680
569
  return;
681
570
  }
682
571
 
683
- this._totalPositions = totalPositions;
572
+ this._dirty = false;
684
573
 
685
574
  // If there are no clipping polygons, there's nothing to update.
686
575
  if (this.length === 0) {
687
576
  return;
688
577
  }
689
578
 
690
- if (defined(this._signedDistanceComputeCommand)) {
691
- this._signedDistanceComputeCommand.canceled = true;
692
- this._signedDistanceComputeCommand = undefined;
693
- }
694
-
695
- let polygonsTexture = this._polygonsTexture;
696
- let extentsTexture = this._extentsTexture;
697
- let signedDistanceTexture = this._signedDistanceTexture;
698
- if (defined(polygonsTexture)) {
699
- const currentPixelCount = polygonsTexture.width * polygonsTexture.height;
700
- // Recreate the texture to double current requirement if it isn't big enough or is 4 times larger than it needs to be.
701
- // Optimization note: this isn't exactly the classic resizeable array algorithm
702
- // * not necessarily checking for resize after each add/remove operation
703
- // * random-access deletes instead of just pops
704
- // * alloc ops likely more expensive than demonstrable via big-O analysis
705
- if (
706
- currentPixelCount < this.pixelsNeededForPolygonPositions ||
707
- this.pixelsNeededForPolygonPositions < 0.25 * currentPixelCount
708
- ) {
709
- polygonsTexture.destroy();
710
- polygonsTexture = undefined;
711
- this._polygonsTexture = undefined;
712
- }
713
- }
714
-
715
- if (!defined(polygonsTexture)) {
716
- const requiredResolution = ClippingPolygonCollection.getTextureResolution(
717
- polygonsTexture,
718
- this.pixelsNeededForPolygonPositions,
719
- textureResolutionScratch,
720
- );
721
-
722
- polygonsTexture = new Texture({
723
- context: context,
724
- width: requiredResolution.x,
725
- height: requiredResolution.y,
726
- pixelFormat: PixelFormat.RG,
727
- pixelDatatype: PixelDatatype.FLOAT,
728
- sampler: Sampler.NEAREST,
729
- flipY: false,
730
- });
731
- this._float32View = new Float32Array(
732
- requiredResolution.x * requiredResolution.y * 2,
733
- );
734
- this._polygonsTexture = polygonsTexture;
735
- }
736
-
737
- if (defined(extentsTexture)) {
738
- const currentPixelCount = extentsTexture.width * extentsTexture.height;
739
- // Recreate the texture to double current requirement if it isn't big enough or is 4 times larger than it needs to be.
740
- // Optimization note: this isn't exactly the classic resizeable array algorithm
741
- // * not necessarily checking for resize after each add/remove operation
742
- // * random-access deletes instead of just pops
743
- // * alloc ops likely more expensive than demonstrable via big-O analysis
744
- if (
745
- currentPixelCount < this.pixelsNeededForExtents ||
746
- this.pixelsNeededForExtents < 0.25 * currentPixelCount
747
- ) {
748
- extentsTexture.destroy();
749
- extentsTexture = undefined;
750
- this._extentsTexture = undefined;
751
- }
752
- }
753
-
754
- if (!defined(extentsTexture)) {
755
- const requiredResolution = ClippingPolygonCollection.getTextureResolution(
756
- extentsTexture,
757
- this.pixelsNeededForExtents,
758
- textureResolutionScratch,
759
- );
760
-
761
- extentsTexture = new Texture({
762
- context: context,
763
- width: requiredResolution.x,
764
- height: requiredResolution.y,
765
- pixelFormat: PixelFormat.RGBA,
766
- pixelDatatype: PixelDatatype.FLOAT,
767
- sampler: Sampler.NEAREST,
768
- flipY: false,
769
- });
770
- this._extentsFloat32View = new Float32Array(
771
- requiredResolution.x * requiredResolution.y * 4,
772
- );
773
-
774
- this._extentsTexture = extentsTexture;
775
- }
776
-
777
- packPolygonsAsFloats(this);
778
-
779
- extentsTexture.copyFrom({
780
- source: {
781
- width: extentsTexture.width,
782
- height: extentsTexture.height,
783
- arrayBufferView: this._extentsFloat32View,
784
- },
785
- });
786
-
787
- polygonsTexture.copyFrom({
788
- source: {
789
- width: polygonsTexture.width,
790
- height: polygonsTexture.height,
791
- arrayBufferView: this._float32View,
792
- },
793
- });
794
-
795
- if (!defined(signedDistanceTexture)) {
796
- const textureDimensions =
797
- ClippingPolygonCollection.getClippingDistanceTextureResolution(
798
- this,
799
- textureResolutionScratch,
800
- );
801
- signedDistanceTexture = new Texture({
802
- context: context,
803
- width: textureDimensions.x,
804
- height: textureDimensions.y,
805
- pixelFormat: context.webgl2 ? PixelFormat.RED : PixelFormat.LUMINANCE,
806
- pixelDatatype: PixelDatatype.FLOAT,
807
- sampler: new Sampler({
808
- wrapS: TextureWrap.CLAMP_TO_EDGE,
809
- wrapT: TextureWrap.CLAMP_TO_EDGE,
810
- minificationFilter: TextureMinificationFilter.LINEAR,
811
- magnificationFilter: TextureMagnificationFilter.LINEAR,
812
- }),
813
- flipY: false,
814
- });
815
-
816
- this._signedDistanceTexture = signedDistanceTexture;
817
- }
818
-
819
- this._signedDistanceComputeCommand = createSignedDistanceTextureCommand(this);
820
- };
821
-
822
- function createDebugCommand(texture, context) {
823
- const fs =
824
- "uniform highp sampler2D billboard_texture; \n" +
825
- "in vec2 v_textureCoordinates; \n" +
826
- "float getSignedDistance(vec2 uv, highp sampler2D clippingDistance) { \n" +
827
- " float signedDistance = texture(clippingDistance, uv).r; \n" +
828
- " return (signedDistance - 0.5) * 2.0; \n" +
829
- "} \n" +
830
- "void main() \n" +
831
- "{ \n" +
832
- " float dist = texture(billboard_texture, v_textureCoordinates).r; \n" +
833
- " if (dist > 0.5) { \n" +
834
- " out_FragColor = vec4(dist, 0.0, 0.0, 1.0); \n" + // outside
835
- " } else {\n" +
836
- " out_FragColor = vec4(0.0, dist, 0.0, 1.0); \n" + // inside
837
- " } \n" +
838
- "} \n";
839
-
840
- const drawCommand = context.createViewportQuadCommand(fs, {
841
- uniformMap: {
842
- billboard_texture: function () {
843
- return texture;
844
- },
845
- },
846
- });
847
- drawCommand.pass = Pass.OVERLAY;
848
- return drawCommand;
849
- }
850
-
851
- /**
852
- * Called when {@link Viewer} or {@link CesiumWidget} render the scene to
853
- * build the resources for clipping polygons.
854
- * <p>
855
- * Do not call this function directly.
856
- * </p>
857
- * @private
858
- * @param {FrameState} frameState
859
- */
860
- ClippingPolygonCollection.prototype.queueCommands = function (frameState) {
861
- if (defined(this._signedDistanceComputeCommand)) {
862
- frameState.commandList.push(this._signedDistanceComputeCommand);
863
- }
579
+ // Update the vector polygon data
580
+ this._vectorCollectionData = VectorPipeline.packPolygonCollectionData(
581
+ this._bufferPolygonCollection,
582
+ this.ellipsoid,
583
+ );
864
584
  };
865
585
 
866
- function createSignedDistanceTextureCommand(collection) {
867
- const polygonTexture = collection._polygonsTexture;
868
- const extentsTexture = collection._extentsTexture;
869
-
870
- return new ComputeCommand({
871
- fragmentShaderSource: PolygonSignedDistanceFS,
872
- outputTexture: collection._signedDistanceTexture,
873
- uniformMap: {
874
- u_polygonsLength: function () {
875
- return collection.length;
876
- },
877
- u_extentsLength: function () {
878
- return collection.extentsCount;
879
- },
880
- u_extentsTexture: function () {
881
- return extentsTexture;
882
- },
883
- u_polygonTexture: function () {
884
- return polygonTexture;
885
- },
886
- },
887
- persists: false,
888
- owner: collection,
889
- postExecute: () => {
890
- collection._signedDistanceComputeCommand = undefined;
891
- },
892
- });
893
- }
894
-
895
586
  const scratchRectangleTile = new Rectangle();
896
587
  const scratchRectangleIntersection = new Rectangle();
897
- const scratchRectanglePolygon = new Rectangle();
898
588
  /**
899
589
  * Determines the type intersection with the polygons of this ClippingPolygonCollection instance and the specified {@link TileBoundingVolume}.
900
590
  * @ignore
@@ -936,15 +626,11 @@ ClippingPolygonCollection.prototype.computeIntersectionWithBoundingVolume =
936
626
  }
937
627
 
938
628
  for (let i = 0; i < length; ++i) {
939
- const polygon = polygons[i];
940
-
941
- const polygonBoundingRectangle = polygon.computeRectangle(
942
- scratchRectanglePolygon,
943
- );
629
+ const polygon = polygons[i].clippingPolygon;
944
630
 
945
- const result = Rectangle.simpleIntersection(
631
+ const result = Rectangle.intersection(
946
632
  tileBoundingRectangle,
947
- polygonBoundingRectangle,
633
+ polygon.rectangle,
948
634
  scratchRectangleIntersection,
949
635
  );
950
636
 
@@ -970,12 +656,13 @@ ClippingPolygonCollection.setOwner = function (
970
656
  owner,
971
657
  key,
972
658
  ) {
973
- // Don't destroy the ClippingPolygonCollection if it is already owned by newOwner
659
+ // Don't detach the ClippingPolygonCollection if it is already owned by newOwner
974
660
  if (clippingPolygonsCollection === owner[key]) {
975
661
  return;
976
662
  }
977
- // Destroy the existing ClippingPolygonCollection, if any
978
- owner[key] = owner[key] && owner[key].destroy();
663
+ // Detach the existing ClippingPolygonCollection, if any. It holds no GPU
664
+ // resources of its own, so dropping the reference is sufficient.
665
+ owner[key] = undefined;
979
666
  if (defined(clippingPolygonsCollection)) {
980
667
  //>>includeStart('debug', pragmas.debug);
981
668
  if (defined(clippingPolygonsCollection._owner)) {
@@ -990,102 +677,72 @@ ClippingPolygonCollection.setOwner = function (
990
677
  };
991
678
 
992
679
  /**
993
- * Function for checking if the context will allow clipping polygons, which require floating point textures.
680
+ * Compute data and pack into textures used for vector-style clipping.
681
+ * Consumers should listen to {@link ClippingPolygonCollection#polygonAdded} and {@link ClippingPolygonCollection#polygonRemoved}
682
+ * to know when this data becomes stale. It will be refreshed on the next update call (note: update is invoked by the collection's owner).
994
683
  *
995
- * @param {Scene|object} scene The scene that will contain clipped objects and clipping textures.
996
- * @returns {boolean} <code>true</code> if the context supports clipping polygons.
997
- */
998
- ClippingPolygonCollection.isSupported = function (scene) {
999
- return scene?.context.webgl2;
1000
- };
1001
-
1002
- /**
1003
- * Function for getting packed texture resolution.
1004
- * If the ClippingPolygonCollection hasn't been updated, returns the resolution that will be
1005
- * allocated based on the provided needed pixels.
684
+ * @param {Rectangle} rectangle The region of space to consider for clipping. Polygons outside of this rectangle
685
+ * will not be included in the returned data.
686
+ * @param {Context} context The context to use for creating textures.
687
+ * @returns {VectorTileData} The data (including textures) for the clipping polygons in the specified rectangle.
1006
688
  *
1007
- * @param {Texture} texture The texture to be packed.
1008
- * @param {number} pixelsNeeded The number of pixels needed based on the current polygon count.
1009
- * @param {Cartesian2} result A Cartesian2 for the result.
1010
- * @returns {Cartesian2} The required resolution.
1011
- * @private
689
+ * @ignore
1012
690
  */
1013
- ClippingPolygonCollection.getTextureResolution = function (
1014
- texture,
1015
- pixelsNeeded,
1016
- result,
691
+ ClippingPolygonCollection.prototype.requestRectangleData = function (
692
+ rectangle,
693
+ context,
1017
694
  ) {
1018
- if (defined(texture)) {
1019
- result.x = texture.width;
1020
- result.y = texture.height;
1021
- return result;
695
+ //>>includeStart('debug', pragmas.debug);
696
+ Check.typeOf.object("rectangle", rectangle);
697
+ Check.typeOf.object("context", context);
698
+ //>>includeEnd('debug');
699
+
700
+ const vectorTileData = {
701
+ rectangle: Rectangle.clone(rectangle),
702
+ polygonRings: [],
703
+ };
704
+
705
+ if (this.length === 0) {
706
+ return vectorTileData;
1022
707
  }
1023
708
 
1024
- const maxSize = ContextLimits.maximumTextureSize;
1025
- result.x = Math.min(pixelsNeeded, maxSize);
1026
- result.y = Math.ceil(pixelsNeeded / result.x);
709
+ VectorPipeline.packPolygonRings(
710
+ this._bufferPolygonCollection,
711
+ this._vectorCollectionData,
712
+ rectangle,
713
+ vectorTileData,
714
+ );
1027
715
 
1028
- // Allocate twice as much space as needed to avoid frequent texture reallocation.
1029
- result.y *= 2;
716
+ // No overlapping polygons means no textures to pack (and the caller can skip the clipping rendering step)
717
+ if (vectorTileData.polygonRings.length === 0) {
718
+ return vectorTileData;
719
+ }
1030
720
 
1031
- return result;
721
+ VectorPipeline.packPolygonGrid(vectorTileData);
722
+
723
+ VectorPipeline.packPolygonTextures(context, vectorTileData);
724
+
725
+ return vectorTileData;
1032
726
  };
1033
727
 
1034
728
  /**
1035
- * Function for getting the clipping collection's signed distance texture resolution.
1036
- * If the ClippingPolygonCollection hasn't been updated, returns the resolution that will be
1037
- * allocated based on the current settings
729
+ * Destroy resources associated with the given rectangle data.
1038
730
  *
1039
- * @param {ClippingPolygonCollection} clippingPolygonCollection The clipping polygon collection
1040
- * @param {Cartesian2} result A Cartesian2 for the result.
1041
- * @returns {Cartesian2} The required resolution.
1042
- * @private
731
+ * @param {VectorTileData} data The data (including textures) for the clipping polygons in the specified rectangle.
732
+ * @ignore
1043
733
  */
1044
- ClippingPolygonCollection.getClippingDistanceTextureResolution = function (
1045
- clippingPolygonCollection,
1046
- result,
1047
- ) {
1048
- const texture = clippingPolygonCollection.signedDistanceTexture;
1049
- if (defined(texture)) {
1050
- result.x = texture.width;
1051
- result.y = texture.height;
1052
- return result;
1053
- }
1054
-
1055
- const quality = clippingPolygonCollection.quality;
1056
- const baseSize = Math.max(128, Math.ceil(4096 * quality));
1057
- result.x = Math.min(ContextLimits.maximumTextureSize, baseSize);
1058
- result.y = Math.min(ContextLimits.maximumTextureSize, baseSize);
1059
-
1060
- return result;
734
+ ClippingPolygonCollection.releaseRectangleData = function (data) {
735
+ VectorPipeline.freeResources(data);
1061
736
  };
1062
737
 
1063
738
  /**
1064
- * Function for getting the clipping collection's extents texture resolution.
1065
- * If the ClippingPolygonCollection hasn't been updated, returns the resolution that will be
1066
- * allocated based on the current polygon count.
739
+ * Function for checking if the context will allow clipping polygons, which require floating point textures.
1067
740
  *
1068
- * @param {ClippingPolygonCollection} clippingPolygonCollection The clipping polygon collection
1069
- * @param {Cartesian2} result A Cartesian2 for the result.
1070
- * @returns {Cartesian2} The required resolution.
1071
- * @private
741
+ * @param {Scene|object} scene The scene that will contain clipped objects and clipping textures.
742
+ * @returns {boolean} <code>true</code> if the context supports clipping polygons.
1072
743
  */
1073
- ClippingPolygonCollection.getClippingExtentsTextureResolution = function (
1074
- clippingPolygonCollection,
1075
- result,
1076
- ) {
1077
- const texture = clippingPolygonCollection.extentsTexture;
1078
- if (defined(texture)) {
1079
- result.x = texture.width;
1080
- result.y = texture.height;
1081
- return result;
1082
- }
1083
-
1084
- return ClippingPolygonCollection.getTextureResolution(
1085
- texture,
1086
- clippingPolygonCollection.pixelsNeededForExtents,
1087
- result,
1088
- );
744
+ ClippingPolygonCollection.isSupported = function (scene) {
745
+ return scene?.context.webgl2;
1089
746
  };
1090
747
 
1091
748
  /**
@@ -1096,9 +753,14 @@ ClippingPolygonCollection.getClippingExtentsTextureResolution = function (
1096
753
  *
1097
754
  * @returns {boolean} <code>true</code> if this object was destroyed; otherwise, <code>false</code>.
1098
755
  *
756
+ * @deprecated This function was deprecated in CesiumJS 1.145 and will be removed in 1.147. The collection no longer holds any GPU resources of its own, so it does not need to be destroyed.
1099
757
  * @see ClippingPolygonCollection#destroy
1100
758
  */
1101
759
  ClippingPolygonCollection.prototype.isDestroyed = function () {
760
+ deprecationWarning(
761
+ "ClippingPolygonCollection.isDestroyed",
762
+ isDestroyedDeprecationMessage,
763
+ );
1102
764
  return false;
1103
765
  };
1104
766
 
@@ -1116,18 +778,14 @@ ClippingPolygonCollection.prototype.isDestroyed = function () {
1116
778
  * @example
1117
779
  * clippingPolygons = clippingPolygons && clippingPolygons.destroy();
1118
780
  *
781
+ * @deprecated This function was deprecated in CesiumJS 1.145 and will be removed in 1.147. The collection no longer holds any GPU resources of its own, so it does not need to be destroyed.
1119
782
  * @see ClippingPolygonCollection#isDestroyed
1120
783
  */
1121
784
  ClippingPolygonCollection.prototype.destroy = function () {
1122
- if (defined(this._signedDistanceComputeCommand)) {
1123
- this._signedDistanceComputeCommand.canceled = true;
1124
- }
1125
-
1126
- this._polygonsTexture =
1127
- this._polygonsTexture && this._polygonsTexture.destroy();
1128
- this._extentsTexture = this._extentsTexture && this._extentsTexture.destroy();
1129
- this._signedDistanceTexture =
1130
- this._signedDistanceTexture && this._signedDistanceTexture.destroy();
785
+ deprecationWarning(
786
+ "ClippingPolygonCollection.destroy",
787
+ destroyDeprecationMessage,
788
+ );
1131
789
  return destroyObject(this);
1132
790
  };
1133
791