@cesium/engine 24.0.0 → 26.0.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 (362) hide show
  1. package/Build/Workers/{chunk-6WLHJFD3.js → chunk-3VFEWOBI.js} +59 -32
  2. package/Build/Workers/{chunk-UQU4RXLT.js → chunk-424RNO3D.js} +50 -45
  3. package/Build/Workers/chunk-4MGMYHOO.js +147 -0
  4. package/Build/Workers/{chunk-AMIHNSST.js → chunk-4S7IE3LB.js} +2 -2
  5. package/Build/Workers/{chunk-J6AW5YHS.js → chunk-52JDLOEM.js} +14 -14
  6. package/Build/Workers/{chunk-6RMS4S72.js → chunk-54I6Y66F.js} +6 -6
  7. package/Build/Workers/{chunk-C6P4IG5P.js → chunk-6YEE6JDR.js} +6 -6
  8. package/Build/Workers/{chunk-72VYSVEW.js → chunk-7J2HKPRH.js} +11 -10
  9. package/Build/Workers/{chunk-7O5XJTVE.js → chunk-7WM2PX4V.js} +5 -5
  10. package/Build/Workers/{chunk-5A2SW66E.js → chunk-ACXQXN46.js} +16 -16
  11. package/Build/Workers/{chunk-VLDEUTOP.js → chunk-AYKR4VBR.js} +2 -2
  12. package/Build/Workers/{chunk-YQFTYQMZ.js → chunk-C6J67V5A.js} +3 -2
  13. package/Build/Workers/{chunk-D4EJ2NXG.js → chunk-C6KNZ7T4.js} +17 -17
  14. package/Build/Workers/{chunk-7MDYBRYJ.js → chunk-CFQP6LYM.js} +4 -4
  15. package/Build/Workers/{chunk-YAOZMOFL.js → chunk-CXOYE2WM.js} +5 -5
  16. package/Build/Workers/{chunk-B6SCUUFP.js → chunk-CZEYZU4N.js} +10 -10
  17. package/Build/Workers/{chunk-NPF7SSHZ.js → chunk-DBOEKL43.js} +7 -7
  18. package/Build/Workers/{chunk-44EMEGKW.js → chunk-DDWSZVMY.js} +5 -5
  19. package/Build/Workers/{chunk-7X322WP2.js → chunk-DOBXCNC3.js} +13 -13
  20. package/Build/Workers/{chunk-JCI63T3K.js → chunk-E7VQ76KE.js} +6 -6
  21. package/Build/Workers/{chunk-7TYLCBGK.js → chunk-EBSIOBXY.js} +12 -10
  22. package/Build/Workers/{chunk-GQUNK2XC.js → chunk-EF2QYXGA.js} +14 -14
  23. package/Build/Workers/{chunk-BJD6QGXZ.js → chunk-EPYXRCDB.js} +12 -12
  24. package/Build/Workers/{chunk-63SIWPLS.js → chunk-F6QDY6HU.js} +13 -13
  25. package/Build/Workers/{chunk-XY6HMDGI.js → chunk-FRQZECAO.js} +5 -5
  26. package/Build/Workers/{chunk-VMVOUQ5J.js → chunk-G7PXZRVF.js} +7 -7
  27. package/Build/Workers/{chunk-N65BAKSH.js → chunk-INUEEEQA.js} +8 -8
  28. package/Build/Workers/{chunk-7QRFIKWQ.js → chunk-IRBKFCEJ.js} +2 -2
  29. package/Build/Workers/{chunk-UIGVOKKI.js → chunk-IYOUHCZB.js} +3 -2
  30. package/Build/Workers/{chunk-5GXYJQ2K.js → chunk-J6BWOHUF.js} +3 -3
  31. package/Build/Workers/{chunk-A47HVBC5.js → chunk-KFSTQKNM.js} +7 -7
  32. package/Build/Workers/{chunk-EV3VGO6Y.js → chunk-KKOSKAZB.js} +17 -17
  33. package/Build/Workers/{chunk-6MPGQEHA.js → chunk-KSSWJIZW.js} +2 -2
  34. package/Build/Workers/{chunk-DHKPFLSJ.js → chunk-M3B5JKSM.js} +3 -2
  35. package/Build/Workers/chunk-MPZHGZU6.js +2342 -0
  36. package/Build/Workers/{chunk-YJZGW74L.js → chunk-MYP774IS.js} +2213 -1349
  37. package/Build/Workers/{chunk-LIB2H534.js → chunk-O3EA5HS7.js} +12 -11
  38. package/Build/Workers/{chunk-ILMFADZA.js → chunk-P3CK7MCY.js} +27 -5
  39. package/Build/Workers/chunk-Q3PY526V.js +3201 -0
  40. package/Build/Workers/chunk-QN67VG36.js +973 -0
  41. package/Build/Workers/{chunk-XJRBB253.js → chunk-QRWGUWI6.js} +11 -11
  42. package/Build/Workers/{chunk-AF3MU2RL.js → chunk-S4MCOY6I.js} +7 -6
  43. package/Build/Workers/{chunk-Y7HNNPNK.js → chunk-SMQZZOW6.js} +10 -10
  44. package/Build/Workers/{chunk-PVV64VFW.js → chunk-TKKIREQ6.js} +3 -2
  45. package/Build/Workers/{chunk-MKM27KGV.js → chunk-U3ZA64U7.js} +2 -2
  46. package/Build/Workers/{chunk-2N4KDHS3.js → chunk-UA25D5MX.js} +12 -11
  47. package/Build/Workers/{chunk-RQNJD3O4.js → chunk-UOOIQ3KX.js} +12 -12
  48. package/Build/Workers/{chunk-GOQBUCXH.js → chunk-V7VQKN6N.js} +709 -431
  49. package/Build/Workers/{chunk-LXMCPFFS.js → chunk-VQYETPWC.js} +4 -4
  50. package/Build/Workers/{chunk-NKT5K3K3.js → chunk-VWV2IJRB.js} +13 -12
  51. package/Build/Workers/chunk-XZMBNNDX.js +1287 -0
  52. package/Build/Workers/{chunk-ISY4EZCA.js → chunk-Y57HREW5.js} +4 -4
  53. package/Build/Workers/{chunk-EDXL4W76.js → chunk-Y5BF6AFU.js} +2 -2
  54. package/Build/Workers/{chunk-Q3C6VQH6.js → chunk-YLY7NKAB.js} +4 -4
  55. package/Build/Workers/{chunk-4TIG36AW.js → chunk-ZK3CF7ZD.js} +12 -12
  56. package/Build/Workers/{chunk-AJLTU6PF.js → chunk-ZP7JMQV4.js} +4 -1
  57. package/Build/Workers/{chunk-HXJMS2ZI.js → chunk-ZZ46LWL6.js} +1 -1
  58. package/Build/Workers/combineGeometry.js +24 -24
  59. package/Build/Workers/createBoxGeometry.js +18 -18
  60. package/Build/Workers/createBoxOutlineGeometry.js +16 -16
  61. package/Build/Workers/createCircleGeometry.js +26 -26
  62. package/Build/Workers/createCircleOutlineGeometry.js +19 -19
  63. package/Build/Workers/createCoplanarPolygonGeometry.js +33 -33
  64. package/Build/Workers/createCoplanarPolygonOutlineGeometry.js +31 -31
  65. package/Build/Workers/createCorridorGeometry.js +29 -29
  66. package/Build/Workers/createCorridorOutlineGeometry.js +28 -28
  67. package/Build/Workers/createCylinderGeometry.js +20 -20
  68. package/Build/Workers/createCylinderOutlineGeometry.js +18 -18
  69. package/Build/Workers/createEllipseGeometry.js +26 -26
  70. package/Build/Workers/createEllipseOutlineGeometry.js +19 -19
  71. package/Build/Workers/createEllipsoidGeometry.js +19 -19
  72. package/Build/Workers/createEllipsoidOutlineGeometry.js +18 -18
  73. package/Build/Workers/createFrustumGeometry.js +18 -18
  74. package/Build/Workers/createFrustumOutlineGeometry.js +18 -18
  75. package/Build/Workers/createGeometry.js +24 -24
  76. package/Build/Workers/createGroundPolylineGeometry.js +175 -118
  77. package/Build/Workers/createPlaneGeometry.js +16 -16
  78. package/Build/Workers/createPlaneOutlineGeometry.js +15 -15
  79. package/Build/Workers/createPolygonGeometry.js +32 -32
  80. package/Build/Workers/createPolygonOutlineGeometry.js +30 -30
  81. package/Build/Workers/createPolylineGeometry.js +25 -25
  82. package/Build/Workers/createPolylineVolumeGeometry.js +31 -31
  83. package/Build/Workers/createPolylineVolumeOutlineGeometry.js +27 -27
  84. package/Build/Workers/createRectangleGeometry.js +27 -27
  85. package/Build/Workers/createRectangleOutlineGeometry.js +20 -20
  86. package/Build/Workers/createSimplePolylineGeometry.js +23 -23
  87. package/Build/Workers/createSphereGeometry.js +19 -19
  88. package/Build/Workers/createSphereOutlineGeometry.js +18 -18
  89. package/Build/Workers/createTaskProcessorWorker.js +3 -3
  90. package/Build/Workers/createVectorTileClampedPolylines.js +14 -14
  91. package/Build/Workers/createVectorTileGeometries.js +24 -24
  92. package/Build/Workers/createVectorTilePoints.js +13 -13
  93. package/Build/Workers/createVectorTilePolygons.js +22 -22
  94. package/Build/Workers/createVectorTilePolylines.js +14 -14
  95. package/Build/Workers/createVerticesFromCesium3DTilesTerrain.js +25 -25
  96. package/Build/Workers/createVerticesFromGoogleEarthEnterpriseBuffer.js +22 -22
  97. package/Build/Workers/createVerticesFromHeightmap.js +24 -23
  98. package/Build/Workers/createVerticesFromQuantizedTerrainMesh.js +20 -20
  99. package/Build/Workers/createWallGeometry.js +24 -24
  100. package/Build/Workers/createWallOutlineGeometry.js +23 -23
  101. package/Build/Workers/decodeDraco.js +10 -10
  102. package/Build/Workers/decodeGoogleEarthEnterprisePacket.js +5 -5
  103. package/Build/Workers/decodeI3S.js +10 -10
  104. package/Build/Workers/gaussianSplatSorter.js +4 -4
  105. package/Build/Workers/gaussianSplatTextureGenerator.js +4 -4
  106. package/Build/Workers/incrementallyBuildTerrainPicker.js +10 -10
  107. package/Build/Workers/transcodeKTX2.js +12 -9
  108. package/Build/Workers/transferTypedArrayTest.js +1 -1
  109. package/Build/Workers/upsampleQuantizedTerrainMesh.js +22 -22
  110. package/Build/Workers/upsampleVerticesFromCesium3DTilesTerrain.js +25 -25
  111. package/Source/Core/ArcType.js +6 -1
  112. package/Source/Core/ArticulationStageType.js +5 -1
  113. package/Source/Core/AssociativeArray.js +100 -94
  114. package/Source/Core/BoundingSphere.js +1296 -1300
  115. package/Source/Core/Cartesian2.js +1 -1
  116. package/Source/Core/Cartesian3.js +2 -3
  117. package/Source/Core/Cartesian4.js +1 -1
  118. package/Source/Core/Cartographic.js +257 -249
  119. package/Source/Core/ClockRange.js +6 -1
  120. package/Source/Core/ClockStep.js +6 -1
  121. package/Source/Core/Color.js +844 -835
  122. package/Source/Core/ComponentDatatype.js +39 -1
  123. package/Source/Core/CornerType.js +6 -1
  124. package/Source/Core/Credit.js +121 -124
  125. package/Source/Core/Ellipsoid.js +637 -660
  126. package/Source/Core/ExtrapolationType.js +6 -1
  127. package/Source/Core/GeocodeType.js +6 -1
  128. package/Source/Core/GeographicProjection.js +74 -74
  129. package/Source/Core/GeographicTilingScheme.js +179 -198
  130. package/Source/Core/GeometryOffsetAttribute.js +7 -1
  131. package/Source/Core/GeometryType.js +7 -1
  132. package/Source/Core/HeightmapEncoding.js +6 -1
  133. package/Source/Core/Iau2006XysData.js +24 -13
  134. package/Source/Core/IndexDatatype.js +3 -1
  135. package/Source/Core/InterpolationType.js +5 -1
  136. package/Source/Core/Intersect.js +6 -1
  137. package/Source/Core/Ion.js +1 -1
  138. package/Source/Core/IonGeocodeProviderType.js +5 -1
  139. package/Source/Core/JulianDate.js +850 -848
  140. package/Source/Core/KeyboardEventModifier.js +6 -1
  141. package/Source/Core/MapProjection.js +40 -44
  142. package/Source/Core/Matrix2.js +906 -893
  143. package/Source/Core/Matrix3.js +1643 -1575
  144. package/Source/Core/Matrix4.js +2903 -2872
  145. package/Source/Core/PixelFormat.js +3 -1
  146. package/Source/Core/PrimitiveType.js +11 -1
  147. package/Source/Core/Ray.js +62 -60
  148. package/Source/Core/Rectangle.js +913 -904
  149. package/Source/Core/ReferenceFrame.js +6 -1
  150. package/Source/Core/RequestScheduler.js +8 -3
  151. package/Source/Core/RequestState.js +6 -1
  152. package/Source/Core/RequestType.js +6 -1
  153. package/Source/Core/Resource.js +1 -1
  154. package/Source/Core/ScreenSpaceEventHandler.js +51 -41
  155. package/Source/Core/ScreenSpaceEventType.js +6 -1
  156. package/Source/Core/TerrainQuantization.js +6 -1
  157. package/Source/Core/TilingScheme.js +100 -98
  158. package/Source/Core/TimeConstants.js +6 -1
  159. package/Source/Core/TimeStandard.js +6 -1
  160. package/Source/Core/TrackingReferenceFrame.js +6 -1
  161. package/Source/Core/Visibility.js +6 -1
  162. package/Source/Core/VulkanConstants.js +6 -1
  163. package/Source/Core/WebGLConstants.js +6 -1
  164. package/Source/Core/WebMercatorProjection.js +108 -109
  165. package/Source/Core/WebMercatorTilingScheme.js +246 -242
  166. package/Source/Core/WindingOrder.js +3 -1
  167. package/Source/Core/createColorRamp.js +37 -0
  168. package/Source/Core/globalTypes.js +25 -0
  169. package/Source/DataSources/StaticGroundGeometryPerMaterialBatch.js +1 -0
  170. package/Source/DataSources/StaticGroundPolylinePerMaterialBatch.js +1 -0
  171. package/Source/DataSources/StripeOrientation.js +6 -1
  172. package/Source/Renderer/BufferUsage.js +20 -9
  173. package/Source/Renderer/Context.js +2 -29
  174. package/Source/Renderer/DrawCommand.js +435 -403
  175. package/Source/Renderer/MipmapHint.js +5 -1
  176. package/Source/Renderer/Pass.js +10 -3
  177. package/Source/Renderer/PickId.js +44 -0
  178. package/Source/Renderer/PixelDatatype.js +3 -1
  179. package/Source/Renderer/RenderbufferFormat.js +5 -1
  180. package/Source/Renderer/ShaderDestination.js +4 -1
  181. package/Source/Renderer/TextureMagnificationFilter.js +3 -1
  182. package/Source/Renderer/TextureMinificationFilter.js +3 -1
  183. package/Source/Renderer/TextureWrap.js +5 -1
  184. package/Source/Renderer/createUniform.js +346 -239
  185. package/Source/Renderer/createUniformArray.js +494 -381
  186. package/Source/Scene/AlphaMode.js +5 -1
  187. package/Source/Scene/ArcGisBaseMapType.js +6 -1
  188. package/Source/Scene/ArcGisMapService.js +1 -1
  189. package/Source/Scene/AttributeType.js +3 -1
  190. package/Source/Scene/Axis.js +3 -1
  191. package/Source/Scene/BingMapsStyle.js +6 -1
  192. package/Source/Scene/BlendEquation.js +6 -1
  193. package/Source/Scene/BlendFunction.js +6 -1
  194. package/Source/Scene/BlendOption.js +6 -1
  195. package/Source/Scene/BlendingState.js +6 -1
  196. package/Source/Scene/BufferLoader.js +0 -2
  197. package/Source/Scene/BufferPoint.js +1 -0
  198. package/Source/Scene/BufferPointCollection.js +17 -1
  199. package/Source/Scene/BufferPolygon.js +3 -2
  200. package/Source/Scene/BufferPolygonCollection.js +13 -1
  201. package/Source/Scene/BufferPolyline.js +1 -0
  202. package/Source/Scene/BufferPolylineCollection.js +5 -1
  203. package/Source/Scene/BufferPrimitiveCollection.js +210 -43
  204. package/Source/Scene/CameraEventAggregator.js +30 -18
  205. package/Source/Scene/CameraEventType.js +6 -1
  206. package/Source/Scene/Cesium3DTile.js +54 -1
  207. package/Source/Scene/Cesium3DTileColorBlendMode.js +6 -1
  208. package/Source/Scene/Cesium3DTileContent.js +195 -254
  209. package/Source/Scene/Cesium3DTileContentFactory.js +10 -2
  210. package/Source/Scene/Cesium3DTileContentState.js +6 -1
  211. package/Source/Scene/Cesium3DTileContentType.js +3 -1
  212. package/Source/Scene/Cesium3DTileFeature.js +289 -306
  213. package/Source/Scene/Cesium3DTileOptimizationHint.js +6 -1
  214. package/Source/Scene/Cesium3DTilePass.js +5 -1
  215. package/Source/Scene/Cesium3DTilePointFeature.js +433 -511
  216. package/Source/Scene/Cesium3DTileRefine.js +6 -1
  217. package/Source/Scene/Cesium3DTileVectorFeature.js +586 -0
  218. package/Source/Scene/Cesium3DTileset.js +46 -6
  219. package/Source/Scene/ClassificationType.js +3 -1
  220. package/Source/Scene/CloudType.js +3 -1
  221. package/Source/Scene/ColorBlendMode.js +4 -1
  222. package/Source/Scene/Composite3DTileContent.js +254 -292
  223. package/Source/Scene/CullFace.js +6 -1
  224. package/Source/Scene/DepthFunction.js +6 -1
  225. package/Source/Scene/DynamicAtmosphereLightingType.js +3 -1
  226. package/Source/Scene/EdgeDisplayMode.js +50 -0
  227. package/Source/Scene/Empty3DTileContent.js +100 -132
  228. package/Source/Scene/EquirectangularPanorama.js +1 -0
  229. package/Source/Scene/ExpressionNodeType.js +6 -1
  230. package/Source/Scene/GaussianSplat3DTileContent.js +436 -478
  231. package/Source/Scene/GeoJsonPrimitive.js +874 -0
  232. package/Source/Scene/Geometry3DTileContent.js +151 -185
  233. package/Source/Scene/GltfBufferViewLoader.js +0 -2
  234. package/Source/Scene/GltfDracoLoader.js +0 -2
  235. package/Source/Scene/GltfImageLoader.js +0 -3
  236. package/Source/Scene/GltfIndexBufferLoader.js +0 -4
  237. package/Source/Scene/GltfJsonLoader.js +0 -2
  238. package/Source/Scene/GltfLoader.js +109 -5
  239. package/Source/Scene/GltfLoaderUtil.js +14 -0
  240. package/Source/Scene/GltfSpzLoader.js +0 -2
  241. package/Source/Scene/GltfStructuralMetadataLoader.js +0 -2
  242. package/Source/Scene/GltfTextureLoader.js +0 -2
  243. package/Source/Scene/GltfVertexBufferLoader.js +0 -4
  244. package/Source/Scene/HeightReference.js +5 -1
  245. package/Source/Scene/HorizontalOrigin.js +6 -1
  246. package/Source/Scene/ImageryProvider.js +1 -1
  247. package/Source/Scene/ImageryState.js +6 -1
  248. package/Source/Scene/Implicit3DTileContent.js +179 -214
  249. package/Source/Scene/ImplicitSubdivisionScheme.js +3 -1
  250. package/Source/Scene/InstanceAttributeSemantic.js +3 -1
  251. package/Source/Scene/IonWorldImageryStyle.js +6 -1
  252. package/Source/Scene/JobType.js +6 -1
  253. package/Source/Scene/LabelStyle.js +6 -1
  254. package/Source/Scene/MVTDataProvider.js +147 -0
  255. package/Source/Scene/MapMode2D.js +6 -1
  256. package/Source/Scene/MetadataComponentType.js +3 -1
  257. package/Source/Scene/MetadataSchemaLoader.js +0 -2
  258. package/Source/Scene/MetadataSemantic.js +6 -2
  259. package/Source/Scene/MetadataType.js +3 -1
  260. package/Source/Scene/Model/B3dmLoader.js +0 -3
  261. package/Source/Scene/Model/CustomShaderMode.js +3 -1
  262. package/Source/Scene/Model/CustomShaderTranslucencyMode.js +5 -1
  263. package/Source/Scene/Model/EdgeVisibilityPipelineStage.js +78 -337
  264. package/Source/Scene/Model/Extensions/Gpm/PpeSource.js +5 -1
  265. package/Source/Scene/Model/Extensions/Gpm/StorageType.js +5 -1
  266. package/Source/Scene/Model/GeoJsonLoader.js +0 -2
  267. package/Source/Scene/Model/I3dmLoader.js +0 -3
  268. package/Source/Scene/Model/InstancingPipelineStage.js +1 -1
  269. package/Source/Scene/Model/LightingModel.js +5 -1
  270. package/Source/Scene/Model/MaterialPipelineStage.js +184 -3
  271. package/Source/Scene/Model/Model.js +34 -0
  272. package/Source/Scene/Model/Model3DTileContent.js +424 -458
  273. package/Source/Scene/Model/ModelDrawCommand.js +31 -3
  274. package/Source/Scene/Model/ModelReader.js +474 -3
  275. package/Source/Scene/Model/ModelRuntimePrimitive.js +2 -1
  276. package/Source/Scene/Model/ModelType.js +3 -1
  277. package/Source/Scene/Model/ModelUtility.js +4 -0
  278. package/Source/Scene/Model/PntsLoader.js +4 -3
  279. package/Source/Scene/Model/StyleCommandsNeeded.js +3 -1
  280. package/Source/Scene/Model/UniformType.js +5 -1
  281. package/Source/Scene/Model/VaryingType.js +5 -1
  282. package/Source/Scene/Model/createVectorTileBuffersFromModelComponents.js +500 -139
  283. package/Source/Scene/Model/pickModel.js +94 -299
  284. package/Source/Scene/ModelAnimationLoop.js +6 -1
  285. package/Source/Scene/ModelAnimationState.js +6 -1
  286. package/Source/Scene/ModelComponents.js +47 -2
  287. package/Source/Scene/Multiple3DTileContent.js +291 -334
  288. package/Source/Scene/PrimitiveState.js +7 -1
  289. package/Source/Scene/QuadtreeOccluders.js +20 -15
  290. package/Source/Scene/QuadtreeTile.js +547 -541
  291. package/Source/Scene/QuadtreeTileLoadState.js +6 -1
  292. package/Source/Scene/QuadtreeTileProvider.js +159 -175
  293. package/Source/Scene/ResourceLoader.js +0 -1
  294. package/Source/Scene/ResourceLoaderState.js +7 -1
  295. package/Source/Scene/Scene.js +26 -0
  296. package/Source/Scene/SceneMode.js +4 -1
  297. package/Source/Scene/ShadowMode.js +3 -1
  298. package/Source/Scene/SkyBox.js +1 -1
  299. package/Source/Scene/SplitDirection.js +6 -1
  300. package/Source/Scene/StencilFunction.js +6 -1
  301. package/Source/Scene/StencilOperation.js +6 -1
  302. package/Source/Scene/TerrainState.js +7 -1
  303. package/Source/Scene/TileState.js +7 -1
  304. package/Source/Scene/Tileset3DTileContent.js +113 -146
  305. package/Source/Scene/Tonemapper.js +5 -1
  306. package/Source/Scene/UrlTemplate3DTilesDataProvider.js +499 -0
  307. package/Source/Scene/Vector3DTileContent.js +205 -234
  308. package/Source/Scene/VectorGltf3DTileContent.js +131 -61
  309. package/Source/Scene/VertexAttributeSemantic.js +3 -1
  310. package/Source/Scene/VerticalOrigin.js +6 -1
  311. package/Source/Scene/VoxelBoxShape.js +12 -6
  312. package/Source/Scene/VoxelContent.js +2 -0
  313. package/Source/Scene/VoxelCylinderShape.js +39 -38
  314. package/Source/Scene/VoxelEllipsoidShape.js +46 -96
  315. package/Source/Scene/VoxelMetadataOrder.js +6 -1
  316. package/Source/Scene/VoxelPrimitive.js +159 -175
  317. package/Source/Scene/VoxelProvider.js +64 -90
  318. package/Source/Scene/VoxelShapeType.js +3 -1
  319. package/Source/Scene/buildVectorGltfFromMVT.js +1059 -0
  320. package/Source/Scene/buildVoxelCustomShader.js +199 -0
  321. package/Source/Scene/decodeMVT.js +634 -0
  322. package/Source/Scene/renderBufferPointCollection.js +124 -127
  323. package/Source/Scene/renderBufferPolygonCollection.js +122 -122
  324. package/Source/Scene/renderBufferPolylineCollection.js +386 -238
  325. package/Source/Shaders/BufferPointMaterialFS.glsl +1 -0
  326. package/Source/Shaders/BufferPointMaterialFS.js +1 -0
  327. package/Source/Shaders/BufferPointMaterialVS.glsl +19 -9
  328. package/Source/Shaders/BufferPointMaterialVS.js +20 -10
  329. package/Source/Shaders/BufferPolygonMaterialVS.glsl +13 -4
  330. package/Source/Shaders/BufferPolygonMaterialVS.js +14 -5
  331. package/Source/Shaders/BufferPolylineMaterialVS.glsl +16 -2
  332. package/Source/Shaders/BufferPolylineMaterialVS.js +17 -3
  333. package/Source/Shaders/Builtin/Constants/passCesium3DTileEdgesDirect.glsl +9 -0
  334. package/Source/Shaders/Builtin/Constants/passCesium3DTileEdgesDirect.js +11 -0
  335. package/Source/Shaders/Builtin/Constants/passOverlay.glsl +1 -1
  336. package/Source/Shaders/Builtin/Constants/passOverlay.js +1 -1
  337. package/Source/Shaders/Builtin/CzmBuiltins.js +4 -0
  338. package/Source/Shaders/Builtin/Functions/computeTextureTransform.glsl +24 -0
  339. package/Source/Shaders/Builtin/Functions/computeTextureTransform.js +25 -0
  340. package/Source/Shaders/Model/ConstantLodStageFS.glsl +60 -0
  341. package/Source/Shaders/Model/ConstantLodStageFS.js +62 -0
  342. package/Source/Shaders/Model/ConstantLodStageVS.glsl +12 -0
  343. package/Source/Shaders/Model/ConstantLodStageVS.js +13 -0
  344. package/Source/Shaders/Model/EdgeVisibilityStageVS.glsl +0 -1
  345. package/Source/Shaders/Model/EdgeVisibilityStageVS.js +0 -1
  346. package/Source/Shaders/Model/MaterialStageFS.glsl +46 -20
  347. package/Source/Shaders/Model/MaterialStageFS.js +46 -20
  348. package/Source/Shaders/Voxels/convertLocalToBoxUv.glsl +0 -1
  349. package/Source/Shaders/Voxels/convertLocalToBoxUv.js +0 -1
  350. package/Source/Shaders/Voxels/convertLocalToCylinderUv.glsl +7 -9
  351. package/Source/Shaders/Voxels/convertLocalToCylinderUv.js +7 -9
  352. package/Source/Shaders/Voxels/convertLocalToEllipsoidUv.glsl +7 -17
  353. package/Source/Shaders/Voxels/convertLocalToEllipsoidUv.js +7 -17
  354. package/Source/Widget/CesiumWidget.js +11 -4
  355. package/index.d.ts +595 -343
  356. package/index.js +392 -378
  357. package/package.json +3 -3
  358. package/Build/Workers/chunk-DVB56LG7.js +0 -114
  359. package/Build/Workers/chunk-HKUES6UG.js +0 -2357
  360. package/Build/Workers/chunk-HRHRYFHS.js +0 -940
  361. package/Build/Workers/chunk-KLPGTXS3.js +0 -642
  362. package/Build/Workers/chunk-ZBZRTRJB.js +0 -1829
@@ -0,0 +1,1059 @@
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
+
20
+ const scratchWorld = new Cartesian3();
21
+ const scratchLocal = new Cartesian3();
22
+ const tilingScheme = new WebMercatorTilingScheme();
23
+
24
+ /**
25
+ * @typedef {object} VectorTilePoint
26
+ * @property {number} x Tile-local x (0–extent)
27
+ * @property {number} y Tile-local y (0–extent)
28
+ * @ignore
29
+ */
30
+
31
+ /**
32
+ * @typedef {object} VectorTileFeature
33
+ * @property {"Point"|"LineString"|"Polygon"|"Unknown"} type
34
+ * @property {Array<VectorTilePoint>|Array<Array<VectorTilePoint>>} geometry
35
+ * @property {object} [properties]
36
+ * @ignore
37
+ */
38
+
39
+ /**
40
+ * @typedef {object} VectorTileLayer
41
+ * @property {string} [name]
42
+ * @property {number} extent
43
+ * @property {VectorTileFeature[]} features
44
+ * @ignore
45
+ */
46
+
47
+ /**
48
+ * @typedef {object} DecodedVectorTile
49
+ * @property {VectorTileLayer[]} layers
50
+ * @ignore
51
+ */
52
+
53
+ /**
54
+ * @typedef {object} PolygonRingGroup
55
+ * @property {Array.<VectorTilePoint>} outerRing
56
+ * @property {Array.<Array.<VectorTilePoint>>} holes
57
+ * @ignore
58
+ */
59
+
60
+ /**
61
+ * @typedef {object} BuildVectorGltfOptions
62
+ * @property {string} [featureIdProperty] MVT property name to use as feature ID.
63
+ * @ignore
64
+ */
65
+
66
+ /**
67
+ * Build a vector glTF payload from decoded tile-local vector geometry.
68
+ * Each MVT layer produces a separate glTF node (named after the layer),
69
+ * enabling layer-specific styling in the future.
70
+ *
71
+ * @param {DecodedVectorTile} decoded
72
+ * @param {{tileX:number, tileY:number, tileZ:number}} tileCoordinates
73
+ * @param {BuildVectorGltfOptions} [options]
74
+ * @returns {Uint8Array|undefined}
75
+ *
76
+ * @ignore
77
+ */
78
+ function buildVectorGltfFromMVT(decoded, tileCoordinates, options) {
79
+ const tileX = tileCoordinates.tileX;
80
+ const tileY = tileCoordinates.tileY;
81
+ const tileZ = tileCoordinates.tileZ;
82
+ const featureIdProperty = options?.featureIdProperty;
83
+
84
+ const tileRect = tilingScheme.tileXYToRectangle(tileX, tileY, tileZ);
85
+ const tileCenter = Rectangle.center(tileRect);
86
+ const origin = Cartesian3.fromRadians(
87
+ tileCenter.longitude,
88
+ tileCenter.latitude,
89
+ 0,
90
+ );
91
+ // Maximum value of a Uint32; used as sentinel for null feature IDs and primitive restart indices.
92
+ const MAX_INT_U32 = 0xffffffff;
93
+ const nullFeatureId = MAX_INT_U32;
94
+ const primitiveRestartIndex = MAX_INT_U32;
95
+ // Maps a property value (or auto-increment key) to a compact integer feature ID.
96
+ const featureIdLookup = new Map();
97
+
98
+ // Maps featureId -> properties object (first-seen wins for ID collisions).
99
+ /** @type {Map<number, Object.<string, *>>} */
100
+ const featureProperties = new Map();
101
+
102
+ /** @type {object[]} */
103
+ const bufferViews = [];
104
+ /** @type {object[]} */
105
+ const accessors = [];
106
+ /** @type {Uint8Array[]} */
107
+ const chunks = [];
108
+ let byteLength = 0;
109
+
110
+ function addPadding() {
111
+ const padding = (4 - (byteLength % 4)) % 4;
112
+ if (padding > 0) {
113
+ chunks.push(new Uint8Array(padding));
114
+ byteLength += padding;
115
+ }
116
+ }
117
+
118
+ /**
119
+ * @param {TypedArray} typedArray
120
+ * @param {number} target
121
+ * @returns {number}
122
+ */
123
+ function addBufferView(typedArray, target) {
124
+ addPadding();
125
+ const byteOffset = byteLength;
126
+ chunks.push(
127
+ new Uint8Array(
128
+ typedArray.buffer,
129
+ typedArray.byteOffset,
130
+ typedArray.byteLength,
131
+ ),
132
+ );
133
+ byteLength += typedArray.byteLength;
134
+ const bufferViewIndex = bufferViews.length;
135
+ bufferViews.push({
136
+ buffer: 0,
137
+ byteOffset: byteOffset,
138
+ byteLength: typedArray.byteLength,
139
+ target: target,
140
+ });
141
+ return bufferViewIndex;
142
+ }
143
+
144
+ /**
145
+ * @param {TypedArray} typedArray
146
+ * @param {object} options
147
+ * @param {string} options.type
148
+ * @param {number} options.componentType
149
+ * @param {number} options.target
150
+ * @param {number[]} [options.min]
151
+ * @param {number[]} [options.max]
152
+ * @returns {number}
153
+ */
154
+ function addAccessor(typedArray, options) {
155
+ const bufferView = addBufferView(typedArray, options.target);
156
+ const componentCount = /** @type {*} */ (MetadataType).getComponentCount(
157
+ options.type,
158
+ );
159
+ const accessor = /** @type {*} */ ({
160
+ bufferView: bufferView,
161
+ byteOffset: 0,
162
+ componentType: options.componentType,
163
+ count: typedArray.length / componentCount,
164
+ type: options.type,
165
+ });
166
+ if (defined(options.min)) {
167
+ accessor.min = options.min;
168
+ }
169
+ if (defined(options.max)) {
170
+ accessor.max = options.max;
171
+ }
172
+ const accessorIndex = accessors.length;
173
+ accessors.push(accessor);
174
+ return accessorIndex;
175
+ }
176
+
177
+ /**
178
+ * @param {Float32Array} positions
179
+ * @returns {{min:number[],max:number[]}}
180
+ */
181
+ function computeMinMax(positions) {
182
+ let minX = Number.POSITIVE_INFINITY;
183
+ let minY = Number.POSITIVE_INFINITY;
184
+ let minZ = Number.POSITIVE_INFINITY;
185
+ let maxX = Number.NEGATIVE_INFINITY;
186
+ let maxY = Number.NEGATIVE_INFINITY;
187
+ let maxZ = Number.NEGATIVE_INFINITY;
188
+
189
+ for (let i = 0; i < positions.length; i += 3) {
190
+ const x = positions[i];
191
+ const y = positions[i + 1];
192
+ const z = positions[i + 2];
193
+ if (x < minX) {
194
+ minX = x;
195
+ }
196
+ if (y < minY) {
197
+ minY = y;
198
+ }
199
+ if (z < minZ) {
200
+ minZ = z;
201
+ }
202
+ if (x > maxX) {
203
+ maxX = x;
204
+ }
205
+ if (y > maxY) {
206
+ maxY = y;
207
+ }
208
+ if (z > maxZ) {
209
+ maxZ = z;
210
+ }
211
+ }
212
+
213
+ return {
214
+ min: [minX, minY, minZ],
215
+ max: [maxX, maxY, maxZ],
216
+ };
217
+ }
218
+
219
+ /**
220
+ * @param {*} attributes
221
+ * @param {*} extensions
222
+ * @param {number[]} featureIdValues
223
+ */
224
+ function addFeatureIdsToPrimitive(attributes, extensions, featureIdValues) {
225
+ if (featureIdValues.length === 0) {
226
+ return;
227
+ }
228
+ const featureIds = new Uint32Array(featureIdValues);
229
+ const featureAccessor = addAccessor(featureIds, {
230
+ type: "SCALAR",
231
+ componentType: ComponentDatatype.UNSIGNED_INT,
232
+ target: WebGLConstants.ARRAY_BUFFER,
233
+ });
234
+ attributes._FEATURE_ID_0 = featureAccessor;
235
+ /** @type {*} */
236
+ const featureIdDef = {
237
+ featureCount: featureIdLookup.size,
238
+ nullFeatureId: nullFeatureId,
239
+ attribute: 0,
240
+ };
241
+ if (featureProperties.size > 0) {
242
+ featureIdDef.propertyTable = 0;
243
+ }
244
+ extensions.EXT_mesh_features = {
245
+ featureIds: [featureIdDef],
246
+ };
247
+ }
248
+
249
+ /**
250
+ * Adds a raw buffer view for metadata (no accessor target).
251
+ * @param {Uint8Array} bytes
252
+ * @param {number} [alignment=4] Required byte alignment (e.g., 8 for Float64).
253
+ * @returns {number} bufferView index
254
+ */
255
+ function addMetadataBufferView(bytes, alignment) {
256
+ alignment = alignment ?? 4;
257
+ // Align to the required boundary.
258
+ const pad = (alignment - (byteLength % alignment)) % alignment;
259
+ if (pad > 0) {
260
+ chunks.push(new Uint8Array(pad));
261
+ byteLength += pad;
262
+ }
263
+ const byteOffset = byteLength;
264
+ chunks.push(bytes);
265
+ byteLength += bytes.byteLength;
266
+ const bufferViewIndex = bufferViews.length;
267
+ bufferViews.push({
268
+ buffer: 0,
269
+ byteOffset: byteOffset,
270
+ byteLength: bytes.byteLength,
271
+ });
272
+ return bufferViewIndex;
273
+ }
274
+
275
+ /**
276
+ * Builds the EXT_structural_metadata extension object with schema and
277
+ * property table from the collected feature properties.
278
+ * @returns {object|undefined}
279
+ */
280
+ function buildStructuralMetadata() {
281
+ if (featureProperties.size === 0) {
282
+ return undefined;
283
+ }
284
+
285
+ // 1. Determine union of all property names and infer types.
286
+ // propertyName -> "STRING"|"SCALAR"|"BOOLEAN"
287
+ /** @type {Map<string, string>} */
288
+ const propertyTypes = new Map();
289
+
290
+ for (const props of featureProperties.values()) {
291
+ for (const [key, value] of Object.entries(props)) {
292
+ if (!defined(value)) {
293
+ continue;
294
+ }
295
+ const jsType = typeof value;
296
+ let metaType;
297
+ if (jsType === "string") {
298
+ metaType = "STRING";
299
+ } else if (jsType === "number") {
300
+ metaType = "SCALAR";
301
+ } else if (jsType === "boolean") {
302
+ metaType = "BOOLEAN";
303
+ } else {
304
+ // Objects/arrays: coerce to string
305
+ metaType = "STRING";
306
+ }
307
+
308
+ const existing = propertyTypes.get(key);
309
+ if (!defined(existing)) {
310
+ propertyTypes.set(key, metaType);
311
+ } else if (existing !== metaType) {
312
+ // Mixed types: coerce to STRING
313
+ propertyTypes.set(key, "STRING");
314
+ }
315
+ }
316
+ }
317
+
318
+ if (propertyTypes.size === 0) {
319
+ return undefined;
320
+ }
321
+
322
+ // 2. Build schema class properties.
323
+ /** @type {Object.<string, *>} */
324
+ const classProperties = {};
325
+ for (const [name, type] of propertyTypes) {
326
+ if (type === "SCALAR") {
327
+ classProperties[name] = {
328
+ type: "SCALAR",
329
+ componentType: "FLOAT64",
330
+ };
331
+ } else if (type === "BOOLEAN") {
332
+ classProperties[name] = {
333
+ type: "BOOLEAN",
334
+ };
335
+ } else {
336
+ classProperties[name] = {
337
+ type: "STRING",
338
+ };
339
+ }
340
+ }
341
+
342
+ // 3. Encode property values into binary buffers.
343
+ /** @type {Object.<string, *>} */
344
+ const tableProperties = {};
345
+ const count = featureIdLookup.size;
346
+
347
+ for (const [name, type] of propertyTypes) {
348
+ if (type === "SCALAR") {
349
+ const values = new Float64Array(count);
350
+ for (let i = 0; i < count; i++) {
351
+ const props = featureProperties.get(i);
352
+ const raw = props?.[name];
353
+ values[i] =
354
+ typeof raw === "number" && Number.isFinite(raw) ? raw : NaN;
355
+ }
356
+ const bvIndex = addMetadataBufferView(
357
+ new Uint8Array(values.buffer, values.byteOffset, values.byteLength),
358
+ 8,
359
+ );
360
+ tableProperties[name] = { values: bvIndex };
361
+ } else if (type === "BOOLEAN") {
362
+ const byteCount = Math.ceil(count / 8);
363
+ const values = new Uint8Array(byteCount);
364
+ for (let i = 0; i < count; i++) {
365
+ const props = featureProperties.get(i);
366
+ const raw = props?.[name];
367
+ if (raw) {
368
+ values[i >> 3] |= 1 << (i & 7);
369
+ }
370
+ }
371
+ const bvIndex = addMetadataBufferView(values);
372
+ tableProperties[name] = { values: bvIndex };
373
+ } else {
374
+ // STRING encoding: values (UTF-8 bytes) + stringOffsets (Uint32)
375
+ const encoder = new TextEncoder();
376
+ /** @type {Uint8Array[]} */
377
+ const stringParts = [];
378
+ const offsets = new Uint32Array(count + 1);
379
+ let totalBytes = 0;
380
+
381
+ for (let i = 0; i < count; i++) {
382
+ offsets[i] = totalBytes;
383
+ const props = featureProperties.get(i);
384
+ const raw = props?.[name];
385
+ let str;
386
+ if (raw === null || raw === undefined) {
387
+ str = "";
388
+ } else if (typeof raw === "string") {
389
+ str = raw;
390
+ } else {
391
+ str = String(raw);
392
+ }
393
+ const encoded = encoder.encode(str);
394
+ stringParts.push(encoded);
395
+ totalBytes += encoded.byteLength;
396
+ }
397
+ offsets[count] = totalBytes;
398
+
399
+ // Concatenate string bytes
400
+ const valuesBuffer = new Uint8Array(totalBytes);
401
+ let writeOffset = 0;
402
+ for (const part of stringParts) {
403
+ valuesBuffer.set(part, writeOffset);
404
+ writeOffset += part.byteLength;
405
+ }
406
+
407
+ const valuesBv = addMetadataBufferView(valuesBuffer);
408
+ const offsetsBv = addMetadataBufferView(
409
+ new Uint8Array(
410
+ offsets.buffer,
411
+ offsets.byteOffset,
412
+ offsets.byteLength,
413
+ ),
414
+ );
415
+ tableProperties[name] = {
416
+ values: valuesBv,
417
+ stringOffsets: offsetsBv,
418
+ stringOffsetType: "UINT32",
419
+ };
420
+ }
421
+ }
422
+
423
+ return {
424
+ schema: {
425
+ classes: {
426
+ mvt_feature: {
427
+ properties: classProperties,
428
+ },
429
+ },
430
+ },
431
+ propertyTables: [
432
+ {
433
+ class: "mvt_feature",
434
+ count: count,
435
+ properties: tableProperties,
436
+ },
437
+ ],
438
+ };
439
+ }
440
+
441
+ /** @type {object[]} */
442
+ const meshes = [];
443
+ /** @type {object[]} */
444
+ const nodes = [];
445
+ const translation = [origin.x, origin.y, origin.z];
446
+
447
+ for (const layer of decoded.layers) {
448
+ const extent = layer.extent;
449
+
450
+ /** @type {number[]} */
451
+ const pointPositions = [];
452
+ /** @type {number[]} */
453
+ const pointFeatureIds = [];
454
+
455
+ /** @type {number[]} */
456
+ const linePositions = [];
457
+ /** @type {number[]} */
458
+ const lineFeatureIds = [];
459
+ /** @type {number[]} */
460
+ const lineIndices = [];
461
+ let lineCount = 0;
462
+
463
+ /** @type {number[]} */
464
+ const polygonPositions = [];
465
+ /** @type {number[]} */
466
+ const polygonFeatureIds = [];
467
+ /** @type {number[]} */
468
+ const polygonIndices = [];
469
+ /** @type {number[]} */
470
+ const polygonAttributeOffsets = [];
471
+ /** @type {number[]} */
472
+ const polygonIndicesOffsets = [];
473
+ /** @type {number[]} */
474
+ const polygonHoleCounts = [];
475
+ /** @type {number[]} */
476
+ const polygonHoleOffsets = [];
477
+ let polygonCount = 0;
478
+
479
+ for (const feature of layer.features) {
480
+ const currentFeatureId = defined(featureIdProperty)
481
+ ? (mapFeatureIdFromProperty(
482
+ feature,
483
+ featureIdProperty,
484
+ featureIdLookup,
485
+ ) ?? nullFeatureId)
486
+ : getOrAssignAutoFeatureId(feature, featureIdLookup);
487
+
488
+ // Collect properties for the property table (first-seen wins).
489
+ if (
490
+ currentFeatureId !== nullFeatureId &&
491
+ !featureProperties.has(currentFeatureId)
492
+ ) {
493
+ /** @type {Object.<string, *>} */
494
+ const props = Object.assign({}, feature.properties);
495
+ props["_layer"] = layer.name ?? "";
496
+ featureProperties.set(currentFeatureId, props);
497
+ }
498
+
499
+ if (feature.type === "Point") {
500
+ const points = /** @type {VectorTilePoint[]} */ (feature.geometry);
501
+ for (const point of points) {
502
+ appendTilePointAsLocalPosition(
503
+ point,
504
+ tileX,
505
+ tileY,
506
+ tileZ,
507
+ extent,
508
+ DEFAULT_HEIGHT,
509
+ origin,
510
+ pointPositions,
511
+ );
512
+ pointFeatureIds.push(currentFeatureId);
513
+ }
514
+ continue;
515
+ }
516
+
517
+ if (feature.type === "LineString") {
518
+ const lines = /** @type {VectorTilePoint[][]} */ (feature.geometry);
519
+ for (const line of lines) {
520
+ const lineStart = linePositions.length / 3;
521
+ for (const point of line) {
522
+ appendTilePointAsLocalPosition(
523
+ point,
524
+ tileX,
525
+ tileY,
526
+ tileZ,
527
+ extent,
528
+ DEFAULT_HEIGHT,
529
+ origin,
530
+ linePositions,
531
+ );
532
+ lineFeatureIds.push(currentFeatureId);
533
+ }
534
+
535
+ for (let i = 0; i < line.length; i++) {
536
+ lineIndices.push(lineStart + i);
537
+ }
538
+ lineIndices.push(primitiveRestartIndex);
539
+ lineCount++;
540
+ }
541
+ continue;
542
+ }
543
+
544
+ if (feature.type === "Polygon") {
545
+ const rawRings = /** @type {VectorTilePoint[][]} */ (feature.geometry);
546
+ const groups = groupPolygonRings(rawRings);
547
+
548
+ for (const group of groups) {
549
+ const rings = [group.outerRing, ...group.holes];
550
+ /** @type {Cartesian2[]} */
551
+ const positions2D = [];
552
+ /** @type {number[]} */
553
+ const polygonPositionComponents = [];
554
+ /** @type {number[]} */
555
+ const holeOffsets = [];
556
+ let vertexOffset = 0;
557
+
558
+ for (let ringIndex = 0; ringIndex < rings.length; ringIndex++) {
559
+ const ring = rings[ringIndex];
560
+ if (ringIndex > 0) {
561
+ holeOffsets.push(vertexOffset);
562
+ }
563
+
564
+ for (const point of ring) {
565
+ positions2D.push(new Cartesian2(point.x, point.y));
566
+ appendTilePointAsLocalPosition(
567
+ point,
568
+ tileX,
569
+ tileY,
570
+ tileZ,
571
+ extent,
572
+ DEFAULT_HEIGHT,
573
+ origin,
574
+ polygonPositionComponents,
575
+ );
576
+ vertexOffset++;
577
+ }
578
+ }
579
+
580
+ if (positions2D.length < 3) {
581
+ continue;
582
+ }
583
+
584
+ const triangles = PolygonPipeline.triangulate(
585
+ positions2D,
586
+ holeOffsets.length > 0 ? holeOffsets : undefined,
587
+ );
588
+
589
+ if (!defined(triangles) || triangles.length === 0) {
590
+ oneTimeWarning(
591
+ "buildVectorGltfFromMVT-triangulation-failed",
592
+ "Polygon triangulation failed; skipping polygon.",
593
+ );
594
+ continue;
595
+ }
596
+
597
+ const globalVertexStart = polygonPositions.length / 3;
598
+ const globalIndexStart = polygonIndices.length;
599
+ polygonAttributeOffsets.push(globalVertexStart);
600
+ polygonIndicesOffsets.push(globalIndexStart);
601
+ polygonHoleCounts.push(holeOffsets.length);
602
+ for (let i = 0; i < holeOffsets.length; i++) {
603
+ polygonHoleOffsets.push(globalVertexStart + holeOffsets[i]);
604
+ }
605
+
606
+ for (let i = 0; i < polygonPositionComponents.length; i++) {
607
+ polygonPositions.push(polygonPositionComponents[i]);
608
+ }
609
+ for (let i = 0; i < polygonPositionComponents.length / 3; i++) {
610
+ polygonFeatureIds.push(currentFeatureId);
611
+ }
612
+ for (let i = 0; i < triangles.length; i++) {
613
+ polygonIndices.push(triangles[i] + globalVertexStart);
614
+ }
615
+ polygonCount++;
616
+ }
617
+ }
618
+ }
619
+
620
+ // Skip layers with no geometry.
621
+ if (
622
+ pointPositions.length === 0 &&
623
+ linePositions.length === 0 &&
624
+ polygonPositions.length === 0
625
+ ) {
626
+ continue;
627
+ }
628
+
629
+ if (
630
+ lineIndices.length > 0 &&
631
+ lineIndices[lineIndices.length - 1] === primitiveRestartIndex
632
+ ) {
633
+ lineIndices.pop();
634
+ }
635
+
636
+ /** @type {object[]} */
637
+ const primitives = [];
638
+
639
+ if (pointPositions.length > 0) {
640
+ const positions = new Float32Array(pointPositions);
641
+ const minMax = computeMinMax(positions);
642
+
643
+ const positionAccessor = addAccessor(positions, {
644
+ type: "VEC3",
645
+ componentType: ComponentDatatype.FLOAT,
646
+ target: WebGLConstants.ARRAY_BUFFER,
647
+ min: minMax.min,
648
+ max: minMax.max,
649
+ });
650
+ const attributes = /** @type {*} */ ({
651
+ POSITION: positionAccessor,
652
+ });
653
+ const extensions = /** @type {*} */ ({
654
+ CESIUM_mesh_vector: {
655
+ vector: true,
656
+ count: positions.length / 3,
657
+ },
658
+ });
659
+ addFeatureIdsToPrimitive(attributes, extensions, pointFeatureIds);
660
+
661
+ primitives.push({
662
+ mode: PrimitiveType.POINTS,
663
+ attributes: attributes,
664
+ extensions: extensions,
665
+ });
666
+ }
667
+
668
+ if (linePositions.length > 0 && lineIndices.length > 1) {
669
+ const positions = new Float32Array(linePositions);
670
+ const indices = new Uint32Array(lineIndices);
671
+ const minMax = computeMinMax(positions);
672
+
673
+ const positionAccessor = addAccessor(positions, {
674
+ type: "VEC3",
675
+ componentType: ComponentDatatype.FLOAT,
676
+ target: WebGLConstants.ARRAY_BUFFER,
677
+ min: minMax.min,
678
+ max: minMax.max,
679
+ });
680
+ const indicesAccessor = addAccessor(indices, {
681
+ type: "SCALAR",
682
+ componentType: ComponentDatatype.UNSIGNED_INT,
683
+ target: WebGLConstants.ELEMENT_ARRAY_BUFFER,
684
+ });
685
+ const attributes = /** @type {*} */ ({
686
+ POSITION: positionAccessor,
687
+ });
688
+ const extensions = /** @type {*} */ ({
689
+ CESIUM_mesh_vector: {
690
+ vector: true,
691
+ count: lineCount,
692
+ },
693
+ });
694
+ addFeatureIdsToPrimitive(attributes, extensions, lineFeatureIds);
695
+
696
+ primitives.push({
697
+ mode: PrimitiveType.LINE_STRIP,
698
+ indices: indicesAccessor,
699
+ attributes: attributes,
700
+ extensions: extensions,
701
+ });
702
+ }
703
+
704
+ if (polygonPositions.length > 0 && polygonIndices.length >= 3) {
705
+ const positions = new Float32Array(polygonPositions);
706
+ const indices = new Uint32Array(polygonIndices);
707
+ const attributeOffsets = new Uint32Array(polygonAttributeOffsets);
708
+ const indicesOffsets = new Uint32Array(polygonIndicesOffsets);
709
+ const hasPolygonHoles = polygonHoleOffsets.length > 0;
710
+ const holeCounts = hasPolygonHoles
711
+ ? new Uint32Array(polygonHoleCounts)
712
+ : undefined;
713
+ const holeOffsets = hasPolygonHoles
714
+ ? new Uint32Array(polygonHoleOffsets)
715
+ : undefined;
716
+ const minMax = computeMinMax(positions);
717
+
718
+ const positionAccessor = addAccessor(positions, {
719
+ type: "VEC3",
720
+ componentType: ComponentDatatype.FLOAT,
721
+ target: WebGLConstants.ARRAY_BUFFER,
722
+ min: minMax.min,
723
+ max: minMax.max,
724
+ });
725
+ const indicesAccessor = addAccessor(indices, {
726
+ type: "SCALAR",
727
+ componentType: ComponentDatatype.UNSIGNED_INT,
728
+ target: WebGLConstants.ELEMENT_ARRAY_BUFFER,
729
+ });
730
+ const attributeOffsetsAccessor = addAccessor(attributeOffsets, {
731
+ type: "SCALAR",
732
+ componentType: ComponentDatatype.UNSIGNED_INT,
733
+ target: WebGLConstants.ARRAY_BUFFER,
734
+ });
735
+ const indicesOffsetsAccessor = addAccessor(indicesOffsets, {
736
+ type: "SCALAR",
737
+ componentType: ComponentDatatype.UNSIGNED_INT,
738
+ target: WebGLConstants.ARRAY_BUFFER,
739
+ });
740
+ const holeCountsAccessor = defined(holeCounts)
741
+ ? addAccessor(holeCounts, {
742
+ type: "SCALAR",
743
+ componentType: ComponentDatatype.UNSIGNED_INT,
744
+ target: WebGLConstants.ARRAY_BUFFER,
745
+ })
746
+ : undefined;
747
+ const holeOffsetsAccessor = defined(holeOffsets)
748
+ ? addAccessor(holeOffsets, {
749
+ type: "SCALAR",
750
+ componentType: ComponentDatatype.UNSIGNED_INT,
751
+ target: WebGLConstants.ARRAY_BUFFER,
752
+ })
753
+ : undefined;
754
+ const attributes = /** @type {*} */ ({
755
+ POSITION: positionAccessor,
756
+ });
757
+ const extensions = /** @type {*} */ ({
758
+ CESIUM_mesh_vector: {
759
+ vector: true,
760
+ count: polygonCount,
761
+ polygonAttributeOffsets: attributeOffsetsAccessor,
762
+ polygonIndicesOffsets: indicesOffsetsAccessor,
763
+ },
764
+ });
765
+ if (hasPolygonHoles) {
766
+ extensions.CESIUM_mesh_vector.polygonHoleCounts = holeCountsAccessor;
767
+ extensions.CESIUM_mesh_vector.polygonHoleOffsets = holeOffsetsAccessor;
768
+ }
769
+ addFeatureIdsToPrimitive(attributes, extensions, polygonFeatureIds);
770
+
771
+ primitives.push({
772
+ mode: PrimitiveType.TRIANGLES,
773
+ indices: indicesAccessor,
774
+ attributes: attributes,
775
+ extensions: extensions,
776
+ });
777
+ }
778
+
779
+ if (primitives.length === 0) {
780
+ continue;
781
+ }
782
+
783
+ const meshIndex = meshes.length;
784
+ meshes.push({ primitives: primitives });
785
+ nodes.push({
786
+ name: layer.name,
787
+ mesh: meshIndex,
788
+ translation: translation,
789
+ });
790
+ }
791
+
792
+ if (nodes.length === 0) {
793
+ return undefined;
794
+ }
795
+
796
+ // Build property table AFTER primitives (adds metadata buffer views).
797
+ const structuralMetadata = buildStructuralMetadata();
798
+
799
+ const binaryChunk = concatChunks(chunks, byteLength);
800
+ const extensionsUsed = ["CESIUM_mesh_vector"];
801
+ if (featureIdLookup.size > 0) {
802
+ extensionsUsed.push("EXT_mesh_features");
803
+ }
804
+ if (defined(structuralMetadata)) {
805
+ extensionsUsed.push("EXT_structural_metadata");
806
+ }
807
+
808
+ const nodeIndices = nodes.map((_, i) => i);
809
+
810
+ const gltfJson = {
811
+ asset: {
812
+ version: "2.0",
813
+ },
814
+ extensionsUsed: extensionsUsed,
815
+ scene: 0,
816
+ scenes: [
817
+ {
818
+ nodes: nodeIndices,
819
+ },
820
+ ],
821
+ nodes: nodes,
822
+ meshes: meshes,
823
+ accessors: accessors,
824
+ bufferViews: bufferViews,
825
+ buffers: [
826
+ {
827
+ byteLength: binaryChunk.byteLength,
828
+ },
829
+ ],
830
+ extensions: /** @type {Object|undefined} */ (undefined),
831
+ };
832
+
833
+ if (defined(structuralMetadata)) {
834
+ gltfJson.extensions = {
835
+ EXT_structural_metadata: structuralMetadata,
836
+ };
837
+ }
838
+
839
+ return buildGlb(gltfJson, binaryChunk);
840
+ }
841
+
842
+ /**
843
+ * Assigns a stable auto-incrementing integer ID to each unique feature.
844
+ *
845
+ * @param {VectorTileFeature} feature
846
+ * @param {Map<VectorTileFeature, number>} featureIdLookup
847
+ * @returns {number}
848
+ * @ignore
849
+ */
850
+ function getOrAssignAutoFeatureId(feature, featureIdLookup) {
851
+ let id = featureIdLookup.get(feature);
852
+ if (!defined(id)) {
853
+ id = featureIdLookup.size;
854
+ featureIdLookup.set(feature, id);
855
+ }
856
+ return id;
857
+ }
858
+
859
+ /**
860
+ * @param {VectorTileFeature} feature
861
+ * @param {string} featureIdProperty
862
+ * @param {Map<string, number>} featureIdLookup
863
+ * @returns {number|undefined}
864
+ * @ignore
865
+ */
866
+ function mapFeatureIdFromProperty(feature, featureIdProperty, featureIdLookup) {
867
+ const properties = feature.properties;
868
+ if (!defined(properties)) {
869
+ return undefined;
870
+ }
871
+ const propertyValue = /** @type {*} */ (properties)[featureIdProperty];
872
+ if (!defined(propertyValue)) {
873
+ return undefined;
874
+ }
875
+ if (
876
+ typeof propertyValue !== "string" &&
877
+ typeof propertyValue !== "number" &&
878
+ typeof propertyValue !== "boolean"
879
+ ) {
880
+ return undefined;
881
+ }
882
+ if (typeof propertyValue === "number" && !Number.isFinite(propertyValue)) {
883
+ return undefined;
884
+ }
885
+ const mapKey = `${typeof propertyValue}:${propertyValue}`;
886
+ let mappedFeatureId = featureIdLookup.get(mapKey);
887
+ if (defined(mappedFeatureId)) {
888
+ return mappedFeatureId;
889
+ }
890
+ mappedFeatureId = featureIdLookup.size;
891
+ featureIdLookup.set(mapKey, mappedFeatureId);
892
+ return mappedFeatureId;
893
+ }
894
+
895
+ /**
896
+ * @param {VectorTilePoint[][]} rawRings
897
+ * @returns {Array.<PolygonRingGroup>}
898
+ * @ignore
899
+ */
900
+ function groupPolygonRings(rawRings) {
901
+ /** @type {Array.<PolygonRingGroup>} */
902
+ const groups = [];
903
+ for (const rawRing of rawRings) {
904
+ const ring = stripClosingVertex(rawRing);
905
+ if (ring.length < 3) {
906
+ continue;
907
+ }
908
+ const area = ringSignedArea(ring);
909
+ if (area <= 0) {
910
+ groups.push({ outerRing: ring, holes: [] });
911
+ } else if (groups.length > 0) {
912
+ groups[groups.length - 1].holes.push(ring);
913
+ }
914
+ }
915
+ return groups;
916
+ }
917
+
918
+ /**
919
+ * @param {VectorTilePoint[]} ring
920
+ * @returns {number}
921
+ * @ignore
922
+ */
923
+ function ringSignedArea(ring) {
924
+ let area = 0;
925
+ for (let i = 0, j = ring.length - 1; i < ring.length; j = i++) {
926
+ area += (ring[j].x + ring[i].x) * (ring[j].y - ring[i].y);
927
+ }
928
+ return area / 2;
929
+ }
930
+
931
+ /**
932
+ * @param {VectorTilePoint[]} ring
933
+ * @returns {VectorTilePoint[]}
934
+ * @ignore
935
+ */
936
+ function stripClosingVertex(ring) {
937
+ if (
938
+ ring.length > 1 &&
939
+ ring[0].x === ring[ring.length - 1].x &&
940
+ ring[0].y === ring[ring.length - 1].y
941
+ ) {
942
+ return ring.slice(0, ring.length - 1);
943
+ }
944
+ return ring;
945
+ }
946
+
947
+ /**
948
+ * @param {VectorTilePoint} point
949
+ * @param {number} tileX
950
+ * @param {number} tileY
951
+ * @param {number} tileZ
952
+ * @param {number} extent
953
+ * @param {number} height
954
+ * @param {Cartesian3} origin
955
+ * @param {number[]} out
956
+ * @ignore
957
+ */
958
+ function appendTilePointAsLocalPosition(
959
+ point,
960
+ tileX,
961
+ tileY,
962
+ tileZ,
963
+ extent,
964
+ height,
965
+ origin,
966
+ out,
967
+ ) {
968
+ const n = 1 << tileZ;
969
+ const u = (tileX + point.x / extent) / n;
970
+ const v = (tileY + point.y / extent) / n;
971
+ const lon = u * 2 * Math.PI - Math.PI;
972
+ const lat = Math.atan(Math.sinh(Math.PI * (1 - 2 * v)));
973
+
974
+ Cartesian3.fromRadians(lon, lat, height, undefined, scratchWorld);
975
+ Cartesian3.subtract(scratchWorld, origin, scratchLocal);
976
+ out.push(scratchLocal.x, scratchLocal.y, scratchLocal.z);
977
+ }
978
+
979
+ /**
980
+ * Packs a glTF JSON object and binary buffer into a GLB (Binary glTF) Uint8Array.
981
+ * GLB spec: https://registry.khronos.org/glTF/specs/2.0/glTF-2.0.html#binary-gltf-layout
982
+ *
983
+ * @param {object} gltfJson
984
+ * @param {Uint8Array} binaryChunk
985
+ * @returns {Uint8Array}
986
+ * @ignore
987
+ */
988
+ function buildGlb(gltfJson, binaryChunk) {
989
+ const GLB_MAGIC = 0x46546c67; // "glTF"
990
+ const GLB_VERSION = 2;
991
+ const CHUNK_TYPE_JSON = 0x4e4f534a; // "JSON"
992
+ const CHUNK_TYPE_BIN = 0x004e4942; // "BIN\0"
993
+
994
+ const jsonBytes = new TextEncoder().encode(JSON.stringify(gltfJson));
995
+ // Pad JSON to 4-byte boundary with spaces (0x20)
996
+ const jsonPaddedLength = Math.ceil(jsonBytes.length / 4) * 4;
997
+ const jsonChunk = new Uint8Array(jsonPaddedLength);
998
+ jsonChunk.fill(0x20);
999
+ jsonChunk.set(jsonBytes);
1000
+
1001
+ // Pad binary to 4-byte boundary with zeros
1002
+ const binPaddedLength = Math.ceil(binaryChunk.byteLength / 4) * 4;
1003
+ const binChunk = new Uint8Array(binPaddedLength);
1004
+ binChunk.set(binaryChunk);
1005
+
1006
+ const totalLength =
1007
+ 12 + // header
1008
+ 8 +
1009
+ jsonPaddedLength + // JSON chunk header + data
1010
+ 8 +
1011
+ binPaddedLength; // BIN chunk header + data
1012
+
1013
+ const glb = new Uint8Array(totalLength);
1014
+ const view = new DataView(glb.buffer);
1015
+ let offset = 0;
1016
+
1017
+ // Header
1018
+ view.setUint32(offset, GLB_MAGIC, true);
1019
+ offset += 4;
1020
+ view.setUint32(offset, GLB_VERSION, true);
1021
+ offset += 4;
1022
+ view.setUint32(offset, totalLength, true);
1023
+ offset += 4;
1024
+
1025
+ // JSON chunk
1026
+ view.setUint32(offset, jsonPaddedLength, true);
1027
+ offset += 4;
1028
+ view.setUint32(offset, CHUNK_TYPE_JSON, true);
1029
+ offset += 4;
1030
+ glb.set(jsonChunk, offset);
1031
+ offset += jsonPaddedLength;
1032
+
1033
+ // BIN chunk
1034
+ view.setUint32(offset, binPaddedLength, true);
1035
+ offset += 4;
1036
+ view.setUint32(offset, CHUNK_TYPE_BIN, true);
1037
+ offset += 4;
1038
+ glb.set(binChunk, offset);
1039
+
1040
+ return glb;
1041
+ }
1042
+
1043
+ /**
1044
+ * @param {Uint8Array[]} chunks
1045
+ * @param {number} totalByteLength
1046
+ * @returns {Uint8Array}
1047
+ * @ignore
1048
+ */
1049
+ function concatChunks(chunks, totalByteLength) {
1050
+ const out = new Uint8Array(totalByteLength);
1051
+ let offset = 0;
1052
+ for (const chunk of chunks) {
1053
+ out.set(chunk, offset);
1054
+ offset += chunk.byteLength;
1055
+ }
1056
+ return out;
1057
+ }
1058
+
1059
+ export default buildVectorGltfFromMVT;