@arcgis/core 6.0.0-next.33 → 6.0.0-next.35
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/Basemap.d.ts +2 -2
- package/README.md +2 -2
- package/analysis/ShadowCastAnalysis.d.ts +11 -5
- package/applications/Urban/meshUtils.d.ts +1 -0
- package/applications/Urban/meshUtils.js +1 -1
- package/arcgisGlobal.d.ts +1 -0
- package/assets/esri/core/libs/libtess/libtess-f32.wasm +0 -0
- package/assets/esri/core/libs/libtess/libtess-f64.wasm +0 -0
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/01f55004d64309f8538b.js +1 -0
- package/assets/esri/core/workers/chunks/0202eb8c2b2865f99981.js +1 -0
- package/assets/esri/core/workers/chunks/{67e533748435253aaba6.js → 0284f608d25c654fcc11.js} +1 -1
- package/assets/esri/core/workers/chunks/{f3dc0bc0e00635855a7a.js → 03daf6f235c6edef6268.js} +1 -1
- package/assets/esri/core/workers/chunks/04a1d08c3b5b1dc7628f.js +1 -0
- package/assets/esri/core/workers/chunks/{1eaf8bfdd3765a90ccc2.js → 0523f893870a1546d7d9.js} +1 -1
- package/assets/esri/core/workers/chunks/{1ee4df0fd61440cb5f02.js → 06102715e9a8f218e07c.js} +1 -1
- package/assets/esri/core/workers/chunks/{6029773458ab98600f67.js → 07e5482e1fc69be5de09.js} +1 -1
- package/assets/esri/core/workers/chunks/08140725277de5d2e41a.js +1 -0
- package/assets/esri/core/workers/chunks/{72d20d3957d612f86431.js → 0a508e25ec05363e1f04.js} +1 -1
- package/assets/esri/core/workers/chunks/{2d9a1f23ec6ce90723ac.js → 0d99bfb75dcb9fa29080.js} +1 -1
- package/assets/esri/core/workers/chunks/10ad7b35b6800d40444e.js +1 -0
- package/assets/esri/core/workers/chunks/1132e28aaa5825b10b6e.js +1 -0
- package/assets/esri/core/workers/chunks/{84038dd85005fea413eb.js → 139e753d95cfc9470e74.js} +1 -1
- package/assets/esri/core/workers/chunks/{dd30b02c5978c1c5f511.js → 155861fbd0e5fc2db80c.js} +1 -1
- package/assets/esri/core/workers/chunks/15950c2fb173b62ee0ec.js +1 -0
- package/assets/esri/core/workers/chunks/165ca7a97b611c8f26c4.js +1 -0
- package/assets/esri/core/workers/chunks/{418addce122dbb8897b4.js → 1a614bac5db42c6263f8.js} +1 -1
- package/assets/esri/core/workers/chunks/{0cc7fba402a93e6d2455.js → 1ae0c9345626e70affd3.js} +2 -2
- package/assets/esri/core/workers/chunks/{58c3ae6030def2ed5f31.js → 1b17f5f720f6cf3f6d73.js} +1 -1
- package/assets/esri/core/workers/chunks/{cd355baab983033c3ef0.js → 1ec772eaa63eb6937231.js} +1 -1
- package/assets/esri/core/workers/chunks/{f9dc38761b314d33890f.js → 1f51567f47c2e2fc8a23.js} +1 -1
- package/assets/esri/core/workers/chunks/{5c04835b0b52461183cd.js → 1fd82fcba2758741996a.js} +1 -1
- package/assets/esri/core/workers/chunks/21e1d423ee33f916547e.js +1 -0
- package/assets/esri/core/workers/chunks/2211ff0a1f1ae8100231.js +1 -0
- package/assets/esri/core/workers/chunks/{096b2bf1c0d69d27f20c.js → 247617c0dbae2386ab3b.js} +1 -1
- package/assets/esri/core/workers/chunks/{97ec46605f16333144b7.js → 26ea39dfdf887f357fce.js} +1 -1
- package/assets/esri/core/workers/chunks/{85de980c5b296ec69323.js → 279089a6a3f08022c678.js} +1 -1
- package/assets/esri/core/workers/chunks/29c610ce1c81ebb84a6b.js +1 -0
- package/assets/esri/core/workers/chunks/2b4dd42920d37b1ff0a9.js +2 -0
- package/assets/esri/core/workers/chunks/{8da2a10318f49d0dc73a.js → 31ef7b7074b3e3829763.js} +1 -1
- package/assets/esri/core/workers/chunks/{b657363113f4a37e634b.js → 3223f9fbc76ba9ef8d13.js} +1 -1
- package/assets/esri/core/workers/chunks/322b22a5d54e404bebd5.js +1 -0
- package/assets/esri/core/workers/chunks/{122e75b21699a4e83b15.js → 338d800d4efcc91cead1.js} +1 -1
- package/assets/esri/core/workers/chunks/3537fe95b83a13b156cc.js +1 -0
- package/assets/esri/core/workers/chunks/{360c944c610efa2051fc.js → 379db67f78161ebd5468.js} +2 -2
- package/assets/esri/core/workers/chunks/{f09bc86cd52224febfcb.js → 3b380e64566a6cce59e2.js} +1 -1
- package/assets/esri/core/workers/chunks/{be55771758e4bcef0976.js → 3e406043a374ee17475b.js} +1 -1
- package/assets/esri/core/workers/chunks/{e3b212f8af448ec29eef.js → 3fe4c89acd325d36618d.js} +1 -1
- package/assets/esri/core/workers/chunks/449a2dee17b54946f245.js +1 -0
- package/assets/esri/core/workers/chunks/46c290108a90518ef695.js +1 -0
- package/assets/esri/core/workers/chunks/{a596779eaeec7310671d.js → 478a89317a12e9b4d146.js} +1 -1
- package/assets/esri/core/workers/chunks/{fcc3902d6d9eda6f09f5.js → 48b8b57f559a53c6c513.js} +1 -1
- package/assets/esri/core/workers/chunks/{55a9eaeb152a3abada67.js → 4e5405134d079bdf9b7a.js} +1 -1
- package/assets/esri/core/workers/chunks/4f3e0d583cfa9d1d6727.js +2 -0
- package/assets/esri/core/workers/chunks/{d070fcb73ce274ab80e4.js → 5504ec9bd9ee4d10af07.js} +1 -1
- package/assets/esri/core/workers/chunks/552c36b40e5a5ec117fb.js +1 -0
- package/assets/esri/core/workers/chunks/5622f3faa59434772857.js +1 -0
- package/assets/esri/core/workers/chunks/{bd46a04a9ee4ea9e6ef1.js → 5864bce1498a13ee5b7e.js} +2 -2
- package/assets/esri/core/workers/chunks/59a1b637d2c107504a04.js +1 -0
- package/assets/esri/core/workers/chunks/59a88dd53f8806bbec06.js +1 -0
- package/assets/esri/core/workers/chunks/{f4d91d470ca5fea0bd26.js → 5bd1414220e42cb8ebcf.js} +1 -1
- package/assets/esri/core/workers/chunks/5c2fe67527c9d7b4dba3.js +1 -0
- package/assets/esri/core/workers/chunks/5c3aa8386705c5e40358.js +1 -0
- package/assets/esri/core/workers/chunks/5d781c2c6204cffffd0d.js +1 -0
- package/assets/esri/core/workers/chunks/{176d75e76318bfc25a53.js → 60c8eedd06080edab3e3.js} +1 -1
- package/assets/esri/core/workers/chunks/61d36730564c5ac5edab.js +1 -0
- package/assets/esri/core/workers/chunks/6604272ef6fe85279032.js +1 -0
- package/assets/esri/core/workers/chunks/{29cc6b1705418b1be5d7.js → 687deb918eb48a963c8f.js} +1 -1
- package/assets/esri/core/workers/chunks/{0694c7bcfe71692e2ccf.js → 723df53cfa0189837d01.js} +1 -1
- package/assets/esri/core/workers/chunks/{90c1d10eae7ae71889b0.js → 7400b8c454b47ee4fb3c.js} +1 -1
- package/assets/esri/core/workers/chunks/796c6195b6bf59dcc9bd.js +1 -0
- package/assets/esri/core/workers/chunks/7b45ac83e279fe9516a5.js +1 -0
- package/assets/esri/core/workers/chunks/{2de077c7b971f2c215a6.js → 7ddbde8fdd1cf3c53f50.js} +1 -1
- package/assets/esri/core/workers/chunks/804606b194dc9e71d088.js +1 -0
- package/assets/esri/core/workers/chunks/8102f0bf5707c3be3310.js +1 -0
- package/assets/esri/core/workers/chunks/{1a8d8274df292d65f82e.js → 81bcc495e6eaf2cf7474.js} +1 -1
- package/assets/esri/core/workers/chunks/90360c0bd053d3e3fd77.js +1 -0
- package/assets/esri/core/workers/chunks/{d1d6154b4af1c9cc497b.js → 934e1f2153e6fad6ed23.js} +1 -1
- package/assets/esri/core/workers/chunks/{e096c1d9d53af74d3207.js → 990e96139b5a1dccb061.js} +1 -1
- package/assets/esri/core/workers/chunks/9c3de54513bf8619271c.js +1 -0
- package/assets/esri/core/workers/chunks/{f28b63c1179366dac8a2.js → 9e2c30b67bab5795306e.js} +1 -1
- package/assets/esri/core/workers/chunks/{9184c947cdefe06bf551.js → a18c3cbe505a19d29569.js} +1 -1
- package/assets/esri/core/workers/chunks/aa6ee2aa4ff6e6d41efb.js +1 -0
- package/assets/esri/core/workers/chunks/{3fd5c3cd8457ddc68798.js → aa779896fd9e5c341349.js} +1 -1
- package/assets/esri/core/workers/chunks/ac10c7d2c4829a150037.js +1 -0
- package/assets/esri/core/workers/chunks/{fe6dcb21570395e46ce8.js → afc8a9847f31bb66b13b.js} +1 -1
- package/assets/esri/core/workers/chunks/c5bf19da62a3d31009fe.js +2 -0
- package/assets/esri/core/workers/chunks/{2226c20c38e20713bcb5.js.LICENSE.txt → c5bf19da62a3d31009fe.js.LICENSE.txt} +1 -1
- package/assets/esri/core/workers/chunks/c7adb7b77721c75891f4.js +1 -0
- package/assets/esri/core/workers/chunks/cd55cad81accf51d2989.js +1 -0
- package/assets/esri/core/workers/chunks/{bead830a677690eeb6fb.js → ce8ef2eec290e1df6b2a.js} +1 -1
- package/assets/esri/core/workers/chunks/d3369ffed19f4c264dcd.js +1 -0
- package/assets/esri/core/workers/chunks/d3412518a7b518860fbb.js +1 -0
- package/assets/esri/core/workers/chunks/{3048e74e6246324ce6fc.js → d5916500514a41a4758f.js} +1 -1
- package/assets/esri/core/workers/chunks/{89dc49e784f7ba3b93ea.js → dac69c0047488fdf986d.js} +1 -1
- package/assets/esri/core/workers/chunks/db1f7b2562de495b3401.js +2 -0
- package/assets/esri/core/workers/chunks/dcc782e4bf9e8a8202f9.js +1 -0
- package/assets/esri/core/workers/chunks/dcdf837a452dc0cac582.js +1 -0
- package/assets/esri/core/workers/chunks/e0a37d3bcb9a944e53dd.js +1 -0
- package/assets/esri/core/workers/chunks/{19a4fa965b70fc6f78f6.js → e209cb1f3f14bf576ebe.js} +1 -1
- package/assets/esri/core/workers/chunks/e67ea2f1714e5abeae44.js +1 -0
- package/assets/esri/core/workers/chunks/e8fb2ba7b7a4f0916325.js +1 -0
- package/assets/esri/core/workers/chunks/{636e9c4ac1f9ae98f9d1.js → ea81f9d71b0842a4be26.js} +1 -1
- package/assets/esri/core/workers/chunks/{164c8eeefa8232b2b191.js → eaa0e906b46ae4c84d72.js} +2 -2
- package/assets/esri/core/workers/chunks/efcd38aad9aa667001b2.js +1 -0
- package/assets/esri/core/workers/chunks/{3aafdb905c697bc9b1ad.js → f372f4eb5527238c46f5.js} +1 -1
- package/assets/esri/core/workers/chunks/f497968055af459c5da4.js +1 -0
- package/assets/esri/core/workers/chunks/f7123ba1286f64e13e91.js +1 -0
- package/assets/esri/core/workers/chunks/fcb4707c2e95099b9f30.js +1 -0
- package/assets/esri/libs/lyr3d/lyr3DMain.wasm +0 -0
- package/assets/esri/libs/lyr3d/lyr3DWorker.wasm +0 -0
- package/chunks/BlurEmission.glsl.js +9 -4
- package/chunks/GlobalIllumination.glsl.js +55 -46
- package/chunks/GlobalIlluminationBlur.glsl.js +13 -9
- package/chunks/RibbonLine.glsl.js +90 -88
- package/chunks/Terrain.glsl.js +9 -9
- package/chunks/libtess-f32.js +1 -1
- package/chunks/libtess-f64.js +1 -1
- package/chunks/lyr3DMain.js +1 -1
- package/chunks/lyr3DWorker.js +2 -2
- package/config.d.ts +3 -3
- package/config.js +1 -1
- package/core/has.js +1 -1
- package/core/mathUtils.js +1 -1
- package/core/workers.d.ts +1 -0
- package/form/FormTemplate.d.ts +1 -1
- package/geometry/libtess.js +1 -1
- package/geometry/projection/projectors.js +1 -1
- package/geometry/support/MeshLocalVertexSpace.d.ts +3 -3
- package/geometry/support/aaBoundingRect.js +1 -1
- package/geometry/support/meshUtils/convertMeshVertexSpace.js +1 -1
- package/geometry/support/meshUtils/vertexSpaceConversion.js +1 -1
- package/identity/Credential.d.ts +1 -1
- package/identity/IdentityManager.d.ts +1 -1
- package/identity/IdentityManagerBase.js +1 -1
- package/identity/OAuthInfo.d.ts +1 -1
- package/identity/ServerInfo.d.ts +1 -1
- package/kernel.d.ts +3 -3
- package/kernel.js +1 -1
- package/layers/CSVLayer.js +1 -1
- package/layers/GaussianSplatLayer.js +1 -1
- package/layers/IntegratedMesh3DTilesLayer.js +1 -1
- package/layers/Lyr3DWasmPerSceneView.js +1 -1
- package/layers/VectorTileLayer.d.ts +2 -2
- package/layers/VideoLayer.js +1 -1
- package/layers/VoxelWasmPerSceneView.js +1 -1
- package/layers/WFSLayer.d.ts +8 -4
- package/layers/graphics/controllers/I3SOnDemandController.js +1 -1
- package/layers/graphics/sources/CSVSource.js +1 -1
- package/layers/graphics/sources/GeoJSONSource.js +1 -1
- package/layers/graphics/sources/MemorySource.js +2 -2
- package/layers/graphics/sources/WFSSource.js +1 -1
- package/layers/graphics/sources/geojson/geojson.js +1 -1
- package/layers/graphics/sources/support/ParquetSourceWorker.js +1 -1
- package/layers/graphics/sources/support/QueryTask.js +1 -1
- package/layers/graphics/sources/support/timeQueryUtils.js +2 -0
- package/layers/mixins/APIKeyMixin.d.ts +1 -1
- package/layers/mixins/ArcGISMapService.d.ts +17 -0
- package/layers/mixins/ArcGISMapService.js +1 -1
- package/layers/ogc/types.d.ts +1 -1
- package/layers/ogc/wfsUtils.d.ts +7 -2
- package/layers/ogc/wfsUtils.js +1 -1
- package/layers/ogc/xmlUtils.js +1 -1
- package/layers/support/TelemetryData.d.ts +28 -4
- package/layers/support/TimeInformation.js +1 -1
- package/layers/support/tiles3DUtils.js +1 -1
- package/layers/support/timeInfoUtils.js +2 -0
- package/layers/video/videoUtils.js +1 -1
- package/package.json +4 -4
- package/rest/query/executeAttributeBinsQuery.js +1 -1
- package/rest/query/executeForExtent.js +1 -1
- package/rest/query/executeForTopCount.js +1 -1
- package/rest/query/executeForTopExtents.js +1 -1
- package/rest/query/executeForTopIds.js +1 -1
- package/rest/query/executeTopFeaturesQuery.js +1 -1
- package/rest/query/operations/query.js +1 -1
- package/rest/query/operations/queryAttributeBins.js +1 -1
- package/rest/query/operations/queryTopFeatures.js +1 -1
- package/rest/route.d.ts +1 -1
- package/rest/support/AreasAndLengthsParameters.d.ts +1 -1
- package/rest/support/LengthsParameters.d.ts +1 -1
- package/rest/support/timeUtils.js +1 -1
- package/symbols/TextSymbol.d.ts +0 -1
- package/views/2d/engine/webgl/FeatureDisplayList.js +1 -1
- package/views/2d/engine/webgl/GlyphMosaic.js +1 -1
- package/views/2d/engine/webgl/GlyphWorker.js +1 -1
- package/views/2d/engine/webgl/TextureManager.js +1 -1
- package/views/2d/engine/webgl/materialKeyUtils.js +2 -0
- package/views/2d/engine/webgl/mesh/MeshData.js +1 -1
- package/views/2d/engine/webgl/mesh/templates/shapingUtils.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/animated/AnimatedMarkerMeshWriter.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/animated/AnimatedPolyMeshWriters.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/fill/ComplexOutlineFillMeshWriter.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/fill/GradientFillMeshWriter.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/fill/PatternFillMeshWriter.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/fill/PatternOutlineFillMeshWriter.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/labels/LabelMeshWriter.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/line/GradientStrokeMeshWriter.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/line/TexturedLineMeshWriter.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/markers/MarkerMeshWriter.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/text/TextMeshWriter.js +1 -1
- package/views/2d/layers/VideoLayerView2D.js +1 -1
- package/views/2d/layers/imagery/BaseImageryTileSubView2D.js +1 -1
- package/views/3d/FocusAreasView.js +1 -1
- package/views/3d/analysis/AreaMeasurement/support/AreaMeasurementVisualization.js +1 -1
- package/views/3d/analysis/DirectLineMeasurement/DirectLineMeasurementVisualization.js +1 -1
- package/views/3d/analysis/ElevationProfile/ElevationProfileLineSceneComputation.js +1 -1
- package/views/3d/analysis/LineOfSight/LineOfSightController.js +1 -1
- package/views/3d/analysis/ShadowCast/ShadowCastError.d.ts +40 -0
- package/views/3d/analysis/ShadowCast/ShadowCastError.js +2 -0
- package/views/3d/analysis/ShadowCast/sunlightUtils.js +2 -0
- package/views/3d/analysis/ShadowCastAnalysisView3D.d.ts +16 -1
- package/views/3d/analysis/ShadowCastAnalysisView3D.js +1 -1
- package/views/3d/camera/constraintUtils/surfaceCollision.js +1 -1
- package/views/3d/camera/intersectionUtils.js +1 -1
- package/views/3d/layers/GaussianSplatLayerView3D.js +1 -1
- package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
- package/views/3d/layers/Lyr3DWorker.js +1 -1
- package/views/3d/layers/graphics/ElevationAligners.js +1 -1
- package/views/3d/layers/graphics/Graphics3DCore.js +1 -1
- package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DMeshObject3DGraphicLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DSymbol.js +1 -1
- package/views/3d/layers/graphics/Graphics3DWaterSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DWebStyleSymbol.js +1 -1
- package/views/3d/layers/graphics/MeshFastUpdateProcessor.js +1 -1
- package/views/3d/layers/graphics/polygonUtils.js +1 -1
- package/views/3d/layers/i3s/I3SIndex.js +1 -1
- package/views/3d/layers/i3s/I3SViewportQueries.js +1 -1
- package/views/3d/layers/support/FeatureMemory.js +1 -1
- package/views/3d/layers/support/FeatureTile.js +1 -1
- package/views/3d/navigation/modes/GroundNavigationMode3D.js +1 -1
- package/views/3d/state/Constraints.js +1 -1
- package/views/3d/state/NearFarHeuristic.js +1 -1
- package/views/3d/state/ScreenSizePerspective.js +1 -1
- package/views/3d/state/ViewStateManager.js +1 -1
- package/views/3d/state/helpers/SceneIntersectionHelper.js +1 -1
- package/views/3d/state/utils/groundNavigationUtils.js +1 -1
- package/views/3d/support/RenderCoordsHelper.js +1 -1
- package/views/3d/support/orientedBoundingBox.js +1 -1
- package/views/3d/support/sphereExtentUtils.js +1 -1
- package/views/3d/terrain/TerrainRenderer.js +1 -1
- package/views/3d/terrain/TerrainSurface.js +1 -1
- package/views/3d/terrain/TileRenderer.js +1 -1
- package/views/3d/terrain/tileUtils.js +1 -1
- package/views/3d/webgl-engine/lib/ManagedTexture.js +1 -1
- package/views/3d/webgl-engine/lib/NavigationDepthCache.js +1 -1
- package/views/3d/webgl-engine/lib/Renderer.js +1 -1
- package/views/3d/webgl-engine/lib/RibbonLineVertexInfo.js +1 -1
- package/views/3d/webgl-engine/lib/TextTextureAtlas.js +1 -1
- package/views/3d/webgl-engine/lib/lodRendering/LodRenderer.js +1 -1
- package/views/3d/webgl-engine/materials/RibbonLineMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/WaterMaterial.js +1 -1
- package/views/3d/webgl.d.ts +1 -1
- package/views/SceneView.js +1 -1
- package/views/support/Scheduler.js +1 -1
- package/views/webgl/BufferObject.js +1 -1
- package/views/webgl/FramebufferObject.js +1 -1
- package/widgets/Directions.d.ts +1 -1
- package/widgets/ElevationProfile/ElevationProfileLineView.js +1 -1
- package/widgets/HistogramRangeSlider.d.ts +1 -1
- package/assets/esri/core/workers/chunks/0e445ec3523de9f2dfa2.js +0 -1
- package/assets/esri/core/workers/chunks/0f6c0d42100c21367e5c.js +0 -1
- package/assets/esri/core/workers/chunks/131185d26343a997495e.js +0 -1
- package/assets/esri/core/workers/chunks/176d0a06ebff5a29dedf.js +0 -1
- package/assets/esri/core/workers/chunks/18776a130d96879a68b1.js +0 -1
- package/assets/esri/core/workers/chunks/1a3f71c4d97c36050030.js +0 -1
- package/assets/esri/core/workers/chunks/20a698709c3c11ff2c16.js +0 -1
- package/assets/esri/core/workers/chunks/2226c20c38e20713bcb5.js +0 -2
- package/assets/esri/core/workers/chunks/277263466837e1673f56.js +0 -1
- package/assets/esri/core/workers/chunks/2981e904ab62f3ed80d0.js +0 -2
- package/assets/esri/core/workers/chunks/32cc59e126df8c96a0cf.js +0 -2
- package/assets/esri/core/workers/chunks/379ef56f6b32494832a6.js +0 -1
- package/assets/esri/core/workers/chunks/38d852676677e5697864.js +0 -1
- package/assets/esri/core/workers/chunks/46453ebfee17b5421d9d.js +0 -1
- package/assets/esri/core/workers/chunks/5a9b7eb26f936f03d02e.js +0 -1
- package/assets/esri/core/workers/chunks/5bb6c255bdc8aa9ba23e.js +0 -1
- package/assets/esri/core/workers/chunks/5f07f52bb8b7721f08d3.js +0 -1
- package/assets/esri/core/workers/chunks/654f5441227579d2b6b4.js +0 -1
- package/assets/esri/core/workers/chunks/6b5c073dddd89d06ed80.js +0 -1
- package/assets/esri/core/workers/chunks/6bb191b19ce43a27f205.js +0 -1
- package/assets/esri/core/workers/chunks/6ddc29a144640acb1192.js +0 -1
- package/assets/esri/core/workers/chunks/6ebe73f69ae822053b70.js +0 -1
- package/assets/esri/core/workers/chunks/6f6d1873753a9c6994aa.js +0 -1
- package/assets/esri/core/workers/chunks/7084dd6e10c6c1393e92.js +0 -1
- package/assets/esri/core/workers/chunks/7566321c6a2913f2852b.js +0 -1
- package/assets/esri/core/workers/chunks/7b5cd150a4d0139850be.js +0 -1
- package/assets/esri/core/workers/chunks/7cc9d7a88b64e25fce14.js +0 -1
- package/assets/esri/core/workers/chunks/7e211d8a8ad6c6a7cf3e.js +0 -1
- package/assets/esri/core/workers/chunks/844eedda8f749972f707.js +0 -2
- package/assets/esri/core/workers/chunks/849f446c718e892f39ce.js +0 -1
- package/assets/esri/core/workers/chunks/87177e0f82e8a6ae3189.js +0 -1
- package/assets/esri/core/workers/chunks/9976eaa81085c0d17e14.js +0 -1
- package/assets/esri/core/workers/chunks/a2196a49f89d57a0a1c7.js +0 -1
- package/assets/esri/core/workers/chunks/a504a5e06cb89a620799.js +0 -1
- package/assets/esri/core/workers/chunks/a65951f1d5702cfd996e.js +0 -1
- package/assets/esri/core/workers/chunks/aba259a70bee68d2edb7.js +0 -1
- package/assets/esri/core/workers/chunks/b8fd7c3b36981261378b.js +0 -1
- package/assets/esri/core/workers/chunks/b9cb92858a576eb6aa06.js +0 -1
- package/assets/esri/core/workers/chunks/c33a9635c294c8774977.js +0 -1
- package/assets/esri/core/workers/chunks/c570b90995c65bbb2e14.js +0 -1
- package/assets/esri/core/workers/chunks/c576bef77e34920af188.js +0 -1
- package/assets/esri/core/workers/chunks/cf1ec61eb2ad147bb931.js +0 -1
- package/assets/esri/core/workers/chunks/daae21cf77864f3293ef.js +0 -1
- package/assets/esri/core/workers/chunks/dc2f93453dfa40f623ab.js +0 -1
- package/assets/esri/core/workers/chunks/e81173724e8de8c1e65b.js +0 -1
- package/assets/esri/core/workers/chunks/e83f9abee611c5b80009.js +0 -1
- package/assets/esri/core/workers/chunks/f39c700f3db7db52b522.js +0 -1
- package/assets/esri/core/workers/chunks/f45064066e1ab041a0b2.js +0 -1
- package/assets/esri/core/workers/chunks/ffe49d9e7df081bef4a5.js +0 -1
- package/views/2d/engine/webgl/hashMosaic.js +0 -2
- /package/assets/esri/core/workers/chunks/{0cc7fba402a93e6d2455.js.LICENSE.txt → 1ae0c9345626e70affd3.js.LICENSE.txt} +0 -0
- /package/assets/esri/core/workers/chunks/{844eedda8f749972f707.js.LICENSE.txt → 2b4dd42920d37b1ff0a9.js.LICENSE.txt} +0 -0
- /package/assets/esri/core/workers/chunks/{32cc59e126df8c96a0cf.js.LICENSE.txt → 4f3e0d583cfa9d1d6727.js.LICENSE.txt} +0 -0
- /package/assets/esri/core/workers/chunks/{bd46a04a9ee4ea9e6ef1.js.LICENSE.txt → 5864bce1498a13ee5b7e.js.LICENSE.txt} +0 -0
- /package/assets/esri/core/workers/chunks/{2981e904ab62f3ed80d0.js.LICENSE.txt → db1f7b2562de495b3401.js.LICENSE.txt} +0 -0
- /package/assets/esri/core/workers/chunks/{164c8eeefa8232b2b191.js.LICENSE.txt → eaa0e906b46ae4c84d72.js.LICENSE.txt} +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import{createScreenPointArray as e}from"../../../../core/screenUtils.js";import{crossAndNormalize as t,copy as n,scale as r,subtract as i,add as a,distance as o,normalize as s,cross as c,dot as l,scaleAndAdd as u,length as d}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as f}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as p}from"../../../../geometry/ellipsoidUtils.js";import{fromValues as m}from"../../../../geometry/support/lineSegment.js";import{create as h,fromPositionAndNormal as g,distance as _,projectPoint as v,projectVector as y,intersectLineSegment as b}from"../../../../geometry/support/plane.js";import{create as x}from"../../../../geometry/support/ray.js";import{Sphere as S}from"../../../../geometry/support/sphere.js";import{fromRenderCamera as ee}from"../../webgl.js";import{getVoxelWasm as C}from"../../layers/VoxelWasm.js";import{pickPointAndInitSphere as w,sphereOrPlanePointFromScreenPoint as T,intersectPlaneFromScreenPoint as E,searchAreaSize as D}from"./navigationUtils.js";import{OffsetCorrectionController as O}from"./OffsetCorrectionController.js";import{fromScreenAtEye as te}from"../../support/geometryUtils/ray.js";import ne from"../../webgl/RenderCamera.js";import{Intersector as re}from"../../webgl-engine/lib/Intersector.js";const k=1.5,A={xSpeedMultiplier:k,ySpeedMultiplier:k,maxElevation:1e4,relativeHorizonPadding:.1,minimumHorizonPadding:12},j=f(),M=f(),N=e(),P=f(),F=h(),I=f(),L=f(),R=f(),z=f(),B=f(),ie=f(),V=f(),H=f(),U=f(),W=f(),G=e(),K=x(),q=new S,J=f(),Y=h(),X=f(),ae=f();function oe(e,t){return y(t,e.viewForward,j),a(M,e.eye,j),e.projectToScreen(M,N),N[1]}function se(e,n,d){let f=e.eye;if(o(n.center,f)<n.radius)return s(B,f),c(ie,B,e.viewRight),a(M,f,ie),e.projectToScreen(M,G),G[1];let p=e.up;te(e,d,K);let m=n.radius;if(t(P,p,K.direction),g(f,P,F),_(F,n.center)>m)return null;v(F,n.center,I);let h=o(n.center,I),y=Math.sqrt(m**2-h**2);i(L,f,I),s(R,L),t(z,P,R);let b=l(L,R),x=l(L,z),S=Math.sqrt(b**2+x**2),ee=Math.sqrt(S**2-y**2),C=y**2/S**2,w=y/S**2*ee,T=C*b,E=w*-x,D=C*x,O=w*b,ne=T+E,re=T-E,k=D+O,A=D-O;return a(V,I,u(V,r(V,R,ne),z,k)),a(H,I,u(H,r(H,R,re),z,A)),i(U,V,f),s(U,U),i(W,H,f),s(W,W),l(e.viewForward,U)>=l(e.viewForward,W)?e.projectToScreen(V,G):e.projectToScreen(H,G),G[1]}function ce(e,t,n=!0){return n?e<t:e<=t}function Z(e,t,n=!0){return n?e>t:e>=t}function le(e,t,n){return t?e>n:e<n}function Q(e,t){let n=e.fullHeight/e.pixelRatio,r=Math.max(t,n-t);return Math.max(A.minimumHorizonPadding,A.relativeHorizonPadding*r)}function ue(e,t){return[de(e,t),fe(e,t)]}function de(e,t){let n=e.fullHeight/e.pixelRatio;return Math.min(n,t+Q(e,t))}function fe(e,t){return Math.max(0,t-Q(e,t))}function pe(e,t,n){let r={translation:e,location:t};return n&&(r.normal=n),r}function me(e){let{view:t}=e;return t.viewingMode===`global`?he(e):ge(e)}function he(e){let{view:t,originalScreenPoint:r,horizonY:i,horizonPadding:a,outTranslation:c,outGrabLocation:l,outGrabNormal:u,intersectionOptions:d,depthSearchSize:f}=e,m=t.state.camera,h=pe(c,l,u);q.radius=p(t.spatialReference).radius;let g=w(t,m,r,q.radius,1,d);if(g.scenePickPoint==null)return!1;let _=g.hasGeometryIntersection;n(J,g.scenePickPoint),n(h.location,J);let v=g.sphere;h.normal&&g.normal&&n(h.normal,g.normal);let y=ve(r,i,a,_),b=_?o(J,m.eye):1/0;return y.wasAdjusted&&ye({view:t,screenAdjustment:y,intersector:$(t),fallbackCheck:(e,t,n)=>{let r=T(v,m,e,t);return r&&n&&s(n,t),r},output:h,intersectionOptions:d}),xe({view:t,screenPoint:y.adjustedScreenPoint,camera:m,initialDistance:b,depthSearchSize:f??D,output:h}),!0}function ge(e){let{view:t,originalScreenPoint:r,horizonY:i,horizonPadding:a,outTranslation:c,outGrabLocation:l,outGrabNormal:d,intersectionOptions:f,depthSearchSize:p}=e,m=t.sceneIntersectionHelper,h=t.state.camera,_=$(t),v=pe(c,l,d);m.intersectIntersectorScreen(r,_,f);let y=_.results.min.getIntersectionPoint(J),b=y?o(J,h.eye):1/0;y&&(n(v.location,J),v.normal&&n(v.normal,_.results.min.normal)),t.renderCoordsHelper.worldUpAtPosition(h.eye,B),u(X,h.eye,B,-h.relativeElevation),g(X,B,Y);let x=ve(r,i,a,y);return x.wasAdjusted&&ye({view:t,screenAdjustment:x,intersector:_,fallbackCheck:(e,t,n)=>{let r=E(Y,h,e,t);return r&&n&&s(n,B),r},output:v,intersectionOptions:f}),xe({view:t,screenPoint:x.adjustedScreenPoint,camera:h,initialDistance:b,depthSearchSize:p??D,output:v}),!0}function _e(e,t,n,r){return!r&&ce(e,t)||r&&le(e,!1,n[0])?n[0]:!r&&Z(e,t,!1)?n[1]:null}function ve(t,n,r,i){let a=_e(t[1],n,r,i);return{originalScreenPoint:t,adjustedScreenPoint:e(t[0],a??t[1]),horizonY:n,horizonPadding:r,wasAdjusted:a!==null}}function $(e){let t=new re(e.state.viewingMode);return t.options.selectionMode=!0,t.options.store=0,t.options.hud=!1,t.options.normalRequired=!0,t}function ye(e){let{view:t,screenAdjustment:r,fallbackCheck:i,intersector:a,output:o,intersectionOptions:s}=e,c=t.sceneIntersectionHelper;c.intersectIntersectorScreen(r.adjustedScreenPoint,a,{...s,requiresGroundFeedback:!0});let l=a.results.min.getIntersectionPoint(o.location);if(l){o.normal&&n(o.normal,a.results.min.normal);return}let u=be(r);c.intersectIntersectorScreen(u,a,{...s,requiresGroundFeedback:!0}),l=a.results.min.getIntersectionPoint(o.location),l?o.normal&&n(o.normal,a.results.min.normal):(l=i(r.adjustedScreenPoint,o.location,o.normal),l||i(u,o.location,o.normal))}function be(t){let{originalScreenPoint:n,adjustedScreenPoint:r,horizonY:i,horizonPadding:a}=t,o=Z(r[1],i)?Math.min(a[1],n[1]):Math.max(a[0],n[1]);return e(r[0],o)}function xe(e){Se(e),Ce(e)}function Se(e){let{view:t,camera:r,output:a}=e,{offset:o}=t.navigation.mode;if(!o)return;let{translation:s,location:c}=a;t.renderCoordsHelper.worldUpAtPosition(r.eye,B),u(X,r.eye,B,-o),g(X,B,F),b(F,m(r.eye,i(j,c,r.eye)),X)&&(n(c,X),i(s,c,r.eye))}function Ce(e){let{view:t,screenPoint:n,camera:o,initialDistance:c,depthSearchSize:l,output:u}=e,f=l>0?t.stage.renderView.getMinimalDepthForArea(C(t),n[0],n[1],o,l):null;i(u.translation,u.location,o.eye);let p=Math.min(d(u.translation),c);f&&f<=p&&(p=f),s(u.translation,u.translation),r(u.translation,u.translation,p),a(u.location,u.translation,o.eye)}async function we(e,t,n,r,i){let a=new ne().copyFrom(e.state.camera);if(Te({view:e,camera:a,forwardDirection:t,forwardDistance:n,detectCollisions:!0}))return r?r.smoothlyCorrectGroundElevation({camera:a,deltaTime:i}):new O(e).immediatelyCorrectGroundElevation({camera:a,correctionLimit:100}),e.goTo(ee(e,a),{duration:500,liftOffDisabled:!0})}function Te(e){let{view:s,camera:c,forwardDirection:l,forwardDistance:u,detectCollisions:f}=e,p=s.navigation.mode;if(p.type!==`ground`)return!1;s.renderCoordsHelper.worldUpAtPosition(c.eye,B);let m=s.sceneIntersectionHelper,h=$(s),g=t(j,B,t(j,l,B));n(K.origin,c.eye),r(K.direction,g,u);let _=m.intersectRay(K,h,J,{include:p.include,exclude:p.exclude}),v=i(ae,c.center,c.eye);return!f||!_||o(J,c.eye)>Math.abs(u)?c.eye=a(j,K.origin,K.direction):(i(j,J,c.eye),d(j)>2&&(Ee(j,j,.25,2),c.eye=a(j,c.eye,j))),c.center=a(j,c.eye,v),!0}function Ee(e,t,n,i){let a=d(e),o=Math.min(n,Math.max(a-i,0)/a);r(t,e,o)}export{Te as advanceGroundNavigationCamera,Q as computeHorizonPadding,ue as computeHorizonPaddingLimits,me as findGroundNavigationGrabLocation,oe as findPlaneHorizonY,se as findSphereHorizonY,we as groundNavigationAdvance,A as groundNavigationConstants,ce as isAboveHorizon,Z as isBelowHorizon,Ee as shortenTranslation,le as shouldClampScreenY};
|
|
2
|
+
import{createScreenPointArray as e}from"../../../../core/screenUtils.js";import{crossAndNormalize as t,copy as n,scale as r,subtract as i,add as a,distance as o,normalize as s,cross as c,dot as l,scaleAndAdd as u,length as d}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as f}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as p}from"../../../../geometry/ellipsoidUtils.js";import{fromValues as m}from"../../../../geometry/support/lineSegment.js";import{create as h,fromPositionAndNormal as g,distance as _,projectPoint as v,projectVector as y,intersectLineSegment as b}from"../../../../geometry/support/plane.js";import{create as x}from"../../../../geometry/support/ray.js";import{Sphere as S}from"../../../../geometry/support/sphere.js";import{fromRenderCamera as ee}from"../../webgl.js";import{getVoxelWasm as C}from"../../layers/VoxelWasm.js";import{pickPointAndInitSphere as w,sphereOrPlanePointFromScreenPoint as T,intersectPlaneFromScreenPoint as E,searchAreaSize as D}from"./navigationUtils.js";import{OffsetCorrectionController as O}from"./OffsetCorrectionController.js";import{fromScreenAtEye as te}from"../../support/geometryUtils/ray.js";import ne from"../../webgl/RenderCamera.js";import{Intersector as re}from"../../webgl-engine/lib/Intersector.js";const k=1.5,A={xSpeedMultiplier:k,ySpeedMultiplier:k,maxElevation:1e4,relativeHorizonPadding:.1,minimumHorizonPadding:12,i3sNodeDownwardCheckDistanceInMeters:5},j=f(),M=f(),N=e(),P=f(),F=h(),I=f(),L=f(),R=f(),z=f(),B=f(),ie=f(),V=f(),H=f(),U=f(),W=f(),G=e(),K=x(),q=new S,J=f(),Y=h(),X=f(),ae=f();function oe(e,t){return y(t,e.viewForward,j),a(M,e.eye,j),e.projectToScreen(M,N),N[1]}function se(e,n,d){let f=e.eye;if(o(n.center,f)<n.radius)return s(B,f),c(ie,B,e.viewRight),a(M,f,ie),e.projectToScreen(M,G),G[1];let p=e.up;te(e,d,K);let m=n.radius;if(t(P,p,K.direction),g(f,P,F),_(F,n.center)>m)return null;v(F,n.center,I);let h=o(n.center,I),y=Math.sqrt(m**2-h**2);i(L,f,I),s(R,L),t(z,P,R);let b=l(L,R),x=l(L,z),S=Math.sqrt(b**2+x**2),ee=Math.sqrt(S**2-y**2),C=y**2/S**2,w=y/S**2*ee,T=C*b,E=w*-x,D=C*x,O=w*b,ne=T+E,re=T-E,k=D+O,A=D-O;return a(V,I,u(V,r(V,R,ne),z,k)),a(H,I,u(H,r(H,R,re),z,A)),i(U,V,f),s(U,U),i(W,H,f),s(W,W),l(e.viewForward,U)>=l(e.viewForward,W)?e.projectToScreen(V,G):e.projectToScreen(H,G),G[1]}function ce(e,t,n=!0){return n?e<t:e<=t}function Z(e,t,n=!0){return n?e>t:e>=t}function le(e,t,n){return t?e>n:e<n}function Q(e,t){let n=e.fullHeight/e.pixelRatio,r=Math.max(t,n-t);return Math.max(A.minimumHorizonPadding,A.relativeHorizonPadding*r)}function ue(e,t){return[de(e,t),fe(e,t)]}function de(e,t){let n=e.fullHeight/e.pixelRatio;return Math.min(n,t+Q(e,t))}function fe(e,t){return Math.max(0,t-Q(e,t))}function pe(e,t,n){let r={translation:e,location:t};return n&&(r.normal=n),r}function me(e){let{view:t}=e;return t.viewingMode===`global`?he(e):ge(e)}function he(e){let{view:t,originalScreenPoint:r,horizonY:i,horizonPadding:a,outTranslation:c,outGrabLocation:l,outGrabNormal:u,intersectionOptions:d,depthSearchSize:f}=e,m=t.state.camera,h=pe(c,l,u);q.radius=p(t.spatialReference).radius;let g=w(t,m,r,q.radius,1,d);if(g.scenePickPoint==null)return!1;let _=g.hasGeometryIntersection;n(J,g.scenePickPoint),n(h.location,J);let v=g.sphere;h.normal&&g.normal&&n(h.normal,g.normal);let y=ve(r,i,a,_),b=_?o(J,m.eye):1/0;return y.wasAdjusted&&ye({view:t,screenAdjustment:y,intersector:$(t),fallbackCheck:(e,t,n)=>{let r=T(v,m,e,t);return r&&n&&s(n,t),r},output:h,intersectionOptions:d}),xe({view:t,screenPoint:y.adjustedScreenPoint,camera:m,initialDistance:b,depthSearchSize:f??D,output:h}),!0}function ge(e){let{view:t,originalScreenPoint:r,horizonY:i,horizonPadding:a,outTranslation:c,outGrabLocation:l,outGrabNormal:d,intersectionOptions:f,depthSearchSize:p}=e,m=t.sceneIntersectionHelper,h=t.state.camera,_=$(t),v=pe(c,l,d);m.intersectIntersectorScreen(r,_,f);let y=_.results.min.getIntersectionPoint(J),b=y?o(J,h.eye):1/0;y&&(n(v.location,J),v.normal&&n(v.normal,_.results.min.normal)),t.renderCoordsHelper.worldUpAtPosition(h.eye,B),u(X,h.eye,B,-h.relativeElevation),g(X,B,Y);let x=ve(r,i,a,y);return x.wasAdjusted&&ye({view:t,screenAdjustment:x,intersector:_,fallbackCheck:(e,t,n)=>{let r=E(Y,h,e,t);return r&&n&&s(n,B),r},output:v,intersectionOptions:f}),xe({view:t,screenPoint:x.adjustedScreenPoint,camera:h,initialDistance:b,depthSearchSize:p??D,output:v}),!0}function _e(e,t,n,r){return!r&&ce(e,t)||r&&le(e,!1,n[0])?n[0]:!r&&Z(e,t,!1)?n[1]:null}function ve(t,n,r,i){let a=_e(t[1],n,r,i);return{originalScreenPoint:t,adjustedScreenPoint:e(t[0],a??t[1]),horizonY:n,horizonPadding:r,wasAdjusted:a!==null}}function $(e){let t=new re(e.state.viewingMode);return t.options.selectionMode=!0,t.options.store=0,t.options.hud=!1,t.options.normalRequired=!0,t}function ye(e){let{view:t,screenAdjustment:r,fallbackCheck:i,intersector:a,output:o,intersectionOptions:s}=e,c=t.sceneIntersectionHelper;c.intersectIntersectorScreen(r.adjustedScreenPoint,a,{...s,requiresGroundFeedback:!0});let l=a.results.min.getIntersectionPoint(o.location);if(l){o.normal&&n(o.normal,a.results.min.normal);return}let u=be(r);c.intersectIntersectorScreen(u,a,{...s,requiresGroundFeedback:!0}),l=a.results.min.getIntersectionPoint(o.location),l?o.normal&&n(o.normal,a.results.min.normal):(l=i(r.adjustedScreenPoint,o.location,o.normal),l||i(u,o.location,o.normal))}function be(t){let{originalScreenPoint:n,adjustedScreenPoint:r,horizonY:i,horizonPadding:a}=t,o=Z(r[1],i)?Math.min(a[1],n[1]):Math.max(a[0],n[1]);return e(r[0],o)}function xe(e){Se(e),Ce(e)}function Se(e){let{view:t,camera:r,output:a}=e,{offset:o}=t.navigation.mode;if(!o)return;let{translation:s,location:c}=a;t.renderCoordsHelper.worldUpAtPosition(r.eye,B),u(X,r.eye,B,-o),g(X,B,F),b(F,m(r.eye,i(j,c,r.eye)),X)&&(n(c,X),i(s,c,r.eye))}function Ce(e){let{view:t,screenPoint:n,camera:o,initialDistance:c,depthSearchSize:l,output:u}=e,f=l>0?t.stage.renderView.getMinimalDepthForArea(C(t),n[0],n[1],o,l):null;i(u.translation,u.location,o.eye);let p=Math.min(d(u.translation),c);f&&f<=p&&(p=f),s(u.translation,u.translation),r(u.translation,u.translation,p),a(u.location,u.translation,o.eye)}async function we(e,t,n,r,i){let a=new ne().copyFrom(e.state.camera);if(Te({view:e,camera:a,forwardDirection:t,forwardDistance:n,detectCollisions:!0}))return r?r.smoothlyCorrectGroundElevation({camera:a,deltaTime:i}):new O(e).immediatelyCorrectGroundElevation({camera:a,correctionLimit:100}),e.goTo(ee(e,a),{duration:500,liftOffDisabled:!0})}function Te(e){let{view:s,camera:c,forwardDirection:l,forwardDistance:u,detectCollisions:f}=e,p=s.navigation.mode;if(p.type!==`ground`)return!1;s.renderCoordsHelper.worldUpAtPosition(c.eye,B);let m=s.sceneIntersectionHelper,h=$(s),g=t(j,B,t(j,l,B));n(K.origin,c.eye),r(K.direction,g,u);let _=m.intersectRay(K,h,J,{include:p.include,exclude:p.exclude}),v=i(ae,c.center,c.eye);return!f||!_||o(J,c.eye)>Math.abs(u)?c.eye=a(j,K.origin,K.direction):(i(j,J,c.eye),d(j)>2&&(Ee(j,j,.25,2),c.eye=a(j,c.eye,j))),c.center=a(j,c.eye,v),!0}function Ee(e,t,n,i){let a=d(e),o=Math.min(n,Math.max(a-i,0)/a);r(t,e,o)}export{Te as advanceGroundNavigationCamera,Q as computeHorizonPadding,ue as computeHorizonPaddingLimits,me as findGroundNavigationGrabLocation,oe as findPlaneHorizonY,se as findSphereHorizonY,we as groundNavigationAdvance,A as groundNavigationConstants,ce as isAboveHorizon,Z as isBelowHorizon,Ee as shortenTranslation,le as shouldClampScreenY};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import{
|
|
2
|
+
import{__decorate as e}from"tslib";import t from"../../../core/Accessor.js";import{rad2deg as n}from"../../../core/mathUtils.js";import{watch as r,syncAndInitial as i}from"../../../core/reactiveUtils.js";import{getMetersPerCartesianUnitForSR as a,getMetersPerUnitForSR as o}from"../../../core/units.js";import{property as s}from"../../../core/accessorSupport/decorators/property.js";import{subclass as c}from"../../../core/accessorSupport/decorators/subclass.js";import{set as l}from"../../../core/libs/gl-matrix-2/math/mat4.js";import{set as u,copy as d}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{create as f}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as p}from"../../../geometry/ellipsoidUtils.js";import m from"../../../geometry/SpatialReference.js";import{getSphericalPCPF as h}from"../../../geometry/spatialReferenceEllipsoidUtils.js";import{projectPointToVector as g}from"../../../geometry/projection/projectPointToVector.js";import{projectVectorToPoint as _}from"../../../geometry/projection/projectVectorToPoint.js";import{projectVectorToVector as v}from"../../../geometry/projection/projectVectorToVector.js";import{create as y}from"../../../geometry/support/aaBoundingRect.js";import{GlobalCoordinateSystem as b}from"../../../geometry/support/GlobalCoordinateSystem.js";import{LocalCoordinateSystem as x}from"../../../geometry/support/LocalCoordinateSystem.js";import{intersectRay as S}from"../../../geometry/support/plane.js";import{angleAroundAxis as C}from"../../../geometry/support/vector.js";import{sv3d as w}from"../../../geometry/support/vectorStacks.js";import{isDehydratedPoint as T}from"../../../layers/graphics/dehydratedFeatureUtils.js";let E=class extends t{constructor(e){super(e),this.viewingMode=2,this.spatialReference=m.WebMercator,this._coordinateSystem=new x,this._tmpCoordinateSystem=this._coordinateSystem.clone(),this.addHandles(r(()=>[this.viewingMode,this.spatialReference],([e,t])=>this._setup(e,t),i))}_setup(e,t){this._coordinateSystem=e===2?new x:new b(t),this._tmpCoordinateSystem=this._coordinateSystem.clone()}set extent(e){this._coordinateSystem.setExtent(e)}get extent(){return this._coordinateSystem.getExtent(y())}getAltitude(e){return this._coordinateSystem.altitudeAt(e)}setAltitude(e,t,n=e){return this._coordinateSystem.setAltitudeAt(n,t,e),e}setAltitudeOfTransformation(e,t){u(D,t[12],t[13],t[14]),this._coordinateSystem.setAltitudeAt(D,e,D),t[12]=D[0],t[13]=D[1],t[14]=D[2]}worldUpAtPosition(e,t){return this._coordinateSystem.worldBasisAtPosition(e,2,t),t}worldBasisAtPosition(e,t,n){return this._coordinateSystem.worldBasisAtPosition(e,t,n),n}basisMatrixAtPosition(e,t){let n=this.worldBasisAtPosition(e,0,w.get()),r=this.worldBasisAtPosition(e,1,w.get()),i=this.worldBasisAtPosition(e,2,w.get());return l(t,n[0],n[1],n[2],0,r[0],r[1],r[2],0,i[0],i[1],i[2],0,0,0,0,1),t}headingAtPosition(e,t){let r=this.worldUpAtPosition(e,w.get()),i=this.worldBasisAtPosition(e,1,w.get()),a=C(t,i,r);return n(a)}intersectManifoldClosestSilhouette(e,t,n){return this._coordinateSystem.elevate(t,this._tmpCoordinateSystem),this._tmpCoordinateSystem.intersectRayClosestSilhouette(e,n),n}intersectManifold(e,t,n){this._coordinateSystem.elevate(t,this._tmpCoordinateSystem);let r=w.get();return this._tmpCoordinateSystem.intersectRay(e,r)?d(n,r):null}intersectInfiniteManifold(e,t,n){if(this.viewingMode===1)return this.intersectManifold(e,t,n);this._coordinateSystem.elevate(t,this._tmpCoordinateSystem);let r=this._tmpCoordinateSystem.plane,i=w.get();return S(r,e,i)?d(n,i):null}toRenderCoords(e,t,n){return T(e)?g(e,t,this.spatialReference):v(e,t,n,this.spatialReference)}fromRenderCoords(e,t,n=null){return T(t)?(n!=null&&(t.spatialReference=n),_(e,this.spatialReference,t)?t:null):v(e,this.spatialReference,t,n)?t:null}static renderUnitScaleFactor(e,t){return a(e)/a(t)}get unitInMeters(){return o(this.spatialReference)}get referenceEllipsoid(){return p(this.spatialReference)}get sphericalPCPF(){return h(this.spatialReference)}};e([s()],E.prototype,`unitInMeters`,null),e([s()],E.prototype,`referenceEllipsoid`,null),e([s()],E.prototype,`sphericalPCPF`,null),e([s()],E.prototype,`viewingMode`,void 0),e([s()],E.prototype,`spatialReference`,void 0),E=e([c(`esri.views.3d.support.RenderCoordsHelper`)],E);const D=f();export{E as RenderCoordsHelper};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import{fromQuat as e,scale as t}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{create as n}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{create as r}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{set as i,conjugate as a,multiply as o}from"../../../core/libs/gl-matrix-2/math/quat.js";import{IDENTITY as s,create as c}from"../../../core/libs/gl-matrix-2/factories/quatf64.js";import{transformQuat as l,dot as u,cross as d,len as f,scale as p,set as m,transformMat3 as h,add as g,transformQuatValues as _,sub as v,abs as y,max as b,min as x,length as S,scaleAndAdd as C,sign as w,multiply as T}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{ZEROS as E,freeze as D,create as O,UNIT_Z as k}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{transformMat4 as A}from"../../../core/libs/gl-matrix-2/math/vec4.js";import{create as ee}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{getReferenceEllipsoid as te}from"../../../geometry/ellipsoidUtils.js";import{getSphericalPCPF as j}from"../../../geometry/spatialReferenceEllipsoidUtils.js";import{computeTranslationToOriginAndRotation as ne}from"../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{projectBuffer as M}from"../../../geometry/projection/projectBuffer.js";import{getProjector as N}from"../../../geometry/projection/projectors.js";import{getNormal as P}from"../../../geometry/support/plane.js";import{isPlateCarree as re}from"../../../geometry/support/spatialReferenceUtils.js";import{computeOBB as ie}from"./dito.js";import{Vertices as ae}from"../webgl-engine/lib/Attribute.js";class F{constructor(e=E,t=me,n=s){this._data=[e[0],e[1],e[2],t[0],t[1],t[2],n[0],n[1],n[2],n[3]]}clone(){return F.fromData(this._data)}invalidate(){this._data[3]=-1}get isValid(){return this._data[3]>=0}static fromData(e){let t=new F;return t._copyFromData(e),t}static fromJSON(e){return new F(e.center,e.halfSize,e.quaternion)}copy(e){this._copyFromData(e.data)}_copyFromData(e){for(let t=0;t<10;++t)this._data[t]=e[t]}get centerX(){return this._data[0]}get centerY(){return this._data[1]}get centerZ(){return this._data[2]}getCenter(e){return e[0]=this._data[0],e[1]=this._data[1],e[2]=this._data[2],e}setCenter(e){this._data[0]=e[0],this._data[1]=e[1],this._data[2]=e[2]}setCenterFromValues(e,t,n){this._data[0]=e,this._data[1]=t,this._data[2]=n}get halfSizeX(){return this._data[3]}get halfSizeY(){return this._data[4]}get halfSizeZ(){return this._data[5]}getHalfSize(e){return e[0]=this._data[3],e[1]=this._data[4],e[2]=this._data[5],e}setHalfSize(e){this._data[3]=e[0],this._data[4]=e[1],this._data[5]=e[2]}setHalfSizeFromValues(e,t,n){this._data[3]=e,this._data[4]=t,this._data[5]=n}getQuaternion(e){return e[0]=this._data[6],e[1]=this._data[7],e[2]=this._data[8],e[3]=this._data[9],e}getQuaternionConjugate(e){return e[0]=-this._data[6],e[1]=-this._data[7],e[2]=-this._data[8],e[3]=this._data[9],e}setQuaternion(e){this._data[6]=e[0],this._data[7]=e[1],this._data[8]=e[2],this._data[9]=e[3]}get data(){return this._data}getCorners(e){let t=this._data,n=i(I,t[6],t[7],t[8],t[9]);for(let r=0;r<8;++r){let i=e[r];i[0]=(r&1?-1:1)*t[3],i[1]=(r&2?-1:1)*t[4],i[2]=(r&4?-1:1)*t[5],l(i,i,n),i[0]+=t[0],i[1]+=t[1],i[2]+=t[2]}return e}getAxes(e){let t=this._data,n=i(I,t[6],t[7],t[8],t[9]);return l(e[0],[1,0,0],n),l(e[1],[0,1,0],n),l(e[2],[0,0,1],n),e}intersectsFrustum(e){let{centerX:t,centerY:n,centerZ:r}=this,i=e.planes;for(let e of i){let i=P(e),a=this.projectedRadius(i);if(t*i[0]+n*i[1]+r*i[2]+e[3]-a>0)return!1}let a=this.getAxes(X),o=e.points,s=this.getHalfSize(K);for(let e=0;e<3;++e){let i=a[e],c=-i[0]*t-i[1]*n-i[2]*r,l=s[e],d=!0,f=!0;for(let e of o){let t=u(e,i)+c;d&&=t>l,f&&=t<-l}if(d||f)return!1}if(this.getCorners(Y).some(t=>e.intersectsPoint(t)))return!0;let c=ve;for(let e=0;e<3;++e){let i=a[e];c[e]=i[0]*t+i[1]*n+i[2]*r}let l=e=>{for(let t=0;t<3;++t){let n=a[t],r=s[t],i=n[0]*e[0]+n[1]*e[1]+n[2]*e[2]-c[t];if(i>r||i<-r)return!1}return!0};if(e.points.some(e=>l(e)))return!0;let m=e.lines,h=_e;for(let e=0;e<8;++e){let i=m[e].direction;for(let e of a){d(h,i,e);let a=f(h);if(a>0)p(h,h,1/a);else continue;let s=this.projectedRadius(h),c=h[0]*t+h[1]*n+h[2]*r,l=c-s,m=c+s,g=!1,_=!1,v=!0;for(let e of o){let t=u(h,e);if(t>m){if(_){v=!1;break}g=!0}else if(t<l){if(g){v=!1;break}_=!0}else{v=!1;break}}if(v)return!1}}return!0}intersectsFrustumConservativeApproximation(e){return this.intersectPlane(e[0])<=0&&this.intersectPlane(e[1])<=0&&this.intersectPlane(e[2])<=0&&this.intersectPlane(e[3])<=0&&this.intersectPlane(e[4])<=0&&this.intersectPlane(e[5])<=0}intersectsFrustumConservativeApproximationWithMargin(e,t){return this.signedDistanceRangePlane(e[0]).min<=t&&this.signedDistanceRangePlane(e[1]).min<=t&&this.signedDistanceRangePlane(e[2]).min<=t&&this.signedDistanceRangePlane(e[3]).min<=t&&this.signedDistanceRangePlane(e[4]).min<=t&&this.signedDistanceRangePlane(e[5]).min<=t}get radius(){let e=this._data[3],t=this._data[4],n=this._data[5];return Math.sqrt(e*e+t*t+n*n)}intersectsPoint(e){let t=this.getAxes(X),n=this.getHalfSize(K),r=this.getCenter(G);for(let i=0;i<3;++i){let a=t[i],o=n[i],s=u(a,e)-u(a,r);if(s>o||s<-o)return!1}return!0}intersectSphere(e){let{center:t,radius:n}=e,r=this._data,i=r[3],a=r[4],o=r[5],s=i+a+o+n,c=r[0]-t[0];if(Math.abs(c)>s)return!1;let l=r[1]-t[1];if(Math.abs(l)>s)return!1;let u=r[2]-t[2];if(Math.abs(u)>s)return!1;let d=-r[6],f=-r[7],p=-r[8],m=r[9],h=f*u-p*l,g=p*c-d*u,_=d*l-f*c,v=f*_-p*g,y=p*h-d*_,b=d*g-f*h,x=m*2,S=Math.abs(c+h*x+v*2),C=Math.abs(l+g*x+y*2),w=Math.abs(u+_*x+b*2),T=Math.min(S,i),E=Math.min(C,a),D=Math.min(w,o),O=S-T,k=C-E,A=w-D;return O*O+k*k+A*A<=n*n}intersectSphereWithMBS(e,t=this.radius){let n=this._data,{center:r,radius:i}=e,a=t+i,o=n[0]-r[0];if(o>a)return!1;let s=n[1]-r[1];if(s>a)return!1;let c=n[2]-r[2];if(c>a||o*o+s*s+c*c>a*a)return!1;let l=-n[6],u=-n[7],d=-n[8],f=n[9],p=u*c-d*s,m=d*o-l*c,h=l*s-u*o,g=u*h-d*m,_=d*p-l*h,v=l*m-u*p,y=f*2,b=Math.abs(o+p*y+g*2),x=Math.abs(s+m*y+_*2),S=Math.abs(c+h*y+v*2),C=Math.min(b,n[3]),w=Math.min(x,n[4]),T=Math.min(S,n[5]),E=b-C,D=x-w,O=S-T;return E*E+D*D+O*O<i*i}intersectPlane(e){let t=e[0]*this._data[0]+e[1]*this._data[1]+e[2]*this._data[2]+e[3],n=this.projectedRadius(P(e));return t>n?1:t<-n?-1:0}intersectRay(e,t,n=0){let r=this._data,i=I;i[0]=-r[6],i[1]=-r[7],i[2]=-r[8],i[3]=r[9],R[0]=e[0]-r[0],R[1]=e[1]-r[1],R[2]=e[2]-r[2];let a=l(R,R,I),o=l(se,t,I),s=-1/0,c=1/0,u=this.getHalfSize(K);for(let e=0;e<3;e++){let t=a[e],r=o[e],i=u[e]+n;if(Math.abs(r)>1e-6){let e=(i-t)/r,n=(-i-t)/r;s=Math.max(s,Math.min(e,n)),c=Math.min(c,Math.max(e,n))}else if(t>i||t<-i)return!1}return s<=c}projectedArea(n,r,i,o){let s=this.getQuaternion(L);a(I,s),R[0]=n[0]-this._data[0],R[1]=n[1]-this._data[1],R[2]=n[2]-this._data[2],l(R,R,I);let c=this.getHalfSize(K),u=R[0]<-c[0]?-1:+(R[0]>c[0]),d=R[1]<-c[1]?-1:+(R[1]>c[1]),f=R[2]<-c[2]?-1:+(R[2]>c[2]),p=Math.abs(u)+Math.abs(d)+Math.abs(f);if(p===0)return 1/0;let _=p===1?4:6,v=(u+d*3+f*9+13)*6;e(q,s),t(q,q,c);let y=this.getCenter(G);for(let e=0;e<_;e++){let t=ce[v+e];m(R,((t&1)<<1)-1,(t&2)-1,((t&4)>>1)-1),h(R,R,q),g(z,y,R),z[3]=1,A(z,z,r);let n=1/Math.max(1e-6,z[3]);V[e*2]=z[0]*n,V[e*2+1]=z[1]*n}let b=_*2-2,x=V[0]*(V[3]-V[b+1])+V[b]*(V[1]-V[b-1]);for(let e=2;e<b;e+=2)x+=V[e]*(V[e+3]-V[e-1]);return Math.abs(x)*i*o*.125}projectedRadius(e){let t=this._data;return _(R,e,-t[6],-t[7],-t[8],t[9]),Math.abs(R[0]*t[3])+Math.abs(R[1]*t[4])+Math.abs(R[2]*t[5])}signedDistancePlane(e,t){let n=this._data,r=e[0]*n[0]+e[1]*n[1]+e[2]*n[2]+t,i=this.projectedRadius(e);return r>i?r-i:r<-i?r+i:0}signedDistanceRangePlane(e){let t=e[0]*this._data[0]+e[1]*this._data[1]+e[2]*this._data[2]+e[3],n=this.projectedRadius(P(e));return{min:t-n,max:t+n}}toAaBoundingBox(t){let n=this.getQuaternion(L),r=e(q,n),i=this._data[3]*Math.abs(r[0])+this._data[4]*Math.abs(r[3])+this._data[5]*Math.abs(r[6]),a=this._data[3]*Math.abs(r[1])+this._data[4]*Math.abs(r[4])+this._data[5]*Math.abs(r[7]),o=this._data[3]*Math.abs(r[2])+this._data[4]*Math.abs(r[5])+this._data[5]*Math.abs(r[8]);t[0]=this._data[0]-i,t[1]=this._data[1]-a,t[2]=this._data[2]-o,t[3]=this._data[0]+i,t[4]=this._data[1]+a,t[5]=this._data[2]+o}transform(e,t,n,r=0,i=j(n),a=j(t),o=N(t,a)){if(n===i)t.isGeographic?pe(this,e,t,r,a):fe(this,e,t,r,a,o);else if(t.isGeographic&&(n.isWebMercator||re(n)))ue(t,this,n,e,r);else if(t.isWebMercator&&re(n))de(t,this,n,e,r);else{let i=this.getCenter(G);i[2]+=r,M(i,t,0,i,n,0),e.setCenter(i),this!==e&&(e.setQuaternion(this.getQuaternion(L)),e.setHalfSize(this.getHalfSize(K)))}}}const I=c(),L=c(),oe=c(),R=O(),se=O(),z=ee();function B(e,t=new F){return ie(e,t),t}const V=[.1,.2,.3,.4,.5,.6,.7,.8,.9,1,1.1,1.2],ce=(()=>{let e=new Int8Array(162),t=0,n=n=>{for(let r=0;r<n.length;r++)e[t+r]=n[r];t+=6};return n([6,2,3,1,5,4]),n([0,2,3,1,5,4]),n([0,2,3,7,5,4]),n([0,1,3,2,6,4]),n([0,1,3,2,0,0]),n([0,1,5,7,3,2]),n([0,1,3,7,6,4]),n([0,1,3,7,6,2]),n([0,1,5,7,6,2]),n([0,1,5,4,6,2]),n([0,1,5,4,0,0]),n([0,1,3,7,5,4]),n([0,2,6,4,0,0]),n([0,0,0,0,0,0]),n([1,3,7,5,0,0]),n([2,3,7,6,4,0]),n([2,3,7,6,0,0]),n([2,3,1,5,7,6]),n([0,1,5,7,6,2]),n([0,1,5,7,6,4]),n([0,1,3,7,6,4]),n([4,5,7,6,2,0]),n([4,5,7,6,0,0]),n([4,5,1,3,7,6]),n([0,2,3,7,5,4]),n([6,2,3,7,5,4]),n([6,2,3,1,5,4]),e})();function le(e,t,n,r,i){let o=e.getQuaternion(L);i.setQuaternion(o),a(I,o);let s=e.getCenter(G),c=e.getHalfSize(K);if(r===1){l(Z,s,I),y(Q,Z),x($,Q,c),v($,Q,$);let r=S($);g($,Q,c);let a=S($);if(r<n)i.setCenter(s),m(Z,n,n,n),i.setHalfSize(g(Z,c,Z));else{let o=a>0?1+t/a:1,s=r>0?1+n/r:1,u=(s+o)/2,d=(s-o)/2;p($,Q,d),i.setHalfSize(C($,$,c,u)),p($,Q,u),C($,$,c,d),w(Z,Z),T(Z,$,Z);let f=e.getQuaternion(oe);i.setCenter(l(Z,Z,f))}}else{i.setCenter(C(Z,s,k,(n+t)/2));let e=l(Z,k,I);y(e,e),i.setHalfSize(C(Q,c,e,(n-t)/2))}return i}function ue(e,t,n,r,i){let a=t.getCenter(G);a[2]+=i;let o=j(n);M(a,e,0,a,o,0),H(o,t,a,n,r)}function de(e,t,n,r,i){let a=t.getCenter(G);a[2]+=i,H(e,t,a,n,r)}function H(t,n,r,i,a){let o=n.getQuaternion(L),s=e(q,o),c=n.getHalfSize(K);for(let e=0;e<8;++e){for(let t=0;t<3;++t)W[t]=c[t]*(e&1<<t?-1:1);for(let t=0;t<3;++t){let n=r[t];for(let e=0;e<3;++e)n+=W[e]*s[3*e+t];U[e*3+t]=n}}M(U,t,0,U,i,0,8),B(ge,a)}function fe(e,t,n,r,i=j(n),s=N(n,i)){e.getCorners(Y);let c=e.getCenter(G);c[2]+=r,ne(n,c,J,i),t.setCenterFromValues(J[12],J[13],J[14]);let u=Math.sqrt(1+J[0]+J[5]+J[10])*2;I[0]=(J[6]-J[9])/u,I[1]=(J[8]-J[2])/u,I[2]=(J[1]-J[4])/u,I[3]=u*.25;let d=e.getQuaternion(L);t.setQuaternion(o(I,I,d)),a(I,I),m(Q,0,0,0);let f=t.getCenter(G);for(let e of Y)e[2]+=r,s(e,0,e,0),v(Z,e,f),l(Z,Z,I),y(Z,Z),b(Q,Q,Z);t.setHalfSize(Q)}function pe(e,t,n,r,i=j(n)){let o=te(n),s=1+Math.max(0,r)/(o.radius+e.centerZ);e.getCenter(W),W[2]+=r,M(W,n,0,W,i,0),t.setCenter(W);let c=e.getQuaternion(L);t.setQuaternion(c),a(I,c),m(Z,0,0,1),l(Z,Z,I);let u=e.getHalfSize(K);m(Z,u[0]*Math.abs(Z[0]),u[1]*Math.abs(Z[1]),u[2]*Math.abs(Z[2])),p(Z,Z,o.inverseFlattening),g(Z,u,Z),t.setHalfSize(p(Z,Z,s))}const me=D(-1,-1,-1);function he(e){return Array.from(e)}const U=Array(24),ge=new ae(U,3),W=O(),G=O(),K=O(),q=n(),J=r(),Y=[[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0]],X=[O(),O(),O()],Z=O(),Q=O(),$=O(),_e=O(),ve=[0,0,0];export{F as Obb,B as compute,le as computeOffsetObb,he as ensurePackedObbData};
|
|
2
|
+
import{fromQuat as e,scale as t}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{create as n}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{create as r}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{set as i,conjugate as a,multiply as o}from"../../../core/libs/gl-matrix-2/math/quat.js";import{IDENTITY as s,create as c}from"../../../core/libs/gl-matrix-2/factories/quatf64.js";import{transformQuat as l,dot as u,cross as d,len as f,scale as p,distance as m,direction as h,set as g,transformMat3 as _,add as v,transformQuatValues as y,sub as b,abs as x,max as S,min as C,length as w,scaleAndAdd as T,sign as E,multiply as D}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{ZEROS as O,freeze as k,create as A,UNIT_Z as ee}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{transformMat4 as te}from"../../../core/libs/gl-matrix-2/math/vec4.js";import{create as ne}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{getReferenceEllipsoid as re}from"../../../geometry/ellipsoidUtils.js";import{getSphericalPCPF as j}from"../../../geometry/spatialReferenceEllipsoidUtils.js";import{computeTranslationToOriginAndRotation as ie}from"../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{projectBuffer as M}from"../../../geometry/projection/projectBuffer.js";import{getProjector as ae}from"../../../geometry/projection/projectors.js";import{getNormal as N}from"../../../geometry/support/plane.js";import{isPlateCarree as P}from"../../../geometry/support/spatialReferenceUtils.js";import{computeOBB as oe}from"./dito.js";import{Vertices as se}from"../webgl-engine/lib/Attribute.js";class F{constructor(e=O,t=_e,n=s){this._data=[e[0],e[1],e[2],t[0],t[1],t[2],n[0],n[1],n[2],n[3]]}clone(){return F.fromData(this._data)}invalidate(){this._data[3]=-1}get isValid(){return this._data[3]>=0}static fromData(e){let t=new F;return t._copyFromData(e),t}static fromJSON(e){return new F(e.center,e.halfSize,e.quaternion)}copy(e){this._copyFromData(e.data)}_copyFromData(e){for(let t=0;t<10;++t)this._data[t]=e[t]}get centerX(){return this._data[0]}get centerY(){return this._data[1]}get centerZ(){return this._data[2]}getCenter(e){return e[0]=this._data[0],e[1]=this._data[1],e[2]=this._data[2],e}setCenter(e){this._data[0]=e[0],this._data[1]=e[1],this._data[2]=e[2]}setCenterFromValues(e,t,n){this._data[0]=e,this._data[1]=t,this._data[2]=n}get halfSizeX(){return this._data[3]}get halfSizeY(){return this._data[4]}get halfSizeZ(){return this._data[5]}getHalfSize(e){return e[0]=this._data[3],e[1]=this._data[4],e[2]=this._data[5],e}setHalfSize(e){this._data[3]=e[0],this._data[4]=e[1],this._data[5]=e[2]}setHalfSizeFromValues(e,t,n){this._data[3]=e,this._data[4]=t,this._data[5]=n}getQuaternion(e){return e[0]=this._data[6],e[1]=this._data[7],e[2]=this._data[8],e[3]=this._data[9],e}getQuaternionConjugate(e){return e[0]=-this._data[6],e[1]=-this._data[7],e[2]=-this._data[8],e[3]=this._data[9],e}setQuaternion(e){this._data[6]=e[0],this._data[7]=e[1],this._data[8]=e[2],this._data[9]=e[3]}get data(){return this._data}getCorners(e){let t=this._data,n=i(I,t[6],t[7],t[8],t[9]);for(let r=0;r<8;++r){let i=e[r];i[0]=(r&1?-1:1)*t[3],i[1]=(r&2?-1:1)*t[4],i[2]=(r&4?-1:1)*t[5],l(i,i,n),i[0]+=t[0],i[1]+=t[1],i[2]+=t[2]}return e}getAxes(e){let t=this._data,n=i(I,t[6],t[7],t[8],t[9]);return l(e[0],[1,0,0],n),l(e[1],[0,1,0],n),l(e[2],[0,0,1],n),e}intersectsFrustum(e){let{centerX:t,centerY:n,centerZ:r}=this,i=e.planes;for(let e of i){let i=N(e),a=this.projectedRadius(i);if(t*i[0]+n*i[1]+r*i[2]+e[3]-a>0)return!1}let a=this.getAxes(X),o=e.points,s=this.getHalfSize(K);for(let e=0;e<3;++e){let i=a[e],c=-i[0]*t-i[1]*n-i[2]*r,l=s[e],d=!0,f=!0;for(let e of o){let t=u(e,i)+c;d&&=t>l,f&&=t<-l}if(d||f)return!1}if(this.getCorners(Y).some(t=>e.intersectsPoint(t)))return!0;let c=xe;for(let e=0;e<3;++e){let i=a[e];c[e]=i[0]*t+i[1]*n+i[2]*r}let l=e=>{for(let t=0;t<3;++t){let n=a[t],r=s[t],i=n[0]*e[0]+n[1]*e[1]+n[2]*e[2]-c[t];if(i>r||i<-r)return!1}return!0};if(e.points.some(e=>l(e)))return!0;let m=e.lines,h=be;for(let e=0;e<8;++e){let i=m[e].direction;for(let e of a){d(h,i,e);let a=f(h);if(a>0)p(h,h,1/a);else continue;let s=this.projectedRadius(h),c=h[0]*t+h[1]*n+h[2]*r,l=c-s,m=c+s,g=!1,_=!1,v=!0;for(let e of o){let t=u(h,e);if(t>m){if(_){v=!1;break}g=!0}else if(t<l){if(g){v=!1;break}_=!0}else{v=!1;break}}if(v)return!1}}return!0}intersectsFrustumConservativeApproximation(e){return this.intersectPlane(e[0])<=0&&this.intersectPlane(e[1])<=0&&this.intersectPlane(e[2])<=0&&this.intersectPlane(e[3])<=0&&this.intersectPlane(e[4])<=0&&this.intersectPlane(e[5])<=0}intersectsFrustumConservativeApproximationWithMargin(e,t){return this.signedDistanceRangePlane(e[0]).min<=t&&this.signedDistanceRangePlane(e[1]).min<=t&&this.signedDistanceRangePlane(e[2]).min<=t&&this.signedDistanceRangePlane(e[3]).min<=t&&this.signedDistanceRangePlane(e[4]).min<=t&&this.signedDistanceRangePlane(e[5]).min<=t}get radius(){let e=this._data[3],t=this._data[4],n=this._data[5];return Math.sqrt(e*e+t*t+n*n)}intersectsPoint(e){let t=this.getAxes(X),n=this.getHalfSize(K),r=this.getCenter(G);for(let i=0;i<3;++i){let a=t[i],o=n[i],s=u(a,e)-u(a,r);if(s>o||s<-o)return!1}return!0}intersectSphere(e){let{center:t,radius:n}=e,r=this._data,i=r[3],a=r[4],o=r[5],s=i+a+o+n,c=r[0]-t[0];if(Math.abs(c)>s)return!1;let l=r[1]-t[1];if(Math.abs(l)>s)return!1;let u=r[2]-t[2];if(Math.abs(u)>s)return!1;let d=-r[6],f=-r[7],p=-r[8],m=r[9],h=f*u-p*l,g=p*c-d*u,_=d*l-f*c,v=f*_-p*g,y=p*h-d*_,b=d*g-f*h,x=m*2,S=Math.abs(c+h*x+v*2),C=Math.abs(l+g*x+y*2),w=Math.abs(u+_*x+b*2),T=Math.min(S,i),E=Math.min(C,a),D=Math.min(w,o),O=S-T,k=C-E,A=w-D;return O*O+k*k+A*A<=n*n}intersectSphereWithMBS(e,t=this.radius){let n=this._data,{center:r,radius:i}=e,a=t+i,o=n[0]-r[0];if(o>a)return!1;let s=n[1]-r[1];if(s>a)return!1;let c=n[2]-r[2];if(c>a||o*o+s*s+c*c>a*a)return!1;let l=-n[6],u=-n[7],d=-n[8],f=n[9],p=u*c-d*s,m=d*o-l*c,h=l*s-u*o,g=u*h-d*m,_=d*p-l*h,v=l*m-u*p,y=f*2,b=Math.abs(o+p*y+g*2),x=Math.abs(s+m*y+_*2),S=Math.abs(c+h*y+v*2),C=Math.min(b,n[3]),w=Math.min(x,n[4]),T=Math.min(S,n[5]),E=b-C,D=x-w,O=S-T;return E*E+D*D+O*O<i*i}intersectPlane(e){let t=e[0]*this._data[0]+e[1]*this._data[1]+e[2]*this._data[2]+e[3],n=this.projectedRadius(N(e));return t>n?1:t<-n?-1:0}intersectRay(e,t,n=0,r=-1/0,i=1/0){let a=this._data,o=I;o[0]=-a[6],o[1]=-a[7],o[2]=-a[8],o[3]=a[9],R[0]=e[0]-a[0],R[1]=e[1]-a[1],R[2]=e[2]-a[2];let s=l(R,R,I),c=l(le,t,I),u=r,d=i,f=this.getHalfSize(K);for(let e=0;e<3;e++){let t=s[e],r=c[e],i=f[e]+n;if(Math.abs(r)>1e-6){let e=(i-t)/r,n=(-i-t)/r;u=Math.max(u,Math.min(e,n)),d=Math.min(d,Math.max(e,n))}else if(t>i||t<-i)return!1}return u<=d}intersectSegment(e,t,n=0){let r=m(e,t);return h(H,e,t),this.intersectRay(e,H,n,0,r)}projectedArea(n,r,i,o){let s=this.getQuaternion(L);a(I,s),R[0]=n[0]-this._data[0],R[1]=n[1]-this._data[1],R[2]=n[2]-this._data[2],l(R,R,I);let c=this.getHalfSize(K),u=R[0]<-c[0]?-1:+(R[0]>c[0]),d=R[1]<-c[1]?-1:+(R[1]>c[1]),f=R[2]<-c[2]?-1:+(R[2]>c[2]),p=Math.abs(u)+Math.abs(d)+Math.abs(f);if(p===0)return 1/0;let m=p===1?4:6,h=(u+d*3+f*9+13)*6;e(q,s),t(q,q,c);let y=this.getCenter(G);for(let e=0;e<m;e++){let t=de[h+e];g(R,((t&1)<<1)-1,(t&2)-1,((t&4)>>1)-1),_(R,R,q),v(z,y,R),z[3]=1,te(z,z,r);let n=1/Math.max(1e-6,z[3]);B[e*2]=z[0]*n,B[e*2+1]=z[1]*n}let b=m*2-2,x=B[0]*(B[3]-B[b+1])+B[b]*(B[1]-B[b-1]);for(let e=2;e<b;e+=2)x+=B[e]*(B[e+3]-B[e-1]);return Math.abs(x)*i*o*.125}projectedRadius(e){let t=this._data;return y(R,e,-t[6],-t[7],-t[8],t[9]),Math.abs(R[0]*t[3])+Math.abs(R[1]*t[4])+Math.abs(R[2]*t[5])}signedDistancePlane(e,t){let n=this._data,r=e[0]*n[0]+e[1]*n[1]+e[2]*n[2]+t,i=this.projectedRadius(e);return r>i?r-i:r<-i?r+i:0}signedDistanceRangePlane(e){let t=e[0]*this._data[0]+e[1]*this._data[1]+e[2]*this._data[2]+e[3],n=this.projectedRadius(N(e));return{min:t-n,max:t+n}}toAaBoundingBox(t){let n=this.getQuaternion(L),r=e(q,n),i=this._data[3]*Math.abs(r[0])+this._data[4]*Math.abs(r[3])+this._data[5]*Math.abs(r[6]),a=this._data[3]*Math.abs(r[1])+this._data[4]*Math.abs(r[4])+this._data[5]*Math.abs(r[7]),o=this._data[3]*Math.abs(r[2])+this._data[4]*Math.abs(r[5])+this._data[5]*Math.abs(r[8]);t[0]=this._data[0]-i,t[1]=this._data[1]-a,t[2]=this._data[2]-o,t[3]=this._data[0]+i,t[4]=this._data[1]+a,t[5]=this._data[2]+o}transform(e,t,n,r=0,i=j(n),a=j(t),o=ae(t,a)){if(n===i)t.isGeographic?ge(this,e,t,r,a):he(this,e,t,r,a,o);else if(t.isGeographic&&(n.isWebMercator||P(n)))pe(t,this,n,e,r);else if(t.isWebMercator&&P(n))me(t,this,n,e,r);else{let i=this.getCenter(G);i[2]+=r,M(i,t,0,i,n,0),e.setCenter(i),this!==e&&(e.setQuaternion(this.getQuaternion(L)),e.setHalfSize(this.getHalfSize(K)))}}}const I=c(),L=c(),ce=c(),R=A(),le=A(),z=ne();function ue(e,t=new F){return oe(e,t),t}const B=[.1,.2,.3,.4,.5,.6,.7,.8,.9,1,1.1,1.2],de=(()=>{let e=new Int8Array(162),t=0,n=n=>{for(let r=0;r<n.length;r++)e[t+r]=n[r];t+=6};return n([6,2,3,1,5,4]),n([0,2,3,1,5,4]),n([0,2,3,7,5,4]),n([0,1,3,2,6,4]),n([0,1,3,2,0,0]),n([0,1,5,7,3,2]),n([0,1,3,7,6,4]),n([0,1,3,7,6,2]),n([0,1,5,7,6,2]),n([0,1,5,4,6,2]),n([0,1,5,4,0,0]),n([0,1,3,7,5,4]),n([0,2,6,4,0,0]),n([0,0,0,0,0,0]),n([1,3,7,5,0,0]),n([2,3,7,6,4,0]),n([2,3,7,6,0,0]),n([2,3,1,5,7,6]),n([0,1,5,7,6,2]),n([0,1,5,7,6,4]),n([0,1,3,7,6,4]),n([4,5,7,6,2,0]),n([4,5,7,6,0,0]),n([4,5,1,3,7,6]),n([0,2,3,7,5,4]),n([6,2,3,7,5,4]),n([6,2,3,1,5,4]),e})();function fe(e,t,n,r,i){let o=e.getQuaternion(L);i.setQuaternion(o),a(I,o);let s=e.getCenter(G),c=e.getHalfSize(K);if(r===1){l(Z,s,I),x(Q,Z),C($,Q,c),b($,Q,$);let r=w($);v($,Q,c);let a=w($);if(r<n)i.setCenter(s),g(Z,n,n,n),i.setHalfSize(v(Z,c,Z));else{let o=a>0?1+t/a:1,s=r>0?1+n/r:1,u=(s+o)/2,d=(s-o)/2;p($,Q,d),i.setHalfSize(T($,$,c,u)),p($,Q,u),T($,$,c,d),E(Z,Z),D(Z,$,Z);let f=e.getQuaternion(ce);i.setCenter(l(Z,Z,f))}}else{i.setCenter(T(Z,s,ee,(n+t)/2));let e=l(Z,ee,I);x(e,e),i.setHalfSize(T(Q,c,e,(n-t)/2))}return i}function pe(e,t,n,r,i){let a=t.getCenter(G);a[2]+=i;let o=j(n);M(a,e,0,a,o,0),V(o,t,a,n,r)}function me(e,t,n,r,i){let a=t.getCenter(G);a[2]+=i,V(e,t,a,n,r)}function V(t,n,r,i,a){let o=n.getQuaternion(L),s=e(q,o),c=n.getHalfSize(K);for(let e=0;e<8;++e){for(let t=0;t<3;++t)W[t]=c[t]*(e&1<<t?-1:1);for(let t=0;t<3;++t){let n=r[t];for(let e=0;e<3;++e)n+=W[e]*s[3*e+t];U[e*3+t]=n}}M(U,t,0,U,i,0,8),ue(ye,a)}function he(e,t,n,r,i=j(n),s=ae(n,i)){e.getCorners(Y);let c=e.getCenter(G);c[2]+=r,ie(n,c,J,i),t.setCenterFromValues(J[12],J[13],J[14]);let u=Math.sqrt(1+J[0]+J[5]+J[10])*2;I[0]=(J[6]-J[9])/u,I[1]=(J[8]-J[2])/u,I[2]=(J[1]-J[4])/u,I[3]=u*.25;let d=e.getQuaternion(L);t.setQuaternion(o(I,I,d)),a(I,I),g(Q,0,0,0);let f=t.getCenter(G);for(let e of Y)e[2]+=r,s(e,0,e,0),b(Z,e,f),l(Z,Z,I),x(Z,Z),S(Q,Q,Z);t.setHalfSize(Q)}function ge(e,t,n,r,i=j(n)){let o=re(n),s=1+Math.max(0,r)/(o.radius+e.centerZ);e.getCenter(W),W[2]+=r,M(W,n,0,W,i,0),t.setCenter(W);let c=e.getQuaternion(L);t.setQuaternion(c),a(I,c),g(Z,0,0,1),l(Z,Z,I);let u=e.getHalfSize(K);g(Z,u[0]*Math.abs(Z[0]),u[1]*Math.abs(Z[1]),u[2]*Math.abs(Z[2])),p(Z,Z,o.inverseFlattening),v(Z,u,Z),t.setHalfSize(p(Z,Z,s))}const _e=k(-1,-1,-1);function ve(e){return Array.from(e)}const H=A(),U=Array(24),ye=new se(U,3),W=A(),G=A(),K=A(),q=n(),J=r(),Y=[[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0]],X=[A(),A(),A()],Z=A(),Q=A(),$=A(),be=A(),xe=[0,0,0];export{F as Obb,ue as compute,fe as computeOffsetObb,ve as ensurePackedObbData};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import{length as e}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{intersects as
|
|
2
|
+
import{length as e}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{getSphericalPCPF as t}from"../../../geometry/spatialReferenceEllipsoidUtils.js";import{projectBoundingSphere as n}from"../../../geometry/projection/projectBoundingSphere.js";import{intersects as r,fromValues as i}from"../../../geometry/support/aaBoundingRect.js";import{earth as a}from"../../../geometry/support/Ellipsoid.js";import{getInfo as o}from"../../../geometry/support/spatialReferenceUtils.js";import{Sphere as s}from"../../../geometry/support/sphere.js";function c(e,t,n){if(r(e,t))return!0;let i=o(n);if(i==null||e[1]>t[3]||e[3]<t[1])return!1;let a=i.valid[1]-i.valid[0];return Math.ceil((e[0]-t[2])/a)<=Math.floor((e[2]-t[0])/a)}function l(t,n){let r=e(t.center);if(!t.isValid||r<=t.radius)return i(-1/0,-1/0,1/0,1/0,n);let a=Math.asin(t.radius/r),o=Math.atan2(t.center[2],Math.hypot(t.center[0],t.center[1])),s=o*180/Math.PI;return f(Math.atan2(t.center[1],t.center[0])*180/Math.PI,s,o,a,n)}function u(e,t,n=a.radius){let r=n+e.center[2],o=e.radius;if(!e.isValid||r<=o||Math.abs(e.center[1])>90)return i(-1/0,-1/0,1/0,1/0,t);let s=e.center[0]-360*Math.floor((e.center[0]+180)/360),c=e.center[1];return f(s,c,c*Math.PI/180,Math.asin(o/r),t)}function d(e,r,i,a){return n(e,r,p,t(a))?(l(p,i),!0):!1}function f(e,t,n,r,a){let o=r*180/Math.PI;if(Math.abs(n)+r>=Math.PI/2)return i(-180,Math.max(-90,t-o),180,Math.min(90,t+o),a);let s=Math.asin(Math.min(1,Math.sin(r)/Math.cos(n)))*180/Math.PI;return i(e-s,t-o,e+s,t+o,a)}const p=new s;export{u as geographicMbsToGeographicExtent,c as intersectsGeographicExtent,d as mbsToGeographicExtent,l as sphereToGeographicExtent};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import has from"../../../core/has.js";import{disposeMaybe as t}from"../../../core/maybe.js";import{MemCachePool as n}from"../../../core/MemCachePool.js";import r from"../../../core/ObjectPool.js";import{watch as i,sync as a}from"../../../core/reactiveUtils.js";import{property as o,subclass as s}from"../../../core/accessorSupport/decorators.js";import{subtract as c,set as l,dot as u}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{ZEROS as d,fromValues as f,create as p}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as m,ZEROS as h}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{create as g,set as _}from"../../../geometry/support/aaBoundingBox.js";import{BufferViewVec3f as v}from"../../../geometry/support/buffer/BufferView.js";import{overlayRenderOccludedFlag as y}from"./OverlayRenderer.js";import{PatchRenderData as b}from"./PatchRenderData.js";import{TerrainAttributesCache as x}from"./TerrainAttributesCache.js";import{enableTerrainInternalChecks as S}from"./terrainUtils.js";import{TileRenderer as C}from"./TileRenderer.js";import{IteratorPreorder as w,fallsWithinLayerView as T,usesStencil as E,sortTiles as D,compareTiles as O}from"./tileUtils.js";import{getOverlayContentForOutputTerrain as k}from"../webgl-engine/core/shaderLibrary/terrain/Overlay.glsl.js";import{SyncRenderPlugin as A}from"../webgl-engine/effects/RenderPlugin.js";import{Vertices as j}from"../webgl-engine/lib/Attribute.js";import{IntersectorResultRay as M}from"../webgl-engine/lib/IntersectorResult.js";import{intersectAabbInvDirBefore as N,MeshIntersectionOptions as P,intersectTriangles as F}from"../webgl-engine/lib/RayIntersections.js";import{TriangleIntersectionData as I}from"../webgl-engine/lib/TriangleIntersectionData.js";import{terrainId as L,getVerticalOffsetTerrain as R}from"../webgl-engine/lib/verticalOffsetUtils.js";import{DrawParameters as z}from"../webgl-engine/materials/DrawParameters.js";import{hasShadowHighlights as B}from"../webgl-engine/shaders/ReceiveShadowsConfiguration.js";import{T as V}from"../../../chunks/Terrain.glsl.js";import{TerrainTechnique as H}from"../webgl-engine/shaders/TerrainTechnique.js";import{TerrainTechniqueConfiguration as U}from"../webgl-engine/shaders/TerrainTechniqueConfiguration.js";import{PrimitiveType as W}from"../../webgl/enums.js";const G=g();let K=class extends A{get visibleTiles(){return Array.from(this._visiblePatchesByOrigin.values()).flat()}get _isGlobal(){return this._view.stage.viewingMode===1}get _techniques(){return this._context.techniques}get _rctx(){return this._context.renderContext.rctx}get renderOccludedFlags(){return this._overlayRenderer.renderOccludedFlags}constructor(e,t,i,a,o){super({}),this._surface=e,this._overlayRenderer=t,this._allTiles=i,this._compressionTracker=a,this.type=7,this.isGround=!0,this._passParameters=new V,this._drawParameters=new z,this._renderDataPool=new r(()=>new b),this._visiblePatchesByOrigin=new Map,this._allPatchesByOrigin=new Map,this._patchesByOriginDirty=!0,this._patchSortingDirty=!0,this._tileIterator=new w,this._castShadows=!1,this._inViewshed=!1,this._cutFillEnabled=!1,this._tileRenderer=null,this._numTilesRendered=0,this._numTilesCulled=0,this._numOriginsRendered=0,this.produces=new Map([[1,()=>this._desiredSlot===1],[7,()=>this._desiredSlot===7],[9,()=>this._produces()&&this.renderOccludedFlags===y]]),this._tileSize=256,this._configuration=new U(e.isGlobal),this._tileTextureCache=new n((e,t)=>o.newCache(e,t),`TileTexture`),this.tileGeometryCache=new x(o)}normalizeCtorArgs(){return{}}initialize(){this.addHandles(i(()=>this._overlayRenderer.renderOccludedFlags,()=>this.requestRender(),a))}destroy(){this._tileTextureCache.destroy(),this.tileGeometryCache.destroy(),this._allTiles.prune(),this._tileRenderer=null}_produces(){return this.visible&&!!this._rootTiles&&!this.renderingDisabled}set renderingDisabled(e){this._set(`renderingDisabled`,!!e),this.setDirty()}set visible(e){this._set(`visible`,!!e),this.setDirty()}updateHeading(e){this._tileRenderer?.updateHeading(e)}set transparency(e){this._configuration.transparencyMode!==e&&(this._configuration.transparencyMode=e,this.requestRender())}get transparency(){return this._configuration.transparencyMode}get renderPatchBorders(){return this._configuration.tileBorders}set renderPatchBorders(e){this._configuration.tileBorders!==e&&(this._configuration.tileBorders=e,this.requestRender(),this.notifyChange(`renderPatchBorders`))}get layerViewUid(){return L}get slicePlaneEnabled(){return this._configuration.hasSlicePlane}set slicePlaneEnabled(e){this._configuration.hasSlicePlane!==e&&(this._configuration.hasSlicePlane=e,this.requestRender())}set textureFadingEnabled(e){this._configuration.textureFadingEnabled!==e&&(this._configuration.textureFadingEnabled=e,this.requestRender())}set pbrMode(e){this._configuration.pbrMode!==e&&(this._configuration.pbrMode=e,this.requestRender())}setRootTiles(e){this._rootTiles=e,this.setDirty()}setStencilEnabledLayerExtents(e){this._stencilEnabledLayerExtents=e,this._setSortingDirty()}set tileSize(e){this._tileSize=e,this._tileRenderer!=null&&(this._tileRenderer.tileSize=e),this.setDirty()}get tileSize(){return this._tileSize}_ensureRenderData(e){e.renderData||(e.renderData=this._renderDataPool.acquire(),e.renderData.init(e,this._getLocalOriginOfTile(e)))}loadTile(e){this._ensureRenderData(e),this.updateTileGeometryState(e),this.reuseTextureFromParent(e)||this.updateTileTexture(e,32)}reuseTextureFromParent(e){let{parent:t}=e;if(!this._canReuseTextureFromParent(t,e))return!1;let n=m(e.lij[2]&1?.5:0,e.lij[1]&1?0:.5,.5,.5);return t.renderData?.reuseTexture(e.renderData,n)??!1}_canReuseTextureFromParent(e,t){if(!e)return!1;let{layerInfo:n,surface:r}=t;for(let i=0;i<n[1].length;i++){let n=r.layerViewByIndex(i,1);if(T(e,n)!==T(t,n))return!1}return!0}updateTileTexture(e,t){this._tileRenderer!=null&&(this._tileRenderer.updateTileTexture(e,t===32?0:2),this.requestRender(),e.resetPendingUpdate(t))}updateTileGeometryState(e){for(let t of e.layerInfo[0])t.pendingUpdates&=-9;e.resetPendingUpdate(8);let t=e.renderData.updateGeometryState();return t&&this.setDirty(),t}updateGeometryIfNeeded(e){e.loaded&&e.renderData.updateGeometryIfNeeded(this._rctx)}unloadTile(e){let t=e.renderData;t&&(t.releaseGeometry(),this._renderDataPool.release(t),t.clear(),e.renderData=null,e.setMemoryDirty(),this.setDirty())}_getLocalOriginOfTile(e){let t=Math.max(0,Math.floor((e.level-3)/7)*7);if(this._isGlobal&&t===0)return d;for(;e.parent&&e.level>t;)e=e.parent;return e.centerAtSeaLevel}getStats(){return{numTilesRendered:this._numTilesRendered,numTilesCulled:this._numTilesCulled,numOriginsRendered:this._numOriginsRendered}}set wireframe(e){this._get(`wireframe`)!==e&&(this._set(`wireframe`,e),this.requestRender())}setDirty(e=1){this._patchesByOriginDirty=!0,this._context.requestRender(e)}_setSortingDirty(e=1){this._patchSortingDirty=!0,this._context.requestRender(e)}requestRender(e=1){this._context.requestRender(e)}initializeRenderContext(e){this._context=e,this._tileRenderer=new C(this._surface,this._rctx,this._tileSize,this._techniques,this._tileTextureCache,this._compressionTracker),this.updateTileBackground()}uninitializeRenderContext(){this._tileRenderer=t(this._tileRenderer)}intersectRay(e,t,n,r){let i=this._rootTiles;if(!i||e.options.selectOpaqueTerrainOnly&&e.options.selectionMode&&this.transparency!==0)return;let a=q,o=J;c(a,r,n),l(o,1/a[0],1/a[1],1/a[2]);let s=e.results.min,d=e.results.max,f=e.results.ground,p=e.options.store===0,m=!!e.results.ground.target,h=R(e.verticalOffset),g=e.tolerance,y,b=p&&s.distance!=null?s.distance:1/0,x=e.options,S=x.normalRequired||!x.backfacesTerrain,C=new P(g,!1,S),w=i=>{let l=i.renderData;if(!l?.vao)return;let m=l.geometry;_(G,m.boundingBox);let w=l.localOrigin;if(h!=null&&(h.localOrigin=w,h.applyToAabb(G)),Y[0]=n[0]-w[0],Y[1]=n[1]-w[1],Y[2]=n[2]-w[2],!N(G,Y,o,g,b))return;let T=(e,t,n,r)=>{e.set(this.type,i,t,n,r),b=p&&s.renderDistance!=null?s.renderDistance:1/0},E=(i,o,c)=>{(!S||c!=null)&&o>=0&&(x.backfacesTerrain||u(c,a)<0)&&(x.invisibleTerrain||!x.selectionMode||t==null||t(n,r,o))&&((f.renderDistance==null||o<f.renderDistance)&&T(f,i,o,c),x.isFiltered||(x.store===2&&(y==null?(y=new M(e.ray),T(y,i,o,c),e.results.all.push(y)):o<y.renderDistance&&T(y,i,o,c)),(s.renderDistance==null||o<s.renderDistance)&&T(s,i,o,c),x.store!==0&&(d.renderDistance==null||o>d.renderDistance)&&T(d,i,o,c)))},D=X;c(D,r,w);let{indices:O,indexCount:k}=m,A=m.vertexAttributes,P=A.getField(`position`,v),L=new j(P.typedBuffer,3,A.stride/4),R=k/3;!h&&R>200?(l.intersectionData??=new I(O,R,L),l.intersectionData.intersectRay(Y,D,C,E)):F(Y,D,0,R,(e,t)=>P.getVec(O[t],e),h,C,E)},T=this._tileIterator;T.reset(i);let D=e.options.invisibleTerrain;for(let e=T.next();e;e=T.next())(e.visible||D&&e.intersectsClippingArea)&&(h!=null||e.intersectsRay(n,a,g,b))&&(!m||!E(e,this._stencilEnabledLayerExtents))?w(e):T.skipSubtree()}processScaleRangeQueries(e,t){if(!t.done&&e)for(this._updatePatchGroups();e.updating&&!t.done;){e.prepare();for(let t of this._visiblePatchesByOrigin.values())for(let n of t)n.renderData?.textureReference!=null&&e.queriesForTile(n);e.process(),t.madeProgress()}}get _view(){return this._surface.view}get _desiredSlot(){if(!this._produces())return null;switch(this.transparency){case 0:return 1;case 1:case 2:return 7;case 3:case 4:return null}}acquireTechniques(e){let{shadowMap:t,viewshedEnabled:n,cutFillComputationEnabled:r,slot:i,hasEmission:a,useFloatBlend:o}=e.bind,s=!!has(`enable-feature:terrain-shadows`)&&t.enabled;if(s!==this._castShadows&&(this._castShadows=s,this._patchesByOriginDirty=!0),this._inViewshed!==n&&(this._inViewshed=n,this._patchesByOriginDirty=!0),this._cutFillEnabled!==r&&(this._cutFillEnabled=r,this._patchesByOriginDirty=!0),this.transparency===3)return null;if(i===9){if((e.renderOccludedMask&y)===0)return null}else if(i!==this._desiredSlot)return null;let c=this._configuration;switch(c.receiveGlobalIllumination=c.screenSpaceReflections=c.cloudReflections=c.receiveShadows=c.hasShadowHighlights=c.receiveAmbientOcclusion=c.renderOccluded=c.hasHighlightMixTexture=!1,c.hasEmission=a,c.overlayMode=this._overlayRenderer.mode,c.useFloatBlend=o.value,e.output){case 0:case 1:case 2:{let n=e.bind;c.screenSpaceReflections=n.hasScreenSpaceReflections,c.cloudReflections=n.clouds.data!=null;let r=i===9;return c.receiveShadows=t.ready&&!r,c.hasShadowHighlights=B(c,e.bind),c.renderOccluded=r,c.receiveAmbientOcclusion=!r&&n.ssao!=null,c.receiveGlobalIllumination=!r&&n.globalIlluminationEnabled,this._acquireTechnique(e.output)}case 5:case 7:return this._castShadows?this._acquireTechnique(5):null;case 8:return this._inViewshed?this._acquireTechnique(8):null;case 9:return this._cutFillEnabled?this._acquireTechnique(9):null;case 3:case 4:case 11:return this._acquireTechnique(e.output);case 10:return c.hasHighlightMixTexture=e.bind.highlightMixTexture!=null,this._overlayRenderer.hasHighlights?this._acquireTechnique(10):null}return null}render(e,t){switch(this._updatePatchGroups(),this._passParameters.useStencil=!1,this._passParameters.overlayContent=k(e.output,e.bind),e.output){case 0:case 1:case 2:return this._renderMaterialPass(e,t);case 3:case 4:case 11:return this._renderAuxiliaryPass(e,t,this._visiblePatchesByOrigin);case 10:{let n=e.bind.highlight?.name;n&&this._overlayRenderer.hasHighlights&&this._overlayRenderer.renders(2)&&this._overlayRenderer.hasHighlight(n)&&this._renderAuxiliaryPass(e,t,this._visiblePatchesByOrigin);break}case 5:case 7:case 8:case 9:return this._renderAuxiliaryPass(e,t,this._allPatchesByOrigin)}}updateTileBackground(e){if(this._tileRenderer==null)return;let t=this._tileRenderer,n;if(e!=null){let t=e.toUnitRGBA();n=f(t[0]||0,t[1]||0,t[2]||0)}t.setBackground(n),this._allTiles.forAll(e=>t.updateTileTexture(e,0)),this._configuration.tileBlendInput=t.backgroundIsGrid?2:t.backgroundColor==null?0:1,this.requestRender()}_updatePatchGroups(){if(this._patchesByOriginDirty&&(this._rebuildPatchGroups(),this._patchesByOriginDirty=!1,this._patchSortingDirty=!0),this._patchSortingDirty){let e=Array.from(this._visiblePatchesByOrigin.values()),t=this._stencilEnabledLayerExtents;for(let n of e)D(n,t);e.sort((e,t)=>O(e[0],t[0])),this._visiblePatchesByOrigin=new Map(e.map(e=>[e[0].renderData.localOrigin,e])),this.notifyChange(`visibleTiles`),this._patchSortingDirty=!1}}_rebuildPatchGroups(){let e=this._rootTiles;if(e!=null){e[0]?.surface.checkAllTilesWaterproofness(`render-patch-groups`),this._visiblePatchesByOrigin.clear(),this._allPatchesByOrigin.clear();for(let t of e)this._rebuildPatchGroupsForRootTile(t)}}_rebuildPatchGroupsForRootTile(e){let t=this._tileIterator;for(t.resetOne(e);!t.done;){let e=t.next(),n=e.renderData;if(!n){this._numTilesCulled++;continue}let r=n.localOrigin;if(this._castShadows||this._inViewshed||this._cutFillEnabled){let t=this._allPatchesByOrigin.get(r);t||(t=[],this._allPatchesByOrigin.set(r,t)),t.push(e)}if(!e.visible){this._numTilesCulled++,t.skipSubtree();continue}let i=this._visiblePatchesByOrigin.get(r);i||(i=[],this._visiblePatchesByOrigin.set(r,i)),i.push(e),t.skipSubtree()}}_renderAuxiliaryPass(e,t,n){let{rctx:r,bind:i}=e;r.bindTechnique(t,i,this._passParameters);let a=!!this._stencilEnabledLayerExtents?.length;n.forEach(n=>{this._drawParameters.origin=n[0].renderData.localOrigin,t.program.bindDraw(i,this._passParameters,this._drawParameters);for(let r=0;r<n.length;r++)this._renderPatch(e,t,n[r],W.TRIANGLES,a,this._passParameters.overlayContent===null)}),r.bindVAO(null)}_renderMaterialPass(e,t){let{rctx:n,bind:r}=e,i=n.bindTechnique(t,r,this._passParameters);this._numTilesRendered=0,this._numTilesCulled=0,this._numOriginsRendered=0;let a=r.slot===9;a&&(i.bindTexture(`tex`,n.emptyTexture),i.setUniform3fv(`textureOpacities`,d),i.setUniform4fv(`texOffsetAndScale`,h));let o=this._tileRenderer?.backgroundColor==null?d:this._tileRenderer.backgroundColor;this._configuration.tileBlendInput===1&&i.setUniform3fv(`backgroundColor`,o);let s=!!this._stencilEnabledLayerExtents?.length,c=this.wireframe?W.LINES:W.TRIANGLES;this._configuration.textureFadingEnabled&&i.bindTexture(`texNext`,n.emptyTexture);for(let n of this._visiblePatchesByOrigin.values()){this._drawParameters.origin=n[0].renderData.localOrigin,t.program.bindDraw(r,this._passParameters,this._drawParameters),this._numOriginsRendered++;for(let r of n){let n=r.renderData,o=n.textureReference;if(o!=null){if(!a){i.setUniform4fv(`texOffsetAndScale`,o.offsetAndScale),i.bindTexture(`tex`,o.texture.texture);let e=n.textureFadeFactor,t=e<1?n.nextTextureReference:null;this._configuration.textureFadingEnabled&&t&&e<1?(i.setUniform1f(`fadeFactor`,e),i.setUniform4fv(`nextTexOffsetAndScale`,t.offsetAndScale),i.setUniform3fv(`nextTexOpacities`,t.opacities),i.bindTexture(`texNext`,t.texture.texture)):i.setUniform1f(`fadeFactor`,1),n.textureIsFading&&this.requestRender(2),i.setUniform3fv(`textureOpacities`,o.opacities)}this._renderPatch(e,t,r,c,s),r.renderOrder=this._numTilesRendered,this._numTilesRendered++}}}n.bindVAO(null)}_renderPatch(e,t,n,r,i,a=!1){let o=n.renderData,s=o.vao,c=s?.indexBuffer;if(!s||c==null){S&&console.error(`Rendered tile with no indices: `,n.lij,` : `,o);return}let l=t.program;!a&&!this._overlayRenderer.isEmpty&&this._bindOverlayPatchData(l,o.overlay);let{rctx:u,bind:d}=e;i&&(this._passParameters.useStencil=E(n,this._stencilEnabledLayerExtents),u.setPipelineState(t.getPipeline(d,this._passParameters)));let f=o.geometry.indexCount;u.bindVAO(s),l.assertCompatibleVertexAttributeLocations(s),u.drawElements(r,f,c.indexType,0)}_bindOverlayPatchData(e,t){e.setUniform4fv(`overlayTexOffset`,t.offsets),e.setUniform4fv(`overlayTexScale`,t.scales)}_acquireTechnique(e){return this._configuration.output=e,this._techniques.get(H,this._configuration)}get test(){}hasHighlight(e){return this._overlayRenderer.hasHighlight(e)}};e([o({readOnly:!0})],K.prototype,`visibleTiles`,null),e([o({readOnly:!0})],K.prototype,`_isGlobal`,null),e([o()],K.prototype,`renderOccludedFlags`,null),e([o({value:!1})],K.prototype,`renderingDisabled`,null),e([o({value:!0})],K.prototype,`visible`,null),e([o()],K.prototype,`renderPatchBorders`,null),e([o()],K.prototype,`wireframe`,null),K=e([s(`esri.views.3d.terrain.TerrainRenderer`)],K);const q=p(),J=p(),Y=p(),X=p();export{K as TerrainRenderer};
|
|
2
|
+
import{__decorate as e}from"tslib";import has from"../../../core/has.js";import{disposeMaybe as t}from"../../../core/maybe.js";import{MemCachePool as n}from"../../../core/MemCachePool.js";import r from"../../../core/ObjectPool.js";import{watch as i,sync as a}from"../../../core/reactiveUtils.js";import{property as o,subclass as s}from"../../../core/accessorSupport/decorators.js";import{subtract as c,set as l,dot as u}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{ZEROS as d,fromValues as f,create as p}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as m,ZEROS as h}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{create as g,set as _}from"../../../geometry/support/aaBoundingBox.js";import{BufferViewVec3f as v}from"../../../geometry/support/buffer/BufferView.js";import{overlayRenderOccludedFlag as y}from"./OverlayRenderer.js";import{PatchRenderData as b}from"./PatchRenderData.js";import{TerrainAttributesCache as x}from"./TerrainAttributesCache.js";import{enableTerrainInternalChecks as S}from"./terrainUtils.js";import{TileRenderer as C}from"./TileRenderer.js";import{IteratorPreorder as w,fallsWithinLayerView as T,usesStencil as E,sortTiles as D,compareTiles as O}from"./tileUtils.js";import{getOverlayContentForOutputTerrain as k}from"../webgl-engine/core/shaderLibrary/terrain/Overlay.glsl.js";import{SyncRenderPlugin as A}from"../webgl-engine/effects/RenderPlugin.js";import{Vertices as j}from"../webgl-engine/lib/Attribute.js";import{IntersectorResultRay as M}from"../webgl-engine/lib/IntersectorResult.js";import{intersectAabbInvDirBefore as N,MeshIntersectionOptions as P,intersectTriangles as F}from"../webgl-engine/lib/RayIntersections.js";import{TriangleIntersectionData as I}from"../webgl-engine/lib/TriangleIntersectionData.js";import{terrainId as L,getVerticalOffsetTerrain as R}from"../webgl-engine/lib/verticalOffsetUtils.js";import{DrawParameters as z}from"../webgl-engine/materials/DrawParameters.js";import{hasShadowHighlights as B}from"../webgl-engine/shaders/ReceiveShadowsConfiguration.js";import{T as V}from"../../../chunks/Terrain.glsl.js";import{TerrainTechnique as H}from"../webgl-engine/shaders/TerrainTechnique.js";import{TerrainTechniqueConfiguration as U}from"../webgl-engine/shaders/TerrainTechniqueConfiguration.js";import{PrimitiveType as W}from"../../webgl/enums.js";const G=g();let K=class extends A{get visibleTiles(){return Array.from(this._visiblePatchesByOrigin.values()).flat()}get _isGlobal(){return this._view.stage.viewingMode===1}get _techniques(){return this._context.techniques}get _rctx(){return this._context.renderContext.rctx}get renderOccludedFlags(){return this._overlayRenderer.renderOccludedFlags}constructor(e,t,i,a,o){super({}),this._surface=e,this._overlayRenderer=t,this._allTiles=i,this._compressionTracker=a,this.type=7,this.isGround=!0,this._passParameters=new V,this._drawParameters=new z,this._renderDataPool=new r(()=>new b),this._visiblePatchesByOrigin=new Map,this._allPatchesByOrigin=new Map,this._patchesByOriginDirty=!0,this._patchSortingDirty=!0,this._tileIterator=new w,this._castShadows=!1,this._inViewshed=!1,this._cutFillEnabled=!1,this._tileRenderer=null,this._numTilesRendered=0,this._numTilesCulled=0,this._numOriginsRendered=0,this.produces=new Map([[1,()=>this._desiredSlot===1],[7,()=>this._desiredSlot===7],[9,()=>this._produces()&&this.renderOccludedFlags===y]]),this._tileSize=256,this._configuration=new U(e.isGlobal),this._tileTextureCache=new n((e,t)=>o.newCache(e,t),`TileTexture`),this.tileGeometryCache=new x(o)}normalizeCtorArgs(){return{}}initialize(){this.addHandles(i(()=>this._overlayRenderer.renderOccludedFlags,()=>this.requestRender(),a))}destroy(){this._tileTextureCache.destroy(),this.tileGeometryCache.destroy(),this._allTiles.prune(),this._tileRenderer=null}_produces(){return this.visible&&!!this._rootTiles&&!this.renderingDisabled}set renderingDisabled(e){this._set(`renderingDisabled`,!!e),this.setDirty()}set visible(e){this._set(`visible`,!!e),this.setDirty()}updateHeading(e){this._tileRenderer?.updateHeading(e)}set transparency(e){this._configuration.transparencyMode!==e&&(this._configuration.transparencyMode=e,this.requestRender())}get transparency(){return this._configuration.transparencyMode}get renderPatchBorders(){return this._configuration.tileBorders}set renderPatchBorders(e){this._configuration.tileBorders!==e&&(this._configuration.tileBorders=e,this.requestRender(),this.notifyChange(`renderPatchBorders`))}get layerViewUid(){return L}get slicePlaneEnabled(){return this._configuration.hasSlicePlane}set slicePlaneEnabled(e){this._configuration.hasSlicePlane!==e&&(this._configuration.hasSlicePlane=e,this.requestRender())}set textureFadingEnabled(e){this._configuration.textureFadingEnabled!==e&&(this._configuration.textureFadingEnabled=e,this.requestRender())}set pbrMode(e){this._configuration.pbrMode!==e&&(this._configuration.pbrMode=e,this.requestRender())}setRootTiles(e){this._rootTiles=e,this.setDirty()}setStencilEnabledLayerExtents(e){this._stencilEnabledLayerExtents=e,this._setSortingDirty()}set tileSize(e){this._tileSize=e,this._tileRenderer!=null&&(this._tileRenderer.tileSize=e),this.setDirty()}get tileSize(){return this._tileSize}_ensureRenderData(e){e.renderData||(e.renderData=this._renderDataPool.acquire(),e.renderData.init(e,this._getLocalOriginOfTile(e)))}loadTile(e){this._ensureRenderData(e),this.updateTileGeometryState(e),this.reuseTextureFromParent(e)||this.updateTileTexture(e,32)}reuseTextureFromParent(e){let{parent:t}=e;if(!this._canReuseTextureFromParent(t,e))return!1;let n=m(e.lij[2]&1?.5:0,e.lij[1]&1?0:.5,.5,.5);return t.renderData?.reuseTexture(e.renderData,n)??!1}_canReuseTextureFromParent(e,t){if(!e)return!1;let{layerInfo:n,surface:r}=t;for(let i=0;i<n[1].length;i++){let n=r.layerViewByIndex(i,1);if(T(e,n)!==T(t,n))return!1}return!0}updateTileTexture(e,t){this._tileRenderer!=null&&(this._tileRenderer.updateTileTexture(e,t===32?0:2),this.requestRender(),e.resetPendingUpdate(t))}updateTileGeometryState(e){for(let t of e.layerInfo[0])t.pendingUpdates&=-9;e.resetPendingUpdate(8);let t=e.renderData.updateGeometryState();return this._surface.updateElevationSources(e),t&&this.setDirty(),t}updateGeometryIfNeeded(e){e.loaded&&e.renderData.updateGeometryIfNeeded(this._rctx)}unloadTile(e){let t=e.renderData;t&&(t.releaseGeometry(),this._renderDataPool.release(t),t.clear(),e.renderData=null,e.setMemoryDirty(),this.setDirty())}_getLocalOriginOfTile(e){let t=Math.max(0,Math.floor((e.level-3)/7)*7);if(this._isGlobal&&t===0)return d;for(;e.parent&&e.level>t;)e=e.parent;return e.centerAtSeaLevel}getStats(){return{numTilesRendered:this._numTilesRendered,numTilesCulled:this._numTilesCulled,numOriginsRendered:this._numOriginsRendered}}set wireframe(e){this._get(`wireframe`)!==e&&(this._set(`wireframe`,e),this.requestRender())}setDirty(e=1){this._patchesByOriginDirty=!0,this._context.requestRender(e)}_setSortingDirty(e=1){this._patchSortingDirty=!0,this._context.requestRender(e)}requestRender(e=1){this._context.requestRender(e)}initializeRenderContext(e){this._context=e,this._tileRenderer=new C(this._surface,this._rctx,this._tileSize,this._techniques,this._tileTextureCache,this._compressionTracker),this.updateTileBackground()}uninitializeRenderContext(){this._tileRenderer=t(this._tileRenderer)}intersectRay(e,t,n,r){let i=this._rootTiles;if(!i||e.options.selectOpaqueTerrainOnly&&e.options.selectionMode&&this.transparency!==0)return;let a=q,o=J;c(a,r,n),l(o,1/a[0],1/a[1],1/a[2]);let s=e.results.min,d=e.results.max,f=e.results.ground,p=e.options.store===0,m=!!e.results.ground.target,h=R(e.verticalOffset),g=e.tolerance,y,b=p&&s.distance!=null?s.distance:1/0,x=e.options,S=x.normalRequired||!x.backfacesTerrain,C=new P(g,!1,S),w=i=>{let l=i.renderData;if(!l?.vao)return;let m=l.geometry;_(G,m.boundingBox);let w=l.localOrigin;if(h!=null&&(h.localOrigin=w,h.applyToAabb(G)),Y[0]=n[0]-w[0],Y[1]=n[1]-w[1],Y[2]=n[2]-w[2],!N(G,Y,o,g,b))return;let T=(e,t,n,r)=>{e.set(this.type,i,t,n,r),b=p&&s.renderDistance!=null?s.renderDistance:1/0},E=(i,o,c)=>{(!S||c!=null)&&o>=0&&(x.backfacesTerrain||u(c,a)<0)&&(x.invisibleTerrain||!x.selectionMode||t==null||t(n,r,o))&&((f.renderDistance==null||o<f.renderDistance)&&T(f,i,o,c),x.isFiltered||(x.store===2&&(y==null?(y=new M(e.ray),T(y,i,o,c),e.results.all.push(y)):o<y.renderDistance&&T(y,i,o,c)),(s.renderDistance==null||o<s.renderDistance)&&T(s,i,o,c),x.store!==0&&(d.renderDistance==null||o>d.renderDistance)&&T(d,i,o,c)))},D=X;c(D,r,w);let{indices:O,indexCount:k}=m,A=m.vertexAttributes,P=A.getField(`position`,v),L=new j(P.typedBuffer,3,A.stride/4),R=k/3;!h&&R>200?(l.intersectionData??=new I(O,R,L),l.intersectionData.intersectRay(Y,D,C,E)):F(Y,D,0,R,(e,t)=>P.getVec(O[t],e),h,C,E)},T=this._tileIterator;T.reset(i);let D=e.options.invisibleTerrain;for(let e=T.next();e;e=T.next())(e.visible||D&&e.intersectsClippingArea)&&(h!=null||e.intersectsRay(n,a,g,b))&&(!m||!E(e,this._stencilEnabledLayerExtents))?w(e):T.skipSubtree()}processScaleRangeQueries(e,t){if(!t.done&&e)for(this._updatePatchGroups();e.updating&&!t.done;){e.prepare();for(let t of this._visiblePatchesByOrigin.values())for(let n of t)n.renderData?.textureReference!=null&&e.queriesForTile(n);e.process(),t.madeProgress()}}get _view(){return this._surface.view}get _desiredSlot(){if(!this._produces())return null;switch(this.transparency){case 0:return 1;case 1:case 2:return 7;case 3:case 4:return null}}acquireTechniques(e){let{shadowMap:t,viewshedEnabled:n,cutFillComputationEnabled:r,slot:i,hasEmission:a,useFloatBlend:o}=e.bind,s=!!has(`enable-feature:terrain-shadows`)&&t.enabled;if(s!==this._castShadows&&(this._castShadows=s,this._patchesByOriginDirty=!0),this._inViewshed!==n&&(this._inViewshed=n,this._patchesByOriginDirty=!0),this._cutFillEnabled!==r&&(this._cutFillEnabled=r,this._patchesByOriginDirty=!0),this.transparency===3)return null;if(i===9){if((e.renderOccludedMask&y)===0)return null}else if(i!==this._desiredSlot)return null;let c=this._configuration;switch(c.receiveGlobalIllumination=c.screenSpaceReflections=c.cloudReflections=c.receiveShadows=c.hasShadowHighlights=c.receiveAmbientOcclusion=c.renderOccluded=c.hasHighlightMixTexture=!1,c.hasEmission=a,c.overlayMode=this._overlayRenderer.mode,c.useFloatBlend=o.value,e.output){case 0:case 1:case 2:{let n=e.bind;c.screenSpaceReflections=n.hasScreenSpaceReflections,c.cloudReflections=n.clouds.data!=null;let r=i===9;return c.receiveShadows=t.ready&&!r,c.hasShadowHighlights=B(c,e.bind),c.renderOccluded=r,c.receiveAmbientOcclusion=!r&&n.ssao!=null,c.receiveGlobalIllumination=!r&&n.globalIlluminationEnabled,this._acquireTechnique(e.output)}case 5:case 7:return this._castShadows?this._acquireTechnique(5):null;case 8:return this._inViewshed?this._acquireTechnique(8):null;case 9:return this._cutFillEnabled?this._acquireTechnique(9):null;case 3:case 4:case 11:return this._acquireTechnique(e.output);case 10:return c.hasHighlightMixTexture=e.bind.highlightMixTexture!=null,this._overlayRenderer.hasHighlights?this._acquireTechnique(10):null}return null}render(e,t){switch(this._updatePatchGroups(),this._passParameters.useStencil=!1,this._passParameters.overlayContent=k(e.output,e.bind),e.output){case 0:case 1:case 2:return this._renderMaterialPass(e,t);case 3:case 4:case 11:return this._renderAuxiliaryPass(e,t,this._visiblePatchesByOrigin);case 10:{let n=e.bind.highlight?.name;n&&this._overlayRenderer.hasHighlights&&this._overlayRenderer.renders(2)&&this._overlayRenderer.hasHighlight(n)&&this._renderAuxiliaryPass(e,t,this._visiblePatchesByOrigin);break}case 5:case 7:case 8:case 9:return this._renderAuxiliaryPass(e,t,this._allPatchesByOrigin)}}updateTileBackground(e){if(this._tileRenderer==null)return;let t=this._tileRenderer,n;if(e!=null){let t=e.toUnitRGBA();n=f(t[0]||0,t[1]||0,t[2]||0)}t.setBackground(n),this._allTiles.forAll(e=>t.updateTileTexture(e,0)),this._configuration.tileBlendInput=t.backgroundIsGrid?2:t.backgroundColor==null?0:1,this.requestRender()}_updatePatchGroups(){if(this._patchesByOriginDirty&&(this._rebuildPatchGroups(),this._patchesByOriginDirty=!1,this._patchSortingDirty=!0),this._patchSortingDirty){let e=Array.from(this._visiblePatchesByOrigin.values()),t=this._stencilEnabledLayerExtents;for(let n of e)D(n,t);e.sort((e,t)=>O(e[0],t[0])),this._visiblePatchesByOrigin=new Map(e.map(e=>[e[0].renderData.localOrigin,e])),this.notifyChange(`visibleTiles`),this._patchSortingDirty=!1}}_rebuildPatchGroups(){let e=this._rootTiles;if(e!=null){e[0]?.surface.checkAllTilesWaterproofness(`render-patch-groups`),this._visiblePatchesByOrigin.clear(),this._allPatchesByOrigin.clear();for(let t of e)this._rebuildPatchGroupsForRootTile(t)}}_rebuildPatchGroupsForRootTile(e){let t=this._tileIterator;for(t.resetOne(e);!t.done;){let e=t.next(),n=e.renderData;if(!n){this._numTilesCulled++;continue}let r=n.localOrigin;if(this._castShadows||this._inViewshed||this._cutFillEnabled){let t=this._allPatchesByOrigin.get(r);t||(t=[],this._allPatchesByOrigin.set(r,t)),t.push(e)}if(!e.visible){this._numTilesCulled++,t.skipSubtree();continue}let i=this._visiblePatchesByOrigin.get(r);i||(i=[],this._visiblePatchesByOrigin.set(r,i)),i.push(e),t.skipSubtree()}}_renderAuxiliaryPass(e,t,n){let{rctx:r,bind:i}=e;r.bindTechnique(t,i,this._passParameters);let a=!!this._stencilEnabledLayerExtents?.length;n.forEach(n=>{this._drawParameters.origin=n[0].renderData.localOrigin,t.program.bindDraw(i,this._passParameters,this._drawParameters);for(let r=0;r<n.length;r++)this._renderPatch(e,t,n[r],W.TRIANGLES,a,this._passParameters.overlayContent===null)}),r.bindVAO(null)}_renderMaterialPass(e,t){let{rctx:n,bind:r}=e,i=n.bindTechnique(t,r,this._passParameters);this._numTilesRendered=0,this._numTilesCulled=0,this._numOriginsRendered=0;let a=r.slot===9;a&&(i.bindTexture(`tex`,n.emptyTexture),i.setUniform3fv(`textureOpacities`,d),i.setUniform4fv(`texOffsetAndScale`,h));let o=this._tileRenderer?.backgroundColor==null?d:this._tileRenderer.backgroundColor;this._configuration.tileBlendInput===1&&i.setUniform3fv(`backgroundColor`,o);let s=!!this._stencilEnabledLayerExtents?.length,c=this.wireframe?W.LINES:W.TRIANGLES;this._configuration.textureFadingEnabled&&i.bindTexture(`texNext`,n.emptyTexture);for(let n of this._visiblePatchesByOrigin.values()){this._drawParameters.origin=n[0].renderData.localOrigin,t.program.bindDraw(r,this._passParameters,this._drawParameters),this._numOriginsRendered++;for(let r of n){let n=r.renderData,o=n.textureReference;if(o!=null){if(!a){i.setUniform4fv(`texOffsetAndScale`,o.offsetAndScale),i.bindTexture(`tex`,o.texture.texture);let e=n.textureFadeFactor,t=e<1?n.nextTextureReference:null;this._configuration.textureFadingEnabled&&t&&e<1?(i.setUniform1f(`fadeFactor`,e),i.setUniform4fv(`nextTexOffsetAndScale`,t.offsetAndScale),i.setUniform3fv(`nextTexOpacities`,t.opacities),i.bindTexture(`texNext`,t.texture.texture)):i.setUniform1f(`fadeFactor`,1),n.textureIsFading&&this.requestRender(2),i.setUniform3fv(`textureOpacities`,o.opacities)}this._renderPatch(e,t,r,c,s),r.renderOrder=this._numTilesRendered,this._numTilesRendered++}}}n.bindVAO(null)}_renderPatch(e,t,n,r,i,a=!1){let o=n.renderData,s=o.vao,c=s?.indexBuffer;if(!s||c==null){S&&console.error(`Rendered tile with no indices: `,n.lij,` : `,o);return}let l=t.program;!a&&!this._overlayRenderer.isEmpty&&this._bindOverlayPatchData(l,o.overlay);let{rctx:u,bind:d}=e;i&&(this._passParameters.useStencil=E(n,this._stencilEnabledLayerExtents),u.setPipelineState(t.getPipeline(d,this._passParameters)));let f=o.geometry.indexCount;u.bindVAO(s),l.assertCompatibleVertexAttributeLocations(s),u.drawElements(r,f,c.indexType,0)}_bindOverlayPatchData(e,t){e.setUniform4fv(`overlayTexOffset`,t.offsets),e.setUniform4fv(`overlayTexScale`,t.scales)}_acquireTechnique(e){return this._configuration.output=e,this._techniques.get(H,this._configuration)}get test(){}hasHighlight(e){return this._overlayRenderer.hasHighlight(e)}};e([o({readOnly:!0})],K.prototype,`visibleTiles`,null),e([o({readOnly:!0})],K.prototype,`_isGlobal`,null),e([o()],K.prototype,`renderOccludedFlags`,null),e([o({value:!1})],K.prototype,`renderingDisabled`,null),e([o({value:!0})],K.prototype,`visible`,null),e([o()],K.prototype,`renderPatchBorders`,null),e([o()],K.prototype,`wireframe`,null),K=e([s(`esri.views.3d.terrain.TerrainRenderer`)],K);const q=p(),J=p(),Y=p(),X=p();export{K as TerrainRenderer};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import t from"../../../Color.js";import{filterInPlace as n,difference as r}from"../../../core/arrayUtils.js";import i from"../../../core/CollectionFlattener.js";import{toConst as a}from"../../../core/compilerUtils.js";import{EventedAccessor as o}from"../../../core/Evented.js";import has from"../../../core/has.js";import s from"../../../core/Logger.js";import{clamp as c}from"../../../core/mathUtils.js";import{removeMaybe as l,destroyMaybe as u}from"../../../core/maybe.js";import{MemCachePool as ee}from"../../../core/MemCachePool.js";import d from"../../../core/ObjectPool.js";import f from"../../../core/PooledArray.js";import{throwIfAborted as te,isAbortError as p,isAborted as m}from"../../../core/promiseUtils.js";import{watch as h,syncAndInitial as g,initial as _,sync as v}from"../../../core/reactiveUtils.js";import"../../../core/scheduling.js";import{getMetersPerUnitForSR as ne}from"../../../core/units.js";import{property as y,subclass as re}from"../../../core/accessorSupport/decorators.js";import{exactEquals as ie,set as ae,copy as oe}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{create as b}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{UpdatingHandles as se}from"../../../core/support/UpdatingHandles.js";import{getReferenceEllipsoid as ce,radiusModifier as le}from"../../../geometry/ellipsoidUtils.js";import{projectWithoutEngine as ue}from"../../../geometry/projectionUtils.js";import x from"../../../geometry/SpatialReference.js";import{getProjector as de}from"../../../geometry/projection/projectors.js";import{projectPointToVector as S}from"../../../geometry/projection/projectPointToVector.js";import{projectVectorToVector as fe}from"../../../geometry/projection/projectVectorToVector.js";import{create as C,fromExtent as pe,equals as w,intersection as me,intersectsSphere as T}from"../../../geometry/support/aaBoundingRect.js";import{copy as he,create as ge}from"../../../geometry/support/frustumPlanes.js";import{createSpatialReferenceCyclical as _e}from"../../../geometry/support/normalizeUtils.js";import{isPlateCarree as ve}from"../../../geometry/support/spatialReferenceUtils.js";import{Sphere as ye}from"../../../geometry/support/sphere.js";import{ElevationQueryTileCache as be}from"../../../layers/support/ElevationQueryTileCache.js";import{isIntegratedMeshLayer as xe,isBaseLayer as Se}from"../../../layers/support/layerUtils.js";import{queueHighPriority as Ce}from"../../../request/queue.js";import{debugFlags as E}from"../support/debugFlags.js";import{ElevationRange as D}from"../support/ElevationRange.js";import{ElevationUpdateEvent as we}from"../support/ElevationUpdateEvent.js";import{calculateElevationUpdateExtents as Te}from"../support/elevationUpdateExtentUtils.js";import{toBoundingRect as Ee}from"../support/extentUtils.js";import{updatingProgress as De}from"../support/updatingProperties.js";import{ElevationBounds as O}from"./ElevationBounds.js";import{ElevationData as Oe,sampleElevation as ke}from"./ElevationData.js";import{create as Ae}from"./ExtentHelper.js";import{LayerClasses as je}from"./LayerClass.js";import{OverlayManager as Me}from"./OverlayManager.js";import{PlanarPatch as Ne}from"./PlanarPatch.js";import{Queue as Pe}from"./Queue.js";import{ScaleRangeQueries as Fe}from"./ScaleRangeQueries.js";import{SphericalPatch as Ie}from"./SphericalPatch.js";import{SplitLimits as Le}from"./SplitLimits.js";import{maxRootTiles as k,tooManyRootTilesAfterChangeError as Re,tooManyRootTilesForLayerError as ze,maxTileNeighborLevelDelta as A,maxMemoryLodBias as Be}from"./TerrainConst.js";import{TerrainRenderer as Ve}from"./TerrainRenderer.js";import He from"./TerrainSurfacePerformanceInfo.js";import{weakAssert as j,isVectorTileLayerView as M,internalAssert as N,oppositeEdge as Ue,neighborEdgeIndices as P,isSurfaceLayerView as F,isGroupLayerView as I,isMapTileLayerView as L,isBlendableLayerView as R,isElevationLayerView as z,releaseTerrainData as B,oppositeCorner as We,enableTerrainInternalChecks as V,enableWaterproofTests as Ge,enableInternalTerrainChecks as Ke,enableTerrainWaterproofChecks as qe,neighborCornerIndices as Je}from"./terrainUtils.js";import{Tile as Ye,lijEquals as H}from"./Tile.js";import{printAllocations as Xe}from"./TilePerLayerInfo.js";import{sortTiles as Ze,IteratorPreorder as Qe,IteratorPostorder as $e,compareTilesByLij as U,hasLoadableSiblings as et,sortTilesByPOI as tt,traverseTilesPreorder as W}from"./tileUtils.js";import{TilingSchemeLogic as nt}from"./TilingSchemeLogic.js";import{getGroundTransparencyModeFromOpacity as rt}from"./TransparencyMode.js";import{UpsampleInfo as it}from"./UpsampleInfo.js";import{isCompositeBlendMode as at,blendModeFromString as ot}from"../webgl-engine/core/shaderLibrary/output/BlendOptions.js";import{hasLayerBasedScaleVisibility as st}from"../../support/layerViewUtils.js";import{ImmediateTask as G,TaskPriority as ct,noBudget as lt}from"../../support/Scheduler.js";import{TextureCompressionTracker as ut}from"../../support/TextureCompressionTracker.js";import{Yield as dt}from"../../support/Yield.js";var K;let q=class extends o{static{K=this}get allTilesCreated(){return this._allTilesCreated}get allTiles(){return a(this._allTiles)}get renderedTiles(){return Ze(n(this._allTiles.toArray(),e=>e.visible&&e.rendered))}get demResolution(){let{_allTiles:e,tilingScheme:t}=this;if(e.length===0)return{min:1,max:1};let n=ne(t.spatialReference),r=1/0,i=-1/0;for(let a of e){let e=t.resolutionAtLevel(a.level)*n;r=Math.min(r,e),i=Math.max(i,e)}return{min:r,max:i}}constructor(e){super(e),this.terrainTextureCompressionTracker=new ut,this._iteratorPool=new d(()=>new Qe,e=>e.remove=()=>this._iteratorPool.release(e)),this._postorderIterator=new $e,this._hasPendingUpdates=!1,this._pendingUpdates=0,this._asyncWorkItems=0,this._allTilesDirty=!0,this._allTilesSorted=!0,this._allTilesCreated=!1,this._usedMemory=null,this._performanceInfo=new He,this._waterproofnessErrorHandle=null,this._viewChanged=!1,this.heading=0,this._inFrameTask=!1,this._viewChangeUpdateDirty=!1,this._eyePosRenderSR=b(),this._eyePosSurfaceSR=b(),this._splitLimits=new Le,this._layerViews=[[],[]],this._layerIndexByUid=[new Map,new Map],this._basemapLayerViewHandles=new Map,this._updatingHandles=new se,this._poiWatchHandle=null,this._frameTask=G,this._allTiles=new f,this._upsampleInfoPool=new d(()=>new it),this._shouldEmitChangeEvent=!1,this._rootTilesExtent=C(),this.updatingProgress=.5,this._maxNumUpdating=1,this.maxTextureScale=1.2,this._spatialReference=x.WebMercator,this._elevationProjectorCache=new Map,this.visibleElevationRange=new D(1/0,-1/0),this._rootTileElevationRange=new D(1/0,-1/0),this._projectorCache=new Map,this._tilingSchemeSpatialReference=null,this._updatingRootTiles=!1,this._pendingTilesForElevationUpdateEvent=new Set,this._pendingTilesToUpdate=new Set,this.totalGeometryUpdates=0,this.totalTileUpdates=0,this._layerViewsDirty=!1,this.unloadedMemory=0,this.ignoresMemoryFactor=!1,this._isWebMercator=!1,this._isWebMercatorOnPlateCarree=!1,this.enabled=!0;let{view:t}=e;this.overlayManager=new Me({...e,terrainSurface:this}),this._isGlobal=!t.state?.isLocal,this._isGeographic=this._spatialReference?.isGeographic??!1,this._tileConstructor=this._isGlobal?Ie:Ne,this._ellipsoid=ce(t.spatialReference),this._renderer=new Ve(this,this.overlayManager.renderer,this._allTiles,this.terrainTextureCompressionTracker,t.resourceController.memoryController),st()||(this._scaleRangeQueries=new Fe)}initialize(){let{view:e}=this,{resourceController:t}=e,{memoryController:n}=t;e.stage.addRenderPlugin(this._renderer),this._tileCache=new ee((e,t)=>n.newCache(e,t),`terrain-tile`),this._upsampleMapCache=n.newCache(`terrain-upsample`,({tile:e})=>e.unloadMapData()),this._elevationQueryCache=new be(n.newCache(`elevation-query`));let r=this.overlayManager;this.addHandles([h(()=>r.renderer.isEmpty,()=>this._evaluateTransparency()),h(()=>this.renderer.visible,e=>this.freeze=!e),h(()=>this.heading,e=>{this._renderer.updateHeading(e),this._updateTileTextures(0)},g)],`overlayManager`),this._updatingHandles.add(()=>({heading:e.camera?.heading,state:e.state?.mode}),({heading:e,state:t})=>{if(e==null)return;if(this.isGlobal&&this.isGeographic||this.isWebMercatorOnPlateCarree){this.heading=Math.round(e/90)*90%360;return}let n=Math.round(e)%360,r=Math.abs(n-this.heading);(t===2||Math.min(r,360-r)>=30)&&(this.heading=n)},_),this.addHandles([h(()=>this.baseOpacity,()=>{this._handleLayerViewChanges(),this._updateTileTextures(this._evaluateTransparency()?1:2)},g),h(()=>this.hasCompositeBlendMode,()=>this._updateTileTextures(this._evaluateTransparency()?1:2),g),h(()=>this.backgroundColor,(e,t)=>{e?.equals(t)||(this._handleLayerViewChanges(),this._renderer.updateTileBackground(e))},v),h(()=>this.snapLevel,()=>this._viewChanged=!0,v),h(()=>this.view.pointsOfInterest,e=>{this._renderer.pointsOfInterest=e,this._poiWatchHandle=l(this._poiWatchHandle),e&&(this._poiWatchHandle=this._updatingHandles.add(()=>e.focus?.renderLocation,()=>this._allTilesSorted=!1,{equals:ie}))}),h(()=>E.TERRAIN_TILE_TREE_SHOW_TILES,t=>{t&&!this._treeDebugger?import(`../layers/support/TerrainTileTree3DDebugger.js`).then(({TerrainTileTree3DDebugger:t})=>{!this._treeDebugger&&E.TERRAIN_TILE_TREE_SHOW_TILES&&(this._treeDebugger=new t({view:e}))}):t||(this._treeDebugger=u(this._treeDebugger))},_)]);let{spatialReference:a}=e;this._extentHelper=Ae(this.viewingMode,{layers:e.map.allLayers,layerViews:e.allLayerViews,viewSpatialReference:a});let o=new i({getCollections:()=>e.defaultsFromMap?.mapCollections?.map(({layers:e})=>e),getChildrenFunction:e=>e&&`layers`in e?e.layers:null}),s=new nt({layers:o,extentHelper:this._extentHelper,viewingMode:this.viewingMode,viewSpatialReference:a});this._set(`tilingSchemeLogic`,s),this._updateTilingScheme();let c=t.scheduler;this._frameTask=c.registerTask(ct.TERRAIN_SURFACE,this),this.addHandles([h(()=>this._stencilEnabledExtents,e=>this._renderer.setStencilEnabledLayerExtents(e),_),h(()=>this.tilingSchemeLogic.tilingScheme,()=>this._updateTilingScheme(),v),h(()=>this.groundExtent,()=>this._updateRootTiles(),_),e.on(`resize`,()=>this._viewChangeUpdate()),h(()=>{let t=e.state;return[this._lodBias,this.lodSnappingEnabled,e.quality,t.camera,t.contentCamera,t.fixedContentCamera]},()=>this._viewChangeUpdate(),g),h(()=>e.qualitySettings?.fadeDuration,e=>this._renderer.textureFadingEnabled=e>0,_),h(()=>e.qualitySettings?.physicallyBasedRenderingEnabled,e=>this._renderer.pbrMode=e?5:0,_),h(()=>e.qualitySettings?.tiledSurface.elevationLevelDelta,()=>this._updateAllTileGeometries()),h(()=>this.userClippingExtent,()=>this._updateClippingExtent(),v)]),this.addHandles(e.allLayerViews.on(`after-changes`,()=>this._layerViewsDirty=!0)),this._layerViewsDirty=!0,this._handleLayerViewChanges(),this._renderer.updateTileBackground(this.backgroundColor)}clearHandles(){this._updatingHandles?.removeAll(),this.removeAllHandles(),this._basemapLayerViewHandles.forEach((e,t)=>this._unregisterTiledLayerView(t)),this._basemapLayerViewHandles.clear()}destroy(){this._waterproofnessErrorHandle?.remove(),this._waterproofnessErrorHandle=null,this._frameTask.remove(),this._frameTask=G,this._updatingHandles?.destroy(),this._removeAllTiles(),this._set(`tilingSchemeLogic`,u(this.tilingSchemeLogic)),this._basemapLayerViewHandles.forEach((e,t)=>this._unregisterTiledLayerView(t)),this._basemapLayerViewHandles.clear(),this._set(`overlayManager`,u(this.overlayManager)),this._tileCache=u(this._tileCache),this._allTiles.prune(),Ye.prune(),this._treeDebugger=u(this._treeDebugger),this._renderer.destroyed||(this.view.stage.removeRenderPlugin(this._renderer),this._renderer.destroy()),this._renderer=null,this._iteratorPool=u(this._iteratorPool),this._upsampleMapCache=u(this._upsampleMapCache),this._elevationQueryCache=u(this._elevationQueryCache),this._set(`view`,null),this._extentHelper=u(this._extentHelper),this._upsampleInfoPool=u(this._upsampleInfoPool),Xe(),this._layerViews.forEach(e=>e.length=0),this._performanceInfo=null}get renderer(){return this._renderer}get frustum(){return this.view.state.camera.frustum}get snapLevel(){return this.lodSnappingEnabled?this.view.terrainLevel:null}get lodSnappingEnabled(){return this.view.qualitySettings.tiledSurface.reduceTileLevelDifferences}get upsampleInfoPool(){return this._upsampleInfoPool}get upsampleMapCache(){return this._upsampleMapCache}get elevationQueryCache(){return this._elevationQueryCache}get hasStencilEnabledExtents(){return!!this._stencilEnabledExtents?.length}get _stencilEnabledExtents(){let e=this.spatialReference,t=!!has(`enable-feature:im-as-ground`);return e==null?null:Iterator.from(this.view.allLayerViews).map(n=>{let{layer:r}=n;if(!xe(r)||t&&!r.isUsedAsGroundLayer)return null;let{fullExtent:i}=r,a=i==null||i.spatialReference.equals(e)?i:ue(i,i.spatialReference,e);return a?pe(a):null}).filter(e=>e!=null).toArray()}get userClippingExtent(){let{spatialReference:e}=this,t=this.view?.clippingArea;if(t==null||e==null)return null;let n=C(),r=Ee(t,n,e)?n:null,i=this._get(`userClippingExtent`);return w(r,i)?i:r}get rootTilesExtent(){return this._rootTilesExtent}get groundExtent(){let e=me(this.fullGroundExtent,this.userClippingExtent,C()),t=this._get(`groundExtent`);return w(e,t)?t:e}get fullGroundExtent(){return this._tilingSchemeExtent==null?this._rootTilesExtent:this._tilingSchemeExtent}get _tilingSchemeExtent(){return this.tilingSchemeLogic?.extent}get updating(){return this._hasPendingUpdates||(this._maxNumUpdating=1),this.enabled&&!!((this.readyToRun||this._updatingHandles?.updating||this._asyncWorkItems>0)&&this.ready&&!this.freeze||this.overlayManager?.updating||this.terrainTextureCompressionTracker.compressing)}get readyToRun(){return this.enabled&&(this._hasPendingUpdates||this._viewChanged||this._allTilesDirty||!this._allTilesSorted||this._hasElevationSourceUpdates||this._layerViewsDirty||this._scaleRangeQueries?.updating||this._frameTask.updating)&&this.ready&&!this.freeze}get _hasElevationSourceUpdates(){return this._allTiles.some(e=>e.needsElevationSourceUpdate())}get updatingProgressValue(){return this._maxNumUpdating=Math.max(this._pendingUpdates,this._maxNumUpdating),1-this._pendingUpdates/this._maxNumUpdating}get baseOpacity(){return this.view?.map?.ground?.opacity??1}set baseOpacity(e){this.view.map.ground.opacity=e}get viewingMode(){return this.view.state.viewingMode}get ready(){return!this.enabled||this._rootTiles!=null}get rootTiles(){return this._rootTiles}get spatialReference(){return this.tilingScheme?.spatialReference??null}get backgroundColor(){return this.view?.map?.ground?.surfaceColor}set backgroundColor(e){this.view.map.ground.surfaceColor=e}set slicePlaneEnabled(e){this._renderer.slicePlaneEnabled=e,this._set(`slicePlaneEnabled`,e),this._evaluateTransparency()}get tilingSchemeLocked(){return this.tilingSchemeLogic?.tilingSchemeLocked??!1}get wireframe(){return this._renderer?.wireframe}set wireframe(e){e!==this._renderer.wireframe&&(this._renderer.wireframe=e,this._updateAllTileGeometries())}get opaque(){return this._renderer.transparency===0}get invisible(){return this._renderer.transparency===3}set freeze(e){this._set(`freeze`,e),this._viewChangeUpdate()}get fadeDuration(){return this.view.qualitySettings.fadeDuration??0}intersect(e,t,n,r){this._renderer.intersectRay(e,t,n,r)}getElevationLevelDelta(e){return e<4?3:this.view.qualitySettings.tiledSurface.elevationLevelDelta}get _xNormalizer(){return _e(this._spatialReference)}getElevation(e,t,n,r){let i=this._rootTiles;if(!i?.length||!this.enabled||i[0].layerInfo[0].length===0)return null;let a=this._elevationProjectorCache.get(r);if(a===void 0&&(a=de(r,this._spatialReference)??null,this._elevationProjectorCache.set(r,a)),a==null)return s.getLogger(this).error(`TerrainSurface.getElevation(): could not project given point to tiling scheme coordinate system`),null;let o=ae(J,e,t,n);a(o,0,o,0);let c=this._xNormalizer?.normalize(o[0])??o[0],l=o[1];return ht(i,c,l)}getElevations(e,t,n){let r=this._rootTiles,i=r?r[0].layerInfo[0].length:0;if(!r?.length||i===0||!this.enabled)for(let e=0;e<t;++e)n(e,null);else for(let i=0;i<t;++i){let t=i*3,a=e[t],o=e[t+1],s=ht(r,a,o);n(i,s)}}getLayerIndexByUID(e,t){return this._layerIndexByUid[e].get(t)}getScale(e){if(!this.tilingScheme)return null;if(!S(e,J,this.spatialReference))return s.getLogger(this).error(`TerrainSurface.getScale(): could not project given point to tiling scheme coordinate system`),null;let t=this._rootTiles;if(t!=null){for(let e of t)if(e?.containsPoint(J)){let t=e;for(;t.children[0]&&!t.rendered;){let e=t.children[0].extent,n=0;J[0]>e[2]&&(n+=1),J[1]<e[1]&&(n+=2),t=t.children[n]}return this._getLodBiasCorrectedScale(t.level)}}return 1/0}_ensureProjector(e){let t=this._projectorCache.get(e);if(t)return t;let n=de(e,this._tilingSchemeSpatialReference)??null;return this._projectorCache.set(e,n),n}getSphereElevationRange(e,t){if(!this.enabled||this._rootTiles==null)return null;let n=this._ensureProjector(t);if(n==null)return s.getLogger(this).error(`TerrainSurface.getSphereElevationRange(): could not project given point to tiling scheme coordinate system`),null;Y.copyFrom(e),n(Y.center,0,Y.center,0);let r=new D,i=this._rootTiles;if(i!=null){let e=[];for(let t of i)e.push(t);let t=0;for(;t<e.length;){let n=e[t];if(++t,!T(n.extent,Y))continue;let i=n.children;if(i[0]==null||n.rendered)r.expandElevationRangeValues(n.elevationBoundsMin,n.elevationBoundsMax);else for(let t of i)e.push(t)}}return r}getRootElevationRange(){return this.enabled&&this._rootTiles!=null?new D(this._rootTileElevationRange.minElevation,this._rootTileElevationRange.maxElevation):null}getLowerBoundRadius(){let e=(this._ellipsoid.radius+this.visibleElevationRange.minElevation)*le;return Math.min(e,this._ellipsoid.radius)}getSphereScale(e,t){if(!this.tilingScheme)return null;if(!S(e,Y.center,this.spatialReference))return s.getLogger(this).error(`TerrainSurface.getSphereScale(): could not project given point to tiling scheme coordinate system`),null;Y.radius=t;let n=null,r=e=>{if(e&&T(e.extent,Y)){let t=e.children;if(t[0]&&!e.rendered)for(let e of t)r(e);else{let t=this._getLodBiasCorrectedScale(e.level);n=n==null?t:Math.min(n,t)}}},i=this._rootTiles;if(i!=null)for(let e of i)r(e);return n}queryVisibleScaleRange(e,t,n,r){if(!this._scaleRangeQueries)return;let i=t?this.tilingScheme.levelAtScale(t):0,a=n?this.tilingScheme.levelAtScale(n):1/0,o=this._lodBias;this._scaleRangeQueries.queryVisibleLevelRange(e,i+o,a+o,r)}_evaluateTransparency(){let e=this.baseOpacity,t=this.overlayManager.renderer.isEmpty,n=this._renderer.transparency,r=this._isFullyTransparent?rt(0,t):e>=1&&!this.hasCompositeBlendMode&&!this._renderer.slicePlaneEnabled?0:1;return this._renderer.transparency=r,n!==r&&(this.notifyChange(`opaque`),this.notifyChange(`invisible`),!0)}_updateTilingScheme(){let{tilingScheme:e}=this.tilingSchemeLogic;if(e===this.tilingScheme)return;j(!!e,`tiling scheme cannot be reset to undefined`),this._isGlobal=!this.view?.state?.isLocal,this.tilingScheme&&this._removeAllTiles();let t=e?.spatialReference??x.WebMercator;this._spatialReference=t,this._isWebMercator=!!t?.isWebMercator,this._isWebMercatorOnPlateCarree=this._isWebMercator&&ve(this.view?.renderSpatialReference),this._isGeographic=t?.isGeographic??!1,this._set(`tilingScheme`,e),this._tilingSchemeSpatialReference=this.tilingScheme?.spatialReference,this._projectorCache.clear(),this._updateClippingExtent(),e&&(this._updateTiledLayers(),this._renderer.tileSize=e.pixelSize,this.overlayManager.spatialReference=e.spatialReference,this._updateRootTiles())}static{this._tileMemcacheKey=`TerrainTileMemcache`}_acquireTile(e,t,n,r){let i=this._tileCache.pop(K._tileMemcacheKey);return i?(i.init(e,t,n,r,this),i):new this._tileConstructor(e,t,n,r,this)}get updatingRootTiles(){return this._updatingRootTiles}_updateRootTiles(){let{groundExtent:e,tilingScheme:t}=this;if(!t)return;if(!this.enabled){this._setRootTiles(null);return}let n=pt,i=t.rootTilesInExtent(e,n,k*5);if(this._rootTiles!=null){if(i.length>k){s.getLogger(this).warn(Re);return}let e=this._rootTiles.map(e=>e.lij),t=r(e,i,H);if(this._updatingRootTiles=!0,t.removed.length>0||t.added.length>0){let e=this._rootTiles.filter(e=>t.removed.findIndex(t=>H(t,e.lij))>-1?(this._purgeTile(e),!1):!0);t.added.forEach(t=>e.push(this._newRootTile(t))),this._setRootTiles(e)}}else this._updatingRootTiles=!0,i.length>k&&(s.getLogger(this).warn(ze),i=t.rootTilesInExtent(e,n,k)),this._setRootTiles(i.map(e=>this._newRootTile(e)));w(n,this._rootTilesExtent)||(this._rootTilesExtent=C(n)),this.renderer.visible=!0,this._viewChangeUpdate(),this.overlayManager.setPlacementDirty(),this.notifyChange(`ready`),this._updateAllTileGeometries(),this._updatingRootTiles=!1,this.checkAllTilesWaterproofness(`root-tiles-updated`)}_updateAllTileGeometries(){let e=this._allTiles.filter(e=>this._canUpdateTileGeometry(e));e.length===0||(e.sort(U),e.forEach(e=>this._renderer.updateTileGeometryState(e)),e.forEach(e=>e.renderData.updateNeighborData()),this._updateTilesGeometries(e)),this._pendingTilesToUpdate.clear()}_updateTilesGeometries(e){let t=e.filter(e=>this._canUpdateTileGeometry(e));if(t.length===0)return;let n=this.renderer;for(let e of t)n.updateGeometryIfNeeded(e);for(let e of t)this._pendingTilesForElevationUpdateEvent.add(e)}_canUpdateTileGeometry(e){return e.loaded&&e.intersectsClippingArea&&e.hasGeometryState}_shouldSplit(e){return e.shouldSplit(this._splitLimits,this._eyePosRenderSR,this.snapLevel)===1}_newRootTile(e){let t=this._acquireTile(0,e[1],e[2],null);return this._shouldSplit(t)&&t.setPendingUpdate(1),this._loadTile(t),this._markTileToUpdate(t),this._updateRootTileElevationRange(),t}_setRootTiles(e){if(this._rootTiles=e,this._allTiles.clear(),e!=null){let t=this._iteratorPool.acquire();for(t.reset(e);!t.done;)this._allTiles.push(t.next());t.remove()}this._renderer.setRootTiles(this._rootTiles),this._updateTilesVisibility(e),this.notifyChange(`demResolution`),this.emit(`tiles-changed`,{allTiles:this.allTiles})}_runViewChangeUpdateIfDirty(){this._viewChangeUpdateDirty&&(this._viewChangeUpdateDirty=!1,this._viewChangeUpdate())}_viewChangeUpdate(){this.view&&!this.freeze&&this.tilingScheme&&this.renderer.visible&&(this._inFrameTask?this._viewChangeUpdateDirty=!0:(this._viewChangeUpdateDirty=!1,this._updateViewDependentParameters(),this._updateTilesVisibility(this._rootTiles)))}_updateClippingStatus(e){e.updateClippingStatus(this.groundExtent)&&e.resetPendingUpdate(8)&&this._updateTileGeometryState(e)}_updateTilesVisibility(e){if(e==null)return;let t=et(e),n=this.visibleElevationRange,r=t?n.minElevation:1/0,i=t?n.maxElevation:-1/0,a=this.groundExtent,o=this.view.state.contentCamera.viewProjectionMatrix;this.setTileTreeDirty(!1);let s=this._iteratorPool.acquire();for(s.reset(e);!s.done;){let e=s.next();e.updateClippingStatus(a)&&e.resetPendingUpdate(8)&&this._updateTileGeometryState(e),e.computeVisibility(),e.updateScreenDepth(o),e.renderData&&(r=Math.min(e.elevationBoundsMin,r),i=Math.max(e.elevationBoundsMax,i))}s.remove(),this._viewChanged=!0,this._allTilesDirty=!0,this._updatePendingTileGeometries(),isFinite(r)&&isFinite(i)&&(n.minElevation!==r||n.maxElevation!==i)&&(this.visibleElevationRange=new O(r,i))}_updateRootTileElevationRange(){let e=1/0,t=-1/0;this._rootTiles?.forEach(({elevationBoundsMin:n,elevationBoundsMax:r})=>{e=Math.min(e,n),t=Math.max(t,r)});let n=this._rootTileElevationRange;(n.minElevation!==e||n.maxElevation!==t)&&(this._rootTileElevationRange=new O(e,t))}_updateViewDependentParameters(){let{camera:e,contentCamera:t}=this.view.state,n=Math.tan(t.fovX*.5),r=Math.tan(t.fovY*.5),i=this.tilingScheme.pixelSize,a=2**-this._lodBias*e.pixelRatio;this._splitLimits.aboveGround=e.aboveGround,this._splitLimits.fovX=n,this._splitLimits.fovY=r,this._splitLimits.relativeWidthLimit=i/e.width*this.maxTextureScale*a,this._splitLimits.relativeHeightLimit=i/e.height*this.maxTextureScale*a,this._splitLimits.maxLod=this.tilingScheme.getMaxLod(),this._splitLimits.angledSplitBias=this.view.qualitySettings.tiledSurface.angledSplitBias,this.view.state.fixedContentCamera?this._splitLimits.frustum=he(this._splitLimits.frustum??ge(),t.frustum):this._splitLimits.frustum=null,oe(this._eyePosRenderSR,t.eye),fe(e.eye,this.view.renderSpatialReference,this._eyePosSurfaceSR,this.spatialReference)}_updateTileGeometryState(e){e.updateVisibility();let t=this._renderer.updateTileGeometryState(e);e.needsElevationSourceUpdate()&&(e.updateAgents(0),e.markElevationSourceUpdateRequested(),this.requestUpdate()),t&&this._markTileToUpdate(e),this.setMemoryDirty()}_markAllTileNeighborsForUpdate(e){let t;e.forEachLoadedNeighbor(e=>{t??=this._layerViews[1].some(M),t&&e.setPendingUpdate(32),this._pendingTilesToUpdate.add(e)})}_updateTileTexture(e,t){let n=e.resetPendingUpdate(32)?32:e.resetPendingUpdate(16)?16:!1;n&&(this._renderer.updateTileTexture(e,n),this._usedMemory=null,t.madeProgress())}_emitElevationUpdateEventForTiles(){if(!this._shouldEmitChangeEvent)return;let e=this._pendingTilesForElevationUpdateEvent;if(e.size>0){let t=new Float64Array(4*e.size),n=0;for(let r of e)t.set(r.extent,4*n),++n;e.clear();for(let e of Te(t,this.spatialReference)){let t=new we(this.spatialReference,e,`ground`);this.emit(`elevation-change`,t)}}this._shouldEmitChangeEvent=!1}runTask(e){this._handleLayerViewChanges(e),this._frameTask.processQueue(e),this.renderer.processScaleRangeQueries(this._scaleRangeQueries,e),this._inFrameTask=!0,this._pendingUpdates=0,this._hasPendingUpdates=!1,this._updateAllTilesStatus(e),this._sortTiles(e);let t=!this.view.state.fixedContentCamera;this._mergeAndSplit(e,t),this._updateElevation(e),this._updateElevationSources(e),this._updateTextures(e),t||this._mergeAndSplit(e,!0),this._inFrameTask=!1,this._runViewChangeUpdateIfDirty();let n=this._pendingTilesToUpdate.size>0,r=n&&this._hasPendingGeometryWithoutIndices();if((!e.done||r)&&this._updatePendingTileGeometries(),this._emitElevationUpdateEventForTiles(),e.done&&(e.hasProgressed||n&&!r)&&this.requestUpdate(),this.notifyChange(`updatingProgressValue`),!e.hasProgressed)return dt}_checkTileInvariant(){}_updateAllTilesStatus(e){if(!this._viewChanged||!this._rootTiles||e.done)return;this._viewChanged=!1;let t=!1,n=new Pe(this._allTiles.length);n.pushAll(this._rootTiles);let r=this.snapLevel,i=this._splitLimits,a=this._eyePosRenderSR;this._allTiles.forAll(e=>{e.maxLevelDeltaNeighborCount=0,e.unmergableChildCount=0});let o=this.view.state.contentCamera.viewProjectionMatrix;for(;!n.empty;){let e=n.pop(),s=e.parent?.hasPendingUpdate(4),c=s?4:e.shouldSplit(i,a,r),l=c===1;e.leaf?Z(e,l):n.pushAll(e.children),s?(e.resetPendingUpdate(1),e.leaf||(e.setPendingUpdate(4),t=!0),this._updateClippingStatus(e),e.updateVisibility(),e.updateScreenDepth(o)):l?(e.resetPendingUpdate(4),e.leaf&&(e.setPendingUpdate(1),t=!0)):(e.resetPendingUpdate(1)&&e.updateAgentSuspension(),c===2&&e.updateAgents(0),e.leaf||(e.setPendingUpdate(4),e.resetPendingUpdate(1),t=!0))}this._allTilesDirty=t,this.requestUpdate(),this._shortBatches&&this._updatePendingTileGeometries(),e.madeProgress()}_sortTiles(e){!e.done&&!this._allTilesSorted&&this.view.pointsOfInterest?.focus&&(tt(this._allTiles,this.view.pointsOfInterest.focus.renderLocation),this._allTilesSorted=!0,this._treeDebugger?.update(),e.madeProgress())}_markTileToUpdate(e){N(e.loaded),e.intersectsClippingArea&&(this._pendingTilesToUpdate.add(e),this._markAllTileNeighborsForUpdate(e))}_hasPendingGeometryWithoutIndices(){for(let e of this._pendingTilesToUpdate)if(e.loaded&&e.intersectsClippingArea&&e.renderData?.vao?.indexBuffer==null)return!0;return!1}_updatePendingTileGeometries(){let e=this._pendingTilesToUpdate,t=[];if(e.forEach(e=>{this._canUpdateTileGeometry(e)&&t.push(e)}),t.length===0){e.clear();return}let n=(n,r)=>{!r||!this._canUpdateTileGeometry(r)||r.level<n.level||e.has(r)||(e.add(r),t.push(r),r.renderData.updateNeighborData())};t.sort(U);let r=t.length;for(let i=0;i<r;++i){let r=t[i];N(r.loaded),N(r.intersectsClippingArea);let a=r.renderData;if(!a?.geometryState)continue;a.updateNeighborData();let o=a.dirtyEdgeResolutions,s=a.geometryState,c=e=>{let t=Je[e];n(r,s.cornerPeerNeighbors[e]?.findCorner(We(t),e=>e.loaded))};for(let t=0;t<4;++t)if(o&1<<t){let i=a.geometryState.edgePeerNeighbors[t];i&&i?.level>=r.level&&i.forAllSubtreeOnSide(Ue(P[t]),t=>this._canUpdateTileGeometry(t)?(N(e.has(t)||U(r,t)<0),n(r,t),!0):!1),c((t+1)%4),c(t)}}e.clear(),this._updateTilesGeometries(t),this._shouldEmitChangeEvent=!0,V&&Ge&&this.checkAllTilesWaterproofness(`pending-geometries-updated`)}_mergeAndSplit(e,t){if(this.freeze||e.done||!this._allTilesDirty)return;this._allTilesDirty=!1,this.requestUpdate();let n=!1,r=this.view.state.fixedContentCamera,i=!1;for(;!e.done;){i=!0;let a=!1,o=!this._allTiles.some(i=>{if(!n&&!r&&!i.visible)return e.done;let o=i;if(i.hasPendingUpdate(4)){if(!t||i.unmergableChildCount>0)return e.done;for(i.resetPendingUpdate(4);o.parent!=null&&o.parent.unmergableChildCount===0&&o.parent.resetPendingUpdate(4);)o=o.parent;this._mergeTile(o),a=!0,e.madeProgress()}else if(i.resetPendingUpdate(1)){let t=!0,n=i.level;if(n>=A){let e=e=>e.leaf||n-e.level<A;for(let r=0;r<4;++r){let a=i.findNeighborTile(P[r],e);a!=null&&n-a.level===A&&(t=!1,V&&(N(a.leaf),N(a.hasPendingUpdate(1))))}}t?(this._splitTile(i),e.madeProgress(),a=!0):i.setPendingUpdate(1)}return e.done});if(a&&(this._allTilesSorted=!1,this._allTilesDirty=!0),o){if(!n){n=!0;continue}if(!a)break}else this._allTilesDirty=!0}i?e.madeProgress():this._allTilesDirty=!0,this._allTilesCreated=!this.allTiles.some(e=>e.hasPendingUpdate(1)||e.hasPendingUpdate(4)&&e.unmergableChildCount===0),this._sortTiles(e)}_updateElevation(e){e.done||this._allTiles.some(t=>(t.resetPendingUpdate(8)&&(this._updateTileGeometryState(t),e.madeProgress()),e.done))}_updateElevationSources(e){e.done||this._allTiles.some(t=>(t.needsElevationSourceUpdate()&&(t.updateAgents(0),t.markElevationSourceUpdateRequested(),e.madeProgress()),e.done))}_updateTextures(e){e.done||this._allTiles.some(t=>(this._updateTileTexture(t,e),e.done))}_updateClippingExtent(){this.spatialReference&&(this.updateOverlayParameters(),this.requestRender(1),this.overlayManager.setPlacementDirty(),this._updateRootTiles())}get _lodBias(){return this.view.qualitySettings.tiledSurface.lodBias-(1-this.view.quality)*Be}_getLodBiasCorrectedScale(e){let t=this.tilingScheme.levels,n=c(e-this._lodBias,0,t.length-1),r=n-Math.floor(n),i=t[Math.floor(n)].scale,a=t[Math.ceil(n)].scale;return i*(1-r)+a*r}_removeAllTiles(){this._pendingTilesToUpdate.clear(),this._pendingTilesForElevationUpdateEvent.clear(),this._rootTiles!=null&&(this._rootTiles.forEach(e=>this._purgeTile(e)),this._setRootTiles(null),this.notifyChange(`ready`)),this._allTiles.clear(),this.notifyChange(`demResolution`),this.emit(`tiles-changed`,{allTiles:this.allTiles}),this.renderer.visible=!1}_purgeSubtree(e){let t=e.children;t[0]&&(this._purgeTile(t[0]),this._purgeTile(t[1]),this._purgeTile(t[2]),this._purgeTile(t[3]),e.clearChildren())}_purgeTile(e){e.leaf?_t(e):this._purgeSubtree(e),this._allTiles.removeUnordered(e),this._unloadTile(e),e.dispose(),this._tileCache.put(K._tileMemcacheKey,e),this.notifyChange(`demResolution`),this.emit(`tiles-changed`,{allTiles:this.allTiles})}_unloadTile(e){this._pendingTilesToUpdate.delete(e),this._pendingTilesForElevationUpdateEvent.delete(e),e.unload()}_splitTile(e){j(e.leaf,`Tile that is already split should not be split again!`),j(e.rendered,`Tile marked to split is not rendered`),_t(e);let t=e.createChildren();this._allTiles.pushArray(t),this.notifyChange(`demResolution`),this.emit(`tiles-changed`,{allTiles:this.allTiles}),e.updateAgentSuspension(),j(e.rendered,`parent should be rendered`),t.forEach(e=>this._loadTile(e)),t.forEach(e=>this._pendingTilesToUpdate.add(e)),this._unloadTile(e),this._markAllTileNeighborsForUpdate(e),this._emitTileScaleChange(e,e.level+1),this._allTilesDirty=!0,this._shortBatches&&this._updatePendingTileGeometries(),t.forEach(e=>Z(e,e.hasPendingUpdate(1))),++this._performanceInfo.numSplit}_emitTileScaleChange(e,t=e.level){X.spatialReference=this.spatialReference,X.extent=e.extent,X.scale=this._getLodBiasCorrectedScale(t),this.emit(`scale-change`,X)}createTile(e,t,n,r){j(!!r,`createTile sanity check`);let i=this._acquireTile(e,t,n,r);return i.updateClippingStatus(this.groundExtent),i.updateScreenDepth(this.view.state.contentCamera.viewProjectionMatrix),this._shouldSplit(i)&&i.setPendingUpdate(1),i}get _shortBatches(){return this.view.state.mode!==2}_mergeTile(e){j(!e.hasPendingUpdate(1),`_mergeTile sanity check`),j(!e.leaf,`Cannot merge a leaf`),e.leaf||(this._purgeSubtree(e),j(!e.renderData,`Merging tile with existing render data?`),this._loadTile(e),this._markTileToUpdate(e),this._emitTileScaleChange(e),this._shortBatches&&this._updatePendingTileGeometries(),Z(e,!1),this._allTilesDirty=!0,++this._performanceInfo.numMerged)}_loadTile(e){e.load(),this.requestUpdate(),this._allTilesDirty=!0,this.overlayManager?.hasOverlays&&e.updateOverlayParameters(this.overlayManager)}_handleLayerViewChanges(e=lt){if(!this._layerViewsDirty)return;this._layerViewsDirty=!1;let t=!1,n=new Set,r=-1;for(let e=this.view.allLayerViews.length-1;e>=0;e--){let i=this.view.allLayerViews.items[e];if(n.add(i.uid),F(i)||I(i)){if(this._basemapLayerViewHandles.has(i.uid)&&!I(i)){let e=this._layerClassFromLayerView(i),n=this.getLayerIndexByUID(e,i.uid);n!=null&&((n<r||r==null)&&(t=!0),r=n)}else this._registerTiledLayerView(i),i.layer.loaded&&(t=!0)}}this._basemapLayerViewHandles.forEach((e,r)=>{n.has(r)||(this._unregisterTiledLayerView(r),t=!0)}),t&&this._updateTiledLayers(),this.hasCompositeBlendMode=this._hasCompositeBlendMode(),this._evaluateTransparency(),e.madeProgress()}get _isFullyTransparent(){if(this.view.map?.ground?.opacity>0)return!1;for(let e of this.view.allLayerViews.items)if(L(e)&&!Se(e.layer)&&e.fullOpacity!==0)return!1;return!0}_hasCompositeBlendMode(){for(let e of this.view.allLayerViews.items)if((R(e)||I(e))&&at(ot[e.layer.blendMode]))return!0;return!1}_layerClassFromLayerView(e){return+!z(e)}_registerTiledLayerView(e){let t=[];if((R(e)||I(e))&&t.push(h(()=>e.layer.blendMode,()=>{this.hasCompositeBlendMode=this._hasCompositeBlendMode(),this._updateTileTextures(2)})),!I(e)){let n=this._layerClassFromLayerView(e);t.push(h(()=>!e.destroyed&&e.suspended,()=>this._updateTiledLayers())),t.push(h(()=>!e.destroyed&&e.fullOpacity,()=>this._updateTileTextures(2)));let{layer:r}=e;`effectiveScaleRange`in r&&t.push(h(()=>!e.destroyed&&r.effectiveScaleRange,()=>this._restartAllAgents(n))),t.push(e.on(`data-changed`,()=>{let t=this.getLayerIndexByUID(n,e.uid);t!=null&&this._invalidateLayerData(t,n)}))}this._unregisterTiledLayerView(e.uid),this._basemapLayerViewHandles.set(e.uid,t)}_unregisterTiledLayerView(e){let t=this._basemapLayerViewHandles.get(e);if(t){for(let e of t)e.remove();this._basemapLayerViewHandles.delete(e)}}_updateTiledLayers(){if(!this.tilingScheme||this.view.suspended)return;let e=this.view.allLayerViews,t=[[],[]],n=null;e.forEach(e=>{if(!e.layer||e.suspended||!F(e)||!e.fullExtent)return;let r=this._layerClassFromLayerView(e);if(r===1){let t=e.displayLevelRange.maxLevel;t!==1/0&&(n===null||t>n)&&(n=t)}t[r].push(e)});for(let e of je){let n=this._layerViews[e],r=t[e];r.reverse();let i=r.length,a=n.length!==i,o=Array(i),s=Array(n.length);this._layerIndexByUid[e].clear();for(let t=0;t<i;t++){let i=r[t].uid;this._layerIndexByUid[e].set(i,t);let c=n.indexOf(r[t]);o[t]=c,t!==c&&(a=!0),c>-1&&(s[c]=t)}if(a){let t=this._postorderIterator;for(t.reset(this._rootTiles);!t.done;)t.next().modifyLayers(s,o,e);this._layerViews[e]=r,this._restartAllAgents(e),this._updateTilesVisibility(this._rootTiles)}}this.tilingScheme.ensureMaxLod(n)&&(this._viewChangeUpdate(),this.notifyChange(`tilingScheme`))}_restartAllAgents(e){let t=this._postorderIterator;for(t.reset(this._rootTiles);!t.done;){let n=t.next();n.restartAgents(e),e===0&&n.computeElevationBounds()}this._updateRootTileElevationRange()}layerViewByIndex(e,t){return this._layerViews[t][e]}numLayers(e){return this._layerViews[e].length}_updateTileTextures(e){this._allTiles.forAll(t=>{t.updateAgents(1),e===1?this.renderer.updateTileTexture(t,16):t.updateRenderData(1,e)}),this._evaluateTransparency()}_invalidateLayerData(e,t){this._rootTiles!=null&&(W(this._rootTiles,n=>n.removeLayerAgent(e,t)),W(this._rootTiles,n=>{n.invalidateLayerData(e,t),n.restartAgents(t)}))}setTileTreeDirty(e){this._allTilesDirty=!0,e&&(this._allTilesCreated=!1)}requestRender(e=1){this.renderer.requestRender(e)}requestUpdate(){++this._pendingUpdates===1&&(this._hasPendingUpdates=!0)}requestTileData(e,t,n,r){let i=this.layerViewByIndex(t,n),{tilemapCache:a}=i;return!a||M(i)?this._requestTileData(e,n,i,r):(++this._asyncWorkItems,a.fetchAvailability(e.level,e.lij[1],e.lij[2],{...r,timeout:6e3}).catch(t=>{throw te(r),p(t)||this._dataMissing(e,n,i),t}).then(()=>this._frameTask.schedule(()=>this._requestTileData(e,n,i,r),r.signal)).finally(()=>--this._asyncWorkItems))}_requestTileData(e,t,n,r){return this.destroying?Promise.resolve():t===0?z(n)?this._requestElevationTileData(e,n,r):Promise.reject():L(n)?this._requestMapTileData(e,n,r):Promise.reject()}_requestElevationTileData(e,t,n){++this._asyncWorkItems;let r=r=>{!m(n)&&r&&(this.setMemoryDirty(),this.requestUpdate(),this._elevationDataArrived(e,t,r))},i=n=>{p(n)||(s.getLogger(this).error(`Tile ${e.lij.toString()} layer 0/${t.uid} error ${n}`),this._dataMissing(e,0,t),this.requestUpdate())};return t.fetchElevationTile(e,{...Ce,...n}).then(e=>this._frameTask.schedule(()=>r(e)),i).finally(()=>--this._asyncWorkItems)}_elevationDataArrived(e,t,n){let r=this._layerIndexByUid[0].get(t.uid);if(r==null){s.getLogger(this).warn(`TerrainSurface: received data from unknown layer %d %s`,0,e.lij.toString());return}let i=new Oe(e.lij,e.extent,n);e.dataArrived(r,0,i),this.emit(`tile-data-changed`,{tile:e,layerIndex:r,layerClass:0});let a=[e],o=e.level,c=this._iteratorPool.acquire();for(c.reset(a);!c.done;){let e=c.next();e.findElevationBoundsForLayer(r,o),e.computeElevationBounds()}o===0&&this._updateRootTileElevationRange(),c.remove(),this._updateTilesVisibility(a)}_requestMapTileData(e,t,n){++this._asyncWorkItems;let r=(r,i)=>{B(i),m(n)||(console.error(`Tile ${e.lij.toString()} layer 1/${t.uid} error ${r}`),this._dataMissing(e,1,t),this.requestUpdate())},i=e=>t=>r(t,e);return t.fetchTile(e.lij,n).then(r=>this._frameTask.schedule(()=>{this.requestUpdate(),m(n)?B(r):this._mapTileDataArrived(e,t,r)},n.signal,i(r)).catch(i(r)),(e,t=null)=>this._frameTask.schedule(()=>r(e,t))).finally(()=>--this._asyncWorkItems)}_mapTileDataArrived(e,t,n){let r=this.getLayerIndexByUID(1,t.uid);r==null?(B(n),s.getLogger(this).warn(`TerrainSurface: received data from unknown layer`)):(e.dataArrived(r,1,n),this.emit(`tile-data-changed`,{tile:e,layerIndex:r,layerClass:1}))}_dataMissing(e,t,n){let r=this.getLayerIndexByUID(t,n.uid);r==null?s.getLogger(this).warn(`TerrainSurface: received data from unknown layer`):(e.dataMissing(r,t),this.emit(`tile-data-changed`,{tile:e,layerIndex:r,layerClass:t}))}get performanceInfo(){let e=this._performanceInfo;return e.numNodes=this._allTiles.length,e.numLeaves=e.numVisible=e.numRendered=e.numLoadedPerLevel.length=e.numRenderedPerLevel.length=0,this._allTiles.forAll(t=>{t.leaf&&e.numLeaves++;let n=t.level;t.renderData&&(e.numLoadedPerLevel[n]=(e.numLoadedPerLevel[n]||0)+1),t.visible&&(e.numVisible++,t.rendered&&(e.numRenderedPerLevel[n]=(e.numRenderedPerLevel[n]||0)+1,e.numRendered++))}),e}setMemoryDirty(){this._usedMemory=null}get usedMemory(){return this.tilingScheme?(this._usedMemory??=this._recalculateUsedMemory(),this._usedMemory??0):0}_recalculateUsedMemory(){return this.tilingScheme?Math.round(this._allTiles.reduce((e,t)=>e+t.usedMemory,0)):null}getUsedMemoryForLayerView(e){let t=0,n=this._layerClassFromLayerView(e),r=this.getLayerIndexByUID(n,e.uid);return r!=null&&this._allTiles.forAll(e=>t+=e.getUsedMemoryForLayer(n,r)),t}get renderPatchBorders(){return this._renderer.renderPatchBorders}set renderPatchBorders(e){this._renderer.renderPatchBorders=e}get renderingDisabled(){return this._renderer.renderingDisabled}set renderingDisabled(e){this._renderer.renderingDisabled=e}get test(){}checkAllTilesWaterproofness(e=`render-patch-groups`){}get isGlobal(){return this._isGlobal}get isGeographic(){return this._isGeographic}get isWebMercator(){return this._isWebMercator}get isWebMercatorOnPlateCarree(){return this._isWebMercatorOnPlateCarree}isEastEndWrap(e){return this._isGlobal&&e[2]===this.lijEastEnd(e[0])-1}isWestEndWrap(e){return this._isGlobal&&e[2]===0}lijEastEnd(e){return 1<<e+ +!!this._isGeographic}wrapEastWest(e){let t=this.lijEastEnd(e[0]),n=e[2];if(0<=n&&n<t)return e;if(!this._isGlobal)return null;let r=(n+(n<0?t:0))%t;return[e[0],e[1],r]}enableInternalChecks(e){Ke(e)}enableWaterproofnessChecks(e){qe(e)}static cleanupTerrainSurface(){mt.prune()}enable(e){e!==this.enabled&&(this._set(`enabled`,e),e?(this._updateRootTiles(),this.freeze=!1,this.view.elevationProvider.register(0,this)):(this.view.elevationProvider.unregister(this),this.freeze=!0,this._removeAllTiles(),this._setRootTiles(null)),this.notifyChange(`ready`))}updateOverlayParameters(){let{overlayManager:e}=this;this.allTiles.forAll(t=>t.updateOverlayParameters(e))}};e([y()],q.prototype,`_renderer`,void 0),e([y({constructOnly:!0})],q.prototype,`_scaleRangeQueries`,void 0),e([y({constructOnly:!0})],q.prototype,`view`,void 0),e([y({constructOnly:!0})],q.prototype,`overlayManager`,void 0),e([y()],q.prototype,`_hasPendingUpdates`,void 0),e([y()],q.prototype,`_asyncWorkItems`,void 0),e([y()],q.prototype,`_allTilesDirty`,void 0),e([y()],q.prototype,`_allTilesSorted`,void 0),e([y()],q.prototype,`allTilesCreated`,null),e([y()],q.prototype,`_allTilesCreated`,void 0),e([y()],q.prototype,`_viewChanged`,void 0),e([y({type:Number})],q.prototype,`heading`,void 0),e([y()],q.prototype,`_splitLimits`,void 0),e([y()],q.prototype,`_frameTask`,void 0),e([y()],q.prototype,`demResolution`,null),e([y({readOnly:!0})],q.prototype,`snapLevel`,null),e([y({readOnly:!0})],q.prototype,`lodSnappingEnabled`,null),e([y()],q.prototype,`_stencilEnabledExtents`,null),e([y({readOnly:!0})],q.prototype,`userClippingExtent`,null),e([y()],q.prototype,`_rootTilesExtent`,void 0),e([y({readOnly:!0})],q.prototype,`groundExtent`,null),e([y({readOnly:!0})],q.prototype,`fullGroundExtent`,null),e([y({readOnly:!0})],q.prototype,`_tilingSchemeExtent`,null),e([y({readOnly:!0})],q.prototype,`updating`,null),e([y({readOnly:!0})],q.prototype,`readyToRun`,null),e([y(De)],q.prototype,`updatingProgress`,void 0),e([y({readOnly:!0})],q.prototype,`updatingProgressValue`,null),e([y()],q.prototype,`_maxNumUpdating`,void 0),e([y()],q.prototype,`baseOpacity`,null),e([y()],q.prototype,`hasCompositeBlendMode`,void 0),e([y({readOnly:!0})],q.prototype,`viewingMode`,null),e([y()],q.prototype,`maxTextureScale`,void 0),e([y({readOnly:!0})],q.prototype,`ready`,null),e([y({readOnly:!0})],q.prototype,`rootTiles`,null),e([y()],q.prototype,`_rootTiles`,void 0),e([y({readOnly:!0})],q.prototype,`spatialReference`,null),e([y({type:t})],q.prototype,`backgroundColor`,null),e([y({value:!1})],q.prototype,`slicePlaneEnabled`,null),e([y({readOnly:!0})],q.prototype,`tilingScheme`,void 0),e([y({readOnly:!0})],q.prototype,`tilingSchemeLocked`,null),e([y({readOnly:!0})],q.prototype,`tilingSchemeLogic`,void 0),e([y()],q.prototype,`wireframe`,null),e([y()],q.prototype,`opaque`,null),e([y()],q.prototype,`invisible`,null),e([y({value:!1})],q.prototype,`freeze`,null),e([y()],q.prototype,`fadeDuration`,null),e([y()],q.prototype,`_xNormalizer`,null),e([y()],q.prototype,`visibleElevationRange`,void 0),e([y()],q.prototype,`_rootTileElevationRange`,void 0),e([y()],q.prototype,`_layerViewsDirty`,void 0),e([y()],q.prototype,`renderPatchBorders`,null),e([y()],q.prototype,`renderingDisabled`,null),e([y({readOnly:!0})],q.prototype,`enabled`,void 0),q=K=e([re(`esri.views.3d.terrain.TerrainSurface`)],q);const ft=q,J=b(),Y=new ye,pt=C(),mt=new f,X={spatialReference:null,extent:null,scale:0};function ht(e,t,n){for(let r of e){if(!r.containsPointXY(t,n))continue;let e=r;for(;e&&!e.renderData;){let r=+(t>e.extentMidX)+(n<e.extentMidY?2:0);e=e.children[r]}let i=e?.renderData?.geometryState.samplerData??null;return ke(t,n,i)}return null}function Z(e,t){!e.leaf||e.level<A||$(e,e=>{t&>(e);let n=Q(e);if(e.maxLevelDeltaNeighborCount++,n){let t=e.parent;for(;t;){let e=Q(t);if(t.unmergableChildCount++,e)t=t.parent;else break}}})}function gt(e){if(e.hasPendingUpdate(1))return;let t=e.parent;for(;t?.resetPendingUpdate(4);)t=t.parent;e.resetPendingUpdate(4),e.leaf&&e.setPendingUpdate(1),e.level<A||$(e,e=>{gt(e)})}function _t(e){e.level<A||$(e,e=>{if(e.maxLevelDeltaNeighborCount--,e.maxLevelDeltaNeighborCount===0&&e.unmergableChildCount===0){let t=e.parent;for(;t&&(t.unmergableChildCount--,Q(t));)t=t.parent}})}function Q(e){return e.maxLevelDeltaNeighborCount===0&&e.unmergableChildCount===0}function $(e,t){if(e.level<A)return;let n=e.level-A,r=e.lij[1]>>A,i=e.lij[2]>>A,a=e=>e.leaf||e.level===n;for(let o=0;o<4;++o){let s=e.findNeighborTile(P[o],a);if(!s||s.level!==n)continue;let c=s.lij;(c[1]!==r||c[2]!==i)&&t(s)}}export{ft as default};
|
|
2
|
+
import{__decorate as e}from"tslib";import t from"../../../Color.js";import{filterInPlace as n,difference as r}from"../../../core/arrayUtils.js";import i from"../../../core/CollectionFlattener.js";import{toConst as a}from"../../../core/compilerUtils.js";import{EventedAccessor as o}from"../../../core/Evented.js";import has from"../../../core/has.js";import s from"../../../core/Logger.js";import{clamp as c}from"../../../core/mathUtils.js";import{removeMaybe as l,destroyMaybe as u}from"../../../core/maybe.js";import{MemCachePool as ee}from"../../../core/MemCachePool.js";import d from"../../../core/ObjectPool.js";import f from"../../../core/PooledArray.js";import{throwIfAborted as te,isAbortError as ne,isAborted as p}from"../../../core/promiseUtils.js";import{watch as m,syncAndInitial as h,initial as g,sync as _}from"../../../core/reactiveUtils.js";import"../../../core/scheduling.js";import{getMetersPerUnitForSR as re}from"../../../core/units.js";import{property as v,subclass as ie}from"../../../core/accessorSupport/decorators.js";import{exactEquals as ae,set as oe,copy as se}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{create as y}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{UpdatingHandles as ce}from"../../../core/support/UpdatingHandles.js";import{getReferenceEllipsoid as b,radiusModifier as le}from"../../../geometry/ellipsoidUtils.js";import{projectWithoutEngine as ue}from"../../../geometry/projectionUtils.js";import x from"../../../geometry/SpatialReference.js";import{projectBoundingSphere as de}from"../../../geometry/projection/projectBoundingSphere.js";import{getProjector as fe}from"../../../geometry/projection/projectors.js";import{projectPointToVector as pe}from"../../../geometry/projection/projectPointToVector.js";import{projectVectorToVector as me}from"../../../geometry/projection/projectVectorToVector.js";import{create as S,fromExtent as he,equals as C,intersection as ge,intersectsSphere as _e}from"../../../geometry/support/aaBoundingRect.js";import{copy as ve,create as ye}from"../../../geometry/support/frustumPlanes.js";import{createSpatialReferenceCyclical as be}from"../../../geometry/support/normalizeUtils.js";import{isGeographic as w,isPlateCarree as xe}from"../../../geometry/support/spatialReferenceUtils.js";import{Sphere as Se}from"../../../geometry/support/sphere.js";import{ElevationQueryTileCache as Ce}from"../../../layers/support/ElevationQueryTileCache.js";import{isIntegratedMeshLayer as we,isBaseLayer as Te}from"../../../layers/support/layerUtils.js";import{queueHighPriority as Ee}from"../../../request/queue.js";import{debugFlags as T}from"../support/debugFlags.js";import{ElevationRange as E}from"../support/ElevationRange.js";import{ElevationUpdateEvent as De}from"../support/ElevationUpdateEvent.js";import{calculateElevationUpdateExtents as Oe}from"../support/elevationUpdateExtentUtils.js";import{toBoundingRect as ke}from"../support/extentUtils.js";import{geographicMbsToGeographicExtent as Ae,mbsToGeographicExtent as je,intersectsGeographicExtent as Me}from"../support/sphereExtentUtils.js";import{isSupportedGCSOnGlobe as D}from"../support/supportedSpatialReference.js";import{updatingProgress as Ne}from"../support/updatingProperties.js";import{ElevationBounds as O}from"./ElevationBounds.js";import{ElevationData as Pe,sampleElevation as Fe}from"./ElevationData.js";import{create as Ie}from"./ExtentHelper.js";import{LayerClasses as Le}from"./LayerClass.js";import{OverlayManager as Re}from"./OverlayManager.js";import{PlanarPatch as ze}from"./PlanarPatch.js";import{Queue as Be}from"./Queue.js";import{ScaleRangeQueries as Ve}from"./ScaleRangeQueries.js";import{SphericalPatch as He}from"./SphericalPatch.js";import{SplitLimits as Ue}from"./SplitLimits.js";import{maxRootTiles as k,tooManyRootTilesAfterChangeError as We,tooManyRootTilesForLayerError as Ge,maxTileNeighborLevelDelta as A,maxMemoryLodBias as Ke}from"./TerrainConst.js";import{TerrainRenderer as qe}from"./TerrainRenderer.js";import Je from"./TerrainSurfacePerformanceInfo.js";import{weakAssert as j,isVectorTileLayerView as M,internalAssert as N,oppositeEdge as Ye,neighborEdgeIndices as P,isSurfaceLayerView as F,isGroupLayerView as I,isMapTileLayerView as L,isBlendableLayerView as R,isElevationLayerView as z,releaseTerrainData as B,oppositeCorner as Xe,enableTerrainInternalChecks as V,enableWaterproofTests as Ze,enableInternalTerrainChecks as Qe,enableTerrainWaterproofChecks as $e,neighborCornerIndices as et}from"./terrainUtils.js";import{Tile as tt,lijEquals as H}from"./Tile.js";import{printAllocations as nt}from"./TilePerLayerInfo.js";import{sortTiles as rt,IteratorPreorder as it,IteratorPostorder as at,compareTilesByLij as U,hasLoadableSiblings as ot,sortTilesByPOI as st,traverseTilesPreorder as W}from"./tileUtils.js";import{TilingSchemeLogic as ct}from"./TilingSchemeLogic.js";import{getGroundTransparencyModeFromOpacity as lt}from"./TransparencyMode.js";import{UpsampleInfo as ut}from"./UpsampleInfo.js";import{isCompositeBlendMode as dt,blendModeFromString as ft}from"../webgl-engine/core/shaderLibrary/output/BlendOptions.js";import{hasLayerBasedScaleVisibility as pt}from"../../support/layerViewUtils.js";import{ImmediateTask as G,TaskPriority as mt,noBudget as ht}from"../../support/Scheduler.js";import{TextureCompressionTracker as gt}from"../../support/TextureCompressionTracker.js";import{Yield as _t}from"../../support/Yield.js";var K;let q=class extends o{static{K=this}get allTilesCreated(){return this._allTilesCreated}get allTiles(){return a(this._allTiles)}get renderedTiles(){return rt(n(this._allTiles.toArray(),e=>e.visible&&e.rendered))}get demResolution(){let{_allTiles:e,tilingScheme:t}=this;if(e.length===0)return{min:1,max:1};let n=re(t.spatialReference),r=1/0,i=-1/0;for(let a of e){let e=t.resolutionAtLevel(a.level)*n;r=Math.min(r,e),i=Math.max(i,e)}return{min:r,max:i}}constructor(e){super(e),this.terrainTextureCompressionTracker=new gt,this._iteratorPool=new d(()=>new it,e=>e.remove=()=>this._iteratorPool.release(e)),this._postorderIterator=new at,this._hasPendingUpdates=!1,this._pendingUpdates=0,this._asyncWorkItems=0,this._allTilesDirty=!0,this._allTilesSorted=!0,this._allTilesCreated=!1,this._usedMemory=null,this._performanceInfo=new Je,this._waterproofnessErrorHandle=null,this._viewChanged=!1,this.heading=0,this._inFrameTask=!1,this._viewChangeUpdateDirty=!1,this._eyePosRenderSR=y(),this._eyePosSurfaceSR=y(),this._splitLimits=new Ue,this._layerViews=[[],[]],this._layerIndexByUid=[new Map,new Map],this._basemapLayerViewHandles=new Map,this._updatingHandles=new ce,this._poiWatchHandle=null,this._frameTask=G,this._allTiles=new f,this._upsampleInfoPool=new d(()=>new ut),this._shouldEmitChangeEvent=!1,this._rootTilesExtent=S(),this.updatingProgress=.5,this._maxNumUpdating=1,this.maxTextureScale=1.2,this._spatialReference=x.WebMercator,this._elevationProjectorCache=new Map,this.visibleElevationRange=new E(1/0,-1/0),this._rootTileElevationRange=new E(1/0,-1/0),this._tilingSchemeSpatialReference=null,this._updatingRootTiles=!1,this._pendingTilesForElevationUpdateEvent=new Set,this._pendingTilesToUpdate=new Set,this.totalGeometryUpdates=0,this.totalTileUpdates=0,this._layerViewsDirty=!1,this.unloadedMemory=0,this.ignoresMemoryFactor=!1,this._isWebMercator=!1,this._isWebMercatorOnPlateCarree=!1,this.enabled=!0;let{view:t}=e;this.overlayManager=new Re({...e,terrainSurface:this}),this._isGlobal=!t.state?.isLocal,this._isGeographic=this._spatialReference?.isGeographic??!1,this._tileConstructor=this._isGlobal?He:ze,this._ellipsoid=b(t.spatialReference),this._renderer=new qe(this,this.overlayManager.renderer,this._allTiles,this.terrainTextureCompressionTracker,t.resourceController.memoryController),pt()||(this._scaleRangeQueries=new Ve)}initialize(){let{view:e}=this,{resourceController:t}=e,{memoryController:n}=t;e.stage.addRenderPlugin(this._renderer),this._tileCache=new ee((e,t)=>n.newCache(e,t),`terrain-tile`),this._upsampleMapCache=n.newCache(`terrain-upsample`,({tile:e})=>e.unloadMapData()),this._elevationQueryCache=new Ce(n.newCache(`elevation-query`));let r=this.overlayManager;this.addHandles([m(()=>r.renderer.isEmpty,()=>this._evaluateTransparency()),m(()=>this.renderer.visible,e=>this.freeze=!e),m(()=>this.heading,e=>{this._renderer.updateHeading(e),this._updateTileTextures(0)},h)],`overlayManager`),this._updatingHandles.add(()=>({heading:e.camera?.heading,state:e.state?.mode}),({heading:e,state:t})=>{if(e==null)return;if(this.isGlobal&&this.isGeographic||this.isWebMercatorOnPlateCarree){this.heading=Math.round(e/90)*90%360;return}let n=Math.round(e)%360,r=Math.abs(n-this.heading);(t===2||Math.min(r,360-r)>=30)&&(this.heading=n)},g),this.addHandles([m(()=>this.baseOpacity,()=>{this._handleLayerViewChanges(),this._updateTileTextures(this._evaluateTransparency()?1:2)},h),m(()=>this.hasCompositeBlendMode,()=>this._updateTileTextures(this._evaluateTransparency()?1:2),h),m(()=>this.backgroundColor,(e,t)=>{e?.equals(t)||(this._handleLayerViewChanges(),this._renderer.updateTileBackground(e))},_),m(()=>this.snapLevel,()=>this._viewChanged=!0,_),m(()=>this.view.pointsOfInterest,e=>{this._renderer.pointsOfInterest=e,this._poiWatchHandle=l(this._poiWatchHandle),e&&(this._poiWatchHandle=this._updatingHandles.add(()=>e.focus?.renderLocation,()=>this._allTilesSorted=!1,{equals:ae}))}),m(()=>T.TERRAIN_TILE_TREE_SHOW_TILES,t=>{t&&!this._treeDebugger?import(`../layers/support/TerrainTileTree3DDebugger.js`).then(({TerrainTileTree3DDebugger:t})=>{!this._treeDebugger&&T.TERRAIN_TILE_TREE_SHOW_TILES&&(this._treeDebugger=new t({view:e}))}):t||(this._treeDebugger=u(this._treeDebugger))},g)]);let{spatialReference:a}=e;this._extentHelper=Ie(this.viewingMode,{layers:e.map.allLayers,layerViews:e.allLayerViews,viewSpatialReference:a});let o=new i({getCollections:()=>e.defaultsFromMap?.mapCollections?.map(({layers:e})=>e),getChildrenFunction:e=>e&&`layers`in e?e.layers:null}),s=new ct({layers:o,extentHelper:this._extentHelper,viewingMode:this.viewingMode,viewSpatialReference:a});this._set(`tilingSchemeLogic`,s),this._updateTilingScheme();let c=t.scheduler;this._frameTask=c.registerTask(mt.TERRAIN_SURFACE,this),this.addHandles([m(()=>this._stencilEnabledExtents,e=>this._renderer.setStencilEnabledLayerExtents(e),g),m(()=>this.tilingSchemeLogic.tilingScheme,()=>this._updateTilingScheme(),_),m(()=>this.groundExtent,()=>this._updateRootTiles(),g),e.on(`resize`,()=>this._viewChangeUpdate()),m(()=>{let t=e.state;return[this._lodBias,this.lodSnappingEnabled,e.quality,t.camera,t.contentCamera,t.fixedContentCamera]},()=>this._viewChangeUpdate(),h),m(()=>e.qualitySettings?.fadeDuration,e=>this._renderer.textureFadingEnabled=e>0,g),m(()=>e.qualitySettings?.physicallyBasedRenderingEnabled,e=>this._renderer.pbrMode=e?5:0,g),m(()=>e.qualitySettings?.tiledSurface.elevationLevelDelta,()=>{this._allTiles.forAll(e=>this.updateElevationSources(e)),this._updateAllTileGeometries()}),m(()=>this.userClippingExtent,()=>this._updateClippingExtent(),_)]),this.addHandles(e.allLayerViews.on(`after-changes`,()=>this._layerViewsDirty=!0)),this._layerViewsDirty=!0,this._handleLayerViewChanges(),this._renderer.updateTileBackground(this.backgroundColor)}clearHandles(){this._updatingHandles?.removeAll(),this.removeAllHandles(),this._basemapLayerViewHandles.forEach((e,t)=>this._unregisterTiledLayerView(t)),this._basemapLayerViewHandles.clear()}destroy(){this._waterproofnessErrorHandle?.remove(),this._waterproofnessErrorHandle=null,this._frameTask.remove(),this._frameTask=G,this._updatingHandles?.destroy(),this._removeAllTiles(),this._set(`tilingSchemeLogic`,u(this.tilingSchemeLogic)),this._basemapLayerViewHandles.forEach((e,t)=>this._unregisterTiledLayerView(t)),this._basemapLayerViewHandles.clear(),this._set(`overlayManager`,u(this.overlayManager)),this._tileCache=u(this._tileCache),this._allTiles.prune(),tt.prune(),this._treeDebugger=u(this._treeDebugger),this._renderer.destroyed||(this.view.stage.removeRenderPlugin(this._renderer),this._renderer.destroy()),this._renderer=null,this._iteratorPool=u(this._iteratorPool),this._upsampleMapCache=u(this._upsampleMapCache),this._elevationQueryCache=u(this._elevationQueryCache),this._set(`view`,null),this._extentHelper=u(this._extentHelper),this._upsampleInfoPool=u(this._upsampleInfoPool),nt(),this._layerViews.forEach(e=>e.length=0),this._performanceInfo=null}get renderer(){return this._renderer}get frustum(){return this.view.state.camera.frustum}get snapLevel(){return this.lodSnappingEnabled?this.view.terrainLevel:null}get lodSnappingEnabled(){return this.view.qualitySettings.tiledSurface.reduceTileLevelDifferences}get upsampleInfoPool(){return this._upsampleInfoPool}get upsampleMapCache(){return this._upsampleMapCache}get elevationQueryCache(){return this._elevationQueryCache}get hasStencilEnabledExtents(){return!!this._stencilEnabledExtents?.length}get _stencilEnabledExtents(){let e=this.spatialReference,t=!!has(`enable-feature:im-as-ground`);return e==null?null:Iterator.from(this.view.allLayerViews).map(n=>{let{layer:r}=n;if(!we(r)||t&&!r.isUsedAsGroundLayer)return null;let{fullExtent:i}=r,a=i==null||i.spatialReference.equals(e)?i:ue(i,i.spatialReference,e);return a?he(a):null}).filter(e=>e!=null).toArray()}get userClippingExtent(){let{spatialReference:e}=this,t=this.view?.clippingArea;if(t==null||e==null)return null;let n=S(),r=ke(t,n,e)?n:null,i=this._get(`userClippingExtent`);return C(r,i)?i:r}get rootTilesExtent(){return this._rootTilesExtent}get groundExtent(){let e=ge(this.fullGroundExtent,this.userClippingExtent,S()),t=this._get(`groundExtent`);return C(e,t)?t:e}get fullGroundExtent(){return this._tilingSchemeExtent==null?this._rootTilesExtent:this._tilingSchemeExtent}get _tilingSchemeExtent(){return this.tilingSchemeLogic?.extent}get updating(){return this._hasPendingUpdates||(this._maxNumUpdating=1),this.enabled&&!!((this.readyToRun||this._updatingHandles?.updating||this._asyncWorkItems>0)&&this.ready&&!this.freeze||this.overlayManager?.updating||this.terrainTextureCompressionTracker.compressing)}get readyToRun(){return this.enabled&&(this._hasPendingUpdates||this._viewChanged||this._allTilesDirty||!this._allTilesSorted||this._layerViewsDirty||this._scaleRangeQueries?.updating||this._frameTask.updating)&&this.ready&&!this.freeze}get updatingProgressValue(){return this._maxNumUpdating=Math.max(this._pendingUpdates,this._maxNumUpdating),1-this._pendingUpdates/this._maxNumUpdating}get baseOpacity(){return this.view?.map?.ground?.opacity??1}set baseOpacity(e){this.view.map.ground.opacity=e}get viewingMode(){return this.view.state.viewingMode}get ready(){return!this.enabled||this._rootTiles!=null}get rootTiles(){return this._rootTiles}get spatialReference(){return this.tilingScheme?.spatialReference??null}get backgroundColor(){return this.view?.map?.ground?.surfaceColor}set backgroundColor(e){this.view.map.ground.surfaceColor=e}set slicePlaneEnabled(e){this._renderer.slicePlaneEnabled=e,this._set(`slicePlaneEnabled`,e),this._evaluateTransparency()}get tilingSchemeLocked(){return this.tilingSchemeLogic?.tilingSchemeLocked??!1}get wireframe(){return this._renderer?.wireframe}set wireframe(e){e!==this._renderer.wireframe&&(this._renderer.wireframe=e,this._updateAllTileGeometries())}get opaque(){return this._renderer.transparency===0}get invisible(){return this._renderer.transparency===3}set freeze(e){this._set(`freeze`,e),this._viewChangeUpdate()}get fadeDuration(){return this.view.qualitySettings.fadeDuration??0}intersect(e,t,n,r){this._renderer.intersectRay(e,t,n,r)}getElevationLevelDelta(e){return e<4?3:this.view.qualitySettings.tiledSurface.elevationLevelDelta}get _xNormalizer(){return be(this._spatialReference)}getElevation(e,t,n,r){let i=this._rootTiles;if(!i?.length||!this.enabled||i[0].layerInfo[0].length===0)return null;let a=this._elevationProjectorCache.get(r);if(a===void 0&&(a=fe(r,this._spatialReference)??null,this._elevationProjectorCache.set(r,a)),a==null)return s.getLogger(this).error(`TerrainSurface.getElevation(): could not project given point to tiling scheme coordinate system`),null;let o=oe(J,e,t,n);a(o,0,o,0);let c=this._xNormalizer?.normalize(o[0])??o[0],l=o[1];return St(i,c,l)}getElevations(e,t,n){let r=this._rootTiles,i=r?r[0].layerInfo[0].length:0;if(!r?.length||i===0||!this.enabled)for(let e=0;e<t;++e)n(e,null);else for(let i=0;i<t;++i){let t=i*3,a=e[t],o=e[t+1],s=St(r,a,o);n(i,s)}}getLayerIndexByUID(e,t){return this._layerIndexByUid[e].get(t)}getScale(e){if(!this.tilingScheme)return null;if(!pe(e,J,this.spatialReference))return s.getLogger(this).error(`TerrainSurface.getScale(): could not project given point to tiling scheme coordinate system`),null;let t=this._rootTiles;if(t!=null){for(let e of t)if(e?.containsPoint(J)){let t=e;for(;t.children[0]&&!t.rendered;){let e=t.children[0].extent,n=0;J[0]>e[2]&&(n+=1),J[1]<e[1]&&(n+=2),t=t.children[n]}return this._getLodBiasCorrectedScale(t.level)}}return 1/0}getSphereElevationRange(e,t){if(!this.enabled)return null;let n=this._rootTiles,r=this._tilingSchemeSpatialReference;if(n==null||r==null||n.length===0)return null;let i=w(r);if(i){let n=w(t)&&D(t),i=b(t);if(n&&D(r)&&i===b(r))Ae(e,Y,i.radius);else if(!je(e,t,Y,r))return s.getLogger(this).error(`TerrainSurface.getSphereElevationRange(): could not project the query sphere`),null}else if(!de(e,t,yt,r))return s.getLogger(this).error(`TerrainSurface.getSphereElevationRange(): could not project the query sphere`),null;let a=new E,o=[];for(let e of n)o.push(e);let c=0;for(;c<o.length;){let e=o[c];if(++c,!(i?Me(e.extent,Y,r):_e(e.extent,yt)))continue;let t=e.children;if(t[0]==null||e.rendered)a.expandElevationRangeValues(e.elevationBoundsMin,e.elevationBoundsMax);else for(let e of t)o.push(e)}return a}getRootElevationRange(){return this.enabled&&this._rootTiles!=null?new E(this._rootTileElevationRange.minElevation,this._rootTileElevationRange.maxElevation):null}getLowerBoundRadius(){let e=(this._ellipsoid.radius+this.visibleElevationRange.minElevation)*le;return Math.min(e,this._ellipsoid.radius)}queryVisibleScaleRange(e,t,n,r){if(!this._scaleRangeQueries)return;let i=t?this.tilingScheme.levelAtScale(t):0,a=n?this.tilingScheme.levelAtScale(n):1/0,o=this._lodBias;this._scaleRangeQueries.queryVisibleLevelRange(e,i+o,a+o,r)}_evaluateTransparency(){let e=this.baseOpacity,t=this.overlayManager.renderer.isEmpty,n=this._renderer.transparency,r=this._isFullyTransparent?lt(0,t):e>=1&&!this.hasCompositeBlendMode&&!this._renderer.slicePlaneEnabled?0:1;return this._renderer.transparency=r,n!==r&&(this.notifyChange(`opaque`),this.notifyChange(`invisible`),!0)}_updateTilingScheme(){let{tilingScheme:e}=this.tilingSchemeLogic;if(e===this.tilingScheme)return;j(!!e,`tiling scheme cannot be reset to undefined`),this._isGlobal=!this.view?.state?.isLocal,this.tilingScheme&&this._removeAllTiles();let t=e?.spatialReference??x.WebMercator;this._spatialReference=t,this._isWebMercator=!!t?.isWebMercator,this._isWebMercatorOnPlateCarree=this._isWebMercator&&xe(this.view?.renderSpatialReference),this._isGeographic=t?.isGeographic??!1,this._set(`tilingScheme`,e),this._tilingSchemeSpatialReference=this.tilingScheme?.spatialReference,this._updateClippingExtent(),e&&(this._updateTiledLayers(),this._renderer.tileSize=e.pixelSize,this.overlayManager.spatialReference=e.spatialReference,this._updateRootTiles())}static{this._tileMemcacheKey=`TerrainTileMemcache`}_acquireTile(e,t,n,r){let i=this._tileCache.pop(K._tileMemcacheKey);return i?(i.init(e,t,n,r,this),i):new this._tileConstructor(e,t,n,r,this)}get updatingRootTiles(){return this._updatingRootTiles}_updateRootTiles(){let{groundExtent:e,tilingScheme:t}=this;if(!t)return;if(!this.enabled){this._setRootTiles(null);return}let n=bt,i=t.rootTilesInExtent(e,n,k*5);if(this._rootTiles!=null){if(i.length>k){s.getLogger(this).warn(We);return}let e=this._rootTiles.map(e=>e.lij),t=r(e,i,H);if(this._updatingRootTiles=!0,t.removed.length>0||t.added.length>0){let e=this._rootTiles.filter(e=>t.removed.findIndex(t=>H(t,e.lij))>-1?(this._purgeTile(e),!1):!0);t.added.forEach(t=>e.push(this._newRootTile(t))),this._setRootTiles(e)}}else this._updatingRootTiles=!0,i.length>k&&(s.getLogger(this).warn(Ge),i=t.rootTilesInExtent(e,n,k)),this._setRootTiles(i.map(e=>this._newRootTile(e)));C(n,this._rootTilesExtent)||(this._rootTilesExtent=S(n)),this.renderer.visible=!0,this._viewChangeUpdate(),this.overlayManager.setPlacementDirty(),this.notifyChange(`ready`),this._updateAllTileGeometries(),this._updatingRootTiles=!1,this.checkAllTilesWaterproofness(`root-tiles-updated`)}_updateAllTileGeometries(){let e=this._allTiles.filter(e=>this._canUpdateTileGeometry(e));e.length===0||(e.sort(U),e.forEach(e=>this._renderer.updateTileGeometryState(e)),e.forEach(e=>e.renderData.updateNeighborData()),this._updateTilesGeometries(e)),this._pendingTilesToUpdate.clear()}_updateTilesGeometries(e){let t=e.filter(e=>this._canUpdateTileGeometry(e));if(t.length===0)return;let n=this.renderer;for(let e of t)n.updateGeometryIfNeeded(e);for(let e of t)this._pendingTilesForElevationUpdateEvent.add(e)}_canUpdateTileGeometry(e){return e.loaded&&e.intersectsClippingArea&&e.hasGeometryState}_shouldSplit(e){return e.shouldSplit(this._splitLimits,this._eyePosRenderSR,this.snapLevel)===1}_newRootTile(e){let t=this._acquireTile(0,e[1],e[2],null);return this._shouldSplit(t)&&t.setPendingUpdate(1),this._loadTile(t),this._markTileToUpdate(t),this._updateRootTileElevationRange(),t}_setRootTiles(e){if(this._rootTiles=e,this._allTiles.clear(),e!=null){let t=this._iteratorPool.acquire();for(t.reset(e);!t.done;)this._allTiles.push(t.next());t.remove()}this._renderer.setRootTiles(this._rootTiles),this._updateTilesVisibility(e),this.notifyChange(`demResolution`),this.emit(`tiles-changed`,{allTiles:this.allTiles})}_runViewChangeUpdateIfDirty(){this._viewChangeUpdateDirty&&(this._viewChangeUpdateDirty=!1,this._viewChangeUpdate())}_viewChangeUpdate(){this.view&&!this.freeze&&this.tilingScheme&&this.renderer.visible&&(this._inFrameTask?this._viewChangeUpdateDirty=!0:(this._viewChangeUpdateDirty=!1,this._updateViewDependentParameters(),this._updateTilesVisibility(this._rootTiles)))}_updateClippingStatus(e){e.updateClippingStatus(this.groundExtent)&&e.resetPendingUpdate(8)&&this._updateTileGeometryState(e)}_updateTilesVisibility(e){if(e==null)return;let t=ot(e),n=this.visibleElevationRange,r=t?n.minElevation:1/0,i=t?n.maxElevation:-1/0,a=this.groundExtent,o=this.view.state.contentCamera.viewProjectionMatrix;this.setTileTreeDirty(!1);let s=this._iteratorPool.acquire();for(s.reset(e);!s.done;){let e=s.next();e.updateClippingStatus(a)&&e.resetPendingUpdate(8)&&this._updateTileGeometryState(e),e.computeVisibility(),e.updateScreenDepth(o),e.renderData&&(r=Math.min(e.elevationBoundsMin,r),i=Math.max(e.elevationBoundsMax,i))}s.remove(),this._viewChanged=!0,this._allTilesDirty=!0,this._updatePendingTileGeometries(),isFinite(r)&&isFinite(i)&&(n.minElevation!==r||n.maxElevation!==i)&&(this.visibleElevationRange=new O(r,i))}_updateRootTileElevationRange(){let e=1/0,t=-1/0;this._rootTiles?.forEach(({elevationBoundsMin:n,elevationBoundsMax:r})=>{e=Math.min(e,n),t=Math.max(t,r)});let n=this._rootTileElevationRange;(n.minElevation!==e||n.maxElevation!==t)&&(this._rootTileElevationRange=new O(e,t))}_updateViewDependentParameters(){let{camera:e,contentCamera:t}=this.view.state,n=Math.tan(t.fovX*.5),r=Math.tan(t.fovY*.5),i=this.tilingScheme.pixelSize,a=2**-this._lodBias*e.pixelRatio;this._splitLimits.aboveGround=e.aboveGround,this._splitLimits.fovX=n,this._splitLimits.fovY=r,this._splitLimits.relativeWidthLimit=i/e.width*this.maxTextureScale*a,this._splitLimits.relativeHeightLimit=i/e.height*this.maxTextureScale*a,this._splitLimits.maxLod=this.tilingScheme.getMaxLod(),this._splitLimits.angledSplitBias=this.view.qualitySettings.tiledSurface.angledSplitBias,this.view.state.fixedContentCamera?this._splitLimits.frustum=ve(this._splitLimits.frustum??ye(),t.frustum):this._splitLimits.frustum=null,se(this._eyePosRenderSR,t.eye),me(e.eye,this.view.renderSpatialReference,this._eyePosSurfaceSR,this.spatialReference)}_updateTileGeometryState(e){e.updateVisibility(),this._renderer.updateTileGeometryState(e)&&this._markTileToUpdate(e),this.setMemoryDirty()}_markAllTileNeighborsForUpdate(e){let t;e.forEachLoadedNeighbor(e=>{t??=this._layerViews[1].some(M),t&&e.setPendingUpdate(32),this._pendingTilesToUpdate.add(e)})}_updateTileTexture(e,t){let n=e.resetPendingUpdate(32)?32:e.resetPendingUpdate(16)?16:!1;n&&(this._renderer.updateTileTexture(e,n),this._usedMemory=null,t.madeProgress())}_emitElevationUpdateEventForTiles(){if(!this._shouldEmitChangeEvent)return;let e=this._pendingTilesForElevationUpdateEvent;if(e.size>0){let t=new Float64Array(4*e.size),n=0;for(let r of e)t.set(r.extent,4*n),++n;e.clear();for(let e of Oe(t,this.spatialReference)){let t=new De(this.spatialReference,e,`ground`);this.emit(`elevation-change`,t)}}this._shouldEmitChangeEvent=!1}runTask(e){this._handleLayerViewChanges(e),this._frameTask.processQueue(e),this.renderer.processScaleRangeQueries(this._scaleRangeQueries,e),this._inFrameTask=!0,this._pendingUpdates=0,this._hasPendingUpdates=!1,this._updateAllTilesStatus(e),this._sortTiles(e);let t=!this.view.state.fixedContentCamera;this._mergeAndSplit(e,t),this._updateElevation(e),this._updateTextures(e),t||this._mergeAndSplit(e,!0),this._inFrameTask=!1,this._runViewChangeUpdateIfDirty();let n=this._pendingTilesToUpdate.size>0,r=n&&this._hasPendingGeometryWithoutIndices();if((!e.done||r)&&this._updatePendingTileGeometries(),this._emitElevationUpdateEventForTiles(),e.done&&(e.hasProgressed||n&&!r)&&this.requestUpdate(),this.notifyChange(`updatingProgressValue`),!e.hasProgressed)return _t}_checkTileInvariant(){}_updateAllTilesStatus(e){if(!this._viewChanged||!this._rootTiles||e.done)return;this._viewChanged=!1;let t=!1,n=new Be(this._allTiles.length);n.pushAll(this._rootTiles);let r=this.snapLevel,i=this._splitLimits,a=this._eyePosRenderSR;this._allTiles.forAll(e=>{e.maxLevelDeltaNeighborCount=0,e.unmergableChildCount=0});let o=this.view.state.contentCamera.viewProjectionMatrix;for(;!n.empty;){let e=n.pop(),s=e.parent?.hasPendingUpdate(4),c=e.elevationLevel,l=s?4:e.shouldSplit(i,a,r),u=l===1;e.leaf?Z(e,u):n.pushAll(e.children),s?(e.resetPendingUpdate(1),e.leaf||(e.setPendingUpdate(4),t=!0),this._updateClippingStatus(e),e.updateVisibility(),e.updateScreenDepth(o)):(u?(e.resetPendingUpdate(4),e.leaf&&(e.setPendingUpdate(1),t=!0)):(e.resetPendingUpdate(1)&&e.updateAgentSuspension(),l===2&&e.updateAgents(0),e.leaf||(e.setPendingUpdate(4),e.resetPendingUpdate(1),t=!0)),e.elevationLevel!==c&&this.updateElevationSources(e))}this._allTilesDirty=t,this.requestUpdate(),this._shortBatches&&this._updatePendingTileGeometries(),e.madeProgress()}_sortTiles(e){!e.done&&!this._allTilesSorted&&this.view.pointsOfInterest?.focus&&(st(this._allTiles,this.view.pointsOfInterest.focus.renderLocation),this._allTilesSorted=!0,this._treeDebugger?.update(),e.madeProgress())}_markTileToUpdate(e){N(e.loaded),e.intersectsClippingArea&&(this._pendingTilesToUpdate.add(e),this._markAllTileNeighborsForUpdate(e))}_hasPendingGeometryWithoutIndices(){for(let e of this._pendingTilesToUpdate)if(e.loaded&&e.intersectsClippingArea&&e.renderData?.vao?.indexBuffer==null)return!0;return!1}_updatePendingTileGeometries(){let e=this._pendingTilesToUpdate,t=[];if(e.forEach(e=>{this._canUpdateTileGeometry(e)&&t.push(e)}),t.length===0){e.clear();return}let n=(n,r)=>{!r||!this._canUpdateTileGeometry(r)||r.level<n.level||e.has(r)||(e.add(r),t.push(r),r.renderData.updateNeighborData())};t.sort(U);let r=t.length;for(let i=0;i<r;++i){let r=t[i];N(r.loaded),N(r.intersectsClippingArea);let a=r.renderData;if(!a?.geometryState)continue;a.updateNeighborData();let o=a.dirtyEdgeResolutions,s=a.geometryState,c=e=>{let t=et[e];n(r,s.cornerPeerNeighbors[e]?.findCorner(Xe(t),e=>e.loaded))};for(let t=0;t<4;++t)if(o&1<<t){let i=a.geometryState.edgePeerNeighbors[t];i&&i?.level>=r.level&&i.forAllSubtreeOnSide(Ye(P[t]),t=>this._canUpdateTileGeometry(t)?(N(e.has(t)||U(r,t)<0),n(r,t),!0):!1),c((t+1)%4),c(t)}}e.clear(),t.sort(U),this._updateTilesGeometries(t),this._shouldEmitChangeEvent=!0,V&&Ze&&this.checkAllTilesWaterproofness(`pending-geometries-updated`)}_mergeAndSplit(e,t){if(this.freeze||e.done||!this._allTilesDirty)return;this._allTilesDirty=!1,this.requestUpdate();let n=!1,r=this.view.state.fixedContentCamera,i=!1;for(;!e.done;){i=!0;let a=!1,o=!this._allTiles.some(i=>{if(!n&&!r&&!i.visible)return e.done;let o=i;if(i.hasPendingUpdate(4)){if(!t||i.unmergableChildCount>0)return e.done;for(i.resetPendingUpdate(4);o.parent!=null&&o.parent.unmergableChildCount===0&&o.parent.resetPendingUpdate(4);)o=o.parent;this._mergeTile(o),a=!0,e.madeProgress()}else if(i.resetPendingUpdate(1)){let t=!0,n=i.level;if(n>=A){let e=e=>e.leaf||n-e.level<A;for(let r=0;r<4;++r){let a=i.findNeighborTile(P[r],e);a!=null&&n-a.level===A&&(t=!1,V&&(N(a.leaf),N(a.hasPendingUpdate(1))))}}t?(this._splitTile(i),e.madeProgress(),a=!0):i.setPendingUpdate(1)}return e.done});if(a&&(this._allTilesSorted=!1,this._allTilesDirty=!0),o){if(!n){n=!0;continue}if(!a)break}else this._allTilesDirty=!0}i?e.madeProgress():this._allTilesDirty=!0,this._allTilesCreated=!this.allTiles.some(e=>e.hasPendingUpdate(1)||e.hasPendingUpdate(4)&&e.unmergableChildCount===0),this._sortTiles(e)}_updateElevation(e){e.done||this._allTiles.some(t=>(t.resetPendingUpdate(8)&&(this._updateTileGeometryState(t),e.madeProgress()),e.done))}updateElevationSources(e){e.needsElevationSourceUpdate()&&(e.updateAgents(0),e.markElevationSourceUpdateRequested(),this.requestUpdate())}_updateTextures(e){e.done||this._allTiles.some(t=>(this._updateTileTexture(t,e),e.done))}_updateClippingExtent(){this.spatialReference&&(this.updateOverlayParameters(),this.requestRender(1),this.overlayManager.setPlacementDirty(),this._updateRootTiles())}get _lodBias(){return this.view.qualitySettings.tiledSurface.lodBias-(1-this.view.quality)*Ke}_getLodBiasCorrectedScale(e){let t=this.tilingScheme.levels,n=c(e-this._lodBias,0,t.length-1),r=n-Math.floor(n),i=t[Math.floor(n)].scale,a=t[Math.ceil(n)].scale;return i*(1-r)+a*r}_removeAllTiles(){this._pendingTilesToUpdate.clear(),this._pendingTilesForElevationUpdateEvent.clear(),this._rootTiles!=null&&(this._rootTiles.forEach(e=>this._purgeTile(e)),this._setRootTiles(null),this.notifyChange(`ready`)),this._allTiles.clear(),this.notifyChange(`demResolution`),this.emit(`tiles-changed`,{allTiles:this.allTiles}),this.renderer.visible=!1}_purgeSubtree(e){let t=e.children;t[0]&&(this._purgeTile(t[0]),this._purgeTile(t[1]),this._purgeTile(t[2]),this._purgeTile(t[3]),e.clearChildren())}_purgeTile(e){e.leaf?wt(e):this._purgeSubtree(e),this._allTiles.removeUnordered(e),this._unloadTile(e),e.dispose(),this._tileCache.put(K._tileMemcacheKey,e),this.notifyChange(`demResolution`),this.emit(`tiles-changed`,{allTiles:this.allTiles})}_unloadTile(e){this._pendingTilesToUpdate.delete(e),this._pendingTilesForElevationUpdateEvent.delete(e),e.unload()}_splitTile(e){j(e.leaf,`Tile that is already split should not be split again!`),j(e.rendered,`Tile marked to split is not rendered`),wt(e);let t=e.createChildren();this._allTiles.pushArray(t),this.notifyChange(`demResolution`),this.emit(`tiles-changed`,{allTiles:this.allTiles}),e.updateAgentSuspension(),j(e.rendered,`parent should be rendered`),t.forEach(e=>this._loadTile(e)),t.forEach(e=>this._pendingTilesToUpdate.add(e)),this._unloadTile(e),this._markAllTileNeighborsForUpdate(e),this._emitTileScaleChange(e,e.level+1),this._allTilesDirty=!0,this._shortBatches&&this._updatePendingTileGeometries(),t.forEach(e=>Z(e,e.hasPendingUpdate(1))),++this._performanceInfo.numSplit}_emitTileScaleChange(e,t=e.level){X.spatialReference=this.spatialReference,X.extent=e.extent,X.scale=this._getLodBiasCorrectedScale(t),this.emit(`scale-change`,X)}createTile(e,t,n,r){j(!!r,`createTile sanity check`);let i=this._acquireTile(e,t,n,r);return i.updateClippingStatus(this.groundExtent),i.updateScreenDepth(this.view.state.contentCamera.viewProjectionMatrix),this._shouldSplit(i)&&i.setPendingUpdate(1),i}get _shortBatches(){return this.view.state.mode!==2}_mergeTile(e){j(!e.hasPendingUpdate(1),`_mergeTile sanity check`),j(!e.leaf,`Cannot merge a leaf`),e.leaf||(this._purgeSubtree(e),j(!e.renderData,`Merging tile with existing render data?`),this._loadTile(e),this._markTileToUpdate(e),this._emitTileScaleChange(e),this._shortBatches&&this._updatePendingTileGeometries(),Z(e,!1),this._allTilesDirty=!0,++this._performanceInfo.numMerged)}_loadTile(e){e.load(),this.requestUpdate(),this._allTilesDirty=!0,this.overlayManager?.hasOverlays&&e.updateOverlayParameters(this.overlayManager)}_handleLayerViewChanges(e=ht){if(!this._layerViewsDirty)return;this._layerViewsDirty=!1;let t=!1,n=new Set,r=-1;for(let e=this.view.allLayerViews.length-1;e>=0;e--){let i=this.view.allLayerViews.items[e];if(n.add(i.uid),F(i)||I(i)){if(this._basemapLayerViewHandles.has(i.uid)&&!I(i)){let e=this._layerClassFromLayerView(i),n=this.getLayerIndexByUID(e,i.uid);n!=null&&((n<r||r==null)&&(t=!0),r=n)}else this._registerTiledLayerView(i),i.layer.loaded&&(t=!0)}}this._basemapLayerViewHandles.forEach((e,r)=>{n.has(r)||(this._unregisterTiledLayerView(r),t=!0)}),t&&this._updateTiledLayers(),this.hasCompositeBlendMode=this._hasCompositeBlendMode(),this._evaluateTransparency(),e.madeProgress()}get _isFullyTransparent(){if(this.view.map?.ground?.opacity>0)return!1;for(let e of this.view.allLayerViews.items)if(L(e)&&!Te(e.layer)&&e.fullOpacity!==0)return!1;return!0}_hasCompositeBlendMode(){for(let e of this.view.allLayerViews.items)if((R(e)||I(e))&&dt(ft[e.layer.blendMode]))return!0;return!1}_layerClassFromLayerView(e){return+!z(e)}_registerTiledLayerView(e){let t=[];if((R(e)||I(e))&&t.push(m(()=>e.layer.blendMode,()=>{this.hasCompositeBlendMode=this._hasCompositeBlendMode(),this._updateTileTextures(2)})),!I(e)){let n=this._layerClassFromLayerView(e);t.push(m(()=>!e.destroyed&&e.suspended,()=>this._updateTiledLayers())),t.push(m(()=>!e.destroyed&&e.fullOpacity,()=>this._updateTileTextures(2)));let{layer:r}=e;`effectiveScaleRange`in r&&t.push(m(()=>!e.destroyed&&r.effectiveScaleRange,()=>this._restartAllAgents(n))),t.push(e.on(`data-changed`,()=>{let t=this.getLayerIndexByUID(n,e.uid);t!=null&&this._invalidateLayerData(t,n)}))}this._unregisterTiledLayerView(e.uid),this._basemapLayerViewHandles.set(e.uid,t)}_unregisterTiledLayerView(e){let t=this._basemapLayerViewHandles.get(e);if(t){for(let e of t)e.remove();this._basemapLayerViewHandles.delete(e)}}_updateTiledLayers(){if(!this.tilingScheme||this.view.suspended)return;let e=this.view.allLayerViews,t=[[],[]],n=null;e.forEach(e=>{if(!e.layer||e.suspended||!F(e)||!e.fullExtent)return;let r=this._layerClassFromLayerView(e);if(r===1){let t=e.displayLevelRange.maxLevel;t!==1/0&&(n===null||t>n)&&(n=t)}t[r].push(e)});for(let e of Le){let n=this._layerViews[e],r=t[e];r.reverse();let i=r.length,a=n.length!==i,o=Array(i),s=Array(n.length);this._layerIndexByUid[e].clear();for(let t=0;t<i;t++){let i=r[t].uid;this._layerIndexByUid[e].set(i,t);let c=n.indexOf(r[t]);o[t]=c,t!==c&&(a=!0),c>-1&&(s[c]=t)}if(a){let t=this._postorderIterator;for(t.reset(this._rootTiles);!t.done;)t.next().modifyLayers(s,o,e);this._layerViews[e]=r,this._restartAllAgents(e),this._updateTilesVisibility(this._rootTiles)}}this.tilingScheme.ensureMaxLod(n)&&(this._viewChangeUpdate(),this.notifyChange(`tilingScheme`))}_restartAllAgents(e){let t=this._postorderIterator;for(t.reset(this._rootTiles);!t.done;){let n=t.next();n.restartAgents(e),e===0&&n.computeElevationBounds()}this._updateRootTileElevationRange()}layerViewByIndex(e,t){return this._layerViews[t][e]}numLayers(e){return this._layerViews[e].length}_updateTileTextures(e){this._allTiles.forAll(t=>{t.updateAgents(1),e===1?this.renderer.updateTileTexture(t,16):t.updateRenderData(1,e)}),this._evaluateTransparency()}_invalidateLayerData(e,t){this._rootTiles!=null&&(W(this._rootTiles,n=>n.removeLayerAgent(e,t)),W(this._rootTiles,n=>{n.invalidateLayerData(e,t),n.restartAgents(t)}))}setTileTreeDirty(e){this._allTilesDirty=!0,e&&(this._allTilesCreated=!1)}requestRender(e=1){this.renderer.requestRender(e)}requestUpdate(){++this._pendingUpdates===1&&(this._hasPendingUpdates=!0)}requestTileData(e,t,n,r){let i=this.layerViewByIndex(t,n),{tilemapCache:a}=i;return!a||M(i)?this._requestTileData(e,n,i,r):(++this._asyncWorkItems,a.fetchAvailability(e.level,e.lij[1],e.lij[2],{...r,timeout:6e3}).catch(t=>{throw te(r),ne(t)||this._dataMissing(e,n,i),t}).then(()=>this._frameTask.schedule(()=>this._requestTileData(e,n,i,r),r.signal)).finally(()=>--this._asyncWorkItems))}_requestTileData(e,t,n,r){return this.destroying?Promise.resolve():t===0?z(n)?this._requestElevationTileData(e,n,r):Promise.reject():L(n)?this._requestMapTileData(e,n,r):Promise.reject()}_requestElevationTileData(e,t,n){++this._asyncWorkItems;let r=r=>{!p(n)&&r&&(this.setMemoryDirty(),this.requestUpdate(),this._elevationDataArrived(e,t,r))},i=n=>{ne(n)||(s.getLogger(this).error(`Tile ${e.lij.toString()} layer 0/${t.uid} error ${n}`),this._dataMissing(e,0,t),this.requestUpdate())};return t.fetchElevationTile(e,{...Ee,...n}).then(e=>this._frameTask.schedule(()=>r(e)),i).finally(()=>--this._asyncWorkItems)}_elevationDataArrived(e,t,n){let r=this._layerIndexByUid[0].get(t.uid);if(r==null){s.getLogger(this).warn(`TerrainSurface: received data from unknown layer %d %s`,0,e.lij.toString());return}let i=new Pe(e.lij,e.extent,n);e.dataArrived(r,0,i),this.emit(`tile-data-changed`,{tile:e,layerIndex:r,layerClass:0});let a=[e],o=e.level,c=this._iteratorPool.acquire();for(c.reset(a);!c.done;){let e=c.next();e.findElevationBoundsForLayer(r,o),e.computeElevationBounds()}o===0&&this._updateRootTileElevationRange(),c.remove(),this._updateTilesVisibility(a)}_requestMapTileData(e,t,n){++this._asyncWorkItems;let r=(r,i)=>{B(i),p(n)||(console.error(`Tile ${e.lij.toString()} layer 1/${t.uid} error ${r}`),this._dataMissing(e,1,t),this.requestUpdate())},i=e=>t=>r(t,e);return t.fetchTile(e.lij,n).then(r=>this._frameTask.schedule(()=>{this.requestUpdate(),p(n)?B(r):this._mapTileDataArrived(e,t,r)},n.signal,i(r)).catch(i(r)),(e,t=null)=>this._frameTask.schedule(()=>r(e,t))).finally(()=>--this._asyncWorkItems)}_mapTileDataArrived(e,t,n){let r=this.getLayerIndexByUID(1,t.uid);r==null?(B(n),s.getLogger(this).warn(`TerrainSurface: received data from unknown layer`)):(e.dataArrived(r,1,n),this.emit(`tile-data-changed`,{tile:e,layerIndex:r,layerClass:1}))}_dataMissing(e,t,n){let r=this.getLayerIndexByUID(t,n.uid);r==null?s.getLogger(this).warn(`TerrainSurface: received data from unknown layer`):(e.dataMissing(r,t),this.emit(`tile-data-changed`,{tile:e,layerIndex:r,layerClass:t}))}get performanceInfo(){let e=this._performanceInfo;return e.numNodes=this._allTiles.length,e.numLeaves=e.numVisible=e.numRendered=e.numLoadedPerLevel.length=e.numRenderedPerLevel.length=0,this._allTiles.forAll(t=>{t.leaf&&e.numLeaves++;let n=t.level;t.renderData&&(e.numLoadedPerLevel[n]=(e.numLoadedPerLevel[n]||0)+1),t.visible&&(e.numVisible++,t.rendered&&(e.numRenderedPerLevel[n]=(e.numRenderedPerLevel[n]||0)+1,e.numRendered++))}),e}setMemoryDirty(){this._usedMemory=null}get usedMemory(){return this.tilingScheme?(this._usedMemory??=this._recalculateUsedMemory(),this._usedMemory??0):0}_recalculateUsedMemory(){return this.tilingScheme?Math.round(this._allTiles.reduce((e,t)=>e+t.usedMemory,0)):null}getUsedMemoryForLayerView(e){let t=0,n=this._layerClassFromLayerView(e),r=this.getLayerIndexByUID(n,e.uid);return r!=null&&this._allTiles.forAll(e=>t+=e.getUsedMemoryForLayer(n,r)),t}get renderPatchBorders(){return this._renderer.renderPatchBorders}set renderPatchBorders(e){this._renderer.renderPatchBorders=e}get renderingDisabled(){return this._renderer.renderingDisabled}set renderingDisabled(e){this._renderer.renderingDisabled=e}get test(){}checkAllTilesWaterproofness(e=`render-patch-groups`){}get isGlobal(){return this._isGlobal}get isGeographic(){return this._isGeographic}get isWebMercator(){return this._isWebMercator}get isWebMercatorOnPlateCarree(){return this._isWebMercatorOnPlateCarree}isEastEndWrap(e){return this._isGlobal&&e[2]===this.lijEastEnd(e[0])-1}isWestEndWrap(e){return this._isGlobal&&e[2]===0}lijEastEnd(e){return 1<<e+ +!!this._isGeographic}wrapEastWest(e){let t=this.lijEastEnd(e[0]),n=e[2];if(0<=n&&n<t)return e;if(!this._isGlobal)return null;let r=(n+(n<0?t:0))%t;return[e[0],e[1],r]}enableInternalChecks(e){Qe(e)}enableWaterproofnessChecks(e){$e(e)}static cleanupTerrainSurface(){xt.prune()}enable(e){e!==this.enabled&&(this._set(`enabled`,e),e?(this._updateRootTiles(),this.freeze=!1,this.view.elevationProvider.register(0,this)):(this.view.elevationProvider.unregister(this),this.freeze=!0,this._removeAllTiles(),this._setRootTiles(null)),this.notifyChange(`ready`))}updateOverlayParameters(){let{overlayManager:e}=this;this.allTiles.forAll(t=>t.updateOverlayParameters(e))}};e([v()],q.prototype,`_renderer`,void 0),e([v({constructOnly:!0})],q.prototype,`_scaleRangeQueries`,void 0),e([v({constructOnly:!0})],q.prototype,`view`,void 0),e([v({constructOnly:!0})],q.prototype,`overlayManager`,void 0),e([v()],q.prototype,`_hasPendingUpdates`,void 0),e([v()],q.prototype,`_asyncWorkItems`,void 0),e([v()],q.prototype,`_allTilesDirty`,void 0),e([v()],q.prototype,`_allTilesSorted`,void 0),e([v()],q.prototype,`allTilesCreated`,null),e([v()],q.prototype,`_allTilesCreated`,void 0),e([v()],q.prototype,`_viewChanged`,void 0),e([v({type:Number})],q.prototype,`heading`,void 0),e([v()],q.prototype,`_splitLimits`,void 0),e([v()],q.prototype,`_frameTask`,void 0),e([v()],q.prototype,`demResolution`,null),e([v({readOnly:!0})],q.prototype,`snapLevel`,null),e([v({readOnly:!0})],q.prototype,`lodSnappingEnabled`,null),e([v()],q.prototype,`_stencilEnabledExtents`,null),e([v({readOnly:!0})],q.prototype,`userClippingExtent`,null),e([v()],q.prototype,`_rootTilesExtent`,void 0),e([v({readOnly:!0})],q.prototype,`groundExtent`,null),e([v({readOnly:!0})],q.prototype,`fullGroundExtent`,null),e([v({readOnly:!0})],q.prototype,`_tilingSchemeExtent`,null),e([v({readOnly:!0})],q.prototype,`updating`,null),e([v({readOnly:!0})],q.prototype,`readyToRun`,null),e([v(Ne)],q.prototype,`updatingProgress`,void 0),e([v({readOnly:!0})],q.prototype,`updatingProgressValue`,null),e([v()],q.prototype,`_maxNumUpdating`,void 0),e([v()],q.prototype,`baseOpacity`,null),e([v()],q.prototype,`hasCompositeBlendMode`,void 0),e([v({readOnly:!0})],q.prototype,`viewingMode`,null),e([v()],q.prototype,`maxTextureScale`,void 0),e([v({readOnly:!0})],q.prototype,`ready`,null),e([v({readOnly:!0})],q.prototype,`rootTiles`,null),e([v()],q.prototype,`_rootTiles`,void 0),e([v({readOnly:!0})],q.prototype,`spatialReference`,null),e([v({type:t})],q.prototype,`backgroundColor`,null),e([v({value:!1})],q.prototype,`slicePlaneEnabled`,null),e([v({readOnly:!0})],q.prototype,`tilingScheme`,void 0),e([v({readOnly:!0})],q.prototype,`tilingSchemeLocked`,null),e([v({readOnly:!0})],q.prototype,`tilingSchemeLogic`,void 0),e([v()],q.prototype,`wireframe`,null),e([v()],q.prototype,`opaque`,null),e([v()],q.prototype,`invisible`,null),e([v({value:!1})],q.prototype,`freeze`,null),e([v()],q.prototype,`fadeDuration`,null),e([v()],q.prototype,`_xNormalizer`,null),e([v()],q.prototype,`visibleElevationRange`,void 0),e([v()],q.prototype,`_rootTileElevationRange`,void 0),e([v()],q.prototype,`_layerViewsDirty`,void 0),e([v()],q.prototype,`renderPatchBorders`,null),e([v()],q.prototype,`renderingDisabled`,null),e([v({readOnly:!0})],q.prototype,`enabled`,void 0),q=K=e([ie(`esri.views.3d.terrain.TerrainSurface`)],q);const vt=q,J=y(),yt=new Se,Y=S(),bt=S(),xt=new f,X={spatialReference:null,extent:null,scale:0};function St(e,t,n){for(let r of e){if(!r.containsPointXY(t,n))continue;let e=r;for(;e&&!e.renderData;){let r=+(t>e.extentMidX)+(n<e.extentMidY?2:0);e=e.children[r]}let i=e?.renderData?.geometryState.samplerData??null;return Fe(t,n,i)}return null}function Z(e,t){!e.leaf||e.level<A||$(e,e=>{t&&Ct(e);let n=Q(e);if(e.maxLevelDeltaNeighborCount++,n){let t=e.parent;for(;t;){let e=Q(t);if(t.unmergableChildCount++,e)t=t.parent;else break}}})}function Ct(e){if(e.hasPendingUpdate(1))return;let t=e.parent;for(;t?.resetPendingUpdate(4);)t=t.parent;e.resetPendingUpdate(4),e.leaf&&e.setPendingUpdate(1),e.level<A||$(e,e=>{Ct(e)})}function wt(e){e.level<A||$(e,e=>{if(e.maxLevelDeltaNeighborCount--,e.maxLevelDeltaNeighborCount===0&&e.unmergableChildCount===0){let t=e.parent;for(;t&&(t.unmergableChildCount--,Q(t));)t=t.parent}})}function Q(e){return e.maxLevelDeltaNeighborCount===0&&e.unmergableChildCount===0}function $(e,t){if(e.level<A)return;let n=e.level-A,r=e.lij[1]>>A,i=e.lij[2]>>A,a=e=>e.leaf||e.level===n;for(let o=0;o<4;++o){let s=e.findNeighborTile(P[o],a);if(!s||s.level!==n)continue;let c=s.lij;(c[1]!==r||c[2]!==i)&&t(s)}}export{vt as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import"../../../core/has.js";import{disposeMaybe as e,releaseMaybe as t}from"../../../core/maybe.js";import{set as n,copy as r}from"../../../core/libs/gl-matrix-2/math/vec2.js";import{ZEROS as i}from"../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{fromValues as a}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{isBaseLayer as o,isGroupLayer as s,isReferenceLayer as c}from"../../../layers/support/layerUtils.js";import{isLayerViewWithFlowRenderer as l}from"../support/flowUtils.js";import{BlendLayersPassParameters as u}from"./BlendLayersTechnique.js";import{isBlendableLayerView as d,isVectorTileLayerView as f,isVectorTileRenderInfo as p,isImageryTileRenderInfo as m,isImageSourceRenderInfo as h,isTextureTileRenderInfo as g,isVectorTilePerLayerInfo as _}from"./terrainUtils.js";import{TextureReference as v}from"./TextureReference.js";import{TileCompositor as y}from"./TileCompositor.js";import{TileRenderInfo as b}from"./TileRenderInfo.js";import{getCacheKey as x,TileTexture as S}from"./TileTexture.js";import{fallsWithinLayerView as C}from"./tileUtils.js";import{blendModeFromString as w}from"../webgl-engine/core/shaderLibrary/output/BlendOptions.js";import{isCompressible as T}from"../../support/TextureCompressionWorkerHandle.js";import E from"../../webgl/Texture.js";import{TextureDescriptor as D}from"../../webgl/TextureDescriptor.js";class O{constructor(e,t,n,r,i,a){this._surface=e,this._rctx=t,this.tileSize=n,this._techniques=r,this._cache=i,this._compressionTracker=a,this._passParameters=new u,this._backgroundColor=null,this._maxAnisotropy=this._rctx.parameters.maxMaxAnisotropy,this._compositor=new y(this._rctx,this._techniques)}dispose(){this._compositor=e(this._compositor),this._sharedBackground=t(this._sharedBackground)}get backgroundIsGrid(){return this._backgroundColor==null}get backgroundColor(){return this._backgroundColor}updateHeading(e){this._compositor?.updateHeading(e)}updateTileTexture(e,t){if(!e.renderData)return;let n=this._prepareComposite(e),r=n.targetTextureSize/this.tileSize;n.numTexturedLayers===0||n.firstTexturedLayerIndex===null?this._useBackgroundTexture(e,n,t!==0):(n.numTexturedLayers!==1||n.backgroundVTLIndex!=null||n.foundBlendMode||!this._useLayerTexture(e,n.firstTexturedLayerIndex??0))&&this._composeLayers(e,t,r,F,n)}_prepareComposite(e){let t=this._surface,n=t.baseOpacity,r=t.view.state.contentPixelRatio,i=e.layerInfo[1],a=new P(e.lij,this.tileSize);F.clear(),I.length=0;for(let u=0;u<i.length;u++){let p=t.layerViewByIndex(u,1),m=p.layer,h=!C(e,p),g=m.opacity,_=p.fullOpacity;if(a.hasBasemapLayers=a.hasBasemapLayers||o(m),l(p))continue;if(d(p)){let e=p.layer.blendMode!==`normal`;if(s(m.parent)){let t=m.parent.uid;t!=null&&t!==``&&(e=j(m.parent)||e)}e&&(a.foundBlendMode=e,a.backgroundCovered=!1)}if(this._canSkipLayer(g,h,a.foundBlendMode)){this._clearTexturePendingUpdates(i[u]);continue}++a.numVisibleLayers;let v=f(p);a.backgroundVTLIndex==null&&v&&p.layer.styleRepository.backgroundBucketIds.length>0&&(a.backgroundVTLIndex=u);let y=k(e,u,v);if(!(!y||(this._clearTexturePendingUpdates(i[u]),!y.sourceLayerInfo.data))){if(s(m.parent)){let e=m.parent.uid;e!=null&&e!==``&&M(m.parent,u)}if(v)a.targetTextureSize=Math.max(a.targetTextureSize,this.tileSize*r);else{let e=this._prepareTextureForBackgroundCoverageCheck(y,c(m));n===1&&_===1&&(p.isOpaque||e?.descriptor.isOpaque===!0)&&(a.backgroundCovered=!0)}++a.numTexturedLayers,a.firstTexturedLayerIndex??=u}}return a.lastLayerIndex=i.length-1,a}_canSkipLayer(e,t,n){return this._isLayerNonContributing(e,t)&&!n}_isLayerNonContributing(e,t){return e===0||t}_clearTexturePendingUpdates(e){e.pendingUpdates&=-1}_prepareTextureForBackgroundCoverageCheck(e,t){return this._dataToTexture(e,t)?e.sourceLayerInfo.data:null}setBackground(e){this._backgroundColor!==e&&(this._backgroundColor=e,this._sharedBackground&&this._drawBackgroundTexture(this._sharedBackground))}_drawBackgroundTexture(e,t,n){if(this._passParameters.offset=i,this._passParameters.scale=1,this._passParameters.opacity=1,this.backgroundColor&&(this._passParameters.backgroundColor=this.backgroundColor),this._compositor.bind(this.tileSize),n?.backgroundVTLIndex==null||t==null)this._compositor.drawBackground(this._passParameters,this.backgroundColor!=null);else{let e=k(t,n.backgroundVTLIndex,!0);this._passParameters.opacity=this._surface.layerViewByIndex(n.backgroundVTLIndex,1).layer.opacity,this._compositor.drawVectorData(this._passParameters,this.backgroundIsGrid?3:2,n.targetTextureSize,0,e,n.targetTextureSize/this.tileSize,this.tileSize,!1)}this._compositor.copyFBOToTexture(e),this._compositor.unbind()}_useBackgroundTexture(e,t,n){let r=e.renderData,i=!n&&!r.textureReference?.isBackground&&(this._surface.view.layerViewManager.updating||t.numVisibleLayers>0)?5e3:0;r.setTextureReference(new v(this._composeBackground(e,t),!0,0,R,this._surface.baseOpacity,0,1),i)}_composeBackground(e,t){if(t?.backgroundVTLIndex==null)return this._sharedBackground??(this._sharedBackground=this._buildTexture(this.tileSize,!1),this._drawBackgroundTexture(this._sharedBackground)),this._sharedBackground;let n=e.renderData.ensureTexture(this.tileSize,!1,0,()=>this._buildTexture(this.tileSize,!1,9987));return this._drawBackgroundTexture(n,e,t),n}_useLayerTexture(e,t){let n=this._surface.layerViewByIndex(t,1),r=o(n.layer),i=r?this._surface.baseOpacity:1,s=r?1:this._surface.baseOpacity,l=n.fullOpacity,u=k(e,t,!1);return this._dataToTexture(u,c(n.layer))?(e.renderData.setTextureReference(new v(u.sourceLayerInfo.data,!1,0,a(u.offset[0],u.offset[1],u.scale,u.scale),i,s,l)),!0):!1}_composeLayers(e,t,n,r,a){let{lastLayerIndex:s,hasBasemapLayers:u,targetTextureSize:h,backgroundCovered:g,foundBlendMode:_,backgroundVTLIndex:y}=a;this._compositor.ensureBuffer(h);let b=!g||_,x=this._surface.baseOpacity,S=!1,T=9987,E=!1,D=0;for(let t=s;t>=0;t--){let a=this._surface.layerViewByIndex(t,1);if(l(a))continue;let s=a.layer,g=f(a),v=k(e,t,g),O=s.opacity,j=!C(e,a),M=!v?.sourceLayerInfo.data&&t===y;if(!v?.sourceLayerInfo.data&&!M||this._canSkipLayer(O,j,_))continue;let N=!o(s)&&!S;S||=N;let P=this._openGroupsAtLayer(t,h,x,u,b,N,r),F=P?4:b&&D===0?this.backgroundIsGrid?3:2:1,L=w[d(a)?a.layer.blendMode:`normal`];for(this._passParameters.baseOpacity=N&&!P&&x<1?x:1,this._passParameters.opacity=O,M||p(v)?E=this._compositor.drawVectorData(this._passParameters,F,h,L,v,n,this.tileSize,E):m(v)?(this._compositor.drawRasterData(this._passParameters,F,h,L,v),A(v)&&(T=9728)):this._dataToTexture(v,c(s))&&(this._passParameters.texture=v.sourceLayerInfo.data.texture,this._passParameters.offset=v.offset,this._passParameters.scale=v.scale,this._compositor.drawImageData(this._passParameters,F,h,L));I.length>0&&I[I.length-1].end===t;){let e=I.pop();this._passParameters.baseOpacity=e.baseOpacity,this._passParameters.opacity=e.opacity,this._passParameters.offset=i,this._passParameters.scale=1,this._compositor.drawGroup(this._passParameters,e.output,h,w[e.blendMode])}D++}let O=e.renderData,j=_||S&&x<1,M=O.ensureTexture(h,j,t,()=>this._buildTexture(h,j,T));this._compositor.copyFBOToTexture(M),this._compositor.unbind(),O.setTextureReference(new v(M,!1,t,R,S?1:x,0,1))}_openGroupsAtLayer(e,t,n,r,i,a,o){let s=!1;return o.forEach(o=>{o.start===e&&(o.output=r?1:i&&a?this.backgroundIsGrid?3:2:1,o.baseOpacity=a?n:1,I.push(o),this._compositor.openGroup(t),s=!0)}),s}_dataToTexture(e,t){if(h(e)){let n=e.sourceLayerInfo,r=!t;n.data=this._buildTexture(n.data,!0,r,e.scale!==1,e.tile.onCompressionFinished),e.tile.setMemoryDirty()}return g(e)}_buildTexture(e,t,n=9987,r=!1,i=()=>{}){return e==null?null:typeof e==`number`?this._buildTextureFromSize(e,t,n):this._buildTextureFromImage(e,t,n,r,i)}_buildTextureFromSize(e,t,n){let r=this._createTextureDescriptor(t,typeof n==`boolean`?9987:n);r.width=r.height=e;let i=this._buildTileTexture(r);return this._generateTextureMipmap(i),i}_buildTextureFromImage(e,t,n,r,i){let a=this._createTextureDescriptor(t,typeof n==`boolean`?9987:n);a.isOpaque=e.isOpaque,a.isOpaque&&(a.pixelFormat=6407);let{bitmap:o}=e;a.width=o.width,a.height=o.height;let s=typeof n==`boolean`&&n,c=this._buildTileTexture(a,s,r,i,o);return this._generateTextureMipmap(c),c}_createTextureDescriptor(e,t){let n=new D;return n.wrapMode=33071,n.samplingMode=t,n.maxAnisotropy=this._maxAnisotropy,n.preMultiplyAlpha=!0,n.flipped=!0,n.hasMipmap=!0,e||(n.pixelFormat=6407),n}_generateTextureMipmap(e){let t=this._rctx,n=t.bindTexture(e.texture,E.TEXTURE_UNIT_FOR_UPDATES);e.generateMipmap(),t.bindTexture(n,E.TEXTURE_UNIT_FOR_UPDATES)}_buildTileTexture(e,t=!1,n=!1,r=()=>{},i){let a=this._cache.pop(x(e,!1))??this._cache.pop(x(e,!0));if(t&&=T(i,e),a)return a.retain(),t?a.texture.enableCompression({compressionTracker:this._compressionTracker,compressionCallback:r,preserveSourceBitmap:n}):a.texture.disableCompression(),a.texture.setData(i),a;e.compress=t?{compressionTracker:this._compressionTracker,compressionCallback:r,preserveSourceBitmap:n}:void 0;let o=new E(this._rctx,e,i);return new S(o,this._cache)}get test(){}}function k(e,t,i){L.layerIndex=t,L.vtlNeighborInfos.clear();let a=e.layerInfo[1][t];if(n(L.offset,0,0),L.tile=e,L.scale=1,L.sourceLod=e.lij,L.sourceLayerInfo=a,a.data)return i&&e.forEachLoadedNeighbor((n,r)=>{if(n.level!==e.level)return;let i=n.layerInfo[1][t];if(!_(i)||a.data===i.data)return;let o=L.vtlNeighborInfos.pushNew();o.offset=z[r],o.sourceLod=n.lij,o.sourceLayerInfo=i}),L;let o=a.upsampleInfo,s=o?.tile?.layerInfo[1][t];return s&&o.tile?(L.tile=o.tile,r(L.offset,o.offset),L.scale=o.scale,L.sourceLod=o.tile.lij,L.sourceLayerInfo=s,L):i?L:null}function A(e){let t=e.sourceLayerInfo.data;return t.source?t.interpolation===`nearest`:!1}function j(e){let t=e.blendMode!==`normal`;return s(e.parent)&&(t=j(e.parent)||t),t}function M(e,t){s(e.parent)&&M(e.parent,t);let n=e.uid;if(n!=null&&n!==``){let r=F.get(n);r?r.start=t:F.set(n,new N(t,t,e.blendMode,e.opacity,1,1))}}class N{constructor(e,t,n,r,i,a){this.start=e,this.end=t,this.blendMode=n,this.opacity=r,this.output=i,this.baseOpacity=a}}class P{constructor(e,t){this.lij=e,this.targetTextureSize=t,this.numTexturedLayers=0,this.numVisibleLayers=0,this.backgroundCovered=!1,this.hasBasemapLayers=!1,this.foundBlendMode=!1,this.lastLayerIndex=0}}const F=new Map,I=[],L=new b,R=a(0,0,1,1),z=[];z[0]=[0,-1],z[1]=[-1,-1],z[2]=[-1,0],z[3]=[-1,1],z[4]=[0,1],z[5]=[1,1],z[6]=[1,0],z[7]=[1,-1];function B(){L.sourceLayerInfo=null,L.tile=null,L.vtlNeighborInfos.prune()}export{N as GroupInfo,O as TileRenderer,B as cleanupTileRenderer};
|
|
2
|
+
import"../../../core/has.js";import{disposeMaybe as e,releaseMaybe as t}from"../../../core/maybe.js";import{set as n,copy as r}from"../../../core/libs/gl-matrix-2/math/vec2.js";import{ZEROS as i}from"../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{fromValues as a}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{isBaseLayer as o,isGroupLayer as s,isReferenceLayer as c}from"../../../layers/support/layerUtils.js";import{isLayerViewWithFlowRenderer as l}from"../support/flowUtils.js";import{BlendLayersPassParameters as u}from"./BlendLayersTechnique.js";import{isBlendableLayerView as d,isVectorTileLayerView as f,isVectorTileRenderInfo as p,isImageryTileRenderInfo as m,isImageSourceRenderInfo as h,isTextureTileRenderInfo as g,isVectorTilePerLayerInfo as _}from"./terrainUtils.js";import{TextureReference as v}from"./TextureReference.js";import{TileCompositor as y}from"./TileCompositor.js";import{TileRenderInfo as b}from"./TileRenderInfo.js";import{getCacheKey as x,TileTexture as S}from"./TileTexture.js";import{fallsWithinLayerView as C}from"./tileUtils.js";import{blendModeFromString as w}from"../webgl-engine/core/shaderLibrary/output/BlendOptions.js";import{isCompressible as T}from"../../support/TextureCompressionWorkerHandle.js";import E from"../../webgl/Texture.js";import{TextureDescriptor as D}from"../../webgl/TextureDescriptor.js";class O{constructor(e,t,n,r,i,a){this._surface=e,this._rctx=t,this.tileSize=n,this._techniques=r,this._cache=i,this._compressionTracker=a,this._passParameters=new u,this._backgroundColor=null,this._maxAnisotropy=this._rctx.parameters.maxMaxAnisotropy,this._compositor=new y(this._rctx,this._techniques)}dispose(){this._compositor=e(this._compositor),this._sharedBackground=t(this._sharedBackground)}get backgroundIsGrid(){return this._backgroundColor==null}get backgroundColor(){return this._backgroundColor}updateHeading(e){this._compositor?.updateHeading(e)}updateTileTexture(e,t){if(!e.renderData)return;let n=this._prepareComposite(e),r=n.targetTextureSize/this.tileSize;n.numTexturedLayers===0||n.firstTexturedLayerIndex===null?this._useBackgroundTexture(e,n,t!==0):(n.numTexturedLayers!==1||n.backgroundVTLIndex!=null||n.foundBlendMode||!this._useLayerTexture(e,n.firstTexturedLayerIndex??0))&&this._composeLayers(e,t,r,F,n)}_prepareComposite(e){let t=this._surface,n=t.baseOpacity,r=t.view.state.contentPixelRatio,i=e.layerInfo[1],a=new P(e.lij,this.tileSize);F.clear(),I.length=0;for(let u=0;u<i.length;u++){let p=t.layerViewByIndex(u,1),m=p.layer,h=!C(e,p),g=m.opacity,_=p.fullOpacity;if(a.hasBasemapLayers=a.hasBasemapLayers||o(m),l(p))continue;if(d(p)){let e=p.layer.blendMode!==`normal`;if(s(m.parent)){let t=m.parent.uid;t!=null&&t!==``&&(e=j(m.parent)||e)}e&&(a.foundBlendMode=e,a.backgroundCovered=!1)}if(this._canSkipLayer(g,h,a.foundBlendMode)){this._clearTexturePendingUpdates(i[u]);continue}++a.numVisibleLayers;let v=f(p);a.backgroundVTLIndex==null&&v&&p.layer.styleRepository.backgroundBucketIds.length>0&&(a.backgroundVTLIndex=u);let y=k(e,u,v);if(!(!y||(this._clearTexturePendingUpdates(i[u]),!y.sourceLayerInfo.data))){if(s(m.parent)){let e=m.parent.uid;e!=null&&e!==``&&M(m.parent,u)}if(v)a.targetTextureSize=Math.max(a.targetTextureSize,this.tileSize*r);else{let e=this._prepareTextureForBackgroundCoverageCheck(y,c(m));n===1&&_===1&&(p.isOpaque||e?.descriptor.isOpaque===!0)&&(a.backgroundCovered=!0)}++a.numTexturedLayers,a.firstTexturedLayerIndex??=u}}return a.lastLayerIndex=i.length-1,a}_canSkipLayer(e,t,n){return this._isLayerNonContributing(e,t)&&!n}_isLayerNonContributing(e,t){return e===0||t}_clearTexturePendingUpdates(e){e.pendingUpdates&=-1}_prepareTextureForBackgroundCoverageCheck(e,t){return this._dataToTexture(e,t)?e.sourceLayerInfo.data:null}setBackground(e){this._backgroundColor!==e&&(this._backgroundColor=e,this._sharedBackground&&this._drawBackgroundTexture(this._sharedBackground))}_drawBackgroundTexture(e,t,n){if(e.texture.setSamplingMode(9987),this._passParameters.offset=i,this._passParameters.scale=1,this._passParameters.opacity=1,this.backgroundColor&&(this._passParameters.backgroundColor=this.backgroundColor),this._compositor.bind(this.tileSize),n?.backgroundVTLIndex==null||t==null)this._compositor.drawBackground(this._passParameters,this.backgroundColor!=null);else{let e=k(t,n.backgroundVTLIndex,!0);this._passParameters.opacity=this._surface.layerViewByIndex(n.backgroundVTLIndex,1).layer.opacity,this._compositor.drawVectorData(this._passParameters,this.backgroundIsGrid?3:2,n.targetTextureSize,0,e,n.targetTextureSize/this.tileSize,this.tileSize,!1)}this._compositor.copyFBOToTexture(e),this._compositor.unbind()}_useBackgroundTexture(e,t,n){let r=e.renderData,i=!n&&!r.textureReference?.isBackground&&(this._surface.view.layerViewManager.updating||t.numVisibleLayers>0)?5e3:0;r.setTextureReference(new v(this._composeBackground(e,t),!0,0,R,this._surface.baseOpacity,0,1),i)}_composeBackground(e,t){if(t?.backgroundVTLIndex==null)return this._sharedBackground??(this._sharedBackground=this._buildTexture(this.tileSize,!1),this._drawBackgroundTexture(this._sharedBackground)),this._sharedBackground;let n=e.renderData.ensureTexture(this.tileSize,!1,0,()=>this._buildTexture(this.tileSize,!1,9987));return this._drawBackgroundTexture(n,e,t),n}_useLayerTexture(e,t){let n=this._surface.layerViewByIndex(t,1),r=o(n.layer),i=r?this._surface.baseOpacity:1,s=r?1:this._surface.baseOpacity,l=n.fullOpacity,u=k(e,t,!1);return this._dataToTexture(u,c(n.layer))?(e.renderData.setTextureReference(new v(u.sourceLayerInfo.data,!1,0,a(u.offset[0],u.offset[1],u.scale,u.scale),i,s,l)),!0):!1}_composeLayers(e,t,n,r,a){let{lastLayerIndex:s,hasBasemapLayers:u,targetTextureSize:h,backgroundCovered:g,foundBlendMode:_,backgroundVTLIndex:y}=a;this._compositor.ensureBuffer(h);let b=!g||_,x=this._surface.baseOpacity,S=!1,T=9987,E=!1,D=0;for(let t=s;t>=0;t--){let a=this._surface.layerViewByIndex(t,1);if(l(a))continue;let s=a.layer,g=f(a),v=k(e,t,g),O=s.opacity,j=!C(e,a),M=!v?.sourceLayerInfo.data&&t===y;if(!v?.sourceLayerInfo.data&&!M||this._canSkipLayer(O,j,_))continue;let N=!o(s)&&!S;S||=N;let P=this._openGroupsAtLayer(t,h,x,u,b,N,r),F=P?4:b&&D===0?this.backgroundIsGrid?3:2:1,L=w[d(a)?a.layer.blendMode:`normal`];for(this._passParameters.baseOpacity=N&&!P&&x<1?x:1,this._passParameters.opacity=O,M||p(v)?E=this._compositor.drawVectorData(this._passParameters,F,h,L,v,n,this.tileSize,E):m(v)?(this._compositor.drawRasterData(this._passParameters,F,h,L,v),A(v)&&(T=9728)):this._dataToTexture(v,c(s))&&(this._passParameters.texture=v.sourceLayerInfo.data.texture,this._passParameters.offset=v.offset,this._passParameters.scale=v.scale,this._compositor.drawImageData(this._passParameters,F,h,L));I.length>0&&I[I.length-1].end===t;){let e=I.pop();this._passParameters.baseOpacity=e.baseOpacity,this._passParameters.opacity=e.opacity,this._passParameters.offset=i,this._passParameters.scale=1,this._compositor.drawGroup(this._passParameters,e.output,h,w[e.blendMode])}D++}let O=e.renderData,j=_||S&&x<1,M=O.ensureTexture(h,j,t,()=>this._buildTexture(h,j,T));M.texture.setSamplingMode(T),this._compositor.copyFBOToTexture(M),this._compositor.unbind(),O.setTextureReference(new v(M,!1,t,R,S?1:x,0,1))}_openGroupsAtLayer(e,t,n,r,i,a,o){let s=!1;return o.forEach(o=>{o.start===e&&(o.output=r?1:i&&a?this.backgroundIsGrid?3:2:1,o.baseOpacity=a?n:1,I.push(o),this._compositor.openGroup(t),s=!0)}),s}_dataToTexture(e,t){if(h(e)){let n=e.sourceLayerInfo,r=!t;n.data=this._buildTexture(n.data,!0,r,e.scale!==1,e.tile.onCompressionFinished),e.tile.setMemoryDirty()}return g(e)}_buildTexture(e,t,n=9987,r=!1,i=()=>{}){return e==null?null:typeof e==`number`?this._buildTextureFromSize(e,t,n):this._buildTextureFromImage(e,t,n,r,i)}_buildTextureFromSize(e,t,n){let r=this._createTextureDescriptor(t,typeof n==`boolean`?9987:n);return r.width=r.height=e,this._buildTileTexture(r)}_buildTextureFromImage(e,t,n,r,i){let a=this._createTextureDescriptor(t,typeof n==`boolean`?9987:n);a.isOpaque=e.isOpaque,a.isOpaque&&(a.pixelFormat=6407);let{bitmap:o}=e;a.width=o.width,a.height=o.height;let s=typeof n==`boolean`&&n;return this._buildTileTexture(a,s,r,i,o)}_createTextureDescriptor(e,t){let n=new D;return n.wrapMode=33071,n.samplingMode=t,n.maxAnisotropy=this._maxAnisotropy,n.preMultiplyAlpha=!0,n.flipped=!0,n.hasMipmap=!0,e||(n.pixelFormat=6407),n}_buildTileTexture(e,t=!1,n=!1,r=()=>{},i){let a=this._cache.pop(x(e,!1))??this._cache.pop(x(e,!0));if(t&&=T(i,e),a)return a.retain(),a.texture.setSamplingMode(e.samplingMode),t?a.texture.enableCompression({compressionTracker:this._compressionTracker,compressionCallback:r,preserveSourceBitmap:n}):a.texture.disableCompression(),a.texture.setData(i),a;e.compress=t?{compressionTracker:this._compressionTracker,compressionCallback:r,preserveSourceBitmap:n}:void 0;let o=new E(this._rctx,e,i);return new S(o,this._cache)}get test(){}}function k(e,t,i){L.layerIndex=t,L.vtlNeighborInfos.clear();let a=e.layerInfo[1][t];if(n(L.offset,0,0),L.tile=e,L.scale=1,L.sourceLod=e.lij,L.sourceLayerInfo=a,a.data)return i&&e.forEachLoadedNeighbor((n,r)=>{if(n.level!==e.level)return;let i=n.layerInfo[1][t];if(!_(i)||a.data===i.data)return;let o=L.vtlNeighborInfos.pushNew();o.offset=z[r],o.sourceLod=n.lij,o.sourceLayerInfo=i}),L;let o=a.upsampleInfo,s=o?.tile?.layerInfo[1][t];return s&&o.tile?(L.tile=o.tile,r(L.offset,o.offset),L.scale=o.scale,L.sourceLod=o.tile.lij,L.sourceLayerInfo=s,L):i?L:null}function A(e){let t=e.sourceLayerInfo.data;return t.source?t.interpolation===`nearest`:!1}function j(e){let t=e.blendMode!==`normal`;return s(e.parent)&&(t=j(e.parent)||t),t}function M(e,t){s(e.parent)&&M(e.parent,t);let n=e.uid;if(n!=null&&n!==``){let r=F.get(n);r?r.start=t:F.set(n,new N(t,t,e.blendMode,e.opacity,1,1))}}class N{constructor(e,t,n,r,i,a){this.start=e,this.end=t,this.blendMode=n,this.opacity=r,this.output=i,this.baseOpacity=a}}class P{constructor(e,t){this.lij=e,this.targetTextureSize=t,this.numTexturedLayers=0,this.numVisibleLayers=0,this.backgroundCovered=!1,this.hasBasemapLayers=!1,this.foundBlendMode=!1,this.lastLayerIndex=0}}const F=new Map,I=[],L=new b,R=a(0,0,1,1),z=[];z[0]=[0,-1],z[1]=[-1,-1],z[2]=[-1,0],z[3]=[-1,1],z[4]=[0,1],z[5]=[1,1],z[6]=[1,0],z[7]=[1,-1];function B(){L.sourceLayerInfo=null,L.tile=null,L.vtlNeighborInfos.prune()}export{N as GroupInfo,O as TileRenderer,B as cleanupTileRenderer};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import e from"../../../core/PooledArray.js";import{isImageryTileLayerView as t}from"./terrainUtils.js";class n{constructor(){this._queue=new e,this.remove=()=>{}}get done(){return this._queue.length===0&&(!this._last||this._last.leaf)}resetOne(e){this._queue.clear(),this._queue.push(e),this._last=void 0}reset(e=null){this._queue.clear(),e!=null&&this._queue.pushArray(e),this._last=void 0}skipSubtree(){this._last=void 0}next(){let e=this._last?.children;return e?.[0]&&this._queue.pushArray(e),this._last=this._queue.pop(),this._last}}class r{constructor(){this._q=new e}get done(){return this._q.length===0}reset(e){if(this._q.clear(),e!=null){this._q.pushArray(e);for(let e=0;e<this._q.length;++e){let t=this._q.data[e];t.leaf||this._q.pushArray(t.children)}}}next(){return this._q.pop()}}function i(e,t,n=()=>!0){if(Array.isArray(e))for(let r=0;r<e.length;r++)a(e[r],t,n);else a(e,t,n)}function a(e,t,n=()=>!0){if(t(e),!e.leaf&&n(e))for(let n of e.children)a(n,t)}function o(e,t){let n=e.extent;return!(t.xmin>n[2]||t.ymin>n[3]||t.xmax<n[0]||t.ymax<n[1])}function s(e,t,n){let r=e.surface.tilingScheme.levels[e.level].scale;return!(t&&t>0&&r>t*1.00000001||n&&n>0&&r<n*.99999999)}function c(e,t){if(t==null||t.destroyed)return!1;let n=l(t);return!(n?.fullExtent==null||!o(e,n.fullExtent)||!s(e,n.minScale,n.maxScale))}function l(e){return t(e)||e.type===`wmts-3d`?{fullExtent:e.fullExtent,minScale:e.layer.minScale,maxScale:e.layer.maxScale}:e.layer}function u(e,t){let n=e.lij,r=t.lij;return n[0]-r[0]||n[1]-r[1]||n[2]-r[2]}function d(e,t=null){return t==null||t.length===0?e.sort(f):e.sort((e,n)=>m(e,n,t))}function f(e,t){let n=e.screenDepth-t.screenDepth;if(n!==0)return n;let r=e.lij,i=t.lij;return r[0]-i[0]||r[1]-i[1]||r[2]-i[2]}function p(e,t){let n=e.screenDepth,r=t.screenDepth;return n<r?-1:n>r?1:u(e,t)}function m(e,t,n){
|
|
2
|
+
import e from"../../../core/PooledArray.js";import{isImageryTileLayerView as t}from"./terrainUtils.js";class n{constructor(){this._queue=new e,this.remove=()=>{}}get done(){return this._queue.length===0&&(!this._last||this._last.leaf)}resetOne(e){this._queue.clear(),this._queue.push(e),this._last=void 0}reset(e=null){this._queue.clear(),e!=null&&this._queue.pushArray(e),this._last=void 0}skipSubtree(){this._last=void 0}next(){let e=this._last?.children;return e?.[0]&&this._queue.pushArray(e),this._last=this._queue.pop(),this._last}}class r{constructor(){this._q=new e}get done(){return this._q.length===0}reset(e){if(this._q.clear(),e!=null){this._q.pushArray(e);for(let e=0;e<this._q.length;++e){let t=this._q.data[e];t.leaf||this._q.pushArray(t.children)}}}next(){return this._q.pop()}}function i(e,t,n=()=>!0){if(Array.isArray(e))for(let r=0;r<e.length;r++)a(e[r],t,n);else a(e,t,n)}function a(e,t,n=()=>!0){if(t(e),!e.leaf&&n(e))for(let n of e.children)a(n,t)}function o(e,t){let n=e.extent;return!(t.xmin>n[2]||t.ymin>n[3]||t.xmax<n[0]||t.ymax<n[1])}function s(e,t,n){let r=e.surface.tilingScheme.levels[e.level].scale;return!(t&&t>0&&r>t*1.00000001||n&&n>0&&r<n*.99999999)}function c(e,t){if(t==null||t.destroyed)return!1;let n=l(t);return!(n?.fullExtent==null||!o(e,n.fullExtent)||!s(e,n.minScale,n.maxScale))}function l(e){return t(e)||e.type===`wmts-3d`?{fullExtent:e.fullExtent,minScale:e.layer.minScale,maxScale:e.layer.maxScale}:e.layer}function u(e,t){let n=e.lij,r=t.lij;return n[0]-r[0]||n[1]-r[1]||n[2]-r[2]}function d(e,t=null){return t==null||t.length===0?e.sort(f):e.sort((e,n)=>m(e,n,t))}function f(e,t){let n=e.screenDepth-t.screenDepth;if(n!==0)return n;let r=e.lij,i=t.lij;return r[0]-i[0]||r[1]-i[1]||r[2]-i[2]}function p(e,t){let n=e.screenDepth,r=t.screenDepth;return n<r?-1:n>r?1:u(e,t)}function m(e,t,n){let r=h(e,n);return r===h(t,n)?p(e,t):r?1:-1}function h(e,t){return t?.some(t=>e.intersectsExtent(t))??!1}function g(e,t){let n=e.distanceToPOI-t.distanceToPOI;if(n!==0)return n;let r=e.lij,i=t.lij;return r[0]-i[0]||r[1]-i[1]||r[2]-i[2]}function _(e,t){let n=e.length;for(let r=0;r<n;++r)e.at(r).updateDistanceToPOI(t);e.sort(g)}function v(e,t,n){let r=1,i=0,a=0;for(;e!==t;)if(r*=.5,i*=.5,a*=.5,e.lij[2]&1&&(i+=.5),e.lij[1]&1||(a+=.5),e=e.parent,e==null)throw Error(`tile was not a descendant of upsampleTile`);n.init(t,i,a,r)}function y(e){for(let t=0;t<e.length;t++){let n=e[t],r=n.parent;if(r)for(let e=0;e<4;e++){let t=r.children[e];if(t&&t!==n)return!0}}return!1}function b(e,t){if(!e||!t||e[0]===t[0])return!1;let n=e[0]<t[0],r=n?e:t,i=n?t:e,a=1<<i[0]-r[0];return Math.floor(i[1]/a)===r[1]&&Math.floor(i[2]/a)===r[2]}function x(e,t){if(t<=e[0])return[[...e]];let n=1<<t-e[0],r=[],i=e[1]*n,a=e[2]*n;for(let e=0;e<n;++e)for(let o=0;o<n;++o)r.push([t,e+i,o+a]);return r}export{r as IteratorPostorder,n as IteratorPreorder,p as compareTiles,u as compareTilesByLij,m as compareTilesWithStencil,v as computeUpsampleInfo,x as descendantsAtLevel,c as fallsWithinLayerView,y as hasLoadableSiblings,d as sortTiles,_ as sortTilesByPOI,b as tilesAreRelated,i as traverseTilesPreorder,h as usesStencil};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import e from"../../../../core/Error.js";import{EventEmitter as t}from"../../../../core/Evented.js";import has from"../../../../core/has.js";import{disposeMaybe as n,removeMaybe as r}from"../../../../core/maybe.js";import{throwIfAborted as i,onAbort as a,createAbortError as o}from"../../../../core/promiseUtils.js";import{isUint8Array as s,isArrayBuffer as c,isTypedArray as l}from"../../../../core/typedArrayUtil.js";import{generateUID as u}from"../../../../core/uid.js";import{isBlobProtocol as d,isDataProtocol as f}from"../../../../core/urlUtils.js";import{whenVideoPlayable as p}from"../../../../layers/support/videoUtils.js";import{requestImage as m}from"../../../../request/image.js";import{loadImage as h}from"../../../../request/loadImage.js";import{createTextureKTX1 as g,createTextureKTX2 as _,createTextureBasis as v,estimateMemoryKTX2 as y,estimateMemoryBasis as b}from"./BasisUtil.js";import{createDDSTexture as x}from"./DDSUtil.js";import{ensureImageMaxSize as S}from"./textureUtils.js";import{assert as C}from"./Util.js";import w from"../../../webgl/Texture.js";import{TextureDescriptor as T}from"../../../webgl/TextureDescriptor.js";import{isCompressedFormat as E,isSizedPixelFormat as D,isSizedDepthFormat as O,isSizedDepthStencilFormat as k}from"../../../webgl/textureUtils.js";import{getFormatComponents as A}from"../../../webgl/Util.js";const j=!!has(`esri-tests-disable-gpu-memory-measurements`);class M{constructor(e,n){this._data=e,this.id=u(),this.events=new t,this._parameters={...F,...n},this._startPreload(e)}dispose(){this.unload(),this._data=this.update=void 0}_startPreload(e){e instanceof HTMLVideoElement?(this.update=t=>this._update(e,t),this._startPreloadVideoElement(e)):e instanceof HTMLImageElement&&this._startPreloadImageElement(e)}_startPreloadVideoElement(e){if(!d(e.src)&&(e.preload!==`auto`||!e.crossOrigin)&&(e.preload=`auto`,e.crossOrigin=`anonymous`,e.src=e.src,e.paused&&e.autoplay)){let t=[];p(e,e=>t.push(e)).then(()=>{e.play()}).finally(()=>t.forEach(e=>e.remove()))}}_startPreloadImageElement(e){f(e.src)||d(e.src)||e.crossOrigin||(e.crossOrigin=`anonymous`,e.src=e.src)}_createDescriptor(e){let t=new T;return t.wrapMode=this._parameters.wrap??10497,t.flipped=!this._parameters.noUnpackFlip,t.samplingMode=this._parameters.mipmap?9987:9729,t.hasMipmap=!!this._parameters.mipmap,t.preMultiplyAlpha=!!this._parameters.preMultiplyAlpha,t.maxAnisotropy=this._parameters.maxAnisotropy??(this._parameters.mipmap?e.parameters.maxMaxAnisotropy:1),t.dataType=this._parameters.dataType??t.dataType,t.pixelFormat=this._parameters.pixelFormat??t.pixelFormat,t.internalFormat=this._parameters.internalFormat??t.internalFormat,t.isImmutable=this._parameters.immutable===!0&&I(this._parameters.internalFormat),t}get texture(){return this._texture??this._emptyTexture}get loaded(){return this._texture!=null}get usedMemory(){return j?0:this._texture?.usedMemory??N(this._data,this._parameters)}load(e){if(this._loadingPromise)return this._loadingPromise;if(this._texture)return this._texture;let t=this._data;return t==null?(this._texture=new w(e,this._createDescriptor(e),null),this._texture):(this._emptyTexture=e.emptyTexture,this._parameters.reloadable||(this._data=void 0),typeof t==`string`?this._loadFromURL(e,t):t instanceof Image?this._loadFromImageElement(e,t):t instanceof HTMLVideoElement?this._loadFromVideoElement(e,t):t instanceof ImageData||t instanceof HTMLCanvasElement?this._loadFromImage(e,t):s(t)&&this._parameters.encoding===`image/vnd-ms.dds`?this._loadFromDDSData(e,t):c(t)&&this._parameters.encoding===`image/vnd-ms.dds`?this._loadFromDDSData(e,new Uint8Array(t)):s(t)&&this._parameters.encoding===`image/ktx`?this._loadFromKTX1(e,t):c(t)&&this._parameters.encoding===`image/ktx`?this._loadFromKTX1(e,new Uint8Array(t)):(c(t)||s(t))&&this._parameters.encoding===`image/ktx2`?this._loadFromKTX2(e,t):(c(t)||s(t))&&this._parameters.encoding===`image/x.basis`?this._loadFromBasis(e,t):c(t)?this._loadFromPixelData(e,new Uint8Array(t)):l(t)?this._loadFromPixelData(e,t):null)}_update(e,t){return this._texture==null||e.readyState<HTMLMediaElement.HAVE_CURRENT_DATA||t===e.currentTime?t:(this._texture.setData(e),this.
|
|
2
|
+
import e from"../../../../core/Error.js";import{EventEmitter as t}from"../../../../core/Evented.js";import has from"../../../../core/has.js";import{disposeMaybe as n,removeMaybe as r}from"../../../../core/maybe.js";import{throwIfAborted as i,onAbort as a,createAbortError as o}from"../../../../core/promiseUtils.js";import{isUint8Array as s,isArrayBuffer as c,isTypedArray as l}from"../../../../core/typedArrayUtil.js";import{generateUID as u}from"../../../../core/uid.js";import{isBlobProtocol as d,isDataProtocol as f}from"../../../../core/urlUtils.js";import{whenVideoPlayable as p}from"../../../../layers/support/videoUtils.js";import{requestImage as m}from"../../../../request/image.js";import{loadImage as h}from"../../../../request/loadImage.js";import{createTextureKTX1 as g,createTextureKTX2 as _,createTextureBasis as v,estimateMemoryKTX2 as y,estimateMemoryBasis as b}from"./BasisUtil.js";import{createDDSTexture as x}from"./DDSUtil.js";import{ensureImageMaxSize as S}from"./textureUtils.js";import{assert as C}from"./Util.js";import w from"../../../webgl/Texture.js";import{TextureDescriptor as T}from"../../../webgl/TextureDescriptor.js";import{isCompressedFormat as E,isSizedPixelFormat as D,isSizedDepthFormat as O,isSizedDepthStencilFormat as k}from"../../../webgl/textureUtils.js";import{getFormatComponents as A}from"../../../webgl/Util.js";const j=!!has(`esri-tests-disable-gpu-memory-measurements`);class M{constructor(e,n){this._data=e,this.id=u(),this.events=new t,this._parameters={...F,...n},this._startPreload(e)}dispose(){this.unload(),this._data=this.update=void 0}_startPreload(e){e instanceof HTMLVideoElement?(this.update=t=>this._update(e,t),this._startPreloadVideoElement(e)):e instanceof HTMLImageElement&&this._startPreloadImageElement(e)}_startPreloadVideoElement(e){if(!d(e.src)&&(e.preload!==`auto`||!e.crossOrigin)&&(e.preload=`auto`,e.crossOrigin=`anonymous`,e.src=e.src,e.paused&&e.autoplay)){let t=[];p(e,e=>t.push(e)).then(()=>{e.play()}).finally(()=>t.forEach(e=>e.remove()))}}_startPreloadImageElement(e){f(e.src)||d(e.src)||e.crossOrigin||(e.crossOrigin=`anonymous`,e.src=e.src)}_createDescriptor(e){let t=new T;return t.wrapMode=this._parameters.wrap??10497,t.flipped=!this._parameters.noUnpackFlip,t.samplingMode=this._parameters.mipmap?9987:9729,t.hasMipmap=!!this._parameters.mipmap,t.preMultiplyAlpha=!!this._parameters.preMultiplyAlpha,t.maxAnisotropy=this._parameters.maxAnisotropy??(this._parameters.mipmap?e.parameters.maxMaxAnisotropy:1),t.dataType=this._parameters.dataType??t.dataType,t.pixelFormat=this._parameters.pixelFormat??t.pixelFormat,t.internalFormat=this._parameters.internalFormat??t.internalFormat,t.isImmutable=this._parameters.immutable===!0&&I(this._parameters.internalFormat),t}get texture(){return this._texture??this._emptyTexture}get loaded(){return this._texture!=null}get usedMemory(){return j?0:this._texture?.usedMemory??N(this._data,this._parameters)}load(e){if(this._loadingPromise)return this._loadingPromise;if(this._texture)return this._texture;let t=this._data;return t==null?(this._texture=new w(e,this._createDescriptor(e),null),this._texture):(this._emptyTexture=e.emptyTexture,this._parameters.reloadable||(this._data=void 0),typeof t==`string`?this._loadFromURL(e,t):t instanceof Image?this._loadFromImageElement(e,t):t instanceof HTMLVideoElement?this._loadFromVideoElement(e,t):t instanceof ImageData||t instanceof HTMLCanvasElement?this._loadFromImage(e,t):s(t)&&this._parameters.encoding===`image/vnd-ms.dds`?this._loadFromDDSData(e,t):c(t)&&this._parameters.encoding===`image/vnd-ms.dds`?this._loadFromDDSData(e,new Uint8Array(t)):s(t)&&this._parameters.encoding===`image/ktx`?this._loadFromKTX1(e,t):c(t)&&this._parameters.encoding===`image/ktx`?this._loadFromKTX1(e,new Uint8Array(t)):(c(t)||s(t))&&this._parameters.encoding===`image/ktx2`?this._loadFromKTX2(e,t):(c(t)||s(t))&&this._parameters.encoding===`image/x.basis`?this._loadFromBasis(e,t):c(t)?this._loadFromPixelData(e,new Uint8Array(t)):l(t)?this._loadFromPixelData(e,t):null)}_update(e,t){return this._texture==null||e.readyState<HTMLMediaElement.HAVE_CURRENT_DATA||t===e.currentTime?t:(this._texture.setData(e),this._parameters.updateCallback&&this._parameters.updateCallback(),e.currentTime)}_loadFromDDSData(e,t){return this._texture=x(e,this._createDescriptor(e),t),this._emptyTexture=null,this._texture}_loadFromKTX1(e,t){return this._texture=g(e,this._createDescriptor(e),t),this._emptyTexture=null,this._texture}_loadFromKTX2(e,t){return this._loadAsync(()=>_(e,this._createDescriptor(e),t).then(e=>(this._texture=e,e)))}_loadFromBasis(e,t){return this._loadAsync(()=>v(e,this._createDescriptor(e),t).then(e=>(this._texture=e,e)))}_loadFromPixelData(e,t){C(this._parameters.width>0&&this._parameters.height>0);let n=this._createDescriptor(e);return(n.pixelFormat===6407||n.pixelFormat===6408)&&(n.compress=this._parameters.compressionOptions),n.width=this._parameters.width??0,n.height=this._parameters.height??0,this._texture=new w(e,n,t),this._texture}_loadFromURL(e,t){return this._loadAsync(async n=>{let r=await m(t,{signal:n});return i(n),this._loadFromImage(e,r)})}_loadFromImageElement(e,t){return t.complete?this._loadFromImage(e,t):this._loadAsync(async n=>{let r=await h(t,t.src,!1,n);return i(n),this._loadFromImage(e,r)})}_loadFromVideoElement(e,t){return t.readyState>=HTMLMediaElement.HAVE_CURRENT_DATA?this._loadFromImage(e,t):this._loadFromVideoElementAsync(e,t)}_loadFromVideoElementAsync(t,n){return this._loadAsync(i=>new Promise((s,c)=>{let l=()=>{n.removeEventListener(`loadeddata`,u),n.removeEventListener(`error`,d),r(f)},u=()=>{n.readyState>=HTMLMediaElement.HAVE_CURRENT_DATA&&(l(),s(this._loadFromImage(t,n)))},d=t=>{l(),c(t||new e(`texture:load-error`,`Failed to load video`))};n.addEventListener(`loadeddata`,u),n.addEventListener(`error`,d);let f=a(i,()=>d(o()))}))}_loadFromImage(e,t){let n=t;n instanceof HTMLVideoElement||(n=S(n,e.parameters));let r=P(n);this._parameters.width=r.width,this._parameters.height=r.height;let i=this._createDescriptor(e);return i.width=r.width,i.height=r.height,i.compress=this._parameters.compressionOptions,this._texture=new w(e,i,n),this._emptyTexture=null,this.events.emit(`loaded`),this._texture}_loadAsync(e){let t=new AbortController;this._loadingController=t;let n=e(t.signal);this._loadingPromise=n;let r=()=>{this._loadingController===t&&(this._loadingController=null),this._loadingPromise===n&&(this._loadingPromise=null),this._emptyTexture=null};return n.then(r,r),n}unload(){if(this._texture=n(this._texture),this._emptyTexture=null,this._loadingController!=null){let e=this._loadingController;this._loadingController=null,this._loadingPromise=null,e.abort()}this.events.emit(`unloaded`)}get parameters(){return this._parameters}}function N(e,t){if(e==null)return 0;if(c(e)||s(e))return t.encoding===`image/ktx2`?y(e,!!t.mipmap):t.encoding===`image/x.basis`?b(e,!!t.mipmap):e.byteLength;let{width:n,height:r}=e instanceof Image||e instanceof ImageData||e instanceof HTMLCanvasElement||e instanceof HTMLVideoElement?P(e):t,i=t.pixelFormat??6408,a=A(i);return(t.mipmap?4/3:1)*n*r*a||0}function P(e){return e instanceof HTMLVideoElement?{width:e.videoWidth,height:e.videoHeight}:e}const F={wrap:{s:10497,t:10497},mipmap:!0,noUnpackFlip:!1,preMultiplyAlpha:!1};function I(e){return e!=null&&(E(e)||D(e)||O(e)||k(e))}export{M as ManagedTexture};
|