@hztxi/cesium-engine 25.0.7 → 26.2.2

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/Workers/chunk-2FNKHQL3.js +754 -0
  2. package/Build/Workers/chunk-2NCNUVAT.js +56 -0
  3. package/Build/Workers/chunk-2ZYRUVVU.js +301 -0
  4. package/Build/Workers/chunk-36IU7N4V.js +1284 -0
  5. package/Build/Workers/chunk-3BDLET5S.js +198 -0
  6. package/Build/Workers/chunk-3JZXI44G.js +3822 -0
  7. package/Build/Workers/chunk-3N2UNLWJ.js +101 -0
  8. package/Build/Workers/chunk-3NCG2YYR.js +58 -0
  9. package/Build/Workers/chunk-3PRHI4KX.js +241 -0
  10. package/Build/Workers/chunk-3R6E2SH4.js +672 -0
  11. package/Build/Workers/chunk-3ZKKXEXL.js +415 -0
  12. package/Build/Workers/chunk-47KVKPTO.js +415 -0
  13. package/Build/Workers/chunk-4FFIJ7ZV.js +56 -0
  14. package/Build/Workers/chunk-4N227IPR.js +973 -0
  15. package/Build/Workers/chunk-4P6OAPBM.js +97 -0
  16. package/Build/Workers/chunk-4XR3K4GD.js +280 -0
  17. package/Build/Workers/chunk-4Z2JINRS.js +519 -0
  18. package/Build/Workers/chunk-4ZOLEPZK.js +519 -0
  19. package/Build/Workers/chunk-5EF3WWQG.js +352 -0
  20. package/Build/Workers/chunk-5I76476T.js +288 -0
  21. package/Build/Workers/chunk-5PBZKBAP.js +511 -0
  22. package/Build/Workers/chunk-5RVAAW26.js +82 -0
  23. package/Build/Workers/chunk-5VWK76PO.js +511 -0
  24. package/Build/Workers/chunk-6SEICASZ.js +241 -0
  25. package/Build/Workers/chunk-77DBX23X.js +455 -0
  26. package/Build/Workers/chunk-7C2D3DTI.js +959 -0
  27. package/Build/Workers/chunk-7GQOWCSN.js +959 -0
  28. package/Build/Workers/chunk-7J2ONMKC.js +198 -0
  29. package/Build/Workers/chunk-7MHUHXZZ.js +219 -0
  30. package/Build/Workers/chunk-7MQPHOAS.js +455 -0
  31. package/Build/Workers/chunk-7NJ5O7TP.js +387 -0
  32. package/Build/Workers/chunk-7T4MW2W4.js +368 -0
  33. package/Build/Workers/chunk-7UXZUGUZ.js +82 -0
  34. package/Build/Workers/chunk-7Y642MCO.js +352 -0
  35. package/Build/Workers/chunk-7ZFKBLUE.js +1054 -0
  36. package/Build/Workers/chunk-A2UHPWPL.js +38 -0
  37. package/Build/Workers/chunk-A7LGY5XS.js +140 -0
  38. package/Build/Workers/chunk-AN2NVYL6.js +1483 -0
  39. package/Build/Workers/chunk-AS2QC7H2.js +219 -0
  40. package/Build/Workers/chunk-AVOLMIGJ.js +57 -0
  41. package/Build/Workers/chunk-B7PT2VL5.js +630 -0
  42. package/Build/Workers/chunk-BHRHMUDM.js +147 -0
  43. package/Build/Workers/chunk-BUWAHRK5.js +672 -0
  44. package/Build/Workers/chunk-C5ET5HON.js +198 -0
  45. package/Build/Workers/chunk-C6XQGBPV.js +476 -0
  46. package/Build/Workers/chunk-C7B672RR.js +73 -0
  47. package/Build/Workers/chunk-CAEC5DA2.js +57 -0
  48. package/Build/Workers/chunk-CBCOHH5O.js +837 -0
  49. package/Build/Workers/chunk-CEMXKBQO.js +1800 -0
  50. package/Build/Workers/chunk-CKW3STKA.js +1067 -0
  51. package/Build/Workers/chunk-CV5RICKT.js +1992 -0
  52. package/Build/Workers/chunk-DBWSISJT.js +56 -0
  53. package/Build/Workers/chunk-DCMOBPLG.js +352 -0
  54. package/Build/Workers/chunk-DSBSPPPJ.js +1344 -0
  55. package/Build/Workers/chunk-DSGLDRTI.js +278 -0
  56. package/Build/Workers/chunk-DXD7OPSP.js +1992 -0
  57. package/Build/Workers/chunk-DXECZBSA.js +368 -0
  58. package/Build/Workers/chunk-DZIRO6ZK.js +682 -0
  59. package/Build/Workers/chunk-E4CRPGX5.js +140 -0
  60. package/Build/Workers/chunk-E4IVMEBH.js +52 -0
  61. package/Build/Workers/chunk-E6IPM6HP.js +56 -0
  62. package/Build/Workers/chunk-EB2HAHRY.js +1054 -0
  63. package/Build/Workers/chunk-ECDCQXCO.js +1992 -0
  64. package/Build/Workers/chunk-ECN3VUMA.js +73 -0
  65. package/Build/Workers/chunk-ECSKVHUB.js +476 -0
  66. package/Build/Workers/chunk-EIENGLA5.js +278 -0
  67. package/Build/Workers/chunk-EK5CWDW2.js +476 -0
  68. package/Build/Workers/chunk-EL4B5CSQ.js +162 -0
  69. package/Build/Workers/chunk-EUCUBIEZ.js +97 -0
  70. package/Build/Workers/chunk-FAYBQGKO.js +219 -0
  71. package/Build/Workers/chunk-FGCXPEZM.js +3201 -0
  72. package/Build/Workers/chunk-FHCRXPA6.js +44 -0
  73. package/Build/Workers/chunk-FM6EQUFX.js +1800 -0
  74. package/Build/Workers/chunk-FPFGGQ4X.js +301 -0
  75. package/Build/Workers/chunk-FQ42MT7M.js +58 -0
  76. package/Build/Workers/chunk-FQDYQG4P.js +1284 -0
  77. package/Build/Workers/chunk-FQTV6W3I.js +973 -0
  78. package/Build/Workers/chunk-FTCBY5HH.js +138 -0
  79. package/Build/Workers/chunk-GI5RWJAY.js +101 -0
  80. package/Build/Workers/chunk-GNLMSDRO.js +945 -0
  81. package/Build/Workers/chunk-GTA727KQ.js +140 -0
  82. package/Build/Workers/chunk-GVUJ6O3R.js +73 -0
  83. package/Build/Workers/chunk-GXTM7AG3.js +1483 -0
  84. package/Build/Workers/chunk-HAXQB2FS.js +2719 -0
  85. package/Build/Workers/chunk-HCGU7OCG.js +97 -0
  86. package/Build/Workers/chunk-HRIPVWSC.js +58 -0
  87. package/Build/Workers/chunk-IC3BR6SC.js +102 -0
  88. package/Build/Workers/chunk-IEPPOHF3.js +44 -0
  89. package/Build/Workers/chunk-IU3YAYPT.js +1344 -0
  90. package/Build/Workers/chunk-J3AXZ4WC.js +124 -0
  91. package/Build/Workers/chunk-J7MZR7B2.js +1483 -0
  92. package/Build/Workers/chunk-KBNW776Q.js +305 -0
  93. package/Build/Workers/chunk-KBSWXVSY.js +837 -0
  94. package/Build/Workers/chunk-KEYTLNVK.js +1067 -0
  95. package/Build/Workers/chunk-KN3RQWUA.js +3201 -0
  96. package/Build/Workers/chunk-KSIEJYNL.js +3822 -0
  97. package/Build/Workers/chunk-KT3GG7AW.js +754 -0
  98. package/Build/Workers/chunk-KYCEM22I.js +1800 -0
  99. package/Build/Workers/chunk-L2TFZKN6.js +455 -0
  100. package/Build/Workers/chunk-LHKE2VUR.js +945 -0
  101. package/Build/Workers/chunk-LJTQW46H.js +57 -0
  102. package/Build/Workers/chunk-LMQGYJME.js +672 -0
  103. package/Build/Workers/chunk-LOBYJQA4.js +76 -0
  104. package/Build/Workers/chunk-LOF32O7F.js +163 -0
  105. package/Build/Workers/chunk-LOTIJA7D.js +124 -0
  106. package/Build/Workers/chunk-M7Z3MPAX.js +973 -0
  107. package/Build/Workers/chunk-MHNLTQHO.js +3201 -0
  108. package/Build/Workers/chunk-MICPAD7R.js +398 -0
  109. package/Build/Workers/chunk-ML7OMD72.js +2342 -0
  110. package/Build/Workers/chunk-MPJ73WMH.js +138 -0
  111. package/Build/Workers/chunk-MUTHG7T7.js +171 -0
  112. package/Build/Workers/chunk-NBTGXEMT.js +945 -0
  113. package/Build/Workers/chunk-NQZC37F7.js +38 -0
  114. package/Build/Workers/chunk-O3X3D2Z3.js +352 -0
  115. package/Build/Workers/chunk-OBUIHPKF.js +352 -0
  116. package/Build/Workers/chunk-PAEWNYIV.js +138 -0
  117. package/Build/Workers/chunk-PANJ7YH6.js +102 -0
  118. package/Build/Workers/chunk-PCL3Y7H5.js +82 -0
  119. package/Build/Workers/chunk-PHUELDXQ.js +76 -0
  120. package/Build/Workers/chunk-PIIUGRQD.js +387 -0
  121. package/Build/Workers/chunk-POKD22OT.js +2719 -0
  122. package/Build/Workers/chunk-PQMA7MFS.js +9237 -0
  123. package/Build/Workers/chunk-PQZW2QZG.js +163 -0
  124. package/Build/Workers/chunk-PURIPUSY.js +682 -0
  125. package/Build/Workers/chunk-QQZPPXY4.js +3822 -0
  126. package/Build/Workers/chunk-QXLQLGL2.js +1067 -0
  127. package/Build/Workers/chunk-R2JQAAU7.js +630 -0
  128. package/Build/Workers/chunk-RC4YC3VU.js +278 -0
  129. package/Build/Workers/chunk-RGNNWVR6.js +171 -0
  130. package/Build/Workers/chunk-RUOETBWP.js +288 -0
  131. package/Build/Workers/chunk-RV4EPLBO.js +2342 -0
  132. package/Build/Workers/chunk-SBBIEHYT.js +44 -0
  133. package/Build/Workers/chunk-SBEQLEO5.js +352 -0
  134. package/Build/Workers/chunk-SGC2GT3Y.js +1284 -0
  135. package/Build/Workers/chunk-SKLK4CBL.js +162 -0
  136. package/Build/Workers/chunk-SWVZTU6X.js +305 -0
  137. package/Build/Workers/chunk-T3EUPM5A.js +454 -0
  138. package/Build/Workers/chunk-TA6IU2XL.js +171 -0
  139. package/Build/Workers/chunk-TLSGD5TR.js +280 -0
  140. package/Build/Workers/chunk-TNDQT5AB.js +682 -0
  141. package/Build/Workers/chunk-TOXDLWKZ.js +368 -0
  142. package/Build/Workers/chunk-TZBM6TAB.js +124 -0
  143. package/Build/Workers/chunk-U2OY6MX6.js +398 -0
  144. package/Build/Workers/chunk-UCY4B5EV.js +288 -0
  145. package/Build/Workers/chunk-V52FEPCV.js +754 -0
  146. package/Build/Workers/chunk-VBEXZBG5.js +147 -0
  147. package/Build/Workers/chunk-VC76B6GM.js +959 -0
  148. package/Build/Workers/chunk-VCUOYHWC.js +519 -0
  149. package/Build/Workers/chunk-VDBQVKTF.js +387 -0
  150. package/Build/Workers/chunk-VJIL5H6K.js +2719 -0
  151. package/Build/Workers/chunk-VJLDRHKN.js +511 -0
  152. package/Build/Workers/chunk-VMF7KOGY.js +162 -0
  153. package/Build/Workers/chunk-W3X2ZAEJ.js +52 -0
  154. package/Build/Workers/chunk-W5OCKMPJ.js +101 -0
  155. package/Build/Workers/chunk-X4VZ33YL.js +454 -0
  156. package/Build/Workers/chunk-XDM5A6C4.js +102 -0
  157. package/Build/Workers/chunk-XHT5SVP4.js +52 -0
  158. package/Build/Workers/chunk-XITBARMZ.js +2342 -0
  159. package/Build/Workers/chunk-XLQZNQ4Z.js +163 -0
  160. package/Build/Workers/chunk-XZ6HDXKM.js +76 -0
  161. package/Build/Workers/chunk-Y6AQK4FY.js +1344 -0
  162. package/Build/Workers/chunk-Y7NDFEQ3.js +398 -0
  163. package/Build/Workers/chunk-YBBQDYX2.js +301 -0
  164. package/Build/Workers/chunk-YHPYPVAB.js +837 -0
  165. package/Build/Workers/chunk-YJBPRW4A.js +415 -0
  166. package/Build/Workers/chunk-YNKK6BXY.js +454 -0
  167. package/Build/Workers/chunk-YRAJ74HR.js +305 -0
  168. package/Build/Workers/chunk-YULTZK5O.js +147 -0
  169. package/Build/Workers/chunk-YUNQYP3Z.js +9237 -0
  170. package/Build/Workers/chunk-YX2FOQMF.js +9237 -0
  171. package/Build/Workers/chunk-Z7BONRW2.js +241 -0
  172. package/Build/Workers/chunk-ZK2R3DEJ.js +1054 -0
  173. package/Build/Workers/combineGeometry.js +24 -24
  174. package/Build/Workers/createBoxGeometry.js +18 -18
  175. package/Build/Workers/createBoxOutlineGeometry.js +18 -18
  176. package/Build/Workers/createCircleGeometry.js +26 -26
  177. package/Build/Workers/createCircleOutlineGeometry.js +19 -19
  178. package/Build/Workers/createCoplanarPolygonGeometry.js +39 -39
  179. package/Build/Workers/createCoplanarPolygonOutlineGeometry.js +33 -33
  180. package/Build/Workers/createCorridorGeometry.js +36 -37
  181. package/Build/Workers/createCorridorOutlineGeometry.js +34 -35
  182. package/Build/Workers/createCylinderGeometry.js +20 -20
  183. package/Build/Workers/createCylinderOutlineGeometry.js +20 -20
  184. package/Build/Workers/createEllipseGeometry.js +26 -26
  185. package/Build/Workers/createEllipseOutlineGeometry.js +19 -19
  186. package/Build/Workers/createEllipsoidGeometry.js +19 -19
  187. package/Build/Workers/createEllipsoidOutlineGeometry.js +18 -18
  188. package/Build/Workers/createFrustumGeometry.js +18 -18
  189. package/Build/Workers/createFrustumOutlineGeometry.js +20 -20
  190. package/Build/Workers/createGeometry.js +25 -24
  191. package/Build/Workers/createGroundPolylineGeometry.js +26 -26
  192. package/Build/Workers/createMvtTile.js +111 -19
  193. package/Build/Workers/createPlaneGeometry.js +18 -18
  194. package/Build/Workers/createPlaneOutlineGeometry.js +17 -17
  195. package/Build/Workers/createPolygonGeometry.js +36 -36
  196. package/Build/Workers/createPolygonOutlineGeometry.js +33 -33
  197. package/Build/Workers/createPolylineGeometry.js +28 -28
  198. package/Build/Workers/createPolylineVolumeGeometry.js +38 -36
  199. package/Build/Workers/createPolylineVolumeOutlineGeometry.js +32 -31
  200. package/Build/Workers/createRectangleGeometry.js +29 -29
  201. package/Build/Workers/createRectangleOutlineGeometry.js +23 -23
  202. package/Build/Workers/createSimplePolylineGeometry.js +26 -26
  203. package/Build/Workers/createSphereGeometry.js +19 -19
  204. package/Build/Workers/createSphereOutlineGeometry.js +18 -18
  205. package/Build/Workers/createTaskProcessorWorker.js +3 -3
  206. package/Build/Workers/createVectorTileClampedPolylines.js +14 -14
  207. package/Build/Workers/createVectorTileGeometries.js +24 -24
  208. package/Build/Workers/createVectorTilePoints.js +13 -13
  209. package/Build/Workers/createVectorTilePolygons.js +22 -22
  210. package/Build/Workers/createVectorTilePolylines.js +14 -14
  211. package/Build/Workers/createVerticesFromCesium3DTilesTerrain.js +26 -26
  212. package/Build/Workers/createVerticesFromGoogleEarthEnterpriseBuffer.js +23 -23
  213. package/Build/Workers/createVerticesFromHeightmap.js +23 -23
  214. package/Build/Workers/createVerticesFromQuantizedTerrainMesh.js +21 -21
  215. package/Build/Workers/createWallGeometry.js +26 -26
  216. package/Build/Workers/createWallOutlineGeometry.js +26 -26
  217. package/Build/Workers/decodeDraco.js +10 -10
  218. package/Build/Workers/decodeGoogleEarthEnterprisePacket.js +993 -2334
  219. package/Build/Workers/decodeI3S.js +10 -10
  220. package/Build/Workers/gaussianSplatSorter.js +4 -4
  221. package/Build/Workers/gaussianSplatTextureGenerator.js +4 -4
  222. package/Build/Workers/incrementallyBuildTerrainPicker.js +10 -10
  223. package/Build/Workers/transcodeKTX2.js +6 -6
  224. package/Build/Workers/transferTypedArrayTest.js +1 -1
  225. package/Build/Workers/upsampleQuantizedTerrainMesh.js +23 -23
  226. package/Build/Workers/upsampleVerticesFromCesium3DTilesTerrain.js +26 -26
  227. package/Source/Core/ArcGISTiledElevationTerrainProvider.js +1 -5
  228. package/Source/Core/BoundingRectangle.js +6 -8
  229. package/Source/Core/BoundingSphere.js +0 -3
  230. package/Source/Core/Cartesian2.js +1 -1
  231. package/Source/Core/Cartesian3.js +1 -1
  232. package/Source/Core/Cartesian4.js +1 -1
  233. package/Source/Core/Cesium3DTilesTerrainGeometryProcessor.js +3 -4
  234. package/Source/Core/Color.js +1 -0
  235. package/Source/Core/ComponentDatatype.js +35 -0
  236. package/Source/Core/CoplanarPolygonGeometry.js +2 -2
  237. package/Source/Core/CorridorGeometry.js +2 -4
  238. package/Source/Core/CorridorOutlineGeometry.js +1 -3
  239. package/Source/Core/EarthOrientationParameters.js +2 -2
  240. package/Source/Core/EllipseGeometryLibrary.js +2 -2
  241. package/Source/Core/EllipsoidGeodesic.js +3 -3
  242. package/Source/Core/EllipsoidRhumbLine.js +1 -1
  243. package/Source/Core/Heap.js +1 -1
  244. package/Source/Core/HermitePolynomialApproximation.js +215 -179
  245. package/Source/Core/InterpolationAlgorithm.js +58 -50
  246. package/Source/Core/Ion.js +1 -1
  247. package/Source/Core/JulianDate.js +1 -1
  248. package/Source/Core/LagrangePolynomialApproximation.js +55 -52
  249. package/Source/Core/LinearApproximation.js +69 -66
  250. package/Source/Core/MapProjection.js +1 -0
  251. package/Source/Core/Math.js +59 -0
  252. package/Source/Core/Matrix2.js +3 -3
  253. package/Source/Core/Matrix3.js +3 -3
  254. package/Source/Core/Matrix4.js +1 -1
  255. package/Source/Core/OrthographicFrustum.js +1 -1
  256. package/Source/Core/PerspectiveFrustum.js +1 -1
  257. package/Source/Core/PolygonGeometry.js +2 -2
  258. package/Source/Core/PolygonGeometryLibrary.js +1 -1
  259. package/Source/Core/PolygonOutlineGeometry.js +1 -1
  260. package/Source/Core/PolylineGeometry.js +1 -1
  261. package/Source/Core/PolylineVolumeGeometryLibrary.js +1 -1
  262. package/Source/Core/Rectangle.js +7 -1
  263. package/Source/Core/RectangleOutlineGeometry.js +1 -1
  264. package/Source/Core/Resource.js +1 -1
  265. package/Source/Core/ScreenSpaceEventHandler.js +51 -41
  266. package/Source/Core/SimplePolylineGeometry.js +1 -1
  267. package/Source/Core/TerrainEncoding.js +2 -2
  268. package/Source/Core/TerrainMesh.js +3 -3
  269. package/Source/Core/TerrainPicker.js +180 -168
  270. package/Source/Core/TimeIntervalCollection.js +1 -3
  271. package/Source/Core/Tipsify.js +1 -1
  272. package/Source/Core/Transforms.js +5 -1
  273. package/Source/Core/VectorPipeline.js +1117 -0
  274. package/Source/Core/VectorProvider.js +429 -0
  275. package/Source/Core/WallOutlineGeometry.js +1 -1
  276. package/Source/Core/createColorRamp.js +37 -0
  277. package/Source/Core/getTimestamp.js +4 -2
  278. package/Source/Core/globalTypes.js +25 -0
  279. package/Source/Core/writeTextToCanvas.js +1 -0
  280. package/Source/DataSources/CompositeEntityCollection.js +0 -1
  281. package/Source/DataSources/CzmlDataSource.js +14 -0
  282. package/Source/DataSources/DataSourceDisplay.js +1 -1
  283. package/Source/DataSources/GeoJsonDataSource.js +0 -1
  284. package/Source/DataSources/GeometryVisualizer.js +1 -1
  285. package/Source/DataSources/KmlDataSource.js +529 -557
  286. package/Source/DataSources/PathGraphics.js +8 -1
  287. package/Source/DataSources/PathMode.js +27 -0
  288. package/Source/DataSources/PathVisualizer.js +298 -1
  289. package/Source/DataSources/PolylineVisualizer.js +1 -1
  290. package/Source/DataSources/StaticOutlineGeometryBatch.js +1 -1
  291. package/Source/Renderer/AutomaticUniforms.js +23 -0
  292. package/Source/Renderer/Context.js +9 -3
  293. package/Source/Renderer/DrawCommand.js +22 -0
  294. package/Source/Renderer/Framebuffer.js +4 -0
  295. package/Source/Renderer/Pass.js +11 -9
  296. package/Source/Renderer/Texture.js +12 -1
  297. package/Source/Renderer/UniformState.js +7 -0
  298. package/Source/Renderer/VertexArray.js +1 -1
  299. package/Source/Renderer/createUniform.js +346 -239
  300. package/Source/Renderer/createUniformArray.js +494 -381
  301. package/Source/Scene/ArcGisMapServerImageryProvider.js +0 -5
  302. package/Source/Scene/ArcGisMapService.js +1 -1
  303. package/Source/Scene/Billboard.js +2 -1
  304. package/Source/Scene/BillboardCollection.js +15 -5
  305. package/Source/Scene/BillboardTexture.js +5 -3
  306. package/Source/Scene/BufferPointCollection.js +11 -1
  307. package/Source/Scene/BufferPolygonCollection.js +26 -0
  308. package/Source/Scene/BufferPolylineCollection.js +2 -0
  309. package/Source/Scene/BufferPrimitiveCollection.js +105 -32
  310. package/Source/Scene/Camera.js +85 -9
  311. package/Source/Scene/CameraEventAggregator.js +30 -18
  312. package/Source/Scene/CameraFlightPath.js +7 -4
  313. package/Source/Scene/Cesium3DTile.js +102 -4
  314. package/Source/Scene/Cesium3DTileContent.js +195 -254
  315. package/Source/Scene/Cesium3DTileContentFactory.js +10 -2
  316. package/Source/Scene/Cesium3DTileOptimizations.js +4 -6
  317. package/Source/Scene/Cesium3DTileStyle.js +40 -0
  318. package/Source/Scene/Cesium3DTileset.js +213 -8
  319. package/Source/Scene/Cesium3DTilesetTraversal.js +14 -0
  320. package/Source/Scene/ClippingPlaneCollection.js +4 -4
  321. package/Source/Scene/ClippingPolygon.js +2 -0
  322. package/Source/Scene/ClippingPolygonCollection.js +2 -2
  323. package/Source/Scene/Composite3DTileContent.js +254 -292
  324. package/Source/Scene/Controllers/Controller.js +63 -0
  325. package/Source/Scene/Controllers/ControllerHost.js +78 -0
  326. package/Source/Scene/Controllers/HybridScreenSpacePanCameraController.js +106 -0
  327. package/Source/Scene/Controllers/MouseButton.js +32 -0
  328. package/Source/Scene/Controllers/ScreenSpaceElevatorCameraController.js +295 -0
  329. package/Source/Scene/Controllers/ScreenSpaceInputBindings.js +154 -0
  330. package/Source/Scene/Controllers/ScreenSpaceMapCameraController.js +310 -0
  331. package/Source/Scene/Controllers/ScreenSpaceTiltOrbitCameraController.js +642 -0
  332. package/Source/Scene/Controllers/ScreenSpaceZoomCameraController.js +431 -0
  333. package/Source/Scene/Controllers/defaultPickWorldPosition.js +84 -0
  334. package/Source/Scene/DerivedCommand.js +98 -0
  335. package/Source/Scene/EdgeDisplayMode.js +50 -0
  336. package/Source/Scene/EdgeFramebuffer.js +1 -5
  337. package/Source/Scene/Empty3DTileContent.js +100 -132
  338. package/Source/Scene/Expression.js +6 -8
  339. package/Source/Scene/FrameState.js +17 -0
  340. package/Source/Scene/GaussianSplat3DTileContent.js +436 -478
  341. package/Source/Scene/GeoJsonPrimitive.js +874 -0
  342. package/Source/Scene/Geometry3DTileContent.js +151 -185
  343. package/Source/Scene/Globe.js +22 -1
  344. package/Source/Scene/GlobeDepth.js +27 -1
  345. package/Source/Scene/GlobeSurfaceShaderSet.js +637 -540
  346. package/Source/Scene/GlobeSurfaceTile.js +575 -398
  347. package/Source/Scene/GlobeSurfaceTileProvider.js +1412 -1184
  348. package/Source/Scene/GltfBufferViewLoader.js +3 -3
  349. package/Source/Scene/GltfLoader.js +146 -3
  350. package/Source/Scene/GltfLoaderUtil.js +20 -4
  351. package/Source/Scene/GltfPipeline/forEachTextureInMaterial.js +10 -0
  352. package/Source/Scene/GltfPipeline/removeUnusedElements.js +21 -11
  353. package/Source/Scene/GltfSpzLoader.js +1 -1
  354. package/Source/Scene/GltfVertexBufferLoader.js +6 -3
  355. package/Source/Scene/I3SDataProvider.js +1 -1
  356. package/Source/Scene/I3SLayer.js +1 -1
  357. package/Source/Scene/I3SNode.js +2 -2
  358. package/Source/Scene/ImageryLayer.js +2 -2
  359. package/Source/Scene/ImageryLayerCollection.js +190 -6
  360. package/Source/Scene/Implicit3DTileContent.js +192 -216
  361. package/Source/Scene/ImplicitTileCoordinates.js +17 -0
  362. package/Source/Scene/IonImageryProvider.js +1 -5
  363. package/Source/Scene/Label.js +4 -4
  364. package/Source/Scene/LabelCollection.js +4 -1
  365. package/Source/Scene/MVTDataProvider.js +555 -0
  366. package/Source/Scene/Material.js +1 -0
  367. package/Source/Scene/Model/B3dmLoader.js +1 -2
  368. package/Source/Scene/Model/EdgeVisibilityPipelineStage.js +82 -312
  369. package/Source/Scene/Model/Extensions/Gpm/GltfGpmLoader.js +4 -0
  370. package/Source/Scene/Model/I3dmLoader.js +1 -1
  371. package/Source/Scene/Model/InstancingPipelineStage.js +4 -7
  372. package/Source/Scene/Model/MaterialPipelineStage.js +124 -1
  373. package/Source/Scene/Model/Model.js +45 -10
  374. package/Source/Scene/Model/Model3DTileContent.js +424 -458
  375. package/Source/Scene/Model/ModelClippingPlanesPipelineStage.js +28 -1
  376. package/Source/Scene/Model/ModelDrawCommand.js +180 -8
  377. package/Source/Scene/Model/ModelDrawCommands.js +4 -0
  378. package/Source/Scene/Model/ModelSceneGraph.js +21 -0
  379. package/Source/Scene/Model/ModelUtility.js +5 -0
  380. package/Source/Scene/Model/PickingPipelineStage.js +29 -0
  381. package/Source/Scene/Model/PrimitiveRenderResources.js +24 -0
  382. package/Source/Scene/Model/createVectorTileBuffersFromModelComponents.js +645 -153
  383. package/Source/Scene/ModelComponents.js +112 -0
  384. package/Source/Scene/Multiple3DTileContent.js +291 -334
  385. package/Source/Scene/MvtLabelCandidates.js +295 -0
  386. package/Source/Scene/MvtLabelManager.js +1069 -0
  387. package/Source/Scene/Picking.js +19 -3
  388. package/Source/Scene/PlanarFillIdFramebuffer.js +172 -0
  389. package/Source/Scene/PntsParser.js +1 -1
  390. package/Source/Scene/PolylineCollection.js +5 -3
  391. package/Source/Scene/PostProcessStage.js +4 -2
  392. package/Source/Scene/QuadtreePrimitive.js +3 -2
  393. package/Source/Scene/ResourceCache.js +7 -4
  394. package/Source/Scene/ResourceCacheKey.js +21 -18
  395. package/Source/Scene/Scene.js +237 -11
  396. package/Source/Scene/SceneTransforms.js +6 -5
  397. package/Source/Scene/ShadowMap.js +9 -3
  398. package/Source/Scene/ShadowMapShader.js +50 -2
  399. package/Source/Scene/SnapFramebuffer.js +121 -0
  400. package/Source/Scene/Snapping.js +184 -0
  401. package/Source/Scene/TerrainFillMesh.js +3 -2
  402. package/Source/Scene/Tileset3DTileContent.js +113 -146
  403. package/Source/Scene/UrlTemplate3DTilesDataProvider.js +543 -0
  404. package/Source/Scene/Vector3DTileContent.js +207 -237
  405. package/Source/Scene/VectorGltf3DTileContent.js +185 -45
  406. package/Source/Scene/View.js +10 -8
  407. package/Source/Scene/VoxelPrimitive.js +159 -175
  408. package/Source/Scene/VoxelProvider.js +64 -91
  409. package/Source/Scene/VoxelTraversal.js +1 -1
  410. package/Source/Scene/buildVectorGltfFromMVT.js +1208 -0
  411. package/Source/Scene/buildVoxelCustomShader.js +199 -0
  412. package/Source/Scene/createElevationBandMaterial.js +1 -1
  413. package/Source/Scene/decodeMVT.js +877 -0
  414. package/Source/Scene/findMeshoptExtension.js +23 -0
  415. package/Source/Scene/renderBufferPointCollection.js +114 -64
  416. package/Source/Scene/renderBufferPolygonCollection.js +245 -53
  417. package/Source/Scene/renderBufferPolylineCollection.js +271 -145
  418. package/Source/Shaders/BillboardCollectionVS.glsl +23 -25
  419. package/Source/Shaders/BillboardCollectionVS.js +23 -25
  420. package/Source/Shaders/BufferPointMaterialFS.glsl +1 -0
  421. package/Source/Shaders/BufferPointMaterialFS.js +1 -0
  422. package/Source/Shaders/BufferPointMaterialVS.glsl +19 -9
  423. package/Source/Shaders/BufferPointMaterialVS.js +20 -10
  424. package/Source/Shaders/BufferPolygonMaterialFS.glsl +13 -0
  425. package/Source/Shaders/BufferPolygonMaterialFS.js +13 -0
  426. package/Source/Shaders/BufferPolygonMaterialVS.glsl +22 -4
  427. package/Source/Shaders/BufferPolygonMaterialVS.js +23 -5
  428. package/Source/Shaders/BufferPolylineMaterialVS.glsl +16 -2
  429. package/Source/Shaders/BufferPolylineMaterialVS.js +17 -3
  430. package/Source/Shaders/Builtin/Constants/passCesium3DTile.glsl +1 -1
  431. package/Source/Shaders/Builtin/Constants/passCesium3DTile.js +1 -1
  432. package/Source/Shaders/Builtin/Constants/passCesium3DTileClassification.glsl +1 -1
  433. package/Source/Shaders/Builtin/Constants/passCesium3DTileClassification.js +1 -1
  434. package/Source/Shaders/Builtin/Constants/passCesium3DTileClassificationIgnoreShow.glsl +1 -1
  435. package/Source/Shaders/Builtin/Constants/passCesium3DTileClassificationIgnoreShow.js +1 -1
  436. package/Source/Shaders/Builtin/Constants/passCesium3DTileEdgesDirect.glsl +9 -0
  437. package/Source/Shaders/Builtin/Constants/passCesium3DTileEdgesDirect.js +11 -0
  438. package/Source/Shaders/Builtin/Constants/passCesium3DTilePlanarFillId.glsl +9 -0
  439. package/Source/Shaders/Builtin/Constants/passCesium3DTilePlanarFillId.js +11 -0
  440. package/Source/Shaders/Builtin/Constants/passClassification.glsl +1 -1
  441. package/Source/Shaders/Builtin/Constants/passClassification.js +1 -1
  442. package/Source/Shaders/Builtin/Constants/passGaussianSplats.glsl +1 -1
  443. package/Source/Shaders/Builtin/Constants/passGaussianSplats.js +1 -1
  444. package/Source/Shaders/Builtin/Constants/passOpaque.glsl +1 -1
  445. package/Source/Shaders/Builtin/Constants/passOpaque.js +1 -1
  446. package/Source/Shaders/Builtin/Constants/passOverlay.glsl +1 -1
  447. package/Source/Shaders/Builtin/Constants/passOverlay.js +1 -1
  448. package/Source/Shaders/Builtin/Constants/passTranslucent.glsl +1 -1
  449. package/Source/Shaders/Builtin/Constants/passTranslucent.js +1 -1
  450. package/Source/Shaders/Builtin/Constants/passVoxels.glsl +1 -1
  451. package/Source/Shaders/Builtin/Constants/passVoxels.js +1 -1
  452. package/Source/Shaders/Builtin/CzmBuiltins.js +4 -0
  453. package/Source/Shaders/GlobeFS.glsl +10 -6
  454. package/Source/Shaders/GlobeFS.js +10 -6
  455. package/Source/Shaders/Materials/PolylineGlowMaterial.glsl +1 -1
  456. package/Source/Shaders/Materials/PolylineGlowMaterial.js +1 -1
  457. package/Source/Shaders/Model/EdgeVisibilityStageVS.glsl +0 -1
  458. package/Source/Shaders/Model/EdgeVisibilityStageVS.js +0 -1
  459. package/Source/Shaders/Model/MaterialStageFS.glsl +8 -2
  460. package/Source/Shaders/Model/MaterialStageFS.js +8 -2
  461. package/Source/Shaders/Model/ModelFS.glsl +105 -0
  462. package/Source/Shaders/Model/ModelFS.js +105 -0
  463. package/Source/Shaders/VectorCommon.glsl +178 -0
  464. package/Source/Shaders/VectorCommon.js +180 -0
  465. package/Source/ThirdParty/zip-module.wasm +0 -0
  466. package/Source/Widget/CesiumWidget.js +30 -0
  467. package/Source/Workers/createMvtTile.js +39 -0
  468. package/Source/Workers/decodeGoogleEarthEnterprisePacket.js +2 -2
  469. package/Source/Workers/incrementallyBuildTerrainPicker.js +2 -0
  470. package/index.js +214 -184
  471. package/package.json +13 -13
@@ -0,0 +1,1208 @@
1
+ // @ts-check
2
+
3
+ import Cartesian2 from "../Core/Cartesian2.js";
4
+ import Cartesian3 from "../Core/Cartesian3.js";
5
+ import ComponentDatatype from "../Core/ComponentDatatype.js";
6
+ import PolygonPipeline from "../Core/PolygonPipeline.js";
7
+ import PrimitiveType from "../Core/PrimitiveType.js";
8
+ import Rectangle from "../Core/Rectangle.js";
9
+ import WebGLConstants from "../Core/WebGLConstants.js";
10
+ import WebMercatorTilingScheme from "../Core/WebMercatorTilingScheme.js";
11
+ import defined from "../Core/defined.js";
12
+ import oneTimeWarning from "../Core/oneTimeWarning.js";
13
+ import MetadataType from "./MetadataType.js";
14
+
15
+ /** @import { TypedArray } from "../Core/globalTypes.js"; */
16
+
17
+ /** @ignore */
18
+ const DEFAULT_HEIGHT = 0;
19
+ const TILE_BOUNDARY_WEST = 1;
20
+ const TILE_BOUNDARY_EAST = 2;
21
+ const TILE_BOUNDARY_SOUTH = 4;
22
+ const TILE_BOUNDARY_NORTH = 8;
23
+ const TILE_BOUNDARY_EPSILON = 1e-6;
24
+
25
+ const scratchWorld = new Cartesian3();
26
+ const scratchLocal = new Cartesian3();
27
+ const tilingScheme = new WebMercatorTilingScheme();
28
+
29
+ /**
30
+ * @typedef {object} VectorTilePoint
31
+ * @property {number} x Tile-local x (0–extent)
32
+ * @property {number} y Tile-local y (0–extent)
33
+ * @ignore
34
+ */
35
+
36
+ /**
37
+ * @typedef {object} VectorTileFeature
38
+ * @property {"Point"|"LineString"|"Polygon"|"Unknown"} type
39
+ * @property {Array<VectorTilePoint>|Array<Array<VectorTilePoint>>} geometry
40
+ * @property {object} [properties]
41
+ * @ignore
42
+ */
43
+
44
+ /**
45
+ * @typedef {object} VectorTileLayer
46
+ * @property {string} [name]
47
+ * @property {number} extent
48
+ * @property {VectorTileFeature[]} features
49
+ * @ignore
50
+ */
51
+
52
+ /**
53
+ * @typedef {object} DecodedVectorTile
54
+ * @property {VectorTileLayer[]} layers
55
+ * @ignore
56
+ */
57
+
58
+ /**
59
+ * @typedef {object} PolygonRingGroup
60
+ * @property {Array.<VectorTilePoint>} outerRing
61
+ * @property {Array.<Array.<VectorTilePoint>>} holes
62
+ * @ignore
63
+ */
64
+
65
+ /**
66
+ * @typedef {object} BuildVectorGltfOptions
67
+ * @property {string} [featureIdProperty] MVT property name to use as feature ID.
68
+ * @ignore
69
+ */
70
+
71
+ /**
72
+ * Build a vector glTF payload from decoded tile-local vector geometry.
73
+ * Each MVT layer produces a separate glTF node (named after the layer),
74
+ * enabling layer-specific styling in the future.
75
+ *
76
+ * @param {DecodedVectorTile} decoded
77
+ * @param {{tileX:number, tileY:number, tileZ:number}} tileCoordinates
78
+ * @param {BuildVectorGltfOptions} [options]
79
+ * @returns {Uint8Array|undefined}
80
+ *
81
+ * @ignore
82
+ */
83
+ function buildVectorGltfFromMVT(decoded, tileCoordinates, options) {
84
+ const tileX = tileCoordinates.tileX;
85
+ const tileY = tileCoordinates.tileY;
86
+ const tileZ = tileCoordinates.tileZ;
87
+ const featureIdProperty = options?.featureIdProperty;
88
+
89
+ const tileRect = tilingScheme.tileXYToRectangle(tileX, tileY, tileZ);
90
+ const tileCenter = Rectangle.center(tileRect);
91
+ const origin = Cartesian3.fromRadians(
92
+ tileCenter.longitude,
93
+ tileCenter.latitude,
94
+ 0,
95
+ );
96
+ // Maximum value of a Uint32; used as sentinel for null feature IDs and primitive restart indices.
97
+ const MAX_INT_U32 = 0xffffffff;
98
+ const nullFeatureId = MAX_INT_U32;
99
+ const primitiveRestartIndex = MAX_INT_U32;
100
+ // Maps a property value (or auto-increment key) to a compact integer feature ID.
101
+ const featureIdLookup = new Map();
102
+
103
+ // Maps featureId -> properties object (first-seen wins for ID collisions).
104
+ /** @type {Map<number, Object.<string, *>>} */
105
+ const featureProperties = new Map();
106
+
107
+ /** @type {object[]} */
108
+ const bufferViews = [];
109
+ /** @type {object[]} */
110
+ const accessors = [];
111
+ /** @type {Uint8Array[]} */
112
+ const chunks = [];
113
+ let byteLength = 0;
114
+
115
+ function addPadding() {
116
+ const padding = (4 - (byteLength % 4)) % 4;
117
+ if (padding > 0) {
118
+ chunks.push(new Uint8Array(padding));
119
+ byteLength += padding;
120
+ }
121
+ }
122
+
123
+ /**
124
+ * @param {TypedArray} typedArray
125
+ * @param {number} target
126
+ * @returns {number}
127
+ */
128
+ function addBufferView(typedArray, target) {
129
+ addPadding();
130
+ const byteOffset = byteLength;
131
+ chunks.push(
132
+ new Uint8Array(
133
+ typedArray.buffer,
134
+ typedArray.byteOffset,
135
+ typedArray.byteLength,
136
+ ),
137
+ );
138
+ byteLength += typedArray.byteLength;
139
+ const bufferViewIndex = bufferViews.length;
140
+ bufferViews.push({
141
+ buffer: 0,
142
+ byteOffset: byteOffset,
143
+ byteLength: typedArray.byteLength,
144
+ target: target,
145
+ });
146
+ return bufferViewIndex;
147
+ }
148
+
149
+ /**
150
+ * @param {TypedArray} typedArray
151
+ * @param {object} options
152
+ * @param {string} options.type
153
+ * @param {number} options.componentType
154
+ * @param {number} options.target
155
+ * @param {number[]} [options.min]
156
+ * @param {number[]} [options.max]
157
+ * @returns {number}
158
+ */
159
+ function addAccessor(typedArray, options) {
160
+ const bufferView = addBufferView(typedArray, options.target);
161
+ const componentCount = /** @type {*} */ (MetadataType).getComponentCount(
162
+ options.type,
163
+ );
164
+ const accessor = /** @type {*} */ ({
165
+ bufferView: bufferView,
166
+ byteOffset: 0,
167
+ componentType: options.componentType,
168
+ count: typedArray.length / componentCount,
169
+ type: options.type,
170
+ });
171
+ if (defined(options.min)) {
172
+ accessor.min = options.min;
173
+ }
174
+ if (defined(options.max)) {
175
+ accessor.max = options.max;
176
+ }
177
+ const accessorIndex = accessors.length;
178
+ accessors.push(accessor);
179
+ return accessorIndex;
180
+ }
181
+
182
+ /**
183
+ * @param {Float32Array} positions
184
+ * @returns {{min:number[],max:number[]}}
185
+ */
186
+ function computeMinMax(positions) {
187
+ let minX = Number.POSITIVE_INFINITY;
188
+ let minY = Number.POSITIVE_INFINITY;
189
+ let minZ = Number.POSITIVE_INFINITY;
190
+ let maxX = Number.NEGATIVE_INFINITY;
191
+ let maxY = Number.NEGATIVE_INFINITY;
192
+ let maxZ = Number.NEGATIVE_INFINITY;
193
+
194
+ for (let i = 0; i < positions.length; i += 3) {
195
+ const x = positions[i];
196
+ const y = positions[i + 1];
197
+ const z = positions[i + 2];
198
+ if (x < minX) {
199
+ minX = x;
200
+ }
201
+ if (y < minY) {
202
+ minY = y;
203
+ }
204
+ if (z < minZ) {
205
+ minZ = z;
206
+ }
207
+ if (x > maxX) {
208
+ maxX = x;
209
+ }
210
+ if (y > maxY) {
211
+ maxY = y;
212
+ }
213
+ if (z > maxZ) {
214
+ maxZ = z;
215
+ }
216
+ }
217
+
218
+ return {
219
+ min: [minX, minY, minZ],
220
+ max: [maxX, maxY, maxZ],
221
+ };
222
+ }
223
+
224
+ /**
225
+ * @param {*} attributes
226
+ * @param {*} extensions
227
+ * @param {number[]} featureIdValues
228
+ */
229
+ function addFeatureIdsToPrimitive(attributes, extensions, featureIdValues) {
230
+ if (featureIdValues.length === 0) {
231
+ return;
232
+ }
233
+ const featureIds = new Uint32Array(featureIdValues);
234
+ const featureAccessor = addAccessor(featureIds, {
235
+ type: "SCALAR",
236
+ componentType: ComponentDatatype.UNSIGNED_INT,
237
+ target: WebGLConstants.ARRAY_BUFFER,
238
+ });
239
+ attributes._FEATURE_ID_0 = featureAccessor;
240
+ /** @type {*} */
241
+ const featureIdDef = {
242
+ featureCount: featureIdLookup.size,
243
+ nullFeatureId: nullFeatureId,
244
+ attribute: 0,
245
+ };
246
+ if (featureProperties.size > 0) {
247
+ featureIdDef.propertyTable = 0;
248
+ }
249
+ extensions.EXT_mesh_features = {
250
+ featureIds: [featureIdDef],
251
+ };
252
+ }
253
+
254
+ /**
255
+ * Adds a raw buffer view for metadata (no accessor target).
256
+ * @param {Uint8Array} bytes
257
+ * @param {number} [alignment=4] Required byte alignment (e.g., 8 for Float64).
258
+ * @returns {number} bufferView index
259
+ */
260
+ function addMetadataBufferView(bytes, alignment) {
261
+ alignment = alignment ?? 4;
262
+ // Align to the required boundary.
263
+ const pad = (alignment - (byteLength % alignment)) % alignment;
264
+ if (pad > 0) {
265
+ chunks.push(new Uint8Array(pad));
266
+ byteLength += pad;
267
+ }
268
+ const byteOffset = byteLength;
269
+ chunks.push(bytes);
270
+ byteLength += bytes.byteLength;
271
+ const bufferViewIndex = bufferViews.length;
272
+ bufferViews.push({
273
+ buffer: 0,
274
+ byteOffset: byteOffset,
275
+ byteLength: bytes.byteLength,
276
+ });
277
+ return bufferViewIndex;
278
+ }
279
+
280
+ /**
281
+ * Builds the EXT_structural_metadata extension object with schema and
282
+ * property table from the collected feature properties.
283
+ * @returns {object|undefined}
284
+ */
285
+ function buildStructuralMetadata() {
286
+ if (featureProperties.size === 0) {
287
+ return undefined;
288
+ }
289
+
290
+ // 1. Determine union of all property names and infer types.
291
+ // propertyName -> "STRING"|"SCALAR"|"BOOLEAN"
292
+ /** @type {Map<string, string>} */
293
+ const propertyTypes = new Map();
294
+
295
+ for (const props of featureProperties.values()) {
296
+ for (const [key, value] of Object.entries(props)) {
297
+ if (!defined(value)) {
298
+ continue;
299
+ }
300
+ const jsType = typeof value;
301
+ let metaType;
302
+ if (jsType === "string") {
303
+ metaType = "STRING";
304
+ } else if (jsType === "number") {
305
+ metaType = "SCALAR";
306
+ } else if (jsType === "boolean") {
307
+ metaType = "BOOLEAN";
308
+ } else {
309
+ // Objects/arrays: coerce to string
310
+ metaType = "STRING";
311
+ }
312
+
313
+ const existing = propertyTypes.get(key);
314
+ if (!defined(existing)) {
315
+ propertyTypes.set(key, metaType);
316
+ } else if (existing !== metaType) {
317
+ // Mixed types: coerce to STRING
318
+ propertyTypes.set(key, "STRING");
319
+ }
320
+ }
321
+ }
322
+
323
+ if (propertyTypes.size === 0) {
324
+ return undefined;
325
+ }
326
+
327
+ // 2. Build schema class properties.
328
+ /** @type {Object.<string, *>} */
329
+ const classProperties = {};
330
+ for (const [name, type] of propertyTypes) {
331
+ if (type === "SCALAR") {
332
+ classProperties[name] = {
333
+ type: "SCALAR",
334
+ componentType: "FLOAT64",
335
+ };
336
+ } else if (type === "BOOLEAN") {
337
+ classProperties[name] = {
338
+ type: "BOOLEAN",
339
+ };
340
+ } else {
341
+ classProperties[name] = {
342
+ type: "STRING",
343
+ };
344
+ }
345
+ }
346
+
347
+ // 3. Encode property values into binary buffers.
348
+ /** @type {Object.<string, *>} */
349
+ const tableProperties = {};
350
+ const count = featureIdLookup.size;
351
+
352
+ for (const [name, type] of propertyTypes) {
353
+ if (type === "SCALAR") {
354
+ const values = new Float64Array(count);
355
+ for (let i = 0; i < count; i++) {
356
+ const props = featureProperties.get(i);
357
+ const raw = props?.[name];
358
+ values[i] =
359
+ typeof raw === "number" && Number.isFinite(raw) ? raw : NaN;
360
+ }
361
+ const bvIndex = addMetadataBufferView(
362
+ new Uint8Array(values.buffer, values.byteOffset, values.byteLength),
363
+ 8,
364
+ );
365
+ tableProperties[name] = { values: bvIndex };
366
+ } else if (type === "BOOLEAN") {
367
+ const byteCount = Math.ceil(count / 8);
368
+ const values = new Uint8Array(byteCount);
369
+ for (let i = 0; i < count; i++) {
370
+ const props = featureProperties.get(i);
371
+ const raw = props?.[name];
372
+ if (raw) {
373
+ values[i >> 3] |= 1 << (i & 7);
374
+ }
375
+ }
376
+ const bvIndex = addMetadataBufferView(values);
377
+ tableProperties[name] = { values: bvIndex };
378
+ } else {
379
+ // STRING encoding: values (UTF-8 bytes) + stringOffsets (Uint32)
380
+ const encoder = new TextEncoder();
381
+ /** @type {Uint8Array[]} */
382
+ const stringParts = [];
383
+ const offsets = new Uint32Array(count + 1);
384
+ let totalBytes = 0;
385
+
386
+ for (let i = 0; i < count; i++) {
387
+ offsets[i] = totalBytes;
388
+ const props = featureProperties.get(i);
389
+ const raw = props?.[name];
390
+ let str;
391
+ if (raw === null || raw === undefined) {
392
+ str = "";
393
+ } else if (typeof raw === "string") {
394
+ str = raw;
395
+ } else {
396
+ str = String(raw);
397
+ }
398
+ const encoded = encoder.encode(str);
399
+ stringParts.push(encoded);
400
+ totalBytes += encoded.byteLength;
401
+ }
402
+ offsets[count] = totalBytes;
403
+
404
+ // Concatenate string bytes
405
+ const valuesBuffer = new Uint8Array(totalBytes);
406
+ let writeOffset = 0;
407
+ for (const part of stringParts) {
408
+ valuesBuffer.set(part, writeOffset);
409
+ writeOffset += part.byteLength;
410
+ }
411
+
412
+ const valuesBv = addMetadataBufferView(valuesBuffer);
413
+ const offsetsBv = addMetadataBufferView(
414
+ new Uint8Array(
415
+ offsets.buffer,
416
+ offsets.byteOffset,
417
+ offsets.byteLength,
418
+ ),
419
+ );
420
+ tableProperties[name] = {
421
+ values: valuesBv,
422
+ stringOffsets: offsetsBv,
423
+ stringOffsetType: "UINT32",
424
+ };
425
+ }
426
+ }
427
+
428
+ return {
429
+ schema: {
430
+ classes: {
431
+ mvt_feature: {
432
+ properties: classProperties,
433
+ },
434
+ },
435
+ },
436
+ propertyTables: [
437
+ {
438
+ class: "mvt_feature",
439
+ count: count,
440
+ properties: tableProperties,
441
+ },
442
+ ],
443
+ };
444
+ }
445
+
446
+ /** @type {object[]} */
447
+ const meshes = [];
448
+ /** @type {object[]} */
449
+ const nodes = [];
450
+ const translation = [origin.x, origin.y, origin.z];
451
+
452
+ for (const layer of decoded.layers) {
453
+ const extent = layer.extent;
454
+
455
+ /** @type {number[]} */
456
+ const pointPositions = [];
457
+ /** @type {number[]} */
458
+ const pointFeatureIds = [];
459
+
460
+ /** @type {number[]} */
461
+ const linePositions = [];
462
+ /** @type {number[]} */
463
+ const lineFeatureIds = [];
464
+ /** @type {number[]} */
465
+ const lineIndices = [];
466
+ let lineCount = 0;
467
+
468
+ /** @type {number[]} */
469
+ const polygonPositions = [];
470
+ /** @type {number[]} */
471
+ const polygonFeatureIds = [];
472
+ /** @type {number[]} */
473
+ const polygonIndices = [];
474
+ /** @type {number[]} */
475
+ const polygonAttributeOffsets = [];
476
+ /** @type {number[]} */
477
+ const polygonIndicesOffsets = [];
478
+ /** @type {number[]} */
479
+ const polygonHoleCounts = [];
480
+ /** @type {number[]} */
481
+ const polygonHoleOffsets = [];
482
+ /** @type {number[]} */
483
+ const polygonTileBoundaryFlags = [];
484
+ let polygonCount = 0;
485
+
486
+ for (const feature of layer.features) {
487
+ const currentFeatureId = defined(featureIdProperty)
488
+ ? (mapFeatureIdFromProperty(
489
+ feature,
490
+ featureIdProperty,
491
+ featureIdLookup,
492
+ ) ?? nullFeatureId)
493
+ : getOrAssignAutoFeatureId(feature, featureIdLookup);
494
+
495
+ // Collect properties for the property table (first-seen wins).
496
+ if (
497
+ currentFeatureId !== nullFeatureId &&
498
+ !featureProperties.has(currentFeatureId)
499
+ ) {
500
+ /** @type {Object.<string, *>} */
501
+ const props = Object.assign({}, feature.properties);
502
+ props["_layer"] = layer.name ?? "";
503
+ featureProperties.set(currentFeatureId, props);
504
+ }
505
+
506
+ if (feature.type === "Point") {
507
+ const points = /** @type {VectorTilePoint[]} */ (feature.geometry);
508
+ for (const point of points) {
509
+ appendTilePointAsLocalPosition(
510
+ point,
511
+ tileX,
512
+ tileY,
513
+ tileZ,
514
+ extent,
515
+ DEFAULT_HEIGHT,
516
+ origin,
517
+ pointPositions,
518
+ );
519
+ pointFeatureIds.push(currentFeatureId);
520
+ }
521
+ continue;
522
+ }
523
+
524
+ if (feature.type === "LineString") {
525
+ const lines = /** @type {VectorTilePoint[][]} */ (feature.geometry);
526
+ for (const line of lines) {
527
+ const lineStart = linePositions.length / 3;
528
+ for (const point of line) {
529
+ appendTilePointAsLocalPosition(
530
+ point,
531
+ tileX,
532
+ tileY,
533
+ tileZ,
534
+ extent,
535
+ DEFAULT_HEIGHT,
536
+ origin,
537
+ linePositions,
538
+ );
539
+ lineFeatureIds.push(currentFeatureId);
540
+ }
541
+
542
+ for (let i = 0; i < line.length; i++) {
543
+ lineIndices.push(lineStart + i);
544
+ }
545
+ lineIndices.push(primitiveRestartIndex);
546
+ lineCount++;
547
+ }
548
+ continue;
549
+ }
550
+
551
+ if (feature.type === "Polygon") {
552
+ const rawRings = /** @type {VectorTilePoint[][]} */ (feature.geometry);
553
+ const clippedRings = rawRings
554
+ .map((ring) => clipRingToTileExtent(ring, extent))
555
+ .filter((ring) => ring.length >= 3);
556
+ const groups = groupPolygonRings(clippedRings);
557
+
558
+ for (const group of groups) {
559
+ const rings = [group.outerRing, ...group.holes];
560
+ /** @type {Cartesian2[]} */
561
+ const positions2D = [];
562
+ /** @type {number[]} */
563
+ const polygonPositionComponents = [];
564
+ /** @type {number[]} */
565
+ const polygonBoundaryFlags = [];
566
+ /** @type {number[]} */
567
+ const holeOffsets = [];
568
+ let vertexOffset = 0;
569
+
570
+ for (let ringIndex = 0; ringIndex < rings.length; ringIndex++) {
571
+ const ring = rings[ringIndex];
572
+ if (ringIndex > 0) {
573
+ holeOffsets.push(vertexOffset);
574
+ }
575
+
576
+ for (const point of ring) {
577
+ positions2D.push(new Cartesian2(point.x, point.y));
578
+ appendTilePointAsLocalPosition(
579
+ point,
580
+ tileX,
581
+ tileY,
582
+ tileZ,
583
+ extent,
584
+ DEFAULT_HEIGHT,
585
+ origin,
586
+ polygonPositionComponents,
587
+ );
588
+ vertexOffset++;
589
+ polygonBoundaryFlags.push(getTileBoundaryFlags(point, extent));
590
+ }
591
+ }
592
+
593
+ if (positions2D.length < 3) {
594
+ continue;
595
+ }
596
+
597
+ const triangles = PolygonPipeline.triangulate(
598
+ positions2D,
599
+ holeOffsets.length > 0 ? holeOffsets : undefined,
600
+ );
601
+
602
+ if (!defined(triangles) || triangles.length === 0) {
603
+ oneTimeWarning(
604
+ "buildVectorGltfFromMVT-triangulation-failed",
605
+ "Polygon triangulation failed; skipping polygon.",
606
+ );
607
+ continue;
608
+ }
609
+
610
+ const globalVertexStart = polygonPositions.length / 3;
611
+ const globalIndexStart = polygonIndices.length;
612
+ polygonAttributeOffsets.push(globalVertexStart);
613
+ polygonIndicesOffsets.push(globalIndexStart);
614
+ polygonHoleCounts.push(holeOffsets.length);
615
+ for (let i = 0; i < holeOffsets.length; i++) {
616
+ polygonHoleOffsets.push(globalVertexStart + holeOffsets[i]);
617
+ }
618
+
619
+ for (let i = 0; i < polygonPositionComponents.length; i++) {
620
+ polygonPositions.push(polygonPositionComponents[i]);
621
+ }
622
+ for (let i = 0; i < polygonBoundaryFlags.length; i++) {
623
+ polygonTileBoundaryFlags.push(polygonBoundaryFlags[i]);
624
+ }
625
+ for (let i = 0; i < polygonPositionComponents.length / 3; i++) {
626
+ polygonFeatureIds.push(currentFeatureId);
627
+ }
628
+ for (let i = 0; i < triangles.length; i++) {
629
+ polygonIndices.push(triangles[i] + globalVertexStart);
630
+ }
631
+ polygonCount++;
632
+ }
633
+ }
634
+ }
635
+
636
+ // Skip layers with no geometry.
637
+ if (
638
+ pointPositions.length === 0 &&
639
+ linePositions.length === 0 &&
640
+ polygonPositions.length === 0
641
+ ) {
642
+ continue;
643
+ }
644
+
645
+ if (
646
+ lineIndices.length > 0 &&
647
+ lineIndices[lineIndices.length - 1] === primitiveRestartIndex
648
+ ) {
649
+ lineIndices.pop();
650
+ }
651
+
652
+ /** @type {object[]} */
653
+ const primitives = [];
654
+
655
+ if (pointPositions.length > 0) {
656
+ const positions = new Float32Array(pointPositions);
657
+ const minMax = computeMinMax(positions);
658
+
659
+ const positionAccessor = addAccessor(positions, {
660
+ type: "VEC3",
661
+ componentType: ComponentDatatype.FLOAT,
662
+ target: WebGLConstants.ARRAY_BUFFER,
663
+ min: minMax.min,
664
+ max: minMax.max,
665
+ });
666
+ const attributes = /** @type {*} */ ({
667
+ POSITION: positionAccessor,
668
+ });
669
+ const extensions = /** @type {*} */ ({
670
+ CESIUM_mesh_vector: {
671
+ vector: true,
672
+ count: positions.length / 3,
673
+ },
674
+ });
675
+ addFeatureIdsToPrimitive(attributes, extensions, pointFeatureIds);
676
+
677
+ primitives.push({
678
+ mode: PrimitiveType.POINTS,
679
+ attributes: attributes,
680
+ extensions: extensions,
681
+ });
682
+ }
683
+
684
+ if (linePositions.length > 0 && lineIndices.length > 1) {
685
+ const positions = new Float32Array(linePositions);
686
+ const indices = new Uint32Array(lineIndices);
687
+ const minMax = computeMinMax(positions);
688
+
689
+ const positionAccessor = addAccessor(positions, {
690
+ type: "VEC3",
691
+ componentType: ComponentDatatype.FLOAT,
692
+ target: WebGLConstants.ARRAY_BUFFER,
693
+ min: minMax.min,
694
+ max: minMax.max,
695
+ });
696
+ const indicesAccessor = addAccessor(indices, {
697
+ type: "SCALAR",
698
+ componentType: ComponentDatatype.UNSIGNED_INT,
699
+ target: WebGLConstants.ELEMENT_ARRAY_BUFFER,
700
+ });
701
+ const attributes = /** @type {*} */ ({
702
+ POSITION: positionAccessor,
703
+ });
704
+ const extensions = /** @type {*} */ ({
705
+ CESIUM_mesh_vector: {
706
+ vector: true,
707
+ count: lineCount,
708
+ },
709
+ });
710
+ addFeatureIdsToPrimitive(attributes, extensions, lineFeatureIds);
711
+
712
+ primitives.push({
713
+ mode: PrimitiveType.LINE_STRIP,
714
+ indices: indicesAccessor,
715
+ attributes: attributes,
716
+ extensions: extensions,
717
+ });
718
+ }
719
+
720
+ if (polygonPositions.length > 0 && polygonIndices.length >= 3) {
721
+ const positions = new Float32Array(polygonPositions);
722
+ const indices = new Uint32Array(polygonIndices);
723
+ const attributeOffsets = new Uint32Array(polygonAttributeOffsets);
724
+ const indicesOffsets = new Uint32Array(polygonIndicesOffsets);
725
+ const hasPolygonHoles = polygonHoleOffsets.length > 0;
726
+ const holeCounts = hasPolygonHoles
727
+ ? new Uint32Array(polygonHoleCounts)
728
+ : undefined;
729
+ const holeOffsets = hasPolygonHoles
730
+ ? new Uint32Array(polygonHoleOffsets)
731
+ : undefined;
732
+ const tileBoundaryFlags = new Uint8Array(polygonTileBoundaryFlags);
733
+ const minMax = computeMinMax(positions);
734
+
735
+ const positionAccessor = addAccessor(positions, {
736
+ type: "VEC3",
737
+ componentType: ComponentDatatype.FLOAT,
738
+ target: WebGLConstants.ARRAY_BUFFER,
739
+ min: minMax.min,
740
+ max: minMax.max,
741
+ });
742
+ const indicesAccessor = addAccessor(indices, {
743
+ type: "SCALAR",
744
+ componentType: ComponentDatatype.UNSIGNED_INT,
745
+ target: WebGLConstants.ELEMENT_ARRAY_BUFFER,
746
+ });
747
+ const attributeOffsetsAccessor = addAccessor(attributeOffsets, {
748
+ type: "SCALAR",
749
+ componentType: ComponentDatatype.UNSIGNED_INT,
750
+ target: WebGLConstants.ARRAY_BUFFER,
751
+ });
752
+ const indicesOffsetsAccessor = addAccessor(indicesOffsets, {
753
+ type: "SCALAR",
754
+ componentType: ComponentDatatype.UNSIGNED_INT,
755
+ target: WebGLConstants.ARRAY_BUFFER,
756
+ });
757
+ const holeCountsAccessor = defined(holeCounts)
758
+ ? addAccessor(holeCounts, {
759
+ type: "SCALAR",
760
+ componentType: ComponentDatatype.UNSIGNED_INT,
761
+ target: WebGLConstants.ARRAY_BUFFER,
762
+ })
763
+ : undefined;
764
+ const holeOffsetsAccessor = defined(holeOffsets)
765
+ ? addAccessor(holeOffsets, {
766
+ type: "SCALAR",
767
+ componentType: ComponentDatatype.UNSIGNED_INT,
768
+ target: WebGLConstants.ARRAY_BUFFER,
769
+ })
770
+ : undefined;
771
+ const tileBoundaryFlagsAccessor = addAccessor(tileBoundaryFlags, {
772
+ type: "SCALAR",
773
+ componentType: ComponentDatatype.UNSIGNED_BYTE,
774
+ target: WebGLConstants.ARRAY_BUFFER,
775
+ });
776
+ const attributes = /** @type {*} */ ({
777
+ POSITION: positionAccessor,
778
+ });
779
+ const extensions = /** @type {*} */ ({
780
+ CESIUM_mesh_vector: {
781
+ vector: true,
782
+ count: polygonCount,
783
+ polygonAttributeOffsets: attributeOffsetsAccessor,
784
+ polygonIndicesOffsets: indicesOffsetsAccessor,
785
+ polygonTileBoundaryFlags: tileBoundaryFlagsAccessor,
786
+ },
787
+ });
788
+ if (hasPolygonHoles) {
789
+ extensions.CESIUM_mesh_vector.polygonHoleCounts = holeCountsAccessor;
790
+ extensions.CESIUM_mesh_vector.polygonHoleOffsets = holeOffsetsAccessor;
791
+ }
792
+ addFeatureIdsToPrimitive(attributes, extensions, polygonFeatureIds);
793
+
794
+ primitives.push({
795
+ mode: PrimitiveType.TRIANGLES,
796
+ indices: indicesAccessor,
797
+ attributes: attributes,
798
+ extensions: extensions,
799
+ });
800
+ }
801
+
802
+ if (primitives.length === 0) {
803
+ continue;
804
+ }
805
+
806
+ const meshIndex = meshes.length;
807
+ meshes.push({ primitives: primitives });
808
+ nodes.push({
809
+ name: layer.name,
810
+ mesh: meshIndex,
811
+ translation: translation,
812
+ });
813
+ }
814
+
815
+ if (nodes.length === 0) {
816
+ return undefined;
817
+ }
818
+
819
+ // Build property table AFTER primitives (adds metadata buffer views).
820
+ const structuralMetadata = buildStructuralMetadata();
821
+
822
+ const binaryChunk = concatChunks(chunks, byteLength);
823
+ const extensionsUsed = ["CESIUM_mesh_vector"];
824
+ if (featureIdLookup.size > 0) {
825
+ extensionsUsed.push("EXT_mesh_features");
826
+ }
827
+ if (defined(structuralMetadata)) {
828
+ extensionsUsed.push("EXT_structural_metadata");
829
+ }
830
+
831
+ const nodeIndices = nodes.map((_, i) => i);
832
+
833
+ const gltfJson = {
834
+ asset: {
835
+ version: "2.0",
836
+ },
837
+ extensionsUsed: extensionsUsed,
838
+ scene: 0,
839
+ scenes: [
840
+ {
841
+ nodes: nodeIndices,
842
+ },
843
+ ],
844
+ nodes: nodes,
845
+ meshes: meshes,
846
+ accessors: accessors,
847
+ bufferViews: bufferViews,
848
+ buffers: [
849
+ {
850
+ byteLength: binaryChunk.byteLength,
851
+ },
852
+ ],
853
+ extensions: /** @type {Object|undefined} */ (undefined),
854
+ };
855
+
856
+ if (defined(structuralMetadata)) {
857
+ gltfJson.extensions = {
858
+ EXT_structural_metadata: structuralMetadata,
859
+ };
860
+ }
861
+
862
+ return buildGlb(gltfJson, binaryChunk);
863
+ }
864
+
865
+ /**
866
+ * Assigns a stable auto-incrementing integer ID to each unique feature.
867
+ *
868
+ * @param {VectorTileFeature} feature
869
+ * @param {Map<VectorTileFeature, number>} featureIdLookup
870
+ * @returns {number}
871
+ * @ignore
872
+ */
873
+ function getOrAssignAutoFeatureId(feature, featureIdLookup) {
874
+ let id = featureIdLookup.get(feature);
875
+ if (!defined(id)) {
876
+ id = featureIdLookup.size;
877
+ featureIdLookup.set(feature, id);
878
+ }
879
+ return id;
880
+ }
881
+
882
+ /**
883
+ * @param {VectorTileFeature} feature
884
+ * @param {string} featureIdProperty
885
+ * @param {Map<string, number>} featureIdLookup
886
+ * @returns {number|undefined}
887
+ * @ignore
888
+ */
889
+ function mapFeatureIdFromProperty(feature, featureIdProperty, featureIdLookup) {
890
+ const properties = feature.properties;
891
+ if (!defined(properties)) {
892
+ return undefined;
893
+ }
894
+ const propertyValue = /** @type {*} */ (properties)[featureIdProperty];
895
+ if (!defined(propertyValue)) {
896
+ return undefined;
897
+ }
898
+ if (
899
+ typeof propertyValue !== "string" &&
900
+ typeof propertyValue !== "number" &&
901
+ typeof propertyValue !== "boolean"
902
+ ) {
903
+ return undefined;
904
+ }
905
+ if (typeof propertyValue === "number" && !Number.isFinite(propertyValue)) {
906
+ return undefined;
907
+ }
908
+ const mapKey = `${typeof propertyValue}:${propertyValue}`;
909
+ let mappedFeatureId = featureIdLookup.get(mapKey);
910
+ if (defined(mappedFeatureId)) {
911
+ return mappedFeatureId;
912
+ }
913
+ mappedFeatureId = featureIdLookup.size;
914
+ featureIdLookup.set(mapKey, mappedFeatureId);
915
+ return mappedFeatureId;
916
+ }
917
+
918
+ /**
919
+ * @param {VectorTilePoint[][]} rawRings
920
+ * @returns {Array.<PolygonRingGroup>}
921
+ * @ignore
922
+ */
923
+ function groupPolygonRings(rawRings) {
924
+ /** @type {Array.<PolygonRingGroup>} */
925
+ const groups = [];
926
+ for (const rawRing of rawRings) {
927
+ const ring = stripClosingVertex(rawRing);
928
+ if (ring.length < 3) {
929
+ continue;
930
+ }
931
+ const area = ringSignedArea(ring);
932
+ if (area <= 0) {
933
+ groups.push({ outerRing: ring, holes: [] });
934
+ } else if (groups.length > 0) {
935
+ groups[groups.length - 1].holes.push(ring);
936
+ }
937
+ }
938
+ return groups;
939
+ }
940
+
941
+ /**
942
+ * @param {VectorTilePoint[]} ring
943
+ * @returns {number}
944
+ * @ignore
945
+ */
946
+ function ringSignedArea(ring) {
947
+ let area = 0;
948
+ for (let i = 0, j = ring.length - 1; i < ring.length; j = i++) {
949
+ area += (ring[j].x + ring[i].x) * (ring[j].y - ring[i].y);
950
+ }
951
+ return area / 2;
952
+ }
953
+
954
+ /**
955
+ * @param {VectorTilePoint[]} ring
956
+ * @returns {VectorTilePoint[]}
957
+ * @ignore
958
+ */
959
+ function stripClosingVertex(ring) {
960
+ if (
961
+ ring.length > 1 &&
962
+ ring[0].x === ring[ring.length - 1].x &&
963
+ ring[0].y === ring[ring.length - 1].y
964
+ ) {
965
+ return ring.slice(0, ring.length - 1);
966
+ }
967
+ return ring;
968
+ }
969
+
970
+ /**
971
+ * Clips a decoded MVT ring to the tile's actual extent. MVT tiles commonly
972
+ * include geometry in a buffer outside [0, extent]; rendering that buffer from
973
+ * adjacent tiles can overlap translucent polygons.
974
+ *
975
+ * @param {VectorTilePoint[]} ring
976
+ * @param {number} extent
977
+ * @returns {VectorTilePoint[]}
978
+ * @ignore
979
+ */
980
+ function clipRingToTileExtent(ring, extent) {
981
+ const unclosedRing = stripClosingVertex(ring);
982
+ let clipped = unclosedRing;
983
+ clipped = clipRingToEdge(clipped, 0, extent, true, false);
984
+ clipped = clipRingToEdge(clipped, 0, extent, true, true);
985
+ clipped = clipRingToEdge(clipped, 0, extent, false, false);
986
+ clipped = clipRingToEdge(clipped, 0, extent, false, true);
987
+ return clipped;
988
+ }
989
+
990
+ /**
991
+ * Marks vertices that lie on a tile boundary after clipping. Polygon outlines
992
+ * skip edges whose endpoints share a boundary flag, preventing tile seams from
993
+ * being rendered as artificial borders.
994
+ *
995
+ * @param {VectorTilePoint} point
996
+ * @param {number} extent
997
+ * @returns {number}
998
+ * @ignore
999
+ */
1000
+ function getTileBoundaryFlags(point, extent) {
1001
+ let flags = 0;
1002
+ if (point.x <= TILE_BOUNDARY_EPSILON) {
1003
+ flags |= TILE_BOUNDARY_WEST;
1004
+ } else if (point.x >= extent - TILE_BOUNDARY_EPSILON) {
1005
+ flags |= TILE_BOUNDARY_EAST;
1006
+ }
1007
+ if (point.y <= TILE_BOUNDARY_EPSILON) {
1008
+ flags |= TILE_BOUNDARY_NORTH;
1009
+ } else if (point.y >= extent - TILE_BOUNDARY_EPSILON) {
1010
+ flags |= TILE_BOUNDARY_SOUTH;
1011
+ }
1012
+ return flags;
1013
+ }
1014
+
1015
+ /**
1016
+ * @param {VectorTilePoint} point
1017
+ * @param {number} minimum
1018
+ * @param {number} maximum
1019
+ * @param {boolean} isX
1020
+ * @param {boolean} isMaximum
1021
+ * @returns {boolean}
1022
+ * @ignore
1023
+ */
1024
+ function isInsideEdge(point, minimum, maximum, isX, isMaximum) {
1025
+ const value = isX ? point.x : point.y;
1026
+ return isMaximum ? value <= maximum : value >= minimum;
1027
+ }
1028
+
1029
+ /**
1030
+ * @param {VectorTilePoint} previous
1031
+ * @param {VectorTilePoint} current
1032
+ * @param {number} minimum
1033
+ * @param {number} maximum
1034
+ * @param {boolean} isX
1035
+ * @param {boolean} isMaximum
1036
+ * @returns {VectorTilePoint}
1037
+ * @ignore
1038
+ */
1039
+ function intersectEdge(previous, current, minimum, maximum, isX, isMaximum) {
1040
+ const previousValue = isX ? previous.x : previous.y;
1041
+ const currentValue = isX ? current.x : current.y;
1042
+ const boundary = isMaximum ? maximum : minimum;
1043
+ const t = (boundary - previousValue) / (currentValue - previousValue);
1044
+ const point = {
1045
+ x: previous.x + t * (current.x - previous.x),
1046
+ y: previous.y + t * (current.y - previous.y),
1047
+ };
1048
+ point[isX ? "x" : "y"] = boundary;
1049
+ return point;
1050
+ }
1051
+
1052
+ /**
1053
+ * @param {VectorTilePoint[]} ring
1054
+ * @param {number} minimum
1055
+ * @param {number} maximum
1056
+ * @param {boolean} isX
1057
+ * @param {boolean} isMaximum
1058
+ * @returns {VectorTilePoint[]}
1059
+ * @ignore
1060
+ */
1061
+ function clipRingToEdge(ring, minimum, maximum, isX, isMaximum) {
1062
+ const clipped = [];
1063
+ for (let i = 0; i < ring.length; i++) {
1064
+ const current = ring[i];
1065
+ const previous = ring[(i + ring.length - 1) % ring.length];
1066
+ const currentInside = isInsideEdge(
1067
+ current,
1068
+ minimum,
1069
+ maximum,
1070
+ isX,
1071
+ isMaximum,
1072
+ );
1073
+ const previousInside = isInsideEdge(
1074
+ previous,
1075
+ minimum,
1076
+ maximum,
1077
+ isX,
1078
+ isMaximum,
1079
+ );
1080
+ if (currentInside) {
1081
+ if (!previousInside) {
1082
+ clipped.push(
1083
+ intersectEdge(previous, current, minimum, maximum, isX, isMaximum),
1084
+ );
1085
+ }
1086
+ clipped.push(current);
1087
+ } else if (previousInside) {
1088
+ clipped.push(
1089
+ intersectEdge(previous, current, minimum, maximum, isX, isMaximum),
1090
+ );
1091
+ }
1092
+ }
1093
+ return clipped;
1094
+ }
1095
+
1096
+ /**
1097
+ * @param {VectorTilePoint} point
1098
+ * @param {number} tileX
1099
+ * @param {number} tileY
1100
+ * @param {number} tileZ
1101
+ * @param {number} extent
1102
+ * @param {number} height
1103
+ * @param {Cartesian3} origin
1104
+ * @param {number[]} out
1105
+ * @ignore
1106
+ */
1107
+ function appendTilePointAsLocalPosition(
1108
+ point,
1109
+ tileX,
1110
+ tileY,
1111
+ tileZ,
1112
+ extent,
1113
+ height,
1114
+ origin,
1115
+ out,
1116
+ ) {
1117
+ const n = 1 << tileZ;
1118
+ const u = (tileX + point.x / extent) / n;
1119
+ const v = (tileY + point.y / extent) / n;
1120
+ const lon = u * 2 * Math.PI - Math.PI;
1121
+ const lat = Math.atan(Math.sinh(Math.PI * (1 - 2 * v)));
1122
+
1123
+ Cartesian3.fromRadians(lon, lat, height, undefined, scratchWorld);
1124
+ Cartesian3.subtract(scratchWorld, origin, scratchLocal);
1125
+ out.push(scratchLocal.x, scratchLocal.y, scratchLocal.z);
1126
+ }
1127
+
1128
+ /**
1129
+ * Packs a glTF JSON object and binary buffer into a GLB (Binary glTF) Uint8Array.
1130
+ * GLB spec: https://registry.khronos.org/glTF/specs/2.0/glTF-2.0.html#binary-gltf-layout
1131
+ *
1132
+ * @param {object} gltfJson
1133
+ * @param {Uint8Array} binaryChunk
1134
+ * @returns {Uint8Array}
1135
+ * @ignore
1136
+ */
1137
+ function buildGlb(gltfJson, binaryChunk) {
1138
+ const GLB_MAGIC = 0x46546c67; // "glTF"
1139
+ const GLB_VERSION = 2;
1140
+ const CHUNK_TYPE_JSON = 0x4e4f534a; // "JSON"
1141
+ const CHUNK_TYPE_BIN = 0x004e4942; // "BIN\0"
1142
+
1143
+ const jsonBytes = new TextEncoder().encode(JSON.stringify(gltfJson));
1144
+ // Pad JSON to 4-byte boundary with spaces (0x20)
1145
+ const jsonPaddedLength = Math.ceil(jsonBytes.length / 4) * 4;
1146
+ const jsonChunk = new Uint8Array(jsonPaddedLength);
1147
+ jsonChunk.fill(0x20);
1148
+ jsonChunk.set(jsonBytes);
1149
+
1150
+ // Pad binary to 4-byte boundary with zeros
1151
+ const binPaddedLength = Math.ceil(binaryChunk.byteLength / 4) * 4;
1152
+ const binChunk = new Uint8Array(binPaddedLength);
1153
+ binChunk.set(binaryChunk);
1154
+
1155
+ const totalLength =
1156
+ 12 + // header
1157
+ 8 +
1158
+ jsonPaddedLength + // JSON chunk header + data
1159
+ 8 +
1160
+ binPaddedLength; // BIN chunk header + data
1161
+
1162
+ const glb = new Uint8Array(totalLength);
1163
+ const view = new DataView(glb.buffer);
1164
+ let offset = 0;
1165
+
1166
+ // Header
1167
+ view.setUint32(offset, GLB_MAGIC, true);
1168
+ offset += 4;
1169
+ view.setUint32(offset, GLB_VERSION, true);
1170
+ offset += 4;
1171
+ view.setUint32(offset, totalLength, true);
1172
+ offset += 4;
1173
+
1174
+ // JSON chunk
1175
+ view.setUint32(offset, jsonPaddedLength, true);
1176
+ offset += 4;
1177
+ view.setUint32(offset, CHUNK_TYPE_JSON, true);
1178
+ offset += 4;
1179
+ glb.set(jsonChunk, offset);
1180
+ offset += jsonPaddedLength;
1181
+
1182
+ // BIN chunk
1183
+ view.setUint32(offset, binPaddedLength, true);
1184
+ offset += 4;
1185
+ view.setUint32(offset, CHUNK_TYPE_BIN, true);
1186
+ offset += 4;
1187
+ glb.set(binChunk, offset);
1188
+
1189
+ return glb;
1190
+ }
1191
+
1192
+ /**
1193
+ * @param {Uint8Array[]} chunks
1194
+ * @param {number} totalByteLength
1195
+ * @returns {Uint8Array}
1196
+ * @ignore
1197
+ */
1198
+ function concatChunks(chunks, totalByteLength) {
1199
+ const out = new Uint8Array(totalByteLength);
1200
+ let offset = 0;
1201
+ for (const chunk of chunks) {
1202
+ out.set(chunk, offset);
1203
+ offset += chunk.byteLength;
1204
+ }
1205
+ return out;
1206
+ }
1207
+
1208
+ export default buildVectorGltfFromMVT;