@cesium/engine 26.1.0 → 26.3.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 (325) hide show
  1. package/Build/ThirdParty/Workers/zip-web-worker.js +764 -520
  2. package/Build/Workers/{chunk-HS6AD4P2.js → chunk-2DKJSPYF.js} +14 -14
  3. package/Build/Workers/{chunk-QVLAFFJY.js → chunk-2PWVICP6.js} +1 -1
  4. package/Build/Workers/{chunk-ILME5BXA.js → chunk-2YY724ZX.js} +8 -8
  5. package/Build/Workers/{chunk-ENNFMWDW.js → chunk-4DMAXPKB.js} +12 -12
  6. package/Build/Workers/{chunk-CDJDJ5LK.js → chunk-4LRFYRBX.js} +2 -2
  7. package/Build/Workers/{chunk-76FDC45O.js → chunk-5JCZHJUU.js} +13 -13
  8. package/Build/Workers/{chunk-5LSOO2KD.js → chunk-5KG7KDDW.js} +7 -7
  9. package/Build/Workers/{chunk-A6X24AZI.js → chunk-6BSNYZZG.js} +5 -5
  10. package/Build/Workers/{chunk-IGAZBTFZ.js → chunk-6R6SGKYN.js} +6 -6
  11. package/Build/Workers/{chunk-SS5ABQGY.js → chunk-6V2KDEHL.js} +4 -4
  12. package/Build/Workers/{chunk-ZMBHFYOX.js → chunk-75BC2IHI.js} +7 -7
  13. package/Build/Workers/{chunk-LGNDTZVX.js → chunk-7SESBH2I.js} +4 -4
  14. package/Build/Workers/{chunk-CLCTQVVL.js → chunk-7WXBTNRV.js} +8 -8
  15. package/Build/Workers/{chunk-WBSY7HDY.js → chunk-A7SMPV6B.js} +12 -12
  16. package/Build/Workers/{chunk-CEEZE3YZ.js → chunk-ATSXKJ3L.js} +7 -7
  17. package/Build/Workers/{chunk-AHWAZRBV.js → chunk-B4AVL7VI.js} +1 -1
  18. package/Build/Workers/{chunk-6HK6IXK2.js → chunk-B7Q2WF6Q.js} +4 -4
  19. package/Build/Workers/{chunk-YKU2Q3A2.js → chunk-BNDSDQ7D.js} +9 -12
  20. package/Build/Workers/{chunk-R4FPNAZ2.js → chunk-CKK6CUXK.js} +9 -9
  21. package/Build/Workers/{chunk-FCP2QY4G.js → chunk-COKOYTRS.js} +5 -5
  22. package/Build/Workers/{chunk-7D2HZKH7.js → chunk-CQ4TZXAT.js} +7 -7
  23. package/Build/Workers/{chunk-TVZD72WJ.js → chunk-DKSANM4A.js} +12 -12
  24. package/Build/Workers/{chunk-FDK4K5IA.js → chunk-DZK34ZVD.js} +1 -1
  25. package/Build/Workers/{chunk-N7CCOFLX.js → chunk-E7G32DWL.js} +1 -1
  26. package/Build/Workers/{chunk-XDWCTQCZ.js → chunk-EDETO6NY.js} +2 -2
  27. package/Build/Workers/{chunk-2EFYUSUY.js → chunk-F34TJJLA.js} +16 -16
  28. package/Build/Workers/{chunk-GXWQZBAI.js → chunk-GLHDTTTO.js} +2 -2
  29. package/Build/Workers/{chunk-T5QBPLE3.js → chunk-GS7RY2DH.js} +11 -11
  30. package/Build/Workers/{chunk-C7JQVRLM.js → chunk-HDD3RFLT.js} +25 -3
  31. package/Build/Workers/{chunk-E7NZJOK7.js → chunk-HDPNFEPP.js} +121 -93
  32. package/Build/Workers/{chunk-VAL7DYNR.js → chunk-JBJ6BRIM.js} +4 -4
  33. package/Build/Workers/{chunk-XQ3SKCMM.js → chunk-JKTWW7IO.js} +5 -5
  34. package/Build/Workers/{chunk-UVO6COT2.js → chunk-JL4NWWQY.js} +5 -5
  35. package/Build/Workers/{chunk-DBD5WWG2.js → chunk-JMUUAW4X.js} +10 -10
  36. package/Build/Workers/{chunk-UEY73NRN.js → chunk-KBGAHN5R.js} +1 -1
  37. package/Build/Workers/{chunk-LD64RPYV.js → chunk-KEWK6VZL.js} +12 -12
  38. package/Build/Workers/{chunk-JW6OZT4R.js → chunk-L73K5UPP.js} +10 -10
  39. package/Build/Workers/{chunk-DIGUUD6G.js → chunk-LL2SGJYH.js} +6 -6
  40. package/Build/Workers/{chunk-XLXSDIP5.js → chunk-LYJUL4XQ.js} +6 -6
  41. package/Build/Workers/{chunk-SM2CDCYF.js → chunk-M6W46OAP.js} +7 -7
  42. package/Build/Workers/{chunk-EHTS2YPT.js → chunk-MDDKCLMF.js} +17 -17
  43. package/Build/Workers/{chunk-FGQFQHN5.js → chunk-MUW4DJV7.js} +18 -18
  44. package/Build/Workers/{chunk-HHV3MCGV.js → chunk-N5YK44FS.js} +5 -5
  45. package/Build/Workers/{chunk-RG4F5R57.js → chunk-NZQUP52G.js} +9 -9
  46. package/Build/Workers/{chunk-B4CQSLZJ.js → chunk-PKZA44LH.js} +6 -6
  47. package/Build/Workers/{chunk-OBEU25PI.js → chunk-Q2JS5LCB.js} +17 -17
  48. package/Build/Workers/{chunk-KGXSYGBG.js → chunk-QTAEVUED.js} +13 -13
  49. package/Build/Workers/{chunk-NIWITKQK.js → chunk-SEJIXZZ4.js} +11 -11
  50. package/Build/Workers/{chunk-SGRGNDOD.js → chunk-SL2HCFYW.js} +10 -10
  51. package/Build/Workers/{chunk-SF6K72D7.js → chunk-SLHK3KAR.js} +5 -5
  52. package/Build/Workers/{chunk-JKXV6PG5.js → chunk-UZY5XRL2.js} +1 -1
  53. package/Build/Workers/{chunk-LNSQVXFH.js → chunk-VRECSMG3.js} +2 -2
  54. package/Build/Workers/{chunk-A3O6EDBK.js → chunk-X27HKF5E.js} +2 -2
  55. package/Build/Workers/{chunk-7KVKHY7O.js → chunk-XBY3354M.js} +6 -6
  56. package/Build/Workers/{chunk-GSWMAFTE.js → chunk-XRZCS3HE.js} +23 -16
  57. package/Build/Workers/{chunk-6YR6JBMY.js → chunk-XSIUYAT6.js} +2 -2
  58. package/Build/Workers/{chunk-ZSGUV73H.js → chunk-Z2DW5NM2.js} +6 -6
  59. package/Build/Workers/combineGeometry.js +24 -24
  60. package/Build/Workers/createBoxGeometry.js +18 -18
  61. package/Build/Workers/createBoxOutlineGeometry.js +16 -16
  62. package/Build/Workers/createCircleGeometry.js +26 -26
  63. package/Build/Workers/createCircleOutlineGeometry.js +19 -19
  64. package/Build/Workers/createCoplanarPolygonGeometry.js +35 -35
  65. package/Build/Workers/createCoplanarPolygonOutlineGeometry.js +31 -31
  66. package/Build/Workers/createCorridorGeometry.js +31 -33
  67. package/Build/Workers/createCorridorOutlineGeometry.js +29 -31
  68. package/Build/Workers/createCylinderGeometry.js +20 -20
  69. package/Build/Workers/createCylinderOutlineGeometry.js +18 -18
  70. package/Build/Workers/createEllipseGeometry.js +26 -26
  71. package/Build/Workers/createEllipseOutlineGeometry.js +19 -19
  72. package/Build/Workers/createEllipsoidGeometry.js +19 -19
  73. package/Build/Workers/createEllipsoidOutlineGeometry.js +18 -18
  74. package/Build/Workers/createFrustumGeometry.js +18 -18
  75. package/Build/Workers/createFrustumOutlineGeometry.js +18 -18
  76. package/Build/Workers/createGeometry.js +24 -24
  77. package/Build/Workers/createGroundPolylineGeometry.js +24 -24
  78. package/Build/Workers/createPlaneGeometry.js +16 -16
  79. package/Build/Workers/createPlaneOutlineGeometry.js +15 -15
  80. package/Build/Workers/createPolygonGeometry.js +34 -34
  81. package/Build/Workers/createPolygonOutlineGeometry.js +31 -31
  82. package/Build/Workers/createPolylineGeometry.js +26 -26
  83. package/Build/Workers/createPolylineVolumeGeometry.js +31 -31
  84. package/Build/Workers/createPolylineVolumeOutlineGeometry.js +27 -27
  85. package/Build/Workers/createRectangleGeometry.js +27 -27
  86. package/Build/Workers/createRectangleOutlineGeometry.js +21 -21
  87. package/Build/Workers/createSimplePolylineGeometry.js +24 -24
  88. package/Build/Workers/createSphereGeometry.js +19 -19
  89. package/Build/Workers/createSphereOutlineGeometry.js +18 -18
  90. package/Build/Workers/createTaskProcessorWorker.js +3 -3
  91. package/Build/Workers/createVectorTileClampedPolylines.js +14 -14
  92. package/Build/Workers/createVectorTileGeometries.js +24 -24
  93. package/Build/Workers/createVectorTilePoints.js +13 -13
  94. package/Build/Workers/createVectorTilePolygons.js +22 -22
  95. package/Build/Workers/createVectorTilePolylines.js +14 -14
  96. package/Build/Workers/createVerticesFromCesium3DTilesTerrain.js +25 -25
  97. package/Build/Workers/createVerticesFromGoogleEarthEnterpriseBuffer.js +22 -22
  98. package/Build/Workers/createVerticesFromHeightmap.js +22 -22
  99. package/Build/Workers/createVerticesFromQuantizedTerrainMesh.js +20 -20
  100. package/Build/Workers/createWallGeometry.js +24 -24
  101. package/Build/Workers/createWallOutlineGeometry.js +24 -24
  102. package/Build/Workers/decodeDraco.js +10 -10
  103. package/Build/Workers/decodeGoogleEarthEnterprisePacket.js +5 -5
  104. package/Build/Workers/decodeI3S.js +10 -10
  105. package/Build/Workers/gaussianSplatSorter.js +4 -4
  106. package/Build/Workers/gaussianSplatTextureGenerator.js +4 -4
  107. package/Build/Workers/incrementallyBuildTerrainPicker.js +10 -10
  108. package/Build/Workers/transcodeKTX2.js +6 -6
  109. package/Build/Workers/transferTypedArrayTest.js +1 -1
  110. package/Build/Workers/upsampleQuantizedTerrainMesh.js +22 -22
  111. package/Build/Workers/upsampleVerticesFromCesium3DTilesTerrain.js +25 -25
  112. package/Source/Core/ArcGISTiledElevationTerrainProvider.js +1 -5
  113. package/Source/Core/BoundingSphere.js +0 -3
  114. package/Source/Core/Cesium3DTilesTerrainGeometryProcessor.js +3 -4
  115. package/Source/Core/CoplanarPolygonGeometry.js +2 -2
  116. package/Source/Core/CorridorGeometry.js +2 -4
  117. package/Source/Core/CorridorOutlineGeometry.js +1 -3
  118. package/Source/Core/EarthOrientationParameters.js +2 -2
  119. package/Source/Core/EllipseGeometryLibrary.js +2 -2
  120. package/Source/Core/EllipsoidGeodesic.js +3 -3
  121. package/Source/Core/EllipsoidRhumbLine.js +1 -1
  122. package/Source/Core/GroundPolylineGeometry.js +2 -2
  123. package/Source/Core/Heap.js +1 -1
  124. package/Source/Core/HermitePolynomialApproximation.js +215 -179
  125. package/Source/Core/InterpolationAlgorithm.js +1 -0
  126. package/Source/Core/Ion.js +1 -1
  127. package/Source/Core/IonResource.js +5 -0
  128. package/Source/Core/IonSnapGeometryType.js +59 -0
  129. package/Source/Core/IonSnapHeat.js +33 -0
  130. package/Source/Core/IonSnapMode.js +45 -0
  131. package/Source/Core/IonSnapParentGeometryType.js +52 -0
  132. package/Source/Core/IonSnapService.js +369 -0
  133. package/Source/Core/JulianDate.js +1 -1
  134. package/Source/Core/LagrangePolynomialApproximation.js +55 -52
  135. package/Source/Core/LinearApproximation.js +69 -66
  136. package/Source/Core/Math.js +59 -0
  137. package/Source/Core/Matrix2.js +2 -2
  138. package/Source/Core/Matrix3.js +2 -2
  139. package/Source/Core/OrthographicFrustum.js +1 -1
  140. package/Source/Core/PerspectiveFrustum.js +1 -1
  141. package/Source/Core/PolygonGeometry.js +2 -2
  142. package/Source/Core/PolygonGeometryLibrary.js +1 -1
  143. package/Source/Core/PolygonOutlineGeometry.js +1 -1
  144. package/Source/Core/PolylineGeometry.js +1 -1
  145. package/Source/Core/PolylineVolumeGeometryLibrary.js +1 -1
  146. package/Source/Core/Rectangle.js +7 -1
  147. package/Source/Core/RectangleOutlineGeometry.js +1 -1
  148. package/Source/Core/SimplePolylineGeometry.js +1 -1
  149. package/Source/Core/SnapService.js +63 -0
  150. package/Source/Core/TerrainEncoding.js +2 -2
  151. package/Source/Core/TerrainPicker.js +179 -168
  152. package/Source/Core/TimeIntervalCollection.js +1 -3
  153. package/Source/Core/Tipsify.js +1 -1
  154. package/Source/Core/Transforms.js +5 -1
  155. package/Source/Core/VectorPipeline.js +1211 -0
  156. package/Source/Core/VectorProvider.js +669 -0
  157. package/Source/Core/WallOutlineGeometry.js +1 -1
  158. package/Source/Core/getTimestamp.js +4 -2
  159. package/Source/DataSources/CompositeEntityCollection.js +0 -1
  160. package/Source/DataSources/CzmlDataSource.js +2 -0
  161. package/Source/DataSources/DataSourceDisplay.js +1 -1
  162. package/Source/DataSources/GeoJsonDataSource.js +0 -1
  163. package/Source/DataSources/GeometryVisualizer.js +1 -1
  164. package/Source/DataSources/KmlDataSource.js +1 -2
  165. package/Source/DataSources/PolylineVisualizer.js +1 -1
  166. package/Source/DataSources/StaticOutlineGeometryBatch.js +1 -1
  167. package/Source/Renderer/AutomaticUniforms.js +67 -2
  168. package/Source/Renderer/Context.js +9 -3
  169. package/Source/Renderer/DrawCommand.js +22 -0
  170. package/Source/Renderer/Framebuffer.js +4 -0
  171. package/Source/Renderer/Pass.js +11 -10
  172. package/Source/Renderer/ShaderBuilder.js +1 -1
  173. package/Source/Renderer/Texture.js +11 -0
  174. package/Source/Renderer/UniformState.js +54 -1
  175. package/Source/Renderer/VertexArray.js +0 -1
  176. package/Source/Scene/ArcGisMapServerImageryProvider.js +0 -5
  177. package/Source/Scene/ArcGisMapService.js +1 -1
  178. package/Source/Scene/Billboard.js +2 -1
  179. package/Source/Scene/BillboardCollection.js +7 -3
  180. package/Source/Scene/BufferPointCollection.js +4 -7
  181. package/Source/Scene/BufferPolygonCollection.js +56 -27
  182. package/Source/Scene/BufferPolylineCollection.js +61 -8
  183. package/Source/Scene/BufferPolylineMaterial.js +6 -5
  184. package/Source/Scene/BufferPrimitiveCollection.js +226 -34
  185. package/Source/Scene/Camera.js +71 -5
  186. package/Source/Scene/Cesium3DTile.js +12 -0
  187. package/Source/Scene/Cesium3DTileset.js +62 -9
  188. package/Source/Scene/Cesium3DTilesetBaseTraversal.js +15 -3
  189. package/Source/Scene/Cesium3DTilesetCache.js +15 -0
  190. package/Source/Scene/ClippingPlaneCollection.js +2 -2
  191. package/Source/Scene/ClippingPolygon.js +154 -100
  192. package/Source/Scene/ClippingPolygonCollection.js +352 -694
  193. package/Source/Scene/Controllers/Controller.js +63 -0
  194. package/Source/Scene/Controllers/ControllerHost.js +78 -0
  195. package/Source/Scene/Controllers/HybridScreenSpacePanCameraController.js +106 -0
  196. package/Source/Scene/Controllers/MouseButton.js +32 -0
  197. package/Source/Scene/Controllers/ScreenSpaceElevatorCameraController.js +295 -0
  198. package/Source/Scene/Controllers/ScreenSpaceInputBindings.js +154 -0
  199. package/Source/Scene/Controllers/ScreenSpaceMapCameraController.js +310 -0
  200. package/Source/Scene/Controllers/ScreenSpaceTiltOrbitCameraController.js +642 -0
  201. package/Source/Scene/Controllers/ScreenSpaceZoomCameraController.js +431 -0
  202. package/Source/Scene/Controllers/defaultPickWorldPosition.js +84 -0
  203. package/Source/Scene/CreditDisplay.js +62 -0
  204. package/Source/Scene/DerivedCommand.js +94 -0
  205. package/Source/Scene/EdgeFramebuffer.js +1 -5
  206. package/Source/Scene/FrameState.js +17 -0
  207. package/Source/Scene/GeoJsonPrimitive.js +114 -24
  208. package/Source/Scene/Globe.js +20 -0
  209. package/Source/Scene/GlobeDepth.js +27 -1
  210. package/Source/Scene/GlobeSurfaceShaderSet.js +42 -53
  211. package/Source/Scene/GlobeSurfaceTile.js +61 -10
  212. package/Source/Scene/GlobeSurfaceTileProvider.js +351 -26
  213. package/Source/Scene/GltfLoader.js +88 -9
  214. package/Source/Scene/GltfSpzLoader.js +1 -1
  215. package/Source/Scene/GltfVertexBufferLoader.js +6 -3
  216. package/Source/Scene/HeightReference.js +1 -1
  217. package/Source/Scene/I3SDataProvider.js +1 -1
  218. package/Source/Scene/I3SLayer.js +1 -1
  219. package/Source/Scene/I3SNode.js +2 -2
  220. package/Source/Scene/ImageryLayerCollection.js +188 -4
  221. package/Source/Scene/IonImageryProvider.js +1 -5
  222. package/Source/Scene/Label.js +4 -4
  223. package/Source/Scene/LabelCollection.js +1 -1
  224. package/Source/Scene/MVTDataProvider.js +11 -0
  225. package/Source/Scene/Model/B3dmLoader.js +1 -2
  226. package/Source/Scene/Model/EdgeVisibilityPipelineStage.js +10 -8
  227. package/Source/Scene/Model/I3dmLoader.js +1 -1
  228. package/Source/Scene/Model/InstancingPipelineStage.js +4 -7
  229. package/Source/Scene/Model/MaterialPipelineStage.js +124 -1
  230. package/Source/Scene/Model/Model.js +250 -26
  231. package/Source/Scene/Model/Model3DTileContent.js +5 -0
  232. package/Source/Scene/Model/ModelClippingPlanesPipelineStage.js +28 -1
  233. package/Source/Scene/Model/ModelClippingPolygonsPipelineStage.js +54 -19
  234. package/Source/Scene/Model/ModelDrawCommand.js +160 -16
  235. package/Source/Scene/Model/ModelDrawCommands.js +4 -0
  236. package/Source/Scene/Model/ModelRenderResources.js +2 -3
  237. package/Source/Scene/Model/ModelSceneGraph.js +31 -1
  238. package/Source/Scene/Model/ModelVectorLookupPipelineStage.js +205 -0
  239. package/Source/Scene/Model/PickingPipelineStage.js +33 -0
  240. package/Source/Scene/Model/PrimitiveRenderResources.js +24 -0
  241. package/Source/Scene/ModelComponents.js +71 -0
  242. package/Source/Scene/Picking.js +16 -5
  243. package/Source/Scene/PlanarFillIdFramebuffer.js +172 -0
  244. package/Source/Scene/PntsParser.js +0 -1
  245. package/Source/Scene/PolylineCollection.js +1 -1
  246. package/Source/Scene/PostProcessStage.js +26 -5
  247. package/Source/Scene/ResourceCache.js +7 -4
  248. package/Source/Scene/ResourceCacheKey.js +16 -13
  249. package/Source/Scene/Scene.js +258 -6
  250. package/Source/Scene/ScreenSpaceCameraController.js +1 -2
  251. package/Source/Scene/ShadowMap.js +9 -3
  252. package/Source/Scene/ShadowMapShader.js +50 -2
  253. package/Source/Scene/SnapFramebuffer.js +121 -0
  254. package/Source/Scene/Snapping.js +241 -0
  255. package/Source/Scene/TerrainFillMesh.js +3 -2
  256. package/Source/Scene/UrlTemplate3DTilesDataProvider.js +13 -2
  257. package/Source/Scene/Vector3DTileContent.js +2 -3
  258. package/Source/Scene/VectorGltf3DTileContent.js +31 -3
  259. package/Source/Scene/View.js +10 -8
  260. package/Source/Scene/VoxelTraversal.js +1 -1
  261. package/Source/Scene/WebMapServiceImageryProvider.js +5 -1
  262. package/Source/Scene/WebMapTileServiceImageryProvider.js +6 -1
  263. package/Source/Scene/createElevationBandMaterial.js +1 -1
  264. package/Source/Scene/renderBufferPointCollection.js +1 -2
  265. package/Source/Scene/renderBufferPolygonCollection.js +1 -2
  266. package/Source/Scene/renderBufferPolylineCollection.js +6 -3
  267. package/Source/Shaders/BufferPolylineMaterialVS.glsl +14 -2
  268. package/Source/Shaders/BufferPolylineMaterialVS.js +14 -2
  269. package/Source/Shaders/Builtin/Constants/passCesium3DTile.glsl +1 -1
  270. package/Source/Shaders/Builtin/Constants/passCesium3DTile.js +1 -1
  271. package/Source/Shaders/Builtin/Constants/passCesium3DTileClassification.glsl +1 -1
  272. package/Source/Shaders/Builtin/Constants/passCesium3DTileClassification.js +1 -1
  273. package/Source/Shaders/Builtin/Constants/passCesium3DTileClassificationIgnoreShow.glsl +1 -1
  274. package/Source/Shaders/Builtin/Constants/passCesium3DTileClassificationIgnoreShow.js +1 -1
  275. package/Source/Shaders/Builtin/Constants/passCesium3DTilePlanarFillId.glsl +9 -0
  276. package/Source/Shaders/Builtin/Constants/passCesium3DTilePlanarFillId.js +11 -0
  277. package/Source/Shaders/Builtin/Constants/passClassification.glsl +1 -1
  278. package/Source/Shaders/Builtin/Constants/passClassification.js +1 -1
  279. package/Source/Shaders/Builtin/Constants/passGaussianSplats.glsl +1 -1
  280. package/Source/Shaders/Builtin/Constants/passGaussianSplats.js +1 -1
  281. package/Source/Shaders/Builtin/Constants/passOpaque.glsl +1 -1
  282. package/Source/Shaders/Builtin/Constants/passOpaque.js +1 -1
  283. package/Source/Shaders/Builtin/Constants/passTranslucent.glsl +1 -1
  284. package/Source/Shaders/Builtin/Constants/passTranslucent.js +1 -1
  285. package/Source/Shaders/Builtin/Constants/passVoxels.glsl +1 -1
  286. package/Source/Shaders/Builtin/Constants/passVoxels.js +1 -1
  287. package/Source/Shaders/Builtin/CzmBuiltins.js +4 -4
  288. package/Source/Shaders/Builtin/Functions/eyeToCartographicDelta.glsl +74 -0
  289. package/Source/Shaders/Builtin/Functions/eyeToCartographicDelta.js +76 -0
  290. package/Source/Shaders/GlobeFS.glsl +20 -14
  291. package/Source/Shaders/GlobeFS.js +20 -14
  292. package/Source/Shaders/GlobeVS.glsl +0 -32
  293. package/Source/Shaders/GlobeVS.js +0 -32
  294. package/Source/Shaders/Materials/PolylineGlowMaterial.glsl +1 -1
  295. package/Source/Shaders/Materials/PolylineGlowMaterial.js +1 -1
  296. package/Source/Shaders/Model/MaterialStageFS.glsl +8 -2
  297. package/Source/Shaders/Model/MaterialStageFS.js +8 -2
  298. package/Source/Shaders/Model/ModelClippingPolygonsStageFS.glsl +15 -3
  299. package/Source/Shaders/Model/ModelClippingPolygonsStageFS.js +15 -3
  300. package/Source/Shaders/Model/ModelClippingPolygonsStageVS.glsl +20 -24
  301. package/Source/Shaders/Model/ModelClippingPolygonsStageVS.js +20 -24
  302. package/Source/Shaders/Model/ModelFS.glsl +109 -0
  303. package/Source/Shaders/Model/ModelFS.js +109 -0
  304. package/Source/Shaders/Model/ModelVS.glsl +7 -2
  305. package/Source/Shaders/Model/ModelVS.js +7 -2
  306. package/Source/Shaders/Model/ModelVectorLookupStageFS.glsl +6 -0
  307. package/Source/Shaders/Model/ModelVectorLookupStageFS.js +8 -0
  308. package/Source/Shaders/Model/ModelVectorLookupStageVS.glsl +15 -0
  309. package/Source/Shaders/Model/ModelVectorLookupStageVS.js +17 -0
  310. package/Source/Shaders/Model/VerticalExaggerationStageVS.glsl +9 -10
  311. package/Source/Shaders/Model/VerticalExaggerationStageVS.js +9 -11
  312. package/Source/Shaders/VectorCommon.glsl +305 -0
  313. package/Source/Shaders/VectorCommon.js +307 -0
  314. package/Source/ThirdParty/Workers/zip-web-worker.js +1 -1
  315. package/Source/ThirdParty/zip-module.wasm +0 -0
  316. package/Source/Widget/CesiumWidget.js +30 -0
  317. package/index.d.ts +1326 -65
  318. package/index.js +179 -155
  319. package/package.json +6 -6
  320. package/Source/Shaders/Builtin/Functions/clipPolygons.glsl +0 -37
  321. package/Source/Shaders/Builtin/Functions/clipPolygons.js +0 -39
  322. package/Source/Shaders/Builtin/Functions/unpackClippingExtents.glsl +0 -14
  323. package/Source/Shaders/Builtin/Functions/unpackClippingExtents.js +0 -15
  324. package/Source/Shaders/PolygonSignedDistanceFS.glsl +0 -131
  325. package/Source/Shaders/PolygonSignedDistanceFS.js +0 -132
@@ -77,18 +77,12 @@ uniform mat4 u_clippingPlanesMatrix;
77
77
  uniform vec4 u_clippingPlanesEdgeStyle;
78
78
  #endif
79
79
 
80
- #ifdef ENABLE_CLIPPING_POLYGONS
81
- uniform highp sampler2D u_clippingDistance;
82
- in vec2 v_clippingPosition;
83
- flat in int v_regionIndex;
84
- #endif
85
-
86
80
  #if defined(GROUND_ATMOSPHERE) || defined(FOG) && defined(DYNAMIC_ATMOSPHERE_LIGHTING) && (defined(ENABLE_VERTEX_LIGHTING) || defined(ENABLE_DAYNIGHT_SHADING))
87
81
  uniform float u_minimumBrightness;
88
82
  #endif
89
83
 
90
84
  // Based on colorCorrect
91
- // The colorCorrect flag can only be true when tileProvider.hue/saturation/brightnessShift
85
+ // The colorCorrect flag can only be true when tileProvider.hue/saturation/brightnessShift
92
86
  // are nonzero AND when (applyFog || showGroundAtmosphere) in the tile provider
93
87
  // - The tileProvider.hue/saturation/brightnessShift are just passed through
94
88
  // from the Globe hue/saturation/brightness, like atmosphereBrightnessShift
@@ -116,8 +110,8 @@ uniform vec4 u_translucencyRectangle;
116
110
  #endif
117
111
 
118
112
  // Based on showUndergroundColor
119
- // This is set when GlobeSurfaceTileProvider.isUndergroundVisible
120
- // returns true, AND the tileProvider.undergroundColor had a value with
113
+ // This is set when GlobeSurfaceTileProvider.isUndergroundVisible
114
+ // returns true, AND the tileProvider.undergroundColor had a value with
121
115
  // nonzero alpha, and the tileProvider.undergroundColorAlphaByDistance
122
116
  // was in the right range
123
117
  #ifdef UNDERGROUND_COLOR
@@ -457,9 +451,16 @@ void main()
457
451
  #endif
458
452
 
459
453
  #ifdef ENABLE_CLIPPING_POLYGONS
460
- vec2 clippingPosition = v_clippingPosition;
461
- int regionIndex = v_regionIndex;
462
- clipPolygons(u_clippingDistance, CLIPPING_POLYGON_REGIONS_LENGTH, clippingPosition, regionIndex);
454
+ bool insideAny = vectorClip(v_textureCoordinates.xy);
455
+ #ifdef CLIPPING_INVERSE
456
+ if (!insideAny) {
457
+ discard;
458
+ }
459
+ #else
460
+ if (insideAny) {
461
+ discard;
462
+ }
463
+ #endif
463
464
  #endif
464
465
 
465
466
  #ifdef HIGHLIGHT_FILL_TILE
@@ -576,11 +577,16 @@ void main()
576
577
  }
577
578
  #endif
578
579
 
580
+ #ifdef HAS_VECTOR_LAYER
581
+ finalColor = vectorPolygonRender(v_textureCoordinates.xy, finalColor);
582
+ finalColor = vectorPolylineRender(v_textureCoordinates.xy, finalColor);
583
+ #endif
584
+
579
585
  #ifdef TRANSLUCENT
580
586
  if (inTranslucencyRectangle())
581
587
  {
582
- vec4 alphaByDistance = gl_FrontFacing ? u_frontFaceAlphaByDistance : u_backFaceAlphaByDistance;
583
- finalColor.a *= interpolateByDistance(alphaByDistance, v_distance);
588
+ vec4 alphaByDistance = gl_FrontFacing ? u_frontFaceAlphaByDistance : u_backFaceAlphaByDistance;
589
+ finalColor.a *= interpolateByDistance(alphaByDistance, v_distance);
584
590
  }
585
591
  #endif
586
592
 
@@ -78,18 +78,12 @@ uniform mat4 u_clippingPlanesMatrix;\n\
78
78
  uniform vec4 u_clippingPlanesEdgeStyle;\n\
79
79
  #endif\n\
80
80
  \n\
81
- #ifdef ENABLE_CLIPPING_POLYGONS\n\
82
- uniform highp sampler2D u_clippingDistance;\n\
83
- in vec2 v_clippingPosition;\n\
84
- flat in int v_regionIndex;\n\
85
- #endif\n\
86
- \n\
87
81
  #if defined(GROUND_ATMOSPHERE) || defined(FOG) && defined(DYNAMIC_ATMOSPHERE_LIGHTING) && (defined(ENABLE_VERTEX_LIGHTING) || defined(ENABLE_DAYNIGHT_SHADING))\n\
88
82
  uniform float u_minimumBrightness;\n\
89
83
  #endif\n\
90
84
  \n\
91
85
  // Based on colorCorrect\n\
92
- // The colorCorrect flag can only be true when tileProvider.hue/saturation/brightnessShift \n\
86
+ // The colorCorrect flag can only be true when tileProvider.hue/saturation/brightnessShift\n\
93
87
  // are nonzero AND when (applyFog || showGroundAtmosphere) in the tile provider\n\
94
88
  // - The tileProvider.hue/saturation/brightnessShift are just passed through\n\
95
89
  // from the Globe hue/saturation/brightness, like atmosphereBrightnessShift\n\
@@ -117,8 +111,8 @@ uniform vec4 u_translucencyRectangle;\n\
117
111
  #endif\n\
118
112
  \n\
119
113
  // Based on showUndergroundColor\n\
120
- // This is set when GlobeSurfaceTileProvider.isUndergroundVisible \n\
121
- // returns true, AND the tileProvider.undergroundColor had a value with \n\
114
+ // This is set when GlobeSurfaceTileProvider.isUndergroundVisible\n\
115
+ // returns true, AND the tileProvider.undergroundColor had a value with\n\
122
116
  // nonzero alpha, and the tileProvider.undergroundColorAlphaByDistance\n\
123
117
  // was in the right range\n\
124
118
  #ifdef UNDERGROUND_COLOR\n\
@@ -458,9 +452,16 @@ void main()\n\
458
452
  #endif\n\
459
453
  \n\
460
454
  #ifdef ENABLE_CLIPPING_POLYGONS\n\
461
- vec2 clippingPosition = v_clippingPosition;\n\
462
- int regionIndex = v_regionIndex;\n\
463
- clipPolygons(u_clippingDistance, CLIPPING_POLYGON_REGIONS_LENGTH, clippingPosition, regionIndex);\n\
455
+ bool insideAny = vectorClip(v_textureCoordinates.xy);\n\
456
+ #ifdef CLIPPING_INVERSE\n\
457
+ if (!insideAny) {\n\
458
+ discard;\n\
459
+ }\n\
460
+ #else\n\
461
+ if (insideAny) {\n\
462
+ discard;\n\
463
+ }\n\
464
+ #endif\n\
464
465
  #endif\n\
465
466
  \n\
466
467
  #ifdef HIGHLIGHT_FILL_TILE\n\
@@ -577,11 +578,16 @@ void main()\n\
577
578
  }\n\
578
579
  #endif\n\
579
580
  \n\
581
+ #ifdef HAS_VECTOR_LAYER\n\
582
+ finalColor = vectorPolygonRender(v_textureCoordinates.xy, finalColor);\n\
583
+ finalColor = vectorPolylineRender(v_textureCoordinates.xy, finalColor);\n\
584
+ #endif\n\
585
+ \n\
580
586
  #ifdef TRANSLUCENT\n\
581
587
  if (inTranslucencyRectangle())\n\
582
588
  {\n\
583
- vec4 alphaByDistance = gl_FrontFacing ? u_frontFaceAlphaByDistance : u_backFaceAlphaByDistance;\n\
584
- finalColor.a *= interpolateByDistance(alphaByDistance, v_distance);\n\
589
+ vec4 alphaByDistance = gl_FrontFacing ? u_frontFaceAlphaByDistance : u_backFaceAlphaByDistance;\n\
590
+ finalColor.a *= interpolateByDistance(alphaByDistance, v_distance);\n\
585
591
  }\n\
586
592
  #endif\n\
587
593
  \n\
@@ -46,12 +46,6 @@ out vec3 v_atmosphereMieColor;
46
46
  out float v_atmosphereOpacity;
47
47
  #endif
48
48
 
49
- #ifdef ENABLE_CLIPPING_POLYGONS
50
- uniform highp sampler2D u_clippingExtents;
51
- out vec2 v_clippingPosition;
52
- flat out int v_regionIndex;
53
- #endif
54
-
55
49
  // These functions are generated at runtime.
56
50
  vec4 getPosition(vec3 position, float height, vec2 textureCoordinates);
57
51
  float get2DYPositionFraction(vec2 textureCoordinates);
@@ -214,32 +208,6 @@ void main()
214
208
  v_normalEC = czm_normal3D * v_normalMC;
215
209
  #endif
216
210
 
217
- #ifdef ENABLE_CLIPPING_POLYGONS
218
- vec2 sphericalLatLong = czm_approximateSphericalCoordinates(position3DWC);
219
- sphericalLatLong.y = czm_branchFreeTernary(sphericalLatLong.y < czm_pi, sphericalLatLong.y, sphericalLatLong.y - czm_twoPi);
220
-
221
- vec2 minDistance = vec2(czm_infinity);
222
- v_clippingPosition = vec2(czm_infinity);
223
- v_regionIndex = -1;
224
-
225
- for (int regionIndex = 0; regionIndex < CLIPPING_POLYGON_REGIONS_LENGTH; regionIndex++) {
226
- vec4 extents = unpackClippingExtents(u_clippingExtents, regionIndex);
227
- vec2 rectUv = (sphericalLatLong.yx - extents.yx) * extents.wz;
228
-
229
- vec2 clamped = clamp(rectUv, vec2(0.0), vec2(1.0));
230
- vec2 distance = abs(rectUv - clamped) * extents.wz;
231
-
232
- float threshold = 0.01;
233
- if (minDistance.x > distance.x || minDistance.y > distance.y) {
234
- minDistance = distance;
235
- v_clippingPosition = rectUv;
236
- if (rectUv.x > threshold && rectUv.y > threshold && rectUv.x < 1.0 - threshold && rectUv.y < 1.0 - threshold) {
237
- v_regionIndex = regionIndex;
238
- }
239
- }
240
- }
241
- #endif
242
-
243
211
  #if defined(FOG) || (defined(GROUND_ATMOSPHERE) && !defined(PER_FRAGMENT_GROUND_ATMOSPHERE))
244
212
 
245
213
  bool dynamicLighting = false;
@@ -47,12 +47,6 @@ out vec3 v_atmosphereMieColor;\n\
47
47
  out float v_atmosphereOpacity;\n\
48
48
  #endif\n\
49
49
  \n\
50
- #ifdef ENABLE_CLIPPING_POLYGONS\n\
51
- uniform highp sampler2D u_clippingExtents;\n\
52
- out vec2 v_clippingPosition;\n\
53
- flat out int v_regionIndex;\n\
54
- #endif\n\
55
- \n\
56
50
  // These functions are generated at runtime.\n\
57
51
  vec4 getPosition(vec3 position, float height, vec2 textureCoordinates);\n\
58
52
  float get2DYPositionFraction(vec2 textureCoordinates);\n\
@@ -215,32 +209,6 @@ void main()\n\
215
209
  v_normalEC = czm_normal3D * v_normalMC;\n\
216
210
  #endif\n\
217
211
  \n\
218
- #ifdef ENABLE_CLIPPING_POLYGONS\n\
219
- vec2 sphericalLatLong = czm_approximateSphericalCoordinates(position3DWC);\n\
220
- sphericalLatLong.y = czm_branchFreeTernary(sphericalLatLong.y < czm_pi, sphericalLatLong.y, sphericalLatLong.y - czm_twoPi);\n\
221
- \n\
222
- vec2 minDistance = vec2(czm_infinity);\n\
223
- v_clippingPosition = vec2(czm_infinity);\n\
224
- v_regionIndex = -1;\n\
225
- \n\
226
- for (int regionIndex = 0; regionIndex < CLIPPING_POLYGON_REGIONS_LENGTH; regionIndex++) {\n\
227
- vec4 extents = unpackClippingExtents(u_clippingExtents, regionIndex);\n\
228
- vec2 rectUv = (sphericalLatLong.yx - extents.yx) * extents.wz;\n\
229
- \n\
230
- vec2 clamped = clamp(rectUv, vec2(0.0), vec2(1.0));\n\
231
- vec2 distance = abs(rectUv - clamped) * extents.wz;\n\
232
- \n\
233
- float threshold = 0.01;\n\
234
- if (minDistance.x > distance.x || minDistance.y > distance.y) {\n\
235
- minDistance = distance;\n\
236
- v_clippingPosition = rectUv;\n\
237
- if (rectUv.x > threshold && rectUv.y > threshold && rectUv.x < 1.0 - threshold && rectUv.y < 1.0 - threshold) {\n\
238
- v_regionIndex = regionIndex;\n\
239
- }\n\
240
- }\n\
241
- }\n\
242
- #endif\n\
243
- \n\
244
212
  #if defined(FOG) || (defined(GROUND_ATMOSPHERE) && !defined(PER_FRAGMENT_GROUND_ATMOSPHERE))\n\
245
213
  \n\
246
214
  bool dynamicLighting = false;\n\
@@ -15,7 +15,7 @@ czm_material czm_getMaterial(czm_materialInput materialInput)
15
15
 
16
16
  vec4 fragColor;
17
17
  fragColor.rgb = max(vec3(glow - 1.0 + color.rgb), color.rgb);
18
- fragColor.a = clamp(0.0, 1.0, glow) * color.a;
18
+ fragColor.a = clamp(glow, 0.0, 1.0) * color.a;
19
19
  fragColor = czm_gammaCorrect(fragColor);
20
20
 
21
21
  material.emission = fragColor.rgb;
@@ -16,7 +16,7 @@ czm_material czm_getMaterial(czm_materialInput materialInput)\n\
16
16
  \n\
17
17
  vec4 fragColor;\n\
18
18
  fragColor.rgb = max(vec3(glow - 1.0 + color.rgb), color.rgb);\n\
19
- fragColor.a = clamp(0.0, 1.0, glow) * color.a;\n\
19
+ fragColor.a = clamp(glow, 0.0, 1.0) * color.a;\n\
20
20
  fragColor = czm_gammaCorrect(fragColor);\n\
21
21
  \n\
22
22
  material.emission = fragColor.rgb;\n\
@@ -463,8 +463,14 @@ void materialStage(inout czm_modelMaterial material, ProcessedAttributes attribu
463
463
  #endif
464
464
 
465
465
  vec4 baseColorWithAlpha = vec4(1.0);
466
- // Regardless of whether we use PBR, set a base color
467
- #ifdef HAS_BASE_COLOR_TEXTURE
466
+ // Regardless of whether we use PBR, set a base color.
467
+ // HAS_BACKGROUND_FILL (from BENTLEY_materials_planar_fill) overrides with
468
+ // the view's background color to create an invisible masking polygon.
469
+ // The background color is in sRGB, so convert to linear to match the
470
+ // material pipeline's expected color space.
471
+ #ifdef HAS_BACKGROUND_FILL
472
+ baseColorWithAlpha = czm_srgbToLinear(czm_backgroundColor);
473
+ #elif defined(HAS_BASE_COLOR_TEXTURE)
468
474
  baseColorWithAlpha = getBaseColorFromTexture();
469
475
  #elif defined(HAS_BASE_COLOR_FACTOR)
470
476
  baseColorWithAlpha = u_baseColorFactor;
@@ -464,8 +464,14 @@ void materialStage(inout czm_modelMaterial material, ProcessedAttributes attribu
464
464
  #endif\n\
465
465
  \n\
466
466
  vec4 baseColorWithAlpha = vec4(1.0);\n\
467
- // Regardless of whether we use PBR, set a base color\n\
468
- #ifdef HAS_BASE_COLOR_TEXTURE\n\
467
+ // Regardless of whether we use PBR, set a base color.\n\
468
+ // HAS_BACKGROUND_FILL (from BENTLEY_materials_planar_fill) overrides with\n\
469
+ // the view's background color to create an invisible masking polygon.\n\
470
+ // The background color is in sRGB, so convert to linear to match the\n\
471
+ // material pipeline's expected color space.\n\
472
+ #ifdef HAS_BACKGROUND_FILL\n\
473
+ baseColorWithAlpha = czm_srgbToLinear(czm_backgroundColor);\n\
474
+ #elif defined(HAS_BASE_COLOR_TEXTURE)\n\
469
475
  baseColorWithAlpha = getBaseColorFromTexture();\n\
470
476
  #elif defined(HAS_BASE_COLOR_FACTOR)\n\
471
477
  baseColorWithAlpha = u_baseColorFactor;\n\
@@ -1,6 +1,18 @@
1
1
  void modelClippingPolygonsStage()
2
2
  {
3
- vec2 clippingPosition = v_clippingPosition;
4
- int regionIndex = v_regionIndex;
5
- czm_clipPolygons(model_clippingDistance, CLIPPING_POLYGON_REGIONS_LENGTH, clippingPosition, regionIndex);
3
+ // The lookup uv was computed per vertex in the vertex stage and
4
+ // interpolated across the primitive, so the fragment shader only samples it.
5
+ bool insideAny = vectorClip(v_clippingUv);
6
+
7
+ #ifdef CLIPPING_INVERSE
8
+ if (!insideAny)
9
+ {
10
+ discard;
11
+ }
12
+ #else
13
+ if (insideAny)
14
+ {
15
+ discard;
16
+ }
17
+ #endif
6
18
  }
@@ -1,8 +1,20 @@
1
1
  //This file is automatically rebuilt by the Cesium build process.
2
2
  export default "void modelClippingPolygonsStage()\n\
3
3
  {\n\
4
- vec2 clippingPosition = v_clippingPosition;\n\
5
- int regionIndex = v_regionIndex;\n\
6
- czm_clipPolygons(model_clippingDistance, CLIPPING_POLYGON_REGIONS_LENGTH, clippingPosition, regionIndex);\n\
4
+ // The lookup uv was computed per vertex in the vertex stage and\n\
5
+ // interpolated across the primitive, so the fragment shader only samples it.\n\
6
+ bool insideAny = vectorClip(v_clippingUv);\n\
7
+ \n\
8
+ #ifdef CLIPPING_INVERSE\n\
9
+ if (!insideAny)\n\
10
+ {\n\
11
+ discard;\n\
12
+ }\n\
13
+ #else\n\
14
+ if (insideAny)\n\
15
+ {\n\
16
+ discard;\n\
17
+ }\n\
18
+ #endif\n\
7
19
  }\n\
8
20
  ";
@@ -1,27 +1,23 @@
1
- void modelClippingPolygonsStage(ProcessedAttributes attributes)
1
+ /**
2
+ * This vertex shader derives each vertex's UV coordinate within the model's clipping rectangle (its ellipsoid footprint).
3
+ * This UV is a normalized vec2, where [0,1] spans the rectangle. The fragment shader then compares each fragment's uv against the clipping polygons,
4
+ * whose positions live in the same uv space. See {@link ModelClippingPolygonsStageFS.glsl}.
5
+ *
6
+ * To get this uv, we need each vertex's geodetic (lon, lat), normalized against the model's rectangle.
7
+ * What makes this complicated is precision: we *cannot* use v_positionWC, because it only has 32-bit precision and is too large to be represented precisely.
8
+ * (Moreover, even representing v_positionWC with hi/lo components to emulate double precision, we could not perform the trig and other ops needed to derive lat/lon.)
9
+ * Instead, we use v_positionEC, and let {@link czm_eyeToCartographicDelta} compute a geodetic delta (long, lat) between the camera and vertex. This delta is a smaller quantity (and gets smaller and more precise as we zoom in).
10
+ * Then, we can combine this delta with the camera's own UV coordinate within the model's rectangle to obtain the vertex's uv coordinate.
11
+ *
12
+ * Ultimately, all this shader does is some geometry to obtain the vertex's relative position within the bounds of the model's geodetic rectangle.
13
+ * The complexity arises from doing so in a way that preserves precision.
14
+ */
15
+ void modelClippingPolygonsStage()
2
16
  {
3
- vec2 sphericalLatLong = czm_approximateSphericalCoordinates(v_positionWC);
4
- sphericalLatLong.y = czm_branchFreeTernary(sphericalLatLong.y < czm_pi, sphericalLatLong.y, sphericalLatLong.y - czm_twoPi);
17
+ // (We don't need the height component)
18
+ vec2 delta = czm_eyeToCartographicDelta(v_positionEC).xy;
5
19
 
6
- vec2 minDistance = vec2(czm_infinity);
7
- v_regionIndex = -1;
8
- v_clippingPosition = vec2(czm_infinity);
9
-
10
- for (int regionIndex = 0; regionIndex < CLIPPING_POLYGON_REGIONS_LENGTH; regionIndex++) {
11
- vec4 extents = czm_unpackClippingExtents(model_clippingExtents, regionIndex);
12
- vec2 rectUv = (sphericalLatLong.yx - extents.yx) * extents.wz;
13
-
14
- vec2 clamped = clamp(rectUv, vec2(0.0), vec2(1.0));
15
- vec2 distance = abs(rectUv - clamped) * extents.wz;
16
-
17
- if (minDistance.x > distance.x || minDistance.y > distance.y) {
18
- minDistance = distance;
19
- v_clippingPosition = rectUv;
20
- }
21
-
22
- float threshold = 0.01;
23
- if (rectUv.x > threshold && rectUv.y > threshold && rectUv.x < 1.0 - threshold && rectUv.y < 1.0 - threshold) {
24
- v_regionIndex = regionIndex;
25
- }
26
- }
20
+ // Express the vertex's position within the model's rectangle as a normalized uv coordinate, by adding the camera's uv and scaling by the rectangle's size.
21
+ // Since the camera's UV is computed on the CPU in double precision, and gets more precise as one zooms in, this ensures good precision on the vertex's uv.
22
+ v_clippingUv = u_clippingCameraUv + delta * u_clippingRectangleInverseSize;
27
23
  }
@@ -1,29 +1,25 @@
1
1
  //This file is automatically rebuilt by the Cesium build process.
2
- export default "void modelClippingPolygonsStage(ProcessedAttributes attributes)\n\
2
+ export default "/**\n\
3
+ * This vertex shader derives each vertex's UV coordinate within the model's clipping rectangle (its ellipsoid footprint).\n\
4
+ * This UV is a normalized vec2, where [0,1] spans the rectangle. The fragment shader then compares each fragment's uv against the clipping polygons,\n\
5
+ * whose positions live in the same uv space. See {@link ModelClippingPolygonsStageFS.glsl}.\n\
6
+ *\n\
7
+ * To get this uv, we need each vertex's geodetic (lon, lat), normalized against the model's rectangle.\n\
8
+ * What makes this complicated is precision: we *cannot* use v_positionWC, because it only has 32-bit precision and is too large to be represented precisely.\n\
9
+ * (Moreover, even representing v_positionWC with hi/lo components to emulate double precision, we could not perform the trig and other ops needed to derive lat/lon.)\n\
10
+ * Instead, we use v_positionEC, and let {@link czm_eyeToCartographicDelta} compute a geodetic delta (long, lat) between the camera and vertex. This delta is a smaller quantity (and gets smaller and more precise as we zoom in).\n\
11
+ * Then, we can combine this delta with the camera's own UV coordinate within the model's rectangle to obtain the vertex's uv coordinate.\n\
12
+ *\n\
13
+ * Ultimately, all this shader does is some geometry to obtain the vertex's relative position within the bounds of the model's geodetic rectangle.\n\
14
+ * The complexity arises from doing so in a way that preserves precision.\n\
15
+ */\n\
16
+ void modelClippingPolygonsStage()\n\
3
17
  {\n\
4
- vec2 sphericalLatLong = czm_approximateSphericalCoordinates(v_positionWC);\n\
5
- sphericalLatLong.y = czm_branchFreeTernary(sphericalLatLong.y < czm_pi, sphericalLatLong.y, sphericalLatLong.y - czm_twoPi);\n\
18
+ // (We don't need the height component)\n\
19
+ vec2 delta = czm_eyeToCartographicDelta(v_positionEC).xy;\n\
6
20
  \n\
7
- vec2 minDistance = vec2(czm_infinity);\n\
8
- v_regionIndex = -1;\n\
9
- v_clippingPosition = vec2(czm_infinity);\n\
10
- \n\
11
- for (int regionIndex = 0; regionIndex < CLIPPING_POLYGON_REGIONS_LENGTH; regionIndex++) {\n\
12
- vec4 extents = czm_unpackClippingExtents(model_clippingExtents, regionIndex);\n\
13
- vec2 rectUv = (sphericalLatLong.yx - extents.yx) * extents.wz;\n\
14
- \n\
15
- vec2 clamped = clamp(rectUv, vec2(0.0), vec2(1.0));\n\
16
- vec2 distance = abs(rectUv - clamped) * extents.wz;\n\
17
- \n\
18
- if (minDistance.x > distance.x || minDistance.y > distance.y) {\n\
19
- minDistance = distance;\n\
20
- v_clippingPosition = rectUv;\n\
21
- }\n\
22
- \n\
23
- float threshold = 0.01;\n\
24
- if (rectUv.x > threshold && rectUv.y > threshold && rectUv.x < 1.0 - threshold && rectUv.y < 1.0 - threshold) {\n\
25
- v_regionIndex = regionIndex;\n\
26
- }\n\
27
- }\n\
21
+ // Express the vertex's position within the model's rectangle as a normalized uv coordinate, by adding the camera's uv and scaling by the rectangle's size.\n\
22
+ // Since the camera's UV is computed on the CPU in double precision, and gets more precise as one zooms in, this ensures good precision on the vertex's uv.\n\
23
+ v_clippingUv = u_clippingCameraUv + delta * u_clippingRectangleInverseSize;\n\
28
24
  }\n\
29
25
  ";
@@ -1,6 +1,29 @@
1
1
 
2
2
  precision highp float;
3
3
 
4
+ // ──────────────────────────────────────────────────────────────────────
5
+ // BENTLEY_materials_planar_fill constants
6
+ //
7
+ // These factors scale gl_FragDepth AFTER czm_writeLogDepth has run, so
8
+ // they are proportional offsets in log-depth space. The corresponding
9
+ // eye-space offset therefore varies with the fragment's distance from
10
+ // the camera (growing with distance). This is the intended behavior: it
11
+ // matches the proportional depth comparison tolerance used by the edge
12
+ // visibility system, so fills and edges stay consistently ordered at all
13
+ // viewing distances.
14
+ // ──────────────────────────────────────────────────────────────────────
15
+ // Depth pull factor for all planar fills: scales log depth by 0.9995,
16
+ // i.e. a 0.05% pull toward the camera in log-depth space.
17
+ const float PLANAR_DEPTH_PULL = 0.9995;
18
+ // Depth push factor for behind fills: scales log depth by 1.0002, i.e. a
19
+ // 0.02% push away from the camera in log-depth space, so behind fills sit
20
+ // behind same-object siblings.
21
+ const float BEHIND_DEPTH_PUSH = 1.0002;
22
+ // Tolerance for comparing feature IDs stored as floats (integer equality).
23
+ const float FEATURE_ID_TOLERANCE = 0.5;
24
+ // Offset added to feature IDs so 0 means "no planar fill" in the texture.
25
+ const float FEATURE_ID_OFFSET = 1.0;
26
+
4
27
  czm_modelMaterial defaultModelMaterial()
5
28
  {
6
29
  czm_modelMaterial material;
@@ -40,6 +63,10 @@ void lineStyleStage()
40
63
 
41
64
  SelectedFeature selectedFeature;
42
65
 
66
+ // Set by edge-pass fragments below; consumed by the snapId expression built
67
+ // in PickingPipelineStage (see Scene#snap).
68
+ bool isEdge = false;
69
+
43
70
  void main()
44
71
  {
45
72
  #if defined(PRIMITIVE_TYPE_POINTS) && defined(HAS_POINT_DIAMETER)
@@ -69,6 +96,26 @@ void main()
69
96
  FeatureIds featureIds;
70
97
  featureIdStage(featureIds, attributes);
71
98
 
99
+ // ──────────────────────────────────────────────────────────────────────
100
+ // BENTLEY_materials_planar_fill: Feature-ID pre-pass output.
101
+ //
102
+ // When HAS_PLANAR_FILL_ID_PASS is defined this command is being rendered
103
+ // into the planar fill ID framebuffer. Non-behind planar geometry writes
104
+ // its feature ID + 1 into the R channel (0 = no feature) and returns.
105
+ // No material / lighting / post-process stages are needed.
106
+ // ──────────────────────────────────────────────────────────────────────
107
+ #ifdef HAS_PLANAR_FILL_ID_PASS
108
+ if (u_isPlanarFillIdPass) {
109
+ float fid = float(featureIds.PLANAR_FILL_FEATURE_ID) + FEATURE_ID_OFFSET;
110
+ out_FragColor = vec4(fid, 0.0, 0.0, 1.0);
111
+ // Still need to write log depth so the depth buffer is correct.
112
+ #ifdef LOG_DEPTH
113
+ czm_writeLogDepth();
114
+ #endif
115
+ return;
116
+ }
117
+ #endif
118
+
72
119
  Metadata metadata;
73
120
  MetadataClass metadataClass;
74
121
  MetadataStatistics metadataStatistics;
@@ -130,6 +177,10 @@ void main()
130
177
  modelClippingPolygonsStage();
131
178
  #endif
132
179
 
180
+ #ifdef HAS_VECTOR_LOOKUP
181
+ modelVectorLookupStage(color);
182
+ #endif
183
+
133
184
  //========================================================================
134
185
  // When not picking metadata START
135
186
  #ifndef METADATA_PICKING_ENABLED
@@ -145,6 +196,12 @@ void main()
145
196
  #ifdef HAS_EDGE_VISIBILITY
146
197
  edgeVisibilityStage(color, featureIds);
147
198
  edgeDetectionStage(color, featureIds);
199
+ // Edge-pass fragments rasterize the edge band itself. Flag them so the
200
+ // snap payload (see Scene#snap) can distinguish edges from surfaces;
201
+ // surface fragments leave isEdge false.
202
+ if (u_isEdgePass) {
203
+ isEdge = true;
204
+ }
148
205
  #endif
149
206
 
150
207
  #endif
@@ -152,5 +209,57 @@ void main()
152
209
  //========================================================================
153
210
 
154
211
  out_FragColor = color;
212
+
213
+ // ──────────────────────────────────────────────────────────────────────
214
+ // Explicit log-depth write.
215
+ //
216
+ // DerivedCommand.getLogDepthShaderProgram auto-wraps only when the raw
217
+ // source does NOT already mention czm_writeLogDepth. We mention it
218
+ // above in the HAS_PLANAR_FILL_ID_PASS block, so we must also handle
219
+ // the normal code path ourselves. The LOG_DEPTH define is injected by
220
+ // that same auto-wrapper, so this block is active exactly when needed.
221
+ // ──────────────────────────────────────────────────────────────────────
222
+ #ifdef LOG_DEPTH
223
+ czm_writeLogDepth();
224
+ #endif
225
+
226
+ // ──────────────────────────────────────────────────────────────────────
227
+ // BENTLEY_materials_planar_fill: Proportional depth adjustment.
228
+ //
229
+ // Per the spec, planar primitives must render in front of non-planar
230
+ // geometry. We use proportional depth scaling (similar to edge visibility)
231
+ // which scales naturally with logarithmic depth at all viewing distances.
232
+ //
233
+ // ──────────────────────────────────────────────────────────────────────
234
+ #ifdef HAS_PLANAR_FILL_DEPTH
235
+ gl_FragDepth *= PLANAR_DEPTH_PULL;
236
+ #endif
237
+
238
+ // ──────────────────────────────────────────────────────────────────────
239
+ // BENTLEY_materials_planar_fill: Behind fill depth adjustment.
240
+ //
241
+ // After the proportional depth pull has been applied, sample the planar
242
+ // fill ID texture. If the pixel already belongs to the same feature,
243
+ // apply a small proportional push so this "behind" fill sits behind its
244
+ // non-behind sibling. If the pixel has no stored feature, the base pull
245
+ // still keeps us in front of non-planar geometry.
246
+ //
247
+ // ──────────────────────────────────────────────────────────────────────
248
+ #ifdef HAS_PLANAR_FILL_BEHIND
249
+ {
250
+ vec2 screenCoord = gl_FragCoord.xy / czm_viewport.zw;
251
+ float storedEncoded = texture(czm_planarFillIdTexture, screenCoord).r;
252
+ float storedFeatureId = storedEncoded - FEATURE_ID_OFFSET;
253
+ float myFeatureId = float(featureIds.PLANAR_FILL_FEATURE_ID);
254
+
255
+ // storedFeatureId < 0 means "no planar fill at this pixel".
256
+ if (storedFeatureId >= 0.0 && abs(storedFeatureId - myFeatureId) < FEATURE_ID_TOLERANCE) {
257
+ // Proportional push: multiply by >1 to move away from camera.
258
+ // Net effect: PLANAR_DEPTH_PULL * BEHIND_DEPTH_PUSH ≈ 0.9997,
259
+ // still in front of non-planar but behind same-feature non-behind fills.
260
+ gl_FragDepth *= BEHIND_DEPTH_PUSH;
261
+ }
262
+ }
263
+ #endif
155
264
  }
156
265