@arcgis/core 6.0.0-next.53 → 6.0.0-next.55

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (300) hide show
  1. package/WebScene.js +2 -2
  2. package/applications/Components/OrientedImageryViewer/shared/constants.js +1 -1
  3. package/applications/SceneViewer/sceneViewerUtils.js +1 -1
  4. package/arcade/arcadeAsyncRuntime.js +1 -1
  5. package/arcade/arcadeCompiler.js +1 -1
  6. package/arcade/arcadeRuntime.js +1 -1
  7. package/arcade/featureset/support/sqlUtils.js +1 -1
  8. package/arcade/validation/arcadeValidator.js +1 -1
  9. package/assets/esri/core/workers/RemoteClient.js +1 -1
  10. package/assets/esri/core/workers/chunks/0329fa3aa3403f1c243b.js +1 -0
  11. package/assets/esri/core/workers/chunks/{6602310c3fcd91fb6a2f.js → 07c8ac092e4b9e8d5b3c.js} +1 -1
  12. package/assets/esri/core/workers/chunks/0a97b1974367382cfdf5.js +1 -0
  13. package/assets/esri/core/workers/chunks/{db0a7671ab5cbe8afd72.js → 123661019bb69c53f2d3.js} +1 -1
  14. package/assets/esri/core/workers/chunks/{d14732a57c8e63948c60.js → 14259910f44c08fd5bbd.js} +1 -1
  15. package/assets/esri/core/workers/chunks/{1b41ba050cde068d2860.js → 193a73a2c7f4f8482c21.js} +1 -1
  16. package/assets/esri/core/workers/chunks/20acb6f3ed5140b6c6c6.js +1 -0
  17. package/assets/esri/core/workers/chunks/{e507dfc4788295d9c244.js → 249a687ce1b6d0815242.js} +1 -1
  18. package/assets/esri/core/workers/chunks/{afb4dfb89fbc8a342cc5.js → 3354f1fa90f8ce4c8fde.js} +1 -1
  19. package/assets/esri/core/workers/chunks/{9b458b0d1627f22fdd93.js → 3b11e4d2e69b7aea1d65.js} +1 -1
  20. package/assets/esri/core/workers/chunks/41694ee8990e799da225.js +1 -0
  21. package/assets/esri/core/workers/chunks/{e592f2483db71230e8e5.js → 4401b3f8ebb658abe789.js} +1 -1
  22. package/assets/esri/core/workers/chunks/{12add2003631fa314f25.js → 5060be52a380fc4920f8.js} +1 -1
  23. package/assets/esri/core/workers/chunks/{2aa6be0b047a1b25a520.js → 53bbb9aa6e4e4a0a8121.js} +1 -1
  24. package/assets/esri/core/workers/chunks/{4707aedcc1b3bdf5e987.js → 5c34d49a6c9cc34b7626.js} +1 -1
  25. package/assets/esri/core/workers/chunks/69a09c6acb5ae03c67f6.js +1 -0
  26. package/assets/esri/core/workers/chunks/7b156905d168bf973518.js +1 -0
  27. package/assets/esri/core/workers/chunks/{e83806797979138fd22a.js → 844c593754b2692257f4.js} +1 -1
  28. package/assets/esri/core/workers/chunks/{2d3e977f3b75474d7ebc.js → 846248697c398468d8e6.js} +1 -1
  29. package/assets/esri/core/workers/chunks/{f7e33d37dd11fb08f3f8.js → 97107e64407fa6825620.js} +1 -1
  30. package/assets/esri/core/workers/chunks/{032733b863426c5bde00.js → 9e508f930086d2ef5f22.js} +3 -3
  31. package/assets/esri/core/workers/chunks/{5118c7269b706089c88e.js → a05a2c2aaf0c288f9681.js} +1 -1
  32. package/assets/esri/core/workers/chunks/{817bf487df056da1e6ec.js → a116dd204921e7464944.js} +1 -1
  33. package/assets/esri/core/workers/chunks/{944f17e9c9f681b971fb.js → a12e2a345005189c64be.js} +1 -1
  34. package/assets/esri/core/workers/chunks/{15b3386ad92a0b4149b8.js → a24dc5350af001db417a.js} +1 -1
  35. package/assets/esri/core/workers/chunks/{10967a36c77c5188690d.js → a66d6298236d59a615db.js} +1 -1
  36. package/assets/esri/core/workers/chunks/{255f5b45c4d32f97f86c.js → ac0861014b3d2f1a1de2.js} +1 -1
  37. package/assets/esri/core/workers/chunks/ace210d313ce53f3ae10.js +1 -0
  38. package/assets/esri/core/workers/chunks/ae48ee283cfa5b3c14b0.js +1 -0
  39. package/assets/esri/core/workers/chunks/bbd8fcb0bbba7bde3d9b.js +1 -0
  40. package/assets/esri/core/workers/chunks/{ac8d38016e4bee37a77c.js → be0b8bb4f09aae6ff5de.js} +1 -1
  41. package/assets/esri/core/workers/chunks/d0659f1b0495734be4b3.js +1 -0
  42. package/assets/esri/core/workers/chunks/{b9a2b05ede02c305e865.js → d8ffb1502def5c85740b.js} +1 -1
  43. package/assets/esri/core/workers/chunks/{7dfe1e78d2e66de6be22.js → d9ef244019954d5a8a27.js} +1 -1
  44. package/assets/esri/core/workers/chunks/{95403bb27a4ea0a4b7b1.js → ddbfa664e69612295785.js} +1 -1
  45. package/assets/esri/core/workers/chunks/{c6d82397044e403a1f61.js → e61082f56c08abe54b3a.js} +1 -1
  46. package/assets/esri/core/workers/chunks/{55d28d3f5b8ced061e39.js → eaf73ce60f39a48ddd2a.js} +1 -1
  47. package/assets/esri/core/workers/chunks/ed2f2a5da830d058e339.js +1 -0
  48. package/assets/esri/core/workers/chunks/{944cb751c85d3a127f49.js → f52d081bbde5c95265cf.js} +1 -1
  49. package/assets/esri/core/workers/chunks/{1de9be7b65109c207bd5.js → fbd5f3b81cd9f061824d.js} +1 -1
  50. package/assets/esri/layers/raster/formats/blosc-wasm.wasm +0 -0
  51. package/assets/esri/libs/librust-parquet/pkg/parquet_bg.wasm +0 -0
  52. package/basemapGallery/support/basemapCompatibilityUtils.js +1 -1
  53. package/chunks/CypherParser.js +1 -1
  54. package/chunks/GeodeticDistanceCalculator-zRp89-dW.js +1 -1
  55. package/chunks/MultiPathImpl.js +1 -1
  56. package/chunks/OperatorGeodesicBuffer.js +1 -1
  57. package/chunks/UnitFactory.js +1 -1
  58. package/chunks/blosc-wasm.js +2 -0
  59. package/chunks/cameraUtilsSpherical.js +1 -1
  60. package/chunks/parquet.js +1 -1
  61. package/chunks/text.js +1 -1
  62. package/config.js +1 -1
  63. package/core/sql/SqlInterval.js +1 -1
  64. package/core/urlUtils.js +1 -1
  65. package/geometry/geometryEngine.js +1 -1
  66. package/geometry/operators/gx/operatorOffset.js +1 -1
  67. package/geometry/support/Ellipsoid.js +1 -1
  68. package/geometry/support/curves/ellipticArc7Utils.js +1 -1
  69. package/geometry/support/geodesicConstants.js +1 -1
  70. package/geometry/support/meshUtils/primitives.js +1 -1
  71. package/kernel.js +1 -1
  72. package/layers/Lyr3DWasmPerSceneView.js +1 -1
  73. package/layers/VoxelWasmPerSceneView.js +1 -1
  74. package/layers/effects/parser.js +1 -1
  75. package/layers/geospatialPDF/GeospatialPDFLayerWorker.js +1 -1
  76. package/layers/graphics/controllers/I3SOnDemandController.js +1 -1
  77. package/layers/graphics/data/QueryEngineResult.js +1 -1
  78. package/layers/graphics/sources/support/ParquetSourceWorker.js +1 -1
  79. package/layers/parquet.js +1 -1
  80. package/layers/raster/datasets/ZarrRaster.js +1 -1
  81. package/layers/raster/datasets/wcsCoverageParser.js +1 -1
  82. package/layers/raster/formats/RasterCodec.js +1 -1
  83. package/layers/raster/formats/blosc.js +2 -0
  84. package/layers/support/BuildingFilter.js +1 -1
  85. package/layers/support/IntegratedMeshSemantics.js +1 -1
  86. package/layers/support/fieldUtils.d.ts +23 -87
  87. package/layers/support/fieldUtils.js +1 -1
  88. package/layers/support/layersMapping.js +1 -1
  89. package/layers/video/VideoController.js +1 -1
  90. package/legend/ActiveLayerInfo.js +1 -1
  91. package/libs/ajv/ajv.bundle-wrapper.js +1 -1
  92. package/package.json +4 -4
  93. package/renderers/types.d.ts +1 -1
  94. package/rest/knowledgeGraphService.js +1 -1
  95. package/rest/query/operations/pbfFeatureServiceParser.js +1 -1
  96. package/smartMapping/statistics/support/attributeDensity.js +1 -1
  97. package/smartMapping/support/adapters/support/utils.js +1 -1
  98. package/support/tests/serviceMockDependencies.js +1 -1
  99. package/symbols/cim/CIMEffects.js +1 -1
  100. package/symbols/cim/CIMSymbolDrawHelper.js +1 -1
  101. package/symbols/cim/effects/EffectControlMeasureLine.js +1 -1
  102. package/symbols/cim/placements/PlacementInsidePolygon.js +1 -1
  103. package/symbols/cim/rasterizingUtils.js +1 -1
  104. package/views/2d/PaddedViewState.js +1 -1
  105. package/views/2d/engine/vectorTiles/buckets/FillBucket.js +1 -1
  106. package/views/2d/engine/vectorTiles/constants.js +1 -1
  107. package/views/2d/engine/vectorTiles/style/geoJSONVectorTileUtils.js +1 -1
  108. package/views/2d/engine/webgl/effects/HighlightEffect.js +1 -1
  109. package/views/2d/engine/webgl/mesh/templates/segmentUtils.js +1 -1
  110. package/views/2d/engine/webgl/mesh/templates/shapingUtils.js +1 -1
  111. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/constants.js +1 -1
  112. package/views/2d/engine/webgl/shaderGraph/techniques/text/TextShader.js +1 -1
  113. package/views/2d/interactive/editingTools/ControlPointsTransformTool.js +1 -1
  114. package/views/2d/interactive/editingTools/TransformTool.js +1 -1
  115. package/views/2d/layers/FeatureLikeLayerView2D.js +1 -1
  116. package/views/2d/layers/ParquetLayerView2D.js +1 -1
  117. package/views/2d/layers/features/Processor.js +1 -1
  118. package/views/2d/layers/features/aggregation/GridSpatialIndex.js +1 -1
  119. package/views/2d/layers/features/support/AttributeStore.js +1 -1
  120. package/views/2d/layers/features/support/FeatureSetReaderPBF.js +1 -1
  121. package/views/2d/layers/graphics/GraphicsView2D.js +1 -1
  122. package/views/3d/analysis/AreaMeasurement/support/AreaMeasurementPathHelper.js +1 -1
  123. package/views/3d/analysis/Dimension/DimensionTool.js +1 -1
  124. package/views/3d/analysis/Dimension/LengthDimensionSubTool.js +1 -1
  125. package/views/3d/analysis/ElevationProfile/ElevationProfileLineSceneComputation.js +1 -1
  126. package/views/3d/analysis/LineOfSight/LineOfSightController.js +1 -1
  127. package/views/3d/analysis/LineOfSight/LineOfSightItemManipulatedObject3D.js +1 -1
  128. package/views/3d/analysis/LineOfSight/LineOfSightRayIntersector.js +1 -1
  129. package/views/3d/analysis/ShadowCastAnalysisView3D.js +1 -1
  130. package/views/3d/analysis/Slice/SliceTool.js +1 -1
  131. package/views/3d/analysis/Viewshed/ViewshedObserverManipulatedObject3D.js +1 -1
  132. package/views/3d/analysis/Viewshed/ViewshedSnappingController.js +1 -1
  133. package/views/3d/analysis/Viewshed/ViewshedTool.js +1 -1
  134. package/views/3d/analysis/ViewshedAnalysisView3D.js +1 -1
  135. package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementCutFillComputation.js +1 -1
  136. package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementVisualization.js +1 -1
  137. package/views/3d/animation/pointToPoint/Camera.js +1 -1
  138. package/views/3d/camera/constraintUtils.js +1 -1
  139. package/views/3d/camera/intersectionUtils.js +1 -1
  140. package/views/3d/environment/EnvironmentView.js +1 -1
  141. package/views/3d/focusAreaUtils.js +1 -1
  142. package/views/3d/interactive/editingTools/ManipulatedObject3DGraphic.js +1 -1
  143. package/views/3d/interactive/editingTools/dragEventPipeline3D.js +1 -1
  144. package/views/3d/interactive/editingTools/manipulations/config.js +1 -1
  145. package/views/3d/interactive/editingTools/media/MediaElementControllerControlPoints.js +1 -1
  146. package/views/3d/interactive/editingTools/media/MediaElementControllerShape.js +1 -1
  147. package/views/3d/interactive/editingTools/move/MoveTool3D.js +1 -1
  148. package/views/3d/interactive/editingTools/transform/ScaleRotateMeshAdapter.js +1 -1
  149. package/views/3d/interactive/editingTools/transform/TransformTool3D.js +1 -1
  150. package/views/3d/interactive/measurementTools/areaMeasurement3D/AreaMeasurement3DTool.js +1 -1
  151. package/views/3d/interactive/measurementTools/areaMeasurement3D/AreaMeasurement3DView.js +1 -1
  152. package/views/3d/interactive/measurementTools/directLineMeasurement3D/DirectLineMeasurement3DTool.js +1 -1
  153. package/views/3d/layers/I3SMeshView3D.js +1 -1
  154. package/views/3d/layers/SceneLayerGraphicsView3D.js +1 -1
  155. package/views/3d/layers/TiledLayerView3D.js +1 -1
  156. package/views/3d/layers/graphics/Graphics3DExtrudeSymbolLayer.js +1 -1
  157. package/views/3d/layers/graphics/Graphics3DIconSymbolLayer.js +1 -1
  158. package/views/3d/layers/graphics/Graphics3DLineSymbolLayer.js +1 -1
  159. package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
  160. package/views/3d/layers/graphics/Graphics3DObjectSymbolLayer.js +1 -1
  161. package/views/3d/layers/graphics/Graphics3DPathSymbolLayer.js +1 -1
  162. package/views/3d/layers/graphics/Graphics3DPolygonFillSymbolLayer.js +1 -1
  163. package/views/3d/layers/graphics/Graphics3DSymbolFactory.js +1 -1
  164. package/views/3d/layers/graphics/LabelInfo.js +1 -1
  165. package/views/3d/layers/i3s/I3SClientNodeLoader.js +1 -1
  166. package/views/3d/layers/i3s/I3SIndex.js +1 -1
  167. package/views/3d/layers/i3s/I3SIntersectionHandler.js +1 -1
  168. package/views/3d/layers/i3s/I3SMeshViewFilter.js +1 -1
  169. package/views/3d/layers/i3s/I3SNode.js +1 -1
  170. package/views/3d/layers/i3s/I3SOverrides.js +1 -1
  171. package/views/3d/layers/i3s/I3SViewportQueries.js +1 -1
  172. package/views/3d/layers/i3s/LayerElevationProvider.js +1 -1
  173. package/views/3d/layers/support/FeatureTileFetcher3D.js +1 -1
  174. package/views/3d/layers/support/FeatureTileFetcher3DContext.js +1 -1
  175. package/views/3d/layers/support/FeatureTileMeasurements3D.js +1 -1
  176. package/views/3d/layers/support/FeatureTileVisibility3D.js +1 -1
  177. package/views/3d/layers/support/StageLayerElevationProvider.js +1 -1
  178. package/views/3d/layers/support/Tiles3DLayerViewRegistration.js +1 -1
  179. package/views/3d/layers/support/selectTiles3DSpatialReference.js +1 -1
  180. package/views/3d/layers/support/uvUtils.js +1 -1
  181. package/views/3d/state/Constraints.js +1 -1
  182. package/views/3d/state/ConstraintsManager.js +1 -1
  183. package/views/3d/state/NearFarHeuristic.js +1 -1
  184. package/views/3d/state/ViewState.js +1 -1
  185. package/views/3d/state/ViewStateManager.js +1 -1
  186. package/views/3d/state/controllers/PinchAndPanControllerGlobal.js +1 -1
  187. package/views/3d/state/controllers/PinchAndPanControllerLocal.js +1 -1
  188. package/views/3d/state/controllers/PointToPointAnimationController.js +1 -1
  189. package/views/3d/state/controllers/ZoomStepControllerGlobal.js +1 -1
  190. package/views/3d/state/controllers/ZoomStepControllerLocal.js +1 -1
  191. package/views/3d/state/helpers/SceneIntersectionHelper.js +1 -1
  192. package/views/3d/state/utils/OffsetCorrectionController.js +1 -1
  193. package/views/3d/state/utils/groundNavigationUtils.js +1 -1
  194. package/views/3d/state/utils/navigationUtils.js +1 -1
  195. package/views/3d/support/FrustumExtentIntersection.js +1 -1
  196. package/views/3d/support/RenderCoordsHelper.js +1 -1
  197. package/views/3d/support/SweptSphereVolume.js +1 -1
  198. package/views/3d/support/cameraUtils.js +1 -1
  199. package/views/3d/support/elevationUpdateExtentUtils.js +1 -1
  200. package/views/3d/support/engineContent/line.js +1 -1
  201. package/views/3d/support/engineContent/marker.js +1 -1
  202. package/views/3d/support/hitTest.js +1 -1
  203. package/views/3d/support/orientedBoundingBox.js +1 -1
  204. package/views/3d/support/pointsOfInterest/CameraOnSurface.js +1 -1
  205. package/views/3d/support/pointsOfInterest/PointsOfInterest.js +1 -1
  206. package/views/3d/support/pointsOfInterest/SurfaceGeometryUpdates.js +1 -1
  207. package/views/3d/support/sunUtils.js +1 -1
  208. package/views/3d/terrain/ExtentHelper.js +1 -1
  209. package/views/3d/terrain/OverlayManager.js +1 -1
  210. package/views/3d/terrain/OverlayRenderer.js +1 -1
  211. package/views/3d/terrain/PatchGeometryFactory.js +1 -1
  212. package/views/3d/terrain/TerrainRenderer.js +1 -1
  213. package/views/3d/terrain/TerrainSurface.js +1 -1
  214. package/views/3d/terrain/Tile.js +1 -1
  215. package/views/3d/terrain/TilingSchemeLogic.js +1 -1
  216. package/views/3d/terrain/terrainUtils.js +1 -1
  217. package/views/3d/webgl/RenderCamera.js +1 -1
  218. package/views/3d/webgl-engine/Stage.js +1 -1
  219. package/views/3d/webgl-engine/collections/Component/ComponentObject.js +1 -1
  220. package/views/3d/webgl-engine/collections/Component/ComponentObjectCollection.js +1 -1
  221. package/views/3d/webgl-engine/collections/Component/ComponentObjectElevationAgnosticBVH.js +1 -1
  222. package/views/3d/webgl-engine/collections/Component/ComponentObjectElevationAgnosticComponentGeometryBVH.js +1 -1
  223. package/views/3d/webgl-engine/collections/Component/ElevationAgnosticBVH.js +1 -1
  224. package/views/3d/webgl-engine/collections/Component/IntersectionGeometry.js +1 -1
  225. package/views/3d/webgl-engine/collections/Component/Material/ComponentMaterial.js +1 -1
  226. package/views/3d/webgl-engine/collections/Component/Material/ComponentMaterialRepository.js +1 -1
  227. package/views/3d/webgl-engine/collections/Component/Material/ComponentTechniqueConfiguration.js +1 -1
  228. package/views/3d/webgl-engine/core/shaderLibrary/terrain/Overlay.glsl.js +1 -1
  229. package/views/3d/webgl-engine/effects/atmosphere/MarsAtmosphere.js +1 -1
  230. package/views/3d/webgl-engine/effects/debug/RenderNodeVisualizerNode.js +1 -1
  231. package/views/3d/webgl-engine/effects/highlight/ShadowHighlight.js +1 -1
  232. package/views/3d/webgl-engine/effects/laserlines/LaserlinePathData.js +1 -1
  233. package/views/3d/webgl-engine/effects/shadowAccumulation/ShadowAccumulator.js +1 -1
  234. package/views/3d/webgl-engine/lib/Intersector.js +1 -1
  235. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  236. package/views/3d/webgl-engine/lib/ShadowMap.js +1 -1
  237. package/views/3d/webgl-engine/lib/TextRenderParameters.js +1 -1
  238. package/views/3d/webgl-engine/lib/TextRenderer.js +1 -1
  239. package/views/3d/webgl-engine/lib/TriangleIntersectionData.js +1 -1
  240. package/views/3d/webgl-engine/lib/edgeRendering/EdgeView.js +1 -1
  241. package/views/3d/webgl-engine/lib/edgeRendering/strokes.js +1 -1
  242. package/views/3d/webgl-engine/lib/verticalOffsetUtils.js +1 -1
  243. package/views/3d/webgl-engine/materials/DefaultMaterial.js +1 -1
  244. package/views/3d/webgl-engine/materials/PolygonOffset.js +1 -1
  245. package/views/3d/webgl-engine/materials/RibbonLineMaterial.js +1 -1
  246. package/views/3d/webgl-engine/parts/RenderView.js +1 -1
  247. package/views/MapView.d.ts +1 -0
  248. package/views/SceneView.js +1 -1
  249. package/views/View2D.js +1 -1
  250. package/views/ViewingMode.js +1 -1
  251. package/views/analysis/ElevationProfile/elevationProfileChartBoundsUtils.js +1 -1
  252. package/views/analysis/ElevationProfile/elevationProfileGeometryUtils.js +1 -1
  253. package/views/draw/DrawAction.js +1 -1
  254. package/views/draw/DrawOperation.js +1 -1
  255. package/views/draw/DrawTool.js +1 -1
  256. package/views/draw/SegmentDrawAction.js +1 -1
  257. package/views/draw/support/Reshape.js +1 -1
  258. package/views/draw/support/helpMessageUtils.js +1 -1
  259. package/views/draw/support/managers/EditSessionManager.js +1 -1
  260. package/views/interactive/dragEventPipeline.js +1 -1
  261. package/views/interactive/editGeometry/EditGeometry.js +1 -1
  262. package/views/interactive/editGeometry/EditGeometryOperations.js +1 -1
  263. package/views/interactive/editGeometry/operations/AddOrUpdatePart.js +1 -1
  264. package/views/layers/support/editableLayerViews.js +1 -1
  265. package/views/overlay/TextOverlayItem.js +1 -1
  266. package/views/support/DefaultsFromMap.js +1 -1
  267. package/views/support/Scheduler.js +1 -1
  268. package/views/support/spatialReferenceSupport.js +1 -1
  269. package/views/webgl/ShaderTranspiler.js +2 -2
  270. package/widgets/AreaMeasurement2D/AreaMeasurement2DTool.js +1 -1
  271. package/widgets/BasemapGallery/support/basemapCompatibilityUtils.js +1 -1
  272. package/widgets/BatchAttributeForm.js +1 -1
  273. package/widgets/DistanceMeasurement2D/DistanceMeasurement2DTool.js +1 -1
  274. package/widgets/Editor/workflowUtils.js +1 -1
  275. package/widgets/ElevationProfile/ElevationProfileLineView.js +1 -1
  276. package/widgets/ElevationProfile/support/chartUtils.js +1 -1
  277. package/widgets/ElevationProfile/support/geometryUtils.js +1 -1
  278. package/widgets/FeatureForm.js +1 -1
  279. package/widgets/Legend/styles/card/ColorRamp.js +1 -1
  280. package/widgets/Legend/support/ActiveLayerInfo.js +1 -1
  281. package/widgets/Measurement.js +1 -1
  282. package/widgets/OrientedImageryViewer/components/ImageLocationWidget.js +1 -1
  283. package/widgets/OrientedImageryViewer/components/ImageMeasurementWidget.js +1 -1
  284. package/widgets/Search/support/layerSearchUtils.js +1 -1
  285. package/widgets/ShadowCast/ShadowCastViewModel.js +1 -1
  286. package/widgets/UtilityNetworkAssociations/UtilityNetworkAssociationsViewModel.js +1 -1
  287. package/widgets/UtilityNetworkAssociations.js +1 -1
  288. package/widgets/Weather/WeatherViewModel.js +1 -1
  289. package/widgets/Weather/css.js +1 -1
  290. package/widgets/Weather.js +1 -1
  291. package/assets/esri/core/workers/chunks/021bd07b9a3e70598840.js +0 -1
  292. package/assets/esri/core/workers/chunks/170e68624b71ac96de4a.js +0 -1
  293. package/assets/esri/core/workers/chunks/8a820e303941b351de81.js +0 -1
  294. package/assets/esri/core/workers/chunks/90d567e920b6982b402d.js +0 -1
  295. package/assets/esri/core/workers/chunks/97cdcedfe853280f6258.js +0 -1
  296. package/assets/esri/core/workers/chunks/9ebc6026934400fc1e1f.js +0 -1
  297. package/assets/esri/core/workers/chunks/b4a325dcf50e276751d7.js +0 -1
  298. package/assets/esri/core/workers/chunks/be5857b0d1b00faf430b.js +0 -1
  299. package/assets/esri/core/workers/chunks/cd9100a7c8309dfa7569.js +0 -1
  300. package/assets/esri/core/workers/chunks/e58f51618251f74aaafd.js +0 -1
@@ -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{property as n,subclass as r}from"../../../core/accessorSupport/decorators.js";import{filterInPlace as i,difference as a}from"../../../core/arrayUtils.js";import o from"../../../core/CollectionFlattener.js";import{toConst as s}from"../../../core/compilerUtils.js";import{EventedAccessor as c}from"../../../core/Evented.js";import"../../../core/has.js";import{set as l,copy as u,exactEquals as ee}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{create as d}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import f from"../../../core/Logger.js";import{clamp as te}from"../../../core/mathUtils.js";import{destroyMaybe as p,removeMaybe as ne}from"../../../core/maybe.js";import{MemCachePool as re}from"../../../core/MemCachePool.js";import m from"../../../core/ObjectPool.js";import ie from"../../../core/PooledArray.js";import{throwIfAborted as ae,isAbortError as h,isAborted as g}from"../../../core/promiseUtils.js";import{watch as _,syncAndInitial as v,initial as y,sync as b}from"../../../core/reactiveUtils.js";import"../../../core/scheduling.js";import{UpdatingHandles as oe}from"../../../core/support/UpdatingHandles.js";import{getMetersPerUnitForSR as se}from"../../../core/units.js";import{getReferenceEllipsoid as x,radiusModifier as ce}from"../../../geometry/ellipsoidUtils.js";import{projectBoundingSphere as le}from"../../../geometry/projection/projectBoundingSphere.js";import{getProjector as ue}from"../../../geometry/projection/projectors.js";import{projectPointToVector as de}from"../../../geometry/projection/projectPointToVector.js";import{projectVectorToVector as fe}from"../../../geometry/projection/projectVectorToVector.js";import{projectWithoutEngine as pe}from"../../../geometry/projectionUtils.js";import me from"../../../geometry/SpatialReference.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{IntegratedMeshSemantics as we}from"../../../layers/support/IntegratedMeshSemantics.js";import{isIntegratedMeshLayer as Te,isBaseLayer as Ee}from"../../../layers/support/layerUtils.js";import{queueHighPriority as De}from"../../../request/queue.js";import{hasLayerBasedScaleVisibility as Oe}from"../../support/layerViewUtils.js";import{ImmediateTask as T,TaskPriority as ke,noBudget as Ae}from"../../support/Scheduler.js";import{TextureCompressionTracker as je}from"../../support/TextureCompressionTracker.js";import{Yield as Me}from"../../support/Yield.js";import{debugFlags as E}from"../support/debugFlags.js";import{ElevationRange as D}from"../support/ElevationRange.js";import{ElevationUpdateEvent as Ne}from"../support/ElevationUpdateEvent.js";import{calculateElevationUpdateExtents as Pe}from"../support/elevationUpdateExtentUtils.js";import{toBoundingRect as Fe}from"../support/extentUtils.js";import{geographicMbsToGeographicExtent as Ie,mbsToGeographicExtent as Le,intersectsGeographicExtent as Re}from"../support/sphereExtentUtils.js";import{isSupportedGCSOnGlobe as O}from"../support/supportedSpatialReference.js";import{updatingProgress as ze}from"../support/updatingProperties.js";import{isCompositeBlendMode as Be,blendModeFromString as Ve}from"../webgl-engine/core/shaderLibrary/output/BlendOptions.js";import{ElevationBounds as He}from"./ElevationBounds.js";import{ElevationData as Ue,sampleElevation as We}from"./ElevationData.js";import{create as Ge}from"./ExtentHelper.js";import{LayerClasses as Ke}from"./LayerClass.js";import{OverlayManager as qe}from"./OverlayManager.js";import{PlanarPatch as Je}from"./PlanarPatch.js";import{Queue as Ye}from"./Queue.js";import{ScaleRangeQueries as Xe}from"./ScaleRangeQueries.js";import{SphericalPatch as Ze}from"./SphericalPatch.js";import{SplitLimits as Qe}from"./SplitLimits.js";import{maxRootTiles as k,tooManyRootTilesAfterChangeError as $e,tooManyRootTilesForLayerError as et,maxTileNeighborLevelDelta as A,maxMemoryLodBias as tt}from"./TerrainConst.js";import{TerrainRenderer as nt}from"./TerrainRenderer.js";import rt from"./TerrainSurfacePerformanceInfo.js";import{weakAssert as j,isVectorTileLayerView as M,internalAssert as N,oppositeEdge as it,neighborEdgeIndices as P,isSurfaceLayerView as F,isGroupLayerView as I,isMapTileLayerView as L,isBlendableLayerView as R,isElevationLayerView as z,releaseTerrainData as B,oppositeCorner as at,enableTerrainInternalChecks as V,enableWaterproofTests as ot,enableInternalTerrainChecks as st,enableTerrainWaterproofChecks as ct,neighborCornerIndices as lt}from"./terrainUtils.js";import{Tile as ut,lijEquals as H}from"./Tile.js";import{printAllocations as dt}from"./TilePerLayerInfo.js";import{sortTiles as ft,IteratorPreorder as pt,IteratorPostorder as mt,compareTilesByLij as U,sortTilesByPOI as ht,traverseTilesPreorder as W}from"./tileUtils.js";import{TilingSchemeLogic as gt}from"./TilingSchemeLogic.js";import{getGroundTransparencyModeFromOpacity as _t}from"./TransparencyMode.js";import{UpsampleInfo as vt}from"./UpsampleInfo.js";var G;let K=class extends c{static{G=this}get allTilesCreated(){return this._allTilesCreated}get allTiles(){return s(this._allTiles)}get renderedTiles(){return ft(i(this._allTiles.toArray(),e=>e.visible&&e.rendered))}get _tileConstructor(){return this.view.state.isGlobal?Ze:Je}get _ellipsoid(){return x(this.view.spatialReference)}get demResolution(){let{_allTiles:e,tilingScheme:t}=this;if(e.length===0)return{min:1,max:1};let n=se(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 je,this._iteratorPool=new m(()=>new pt,e=>e.remove=()=>this._iteratorPool.release(e)),this._postorderIterator=new mt,this._hasPendingUpdates=!1,this._pendingUpdates=0,this._asyncWorkItems=0,this._allTilesDirty=!0,this._allTilesSorted=!0,this._allTilesCreated=!1,this._usedMemory=null,this._performanceInfo=new rt,this._waterproofnessErrorHandle=null,this._viewChanged=!1,this.heading=0,this._inFrameTask=!1,this._viewChangeUpdateDirty=!1,this._eyePosRenderSR=d(),this._eyePosSurfaceSR=d(),this._splitLimits=new Qe,this._layerViews=[[],[]],this._layerIndexByUid=[new Map,new Map],this._basemapLayerViewHandles=new Map,this._updatingHandles=new oe,this._poiWatchHandle=null,this._frameTask=T,this._allTiles=new ie,this._upsampleInfoPool=new m(()=>new vt),this._shouldEmitChangeEvent=!1,this._rootTilesExtent=S(),this.updatingProgress=.5,this._maxNumUpdating=1,this.hasCompositeBlendMode=!1,this.maxTextureScale=1.2,this._elevationProjectorCache=new Map,this._rootTileElevationRange=new D(1/0,-1/0),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.enabled=!0,this.overlayManager=new qe({...e,terrainSurface:this}),this._renderer=new nt(this,this.overlayManager.renderer,this._allTiles,this.terrainTextureCompressionTracker,e.view),Oe()||(this._scaleRangeQueries=new Xe)}initialize(){let{view:e}=this,{resourceController:t}=e,{memoryController:n}=t;e.stage.addRenderPlugin(this._renderer),this._tileCache=new re((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([_(()=>r.renderer.isEmpty,()=>this._evaluateTransparency()),_(()=>this.renderer.visible,e=>this.freeze=!e),_(()=>this.heading,e=>{this._renderer.updateHeading(e),this._updateTileTextures(0)},v)],`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)},y),this.addHandles([_(()=>this.baseOpacity,()=>{this._handleLayerViewChanges(),this._updateTileTextures(this._evaluateTransparency()?1:2)},v),_(()=>this.hasCompositeBlendMode,()=>this._updateTileTextures(this._evaluateTransparency()?1:2),v),_(()=>this.backgroundColor,(e,t)=>{e?.equals(t)||(this._handleLayerViewChanges(),this._renderer.updateTileBackground(e))},b),_(()=>this.snapLevel,()=>this._viewChanged=!0,b),_(()=>this.view.pointsOfInterest,e=>{this._renderer.pointsOfInterest=e,this._poiWatchHandle=ne(this._poiWatchHandle),e&&(this._poiWatchHandle=this._updatingHandles.add(()=>e.focus?.renderLocation,()=>this._allTilesSorted=!1,{equals:ee}))}),_(()=>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=p(this._treeDebugger))},y),_(()=>this.tilingScheme,e=>this._updateTilingScheme(e),b)]);let{spatialReference:i}=e;this._extentHelper=Ge(this.viewingMode,{layers:e.map.allLayers,layerViews:e.allLayerViews,viewSpatialReference:i});let a=new o({getCollections:()=>e.defaultsFromMap?.mapCollections?.map(({layers:e})=>e),getChildrenFunction:e=>e&&`layers`in e?e.layers:null}),s=new gt({layers:a,extentHelper:this._extentHelper,viewingMode:this.viewingMode,viewSpatialReference:i});this._set(`tilingSchemeLogic`,s);let c=t.scheduler;this._frameTask=c.registerTask(ke.TERRAIN_SURFACE,this),this.addHandles([_(()=>this._stencilEnabledExtents,e=>this._renderer.setStencilEnabledLayerExtents(e),y),_(()=>this.groundExtent,()=>this._updateRootTiles(),y),e.on(`resize`,()=>this._viewChangeUpdate()),_(()=>{let t=e.state;return[this._lodBias,this.lodSnappingEnabled,e.quality,t.camera,t.contentCamera,t.fixedContentCamera]},()=>this._viewChangeUpdate(),v),_(()=>e.qualitySettings?.fadeDuration,e=>this._renderer.textureFadingEnabled=e>0,y),_(()=>e.qualitySettings?.physicallyBasedRenderingEnabled,e=>this._renderer.pbrMode=e?5:0,y),_(()=>e.qualitySettings?.tiledSurface.elevationLevelDelta,()=>{this._allTiles.forAll(e=>this.updateElevationSources(e)),this._updateAllTileGeometries()}),e.allLayerViews.on(`after-changes`,()=>this._layerViewsDirty=!0)]),this._updatingHandles.add(()=>this.userClippingExtent,()=>this._updateClippingExtent()),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=T,this._updatingHandles?.destroy(),this._removeAllTiles(),this._set(`tilingSchemeLogic`,p(this.tilingSchemeLogic)),this._basemapLayerViewHandles.forEach((e,t)=>this._unregisterTiledLayerView(t)),this._basemapLayerViewHandles.clear(),this._set(`overlayManager`,p(this.overlayManager)),this._tileCache=p(this._tileCache),this._allTiles.prune(),ut.prune(),this._treeDebugger=p(this._treeDebugger),this._renderer.destroyed||(this.view.stage.removeRenderPlugin(this._renderer),this._renderer.destroy()),this._renderer=null,this._iteratorPool=p(this._iteratorPool),this._upsampleMapCache=p(this._upsampleMapCache),this._elevationQueryCache=p(this._elevationQueryCache),this._set(`view`,null),this._extentHelper=p(this._extentHelper),this._upsampleInfoPool=p(this._upsampleInfoPool),dt(),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;return e==null?null:Iterator.from(this.view.allLayerViews).map(t=>{let{layer:n}=t;if(!Te(n)||!we.shouldStencilTerrain(n))return null;let{fullExtent:r}=n,i=r==null||r.spatialReference.equals(e)?r:pe(r,r.spatialReference,e);return i?he(i):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=Fe(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 isGlobal(){return this.view.state.isGlobal}get ready(){return!this.enabled||this._rootTiles!=null}get rootTiles(){return this._rootTiles}get spatialReference(){return this.tilingScheme?.spatialReference??me.WebMercator}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 tilingScheme(){return this.tilingSchemeLogic?.tilingScheme}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)}intersectBudgeted(e,t,n,r,i){return this._renderer.intersectRayBudgeted(e,t,n,r,i)}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=ue(r,this.spatialReference)??null,this._elevationProjectorCache.set(r,a)),a==null)return f.getLogger(this).error(`TerrainSurface.getElevation(): could not project given point to tiling scheme coordinate system`),null;let o=l(q,e,t,n);return a(o,0,o,0),Ct(i,this._xNormalizer?.normalize(o[0])??o[0],o[1])}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=Ct(r,e[t],e[t+1]);n(i,a)}}getLayerIndexByUID(e,t){return this._layerIndexByUid[e].get(t)}get visibleElevationRange(){let e=1/0,t=-1/0;for(let n of this._allTiles)n.renderData&&(e=Math.min(e,n.elevationBoundsMin),t=Math.max(t,n.elevationBoundsMax));let n=this._get(`visibleElevationRange`);return n?.minElevation===e&&n.maxElevation===t?n:new D(e,t)}invalidateElevationRange(){this.notifyChange(`visibleElevationRange`)}tileElevationRangeChanged(e,t=1/0,n=-1/0){let r=this._get(`visibleElevationRange`);(!r||t===r.minElevation||n===r.maxElevation||e.renderData&&(e.elevationBoundsMin<r.minElevation||e.elevationBoundsMax>r.maxElevation))&&this.invalidateElevationRange()}getScale(e){if(!this.tilingScheme)return null;if(!de(e,q,this.spatialReference))return f.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(q)){let t=e;for(;t.children[0]&&!t.rendered;){let e=t.children[0].extent,n=0;q[0]>e[2]&&(n+=1),q[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.spatialReference;if(n==null||r==null||n.length===0)return null;let i=w(r);if(i){let n=w(t)&&O(t),i=x(t);if(n&&O(r)&&i===x(r))Ie(e,J,i.radius);else if(!Le(e,t,J,r))return f.getLogger(this).error(`TerrainSurface.getSphereElevationRange(): could not project the query sphere`),null}else if(!le(e,t,bt,r))return f.getLogger(this).error(`TerrainSurface.getSphereElevationRange(): could not project the query sphere`),null;let a=new D,o=[];for(let e of n)o.push(e);let s=0;for(;s<o.length;){let e=o[s];if(++s,!(i?Re(e.extent,J,r):_e(e.extent,bt)))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?new D(this._rootTileElevationRange.minElevation,this._rootTileElevationRange.maxElevation):null}getLowerBoundRadius(){let e=this.visibleElevationRange,t=(this._ellipsoid.radius+(e.isEmpty?0:e.minElevation))*ce;return Math.min(t,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?_t(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(e){j(!!e,`tiling scheme cannot be reset to undefined`),e&&this._removeAllTiles(),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(G._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=xt,r=t.rootTilesInExtent(e,n,k*5);if(this._rootTiles!=null){if(r.length>k){f.getLogger(this).warn($e);return}let e=this._rootTiles.map(e=>e.lij),t=a(e,r,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,r.length>k&&(f.getLogger(this).warn(et),r=t.rootTilesInExtent(e,n,k)),this._setRootTiles(r.map(e=>this._newRootTile(e)));C(n,this._rootTilesExtent)||(this._rootTilesExtent=S(n)),this.renderer.visible=!0,this.overlayManager.setPlacementDirty(),this.notifyChange(`ready`),this._updateAllTileGeometries(),this._updatingRootTiles=!1,this._viewChangeUpdate(),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.invalidateElevationRange(),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._updatingRootTiles?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=this.groundExtent,n=this.view.state.contentCamera.viewProjectionMatrix;this.setTileTreeDirty(!1);let r=this._iteratorPool.acquire();for(r.reset(e);!r.done;){let e=r.next();e.updateClippingStatus(t)&&e.resetPendingUpdate(8)&&this._updateTileGeometryState(e),e.computeVisibility(),e.updateScreenDepth(n)}r.remove(),this._viewChanged=!0,this._allTilesDirty=!0,this._updatePendingTileGeometries()}_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 He(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,u(this._eyePosRenderSR,t.eye),fe(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.hasPendingUpdate(32)?32:e.hasPendingUpdate(16)?16:!1;if(n){let r=this._renderer.updateTileTexture(e,n);return this._usedMemory=null,r&&e.resetPendingUpdate(n),t.madeProgress(),r}return!0}_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 Pe(t,this.spatialReference)){let t=new Ne(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);let n=this._updateTextures(e);t||this._mergeAndSplit(e,!0),this._inFrameTask=!1,this._runViewChangeUpdateIfDirty();let r=this._pendingTilesToUpdate.size>0,i=r&&this._hasPendingGeometryWithoutIndices();if((!e.done||i)&&this._updatePendingTileGeometries(),this._emitElevationUpdateEventForTiles(),e.done&&(e.hasProgressed||r&&!i)&&this.requestUpdate(),this.notifyChange(`updatingProgressValue`),!n||!e.hasProgressed)return Me}_checkTileInvariant(){}_updateAllTilesStatus(e){if(!this._viewChanged||!this._rootTiles||e.done)return;this._viewChanged=!1;let t=!1,n=new Ye(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?X(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&&(ht(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=lt[e];n(r,s.cornerPeerNeighbors[e]?.findCorner(at(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(it(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&&ot&&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){if(e.done)return!0;let t=!0;return this._allTiles.some(n=>(this._updateTileTexture(n,e)||(t=!1),e.done)),t}_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)*tt}_getLodBiasCorrectedScale(e){let t=this.tilingScheme.levels,n=te(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.renderer.visible=!1,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})}_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?Z(e):this._purgeSubtree(e),this._allTiles.removeUnordered(e),this._unloadTile(e),e.dispose(),this._tileCache.put(G._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`),Z(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=>X(e,e.hasPendingUpdate(1))),++this._performanceInfo.numSplit}_emitTileScaleChange(e,t=e.level){Y.spatialReference=this.spatialReference,Y.extent=e.extent,Y.scale=this._getLodBiasCorrectedScale(t),this.emit(`scale-change`,Y)}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(),X(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=Ae){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)&&!Ee(e.layer)&&e.fullOpacity!==0)return!1;return!0}_hasCompositeBlendMode(){for(let e of this.view.allLayerViews.items)if((R(e)||I(e))&&Be(Ve[e.layer.blendMode]))return!0;return!1}_layerClassFromLayerView(e){return+!z(e)}_registerTiledLayerView(e){let t=[];if((R(e)||I(e))&&t.push(_(()=>e.layer.blendMode,()=>{this.hasCompositeBlendMode=this._hasCompositeBlendMode(),this._updateTileTextures(2)})),!I(e)){let n=this._layerClassFromLayerView(e);t.push(_(()=>!e.destroyed&&e.suspended,()=>this._updateTiledLayers())),t.push(_(()=>!e.destroyed&&e.fullOpacity,()=>this._updateTileTextures(2)));let{layer:r}=e;`effectiveScaleRange`in r&&t.push(_(()=>!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 Ke){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 ae(r),h(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=>{!g(n)&&r&&(this.setMemoryDirty(),this.requestUpdate(),this._elevationDataArrived(e,t,r))},i=n=>{h(n)||(f.getLogger(this).error(`Tile ${e.lij.toString()} layer 0/${t.uid} error ${n}`),this._dataMissing(e,0,t),this.requestUpdate())};return t.fetchElevationTile(e,{...De,...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){f.getLogger(this).warn(`TerrainSurface: received data from unknown layer %d %s`,0,e.lij.toString());return}let i=new Ue(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,s=this._iteratorPool.acquire();for(s.reset(a);!s.done;){let e=s.next();e.findElevationBoundsForLayer(r,o),e.computeElevationBounds()}o===0&&this._updateRootTileElevationRange(),s.remove(),this._updateTilesVisibility(a)}_requestMapTileData(e,t,n){++this._asyncWorkItems;let r=(r,i)=>{B(i),g(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(),g(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),f.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?f.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 isGeographic(){return this.spatialReference?.isGeographic??!1}get isWebMercator(){return this.spatialReference?.isWebMercator??!1}get isWebMercatorOnPlateCarree(){return this.isWebMercator&&xe(this.view?.renderSpatialReference)}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){st(e)}enableWaterproofnessChecks(e){ct(e)}static cleanupTerrainSurface(){St.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([n()],K.prototype,`_renderer`,void 0),e([n({constructOnly:!0})],K.prototype,`_scaleRangeQueries`,void 0),e([n({constructOnly:!0})],K.prototype,`view`,void 0),e([n({constructOnly:!0})],K.prototype,`overlayManager`,void 0),e([n()],K.prototype,`_hasPendingUpdates`,void 0),e([n()],K.prototype,`_asyncWorkItems`,void 0),e([n()],K.prototype,`_allTilesDirty`,void 0),e([n()],K.prototype,`_allTilesSorted`,void 0),e([n()],K.prototype,`allTilesCreated`,null),e([n()],K.prototype,`_allTilesCreated`,void 0),e([n()],K.prototype,`_viewChanged`,void 0),e([n({type:Number})],K.prototype,`heading`,void 0),e([n()],K.prototype,`_splitLimits`,void 0),e([n()],K.prototype,`_frameTask`,void 0),e([n()],K.prototype,`_tileConstructor`,null),e([n()],K.prototype,`_ellipsoid`,null),e([n()],K.prototype,`demResolution`,null),e([n({readOnly:!0})],K.prototype,`snapLevel`,null),e([n({readOnly:!0})],K.prototype,`lodSnappingEnabled`,null),e([n()],K.prototype,`_stencilEnabledExtents`,null),e([n({readOnly:!0})],K.prototype,`userClippingExtent`,null),e([n()],K.prototype,`_rootTilesExtent`,void 0),e([n({readOnly:!0})],K.prototype,`groundExtent`,null),e([n({readOnly:!0})],K.prototype,`fullGroundExtent`,null),e([n({readOnly:!0})],K.prototype,`_tilingSchemeExtent`,null),e([n({readOnly:!0})],K.prototype,`updating`,null),e([n({readOnly:!0})],K.prototype,`readyToRun`,null),e([n(ze)],K.prototype,`updatingProgress`,void 0),e([n({readOnly:!0})],K.prototype,`updatingProgressValue`,null),e([n()],K.prototype,`_maxNumUpdating`,void 0),e([n()],K.prototype,`baseOpacity`,null),e([n()],K.prototype,`hasCompositeBlendMode`,void 0),e([n({readOnly:!0})],K.prototype,`viewingMode`,null),e([n()],K.prototype,`maxTextureScale`,void 0),e([n({readOnly:!0})],K.prototype,`ready`,null),e([n({readOnly:!0})],K.prototype,`rootTiles`,null),e([n()],K.prototype,`_rootTiles`,void 0),e([n()],K.prototype,`spatialReference`,null),e([n({type:t})],K.prototype,`backgroundColor`,null),e([n({value:!1})],K.prototype,`slicePlaneEnabled`,null),e([n()],K.prototype,`tilingScheme`,null),e([n({readOnly:!0})],K.prototype,`tilingSchemeLocked`,null),e([n({readOnly:!0})],K.prototype,`tilingSchemeLogic`,void 0),e([n()],K.prototype,`wireframe`,null),e([n()],K.prototype,`opaque`,null),e([n()],K.prototype,`invisible`,null),e([n({value:!1})],K.prototype,`freeze`,null),e([n()],K.prototype,`fadeDuration`,null),e([n()],K.prototype,`_xNormalizer`,null),e([n()],K.prototype,`visibleElevationRange`,null),e([n()],K.prototype,`_rootTileElevationRange`,void 0),e([n()],K.prototype,`_layerViewsDirty`,void 0),e([n()],K.prototype,`renderPatchBorders`,null),e([n()],K.prototype,`renderingDisabled`,null),e([n()],K.prototype,`isGeographic`,null),e([n()],K.prototype,`isWebMercator`,null),e([n()],K.prototype,`isWebMercatorOnPlateCarree`,null),e([n({readOnly:!0})],K.prototype,`enabled`,void 0),K=G=e([r(`esri.views.3d.terrain.TerrainSurface`)],K);const yt=K,q=d(),bt=new Se,J=S(),xt=S(),St=new ie,Y={spatialReference:null,extent:null,scale:0};function Ct(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 We(t,n,i)}return null}function X(e,t){!e.leaf||e.level<A||$(e,e=>{t&&wt(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 wt(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=>{wt(e)})}function Z(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{yt as default};
2
+ import{__decorate as e}from"tslib";import t from"../../../Color.js";import{property as n,subclass as r}from"../../../core/accessorSupport/decorators.js";import{filterInPlace as i,difference as a}from"../../../core/arrayUtils.js";import o from"../../../core/CollectionFlattener.js";import{toConst as s}from"../../../core/compilerUtils.js";import{EventedAccessor as c}from"../../../core/Evented.js";import"../../../core/has.js";import{set as l,copy as u,exactEquals as ee}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{create as d}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import f from"../../../core/Logger.js";import{clamp as te}from"../../../core/mathUtils.js";import{destroyMaybe as p,removeMaybe as ne}from"../../../core/maybe.js";import{MemCachePool as re}from"../../../core/MemCachePool.js";import m from"../../../core/ObjectPool.js";import ie from"../../../core/PooledArray.js";import{throwIfAborted as ae,isAbortError as h,isAborted as g}from"../../../core/promiseUtils.js";import{watch as _,syncAndInitial as v,initial as y,sync as b}from"../../../core/reactiveUtils.js";import"../../../core/scheduling.js";import{UpdatingHandles as oe}from"../../../core/support/UpdatingHandles.js";import{getMetersPerUnitForSR as se}from"../../../core/units.js";import{getReferenceEllipsoid as x,radiusModifier as ce}from"../../../geometry/ellipsoidUtils.js";import{projectBoundingSphere as le}from"../../../geometry/projection/projectBoundingSphere.js";import{getProjector as ue}from"../../../geometry/projection/projectors.js";import{projectPointToVector as de}from"../../../geometry/projection/projectPointToVector.js";import{projectVectorToVector as fe}from"../../../geometry/projection/projectVectorToVector.js";import{projectWithoutEngine as pe}from"../../../geometry/projectionUtils.js";import me from"../../../geometry/SpatialReference.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{IntegratedMeshSemantics as we}from"../../../layers/support/IntegratedMeshSemantics.js";import{isIntegratedMeshLayer as Te,isBaseLayer as Ee}from"../../../layers/support/layerUtils.js";import{queueHighPriority as De}from"../../../request/queue.js";import{hasLayerBasedScaleVisibility as Oe}from"../../support/layerViewUtils.js";import{ImmediateTask as T,TaskPriority as ke,noBudget as Ae}from"../../support/Scheduler.js";import{TextureCompressionTracker as je}from"../../support/TextureCompressionTracker.js";import{Yield as Me}from"../../support/Yield.js";import{debugFlags as E}from"../support/debugFlags.js";import{ElevationRange as D}from"../support/ElevationRange.js";import{ElevationUpdateEvent as Ne}from"../support/ElevationUpdateEvent.js";import{calculateElevationUpdateExtents as Pe}from"../support/elevationUpdateExtentUtils.js";import{toBoundingRect as Fe}from"../support/extentUtils.js";import{geographicMbsToGeographicExtent as Ie,mbsToGeographicExtent as Le,intersectsGeographicExtent as Re}from"../support/sphereExtentUtils.js";import{isSupportedGCSOnGlobe as O}from"../support/supportedSpatialReference.js";import{updatingProgress as ze}from"../support/updatingProperties.js";import{isCompositeBlendMode as Be,blendModeFromString as Ve}from"../webgl-engine/core/shaderLibrary/output/BlendOptions.js";import{ElevationBounds as He}from"./ElevationBounds.js";import{ElevationData as Ue,sampleElevation as We}from"./ElevationData.js";import{create as Ge}from"./ExtentHelper.js";import{LayerClasses as Ke}from"./LayerClass.js";import{OverlayManager as qe}from"./OverlayManager.js";import{PlanarPatch as Je}from"./PlanarPatch.js";import{Queue as Ye}from"./Queue.js";import{ScaleRangeQueries as Xe}from"./ScaleRangeQueries.js";import{SphericalPatch as Ze}from"./SphericalPatch.js";import{SplitLimits as Qe}from"./SplitLimits.js";import{maxRootTiles as k,tooManyRootTilesAfterChangeError as $e,tooManyRootTilesForLayerError as et,maxTileNeighborLevelDelta as A,maxMemoryLodBias as tt}from"./TerrainConst.js";import{TerrainRenderer as nt}from"./TerrainRenderer.js";import rt from"./TerrainSurfacePerformanceInfo.js";import{weakAssert as j,isVectorTileLayerView as M,internalAssert as N,oppositeEdge as it,neighborEdgeIndices as P,isSurfaceLayerView as F,isGroupLayerView as I,isMapTileLayerView as L,isBlendableLayerView as R,isElevationLayerView as z,releaseTerrainData as B,oppositeCorner as at,enableTerrainInternalChecks as V,enableWaterproofTests as ot,enableInternalTerrainChecks as st,enableTerrainWaterproofChecks as ct,neighborCornerIndices as lt}from"./terrainUtils.js";import{Tile as ut,lijEquals as H}from"./Tile.js";import{printAllocations as dt}from"./TilePerLayerInfo.js";import{sortTiles as ft,IteratorPreorder as pt,IteratorPostorder as mt,compareTilesByLij as U,sortTilesByPOI as ht,traverseTilesPreorder as W}from"./tileUtils.js";import{TilingSchemeLogic as gt}from"./TilingSchemeLogic.js";import{getGroundTransparencyModeFromOpacity as _t}from"./TransparencyMode.js";import{UpsampleInfo as vt}from"./UpsampleInfo.js";var G;let K=class extends c{static{G=this}get allTilesCreated(){return this._allTilesCreated}get allTiles(){return s(this._allTiles)}get renderedTiles(){return ft(i(this._allTiles.toArray(),e=>e.visible&&e.rendered))}get _tileConstructor(){return this.view.state.isGlobal?Ze:Je}get _ellipsoid(){return x(this.view.spatialReference)}get demResolution(){let{_allTiles:e,tilingScheme:t}=this;if(e.length===0)return{min:1,max:1};let n=se(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 je,this._iteratorPool=new m(()=>new pt,e=>e.remove=()=>this._iteratorPool.release(e)),this._postorderIterator=new mt,this._hasPendingUpdates=!1,this._pendingUpdates=0,this._asyncWorkItems=0,this._allTilesDirty=!0,this._allTilesSorted=!0,this._allTilesCreated=!1,this._usedMemory=null,this._performanceInfo=new rt,this._waterproofnessErrorHandle=null,this._viewChanged=!1,this.heading=0,this._inFrameTask=!1,this._viewChangeUpdateDirty=!1,this._eyePosRenderSR=d(),this._eyePosSurfaceSR=d(),this._splitLimits=new Qe,this._layerViews=[[],[]],this._layerIndexByUid=[new Map,new Map],this._basemapLayerViewHandles=new Map,this._updatingHandles=new oe,this._poiWatchHandle=null,this._frameTask=T,this._allTiles=new ie,this._upsampleInfoPool=new m(()=>new vt),this._shouldEmitChangeEvent=!1,this._rootTilesExtent=S(),this.updatingProgress=.5,this._maxNumUpdating=1,this.hasCompositeBlendMode=!1,this.maxTextureScale=1.2,this._elevationProjectorCache=new Map,this._rootTileElevationRange=new D(1/0,-1/0),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.enabled=!0,this.overlayManager=new qe({...e,terrainSurface:this}),this._renderer=new nt(this,this.overlayManager.renderer,this._allTiles,this.terrainTextureCompressionTracker,e.view),Oe()||(this._scaleRangeQueries=new Xe)}initialize(){let{view:e}=this,{resourceController:t}=e,{memoryController:n}=t;e.stage.addRenderPlugin(this._renderer),this._tileCache=new re((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([_(()=>r.renderer.isEmpty,()=>this._evaluateTransparency()),_(()=>this.renderer.visible,e=>this.freeze=!e),_(()=>this.heading,e=>{this._renderer.updateHeading(e),this._updateTileTextures(0)},v)],`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)},y),this.addHandles([_(()=>this.baseOpacity,()=>{this._handleLayerViewChanges(),this._updateTileTextures(this._evaluateTransparency()?1:2)},v),_(()=>this.hasCompositeBlendMode,()=>this._updateTileTextures(this._evaluateTransparency()?1:2),v),_(()=>this.backgroundColor,(e,t)=>{e?.equals(t)||(this._handleLayerViewChanges(),this._renderer.updateTileBackground(e))},b),_(()=>this.snapLevel,()=>this._viewChanged=!0,b),_(()=>this.view.pointsOfInterest,e=>{this._renderer.pointsOfInterest=e,this._poiWatchHandle=ne(this._poiWatchHandle),e&&(this._poiWatchHandle=this._updatingHandles.add(()=>e.focus?.renderLocation,()=>this._allTilesSorted=!1,{equals:ee}))}),_(()=>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=p(this._treeDebugger))},y),_(()=>this.tilingScheme,e=>this._updateTilingScheme(e),b)]);let{spatialReference:i}=e;this._extentHelper=Ge(this.isGlobal,{layers:e.map.allLayers,layerViews:e.allLayerViews,viewSpatialReference:i});let a=new o({getCollections:()=>e.defaultsFromMap?.mapCollections?.map(({layers:e})=>e),getChildrenFunction:e=>e&&`layers`in e?e.layers:null}),s=new gt({layers:a,extentHelper:this._extentHelper,isGlobal:this.isGlobal,viewSpatialReference:i});this._set(`tilingSchemeLogic`,s);let c=t.scheduler;this._frameTask=c.registerTask(ke.TERRAIN_SURFACE,this),this.addHandles([_(()=>this._stencilEnabledExtents,e=>this._renderer.setStencilEnabledLayerExtents(e),y),_(()=>this.groundExtent,()=>this._updateRootTiles(),y),e.on(`resize`,()=>this._viewChangeUpdate()),_(()=>{let t=e.state;return[this._lodBias,this.lodSnappingEnabled,e.quality,t.camera,t.contentCamera,t.fixedContentCamera]},()=>this._viewChangeUpdate(),v),_(()=>e.qualitySettings?.fadeDuration,e=>this._renderer.textureFadingEnabled=e>0,y),_(()=>e.qualitySettings?.physicallyBasedRenderingEnabled,e=>this._renderer.pbrMode=e?5:0,y),_(()=>e.qualitySettings?.tiledSurface.elevationLevelDelta,()=>{this._allTiles.forAll(e=>this.updateElevationSources(e)),this._updateAllTileGeometries()}),e.allLayerViews.on(`after-changes`,()=>this._layerViewsDirty=!0)]),this._updatingHandles.add(()=>this.userClippingExtent,()=>this._updateClippingExtent()),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=T,this._updatingHandles?.destroy(),this._removeAllTiles(),this._set(`tilingSchemeLogic`,p(this.tilingSchemeLogic)),this._basemapLayerViewHandles.forEach((e,t)=>this._unregisterTiledLayerView(t)),this._basemapLayerViewHandles.clear(),this._set(`overlayManager`,p(this.overlayManager)),this._tileCache=p(this._tileCache),this._allTiles.prune(),ut.prune(),this._treeDebugger=p(this._treeDebugger),this._renderer.destroyed||(this.view.stage.removeRenderPlugin(this._renderer),this._renderer.destroy()),this._renderer=null,this._iteratorPool=p(this._iteratorPool),this._upsampleMapCache=p(this._upsampleMapCache),this._elevationQueryCache=p(this._elevationQueryCache),this._set(`view`,null),this._extentHelper=p(this._extentHelper),this._upsampleInfoPool=p(this._upsampleInfoPool),dt(),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;return e==null?null:Iterator.from(this.view.allLayerViews).map(t=>{let{layer:n}=t;if(!Te(n)||!we.shouldStencilTerrain(n))return null;let{fullExtent:r}=n,i=r==null||r.spatialReference.equals(e)?r:pe(r,r.spatialReference,e);return i?he(i):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=Fe(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 isGlobal(){return this.view.state.isGlobal}get ready(){return!this.enabled||this._rootTiles!=null}get rootTiles(){return this._rootTiles}get spatialReference(){return this.tilingScheme?.spatialReference??me.WebMercator}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 tilingScheme(){return this.tilingSchemeLogic?.tilingScheme}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)}intersectBudgeted(e,t,n,r,i){return this._renderer.intersectRayBudgeted(e,t,n,r,i)}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=ue(r,this.spatialReference)??null,this._elevationProjectorCache.set(r,a)),a==null)return f.getLogger(this).error(`TerrainSurface.getElevation(): could not project given point to tiling scheme coordinate system`),null;let o=l(q,e,t,n);return a(o,0,o,0),Ct(i,this._xNormalizer?.normalize(o[0])??o[0],o[1])}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=Ct(r,e[t],e[t+1]);n(i,a)}}getLayerIndexByUID(e,t){return this._layerIndexByUid[e].get(t)}get visibleElevationRange(){let e=1/0,t=-1/0;for(let n of this._allTiles)n.renderData&&(e=Math.min(e,n.elevationBoundsMin),t=Math.max(t,n.elevationBoundsMax));let n=this._get(`visibleElevationRange`);return n?.minElevation===e&&n.maxElevation===t?n:new D(e,t)}invalidateElevationRange(){this.notifyChange(`visibleElevationRange`)}tileElevationRangeChanged(e,t=1/0,n=-1/0){let r=this._get(`visibleElevationRange`);(!r||t===r.minElevation||n===r.maxElevation||e.renderData&&(e.elevationBoundsMin<r.minElevation||e.elevationBoundsMax>r.maxElevation))&&this.invalidateElevationRange()}getScale(e){if(!this.tilingScheme)return null;if(!de(e,q,this.spatialReference))return f.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(q)){let t=e;for(;t.children[0]&&!t.rendered;){let e=t.children[0].extent,n=0;q[0]>e[2]&&(n+=1),q[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.spatialReference;if(n==null||r==null||n.length===0)return null;let i=w(r);if(i){let n=w(t)&&O(t),i=x(t);if(n&&O(r)&&i===x(r))Ie(e,J,i.radius);else if(!Le(e,t,J,r))return f.getLogger(this).error(`TerrainSurface.getSphereElevationRange(): could not project the query sphere`),null}else if(!le(e,t,bt,r))return f.getLogger(this).error(`TerrainSurface.getSphereElevationRange(): could not project the query sphere`),null;let a=new D,o=[];for(let e of n)o.push(e);let s=0;for(;s<o.length;){let e=o[s];if(++s,!(i?Re(e.extent,J,r):_e(e.extent,bt)))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?new D(this._rootTileElevationRange.minElevation,this._rootTileElevationRange.maxElevation):null}getLowerBoundRadius(){let e=this.visibleElevationRange,t=(this._ellipsoid.radius+(e.isEmpty?0:e.minElevation))*ce;return Math.min(t,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?_t(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(e){j(!!e,`tiling scheme cannot be reset to undefined`),e&&this._removeAllTiles(),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(G._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=xt,r=t.rootTilesInExtent(e,n,k*5);if(this._rootTiles!=null){if(r.length>k){f.getLogger(this).warn($e);return}let e=this._rootTiles.map(e=>e.lij),t=a(e,r,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,r.length>k&&(f.getLogger(this).warn(et),r=t.rootTilesInExtent(e,n,k)),this._setRootTiles(r.map(e=>this._newRootTile(e)));C(n,this._rootTilesExtent)||(this._rootTilesExtent=S(n)),this.renderer.visible=!0,this.overlayManager.setPlacementDirty(),this.notifyChange(`ready`),this._updateAllTileGeometries(),this._updatingRootTiles=!1,this._viewChangeUpdate(),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.invalidateElevationRange(),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._updatingRootTiles?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=this.groundExtent,n=this.view.state.contentCamera.viewProjectionMatrix;this.setTileTreeDirty(!1);let r=this._iteratorPool.acquire();for(r.reset(e);!r.done;){let e=r.next();e.updateClippingStatus(t)&&e.resetPendingUpdate(8)&&this._updateTileGeometryState(e),e.computeVisibility(),e.updateScreenDepth(n)}r.remove(),this._viewChanged=!0,this._allTilesDirty=!0,this._updatePendingTileGeometries()}_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 He(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,u(this._eyePosRenderSR,t.eye),fe(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.hasPendingUpdate(32)?32:e.hasPendingUpdate(16)?16:!1;if(n){let r=this._renderer.updateTileTexture(e,n);return this._usedMemory=null,r&&e.resetPendingUpdate(n),t.madeProgress(),r}return!0}_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 Pe(t,this.spatialReference)){let t=new Ne(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);let n=this._updateTextures(e);t||this._mergeAndSplit(e,!0),this._inFrameTask=!1,this._runViewChangeUpdateIfDirty();let r=this._pendingTilesToUpdate.size>0,i=r&&this._hasPendingGeometryWithoutIndices();if((!e.done||i)&&this._updatePendingTileGeometries(),this._emitElevationUpdateEventForTiles(),e.done&&(e.hasProgressed||r&&!i)&&this.requestUpdate(),this.notifyChange(`updatingProgressValue`),!n||!e.hasProgressed)return Me}_checkTileInvariant(){}_updateAllTilesStatus(e){if(!this._viewChanged||!this._rootTiles||e.done)return;this._viewChanged=!1;let t=!1,n=new Ye(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?X(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&&(ht(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=lt[e];n(r,s.cornerPeerNeighbors[e]?.findCorner(at(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(it(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&&ot&&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){if(e.done)return!0;let t=!0;return this._allTiles.some(n=>(this._updateTileTexture(n,e)||(t=!1),e.done)),t}_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)*tt}_getLodBiasCorrectedScale(e){let t=this.tilingScheme.levels,n=te(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.renderer.visible=!1,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})}_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?Z(e):this._purgeSubtree(e),this._allTiles.removeUnordered(e),this._unloadTile(e),e.dispose(),this._tileCache.put(G._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`),Z(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=>X(e,e.hasPendingUpdate(1))),++this._performanceInfo.numSplit}_emitTileScaleChange(e,t=e.level){Y.spatialReference=this.spatialReference,Y.extent=e.extent,Y.scale=this._getLodBiasCorrectedScale(t),this.emit(`scale-change`,Y)}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(),X(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=Ae){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)&&!Ee(e.layer)&&e.fullOpacity!==0)return!1;return!0}_hasCompositeBlendMode(){for(let e of this.view.allLayerViews.items)if((R(e)||I(e))&&Be(Ve[e.layer.blendMode]))return!0;return!1}_layerClassFromLayerView(e){return+!z(e)}_registerTiledLayerView(e){let t=[];if((R(e)||I(e))&&t.push(_(()=>e.layer.blendMode,()=>{this.hasCompositeBlendMode=this._hasCompositeBlendMode(),this._updateTileTextures(2)})),!I(e)){let n=this._layerClassFromLayerView(e);t.push(_(()=>!e.destroyed&&e.suspended,()=>this._updateTiledLayers())),t.push(_(()=>!e.destroyed&&e.fullOpacity,()=>this._updateTileTextures(2)));let{layer:r}=e;`effectiveScaleRange`in r&&t.push(_(()=>!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 Ke){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 ae(r),h(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=>{!g(n)&&r&&(this.setMemoryDirty(),this.requestUpdate(),this._elevationDataArrived(e,t,r))},i=n=>{h(n)||(f.getLogger(this).error(`Tile ${e.lij.toString()} layer 0/${t.uid} error ${n}`),this._dataMissing(e,0,t),this.requestUpdate())};return t.fetchElevationTile(e,{...De,...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){f.getLogger(this).warn(`TerrainSurface: received data from unknown layer %d %s`,0,e.lij.toString());return}let i=new Ue(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,s=this._iteratorPool.acquire();for(s.reset(a);!s.done;){let e=s.next();e.findElevationBoundsForLayer(r,o),e.computeElevationBounds()}o===0&&this._updateRootTileElevationRange(),s.remove(),this._updateTilesVisibility(a)}_requestMapTileData(e,t,n){++this._asyncWorkItems;let r=(r,i)=>{B(i),g(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(),g(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),f.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?f.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 isGeographic(){return this.spatialReference?.isGeographic??!1}get isWebMercator(){return this.spatialReference?.isWebMercator??!1}get isWebMercatorOnPlateCarree(){return this.isWebMercator&&xe(this.view?.renderSpatialReference)}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){st(e)}enableWaterproofnessChecks(e){ct(e)}static cleanupTerrainSurface(){St.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([n()],K.prototype,`_renderer`,void 0),e([n({constructOnly:!0})],K.prototype,`_scaleRangeQueries`,void 0),e([n({constructOnly:!0})],K.prototype,`view`,void 0),e([n({constructOnly:!0})],K.prototype,`overlayManager`,void 0),e([n()],K.prototype,`_hasPendingUpdates`,void 0),e([n()],K.prototype,`_asyncWorkItems`,void 0),e([n()],K.prototype,`_allTilesDirty`,void 0),e([n()],K.prototype,`_allTilesSorted`,void 0),e([n()],K.prototype,`allTilesCreated`,null),e([n()],K.prototype,`_allTilesCreated`,void 0),e([n()],K.prototype,`_viewChanged`,void 0),e([n({type:Number})],K.prototype,`heading`,void 0),e([n()],K.prototype,`_splitLimits`,void 0),e([n()],K.prototype,`_frameTask`,void 0),e([n()],K.prototype,`_tileConstructor`,null),e([n()],K.prototype,`_ellipsoid`,null),e([n()],K.prototype,`demResolution`,null),e([n({readOnly:!0})],K.prototype,`snapLevel`,null),e([n({readOnly:!0})],K.prototype,`lodSnappingEnabled`,null),e([n()],K.prototype,`_stencilEnabledExtents`,null),e([n({readOnly:!0})],K.prototype,`userClippingExtent`,null),e([n()],K.prototype,`_rootTilesExtent`,void 0),e([n({readOnly:!0})],K.prototype,`groundExtent`,null),e([n({readOnly:!0})],K.prototype,`fullGroundExtent`,null),e([n({readOnly:!0})],K.prototype,`_tilingSchemeExtent`,null),e([n({readOnly:!0})],K.prototype,`updating`,null),e([n({readOnly:!0})],K.prototype,`readyToRun`,null),e([n(ze)],K.prototype,`updatingProgress`,void 0),e([n({readOnly:!0})],K.prototype,`updatingProgressValue`,null),e([n()],K.prototype,`_maxNumUpdating`,void 0),e([n()],K.prototype,`baseOpacity`,null),e([n()],K.prototype,`hasCompositeBlendMode`,void 0),e([n()],K.prototype,`maxTextureScale`,void 0),e([n({readOnly:!0})],K.prototype,`ready`,null),e([n({readOnly:!0})],K.prototype,`rootTiles`,null),e([n()],K.prototype,`_rootTiles`,void 0),e([n()],K.prototype,`spatialReference`,null),e([n({type:t})],K.prototype,`backgroundColor`,null),e([n({value:!1})],K.prototype,`slicePlaneEnabled`,null),e([n()],K.prototype,`tilingScheme`,null),e([n({readOnly:!0})],K.prototype,`tilingSchemeLocked`,null),e([n({readOnly:!0})],K.prototype,`tilingSchemeLogic`,void 0),e([n()],K.prototype,`wireframe`,null),e([n()],K.prototype,`opaque`,null),e([n()],K.prototype,`invisible`,null),e([n({value:!1})],K.prototype,`freeze`,null),e([n()],K.prototype,`fadeDuration`,null),e([n()],K.prototype,`_xNormalizer`,null),e([n()],K.prototype,`visibleElevationRange`,null),e([n()],K.prototype,`_rootTileElevationRange`,void 0),e([n()],K.prototype,`_layerViewsDirty`,void 0),e([n()],K.prototype,`renderPatchBorders`,null),e([n()],K.prototype,`renderingDisabled`,null),e([n()],K.prototype,`isGeographic`,null),e([n()],K.prototype,`isWebMercator`,null),e([n()],K.prototype,`isWebMercatorOnPlateCarree`,null),e([n({readOnly:!0})],K.prototype,`enabled`,void 0),K=G=e([r(`esri.views.3d.terrain.TerrainSurface`)],K);const yt=K,q=d(),bt=new Se,J=S(),xt=S(),St=new ie,Y={spatialReference:null,extent:null,scale:0};function Ct(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 We(t,n,i)}return null}function X(e,t){!e.leaf||e.level<A||$(e,e=>{t&&wt(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 wt(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=>{wt(e)})}function Z(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{yt as default};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import{toConst as e}from"../../../core/compilerUtils.js";import"../../../core/has.js";import{subtract as t,squaredLength as n,dot as r,scale as i,add as a,length as o,copy as s}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{create as c,unitZ as l}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{clamp as u}from"../../../core/mathUtils.js";import{abortMaybe as d}from"../../../core/maybe.js";import f from"../../../core/ObjectPool.js";import{getReferenceEllipsoid as p}from"../../../geometry/ellipsoidUtils.js";import{create as m,equals as h,rectangleContainsRectangleCyclicalAware as g,rectanglesIntersectCyclicalAware as _,width as v,height as y}from"../../../geometry/support/aaBoundingRect.js";import{Sphere as b}from"../../../geometry/support/sphere.js";import{isGroupLayer as x}from"../../../layers/support/layerUtils.js";import{isLayerViewWithFlowRenderer as S}from"../support/flowUtils.js";import{ElevationBounds as C}from"./ElevationBounds.js";import{ElevationTileAgent as w,isElevationTileAgent as T}from"./ElevationTileAgent.js";import{LayerClasses as E}from"./LayerClass.js";import{MapDataCacheItem as D}from"./MapDataCacheItem.js";import{MapTileAgent as ee,isMapTileAgent as te}from"./MapTileAgent.js";import{maxPatchTesselation as ne}from"./TerrainConst.js";import{isVectorTile as O,isTileTexture as re,isRasterTile as ie,isCreateBitmapResult as ae}from"./TerrainData.js";import{weakAssert as k,isBlendableLayerView as oe,oppositeCorner as A,internalAssert as j,enableTerrainInternalChecks as M,neighborEdgeIndices as N,oppositeEdge as P,neighborCornerIndices as F,almostEquals as I,isNorth as L,isSouth as R,isWest as z,isEast as B,isWestCorner as se,isNorthCorner as ce}from"./terrainUtils.js";import{tileAgentDone as V}from"./TileAgent.js";import{TilePerLayerInfo as H}from"./TilePerLayerInfo.js";import{fallsWithinLayerView as U}from"./tileUtils.js";const le={0:[0,1],1:[1],2:[1,3],3:[3],4:[2,3],5:[2],6:[0,2],7:[0]};class ue{constructor(){this._lij=[0,0,0],this._children=[null,null,null,null],this._pendingUpdates=0,this._dirty=!0,this._previouslyRendered=!1,this._lastElevationSourceUpdateRequestSignature=null,this.extent=m(),this._elevationBoundsMin=NaN,this._elevationBoundsMax=0,this.layerInfo=[[],[]],this.extentInRadians=m(),this.centerAtSeaLevel=c(),this._center=[c(),new b,c()],this.up=l(),this._withinClippingArea=!0,this._intersectsClippingArea=!0,this._maxTesselation=0,this._usedMemory=0,this._rasterTileMemory=0,this._vectorTileMemory=0,this._mapDataRefCount=0,this.screenDepth=0,this.renderOrder=0,this._edgeLen=0,this._edgeLen2=0,this._curvatureHeight=0,this.onCompressionFinished=()=>{this.setPendingUpdate(16),this.setMemoryDirty()},this.extentMidX=0,this.extentMidY=0,this.distanceToPOI=-1,this._lastPOI=c(),this.maxLevelDeltaNeighborCount=0,this.unmergableChildCount=0}get lij(){return this._lij}get spatialReference(){return this._surface.spatialReference??this._surface.tilingScheme.spatialReference}get isDisposed(){return this._surface==null}get elevationLevelDelta(){return this._surface.getElevationLevelDelta(this.level)}_setPendingUpdateForDescendants(){let e=this._children;if(e[0])for(let t of e)t.renderData&&(t.setPendingUpdate(16),t.setMemoryDirty()),t._setPendingUpdateForDescendants()}static prune(){G.prune(0),K.prune(0),H.prune()}get _cached(){return!this.leaf&&this._mapDataRefCount<=0}get withinClippingArea(){return this._withinClippingArea}get intersectsClippingArea(){return this._intersectsClippingArea}get clippingArea(){return this._clippingArea}get parent(){return this._parent}get children(){return this._children}get surface(){return this._surface}get elevationBoundsMin(){return this._elevationBoundsMin}get elevationBoundsMax(){return this._elevationBoundsMax}get level(){return this._lij[0]}get key(){return`${this._lij[0]}/${this._lij[1]}/${this._lij[2]}`}get edgeLen(){return this._edgeLen}get radius(){return this._center[1].radius}get visible(){return this._dirty&&this.computeVisibility(),this._visible}get frustumVisibility(){return this._dirty&&this.computeVisibility(),this._frustumVisibility}checkVisibility(e){if(this._dirty)return null;let t=this._calculateVisibility(e);if(this._frustumVisibility!==t||this._visible!==(t!==2&&this._intersectsClippingArea))throw Error(`Assertion failed: waterproof.visibility-cache-mismatch: Tile[${this.lij}]`);return t}computeVisibility(){this._dirty=!1;let e=this.parent?.frustumVisibility??1;this._frustumVisibility=this._calculateVisibility(e);let t=this._frustumVisibility!==2&&this._intersectsClippingArea;t!==this._visible&&(this._visible=t,this._surface.emit(`tiles-visibility-changed`),this._surface.renderer.setDirty(),this.updateAgentSuspension())}_calculateVisibility(e){let t=this.parent;return e===0?0:t!=null&&e===2&&this._elevationBoundsMin>=t._elevationBoundsMin&&this._elevationBoundsMax<=t._elevationBoundsMax?2:this._calculateFrustumVisibility(this.surface.frustum,this._surface.view.frustum.boundingSphere)}get _loadable(){return this.visible||this._surface.view.state.fixedContentCamera}get rendered(){let e=!!this.renderData;return e!==this._previouslyRendered&&(this._surface.emit(`tiles-visibility-changed`),this._previouslyRendered=e,this._surface.renderer.setDirty()),e}init(e,t,n,r,i){this._lij[0]=e,this._lij[1]=t,this._lij[2]=n,this.ellipsoid=p(i.tilingScheme.spatialReference),i.tilingScheme.getExtent(e,t,n,this.extent),i.tilingScheme.convertExtentToRadians(this.extent,this.extentInRadians),this.extentMidX=.5*(this.extent[0]+this.extent[2]),this.extentMidY=.5*(this.extent[1]+this.extent[3]),this._withinClippingArea=!0,this._intersectsClippingArea=!0,this._clippingArea=null,this._mapDataRefCount=0,i.upsampleMapCache.pop(this.key),this._edgeLen=0,this._edgeLen2=0,this._center[1].radius=0,this.elevationLevel=e,this._lastElevationSourceUpdateRequestSignature=null,r&&!Number.isNaN(r.elevationBoundsMin)?(this._elevationBoundsMin=r.elevationBoundsMin,this._elevationBoundsMax=r.elevationBoundsMax):(this._elevationBoundsMin=0,this._elevationBoundsMax=0),this._pendingUpdates=0,this.renderData=null,this.screenDepth=0,this._visible=!1,this._previouslyRendered=!1,this._parent=r,this.clearChildren(),this._surface=i,this.updateVisibility(),this.maxLevelDeltaNeighborCount=0,this.unmergableChildCount=0;for(let e of E){let t=i.numLayers(e),n=this.layerInfo[e];for(let e of n)e.release();n.length=t;for(let r=0;r<t;r++)n[r]=H.acquire(this._surface.upsampleInfoPool),e===0&&this.findElevationBoundsForLayer(r,-1)}this.computeElevationBounds(),this._maxTesselation=Math.min(i.tilingScheme.pixelSize,ne)}dispose(){k(!this.renderData,`tile.renderData was not unloaded`),this._surface?.upsampleMapCache.pop(this.key),this.layerInfo.forEach(e=>{e.forEach(e=>e.release()),e.length=0}),this._surface=this._parent=null,this.clearChildren(),this.setMemoryDirty()}refMapData(){++this._mapDataRefCount,this._cached||this._surface.upsampleMapCache.pop(this.key)}unrefMapData(){--this._mapDataRefCount,this._cached&&this.cachedMemory>0&&this._surface.upsampleMapCache.put(this.key,new D(e(this)))}setMemoryDirty(){this._usedMemory=0}get usedMemory(){return this._ensureUsedMemory()+(this._cached?0:this.mapDataMemory)}get cachedMemory(){return this._ensureUsedMemory(),this._surface==null?this.usedMemory:this._cached?this.mapDataMemory:0}get mapDataMemory(){return this._rasterTileMemory+this._vectorTileMemory}get _cpuImageMemorySize(){let e=this._surface.tilingScheme.pixelSize;return e*e*4}_ensureUsedMemory(){if(this._usedMemory>0)return this._vectorTileMemory=this.layerInfo[1].reduce((e,{data:t})=>e+(O(t)?t.usedMemoryPerReference:0),0),this._usedMemory;this._usedMemory=this._baseUsedMemory,this._rasterTileMemory=0,this._vectorTileMemory=0;for(let{data:e}of this.layerInfo[1])O(e)?this._vectorTileMemory+=e.usedMemoryPerReference:this._rasterTileMemory+=this.getTerrainDataMemory(e);for(let e of this.layerInfo[0])this._usedMemory+=e.data?this._cpuImageMemorySize:0;return this.renderData&&(this._usedMemory+=this.renderData.estimatedGeometryMemoryUsage,this._rasterTileMemory+=this.renderData.texture?.usedMemory??0),this._cached&&this._surface.upsampleMapCache.updateSize(this.key),this._usedMemory}getUsedMemoryForLayer(e,t){let n=this.layerInfo[e][t];return n?.data?e===1?this._cached?0:this.getTerrainDataMemory(n.data):e===0?this._cpuImageMemorySize:0:0}getTerrainDataMemory(e){return re(e)?e.texture.usedMemory:ie(e)?e.memoryUsage:O(e)?e.usedMemoryPerReference:ae(e)?this._cpuImageMemorySize:0}updateScreenDepth(e){let[t,n,r]=this._center[1].center,i=e,a=i[2]*t+i[6]*n+i[10]*r+i[14];this.screenDepth=a<0?0:a/(i[3]*t+i[7]*n+i[11]*r+i[15])}shouldSplit(e,s,c){if(!this.visible||e.frustum&&!(this._intersectsClippingArea&&this._calculateFrustumVisibility(e.frustum)!==2))return 0;let l=this.level;t(Q,this._center[1].center,s);let u=n(Q),d=this._closestCenterOnElevationRange(s,me),f=t(he,d,s),p=Math.min(u,n(f));if(this._edgeLen2>p&&l<e.maxLod)return 1;let m=Math.sqrt(p),h=e.fovX*m*2,g=this._edgeLen/h,_=()=>{if(l<e.maxLod)return this.elevationLevel=l,0;let t=l+Math.ceil(-Math.log2(e.relativeWidthLimit/g));return t===this.elevationLevel?0:(this.elevationLevel=t,2)},v=c==null?1/0:c-l;if(v<=.5)return _();let y=r(this.up,Q),b=this._elevationBoundsMax-this._elevationBoundsMin,x=b/this.edgeLen;if(e.aboveGround&&y>0&&x<.001&&y/m-Math.sin(this._curvatureHeight/(this.edgeLen*Math.SQRT1_2)*Math.PI)-x>0)return _();let S=c==null?1:3-Math.min(v,2);if(g*S<e.relativeWidthLimit||l>=e.maxLod)return _();if(l<7)return 1;i($,this.up,y),t($,$,f);let C=n($);if(C<=this.radius*this.radius)return 1;i($,$,this.radius/Math.sqrt(C)),a($,$,d),t($,s,$);let w=Math.min(1,(Math.abs(r($,this.up))+.5*b+this._curvatureHeight)/o($)),T=.1/e.angledSplitBias,E=e.fovY*m*2;return w*(this._edgeLen/E*S)<T*e.relativeHeightLimit?_():1}needsElevationSourceUpdate(){let e=this.renderData?.geometryState.samplerDataSourceLevels;if(e==null)return!1;let t=Math.max(this.elevationLevel-this.elevationLevelDelta,0);return e.some(e=>e>t)&&this._lastElevationSourceUpdateRequestSignature!==this._elevationSourceUpdateRequestSignature(e)}markElevationSourceUpdateRequested(){let e=this.renderData?.geometryState.samplerDataSourceLevels;this._lastElevationSourceUpdateRequestSignature=e==null?null:this._elevationSourceUpdateRequestSignature(e)}_elevationSourceUpdateRequestSignature(e){return`${Math.max(this.elevationLevel-this.elevationLevelDelta,0)}:${e.join(`,`)}`}createChildren(){let e=this._children,t=this.lij[0]+1,n=this.lij[1]*2,r=this.lij[2]*2;return e[0]=this.surface.createTile(t,n,r,this),e[1]=this.surface.createTile(t,n,r+1,this),e[2]=this.surface.createTile(t,n+1,r,this),e[3]=this.surface.createTile(t,n+1,r+1,this),e}clearChildren(){this._children[0]=this._children[1]=this._children[2]=this._children[3]=null}get loaded(){return this.renderData?.hasGeometry??!1}get hasGeometryState(){return this.renderData?.geometryState!=null}load(){this.refMapData();for(let e of E)this._createOrUpdateAgents(0,e);this.surface.renderer.loadTile(this)}unload(){this.renderData&&this.unrefMapData(),this.surface.renderer.unloadTile(this);for(let e of E){let t=this.layerInfo[e];for(let e of t)e.loadingAgent&&e.loadingAgent!==V&&(W(e.loadingAgent),e.loadingAgent=null),e.pendingUpdates=0}this.resetPendingUpdate(8),this.resetPendingUpdate(16),this.resetPendingUpdate(32)}unloadMapData(){let e=this.layerInfo[1];for(let t of e)t.loadingAgent&&t.loadingAgent!==V&&(W(t.loadingAgent),t.loadingAgent=null),t.pendingUpdates=0,t.invalidateSourceData();this.renderData?.releaseTexture(),this.setMemoryDirty()}updateClippingStatus(e){if(h(e,this._clippingArea))return!1;let t=this._intersectsClippingArea,n=this._withinClippingArea;e==null?(this._intersectsClippingArea=!0,this._withinClippingArea=!0):(this._intersectsClippingArea=this.intersectsExtent(e),this._withinClippingArea=this._isWithinExtent(e)),this._clippingArea=e,this.updateVisibility();let r=n&&this._withinClippingArea,i=!n&&!t&&!this._withinClippingArea&&!this._intersectsClippingArea;return this.renderData&&!(r||i)&&this.setPendingUpdate(8),!0}updateVisibility(){this._dirty=!0,this._surface.setTileTreeDirty(!1)}getLayerInfo(e,t){return this.layerInfo[t][e]}hasLayerData(e,t){let n=this.layerInfo[t][e];return!(!n?.data||n.dataInvalidated)}get updating(){if(this.hasPendingUpdates)return!0;for(let e of E){let t=this.layerInfo[e];for(let e of t)if(e.loadingAgent&&e.loadingAgent!==V&&e.loadingAgent.updating)return!0}return!1}_isSuspended(e){return this.hasPendingUpdate(1)?!0:e!==0&&!this._loadable}get hasPendingUpdates(){return this._pendingUpdates!==0}hasPendingUpdate(e){return(this._pendingUpdates&e)===e}setPendingUpdate(e){let t=this._pendingUpdates;return this._pendingUpdates|=e,e===1||e===4?this._surface.setTileTreeDirty(!0):this._surface.requestUpdate(),t!==this._pendingUpdates}resetPendingUpdate(e){return this.hasPendingUpdate(e)?(this._pendingUpdates&=~e,!0):!1}requestLayerData(e,t,n){let r=this.layerInfo[t][e];if(r.waitingAgents.has(n))return console.warn(`agent already requested this piece of map data (tile %s, agent tile %s, layer: %d/%d)`,this._lij.toString(),n.tile.lij.toString(),t,e),!0;if(r.waitingAgents.push(n),r.data&&!r.dataInvalidated){console.warn(`agent requested existing data (tile %s, agent tile %s, layer: %d/%d)`,this._lij.toString(),n.tile.lij.toString(),t,e);let i=O(r.data);return n.dataArrived(this,i),!0}if(r.requestPromise)return!0;d(r.requestAbort),r.requestAbort=new AbortController;let i=this._surface.requestTileData(this,e,t,{signal:r.requestAbort.signal});if(!i)return r.requestAbort=null,!1;let a=()=>{r.requestPromise===i&&(r.requestPromise=null,r.requestAbort=null)};return r.requestPromise=i,i.then(a,a),!0}get leaf(){return this._children[0]==null}hasLij(e){return this._lij[0]===e[0]&&this._lij[1]===e[1]&&this._lij[2]===e[2]}findByLij(e){if(this.hasLij(e))return this;let t=this._children;return t[0]?t[0].findByLij(e)||t[1].findByLij(e)||t[2].findByLij(e)||t[3].findByLij(e):null}distanceToSquared(e){return n(t($,this._center[1].center,e))}containsPoint(e){let t=this.extent;return e[0]>=t[0]&&e[1]>=t[1]&&e[0]<=t[2]&&e[1]<=t[3]}containsPointXY(e,t){let n=this.extent;return e>=n[0]&&t>=n[1]&&e<=n[2]&&t<=n[3]}unrequestLayerData(e,t,n){let r=this.layerInfo[t][e],i=r.waitingAgents,a=i.removeUnordered(n)!=null;k(a,`agent has not requested this piece of map data`),i.length<1&&(r.abortRequest(),this.setMemoryDirty())}dataArrived(e,t,n){let r=O(n),i=this.layerInfo[t][e];i.data=n,i.dataInvalidated=!1,i.waitingAgents.forAll(e=>e.dataArrived(this,r)),i.waitingAgents.clear(),this.setMemoryDirty()}dataMissing(e,t){let n=this.layerInfo[t][e];n.dataMissing=!0,n.waitingAgents.forAll(e=>e.dataMissing()),n.waitingAgents.clear(),this.setMemoryDirty()}updateRenderData(e,t,n){switch(n&&this.forEachLoadedNeighbor(n=>n.updateRenderData(e,t)),e){case 1:return this._updateTexture(t);case 0:return this._updateGeometry()}}_updateTexture(e){this.renderData&&(this.resetPendingUpdate(e===0?16:32),this.setPendingUpdate(e===0?32:16))}_updateGeometry(){this.setPendingUpdate(8);for(let e of this.layerInfo[0])e.pendingUpdates|=8}invalidateLayerData(e,t){this.layerInfo[t][e].invalidateSourceData()}computeElevationBounds(){let e=this._elevationBoundsMin,t=this._elevationBoundsMax,n=1/0,r=-1/0,i=this.layerInfo[0],a=!0;for(let e of i)e.elevationBounds!=null&&(n=Math.min(n,e.elevationBounds.minElevation),r=Math.max(r,e.elevationBounds.maxElevation),e.elevationBounds.hasNoDataValues||(a=!1));a&&(n=Math.min(n,0),r=Math.max(r,0)),(e!==n||t!==r)&&(this._elevationBoundsMin=n,this._elevationBoundsMax=r,this.updateRadiusAndCenter(),this._surface.setTileTreeDirty(!1),this.renderData&&this._surface.tileElevationRangeChanged(this,e,t))}_updateCenter(){let e=this._elevationBoundsMin,t=this._elevationBoundsMax,n=.5*(e+t),r=this._center;i($,this.up,n),a(r[1].center,this.centerAtSeaLevel,$),i($,this.up,e),a(r[0],this.centerAtSeaLevel,$),i($,this.up,t),a(r[2],this.centerAtSeaLevel,$)}_closestCenterOnElevationRange(e,t){if(this._surface.viewingMode===1){if(this.level===0)return s(t,this._center[1].center);let n=r(this.up,e),a=Math.max(this.ellipsoid.radius+this._elevationBoundsMin,Math.min(this.ellipsoid.radius+this._elevationBoundsMax,n));return i(t,this.up,a)}let n=Math.max(this._elevationBoundsMin,Math.min(this._elevationBoundsMax,e[2]));return t[0]=this.centerAtSeaLevel[0],t[1]=this.centerAtSeaLevel[1],t[2]=n,t}findElevationBoundsForLayer(e,t){let n=this.layerInfo[0][e],r=this.elevationLevelDelta,i=Math.max(this.elevationLevel-r,0),a=n.elevationBounds;if(a!=null&&a.level>t&&a.level<=i)return;let o=this._surface.layerViewByIndex(e,0);if(!U(this,o))return;let s=fe,c=!1,l=n.data;if(l&&l.level<=i){let e=n.data;s.minElevation=e.samplerData.data.minValue,s.maxElevation=e.samplerData.data.maxValue,s.hasNoDataValues=e.samplerData.data.hasNoDataValues,s.level=this.level,c=!0}else{let t=0,n,a;for(let o=this._parent;o&&(!a||t<r)&&(t=this.elevationLevel-o.level,n=a||n,a=o.layerInfo[0][e].data,!(!a&&n&&o.level<=i));o=o.parent);a||=n,a&&(a.computeMinMaxValue(this._lij[0],this._lij[1],this._lij[2],s),s.minElevation!==1/0&&(s.level=a.level,c=!0))}c&&(n.elevationBounds??=new C,n.elevationBounds.copyFrom(s))}modifyLayers(e,t,n){let r=this.layerInfo[n];for(let e of r)e.loadingAgent&&e.loadingAgent!==V&&(W(e.loadingAgent),e.loadingAgent=null),e.waitingAgents.clear();for(let t=0;t<r.length;++t)e[t]===void 0&&r[t].release();let i=new Array(...r),a=t.length;r.length=a;for(let e=0;e<a;e++){let n=t[e];r[e]=n>-1?i[n]:H.acquire(this._surface.upsampleInfoPool)}this.setMemoryDirty()}restartAgents(e){this.renderData&&(this._createOrUpdateAgents(0,e),this.updateRenderData(e,0))}updateAgents(e){if(this.renderData){let t=this.layerInfo[e];for(let e of t)e.loadingAgent===V&&(e.loadingAgent=null);this._createOrUpdateAgents(0,e)}}updateAgentSuspension(){for(let e of E){let t=this._isSuspended(e);for(let n of this.layerInfo[e])n.loadingAgent&&n.loadingAgent!==V&&(n.loadingAgent.setSuspension(t),n.loadingAgent===V&&this.updateRenderData(e,0))}}removeLayerAgent(e,t){let n=this.layerInfo[t][e];n.loadingAgent&&n.loadingAgent!==V&&n.loadingAgent.dispose(),n.loadingAgent=null}agentDone(e,t){let n=this.layerInfo[t][e];n.loadingAgent=V,!n.data&&n.upsampleInfo==null&&this._createOrUpdateAgents(e+1,t)}_hasBlendableAncestor(e){return e.blendMode!==`normal`||x(e.parent)&&this._hasBlendableAncestor(e.parent)}_hasBlendModes(e,t,n){for(let r=e;r<t;++r){let e=this._surface.layerViewByIndex(r,n);if(oe(e)&&e?.layer?.blendMode!==`normal`||x(e?.layer?.parent)&&this._hasBlendableAncestor(e?.layer?.parent))return!0}return!1}_createOrUpdateAgents(e,t){let n=this.layerInfo[t];if(n.length===0)return;let r=this._isSuspended(t),i=!1;for(let a=e;a<n.length;++a){let o=n[a],s=this._surface.layerViewByIndex(a,t),c=!1;(!i||S(s))&&(o.loadingAgent?U(this,s)?(o.loadingAgent!==V&&o.loadingAgent.setSuspension(r),o.loadingAgent!==V&&(c=o.loadingAgent.update())):o.dispose():U(this,s)&&(o.loadingAgent=de(this,a,t,r),c=o.loadingAgent.startLoading(),c?o.loadingAgent===V&&this.setPendingUpdate(8):(W(o.loadingAgent),o.loadingAgent=V)),o.loadingAgent===V&&this.updateRenderData(t,0),!s.destroyed&&!this._hasBlendModes(e,n.length,t)&&c&&s.isOpaque&&(i||=!0))}}_isWithinExtent(e){let t=this.extent;return t[0]>=e[0]&&e[2]>=t[2]&&t[1]>=e[1]&&e[3]>=t[3]}intersectsExtent(e){let t=this.extent;return t[2]>=e[0]&&e[2]>=t[0]&&t[3]>=e[1]&&e[3]>=t[1]}getElevationVerticesPerSide(e){let t=this.elevationLevel-this.level,n=Math.max(this.level-e,this.elevationLevelDelta-t),r=u((this._maxTesselation>>n)+1,2,this._maxTesselation+1),i=this.minimumVerticesPerSide;return Math.max(r,i)}_findLIJ(e,t){if(!e)return null;let{rootTiles:n}=this.surface;if(n!=null){for(let r of n)if(pe(r,e)){let n=r,i=e[0]-n.level-1;for(;i>=0&&!n.leaf&&!t(n);){let t=e[1]>>i&1,r=e[2]>>i&1;n=n.children[t*2+r],i--}return t(n)?n:null}}return null}findNeighborTile(e,t){let n=this._lij,r=this._getNeighborLIJ(n,e);return r?q(n,r)?t(this)?this:null:this._findLIJ(r,t):null}findCorner(e,t){let n=e===1?1:e===7?0:e===5?2:3,r=this;for(;r.children[0]&&(!t||!t(r));)r=r.children[n];return r}findNeighborCornerTileExact(e,t){return this.findNeighborTile(e,e=>t(e)||e.level===this.level)?.findCorner(A(e),t)||null}forAllSubtreeOnSide(e,t){Z(this,le[e],t)}getNeighborEdgeStartVertexIndex(e,t){if(!t)return 0;let n=this.level-t.level;if(j(!M||n>=0),n===0)return 0;let r=2**n,i=(e&1)==1,a=+!i,o=t.lij[a+1]*r,s=this._lij[a+1],c=s-o,l=i?r-1-c:c;return M&&(j(o<=s&&s<o+r),j(0<=l&&l<r)),l}forEachLoadedNeighbor(e){let t=this.level,n=e=>e.level===t||e.loaded;N.forEach(t=>{let r=this.findNeighborTile(t,n);r!=null&&r!==this&&r.forAllSubtreeOnSide(P(t),n=>n.loaded?(e(n,t),!0):!1)}),F.forEach(t=>{let r=this.findNeighborTile(t,n)?.findCorner(A(t),e=>e.loaded);M&&j(!r||J(this,r,t)),r?.loaded&&e(r,t)})}_getNeighborLIJ(e,t){let n=L(t)?-1:+!!R(t),r=z(t)?-1:+!!B(t),i=[e[0],e[1]+n,e[2]+r];return i[1]<0?null:this.surface.isGlobal?this._wrapLIJ(i):i[2]<0?null:i}_wrapLIJ(e){return!e||e[1]<0||e[1]>=2**e[0]?null:this.surface.wrapEastWest(e)}isEdgeNeighbor(e,t){if(e==null)return!1;if(this.level===0&&e.level===0&&(this._eastEnd&&e._westEnd&&t===2||this._westEnd&&e._eastEnd&&t===6))return!0;let n=Math.max((this.extent[2]-this.extent[0])*1e-6,1);switch(t){case 0:return I(this.extent[3],e.extent[1],n);case 4:return I(this.extent[1],e.extent[3],n);case 2:return I(this.extent[2],e.extent[0],n)||I(this.extent[2],-e.extent[0],n);case 6:return I(this.extent[0],e.extent[2],n)||I(this.extent[0],-e.extent[2],n)}}get _eastEnd(){return this._lij[2]===this.surface.lijEastEnd(this.level)-1}get _westEnd(){return this._lij[2]===0}checkGeometryWaterproofness(){}shouldHaveNeighbor(e){let t=this.extent,{rootTilesExtent:n}=this._surface,r=(t[2]-t[0])*.25;if(L(e)&&t[3]+r>=n[3]||R(e)&&t[1]-r<=n[1])return!1;let i=this.surface.isGlobal;return!(!i&&z(e)&&t[0]-r<=n[0]||!i&&B(e)&&t[2]+r>=n[2])}updateDistanceToPOI(e){let t=this._lastPOI;if(this.distanceToPOI>=0&&t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2])return;s(this._lastPOI,e);let n=this._center[1].center,r=e[0]-n[0],i=e[1]-n[1],a=e[2]-n[2];this.distanceToPOI=r*r+i*i+a*a}updateOverlayParameters(e){let{renderData:t}=this;if(!t)return;let{overlays:n,longitudeCyclical:r}=e,i=t.overlay;if(n.length===0)this._clearTileOverlayData(0,i),this._clearTileOverlayData(1,i);else{let[e,t]=n,a=this.extent;g(e.extent,a,r)||_(a,e.extent,r)||_(a,t.extent,r)?(this._setOverlayData(n,r,a,0,i),this._setOverlayData(n,r,a,1,i)):(this._clearTileOverlayData(0,i),this._clearTileOverlayData(1,i))}}_setOverlayData(e,t,n,r,i){let a=e[r].extent,o=v(a),s=y(a),c=n[0];if(t){c=t.minimalMonotonic(a[0],c);let e=t.minimalMonotonic(a[0],n[2]);c>e&&(c=e-(n[2]-n[0]))}if(o===0||s===0){i.setOffsetAndScale(r,0,0,1,1);return}let l=v(n)/o,u=y(n)/s,d=(c-a[0])/o,f=(n[1]-a[1])/s;i.setOffsetAndScale(r,d,f,l,u)}_clearTileOverlayData(e,t){t.setOffsetAndScale(e,-1,-1,-1,-1)}}function de(e,t,n,r){let i=n===0?K.acquire():G.acquire();return i.init(e,t,n,r),i}function W(e){e.dispose(),T(e)?K.release(e):te(e)&&G.release(e)}const G=new f(()=>new ee),K=new f(()=>new w),fe=new C;function pe(e,t){let n=e.lij,r=t[0]-n[0];return r<0?!1:t[1]>>r===n[1]&&t[2]>>r===n[2]}function q(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]}function J(e,t,n){return e==null||t==null||t===e?!1:e.level>=t.level?Y(e,t,n):Y(t,e,A(n))}function Y(e,t,n){j(e.level>=t.level);let r=se(n),i=ce(n),a=e.extent,o=t.extent,s=[r?a[0]:a[2],i?a[3]:a[1]],c=[r?o[2]:o[0],i?o[1]:o[3]],l=(a[2]-a[0])*1e-5,u=I(s[0],c[0],l)||e.surface.isGlobal&&I(s[0],-c[0],l),d=I(s[1],c[1],l);if(u&&d)return!0;if(e.level===t.level||!u&&!d)return j(!1),!1;let f=u?X(o[1],o[3],a[1],a[3],l):X(o[0],o[2],a[0],a[2],l);return j(f),f}function X(e,t,n,r,i){return e-i<=n&&n<=r&&r<=t+i}function Z(e,t,n){let r=e.children;!n(e)&&r[0]&&(Z(r[t[0]],t,n),t.length===2&&Z(r[t[1]],t,n))}const Q=c(),me=c(),he=c(),$=c();export{ue as Tile,J as isCornerNeighbor,q as lijEquals};
2
+ import{toConst as e}from"../../../core/compilerUtils.js";import"../../../core/has.js";import{subtract as t,squaredLength as n,dot as r,scale as i,add as a,length as o,copy as s}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{create as c,unitZ as l}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{clamp as u}from"../../../core/mathUtils.js";import{abortMaybe as d}from"../../../core/maybe.js";import f from"../../../core/ObjectPool.js";import{getReferenceEllipsoid as p}from"../../../geometry/ellipsoidUtils.js";import{create as m,equals as h,rectangleContainsRectangleCyclicalAware as g,rectanglesIntersectCyclicalAware as _,width as v,height as y}from"../../../geometry/support/aaBoundingRect.js";import{Sphere as b}from"../../../geometry/support/sphere.js";import{isGroupLayer as x}from"../../../layers/support/layerUtils.js";import{isLayerViewWithFlowRenderer as S}from"../support/flowUtils.js";import{ElevationBounds as C}from"./ElevationBounds.js";import{ElevationTileAgent as w,isElevationTileAgent as T}from"./ElevationTileAgent.js";import{LayerClasses as E}from"./LayerClass.js";import{MapDataCacheItem as D}from"./MapDataCacheItem.js";import{MapTileAgent as ee,isMapTileAgent as te}from"./MapTileAgent.js";import{maxPatchTesselation as ne}from"./TerrainConst.js";import{isVectorTile as O,isTileTexture as re,isRasterTile as ie,isCreateBitmapResult as ae}from"./TerrainData.js";import{weakAssert as k,isBlendableLayerView as oe,oppositeCorner as A,internalAssert as j,enableTerrainInternalChecks as M,neighborEdgeIndices as N,oppositeEdge as P,neighborCornerIndices as F,almostEquals as I,isNorth as L,isSouth as R,isWest as z,isEast as B,isWestCorner as se,isNorthCorner as ce}from"./terrainUtils.js";import{tileAgentDone as V}from"./TileAgent.js";import{TilePerLayerInfo as H}from"./TilePerLayerInfo.js";import{fallsWithinLayerView as U}from"./tileUtils.js";const le={0:[0,1],1:[1],2:[1,3],3:[3],4:[2,3],5:[2],6:[0,2],7:[0]};class ue{constructor(){this._lij=[0,0,0],this._children=[null,null,null,null],this._pendingUpdates=0,this._dirty=!0,this._previouslyRendered=!1,this._lastElevationSourceUpdateRequestSignature=null,this.extent=m(),this._elevationBoundsMin=NaN,this._elevationBoundsMax=0,this.layerInfo=[[],[]],this.extentInRadians=m(),this.centerAtSeaLevel=c(),this._center=[c(),new b,c()],this.up=l(),this._withinClippingArea=!0,this._intersectsClippingArea=!0,this._maxTesselation=0,this._usedMemory=0,this._rasterTileMemory=0,this._vectorTileMemory=0,this._mapDataRefCount=0,this.screenDepth=0,this.renderOrder=0,this._edgeLen=0,this._edgeLen2=0,this._curvatureHeight=0,this.onCompressionFinished=()=>{this.setPendingUpdate(16),this.setMemoryDirty()},this.extentMidX=0,this.extentMidY=0,this.distanceToPOI=-1,this._lastPOI=c(),this.maxLevelDeltaNeighborCount=0,this.unmergableChildCount=0}get lij(){return this._lij}get spatialReference(){return this._surface.spatialReference??this._surface.tilingScheme.spatialReference}get isDisposed(){return this._surface==null}get elevationLevelDelta(){return this._surface.getElevationLevelDelta(this.level)}_setPendingUpdateForDescendants(){let e=this._children;if(e[0])for(let t of e)t.renderData&&(t.setPendingUpdate(16),t.setMemoryDirty()),t._setPendingUpdateForDescendants()}static prune(){G.prune(0),K.prune(0),H.prune()}get _cached(){return!this.leaf&&this._mapDataRefCount<=0}get withinClippingArea(){return this._withinClippingArea}get intersectsClippingArea(){return this._intersectsClippingArea}get clippingArea(){return this._clippingArea}get parent(){return this._parent}get children(){return this._children}get surface(){return this._surface}get elevationBoundsMin(){return this._elevationBoundsMin}get elevationBoundsMax(){return this._elevationBoundsMax}get level(){return this._lij[0]}get key(){return`${this._lij[0]}/${this._lij[1]}/${this._lij[2]}`}get edgeLen(){return this._edgeLen}get radius(){return this._center[1].radius}get visible(){return this._dirty&&this.computeVisibility(),this._visible}get frustumVisibility(){return this._dirty&&this.computeVisibility(),this._frustumVisibility}checkVisibility(e){if(this._dirty)return null;let t=this._calculateVisibility(e);if(this._frustumVisibility!==t||this._visible!==(t!==2&&this._intersectsClippingArea))throw Error(`Assertion failed: waterproof.visibility-cache-mismatch: Tile[${this.lij}]`);return t}computeVisibility(){this._dirty=!1;let e=this.parent?.frustumVisibility??1;this._frustumVisibility=this._calculateVisibility(e);let t=this._frustumVisibility!==2&&this._intersectsClippingArea;t!==this._visible&&(this._visible=t,this._surface.emit(`tiles-visibility-changed`),this._surface.renderer.setDirty(),this.updateAgentSuspension())}_calculateVisibility(e){let t=this.parent;return e===0?0:t!=null&&e===2&&this._elevationBoundsMin>=t._elevationBoundsMin&&this._elevationBoundsMax<=t._elevationBoundsMax?2:this._calculateFrustumVisibility(this.surface.frustum,this._surface.view.frustum.boundingSphere)}get _loadable(){return this.visible||this._surface.view.state.fixedContentCamera}get rendered(){let e=!!this.renderData;return e!==this._previouslyRendered&&(this._surface.emit(`tiles-visibility-changed`),this._previouslyRendered=e,this._surface.renderer.setDirty()),e}init(e,t,n,r,i){this._lij[0]=e,this._lij[1]=t,this._lij[2]=n,this.ellipsoid=p(i.tilingScheme.spatialReference),i.tilingScheme.getExtent(e,t,n,this.extent),i.tilingScheme.convertExtentToRadians(this.extent,this.extentInRadians),this.extentMidX=.5*(this.extent[0]+this.extent[2]),this.extentMidY=.5*(this.extent[1]+this.extent[3]),this._withinClippingArea=!0,this._intersectsClippingArea=!0,this._clippingArea=null,this._mapDataRefCount=0,i.upsampleMapCache.pop(this.key),this._edgeLen=0,this._edgeLen2=0,this._center[1].radius=0,this.elevationLevel=e,this._lastElevationSourceUpdateRequestSignature=null,r&&!Number.isNaN(r.elevationBoundsMin)?(this._elevationBoundsMin=r.elevationBoundsMin,this._elevationBoundsMax=r.elevationBoundsMax):(this._elevationBoundsMin=0,this._elevationBoundsMax=0),this._pendingUpdates=0,this.renderData=null,this.screenDepth=0,this._visible=!1,this._previouslyRendered=!1,this._parent=r,this.clearChildren(),this._surface=i,this.updateVisibility(),this.maxLevelDeltaNeighborCount=0,this.unmergableChildCount=0;for(let e of E){let t=i.numLayers(e),n=this.layerInfo[e];for(let e of n)e.release();n.length=t;for(let r=0;r<t;r++)n[r]=H.acquire(this._surface.upsampleInfoPool),e===0&&this.findElevationBoundsForLayer(r,-1)}this.computeElevationBounds(),this._maxTesselation=Math.min(i.tilingScheme.pixelSize,ne)}dispose(){k(!this.renderData,`tile.renderData was not unloaded`),this._surface?.upsampleMapCache.pop(this.key),this.layerInfo.forEach(e=>{e.forEach(e=>e.release()),e.length=0}),this._surface=this._parent=null,this.clearChildren(),this.setMemoryDirty()}refMapData(){++this._mapDataRefCount,this._cached||this._surface.upsampleMapCache.pop(this.key)}unrefMapData(){--this._mapDataRefCount,this._cached&&this.cachedMemory>0&&this._surface.upsampleMapCache.put(this.key,new D(e(this)))}setMemoryDirty(){this._usedMemory=0}get usedMemory(){return this._ensureUsedMemory()+(this._cached?0:this.mapDataMemory)}get cachedMemory(){return this._ensureUsedMemory(),this._surface==null?this.usedMemory:this._cached?this.mapDataMemory:0}get mapDataMemory(){return this._rasterTileMemory+this._vectorTileMemory}get _cpuImageMemorySize(){let e=this._surface.tilingScheme.pixelSize;return e*e*4}_ensureUsedMemory(){if(this._usedMemory>0)return this._vectorTileMemory=this.layerInfo[1].reduce((e,{data:t})=>e+(O(t)?t.usedMemoryPerReference:0),0),this._usedMemory;this._usedMemory=this._baseUsedMemory,this._rasterTileMemory=0,this._vectorTileMemory=0;for(let{data:e}of this.layerInfo[1])O(e)?this._vectorTileMemory+=e.usedMemoryPerReference:this._rasterTileMemory+=this.getTerrainDataMemory(e);for(let e of this.layerInfo[0])this._usedMemory+=e.data?this._cpuImageMemorySize:0;return this.renderData&&(this._usedMemory+=this.renderData.estimatedGeometryMemoryUsage,this._rasterTileMemory+=this.renderData.texture?.usedMemory??0),this._cached&&this._surface.upsampleMapCache.updateSize(this.key),this._usedMemory}getUsedMemoryForLayer(e,t){let n=this.layerInfo[e][t];return n?.data?e===1?this._cached?0:this.getTerrainDataMemory(n.data):e===0?this._cpuImageMemorySize:0:0}getTerrainDataMemory(e){return re(e)?e.texture.usedMemory:ie(e)?e.memoryUsage:O(e)?e.usedMemoryPerReference:ae(e)?this._cpuImageMemorySize:0}updateScreenDepth(e){let[t,n,r]=this._center[1].center,i=e,a=i[2]*t+i[6]*n+i[10]*r+i[14];this.screenDepth=a<0?0:a/(i[3]*t+i[7]*n+i[11]*r+i[15])}shouldSplit(e,s,c){if(!this.visible||e.frustum&&!(this._intersectsClippingArea&&this._calculateFrustumVisibility(e.frustum)!==2))return 0;let l=this.level;t(Q,this._center[1].center,s);let u=n(Q),d=this._closestCenterOnElevationRange(s,me),f=t(he,d,s),p=Math.min(u,n(f));if(this._edgeLen2>p&&l<e.maxLod)return 1;let m=Math.sqrt(p),h=e.fovX*m*2,g=this._edgeLen/h,_=()=>{if(l<e.maxLod)return this.elevationLevel=l,0;let t=l+Math.ceil(-Math.log2(e.relativeWidthLimit/g));return t===this.elevationLevel?0:(this.elevationLevel=t,2)},v=c==null?1/0:c-l;if(v<=.5)return _();let y=r(this.up,Q),b=this._elevationBoundsMax-this._elevationBoundsMin,x=b/this.edgeLen;if(e.aboveGround&&y>0&&x<.001&&y/m-Math.sin(this._curvatureHeight/(this.edgeLen*Math.SQRT1_2)*Math.PI)-x>0)return _();let S=c==null?1:3-Math.min(v,2);if(g*S<e.relativeWidthLimit||l>=e.maxLod)return _();if(l<7)return 1;i($,this.up,y),t($,$,f);let C=n($);if(C<=this.radius*this.radius)return 1;i($,$,this.radius/Math.sqrt(C)),a($,$,d),t($,s,$);let w=Math.min(1,(Math.abs(r($,this.up))+.5*b+this._curvatureHeight)/o($)),T=.1/e.angledSplitBias,E=e.fovY*m*2;return w*(this._edgeLen/E*S)<T*e.relativeHeightLimit?_():1}needsElevationSourceUpdate(){let e=this.renderData?.geometryState.samplerDataSourceLevels;if(e==null)return!1;let t=Math.max(this.elevationLevel-this.elevationLevelDelta,0);return e.some(e=>e>t)&&this._lastElevationSourceUpdateRequestSignature!==this._elevationSourceUpdateRequestSignature(e)}markElevationSourceUpdateRequested(){let e=this.renderData?.geometryState.samplerDataSourceLevels;this._lastElevationSourceUpdateRequestSignature=e==null?null:this._elevationSourceUpdateRequestSignature(e)}_elevationSourceUpdateRequestSignature(e){return`${Math.max(this.elevationLevel-this.elevationLevelDelta,0)}:${e.join(`,`)}`}createChildren(){let e=this._children,t=this.lij[0]+1,n=this.lij[1]*2,r=this.lij[2]*2;return e[0]=this.surface.createTile(t,n,r,this),e[1]=this.surface.createTile(t,n,r+1,this),e[2]=this.surface.createTile(t,n+1,r,this),e[3]=this.surface.createTile(t,n+1,r+1,this),e}clearChildren(){this._children[0]=this._children[1]=this._children[2]=this._children[3]=null}get loaded(){return this.renderData?.hasGeometry??!1}get hasGeometryState(){return this.renderData?.geometryState!=null}load(){this.refMapData();for(let e of E)this._createOrUpdateAgents(0,e);this.surface.renderer.loadTile(this)}unload(){this.renderData&&this.unrefMapData(),this.surface.renderer.unloadTile(this);for(let e of E){let t=this.layerInfo[e];for(let e of t)e.loadingAgent&&e.loadingAgent!==V&&(W(e.loadingAgent),e.loadingAgent=null),e.pendingUpdates=0}this.resetPendingUpdate(8),this.resetPendingUpdate(16),this.resetPendingUpdate(32)}unloadMapData(){let e=this.layerInfo[1];for(let t of e)t.loadingAgent&&t.loadingAgent!==V&&(W(t.loadingAgent),t.loadingAgent=null),t.pendingUpdates=0,t.invalidateSourceData();this.renderData?.releaseTexture(),this.setMemoryDirty()}updateClippingStatus(e){if(h(e,this._clippingArea))return!1;let t=this._intersectsClippingArea,n=this._withinClippingArea;e==null?(this._intersectsClippingArea=!0,this._withinClippingArea=!0):(this._intersectsClippingArea=this.intersectsExtent(e),this._withinClippingArea=this._isWithinExtent(e)),this._clippingArea=e,this.updateVisibility();let r=n&&this._withinClippingArea,i=!n&&!t&&!this._withinClippingArea&&!this._intersectsClippingArea;return this.renderData&&!(r||i)&&this.setPendingUpdate(8),!0}updateVisibility(){this._dirty=!0,this._surface.setTileTreeDirty(!1)}getLayerInfo(e,t){return this.layerInfo[t][e]}hasLayerData(e,t){let n=this.layerInfo[t][e];return!(!n?.data||n.dataInvalidated)}get updating(){if(this.hasPendingUpdates)return!0;for(let e of E){let t=this.layerInfo[e];for(let e of t)if(e.loadingAgent&&e.loadingAgent!==V&&e.loadingAgent.updating)return!0}return!1}_isSuspended(e){return this.hasPendingUpdate(1)?!0:e!==0&&!this._loadable}get hasPendingUpdates(){return this._pendingUpdates!==0}hasPendingUpdate(e){return(this._pendingUpdates&e)===e}setPendingUpdate(e){let t=this._pendingUpdates;return this._pendingUpdates|=e,e===1||e===4?this._surface.setTileTreeDirty(!0):this._surface.requestUpdate(),t!==this._pendingUpdates}resetPendingUpdate(e){return this.hasPendingUpdate(e)?(this._pendingUpdates&=~e,!0):!1}requestLayerData(e,t,n){let r=this.layerInfo[t][e];if(r.waitingAgents.has(n))return console.warn(`agent already requested this piece of map data (tile %s, agent tile %s, layer: %d/%d)`,this._lij.toString(),n.tile.lij.toString(),t,e),!0;if(r.waitingAgents.push(n),r.data&&!r.dataInvalidated){console.warn(`agent requested existing data (tile %s, agent tile %s, layer: %d/%d)`,this._lij.toString(),n.tile.lij.toString(),t,e);let i=O(r.data);return n.dataArrived(this,i),!0}if(r.requestPromise)return!0;d(r.requestAbort),r.requestAbort=new AbortController;let i=this._surface.requestTileData(this,e,t,{signal:r.requestAbort.signal});if(!i)return r.requestAbort=null,!1;let a=()=>{r.requestPromise===i&&(r.requestPromise=null,r.requestAbort=null)};return r.requestPromise=i,i.then(a,a),!0}get leaf(){return this._children[0]==null}hasLij(e){return this._lij[0]===e[0]&&this._lij[1]===e[1]&&this._lij[2]===e[2]}findByLij(e){if(this.hasLij(e))return this;let t=this._children;return t[0]?t[0].findByLij(e)||t[1].findByLij(e)||t[2].findByLij(e)||t[3].findByLij(e):null}distanceToSquared(e){return n(t($,this._center[1].center,e))}containsPoint(e){let t=this.extent;return e[0]>=t[0]&&e[1]>=t[1]&&e[0]<=t[2]&&e[1]<=t[3]}containsPointXY(e,t){let n=this.extent;return e>=n[0]&&t>=n[1]&&e<=n[2]&&t<=n[3]}unrequestLayerData(e,t,n){let r=this.layerInfo[t][e],i=r.waitingAgents,a=i.removeUnordered(n)!=null;k(a,`agent has not requested this piece of map data`),i.length<1&&(r.abortRequest(),this.setMemoryDirty())}dataArrived(e,t,n){let r=O(n),i=this.layerInfo[t][e];i.data=n,i.dataInvalidated=!1,i.waitingAgents.forAll(e=>e.dataArrived(this,r)),i.waitingAgents.clear(),this.setMemoryDirty()}dataMissing(e,t){let n=this.layerInfo[t][e];n.dataMissing=!0,n.waitingAgents.forAll(e=>e.dataMissing()),n.waitingAgents.clear(),this.setMemoryDirty()}updateRenderData(e,t,n){switch(n&&this.forEachLoadedNeighbor(n=>n.updateRenderData(e,t)),e){case 1:return this._updateTexture(t);case 0:return this._updateGeometry()}}_updateTexture(e){this.renderData&&(this.resetPendingUpdate(e===0?16:32),this.setPendingUpdate(e===0?32:16))}_updateGeometry(){this.setPendingUpdate(8);for(let e of this.layerInfo[0])e.pendingUpdates|=8}invalidateLayerData(e,t){this.layerInfo[t][e].invalidateSourceData()}computeElevationBounds(){let e=this._elevationBoundsMin,t=this._elevationBoundsMax,n=1/0,r=-1/0,i=this.layerInfo[0],a=!0;for(let e of i)e.elevationBounds!=null&&(n=Math.min(n,e.elevationBounds.minElevation),r=Math.max(r,e.elevationBounds.maxElevation),e.elevationBounds.hasNoDataValues||(a=!1));a&&(n=Math.min(n,0),r=Math.max(r,0)),(e!==n||t!==r)&&(this._elevationBoundsMin=n,this._elevationBoundsMax=r,this.updateRadiusAndCenter(),this._surface.setTileTreeDirty(!1),this.renderData&&this._surface.tileElevationRangeChanged(this,e,t))}_updateCenter(){let e=this._elevationBoundsMin,t=this._elevationBoundsMax,n=.5*(e+t),r=this._center;i($,this.up,n),a(r[1].center,this.centerAtSeaLevel,$),i($,this.up,e),a(r[0],this.centerAtSeaLevel,$),i($,this.up,t),a(r[2],this.centerAtSeaLevel,$)}_closestCenterOnElevationRange(e,t){if(this._surface.isGlobal){if(this.level===0)return s(t,this._center[1].center);let n=r(this.up,e),a=Math.max(this.ellipsoid.radius+this._elevationBoundsMin,Math.min(this.ellipsoid.radius+this._elevationBoundsMax,n));return i(t,this.up,a)}let n=Math.max(this._elevationBoundsMin,Math.min(this._elevationBoundsMax,e[2]));return t[0]=this.centerAtSeaLevel[0],t[1]=this.centerAtSeaLevel[1],t[2]=n,t}findElevationBoundsForLayer(e,t){let n=this.layerInfo[0][e],r=this.elevationLevelDelta,i=Math.max(this.elevationLevel-r,0),a=n.elevationBounds;if(a!=null&&a.level>t&&a.level<=i)return;let o=this._surface.layerViewByIndex(e,0);if(!U(this,o))return;let s=fe,c=!1,l=n.data;if(l&&l.level<=i){let e=n.data;s.minElevation=e.samplerData.data.minValue,s.maxElevation=e.samplerData.data.maxValue,s.hasNoDataValues=e.samplerData.data.hasNoDataValues,s.level=this.level,c=!0}else{let t=0,n,a;for(let o=this._parent;o&&(!a||t<r)&&(t=this.elevationLevel-o.level,n=a||n,a=o.layerInfo[0][e].data,!(!a&&n&&o.level<=i));o=o.parent);a||=n,a&&(a.computeMinMaxValue(this._lij[0],this._lij[1],this._lij[2],s),s.minElevation!==1/0&&(s.level=a.level,c=!0))}c&&(n.elevationBounds??=new C,n.elevationBounds.copyFrom(s))}modifyLayers(e,t,n){let r=this.layerInfo[n];for(let e of r)e.loadingAgent&&e.loadingAgent!==V&&(W(e.loadingAgent),e.loadingAgent=null),e.waitingAgents.clear();for(let t=0;t<r.length;++t)e[t]===void 0&&r[t].release();let i=new Array(...r),a=t.length;r.length=a;for(let e=0;e<a;e++){let n=t[e];r[e]=n>-1?i[n]:H.acquire(this._surface.upsampleInfoPool)}this.setMemoryDirty()}restartAgents(e){this.renderData&&(this._createOrUpdateAgents(0,e),this.updateRenderData(e,0))}updateAgents(e){if(this.renderData){let t=this.layerInfo[e];for(let e of t)e.loadingAgent===V&&(e.loadingAgent=null);this._createOrUpdateAgents(0,e)}}updateAgentSuspension(){for(let e of E){let t=this._isSuspended(e);for(let n of this.layerInfo[e])n.loadingAgent&&n.loadingAgent!==V&&(n.loadingAgent.setSuspension(t),n.loadingAgent===V&&this.updateRenderData(e,0))}}removeLayerAgent(e,t){let n=this.layerInfo[t][e];n.loadingAgent&&n.loadingAgent!==V&&n.loadingAgent.dispose(),n.loadingAgent=null}agentDone(e,t){let n=this.layerInfo[t][e];n.loadingAgent=V,!n.data&&n.upsampleInfo==null&&this._createOrUpdateAgents(e+1,t)}_hasBlendableAncestor(e){return e.blendMode!==`normal`||x(e.parent)&&this._hasBlendableAncestor(e.parent)}_hasBlendModes(e,t,n){for(let r=e;r<t;++r){let e=this._surface.layerViewByIndex(r,n);if(oe(e)&&e?.layer?.blendMode!==`normal`||x(e?.layer?.parent)&&this._hasBlendableAncestor(e?.layer?.parent))return!0}return!1}_createOrUpdateAgents(e,t){let n=this.layerInfo[t];if(n.length===0)return;let r=this._isSuspended(t),i=!1;for(let a=e;a<n.length;++a){let o=n[a],s=this._surface.layerViewByIndex(a,t),c=!1;(!i||S(s))&&(o.loadingAgent?U(this,s)?(o.loadingAgent!==V&&o.loadingAgent.setSuspension(r),o.loadingAgent!==V&&(c=o.loadingAgent.update())):o.dispose():U(this,s)&&(o.loadingAgent=de(this,a,t,r),c=o.loadingAgent.startLoading(),c?o.loadingAgent===V&&this.setPendingUpdate(8):(W(o.loadingAgent),o.loadingAgent=V)),o.loadingAgent===V&&this.updateRenderData(t,0),!s.destroyed&&!this._hasBlendModes(e,n.length,t)&&c&&s.isOpaque&&(i||=!0))}}_isWithinExtent(e){let t=this.extent;return t[0]>=e[0]&&e[2]>=t[2]&&t[1]>=e[1]&&e[3]>=t[3]}intersectsExtent(e){let t=this.extent;return t[2]>=e[0]&&e[2]>=t[0]&&t[3]>=e[1]&&e[3]>=t[1]}getElevationVerticesPerSide(e){let t=this.elevationLevel-this.level,n=Math.max(this.level-e,this.elevationLevelDelta-t),r=u((this._maxTesselation>>n)+1,2,this._maxTesselation+1),i=this.minimumVerticesPerSide;return Math.max(r,i)}_findLIJ(e,t){if(!e)return null;let{rootTiles:n}=this.surface;if(n!=null){for(let r of n)if(pe(r,e)){let n=r,i=e[0]-n.level-1;for(;i>=0&&!n.leaf&&!t(n);){let t=e[1]>>i&1,r=e[2]>>i&1;n=n.children[t*2+r],i--}return t(n)?n:null}}return null}findNeighborTile(e,t){let n=this._lij,r=this._getNeighborLIJ(n,e);return r?q(n,r)?t(this)?this:null:this._findLIJ(r,t):null}findCorner(e,t){let n=e===1?1:e===7?0:e===5?2:3,r=this;for(;r.children[0]&&(!t||!t(r));)r=r.children[n];return r}findNeighborCornerTileExact(e,t){return this.findNeighborTile(e,e=>t(e)||e.level===this.level)?.findCorner(A(e),t)||null}forAllSubtreeOnSide(e,t){Z(this,le[e],t)}getNeighborEdgeStartVertexIndex(e,t){if(!t)return 0;let n=this.level-t.level;if(j(!M||n>=0),n===0)return 0;let r=2**n,i=(e&1)==1,a=+!i,o=t.lij[a+1]*r,s=this._lij[a+1],c=s-o,l=i?r-1-c:c;return M&&(j(o<=s&&s<o+r),j(0<=l&&l<r)),l}forEachLoadedNeighbor(e){let t=this.level,n=e=>e.level===t||e.loaded;N.forEach(t=>{let r=this.findNeighborTile(t,n);r!=null&&r!==this&&r.forAllSubtreeOnSide(P(t),n=>n.loaded?(e(n,t),!0):!1)}),F.forEach(t=>{let r=this.findNeighborTile(t,n)?.findCorner(A(t),e=>e.loaded);M&&j(!r||J(this,r,t)),r?.loaded&&e(r,t)})}_getNeighborLIJ(e,t){let n=L(t)?-1:+!!R(t),r=z(t)?-1:+!!B(t),i=[e[0],e[1]+n,e[2]+r];return i[1]<0?null:this.surface.isGlobal?this._wrapLIJ(i):i[2]<0?null:i}_wrapLIJ(e){return!e||e[1]<0||e[1]>=2**e[0]?null:this.surface.wrapEastWest(e)}isEdgeNeighbor(e,t){if(e==null)return!1;if(this.level===0&&e.level===0&&(this._eastEnd&&e._westEnd&&t===2||this._westEnd&&e._eastEnd&&t===6))return!0;let n=Math.max((this.extent[2]-this.extent[0])*1e-6,1);switch(t){case 0:return I(this.extent[3],e.extent[1],n);case 4:return I(this.extent[1],e.extent[3],n);case 2:return I(this.extent[2],e.extent[0],n)||I(this.extent[2],-e.extent[0],n);case 6:return I(this.extent[0],e.extent[2],n)||I(this.extent[0],-e.extent[2],n)}}get _eastEnd(){return this._lij[2]===this.surface.lijEastEnd(this.level)-1}get _westEnd(){return this._lij[2]===0}checkGeometryWaterproofness(){}shouldHaveNeighbor(e){let t=this.extent,{rootTilesExtent:n}=this._surface,r=(t[2]-t[0])*.25;if(L(e)&&t[3]+r>=n[3]||R(e)&&t[1]-r<=n[1])return!1;let i=this.surface.isGlobal;return!(!i&&z(e)&&t[0]-r<=n[0]||!i&&B(e)&&t[2]+r>=n[2])}updateDistanceToPOI(e){let t=this._lastPOI;if(this.distanceToPOI>=0&&t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2])return;s(this._lastPOI,e);let n=this._center[1].center,r=e[0]-n[0],i=e[1]-n[1],a=e[2]-n[2];this.distanceToPOI=r*r+i*i+a*a}updateOverlayParameters(e){let{renderData:t}=this;if(!t)return;let{overlays:n,longitudeCyclical:r}=e,i=t.overlay;if(n.length===0)this._clearTileOverlayData(0,i),this._clearTileOverlayData(1,i);else{let[e,t]=n,a=this.extent;g(e.extent,a,r)||_(a,e.extent,r)||_(a,t.extent,r)?(this._setOverlayData(n,r,a,0,i),this._setOverlayData(n,r,a,1,i)):(this._clearTileOverlayData(0,i),this._clearTileOverlayData(1,i))}}_setOverlayData(e,t,n,r,i){let a=e[r].extent,o=v(a),s=y(a),c=n[0];if(t){c=t.minimalMonotonic(a[0],c);let e=t.minimalMonotonic(a[0],n[2]);c>e&&(c=e-(n[2]-n[0]))}if(o===0||s===0){i.setOffsetAndScale(r,0,0,1,1);return}let l=v(n)/o,u=y(n)/s,d=(c-a[0])/o,f=(n[1]-a[1])/s;i.setOffsetAndScale(r,d,f,l,u)}_clearTileOverlayData(e,t){t.setOffsetAndScale(e,-1,-1,-1,-1)}}function de(e,t,n,r){let i=n===0?K.acquire():G.acquire();return i.init(e,t,n,r),i}function W(e){e.dispose(),T(e)?K.release(e):te(e)&&G.release(e)}const G=new f(()=>new ee),K=new f(()=>new w),fe=new C;function pe(e,t){let n=e.lij,r=t[0]-n[0];return r<0?!1:t[1]>>r===n[1]&&t[2]>>r===n[2]}function q(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]}function J(e,t,n){return e==null||t==null||t===e?!1:e.level>=t.level?Y(e,t,n):Y(t,e,A(n))}function Y(e,t,n){j(e.level>=t.level);let r=se(n),i=ce(n),a=e.extent,o=t.extent,s=[r?a[0]:a[2],i?a[3]:a[1]],c=[r?o[2]:o[0],i?o[1]:o[3]],l=(a[2]-a[0])*1e-5,u=I(s[0],c[0],l)||e.surface.isGlobal&&I(s[0],-c[0],l),d=I(s[1],c[1],l);if(u&&d)return!0;if(e.level===t.level||!u&&!d)return j(!1),!1;let f=u?X(o[1],o[3],a[1],a[3],l):X(o[0],o[2],a[0],a[2],l);return j(f),f}function X(e,t,n,r,i){return e-i<=n&&n<=r&&r<=t+i}function Z(e,t,n){let r=e.children;!n(e)&&r[0]&&(Z(r[t[0]],t,n),t.length===2&&Z(r[t[1]],t,n))}const Q=c(),me=c(),he=c(),$=c();export{ue as Tile,J as isCornerNeighbor,q as lijEquals};
@@ -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"../../../core/Accessor.js";import{property as n,subclass as r}from"../../../core/accessorSupport/decorators.js";import"../../../core/has.js";import{watch as i}from"../../../core/reactiveUtils.js";import{equals as a}from"../../../geometry/support/aaBoundingRect.js";import{isTiledLayer as o}from"../../../layers/support/layerUtils.js";import{isSupportedEarthGCS as s,isSupportedGCSOnGlobe as c}from"../support/supportedSpatialReference.js";import{isProjectableRasterLayer as l,getTiledLayerInfo as u}from"./terrainUtils.js";import{TilingScheme as d}from"./TilingScheme.js";let f=class extends t{constructor(e){super(e)}initialize(){this.addHandles([this.layers.on(`change`,()=>this._update()),i(()=>this.extentHelper.layerViewsExtent,()=>this._setAdHocTilingScheme())]),this._update(),this.tilingSchemeLocked||this._setAdHocTilingScheme()}destroy(){this._waitTask=null,this.layers.destroy()}_update(){if(this._waitTask=null,this.tilingSchemeLocked)return;let e;if(this.layers.some(t=>!o(t)||t.isRejected()?!1:!t.isFulfilled()||p(t,this.viewSpatialReference,this.viewingMode)?(e=t,t?.type!==`vector-tile`&&!l(t)):!1),e){if(e.isResolved()){let t=u(e,this.viewSpatialReference,this.viewingMode);if(t!=null){let e=new d(t.tileInfo);this._lockTilingScheme(e)}}else this._updateWhen(e)}}_updateWhen(e){let t=e.when().catch(()=>{}).then(()=>{t===this._waitTask&&!this.destroyed&&this._update()});this._waitTask=t}_lockTilingScheme(e){if(this.viewingMode===1){let t=e.levels.length-1,n=e.spatialReference;n.isWebMercator?e=d.makeWebMercatorAuxiliarySphere(t):s(n)&&(e=d.makeGCSWithTileSize(e.spatialReference,e.pixelSize,t))}this.tilingSchemeLocked=!0,this.tilingScheme=e,this.extentHelper.tilingScheme=this.tilingScheme,this._updateTiledLayerExtent(),this.removeAllHandles(),this.addHandles(i(()=>this.extentHelper.tiledLayersExtent,()=>this._updateTiledLayerExtent()))}_updateTiledLayerExtent(){this._set(`extent`,this.extentHelper.tiledLayersExtent)}_setAdHocTilingScheme(){if(this.viewingMode===1){let e=this.extentHelper.viewSpatialReference;e.isWebMercator?this.tilingScheme=d.WebMercatorAuxiliarySphere:c(e)&&(this.tilingScheme=d.makeGCSWithTileSize(e,256)),this._set(`extent`,this.extentHelper.layerViewsExtent)}else{let e=this.extentHelper.layerViewsExtent;e!=null&&!a(e,this.extent)&&(this.tilingScheme=d.fromExtent(e,this.extentHelper.viewSpatialReference),this._set(`extent`,e))}}get test(){}};e([n()],f.prototype,`tilingScheme`,void 0),e([n({readOnly:!0})],f.prototype,`extent`,void 0),e([n({value:!1})],f.prototype,`tilingSchemeLocked`,void 0),e([n({constructOnly:!0})],f.prototype,`viewSpatialReference`,void 0),e([n({constructOnly:!0})],f.prototype,`layers`,void 0),e([n({constructOnly:!0})],f.prototype,`extentHelper`,void 0),e([n({constructOnly:!0})],f.prototype,`viewingMode`,void 0),f=e([r(`esri.views.3d.terrain.TilingSchemeLogic`)],f);function p(e,t,n){return u(e,t,n)!=null}export{f as TilingSchemeLogic};
2
+ import{__decorate as e}from"tslib";import t from"../../../core/Accessor.js";import{property as n,subclass as r}from"../../../core/accessorSupport/decorators.js";import"../../../core/has.js";import{watch as i}from"../../../core/reactiveUtils.js";import{equals as a}from"../../../geometry/support/aaBoundingRect.js";import{isTiledLayer as o}from"../../../layers/support/layerUtils.js";import{isSupportedEarthGCS as s,isSupportedGCSOnGlobe as c}from"../support/supportedSpatialReference.js";import{isProjectableRasterLayer as l,getTiledLayerInfo as u}from"./terrainUtils.js";import{TilingScheme as d}from"./TilingScheme.js";let f=class extends t{constructor(e){super(e)}initialize(){this.addHandles([this.layers.on(`change`,()=>this._update()),i(()=>this.extentHelper.layerViewsExtent,()=>this._setAdHocTilingScheme())]),this._update(),this.tilingSchemeLocked||this._setAdHocTilingScheme()}destroy(){this._waitTask=null,this.layers.destroy()}_update(){if(this._waitTask=null,this.tilingSchemeLocked)return;let e;if(this.layers.some(t=>!o(t)||t.isRejected()?!1:!t.isFulfilled()||p(t,this.viewSpatialReference,this.isGlobal)?(e=t,t?.type!==`vector-tile`&&!l(t)):!1),e){if(e.isResolved()){let t=u(e,this.viewSpatialReference,this.isGlobal);if(t!=null){let e=new d(t.tileInfo);this._lockTilingScheme(e)}}else this._updateWhen(e)}}_updateWhen(e){let t=e.when().catch(()=>{}).then(()=>{t===this._waitTask&&!this.destroyed&&this._update()});this._waitTask=t}_lockTilingScheme(e){if(this.isGlobal){let t=e.levels.length-1,n=e.spatialReference;n.isWebMercator?e=d.makeWebMercatorAuxiliarySphere(t):s(n)&&(e=d.makeGCSWithTileSize(e.spatialReference,e.pixelSize,t))}this.tilingSchemeLocked=!0,this.tilingScheme=e,this.extentHelper.tilingScheme=this.tilingScheme,this._updateTiledLayerExtent(),this.removeAllHandles(),this.addHandles(i(()=>this.extentHelper.tiledLayersExtent,()=>this._updateTiledLayerExtent()))}_updateTiledLayerExtent(){this._set(`extent`,this.extentHelper.tiledLayersExtent)}_setAdHocTilingScheme(){if(this.isGlobal){let e=this.extentHelper.viewSpatialReference;e.isWebMercator?this.tilingScheme=d.WebMercatorAuxiliarySphere:c(e)&&(this.tilingScheme=d.makeGCSWithTileSize(e,256)),this._set(`extent`,this.extentHelper.layerViewsExtent)}else{let e=this.extentHelper.layerViewsExtent;e!=null&&!a(e,this.extent)&&(this.tilingScheme=d.fromExtent(e,this.extentHelper.viewSpatialReference),this._set(`extent`,e))}}get test(){}};e([n()],f.prototype,`tilingScheme`,void 0),e([n({readOnly:!0})],f.prototype,`extent`,void 0),e([n({value:!1})],f.prototype,`tilingSchemeLocked`,void 0),e([n({constructOnly:!0})],f.prototype,`viewSpatialReference`,void 0),e([n({constructOnly:!0})],f.prototype,`layers`,void 0),e([n({constructOnly:!0})],f.prototype,`extentHelper`,void 0),e([n({constructOnly:!0})],f.prototype,`isGlobal`,void 0),f=e([r(`esri.views.3d.terrain.TilingSchemeLogic`)],f);function p(e,t,n){return u(e,t,n)!=null}export{f as TilingSchemeLogic};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import e from"../../../core/Collection.js";import{isEarth as t}from"../../../geometry/ellipsoidUtils.js";import{isCGCS2000 as n}from"../../../geometry/support/spatialReferenceUtils.js";import{getTileMaxtrixSetFromActiveLayer as r}from"../../../layers/support/layerUtils.js";import{isRasterTile as i,isCreateBitmapResult as a,isTileTexture as o,isVectorTile as s}from"./TerrainData.js";import{t as c}from"../../../chunks/terrainUtilsPlanar.js";import{t as l}from"../../../chunks/terrainUtilsSpherical.js";const u={1:l,2:c};function d(e,t){e||console.warn(`Terrain: `+t)}let f=!1,p=!1;function m(e){p=e,f||=e}function h(e){f=e}function g(e,t){if(f&&!e){let e=Error().stack?.slice(5);throw console.warn(`Terrain internal: `+(t??``)+` at `+e),Error(`Assertion failed`+(t?`: `+t:``))}}function _(e){return e?.type===`imagery-tile`||e?.type===`wcs`}function v(e){return e?.type===`imagery-tile-3d`}function y(e){return e?.type===`tile-3d`}function b(e){return e?.type===`vector-tile-3d`}function x(e){return e?.type===`wmts-3d`}function S(e){return e?.type===`elevation-3d`}function C(e){return e?.type===`group`}function w(e){return e&&(y(e)||x(e)||v(e)||b(e))}function T(e){return e&&(y(e)||v(e)||b(e)||x(e))}function E(e){return T(e)||S(e)}function D(e){return i(e?.sourceLayerInfo?.data)}function O(e){return j(e?.sourceLayerInfo)}function k(e){return o(e?.sourceLayerInfo?.data)}function A(e){let t=e?.sourceLayerInfo?.data;return a(t)}function j(e){return s(e?.data)}function M(e){return e!=null&&`release`in e&&e.release(),null}function N(e,t,n,r,i){return u[r].checkIfTileInfoSupportedForViewSR(e,n,t,i)}function P(e,t,n){let r=null,i=null;if(e?.type===`wmts`){let a=F(e,t,n);r=a.tileInfo,i=a.fullExtent}else{i=_(e)?e.getCompatibleFullExtent(t):e.fullExtent;let a=n===2;r=_(e)?e.getCompatibleTileInfo(t,i,a):e?.type===`vector-tile`?a&&!I(t)||L.force512VTL?e.tileInfo:e.tileInfo.getCompatibleForVTL(256):e.tileInfo}let a=`tilemapCache`in e?e.tilemapCache?.effectiveMaxLOD:void 0;return r!=null&&i!=null&&N(r,i,t,n,a)==null?{tileInfo:r,fullExtent:i}:null}function F(t,n,i){let a=r(t);if(a!=null){if(e.isCollection(a)){let e=a.find(e=>N(e.tileInfo,e.fullExtent,n,i)==null);if(e)return{tileInfo:e.tileInfo,fullExtent:e.fullExtent}}else return{tileInfo:a.tileInfo,fullExtent:a.fullExtent}}return{tileInfo:null,fullExtent:null}}function I(e){return e.isWGS84||e.isWebMercator||n(e)||!t(e)}const L={force512VTL:!1};function R(e){return`[`+e[0]+`,`+e[1]+`,`+e[2]+`]`}function z(e){return`(`+e[0]+`,`+e[1]+`,`+e[2]+`)`}function B(e,t,n=Z){return Math.abs(e-t)<n}function V(e){return e===1?5:e===7?3:e===5?1:7}function H(e){return e===0?4:e===2?6:e===4?0:2}function U(e){return e===7||e===5}function W(e){return e===7||e===1}function G(e){return e===7||e===6||e===5}function K(e){return e===1||e===2||e===3}function q(e){return e===3||e===4||e===5}function J(e){return e===1||e===0||e===7}const Y=[0,2,4,6],X=[1,3,5,7],Z=1e-5;export{B as almostEquals,N as checkIfTileInfoSupportedForView,h as enableInternalTerrainChecks,f as enableTerrainInternalChecks,m as enableTerrainWaterproofChecks,p as enableWaterproofTests,Z as eps,F as getTileInfoAndExtentFromWMTSLayer,P as getTiledLayerInfo,g as internalAssert,w as isBlendableLayerView,K as isEast,S as isElevationLayerView,C as isGroupLayerView,A as isImageSourceRenderInfo,v as isImageryTileLayerView,D as isImageryTileRenderInfo,T as isMapTileLayerView,J as isNorth,W as isNorthCorner,_ as isProjectableRasterLayer,q as isSouth,E as isSurfaceLayerView,k as isTextureTileRenderInfo,y as isTileLayerView,b as isVectorTileLayerView,j as isVectorTilePerLayerInfo,O as isVectorTileRenderInfo,x as isWMTSLayerView,G as isWest,U as isWestCorner,R as lij2s,X as neighborCornerIndices,Y as neighborEdgeIndices,V as oppositeCorner,H as oppositeEdge,M as releaseTerrainData,L as test,z as v32s,I as vtlAssumes256PixelSizeAsDefault,d as weakAssert};
2
+ import e from"../../../core/Collection.js";import{isEarth as t}from"../../../geometry/ellipsoidUtils.js";import{isCGCS2000 as n}from"../../../geometry/support/spatialReferenceUtils.js";import{getTileMaxtrixSetFromActiveLayer as r}from"../../../layers/support/layerUtils.js";import{isRasterTile as i,isCreateBitmapResult as a,isTileTexture as o,isVectorTile as s}from"./TerrainData.js";import{t as c}from"../../../chunks/terrainUtilsPlanar.js";import{t as l}from"../../../chunks/terrainUtilsSpherical.js";function u(e,t){e||console.warn(`Terrain: `+t)}let d=!1,f=!1;function p(e){f=e,d||=e}function m(e){d=e}function h(e,t){if(d&&!e){let e=Error().stack?.slice(5);throw console.warn(`Terrain internal: `+(t??``)+` at `+e),Error(`Assertion failed`+(t?`: `+t:``))}}function g(e){return e?.type===`imagery-tile`||e?.type===`wcs`}function _(e){return e?.type===`imagery-tile-3d`}function v(e){return e?.type===`tile-3d`}function y(e){return e?.type===`vector-tile-3d`}function b(e){return e?.type===`wmts-3d`}function x(e){return e?.type===`elevation-3d`}function S(e){return e?.type===`group`}function C(e){return e&&(v(e)||b(e)||_(e)||y(e))}function w(e){return e&&(v(e)||_(e)||y(e)||b(e))}function T(e){return w(e)||x(e)}function E(e){return i(e?.sourceLayerInfo?.data)}function D(e){return A(e?.sourceLayerInfo)}function O(e){return o(e?.sourceLayerInfo?.data)}function k(e){let t=e?.sourceLayerInfo?.data;return a(t)}function A(e){return s(e?.data)}function j(e){return e!=null&&`release`in e&&e.release(),null}function M(e,t,n,r,i){return(r?l:c).checkIfTileInfoSupportedForViewSR(e,n,t,i)}function N(e,t,n){let r=null,i=null;if(e?.type===`wmts`){let a=P(e,t,n);r=a.tileInfo,i=a.fullExtent}else{i=g(e)?e.getCompatibleFullExtent(t):e.fullExtent;let a=!n;r=g(e)?e.getCompatibleTileInfo(t,i,a):e?.type===`vector-tile`?a&&!F(t)||I.force512VTL?e.tileInfo:e.tileInfo.getCompatibleForVTL(256):e.tileInfo}let a=`tilemapCache`in e?e.tilemapCache?.effectiveMaxLOD:void 0;return r!=null&&i!=null&&M(r,i,t,n,a)==null?{tileInfo:r,fullExtent:i}:null}function P(t,n,i){let a=r(t);if(a!=null){if(e.isCollection(a)){let e=a.find(e=>M(e.tileInfo,e.fullExtent,n,i)==null);if(e)return{tileInfo:e.tileInfo,fullExtent:e.fullExtent}}else return{tileInfo:a.tileInfo,fullExtent:a.fullExtent}}return{tileInfo:null,fullExtent:null}}function F(e){return e.isWGS84||e.isWebMercator||n(e)||!t(e)}const I={force512VTL:!1};function L(e){return`[`+e[0]+`,`+e[1]+`,`+e[2]+`]`}function R(e){return`(`+e[0]+`,`+e[1]+`,`+e[2]+`)`}function z(e,t,n=X){return Math.abs(e-t)<n}function B(e){return e===1?5:e===7?3:e===5?1:7}function V(e){return e===0?4:e===2?6:e===4?0:2}function H(e){return e===7||e===5}function U(e){return e===7||e===1}function W(e){return e===7||e===6||e===5}function G(e){return e===1||e===2||e===3}function K(e){return e===3||e===4||e===5}function q(e){return e===1||e===0||e===7}const J=[0,2,4,6],Y=[1,3,5,7],X=1e-5;export{z as almostEquals,M as checkIfTileInfoSupportedForView,m as enableInternalTerrainChecks,d as enableTerrainInternalChecks,p as enableTerrainWaterproofChecks,f as enableWaterproofTests,X as eps,P as getTileInfoAndExtentFromWMTSLayer,N as getTiledLayerInfo,h as internalAssert,C as isBlendableLayerView,G as isEast,x as isElevationLayerView,S as isGroupLayerView,k as isImageSourceRenderInfo,_ as isImageryTileLayerView,E as isImageryTileRenderInfo,w as isMapTileLayerView,q as isNorth,U as isNorthCorner,g as isProjectableRasterLayer,K as isSouth,T as isSurfaceLayerView,O as isTextureTileRenderInfo,v as isTileLayerView,y as isVectorTileLayerView,A as isVectorTilePerLayerInfo,D as isVectorTileRenderInfo,b as isWMTSLayerView,W as isWest,H as isWestCorner,L as lij2s,Y as neighborCornerIndices,J as neighborEdgeIndices,B as oppositeCorner,V as oppositeEdge,j as releaseTerrainData,I as test,R as v32s,F as vtlAssumes256PixelSizeAsDefault,u as weakAssert};
@@ -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"../../../core/Accessor.js";import{property as n,subclass as r}from"../../../core/accessorSupport/decorators.js";import{copy as i,invertOrIdentity as a,multiply as o,invert as s,transpose as c,frustum as l,exactEquals as u,lookAt as d}from"../../../core/libs/gl-matrix-2/math/mat4.js";import{create as f}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{copy as p,exactEquals as m}from"../../../core/libs/gl-matrix-2/math/vec2.js";import{fromValues as ee}from"../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{subtract as h,set as g,distance as te,copy as _,exactEquals as v,sub as y,dot as b,sqrLen as x,sqrDist as S,scale as C,length as w,cross as T,normalize as E,direction as ne}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{create as D,UNIT_Z as O}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{scale as k,equals as A,exactEquals as j,copy as M,squaredDistance as N,transformMat4 as P}from"../../../core/libs/gl-matrix-2/math/vec4.js";import{fromValues as F,create as I}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import L from"../../../core/Logger.js";import{lerp as R}from"../../../core/mathUtils.js";import{createScreenPointArray as z,createRenderScreenPointArray3 as B}from"../../../core/screenUtils.js";import{create as V,copy as H,fromMatrix as U}from"../../../geometry/support/frustumPlanes.js";import{create as W}from"../../../geometry/support/ray.js";import{projectPointSignedLength as G}from"../../../geometry/support/vector.js";import{viewAngle as K}from"../state/utils/viewUtils.js";import{fovd2fovx as re,fovx2fovd as ie,fovd2fovy as ae,fovy2fovd as oe}from"../webgl-engine/lib/fov.js";var q;let J=q=class extends t{constructor(e){super(e),this._ray=W(),this._viewport=F(0,0,1,1),this._padding=F(0,0,0,0),this._fov=55/180*Math.PI,this._nearFar=ee(1,1e3),this._viewDirty=!0,this._viewMatrix=f(),this._viewProjectionDirty=!0,this._viewProjectionMatrix=f(),this._viewInverseTransposeMatrixDirty=!0,this._viewInverseTransposeMatrix=f(),this._frustumDirty=!0,this._frustum=V(),this._fullViewport=I(),this._fullViewportDirty=!0,this._pixelRatio=1,this.pixelScale=1,this.row=0,this.column=0,this._rows=1,this._columns=1,this._center=D(),this._up=D(),this.relativeElevation=0}get pixelRatio(){return this._pixelRatio}set pixelRatio(e){this._pixelRatio=e>0?e:1}get rows(){return this._rows}set rows(e){this._rows=Math.max(1,e)}get columns(){return this._columns}set columns(e){this._columns=Math.max(1,e)}get eye(){return this._ray.origin}set eye(e){this._compareAndSetView(e,this._ray.origin,`eye`)}get center(){return this._center}set center(e){this._compareAndSetView(e,this._center,`_center`)}get ray(){return h(this._ray.direction,this.center,this.eye),this._ray}get up(){return this._up}set up(e){this._compareAndSetView(e,this._up,`_up`)}get viewMatrix(){return this._ensureViewClean(),this._viewMatrix}set viewMatrix(e){i(this._viewMatrix,e),this.notifyChange(`_viewMatrix`),this._viewDirty=!1,this._viewInverseTransposeMatrixDirty=!0,this._viewProjectionDirty=!0,this._frustumDirty=!0}get inverseViewMatrix(){return a(f(),this.viewMatrix)||this._get(`inverseViewMatrix`)||f()}get viewForward(){return this._ensureViewClean(),g(D(),-this._viewMatrix[2],-this._viewMatrix[6],-this._viewMatrix[10])}get viewUp(){return this._ensureViewClean(),g(D(),this._viewMatrix[1],this._viewMatrix[5],this._viewMatrix[9])}get viewRight(){return this._ensureViewClean(),g(D(),this._viewMatrix[0],this._viewMatrix[4],this._viewMatrix[8])}get nearFar(){return this._nearFar}get near(){return this._nearFar[0]}set near(e){this._nearFar[0]!==e&&(this._nearFar[0]=e,this._viewProjectionDirty=!0,this._frustumDirty=!0,this.notifyChange(`_nearFar`))}get far(){return this._nearFar[1]}set far(e){this._nearFar[1]!==e&&(this._nearFar[1]=e,this._viewProjectionDirty=!0,this._frustumDirty=!0,this.notifyChange(`_nearFar`))}get viewport(){return this._viewport}set viewport(e){this.x=e[0],this.y=e[1],this.width=e[2],this.height=e[3]}get screenViewport(){if(this.pixelRatio===1)return this._viewport;let e=k(I(),this._viewport,1/this.pixelRatio),t=this._get(`screenViewport`);return t&&A(e,t)?t:e}get screenPadding(){if(this.pixelRatio===1)return this._padding;let e=k(I(),this._padding,1/this.pixelRatio),t=this._get(`screenPadding`);return t&&A(e,t)?t:e}get x(){return this._viewport[0]}set x(e){e+=this._padding[3],this._viewport[0]!==e&&(this._viewport[0]=e,this._fullViewportDirty=!0,this._viewProjectionDirty=!0,this._frustumDirty=!0,this.notifyChange(`_viewport`))}get y(){return this._viewport[1]}set y(e){e+=this._padding[2],this._viewport[1]!==e&&(this._viewport[1]=e,this._fullViewportDirty=!0,this._viewProjectionDirty=!0,this._frustumDirty=!0,this.notifyChange(`_viewport`))}get width(){return this._viewport[2]}set width(e){this._viewport[2]!==e&&(this._viewport[2]=e,this._fullViewportDirty=!0,this._viewProjectionDirty=!0,this._frustumDirty=!0,this.notifyChange(`_viewport`))}get height(){return this._viewport[3]}set height(e){this._viewport[3]!==e&&(this._viewport[3]=e,this._fullViewportDirty=!0,this._viewProjectionDirty=!0,this._frustumDirty=!0,this.notifyChange(`_viewport`))}get fullWidth(){return this._viewport[2]+this._padding[1]+this._padding[3]}set fullWidth(e){this.width=e-(this._padding[1]+this._padding[3])}get fullHeight(){return this._viewport[3]+this._padding[0]+this._padding[2]}set fullHeight(e){this.height=e-(this._padding[0]+this._padding[2])}get fullViewport(){return this._fullViewportDirty&&=(this._fullViewport[0]=this._viewport[0]-this._padding[3],this._fullViewport[1]=this._viewport[1]-this._padding[2],this._fullViewport[2]=this._viewport[2]+this._padding[1]+this._padding[3],this._fullViewport[3]=this._viewport[3]+this._padding[0]+this._padding[2],!1),this._fullViewport}get _aspect(){return this.width/this.height}get padding(){return this._padding}set padding(e){j(this._padding,e)||(this._viewport[0]+=e[3]-this._padding[3],this._viewport[1]+=e[2]-this._padding[2],this._viewport[2]-=e[1]+e[3]-(this._padding[1]+this._padding[3]),this._viewport[3]-=e[0]+e[2]-(this._padding[0]+this._padding[2]),M(this._padding,e),this._fullViewportDirty=!0,this._viewProjectionDirty=!0,this._frustumDirty=!0,this.notifyChange(`_padding`),this.notifyChange(`_viewport`))}get viewProjectionMatrix(){return this._viewProjectionDirty&&=(o(this._viewProjectionMatrix,this.projectionMatrix,this.viewMatrix),!1),this._viewProjectionMatrix}get projectionMatrix(){return this._projectionMatrixInternal}get inverseProjectionMatrix(){return s(f(),this.projectionMatrix)||this._get(`inverseProjectionMatrix`)||f()}get fov(){return this._fov}set fov(e){this._fov=e,this._viewProjectionDirty=!0,this._frustumDirty=!0}get fovX(){return re(this._fov,this.width,this.height)}set fovX(e){this._fov=ie(e,this.width,this.height),this._viewProjectionDirty=!0,this._frustumDirty=!0}get fovY(){return ae(this._fov,this.width,this.height)}set fovY(e){this._fov=oe(e,this.width,this.height),this._viewProjectionDirty=!0,this._frustumDirty=!0}get distance(){return te(this.center,this.eye)}get frustum(){return this._recomputeFrustum(),this._frustum}get viewInverseTransposeMatrix(){return(this._viewInverseTransposeMatrixDirty||this._viewDirty)&&(s(this._viewInverseTransposeMatrix,this.viewMatrix),c(this._viewInverseTransposeMatrix,this._viewInverseTransposeMatrix),this._viewInverseTransposeMatrixDirty=!1),this._viewInverseTransposeMatrix}depthNDCToWorld(e){let{near:t,far:n}=this;return 2*t*n/(n+t-e*(n-t))}get renderPixelSizePerDistance(){return Math.tan(this.fovX/2)/(this.width/2)}get screenPixelSizePerDistance(){return this.renderPixelSizePerDistance*this.pixelRatio}get aboveGround(){return this.relativeElevation!=null&&this.relativeElevation>=0}get _projectionMatrixInternal(){let e=this.width,t=this.height,n=this.near*Math.tan(this.fovY/2)*2,r=n*this._aspect,i=n/this.rows,a=r/this.columns,o=-r/2+this.column*a,s=o+a,c=-n/2+this.row*i,d=c+i,p=l(f(),o*(1+2*this._padding[3]/e),s*(1+2*this._padding[1]/e),c*(1+2*this._padding[2]/t),d*(1+2*this._padding[0]/t),this.near,this.far),m=this._get(`projectionMatrix`);return m&&u(m,p)?m:p}copyFrom(e){_(this._ray.origin,e.eye),this.center=e.center,this.up=e.up,M(this._viewport,e.viewport),this.notifyChange(`_viewport`),M(this._padding,e.padding),this.notifyChange(`_padding`),this._fullViewportDirty=!0,p(this._nearFar,e.nearFar),this.notifyChange(`_nearFar`),this._fov=e.fov,this.row=e.row,this.column=e.column,this.rows=e.rows,this.columns=e.columns,this.relativeElevation=e.relativeElevation;let t=e;return this._viewDirty=t._viewDirty,this._viewDirty||(i(this._viewMatrix,e.viewMatrix),this.notifyChange(`_viewMatrix`)),this._viewProjectionDirty=!0,this._frustumDirty=t._frustumDirty,this._frustumDirty||=(H(this._frustum,e.frustum),!1),t._viewInverseTransposeMatrixDirty?this._viewInverseTransposeMatrixDirty=!0:(i(this._viewInverseTransposeMatrix,e.viewInverseTransposeMatrix),this._viewInverseTransposeMatrixDirty=!1),this.pixelRatio=e.pixelRatio,this.pixelScale=e.pixelScale,this}copyViewFrom(e){this.eye=e.eye,this.center=e.center,this.up=e.up,this.fov=e.fov}clone(){return new q().copyFrom(this)}equals(e){return v(this.eye,e.eye)&&v(this.center,e.center)&&v(this.up,e.up)&&j(this._viewport,e.viewport)&&j(this._padding,e.padding)&&m(this.nearFar,e.nearFar)&&this._fov===e.fov&&this.pixelRatio===e.pixelRatio&&this.relativeElevation===e.relativeElevation&&this.row===e.row&&this.column===e.column&&this.rows===e.rows&&this.columns===e.columns}equalsView(e){return v(this.eye,e.eye)&&v(this.center,e.center)&&v(this.up,e.up)&&this._fov===e.fov}almostEquals(e){let t=Math.max(1,1/this.pixelRatio,1/e.pixelRatio);if(Math.abs(e.fov-this._fov)>=.001||N(e.screenPadding,this.screenPadding)>=t||N(this.screenViewport,e.screenViewport)>=t||this.row!==e.row||this.column!==e.column||this.rows!==e.rows||this.columns!==e.columns)return!1;y(Z,e.eye,e.center),y(Q,this.eye,this.center);let n=b(Z,Q),r=x(Z),i=x(Q),a=5e-4;return n*n>=.9999999999*r*i&&S(e.eye,this.eye)<Math.max(r,i)*a*a}computeRenderPixelSizeAt(e){return this.computeRenderPixelSizeAtDistance(this._viewDirectionDistance(e))}computeRenderPixelSizeAtDistance(e){return e*this.renderPixelSizePerDistance}computeScreenPixelSizeAt(e){return this.computeScreenPixelSizeAtDistance(this._viewDirectionDistance(e))}_viewDirectionDistance(e){return Math.abs(G(this.viewForward,h(Z,e,this.eye)))}computeScreenPixelSizeAtDistance(e){return e*this.screenPixelSizePerDistance}computeDistanceFromRadius(e,t){return e/Math.tan(Math.min(this.fovX,this.fovY)/(2*(t||1)))}getScreenCenter(e=z()){return e[0]=(this.padding[3]+this.width/2)/this.pixelRatio,e[1]=(this.padding[0]+this.height/2)/this.pixelRatio,e}getRenderCenter(e,t=.5,n=.5){return e[0]=this.padding[3]+this.width*t,e[1]=this.padding[2]+this.height*n,e[2]=.5,e}setGLViewport(e){let t=this.viewport,n=this.padding;e.setViewport(t[0]-n[3],t[1]-n[2],t[2]+n[1]+n[3],t[3]+n[0]+n[2])}applyProjection(e,t){e!==Y&&_(Y,e),Y[3]=1,P(Y,Y,this.projectionMatrix);let n=Math.abs(Y[3]);C(Y,Y,1/n);let r=this.fullViewport;t[0]=R(0,r[0]+r[2],.5+.5*Y[0]),t[1]=R(0,r[1]+r[3],.5+.5*Y[1]),t[2]=.5*(Y[2]+1),t[3]=n}unapplyProjection(e,t){let n=this.fullViewport;Y[0]=(e[0]/(n[0]+n[2])*2-1)*e[3],Y[1]=(e[1]/(n[1]+n[3])*2-1)*e[3],Y[2]=(e[2]*2-1)*e[3],Y[3]=e[3],this.inverseProjectionMatrix!=null&&(P(Y,Y,this.inverseProjectionMatrix),t[0]=Y[0],t[1]=Y[1],t[2]=Y[2])}projectToScreen(e,t){return this.projectToRenderScreen(e,$)==null?null:(this.renderToScreen($,t),t)}projectToRenderScreen(e,t){if(Y[0]=e[0],Y[1]=e[1],Y[2]=e[2],Y[3]=1,P(Y,Y,this.viewProjectionMatrix),Y[3]===0)return null;let n=Y;C(n,n,1/Math.abs(Y[3]));let r=this.fullViewport,i=R(0,r[0]+r[2],.5+.5*n[0]),a=R(0,r[1]+r[3],.5+.5*n[1]);return`x`in t?(t.x=i,t.y=a):(t[0]=i,t[1]=a,t.length>2&&(t[2]=.5*(n[2]+1))),t}unprojectFromScreen(e,t){return this.unprojectFromRenderScreen(this.screenToRender(e,$),t)}unprojectFromRenderScreen(e,t){if(o(X,this.projectionMatrix,this.viewMatrix),!s(X,X))return null;let n=this.fullViewport;return Y[0]=(e[0]-n[0])*2/n[2]-1,Y[1]=(e[1]-n[1])*2/n[3]-1,Y[2]=2*e[2]-1,Y[3]=1,P(Y,Y,X),Y[3]===0?null:(t[0]=Y[0]/Y[3],t[1]=Y[1]/Y[3],t[2]=Y[2]/Y[3],t)}constrainWindowSize(e,t,n,r){let i=e*this.pixelRatio,a=t*this.pixelRatio,o=Math.max(i-n/2,0),s=Math.max(this.fullHeight-a-r/2,0),c=-Math.min(i-n/2,0),l=-Math.min(this.fullHeight-a-r/2,0),u=-Math.min(this.fullWidth-i-n/2,0),d=-Math.min(a-r/2,0),f=n-c-u,p=r-l-d;return[Math.round(o),Math.round(s),Math.round(f),Math.round(p)]}computeUp(e){e===1?this._computeUpGlobal():this._computeUpLocal()}screenToRender(e,t){let n=e[0]*this.pixelRatio,r=this.fullHeight-e[1]*this.pixelRatio;return t[0]=n,t[1]=r,t}renderToScreen(e,t){let n=e[0]/this.pixelRatio,r=(this.fullHeight-e[1])/this.pixelRatio;t[0]=n,t[1]=r}sphereFrustumCoverage(e,t){let{center:n,eye:r,distance:i,fovY:a}=this,o=Math.abs(Math.PI/2-K(t,n,r));return e.frustumCoverage(o,i,a)}_computeUpGlobal(){h(Z,this.center,this.eye);let e=w(this.center);e<1?v(this._up,O)&&(_(this._up,O),this._markViewDirty(),this.notifyChange(`_up`)):Math.abs(b(Z,this.center))>.9999*w(Z)*e||(T(Q,Z,this.center),T(Q,Q,Z),E(Q,Q),v(this._up,Q)||(_(this._up,Q),this.notifyChange(`_up`),this._markViewDirty()))}_computeUpLocal(){ne(Z,this.eye,this.center),Math.abs(Z[2])<=.9999&&(C(Z,Z,Z[2]),g(Z,-Z[0],-Z[1],1-Z[2]),E(Z,Z),v(this._up,Z)||(_(this._up,Z),this.notifyChange(`_up`),this._markViewDirty()))}_compareAndSetView(e,t,n){typeof e[0]!=`number`||!isFinite(e[0])||typeof e[1]!=`number`||!isFinite(e[1])||typeof e[2]!=`number`||!isFinite(e[2])?L.getLogger(`esri.views.3d.webgl-engine.lib.RenderCamera`).warn(`RenderCamera vector contains invalid number, ignoring value`):v(e,t)||(_(t,e),this._markViewDirty(),this.notifyChange(n))}_markViewDirty(){this._viewDirty=!0,this._frustumDirty=!0,this._viewProjectionDirty=!0}_recomputeFrustum(){this._frustumDirty&&=(U(this.viewMatrix,this.projectionMatrix,this._frustum),!1)}_ensureViewClean(){this._viewDirty&&(d(this._viewMatrix,this.eye,this.center,this.up),this.notifyChange(`_viewMatrix`),this._viewDirty=!1,this._viewInverseTransposeMatrixDirty=!0)}};e([n()],J.prototype,`_viewport`,void 0),e([n()],J.prototype,`_padding`,void 0),e([n()],J.prototype,`_fov`,void 0),e([n()],J.prototype,`_nearFar`,void 0),e([n()],J.prototype,`_viewDirty`,void 0),e([n()],J.prototype,`_viewMatrix`,void 0),e([n()],J.prototype,`pixelRatio`,null),e([n()],J.prototype,`_pixelRatio`,void 0),e([n()],J.prototype,`pixelScale`,void 0),e([n()],J.prototype,`row`,void 0),e([n()],J.prototype,`column`,void 0),e([n()],J.prototype,`_rows`,void 0),e([n()],J.prototype,`rows`,null),e([n()],J.prototype,`_columns`,void 0),e([n()],J.prototype,`columns`,null),e([n()],J.prototype,`eye`,null),e([n()],J.prototype,`center`,null),e([n()],J.prototype,`_center`,void 0),e([n()],J.prototype,`up`,null),e([n()],J.prototype,`_up`,void 0),e([n()],J.prototype,`viewMatrix`,null),e([n({readOnly:!0})],J.prototype,`inverseViewMatrix`,null),e([n({readOnly:!0})],J.prototype,`viewForward`,null),e([n({readOnly:!0})],J.prototype,`viewUp`,null),e([n({readOnly:!0})],J.prototype,`viewRight`,null),e([n({readOnly:!0})],J.prototype,`nearFar`,null),e([n()],J.prototype,`near`,null),e([n()],J.prototype,`far`,null),e([n()],J.prototype,`viewport`,null),e([n({readOnly:!0})],J.prototype,`screenViewport`,null),e([n({readOnly:!0})],J.prototype,`screenPadding`,null),e([n()],J.prototype,`x`,null),e([n()],J.prototype,`y`,null),e([n()],J.prototype,`width`,null),e([n()],J.prototype,`height`,null),e([n()],J.prototype,`fullWidth`,null),e([n()],J.prototype,`fullHeight`,null),e([n({readOnly:!0})],J.prototype,`_aspect`,null),e([n()],J.prototype,`padding`,null),e([n({readOnly:!0})],J.prototype,`projectionMatrix`,null),e([n({readOnly:!0})],J.prototype,`inverseProjectionMatrix`,null),e([n()],J.prototype,`fov`,null),e([n()],J.prototype,`fovX`,null),e([n()],J.prototype,`fovY`,null),e([n()],J.prototype,`viewInverseTransposeMatrix`,null),e([n({readOnly:!0})],J.prototype,`_projectionMatrixInternal`,null),e([n()],J.prototype,`relativeElevation`,void 0),J=q=e([r(`esri.views.3d.webgl.RenderCamera`)],J);const se=J,Y=I(),X=f(),Z=D(),Q=D(),$=B();export{se as default};
2
+ import{__decorate as e}from"tslib";import t from"../../../core/Accessor.js";import{property as n,subclass as r}from"../../../core/accessorSupport/decorators.js";import{copy as i,invertOrIdentity as a,multiply as o,invert as s,transpose as c,frustum as l,exactEquals as u,lookAt as d}from"../../../core/libs/gl-matrix-2/math/mat4.js";import{create as f}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{copy as p,exactEquals as m}from"../../../core/libs/gl-matrix-2/math/vec2.js";import{fromValues as ee}from"../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{subtract as h,set as g,distance as te,copy as _,exactEquals as v,sub as y,dot as b,sqrLen as x,sqrDist as S,scale as C,length as w,cross as T,normalize as E,direction as ne}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{create as D,UNIT_Z as O}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{scale as k,equals as A,exactEquals as j,copy as M,squaredDistance as N,transformMat4 as P}from"../../../core/libs/gl-matrix-2/math/vec4.js";import{fromValues as F,create as I}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import L from"../../../core/Logger.js";import{lerp as R}from"../../../core/mathUtils.js";import{createScreenPointArray as z,createRenderScreenPointArray3 as B}from"../../../core/screenUtils.js";import{create as V,copy as H,fromMatrix as U}from"../../../geometry/support/frustumPlanes.js";import{create as W}from"../../../geometry/support/ray.js";import{projectPointSignedLength as G}from"../../../geometry/support/vector.js";import{viewAngle as K}from"../state/utils/viewUtils.js";import{fovd2fovx as re,fovx2fovd as ie,fovd2fovy as ae,fovy2fovd as oe}from"../webgl-engine/lib/fov.js";var q;let J=q=class extends t{constructor(e){super(e),this._ray=W(),this._viewport=F(0,0,1,1),this._padding=F(0,0,0,0),this._fov=55/180*Math.PI,this._nearFar=ee(1,1e3),this._viewDirty=!0,this._viewMatrix=f(),this._viewProjectionDirty=!0,this._viewProjectionMatrix=f(),this._viewInverseTransposeMatrixDirty=!0,this._viewInverseTransposeMatrix=f(),this._frustumDirty=!0,this._frustum=V(),this._fullViewport=I(),this._fullViewportDirty=!0,this._pixelRatio=1,this.pixelScale=1,this.row=0,this.column=0,this._rows=1,this._columns=1,this._center=D(),this._up=D(),this.relativeElevation=0}get pixelRatio(){return this._pixelRatio}set pixelRatio(e){this._pixelRatio=e>0?e:1}get rows(){return this._rows}set rows(e){this._rows=Math.max(1,e)}get columns(){return this._columns}set columns(e){this._columns=Math.max(1,e)}get eye(){return this._ray.origin}set eye(e){this._compareAndSetView(e,this._ray.origin,`eye`)}get center(){return this._center}set center(e){this._compareAndSetView(e,this._center,`_center`)}get ray(){return h(this._ray.direction,this.center,this.eye),this._ray}get up(){return this._up}set up(e){this._compareAndSetView(e,this._up,`_up`)}get viewMatrix(){return this._ensureViewClean(),this._viewMatrix}set viewMatrix(e){i(this._viewMatrix,e),this.notifyChange(`_viewMatrix`),this._viewDirty=!1,this._viewInverseTransposeMatrixDirty=!0,this._viewProjectionDirty=!0,this._frustumDirty=!0}get inverseViewMatrix(){return a(f(),this.viewMatrix)||this._get(`inverseViewMatrix`)||f()}get viewForward(){return this._ensureViewClean(),g(D(),-this._viewMatrix[2],-this._viewMatrix[6],-this._viewMatrix[10])}get viewUp(){return this._ensureViewClean(),g(D(),this._viewMatrix[1],this._viewMatrix[5],this._viewMatrix[9])}get viewRight(){return this._ensureViewClean(),g(D(),this._viewMatrix[0],this._viewMatrix[4],this._viewMatrix[8])}get nearFar(){return this._nearFar}get near(){return this._nearFar[0]}set near(e){this._nearFar[0]!==e&&(this._nearFar[0]=e,this._viewProjectionDirty=!0,this._frustumDirty=!0,this.notifyChange(`_nearFar`))}get far(){return this._nearFar[1]}set far(e){this._nearFar[1]!==e&&(this._nearFar[1]=e,this._viewProjectionDirty=!0,this._frustumDirty=!0,this.notifyChange(`_nearFar`))}get viewport(){return this._viewport}set viewport(e){this.x=e[0],this.y=e[1],this.width=e[2],this.height=e[3]}get screenViewport(){if(this.pixelRatio===1)return this._viewport;let e=k(I(),this._viewport,1/this.pixelRatio),t=this._get(`screenViewport`);return t&&A(e,t)?t:e}get screenPadding(){if(this.pixelRatio===1)return this._padding;let e=k(I(),this._padding,1/this.pixelRatio),t=this._get(`screenPadding`);return t&&A(e,t)?t:e}get x(){return this._viewport[0]}set x(e){e+=this._padding[3],this._viewport[0]!==e&&(this._viewport[0]=e,this._fullViewportDirty=!0,this._viewProjectionDirty=!0,this._frustumDirty=!0,this.notifyChange(`_viewport`))}get y(){return this._viewport[1]}set y(e){e+=this._padding[2],this._viewport[1]!==e&&(this._viewport[1]=e,this._fullViewportDirty=!0,this._viewProjectionDirty=!0,this._frustumDirty=!0,this.notifyChange(`_viewport`))}get width(){return this._viewport[2]}set width(e){this._viewport[2]!==e&&(this._viewport[2]=e,this._fullViewportDirty=!0,this._viewProjectionDirty=!0,this._frustumDirty=!0,this.notifyChange(`_viewport`))}get height(){return this._viewport[3]}set height(e){this._viewport[3]!==e&&(this._viewport[3]=e,this._fullViewportDirty=!0,this._viewProjectionDirty=!0,this._frustumDirty=!0,this.notifyChange(`_viewport`))}get fullWidth(){return this._viewport[2]+this._padding[1]+this._padding[3]}set fullWidth(e){this.width=e-(this._padding[1]+this._padding[3])}get fullHeight(){return this._viewport[3]+this._padding[0]+this._padding[2]}set fullHeight(e){this.height=e-(this._padding[0]+this._padding[2])}get fullViewport(){return this._fullViewportDirty&&=(this._fullViewport[0]=this._viewport[0]-this._padding[3],this._fullViewport[1]=this._viewport[1]-this._padding[2],this._fullViewport[2]=this._viewport[2]+this._padding[1]+this._padding[3],this._fullViewport[3]=this._viewport[3]+this._padding[0]+this._padding[2],!1),this._fullViewport}get _aspect(){return this.width/this.height}get padding(){return this._padding}set padding(e){j(this._padding,e)||(this._viewport[0]+=e[3]-this._padding[3],this._viewport[1]+=e[2]-this._padding[2],this._viewport[2]-=e[1]+e[3]-(this._padding[1]+this._padding[3]),this._viewport[3]-=e[0]+e[2]-(this._padding[0]+this._padding[2]),M(this._padding,e),this._fullViewportDirty=!0,this._viewProjectionDirty=!0,this._frustumDirty=!0,this.notifyChange(`_padding`),this.notifyChange(`_viewport`))}get viewProjectionMatrix(){return this._viewProjectionDirty&&=(o(this._viewProjectionMatrix,this.projectionMatrix,this.viewMatrix),!1),this._viewProjectionMatrix}get projectionMatrix(){return this._projectionMatrixInternal}get inverseProjectionMatrix(){return s(f(),this.projectionMatrix)||this._get(`inverseProjectionMatrix`)||f()}get fov(){return this._fov}set fov(e){this._fov=e,this._viewProjectionDirty=!0,this._frustumDirty=!0}get fovX(){return re(this._fov,this.width,this.height)}set fovX(e){this._fov=ie(e,this.width,this.height),this._viewProjectionDirty=!0,this._frustumDirty=!0}get fovY(){return ae(this._fov,this.width,this.height)}set fovY(e){this._fov=oe(e,this.width,this.height),this._viewProjectionDirty=!0,this._frustumDirty=!0}get distance(){return te(this.center,this.eye)}get frustum(){return this._recomputeFrustum(),this._frustum}get viewInverseTransposeMatrix(){return(this._viewInverseTransposeMatrixDirty||this._viewDirty)&&(s(this._viewInverseTransposeMatrix,this.viewMatrix),c(this._viewInverseTransposeMatrix,this._viewInverseTransposeMatrix),this._viewInverseTransposeMatrixDirty=!1),this._viewInverseTransposeMatrix}depthNDCToWorld(e){let{near:t,far:n}=this;return 2*t*n/(n+t-e*(n-t))}get renderPixelSizePerDistance(){return Math.tan(this.fovX/2)/(this.width/2)}get screenPixelSizePerDistance(){return this.renderPixelSizePerDistance*this.pixelRatio}get aboveGround(){return this.relativeElevation!=null&&this.relativeElevation>=0}get _projectionMatrixInternal(){let e=this.width,t=this.height,n=this.near*Math.tan(this.fovY/2)*2,r=n*this._aspect,i=n/this.rows,a=r/this.columns,o=-r/2+this.column*a,s=o+a,c=-n/2+this.row*i,d=c+i,p=l(f(),o*(1+2*this._padding[3]/e),s*(1+2*this._padding[1]/e),c*(1+2*this._padding[2]/t),d*(1+2*this._padding[0]/t),this.near,this.far),m=this._get(`projectionMatrix`);return m&&u(m,p)?m:p}copyFrom(e){_(this._ray.origin,e.eye),this.center=e.center,this.up=e.up,M(this._viewport,e.viewport),this.notifyChange(`_viewport`),M(this._padding,e.padding),this.notifyChange(`_padding`),this._fullViewportDirty=!0,p(this._nearFar,e.nearFar),this.notifyChange(`_nearFar`),this._fov=e.fov,this.row=e.row,this.column=e.column,this.rows=e.rows,this.columns=e.columns,this.relativeElevation=e.relativeElevation;let t=e;return this._viewDirty=t._viewDirty,this._viewDirty||(i(this._viewMatrix,e.viewMatrix),this.notifyChange(`_viewMatrix`)),this._viewProjectionDirty=!0,this._frustumDirty=t._frustumDirty,this._frustumDirty||=(H(this._frustum,e.frustum),!1),t._viewInverseTransposeMatrixDirty?this._viewInverseTransposeMatrixDirty=!0:(i(this._viewInverseTransposeMatrix,e.viewInverseTransposeMatrix),this._viewInverseTransposeMatrixDirty=!1),this.pixelRatio=e.pixelRatio,this.pixelScale=e.pixelScale,this}copyViewFrom(e){this.eye=e.eye,this.center=e.center,this.up=e.up,this.fov=e.fov}clone(){return new q().copyFrom(this)}equals(e){return v(this.eye,e.eye)&&v(this.center,e.center)&&v(this.up,e.up)&&j(this._viewport,e.viewport)&&j(this._padding,e.padding)&&m(this.nearFar,e.nearFar)&&this._fov===e.fov&&this.pixelRatio===e.pixelRatio&&this.relativeElevation===e.relativeElevation&&this.row===e.row&&this.column===e.column&&this.rows===e.rows&&this.columns===e.columns}equalsView(e){return v(this.eye,e.eye)&&v(this.center,e.center)&&v(this.up,e.up)&&this._fov===e.fov}almostEquals(e){let t=Math.max(1,1/this.pixelRatio,1/e.pixelRatio);if(Math.abs(e.fov-this._fov)>=.001||N(e.screenPadding,this.screenPadding)>=t||N(this.screenViewport,e.screenViewport)>=t||this.row!==e.row||this.column!==e.column||this.rows!==e.rows||this.columns!==e.columns)return!1;y(Z,e.eye,e.center),y(Q,this.eye,this.center);let n=b(Z,Q),r=x(Z),i=x(Q),a=5e-4;return n*n>=.9999999999*r*i&&S(e.eye,this.eye)<Math.max(r,i)*a*a}computeRenderPixelSizeAt(e){return this.computeRenderPixelSizeAtDistance(this._viewDirectionDistance(e))}computeRenderPixelSizeAtDistance(e){return e*this.renderPixelSizePerDistance}computeScreenPixelSizeAt(e){return this.computeScreenPixelSizeAtDistance(this._viewDirectionDistance(e))}_viewDirectionDistance(e){return Math.abs(G(this.viewForward,h(Z,e,this.eye)))}computeScreenPixelSizeAtDistance(e){return e*this.screenPixelSizePerDistance}computeDistanceFromRadius(e,t){return e/Math.tan(Math.min(this.fovX,this.fovY)/(2*(t||1)))}getScreenCenter(e=z()){return e[0]=(this.padding[3]+this.width/2)/this.pixelRatio,e[1]=(this.padding[0]+this.height/2)/this.pixelRatio,e}getRenderCenter(e,t=.5,n=.5){return e[0]=this.padding[3]+this.width*t,e[1]=this.padding[2]+this.height*n,e[2]=.5,e}setGLViewport(e){let t=this.viewport,n=this.padding;e.setViewport(t[0]-n[3],t[1]-n[2],t[2]+n[1]+n[3],t[3]+n[0]+n[2])}applyProjection(e,t){e!==Y&&_(Y,e),Y[3]=1,P(Y,Y,this.projectionMatrix);let n=Math.abs(Y[3]);C(Y,Y,1/n);let r=this.fullViewport;t[0]=R(0,r[0]+r[2],.5+.5*Y[0]),t[1]=R(0,r[1]+r[3],.5+.5*Y[1]),t[2]=.5*(Y[2]+1),t[3]=n}unapplyProjection(e,t){let n=this.fullViewport;Y[0]=(e[0]/(n[0]+n[2])*2-1)*e[3],Y[1]=(e[1]/(n[1]+n[3])*2-1)*e[3],Y[2]=(e[2]*2-1)*e[3],Y[3]=e[3],this.inverseProjectionMatrix!=null&&(P(Y,Y,this.inverseProjectionMatrix),t[0]=Y[0],t[1]=Y[1],t[2]=Y[2])}projectToScreen(e,t){return this.projectToRenderScreen(e,$)==null?null:(this.renderToScreen($,t),t)}projectToRenderScreen(e,t){if(Y[0]=e[0],Y[1]=e[1],Y[2]=e[2],Y[3]=1,P(Y,Y,this.viewProjectionMatrix),Y[3]===0)return null;let n=Y;C(n,n,1/Math.abs(Y[3]));let r=this.fullViewport,i=R(0,r[0]+r[2],.5+.5*n[0]),a=R(0,r[1]+r[3],.5+.5*n[1]);return`x`in t?(t.x=i,t.y=a):(t[0]=i,t[1]=a,t.length>2&&(t[2]=.5*(n[2]+1))),t}unprojectFromScreen(e,t){return this.unprojectFromRenderScreen(this.screenToRender(e,$),t)}unprojectFromRenderScreen(e,t){if(o(X,this.projectionMatrix,this.viewMatrix),!s(X,X))return null;let n=this.fullViewport;return Y[0]=(e[0]-n[0])*2/n[2]-1,Y[1]=(e[1]-n[1])*2/n[3]-1,Y[2]=2*e[2]-1,Y[3]=1,P(Y,Y,X),Y[3]===0?null:(t[0]=Y[0]/Y[3],t[1]=Y[1]/Y[3],t[2]=Y[2]/Y[3],t)}constrainWindowSize(e,t,n,r){let i=e*this.pixelRatio,a=t*this.pixelRatio,o=Math.max(i-n/2,0),s=Math.max(this.fullHeight-a-r/2,0),c=-Math.min(i-n/2,0),l=-Math.min(this.fullHeight-a-r/2,0),u=-Math.min(this.fullWidth-i-n/2,0),d=-Math.min(a-r/2,0),f=n-c-u,p=r-l-d;return[Math.round(o),Math.round(s),Math.round(f),Math.round(p)]}computeUp(e){e?this._computeUpGlobal():this._computeUpLocal()}screenToRender(e,t){let n=e[0]*this.pixelRatio,r=this.fullHeight-e[1]*this.pixelRatio;return t[0]=n,t[1]=r,t}renderToScreen(e,t){let n=e[0]/this.pixelRatio,r=(this.fullHeight-e[1])/this.pixelRatio;t[0]=n,t[1]=r}sphereFrustumCoverage(e,t){let{center:n,eye:r,distance:i,fovY:a}=this,o=Math.abs(Math.PI/2-K(t,n,r));return e.frustumCoverage(o,i,a)}_computeUpGlobal(){h(Z,this.center,this.eye);let e=w(this.center);e<1?v(this._up,O)&&(_(this._up,O),this._markViewDirty(),this.notifyChange(`_up`)):Math.abs(b(Z,this.center))>.9999*w(Z)*e||(T(Q,Z,this.center),T(Q,Q,Z),E(Q,Q),v(this._up,Q)||(_(this._up,Q),this.notifyChange(`_up`),this._markViewDirty()))}_computeUpLocal(){ne(Z,this.eye,this.center),Math.abs(Z[2])<=.9999&&(C(Z,Z,Z[2]),g(Z,-Z[0],-Z[1],1-Z[2]),E(Z,Z),v(this._up,Z)||(_(this._up,Z),this.notifyChange(`_up`),this._markViewDirty()))}_compareAndSetView(e,t,n){typeof e[0]!=`number`||!isFinite(e[0])||typeof e[1]!=`number`||!isFinite(e[1])||typeof e[2]!=`number`||!isFinite(e[2])?L.getLogger(`esri.views.3d.webgl-engine.lib.RenderCamera`).warn(`RenderCamera vector contains invalid number, ignoring value`):v(e,t)||(_(t,e),this._markViewDirty(),this.notifyChange(n))}_markViewDirty(){this._viewDirty=!0,this._frustumDirty=!0,this._viewProjectionDirty=!0}_recomputeFrustum(){this._frustumDirty&&=(U(this.viewMatrix,this.projectionMatrix,this._frustum),!1)}_ensureViewClean(){this._viewDirty&&(d(this._viewMatrix,this.eye,this.center,this.up),this.notifyChange(`_viewMatrix`),this._viewDirty=!1,this._viewInverseTransposeMatrixDirty=!0)}};e([n()],J.prototype,`_viewport`,void 0),e([n()],J.prototype,`_padding`,void 0),e([n()],J.prototype,`_fov`,void 0),e([n()],J.prototype,`_nearFar`,void 0),e([n()],J.prototype,`_viewDirty`,void 0),e([n()],J.prototype,`_viewMatrix`,void 0),e([n()],J.prototype,`pixelRatio`,null),e([n()],J.prototype,`_pixelRatio`,void 0),e([n()],J.prototype,`pixelScale`,void 0),e([n()],J.prototype,`row`,void 0),e([n()],J.prototype,`column`,void 0),e([n()],J.prototype,`_rows`,void 0),e([n()],J.prototype,`rows`,null),e([n()],J.prototype,`_columns`,void 0),e([n()],J.prototype,`columns`,null),e([n()],J.prototype,`eye`,null),e([n()],J.prototype,`center`,null),e([n()],J.prototype,`_center`,void 0),e([n()],J.prototype,`up`,null),e([n()],J.prototype,`_up`,void 0),e([n()],J.prototype,`viewMatrix`,null),e([n({readOnly:!0})],J.prototype,`inverseViewMatrix`,null),e([n({readOnly:!0})],J.prototype,`viewForward`,null),e([n({readOnly:!0})],J.prototype,`viewUp`,null),e([n({readOnly:!0})],J.prototype,`viewRight`,null),e([n({readOnly:!0})],J.prototype,`nearFar`,null),e([n()],J.prototype,`near`,null),e([n()],J.prototype,`far`,null),e([n()],J.prototype,`viewport`,null),e([n({readOnly:!0})],J.prototype,`screenViewport`,null),e([n({readOnly:!0})],J.prototype,`screenPadding`,null),e([n()],J.prototype,`x`,null),e([n()],J.prototype,`y`,null),e([n()],J.prototype,`width`,null),e([n()],J.prototype,`height`,null),e([n()],J.prototype,`fullWidth`,null),e([n()],J.prototype,`fullHeight`,null),e([n({readOnly:!0})],J.prototype,`_aspect`,null),e([n()],J.prototype,`padding`,null),e([n({readOnly:!0})],J.prototype,`projectionMatrix`,null),e([n({readOnly:!0})],J.prototype,`inverseProjectionMatrix`,null),e([n()],J.prototype,`fov`,null),e([n()],J.prototype,`fovX`,null),e([n()],J.prototype,`fovY`,null),e([n()],J.prototype,`viewInverseTransposeMatrix`,null),e([n({readOnly:!0})],J.prototype,`_projectionMatrixInternal`,null),e([n()],J.prototype,`relativeElevation`,void 0),J=q=e([r(`esri.views.3d.webgl.RenderCamera`)],J);const se=J,Y=I(),X=f(),Z=D(),Q=D(),$=B();export{se as default};
@@ -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"../../../core/Accessor.js";import{property as n,subclass as r}from"../../../core/accessorSupport/decorators.js";import{removeUnordered as i}from"../../../core/arrayUtils.js";import{toConst as a}from"../../../core/compilerUtils.js";import"../../../core/has.js";import{destroyMaybe as o}from"../../../core/maybe.js";import{isPromiseLike as s}from"../../../core/promiseUtils.js";import{signal as c}from"../../../core/signal.js";import{TaskPriority as l,noBudget as u}from"../../support/Scheduler.js";import{Yield as d}from"../../support/Yield.js";import{isIntersectionHandler as f}from"../state/helpers/SceneIntersectionHelper.js";import{debugFlags as p}from"../support/debugFlags.js";import{TextureCollection as m}from"../support/TextureCollection.js";import{ChangeSet as h}from"./lib/ChangeSet.js";import{Model as g}from"./parts/Model.js";import{RenderView as _}from"./parts/RenderView.js";let v=class extends t{constructor(e){super(e),this._model=new g,this._canCompact=c(!1),this._layers=[],this._asyncChangeSet=new h,this._syncChangeSet=new h,this._layerSyncSet=new Set,this._textures=new m(this,e.view.resourceController.scheduler),this._frameTask=e.view.resourceController.scheduler.registerTask(l.STAGE,this),this.addHandles(this._frameTask)}initialize(){this._renderView=new _({view:this.view},this)}destroy(){this.removeAllHandles(),this._textures.destroy(),this._set(`textures`,null),this._renderView=o(this._renderView),this._set(`renderView`,null),this._layers.length=0,this._model=null,this._set(`renderer`,null),this.options.context=null,this._set(`options`,null)}get viewingMode(){return this.view.state.viewingMode}get updating(){if(this.destroyed||this.destroying)return!1;let e=this.readyToRun||this.renderView.updating||this._frameTask.updating||this.textures.updating;return e&&p.UPDATING&&console.log(` Stage:`,this.readyToRun,this.renderView.updating,this._frameTask.updating,this.textures.updating),e}get localOriginFactory(){return this._model.localOriginFactory}get renderView(){return this._renderView}get renderer(){return this.renderView?.renderer}get textures(){return this._textures}addTexture(e){this._model.addTexture(e),this.renderView.requestRender()}removeTexture(e){e!=null&&!this.destroyed&&this._model.hasTexture(e)&&(this._model.removeTexture(e),this.renderView.requestRender())}addTextures(e){e!=null&&(this._model.addTextures(e),this.renderView.requestRender())}removeTextures(e){e!=null&&(this._model?.removeTextures(e),this.renderView.requestRender())}forEachTexture(e){this._model.forEachTexture(e)}getTexture(e){return this._model.getTexture(e)}addLayer(e){this._layers.includes(e)||(this._model.addLayer(e),this._layers.push(e),this._model.dirtySet.layerAdded(e),this.renderView.requestRender())}removeLayer(e){e!=null&&!this.destroyed&&this._model.hasLayer(a(e))&&(this._model.dirtySet.layerRemoved(e),this.commitLayer(e),i(this._layers,e),this._model.dirtySet.assertLayerClean(e.id),this._model.removeLayer(e),this.renderView.requestRender())}getLayer(e){return this._model.getLayer(e)}handleEvent(e,t){this.destroyed||(this._model.dirtySet[e](t),this.renderView.requestRender())}get readyToRun(){return this._model.dirtySet.dirty||!this._asyncChangeSet.empty||this._canCompact.value}runTask(e){if(this._frameTask.processQueue(e),this._commit(e),this.renderer.compact(e),this._canCompact.value=this.renderer.canCompact,!e.hasProgressed)return d}compact(e){return this._canCompact.value=!1,this.renderer.compact(e)}_commit(e){let t=this._model.dirtySet;!this._asyncChangeSet.empty&&!e.done&&(this.renderer.commit(this._asyncChangeSet,e),this.renderView.requestRender(),e.madeProgress()),this._layers.forEach(n=>{if(e.done)return;let r=this._layerSyncSet.has(n.id)||n.updatePolicy===1,i=r?this._syncChangeSet:this._asyncChangeSet;t.commitLayer(n.id,i),this._layerSyncSet.delete(n.id),i.empty||(this.renderer.commit(i,r?u:e),this.renderView.requestRender(),e.madeProgress())}),this._syncChangeSet.empty||(this.renderer.commit(this._syncChangeSet,u),this.renderView.requestRender(),e.madeProgress()),this._layers.forEach(n=>{e.done||!this._layerSyncSet.has(n.id)&&n.updatePolicy===0&&(t.commitLayer(n.id,this._asyncChangeSet),this._asyncChangeSet.empty||(this.renderer.commit(this._asyncChangeSet,e),this.renderView.requestRender(),e.madeProgress()))}),this._layerSyncSet.clear(),this.notifyChange(`readyToRun`)}commitSyncLayers(){let e=this._model.dirtySet;this._layers.forEach(t=>{this._layerSyncSet.has(t.id)||t.updatePolicy===1?(e.commitLayer(t.id,this._syncChangeSet),this._layerSyncSet.delete(t.id)):e.commitSyncUpdates(t.id,this._syncChangeSet)});for(let t of this._layerSyncSet)e.commitLayer(t,this._syncChangeSet);this._layerSyncSet.clear(),this._syncChangeSet.empty||(this.renderer.commit(this._syncChangeSet,u),this.renderView.requestRender())}commitLayer(e){this._model.dirtySet.commitLayer(e.id,this._syncChangeSet),this._layerSyncSet.delete(e.id),this._syncChangeSet.empty||(this.renderer.commit(this._syncChangeSet,u),this.renderView.requestRender())}schedule(e,t){return this._frameTask.schedule(e,t)}reschedule(e,t){return this._frameTask.reschedule(e,t)}scheduleGenerator(e,t){return this._frameTask.scheduleGenerator(e,t)}syncLayer(e){this._layerSyncSet.add(e),this.renderView.requestRender()}get layers(){return this._layers}addRenderPlugin(e,t){let n=this.renderer.plugins.add(e,t),r=()=>{f(e)&&this.view.sceneIntersectionHelper.addIntersectionHandler(e)};if(s(n))return n.then(r);r()}removeRenderPlugin(e){this.destroyed||(f(e)&&this.view.sceneIntersectionHelper.removeIntersectionHandler(e),this.renderer.plugins.remove(e))}get test(){}};e([n({constructOnly:!0})],v.prototype,`view`,void 0),e([n({constructOnly:!0})],v.prototype,`options`,void 0),e([n({constructOnly:!0})],v.prototype,`container`,void 0),e([n()],v.prototype,`viewingMode`,null),e([n()],v.prototype,`updating`,null),e([n()],v.prototype,`renderView`,null),e([n()],v.prototype,`renderer`,null),e([n()],v.prototype,`textures`,null),e([n()],v.prototype,`readyToRun`,null),v=e([r(`esri.views.3d.webgl-engine.Stage`)],v);export{v as Stage};
2
+ import{__decorate as e}from"tslib";import t from"../../../core/Accessor.js";import{property as n,subclass as r}from"../../../core/accessorSupport/decorators.js";import{removeUnordered as i}from"../../../core/arrayUtils.js";import{toConst as a}from"../../../core/compilerUtils.js";import"../../../core/has.js";import{destroyMaybe as o}from"../../../core/maybe.js";import{isPromiseLike as s}from"../../../core/promiseUtils.js";import{signal as c}from"../../../core/signal.js";import{TaskPriority as l,noBudget as u}from"../../support/Scheduler.js";import{Yield as d}from"../../support/Yield.js";import{isIntersectionHandler as f}from"../state/helpers/SceneIntersectionHelper.js";import{debugFlags as p}from"../support/debugFlags.js";import{TextureCollection as m}from"../support/TextureCollection.js";import{ChangeSet as h}from"./lib/ChangeSet.js";import{Model as g}from"./parts/Model.js";import{RenderView as _}from"./parts/RenderView.js";let v=class extends t{constructor(e){super(e),this._model=new g,this._canCompact=c(!1),this._layers=[],this._asyncChangeSet=new h,this._syncChangeSet=new h,this._layerSyncSet=new Set,this._textures=new m(this,e.view.resourceController.scheduler),this._frameTask=e.view.resourceController.scheduler.registerTask(l.STAGE,this),this.addHandles(this._frameTask)}initialize(){this._renderView=new _({view:this.view},this)}destroy(){this.removeAllHandles(),this._textures.destroy(),this._set(`textures`,null),this._renderView=o(this._renderView),this._set(`renderView`,null),this._layers.length=0,this._model=null,this._set(`renderer`,null),this.options.context=null,this._set(`options`,null)}get isGlobal(){return this.view.state.isGlobal}get updating(){if(this.destroyed||this.destroying)return!1;let e=this.readyToRun||this.renderView.updating||this._frameTask.updating||this.textures.updating;return e&&p.UPDATING&&console.log(` Stage:`,this.readyToRun,this.renderView.updating,this._frameTask.updating,this.textures.updating),e}get localOriginFactory(){return this._model.localOriginFactory}get renderView(){return this._renderView}get renderer(){return this.renderView?.renderer}get textures(){return this._textures}addTexture(e){this._model.addTexture(e),this.renderView.requestRender()}removeTexture(e){e!=null&&!this.destroyed&&this._model.hasTexture(e)&&(this._model.removeTexture(e),this.renderView.requestRender())}addTextures(e){e!=null&&(this._model.addTextures(e),this.renderView.requestRender())}removeTextures(e){e!=null&&(this._model?.removeTextures(e),this.renderView.requestRender())}forEachTexture(e){this._model.forEachTexture(e)}getTexture(e){return this._model.getTexture(e)}addLayer(e){this._layers.includes(e)||(this._model.addLayer(e),this._layers.push(e),this._model.dirtySet.layerAdded(e),this.renderView.requestRender())}removeLayer(e){e!=null&&!this.destroyed&&this._model.hasLayer(a(e))&&(this._model.dirtySet.layerRemoved(e),this.commitLayer(e),i(this._layers,e),this._model.dirtySet.assertLayerClean(e.id),this._model.removeLayer(e),this.renderView.requestRender())}getLayer(e){return this._model.getLayer(e)}handleEvent(e,t){this.destroyed||(this._model.dirtySet[e](t),this.renderView.requestRender())}get readyToRun(){return this._model.dirtySet.dirty||!this._asyncChangeSet.empty||this._canCompact.value}runTask(e){if(this._frameTask.processQueue(e),this._commit(e),this.renderer.compact(e),this._canCompact.value=this.renderer.canCompact,!e.hasProgressed)return d}compact(e){return this._canCompact.value=!1,this.renderer.compact(e)}_commit(e){let t=this._model.dirtySet;!this._asyncChangeSet.empty&&!e.done&&(this.renderer.commit(this._asyncChangeSet,e),this.renderView.requestRender(),e.madeProgress()),this._layers.forEach(n=>{if(e.done)return;let r=this._layerSyncSet.has(n.id)||n.updatePolicy===1,i=r?this._syncChangeSet:this._asyncChangeSet;t.commitLayer(n.id,i),this._layerSyncSet.delete(n.id),i.empty||(this.renderer.commit(i,r?u:e),this.renderView.requestRender(),e.madeProgress())}),this._syncChangeSet.empty||(this.renderer.commit(this._syncChangeSet,u),this.renderView.requestRender(),e.madeProgress()),this._layers.forEach(n=>{e.done||!this._layerSyncSet.has(n.id)&&n.updatePolicy===0&&(t.commitLayer(n.id,this._asyncChangeSet),this._asyncChangeSet.empty||(this.renderer.commit(this._asyncChangeSet,e),this.renderView.requestRender(),e.madeProgress()))}),this._layerSyncSet.clear(),this.notifyChange(`readyToRun`)}commitSyncLayers(){let e=this._model.dirtySet;this._layers.forEach(t=>{this._layerSyncSet.has(t.id)||t.updatePolicy===1?(e.commitLayer(t.id,this._syncChangeSet),this._layerSyncSet.delete(t.id)):e.commitSyncUpdates(t.id,this._syncChangeSet)});for(let t of this._layerSyncSet)e.commitLayer(t,this._syncChangeSet);this._layerSyncSet.clear(),this._syncChangeSet.empty||(this.renderer.commit(this._syncChangeSet,u),this.renderView.requestRender())}commitLayer(e){this._model.dirtySet.commitLayer(e.id,this._syncChangeSet),this._layerSyncSet.delete(e.id),this._syncChangeSet.empty||(this.renderer.commit(this._syncChangeSet,u),this.renderView.requestRender())}schedule(e,t){return this._frameTask.schedule(e,t)}reschedule(e,t){return this._frameTask.reschedule(e,t)}scheduleGenerator(e,t){return this._frameTask.scheduleGenerator(e,t)}syncLayer(e){this._layerSyncSet.add(e),this.renderView.requestRender()}get layers(){return this._layers}addRenderPlugin(e,t){let n=this.renderer.plugins.add(e,t),r=()=>{f(e)&&this.view.sceneIntersectionHelper.addIntersectionHandler(e)};if(s(n))return n.then(r);r()}removeRenderPlugin(e){this.destroyed||(f(e)&&this.view.sceneIntersectionHelper.removeIntersectionHandler(e),this.renderer.plugins.remove(e))}get test(){}};e([n({constructOnly:!0})],v.prototype,`view`,void 0),e([n({constructOnly:!0})],v.prototype,`options`,void 0),e([n({constructOnly:!0})],v.prototype,`container`,void 0),e([n()],v.prototype,`isGlobal`,null),e([n()],v.prototype,`updating`,null),e([n()],v.prototype,`renderView`,null),e([n()],v.prototype,`renderer`,null),e([n()],v.prototype,`textures`,null),e([n()],v.prototype,`readyToRun`,null),v=e([r(`esri.views.3d.webgl-engine.Stage`)],v);export{v as Stage};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import{set as e}from"../../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as t}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{destroyMaybe as n}from"../../../../../core/maybe.js";import{create as r}from"../../../../../geometry/support/aaBoundingBox.js";import{defaultHighlightName as i}from"../../../../support/HighlightDefaults.js";import{encodeSymbolColor as a}from"../../../layers/support/symbolColorUtils.js";import{computeOffsetObb as o}from"../../../support/orientedBoundingBox.js";import{olidEnabled as s}from"../../effects/geometry/olidUtils.js";import{ComponentParametersUniform as c,ComponentParametersVarying as l}from"./ComponentDrawParameters.js";import{UniformComponentParameters as u}from"./UniformComponentParameters.js";class d{constructor(e,t,n,r,i,a,o=null){this._collection=e,this.transform=t,this.obb=n,this._componentData=r,this._renderable=i,this._intersectionGeometry=a,this._aabbInWorldCoordinates=o,this.visible=!1,this.offsetObb=null}destroy(){this._collection.materials.release(this._renderable.material),this._intersectionGeometry=n(this._intersectionGeometry),this._renderable=n(this._renderable),this._componentData=n(this._componentData)}get componentData(){return this._componentData}get renderable(){return this._renderable}get intersectionGeometry(){return this._intersectionGeometry}get emissions(){return this.renderable.material.emissions}updateMaterial(e,t){let{_renderable:n}=this,r=n.material,{opacity:i,useFloatBlend:a,...o}=e,s=i??n.opacity,c=this._collection.materials.acquire({...r.parameters,...o,groundTransparencyMode:e.groundTransparencyMode??r.parameters.groundTransparencyMode,isObjectTransparent:s<1},n.geometry.parameters,t??n.drawParameters.componentParameters);this._collection.materials.release(r),c!==r&&n.updateMaterial(c)}updatePolygonOffset(e){this._renderable.material.parameters.polygonOffset!==e&&this.updateMaterial({polygonOffset:e})}get opacity(){return this.renderable.opacity}updateOpacity(e,t){if(this.opacity===e){if(t===void 0||t===this.renderable.material.parameters.groundTransparencyMode)return}else this._renderable.updateOpacity(e);this.updateMaterial({opacity:e,groundTransparencyMode:t})}updateCameraDerivedParameters(e){let{eye:t}=e,{centerX:n,centerY:r,centerZ:i}=this.obb;this._renderable.meta.cameraDepthSquared=(t[0]-n)**2+(t[1]-r)**2+(t[2]-i)**2}setComponentData(e,t){let n=this._componentData,{materialDataBuffer:r,materialDataIndices:i}=n,d=new u,p=r.textureBuffer,m=p.getVec4Field(`colorAndCastShadows`),h=p.getScalarField(`elevationOffset`),g=p.getScalarField(`emissiveStrength`),_=p.getScalarField(`emissiveSourceMode`),v=p.getVec4Field(`olidColor`),y=new Uint8Array(4),b=new Uint32Array(y.buffer),x=0,S=0,C=0,w=0,T=0,E=n.verticalOffsets,D=1/0,O=-1/0,k=!1,A=!1,j=!1,M=0;for(let t=0;t<n.count;t++){e(t,d),x+=+(d.externalColor[3]<1),S+=+(d.externalColorMixMode===3&&d.externalColor[3]===1),w+=+(d.emissiveStrength>0),T+=+(d.emissiveSource===1),A||=d.emissiveStrength!==1,C+=+d.castShadows,a(d.externalColor,d.externalColorMixMode,y),y[2]=y[2]&254|d.castShadows,m.setArray(i[t],y),k||=t>0&&M!==b[0],M=b[0],j||=d.elevationOffset!==0,j&&E==null&&(E=Array(t).fill(0)),E!=null&&(E[t]=d.elevationOffset),D=Math.min(D,d.elevationOffset),O=Math.max(O,d.elevationOffset),h.set(i[t],d.elevationOffset),g.set(i[t],d.emissiveStrength),_.set(i[t],d.emissiveSource===0?0:255);let r=d.olidColor;r!=null&&v.setArray(i[t],r),d.pickable!==n.isPickable(t)&&n.updatePickabilityWithCount(t,d.pickable)}n.verticalOffsets=j?E:null,this.offsetObb=j?o(this.obb,D,O,t,this.offsetObb??this.obb.clone()):null;let N;if(k||j||s()||(A||T>0)&&w>0){let{count:e}=n;N=new l(f(x,e),f(S,e),f(w,e),f(T,e),f(C,e)),p.updateTexture(),this._renderable.updateComponentParametersVarying(N,p)}else N=new c(d.externalColor,d.externalColorMixMode,d.emissiveStrength,d.emissiveSource,d.castShadows?0:2),this._renderable.updateComponentParametersUniform(N);this.updateMaterial({},N)}addHighlight(e,t){return this._componentData.addComponentHighlight(e,t)}removeHighlight(e,t){return this._componentData.removeComponentHighlight(e,t)}clearHighlights(){this._componentData.clearHighlights()}get aabbInWorldCoordinates(){let e=this._aabbInWorldCoordinates;return e||(e=this._computeAabbInWorldCoordinates(),this._aabbInWorldCoordinates=e),e}_computeAabbInWorldCoordinates(){let t=r(),{positions:n}=this._intersectionGeometry;if(Math.floor(n.length/3)>0){let{transform:r}=this,i=1/0,a=1/0,o=1/0,s=-1/0,c=-1/0,l=-1/0,u=h;for(let t=0;t<n.length;t+=3)e(u,n[t+0],n[t+1],n[t+2]),r.applyVec3(u,u),i=Math.min(i,u[0]),a=Math.min(a,u[1]),o=Math.min(o,u[2]),s=Math.max(s,u[0]),c=Math.max(c,u[1]),l=Math.max(l,u[2]);t[0]=i,t[1]=a,t[2]=o,t[3]=s,t[4]=c,t[5]=l}return t}submit(e,t){let{componentData:n,renderable:r}=this;if(r.drawParameters.opacity<=0)return;let{geometry:a,drawParameters:o,material:s}=r,c=r.meta.cameraDepthSquared,{geometryRanges:l,highlightRangesMap:u,shadowmapRanges:d}=n;switch(s.materialPass){case 0:e.opaque.submitDraw(s,o,a,l,c);break;case 1:e.transparent.submitDraw(s,o,a,l,c);break;case 2:e.opaque.submitDraw(s,o,a,l,c),e.transparent.submitDraw(s,o,a,l,c);break;case 3:e.integratedMesh.submitDraw(s,o,a,l,c),p(t)&&e.occludedGround.submitDraw(s,o,a,l,c),s.parameters.integratedMeshSemantics.shouldDrapeFeatures&&m(t)&&e.highlightIntegratedMesh.submitDraw(s,o,a,l,c);break;case 4:e.transparentIntegratedMesh.submitDraw(s,o,a,l,c)}if(o.castAnyShadows){if(u!=null)for(let t of u)t[0]===i&&e.highlightShadowMap.submitDraw(s,o,a,t[1],c,t[0]);d!=null&&e.defaultShadowMap.submitDraw(s,o,a,d,c),e.shadowMap.submitDraw(s,o,a,l,c)}if(u!=null)for(let t of u)e.highlight.submitDraw(s,o,a,t[1],c,t[0]);t.viewshedEnabled&&e.viewshedShadowMap.submitDraw(s,o,a,l,c)}}function f(e,t){return e===t?0:e===0?2:1}function p(e){return e.overlay?.getTexture(e.overlay?.allSourcesOccluders?1:4)!=null}function m(e){return e.overlay?.getTexture(2)!=null}const h=t();export{d as ComponentObject};
2
+ import{set as e}from"../../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as t}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{destroyMaybe as n}from"../../../../../core/maybe.js";import{create as r}from"../../../../../geometry/support/aaBoundingBox.js";import{defaultHighlightName as i}from"../../../../support/HighlightDefaults.js";import{encodeSymbolColor as a}from"../../../layers/support/symbolColorUtils.js";import{computeOffsetObb as o}from"../../../support/orientedBoundingBox.js";import{olidEnabled as s}from"../../effects/geometry/olidUtils.js";import{ComponentParametersUniform as c,ComponentParametersVarying as l}from"./ComponentDrawParameters.js";import{UniformComponentParameters as u}from"./UniformComponentParameters.js";class d{constructor(e,t,n,r,i,a,o=null){this._collection=e,this.transform=t,this.obb=n,this._componentData=r,this._renderable=i,this._intersectionGeometry=a,this._aabbInWorldCoordinates=o,this.visible=!1,this.offsetObb=null}destroy(){this._collection.materials.release(this._renderable.material),this._intersectionGeometry=n(this._intersectionGeometry),this._renderable=n(this._renderable),this._componentData=n(this._componentData)}get componentData(){return this._componentData}get renderable(){return this._renderable}get intersectionGeometry(){return this._intersectionGeometry}get emissions(){return this.renderable.material.emissions}updateMaterial(e,t){let{_renderable:n}=this,r=n.material,{opacity:i,useFloatBlend:a,...o}=e,s=i??n.opacity,c=this._collection.materials.acquire({...r.parameters,...o,groundTransparencyMode:e.groundTransparencyMode??r.parameters.groundTransparencyMode,isObjectTransparent:s<1},n.geometry.parameters,t??n.drawParameters.componentParameters);this._collection.materials.release(r),c!==r&&n.updateMaterial(c)}updatePolygonOffset(e){this._renderable.material.parameters.polygonOffset!==e&&this.updateMaterial({polygonOffset:e})}get opacity(){return this.renderable.opacity}updateOpacity(e,t){if(this.opacity===e){if(t===void 0||t===this.renderable.material.parameters.groundTransparencyMode)return}else this._renderable.updateOpacity(e);this.updateMaterial({opacity:e,groundTransparencyMode:t})}updateCameraDerivedParameters(e){let{eye:t}=e,{centerX:n,centerY:r,centerZ:i}=this.obb;this._renderable.meta.cameraDepthSquared=(t[0]-n)**2+(t[1]-r)**2+(t[2]-i)**2}setComponentData(e,t){let n=this._componentData,{materialDataBuffer:r,materialDataIndices:i}=n,d=new u,p=r.textureBuffer,m=p.getVec4Field(`colorAndCastShadows`),h=p.getScalarField(`elevationOffset`),g=p.getScalarField(`emissiveStrength`),_=p.getScalarField(`emissiveSourceMode`),v=p.getVec4Field(`olidColor`),y=new Uint8Array(4),b=new Uint32Array(y.buffer),x=0,S=0,C=0,w=0,T=0,E=n.verticalOffsets,D=1/0,O=-1/0,k=!1,A=!1,j=!1,M=0;for(let t=0;t<n.count;t++){e(t,d),x+=+(d.externalColor[3]<1),S+=+(d.externalColorMixMode===3&&d.externalColor[3]===1),w+=+(d.emissiveStrength>0),T+=+(d.emissiveSource===1),A||=d.emissiveStrength!==1,C+=+d.castShadows,a(d.externalColor,d.externalColorMixMode,y),y[2]=y[2]&254|d.castShadows,m.setArray(i[t],y),k||=t>0&&M!==b[0],M=b[0],j||=d.elevationOffset!==0,j&&E==null&&(E=Array(t).fill(0)),E!=null&&(E[t]=d.elevationOffset),D=Math.min(D,d.elevationOffset),O=Math.max(O,d.elevationOffset),h.set(i[t],d.elevationOffset),g.set(i[t],d.emissiveStrength),_.set(i[t],d.emissiveSource===0?0:255);let r=d.olidColor;r!=null&&v.setArray(i[t],r),d.pickable!==n.isPickable(t)&&n.updatePickabilityWithCount(t,d.pickable)}n.verticalOffsets=j?E:null,this.offsetObb=j?o(this.obb,D,O,t,this.offsetObb??this.obb.clone()):null;let N;if(k||j||s()||(A||T>0)&&w>0){let{count:e}=n;N=new l(f(x,e),f(S,e),f(w,e),f(T,e),f(C,e)),p.updateTexture(),this._renderable.updateComponentParametersVarying(N,p)}else N=new c(d.externalColor,d.externalColorMixMode,d.emissiveStrength,d.emissiveSource,d.castShadows?0:2),this._renderable.updateComponentParametersUniform(N);this.updateMaterial({},N)}addHighlight(e,t){return this._componentData.addComponentHighlight(e,t)}removeHighlight(e,t){return this._componentData.removeComponentHighlight(e,t)}clearHighlights(){this._componentData.clearHighlights()}get aabbInWorldCoordinates(){let e=this._aabbInWorldCoordinates;return e||(e=this._computeAabbInWorldCoordinates(),this._aabbInWorldCoordinates=e),e}_computeAabbInWorldCoordinates(){let t=r(),{positions:n}=this._intersectionGeometry;if(Math.floor(n.length/3)>0){let{transform:r}=this,i=1/0,a=1/0,o=1/0,s=-1/0,c=-1/0,l=-1/0,u=h;for(let t=0;t<n.length;t+=3)e(u,n[t+0],n[t+1],n[t+2]),r.applyVec3(u,u),i=Math.min(i,u[0]),a=Math.min(a,u[1]),o=Math.min(o,u[2]),s=Math.max(s,u[0]),c=Math.max(c,u[1]),l=Math.max(l,u[2]);t[0]=i,t[1]=a,t[2]=o,t[3]=s,t[4]=c,t[5]=l}return t}submit(e,t){let{componentData:n,renderable:r}=this;if(r.drawParameters.opacity<=0)return;let{geometry:a,drawParameters:o,material:s}=r,c=r.meta.cameraDepthSquared,{geometryRanges:l,highlightRangesMap:u,shadowmapRanges:d}=n;switch(s.materialPass){case 0:e.opaque.submitDraw(s,o,a,l,c);break;case 1:e.transparent.submitDraw(s,o,a,l,c);break;case 2:e.opaque.submitDraw(s,o,a,l,c),e.transparent.submitDraw(s,o,a,l,c);break;case 3:e.integratedMesh.submitDraw(s,o,a,l,c),p(t)&&e.occludedGround.submitDraw(s,o,a,l,c),s.parameters.integratedMeshSemantics.shouldDrape&&m(t)&&e.highlightIntegratedMesh.submitDraw(s,o,a,l,c);break;case 4:e.transparentIntegratedMesh.submitDraw(s,o,a,l,c)}if(o.castAnyShadows){if(u!=null)for(let t of u)t[0]===i&&e.highlightShadowMap.submitDraw(s,o,a,t[1],c,t[0]);d!=null&&e.defaultShadowMap.submitDraw(s,o,a,d,c),e.shadowMap.submitDraw(s,o,a,l,c)}if(u!=null)for(let t of u)e.highlight.submitDraw(s,o,a,t[1],c,t[0]);t.viewshedEnabled&&e.viewshedShadowMap.submitDraw(s,o,a,l,c)}}function f(e,t){return e===t?0:e===0?2:1}function p(e){return e.overlay?.getTexture(e.overlay?.allSourcesOccluders?1:4)!=null}function m(e){return e.overlay?.getTexture(2)!=null}const h=t();export{d as ComponentObject};