@arcgis/core 6.0.0-next.26 → 6.0.0-next.28

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 (343) hide show
  1. package/Map.d.ts +6 -0
  2. package/analysis/AreaMeasurementAnalysis.d.ts +4 -2
  3. package/analysis/DirectLineMeasurementAnalysis.d.ts +8 -4
  4. package/assets/esri/core/workers/RemoteClient.js +1 -1
  5. package/assets/esri/core/workers/chunks/0363d29fc665d169ebc4.js +1 -0
  6. package/assets/esri/core/workers/chunks/037c67ef5c4398d5954d.js +1 -0
  7. package/assets/esri/core/workers/chunks/03f33cb78b5405ab7e23.js +1 -0
  8. package/assets/esri/core/workers/chunks/07b726a46864501b90a0.js +1 -0
  9. package/assets/esri/core/workers/chunks/0864da8f8f147016cf1c.js +1 -0
  10. package/assets/esri/core/workers/chunks/{768389f7f8dba6080df7.js → 0cc7fba402a93e6d2455.js} +2 -2
  11. package/assets/esri/core/workers/chunks/0cfdeb53fb7d5532cf01.js +1 -0
  12. package/assets/esri/core/workers/chunks/112ed86f812e4400a7e0.js +1 -0
  13. package/assets/esri/core/workers/chunks/177f353ce72133e2eeed.js +1 -0
  14. package/assets/esri/core/workers/chunks/1dc6f093028530a492e6.js +1 -0
  15. package/assets/esri/core/workers/chunks/2294254af2c6afb560ee.js +1 -0
  16. package/assets/esri/core/workers/chunks/23a4806b4cdf7cc32e4d.js +1 -0
  17. package/assets/esri/core/workers/chunks/2447d2e2a4a3ab8fcf94.js +1 -0
  18. package/assets/esri/core/workers/chunks/271ae7deccb94112c2df.js +1 -0
  19. package/assets/esri/core/workers/chunks/2df37a9a95ceebb87a5f.js +1 -0
  20. package/assets/esri/core/workers/chunks/2e00c155e447e4930442.js +1 -0
  21. package/assets/esri/core/workers/chunks/2e9a1673b1d51aa082b6.js +1 -0
  22. package/assets/esri/core/workers/chunks/344f5334ad95c7974349.js +1 -0
  23. package/assets/esri/core/workers/chunks/348f1def9cd2ddf92e87.js +1 -0
  24. package/assets/esri/core/workers/chunks/{8e4206068c6953bb7df2.js → 3a47fc97c400fca2c736.js} +1 -1
  25. package/assets/esri/core/workers/chunks/47c97640ec525676918b.js +1 -0
  26. package/assets/esri/core/workers/chunks/50763ea061d5fb3f2e49.js +1 -0
  27. package/assets/esri/core/workers/chunks/518ab22f80c3300bcfff.js +1 -0
  28. package/assets/esri/core/workers/chunks/58609bf94f72bc4f1952.js +1 -0
  29. package/assets/esri/core/workers/chunks/586a929bc037e23857af.js +1 -0
  30. package/assets/esri/core/workers/chunks/58d10e0b35968680fd9f.js +1 -0
  31. package/assets/esri/core/workers/chunks/59bc55880e6fd8ce20c0.js +1 -0
  32. package/assets/esri/core/workers/chunks/{7c75a8ee266c36baa902.js → 5eec1c1162779574f46e.js} +1 -1
  33. package/assets/esri/core/workers/chunks/62a0abcf45a2bd14ecbe.js +1 -0
  34. package/assets/esri/core/workers/chunks/63c4412c16d8a44a5668.js +1 -0
  35. package/assets/esri/core/workers/chunks/6b4c3411f63a9ad9354c.js +1 -0
  36. package/assets/esri/core/workers/chunks/{f528ac5c648ca6a98582.js → 711cfb84659cb4437679.js} +1 -1
  37. package/assets/esri/core/workers/chunks/{9dd1fc56eb1ea6eb705e.js → 76e27e36050a3dd9d249.js} +1 -1
  38. package/assets/esri/core/workers/chunks/76f877e2d2493d56afab.js +1 -0
  39. package/assets/esri/core/workers/chunks/77463141652bf1ca6fb2.js +1 -0
  40. package/assets/esri/core/workers/chunks/7d3f7940815fa5dc244e.js +1 -0
  41. package/assets/esri/core/workers/chunks/914a0b5d9fef683cdf9c.js +1 -0
  42. package/assets/esri/core/workers/chunks/96f87c8efd4b11b37686.js +1 -0
  43. package/assets/esri/core/workers/chunks/97ec46605f16333144b7.js +1 -0
  44. package/assets/esri/core/workers/chunks/{7b482afb9fd1229f5707.js → 9934e8e19f94e9169eea.js} +1 -1
  45. package/assets/esri/core/workers/chunks/99f51d5d9da6e9bfc430.js +1 -0
  46. package/assets/esri/core/workers/chunks/9aebe876b1a2fb075f9c.js +1 -0
  47. package/assets/esri/core/workers/chunks/9c3db7a7c05fa0e81f0a.js +1 -0
  48. package/assets/esri/core/workers/chunks/{6f1d6453184e0a1530ad.js → 9c4961213ac6ec283dd9.js} +25 -25
  49. package/assets/esri/core/workers/chunks/a2cc53ad1a514167e4b8.js +1 -0
  50. package/assets/esri/core/workers/chunks/a33ba23aee3f8f40200f.js +1 -0
  51. package/assets/esri/core/workers/chunks/{45ba4aa87a4732198596.js → b13d8f4e4e80ef00b1bd.js} +1 -1
  52. package/assets/esri/core/workers/chunks/b3801d58c024224917df.js +1 -0
  53. package/assets/esri/core/workers/chunks/b3aa29589dcfb5b93106.js +1 -0
  54. package/assets/esri/core/workers/chunks/b3dbcf43f136ba2dadc5.js +1 -0
  55. package/assets/esri/core/workers/chunks/b9596d862da1ec342cd3.js +1 -0
  56. package/assets/esri/core/workers/chunks/bc1fcc9c897461e68e29.js +1 -0
  57. package/assets/esri/core/workers/chunks/{8b4e9fd88c0c313416d4.js → be04f40f8b403befd0ef.js} +1 -1
  58. package/assets/esri/core/workers/chunks/{150e7a7bd5df25693da7.js → c90388932a7825d9d933.js} +1 -1
  59. package/assets/esri/core/workers/chunks/ca21786e519c914fc9e1.js +1 -0
  60. package/assets/esri/core/workers/chunks/cdb5c26fed7d9a97db49.js +1 -0
  61. package/assets/esri/core/workers/chunks/cdf0c7706d3e1221f49b.js +1 -0
  62. package/assets/esri/core/workers/chunks/d63e181f0e48bde73395.js +1 -0
  63. package/assets/esri/core/workers/chunks/d77888c84a8b49478807.js +1 -0
  64. package/assets/esri/core/workers/chunks/d7f2f1708d2a2668676c.js +1 -0
  65. package/assets/esri/core/workers/chunks/{13c64087be3b2985a21b.js → dbda982485d3fe26c729.js} +1 -1
  66. package/assets/esri/core/workers/chunks/dc7aa0a1eb6c6e361f9f.js +1 -0
  67. package/assets/esri/core/workers/chunks/ec1c4d66142b6efb0e8b.js +1 -0
  68. package/assets/esri/core/workers/chunks/ef2c3febcceedc44b3ac.js +1 -0
  69. package/assets/esri/core/workers/chunks/f08a2a262a3b55149396.js +1 -0
  70. package/assets/esri/core/workers/chunks/f2d56f5c15d5977e1d19.js +1 -0
  71. package/assets/esri/core/workers/chunks/ffe2077a9df7c838ea27.js +1 -0
  72. package/assets/esri/layers/raster/formats/lerc-wasm.wasm +0 -0
  73. package/chunks/BlendLayers.glsl.js +1 -1
  74. package/chunks/Component.glsl.js +9 -12
  75. package/chunks/GaussianSplat.glsl.js +65 -21
  76. package/chunks/GaussianSplatDepth.glsl.js +45 -4
  77. package/chunks/GaussianSplatShadow.glsl.js +73 -19
  78. package/chunks/GlobalIllumination.glsl.js +17 -47
  79. package/chunks/LineMarker.glsl.js +32 -31
  80. package/chunks/OITAddEmission.glsl.js +1 -1
  81. package/chunks/RasterColorizer.glsl.js +1 -1
  82. package/chunks/RibbonLine.glsl.js +36 -36
  83. package/chunks/Terrain.glsl.js +3 -4
  84. package/chunks/Water.glsl.js +22 -23
  85. package/config.js +1 -1
  86. package/core/ReentrantObjectPool.js +1 -1
  87. package/core/memoryEstimations.js +1 -1
  88. package/core/workers/workers.js +2 -2
  89. package/core/workers.d.ts +1 -1
  90. package/form/elements/inputs/DynamicChoiceInput.d.ts +2 -2
  91. package/form/elements/inputs.d.ts +126 -25
  92. package/form/elements/inputs.js +1 -1
  93. package/form/elements.d.ts +1 -0
  94. package/geometry/operators/containsOperator.d.ts +1 -1
  95. package/geometry/operators/densifyOperator.d.ts +1 -1
  96. package/geometry/operators/differenceOperator.d.ts +6 -4
  97. package/geometry/operators/distanceOperator.d.ts +1 -1
  98. package/geometry/operators/geodesicProximityOperator.d.ts +8 -8
  99. package/geometry/operators/graphicBufferOperator.d.ts +6 -6
  100. package/geometry/operators/integrateOperator.d.ts +2 -2
  101. package/geometry/operators/intersectsOperator.d.ts +3 -3
  102. package/geometry/operators/linesToPolygonsOperator.d.ts +2 -2
  103. package/geometry/operators/locateBetweenOperator.d.ts +2 -2
  104. package/geometry/operators/minimumBoundingCircleOperator.d.ts +1 -1
  105. package/geometry/operators/multiPartToSinglePartOperator.d.ts +2 -2
  106. package/geometry/operators/polygonSlicerOperator.d.ts +2 -2
  107. package/geometry/operators/projectOperator.d.ts +2 -2
  108. package/geometry/operators/proximityOperator.d.ts +15 -15
  109. package/geometry/operators/shapePreservingProjectOperator.d.ts +2 -2
  110. package/geometry/operators/simplifyOperator.d.ts +2 -2
  111. package/geometry/operators/support/GeographicTransformationStep.d.ts +3 -3
  112. package/geometry/operators/support/Transformation.d.ts +8 -8
  113. package/geometry/operators/support/geographicTransformationUtils.d.ts +3 -3
  114. package/geometry/operators/symmetricDifferenceOperator.d.ts +2 -2
  115. package/geometry/operators/withinOperator.d.ts +3 -3
  116. package/geometry/support/Indices.js +1 -1
  117. package/graphic/MapNotesGraphicOrigin.d.ts +1 -0
  118. package/kernel.js +1 -1
  119. package/layers/GeospatialPDFLayer.d.ts +2 -2
  120. package/layers/GeospatialPDFLayer.js +1 -1
  121. package/layers/MapNotesLayer.d.ts +3 -2
  122. package/layers/ParquetLayer.d.ts +1 -1
  123. package/layers/VectorTileLayer.d.ts +10 -1
  124. package/layers/buildingSublayers/BuildingGroupSublayer.d.ts +2 -1
  125. package/layers/geospatialPDF/CIM2DLayerview.js +2 -0
  126. package/layers/geospatialPDF/GeospatialPDFFrame.js +1 -1
  127. package/layers/graphics/sources/support/ParquetSourceWorker.js +1 -1
  128. package/layers/mixins/SublayersOwner.js +1 -1
  129. package/layers/orientedImagery/transformations/imageToWorld.js +1 -1
  130. package/layers/orientedImagery/transformations/rectifyMapPoint.js +1 -1
  131. package/layers/support/Sublayer.d.ts +2 -2
  132. package/layers/support/Sublayer.js +1 -1
  133. package/layers/support/SubtypeSublayer.js +1 -1
  134. package/layers/support/layerUtils.js +1 -1
  135. package/package.json +3 -3
  136. package/popup/FeaturesModel.js +1 -1
  137. package/popup/support/featureUtils.js +1 -1
  138. package/rest/featureService/FeatureService.d.ts +0 -5
  139. package/rest/networks/support/TraceLocation.d.ts +2 -1
  140. package/rest/networks/support/TraceResult.d.ts +0 -4
  141. package/rest/support/AttributeBinsQuery.d.ts +3 -2
  142. package/rest/support/ImageGPSInfoParameters.d.ts +2 -1
  143. package/rest/support/OutDistance.d.ts +2 -2
  144. package/rest/support/Query.d.ts +3 -2
  145. package/rest/support/TopFeaturesQuery.d.ts +2 -1
  146. package/rest/support/types.d.ts +10 -1
  147. package/smartMapping/raster/renderers/flow.d.ts +2 -1
  148. package/smartMapping/renderers/color.d.ts +11 -8
  149. package/smartMapping/renderers/location.d.ts +7 -4
  150. package/smartMapping/renderers/predominance.d.ts +7 -4
  151. package/smartMapping/renderers/relationship.d.ts +7 -4
  152. package/smartMapping/renderers/size.d.ts +6 -4
  153. package/smartMapping/renderers/type.d.ts +7 -4
  154. package/smartMapping/renderers/types.d.ts +15 -0
  155. package/smartMapping/renderers/univariateColorSize.d.ts +4 -2
  156. package/smartMapping/statistics/histogramForTimeSeries.js +1 -1
  157. package/smartMapping/statistics/summaryStatisticsForTimeSeries.js +1 -1
  158. package/smartMapping/symbology/flow.d.ts +2 -1
  159. package/smartMapping/symbology/types.d.ts +2 -1
  160. package/support/BasemapStyle.d.ts +2 -2
  161. package/symbols/cim/CIMCursor.js +1 -1
  162. package/symbols/cim/types.d.ts +7 -9
  163. package/tables/elements.d.ts +1 -0
  164. package/views/2d/engine/vectorTiles/TileHandler3D.js +1 -1
  165. package/views/2d/engine/webgl/animations/instructions.js +1 -1
  166. package/views/2d/engine/webgl/shaderGraph/techniques/animated/AnimatedMarkerMeshWriter.js +1 -1
  167. package/views/2d/engine/webgl/shaderGraph/techniques/mesh/MeshWriterVertexPack.js +1 -1
  168. package/views/2d/engine/webgl/textureUtils.js +1 -1
  169. package/views/2d/layers/GeospatialPDFLayerView2D.js +1 -1
  170. package/views/2d/layers/MediaLayerView2D.js +1 -1
  171. package/views/2d/layers/TileLayerView2D.js +1 -1
  172. package/views/2d/layers/features/schema/processor/symbols/ComplexSymbolSchema.js +1 -1
  173. package/views/3d/analysis/AreaMeasurement/support/AreaMeasurementPathHelper.js +1 -1
  174. package/views/3d/analysis/AreaMeasurement/support/MeasurementData.js +1 -1
  175. package/views/3d/analysis/DirectLineMeasurement/DirectLineMeasurementController.js +1 -1
  176. package/views/3d/analysis/support/projectionUtils.js +1 -1
  177. package/views/3d/environment/SunLighting.d.ts +15 -2
  178. package/views/3d/environment/VirtualLighting.d.ts +15 -2
  179. package/views/3d/input/SceneInputManager.js +1 -1
  180. package/views/3d/input/handlers/ground/GroundMouseWheelMove.js +2 -0
  181. package/views/3d/interactive/editingTools/reshape/ReshapeOperation.js +1 -1
  182. package/views/3d/interactive/measurementTools/directLineMeasurement3D/DirectLineMeasurement3DTool.js +1 -1
  183. package/views/3d/interactive/measurementTools/directLineMeasurement3D/DirectLineMeasurement3DView.js +1 -1
  184. package/views/3d/layers/GeospatialPDFLayerView3D.js +1 -1
  185. package/views/3d/layers/ImageryTileLayerView3D.js +1 -1
  186. package/views/3d/layers/graphics/Graphics3DBufferGraphicLayer.js +1 -1
  187. package/views/3d/layers/graphics/Graphics3DCore.js +1 -1
  188. package/views/3d/layers/graphics/Graphics3DDrapedGraphicLayerBase.js +1 -1
  189. package/views/3d/layers/graphics/Graphics3DExtrudeSymbolLayer.js +1 -1
  190. package/views/3d/layers/graphics/Graphics3DFeatureStore.js +1 -1
  191. package/views/3d/layers/graphics/Graphics3DGraphic.js +1 -1
  192. package/views/3d/layers/graphics/Graphics3DGraphicCreationContext.js +1 -1
  193. package/views/3d/layers/graphics/Graphics3DLodInstanceGraphicLayer.js +1 -1
  194. package/views/3d/layers/graphics/Graphics3DMeshObject3DGraphicLayer.js +1 -1
  195. package/views/3d/layers/graphics/Graphics3DObject3DGraphicLayer.js +1 -1
  196. package/views/3d/layers/graphics/Graphics3DStageObjectGraphicLayer.js +1 -1
  197. package/views/3d/layers/graphics/Graphics3DSymbol.js +1 -1
  198. package/views/3d/layers/graphics/Labeler.js +1 -1
  199. package/views/3d/layers/graphics/defaultSymbolComplexity.js +1 -1
  200. package/views/3d/layers/support/FeatureTileFetcher3D.js +1 -1
  201. package/views/3d/layers/support/StageLayerElevationProvider.js +1 -1
  202. package/views/3d/layers/support/featureReference.js +1 -1
  203. package/views/3d/navigation/Navigation3D.js +1 -1
  204. package/views/3d/state/controllers/GroundMouseWheelController.js +2 -0
  205. package/views/3d/state/utils/OffsetCorrectionController.js +1 -1
  206. package/views/3d/state/utils/groundNavigationUtils.js +1 -1
  207. package/views/3d/terrain/BlendLayers.glsl.js +1 -1
  208. package/views/3d/terrain/PatchRenderData.js +1 -1
  209. package/views/3d/terrain/RasterColorizer.glsl.js +1 -1
  210. package/views/3d/terrain/TerrainData.js +1 -1
  211. package/views/3d/terrain/TerrainRenderer.js +1 -1
  212. package/views/3d/terrain/TerrainSurface.js +1 -1
  213. package/views/3d/terrain/TextureFader.js +1 -1
  214. package/views/3d/terrain/TextureReference.js +1 -1
  215. package/views/3d/terrain/TileCompositor.js +1 -1
  216. package/views/3d/terrain/TileRenderInfo.js +1 -1
  217. package/views/3d/terrain/TileRenderer.js +1 -1
  218. package/views/3d/terrain/terrainUtils.js +1 -1
  219. package/views/3d/webgl-engine/core/shaderLibrary/attributes/VertexTangent.glsl.js +7 -8
  220. package/views/3d/webgl-engine/core/shaderLibrary/shading/EvaluateSceneLighting.glsl.js +25 -25
  221. package/views/3d/webgl-engine/core/shaderLibrary/shading/NormalUtils.glsl.js +3 -5
  222. package/views/3d/webgl-engine/core/shaderLibrary/shading/forwardLocalUp.glsl.js +6 -0
  223. package/views/3d/webgl-engine/core/shaderLibrary/shading/getLocalUp.glsl.js +4 -0
  224. package/views/3d/webgl-engine/core/shaderLibrary/terrain/TerrainTexture.glsl.js +1 -1
  225. package/views/3d/webgl-engine/core/shaderLibrary/terrain/{TileBackground.glsl.js → blendLayers.glsl.js} +10 -11
  226. package/views/3d/webgl-engine/core/shaderLibrary/util/GaussianSplatEvaluation.glsl.js +8 -2
  227. package/views/3d/webgl-engine/core/shaderLibrary/util/cameraUniforms.js +1 -1
  228. package/views/3d/webgl-engine/effects/globalIllumination/GlobalIllumination.glsl.js +1 -1
  229. package/views/3d/webgl-engine/effects/globalIllumination/GlobalIllumination.js +1 -1
  230. package/views/3d/webgl-engine/effects/globalIllumination/GlobalIlluminationTechniqueConfiguration.js +1 -1
  231. package/views/3d/webgl-engine/lib/BindParameters.js +1 -1
  232. package/views/3d/webgl-engine/lib/BoundingInfo.js +1 -1
  233. package/views/3d/webgl-engine/lib/BufferGeometry.js +1 -1
  234. package/views/3d/webgl-engine/lib/BufferObject3D.js +1 -1
  235. package/views/3d/webgl-engine/lib/DirtyEvents.js +1 -1
  236. package/views/3d/webgl-engine/lib/Geometry.js +1 -1
  237. package/views/3d/webgl-engine/lib/ManagedTexture.js +1 -1
  238. package/views/3d/webgl-engine/lib/ModelDirtySet.js +1 -1
  239. package/views/3d/webgl-engine/lib/Object3D.js +1 -1
  240. package/views/3d/webgl-engine/lib/PathGeometry.js +1 -1
  241. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  242. package/views/3d/webgl-engine/lib/TextureBackedBuffer/TextureBuffer.js +1 -1
  243. package/views/3d/webgl-engine/lib/edgeRendering/EdgeView.js +1 -1
  244. package/views/3d/webgl-engine/lib/geometryMemoryUtils.js +2 -0
  245. package/views/3d/webgl-engine/materials/Water.glsl.js +1 -1
  246. package/views/3d/webgl-engine/shaders/GaussianSplat.glsl.js +1 -1
  247. package/views/3d/webgl-engine/shaders/GaussianSplatDepth.glsl.js +1 -1
  248. package/views/3d/webgl-engine/shaders/GaussianSplatPass.glsl.js +61 -108
  249. package/views/3d/webgl-engine/shaders/GaussianSplatShadow.glsl.js +1 -1
  250. package/views/3d/webgl-engine/shaders/LineMarker.glsl.js +1 -1
  251. package/views/3d/webgl-engine/shaders/RibbonLine.glsl.js +1 -1
  252. package/views/3d/webgl-engine/shaders/Terrain.glsl.js +1 -1
  253. package/views/VideoView.js +1 -1
  254. package/views/draw/DrawOperation.js +1 -1
  255. package/views/draw/DrawScreenTool.js +1 -1
  256. package/views/input/types.d.ts +2 -4
  257. package/views/interactive/options/LabelOptions.d.ts +5 -5
  258. package/views/interactive/options/SnappingOptions.d.ts +2 -2
  259. package/views/selection/SelectionOperation.js +1 -1
  260. package/views/selection/types.d.ts +43 -3
  261. package/views/support/layerViewUtils.js +1 -1
  262. package/views/support/selectionUtils.js +1 -1
  263. package/widgets/BatchAttributeForm/inputs/FieldInput.d.ts +0 -1
  264. package/widgets/Editor/VisibleElements.d.ts +4 -0
  265. package/widgets/Editor.d.ts +2 -0
  266. package/widgets/FeatureTable.js +1 -1
  267. package/widgets/Features/FeaturesViewModel.js +1 -1
  268. package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
  269. package/widgets/OrientedImageryViewer/adapters/view/SceneViewAdapter.js +1 -1
  270. package/widgets/OrientedImageryViewer/services/SuperimposeService.js +1 -1
  271. package/widgets/OrientedImageryViewer/support/NonPanoramicMedia.js +1 -1
  272. package/widgets/OrientedImageryViewer/support/dataCaptureUtils.js +1 -1
  273. package/widgets/OrientedImageryViewer.js +2 -2
  274. package/widgets/PanoramicViewer/utils.js +1 -1
  275. package/widgets/Print.js +1 -1
  276. package/widgets/Search/LayerSearchSource.d.ts +1 -1
  277. package/widgets/Sketch/VisibleElements.d.ts +4 -0
  278. package/widgets/Sketch.d.ts +2 -0
  279. package/widgets/support/SelectionList/GroupLayerItem.d.ts +6 -0
  280. package/widgets/support/SelectionList/GroupLayerItem.js +1 -1
  281. package/widgets/support/SelectionList/ItemBase.js +1 -1
  282. package/widgets/support/SelectionToolbar/SelectionToolbarViewModel.d.ts +6 -1
  283. package/widgets/support/SelectionToolbar/SelectionToolbarViewModel.js +1 -1
  284. package/widgets/support/SelectionToolbar.d.ts +8 -1
  285. package/widgets/support/SelectionToolbar.js +1 -1
  286. package/widgets/support/Selector2D/selectorUtils.js +1 -1
  287. package/assets/esri/core/workers/chunks/0320cbd825f9a4222042.js +0 -1
  288. package/assets/esri/core/workers/chunks/067de1910190da228291.js +0 -1
  289. package/assets/esri/core/workers/chunks/09bd5df07eab80ae7b15.js +0 -1
  290. package/assets/esri/core/workers/chunks/164e74d586297946a717.js +0 -1
  291. package/assets/esri/core/workers/chunks/1c0c5cb13c2590aae906.js +0 -1
  292. package/assets/esri/core/workers/chunks/1c77de1e79860f8d2228.js +0 -1
  293. package/assets/esri/core/workers/chunks/24dac4970526a4e0ae63.js +0 -1
  294. package/assets/esri/core/workers/chunks/2acf2952cef69e382a35.js +0 -1
  295. package/assets/esri/core/workers/chunks/30dcf2cfb31cb70de7df.js +0 -1
  296. package/assets/esri/core/workers/chunks/371e2ddb88cc6b9a41e8.js +0 -1
  297. package/assets/esri/core/workers/chunks/42f6194633c2d879c8da.js +0 -1
  298. package/assets/esri/core/workers/chunks/44f90e75c1dc3d726a95.js +0 -1
  299. package/assets/esri/core/workers/chunks/4abd3753cd9b80e4d937.js +0 -1
  300. package/assets/esri/core/workers/chunks/4bb9a5f4ca944d3fc206.js +0 -1
  301. package/assets/esri/core/workers/chunks/4c389472b8cdb0c55154.js +0 -1
  302. package/assets/esri/core/workers/chunks/4d93bed14945e3d34d5c.js +0 -1
  303. package/assets/esri/core/workers/chunks/4e3f651ac76fcd53df2b.js +0 -1
  304. package/assets/esri/core/workers/chunks/505227797bcf2a1d908d.js +0 -1
  305. package/assets/esri/core/workers/chunks/58da3f8cf0f7f6a7e4fa.js +0 -1
  306. package/assets/esri/core/workers/chunks/5a19a9c3e01d3d415188.js +0 -1
  307. package/assets/esri/core/workers/chunks/5a830bc35adbedd33783.js +0 -1
  308. package/assets/esri/core/workers/chunks/6db0f8fe1402643fbe1a.js +0 -1
  309. package/assets/esri/core/workers/chunks/7124ad8dc5ad40dc66f3.js +0 -1
  310. package/assets/esri/core/workers/chunks/7446d0dfebf93e86c098.js +0 -1
  311. package/assets/esri/core/workers/chunks/7c631e2947243e2c9bde.js +0 -1
  312. package/assets/esri/core/workers/chunks/7f0f9dddc44b1f1600f0.js +0 -1
  313. package/assets/esri/core/workers/chunks/7fb7493f483cd9878bfa.js +0 -1
  314. package/assets/esri/core/workers/chunks/8e310e9cb9d84ac3ca2f.js +0 -1
  315. package/assets/esri/core/workers/chunks/950d4578dc450467404c.js +0 -1
  316. package/assets/esri/core/workers/chunks/99a0a434ea2162166754.js +0 -1
  317. package/assets/esri/core/workers/chunks/9afc87474cef1fc4fe4a.js +0 -1
  318. package/assets/esri/core/workers/chunks/9cbde13e536676767900.js +0 -1
  319. package/assets/esri/core/workers/chunks/9cd3fcb5fca6f9dbbcd8.js +0 -1
  320. package/assets/esri/core/workers/chunks/a025ee38d402504193df.js +0 -1
  321. package/assets/esri/core/workers/chunks/a4b822ee45810c4c292a.js +0 -1
  322. package/assets/esri/core/workers/chunks/a51576d84edca88e41dd.js +0 -1
  323. package/assets/esri/core/workers/chunks/ac24b4370dc7194a3107.js +0 -1
  324. package/assets/esri/core/workers/chunks/ace41659a5ca0e5abfc3.js +0 -1
  325. package/assets/esri/core/workers/chunks/b01804aa6c47a220a603.js +0 -1
  326. package/assets/esri/core/workers/chunks/b3273f847405799e3362.js +0 -1
  327. package/assets/esri/core/workers/chunks/ba3d5abff65aefcb8dee.js +0 -1
  328. package/assets/esri/core/workers/chunks/bca6b469940b7b954123.js +0 -1
  329. package/assets/esri/core/workers/chunks/c0d7ae314ebfad1e3791.js +0 -1
  330. package/assets/esri/core/workers/chunks/c337fc0e6dc69c233e6d.js +0 -1
  331. package/assets/esri/core/workers/chunks/c8eae00b0ec87d8b2ff3.js +0 -1
  332. package/assets/esri/core/workers/chunks/cd9aa950cb74b09008fe.js +0 -1
  333. package/assets/esri/core/workers/chunks/e0d9dc97985561320bd4.js +0 -1
  334. package/assets/esri/core/workers/chunks/e2775b4b753306dc8477.js +0 -1
  335. package/assets/esri/core/workers/chunks/eaddffcc7004101fc230.js +0 -1
  336. package/assets/esri/core/workers/chunks/ebbf425af348e6ede814.js +0 -1
  337. package/assets/esri/core/workers/chunks/efc53007cd2e4991d7d4.js +0 -1
  338. package/assets/esri/core/workers/chunks/f46e92c67986c8c09bdd.js +0 -1
  339. package/assets/esri/core/workers/chunks/f8bc474434fd365ab174.js +0 -1
  340. package/assets/esri/core/workers/chunks/f8d2225f333524ce1d88.js +0 -1
  341. package/assets/esri/core/workers/chunks/f95a1f878c9c1146180e.js +0 -1
  342. package/assets/esri/core/workers/chunks/fb37f0848196c28b7fd7.js +0 -1
  343. /package/assets/esri/core/workers/chunks/{768389f7f8dba6080df7.js.LICENSE.txt → 0cc7fba402a93e6d2455.js.LICENSE.txt} +0 -0
@@ -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{forEach as n,result as r}from"../../../../core/asyncUtils.js";import"../../../../core/has.js";import i from"../../../../core/Logger.js";import{disposeMaybe as a,abortMaybe as o}from"../../../../core/maybe.js";import{throwIfAborted as s,isAbortError as c}from"../../../../core/promiseUtils.js";import l from"../../../../core/Queue.js";import{watch as u}from"../../../../core/reactiveUtils.js";import{property as d,subclass as f}from"../../../../core/accessorSupport/decorators.js";import{fromValues as p}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{isInEffectiveScaleRange as m}from"../../../../geometry/support/scaleUtils.js";import{BufferViewVec4i16 as h,BufferViewVec2f as g}from"../../../../geometry/support/buffer/BufferView.js";import{hydrateGraphic as _}from"../../../../layers/graphics/hydratedFeatures.js";import{createLabelFunction as v}from"../../../../layers/support/labelFormatUtils.js";import{hasCalloutSupport as y}from"../../../../symbols/callouts/calloutUtils.js";import{make as b}from"./Graphics3DCalloutSymbolLayerFactory.js";import{LineCalloutCreationContext as x,LineCalloutSymbolLayerRenderingInfo as S}from"./Graphics3DLineCalloutSymbolLayer.js";import{getGraphics3DSymbol as C}from"./graphicSymbolUtils.js";import{LabelInfo as w}from"./LabelInfo.js";import{LabelParameters as T}from"./LabelParameters.js";import{horizontalPlacementFromAnchor as E,verticalPlacementFromAnchor as D,textRenderAlignmentFromHorizontalPlacement as O}from"./placementUtils.js";import{placePointOnGeometry as k}from"./pointUtils.js";import{TextRenderer as A}from"../../webgl-engine/lib/TextRenderer.js";import{TextRenderParameters as j}from"../../webgl-engine/lib/TextRenderParameters.js";import{TextTextureAtlas as M}from"../../webgl-engine/lib/TextTextureAtlas.js";import{WebGLLayer as N}from"../../webgl-engine/lib/WebGLLayer.js";import{hasLayerBasedScaleVisibility as P}from"../../../support/layerViewUtils.js";import{TaskPriority as F}from"../../../support/Scheduler.js";import{Yield as I}from"../../../support/Yield.js";class L{constructor(e,t){this.labelingContext=e,this.graphics3DGraphic=t,this.hasGraphics3DResources=!1,this.visible=!1,this.textureAtlasHandles=[],this.textInitialized=!1,this.textRenderers=[],this.textLabelPlacements=[]}}class R{constructor(e,t,n,r,i){this.labelClass=e,this.graphics3DSymbol=t,this.graphics3DCalloutSymbolLayer=n,this.textRenderParameters=r,this.labelFunction=i,this.calloutSymbolLayerIndex=0,this.graphics=new Map,this.scaleVisibility=null}}class z{constructor(e,t,n,r,i,a,o,s){this.layer=t,this.graphics3DCore=n,this.scaleVisibility=r,this.emptySymbolLabelSupported=i,this.elevationInfoOverride=a,this.disablePlacement=o,this.active=s,this.labelClassAbortController=new AbortController,this._labelClassContexts=[],this.graphics=new Map,this.labelsToInitialize=new Map,this.stageLayer=new N(e,{pickable:!0},n.owner.layerViewUid)}destroy(){this.stageLayer.destroy()}get labelClassContexts(){return this._labelClassContexts}setLabelClassContext(e,t){this._labelClassContexts[e]=t}resetLabelClassContext(){this._labelClassContexts.length=0}}let B=class extends t{constructor(e){super(e),this._hudMaterials=new Map,this._calloutMaterials=new Map,this._dirty=!1,this._focusAreasLabelsQueue=new l,this._labels=new Map,this._labelingContexts=[]}setup(){this.dispose(),this.addHandles([u(()=>this.view.state?.camera,()=>this.setDirty()),u(()=>this.view.state?.rasterPixelRatio,()=>this._resetAllLabels()),u(()=>this.view.timeZone,()=>this._resetArcadeLabels()),u(()=>this.view.focusAreasView?.polygons,()=>this._updateFocus()),this.view.resourceController.scheduler.registerTask(F.LABELER,this)]),P()&&this.addHandles(u(()=>this.view.scale,()=>this._updateScaleVisibility())),this._textTextureAtlas=new M({view:this.view})}dispose(){this.removeAllHandles(),this._textTextureAtlas=a(this._textTextureAtlas),this._hudMaterials.clear(),this._calloutMaterials.clear(),this._labelingContexts.length=0,this._labels.clear()}destroy(){this.dispose(),q.graphic=null,q.renderingInfo=null,q.layer=null}_updateFocus(){this._focusAreasLabelsQueue.clear(),this._labelingContexts.forEach(e=>{e.graphics.forEach(t=>{this._focusAreasLabelsQueue.push({graphic3DGraphic:t,labelingContext:e})})})}_activateLabelingContext(e){e.graphics.forEach((t,n)=>{let r=new L(e,t);this._labels.set(n,r),e.labelsToInitialize.set(n,r),t.setVisibilityFlag(16,1,!0)}),e.active=!0}_deactivateLabelingContext(e){e.graphics.forEach((e,t)=>{e.setVisibilityFlag(16,1,!1),this.setLabelGraphicVisibility(e,!1),e.clearLabelGraphics(),this._labels.delete(t)}),e.active=!1}_addLabelTextureToAtlas(e){if(this._textTextureAtlas)for(let t of e.graphics3DGraphic.labelLayers){if(!t.labelClass||t.type!==`buffer`)continue;let n=e.textRenderers[t.labelClassContextIndex];n&&(e.textureAtlasHandles.push(this._textTextureAtlas.addText(n,e=>H(t.stageObject,e))),V(t.stageObject,n))}}_removeLabelTextureFromAtlas(e){e.textureAtlasHandles.forEach(e=>e.remove()),e.textureAtlasHandles.length=0}get readyToRun(){return this.view.ready&&(this._dirty||this.deconflictor.readyToRun||this._focusAreasLabelsQueue.length>0)}runTask(e){return this._updateLabels(e),this._applyFocusAreasUpdates(e),!this._dirty&&this.deconflictor.readyToRun&&this.deconflictor.runTask(e),I}_updateLabels(e){if(this._dirty){this._dirty=!1;for(let t of this._labelingContexts)if(t.active){if(U(t))this._dirty=!0;else if(W(t.labelClassContexts)){if(t.labelClassContexts===null){this._deactivateLabelingContext(t);continue}this._createLabelClassContext(t),this._dirty=!0}else for(let[n,r]of t.labelsToInitialize)if(this._ensureGraphics3DResources(r)&&(this._labels.set(n,r),this.deconflictor.setDirty(),e.madeProgress()),(r.visible&&r.textInitialized||!r.visible&&r.hasGraphics3DResources)&&(t.labelsToInitialize.delete(n),e.madeProgress()),e.done){this._dirty=!0;break}}this._dirty||this.notifyChange(`updating`)}}_applyFocusAreasUpdates(e){for(;this._focusAreasLabelsQueue.length>0&&!e.done;){e.madeProgress();let{graphic3DGraphic:t,labelingContext:n}=this._focusAreasLabelsQueue.pop();if(t.labelLayers.length===0||!n.active)continue;let r=k(t.graphic.geometry);if(r==null)continue;let i=this.view.focusAreasView?.containsGeometry(r)??!0;t.labelLayers.forEach(e=>{e.stageObject.geometries.some(e=>e.material.parameters.focusAreaStyle==null!==i)&&(this._removeGraphic(n,t),this._addGraphic(n,t),this.setDirty())})}this._focusAreasLabelsQueue.length===0&&(this.notifyChange(`readyToRun`),this.notifyChange(`updating`))}async _createLabelClassContextAsync(e){let t=e.labelClassAbortController?.signal;e.layer.when&&await e.layer.when(),s(t),e.scaleVisibility?.updateScaleRangeActive();let a=e.graphics3DCore,o=a.layer.labelingInfo?.filter(e=>!!e.symbol);o&&o.length!==0&&(await n(o,async(n,o)=>{let c=n.symbol,l=C(a.getOrCreateGraphics3DSymbol(c));if(l==null){i.getLogger(this).error(`Failed to create Graphics3DSymbol for label`);return}await l.load(),s(t);let u=null;y(c)&&c.hasVisibleCallout()&&(u=b(c,a.symbolCreationContext),await u.load(),s(t));let d=await r(v(n,e.layer.fieldsIndex,this.view.spatialReference));if(s(t),d.ok===!0){let r=await this._createTextRenderParameters(l.symbol);s(t);let i=new R(n,l,u,r,d.value);this._updateLabelClassContextVisibility(i),e.setLabelClassContext(o,i)}else i.getLogger(this).error(`Label expression failed to evaluate: ${d.error}`)}),s(t))}async _createLabelClassContext(e){return e.labelClassPromise??(e.labelClassPromise=this._createLabelClassContextAsync(e).catch(t=>{if(c(t))throw t;e.resetLabelClassContext()}).then(()=>{e.labelClassAbortController=null,this.notifyChange(`updating`)}).catch(()=>{}),this.notifyChange(`updating`)),e.labelClassPromise}async _createTextRenderParameters(e){let t=e.symbolLayers.at(0);return t?.type===`text`?j.fromSymbol(t,this.view.state.rasterPixelRatio):null}_destroyLabelClassContext(e){for(let t of e.labelClassContexts)t&&--t.graphics3DSymbol.referenced;let t=e.labelClassAbortController;e.labelClassAbortController=new AbortController,o(t),e.resetLabelClassContext(),e.labelClassPromise=null,this.notifyChange(`updating`)}_createTextSymbolGraphic(e,t,n,r,i,a){if(!this._textTextureAtlas)return null;let o=new T(n,E(n.anchor),D(n.anchor),e.text,p(e.displayWidth,e.displayHeight));return q.graphic=t,q.layer=r,q.renderingInfo=null,i.createLabel(q,o,this._hudMaterials,this._textTextureAtlas,()=>a.placement?.elevationOffset??null)}_createLineCalloutGraphic(e,t,n,r,i){q.graphic=e,q.layer=i;let a=r.screenOffset[0];return q.renderingInfo=new S(null,t,r.translation,r.centerOffset,r.groundDistance,a,r.centerOffsetUnits,r.elevationOffset),n.createGraphics3DGraphic(q,this._calloutMaterials)}_ensureGraphics3DResources(e){if(e.hasGraphics3DResources)return!1;let t=e.graphics3DGraphic;if(t.destroyed)return!1;this._ensureTextTextureResources(e);let n=e.labelingContext,r=n.labelClassContexts;if(W(r)||!n.emptySymbolLabelSupported&&t.layers.length===0)return!1;let i=!1,a=t.graphic,o=n.layer,s=K(n.layer);for(let c=0;c<r.length;c++){let l=e.textRenderers[c],u=e.textLabelPlacements[c],d=r[c];if(l==null||u==null||d==null)continue;let f=d.graphics3DSymbol,p=G(f),m=f.symbolLayers[0];if(!m)continue;m.setElevationInfoOverride(n.elevationInfoOverride);let h=new w(t,p,d.labelClass),g=this._createTextSymbolGraphic(l,a,u,o,m,h);if(g==null)return!1;g.labelClass=d.labelClass,g.labelClassContextIndex=c,t.addLabelGraphic(g,n.stageLayer),this.deconflictor.setPriority(t,d.textRenderParameters?.definition.size??0),t.setVisibilityFlag(16,1,s),t.setVisibilityFlag(16,2,d.scaleVisibility??!0),t.setVisibilityFlag(16,8,!1),P()&&d.graphics.set(a.uid,t),i=!0;let _=d.graphics3DCalloutSymbolLayer;if(_&&u.hasLabelVerticalOffset){_.setElevationInfoOverride(n.elevationInfoOverride);let e=this._createLineCalloutGraphic(a,p,_,u,o);e!=null&&(d.calloutSymbolLayerIndex=t.labelLayers.length,t.addLabelGraphic(e,n.stageLayer))}break}return i&&n.scaleVisibility?.updateGraphicLabelScaleVisibility(t),e.hasGraphics3DResources=!0,!0}_destroyGraphics3DResources(e){let t=e.labelingContext.labelClassContexts;for(let n of e.graphics3DGraphic.labelLayers)n.labelClass!=null&&t[n.labelClassContextIndex].graphics3DSymbol.symbolLayers[0]?.onRemoveGraphic(n);e.graphics3DGraphic.clearLabelGraphics(),e.hasGraphics3DResources=!1}_ensureTextTextureResources(e){if(e.textInitialized)return;let t=e.labelingContext,n=t.labelClassContexts;if(W(n))return;let r=e.graphics3DGraphic.graphic;for(let i=0;i<n.length;i++){let a=n[i];if(e.textRenderers[i]=null,e.textLabelPlacements[i]=null,a?.textRenderParameters==null)continue;let o=a.labelFunction,s;if(o.type===`arcade`)try{let e=o.needsHydrationToEvaluate()?_(r,t.layer,null):r;s=o.evaluate(e,this.view.timeZone)}catch{s=null}else s=o.evaluate(r);if(s==null||s===``||/^\s+$/.test(s))continue;let c=a.graphics3DSymbol;if(!c.symbolLayers[0])continue;let l=e.graphics3DGraphic,u=c.symbol?.type===`label-3d`?c.symbol:null,d=a.labelClass,f=t.disablePlacement,p=new w(l,u,d,f).placement;if(p==null)continue;let m=E(p.anchor),h=O(m);e.textRenderers[i]=new A(s,h,a.textRenderParameters,M.maxSize),e.textLabelPlacements[i]=p}e.textInitialized=!0}_destroyTextTextureResources(e){e.textInitialized=!1,e.textRenderers.length=0,e.textLabelPlacements.length=0}_addGraphic(e,t){let n=t.graphic.uid;if(e.graphics.set(n,t),e.active){let r=new L(e,t);this._labels.set(n,r),e.labelsToInitialize.set(n,r)}this.setDirty(),this.deconflictor.setDirty()}_updateGraphicGeometry(e,t){let n=t.graphic.uid,r=this._labels.get(n);if(!r)return!0;for(let n of r.graphics3DGraphic.labelLayers){if(n.labelClass==null)continue;let i=e.labelClassContexts[n.labelClassContextIndex].graphics3DSymbol.symbolLayers[0],a=r.textLabelPlacements[n.labelClassContextIndex];if(n.type!==`buffer`||!i.updateGeometry(t.graphic,n,a))return!1}return this.setDirty(),this.deconflictor.setDirty(),!0}_removeGraphic(e,t){let n=t.graphic.uid,r=this._labels.get(n);e.graphics.delete(n),e.labelClassContexts.forEach(e=>e?.graphics.delete(n)),r&&(this._destroyGraphic(r,n),e.labelsToInitialize.delete(n),this.setDirty(),this.deconflictor.setDirty())}_destroyGraphic(e,t){this._labels.delete(t),e.textureAtlasHandles.length&&this._removeLabelTextureFromAtlas(e),this._destroyTextTextureResources(e),e.hasGraphics3DResources&&this._destroyGraphics3DResources(e)}async _labelingInfoChange(e,t){if(t)for(let n of t){let t=e.graphics.get(n);t&&(this._removeGraphic(e,t),this._addGraphic(e,t))}else return this._visibilityInfoChange(e),this._resetLabels(e),this._createLabelClassContext(e)}_globalPropertyChanged(e,t){for(let n of t.labelClassContexts){if(!n)continue;let r=new Map;t.graphics.forEach(e=>r.set(e.graphic.uid,e)),n.graphics3DSymbol.symbolLayers[0].globalPropertyChanged(e,r,e=>e.labelLayers[0]),n.graphics3DCalloutSymbolLayer&&n.graphics3DCalloutSymbolLayer.globalPropertyChanged(e,r,e=>e.labelLayers[n.calloutSymbolLayerIndex])}}_visibilityInfoChange(e){let t=K(e.layer);t&&!e.active&&this._activateLabelingContext(e),!t&&e.active&&this._deactivateLabelingContext(e),this.setDirty()}_resetAllLabels(){for(let e of this._labelingContexts)this._resetLabels(e)}_resetArcadeLabels(){for(let e of this._labelingContexts)e.labelClassContexts.some(e=>e?.labelFunction.type===`arcade`)&&this._resetLabels(e)}_resetLabels(e){e.graphics.forEach((t,n)=>{let r=this._labels.get(n);r&&(this._destroyGraphic(r,n),r.visible=!1,e.labelsToInitialize.set(n,r))}),this._destroyLabelClassContext(e),this.setDirty(),this.deconflictor.setDirty()}_findLabelingContext(e){for(let t of this._labelingContexts)if(t.graphics3DCore===e)return t;return null}addGraphicsOwner(e,t,n){let r=n?.emptySymbolLabelSupported||!1,i=n?.elevationInfoOverride||null,a=n?.disablePlacement||null;if(this._findLabelingContext(e))return;let o=e.layer,s=new z(this.view.stage,o,e,t,r,i,a,K(o));return this._labelingContexts.push(s),this.setDirty(),{addGraphic:e=>this._addGraphic(s,e),removeGraphic:e=>this._removeGraphic(s,e),updateGraphicGeometry:e=>this._updateGraphicGeometry(s,e),layerLabelsEnabled:()=>K(s.layer),labelingInfoChange:e=>this._labelingInfoChange(s,e),elevationInfoChange:()=>this._globalPropertyChanged(`elevationInfo`,s),screenSizePerspectiveEnabledChanged:()=>this._globalPropertyChanged(`screenSizePerspectiveEnabled`,s),slicePlaneEnabledChange:()=>this._globalPropertyChanged(`slicePlaneEnabled`,s),visibilityInfoChange:()=>this._visibilityInfoChange(s),reset:()=>this._resetLabels(s),remove:()=>this._removeGraphicsOwner(e),setDirty:()=>this.setDirty()}}_removeGraphicsOwner(e){let t=this._findLabelingContext(e);if(!t)return;let n=this._labelingContexts.indexOf(t);this._labelingContexts.splice(n,1),t.graphics.forEach(e=>this._removeGraphic(t,e)),t.destroy(),this.setDirty()}_updateScaleVisibility(){for(let e of this._labelingContexts)if(e.active&&!U(e))for(let t of e.labelClassContexts)this._updateLabelClassContextVisibility(t)}_updateLabelClassContextVisibility(e){if(!e||!P())return;let{labelClass:t,graphics:n}=e,r={minScale:t.minScale,maxScale:t.maxScale},i=m(r,this.view.scale),a=e.scaleVisibility==null||e.scaleVisibility!==i;e.scaleVisibility=i,a&&n.size&&(n.forEach(e=>e.setVisibilityFlag(16,2,i)),this.deconflictor.setDirty(),this.setDirty())}setLabelGraphicVisibility(e,t){let n=e.graphic.uid,r=this._labels.get(n);r&&r.visible!==t&&(t&&!r.textureAtlasHandles.length?(this._addLabelTextureToAtlas(r),r.textInitialized||r.labelingContext.labelsToInitialize.set(n,r)):!t&&r.textureAtlasHandles.length&&this._removeLabelTextureFromAtlas(r),r.visible=t,this.setDirty())}setDirty(){!this._dirty&&this._labelingContexts.length>0&&(this._dirty=!0,this.notifyChange(`updating`))}get updating(){return this._dirty||this._textTextureAtlas?.updating||this.deconflictor.updating||this._labelingContexts.some(e=>U(e))||this._focusAreasLabelsQueue.length>0}get updatingProgress(){if(!this.updating||!this._textTextureAtlas)return 1;let e=this._labelingContexts.length>0?this._labelingContexts.reduce((e,t)=>e+ +!U(t),0)/this._labelingContexts.length:1;return(this._dirty?0:.3)+(this._textTextureAtlas.updating?0:.1)+e*.1+this.deconflictor.updatingProgress*.5}get usedMemory(){return this._textTextureAtlas?.usedMemory??0}get test(){}};e([d({constructOnly:!0})],B.prototype,`view`,void 0),e([d({constructOnly:!0})],B.prototype,`deconflictor`,void 0),e([d()],B.prototype,`_textTextureAtlas`,void 0),e([d({type:Boolean,readOnly:!0})],B.prototype,`updating`,null),B=e([f(`esri.views.3d.layers.graphics.Labeler`)],B);function V(e,t){let{displayWidth:n,displayHeight:r}=t,i=e.geometries[0];i.getMutableVertexField(`size`,g).setValues(0,n,r),e.geometryVertexAttributeUpdated(i,`size`)}function H(e,t){let n=e.geometries[0];n.getMutableVertexField(`uvi`,h).setVec(0,t),e.geometryVertexAttributeUpdated(n,`uvi`,!0)}function U(e){return!!e.labelClassPromise&&!!e.labelClassAbortController}function W(e){return(e?.length??0)===0}function G(e){return e.symbol?.type===`label-3d`?e.symbol:null}function K(e){return!!e.labelsVisible&&!!e.labelingInfo?.some(e=>!!e.symbol)}const q=new x(null,null,null);export{B as Labeler,K as areLabelsVisible};
2
+ import{__decorate as e}from"tslib";import t from"../../../../core/Accessor.js";import{forEach as n,result as r}from"../../../../core/asyncUtils.js";import"../../../../core/has.js";import i from"../../../../core/Logger.js";import{disposeMaybe as a,abortMaybe as o}from"../../../../core/maybe.js";import{throwIfAborted as s,isAbortError as c}from"../../../../core/promiseUtils.js";import l from"../../../../core/Queue.js";import{watch as u}from"../../../../core/reactiveUtils.js";import{property as d,subclass as f}from"../../../../core/accessorSupport/decorators.js";import{fromValues as p}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{isInEffectiveScaleRange as m}from"../../../../geometry/support/scaleUtils.js";import{BufferViewVec4i16 as h,BufferViewVec2f as g}from"../../../../geometry/support/buffer/BufferView.js";import{hydrateGraphic as _}from"../../../../layers/graphics/hydratedFeatures.js";import{createLabelFunction as v}from"../../../../layers/support/labelFormatUtils.js";import{hasCalloutSupport as y}from"../../../../symbols/callouts/calloutUtils.js";import{make as b}from"./Graphics3DCalloutSymbolLayerFactory.js";import{LineCalloutCreationContext as x,LineCalloutSymbolLayerRenderingInfo as S}from"./Graphics3DLineCalloutSymbolLayer.js";import{getGraphics3DSymbol as C}from"./graphicSymbolUtils.js";import{LabelInfo as w}from"./LabelInfo.js";import{LabelParameters as T}from"./LabelParameters.js";import{horizontalPlacementFromAnchor as E,verticalPlacementFromAnchor as D,textRenderAlignmentFromHorizontalPlacement as O}from"./placementUtils.js";import{placePointOnGeometry as k}from"./pointUtils.js";import{TextRenderer as A}from"../../webgl-engine/lib/TextRenderer.js";import{TextRenderParameters as j}from"../../webgl-engine/lib/TextRenderParameters.js";import{TextTextureAtlas as M}from"../../webgl-engine/lib/TextTextureAtlas.js";import{WebGLLayer as N}from"../../webgl-engine/lib/WebGLLayer.js";import{hasLayerBasedScaleVisibility as P}from"../../../support/layerViewUtils.js";import{TaskPriority as F}from"../../../support/Scheduler.js";import{Yield as I}from"../../../support/Yield.js";class L{constructor(e,t){this.labelingContext=e,this.graphics3DGraphic=t,this.hasGraphics3DResources=!1,this.visible=!1,this.textureAtlasHandles=[],this.textInitialized=!1,this.textRenderers=[],this.textLabelPlacements=[]}}class R{constructor(e,t,n,r,i){this.labelClass=e,this.graphics3DSymbol=t,this.graphics3DCalloutSymbolLayer=n,this.textRenderParameters=r,this.labelFunction=i,this.calloutSymbolLayerIndex=0,this.graphics=new Map,this.scaleVisibility=null}}class z{constructor(e,t,n,r,i,a,o,s){this.layer=t,this.graphics3DCore=n,this.scaleVisibility=r,this.emptySymbolLabelSupported=i,this.elevationInfoOverride=a,this.disablePlacement=o,this.active=s,this.labelClassAbortController=new AbortController,this._labelClassContexts=[],this.graphics=new Map,this.labelsToInitialize=new Map,this.stageLayer=new N(e,{pickable:!0},n.owner.layerViewUid)}destroy(){this.stageLayer.destroy()}get labelClassContexts(){return this._labelClassContexts}setLabelClassContext(e,t){this._labelClassContexts[e]=t}resetLabelClassContext(){this._labelClassContexts.length=0}}let B=class extends t{constructor(e){super(e),this._hudMaterials=new Map,this._calloutMaterials=new Map,this._dirty=!1,this._focusAreasLabelsQueue=new l,this._labels=new Map,this._labelingContexts=[]}setup(){this.dispose(),this.addHandles([u(()=>this.view.state?.camera,()=>this.setDirty()),u(()=>this.view.state?.rasterPixelRatio,()=>this._resetAllLabels()),u(()=>this.view.timeZone,()=>this._resetArcadeLabels()),u(()=>this.view.focusAreasView?.polygons,()=>this._updateFocus()),this.view.resourceController.scheduler.registerTask(F.LABELER,this)]),P()&&this.addHandles(u(()=>this.view.scale,()=>this._updateScaleVisibility())),this._textTextureAtlas=new M({view:this.view})}dispose(){this.removeAllHandles(),this._textTextureAtlas=a(this._textTextureAtlas),this._hudMaterials.clear(),this._calloutMaterials.clear(),this._labelingContexts.length=0,this._labels.clear()}destroy(){this.dispose(),q.graphic=null,q.renderingInfo=null,q.layer=null}_updateFocus(){this._focusAreasLabelsQueue.clear(),this._labelingContexts.forEach(e=>{e.graphics.forEach(t=>{this._focusAreasLabelsQueue.push({graphic3DGraphic:t,labelingContext:e})})})}_activateLabelingContext(e){e.graphics.forEach((t,n)=>{let r=new L(e,t);this._labels.set(n,r),e.labelsToInitialize.set(n,r),t.setVisibilityFlag(16,1,!0)}),e.active=!0}_deactivateLabelingContext(e){e.graphics.forEach((e,t)=>{e.setVisibilityFlag(16,1,!1),this.setLabelGraphicVisibility(e,!1),e.clearLabelGraphics(),this._labels.delete(t)}),e.active=!1}_addLabelTextureToAtlas(e){if(this._textTextureAtlas)for(let t of e.graphics3DGraphic.labelLayers){if(!t.labelClass||t.type!==`buffer`)continue;let n=e.textRenderers[t.labelClassContextIndex];n&&(e.textureAtlasHandles.push(this._textTextureAtlas.addText(n,e=>H(t.stageObject,e))),V(t.stageObject,n))}}_removeLabelTextureFromAtlas(e){e.textureAtlasHandles.forEach(e=>e.remove()),e.textureAtlasHandles.length=0}get readyToRun(){return this.view.ready&&(this._dirty||this.deconflictor.readyToRun||this._focusAreasLabelsQueue.length>0)}runTask(e){return this._updateLabels(e),this._applyFocusAreasUpdates(e),!this._dirty&&this.deconflictor.readyToRun&&this.deconflictor.runTask(e),I}_updateLabels(e){if(this._dirty){this._dirty=!1;for(let t of this._labelingContexts)if(t.active){if(U(t))this._dirty=!0;else if(W(t.labelClassContexts)){if(t.labelClassContexts===null){this._deactivateLabelingContext(t);continue}this._createLabelClassContext(t),this._dirty=!0}else for(let[n,r]of t.labelsToInitialize)if(this._ensureGraphics3DResources(r)&&(this._labels.set(n,r),this.deconflictor.setDirty(),e.madeProgress()),(r.visible&&r.textInitialized||!r.visible&&r.hasGraphics3DResources)&&(t.labelsToInitialize.delete(n),e.madeProgress()),e.done){this._dirty=!0;break}}this._dirty||this.notifyChange(`updating`)}}_applyFocusAreasUpdates(e){for(;this._focusAreasLabelsQueue.length>0&&!e.done;){e.madeProgress();let{graphic3DGraphic:t,labelingContext:n}=this._focusAreasLabelsQueue.pop();if(t.labelLayers.length===0||!n.active)continue;let r=k(t.graphic.geometry);if(r==null)continue;let i=this.view.focusAreasView?.containsGeometry(r)??!0;t.labelLayers.forEach(e=>{e.stageObject.geometries.some(e=>e.material.parameters.focusAreaStyle==null!==i)&&(this._removeGraphic(n,t),this._addGraphic(n,t),this.setDirty())})}this._focusAreasLabelsQueue.length===0&&(this.notifyChange(`readyToRun`),this.notifyChange(`updating`))}async _createLabelClassContextAsync(e){let t=e.labelClassAbortController?.signal;e.layer.when&&await e.layer.when(),s(t),e.scaleVisibility?.updateScaleRangeActive();let a=e.graphics3DCore,o=a.layer.labelingInfo?.filter(e=>!!e.symbol);o&&o.length!==0&&(await n(o,async(n,o)=>{let c=n.symbol,l=C(a.getOrCreateGraphics3DSymbol(c));if(l==null){i.getLogger(this).error(`Failed to create Graphics3DSymbol for label`);return}await l.load(),s(t);let u=null;y(c)&&c.hasVisibleCallout()&&(u=b(c,a.symbolCreationContext),await u.load(),s(t));let d=await r(v(n,e.layer.fieldsIndex,this.view.spatialReference));if(s(t),d.ok===!0){let r=await this._createTextRenderParameters(l.symbol);s(t);let i=new R(n,l,u,r,d.value);this._updateLabelClassContextVisibility(i),e.setLabelClassContext(o,i)}else i.getLogger(this).error(`Label expression failed to evaluate: ${d.error}`)}),s(t))}async _createLabelClassContext(e){return e.labelClassPromise??(e.labelClassPromise=this._createLabelClassContextAsync(e).catch(t=>{if(c(t))throw t;e.resetLabelClassContext()}).then(()=>{e.labelClassAbortController=null,this.notifyChange(`updating`)}).catch(()=>{}),this.notifyChange(`updating`)),e.labelClassPromise}async _createTextRenderParameters(e){let t=e.symbolLayers.at(0);return t?.type===`text`?j.fromSymbol(t,this.view.state.rasterPixelRatio):null}_destroyLabelClassContext(e){for(let t of e.labelClassContexts)t&&--t.graphics3DSymbol.referenced;let t=e.labelClassAbortController;e.labelClassAbortController=new AbortController,o(t),e.resetLabelClassContext(),e.labelClassPromise=null,this.notifyChange(`updating`)}_createTextSymbolGraphic(e,t,n,r,i,a){if(!this._textTextureAtlas)return null;let o=new T(n,E(n.anchor),D(n.anchor),e.text,p(e.displayWidth,e.displayHeight));return q.graphic=t,q.layer=r,q.renderingInfo=null,i.createLabel(q,o,this._hudMaterials,this._textTextureAtlas,()=>a.placement?.elevationOffset??null)}_createLineCalloutGraphic(e,t,n,r,i){q.graphic=e,q.layer=i;let a=r.screenOffset[0];return q.renderingInfo=new S(null,t,r.translation,r.centerOffset,r.groundDistance,a,r.centerOffsetUnits,r.elevationOffset),n.createGraphics3DGraphic(q,this._calloutMaterials)}_ensureGraphics3DResources(e){if(e.hasGraphics3DResources)return!1;let t=e.graphics3DGraphic;if(t.destroyed)return!1;this._ensureTextTextureResources(e);let n=e.labelingContext,r=n.labelClassContexts;if(W(r)||!n.emptySymbolLabelSupported&&t.layers.length===0)return!1;let i=!1,a=t.graphic,o=n.layer,s=K(n.layer);for(let c=0;c<r.length;c++){let l=e.textRenderers[c],u=e.textLabelPlacements[c],d=r[c];if(l==null||u==null||d==null)continue;let f=d.graphics3DSymbol,p=G(f),m=f.symbolLayers[0];if(!m)continue;m.setElevationInfoOverride(n.elevationInfoOverride);let h=new w(t,p,d.labelClass),g=this._createTextSymbolGraphic(l,a,u,o,m,h);if(g==null)return!1;g.labelClass=d.labelClass,g.labelClassContextIndex=c,t.addLabelGraphic(g,n.stageLayer),this.deconflictor.setPriority(t,d.textRenderParameters?.definition.size??0),t.setVisibilityFlag(16,1,s),t.setVisibilityFlag(16,2,d.scaleVisibility??!0),t.setVisibilityFlag(16,8,!1),P()&&d.graphics.set(a.uid,t),i=!0;let _=d.graphics3DCalloutSymbolLayer;if(_&&u.hasLabelVerticalOffset){_.setElevationInfoOverride(n.elevationInfoOverride);let e=this._createLineCalloutGraphic(a,p,_,u,o);e!=null&&(d.calloutSymbolLayerIndex=t.labelLayers.length,t.addLabelGraphic(e,n.stageLayer))}break}return i&&n.scaleVisibility?.updateGraphicLabelScaleVisibility(t),e.hasGraphics3DResources=!0,!0}_destroyGraphics3DResources(e){let t=e.labelingContext.labelClassContexts;for(let n of e.graphics3DGraphic.labelLayers)n.labelClass!=null&&t[n.labelClassContextIndex].graphics3DSymbol.symbolLayers[0]?.onRemoveGraphic(n);e.graphics3DGraphic.clearLabelGraphics(),e.hasGraphics3DResources=!1}_ensureTextTextureResources(e){if(e.textInitialized)return;let t=e.labelingContext,n=t.labelClassContexts;if(W(n))return;let r=e.graphics3DGraphic.graphic;for(let i=0;i<n.length;i++){let a=n[i];if(e.textRenderers[i]=null,e.textLabelPlacements[i]=null,a?.textRenderParameters==null)continue;let o=a.labelFunction,s;if(o.type===`arcade`)try{let e=o.needsHydrationToEvaluate()?_(r,t.layer,null):r;s=o.evaluate(e,this.view.timeZone)}catch{s=null}else s=o.evaluate(r);if(s==null||s===``||/^\s+$/.test(s))continue;let c=a.graphics3DSymbol;if(!c.symbolLayers[0])continue;let l=e.graphics3DGraphic,u=c.symbol?.type===`label-3d`?c.symbol:null,d=a.labelClass,f=t.disablePlacement,p=new w(l,u,d,f).placement;if(p==null)continue;let m=E(p.anchor),h=O(m);e.textRenderers[i]=new A(s,h,a.textRenderParameters,M.maxSize),e.textLabelPlacements[i]=p}e.textInitialized=!0}_destroyTextTextureResources(e){e.textInitialized=!1,e.textRenderers.length=0,e.textLabelPlacements.length=0}_addGraphic(e,t){let n=t.graphic.uid;if(e.graphics.set(n,t),e.active){let r=new L(e,t);this._labels.set(n,r),e.labelsToInitialize.set(n,r)}this.setDirty(),this.deconflictor.setDirty()}_updateGraphicGeometry(e,t){let n=t.graphic.uid,r=this._labels.get(n);if(!r)return!0;for(let n of r.graphics3DGraphic.labelLayers){if(n.labelClass==null)continue;let i=e.labelClassContexts[n.labelClassContextIndex].graphics3DSymbol.symbolLayers[0],a=r.textLabelPlacements[n.labelClassContextIndex];if(n.type!==`buffer`||!i.updateGeometry(t.graphic,n,a))return!1}return this.setDirty(),this.deconflictor.setDirty(),!0}_removeGraphic(e,t){let n=t.graphic.uid,r=this._labels.get(n);e.graphics.delete(n),e.labelClassContexts.forEach(e=>e?.graphics.delete(n)),r&&(this._destroyGraphic(r,n),e.labelsToInitialize.delete(n),this.setDirty(),this.deconflictor.setDirty())}_destroyGraphic(e,t){this._labels.delete(t),e.textureAtlasHandles.length&&this._removeLabelTextureFromAtlas(e),this._destroyTextTextureResources(e),e.hasGraphics3DResources&&this._destroyGraphics3DResources(e)}async _labelingInfoChange(e,t){if(t)for(let n of t){let t=e.graphics.get(n);t&&(this._removeGraphic(e,t),this._addGraphic(e,t))}else return this._visibilityInfoChange(e),this._resetLabels(e),this._createLabelClassContext(e)}_globalPropertyChanged(e,t){for(let n of t.labelClassContexts){if(!n)continue;let r=new Map;t.graphics.forEach(e=>r.set(e.graphic.uid,e)),n.graphics3DSymbol.symbolLayers[0].globalPropertyChanged(e,r,e=>e.labelLayers[0]),n.graphics3DCalloutSymbolLayer&&n.graphics3DCalloutSymbolLayer.globalPropertyChanged(e,r,e=>e.labelLayers[n.calloutSymbolLayerIndex])}}_visibilityInfoChange(e){let t=K(e.layer);t&&!e.active&&this._activateLabelingContext(e),!t&&e.active&&this._deactivateLabelingContext(e),this.setDirty()}_resetAllLabels(){for(let e of this._labelingContexts)this._resetLabels(e)}_resetArcadeLabels(){for(let e of this._labelingContexts)e.labelClassContexts.some(e=>e?.labelFunction.type===`arcade`)&&this._resetLabels(e)}_resetLabels(e){e.graphics.forEach((t,n)=>{let r=this._labels.get(n);r&&(this._destroyGraphic(r,n),r.visible=!1,e.labelsToInitialize.set(n,r))}),this._destroyLabelClassContext(e),this.setDirty(),this.deconflictor.setDirty()}_findLabelingContext(e){for(let t of this._labelingContexts)if(t.graphics3DCore===e)return t;return null}addGraphicsOwner(e,t,n){let r=n?.emptySymbolLabelSupported||!1,i=n?.elevationInfoOverride||null,a=n?.disablePlacement||null;if(this._findLabelingContext(e))return;let o=e.layer,s=new z(this.view.stage,o,e,t,r,i,a,K(o));return this._labelingContexts.push(s),this.setDirty(),{addGraphic:e=>this._addGraphic(s,e),removeGraphic:e=>this._removeGraphic(s,e),updateGraphicGeometry:e=>this._updateGraphicGeometry(s,e),layerLabelsEnabled:()=>K(s.layer),labelingInfoChange:e=>this._labelingInfoChange(s,e),elevationInfoChange:()=>this._globalPropertyChanged(`elevationInfo`,s),screenSizePerspectiveEnabledChanged:()=>this._globalPropertyChanged(`screenSizePerspectiveEnabled`,s),slicePlaneEnabledChange:()=>this._globalPropertyChanged(`slicePlaneEnabled`,s),visibilityInfoChange:()=>this._visibilityInfoChange(s),reset:()=>this._resetLabels(s),remove:()=>this._removeGraphicsOwner(e),setDirty:()=>this.setDirty()}}_removeGraphicsOwner(e){let t=this._findLabelingContext(e);if(!t)return;let n=this._labelingContexts.indexOf(t);this._labelingContexts.splice(n,1),t.graphics.forEach(e=>this._removeGraphic(t,e)),t.destroy(),this.setDirty()}_updateScaleVisibility(){for(let e of this._labelingContexts)if(e.active&&!U(e))for(let t of e.labelClassContexts)this._updateLabelClassContextVisibility(t)}_updateLabelClassContextVisibility(e){if(!e||!P())return;let{labelClass:t,graphics:n}=e,r={minScale:t.minScale,maxScale:t.maxScale},i=m(r,this.view.scale),a=e.scaleVisibility==null||e.scaleVisibility!==i;e.scaleVisibility=i,a&&n.size&&(n.forEach(e=>e.setVisibilityFlag(16,2,i)),this.deconflictor.setDirty(),this.setDirty())}setLabelGraphicVisibility(e,t){let n=e.graphic.uid,r=this._labels.get(n);r&&r.visible!==t&&(t&&!r.textureAtlasHandles.length?(this._addLabelTextureToAtlas(r),r.textInitialized||r.labelingContext.labelsToInitialize.set(n,r)):!t&&r.textureAtlasHandles.length&&this._removeLabelTextureFromAtlas(r),r.visible=t,this.setDirty())}setDirty(){!this._dirty&&this._labelingContexts.length>0&&(this._dirty=!0,this.notifyChange(`updating`))}get updating(){return this._dirty||this._textTextureAtlas?.updating||this.deconflictor.updating||this._labelingContexts.some(e=>U(e))||this._focusAreasLabelsQueue.length>0}get updatingProgress(){if(!this.updating||!this._textTextureAtlas)return 1;let e=this._labelingContexts.length>0?this._labelingContexts.reduce((e,t)=>e+ +!U(t),0)/this._labelingContexts.length:1;return(this._dirty?0:.3)+(this._textTextureAtlas.updating?0:.1)+e*.1+this.deconflictor.updatingProgress*.5}get usedMemory(){return this._textTextureAtlas?.usedMemory??0}get test(){}};e([d({constructOnly:!0})],B.prototype,`view`,void 0),e([d({constructOnly:!0})],B.prototype,`deconflictor`,void 0),e([d()],B.prototype,`_textTextureAtlas`,void 0),e([d({type:Boolean,readOnly:!0})],B.prototype,`updating`,null),B=e([f(`esri.views.3d.layers.graphics.Labeler`)],B);function V(e,t){let{displayWidth:n,displayHeight:r}=t,i=e.geometries[0];i.getMutableVertexField(`size`,g).setValues(0,n,r),e.geometryVertexAttributeUpdated(i,`size`)}function H(e,t){let n=e.geometries[0];n.getMutableVertexField(`uvi`,h).setVec(0,t),e.geometryVertexAttributeUpdated(n,`uvi`,!0)}function U(e){return!!e.labelClassPromise&&!!e.labelClassAbortController}function W(e){return(e?.length??0)===0}function G(e){return e.symbol?.type===`label-3d`?e.symbol:null}function K(e){return!!e.labelsVisible&&!!e.labelingInfo?.some(e=>!!e.symbol)}const q=new x(null,null,null,!1);export{B as Labeler,K as areLabelsVisible};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import has from"../../../../core/has.js";import{defaultObjectPrimitive as e}from"../../../../symbols/support/primitives.js";import{pathNumJoinSubdivisions as t,pathNumCircleProfileSubdivisions as n,pathNumRoundCapExtrusionSubdivisions as r}from"./Graphics3DPathSymbolLayerConstants.js";import{primitiveLodResources as i}from"./primitiveObjectSymbolUtils.js";import{EstimatedSymbolComplexity as a,AggregateSymbolComplexity as o,SymbolComplexity as s}from"./SymbolComplexity.js";import{hasEdges as c}from"../support/edgeUtils.js";import{DefaultMaterial as l}from"../../webgl-engine/materials/DefaultMaterial.js";const u=new a({});function d(e){if(e.type===`web-style`)return u;let t=new o;return e.symbolLayers.forEach(n=>f(m(e,n),t)),t}function f(e,t){e&&(t.verticesPerFeature+=e.verticesPerFeature,t.verticesPerCoordinate+=e.verticesPerCoordinate,t.drawCallsPerFeature+=e.drawCallsPerFeature,t.memory.bytesPerFeature+=e.memory.bytesPerFeature,t.memory.bytesPerFeatureLabel+=e.memory.bytesPerFeatureLabel,t.memory.resourceBytes+=e.memory.resourceBytes,t.memory.draped.bytesPerFeature+=e.memory.bytesPerFeature,t.memory.draped.bytesPerFeatureLabel+=e.memory.bytesPerFeatureLabel,t.estimated||=e.estimated,t.numComplexities++)}const p={};function m(i,o){let l=h(i,o),u=c(o)?2:0;switch(o.type){case`extrude`:return new s({verticesPerFeature:-12,verticesPerCoordinate:12,drawCallsPerFeature:u,memory:l});case`fill`:if(i.type===`mesh-3d`)return new s({drawCallsPerFeature:u,memory:l});if(o.outline!=null&&o.outline.size>0)return new s({verticesPerFeature:-12,verticesPerCoordinate:9,memory:l});case`water`:return new s({verticesPerFeature:-6,verticesPerCoordinate:3,memory:l});case`line`:return new s({verticesPerFeature:-6,verticesPerCoordinate:6,memory:l});case`object`:return o.resource?.href?new a({verticesPerFeature:100,memory:l}):{...g(o.resource?.primitive??e),memory:l};case`path`:{let e=0;switch(o.profile){case`circle`:e=n;break;case`quad`:e=4;break;default:o.profile;return}let i=e*2,a=e*t*2,c=a+i,u=-2*a-i;switch(o.cap){case`none`:break;case`butt`:case`square`:u+=2*(e-1);break;case`round`:u+=2*(e*(r-1)*2+e);break;default:return}return new s({verticesPerFeature:u,verticesPerCoordinate:c,memory:l})}case`text`:{let e=i.type===`label-3d`?0:2;return new s({verticesPerFeature:6,memory:l,drawCallsPerFeature:e})}case`icon`:return new s({verticesPerFeature:6,memory:l});default:return}}function h(e,t){let n=e.type===`point-3d`;switch(t.type){case`extrude`:return t.edges&&t.edges.size>0?v.EXTRUDE_EDGES:v.EXTRUDE;case`fill`:return t.outline!=null&&t.outline.size>0?v.FILL_OUTLINE:v.FILL;case`water`:return v.FILL;case`line`:return t.join===`round`?v.LINE_ROUND:v.LINE_MITER;case`path`:switch(t.join){case`round`:switch(t.profile){case`circle`:return v.PATH_ROUND_CIRCLE;case`quad`:return v.PATH_ROUND_QUAD;default:t.profile;return}case`miter`:case`bevel`:switch(t.profile){case`circle`:return v.PATH_MITER_CIRCLE;case`quad`:return v.PATH_MITER_QUAD;default:t.profile;return}default:return}case`object`:return n?v.OBJECT_POINT:v.OBJECT_POLYGON;case`icon`:case`text`:return n?v.ICON_POINT:v.ICON_POLYGON;default:return}}function g(e){let t=p[e];if(t)return t;let n=_(i(e,new l({},{spherical:!0})).levels);return p[e]=new s({verticesPerFeature:n}),p[e]}function _(e){return e.reduce((e,t,n)=>e+t.numVertices*(1/10**n),0)/e.reduce((e,t,n)=>e+1/10**n,0)}const v={ICON_POINT:{bytesPerFeature:2604,bytesPerFeatureLabel:3465,resourceBytes:0,draped:{bytesPerFeature:1781,bytesPerFeatureLabel:3456}},ICON_POLYGON:{bytesPerFeature:3198,bytesPerFeatureLabel:2941,resourceBytes:0,draped:{bytesPerFeature:2308,bytesPerFeatureLabel:3006}},OBJECT_POINT:{bytesPerFeature:877,bytesPerFeatureLabel:2952,resourceBytes:0,draped:{bytesPerFeature:877,bytesPerFeatureLabel:2952}},OBJECT_POLYGON:{bytesPerFeature:1307,bytesPerFeatureLabel:2520,resourceBytes:0,draped:{bytesPerFeature:1307,bytesPerFeatureLabel:2520}},LINE_MITER:{bytesPerFeature:2544,bytesPerFeatureLabel:2677,resourceBytes:0,draped:{bytesPerFeature:1924,bytesPerFeatureLabel:2664}},LINE_ROUND:{bytesPerFeature:2564,bytesPerFeatureLabel:2679,resourceBytes:0,draped:{bytesPerFeature:1928,bytesPerFeatureLabel:2673}},PATH_MITER_CIRCLE:{bytesPerFeature:13378,bytesPerFeatureLabel:2656,resourceBytes:0,draped:{bytesPerFeature:13378,bytesPerFeatureLabel:2656}},PATH_ROUND_CIRCLE:{bytesPerFeature:13524,bytesPerFeatureLabel:2686,resourceBytes:0,draped:{bytesPerFeature:13524,bytesPerFeatureLabel:2686}},PATH_MITER_QUAD:{bytesPerFeature:15185,bytesPerFeatureLabel:2993,resourceBytes:0,draped:{bytesPerFeature:15185,bytesPerFeatureLabel:2993}},PATH_ROUND_QUAD:{bytesPerFeature:13151,bytesPerFeatureLabel:2986,resourceBytes:0,draped:{bytesPerFeature:13151,bytesPerFeatureLabel:2986}},FILL:{bytesPerFeature:3514,bytesPerFeatureLabel:2845,resourceBytes:0,draped:{bytesPerFeature:2733,bytesPerFeatureLabel:2837}},FILL_OUTLINE:{bytesPerFeature:3618,bytesPerFeatureLabel:2593,resourceBytes:0,draped:{bytesPerFeature:2828,bytesPerFeatureLabel:2583}},EXTRUDE:{bytesPerFeature:5657,bytesPerFeatureLabel:2569,resourceBytes:0,draped:{bytesPerFeature:5657,bytesPerFeatureLabel:2569}},EXTRUDE_EDGES:{bytesPerFeature:3074,bytesPerFeatureLabel:2172,resourceBytes:0,draped:{bytesPerFeature:3074,bytesPerFeatureLabel:2172}}};if(has(`esri-tests-disable-symbol-memory-estimators`))for(let e in v){let t=v[e];t.bytesPerFeature=0,t.bytesPerFeatureLabel=0,t.draped.bytesPerFeature=0,t.draped.bytesPerFeatureLabel=0}export{f as aggregateSymbolComplexity,d as defaultSymbolComplexity,m as defaultSymbolLayerComplexity,h as defaultSymbolLayerMemoryComplexity,u as emptySymbolComplexity,_ as estimateNumVerticesForLods,v as memoryEstimators};
2
+ import has from"../../../../core/has.js";import{defaultObjectPrimitive as e}from"../../../../symbols/support/primitives.js";import{pathNumJoinSubdivisions as t,pathNumCircleProfileSubdivisions as n,pathNumRoundCapExtrusionSubdivisions as r}from"./Graphics3DPathSymbolLayerConstants.js";import{primitiveLodResources as i}from"./primitiveObjectSymbolUtils.js";import{EstimatedSymbolComplexity as a,AggregateSymbolComplexity as o,SymbolComplexity as s}from"./SymbolComplexity.js";import{hasEdges as c}from"../support/edgeUtils.js";import{DefaultMaterial as l}from"../../webgl-engine/materials/DefaultMaterial.js";const u=new a({});function d(e){if(e.type===`web-style`)return u;let t=new o;return e.symbolLayers.forEach(n=>f(m(e,n),t)),t}function f(e,t){e&&(t.verticesPerFeature+=e.verticesPerFeature,t.verticesPerCoordinate+=e.verticesPerCoordinate,t.drawCallsPerFeature+=e.drawCallsPerFeature,t.memory.bytesPerFeature+=e.memory.bytesPerFeature,t.memory.bytesPerFeatureLabel+=e.memory.bytesPerFeatureLabel,t.memory.resourceBytes+=e.memory.resourceBytes,t.memory.draped.bytesPerFeature+=e.memory.bytesPerFeature,t.memory.draped.bytesPerFeatureLabel+=e.memory.bytesPerFeatureLabel,t.estimated||=e.estimated,t.numComplexities++)}const p={};function m(i,o){let l=h(i,o),u=c(o)?2:0;switch(o.type){case`extrude`:return new s({verticesPerFeature:-12,verticesPerCoordinate:12,drawCallsPerFeature:u,memory:l});case`fill`:if(i.type===`mesh-3d`)return new s({drawCallsPerFeature:u,memory:l});if(o.outline!=null&&o.outline.size>0)return new s({verticesPerFeature:-12,verticesPerCoordinate:9,memory:l});case`water`:return new s({verticesPerFeature:-6,verticesPerCoordinate:3,memory:l});case`line`:return new s({verticesPerFeature:-6,verticesPerCoordinate:6,memory:l});case`object`:return o.resource?.href?new a({verticesPerFeature:100,memory:l}):{...g(o.resource?.primitive??e),memory:l};case`path`:{let e=0;switch(o.profile){case`circle`:e=n;break;case`quad`:e=4;break;default:o.profile;return}let i=e*2,a=e*t*2,c=a+i,u=-2*a-i;switch(o.cap){case`none`:break;case`butt`:case`square`:u+=2*(e-1);break;case`round`:u+=2*(e*(r-1)*2+e);break;default:return}return new s({verticesPerFeature:u,verticesPerCoordinate:c,memory:l})}case`text`:{let e=i.type===`label-3d`?0:2;return new s({verticesPerFeature:6,memory:l,drawCallsPerFeature:e})}case`icon`:return new s({verticesPerFeature:6,memory:l});default:return}}function h(e,t){let n=e.type===`point-3d`;switch(t.type){case`extrude`:return t.edges&&t.edges.size>0?v.EXTRUDE_EDGES:v.EXTRUDE;case`fill`:return t.outline!=null&&t.outline.size>0?v.FILL_OUTLINE:v.FILL;case`water`:return v.FILL;case`line`:return t.join===`round`?v.LINE_ROUND:v.LINE_MITER;case`path`:switch(t.join){case`round`:switch(t.profile){case`circle`:return v.PATH_ROUND_CIRCLE;case`quad`:return v.PATH_ROUND_QUAD;default:t.profile;return}case`miter`:case`bevel`:switch(t.profile){case`circle`:return v.PATH_MITER_CIRCLE;case`quad`:return v.PATH_MITER_QUAD;default:t.profile;return}default:return}case`object`:return n?v.OBJECT_POINT:v.OBJECT_POLYGON;case`icon`:case`text`:return n?v.ICON_POINT:v.ICON_POLYGON;default:return}}function g(e){let t=p[e];if(t)return t;let n=_(i(e,new l({},{spherical:!0})).levels);return p[e]=new s({verticesPerFeature:n}),p[e]}function _(e){return e.reduce((e,t,n)=>e+t.numVertices*(1/10**n),0)/e.reduce((e,t,n)=>e+1/10**n,0)}const v={ICON_POINT:{bytesPerFeature:2395,bytesPerFeatureLabel:4343,resourceBytes:0,draped:{bytesPerFeature:1662,bytesPerFeatureLabel:4409}},ICON_POLYGON:{bytesPerFeature:2750,bytesPerFeatureLabel:4219,resourceBytes:0,draped:{bytesPerFeature:2007,bytesPerFeatureLabel:4289}},OBJECT_POINT:{bytesPerFeature:1315,bytesPerFeatureLabel:4378,resourceBytes:0,draped:{bytesPerFeature:1315,bytesPerFeatureLabel:4378}},OBJECT_POLYGON:{bytesPerFeature:1642,bytesPerFeatureLabel:4239,resourceBytes:0,draped:{bytesPerFeature:1642,bytesPerFeatureLabel:4239}},LINE_MITER:{bytesPerFeature:2443,bytesPerFeatureLabel:4282,resourceBytes:0,draped:{bytesPerFeature:1906,bytesPerFeatureLabel:4210}},LINE_ROUND:{bytesPerFeature:2449,bytesPerFeatureLabel:4246,resourceBytes:0,draped:{bytesPerFeature:1911,bytesPerFeatureLabel:4290}},PATH_MITER_CIRCLE:{bytesPerFeature:3335,bytesPerFeatureLabel:4343,resourceBytes:0,draped:{bytesPerFeature:3335,bytesPerFeatureLabel:4343}},PATH_ROUND_CIRCLE:{bytesPerFeature:3365,bytesPerFeatureLabel:4326,resourceBytes:0,draped:{bytesPerFeature:3365,bytesPerFeatureLabel:4326}},PATH_MITER_QUAD:{bytesPerFeature:3373,bytesPerFeatureLabel:4406,resourceBytes:0,draped:{bytesPerFeature:3373,bytesPerFeatureLabel:4406}},PATH_ROUND_QUAD:{bytesPerFeature:3309,bytesPerFeatureLabel:4426,resourceBytes:0,draped:{bytesPerFeature:3309,bytesPerFeatureLabel:4426}},FILL:{bytesPerFeature:2416,bytesPerFeatureLabel:4281,resourceBytes:0,draped:{bytesPerFeature:1894,bytesPerFeatureLabel:4238}},FILL_OUTLINE:{bytesPerFeature:3286,bytesPerFeatureLabel:4281,resourceBytes:0,draped:{bytesPerFeature:2826,bytesPerFeatureLabel:4205}},EXTRUDE:{bytesPerFeature:3657,bytesPerFeatureLabel:4222,resourceBytes:0,draped:{bytesPerFeature:3657,bytesPerFeatureLabel:4222}},EXTRUDE_EDGES:{bytesPerFeature:4505,bytesPerFeatureLabel:4364,resourceBytes:0,draped:{bytesPerFeature:4505,bytesPerFeatureLabel:4364}}};if(has(`esri-tests-disable-symbol-memory-estimators`))for(let e in v){let t=v[e];t.bytesPerFeature=0,t.bytesPerFeatureLabel=0,t.draped.bytesPerFeature=0,t.draped.bytesPerFeatureLabel=0}export{f as aggregateSymbolComplexity,d as defaultSymbolComplexity,m as defaultSymbolLayerComplexity,h as defaultSymbolLayerMemoryComplexity,u as emptySymbolComplexity,_ as estimateNumVerticesForLods,v as memoryEstimators};
@@ -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{filterInPlace as n}from"../../../../core/arrayUtils.js";import"../../../../core/has.js";import r from"../../../../core/Logger.js";import{getOrCreateMapValue as i}from"../../../../core/MapUtils.js";import{isAbortError as a,throwIfAborted as o}from"../../../../core/promiseUtils.js";import s from"../../../../core/ReactiveMap.js";import{on as c,watch as l}from"../../../../core/reactiveUtils.js";import{schedule as u}from"../../../../core/scheduling.js";import{signal as d}from"../../../../core/signal.js";import{sqlAnd as f}from"../../../../core/sql.js";import{generateUID as p}from"../../../../core/uid.js";import{property as m,subclass as h}from"../../../../core/accessorSupport/decorators.js";import{getEpsilon as g}from"../../../../core/libs/gl-matrix-2/math/common.js";import{create as _,equals as v,clone as y,expand as b,toExtent as x,width as S,height as C}from"../../../../geometry/support/aaBoundingRect.js";import{getObjectId as w,DehydratedFeatureClass as T,hasVertices as E,computeAABR as ee}from"../../../../layers/graphics/dehydratedFeatures.js";import{geometryKey as te,transferGeometryKey as ne,identicalTransferGeometry as re,completeDehydratedFeatureFromTransfer as ie}from"../../../../layers/graphics/transferFeatures.js";import D from"../../../../rest/support/QuantizationParameters.js";import O from"../../../../rest/support/Query.js";import{isGraphic as k}from"../../../../support/graphicInstanceUtils.js";import{FeatureMemory as A}from"./FeatureMemory.js";import{MultiFeatureReference as j,SingleFeatureReference as M}from"./featureReference.js";import{failedFeatureCount as N,FeatureTile as P}from"./FeatureTile.js";import{virtualDisplayFilterHighlightTileId as F,virtualSnapshotTileId as I}from"./FeatureTileDescriptor.js";import{tilesAreRelated as L}from"../../terrain/tileUtils.js";import{ImmediateTask as R,TaskPriority as z}from"../../../support/Scheduler.js";let B=class extends t{set maximumNumberOfFeatures(e){e||=1/0;let t=this._get(`maximumNumberOfFeatures`);e===t||e<1||(this._set(`maximumNumberOfFeatures`,e),this._maximumFeaturesUpdated(t,e))}set memoryFactor(e){this.memoryFactor!==e&&(this._set(`memoryFactor`,e),this._setDirty())}set lodFactor(e){this.lodFactor!==e&&(this._set(`lodFactor`,e),this._supportsResolution&&this.refetch())}get useTileCount(){return this._useTileCount&&this.context.query.queryFeatureCount!=null}set useTileCount(e){this._useTileCount=e,this.notifyChange(`useTileCount`)}get updating(){return this._dirty||!!this._pendingEdits||this._isFetching||(this.tileDescriptors?.updating??!1)}get readyToRun(){return this._dirty}get usedMemory(){return this._memory.usedMemory}get usedMemoryPerFeature(){return this._memory.usedMemoryPerFeature}get totalVertices(){let e=0;return this._featureTiles.forEach(t=>e+=t.numVertices),e}get totalFeatures(){let e=0;return this._featureTiles.forEach(t=>e+=t.numFeatures),e}get showsAllFeatures(){if(this._paused||this.dataUpdating)return!1;for(let e of this._featureTiles.values())if(!this.hasFullGeometries&&e.emptyFeatureRatio!==0||!e.showsAllFeatures)return!1;return!0}get hasFullGeometries(){return!this._supportsResolution||this.tileDescriptors?.some(V)||!this.context.capabilities.supportsQuantization&&this.context.geometryType!==`polyline`}set filterExtent(e){if(e!=null&&this.context.tilingScheme&&!e.spatialReference.equals(this.context.tilingScheme.spatialReference)){r.getLogger(this).error(`#filterExtent=`,`extent needs to be in the same spatial reference as the tiling scheme`);return}let t=this._get(`filterExtent`);if(t===e||t!=null&&e&&t.equals(e))return;let n=e==null?null:e.clone();this._set(`filterExtent`,n),this._reclip(n,t)}_updateTileZQuantization(e){if(this.context.viewingMode===1){let t=e.computeZQuantizationFactor();this._zQuantizationFactor.value<t&&(this._zQuantizationFactor.value=t)}}get _tileZQuantization(){return this.context.isDraped?1:this._zQuantizationFactor.value}constructor(e){super(e),this._useTileCount=!1,this.dataUpdating=!1,this.updatingTotal=0,this.updatingRemaining=0,this.expectedFeatureDiff=0,this.maximumNumberOfFeaturesExceeded=!1,this._fullRatio=1,this._farRatio=1,this._zQuantizationFactor=d(1),this._changes={updates:{adds:[],removes:[]},adds:[],removes:[]},this._featureTiles=new s,this._displayingFeatureReferences=new Map,this._numDisplayingFeatureReferences=0,this._memory=new A(te),this._dirty=!1,this._suspended=!0,this._pendingEdits=null,this._applyEditsTilesUpdated=!1,this.snappingComplexityExceeded=!0,this._isFetching=!1;let t=e.context;this._frameTask=t.scheduler?.registerTask(z.FEATURE_TILE_FETCHER,this)??R,this.FeatureReferenceClass=t.capabilities.supportsMultipleResolutions?j:M,this._objectIdField=t.objectIdField}initialize(){this.addHandles([c(()=>this.tileDescriptors,`change`,()=>this._setDirty(),{onListenerAdd:()=>this._setDirty(),onListenerRemove:()=>this._setDirty()}),l(()=>this._tileZQuantization,()=>this.refetch())]),this._setDirty()}destroy(){this._frameTask.remove(),this._featureTiles.forEach(e=>{this._cancelFetchTile(e),this._removeTile(e)}),this._featureTiles.clear(),this._displayingFeatureReferences.clear(),this._pendingEdits?.controller.abort(),this._pendingEdits=null}get _paused(){return this._suspended||!!this._pendingEdits}restart(){this._featureTiles.forEach(e=>{this._cancelFetchTile(e),this._clearTile(e),this._resetFetchTile(e)}),this.context.memoryCache!=null&&this.context.memoryCache.clear(),this._setDirty()}refetch(){this._featureTiles.forEach(e=>{this._cancelFetchTile(e),this._resetFetchTile(e)}),this.context.memoryCache!=null&&this.context.memoryCache.clear(),this._setDirty()}refetchAttributes(){this._featureTiles.forEach(e=>{let t=e.isFetched||e.needsAttributesFetching;this._cancelFetchTile(e),e.features?.length&&t?e.requestAttributes():this._resetFetchTile(e)}),this.context.memoryCache?.clear(),this._setDirty()}refetchDisplayFilterHighlightTile(){let e=this._featureTiles.get(F);e&&(this._cancelFetchTile(e),this._resetFetchTile(e),this._setDirty())}suspend(){this._suspended||(this._suspended=!0,this._pause(),this._setDirty())}resume(){this._suspended&&(this._suspended=!1,this._unpause())}getMissingAttributesForFeature(e){for(let t of this._featureTiles.values()){let n=t.missingAttributes?.get(e);if(n!=null)return n}}hasMissingAttributes(e){return this._featureTiles.values().some(t=>t?.missingAttributes?.values().some(t=>e.some(e=>t.has(e))))}_pause(){this._paused&&(this._featureTiles.forEach(e=>this._cancelFetchTile(e)),this._updated())}_unpause(){this._paused||this._setDirty()}get availableFields(){let e=null;return this._featureTiles.forEach(t=>{t.displayingFeatures!=null&&t.displayingFeatures.length!==0&&(e==null?e=new Set(t.availableFields):e.forEach(n=>{t.availableFields?.has(n)||e.delete(n)}))}),e??new Set}applyEdits(e){this._pendingEdits||(this._pendingEdits={edits:Promise.resolve(),count:0,controller:new AbortController},this._pause());let t=this._pendingEdits;t.count++;let n=t.edits.then(()=>e.result.catch(e=>{if(a(e))throw e;return null}).then(e=>e&&(this._applyEditsDeleteFeatures(e.deletedFeatures),this._applyEditsAddUpdateFeatures(e.addedFeatures,e.updatedFeatures,t.controller.signal).then(()=>e))).then(e=>(--t.count===0&&(this._pendingEdits===t&&(this._pendingEdits=null),this.context.memoryCache!=null&&this.context.memoryCache.clear(),this._applyEditsTilesUpdated=!1,this._unpause()),e)));return t.edits=n,this._updated(),n}_applyEditsDeleteFeatures(e){if(e.length===0)return;let t=this.context.globalIdField,n=t&&this.availableFields.has(t),i=new Set,a=this._objectIdField;e.forEach(({objectId:e,globalId:o})=>{(!e||e<0)&&t&&o&&(n||r.getLogger(this).errorOncePerTick(`Editing the specified service requires the layer's globalIdField, ${t} to be included the layer's outFields for updates to be reflected in the view`),e=this._objectIdFromGlobalId(o,a,t)),e!=null&&e>=0&&i.add(e)}),this._featureTiles.forEach(e=>{if(!e.features)return;let t=e.features.filter(e=>!i.has(w(e,this._objectIdField)));t.length!==e.features.length&&(this._applyEditsTileUpdated(),e.setFeatures(t,0,e.availableFields,e.missingAttributes),this._updateTileZQuantization(e),this._invalidateCounts())})}_objectIdFromGlobalId(e,t,n){if(e==null)return null;let r=this.features.find(t=>t.attributes?.[n]===e);return r?w(r,t):null}async _applyEditsAddUpdateFeatures(e,t,n){let{objectIdField:i,globalIdField:a}=this.context,o=a&&this.availableFields.has(a),s=new Set,c=new Set;for(let t of e){let e=t.objectId;e!=null&&s.add(e)}for(let{objectId:e,globalId:n}of t){let t=e;(t==null||t<0)&&a&&(o||r.getLogger(this).errorOncePerTick(`Editing the specified service requires the layer's globalIdField, ${a} to be included the layer's outFields for updates to be reflected in the view`),t=this._objectIdFromGlobalId(n,i,a)),t!=null&&t>=0&&(s.add(t),c.add(t))}if(s.size===0)return;let l=[];this._featureTiles.forEach(e=>{let t=this._applyEditsAddUpdateTile(e,s,c,n);l.push(t)}),this._updated(),await Promise.allSettled(l)}async _applyEditsAddUpdateTile(e,t,n,r){if(!e.features)return;e.fetchingResolution=e.descriptor.resolution;let i=this._createQuery(e);i.resultType=void 0,i.cacheHint=!1,i.objectIds=Array.from(t);let a=await this.context.query.queryFeaturesDehydrated(i,{signal:r,timeout:$}),o=null;if(n.size>0){let t=e.features.filter(e=>!n.has(w(e,this._objectIdField)));t.length!==e.features.length&&(o=t)}if(a.features.length>0){o||=e.features.slice();for(let e of a.features)o.push(e)}o&&(e.hasPreciseFeatureCount&&(e.numFeatures=Math.max(e.numFeatures,o.length)),this._applyEditsTileUpdated(),e.setFeatures(o,0,q(e.availableFields,a.fields),J(e.missingAttributes,a.missingAttributes),void 0,!1),this._updateTileZQuantization(e),this._invalidateCounts())}_applyEditsTileUpdated(){this._applyEditsTilesUpdated||(this._applyEditsTilesUpdated=!0,this._updated())}_queryFeatures(e,t,n){return this.context.query.queryFeaturesDehydrated(e,{signal:n,timeout:$,completeFeatureFromTransfer:(e,n,r)=>{let i=ne(e.geometry,n,t),a=this._memory.findGeometry(i,t=>re(e.geometry,n,t));a?e.geometry=a:ie(e,n,r)}})}_setDirty(){this._dirty=!0,this._updated()}runTask(e){let t=this._frameTask.processQueue(e);if(!this._dirty||!this.initialized)return t;this._dirty=!1;let n=this._featureTilesArray;if(this._markTilesNotAlive(n),!e.run(()=>this._addTiles(n,e))||!e.run(()=>this._filterExtentTiles(n,e))||!e.run(()=>this._removeTiles(n,e))||e.done){this._setDirty();return}let r=this._sortTiles(n);e.run(()=>this._showTiles(r,e))&&e.run(()=>this._fetchTiles(r,e))&&e.run(()=>this._updateMemoryEstimates(r,e))||this._setDirty(),this._updated(),this.updating||(this._updateMaximumNumberOfFeaturesExceeded(),this._updateSnappingComplexityExceeded(r))}_updateSnappingComplexityExceeded(e){let t=se;for(let n of e){if(V(n)||t<=0)break;if(!H(n)&&(t--,n.sampledDensityEstimate>oe)){this.snappingComplexityExceeded=!0;return}}this.snappingComplexityExceeded=this._featureTiles.size===0}_markTilesNotAlive(e){for(let t of e)t.alive=!1}_addTiles(e,t){return this._suspended||!this.tileDescriptors?!1:(this.tileDescriptors.forEach(n=>{let r=this._featureTiles.get(n.id);r?r.alive=!0:t.done||(e.push(this._addTile(n)),t.madeProgress())}),t.hasProgressed)}_filterExtentTiles(e,t){for(let n of e){if(t.done)break;n.alive&&(n.filtered=!n.intersects(this.filterExtent),n.filtered&&(this._clearTile(n),t.madeProgress()))}return t.hasProgressed}_removeTiles(e,t){for(let n=e.length-1;n>=0&&!t.done;n--){let r=e[n];r.alive||(this._removeTile(r),n!==e.length-1&&(e[n]=e[e.length-1]),e.pop(),t.madeProgress())}return t.hasProgressed}_sortTiles(e){return e.sort((e,t)=>e.descriptor.loadPriority-t.descriptor.loadPriority),e}_showTiles(e,t){let n=this._updateRatio(e),r=e=>{let t=this._fullRatio<1?n(e)*this._farRatio:1;e.reduceFeatures(t,this.memoryFactor,this._objectIdField,this._reduceMode)&&this._setDirty();let{numFeatures:r,fetchingResolution:i,descriptor:a,isFetched:o}=e;return this._supportsResolution&&r>0&&i!==a.resolution&&o&&(e.requestRefetch(),this._setDirty()),this._showTile(e)};for(let n of e)if(!t.run(()=>r(n))){this._setDirty();break}return t.hasProgressed}_fetchTiles(e,t){if(this._paused)return!1;let n=!1;for(let r of e){if(!r.needsFetch)continue;let e=this.context.memoryCache==null?null:this.context.memoryCache.pop(r.id);if(e?.resolution===r.displayingResolution)r.cache=e,r.numFeatures&&this._notifyDataUpdating(),this._setDirty(),this._scheduleUpdated(),t.madeProgress();else{if(this._needsNumFeatures(r)){let e=new AbortController,i=this._fetchTileCount(r,e.signal);this._handleRequest(r,i,e,()=>r.resetFetching(),()=>r.numFeatures=N),n=!0,t.madeProgress()}if(t.done)return!0}}if(n)return t.hasProgressed;for(let n of e){if(!n.needsFetch)continue;let e=new AbortController,i=this._fetchTile(n,e.signal);if(this._handleRequest(n,i,e,e=>n.fetchDone(e),e=>{n.fetchFailed=!0,this.context.logFetchError(r.getLogger(this),e)}),t.madeProgress(),t.done)return!0}return t.hasProgressed}_updateMemoryEstimates(e,t){return e.some(e=>!t.run(()=>e.updateEstimates())&&(this._setDirty(),!0)),t.hasProgressed}_reclip(e,t){if(!this.initialized)return;let n=[];this._featureTiles.forEach(r=>{r.displayingFeatures!=null&&r.displayingFeatures.length!==0&&(r.intersectionIncludingBorrowed(t,X),r.intersectionIncludingBorrowed(e,Z),v(X,Z)||n.push(r))}),this._refreshDisplayingFeatures(n),this._updated()}_refreshDisplayingFeatures(e){let t=new Set,n=this._changes.updates;for(let r of e)if(r.displayingFeatures!=null)for(let e of r.displayingFeatures){let r=w(e,this._objectIdField);if(t.has(r))continue;t.add(r);let i=this._displayingFeatureReferences.get(r).feature;n.removes.push(i),n.adds.push(i)}this._applyChanges()}_updated(){let e=0;if(this._paused||this._featureTiles.forEach(t=>t.isFetching?++e:0),this._isFetching=e>0,e>0||this._applyEditsTilesUpdated?this._notifyDataUpdating():this._dirty||this._set(`dataUpdating`,!1),this.updating){let t=0,n=0,r=0,i=0,a=0,o=this._displayingFeatureReferences.size/this._numDisplayingFeatureReferences;this._featureTiles.forEach(e=>{if(++n,e.isFetching&&e.hasPreciseFeatureCount){let t=this._maximumFeaturesForTile(e)*(1-e.emptyFeatureRatio),n=e.displayingFeatures==null?0:e.displayingFeatures.length*o;a+=t-n}e.needsFetch?++i:e.numFeatures>0&&(++r,t+=e.numFeatures)}),i+=e;let s=0,c=0;t?(c=t,s=Math.min(i*t/r,t)):(c=n,s=i),a=Math.min(this.maximumNumberOfFeatures-this.features.length,a),this._set(`updatingTotal`,c),this._set(`updatingRemaining`,s),this._set(`expectedFeatureDiff`,a)}else this._set(`updatingTotal`,0),this._set(`updatingRemaining`,0),this._set(`expectedFeatureDiff`,0);this.debugger?.update()}_updateMaximumNumberOfFeaturesExceeded(){for(let{perTileMaximumNumberOfFeaturesExceeded:e}of this._featureTiles.values())if(e){this._set(`maximumNumberOfFeaturesExceeded`,!0);return}this._set(`maximumNumberOfFeaturesExceeded`,!1)}_updateRatio(e){let t=W(e),n=e=>1/(1<<Math.max(0,t-e.descriptor.lij[0])),r=0,i=0;for(let t of e){let e=t.numFeatures;r+=e,i+=e*n(t)}return this._fullRatio=Math.min(1,this.maximumNumberOfFeatures/r),this._farRatio=this.maximumNumberOfFeatures/i,this._scheduleUpdated(),n}_maximumFeaturesUpdated(e,t){e!==t&&(t>e&&this._featureTiles.forEach(e=>{if(!e.featuresMissing)return;let t=this._maximumFeaturesForTile(e);e.isFullyFetched(t)||(this._cancelFetchTile(e),this._resetFetchTile(e))}),this._setDirty())}_addTile(e){let t=new P(e,this._memory);return this._featureTiles.set(t.id,t),this._resetFetchTile(t),this._referenceDisplayingFeaturesFromRelatedTiles(t),t}_referenceDisplayingFeaturesFromRelatedTiles(e){let t=e.displayingResolution;this._featureTiles.forEach(n=>{if(n.displayingFeatures!=null&&e!==n&&L(e.descriptor.lij,n.descriptor.lij)){e.displayingFeatures??=[],e.descriptor.extent&&n.descriptor.extent&&(e.extentIncludingBorrowedFeatures??=y(e.descriptor.extent),b(e.extentIncludingBorrowedFeatures,n.descriptor.extent,e.extentIncludingBorrowedFeatures));for(let r of n.displayingFeatures){e.displayingFeatures.push(r),this._memory.ref(r);let n=this._displayingFeatureReferences.get(w(r,this._objectIdField));n.ref(this._memory,n.feature,t),this._numDisplayingFeatureReferences++}}})}_removeTile(e){this._clearTile(e),this._featureTiles.delete(e.id)}_resetFetchTile(e){e.filtered=!e.intersects(this.filterExtent),e.filtered?e.needsFetch&&e.fetchDone(8):e.requestFetch()}_cancelFetchTile(e){let t=e.requestController;t!=null&&(e.requestController=null,e.resetFetching(),t.abort())}async _fetchTileCount(e,t){e.numFeatures=await this.context.query.queryFeatureCount(this._createFeatureCountQuery(e),{signal:t}),this._updateRatio(this._featureTilesArray)}async _fetchTile(e,t){if(e.fetchFailed=!1,e.needsAttributesFetching&&e.features?.length)return this._fetchTileAttributes(e,t);let n=this._maximumFeaturesForTile(e);if(n<=0)return e.hasPreciseFeatureCount&&e.numFeatures===0||(e.fetchFailed=!0),G(e),e.fetchInformation.value=`Empty tile`,8;let r=this._getMaxRecordCount(e),i=Math.ceil(n/r);if(e.fetchingResolution=e.descriptor.resolution,U(e)||!this.context.capabilities.supportsMaxRecordCountFactor||e.numFeatures<=n&&i>O.MAX_MAX_RECORD_COUNT_FACTOR)return this._fetchPagedTile(e,t);let a=this._createQuery(e);if(a.maxRecordCountFactor=i,e.isRefetching&&e.features&&e.features.length>0){let t=Math.ceil(e.features.length/(1-e.emptyFeatureRatio)/r);a.maxRecordCountFactor=Math.max(t+1,a.maxRecordCountFactor)}e.fetchInformation.value=`Single fetch\n${n} features`;let{features:s,exceededTransferLimit:c,fields:l,missingAttributes:u}=await this._queryFeatures(a,e.fetchingResolution,t),d=c||a.maxRecordCountFactor>=O.MAX_MAX_RECORD_COUNT_FACTOR||n===this._totalFeaturesForTile(e)?9:8,f=await this._frameTask.schedule(()=>{e.exceededTransferLimit.value=!!c;let t=this._removeEmptyFeatures(s,this._getEffectiveTileResolution(e));return e.fetchInformation.value=`Single fetch\n${s.length}/${n} features`,e.setFeatures(s,t,K(l),J(void 0,u)),this._updateTileZQuantization(e),this._maximumFeaturesForTile(e)>n?1:d},t);return o(t),this._invalidateCounts(),f}async _fetchTileAttributes(e,t){let n=e.features,r=new Set(this.context.requiredFields),i=new Set;for(let t of e.missingAttributes?.values()??[])i=i.union(t.intersection(r));let a=this.context.availableFields.filter(t=>!e.availableFields?.has(t)||i.has(t));if(!a.length)return e.attributeRefetchCompletionStatus;a.includes(this._objectIdField)||a.push(this._objectIdField);let s=new Set(n.map(e=>w(e,this._objectIdField))),c=new Map,l=Math.ceil(n.length/(1-e.emptyFeatureRatio)),u=new Set(e.availableFields),d=e.missingAttributes==null?void 0:new Map(Array.from(e.missingAttributes,([e,t])=>[e,new Set(t)])),f=this._queryFeaturePages(e,()=>l,t,{returnGeometry:!1,outFields:a});for await(let e of f){for(let t of e.features){let e=w(t,this._objectIdField);if(s.delete(e)){c.set(e,t);let n=d?.get(e);for(let e of a)Object.hasOwn(t.attributes,e)&&n?.delete(e);n?.size===0&&d?.delete(e)}}for(let{name:t}of e.fields??[])u.add(t);if(d=J(d,e.missingAttributes?.filter(({objectId:e})=>c.has(e))),!s.size)break}return s.size?(e.requestRefetch(),e.startFetch(),this._fetchTile(e,t)):(await this._frameTask.schedule(()=>{o(t);let r=n.map(e=>{let t={...e.attributes,...c.get(w(e,this._objectIdField)).attributes};if(k(e)){let n=e.cloneShallow();return n.attributes=t,n}let n=new T(p(),e.geometry,t);return n.objectId=w(e,this._objectIdField),n.centroid=e.centroid,n}),i=Math.round(n.length*e.emptyFeatureRatio/(1-e.emptyFeatureRatio));e.setFeatures(r,i,u,d),this._setDirty()},t),o(t),e.attributeRefetchCompletionStatus)}async _fetchPagedTile(e,t){let n=0,r,i=this._maximumFeaturesForTile(e),a=null,s,c=this._queryFeaturePages(e,()=>(e.fetchInformation.value=`Paged fetch\n${e.features?.length}/${i} features`,i),t),l=!1;for await(let u of c){let{features:c,fields:d,missingAttributes:f}=u;if(l=!!u.exceededTransferLimit,await this._frameTask.schedule(()=>{n+=this._removeEmptyFeatures(c,this._getEffectiveTileResolution(e)),e.exceededTransferLimit.value=!!l,r=r?.concat(c)??c,a=q(a,d),s=J(s,f),e.setFeatures(r,n,a,s),this._updateTileZQuantization(e),this._invalidateCounts(),this._setDirty()},t),o(t),i=this._maximumFeaturesForTile(e)-(r?.length??0),i<=0)break}return l?8:9}async*_queryFeaturePages(e,t,n,r={}){let i=this._createQuery(e,r.returnGeometry);i.returnGeometry||(i.returnCentroid=!1),r.outFields&&(i.outFields=r.outFields);let a=this._getMaxRecordCount(e),s=0;for(;;){o(n);let r=this._setPagingParameters(i,s,t(),a),c=await this._queryFeatures(i,e.fetchingResolution,n);o(n);let l=c.features.length>0;if(yield c,!r||!c.exceededTransferLimit||!l)return;s+=i.num}}_createFeatureCountQuery(e){let t=this._createQuery(e);return this.context.capabilities.supportsCacheHint&&(t.resultType=void 0,t.cacheHint=!0),t}_createQuery(e,t){let n=this.context.createQuery();if(t!==void 0&&(n.returnGeometry=t),n.resultType=this._resultType(e),!U(e)&&e.descriptor.extent&&this.context.tilingScheme&&(n.geometry=x(e.descriptor.extent,this.context.tilingScheme.spatialReference)),n.returnGeometry&&this._setResolutionParams(n,e),n.resultType!==`tile`&&this.context.capabilities.supportsCacheHint&&(n.cacheHint=!0),H(e)){let{highlightIds:e}=this.context;e&&e.length>Y&&r.getLogger(this).warn(`highlight-too-many-features`,`highlight is limited to ${Y} features on large layers configured with a display filter to avoid performance issues`),n.objectIds=e?.slice(0,Y)}else!V(e)&&this.context.effectiveDisplayFilter&&(n.where=f(n.where,this.context.effectiveDisplayFilter.where));return n}_setPagingParameters(e,t,n,r){let i=n>0&&this.context.capabilities.supportsMaxRecordCountFactor;return i&&(e.maxRecordCountFactor=Math.ceil(n/r)),this.context.capabilities.supportsPagination?(e.start=t,e.num=i?Math.min(e.maxRecordCountFactor*r,n):Math.min(r),!0):!1}_getEffectiveTileResolution(e){if(U(e)||!this._supportsResolution)return null;let t=this.context.viewingMode===1&&this.context.tilingScheme?this.context.tilingScheme.resolutionAtLevel(3):1/0;return Math.min(e.fetchingResolution,t)/this.lodFactor/this._tileZQuantization}get _supportsResolution(){return this.context.capabilities.supportsMultipleResolutions&&this.context.geometryType!==`point`}_setResolutionParams(e,t){let n=this._getEffectiveTileResolution(t);n!=null&&(this.context.capabilities.supportsQuantization?e.quantizationParameters=new D({mode:`view`,originPosition:`upper-left`,tolerance:n,extent:this.context.fullExtent}):this.context.geometryType===`polyline`&&(e.maxAllowableOffset=n))}_removeEmptyFeatures(e,t){let r=e.length;if(t&&this._supportsResolution){let r=t*(1+g());n(e,({geometry:e})=>!e||!E(e)?!1:(ee(e,Q),S(Q)>r||C(Q)>r))}else n(e,({geometry:e})=>E(e));return r-e.length}_needsNumFeatures(e){return this.useTileCount&&e.needsFeatureCount&&!V(e)}_getMaxRecordCount(e){switch(this._resultType(e)){case`tile`:if(this.context.tileMaxRecordCount)return this.context.tileMaxRecordCount;break;case`standard`:if(this.context.standardMaxRecordCount)return this.context.standardMaxRecordCount}return this.context.maxRecordCount||Y}_resultType(e){if(this.context.capabilities.supportsResultType)return V(e)?`standard`:`tile`}get _reduceMode(){let e=this.context.geometryType;return e===`polygon`||e===`polyline`?0:1}_handleRequest(e,t,n,r,i){e.startFetch(),e.requestController=n;let s=!1;t.then(t=>{o(n.signal),e.requestController=null,r(t)}).catch(t=>{e.requestController===n&&(e.requestController=null,e.fetchDone(8)),a(t)?s=!0:i(t)}).then(()=>{s||this._setDirty(),this._scheduleUpdated()})}_scheduleUpdated(){this.hasHandles(`scheduleUpdated`)||this.addHandles(u(()=>{this.removeHandles(`scheduleUpdated`),this._updated()}),`scheduleUpdated`)}_showTile(e){if(e.displayingFeatures&&!e.needsDisplayUpdate)return!1;let t=e.features;if(e.featureLimit===0||!t){let t=e.displayingFeatures!=null&&e.displayingFeatures.length>0;return this._hideTileFeatures(e),e.displayingFeatures=[],t}let n=e.fetchingResolution,{adds:r,updates:i}=this._changes,a=Math.min(e.featureLimit,t.length);for(let e=0;e<a;++e){let a=t[e],o=w(a,this._objectIdField),s=this._displayingFeatureReferences.get(o);if(this._memory.ref(a),s){let{oldVersion:e,newVersion:t}=s.ref(this._memory,a,n);e!==t&&(e&&i.removes.push(e),t&&i.adds.push(t))}else this._displayingFeatureReferences.set(o,new this.FeatureReferenceClass(a,n,this._memory)),r.push(a);this._numDisplayingFeatureReferences++}return this._hideTileFeatures(e),e.displayingResolution=e.fetchingResolution,this._applyChanges(),e.displayingFeatures=t.slice(0,a),!0}_hideTile(e){this._cancelFetchTile(e),this._hideTileFeatures(e)}_hideTileFeatures(e){if(e.displayingFeatures==null)return;let{updates:t,removes:n}=this._changes;for(let r of e.displayingFeatures){this._memory.unref(r);let i=w(r,this._objectIdField),a=this._displayingFeatureReferences.get(i);if(!a)continue;let{oldVersion:o,newVersion:s}=a.unref(this._memory,e.displayingResolution);this._numDisplayingFeatureReferences--,o!==s&&(s==null?(this._displayingFeatureReferences.delete(i),o&&n.push(o)):(t.adds.push(s),o&&t.removes.push(o)))}this._applyChanges(),e.displayingFeatures=null}_notifyDataUpdating(){this._get(`dataUpdating`)||this._set(`dataUpdating`,!0)}_applyChanges(){let e=this._changes.updates;e.removes.length>0&&(this._notifyDataUpdating(),this.features.removeMany(e.removes),e.removes.length=0),e.adds.length>0&&(this._notifyDataUpdating(),this.features.addMany(e.adds),e.adds.length=0);let t=this._changes.adds,n=this._changes.removes,r=Math.min(t.length,n.length),i=0;for(;i<r;){let e=Math.min(i+ae,r);this._notifyDataUpdating(),this.features.addMany(t.slice(i,e)),this.features.removeMany(n.slice(i,e)),i=e}t.length>r&&(this._notifyDataUpdating(),this.features.addMany(i===0?t:t.slice(i))),n.length>r&&(this._notifyDataUpdating(),this.features.removeMany(i===0?n:n.slice(i))),t.length=0,n.length=0}_clearTile(e){this._hideTile(e),e.features&&this.context.memoryCache!=null&&this.context.memoryCache.put(e.id,e.cache),e.setFeatures(null,0,null,void 0),this._invalidateCounts()}_invalidateCounts(){this.notifyChange(`totalVertices`),this.notifyChange(`totalFeatures`)}get _featureTilesArray(){return Array.from(this._featureTiles.values())}get featureTiles(){return this._featureTiles}get storedFeatures(){return this._featureTilesArray.reduce((e,t)=>e+(t.features?t.features.length:0),0)}get missingTiles(){return this._featureTiles.values().reduce((e,t)=>e+(t.needsFetch||t.isFetching?1:0),0)}_totalFeaturesForTile(e){return e.hasPreciseFeatureCount?e.numFeatures:this.maximumNumberOfFeatures}_maximumFeaturesForTile(e){let t=this._totalFeaturesForTile(e),n=this._fullRatio<1?this._farRatio:1;return Math.min(Math.ceil(t*n/(1-e.emptyFeatureRatio)),t)}get test(){}};e([m({constructOnly:!0})],B.prototype,`features`,void 0),e([m({constructOnly:!0})],B.prototype,`context`,void 0),e([m()],B.prototype,`tileDescriptors`,void 0),e([m({value:1/0})],B.prototype,`maximumNumberOfFeatures`,null),e([m({value:1})],B.prototype,`memoryFactor`,null),e([m({value:1})],B.prototype,`lodFactor`,null),e([m()],B.prototype,`useTileCount`,null),e([m({readOnly:!0})],B.prototype,`updating`,null),e([m({readOnly:!0})],B.prototype,`dataUpdating`,void 0),e([m({readOnly:!0})],B.prototype,`updatingTotal`,void 0),e([m({readOnly:!0})],B.prototype,`updatingRemaining`,void 0),e([m({readOnly:!0})],B.prototype,`expectedFeatureDiff`,void 0),e([m()],B.prototype,`usedMemory`,null),e([m()],B.prototype,`usedMemoryPerFeature`,null),e([m({readOnly:!0})],B.prototype,`maximumNumberOfFeaturesExceeded`,void 0),e([m({readOnly:!0})],B.prototype,`totalVertices`,null),e([m({readOnly:!0})],B.prototype,`totalFeatures`,null),e([m({readOnly:!0})],B.prototype,`showsAllFeatures`,null),e([m({readOnly:!0})],B.prototype,`hasFullGeometries`,null),e([m()],B.prototype,`filterExtent`,null),e([m()],B.prototype,`_dirty`,void 0),e([m()],B.prototype,`_suspended`,void 0),e([m()],B.prototype,`_pendingEdits`,void 0),e([m()],B.prototype,`_applyEditsTilesUpdated`,void 0),e([m()],B.prototype,`_paused`,null),e([m()],B.prototype,`snappingComplexityExceeded`,void 0),e([m()],B.prototype,`_isFetching`,void 0),B=e([h(`esri.views.3d.layers.support.FeatureTileFetcher3D`)],B);function V(e){return e.id===I}function H(e){return e.id===F}function U(e){return V(e)||H(e)}function W(e){let t=0;for(let n of e)n.features&&n.features.length>0&&n.alive&&(t=Math.max(t,n.descriptor.lij[0]));return t}function G(e){e.setFeatures([],0,null,void 0)}function K(e){return e==null?new Set:new Set(e.map(e=>e.name))}function q(e,t){if(e==null||t==null)return K(t);let n=new Set;for(let{name:r}of t)e.has(r)&&n.add(r);return n}function J(e,t){if(!t?.length)return e;e??=new Map;let n=()=>new Set;for(let{objectId:r,attribute:a}of t)i(e,r,n).add(a);return e}const Y=2e3,X=_(),Z=_(),Q=_(),$=6e5,ae=200,oe=.95,se=10;export{B as FeatureTileFetcher3D};
2
+ import{__decorate as e}from"tslib";import t from"../../../../core/Accessor.js";import{filterInPlace as n}from"../../../../core/arrayUtils.js";import"../../../../core/has.js";import r from"../../../../core/Logger.js";import{getOrCreateMapValue as i}from"../../../../core/MapUtils.js";import{isAbortError as a,throwIfAborted as o}from"../../../../core/promiseUtils.js";import s from"../../../../core/ReactiveMap.js";import{on as c,watch as l}from"../../../../core/reactiveUtils.js";import{schedule as u}from"../../../../core/scheduling.js";import{signal as d}from"../../../../core/signal.js";import{sqlAnd as f}from"../../../../core/sql.js";import{generateUID as p}from"../../../../core/uid.js";import{property as m,subclass as h}from"../../../../core/accessorSupport/decorators.js";import{getEpsilon as g}from"../../../../core/libs/gl-matrix-2/math/common.js";import{create as _,equals as v,clone as y,expand as b,toExtent as x,width as S,height as C}from"../../../../geometry/support/aaBoundingRect.js";import{getObjectId as w,DehydratedFeatureClass as T,hasVertices as E,computeAABR as ee}from"../../../../layers/graphics/dehydratedFeatures.js";import{geometryKey as te,transferGeometryKey as ne,identicalTransferGeometry as re,completeDehydratedFeatureFromTransfer as ie}from"../../../../layers/graphics/transferFeatures.js";import D from"../../../../rest/support/QuantizationParameters.js";import O from"../../../../rest/support/Query.js";import{isGraphic as k}from"../../../../support/graphicInstanceUtils.js";import{FeatureMemory as A}from"./FeatureMemory.js";import{MultiFeatureReference as j,SingleFeatureReference as M}from"./featureReference.js";import{failedFeatureCount as N,FeatureTile as P}from"./FeatureTile.js";import{virtualDisplayFilterHighlightTileId as F,virtualSnapshotTileId as I}from"./FeatureTileDescriptor.js";import{tilesAreRelated as L}from"../../terrain/tileUtils.js";import{ImmediateTask as R,TaskPriority as z}from"../../../support/Scheduler.js";let B=class extends t{set maximumNumberOfFeatures(e){e||=1/0;let t=this._get(`maximumNumberOfFeatures`);e===t||e<1||(this._set(`maximumNumberOfFeatures`,e),this._maximumFeaturesUpdated(t,e))}set memoryFactor(e){this.memoryFactor!==e&&(this._set(`memoryFactor`,e),this._setDirty())}set lodFactor(e){this.lodFactor!==e&&(this._set(`lodFactor`,e),this._supportsResolution&&this.refetch())}get useTileCount(){return this._useTileCount&&this.context.query.queryFeatureCount!=null}set useTileCount(e){this._useTileCount=e,this.notifyChange(`useTileCount`)}get updating(){return this._dirty||!!this._pendingEdits||this._isFetching||(this.tileDescriptors?.updating??!1)}get readyToRun(){return this._dirty}get usedMemory(){return this._memory.usedMemory}get usedMemoryPerFeature(){return this._memory.usedMemoryPerFeature}get totalVertices(){let e=0;return this._featureTiles.forEach(t=>e+=t.numVertices),e}get totalFeatures(){let e=0;return this._featureTiles.forEach(t=>e+=t.numFeatures),e}get showsAllFeatures(){if(this._paused||this.dataUpdating)return!1;for(let e of this._featureTiles.values())if(!this.hasFullGeometries&&e.emptyFeatureRatio!==0||!e.showsAllFeatures)return!1;return!0}get hasFullGeometries(){return!this._supportsResolution||this.tileDescriptors?.some(V)||!this.context.capabilities.supportsQuantization&&this.context.geometryType!==`polyline`}set filterExtent(e){if(e!=null&&this.context.tilingScheme&&!e.spatialReference.equals(this.context.tilingScheme.spatialReference)){r.getLogger(this).error(`#filterExtent=`,`extent needs to be in the same spatial reference as the tiling scheme`);return}let t=this._get(`filterExtent`);if(t===e||t!=null&&e&&t.equals(e))return;let n=e==null?null:e.clone();this._set(`filterExtent`,n),this._reclip(n,t)}_updateTileZQuantization(e){if(this.context.viewingMode===1){let t=e.computeZQuantizationFactor();this._zQuantizationFactor.value<t&&(this._zQuantizationFactor.value=t)}}get _tileZQuantization(){return this.context.isDraped?1:this._zQuantizationFactor.value}constructor(e){super(e),this._useTileCount=!1,this.dataUpdating=!1,this.updatingTotal=0,this.updatingRemaining=0,this.expectedFeatureDiff=0,this.maximumNumberOfFeaturesExceeded=!1,this._fullRatio=1,this._farRatio=1,this._zQuantizationFactor=d(1),this._changes={updates:{adds:[],removes:[]},adds:[],removes:[]},this._featureTiles=new s,this._displayingFeatureReferences=new Map,this._numDisplayingFeatureReferences=0,this._memory=new A(te),this._dirty=!1,this._suspended=!0,this._pendingEdits=null,this._applyEditsTilesUpdated=!1,this.snappingComplexityExceeded=!0,this._isFetching=!1;let t=e.context;this._frameTask=t.scheduler?.registerTask(z.FEATURE_TILE_FETCHER,this)??R,this.FeatureReferenceClass=t.capabilities.supportsMultipleResolutions?j:M,this._objectIdField=t.objectIdField}initialize(){this.addHandles([c(()=>this.tileDescriptors,`change`,()=>this._setDirty(),{onListenerAdd:()=>this._setDirty(),onListenerRemove:()=>this._setDirty()}),l(()=>this._tileZQuantization,()=>this.refetch())]),this._setDirty()}destroy(){this._frameTask.remove(),this._featureTiles.forEach(e=>{this._cancelFetchTile(e),this._removeTile(e)}),this._featureTiles.clear(),this._displayingFeatureReferences.clear(),this._pendingEdits?.controller.abort(),this._pendingEdits=null}get _paused(){return this._suspended||!!this._pendingEdits}restart(){this._featureTiles.forEach(e=>{this._cancelFetchTile(e),this._clearTile(e),this._resetFetchTile(e)}),this.context.memoryCache!=null&&this.context.memoryCache.clear(),this._setDirty()}refetch(){this._featureTiles.forEach(e=>{this._cancelFetchTile(e),this._resetFetchTile(e)}),this.context.memoryCache!=null&&this.context.memoryCache.clear(),this._setDirty()}refetchAttributes(){this._featureTiles.forEach(e=>{let t=e.isFetched||e.needsAttributesFetching;this._cancelFetchTile(e),e.features?.length&&t?e.requestAttributes():this._resetFetchTile(e)}),this.context.memoryCache?.clear(),this._setDirty()}refetchDisplayFilterHighlightTile(){let e=this._featureTiles.get(F);e&&(this._cancelFetchTile(e),this._resetFetchTile(e),this._setDirty())}suspend(){this._suspended||(this._suspended=!0,this._pause(),this._setDirty())}resume(){this._suspended&&(this._suspended=!1,this._unpause())}getMissingAttributesForFeature(e){for(let t of this._featureTiles.values()){let n=t.missingAttributes?.get(e);if(n!=null)return n}}hasMissingAttributes(e){return this._featureTiles.values().some(t=>t?.missingAttributes?.values().some(t=>e.some(e=>t.has(e))))}_pause(){this._paused&&(this._featureTiles.forEach(e=>this._cancelFetchTile(e)),this._updated())}_unpause(){this._paused||this._setDirty()}get availableFields(){let e=null;return this._featureTiles.forEach(t=>{t.displayingFeatures!=null&&t.displayingFeatures.length!==0&&(e==null?e=new Set(t.availableFields):e.forEach(n=>{t.availableFields?.has(n)||e.delete(n)}))}),e??new Set}applyEdits(e){this._pendingEdits||(this._pendingEdits={edits:Promise.resolve(),count:0,controller:new AbortController},this._pause());let t=this._pendingEdits;t.count++;let n=t.edits.then(()=>e.result.catch(e=>{if(a(e))throw e;return null}).then(e=>e&&(this._applyEditsDeleteFeatures(e.deletedFeatures),this._applyEditsAddUpdateFeatures(e.addedFeatures,e.updatedFeatures,t.controller.signal).then(()=>e))).then(e=>(--t.count===0&&(this._pendingEdits===t&&(this._pendingEdits=null),this.context.memoryCache!=null&&this.context.memoryCache.clear(),this._applyEditsTilesUpdated=!1,this._unpause()),e)));return t.edits=n,this._updated(),n}_applyEditsDeleteFeatures(e){if(e.length===0)return;let t=this.context.globalIdField,n=t&&this.availableFields.has(t),i=new Set,a=this._objectIdField;e.forEach(({objectId:e,globalId:o})=>{(!e||e<0)&&t&&o&&(n||r.getLogger(this).errorOncePerTick(`Editing the specified service requires the layer's globalIdField, ${t} to be included the layer's outFields for updates to be reflected in the view`),e=this._objectIdFromGlobalId(o,a,t)),e!=null&&e>=0&&i.add(e)}),this._featureTiles.forEach(e=>{if(!e.features)return;let t=e.features.filter(e=>!i.has(w(e,this._objectIdField)));t.length!==e.features.length&&(this._applyEditsTileUpdated(),e.setFeatures(t,0,e.availableFields,e.missingAttributes),this._updateTileZQuantization(e),this._invalidateCounts())})}_objectIdFromGlobalId(e,t,n){if(e==null)return null;let r=this.features.find(t=>t.attributes?.[n]===e);return r?w(r,t):null}async _applyEditsAddUpdateFeatures(e,t,n){let{objectIdField:i,globalIdField:a}=this.context,o=a&&this.availableFields.has(a),s=new Set,c=new Set;for(let t of e){let e=t.objectId;e!=null&&s.add(e)}for(let{objectId:e,globalId:n}of t){let t=e;(t==null||t<0)&&a&&(o||r.getLogger(this).errorOncePerTick(`Editing the specified service requires the layer's globalIdField, ${a} to be included the layer's outFields for updates to be reflected in the view`),t=this._objectIdFromGlobalId(n,i,a)),t!=null&&t>=0&&(s.add(t),c.add(t))}if(s.size===0)return;let l=[];this._featureTiles.forEach(e=>{let t=this._applyEditsAddUpdateTile(e,s,c,n);l.push(t)}),this._updated(),await Promise.allSettled(l)}async _applyEditsAddUpdateTile(e,t,n,r){if(!e.features)return;e.fetchingResolution=e.descriptor.resolution;let i=this._createQuery(e);i.resultType=void 0,i.cacheHint=!1,i.objectIds=Array.from(t);let a=await this.context.query.queryFeaturesDehydrated(i,{signal:r,timeout:$}),o=null;if(n.size>0){let t=e.features.filter(e=>!n.has(w(e,this._objectIdField)));t.length!==e.features.length&&(o=t)}if(a.features.length>0){o||=e.features.slice();for(let e of a.features)o.push(e)}o&&(e.hasPreciseFeatureCount&&(e.numFeatures=Math.max(e.numFeatures,o.length)),this._applyEditsTileUpdated(),e.setFeatures(o,0,q(e.availableFields,a.fields),J(e.missingAttributes,a.missingAttributes),void 0,!1),this._updateTileZQuantization(e),this._invalidateCounts())}_applyEditsTileUpdated(){this._applyEditsTilesUpdated||(this._applyEditsTilesUpdated=!0,this._updated())}_queryFeatures(e,t,n){return this.context.query.queryFeaturesDehydrated(e,{signal:n,timeout:$,completeFeatureFromTransfer:(e,n,r)=>{let i=ne(e.geometry,n,t),a=this._memory.findGeometry(i,t=>re(e.geometry,n,t));a?e.geometry=a:ie(e,n,r)}})}_setDirty(){this._dirty=!0,this._updated()}runTask(e){let t=this._frameTask.processQueue(e);if(!this._dirty||!this.initialized)return t;this._dirty=!1;let n=this._featureTilesArray;if(this._markTilesNotAlive(n),!e.run(()=>this._addTiles(n,e))||!e.run(()=>this._filterExtentTiles(n,e))||!e.run(()=>this._removeTiles(n,e))||e.done){this._setDirty();return}let r=this._sortTiles(n);e.run(()=>this._showTiles(r,e))&&e.run(()=>this._fetchTiles(r,e))&&e.run(()=>this._updateMemoryEstimates(r,e))||this._setDirty(),this._updated(),this.updating||(this._updateMaximumNumberOfFeaturesExceeded(),this._updateSnappingComplexityExceeded(r))}_updateSnappingComplexityExceeded(e){let t=se;for(let n of e){if(V(n)||t<=0)break;if(!H(n)&&(t--,n.sampledDensityEstimate>oe)){this.snappingComplexityExceeded=!0;return}}this.snappingComplexityExceeded=this._featureTiles.size===0}_markTilesNotAlive(e){for(let t of e)t.alive=!1}_addTiles(e,t){return this._suspended||!this.tileDescriptors?!1:(this.tileDescriptors.forEach(n=>{let r=this._featureTiles.get(n.id);r?r.alive=!0:t.done||(e.push(this._addTile(n)),t.madeProgress())}),t.hasProgressed)}_filterExtentTiles(e,t){for(let n of e){if(t.done)break;n.alive&&(n.filtered=!n.intersects(this.filterExtent),n.filtered&&(this._clearTile(n),t.madeProgress()))}return t.hasProgressed}_removeTiles(e,t){for(let n=e.length-1;n>=0&&!t.done;n--){let r=e[n];r.alive||(this._removeTile(r),n!==e.length-1&&(e[n]=e[e.length-1]),e.pop(),t.madeProgress())}return t.hasProgressed}_sortTiles(e){return e.sort((e,t)=>e.descriptor.loadPriority-t.descriptor.loadPriority),e}_showTiles(e,t){let n=this._updateRatio(e),r=e=>{let t=this._fullRatio<1?n(e)*this._farRatio:1;e.reduceFeatures(t,this.memoryFactor,this._objectIdField,this._reduceMode)&&this._setDirty();let{numFeatures:r,fetchingResolution:i,descriptor:a,isFetched:o}=e;return this._supportsResolution&&r>0&&i!==a.resolution&&o&&(e.requestRefetch(),this._setDirty()),this._showTile(e)};for(let n of e)if(!t.run(()=>r(n))){this._setDirty();break}return t.hasProgressed}_fetchTiles(e,t){if(this._paused)return!1;let n=!1;for(let r of e){if(!r.needsFetch)continue;let e=this.context.memoryCache==null?null:this.context.memoryCache.pop(r.id);if(e?.resolution===r.displayingResolution)r.cache=e,r.numFeatures&&this._notifyDataUpdating(),this._setDirty(),this._scheduleUpdated(),t.madeProgress();else{if(this._needsNumFeatures(r)){let e=new AbortController,i=this._fetchTileCount(r,e.signal);this._handleRequest(r,i,e,()=>r.resetFetching(),()=>r.numFeatures=N),n=!0,t.madeProgress()}if(t.done)return!0}}if(n)return t.hasProgressed;for(let n of e){if(!n.needsFetch)continue;let e=new AbortController,i=this._fetchTile(n,e.signal);if(this._handleRequest(n,i,e,e=>n.fetchDone(e),e=>{n.fetchFailed=!0,this.context.logFetchError(r.getLogger(this),e)}),t.madeProgress(),t.done)return!0}return t.hasProgressed}_updateMemoryEstimates(e,t){return e.some(e=>!t.run(()=>e.updateEstimates())&&(this._setDirty(),!0)),t.hasProgressed}_reclip(e,t){if(!this.initialized)return;let n=[];this._featureTiles.forEach(r=>{r.displayingFeatures!=null&&r.displayingFeatures.length!==0&&(r.intersectionIncludingBorrowed(t,X),r.intersectionIncludingBorrowed(e,Z),v(X,Z)||n.push(r))}),this._refreshDisplayingFeatures(n),this._updated()}_refreshDisplayingFeatures(e){let t=new Set,n=this._changes.updates;for(let r of e)if(r.displayingFeatures!=null)for(let e of r.displayingFeatures){let r=w(e,this._objectIdField);if(t.has(r))continue;t.add(r);let i=this._displayingFeatureReferences.get(r).feature;n.removes.push(i),n.adds.push(i)}this._applyChanges()}_updated(){let e=0;if(this._paused||this._featureTiles.forEach(t=>t.isFetching?++e:0),this._isFetching=e>0,e>0||this._applyEditsTilesUpdated?this._notifyDataUpdating():this._dirty||this._set(`dataUpdating`,!1),this.updating){let t=0,n=0,r=0,i=0,a=0,o=this._displayingFeatureReferences.size/this._numDisplayingFeatureReferences;this._featureTiles.forEach(e=>{if(++n,e.isFetching&&e.hasPreciseFeatureCount){let t=this._maximumFeaturesForTile(e)*(1-e.emptyFeatureRatio),n=e.displayingFeatures==null?0:e.displayingFeatures.length*o;a+=t-n}e.needsFetch?++i:e.numFeatures>0&&(++r,t+=e.numFeatures)}),i+=e;let s=0,c=0;t?(c=t,s=Math.min(i*t/r,t)):(c=n,s=i),a=Math.min(this.maximumNumberOfFeatures-this.features.length,a),this._set(`updatingTotal`,c),this._set(`updatingRemaining`,s),this._set(`expectedFeatureDiff`,a)}else this._set(`updatingTotal`,0),this._set(`updatingRemaining`,0),this._set(`expectedFeatureDiff`,0);this.debugger?.update()}_updateMaximumNumberOfFeaturesExceeded(){for(let{perTileMaximumNumberOfFeaturesExceeded:e}of this._featureTiles.values())if(e){this._set(`maximumNumberOfFeaturesExceeded`,!0);return}this._set(`maximumNumberOfFeaturesExceeded`,!1)}_updateRatio(e){let t=W(e),n=e=>1/(1<<Math.max(0,t-e.descriptor.lij[0])),r=0,i=0;for(let t of e){let e=t.numFeatures;r+=e,i+=e*n(t)}return this._fullRatio=Math.min(1,this.maximumNumberOfFeatures/r),this._farRatio=this.maximumNumberOfFeatures/i,this._scheduleUpdated(),n}_maximumFeaturesUpdated(e,t){e!==t&&(t>e&&this._featureTiles.forEach(e=>{if(!e.featuresMissing)return;let t=this._maximumFeaturesForTile(e);e.isFullyFetched(t)||(this._cancelFetchTile(e),this._resetFetchTile(e))}),this._setDirty())}_addTile(e){let t=new P(e,this._memory);return this._featureTiles.set(t.id,t),this._resetFetchTile(t),this._referenceDisplayingFeaturesFromRelatedTiles(t),t}_referenceDisplayingFeaturesFromRelatedTiles(e){let t=e.displayingResolution,n=new Set;this._featureTiles.forEach(r=>{if(r.displayingFeatures!=null&&e!==r&&L(e.descriptor.lij,r.descriptor.lij)){e.displayingFeatures??=[],e.descriptor.extent&&r.descriptor.extent&&(e.extentIncludingBorrowedFeatures??=y(e.descriptor.extent),b(e.extentIncludingBorrowedFeatures,r.descriptor.extent,e.extentIncludingBorrowedFeatures));for(let i of r.displayingFeatures){let r=w(i,this._objectIdField);if(n.has(r))continue;n.add(r),e.displayingFeatures.push(i),this._memory.ref(i);let a=this._displayingFeatureReferences.get(r);a.ref(this._memory,a.feature,t),this._numDisplayingFeatureReferences++}}})}_removeTile(e){this._clearTile(e),this._featureTiles.delete(e.id)}_resetFetchTile(e){e.filtered=!e.intersects(this.filterExtent),e.filtered?e.needsFetch&&e.fetchDone(8):e.requestFetch()}_cancelFetchTile(e){let t=e.requestController;t!=null&&(e.requestController=null,e.resetFetching(),t.abort())}async _fetchTileCount(e,t){e.numFeatures=await this.context.query.queryFeatureCount(this._createFeatureCountQuery(e),{signal:t}),this._updateRatio(this._featureTilesArray)}async _fetchTile(e,t){if(e.fetchFailed=!1,e.needsAttributesFetching&&e.features?.length)return this._fetchTileAttributes(e,t);let n=this._maximumFeaturesForTile(e);if(n<=0)return e.hasPreciseFeatureCount&&e.numFeatures===0||(e.fetchFailed=!0),G(e),e.fetchInformation.value=`Empty tile`,8;let r=this._getMaxRecordCount(e),i=Math.ceil(n/r);if(e.fetchingResolution=e.descriptor.resolution,U(e)||!this.context.capabilities.supportsMaxRecordCountFactor||e.numFeatures<=n&&i>O.MAX_MAX_RECORD_COUNT_FACTOR)return this._fetchPagedTile(e,t);let a=this._createQuery(e);if(a.maxRecordCountFactor=i,e.isRefetching&&e.features&&e.features.length>0){let t=Math.ceil(e.features.length/(1-e.emptyFeatureRatio)/r);a.maxRecordCountFactor=Math.max(t+1,a.maxRecordCountFactor)}e.fetchInformation.value=`Single fetch\n${n} features`;let{features:s,exceededTransferLimit:c,fields:l,missingAttributes:u}=await this._queryFeatures(a,e.fetchingResolution,t),d=c||a.maxRecordCountFactor>=O.MAX_MAX_RECORD_COUNT_FACTOR||n===this._totalFeaturesForTile(e)?9:8,f=await this._frameTask.schedule(()=>{e.exceededTransferLimit.value=!!c;let t=this._removeEmptyFeatures(s,this._getEffectiveTileResolution(e));return e.fetchInformation.value=`Single fetch\n${s.length}/${n} features`,e.setFeatures(s,t,K(l),J(void 0,u)),this._updateTileZQuantization(e),this._maximumFeaturesForTile(e)>n?1:d},t);return o(t),this._invalidateCounts(),f}async _fetchTileAttributes(e,t){let n=e.features,r=new Set(this.context.requiredFields),i=new Set;for(let t of e.missingAttributes?.values()??[])i=i.union(t.intersection(r));let a=this.context.availableFields.filter(t=>!e.availableFields?.has(t)||i.has(t));if(!a.length)return e.attributeRefetchCompletionStatus;a.includes(this._objectIdField)||a.push(this._objectIdField);let s=new Set(n.map(e=>w(e,this._objectIdField))),c=new Map,l=Math.ceil(n.length/(1-e.emptyFeatureRatio)),u=new Set(e.availableFields),d=e.missingAttributes==null?void 0:new Map(Array.from(e.missingAttributes,([e,t])=>[e,new Set(t)])),f=this._queryFeaturePages(e,()=>l,t,{returnGeometry:!1,outFields:a});for await(let e of f){for(let t of e.features){let e=w(t,this._objectIdField);if(s.delete(e)){c.set(e,t);let n=d?.get(e);for(let e of a)Object.hasOwn(t.attributes,e)&&n?.delete(e);n?.size===0&&d?.delete(e)}}for(let{name:t}of e.fields??[])u.add(t);if(d=J(d,e.missingAttributes?.filter(({objectId:e})=>c.has(e))),!s.size)break}return s.size?(e.requestRefetch(),e.startFetch(),this._fetchTile(e,t)):(await this._frameTask.schedule(()=>{o(t);let r=n.map(e=>{let t={...e.attributes,...c.get(w(e,this._objectIdField)).attributes};if(k(e)){let n=e.cloneShallow();return n.attributes=t,n}let n=new T(p(),e.geometry,t);return n.objectId=w(e,this._objectIdField),n.centroid=e.centroid,n}),i=Math.round(n.length*e.emptyFeatureRatio/(1-e.emptyFeatureRatio));e.setFeatures(r,i,u,d),this._setDirty()},t),o(t),e.attributeRefetchCompletionStatus)}async _fetchPagedTile(e,t){let n=0,r,i=this._maximumFeaturesForTile(e),a=null,s,c=this._queryFeaturePages(e,()=>(e.fetchInformation.value=`Paged fetch\n${e.features?.length}/${i} features`,i),t),l=!1;for await(let u of c){let{features:c,fields:d,missingAttributes:f}=u;if(l=!!u.exceededTransferLimit,await this._frameTask.schedule(()=>{n+=this._removeEmptyFeatures(c,this._getEffectiveTileResolution(e)),e.exceededTransferLimit.value=!!l,r=r?.concat(c)??c,a=q(a,d),s=J(s,f),e.setFeatures(r,n,a,s),this._updateTileZQuantization(e),this._invalidateCounts(),this._setDirty()},t),o(t),i=this._maximumFeaturesForTile(e)-(r?.length??0),i<=0)break}return l?8:9}async*_queryFeaturePages(e,t,n,r={}){let i=this._createQuery(e,r.returnGeometry);i.returnGeometry||(i.returnCentroid=!1),r.outFields&&(i.outFields=r.outFields);let a=this._getMaxRecordCount(e),s=0;for(;;){o(n);let r=this._setPagingParameters(i,s,t(),a),c=await this._queryFeatures(i,e.fetchingResolution,n);o(n);let l=c.features.length>0;if(yield c,!r||!c.exceededTransferLimit||!l)return;s+=i.num}}_createFeatureCountQuery(e){let t=this._createQuery(e);return this.context.capabilities.supportsCacheHint&&(t.resultType=void 0,t.cacheHint=!0),t}_createQuery(e,t){let n=this.context.createQuery();if(t!==void 0&&(n.returnGeometry=t),n.resultType=this._resultType(e),!U(e)&&e.descriptor.extent&&this.context.tilingScheme&&(n.geometry=x(e.descriptor.extent,this.context.tilingScheme.spatialReference)),n.returnGeometry&&this._setResolutionParams(n,e),n.resultType!==`tile`&&this.context.capabilities.supportsCacheHint&&(n.cacheHint=!0),H(e)){let{highlightIds:e}=this.context;e&&e.length>Y&&r.getLogger(this).warn(`highlight-too-many-features`,`highlight is limited to ${Y} features on large layers configured with a display filter to avoid performance issues`),n.objectIds=e?.slice(0,Y)}else!V(e)&&this.context.effectiveDisplayFilter&&(n.where=f(n.where,this.context.effectiveDisplayFilter.where));return n}_setPagingParameters(e,t,n,r){let i=n>0&&this.context.capabilities.supportsMaxRecordCountFactor;return i&&(e.maxRecordCountFactor=Math.ceil(n/r)),this.context.capabilities.supportsPagination?(e.start=t,e.num=i?Math.min(e.maxRecordCountFactor*r,n):Math.min(r),!0):!1}_getEffectiveTileResolution(e){if(U(e)||!this._supportsResolution)return null;let t=this.context.viewingMode===1&&this.context.tilingScheme?this.context.tilingScheme.resolutionAtLevel(3):1/0;return Math.min(e.fetchingResolution,t)/this.lodFactor/this._tileZQuantization}get _supportsResolution(){return this.context.capabilities.supportsMultipleResolutions&&this.context.geometryType!==`point`}_setResolutionParams(e,t){let n=this._getEffectiveTileResolution(t);n!=null&&(this.context.capabilities.supportsQuantization?e.quantizationParameters=new D({mode:`view`,originPosition:`upper-left`,tolerance:n,extent:this.context.fullExtent}):this.context.geometryType===`polyline`&&(e.maxAllowableOffset=n))}_removeEmptyFeatures(e,t){let r=e.length;if(t&&this._supportsResolution){let r=t*(1+g());n(e,({geometry:e})=>!e||!E(e)?!1:(ee(e,Q),S(Q)>r||C(Q)>r))}else n(e,({geometry:e})=>E(e));return r-e.length}_needsNumFeatures(e){return this.useTileCount&&e.needsFeatureCount&&!V(e)}_getMaxRecordCount(e){switch(this._resultType(e)){case`tile`:if(this.context.tileMaxRecordCount)return this.context.tileMaxRecordCount;break;case`standard`:if(this.context.standardMaxRecordCount)return this.context.standardMaxRecordCount}return this.context.maxRecordCount||Y}_resultType(e){if(this.context.capabilities.supportsResultType)return V(e)?`standard`:`tile`}get _reduceMode(){let e=this.context.geometryType;return e===`polygon`||e===`polyline`?0:1}_handleRequest(e,t,n,r,i){e.startFetch(),e.requestController=n;let s=!1;t.then(t=>{o(n.signal),e.requestController=null,r(t)}).catch(t=>{e.requestController===n&&(e.requestController=null,e.fetchDone(8)),a(t)?s=!0:i(t)}).then(()=>{s||this._setDirty(),this._scheduleUpdated()})}_scheduleUpdated(){this.hasHandles(`scheduleUpdated`)||this.addHandles(u(()=>{this.removeHandles(`scheduleUpdated`),this._updated()}),`scheduleUpdated`)}_showTile(e){if(e.displayingFeatures&&!e.needsDisplayUpdate)return!1;let t=e.features;if(e.featureLimit===0||!t){let t=e.displayingFeatures!=null&&e.displayingFeatures.length>0;return this._hideTileFeatures(e),e.displayingFeatures=[],t}let n=e.fetchingResolution,{adds:r,updates:i}=this._changes,a=Math.min(e.featureLimit,t.length);for(let e=0;e<a;++e){let a=t[e],o=w(a,this._objectIdField),s=this._displayingFeatureReferences.get(o);if(this._memory.ref(a),s){let{oldVersion:e,newVersion:t}=s.ref(this._memory,a,n);e!==t&&(e&&i.removes.push(e),t&&i.adds.push(t))}else this._displayingFeatureReferences.set(o,new this.FeatureReferenceClass(a,n,this._memory)),r.push(a);this._numDisplayingFeatureReferences++}return this._hideTileFeatures(e),e.displayingResolution=e.fetchingResolution,this._applyChanges(),e.displayingFeatures=t.slice(0,a),!0}_hideTile(e){this._cancelFetchTile(e),this._hideTileFeatures(e)}_hideTileFeatures(e){if(e.displayingFeatures==null)return;let{updates:t,removes:n}=this._changes;for(let r of e.displayingFeatures){this._memory.unref(r);let i=w(r,this._objectIdField),a=this._displayingFeatureReferences.get(i);if(!a)continue;let{oldVersion:o,newVersion:s}=a.unref(this._memory,e.displayingResolution);this._numDisplayingFeatureReferences--,o!==s&&(s==null?(this._displayingFeatureReferences.delete(i),o&&n.push(o)):(t.adds.push(s),o&&t.removes.push(o)))}this._applyChanges(),e.displayingFeatures=null}_notifyDataUpdating(){this._get(`dataUpdating`)||this._set(`dataUpdating`,!0)}_applyChanges(){let e=this._changes.updates;e.removes.length>0&&(this._notifyDataUpdating(),this.features.removeMany(e.removes),e.removes.length=0),e.adds.length>0&&(this._notifyDataUpdating(),this.features.addMany(e.adds),e.adds.length=0);let t=this._changes.adds,n=this._changes.removes,r=Math.min(t.length,n.length),i=0;for(;i<r;){let e=Math.min(i+ae,r);this._notifyDataUpdating(),this.features.addMany(t.slice(i,e)),this.features.removeMany(n.slice(i,e)),i=e}t.length>r&&(this._notifyDataUpdating(),this.features.addMany(i===0?t:t.slice(i))),n.length>r&&(this._notifyDataUpdating(),this.features.removeMany(i===0?n:n.slice(i))),t.length=0,n.length=0}_clearTile(e){this._hideTile(e),e.features&&this.context.memoryCache!=null&&this.context.memoryCache.put(e.id,e.cache),e.setFeatures(null,0,null,void 0),this._invalidateCounts()}_invalidateCounts(){this.notifyChange(`totalVertices`),this.notifyChange(`totalFeatures`)}get _featureTilesArray(){return Array.from(this._featureTiles.values())}get featureTiles(){return this._featureTiles}get storedFeatures(){return this._featureTilesArray.reduce((e,t)=>e+(t.features?t.features.length:0),0)}get missingTiles(){return this._featureTiles.values().reduce((e,t)=>e+(t.needsFetch||t.isFetching?1:0),0)}_totalFeaturesForTile(e){return e.hasPreciseFeatureCount?e.numFeatures:this.maximumNumberOfFeatures}_maximumFeaturesForTile(e){let t=this._totalFeaturesForTile(e),n=this._fullRatio<1?this._farRatio:1;return Math.min(Math.ceil(t*n/(1-e.emptyFeatureRatio)),t)}get test(){}};e([m({constructOnly:!0})],B.prototype,`features`,void 0),e([m({constructOnly:!0})],B.prototype,`context`,void 0),e([m()],B.prototype,`tileDescriptors`,void 0),e([m({value:1/0})],B.prototype,`maximumNumberOfFeatures`,null),e([m({value:1})],B.prototype,`memoryFactor`,null),e([m({value:1})],B.prototype,`lodFactor`,null),e([m()],B.prototype,`useTileCount`,null),e([m({readOnly:!0})],B.prototype,`updating`,null),e([m({readOnly:!0})],B.prototype,`dataUpdating`,void 0),e([m({readOnly:!0})],B.prototype,`updatingTotal`,void 0),e([m({readOnly:!0})],B.prototype,`updatingRemaining`,void 0),e([m({readOnly:!0})],B.prototype,`expectedFeatureDiff`,void 0),e([m()],B.prototype,`usedMemory`,null),e([m()],B.prototype,`usedMemoryPerFeature`,null),e([m({readOnly:!0})],B.prototype,`maximumNumberOfFeaturesExceeded`,void 0),e([m({readOnly:!0})],B.prototype,`totalVertices`,null),e([m({readOnly:!0})],B.prototype,`totalFeatures`,null),e([m({readOnly:!0})],B.prototype,`showsAllFeatures`,null),e([m({readOnly:!0})],B.prototype,`hasFullGeometries`,null),e([m()],B.prototype,`filterExtent`,null),e([m()],B.prototype,`_dirty`,void 0),e([m()],B.prototype,`_suspended`,void 0),e([m()],B.prototype,`_pendingEdits`,void 0),e([m()],B.prototype,`_applyEditsTilesUpdated`,void 0),e([m()],B.prototype,`_paused`,null),e([m()],B.prototype,`snappingComplexityExceeded`,void 0),e([m()],B.prototype,`_isFetching`,void 0),B=e([h(`esri.views.3d.layers.support.FeatureTileFetcher3D`)],B);function V(e){return e.id===I}function H(e){return e.id===F}function U(e){return V(e)||H(e)}function W(e){let t=0;for(let n of e)n.features&&n.features.length>0&&n.alive&&(t=Math.max(t,n.descriptor.lij[0]));return t}function G(e){e.setFeatures([],0,null,void 0)}function K(e){return e==null?new Set:new Set(e.map(e=>e.name))}function q(e,t){if(e==null||t==null)return K(t);let n=new Set;for(let{name:r}of t)e.has(r)&&n.add(r);return n}function J(e,t){if(!t?.length)return e;e??=new Map;let n=()=>new Set;for(let{objectId:r,attribute:a}of t)i(e,r,n).add(a);return e}const Y=2e3,X=_(),Z=_(),Q=_(),$=6e5,ae=200,oe=.95,se=10;export{B as FeatureTileFetcher3D};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import{EventedAccessor as t}from"../../../../core/Evented.js";import n from"../../../../core/Logger.js";import{getMetersPerVerticalUnitForSR as r}from"../../../../core/units.js";import{property as i,subclass as a}from"../../../../core/accessorSupport/decorators.js";import{copy as o}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as s,ZEROS as c}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{isEmpty as l,copy as u,center as d,diameter as f,squaredDistanceToPoint as p}from"../../../../geometry/support/aaBoundingBox.js";import{allFinite as m}from"../../../../geometry/support/aaBoundingRect.js";import{getInfo as h}from"../../../../geometry/support/spatialReferenceUtils.js";import{getMetersPerUnit as g}from"../../../../symbols/support/unitConversionUtils.js";import{ElevationUpdateEvent as _}from"../../support/ElevationUpdateEvent.js";import{ProjectedElevationUpdateExtent as v,calculateElevationUpdateExtents as y,fullWorldElevationUpdateExtent as b,planetCenterProximityToleranceMeters as x}from"../../support/elevationUpdateExtentUtils.js";import{affectsGeometry as S}from"../../webgl-engine/lib/affectsGeometry.js";import{Intersector as C}from"../../webgl-engine/lib/Intersector.js";const w=Symbol(`layerHandles`);let T=class extends t{get spatialReference(){return this.view.spatialReference}constructor(e){super(e),this._elevationOffset=0}initialize(){this._renderCoordsHelper=this.view.renderCoordsHelper,this._projectedExtent=new v(this._renderCoordsHelper),this._intersectLayers=[this.stageLayer],this._intersector=new C(this.view.state.viewingMode),this._intersector.options.store=0;let[e,t]=this._computeLayerElevationRange(this.spatialReference,this.stageLayer);this._zmin=e,this._zmax=t;let n=this.stageLayer.events;this.addHandles([n.on([`layerObjectAdded`,`layerObjectRemoved`,`transformationChanged`,`shaderTransformationChanged`],e=>this._objectChanged(e)),n.on([`geometryAdded`,`geometryRemoved`],({object:e})=>this._objectChanged(e)),n.on(`attributesChanged`,({attribute:e,object:t})=>S(e)&&this._objectChanged(t))],w)}destroy(){this.removeHandles(w)}elevationInfoChanged(){let e=this.layer==null?null:this.layer.elevationInfo;if(e!=null&&e.mode!==`on-the-ground`){let t=r(this.layer.spatialReference),n=g(e.unit??`meters`);this._elevationOffset=(e.offset??0)*n/t}else this._elevationOffset=0}getElevation(e,t,r,i){if(j[0]=e,j[1]=t,j[2]=r,!this._renderCoordsHelper.toRenderCoords(j,i,j))return n.getLogger(this).error(`could not project point for elevation alignment`),null;let a=this._elevationOffset,o=this._zmin+a,s=this._zmax+a;return this._renderCoordsHelper.setAltitude(N,s,j),this._renderCoordsHelper.setAltitude(P,o,j),this._intersector.reset(N,P,null),this._intersector.intersect(this._intersectLayers,null,1,null,e=>!!e.lastValidElevationBB),this._intersector.results.min.getIntersectionPoint(j)?this._renderCoordsHelper.getAltitude(j):null}_objectChanged(e){let t=this.spatialReference;if(!e.lastValidElevationBB||!t)return;let n=e.lastValidElevationBB,{box:r,sphere:i}=e.boundingVolumeWorldSpace;if(this.view.state.viewingMode===1&&(!l(n)&&E(n)||E(r))){this._emitFullExtentElevationChange(t),u(n,r);return}let a=!l(n),o=new Float64Array(a?8:4),s=1/0,c=-1/0,d=!1;if(a&&(this._resetProjectedExtent(n,t),this._expandExtent(t,n,k,this._projectedExtent)||(d=!0),m(this._projectedExtent.extent)?(s=Math.min(s,k[0]),c=Math.max(c,k[1]),o.set(this._projectedExtent.extent)):d=!0),this._projectedExtent.reset(i.center,i.radius,t),this._expandExtent(t,r,D,this._projectedExtent)||(d=!0),m(this._projectedExtent.extent)?(s=Math.min(s,D[0]),c=Math.max(c,D[1]),o.set(this._projectedExtent.extent,a?4:0)):d=!0,d){this._emitFullExtentElevationChange(t),u(n,r);return}let f=y(o,t);f.length>0&&(this._zmin=Math.min(this._zmin,s),this._zmax=Math.max(this._zmax,c));for(let e of f)this._emitElevationChangeEvent(e,t);u(n,r)}_computeLayerElevationRange(e,t){let n=1/0,r=-1/0;return e!=null&&t.objects.forEach(t=>{this._expandExtent(e,t.boundingVolumeWorldSpace.box,O)&&(n=Math.min(n,O[0]),r=Math.max(r,O[1]))}),[n,r]}_expandExtent(e,t,n,r=null){n[0]=1/0,n[1]=-1/0;for(let i=0;i<8;++i){j[0]=t[i&1?0:3],j[1]=t[i&2?1:4],j[2]=t[i&4?2:5];let a=r==null?this._renderCoordsHelper.fromRenderCoords(j,j,e):r.addRenderPoint(j,e);if(a!=null)n[0]=Math.min(n[0],a[2]),n[1]=Math.max(n[1],a[2]);else if(r!=null)return!1;if(r!=null){for(let n=0;n<3;++n)if(!(i&1<<n)&&(o(M,j),M[n]=t[n],!r.addRenderEdge(j,M,e)))return!1}}return!0}_emitFullExtentElevationChange(e){let t=h(e);t!=null&&this._emitElevationChangeEvent(b(e,t),e)}_emitElevationChangeEvent(e,t){let n=new _(t,e);this.emit(`elevation-change`,n)}_resetProjectedExtent(e,t){d(e,A),this._projectedExtent.reset(A,.5*f(e),t)}};e([i({constructOnly:!0})],T.prototype,`layer`,void 0),e([i({constructOnly:!0})],T.prototype,`stageLayer`,void 0),e([i({constructOnly:!0})],T.prototype,`view`,void 0),e([i()],T.prototype,`spatialReference`,null),T=e([a(`esri.views.3d.layers.support.StageLayerElevationProvider`)],T);function E(e){return p(e,c)<=x*x}const D=new Float64Array(2),O=new Float64Array(2),k=new Float64Array(2),A=s(),j=s(),M=s(),N=s(),P=s();export{T as StageLayerElevationProvider};
2
+ import{__decorate as e}from"tslib";import{EventedAccessor as t}from"../../../../core/Evented.js";import n from"../../../../core/Logger.js";import{getMetersPerVerticalUnitForSR as r}from"../../../../core/units.js";import{property as i,subclass as a}from"../../../../core/accessorSupport/decorators.js";import{copy as o}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as s,ZEROS as c}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{isEmpty as l,copy as u,center as d,diameter as f,squaredDistanceToPoint as p}from"../../../../geometry/support/aaBoundingBox.js";import{allFinite as m}from"../../../../geometry/support/aaBoundingRect.js";import{getInfo as h}from"../../../../geometry/support/spatialReferenceUtils.js";import{getMetersPerUnit as g}from"../../../../symbols/support/unitConversionUtils.js";import{ElevationUpdateEvent as _}from"../../support/ElevationUpdateEvent.js";import{ProjectedElevationUpdateExtent as v,calculateElevationUpdateExtents as y,fullWorldElevationUpdateExtent as b,planetCenterProximityToleranceMeters as x}from"../../support/elevationUpdateExtentUtils.js";import{affectsGeometry as S}from"../../webgl-engine/lib/affectsGeometry.js";import{Intersector as C}from"../../webgl-engine/lib/Intersector.js";const w=Symbol(`layerHandles`);let T=class extends t{get spatialReference(){return this.view.spatialReference}constructor(e){super(e),this._elevationOffset=0}initialize(){this._renderCoordsHelper=this.view.renderCoordsHelper,this._projectedExtent=new v(this._renderCoordsHelper),this._intersectLayers=[this.stageLayer],this._intersector=new C(this.view.state.viewingMode),this._intersector.options.store=0;let[e,t]=this._computeLayerElevationRange(this.spatialReference,this.stageLayer);this._zmin=e,this._zmax=t;let n=this.stageLayer.events;this.addHandles([n.on([`layerObjectAdded`,`layerObjectRemoved`,`transformationChanged`,`shaderTransformationChanged`],e=>this._objectChanged(e)),n.on(`geometriesChanged`,({object:e})=>this._objectChanged(e)),n.on(`attributesChanged`,({attribute:e,object:t})=>S(e)&&this._objectChanged(t))],w)}destroy(){this.removeHandles(w)}elevationInfoChanged(){let e=this.layer==null?null:this.layer.elevationInfo;if(e!=null&&e.mode!==`on-the-ground`){let t=r(this.layer.spatialReference),n=g(e.unit??`meters`);this._elevationOffset=(e.offset??0)*n/t}else this._elevationOffset=0}getElevation(e,t,r,i){if(j[0]=e,j[1]=t,j[2]=r,!this._renderCoordsHelper.toRenderCoords(j,i,j))return n.getLogger(this).error(`could not project point for elevation alignment`),null;let a=this._elevationOffset,o=this._zmin+a,s=this._zmax+a;return this._renderCoordsHelper.setAltitude(N,s,j),this._renderCoordsHelper.setAltitude(P,o,j),this._intersector.reset(N,P,null),this._intersector.intersect(this._intersectLayers,null,1,null,e=>!!e.lastValidElevationBB),this._intersector.results.min.getIntersectionPoint(j)?this._renderCoordsHelper.getAltitude(j):null}_objectChanged(e){let t=this.spatialReference;if(!e.lastValidElevationBB||!t)return;let n=e.lastValidElevationBB,{box:r,sphere:i}=e.boundingVolumeWorldSpace;if(this.view.state.viewingMode===1&&(!l(n)&&E(n)||E(r))){this._emitFullExtentElevationChange(t),u(n,r);return}let a=!l(n),o=new Float64Array(a?8:4),s=1/0,c=-1/0,d=!1;if(a&&(this._resetProjectedExtent(n,t),this._expandExtent(t,n,k,this._projectedExtent)||(d=!0),m(this._projectedExtent.extent)?(s=Math.min(s,k[0]),c=Math.max(c,k[1]),o.set(this._projectedExtent.extent)):d=!0),this._projectedExtent.reset(i.center,i.radius,t),this._expandExtent(t,r,D,this._projectedExtent)||(d=!0),m(this._projectedExtent.extent)?(s=Math.min(s,D[0]),c=Math.max(c,D[1]),o.set(this._projectedExtent.extent,a?4:0)):d=!0,d){this._emitFullExtentElevationChange(t),u(n,r);return}let f=y(o,t);f.length>0&&(this._zmin=Math.min(this._zmin,s),this._zmax=Math.max(this._zmax,c));for(let e of f)this._emitElevationChangeEvent(e,t);u(n,r)}_computeLayerElevationRange(e,t){let n=1/0,r=-1/0;return e!=null&&t.objects.forEach(t=>{this._expandExtent(e,t.boundingVolumeWorldSpace.box,O)&&(n=Math.min(n,O[0]),r=Math.max(r,O[1]))}),[n,r]}_expandExtent(e,t,n,r=null){n[0]=1/0,n[1]=-1/0;for(let i=0;i<8;++i){j[0]=t[i&1?0:3],j[1]=t[i&2?1:4],j[2]=t[i&4?2:5];let a=r==null?this._renderCoordsHelper.fromRenderCoords(j,j,e):r.addRenderPoint(j,e);if(a!=null)n[0]=Math.min(n[0],a[2]),n[1]=Math.max(n[1],a[2]);else if(r!=null)return!1;if(r!=null){for(let n=0;n<3;++n)if(!(i&1<<n)&&(o(M,j),M[n]=t[n],!r.addRenderEdge(j,M,e)))return!1}}return!0}_emitFullExtentElevationChange(e){let t=h(e);t!=null&&this._emitElevationChangeEvent(b(e,t),e)}_emitElevationChangeEvent(e,t){let n=new _(t,e);this.emit(`elevation-change`,n)}_resetProjectedExtent(e,t){d(e,A),this._projectedExtent.reset(A,.5*f(e),t)}};e([i({constructOnly:!0})],T.prototype,`layer`,void 0),e([i({constructOnly:!0})],T.prototype,`stageLayer`,void 0),e([i({constructOnly:!0})],T.prototype,`view`,void 0),e([i()],T.prototype,`spatialReference`,null),T=e([a(`esri.views.3d.layers.support.StageLayerElevationProvider`)],T);function E(e){return p(e,c)<=x*x}const D=new Float64Array(2),O=new Float64Array(2),k=new Float64Array(2),A=s(),j=s(),M=s(),N=s(),P=s();export{T as StageLayerElevationProvider};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import e from"../../../../core/Error.js";import"../../../../geometry/SpatialReference.js";import"../../../../geometry/support/aaBoundingBox.js";import"../../../../core/mathUtils.js";import"../../../../geometry/Extent.js";import"../../../../geometry/support/typeUtils.js";import"../../../../core/has.js";import{equals as t}from"../../../../layers/graphics/dehydratedFeatureComparison.js";class n{constructor(e,t){this.feature=e,this.resolution=t,this.refCount=1}}class r{get isReferenced(){return this.versions.length!==0}get isSingle(){return this.versions.length===1&&this.versions[0].refCount===1}constructor(e,t,n){this._highestResolutionVersion=null,this.versions=[],this.ref(n,e,t)}ref(e,r,i){let a=this.feature;o.oldVersion=a,a&&Object.defineProperty(r,"uid",{value:a.uid,configurable:!0});let s=this._highestResolutionVersion;for(let n of this.versions)if(n.resolution===i){n.refCount++;let i=s===n&&!t(r,n.feature);return(i||s!==n)&&(e.ref(r),e.unref(n.feature),n.feature=r),o.newVersion=i?r:a,o}let c=new n(r,i);return this.versions.push(c),e.ref(r),!s||i<s.resolution?(o.newVersion=r,this._highestResolutionVersion=c):o.newVersion=a,o}unref(t,n){let{versions:r}=this;for(let e=0;e<r.length;e++){let i=r[e];if(i.resolution===n)return i.refCount--,a.oldVersion=this.feature,i.refCount===0&&(t.unref(i.feature),r[e]=r[r.length-1],--r.length,this._highestResolutionVersion===i&&(this._recalculateHighestResolutionVersion(),a.oldVersion=i.feature)),a.newVersion=this.feature,a}let i=`Unref feature with no references: ${this.feature?.uid}`;throw new e(i,i,Error().stack?.slice(6))}get feature(){return this._highestResolutionVersion?.feature??null}_recalculateHighestResolutionVersion(){if(this.versions.length===0){this._highestResolutionVersion=null;return}let e=this.versions[0];for(let t=1;t<this.versions.length;t++){let n=this.versions[t];n.resolution<e.resolution&&(e=n)}this._highestResolutionVersion=e}}class i{get isReferenced(){return this._refCount!==0}get isSingle(){return this._refCount===1}constructor(e,t,n){this._feature=e,this._refCount=1,n.ref(e)}ref(e,n,r){++this._refCount;let i=this._feature;return o.oldVersion=i,i&&Object.defineProperty(n,"uid",{value:i.uid,configurable:!0}),t(i,n)||(e.ref(n),e.unref(this._feature),this._feature=n),o.newVersion=this._feature,o}unref(t,n){a.oldVersion=this._feature;let r=this._refCount;if(r>0){if(this._refCount=r-1,r===1)return t.unref(this._feature),a.newVersion=null,a}else{let t=`Unref feature with no references: ${this.feature?.uid}`;throw new e(t,t,Error().stack?.slice(6))}return a.newVersion=this._feature,a}get feature(){return this._feature}}const a={oldVersion:null,newVersion:null},o={oldVersion:null,newVersion:null};export{n as FeatureVersion,r as MultiFeatureReference,i as SingleFeatureReference};
2
+ import e from"../../../../core/Error.js";import"../../../../core/memoryEstimations.js";import"../../../../geometry/SpatialReference.js";import"../../../../geometry/support/aaBoundingBox.js";import"../../../../core/mathUtils.js";import"../../../../geometry/Extent.js";import"../../../../geometry/support/typeUtils.js";import"../../../../core/has.js";import{equals as t}from"../../../../layers/graphics/dehydratedFeatureComparison.js";class n{constructor(e,t){this.feature=e,this.resolution=t,this.refCount=1}}class r{get isReferenced(){return this.versions.length!==0}get isSingle(){return this.versions.length===1&&this.versions[0].refCount===1}constructor(e,t,n){this._highestResolutionVersion=null,this.versions=[],this.ref(n,e,t)}ref(e,r,i){let a=this.feature;o.oldVersion=a,a&&Object.defineProperty(r,"uid",{value:a.uid,configurable:!0});let s=this._highestResolutionVersion;for(let n of this.versions)if(n.resolution===i){n.refCount++;let i=s===n&&!t(r,n.feature);return(i||s!==n)&&(e.ref(r),e.unref(n.feature),n.feature=r),o.newVersion=i?r:a,o}let c=new n(r,i);return this.versions.push(c),e.ref(r),!s||i<s.resolution?(o.newVersion=r,this._highestResolutionVersion=c):o.newVersion=a,o}unref(t,n){let{versions:r}=this;for(let e=0;e<r.length;e++){let i=r[e];if(i.resolution===n)return i.refCount--,a.oldVersion=this.feature,i.refCount===0&&(t.unref(i.feature),r[e]=r[r.length-1],--r.length,this._highestResolutionVersion===i&&(this._recalculateHighestResolutionVersion(),a.oldVersion=i.feature)),a.newVersion=this.feature,a}let i=`Unref feature with no references: ${this.feature?.uid}`;throw new e(i,i,Error().stack?.slice(6))}get feature(){return this._highestResolutionVersion?.feature??null}_recalculateHighestResolutionVersion(){if(this.versions.length===0){this._highestResolutionVersion=null;return}let e=this.versions[0];for(let t=1;t<this.versions.length;t++){let n=this.versions[t];n.resolution<e.resolution&&(e=n)}this._highestResolutionVersion=e}}class i{get isReferenced(){return this._refCount!==0}get isSingle(){return this._refCount===1}constructor(e,t,n){this._feature=e,this._refCount=1,n.ref(e)}ref(e,n,r){++this._refCount;let i=this._feature;return o.oldVersion=i,i&&Object.defineProperty(n,"uid",{value:i.uid,configurable:!0}),t(i,n)||(e.ref(n),e.unref(this._feature),this._feature=n),o.newVersion=this._feature,o}unref(t,n){a.oldVersion=this._feature;let r=this._refCount;if(r>0){if(this._refCount=r-1,r===1)return t.unref(this._feature),a.newVersion=null,a}else{let t=`Unref feature with no references: ${this.feature?.uid}`;throw new e(t,t,Error().stack?.slice(6))}return a.newVersion=this._feature,a}get feature(){return this._feature}}const a={oldVersion:null,newVersion:null},o={oldVersion:null,newVersion:null};export{n as FeatureVersion,r as MultiFeatureReference,i as SingleFeatureReference};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import{ignoreAbortErrors as t}from"../../../core/promiseUtils.js";import{watch as n}from"../../../core/reactiveUtils.js";import{property as r,subclass as i}from"../../../core/accessorSupport/decorators.js";import{DefaultNavigationMode3D as a}from"./modes/DefaultNavigationMode3D.js";import{groundNavigationAdvance as o}from"../state/utils/groundNavigationUtils.js";import s from"../../navigation/Navigation.js";let c=class extends s{constructor(e){super(e),this.mode=new a,this.addHandles([n(()=>this.mode,(e,t)=>{t?.detach(),e.attach(this.view)},{sync:!0,initial:!0})])}get isInPlacementMode(){let{activeTool:e}=this.view;return e?`isGroundNavigationPlacementTool`in e:!1}zoom(e){switch(this.mode.type){case`default`:return t(this.view.goTo({zoomFactor:e?2:.5}));case`ground`:return t(o(this.view,e?5:-5));default:this.mode}throw Error(`Unknown navigation mode while calling navigation3D.zoom: ${this.mode}`)}};e([r({constructOnly:!0})],c.prototype,`view`,void 0),e([r()],c.prototype,`mode`,void 0),e([r()],c.prototype,`isInPlacementMode`,null),c=e([i(`esri.views.3d.navigation.Navigation3D`)],c);export{c as Navigation3D};
2
+ import{__decorate as e}from"tslib";import{ignoreAbortErrors as t}from"../../../core/promiseUtils.js";import{watch as n}from"../../../core/reactiveUtils.js";import{property as r,subclass as i}from"../../../core/accessorSupport/decorators.js";import{DefaultNavigationMode3D as a}from"./modes/DefaultNavigationMode3D.js";import{groundNavigationAdvance as o}from"../state/utils/groundNavigationUtils.js";import s from"../../navigation/Navigation.js";let c=class extends s{constructor(e){super(e),this.mode=new a,this.addHandles([n(()=>this.mode,(e,t)=>{t?.detach(),e.attach(this.view)},{sync:!0,initial:!0})])}get isInPlacementMode(){let{activeTool:e}=this.view;return e?`isGroundNavigationPlacementTool`in e:!1}zoom(e){switch(this.mode.type){case`default`:return t(this.view.goTo({zoomFactor:e?2:.5}));case`ground`:return t(o(this.view,this.view.state.camera.viewForward,e?5:-5));default:this.mode}throw Error(`Unknown navigation mode while calling navigation3D.zoom: ${this.mode}`)}};e([r({constructOnly:!0})],c.prototype,`view`,void 0),e([r()],c.prototype,`mode`,void 0),e([r()],c.prototype,`isInPlacementMode`,null),c=e([i(`esri.views.3d.navigation.Navigation3D`)],c);export{c as Navigation3D};
@@ -0,0 +1,2 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
+ import{__decorate as e}from"tslib";import{Milliseconds as t,millisecondsFromSeconds as n}from"../../../../core/time.js";import{subclass as r}from"../../../../core/accessorSupport/decorators.js";import{set as i,scaleAndAdd as a,length as o,scale as s}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as c}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{CameraController as l}from"./CameraController.js";import{advanceGroundNavigationCamera as u}from"../utils/groundNavigationUtils.js";import{OffsetCorrectionController as d}from"../utils/OffsetCorrectionController.js";let f=class extends l{constructor(){super(...arguments),this._remainingMovement=c(),this._direction=c(),this._timeSinceLastInput=t(0)}initialize(){this._offsetCorrectionController=new d(this.view)}get canStop(){return!0}get isInteractive(){return!0}onControllerStart(){this.state=2}onControllerEnd(){i(this._remainingMovement,0,0,0)}addMovement(e,n){a(this._remainingMovement,this._remainingMovement,e,n),this._timeSinceLastInput=t(0)}stepController(e,r){if(!this.running||e<=0)return;if(this._timeSinceLastInput=t(this._timeSinceLastInput+n(e)),this._timeSinceLastInput>=200&&this._offsetCorrectionController.reset(),this.view.navigation.mode.type!==`ground`){this.finishController();return}let i=o(this._remainingMovement),a=i<=1e-5||!this.view.state.animationsEnabled,c=a?1:-Math.expm1(-(e/.08));i>0&&(s(this._direction,this._remainingMovement,1/i),u({view:this.view,camera:r,forwardDirection:this._direction,forwardDistance:i*c,detectCollisions:!1}),s(this._remainingMovement,this._remainingMovement,1-c));let l=this._offsetCorrectionController.smoothlyCorrectGroundElevation({camera:r,deltaTime:e});a&&l<=.01&&this.finishController()}};f=e([r(`esri.views.3d.state.controllers.GroundMouseWheelController`)],f);export{f as GroundMouseWheelController};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import{clamp as e}from"../../../../core/mathUtils.js";import{dot as t,distance as n,subtract as r,scale as i,add as a,copy as o,normalize as s,cross as c,scaleAndAdd as l}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as u,clone as d}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as f}from"../../../../geometry/support/ray.js";import{applyConstraintsAndUpdateCenterRenderCamera as p}from"../../camera/constraintUtils.js";import{Intersector as m}from"../../webgl-engine/lib/Intersector.js";const h=.5,g=new Set([0,2,8]),_=new Set(g).add(7);class v{constructor(e){this._view=e,this._tmpRay=f(),this._tmpWorldUp=u(),this._tmpScaledUp=u(),this._tmpCorrectionOffset=u(),this._tmpUpdatedCameraPos=u(),this._tmpCenterDiff=u(),this._tmpMovementDelta=u(),this._tmpPerpendicularMovementDelta=u(),this._tmpGroundIntersections=[u(),u(),u()],this._tmpGroundIntersectionHits=[!1,!1,!1],this._tmpRayOrigins=[u(),u(),u()],this._tmpRayDirection=u(),this._previousCameraPosition=null,this._intersector=new m(this._view.state.viewingMode),this._intersector.options.invisibleTerrain=!0}smoothlyCorrectGroundElevation(e){let{camera:n,deltaTime:r,constraintOptions:i,navigationModeOverride:a}=e,o=this._prepareMode(a);if(!o||!r)return 0;let s=this._view.renderCoordsHelper.worldUpAtPosition(n.eye,this._tmpWorldUp),c=this._prepareCameraAndPreviousIterationPosition(n,s,this._previousCameraPosition),l=this._prepareRays(n,s,c),u=this._intersectRays(o,s,l);if(!u.hasIntersection){let e=this._adjustCameraElevation(n,s,0,i);return this._previousCameraPosition=d(e),0}let f=this._filterRayResults(s,c,u),p=this._getSmoothedElevationCorrection(o,f,n,s,c,r),m=this._adjustCameraElevation(n,s,p,i);return this._previousCameraPosition=d(m),Math.abs(f-t(m,s))}immediatelyCorrectGroundElevation(e){let{camera:i,constraintOptions:a,navigationModeOverride:o,correctionLimit:s}=e,c=this._prepareMode(o);if(!c)return;let l=this._view.renderCoordsHelper.worldUpAtPosition(i.eye,this._tmpWorldUp),u=this._prepareRays(i,l),d=this._intersectRays(c,l,u),f=d.intersections[0];!d.hasIntersection||n(i.eye,f)>(s??1/0)?this._adjustCameraElevation(i,l,0,a):this._adjustCameraElevation(i,l,t(l,r(this._tmpCorrectionOffset,f,i.eye)),a)}_prepareMode(e){let t=e??this._view.navigation.mode;return t.type!==`ground`||!t.offset?null:t}_prepareCameraAndPreviousIterationPosition(e,n,r){if(r){let o=t(n,e.eye),s=t(n,r);return i(this._tmpCorrectionOffset,n,s-o),e.eye=a(this._tmpUpdatedCameraPos,e.eye,this._tmpCorrectionOffset),e.center=a(this._tmpUpdatedCameraPos,e.center,this._tmpCorrectionOffset),r}return e.eye}_prepareRays(e,t,n){let r=i(this._tmpRayDirection,t,-1e5);if(o(this._tmpRayOrigins[0],e.eye),!n)return{origins:this._tmpRayOrigins,direction:r,count:1};let{forwardMovementDirection:a,rightMovementDirection:s}=this._getMovementDirections(e.eye,n,t);return this._getLeftRayOrigin(e.eye,a,s,this._tmpRayOrigins[1]),this._getRightRayOrigin(e.eye,a,s,this._tmpRayOrigins[2]),{origins:this._tmpRayOrigins,direction:r,count:this._tmpRayOrigins.length}}_getMovementDirections(e,n,a){let o=r(this._tmpMovementDelta,e,n);return r(o,o,i(this._tmpScaledUp,a,t(a,o))),s(o,o),{forwardMovementDirection:o,rightMovementDirection:c(this._tmpPerpendicularMovementDelta,o,a)}}_getLeftRayOrigin(e,t,n,r){return l(r,e,t,h),l(r,r,n,-.5),r}_getRightRayOrigin(e,t,n,r){return l(r,e,t,h),l(r,r,n,h),r}_intersectRays(e,t,r){let i=e.offset,a=this._view.sceneIntersectionHelper,s=y(e,this._view.groundView.baseOpacity===0);o(this._tmpRay.direction,r.direction);for(let e=0;e<r.count;e++)o(this._tmpRay.origin,r.origins[e]),this._tmpGroundIntersectionHits[e]=a.intersectRay(this._tmpRay,this._intersector,this._tmpGroundIntersections[e],s),this._tmpGroundIntersectionHits[e]&&n(this._tmpGroundIntersections[e],this._tmpRay.origin)>1e5&&(this._tmpGroundIntersectionHits[e]=!1),this._tmpGroundIntersectionHits[e]&&l(this._tmpGroundIntersections[e],this._tmpGroundIntersections[e],t,i);let c=this._tmpGroundIntersectionHits.some((e,t)=>t<r.count&&e);return{intersections:this._tmpGroundIntersections,hits:this._tmpGroundIntersectionHits,count:r.count,hasIntersection:c}}_filterRayResults(e,n,r){let i=t(n,e),a=null;for(let n=0;n<r.count;n++){if(!r.hits[n])continue;let o=r.intersections[n],s=t(o,e);(a==null||Math.abs(s-i)<Math.abs(a-i))&&(a=s)}return a}_getSmoothedElevationCorrection(r,i,a,o,s,c){let l=n(a.eye,s)/c,u=1+Math.max(0,(l-5)*.03),d=(u*1e-5)**c,f=t(s,o)*d+i*(1-d),p=t(a.eye,o),m=u*5*c*(r.offset??0),h=f-p;return e(h,-m,m)}_adjustCameraElevation(e,t,n,i){return n!==0&&(l(this._tmpUpdatedCameraPos,e.eye,t,n),r(this._tmpCenterDiff,e.center,e.eye),e.eye=this._tmpUpdatedCameraPos,e.center=a(this._tmpUpdatedCameraPos,this._tmpUpdatedCameraPos,this._tmpCenterDiff)),p(this._view,e,i),e.eye}}function y(e,t){return b(e.include)?{include:e.include,exclude:e.exclude}:{exclude:e.exclude,objectFilter:e=>!!e.lastValidElevationBB,allowedIntersectorTypes:t?g:_}}function b(e){return e!=null&&e.size>0}export{v as OffsetCorrectionController};
2
+ import{clamp as e}from"../../../../core/mathUtils.js";import{dot as t,distance as n,subtract as r,scale as i,add as a,copy as o,normalize as s,cross as c,scaleAndAdd as l}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as u,clone as d}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as f}from"../../../../geometry/support/ray.js";import{applyConstraintsAndUpdateCenterRenderCamera as p}from"../../camera/constraintUtils.js";import{Intersector as m}from"../../webgl-engine/lib/Intersector.js";const h=.5,g=new Set([0,2,8]),_=new Set(g).add(7);class v{constructor(e){this._view=e,this._tmpRay=f(),this._tmpWorldUp=u(),this._tmpScaledUp=u(),this._tmpCorrectionOffset=u(),this._tmpUpdatedCameraPos=u(),this._tmpCenterDiff=u(),this._tmpMovementDelta=u(),this._tmpPerpendicularMovementDelta=u(),this._tmpGroundIntersections=[u(),u(),u()],this._tmpGroundIntersectionHits=[!1,!1,!1],this._tmpRayOrigins=[u(),u(),u()],this._tmpRayDirection=u(),this._previousCameraPosition=null,this._intersector=new m(this._view.state.viewingMode),this._intersector.options.invisibleTerrain=!0}smoothlyCorrectGroundElevation(e){let{camera:n,deltaTime:r,constraintOptions:i,navigationModeOverride:a}=e,o=this._prepareMode(a);if(!o||!r)return 0;let s=this._view.renderCoordsHelper.worldUpAtPosition(n.eye,this._tmpWorldUp),c=this._prepareCameraAndPreviousIterationPosition(n,s,this._previousCameraPosition),l=this._prepareRays(n,s,c),u=this._intersectRays(o,s,l);if(!u.hasIntersection){let e=this._adjustCameraElevation(n,s,0,i);return this._previousCameraPosition=d(e),0}let f=this._filterRayResults(s,c,u),p=this._getSmoothedElevationCorrection(o,f,n,s,c,r),m=this._adjustCameraElevation(n,s,p,i);return this._previousCameraPosition=d(m),Math.abs(f-t(m,s))}immediatelyCorrectGroundElevation(e){let{camera:i,constraintOptions:a,navigationModeOverride:o,correctionLimit:s}=e,c=this._prepareMode(o);if(!c)return;let l=this._view.renderCoordsHelper.worldUpAtPosition(i.eye,this._tmpWorldUp),u=this._prepareRays(i,l),d=this._intersectRays(c,l,u),f=d.intersections[0];!d.hasIntersection||n(i.eye,f)>(s??1/0)?this._adjustCameraElevation(i,l,0,a):this._adjustCameraElevation(i,l,t(l,r(this._tmpCorrectionOffset,f,i.eye)),a)}_prepareMode(e){let t=e??this._view.navigation.mode;return t.type!==`ground`||!t.offset?null:t}_prepareCameraAndPreviousIterationPosition(e,n,r){if(r){let o=t(n,e.eye),s=t(n,r);return i(this._tmpCorrectionOffset,n,s-o),e.eye=a(this._tmpUpdatedCameraPos,e.eye,this._tmpCorrectionOffset),e.center=a(this._tmpUpdatedCameraPos,e.center,this._tmpCorrectionOffset),r}return e.eye}_prepareRays(e,t,n){let r=i(this._tmpRayDirection,t,-1e5);if(o(this._tmpRayOrigins[0],e.eye),!n)return{origins:this._tmpRayOrigins,direction:r,count:1};let{forwardMovementDirection:a,rightMovementDirection:s}=this._getMovementDirections(e.eye,n,t);return this._getLeftRayOrigin(e.eye,a,s,this._tmpRayOrigins[1]),this._getRightRayOrigin(e.eye,a,s,this._tmpRayOrigins[2]),{origins:this._tmpRayOrigins,direction:r,count:this._tmpRayOrigins.length}}_getMovementDirections(e,n,a){let o=r(this._tmpMovementDelta,e,n);return r(o,o,i(this._tmpScaledUp,a,t(a,o))),s(o,o),{forwardMovementDirection:o,rightMovementDirection:c(this._tmpPerpendicularMovementDelta,o,a)}}_getLeftRayOrigin(e,t,n,r){return l(r,e,t,h),l(r,r,n,-.5),r}_getRightRayOrigin(e,t,n,r){return l(r,e,t,h),l(r,r,n,h),r}_intersectRays(e,t,r){let i=e.offset,a=this._view.sceneIntersectionHelper,s=y(e,this._view.groundView.baseOpacity===0);o(this._tmpRay.direction,r.direction);for(let e=0;e<r.count;e++)o(this._tmpRay.origin,r.origins[e]),this._tmpGroundIntersectionHits[e]=a.intersectRay(this._tmpRay,this._intersector,this._tmpGroundIntersections[e],s),this._tmpGroundIntersectionHits[e]&&n(this._tmpGroundIntersections[e],this._tmpRay.origin)>1e5&&(this._tmpGroundIntersectionHits[e]=!1),this._tmpGroundIntersectionHits[e]&&l(this._tmpGroundIntersections[e],this._tmpGroundIntersections[e],t,i);let c=this._tmpGroundIntersectionHits.some((e,t)=>t<r.count&&e);return{intersections:this._tmpGroundIntersections,hits:this._tmpGroundIntersectionHits,count:r.count,hasIntersection:c}}_filterRayResults(e,n,r){let i=t(n,e),a=null;for(let n=0;n<r.count;n++){if(!r.hits[n])continue;let o=r.intersections[n],s=t(o,e);(a==null||Math.abs(s-i)<Math.abs(a-i))&&(a=s)}return a}_getSmoothedElevationCorrection(r,i,a,o,s,c){let l=n(a.eye,s)/c,u=1+Math.max(0,(l-5)*.03),d=(u*1e-5)**c,f=t(s,o)*d+i*(1-d),p=t(a.eye,o),m=u*5*c*(r.offset??0),h=f-p;return e(h,-m,m)}_adjustCameraElevation(e,t,n,i){return n!==0&&(l(this._tmpUpdatedCameraPos,e.eye,t,n),r(this._tmpCenterDiff,e.center,e.eye),e.eye=this._tmpUpdatedCameraPos,e.center=a(this._tmpUpdatedCameraPos,this._tmpUpdatedCameraPos,this._tmpCenterDiff)),p(this._view,e,i),e.eye}reset(){this._previousCameraPosition=null}}function y(e,t){return b(e.include)?{include:e.include,exclude:e.exclude}:{exclude:e.exclude,objectFilter:e=>!!e.lastValidElevationBB,allowedIntersectorTypes:t?g:_}}function b(e){return e!=null&&e.size>0}export{v as OffsetCorrectionController};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import e from"../../../../core/Logger.js";import{createScreenPointArray as t}from"../../../../core/screenUtils.js";import{distance as n,normalize as r,cross as i,add as a,crossAndNormalize as o,subtract as s,dot as c,scaleAndAdd as l,scale as u,copy as d,length as f}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as p}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as m}from"../../../../geometry/ellipsoidUtils.js";import{fromValues as h}from"../../../../geometry/support/lineSegment.js";import{create as g,fromPositionAndNormal as _,distance as v,projectPoint as y,projectVector as b,intersectLineSegment as x}from"../../../../geometry/support/plane.js";import{create as S}from"../../../../geometry/support/ray.js";import{Sphere as C}from"../../../../geometry/support/sphere.js";import{fromRenderCamera as w}from"../../webgl.js";import{getVoxelWasm as T}from"../../layers/VoxelWasm.js";import{pickPointAndInitSphere as E,sphereOrPlanePointFromScreenPoint as D,intersectPlaneFromScreenPoint as O,searchAreaSize as k}from"./navigationUtils.js";import{OffsetCorrectionController as ee}from"./OffsetCorrectionController.js";import{fromScreenAtEye as te}from"../../support/geometryUtils/ray.js";import ne from"../../webgl/RenderCamera.js";import{Intersector as A}from"../../webgl-engine/lib/Intersector.js";const j=1.5,M={xSpeedMultiplier:j,ySpeedMultiplier:j,maxElevation:1e4,relativeHorizonPadding:.1,minimumHorizonPadding:12},N=p(),P=p(),re=t(),F=p(),I=g(),L=p(),R=p(),z=p(),B=p(),V=p(),ie=p(),H=p(),U=p(),W=p(),G=p(),K=t(),q=S(),J=new C,Y=p(),ae=g(),X=p(),oe=p();function se(e,t){return b(t,e.viewForward,N),a(P,e.eye,N),e.projectToScreen(P,re),re[1]}function ce(e,t,d){let f=e.eye;if(n(t.center,f)<t.radius)return r(V,f),i(ie,V,e.viewRight),a(P,f,ie),e.projectToScreen(P,K),K[1];let p=e.up;te(e,d,q);let m=t.radius;if(o(F,p,q.direction),_(f,F,I),v(I,t.center)>m)return null;y(I,t.center,L);let h=n(t.center,L),g=Math.sqrt(m**2-h**2);s(R,f,L),r(z,R),o(B,F,z);let b=c(R,z),x=c(R,B),S=Math.sqrt(b**2+x**2),C=Math.sqrt(S**2-g**2),w=g**2/S**2,T=g/S**2*C,E=w*b,D=T*-x,O=w*x,k=T*b,ee=E+D,ne=E-D,A=O+k,j=O-k;return a(H,L,l(H,u(H,z,ee),B,A)),a(U,L,l(U,u(U,z,ne),B,j)),s(W,H,f),r(W,W),s(G,U,f),r(G,G),c(e.viewForward,W)>=c(e.viewForward,G)?e.projectToScreen(H,K):e.projectToScreen(U,K),K[1]}function le(e,t,n=!0){return n?e<t:e<=t}function Z(e,t,n=!0){return n?e>t:e>=t}function ue(e,t,n){return t?e>n:e<n}function Q(e,t){let n=e.fullHeight/e.pixelRatio,r=Math.max(t,n-t);return Math.max(M.minimumHorizonPadding,M.relativeHorizonPadding*r)}function de(e,t){return[fe(e,t),pe(e,t)]}function fe(e,t){let n=e.fullHeight/e.pixelRatio;return Math.min(n,t+Q(e,t))}function pe(e,t){return Math.max(0,t-Q(e,t))}function me(e,t,n){let r={translation:e,location:t};return n&&(r.normal=n),r}function he(e){let{view:t}=e;return t.viewingMode===`global`?ge(e):_e(e)}function ge(e){let{view:t,originalScreenPoint:i,horizonY:a,horizonPadding:o,outTranslation:s,outGrabLocation:c,outGrabNormal:l,intersectionOptions:u,depthSearchSize:f}=e,p=t.state.camera,h=me(s,c,l);J.radius=m(t.spatialReference).radius;let g=E(t,p,i,J.radius,1,u);if(g.scenePickPoint==null)return!1;let _=g.hasGeometryIntersection;d(Y,g.scenePickPoint),d(h.location,Y);let v=g.sphere;h.normal&&g.normal&&d(h.normal,g.normal);let y=ye(i,a,o,_),b=_?n(Y,p.eye):1/0;return y.wasAdjusted&&be({view:t,screenAdjustment:y,intersector:$(t),fallbackCheck:(e,t,n)=>{let i=D(v,p,e,t);return i&&n&&r(n,t),i},output:h,intersectionOptions:u}),Se({view:t,screenPoint:y.adjustedScreenPoint,camera:p,initialDistance:b,depthSearchSize:f??k,output:h}),!0}function _e(e){let{view:t,originalScreenPoint:i,horizonY:a,horizonPadding:o,outTranslation:s,outGrabLocation:c,outGrabNormal:u,intersectionOptions:f,depthSearchSize:p}=e,m=t.sceneIntersectionHelper,h=t.state.camera,g=$(t),v=me(s,c,u);m.intersectIntersectorScreen(i,g,f);let y=g.results.min.getIntersectionPoint(Y),b=y?n(Y,h.eye):1/0;y&&(d(v.location,Y),v.normal&&d(v.normal,g.results.min.normal)),t.renderCoordsHelper.worldUpAtPosition(h.eye,V),l(X,h.eye,V,-h.relativeElevation),_(X,V,ae);let x=ye(i,a,o,y);return x.wasAdjusted&&be({view:t,screenAdjustment:x,intersector:g,fallbackCheck:(e,t,n)=>{let i=O(ae,h,e,t);return i&&n&&r(n,V),i},output:v,intersectionOptions:f}),Se({view:t,screenPoint:x.adjustedScreenPoint,camera:h,initialDistance:b,depthSearchSize:p??k,output:v}),!0}function ve(e,t,n,r){return!r&&le(e,t)||r&&ue(e,!1,n[0])?n[0]:!r&&Z(e,t,!1)?n[1]:null}function ye(e,n,r,i){let a=ve(e[1],n,r,i);return{originalScreenPoint:e,adjustedScreenPoint:t(e[0],a??e[1]),horizonY:n,horizonPadding:r,wasAdjusted:a!==null}}function $(e){let t=new A(e.state.viewingMode);return t.options.selectionMode=!0,t.options.store=0,t.options.hud=!1,t.options.normalRequired=!0,t}function be(e){let{view:t,screenAdjustment:n,fallbackCheck:r,intersector:i,output:a,intersectionOptions:o}=e,s=t.sceneIntersectionHelper;s.intersectIntersectorScreen(n.adjustedScreenPoint,i,{...o,requiresGroundFeedback:!0});let c=i.results.min.getIntersectionPoint(a.location);if(c){a.normal&&d(a.normal,i.results.min.normal);return}let l=xe(n);s.intersectIntersectorScreen(l,i,{...o,requiresGroundFeedback:!0}),c=i.results.min.getIntersectionPoint(a.location),c?a.normal&&d(a.normal,i.results.min.normal):(c=r(n.adjustedScreenPoint,a.location,a.normal),c||r(l,a.location,a.normal))}function xe(e){let{originalScreenPoint:n,adjustedScreenPoint:r,horizonY:i,horizonPadding:a}=e,o=Z(r[1],i)?Math.min(a[1],n[1]):Math.max(a[0],n[1]);return t(r[0],o)}function Se(e){Ce(e),we(e)}function Ce(e){let{view:t,camera:n,output:r}=e,{offset:i}=t.navigation.mode;if(!i)return;let{translation:a,location:o}=r;t.renderCoordsHelper.worldUpAtPosition(n.eye,V),l(X,n.eye,V,-i),_(X,V,I),x(I,h(n.eye,s(N,o,n.eye)),X)&&(d(o,X),s(a,o,n.eye))}function we(e){let{view:t,screenPoint:n,camera:i,initialDistance:o,depthSearchSize:c,output:l}=e,d=c>0?t.stage.renderView.getMinimalDepthForArea(T(t),n[0],n[1],i,c):null;s(l.translation,l.location,i.eye);let p=Math.min(f(l.translation),o);d&&d<=p&&(p=d),r(l.translation,l.translation),u(l.translation,l.translation,p),a(l.location,l.translation,i.eye)}async function Te(t,r){let i=t.navigation.mode;if(i.type!==`ground`){e.getLogger(`esri`).warn(`Can only advance while in ground navigation mode!`);return}let{camera:c}=t.state;t.renderCoordsHelper.worldUpAtPosition(c.eye,V);let l=t.sceneIntersectionHelper,p=$(t),m=o(N,V,c.viewRight);d(q.origin,c.eye),u(q.direction,m,r);let h=l.intersectRay(q,p,Y,{include:i.include,exclude:i.exclude}),g=new ne().copyFrom(c),_=s(oe,c.center,c.eye);return!h||n(Y,c.eye)>r?g.eye=a(N,q.origin,q.direction):(s(N,Y,c.eye),f(N)>2&&(Ee(N,N,.25,2),g.eye=a(N,c.eye,N))),g.center=a(N,g.eye,_),new ee(t).immediatelyCorrectGroundElevation({camera:g,correctionLimit:100}),t.goTo(w(t,g),{duration:500,liftOffDisabled:!0})}function Ee(e,t,n,r){let i=f(e),a=Math.min(n,Math.max(i-r,0)/i);u(t,e,a)}export{Q as computeHorizonPadding,de as computeHorizonPaddingLimits,he as findGroundNavigationGrabLocation,se as findPlaneHorizonY,ce as findSphereHorizonY,Te as groundNavigationAdvance,M as groundNavigationConstants,le as isAboveHorizon,Z as isBelowHorizon,Ee as shortenTranslation,ue as shouldClampScreenY};
2
+ import{createScreenPointArray as e}from"../../../../core/screenUtils.js";import{crossAndNormalize as t,copy as n,scale as r,subtract as i,add as a,distance as o,normalize as s,cross as c,dot as l,scaleAndAdd as u,length as d}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as f}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as p}from"../../../../geometry/ellipsoidUtils.js";import{fromValues as m}from"../../../../geometry/support/lineSegment.js";import{create as h,fromPositionAndNormal as g,distance as _,projectPoint as v,projectVector as y,intersectLineSegment as b}from"../../../../geometry/support/plane.js";import{create as x}from"../../../../geometry/support/ray.js";import{Sphere as S}from"../../../../geometry/support/sphere.js";import{fromRenderCamera as ee}from"../../webgl.js";import{getVoxelWasm as C}from"../../layers/VoxelWasm.js";import{pickPointAndInitSphere as w,sphereOrPlanePointFromScreenPoint as T,intersectPlaneFromScreenPoint as E,searchAreaSize as D}from"./navigationUtils.js";import{OffsetCorrectionController as O}from"./OffsetCorrectionController.js";import{fromScreenAtEye as te}from"../../support/geometryUtils/ray.js";import ne from"../../webgl/RenderCamera.js";import{Intersector as re}from"../../webgl-engine/lib/Intersector.js";const k=1.5,A={xSpeedMultiplier:k,ySpeedMultiplier:k,maxElevation:1e4,relativeHorizonPadding:.1,minimumHorizonPadding:12},j=f(),M=f(),N=e(),P=f(),F=h(),I=f(),L=f(),R=f(),z=f(),B=f(),ie=f(),V=f(),H=f(),U=f(),W=f(),G=e(),K=x(),q=new S,J=f(),Y=h(),X=f(),ae=f();function oe(e,t){return y(t,e.viewForward,j),a(M,e.eye,j),e.projectToScreen(M,N),N[1]}function se(e,n,d){let f=e.eye;if(o(n.center,f)<n.radius)return s(B,f),c(ie,B,e.viewRight),a(M,f,ie),e.projectToScreen(M,G),G[1];let p=e.up;te(e,d,K);let m=n.radius;if(t(P,p,K.direction),g(f,P,F),_(F,n.center)>m)return null;v(F,n.center,I);let h=o(n.center,I),y=Math.sqrt(m**2-h**2);i(L,f,I),s(R,L),t(z,P,R);let b=l(L,R),x=l(L,z),S=Math.sqrt(b**2+x**2),ee=Math.sqrt(S**2-y**2),C=y**2/S**2,w=y/S**2*ee,T=C*b,E=w*-x,D=C*x,O=w*b,ne=T+E,re=T-E,k=D+O,A=D-O;return a(V,I,u(V,r(V,R,ne),z,k)),a(H,I,u(H,r(H,R,re),z,A)),i(U,V,f),s(U,U),i(W,H,f),s(W,W),l(e.viewForward,U)>=l(e.viewForward,W)?e.projectToScreen(V,G):e.projectToScreen(H,G),G[1]}function ce(e,t,n=!0){return n?e<t:e<=t}function Z(e,t,n=!0){return n?e>t:e>=t}function le(e,t,n){return t?e>n:e<n}function Q(e,t){let n=e.fullHeight/e.pixelRatio,r=Math.max(t,n-t);return Math.max(A.minimumHorizonPadding,A.relativeHorizonPadding*r)}function ue(e,t){return[de(e,t),fe(e,t)]}function de(e,t){let n=e.fullHeight/e.pixelRatio;return Math.min(n,t+Q(e,t))}function fe(e,t){return Math.max(0,t-Q(e,t))}function pe(e,t,n){let r={translation:e,location:t};return n&&(r.normal=n),r}function me(e){let{view:t}=e;return t.viewingMode===`global`?he(e):ge(e)}function he(e){let{view:t,originalScreenPoint:r,horizonY:i,horizonPadding:a,outTranslation:c,outGrabLocation:l,outGrabNormal:u,intersectionOptions:d,depthSearchSize:f}=e,m=t.state.camera,h=pe(c,l,u);q.radius=p(t.spatialReference).radius;let g=w(t,m,r,q.radius,1,d);if(g.scenePickPoint==null)return!1;let _=g.hasGeometryIntersection;n(J,g.scenePickPoint),n(h.location,J);let v=g.sphere;h.normal&&g.normal&&n(h.normal,g.normal);let y=ve(r,i,a,_),b=_?o(J,m.eye):1/0;return y.wasAdjusted&&ye({view:t,screenAdjustment:y,intersector:$(t),fallbackCheck:(e,t,n)=>{let r=T(v,m,e,t);return r&&n&&s(n,t),r},output:h,intersectionOptions:d}),xe({view:t,screenPoint:y.adjustedScreenPoint,camera:m,initialDistance:b,depthSearchSize:f??D,output:h}),!0}function ge(e){let{view:t,originalScreenPoint:r,horizonY:i,horizonPadding:a,outTranslation:c,outGrabLocation:l,outGrabNormal:d,intersectionOptions:f,depthSearchSize:p}=e,m=t.sceneIntersectionHelper,h=t.state.camera,_=$(t),v=pe(c,l,d);m.intersectIntersectorScreen(r,_,f);let y=_.results.min.getIntersectionPoint(J),b=y?o(J,h.eye):1/0;y&&(n(v.location,J),v.normal&&n(v.normal,_.results.min.normal)),t.renderCoordsHelper.worldUpAtPosition(h.eye,B),u(X,h.eye,B,-h.relativeElevation),g(X,B,Y);let x=ve(r,i,a,y);return x.wasAdjusted&&ye({view:t,screenAdjustment:x,intersector:_,fallbackCheck:(e,t,n)=>{let r=E(Y,h,e,t);return r&&n&&s(n,B),r},output:v,intersectionOptions:f}),xe({view:t,screenPoint:x.adjustedScreenPoint,camera:h,initialDistance:b,depthSearchSize:p??D,output:v}),!0}function _e(e,t,n,r){return!r&&ce(e,t)||r&&le(e,!1,n[0])?n[0]:!r&&Z(e,t,!1)?n[1]:null}function ve(t,n,r,i){let a=_e(t[1],n,r,i);return{originalScreenPoint:t,adjustedScreenPoint:e(t[0],a??t[1]),horizonY:n,horizonPadding:r,wasAdjusted:a!==null}}function $(e){let t=new re(e.state.viewingMode);return t.options.selectionMode=!0,t.options.store=0,t.options.hud=!1,t.options.normalRequired=!0,t}function ye(e){let{view:t,screenAdjustment:r,fallbackCheck:i,intersector:a,output:o,intersectionOptions:s}=e,c=t.sceneIntersectionHelper;c.intersectIntersectorScreen(r.adjustedScreenPoint,a,{...s,requiresGroundFeedback:!0});let l=a.results.min.getIntersectionPoint(o.location);if(l){o.normal&&n(o.normal,a.results.min.normal);return}let u=be(r);c.intersectIntersectorScreen(u,a,{...s,requiresGroundFeedback:!0}),l=a.results.min.getIntersectionPoint(o.location),l?o.normal&&n(o.normal,a.results.min.normal):(l=i(r.adjustedScreenPoint,o.location,o.normal),l||i(u,o.location,o.normal))}function be(t){let{originalScreenPoint:n,adjustedScreenPoint:r,horizonY:i,horizonPadding:a}=t,o=Z(r[1],i)?Math.min(a[1],n[1]):Math.max(a[0],n[1]);return e(r[0],o)}function xe(e){Se(e),Ce(e)}function Se(e){let{view:t,camera:r,output:a}=e,{offset:o}=t.navigation.mode;if(!o)return;let{translation:s,location:c}=a;t.renderCoordsHelper.worldUpAtPosition(r.eye,B),u(X,r.eye,B,-o),g(X,B,F),b(F,m(r.eye,i(j,c,r.eye)),X)&&(n(c,X),i(s,c,r.eye))}function Ce(e){let{view:t,screenPoint:n,camera:o,initialDistance:c,depthSearchSize:l,output:u}=e,f=l>0?t.stage.renderView.getMinimalDepthForArea(C(t),n[0],n[1],o,l):null;i(u.translation,u.location,o.eye);let p=Math.min(d(u.translation),c);f&&f<=p&&(p=f),s(u.translation,u.translation),r(u.translation,u.translation,p),a(u.location,u.translation,o.eye)}async function we(e,t,n,r,i){let a=new ne().copyFrom(e.state.camera);if(Te({view:e,camera:a,forwardDirection:t,forwardDistance:n,detectCollisions:!0}))return r?r.smoothlyCorrectGroundElevation({camera:a,deltaTime:i}):new O(e).immediatelyCorrectGroundElevation({camera:a,correctionLimit:100}),e.goTo(ee(e,a),{duration:500,liftOffDisabled:!0})}function Te(e){let{view:s,camera:c,forwardDirection:l,forwardDistance:u,detectCollisions:f}=e,p=s.navigation.mode;if(p.type!==`ground`)return!1;s.renderCoordsHelper.worldUpAtPosition(c.eye,B);let m=s.sceneIntersectionHelper,h=$(s),g=t(j,B,t(j,l,B));n(K.origin,c.eye),r(K.direction,g,u);let _=m.intersectRay(K,h,J,{include:p.include,exclude:p.exclude}),v=i(ae,c.center,c.eye);return!f||!_||o(J,c.eye)>Math.abs(u)?c.eye=a(j,K.origin,K.direction):(i(j,J,c.eye),d(j)>2&&(Ee(j,j,.25,2),c.eye=a(j,c.eye,j))),c.center=a(j,c.eye,v),!0}function Ee(e,t,n,i){let a=d(e),o=Math.min(n,Math.max(a-i,0)/a);r(t,e,o)}export{Te as advanceGroundNavigationCamera,Q as computeHorizonPadding,ue as computeHorizonPaddingLimits,me as findGroundNavigationGrabLocation,oe as findPlaneHorizonY,se as findSphereHorizonY,we as groundNavigationAdvance,A as groundNavigationConstants,ce as isAboveHorizon,Z as isBelowHorizon,Ee as shortenTranslation,le as shouldClampScreenY};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import"../webgl-engine/core/shaderLibrary/terrain/BackgroundGrid.glsl.js";import"../webgl-engine/core/shaderLibrary/terrain/TileBackground.glsl.js";import"../webgl-engine/core/shaderLibrary/terrain/TileComposite.glsl.js";import"../webgl-engine/core/shaderModules/Float3PassUniform.js";import"../webgl-engine/core/shaderModules/FloatPassUniform.js";import"../webgl-engine/core/shaderModules/glsl.js";import"../webgl-engine/core/shaderModules/Texture2DPassUniform.js";import"../../webgl/ShaderBuilder.js";export{b as build}from"../../../chunks/BlendLayers.glsl.js";
2
+ import"../webgl-engine/core/shaderLibrary/terrain/BackgroundGrid.glsl.js";import"../webgl-engine/core/shaderLibrary/terrain/blendLayers.glsl.js";import"../webgl-engine/core/shaderLibrary/terrain/TileComposite.glsl.js";import"../webgl-engine/core/shaderModules/Float3PassUniform.js";import"../webgl-engine/core/shaderModules/FloatPassUniform.js";import"../webgl-engine/core/shaderModules/Texture2DPassUniform.js";import"../../webgl/ShaderBuilder.js";export{b as build}from"../../../chunks/BlendLayers.glsl.js";
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import{equals as e}from"../../../core/arrayUtils.js";import"../../../core/has.js";import{isPowerOfTwo as t}from"../../../core/mathUtils.js";import{disposeMaybe as n,releaseMaybe as r}from"../../../core/maybe.js";import{equals as i}from"../../../geometry/support/aaBoundingRect.js";import{glLayout as a}from"../support/buffer/glUtil.js";import{GeometryState as o}from"./GeometryState.js";import{PatchGeometry as s}from"./PatchGeometry.js";import"../../../geometry/support/Ellipsoid.js";import{internalAssert as c,neighborEdgeIndices as l,oppositeEdge as u,neighborCornerIndices as d,enableTerrainInternalChecks as f}from"./terrainUtils.js";import{maxTileNeighborLevelDelta as p}from"./TerrainConst.js";import{TextureFader as m}from"./TextureFader.js";import{TextureReference as h}from"./TextureReference.js";import g from"./TileOverlayData.js";import{fallsWithinLayerView as _}from"./tileUtils.js";import{VertexArrayObject as v}from"../webgl-engine/lib/VertexArrayObject.js";import{BufferObject as y}from"../../webgl/BufferObject.js";import{VertexBuffer as b}from"../../webgl/VertexBuffer.js";class x{constructor(){this.geometry=new s,this.geometryState=null,this._texture=null,this._textureOpacity=1,this._textureFader=new m(()=>this._tile.surface.fadeDuration),this.overlay=new g,this._localOrigin=null,this._geometryStateChangedSinceLastUpdate=!0,this._hasGeometry=!1,this._modifiedFlags=0}get tile(){return this._tile}get localOrigin(){return this._localOrigin}init(e,t){this.clear(),this._tile=e,this.geometry.reset(),this.intersectionData=null,this.geometryState=new o,this._localOrigin=t,this.overlay.clear()}clear(){this.releaseGeometry(),this.releaseTexture(),this._textureFader.clear(),this._tile=null,this.intersectionData=null,this.geometryState=null}updateGeometryIfNeeded(e){if(this._tile&&this.geometryState&&((!this._vao||this._geometryStateChangedSinceLastUpdate||this.wireframeChanged||this.clippingAreaChanged||this.samplerDataChanged||this.numVerticesPerSideChanged||this.dirtyCorners||this.dirtyEdgeResolutions||this.dirtyEdges)&&(this._updateGeometry(e),this._geometryStateChangedSinceLastUpdate=!1),f&&this.tile.intersectsClippingArea))for(let e=0;e<j;++e)c(this.geometry.getEdgeCount(e)===this.geometryState.edgeResolutions[e]+1)}_calculateEdgeResolution(e,t){let n=this.tile,r=this.geometryState.numVerticesPerSide-1;if(!n.surface.isGlobal){let t=n.surface.groundExtent;if(t!=null&&(e===0&&n.extent[3]>t[3]||e===1&&n.extent[2]>t[2]||e===2&&n.extent[1]<t[1]||e===3&&n.extent[0]<t[0]))return r}let i=n.level,a=l[e];if(!t)return c(n.surface?.rootTiles==null||n.surface.updatingRootTiles||!n.shouldHaveNeighbor(a)),r;if(t.loaded){let n=t,a=n.renderData?.geometryState;if(!a)return r;let o=i-n.level;if(c(o>=0),o===0){let e=a.numVerticesPerSide-1;return Math.max(e,r)}let s=2**o,l=a.edgeResolutions[(e+2)%4]/s;return Math.max(1,l)}c(!t.leaf);let o=r;return t.forAllSubtreeOnSide(u(a),e=>e===n?!0:e.loaded?(o=Math.max(o,2**(e.level-i)),!0):(c(!e.leaf),!1)),o}updateNeighborData(){let e=this.tile;if(!e.intersectsClippingArea)return;let n=e.renderData.geometryState,r=t=>(t.loaded||t.level===e.level)&&t.intersectsClippingArea,i=n.edgePeerNeighbors,a=n.edgePeerNeighborSamplerVersions;for(let o=0;o<j;++o){let s=e.findNeighborTile(l[o],r),u=C(e,s),d=u?.renderData?.geometryState.samplerDataVersion??-1,m=i[o],h=u!==C(e,m),g=a[o]!==d;f&&s&&(c(e.level>=s.level),c(e.level-s.level<=p)),i[o]=s,(h||g)&&(a[o]=d,this._markEdgeDirty(o));let _=n.edgeResolutions[o],v=this._calculateEdgeResolution(o,s);c(t(v)),c(v>=1),n.edgeResolutions[o]=v,_!==v&&this._markEdgeResolutionDirty(o)}for(let t=0;t<j;++t){let a=e.findNeighborTile(d[t],r);n.cornerPeerNeighbors[t]=a;let o=C(e,i[t]),s=C(e,i[(t+1)%j]),l=C(e,a);S[t]=l,S[(t+1)%j]=s,S[(t+2)%j]=e,S[(t+3)%j]=o,c(S.some(t=>t?.loaded||t===e));let u=S.reduce((e,t)=>Math.min(e,t?.level??1/0),1/0);S.forEach((e,t)=>{e&&e.level>u&&(S[t]=null)}),c(S.some(t=>t?.loaded||t===e));let p=n.cornerNeighborCornerTiles,m=n.cornerNeighborCornerTileSamplerVersions;for(let e=0;e<j;++e){let n=S[e],r=n?.renderData?.geometryState?.samplerDataVersion??-1,i=t*j+e,a=p[i]!==n,o=!a&&m[i]!==r;(a||o)&&(p[i]=n,m[i]=r,this._markCornerDirty(t))}f&&c(M.some(n=>{let r=p[t*j+n];return r?.loaded||r===e}))}f&&c(n.edgeResolutions.every(e=>e>0));for(let e=0;e<j;++e)S[e]=null}_updateGeometry(e){if(!this.tile.intersectsClippingArea)return;f&&c(!this.tile.intersectsClippingArea||this.geometryState.edgeResolutions.every(e=>e>0)),this.intersectionData=null;let{tile:t,_vao:n,geometry:r,geometryState:i}=this,{vertexAttributes:a}=r,o=!n||!a||this.wireframeChanged||this.samplerDataChanged||this.clippingAreaChanged,s=this.dirtyEdgeResolutions!==0,l=i.edgeResolutions.reduce((e,t)=>Math.max(e,t),0)+1,u=s&&l>r.maxEdgeVertexCount,d=o||this.numVerticesPerSideChanged||u,p=!d&&s,m=!p&&this.dirtyEdges!==0,h=!m&&this.dirtyCorners!==0;d?(this.releaseGeometry(),this._createGeometry(e)):p?t.updateEdgeElevationsAndResolutions():m||h?t.updateEdgeElevations():console.warn(`Update for no reason?`),this._modifiedFlags=0}get hasGeometry(){return this._hasGeometry}releaseGeometry(){return this._hasGeometry=!1,this.intersectionData=null,this._vao?(this._vao=n(this._vao),this.geometry.release(),!0):!1}ensureTexture(e,t,n,r){let i=t?6408:6407;return this._texture!=null&&(n===0&&this._tile.surface.fadeDuration>0&&this._isTextureVisible(this._texture)||this._texture.descriptor.width!==e||this._texture.descriptor.pixelFormat!==i)&&this.releaseTexture(),this._texture??(this._texture=r(),this.tile.setMemoryDirty()),this._texture}releaseTexture(){this._texture&&(this._texture=r(this._texture),this.tile.setMemoryDirty())}reuseTexture(e,t){return!e||!this._texture?!1:(e.setTextureReference(new h(this._texture,0,t,this._textureOpacity,0,1)),!0)}get numVerticesPerSideChanged(){return(this._modifiedFlags&w)!==0}get samplerDataChanged(){return(this._modifiedFlags&T)!==0}get clippingAreaChanged(){return(this._modifiedFlags&E)!==0}get wireframeChanged(){return(this._modifiedFlags&D)!==0}get dirtyEdges(){return this._modifiedFlags>>O&15}get dirtyCorners(){return this._modifiedFlags>>k&15}get dirtyEdgeResolutions(){return this._modifiedFlags>>A&15}_markCornerDirty(e){let t=1<<e<<k;this._modifiedFlags|=t}_markEdgeDirty(e){let t=1<<e<<O;this._modifiedFlags|=t,this._markCornerDirty((e+0)%4),this._markCornerDirty((e+3)%4)}_markEdgeResolutionDirty(e){let t=1<<e<<A;this._modifiedFlags|=t,this._markEdgeDirty(e)}_markAllEdgesAndCornersDirty(){this._modifiedFlags|=15<<k|15<<O|15<<A}updateGeometryState(){let e=this._elevationInfo,t=this.tile,n=e.samplerData?t.getElevationVerticesPerSide(e.maxTileLevel):t.minimumVerticesPerSide,r=Math.max(n,5),a=t.clippingArea;(!t.intersectsClippingArea||t.withinClippingArea)&&(a=null);let o=this.geometryState,s=!1;o.numVerticesPerSide!==r&&(this._modifiedFlags|=w,o.numVerticesPerSide=r,o.samplerDataVersion++,s=!0),e.changed&&(this._modifiedFlags|=T,o.samplerData=e.samplerData,o.samplerDataSourceLevels=e.samplerDataSourceLevels,o.samplerDataVersion++,s=!0),i(o.clippingArea,a)||(this._modifiedFlags|=E,o.clippingArea=a,s=!0);let c=t.surface.wireframe;return o.wireframe!==c&&(this._modifiedFlags|=D,o.wireframe=c,s=!0),this._geometryStateChangedSinceLastUpdate||=s,s&&this._markAllEdgesAndCornersDirty(),this._hasGeometry=!0,this._geometryStateChangedSinceLastUpdate}_createGeometry(e){this.tile.createGeometry();let{vertexAttributes:t,indices:n}=this.geometry,r=e.gl;this._vao=new v(e,new b(e,a(t.layout),t.buffer),y.createIndex(e,r.STATIC_DRAW,n)),this._hasGeometry=!0}get vao(){return this._vao}setTextureReference(e,t=0){e?.texture===this._texture?this._textureOpacity=e.opacities[0]:this.releaseTexture(),this._textureFader.push(e,t)}get textureReference(){return this._textureFader.current}get nextTextureReference(){return this._textureFader.next}get textureFadeFactor(){return this._textureFader.fadeFactor}get textureIsFading(){return this._textureFader.isFading}_isTextureVisible(e){return this._textureFader.current?.texture===e||this._textureFader.next?.texture===e&&this._textureFader.fadeFactor<1}get _elevationInfo(){let t=this.geometryState.samplerData,n=this.geometryState.samplerDataSourceLevels,r=this.tile.layerInfo[0],i=r.length,a=Array(i),o=Array(i),s=0,c=0,l=!1;for(let e=0;e<i;e++){let n=r[e],i=n.upsampleInfo?.tile;if(i){let n=i.layerInfo[0][e].data,r=n&&n.samplerData;t&&t[s]===r||(l=!0),a[s++]=r,o[s-1]=n?.level??i.level,c=Math.max(c,i.lij[0])}else if(n.data){let r=this.tile.surface.layerViewByIndex(e,0);if(_(this.tile,r)){let e=n.data;t&&t[s]===e.samplerData||(l=!0),a[s++]=e.samplerData,o[s-1]=e.level,c=this.tile.level}}}t!=null&&t.length!==s&&(l=!0);let u=s>0,d=u?a:null,f=u?o:null;return u&&(a.length=s,o.length=s),e(n,f)||(l=!0),{changed:l,samplerData:d,samplerDataSourceLevels:f,maxTileLevel:c}}get estimatedGeometryMemoryUsage(){let e=this.intersectionData?.estimatedMemoryUsage??0;return(this.geometry.indices?.byteLength??0)+(this.geometry.vertexAttributes?.byteLength??0)+e}get texture(){return this._texture}get test(){}checkGeometryWaterproofness(){}}const S=[null,null,null,null];function C(e,t){return t?.loaded||t===e?t:null}const w=1,T=2,E=4,D=8,O=4,k=8,A=12,j=4,M=[0,1,2,3];export{x as PatchRenderData,C as neighborTileIfLoadedOrSelf,M as zeroToFour};
2
+ import{equals as e}from"../../../core/arrayUtils.js";import"../../../core/has.js";import{isPowerOfTwo as t}from"../../../core/mathUtils.js";import{disposeMaybe as n,releaseMaybe as r}from"../../../core/maybe.js";import{equals as i}from"../../../geometry/support/aaBoundingRect.js";import{glLayout as a}from"../support/buffer/glUtil.js";import{GeometryState as o}from"./GeometryState.js";import{PatchGeometry as s}from"./PatchGeometry.js";import"../../../geometry/support/Ellipsoid.js";import{internalAssert as c,neighborEdgeIndices as l,oppositeEdge as u,neighborCornerIndices as d,enableTerrainInternalChecks as f}from"./terrainUtils.js";import{maxTileNeighborLevelDelta as p}from"./TerrainConst.js";import{TextureFader as m}from"./TextureFader.js";import{TextureReference as h}from"./TextureReference.js";import g from"./TileOverlayData.js";import{fallsWithinLayerView as _}from"./tileUtils.js";import{VertexArrayObject as v}from"../webgl-engine/lib/VertexArrayObject.js";import{BufferObject as y}from"../../webgl/BufferObject.js";import{VertexBuffer as b}from"../../webgl/VertexBuffer.js";class x{constructor(){this.geometry=new s,this.geometryState=null,this._texture=null,this._textureOpacity=1,this._textureFader=new m(()=>this._tile.surface.fadeDuration),this.overlay=new g,this._localOrigin=null,this._geometryStateChangedSinceLastUpdate=!0,this._hasGeometry=!1,this._modifiedFlags=0}get tile(){return this._tile}get localOrigin(){return this._localOrigin}init(e,t){this.clear(),this._tile=e,this.geometry.reset(),this.intersectionData=null,this.geometryState=new o,this._localOrigin=t,this.overlay.clear()}clear(){this.releaseGeometry(),this.releaseTexture(),this._textureFader.clear(),this._tile=null,this.intersectionData=null,this.geometryState=null}updateGeometryIfNeeded(e){if(this._tile&&this.geometryState&&((!this._vao||this._geometryStateChangedSinceLastUpdate||this.wireframeChanged||this.clippingAreaChanged||this.samplerDataChanged||this.numVerticesPerSideChanged||this.dirtyCorners||this.dirtyEdgeResolutions||this.dirtyEdges)&&(this._updateGeometry(e),this._geometryStateChangedSinceLastUpdate=!1),f&&this.tile.intersectsClippingArea))for(let e=0;e<j;++e)c(this.geometry.getEdgeCount(e)===this.geometryState.edgeResolutions[e]+1)}_calculateEdgeResolution(e,t){let n=this.tile,r=this.geometryState.numVerticesPerSide-1;if(!n.surface.isGlobal){let t=n.surface.groundExtent;if(t!=null&&(e===0&&n.extent[3]>t[3]||e===1&&n.extent[2]>t[2]||e===2&&n.extent[1]<t[1]||e===3&&n.extent[0]<t[0]))return r}let i=n.level,a=l[e];if(!t)return c(n.surface?.rootTiles==null||n.surface.updatingRootTiles||!n.shouldHaveNeighbor(a)),r;if(t.loaded){let n=t,a=n.renderData?.geometryState;if(!a)return r;let o=i-n.level;if(c(o>=0),o===0){let e=a.numVerticesPerSide-1;return Math.max(e,r)}let s=2**o,l=a.edgeResolutions[(e+2)%4]/s;return Math.max(1,l)}c(!t.leaf);let o=r;return t.forAllSubtreeOnSide(u(a),e=>e===n?!0:e.loaded?(o=Math.max(o,2**(e.level-i)),!0):(c(!e.leaf),!1)),o}updateNeighborData(){let e=this.tile;if(!e.intersectsClippingArea)return;let n=e.renderData.geometryState,r=t=>(t.loaded||t.level===e.level)&&t.intersectsClippingArea,i=n.edgePeerNeighbors,a=n.edgePeerNeighborSamplerVersions;for(let o=0;o<j;++o){let s=e.findNeighborTile(l[o],r),u=C(e,s),d=u?.renderData?.geometryState.samplerDataVersion??-1,m=i[o],h=u!==C(e,m),g=a[o]!==d;f&&s&&(c(e.level>=s.level),c(e.level-s.level<=p)),i[o]=s,(h||g)&&(a[o]=d,this._markEdgeDirty(o));let _=n.edgeResolutions[o],v=this._calculateEdgeResolution(o,s);c(t(v)),c(v>=1),n.edgeResolutions[o]=v,_!==v&&this._markEdgeResolutionDirty(o)}for(let t=0;t<j;++t){let a=e.findNeighborTile(d[t],r);n.cornerPeerNeighbors[t]=a;let o=C(e,i[t]),s=C(e,i[(t+1)%j]),l=C(e,a);S[t]=l,S[(t+1)%j]=s,S[(t+2)%j]=e,S[(t+3)%j]=o,c(S.some(t=>t?.loaded||t===e));let u=S.reduce((e,t)=>Math.min(e,t?.level??1/0),1/0);S.forEach((e,t)=>{e&&e.level>u&&(S[t]=null)}),c(S.some(t=>t?.loaded||t===e));let p=n.cornerNeighborCornerTiles,m=n.cornerNeighborCornerTileSamplerVersions;for(let e=0;e<j;++e){let n=S[e],r=n?.renderData?.geometryState?.samplerDataVersion??-1,i=t*j+e,a=p[i]!==n,o=!a&&m[i]!==r;(a||o)&&(p[i]=n,m[i]=r,this._markCornerDirty(t))}f&&c(M.some(n=>{let r=p[t*j+n];return r?.loaded||r===e}))}f&&c(n.edgeResolutions.every(e=>e>0));for(let e=0;e<j;++e)S[e]=null}_updateGeometry(e){if(!this.tile.intersectsClippingArea)return;f&&c(!this.tile.intersectsClippingArea||this.geometryState.edgeResolutions.every(e=>e>0)),this.intersectionData=null;let{tile:t,_vao:n,geometry:r,geometryState:i}=this,{vertexAttributes:a}=r,o=!n||!a||this.wireframeChanged||this.samplerDataChanged||this.clippingAreaChanged,s=this.dirtyEdgeResolutions!==0,l=i.edgeResolutions.reduce((e,t)=>Math.max(e,t),0)+1,u=s&&l>r.maxEdgeVertexCount,d=o||this.numVerticesPerSideChanged||u,p=!d&&s,m=!p&&this.dirtyEdges!==0,h=!m&&this.dirtyCorners!==0;d?(this.releaseGeometry(),this._createGeometry(e)):p?t.updateEdgeElevationsAndResolutions():m||h?t.updateEdgeElevations():console.warn(`Update for no reason?`),this._modifiedFlags=0}get hasGeometry(){return this._hasGeometry}releaseGeometry(){return this._hasGeometry=!1,this.intersectionData=null,this._vao?(this._vao=n(this._vao),this.geometry.release(),!0):!1}ensureTexture(e,t,n,r){let i=t?6408:6407;return this._texture!=null&&(n===0&&this._tile.surface.fadeDuration>0&&this._isTextureVisible(this._texture)||this._texture.descriptor.width!==e||this._texture.descriptor.pixelFormat!==i)&&this.releaseTexture(),this._texture??(this._texture=r(),this.tile.setMemoryDirty()),this._texture}releaseTexture(){this._texture&&(this._texture=r(this._texture),this.tile.setMemoryDirty())}reuseTexture(e,t){return!e||!this._texture?!1:(e.setTextureReference(new h(this._texture,!1,0,t,this._textureOpacity,0,1)),!0)}get numVerticesPerSideChanged(){return(this._modifiedFlags&w)!==0}get samplerDataChanged(){return(this._modifiedFlags&T)!==0}get clippingAreaChanged(){return(this._modifiedFlags&E)!==0}get wireframeChanged(){return(this._modifiedFlags&D)!==0}get dirtyEdges(){return this._modifiedFlags>>O&15}get dirtyCorners(){return this._modifiedFlags>>k&15}get dirtyEdgeResolutions(){return this._modifiedFlags>>A&15}_markCornerDirty(e){let t=1<<e<<k;this._modifiedFlags|=t}_markEdgeDirty(e){let t=1<<e<<O;this._modifiedFlags|=t,this._markCornerDirty((e+0)%4),this._markCornerDirty((e+3)%4)}_markEdgeResolutionDirty(e){let t=1<<e<<A;this._modifiedFlags|=t,this._markEdgeDirty(e)}_markAllEdgesAndCornersDirty(){this._modifiedFlags|=15<<k|15<<O|15<<A}updateGeometryState(){let e=this._elevationInfo,t=this.tile,n=e.samplerData?t.getElevationVerticesPerSide(e.maxTileLevel):t.minimumVerticesPerSide,r=Math.max(n,5),a=t.clippingArea;(!t.intersectsClippingArea||t.withinClippingArea)&&(a=null);let o=this.geometryState,s=!1;o.numVerticesPerSide!==r&&(this._modifiedFlags|=w,o.numVerticesPerSide=r,o.samplerDataVersion++,s=!0),e.changed&&(this._modifiedFlags|=T,o.samplerData=e.samplerData,o.samplerDataSourceLevels=e.samplerDataSourceLevels,o.samplerDataVersion++,s=!0),i(o.clippingArea,a)||(this._modifiedFlags|=E,o.clippingArea=a,s=!0);let c=t.surface.wireframe;return o.wireframe!==c&&(this._modifiedFlags|=D,o.wireframe=c,s=!0),this._geometryStateChangedSinceLastUpdate||=s,s&&this._markAllEdgesAndCornersDirty(),this._hasGeometry=!0,this._geometryStateChangedSinceLastUpdate}_createGeometry(e){this.tile.createGeometry();let{vertexAttributes:t,indices:n}=this.geometry,r=e.gl;this._vao=new v(e,new b(e,a(t.layout),t.buffer),y.createIndex(e,r.STATIC_DRAW,n)),this._hasGeometry=!0}get vao(){return this._vao}setTextureReference(e,t=0){e?.texture===this._texture?this._textureOpacity=e.opacities[0]:this.releaseTexture(),this._textureFader.push(e,t)}get textureReference(){return this._textureFader.current}get nextTextureReference(){return this._textureFader.next}get textureFadeFactor(){return this._textureFader.fadeFactor}get textureIsFading(){return this._textureFader.isFading}_isTextureVisible(e){return this._textureFader.current?.texture===e||this._textureFader.next?.texture===e&&this._textureFader.fadeFactor<1}get _elevationInfo(){let t=this.geometryState.samplerData,n=this.geometryState.samplerDataSourceLevels,r=this.tile.layerInfo[0],i=r.length,a=Array(i),o=Array(i),s=0,c=0,l=!1;for(let e=0;e<i;e++){let n=r[e],i=n.upsampleInfo?.tile;if(i){let n=i.layerInfo[0][e].data,r=n&&n.samplerData;t&&t[s]===r||(l=!0),a[s++]=r,o[s-1]=n?.level??i.level,c=Math.max(c,i.lij[0])}else if(n.data){let r=this.tile.surface.layerViewByIndex(e,0);if(_(this.tile,r)){let e=n.data;t&&t[s]===e.samplerData||(l=!0),a[s++]=e.samplerData,o[s-1]=e.level,c=this.tile.level}}}t!=null&&t.length!==s&&(l=!0);let u=s>0,d=u?a:null,f=u?o:null;return u&&(a.length=s,o.length=s),e(n,f)||(l=!0),{changed:l,samplerData:d,samplerDataSourceLevels:f,maxTileLevel:c}}get estimatedGeometryMemoryUsage(){let e=this.intersectionData?.estimatedMemoryUsage??0;return(this.geometry.indices?.byteLength??0)+(this.geometry.vertexAttributes?.byteLength??0)+e}get texture(){return this._texture}get test(){}checkGeometryWaterproofness(){}}const S=[null,null,null,null];function C(e,t){return t?.loaded||t===e?t:null}const w=1,T=2,E=4,D=8,O=4,k=8,A=12,j=4,M=[0,1,2,3];export{x as PatchRenderData,C as neighborTileIfLoadedOrSelf,M as zeroToFour};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import"../webgl-engine/core/shaderLibrary/raster/Colormap.glsl.js";import"../webgl-engine/core/shaderLibrary/raster/Common.glsl.js";import"../webgl-engine/core/shaderLibrary/terrain/TileBackground.glsl.js";import"../webgl-engine/core/shaderLibrary/terrain/TileComposite.glsl.js";import"../webgl-engine/core/shaderLibrary/util/ColorConversion.glsl.js";import"../webgl-engine/core/shaderModules/BooleanPassUniform.js";import"../webgl-engine/core/shaderModules/Float2PassUniform.js";import"../webgl-engine/core/shaderModules/Float3PassUniform.js";import"../webgl-engine/core/shaderModules/FloatPassUniform.js";import"../webgl-engine/core/shaderModules/FloatsPassUniform.js";import"../webgl-engine/core/shaderModules/glsl.js";import"../webgl-engine/core/shaderModules/IntegerPassUniform.js";import"../webgl-engine/core/shaderModules/Texture2DPassUniform.js";import"../../webgl/ShaderBuilder.js";export{a as ColorizerHillshadeUniforms,b as ColorizerStretchUniforms,C as ColorizerUniforms,c as build}from"../../../chunks/RasterColorizer.glsl.js";
2
+ import"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import"../webgl-engine/core/shaderLibrary/raster/Colormap.glsl.js";import"../webgl-engine/core/shaderLibrary/raster/Common.glsl.js";import"../webgl-engine/core/shaderLibrary/terrain/blendLayers.glsl.js";import"../webgl-engine/core/shaderLibrary/terrain/TileComposite.glsl.js";import"../webgl-engine/core/shaderLibrary/util/ColorConversion.glsl.js";import"../webgl-engine/core/shaderModules/BooleanPassUniform.js";import"../webgl-engine/core/shaderModules/Float2PassUniform.js";import"../webgl-engine/core/shaderModules/Float3PassUniform.js";import"../webgl-engine/core/shaderModules/FloatPassUniform.js";import"../webgl-engine/core/shaderModules/FloatsPassUniform.js";import"../webgl-engine/core/shaderModules/glsl.js";import"../webgl-engine/core/shaderModules/IntegerPassUniform.js";import"../webgl-engine/core/shaderModules/Texture2DPassUniform.js";import"../../webgl/ShaderBuilder.js";export{a as ColorizerHillshadeUniforms,b as ColorizerStretchUniforms,C as ColorizerUniforms,c as build}from"../../../chunks/RasterColorizer.glsl.js";
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- const e={type:`empty-tile`};function t(e){return e!=null&&`type`in e&&e.type===`vector-tile`}function n(e){return e!=null&&`type`in e&&e.type===`raster-tile`}function r(e){return e!=null&&`type`in e&&e.type===`tile-texture`}function i(e){return e!=null&&`type`in e&&e.type===`empty-tile`}function a(e){return e!=null&&`type`in e&&`bitmap`in e}export{e as emptyTile,a as isCreateBitmapResult,i as isEmptyTile,n as isRasterTile,r as isTileTexture,t as isVectorTile};
2
+ function e(e){return e!=null&&`type`in e&&e.type===`vector-tile`}function t(e){return e!=null&&`type`in e&&e.type===`raster-tile`}function n(e){return e!=null&&`type`in e&&e.type===`tile-texture`}function r(e){return e!=null&&`type`in e&&`bitmap`in e}export{r as isCreateBitmapResult,t as isRasterTile,n as isTileTexture,e as isVectorTile};