@cesium/engine 26.0.0 → 26.2.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 (471) hide show
  1. package/Build/ThirdParty/Workers/zip-web-worker.js +586 -480
  2. package/Build/Workers/{chunk-7J2HKPRH.js → chunk-27FWRTJI.js} +9 -9
  3. package/Build/Workers/{chunk-EF2QYXGA.js → chunk-2EFYUSUY.js} +14 -14
  4. package/Build/Workers/chunk-2H5264K7.js +1284 -0
  5. package/Build/Workers/{chunk-DOBXCNC3.js → chunk-2H73KDBM.js} +13 -13
  6. package/Build/Workers/chunk-2RGJPWQX.js +1284 -0
  7. package/Build/Workers/chunk-2Z4ZLVOD.js +352 -0
  8. package/Build/Workers/{chunk-F6QDY6HU.js → chunk-2ZKH2QZB.js} +13 -13
  9. package/Build/Workers/chunk-36NI5E6W.js +3820 -0
  10. package/Build/Workers/{chunk-ZK3CF7ZD.js → chunk-37SW7SYS.js} +12 -12
  11. package/Build/Workers/chunk-3GHVJ3SO.js +455 -0
  12. package/Build/Workers/chunk-3LB4UVPU.js +387 -0
  13. package/Build/Workers/chunk-3PONLKEL.js +778 -0
  14. package/Build/Workers/{chunk-Y57HREW5.js → chunk-3PSS3T43.js} +4 -4
  15. package/Build/Workers/chunk-3QR662HH.js +3820 -0
  16. package/Build/Workers/{chunk-QN67VG36.js → chunk-3SX2WYSO.js} +6 -6
  17. package/Build/Workers/{chunk-G7PXZRVF.js → chunk-3UDN6LYX.js} +7 -7
  18. package/Build/Workers/chunk-47MCBSXI.js +9237 -0
  19. package/Build/Workers/{chunk-KKOSKAZB.js → chunk-4E626OCE.js} +17 -17
  20. package/Build/Workers/chunk-4NW2MJKH.js +455 -0
  21. package/Build/Workers/{chunk-DBOEKL43.js → chunk-52YK5BSN.js} +7 -7
  22. package/Build/Workers/{chunk-KFSTQKNM.js → chunk-5LSOO2KD.js} +7 -7
  23. package/Build/Workers/chunk-5RNAQZK6.js +9234 -0
  24. package/Build/Workers/chunk-5YPQBFRD.js +519 -0
  25. package/Build/Workers/{chunk-S4MCOY6I.js → chunk-6FHT43QR.js} +5 -5
  26. package/Build/Workers/chunk-6FZDPMTO.js +455 -0
  27. package/Build/Workers/{chunk-VQYETPWC.js → chunk-6HK6IXK2.js} +4 -4
  28. package/Build/Workers/chunk-6R5X2GUA.js +1284 -0
  29. package/Build/Workers/{chunk-AYKR4VBR.js → chunk-6YR6JBMY.js} +2 -2
  30. package/Build/Workers/chunk-76FDC45O.js +511 -0
  31. package/Build/Workers/chunk-7A2OGDHT.js +305 -0
  32. package/Build/Workers/chunk-7CGEQUM2.js +305 -0
  33. package/Build/Workers/{chunk-54I6Y66F.js → chunk-7D2HZKH7.js} +6 -6
  34. package/Build/Workers/{chunk-3VFEWOBI.js → chunk-7I325HV6.js} +7 -7
  35. package/Build/Workers/{chunk-4MGMYHOO.js → chunk-7KVKHY7O.js} +6 -6
  36. package/Build/Workers/chunk-7MM3N2VE.js +1067 -0
  37. package/Build/Workers/chunk-7TKLTCZW.js +219 -0
  38. package/Build/Workers/chunk-7UUKBDH6.js +1054 -0
  39. package/Build/Workers/chunk-7W6DUHAB.js +693 -0
  40. package/Build/Workers/{chunk-DDWSZVMY.js → chunk-7XM5JK5F.js} +5 -5
  41. package/Build/Workers/chunk-7YG3ND3P.js +454 -0
  42. package/Build/Workers/{chunk-IRBKFCEJ.js → chunk-A3O6EDBK.js} +2 -2
  43. package/Build/Workers/chunk-A62YI6S6.js +305 -0
  44. package/Build/Workers/{chunk-V7VQKN6N.js → chunk-A6X24AZI.js} +5 -5
  45. package/Build/Workers/chunk-A7TTWVTF.js +2719 -0
  46. package/Build/Workers/chunk-ACTVJHSP.js +519 -0
  47. package/Build/Workers/chunk-ADX3CBKD.js +9234 -0
  48. package/Build/Workers/{chunk-52JDLOEM.js → chunk-AF7DTMJ7.js} +14 -14
  49. package/Build/Workers/{chunk-ZP7JMQV4.js → chunk-AHWAZRBV.js} +6 -2
  50. package/Build/Workers/chunk-AJSFRY4U.js +1344 -0
  51. package/Build/Workers/{chunk-EBSIOBXY.js → chunk-ARZICEEP.js} +8 -8
  52. package/Build/Workers/chunk-B3QHNA4A.js +147 -0
  53. package/Build/Workers/{chunk-YLY7NKAB.js → chunk-B4CQSLZJ.js} +4 -4
  54. package/Build/Workers/chunk-BKPQFCXH.js +511 -0
  55. package/Build/Workers/{chunk-O3EA5HS7.js → chunk-BSPCI2LO.js} +10 -10
  56. package/Build/Workers/chunk-BUJWSX5S.js +301 -0
  57. package/Build/Workers/{chunk-J6BWOHUF.js → chunk-C7JQVRLM.js} +3 -3
  58. package/Build/Workers/chunk-C7QDUNI3.js +138 -0
  59. package/Build/Workers/{chunk-KSSWJIZW.js → chunk-CDJDJ5LK.js} +2 -2
  60. package/Build/Workers/chunk-CEEZE3YZ.js +476 -0
  61. package/Build/Workers/chunk-CIV5DJOQ.js +778 -0
  62. package/Build/Workers/{chunk-INUEEEQA.js → chunk-CLCTQVVL.js} +8 -8
  63. package/Build/Workers/{chunk-C6J67V5A.js → chunk-CQNFIAZU.js} +1 -1
  64. package/Build/Workers/chunk-CRCGE4J4.js +9237 -0
  65. package/Build/Workers/{chunk-SMQZZOW6.js → chunk-CUTRKXUQ.js} +10 -10
  66. package/Build/Workers/{chunk-Q3PY526V.js → chunk-D6AY775A.js} +6 -6
  67. package/Build/Workers/chunk-DBD5WWG2.js +959 -0
  68. package/Build/Workers/{chunk-E7VQ76KE.js → chunk-DIGUUD6G.js} +6 -6
  69. package/Build/Workers/{chunk-P3CK7MCY.js → chunk-DSGLDRTI.js} +4 -4
  70. package/Build/Workers/chunk-DZBQUULR.js +138 -0
  71. package/Build/Workers/chunk-DZUFEE4L.js +140 -0
  72. package/Build/Workers/chunk-E2NKV5YT.js +3820 -0
  73. package/Build/Workers/{chunk-424RNO3D.js → chunk-E7NZJOK7.js} +196 -22
  74. package/Build/Workers/{chunk-UOOIQ3KX.js → chunk-EB3Y5P3A.js} +12 -12
  75. package/Build/Workers/{chunk-ACXQXN46.js → chunk-EHTS2YPT.js} +16 -16
  76. package/Build/Workers/{chunk-EPYXRCDB.js → chunk-ELE6SC2C.js} +12 -12
  77. package/Build/Workers/{chunk-VWV2IJRB.js → chunk-ENNFMWDW.js} +11 -11
  78. package/Build/Workers/chunk-EOWDZN5S.js +288 -0
  79. package/Build/Workers/chunk-ERKUET22.js +3201 -0
  80. package/Build/Workers/chunk-EZGQPOIG.js +162 -0
  81. package/Build/Workers/chunk-F2IMBMZY.js +241 -0
  82. package/Build/Workers/chunk-F4CSNRZO.js +219 -0
  83. package/Build/Workers/chunk-FBP4DUQJ.js +693 -0
  84. package/Build/Workers/{chunk-FRQZECAO.js → chunk-FCP2QY4G.js} +5 -5
  85. package/Build/Workers/{chunk-ZZ46LWL6.js → chunk-FDK4K5IA.js} +1 -1
  86. package/Build/Workers/{chunk-C6KNZ7T4.js → chunk-FGQFQHN5.js} +17 -17
  87. package/Build/Workers/chunk-FJWZMGOQ.js +1992 -0
  88. package/Build/Workers/{chunk-Y5BF6AFU.js → chunk-FQ42MT7M.js} +2 -2
  89. package/Build/Workers/chunk-FU4BGABC.js +398 -0
  90. package/Build/Workers/chunk-FX3VEAIU.js +2719 -0
  91. package/Build/Workers/chunk-GGNWQWSB.js +301 -0
  92. package/Build/Workers/chunk-GHXVQVUM.js +1344 -0
  93. package/Build/Workers/{chunk-CZEYZU4N.js → chunk-GNKXEN4C.js} +10 -10
  94. package/Build/Workers/{chunk-MYP774IS.js → chunk-GSWMAFTE.js} +8 -8
  95. package/Build/Workers/chunk-GVA7XQI2.js +368 -0
  96. package/Build/Workers/chunk-GXDHRC4J.js +1344 -0
  97. package/Build/Workers/chunk-GXWQZBAI.js +58 -0
  98. package/Build/Workers/chunk-GYSYP6PC.js +1067 -0
  99. package/Build/Workers/chunk-H2WCFXLP.js +241 -0
  100. package/Build/Workers/chunk-HDL4HOXZ.js +778 -0
  101. package/Build/Workers/chunk-HHV3MCGV.js +162 -0
  102. package/Build/Workers/chunk-HLW2ZRVK.js +368 -0
  103. package/Build/Workers/chunk-HS6AD4P2.js +398 -0
  104. package/Build/Workers/chunk-HT6FASOT.js +973 -0
  105. package/Build/Workers/chunk-I74ZH5LK.js +959 -0
  106. package/Build/Workers/{chunk-7WM2PX4V.js → chunk-IDVHUDZT.js} +5 -5
  107. package/Build/Workers/chunk-IGAZBTFZ.js +3201 -0
  108. package/Build/Workers/chunk-IJZJMIUY.js +789 -0
  109. package/Build/Workers/chunk-ILME5BXA.js +301 -0
  110. package/Build/Workers/chunk-IMBVP57H.js +44 -0
  111. package/Build/Workers/chunk-IOO7Z2AV.js +57 -0
  112. package/Build/Workers/chunk-IUIFLOYO.js +44 -0
  113. package/Build/Workers/chunk-J73T2VOY.js +171 -0
  114. package/Build/Workers/chunk-JALGQYDY.js +288 -0
  115. package/Build/Workers/chunk-JKXV6PG5.js +56 -0
  116. package/Build/Workers/chunk-JW6OZT4R.js +288 -0
  117. package/Build/Workers/{chunk-CXOYE2WM.js → chunk-JXYLJCTC.js} +5 -5
  118. package/Build/Workers/{chunk-CFQP6LYM.js → chunk-K27QOAW6.js} +4 -4
  119. package/Build/Workers/chunk-KGXSYGBG.js +387 -0
  120. package/Build/Workers/chunk-KMV25A63.js +789 -0
  121. package/Build/Workers/chunk-KP5QD7WU.js +693 -0
  122. package/Build/Workers/chunk-KZWFWJML.js +2719 -0
  123. package/Build/Workers/chunk-LCXRRALY.js +387 -0
  124. package/Build/Workers/chunk-LD64RPYV.js +368 -0
  125. package/Build/Workers/{chunk-U3ZA64U7.js → chunk-LDRQSYBN.js} +2 -2
  126. package/Build/Workers/chunk-LGNDTZVX.js +97 -0
  127. package/Build/Workers/chunk-LNSQVXFH.js +1800 -0
  128. package/Build/Workers/chunk-M4JZ6TSZ.js +959 -0
  129. package/Build/Workers/chunk-M6QKXVAU.js +1054 -0
  130. package/Build/Workers/chunk-MAAHFYPC.js +198 -0
  131. package/Build/Workers/chunk-MCJDRDJQ.js +102 -0
  132. package/Build/Workers/chunk-MEENMEAH.js +198 -0
  133. package/Build/Workers/{chunk-TKKIREQ6.js → chunk-N7CCOFLX.js} +1 -1
  134. package/Build/Workers/chunk-NAWU5RF4.js +162 -0
  135. package/Build/Workers/{chunk-M3B5JKSM.js → chunk-NCL22ZUX.js} +1 -1
  136. package/Build/Workers/chunk-NEFDMMLY.js +241 -0
  137. package/Build/Workers/{chunk-UA25D5MX.js → chunk-NIWITKQK.js} +10 -10
  138. package/Build/Workers/chunk-NJVBJG63.js +124 -0
  139. package/Build/Workers/chunk-NLLCQBX3.js +73 -0
  140. package/Build/Workers/chunk-NSKZ6SBK.js +1483 -0
  141. package/Build/Workers/chunk-NXGQBQWE.js +837 -0
  142. package/Build/Workers/chunk-O3DKEX7Q.js +352 -0
  143. package/Build/Workers/chunk-O3XFXGPZ.js +476 -0
  144. package/Build/Workers/chunk-OA6MYL2C.js +837 -0
  145. package/Build/Workers/chunk-OBEU25PI.js +1067 -0
  146. package/Build/Workers/chunk-OHP4ELS7.js +198 -0
  147. package/Build/Workers/chunk-OZGPS7FB.js +138 -0
  148. package/Build/Workers/chunk-PCL3Y7H5.js +82 -0
  149. package/Build/Workers/chunk-PD4GK4EM.js +57 -0
  150. package/Build/Workers/chunk-PEDU33QG.js +2342 -0
  151. package/Build/Workers/chunk-PRWUMCXF.js +682 -0
  152. package/Build/Workers/chunk-PVTSNNVI.js +288 -0
  153. package/Build/Workers/chunk-QFSSCLLZ.js +973 -0
  154. package/Build/Workers/chunk-QHPZH22L.js +241 -0
  155. package/Build/Workers/chunk-QIZDWZK6.js +301 -0
  156. package/Build/Workers/chunk-QV6DG2YX.js +1483 -0
  157. package/Build/Workers/chunk-QVLAFFJY.js +56 -0
  158. package/Build/Workers/{chunk-6YEE6JDR.js → chunk-R4FPNAZ2.js} +6 -6
  159. package/Build/Workers/chunk-R4K7EHOU.js +171 -0
  160. package/Build/Workers/chunk-R7JGHDD6.js +789 -0
  161. package/Build/Workers/chunk-RASQEYD4.js +1483 -0
  162. package/Build/Workers/chunk-RG4F5R57.js +454 -0
  163. package/Build/Workers/chunk-RW6ITX7Q.js +3820 -0
  164. package/Build/Workers/chunk-RYSQVJR6.js +398 -0
  165. package/Build/Workers/chunk-S6RJU5NM.js +1054 -0
  166. package/Build/Workers/chunk-SA2A2AN5.js +2342 -0
  167. package/Build/Workers/chunk-SDFHDNS4.js +147 -0
  168. package/Build/Workers/chunk-SF6K72D7.js +124 -0
  169. package/Build/Workers/chunk-SGRGNDOD.js +682 -0
  170. package/Build/Workers/{chunk-QRWGUWI6.js → chunk-SJYSIOEM.js} +11 -11
  171. package/Build/Workers/chunk-SM2CDCYF.js +198 -0
  172. package/Build/Workers/chunk-SMTGMFBL.js +97 -0
  173. package/Build/Workers/chunk-SS5ABQGY.js +102 -0
  174. package/Build/Workers/{chunk-IYOUHCZB.js → chunk-SXSP3JHS.js} +1 -1
  175. package/Build/Workers/chunk-T5QBPLE3.js +414 -0
  176. package/Build/Workers/chunk-TN35HP5B.js +1067 -0
  177. package/Build/Workers/chunk-TNWKJNUZ.js +454 -0
  178. package/Build/Workers/chunk-TOAF47AQ.js +102 -0
  179. package/Build/Workers/chunk-TQ4QCOXT.js +2719 -0
  180. package/Build/Workers/chunk-TSDSILQB.js +124 -0
  181. package/Build/Workers/chunk-TVZD72WJ.js +778 -0
  182. package/Build/Workers/chunk-U5LV3F3Z.js +1054 -0
  183. package/Build/Workers/chunk-UAZUP4I5.js +1992 -0
  184. package/Build/Workers/chunk-UEY73NRN.js +38 -0
  185. package/Build/Workers/chunk-UF46SZEZ.js +789 -0
  186. package/Build/Workers/chunk-UNRTMCET.js +398 -0
  187. package/Build/Workers/chunk-UTB7U3O6.js +1992 -0
  188. package/Build/Workers/chunk-UVO6COT2.js +352 -0
  189. package/Build/Workers/chunk-V46YGZE6.js +352 -0
  190. package/Build/Workers/chunk-VAL7DYNR.js +278 -0
  191. package/Build/Workers/chunk-VDGOCROW.js +57 -0
  192. package/Build/Workers/chunk-VFWSSBPT.js +511 -0
  193. package/Build/Workers/chunk-VVYMXI3I.js +1284 -0
  194. package/Build/Workers/chunk-VXWHPYQM.js +837 -0
  195. package/Build/Workers/chunk-VXYUBRSB.js +219 -0
  196. package/Build/Workers/chunk-VZLDLEWI.js +387 -0
  197. package/Build/Workers/{chunk-4S7IE3LB.js → chunk-W5OCKMPJ.js} +2 -2
  198. package/Build/Workers/chunk-WBSY7HDY.js +837 -0
  199. package/Build/Workers/chunk-WN3F4CVG.js +3201 -0
  200. package/Build/Workers/chunk-WPRUWXGV.js +693 -0
  201. package/Build/Workers/chunk-WTO2ERBP.js +414 -0
  202. package/Build/Workers/chunk-WVHMDVG4.js +959 -0
  203. package/Build/Workers/chunk-XCBZVTIV.js +280 -0
  204. package/Build/Workers/chunk-XDWCTQCZ.js +101 -0
  205. package/Build/Workers/chunk-XGA23TAX.js +73 -0
  206. package/Build/Workers/chunk-XLQZNQ4Z.js +163 -0
  207. package/Build/Workers/chunk-XLXSDIP5.js +973 -0
  208. package/Build/Workers/chunk-XQ3SKCMM.js +140 -0
  209. package/Build/Workers/chunk-XQH66YJC.js +147 -0
  210. package/Build/Workers/chunk-XTA7BXJG.js +682 -0
  211. package/Build/Workers/chunk-XTIDAFRS.js +476 -0
  212. package/Build/Workers/chunk-XUEDWBUD.js +682 -0
  213. package/Build/Workers/chunk-XYFLRH3H.js +124 -0
  214. package/Build/Workers/chunk-Y7JRTRTO.js +305 -0
  215. package/Build/Workers/chunk-Y7QSMDCJ.js +352 -0
  216. package/Build/Workers/chunk-YCB5TYTR.js +1483 -0
  217. package/Build/Workers/chunk-YEYOSTJX.js +219 -0
  218. package/Build/Workers/chunk-YGFVAGYF.js +630 -0
  219. package/Build/Workers/chunk-YIIACKQO.js +368 -0
  220. package/Build/Workers/chunk-YJGSP6PE.js +511 -0
  221. package/Build/Workers/{chunk-XZMBNNDX.js → chunk-YKU2Q3A2.js} +9 -9
  222. package/Build/Workers/chunk-Z4LR5EHE.js +454 -0
  223. package/Build/Workers/chunk-Z66EVE2A.js +44 -0
  224. package/Build/Workers/chunk-ZHIHHHTB.js +414 -0
  225. package/Build/Workers/chunk-ZMBHFYOX.js +1344 -0
  226. package/Build/Workers/chunk-ZNWHFSLE.js +171 -0
  227. package/Build/Workers/chunk-ZQLZG4IN.js +2342 -0
  228. package/Build/Workers/chunk-ZRTSMUZ2.js +414 -0
  229. package/Build/Workers/{chunk-MPZHGZU6.js → chunk-ZSGUV73H.js} +4 -4
  230. package/Build/Workers/chunk-ZZUVT5BM.js +476 -0
  231. package/Build/Workers/combineGeometry.js +24 -24
  232. package/Build/Workers/createBoxGeometry.js +18 -18
  233. package/Build/Workers/createBoxOutlineGeometry.js +16 -16
  234. package/Build/Workers/createCircleGeometry.js +26 -26
  235. package/Build/Workers/createCircleOutlineGeometry.js +19 -19
  236. package/Build/Workers/createCoplanarPolygonGeometry.js +35 -35
  237. package/Build/Workers/createCoplanarPolygonOutlineGeometry.js +31 -31
  238. package/Build/Workers/createCorridorGeometry.js +31 -33
  239. package/Build/Workers/createCorridorOutlineGeometry.js +29 -31
  240. package/Build/Workers/createCylinderGeometry.js +20 -20
  241. package/Build/Workers/createCylinderOutlineGeometry.js +18 -18
  242. package/Build/Workers/createEllipseGeometry.js +26 -26
  243. package/Build/Workers/createEllipseOutlineGeometry.js +19 -19
  244. package/Build/Workers/createEllipsoidGeometry.js +19 -19
  245. package/Build/Workers/createEllipsoidOutlineGeometry.js +18 -18
  246. package/Build/Workers/createFrustumGeometry.js +18 -18
  247. package/Build/Workers/createFrustumOutlineGeometry.js +18 -18
  248. package/Build/Workers/createGeometry.js +24 -24
  249. package/Build/Workers/createGroundPolylineGeometry.js +24 -24
  250. package/Build/Workers/createPlaneGeometry.js +16 -16
  251. package/Build/Workers/createPlaneOutlineGeometry.js +15 -15
  252. package/Build/Workers/createPolygonGeometry.js +34 -34
  253. package/Build/Workers/createPolygonOutlineGeometry.js +31 -31
  254. package/Build/Workers/createPolylineGeometry.js +26 -26
  255. package/Build/Workers/createPolylineVolumeGeometry.js +31 -31
  256. package/Build/Workers/createPolylineVolumeOutlineGeometry.js +27 -27
  257. package/Build/Workers/createRectangleGeometry.js +27 -27
  258. package/Build/Workers/createRectangleOutlineGeometry.js +21 -21
  259. package/Build/Workers/createSimplePolylineGeometry.js +24 -24
  260. package/Build/Workers/createSphereGeometry.js +19 -19
  261. package/Build/Workers/createSphereOutlineGeometry.js +18 -18
  262. package/Build/Workers/createTaskProcessorWorker.js +3 -3
  263. package/Build/Workers/createVectorTileClampedPolylines.js +14 -14
  264. package/Build/Workers/createVectorTileGeometries.js +24 -24
  265. package/Build/Workers/createVectorTilePoints.js +13 -13
  266. package/Build/Workers/createVectorTilePolygons.js +22 -22
  267. package/Build/Workers/createVectorTilePolylines.js +14 -14
  268. package/Build/Workers/createVerticesFromCesium3DTilesTerrain.js +25 -25
  269. package/Build/Workers/createVerticesFromGoogleEarthEnterpriseBuffer.js +22 -22
  270. package/Build/Workers/createVerticesFromHeightmap.js +22 -22
  271. package/Build/Workers/createVerticesFromQuantizedTerrainMesh.js +20 -20
  272. package/Build/Workers/createWallGeometry.js +24 -24
  273. package/Build/Workers/createWallOutlineGeometry.js +24 -24
  274. package/Build/Workers/decodeDraco.js +10 -10
  275. package/Build/Workers/decodeGoogleEarthEnterprisePacket.js +987 -2320
  276. package/Build/Workers/decodeI3S.js +10 -10
  277. package/Build/Workers/gaussianSplatSorter.js +4 -4
  278. package/Build/Workers/gaussianSplatTextureGenerator.js +4 -4
  279. package/Build/Workers/incrementallyBuildTerrainPicker.js +10 -10
  280. package/Build/Workers/transcodeKTX2.js +6 -6
  281. package/Build/Workers/transferTypedArrayTest.js +1 -1
  282. package/Build/Workers/upsampleQuantizedTerrainMesh.js +22 -22
  283. package/Build/Workers/upsampleVerticesFromCesium3DTilesTerrain.js +25 -25
  284. package/Source/Core/ArcGISTiledElevationTerrainProvider.js +1 -5
  285. package/Source/Core/BoundingRectangle.js +6 -8
  286. package/Source/Core/BoundingSphere.js +0 -3
  287. package/Source/Core/Cesium3DTilesTerrainGeometryProcessor.js +3 -4
  288. package/Source/Core/Color.js +1 -0
  289. package/Source/Core/CoplanarPolygonGeometry.js +2 -2
  290. package/Source/Core/CorridorGeometry.js +2 -4
  291. package/Source/Core/CorridorOutlineGeometry.js +1 -3
  292. package/Source/Core/EarthOrientationParameters.js +2 -2
  293. package/Source/Core/EllipseGeometryLibrary.js +2 -2
  294. package/Source/Core/EllipsoidGeodesic.js +3 -3
  295. package/Source/Core/EllipsoidRhumbLine.js +1 -1
  296. package/Source/Core/GroundPolylineGeometry.js +2 -2
  297. package/Source/Core/Heap.js +1 -1
  298. package/Source/Core/HermitePolynomialApproximation.js +215 -179
  299. package/Source/Core/InterpolationAlgorithm.js +58 -50
  300. package/Source/Core/Ion.js +1 -1
  301. package/Source/Core/JulianDate.js +1 -1
  302. package/Source/Core/LagrangePolynomialApproximation.js +55 -52
  303. package/Source/Core/LinearApproximation.js +69 -66
  304. package/Source/Core/Math.js +59 -0
  305. package/Source/Core/Matrix2.js +2 -2
  306. package/Source/Core/Matrix3.js +2 -2
  307. package/Source/Core/OrthographicFrustum.js +1 -1
  308. package/Source/Core/PerspectiveFrustum.js +1 -1
  309. package/Source/Core/PolygonGeometry.js +2 -2
  310. package/Source/Core/PolygonGeometryLibrary.js +1 -1
  311. package/Source/Core/PolygonOutlineGeometry.js +1 -1
  312. package/Source/Core/PolylineGeometry.js +1 -1
  313. package/Source/Core/PolylineVolumeGeometryLibrary.js +1 -1
  314. package/Source/Core/Rectangle.js +7 -1
  315. package/Source/Core/RectangleOutlineGeometry.js +1 -1
  316. package/Source/Core/SimplePolylineGeometry.js +1 -1
  317. package/Source/Core/TerrainEncoding.js +2 -2
  318. package/Source/Core/TerrainMesh.js +3 -3
  319. package/Source/Core/TerrainPicker.js +180 -168
  320. package/Source/Core/TimeIntervalCollection.js +1 -3
  321. package/Source/Core/Tipsify.js +1 -1
  322. package/Source/Core/Transforms.js +5 -1
  323. package/Source/Core/VectorPipeline.js +1117 -0
  324. package/Source/Core/VectorProvider.js +429 -0
  325. package/Source/Core/WallOutlineGeometry.js +1 -1
  326. package/Source/Core/getTimestamp.js +4 -2
  327. package/Source/Core/writeTextToCanvas.js +1 -0
  328. package/Source/DataSources/CompositeEntityCollection.js +0 -1
  329. package/Source/DataSources/CzmlDataSource.js +14 -0
  330. package/Source/DataSources/DataSourceDisplay.js +1 -1
  331. package/Source/DataSources/GeoJsonDataSource.js +0 -1
  332. package/Source/DataSources/GeometryVisualizer.js +1 -1
  333. package/Source/DataSources/KmlDataSource.js +529 -557
  334. package/Source/DataSources/PathGraphics.js +8 -1
  335. package/Source/DataSources/PathMode.js +27 -0
  336. package/Source/DataSources/PathVisualizer.js +298 -1
  337. package/Source/DataSources/PolylineVisualizer.js +1 -1
  338. package/Source/DataSources/StaticOutlineGeometryBatch.js +1 -1
  339. package/Source/Renderer/AutomaticUniforms.js +23 -0
  340. package/Source/Renderer/Context.js +9 -3
  341. package/Source/Renderer/DrawCommand.js +22 -0
  342. package/Source/Renderer/Framebuffer.js +4 -0
  343. package/Source/Renderer/Pass.js +11 -10
  344. package/Source/Renderer/Texture.js +12 -1
  345. package/Source/Renderer/UniformState.js +7 -0
  346. package/Source/Renderer/VertexArray.js +1 -1
  347. package/Source/Scene/ArcGisMapServerImageryProvider.js +0 -5
  348. package/Source/Scene/ArcGisMapService.js +1 -1
  349. package/Source/Scene/Billboard.js +2 -1
  350. package/Source/Scene/BillboardCollection.js +7 -3
  351. package/Source/Scene/BillboardTexture.js +5 -3
  352. package/Source/Scene/BufferPrimitiveCollection.js +27 -5
  353. package/Source/Scene/Camera.js +71 -5
  354. package/Source/Scene/Cesium3DTileOptimizations.js +4 -6
  355. package/Source/Scene/Cesium3DTileset.js +1 -1
  356. package/Source/Scene/ClippingPlaneCollection.js +4 -4
  357. package/Source/Scene/ClippingPolygon.js +2 -0
  358. package/Source/Scene/ClippingPolygonCollection.js +2 -2
  359. package/Source/Scene/Controllers/Controller.js +63 -0
  360. package/Source/Scene/Controllers/ControllerHost.js +78 -0
  361. package/Source/Scene/Controllers/HybridScreenSpacePanCameraController.js +106 -0
  362. package/Source/Scene/Controllers/MouseButton.js +32 -0
  363. package/Source/Scene/Controllers/ScreenSpaceElevatorCameraController.js +295 -0
  364. package/Source/Scene/Controllers/ScreenSpaceInputBindings.js +154 -0
  365. package/Source/Scene/Controllers/ScreenSpaceMapCameraController.js +310 -0
  366. package/Source/Scene/Controllers/ScreenSpaceTiltOrbitCameraController.js +642 -0
  367. package/Source/Scene/Controllers/ScreenSpaceZoomCameraController.js +431 -0
  368. package/Source/Scene/Controllers/defaultPickWorldPosition.js +84 -0
  369. package/Source/Scene/DerivedCommand.js +98 -0
  370. package/Source/Scene/EdgeFramebuffer.js +1 -5
  371. package/Source/Scene/Expression.js +6 -8
  372. package/Source/Scene/FrameState.js +17 -0
  373. package/Source/Scene/Globe.js +20 -0
  374. package/Source/Scene/GlobeDepth.js +27 -1
  375. package/Source/Scene/GlobeSurfaceShaderSet.js +511 -409
  376. package/Source/Scene/GlobeSurfaceTile.js +575 -398
  377. package/Source/Scene/GlobeSurfaceTileProvider.js +1382 -1151
  378. package/Source/Scene/GltfBufferViewLoader.js +3 -3
  379. package/Source/Scene/GltfLoader.js +33 -3
  380. package/Source/Scene/GltfLoaderUtil.js +20 -4
  381. package/Source/Scene/GltfPipeline/forEachTextureInMaterial.js +10 -0
  382. package/Source/Scene/GltfPipeline/removeUnusedElements.js +21 -11
  383. package/Source/Scene/GltfSpzLoader.js +1 -1
  384. package/Source/Scene/GltfVertexBufferLoader.js +6 -3
  385. package/Source/Scene/I3SDataProvider.js +1 -1
  386. package/Source/Scene/I3SLayer.js +1 -1
  387. package/Source/Scene/I3SNode.js +2 -2
  388. package/Source/Scene/ImageryLayer.js +2 -2
  389. package/Source/Scene/ImageryLayerCollection.js +190 -6
  390. package/Source/Scene/IonImageryProvider.js +1 -5
  391. package/Source/Scene/Label.js +4 -4
  392. package/Source/Scene/LabelCollection.js +1 -1
  393. package/Source/Scene/MVTDataProvider.js +2 -0
  394. package/Source/Scene/Material.js +1 -0
  395. package/Source/Scene/Model/B3dmLoader.js +1 -2
  396. package/Source/Scene/Model/EdgeVisibilityPipelineStage.js +10 -8
  397. package/Source/Scene/Model/Extensions/Gpm/GltfGpmLoader.js +4 -0
  398. package/Source/Scene/Model/I3dmLoader.js +1 -1
  399. package/Source/Scene/Model/InstancingPipelineStage.js +4 -7
  400. package/Source/Scene/Model/MaterialPipelineStage.js +124 -1
  401. package/Source/Scene/Model/Model.js +11 -10
  402. package/Source/Scene/Model/ModelClippingPlanesPipelineStage.js +28 -1
  403. package/Source/Scene/Model/ModelDrawCommand.js +160 -16
  404. package/Source/Scene/Model/ModelDrawCommands.js +4 -0
  405. package/Source/Scene/Model/ModelSceneGraph.js +21 -0
  406. package/Source/Scene/Model/ModelUtility.js +1 -0
  407. package/Source/Scene/Model/PickingPipelineStage.js +29 -0
  408. package/Source/Scene/Model/PrimitiveRenderResources.js +24 -0
  409. package/Source/Scene/ModelComponents.js +71 -0
  410. package/Source/Scene/Picking.js +19 -3
  411. package/Source/Scene/PlanarFillIdFramebuffer.js +172 -0
  412. package/Source/Scene/PntsParser.js +1 -1
  413. package/Source/Scene/PolylineCollection.js +1 -1
  414. package/Source/Scene/PostProcessStage.js +4 -2
  415. package/Source/Scene/QuadtreePrimitive.js +3 -2
  416. package/Source/Scene/ResourceCache.js +7 -4
  417. package/Source/Scene/ResourceCacheKey.js +21 -18
  418. package/Source/Scene/Scene.js +203 -5
  419. package/Source/Scene/ScreenSpaceCameraController.js +1 -2
  420. package/Source/Scene/ShadowMap.js +9 -3
  421. package/Source/Scene/ShadowMapShader.js +50 -2
  422. package/Source/Scene/SnapFramebuffer.js +121 -0
  423. package/Source/Scene/Snapping.js +184 -0
  424. package/Source/Scene/TerrainFillMesh.js +3 -2
  425. package/Source/Scene/UrlTemplate3DTilesDataProvider.js +1 -1
  426. package/Source/Scene/Vector3DTileContent.js +2 -3
  427. package/Source/Scene/VectorGltf3DTileContent.js +23 -3
  428. package/Source/Scene/View.js +10 -8
  429. package/Source/Scene/VoxelTraversal.js +1 -1
  430. package/Source/Scene/createElevationBandMaterial.js +1 -1
  431. package/Source/Scene/findMeshoptExtension.js +23 -0
  432. package/Source/Scene/renderBufferPointCollection.js +14 -10
  433. package/Source/Scene/renderBufferPolygonCollection.js +10 -15
  434. package/Source/Scene/renderBufferPolylineCollection.js +121 -194
  435. package/Source/Shaders/Builtin/Constants/passCesium3DTile.glsl +1 -1
  436. package/Source/Shaders/Builtin/Constants/passCesium3DTile.js +1 -1
  437. package/Source/Shaders/Builtin/Constants/passCesium3DTileClassification.glsl +1 -1
  438. package/Source/Shaders/Builtin/Constants/passCesium3DTileClassification.js +1 -1
  439. package/Source/Shaders/Builtin/Constants/passCesium3DTileClassificationIgnoreShow.glsl +1 -1
  440. package/Source/Shaders/Builtin/Constants/passCesium3DTileClassificationIgnoreShow.js +1 -1
  441. package/Source/Shaders/Builtin/Constants/passCesium3DTilePlanarFillId.glsl +9 -0
  442. package/Source/Shaders/Builtin/Constants/passCesium3DTilePlanarFillId.js +11 -0
  443. package/Source/Shaders/Builtin/Constants/passClassification.glsl +1 -1
  444. package/Source/Shaders/Builtin/Constants/passClassification.js +1 -1
  445. package/Source/Shaders/Builtin/Constants/passGaussianSplats.glsl +1 -1
  446. package/Source/Shaders/Builtin/Constants/passGaussianSplats.js +1 -1
  447. package/Source/Shaders/Builtin/Constants/passOpaque.glsl +1 -1
  448. package/Source/Shaders/Builtin/Constants/passOpaque.js +1 -1
  449. package/Source/Shaders/Builtin/Constants/passTranslucent.glsl +1 -1
  450. package/Source/Shaders/Builtin/Constants/passTranslucent.js +1 -1
  451. package/Source/Shaders/Builtin/Constants/passVoxels.glsl +1 -1
  452. package/Source/Shaders/Builtin/Constants/passVoxels.js +1 -1
  453. package/Source/Shaders/Builtin/CzmBuiltins.js +2 -0
  454. package/Source/Shaders/GlobeFS.glsl +10 -5
  455. package/Source/Shaders/GlobeFS.js +9 -5
  456. package/Source/Shaders/Materials/PolylineGlowMaterial.glsl +1 -1
  457. package/Source/Shaders/Materials/PolylineGlowMaterial.js +1 -1
  458. package/Source/Shaders/Model/MaterialStageFS.glsl +8 -2
  459. package/Source/Shaders/Model/MaterialStageFS.js +8 -2
  460. package/Source/Shaders/Model/ModelFS.glsl +105 -0
  461. package/Source/Shaders/Model/ModelFS.js +105 -0
  462. package/Source/Shaders/VectorCommon.glsl +178 -0
  463. package/Source/Shaders/VectorCommon.js +75 -0
  464. package/Source/ThirdParty/Workers/zip-web-worker.js +1 -1
  465. package/Source/ThirdParty/zip-module.wasm +0 -0
  466. package/Source/Widget/CesiumWidget.js +30 -0
  467. package/Source/Workers/decodeGoogleEarthEnterprisePacket.js +2 -2
  468. package/Source/Workers/incrementallyBuildTerrainPicker.js +2 -0
  469. package/index.d.ts +825 -260
  470. package/index.js +29 -10
  471. package/package.json +4 -4
@@ -0,0 +1,1117 @@
1
+ // @ts-check
2
+
3
+ import PixelDatatype from "../Renderer/PixelDatatype.js";
4
+ import Sampler from "../Renderer/Sampler.js";
5
+ import Texture from "../Renderer/Texture.js";
6
+ import BufferPolygon from "../Scene/BufferPolygon.js";
7
+ import BufferPolygonMaterial from "../Scene/BufferPolygonMaterial.js";
8
+ import BufferPolyline from "../Scene/BufferPolyline.js";
9
+ import BufferPolylineMaterial from "../Scene/BufferPolylineMaterial.js";
10
+ import Cartesian2 from "./Cartesian2.js";
11
+ import Cartesian3 from "./Cartesian3.js";
12
+ import Cartographic from "./Cartographic.js";
13
+ import Color from "./Color.js";
14
+ import CesiumMath from "./Math.js";
15
+ import Matrix4 from "./Matrix4.js";
16
+ import PixelFormat from "./PixelFormat.js";
17
+ import defined from "./defined.js";
18
+ import Rectangle from "./Rectangle.js";
19
+
20
+ /** @import BufferPrimitive from "../Scene/BufferPrimitive.js"; */
21
+ /** @import BufferPrimitiveCollection from "../Scene/BufferPrimitiveCollection.js"; */
22
+ /** @import BufferPolygonCollection from "../Scene/BufferPolygonCollection.js"; */
23
+ /** @import BufferPolylineCollection from "../Scene/BufferPolylineCollection.js"; */
24
+ /** @import Context from "../Renderer/Context.js"; */
25
+ /** @import Ellipsoid from "./Ellipsoid.js"; */
26
+ /** @import TilingScheme from "./TilingScheme.js"; */
27
+
28
+ const GRID_TARGET_SEGMENTS_PER_CELL = 16;
29
+ const GRID_NEIGHBOR_PADDING_SCALE = 0.35;
30
+
31
+ const scratchPolyline = new BufferPolyline();
32
+ const scratchPolylineMaterial = new BufferPolylineMaterial();
33
+ const scratchPolygon = new BufferPolygon();
34
+ const scratchPolygonMaterial = new BufferPolygonMaterial();
35
+ const scratchLocalPosition = new Cartesian3();
36
+ const scratchWorldPosition = new Cartesian3();
37
+ const scratchCartographic = new Cartographic();
38
+ const scratchSegmentStart = new Cartesian2();
39
+ const scratchSegmentEnd = new Cartesian2();
40
+
41
+ /**
42
+ * Vector geometry intersecting a terrain tile, mapped into the tile's [0,1]^2 UV domain.
43
+ *
44
+ * @typedef {object} VectorTileData
45
+ *
46
+ * @property {boolean} show Whether this vector data should be rendered.
47
+ *
48
+ * Stage 1: Collect vector segments and polygon rings intersecting tile.
49
+ * @property {number[][]} [polylineSegments] Tile-clipped polyline segments as [ax, ay, bx, by] in tile UV space.
50
+ * @property {number[]} [polylineSegmentPrimitiveIndices] Index per segment, mapping to material for the segment.
51
+ * @property {Float64Array[]} [polygonRings] Tile-clipped polygon rings as flat [x0, y0, x1, y1, ...] in tile UV space.
52
+ * @property {number[]} [polygonRingPrimitiveIndices] Index per ring, mapping to material for the ring.
53
+ * @property {Uint8Array[]} [widths] Primitive widths, by primitive index.
54
+ * @property {Uint8Array[]} [colors] Primitive colors, by primitive index.
55
+ * @property {number} [primitiveCount] Number of vector primitives in tile.
56
+ *
57
+ * Stage 2: Build CPU grid structures.
58
+ * @property {Float32Array} [polylineSegmentTexels] Packed RGBA line segments (ax, ay, bx, by) in tile UV space, -1 filled.
59
+ * @property {number} [polylineSegmentTextureWidth] Width of the segment texture, in texels.
60
+ * @property {number} [polylineSegmentTextureHeight] Height of the segment texture, in texels.
61
+ * @property {Float32Array} [polylineSegmentPrimitiveIndicesTexels] Index per segment, mapping to material for the segment.
62
+ * @property {Uint32Array} [polylineGridCellIndices] Polyline grid header [gridWidth, gridHeight, ...per-cell end offsets].
63
+ * @property {Float32Array} [polygonEdgeTexels] Packed RGBA polygon ring edges (ax, ay, bx, by), clipped per grid cell, -1 filled.
64
+ * @property {number} [polygonEdgeTextureWidth] Width of the polygon edge texture, in texels.
65
+ * @property {number} [polygonEdgeTextureHeight] Height of the polygon edge texture, in texels.
66
+ * @property {Float32Array} [polygonEdgePrimitiveIndicesTexels] Index per polygon edge, mapping to material for the edge.
67
+ * @property {Uint32Array} [polygonGridCellIndices] Polygon grid header [gridWidth, gridHeight, ...per-cell end offsets].
68
+ *
69
+ * Stage 3: Build GPU texture resources, uploaded lazily at draw time.
70
+ * @property {Texture} [polylineSegmentTexture] GPU texture of polylineSegmentTexels.
71
+ * @property {Texture} [polylineSegmentPrimitiveIndicesTexture] GPU texture of primitive indices per segment.
72
+ * @property {Texture} [widthTexture] GPU texture of primitive widths, by primitive index.
73
+ * @property {Texture} [colorTexture] GPU texture of primitive colors, by primitive index.
74
+ * @property {Texture} [polylineGridCellIndicesTexture] GPU texture of polylineGridCellIndices.
75
+ * @property {Texture} [polygonEdgeTexture] GPU texture of polygonEdgeTexels.
76
+ * @property {Texture} [polygonEdgePrimitiveIndicesTexture] GPU texture of primitive indices per polygon edge.
77
+ * @property {Texture} [polygonGridCellIndicesTexture] GPU texture of polygonGridCellIndices.
78
+ *
79
+ * @private
80
+ */
81
+
82
+ /**
83
+ * Snapshot of a vector collection — projected vertex positions and
84
+ * per-primitive material properties — extracted in a single pass so the
85
+ * collection can be marked clean immediately afterward.
86
+ *
87
+ * @typedef {object} VectorCollectionData
88
+ *
89
+ * @property {number} version State of `collection._version` at time data was last updated.
90
+ * @property {Rectangle} rectangle
91
+ * @property {Float64Array} positions Collection positions, projected to the ellipsoid as [lng, lat] in radians.
92
+ * @property {Uint8Array} widths Primitive widths, by primitive index. Zero-filled for polygon collections.
93
+ * @property {Uint8Array} colors Primitive colors, by primitive index.
94
+ *
95
+ * @private
96
+ */
97
+
98
+ /**
99
+ * Pipeline for vector data rendered using clamped {@link HeightReference} modes.
100
+ *
101
+ * Projects vector data into the [0,1]^2 UV domain of a given {@link TilingScheme}, clips to tile
102
+ * bounds, and packs grid-indexed segment lookup tables consumed by Globe and 3D Tiles renderers.
103
+ *
104
+ * @see VectorProvider
105
+ * @ignore
106
+ */
107
+ class VectorPipeline {
108
+ /**
109
+ * @param {BufferPolylineCollection} collection
110
+ * @param {TilingScheme} tilingScheme
111
+ * @param {VectorCollectionData} [result]
112
+ * @returns {VectorCollectionData}
113
+ */
114
+ static packPolylineCollectionData(collection, tilingScheme, result) {
115
+ if (
116
+ defined(result) &&
117
+ collection._dirtyCount === 0 &&
118
+ collection._version === result.version
119
+ ) {
120
+ return result;
121
+ }
122
+
123
+ const primitiveCount = collection.primitiveCount;
124
+ const boundingVolume = collection.boundingVolume;
125
+ const ellipsoid = tilingScheme.ellipsoid;
126
+
127
+ const rectangle = Rectangle.fromBoundingSphere(boundingVolume, ellipsoid);
128
+ const positions = _getProjectedPositions(collection, ellipsoid);
129
+
130
+ const widths = new Uint8Array(primitiveCount);
131
+ const colors = new Uint8Array(primitiveCount * 4);
132
+
133
+ for (let i = 0; i < primitiveCount; i++) {
134
+ const polyline = /** @type {BufferPolyline} */ (
135
+ collection.get(i, scratchPolyline)
136
+ );
137
+
138
+ // Append materials unconditionally, to simplify indexing and updates.
139
+ const polylineMaterial = /** @type {BufferPolylineMaterial} */ (
140
+ polyline.getMaterial(scratchPolylineMaterial)
141
+ );
142
+
143
+ widths[i] = polylineMaterial.width;
144
+
145
+ colors[i * 4] = Color.floatToByte(polylineMaterial.color.red);
146
+ colors[i * 4 + 1] = Color.floatToByte(polylineMaterial.color.green);
147
+ colors[i * 4 + 2] = Color.floatToByte(polylineMaterial.color.blue);
148
+ colors[i * 4 + 3] = Color.floatToByte(polylineMaterial.color.alpha);
149
+ }
150
+
151
+ return Object.assign(
152
+ result ?? {},
153
+ /** @type {VectorCollectionData} */ ({
154
+ version: collection._version,
155
+ rectangle: rectangle,
156
+ positions: positions,
157
+ widths: widths,
158
+ colors: colors,
159
+ }),
160
+ );
161
+ }
162
+
163
+ /**
164
+ * Projects all visible polylines in a collection into tile-local UV segments,
165
+ * clipped to the tile, appending [ax, ay, bx, by] to the segments array.
166
+ *
167
+ * @param {BufferPolylineCollection} collection
168
+ * @param {VectorCollectionData} collectionData
169
+ * @param {Rectangle} rectangle
170
+ * @param {VectorTileData} result
171
+ */
172
+ static packPolylineSegments(collection, collectionData, rectangle, result) {
173
+ result.polylineSegments ??= [];
174
+ result.widths ??= [];
175
+ result.colors ??= [];
176
+ result.polylineSegmentPrimitiveIndices ??= [];
177
+ result.primitiveCount ??= 0;
178
+
179
+ const width = rectangle.width;
180
+ const primitiveCount = collection.primitiveCount;
181
+ const positions = collectionData.positions;
182
+
183
+ for (let i = 0; i < primitiveCount; i++) {
184
+ const polyline = /** @type {BufferPolyline} */ (
185
+ collection.get(i, scratchPolyline)
186
+ );
187
+ if (!polyline.show) {
188
+ continue;
189
+ }
190
+
191
+ const vertexCount = polyline.vertexCount;
192
+ const vertexOffset = polyline.vertexOffset;
193
+
194
+ for (let j = 0; j + 1 < vertexCount; j++) {
195
+ const segmentStart = Cartesian2.fromArray(
196
+ // @ts-expect-error https://github.com/CesiumGS/cesium/pull/13302
197
+ positions,
198
+ (vertexOffset + j) * 2,
199
+ scratchSegmentStart,
200
+ );
201
+
202
+ const segmentEnd = Cartesian2.fromArray(
203
+ // @ts-expect-error https://github.com/CesiumGS/cesium/pull/13302
204
+ positions,
205
+ (vertexOffset + j + 1) * 2,
206
+ scratchSegmentEnd,
207
+ );
208
+
209
+ _projectSegmentToTileUv(segmentStart, segmentEnd, rectangle, width);
210
+
211
+ // Clip segments to the tile expanded by a small margin instead of exactly to
212
+ // [0,1], for robustness at the shared tile boundary. The boundary artifacts
213
+ // observed so far are consistent with floating-point error placing a segment
214
+ // vertex slightly outside the tile; a segment lying just outside the edge could
215
+ // also bleed in through its half line-width, though that case is unconfirmed.
216
+ // The margin is a small fixed fraction of the tile, independent of line width.
217
+ const clipped = _clipSegmentToTile(
218
+ segmentStart,
219
+ segmentEnd,
220
+ CesiumMath.EPSILON3,
221
+ );
222
+
223
+ if (clipped) {
224
+ result.polylineSegments.push([
225
+ segmentStart.x,
226
+ segmentStart.y,
227
+ segmentEnd.x,
228
+ segmentEnd.y,
229
+ ]);
230
+ result.polylineSegmentPrimitiveIndices.push(
231
+ result.primitiveCount + i,
232
+ );
233
+ }
234
+ }
235
+ }
236
+
237
+ // Append materials unconditionally, to simplify indexing and updates.
238
+ result.widths.push(collectionData.widths);
239
+ result.colors.push(collectionData.colors);
240
+
241
+ result.primitiveCount += primitiveCount;
242
+ }
243
+
244
+ /**
245
+ * Packs UV-space segments into a grid-indexed segment lookup. Returns the packed
246
+ * segment texels (RGBA, -1 filled) plus a grid-cell index header.
247
+ *
248
+ * @param {VectorTileData} result
249
+ */
250
+ static packPolylineGrid(result) {
251
+ const segments = result.polylineSegments;
252
+ const segmentPrimitiveIndices = result.polylineSegmentPrimitiveIndices;
253
+
254
+ const gridSize = Math.max(
255
+ 1,
256
+ Math.ceil(Math.sqrt(segments.length / GRID_TARGET_SEGMENTS_PER_CELL)),
257
+ );
258
+
259
+ const grid = new Array(gridSize * gridSize);
260
+ for (let i = 0; i < grid.length; i++) {
261
+ grid[i] = [];
262
+ }
263
+
264
+ let packedSegmentCount = 0;
265
+ // Expand each segment's bounding box by the neighbor padding, then assign it
266
+ // to every grid cell the expanded box overlaps. This includes cells just
267
+ // outside the segment (so the shader still tests lines near cell borders)
268
+ // without a per-cell segment-to-rect distance computation. The shader does
269
+ // the exact distance test, so the slight over-inclusion only costs a few
270
+ // extra comparisons there.
271
+ const padding = GRID_NEIGHBOR_PADDING_SCALE / gridSize;
272
+ for (let i = 0; i < segments.length; i++) {
273
+ const segment = segments[i];
274
+ const minX = Math.max(0.0, Math.min(segment[0], segment[2]) - padding);
275
+ const maxX = Math.min(1.0, Math.max(segment[0], segment[2]) + padding);
276
+ const minY = Math.max(0.0, Math.min(segment[1], segment[3]) - padding);
277
+ const maxY = Math.min(1.0, Math.max(segment[1], segment[3]) + padding);
278
+
279
+ const startCellX = _clampCellIndex(Math.floor(minX * gridSize), gridSize);
280
+ const endCellX = _clampCellIndex(Math.floor(maxX * gridSize), gridSize);
281
+ const startCellY = _clampCellIndex(Math.floor(minY * gridSize), gridSize);
282
+ const endCellY = _clampCellIndex(Math.floor(maxY * gridSize), gridSize);
283
+
284
+ for (let y = startCellY; y <= endCellY; y++) {
285
+ for (let x = startCellX; x <= endCellX; x++) {
286
+ grid[y * gridSize + x].push(i);
287
+ packedSegmentCount++;
288
+ }
289
+ }
290
+ }
291
+
292
+ const [textureWidth, textureHeight] =
293
+ _nextPowerOfTwoSize(packedSegmentCount);
294
+ const capacity = textureWidth * textureHeight;
295
+
296
+ const segmentTexels = new Float32Array(capacity * 4).fill(-1.0);
297
+ const segmentPrimitiveIndicesTexels = new Float32Array(capacity).fill(-1.0);
298
+
299
+ const gridCellIndices = new Uint32Array(grid.length + 2);
300
+ gridCellIndices[0] = gridSize;
301
+ gridCellIndices[1] = gridSize;
302
+
303
+ let offset = 0;
304
+ for (let i = 0; i < grid.length; i++) {
305
+ const cellSegments = grid[i];
306
+ for (let j = 0; j < cellSegments.length; j++) {
307
+ const segmentIndex = cellSegments[j];
308
+ const segment = segments[segmentIndex];
309
+ segmentTexels[offset * 4] = segment[0]; // R
310
+ segmentTexels[offset * 4 + 1] = segment[1]; // G
311
+ segmentTexels[offset * 4 + 2] = segment[2]; // B
312
+ segmentTexels[offset * 4 + 3] = segment[3]; // A
313
+
314
+ const primitiveIndex = segmentPrimitiveIndices[segmentIndex];
315
+ segmentPrimitiveIndicesTexels[offset] = primitiveIndex;
316
+
317
+ offset++;
318
+ }
319
+ gridCellIndices[i + 2] = offset;
320
+ }
321
+
322
+ result.polylineSegmentTexels = segmentTexels;
323
+ result.polylineSegmentTextureWidth = textureWidth;
324
+ result.polylineSegmentTextureHeight = textureHeight;
325
+ result.polylineSegmentPrimitiveIndicesTexels =
326
+ segmentPrimitiveIndicesTexels;
327
+ result.polylineGridCellIndices = gridCellIndices;
328
+ }
329
+
330
+ /**
331
+ * @param {BufferPolygonCollection} collection
332
+ * @param {TilingScheme} tilingScheme
333
+ * @param {VectorCollectionData} [result]
334
+ * @returns {VectorCollectionData}
335
+ */
336
+ static packPolygonCollectionData(collection, tilingScheme, result) {
337
+ if (
338
+ defined(result) &&
339
+ collection._dirtyCount === 0 &&
340
+ collection._version === result.version
341
+ ) {
342
+ return result;
343
+ }
344
+
345
+ const primitiveCount = collection.primitiveCount;
346
+ const boundingVolume = collection.boundingVolume;
347
+ const ellipsoid = tilingScheme.ellipsoid;
348
+
349
+ const rectangle = Rectangle.fromBoundingSphere(boundingVolume, ellipsoid);
350
+ const positions = _getProjectedPositions(collection, ellipsoid);
351
+
352
+ // Widths are unused by polygon fills; zero-filled so polygons share the
353
+ // primitive index space (and width/color textures) with polylines.
354
+ const widths = new Uint8Array(primitiveCount);
355
+ const colors = new Uint8Array(primitiveCount * 4);
356
+
357
+ for (let i = 0; i < primitiveCount; i++) {
358
+ const polygon = /** @type {BufferPolygon} */ (
359
+ collection.get(i, scratchPolygon)
360
+ );
361
+
362
+ // Append materials unconditionally, to simplify indexing and updates.
363
+ const polygonMaterial = /** @type {BufferPolygonMaterial} */ (
364
+ polygon.getMaterial(scratchPolygonMaterial)
365
+ );
366
+
367
+ colors[i * 4] = Color.floatToByte(polygonMaterial.color.red);
368
+ colors[i * 4 + 1] = Color.floatToByte(polygonMaterial.color.green);
369
+ colors[i * 4 + 2] = Color.floatToByte(polygonMaterial.color.blue);
370
+ colors[i * 4 + 3] = Color.floatToByte(polygonMaterial.color.alpha);
371
+ }
372
+
373
+ return Object.assign(
374
+ result ?? {},
375
+ /** @type {VectorCollectionData} */ ({
376
+ version: collection._version,
377
+ rectangle: rectangle,
378
+ positions: positions,
379
+ widths: widths,
380
+ colors: colors,
381
+ }),
382
+ );
383
+ }
384
+
385
+ /**
386
+ * Projects all visible polygon rings (outer rings and holes) in a collection
387
+ * into tile-local UV space, clipped to the tile, appending each surviving
388
+ * ring as a flat [x0, y0, x1, y1, ...] closed loop.
389
+ *
390
+ * @param {BufferPolygonCollection} collection
391
+ * @param {VectorCollectionData} collectionData
392
+ * @param {Rectangle} rectangle
393
+ * @param {VectorTileData} result
394
+ */
395
+ static packPolygonRings(collection, collectionData, rectangle, result) {
396
+ result.polygonRings ??= [];
397
+ result.polygonRingPrimitiveIndices ??= [];
398
+ result.widths ??= [];
399
+ result.colors ??= [];
400
+ result.primitiveCount ??= 0;
401
+
402
+ const width = rectangle.width;
403
+ const primitiveCount = collection.primitiveCount;
404
+ const positions = collectionData.positions;
405
+
406
+ for (let i = 0; i < primitiveCount; i++) {
407
+ const polygon = /** @type {BufferPolygon} */ (
408
+ collection.get(i, scratchPolygon)
409
+ );
410
+ if (!polygon.show) {
411
+ continue;
412
+ }
413
+
414
+ const vertexOffset = polygon.vertexOffset;
415
+ const vertexCount = polygon.vertexCount;
416
+ const holes = polygon.getHoles();
417
+
418
+ // Ring r spans [ringStart, ringEnd): the outer ring, then each hole.
419
+ // The shader's even-odd test makes hole rings cancel enclosing coverage.
420
+ for (let r = 0; r <= holes.length; r++) {
421
+ const ringStart = r === 0 ? 0 : holes[r - 1];
422
+ const ringEnd = r === holes.length ? vertexCount : holes[r];
423
+ const ringVertexCount = ringEnd - ringStart;
424
+ if (ringVertexCount < 3) {
425
+ continue;
426
+ }
427
+
428
+ const ringUv = _projectRingToTileUv(
429
+ positions,
430
+ vertexOffset + ringStart,
431
+ ringVertexCount,
432
+ rectangle,
433
+ width,
434
+ );
435
+
436
+ // Clip to the tile plus the shared tile clip margin. A ring enclosing
437
+ // the whole tile clips to the tile rectangle itself, so tiles
438
+ // interior to a large polygon remain covered.
439
+ const clipped = _clipRingToRect(
440
+ ringUv,
441
+ ringVertexCount,
442
+ -CesiumMath.EPSILON3,
443
+ 1.0 + CesiumMath.EPSILON3,
444
+ -CesiumMath.EPSILON3,
445
+ 1.0 + CesiumMath.EPSILON3,
446
+ scratchClippedRing,
447
+ );
448
+ if (clipped.vertexCount < 3) {
449
+ continue;
450
+ }
451
+
452
+ result.polygonRings.push(
453
+ clipped.positions.slice(0, clipped.vertexCount * 2),
454
+ );
455
+ result.polygonRingPrimitiveIndices.push(result.primitiveCount + i);
456
+ }
457
+ }
458
+
459
+ // Append materials unconditionally, to simplify indexing and updates.
460
+ result.widths.push(collectionData.widths);
461
+ result.colors.push(collectionData.colors);
462
+
463
+ result.primitiveCount += primitiveCount;
464
+ }
465
+
466
+ /**
467
+ * Packs UV-space polygon rings into a grid-indexed edge lookup. Each ring
468
+ * is clipped to every grid cell it overlaps — unlike polyline segments,
469
+ * which are only assigned to cells — so a cell's edges form closed loops
470
+ * and a fragment can evaluate even-odd coverage from its own cell alone.
471
+ *
472
+ * @param {VectorTileData} result
473
+ */
474
+ static packPolygonGrid(result) {
475
+ const rings = result.polygonRings;
476
+ const ringPrimitiveIndices = result.polygonRingPrimitiveIndices;
477
+
478
+ let ringEdgeCount = 0;
479
+ for (let i = 0; i < rings.length; i++) {
480
+ ringEdgeCount += rings[i].length / 2;
481
+ }
482
+
483
+ const gridSize = Math.max(
484
+ 1,
485
+ Math.ceil(Math.sqrt(ringEdgeCount / GRID_TARGET_SEGMENTS_PER_CELL)),
486
+ );
487
+
488
+ // Per-cell packed edges [ax, ay, bx, by, primitiveIndex, ...].
489
+ /** @type {number[][]} */
490
+ const grid = new Array(gridSize * gridSize);
491
+ for (let i = 0; i < grid.length; i++) {
492
+ grid[i] = [];
493
+ }
494
+
495
+ // Rings are appended in primitive order, so each cell's edge list stays
496
+ // grouped by primitive; the shader resolves parity per group.
497
+ let packedEdgeCount = 0;
498
+ for (let r = 0; r < rings.length; r++) {
499
+ const ring = rings[r];
500
+ const primitiveIndex = ringPrimitiveIndices[r];
501
+ const ringVertexCount = ring.length / 2;
502
+
503
+ let minX = Infinity;
504
+ let minY = Infinity;
505
+ let maxX = -Infinity;
506
+ let maxY = -Infinity;
507
+ for (let k = 0; k < ringVertexCount; k++) {
508
+ minX = Math.min(minX, ring[k * 2]);
509
+ maxX = Math.max(maxX, ring[k * 2]);
510
+ minY = Math.min(minY, ring[k * 2 + 1]);
511
+ maxY = Math.max(maxY, ring[k * 2 + 1]);
512
+ }
513
+
514
+ const startCellX = _clampCellIndex(Math.floor(minX * gridSize), gridSize);
515
+ const endCellX = _clampCellIndex(Math.floor(maxX * gridSize), gridSize);
516
+ const startCellY = _clampCellIndex(Math.floor(minY * gridSize), gridSize);
517
+ const endCellY = _clampCellIndex(Math.floor(maxY * gridSize), gridSize);
518
+
519
+ for (let y = startCellY; y <= endCellY; y++) {
520
+ for (let x = startCellX; x <= endCellX; x++) {
521
+ // Expand the clip rectangle slightly so fragments at shared cell
522
+ // boundaries fall strictly inside the clipped loops. Smaller than
523
+ // the tile clip margin above: that one is a fraction of a tile and
524
+ // preserves geometry across the shared tile boundary, while this is
525
+ // a fraction of a grid cell and only has to exceed the float32
526
+ // rounding of a UV coordinate.
527
+ const clipped = _clipRingToRect(
528
+ ring,
529
+ ringVertexCount,
530
+ x / gridSize - CesiumMath.EPSILON5,
531
+ (x + 1) / gridSize + CesiumMath.EPSILON5,
532
+ y / gridSize - CesiumMath.EPSILON5,
533
+ (y + 1) / gridSize + CesiumMath.EPSILON5,
534
+ scratchClippedRing,
535
+ );
536
+ const clippedCount = clipped.vertexCount;
537
+ if (clippedCount < 3) {
538
+ continue;
539
+ }
540
+
541
+ const clippedPositions = clipped.positions;
542
+ const cell = grid[y * gridSize + x];
543
+ for (let k = 0; k < clippedCount; k++) {
544
+ const k2 = (k + 1) % clippedCount;
545
+ const ax = clippedPositions[k * 2];
546
+ const ay = clippedPositions[k * 2 + 1];
547
+ const bx = clippedPositions[k2 * 2];
548
+ const by = clippedPositions[k2 * 2 + 1];
549
+ // Horizontal edges never toggle parity against the shader's
550
+ // horizontal ray; clipping produces many along cell bounds.
551
+ if (ay === by) {
552
+ continue;
553
+ }
554
+ cell.push(ax, ay, bx, by, primitiveIndex);
555
+ packedEdgeCount++;
556
+ }
557
+ }
558
+ }
559
+ }
560
+
561
+ const [textureWidth, textureHeight] = _nextPowerOfTwoSize(packedEdgeCount);
562
+ const capacity = textureWidth * textureHeight;
563
+
564
+ const edgeTexels = new Float32Array(capacity * 4).fill(-1.0);
565
+ const edgePrimitiveIndicesTexels = new Float32Array(capacity).fill(-1.0);
566
+
567
+ const gridCellIndices = new Uint32Array(grid.length + 2);
568
+ gridCellIndices[0] = gridSize;
569
+ gridCellIndices[1] = gridSize;
570
+
571
+ let offset = 0;
572
+ for (let i = 0; i < grid.length; i++) {
573
+ const cellEdges = grid[i];
574
+ for (let j = 0; j < cellEdges.length; j += 5) {
575
+ edgeTexels[offset * 4] = cellEdges[j]; // R
576
+ edgeTexels[offset * 4 + 1] = cellEdges[j + 1]; // G
577
+ edgeTexels[offset * 4 + 2] = cellEdges[j + 2]; // B
578
+ edgeTexels[offset * 4 + 3] = cellEdges[j + 3]; // A
579
+
580
+ edgePrimitiveIndicesTexels[offset] = cellEdges[j + 4];
581
+
582
+ offset++;
583
+ }
584
+ gridCellIndices[i + 2] = offset;
585
+ }
586
+
587
+ result.polygonEdgeTexels = edgeTexels;
588
+ result.polygonEdgeTextureWidth = textureWidth;
589
+ result.polygonEdgeTextureHeight = textureHeight;
590
+ result.polygonEdgePrimitiveIndicesTexels = edgePrimitiveIndicesTexels;
591
+ result.polygonGridCellIndices = gridCellIndices;
592
+ }
593
+
594
+ /**
595
+ * Creates the width and color textures indexed by the primitive index space
596
+ * shared between polylines and polygons.
597
+ *
598
+ * @param {Context} context
599
+ * @param {VectorTileData} result
600
+ */
601
+ static packPrimitiveTextures(context, result) {
602
+ const [primTextureWidth, primTextureHeight] = _nextPowerOfTwoSize(
603
+ result.primitiveCount,
604
+ );
605
+
606
+ const widthTextureView = new Uint8Array(
607
+ primTextureWidth * primTextureHeight,
608
+ );
609
+ widthTextureView.set(_concatByteArrays(result.widths));
610
+ result.widthTexture = new Texture({
611
+ context,
612
+ pixelFormat: PixelFormat.RED,
613
+ pixelDatatype: PixelDatatype.UNSIGNED_BYTE,
614
+ source: {
615
+ width: primTextureWidth,
616
+ height: primTextureHeight,
617
+ arrayBufferView: widthTextureView,
618
+ },
619
+ sampler: Sampler.NEAREST,
620
+ flipY: false,
621
+ });
622
+
623
+ const colorTextureView = new Uint8Array(
624
+ primTextureWidth * primTextureHeight * 4,
625
+ );
626
+ colorTextureView.set(_concatByteArrays(result.colors));
627
+ result.colorTexture = new Texture({
628
+ context,
629
+ pixelFormat: PixelFormat.RGBA,
630
+ pixelDatatype: PixelDatatype.UNSIGNED_BYTE,
631
+ source: {
632
+ width: primTextureWidth,
633
+ height: primTextureHeight,
634
+ arrayBufferView: colorTextureView,
635
+ },
636
+ sampler: Sampler.NEAREST,
637
+ flipY: false,
638
+ });
639
+ }
640
+
641
+ /**
642
+ * @param {Context} context
643
+ * @param {VectorTileData} result
644
+ */
645
+ static packPolylineTextures(context, result) {
646
+ result.polylineSegmentTexture = new Texture({
647
+ context,
648
+ pixelFormat: PixelFormat.RGBA,
649
+ pixelDatatype: PixelDatatype.FLOAT,
650
+ source: {
651
+ width: result.polylineSegmentTextureWidth,
652
+ height: result.polylineSegmentTextureHeight,
653
+ arrayBufferView: result.polylineSegmentTexels,
654
+ },
655
+ sampler: Sampler.NEAREST,
656
+ flipY: false,
657
+ });
658
+
659
+ result.polylineSegmentPrimitiveIndicesTexture = new Texture({
660
+ context,
661
+ pixelFormat: PixelFormat.RED,
662
+ pixelDatatype: PixelDatatype.FLOAT,
663
+ source: {
664
+ width: result.polylineSegmentTextureWidth,
665
+ height: result.polylineSegmentTextureHeight,
666
+ arrayBufferView: result.polylineSegmentPrimitiveIndicesTexels,
667
+ },
668
+ sampler: Sampler.NEAREST,
669
+ flipY: false,
670
+ });
671
+
672
+ result.polylineGridCellIndicesTexture = _createGridCellIndicesTexture(
673
+ context,
674
+ result.polylineGridCellIndices,
675
+ );
676
+ }
677
+
678
+ /**
679
+ * @param {Context} context
680
+ * @param {VectorTileData} result
681
+ */
682
+ static packPolygonTextures(context, result) {
683
+ result.polygonEdgeTexture = new Texture({
684
+ context,
685
+ pixelFormat: PixelFormat.RGBA,
686
+ pixelDatatype: PixelDatatype.FLOAT,
687
+ source: {
688
+ width: result.polygonEdgeTextureWidth,
689
+ height: result.polygonEdgeTextureHeight,
690
+ arrayBufferView: result.polygonEdgeTexels,
691
+ },
692
+ sampler: Sampler.NEAREST,
693
+ flipY: false,
694
+ });
695
+
696
+ result.polygonEdgePrimitiveIndicesTexture = new Texture({
697
+ context,
698
+ pixelFormat: PixelFormat.RED,
699
+ pixelDatatype: PixelDatatype.FLOAT,
700
+ source: {
701
+ width: result.polygonEdgeTextureWidth,
702
+ height: result.polygonEdgeTextureHeight,
703
+ arrayBufferView: result.polygonEdgePrimitiveIndicesTexels,
704
+ },
705
+ sampler: Sampler.NEAREST,
706
+ flipY: false,
707
+ });
708
+
709
+ result.polygonGridCellIndicesTexture = _createGridCellIndicesTexture(
710
+ context,
711
+ result.polygonGridCellIndices,
712
+ );
713
+ }
714
+
715
+ /**
716
+ * @param {VectorTileData} data
717
+ */
718
+ static freeResources(data) {
719
+ data.polylineSegmentTexture?.destroy();
720
+ data.widthTexture?.destroy();
721
+ data.colorTexture?.destroy();
722
+ data.polylineSegmentPrimitiveIndicesTexture?.destroy();
723
+ data.polylineGridCellIndicesTexture?.destroy();
724
+ data.polygonEdgeTexture?.destroy();
725
+ data.polygonEdgePrimitiveIndicesTexture?.destroy();
726
+ data.polygonGridCellIndicesTexture?.destroy();
727
+ }
728
+ }
729
+
730
+ /////////////////////////////////////////////////////////////////////////////
731
+ // INTERNAL METHODS
732
+
733
+ /**
734
+ * Projects a polyline segment (start/end Cartesian2s, x=lng, y=lat, in radians) into the
735
+ * tile's [0,1]^2 UV domain. Endpoint B's longitude is first unwrapped to within
736
+ * π of A so an antimeridian-crossing segment stays geometrically short instead
737
+ * of spanning the globe; then both endpoints are shifted together to the 2π
738
+ * frame nearest the tile center so a segment adjacent to (or crossing) the
739
+ * tile's west/east edge projects correctly. Result written to input Cartesian2s.
740
+ *
741
+ * Only supporting geographic tiling scheme (UV maps linearly to lon/lat)
742
+ *
743
+ * @param {Cartesian2} a [lonA, latA] radians, modified in place.
744
+ * @param {Cartesian2} b [lonB, latB] radians, modified in place.
745
+ * @param {Rectangle} rectangle
746
+ * @param {number} width
747
+ * @private
748
+ */
749
+ function _projectSegmentToTileUv(a, b, rectangle, width) {
750
+ let lonA = a.x;
751
+ let lonB = b.x;
752
+
753
+ // Unwrap B relative to A so the segment follows the shortest longitudinal
754
+ // path (handles antimeridian-crossing segments).
755
+ lonB = lonA + CesiumMath.negativePiToPi(lonB - lonA);
756
+
757
+ // Shift the whole segment to the 2π frame nearest the tile center.
758
+ const center = rectangle.west + width * 0.5;
759
+ const shift = center + CesiumMath.negativePiToPi(lonA - center) - lonA;
760
+ lonA += shift;
761
+ lonB += shift;
762
+
763
+ const height = rectangle.north - rectangle.south;
764
+ a.x = (lonA - rectangle.west) / width;
765
+ a.y = (a.y - rectangle.south) / height;
766
+ b.x = (lonB - rectangle.west) / width;
767
+ b.y = (b.y - rectangle.south) / height;
768
+ }
769
+
770
+ /**
771
+ * Clips a UV-space segment to the tile domain expanded by `margin` on each
772
+ * side ([-margin, 1 + margin]^2) using Liang-Barsky, so a segment just outside
773
+ * the tile boundary is still kept. Writes the clipped endpoints to result;
774
+ * returns false when the segment is entirely outside.
775
+ *
776
+ * @param {Cartesian2} a
777
+ * @param {Cartesian2} b
778
+ * @param {number} margin
779
+ * @returns {boolean}
780
+ * @private
781
+ */
782
+ function _clipSegmentToTile(a, b, margin) {
783
+ const lo = -margin;
784
+ const hi = 1.0 + margin;
785
+
786
+ let tMin = 0.0;
787
+ let tMax = 1.0;
788
+
789
+ const ax = a.x;
790
+ const ay = a.y;
791
+ const bx = b.x;
792
+ const by = b.y;
793
+
794
+ const dx = bx - ax;
795
+ const dy = by - ay;
796
+ const p = [-dx, dx, -dy, dy];
797
+ const q = [ax - lo, hi - ax, ay - lo, hi - ay];
798
+
799
+ for (let i = 0; i < 4; i++) {
800
+ if (Math.abs(p[i]) < 1.0e-12) {
801
+ if (q[i] < 0.0) {
802
+ return false;
803
+ }
804
+ continue;
805
+ }
806
+
807
+ const t = q[i] / p[i];
808
+ if (p[i] < 0.0) {
809
+ tMin = Math.max(tMin, t);
810
+ } else {
811
+ tMax = Math.min(tMax, t);
812
+ }
813
+
814
+ if (tMin > tMax) {
815
+ return false;
816
+ }
817
+ }
818
+
819
+ a.x = ax + tMin * dx;
820
+ a.y = ay + tMin * dy;
821
+ b.x = ax + tMax * dx;
822
+ b.y = ay + tMax * dy;
823
+
824
+ return true;
825
+ }
826
+
827
+ /**
828
+ * @param {number} index
829
+ * @param {number} gridSize
830
+ * @returns {number}
831
+ * @private
832
+ */
833
+ function _clampCellIndex(index, gridSize) {
834
+ return Math.max(0, Math.min(gridSize - 1, index));
835
+ }
836
+
837
+ // Growable module scratch for ring projection and Sutherland-Hodgman clipping.
838
+ /**
839
+ * @type {Float64Array}
840
+ * @private
841
+ */
842
+ let scratchRingUv = new Float64Array(512);
843
+ /**
844
+ * @type {Float64Array}
845
+ * @private
846
+ */
847
+ let scratchClipWorking = new Float64Array(512);
848
+
849
+ /**
850
+ * A ring clipped by {@link _clipRingToRect}.
851
+ *
852
+ * `positions` is reallocated when the clipped ring outgrows it, so callers
853
+ * must read it back from this object after each call rather than caching it.
854
+ *
855
+ * @typedef {object} ClippedRing
856
+ * @property {Float64Array} positions Flat [x0, y0, x1, y1, ...] ring coordinates.
857
+ * @property {number} vertexCount Number of valid vertices in `positions`.
858
+ * @private
859
+ */
860
+
861
+ /**
862
+ * @type {ClippedRing}
863
+ * @private
864
+ */
865
+ const scratchClippedRing = {
866
+ positions: new Float64Array(512),
867
+ vertexCount: 0,
868
+ };
869
+
870
+ /**
871
+ * Projects a polygon ring ([lng, lat] radian pairs from `positions`) into the
872
+ * tile's [0,1]^2 UV domain. Longitudes are sequentially unwrapped so an
873
+ * antimeridian-crossing ring stays continuous, then the whole ring is shifted
874
+ * to the 2π frame nearest the tile center (matching the polyline projection).
875
+ * Returns a module scratch valid until the next call.
876
+ *
877
+ * Only supporting geographic tiling scheme (UV maps linearly to lon/lat)
878
+ *
879
+ * @param {Float64Array} positions Projected collection positions ([lng, lat] radians).
880
+ * @param {number} vertexStart Index of the ring's first vertex.
881
+ * @param {number} vertexCount Number of vertices in the ring.
882
+ * @param {Rectangle} rectangle
883
+ * @param {number} width
884
+ * @returns {Float64Array} Flat [u0, v0, u1, v1, ...] ring coordinates.
885
+ * @private
886
+ */
887
+ function _projectRingToTileUv(
888
+ positions,
889
+ vertexStart,
890
+ vertexCount,
891
+ rectangle,
892
+ width,
893
+ ) {
894
+ if (scratchRingUv.length < vertexCount * 2) {
895
+ scratchRingUv = new Float64Array(vertexCount * 4);
896
+ }
897
+ const result = scratchRingUv;
898
+ const height = rectangle.north - rectangle.south;
899
+
900
+ let previousLon = positions[vertexStart * 2];
901
+ result[0] = previousLon;
902
+ result[1] = positions[vertexStart * 2 + 1];
903
+ for (let i = 1; i < vertexCount; i++) {
904
+ const lon =
905
+ previousLon +
906
+ CesiumMath.negativePiToPi(positions[(vertexStart + i) * 2] - previousLon);
907
+ result[i * 2] = lon;
908
+ result[i * 2 + 1] = positions[(vertexStart + i) * 2 + 1];
909
+ previousLon = lon;
910
+ }
911
+
912
+ const center = rectangle.west + width * 0.5;
913
+ const lon0 = result[0];
914
+ const shift = center + CesiumMath.negativePiToPi(lon0 - center) - lon0;
915
+
916
+ for (let i = 0; i < vertexCount; i++) {
917
+ result[i * 2] = (result[i * 2] + shift - rectangle.west) / width;
918
+ result[i * 2 + 1] = (result[i * 2 + 1] - rectangle.south) / height;
919
+ }
920
+
921
+ return result;
922
+ }
923
+
924
+ /**
925
+ * Clips a closed ring to an axis-aligned rectangle with Sutherland-Hodgman.
926
+ * Writes the clipped ring into `result`, whose `vertexCount` is 0 when the
927
+ * ring is entirely outside the rectangle.
928
+ *
929
+ * @param {Float64Array} ring Flat [x0, y0, x1, y1, ...] ring coordinates.
930
+ * @param {number} vertexCount
931
+ * @param {number} minX
932
+ * @param {number} maxX
933
+ * @param {number} minY
934
+ * @param {number} maxY
935
+ * @param {ClippedRing} result
936
+ * @returns {ClippedRing} The modified result parameter.
937
+ * @private
938
+ */
939
+ function _clipRingToRect(ring, vertexCount, minX, maxX, minY, maxY, result) {
940
+ let input = ring;
941
+ let inputCount = vertexCount;
942
+
943
+ // axis (0 = x, 1 = y), keep side (1 = keep >= limit, -1 = keep <= limit).
944
+ for (let plane = 0; plane < 4; plane++) {
945
+ const axis = plane >> 1;
946
+ const sign = (plane & 1) === 0 ? 1.0 : -1.0;
947
+ const limit =
948
+ plane === 0 ? minX : plane === 1 ? maxX : plane === 2 ? minY : maxY;
949
+
950
+ // Ping-pong between the working scratch and the result, writing odd
951
+ // planes to the result so the fourth and final plane lands there.
952
+ // Each input vertex emits at most 2 output vertices.
953
+ const requiredLength = inputCount * 4 + 4;
954
+ const isWorkingPlane = (plane & 1) === 0;
955
+ let output = isWorkingPlane ? scratchClipWorking : result.positions;
956
+ if (output.length < requiredLength) {
957
+ output = new Float64Array(requiredLength * 2);
958
+ if (isWorkingPlane) {
959
+ scratchClipWorking = output;
960
+ } else {
961
+ result.positions = output;
962
+ }
963
+ }
964
+
965
+ let outputCount = 0;
966
+ let prevX = input[(inputCount - 1) * 2];
967
+ let prevY = input[(inputCount - 1) * 2 + 1];
968
+ let prevInside = sign * ((axis === 0 ? prevX : prevY) - limit) >= 0.0;
969
+
970
+ for (let i = 0; i < inputCount; i++) {
971
+ const x = input[i * 2];
972
+ const y = input[i * 2 + 1];
973
+ const inside = sign * ((axis === 0 ? x : y) - limit) >= 0.0;
974
+
975
+ if (inside !== prevInside) {
976
+ // Pin the clipped coordinate exactly to the plane so boundary edges
977
+ // stay axis-aligned.
978
+ const t =
979
+ axis === 0
980
+ ? (limit - prevX) / (x - prevX)
981
+ : (limit - prevY) / (y - prevY);
982
+ output[outputCount * 2] = axis === 0 ? limit : prevX + t * (x - prevX);
983
+ output[outputCount * 2 + 1] =
984
+ axis === 0 ? prevY + t * (y - prevY) : limit;
985
+ outputCount++;
986
+ }
987
+ if (inside) {
988
+ output[outputCount * 2] = x;
989
+ output[outputCount * 2 + 1] = y;
990
+ outputCount++;
991
+ }
992
+
993
+ prevX = x;
994
+ prevY = y;
995
+ prevInside = inside;
996
+ }
997
+
998
+ if (outputCount === 0) {
999
+ result.vertexCount = 0;
1000
+ return result;
1001
+ }
1002
+
1003
+ input = output;
1004
+ inputCount = outputCount;
1005
+ }
1006
+
1007
+ result.vertexCount = inputCount;
1008
+ return result;
1009
+ }
1010
+
1011
+ /**
1012
+ * @param {number} count
1013
+ * @returns {number[]}
1014
+ * @private
1015
+ */
1016
+ function _nextPowerOfTwoSize(count) {
1017
+ const width = CesiumMath.nextPowerOfTwo(
1018
+ Math.max(1, Math.ceil(Math.sqrt(count))),
1019
+ );
1020
+ const height = CesiumMath.nextPowerOfTwo(
1021
+ Math.max(1, Math.ceil(count / width)),
1022
+ );
1023
+ return [width, height];
1024
+ }
1025
+
1026
+ /**
1027
+ * Creates a grid header texture, wrapped to a 2D power-of-two size so the
1028
+ * header length is not limited by the maximum texture width.
1029
+ *
1030
+ * @param {Context} context
1031
+ * @param {Uint32Array} gridCellIndices
1032
+ * @returns {Texture}
1033
+ * @private
1034
+ */
1035
+ function _createGridCellIndicesTexture(context, gridCellIndices) {
1036
+ const [width, height] = _nextPowerOfTwoSize(gridCellIndices.length);
1037
+ const texels = new Float32Array(width * height);
1038
+ texels.set(gridCellIndices);
1039
+ return new Texture({
1040
+ context: context,
1041
+ pixelFormat: PixelFormat.RED,
1042
+ pixelDatatype: PixelDatatype.FLOAT,
1043
+ source: {
1044
+ width: width,
1045
+ height: height,
1046
+ arrayBufferView: texels,
1047
+ },
1048
+ sampler: Sampler.NEAREST,
1049
+ flipY: false,
1050
+ });
1051
+ }
1052
+
1053
+ /**
1054
+ * Returns the collection's vertex positions, projected to [lng, lat]
1055
+ * coordinates, in radians, on the given ellipsoid.
1056
+ *
1057
+ * @param {BufferPrimitiveCollection<BufferPrimitive>} collection
1058
+ * @param {Ellipsoid} ellipsoid
1059
+ * @param {Float64Array} [result]
1060
+ * @ignore
1061
+ */
1062
+ function _getProjectedPositions(collection, ellipsoid, result) {
1063
+ if (!defined(result)) {
1064
+ result = new Float64Array(collection._positionCountMax * 2);
1065
+ }
1066
+
1067
+ const positions = collection._positionView;
1068
+ const modelMatrix = collection.modelMatrix;
1069
+
1070
+ for (let i = 0; i < collection._positionCount; i++) {
1071
+ const local = Cartesian3.fromArray(
1072
+ // @ts-expect-error https://github.com/CesiumGS/cesium/pull/13302
1073
+ positions,
1074
+ i * 3,
1075
+ scratchLocalPosition,
1076
+ );
1077
+ const world = Matrix4.multiplyByPoint(
1078
+ modelMatrix,
1079
+ local,
1080
+ scratchWorldPosition,
1081
+ );
1082
+ const cartographic = ellipsoid.cartesianToCartographic(
1083
+ world,
1084
+ scratchCartographic,
1085
+ );
1086
+
1087
+ result[i * 2] = cartographic.longitude;
1088
+ result[i * 2 + 1] = cartographic.latitude;
1089
+ }
1090
+
1091
+ return result;
1092
+ }
1093
+
1094
+ /**
1095
+ * Concatenates N byte arrays.
1096
+ * @param {Uint8Array[]} arrays
1097
+ * @returns {Uint8Array}
1098
+ * @ignore
1099
+ */
1100
+ function _concatByteArrays(arrays) {
1101
+ let totalByteLength = 0;
1102
+ for (const array of arrays) {
1103
+ totalByteLength += array.byteLength;
1104
+ }
1105
+
1106
+ const result = new Uint8Array(totalByteLength);
1107
+ let byteOffset = 0;
1108
+
1109
+ for (const array of arrays) {
1110
+ result.set(array, byteOffset);
1111
+ byteOffset += array.byteLength;
1112
+ }
1113
+
1114
+ return result;
1115
+ }
1116
+
1117
+ export default VectorPipeline;