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