@arcgis/core 4.33.0-next.20250203 → 4.33.0-next.20250204

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 (263) hide show
  1. package/WebScene.js +1 -1
  2. package/assets/esri/core/workers/RemoteClient.js +1 -1
  3. package/assets/esri/core/workers/chunks/{d3a8aabdbfb59dd433e3.js → 01c3507d78398baaf61b.js} +1 -1
  4. package/assets/esri/core/workers/chunks/{c74441fbe0f63633796f.js → 04306c2760c1f5b19966.js} +1 -1
  5. package/assets/esri/core/workers/chunks/1a2e1a414e651e988435.js +2 -0
  6. package/assets/esri/core/workers/chunks/{bf9bc52a3c559108c19a.js.LICENSE.txt → 1a2e1a414e651e988435.js.LICENSE.txt} +1 -1
  7. package/assets/esri/core/workers/chunks/308ec51ff4a66f7fcb0d.js.LICENSE.txt +1 -1
  8. package/assets/esri/core/workers/chunks/354531dc2f0dea2ad96f.js +2 -0
  9. package/assets/esri/core/workers/chunks/{6e8905f20101c1f4509d.js.LICENSE.txt → 354531dc2f0dea2ad96f.js.LICENSE.txt} +1 -1
  10. package/assets/esri/core/workers/chunks/{448ee44c7f594e5b2551.js → 3ce826ebf0692363309d.js} +1 -1
  11. package/assets/esri/core/workers/chunks/44abd2cd17aae3299ede.js +1 -0
  12. package/assets/esri/core/workers/chunks/{e9f0402fa3ac5a249807.js → 5196c43dbce48d1b81ae.js} +1 -1
  13. package/assets/esri/core/workers/chunks/568bcf809fcfd4d9c713.js +1 -0
  14. package/assets/esri/core/workers/chunks/{3ec51b75d1a86dad6cb1.js → 60cd8f4bba3e682ba57e.js} +1 -1
  15. package/assets/esri/core/workers/chunks/61243217aed5de012e93.js +1 -0
  16. package/assets/esri/core/workers/chunks/69d307758262e5d7a32e.js +1 -0
  17. package/assets/esri/core/workers/chunks/{e444ec05a8a1dfbd21a8.js → 6dee40b94f94ee7bc4e4.js} +1 -1
  18. package/assets/esri/core/workers/chunks/72cf9192292e5c85c6df.js.LICENSE.txt +1 -1
  19. package/assets/esri/core/workers/chunks/77764ca90bdd13ee2167.js +2 -0
  20. package/assets/esri/core/workers/chunks/{25c8cc30faade043c8dc.js.LICENSE.txt → 77764ca90bdd13ee2167.js.LICENSE.txt} +1 -1
  21. package/assets/esri/core/workers/chunks/{f8367c21fa91435c7c53.js → 7a3e4cb5f64dac2cfe0e.js} +1 -1
  22. package/assets/esri/core/workers/chunks/7b11bf5799ecb3640b48.js +314 -0
  23. package/assets/esri/core/workers/chunks/{ba3c18d1efde46461231.js → 8438fba57e82e4cc7c11.js} +1 -1
  24. package/assets/esri/core/workers/chunks/{0ef5b0f8aa8a09acd6e0.js → 8e90c5fee4ad7c7275dc.js} +1 -1
  25. package/assets/esri/core/workers/chunks/{f2fae056a81f12b56b04.js → 8edae4ca2b18a219a43e.js} +1 -1
  26. package/assets/esri/core/workers/chunks/918bdba41fa470cf77fd.js +1 -0
  27. package/assets/esri/core/workers/chunks/a2409d4921c02614169a.js +1 -0
  28. package/assets/esri/core/workers/chunks/{7810579a5a780933cdc9.js → ad3e692681b50bd1acc2.js} +1 -1
  29. package/assets/esri/core/workers/chunks/{adfa126cea32298c28e9.js → b1269b51cef3e11c85e3.js} +1 -1
  30. package/assets/esri/core/workers/chunks/{692b3d03346f030aa649.js → b1f5344e57ee679a7e81.js} +44 -44
  31. package/assets/esri/core/workers/chunks/b21b152fa15896577242.js.LICENSE.txt +1 -1
  32. package/assets/esri/core/workers/chunks/b8a519d5d24b2e728ff8.js +2 -0
  33. package/assets/esri/core/workers/chunks/{7d3a441d2eb18d709ef9.js.LICENSE.txt → b8a519d5d24b2e728ff8.js.LICENSE.txt} +1 -1
  34. package/assets/esri/core/workers/chunks/b9ce0049e27a3e1ed9f9.js +1 -0
  35. package/assets/esri/core/workers/chunks/{79afe4674a0557eb26e4.js → bf26f58210755875748c.js} +1 -1
  36. package/assets/esri/core/workers/chunks/c032bcd25e2e7a57ad43.js +1 -0
  37. package/assets/esri/core/workers/chunks/{6e25742ceedea7fb1b97.js → c3f03ccabca691186aad.js} +1 -1
  38. package/assets/esri/core/workers/chunks/{5adeb979f178944b9ce5.js → c4c2b94e5cee7b824093.js} +1 -1
  39. package/assets/esri/core/workers/chunks/{3e872e5e528dca7bee0c.js → cc75bbfd779f409943a3.js} +1 -1
  40. package/assets/esri/core/workers/chunks/{4c5279fedf982a174706.js → d175953337fa655dc6b0.js} +1 -1
  41. package/assets/esri/core/workers/chunks/d35efcbe439500bf18bc.js +1 -0
  42. package/assets/esri/core/workers/chunks/{bc50585615f07d5ec1a9.js → e4f82b5b50996b1ae48e.js} +1 -1
  43. package/assets/esri/core/workers/chunks/{2345344be4b0e487d3a6.js → f198f4ba7d3d52882d98.js} +1 -1
  44. package/assets/esri/core/workers/chunks/{881ddbdeb40336208e90.js → f29715459ecd46180829.js} +1 -1
  45. package/assets/esri/core/workers/chunks/{d1678945cf6a58f76863.js → f48ef415b90edc7ccadd.js} +1 -1
  46. package/assets/esri/themes/base/_core.scss +0 -2
  47. package/assets/esri/themes/base/widgets/_Directions.scss +129 -425
  48. package/assets/esri/themes/base/widgets/_Editor.scss +31 -0
  49. package/assets/esri/themes/dark/main.css +1 -1
  50. package/assets/esri/themes/light/main.css +1 -1
  51. package/assets/esri/themes/light/view.css +1 -1
  52. package/assets/esri/widgets/Directions/t9n/Directions_ar.json +1 -1
  53. package/assets/esri/widgets/Directions/t9n/Directions_bg.json +1 -1
  54. package/assets/esri/widgets/Directions/t9n/Directions_bs.json +1 -1
  55. package/assets/esri/widgets/Directions/t9n/Directions_ca.json +1 -1
  56. package/assets/esri/widgets/Directions/t9n/Directions_cs.json +1 -1
  57. package/assets/esri/widgets/Directions/t9n/Directions_da.json +1 -1
  58. package/assets/esri/widgets/Directions/t9n/Directions_de.json +1 -1
  59. package/assets/esri/widgets/Directions/t9n/Directions_el.json +1 -1
  60. package/assets/esri/widgets/Directions/t9n/Directions_es.json +1 -1
  61. package/assets/esri/widgets/Directions/t9n/Directions_et.json +1 -1
  62. package/assets/esri/widgets/Directions/t9n/Directions_fi.json +1 -1
  63. package/assets/esri/widgets/Directions/t9n/Directions_fr.json +1 -1
  64. package/assets/esri/widgets/Directions/t9n/Directions_he.json +1 -1
  65. package/assets/esri/widgets/Directions/t9n/Directions_hr.json +1 -1
  66. package/assets/esri/widgets/Directions/t9n/Directions_hu.json +1 -1
  67. package/assets/esri/widgets/Directions/t9n/Directions_id.json +1 -1
  68. package/assets/esri/widgets/Directions/t9n/Directions_it.json +1 -1
  69. package/assets/esri/widgets/Directions/t9n/Directions_ja.json +1 -1
  70. package/assets/esri/widgets/Directions/t9n/Directions_ko.json +1 -1
  71. package/assets/esri/widgets/Directions/t9n/Directions_lt.json +1 -1
  72. package/assets/esri/widgets/Directions/t9n/Directions_lv.json +1 -1
  73. package/assets/esri/widgets/Directions/t9n/Directions_nl.json +1 -1
  74. package/assets/esri/widgets/Directions/t9n/Directions_no.json +1 -1
  75. package/assets/esri/widgets/Directions/t9n/Directions_pl.json +1 -1
  76. package/assets/esri/widgets/Directions/t9n/Directions_pt-BR.json +1 -1
  77. package/assets/esri/widgets/Directions/t9n/Directions_pt-PT.json +1 -1
  78. package/assets/esri/widgets/Directions/t9n/Directions_ro.json +1 -1
  79. package/assets/esri/widgets/Directions/t9n/Directions_ru.json +1 -1
  80. package/assets/esri/widgets/Directions/t9n/Directions_sk.json +1 -1
  81. package/assets/esri/widgets/Directions/t9n/Directions_sl.json +1 -1
  82. package/assets/esri/widgets/Directions/t9n/Directions_sr.json +1 -1
  83. package/assets/esri/widgets/Directions/t9n/Directions_sv.json +1 -1
  84. package/assets/esri/widgets/Directions/t9n/Directions_th.json +1 -1
  85. package/assets/esri/widgets/Directions/t9n/Directions_tr.json +1 -1
  86. package/assets/esri/widgets/Directions/t9n/Directions_uk.json +1 -1
  87. package/assets/esri/widgets/Directions/t9n/Directions_vi.json +1 -1
  88. package/assets/esri/widgets/Directions/t9n/Directions_zh-CN.json +1 -1
  89. package/assets/esri/widgets/Directions/t9n/Directions_zh-HK.json +1 -1
  90. package/assets/esri/widgets/Directions/t9n/Directions_zh-TW.json +1 -1
  91. package/chunks/ComponentShader.glsl.js +30 -30
  92. package/chunks/DefaultMaterial.glsl.js +19 -19
  93. package/chunks/HUDMaterial.glsl.js +34 -34
  94. package/chunks/MeasurementArrow.glsl.js +6 -6
  95. package/chunks/NativeLine.glsl.js +4 -4
  96. package/chunks/QuadraticBezier.js +1 -1
  97. package/chunks/RealisticTree.glsl.js +14 -14
  98. package/chunks/RibbonLine.glsl.js +32 -32
  99. package/chunks/Terrain.glsl.js +31 -31
  100. package/chunks/WaterSurface.glsl.js +15 -15
  101. package/copyright.txt +0 -29
  102. package/core/Collection.js +1 -1
  103. package/core/has.js +1 -1
  104. package/geometry/support/centroid.js +1 -1
  105. package/interfaces.d.ts +139 -13
  106. package/layers/graphics/controllers/FeatureTileController3D.js +1 -1
  107. package/layers/mixins/ArcGISImageService.js +1 -1
  108. package/layers/mixins/ImageryTileMixin.js +1 -1
  109. package/layers/support/labelUtils.js +1 -1
  110. package/layers/support/rasterDatasets/WCSRaster.js +1 -1
  111. package/layers/support/rasterDatasets/multidimensionalUtils.js +1 -1
  112. package/package.json +4 -5
  113. package/popup/content/AttachmentsContent.js +1 -1
  114. package/popup/support/AttachmentsOrderByInfo.d.ts +4 -0
  115. package/popup/support/AttachmentsOrderByInfo.js +5 -0
  116. package/portal/schemas/definitions.js +1 -1
  117. package/rest/imageService/fetchRasterInfo.js +1 -1
  118. package/support/revision.js +1 -1
  119. package/support/timeUtils.d.ts +0 -1
  120. package/support/timeUtils.js +1 -1
  121. package/symbols/cim/CIMSymbolDrawHelper.js +1 -1
  122. package/symbols/cim/animationUtils.js +1 -1
  123. package/symbols/cim/defaultCIMValues.js +1 -1
  124. package/views/2d/engine/webgl/animations/utils.js +1 -1
  125. package/views/2d/engine/webgl/mesh/factories/FeatureMeshFactory.js +1 -1
  126. package/views/2d/engine/webgl/shaderGraph/techniques/animated/AnimatedShader.js +1 -1
  127. package/views/2d/engine/webgl/shaderGraph/techniques/line/GradientStrokeTechnique.js +1 -1
  128. package/views/2d/engine/webgl/shaderGraph/techniques/line/gradientStrokeConstants.js +1 -1
  129. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/GradientStrokeShader.js +1 -1
  130. package/views/2d/engine/webgl/util/LabelMatcher.js +1 -1
  131. package/views/2d/engine/webgl/util/createMatcher.js +1 -1
  132. package/views/2d/layers/features/layerAdapters/SubtypeGroupLayerAdapter.js +1 -1
  133. package/views/3d/interactive/snapping/featureSources/featureServiceSource/FeatureServiceTiles3D.js +1 -1
  134. package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
  135. package/views/3d/layers/graphics/Graphics3DCore.js +1 -1
  136. package/views/3d/layers/graphics/Graphics3DGraphicsPipeline.js +1 -1
  137. package/views/3d/layers/i3s/I3SClientMaterialUtil.js +1 -1
  138. package/views/3d/layers/i3s/I3SMaterialUtil.js +1 -1
  139. package/views/3d/layers/support/FeatureTileFetcher3D.js +1 -1
  140. package/views/3d/layers/support/FeatureTileFetcher3DContext.js +1 -1
  141. package/views/3d/layers/support/FeatureTileTree3D.js +1 -1
  142. package/views/3d/layers/support/FeatureVisibilityFilter.js +1 -1
  143. package/views/3d/terrain/PatchRenderData.js +1 -1
  144. package/views/3d/webgl-engine/collections/Component/Material/ComponentMaterial.js +1 -1
  145. package/views/3d/webgl-engine/collections/Component/Material/shader/ComponentShader.glsl.js +1 -1
  146. package/views/3d/webgl-engine/core/shaderLibrary/util/DiscardOrAdjustAlpha.glsl.js +3 -3
  147. package/views/3d/webgl-engine/effects/debug/RenderNodeVisualizerNode.js +1 -1
  148. package/views/3d/webgl-engine/materials/CheckerBoardMaterial.js +1 -1
  149. package/views/3d/webgl-engine/materials/ColorMaterial.js +1 -1
  150. package/views/3d/webgl-engine/materials/DefaultMaterial.js +1 -1
  151. package/views/3d/webgl-engine/materials/HUDMaterial.js +1 -1
  152. package/views/3d/webgl-engine/materials/LineCalloutMaterial.js +1 -1
  153. package/views/3d/webgl-engine/materials/LineMarkerMaterial.js +1 -1
  154. package/views/3d/webgl-engine/materials/MeasurementArrowMaterial.js +1 -1
  155. package/views/3d/webgl-engine/materials/NativeLineMaterial.js +1 -1
  156. package/views/3d/webgl-engine/materials/PathMaterial.js +1 -1
  157. package/views/3d/webgl-engine/materials/PatternMaterial.js +1 -1
  158. package/views/3d/webgl-engine/materials/RibbonLineMaterial.js +1 -1
  159. package/views/3d/webgl-engine/materials/ShadedColorMaterial.js +1 -1
  160. package/views/3d/webgl-engine/shaders/DefaultMaterial.glsl.js +1 -1
  161. package/views/3d/webgl-engine/shaders/DefaultMaterialTechnique.js +1 -1
  162. package/views/3d/webgl-engine/shaders/HUDMaterial.glsl.js +1 -1
  163. package/views/3d/webgl-engine/shaders/MeasurementArrow.glsl.js +1 -1
  164. package/views/3d/webgl-engine/shaders/NativeLine.glsl.js +1 -1
  165. package/views/3d/webgl-engine/shaders/OutputColorHighlightOID.glsl.js +8 -8
  166. package/views/3d/webgl-engine/shaders/RealisticTree.glsl.js +1 -1
  167. package/views/3d/webgl-engine/shaders/RibbonLine.glsl.js +1 -1
  168. package/views/3d/webgl-engine/shaders/Terrain.glsl.js +1 -1
  169. package/views/3d/webgl-engine/shaders/WaterSurface.glsl.js +1 -1
  170. package/views/layers/FeatureLayerView.js +1 -1
  171. package/views/layers/ImageryTileLayerView.d.ts +4 -0
  172. package/views/layers/ImageryTileLayerView.js +1 -1
  173. package/webscene/spec-certification/index.js +1 -1
  174. package/widgets/BasemapLayerList.js +1 -1
  175. package/widgets/Directions/DirectionsSearchTool.js +5 -0
  176. package/widgets/Directions/DirectionsViewModel.js +1 -1
  177. package/widgets/Directions/DirectionsVisibleElements.js +5 -0
  178. package/widgets/Directions.js +1 -1
  179. package/widgets/Editor/CreateFeaturesWorkflow.js +1 -1
  180. package/widgets/Editor/CreateFeaturesWorkflowData.js +1 -1
  181. package/widgets/Editor/EditorViewModel.js +1 -1
  182. package/widgets/Editor/Edits.js +1 -1
  183. package/widgets/Editor/UpdateWorkflow.js +1 -1
  184. package/widgets/Editor/VisibleElements.js +1 -1
  185. package/widgets/Editor/components/CreateFeaturesPanelContent.js +1 -1
  186. package/widgets/Editor/components/PanelToolbar.js +1 -1
  187. package/widgets/Editor/components/PendingFeatureList.js +5 -0
  188. package/widgets/Editor/components/UpdateFeaturePanelContent.js +1 -1
  189. package/widgets/Editor/css.js +1 -1
  190. package/widgets/Editor/workflowUtils.js +1 -1
  191. package/widgets/Editor.js +1 -1
  192. package/widgets/FeatureForm/FeatureFormViewModel.js +1 -1
  193. package/widgets/FeatureForm/FieldInput.js +1 -1
  194. package/widgets/FeatureForm.js +1 -1
  195. package/widgets/LayerList.js +1 -1
  196. package/widgets/Legend/LegendViewModel.js +1 -1
  197. package/widgets/Legend/support/ActiveLayerInfo.js +1 -1
  198. package/widgets/Legend.js +1 -1
  199. package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
  200. package/widgets/Search.js +1 -1
  201. package/widgets/Sketch/SketchViewModel.js +1 -1
  202. package/widgets/Sketch/VisibleElements.js +1 -1
  203. package/widgets/Sketch.js +1 -1
  204. package/widgets/support/ItemList.js +1 -1
  205. package/assets/esri/core/workers/chunks/06d72622590dbd38c5de.js +0 -1
  206. package/assets/esri/core/workers/chunks/0a19e1aec6a5502e391a.js +0 -1
  207. package/assets/esri/core/workers/chunks/12964a4b16113cdc9c93.js +0 -1
  208. package/assets/esri/core/workers/chunks/25c8cc30faade043c8dc.js +0 -2
  209. package/assets/esri/core/workers/chunks/326a3f50e585e492b673.js +0 -1
  210. package/assets/esri/core/workers/chunks/34d464dacee52739c98c.js +0 -1
  211. package/assets/esri/core/workers/chunks/4cab082b8432ddc05345.js +0 -1
  212. package/assets/esri/core/workers/chunks/6e8905f20101c1f4509d.js +0 -2
  213. package/assets/esri/core/workers/chunks/6f796f2836f949ab7359.js +0 -1
  214. package/assets/esri/core/workers/chunks/7d3a441d2eb18d709ef9.js +0 -2
  215. package/assets/esri/core/workers/chunks/bf9bc52a3c559108c19a.js +0 -2
  216. package/assets/esri/core/workers/chunks/dd46ec81cebe1a0a7b9c.js +0 -1
  217. package/assets/esri/core/workers/chunks/fb1a89f753057f889971.js +0 -314
  218. package/assets/esri/core/workers/chunks/ffa2b9d70830aed03a8f.js +0 -1
  219. package/assets/esri/themes/base/widgets/_SaveLayer.scss +0 -40
  220. package/assets/esri/widgets/support/t9n/SaveLayer.json +0 -1
  221. package/assets/esri/widgets/support/t9n/SaveLayer_ar.json +0 -1
  222. package/assets/esri/widgets/support/t9n/SaveLayer_bg.json +0 -1
  223. package/assets/esri/widgets/support/t9n/SaveLayer_bs.json +0 -1
  224. package/assets/esri/widgets/support/t9n/SaveLayer_ca.json +0 -1
  225. package/assets/esri/widgets/support/t9n/SaveLayer_cs.json +0 -1
  226. package/assets/esri/widgets/support/t9n/SaveLayer_da.json +0 -1
  227. package/assets/esri/widgets/support/t9n/SaveLayer_de.json +0 -1
  228. package/assets/esri/widgets/support/t9n/SaveLayer_el.json +0 -1
  229. package/assets/esri/widgets/support/t9n/SaveLayer_en.json +0 -1
  230. package/assets/esri/widgets/support/t9n/SaveLayer_es.json +0 -1
  231. package/assets/esri/widgets/support/t9n/SaveLayer_et.json +0 -1
  232. package/assets/esri/widgets/support/t9n/SaveLayer_fi.json +0 -1
  233. package/assets/esri/widgets/support/t9n/SaveLayer_fr.json +0 -1
  234. package/assets/esri/widgets/support/t9n/SaveLayer_he.json +0 -1
  235. package/assets/esri/widgets/support/t9n/SaveLayer_hr.json +0 -1
  236. package/assets/esri/widgets/support/t9n/SaveLayer_hu.json +0 -1
  237. package/assets/esri/widgets/support/t9n/SaveLayer_id.json +0 -1
  238. package/assets/esri/widgets/support/t9n/SaveLayer_it.json +0 -1
  239. package/assets/esri/widgets/support/t9n/SaveLayer_ja.json +0 -1
  240. package/assets/esri/widgets/support/t9n/SaveLayer_ko.json +0 -1
  241. package/assets/esri/widgets/support/t9n/SaveLayer_lt.json +0 -1
  242. package/assets/esri/widgets/support/t9n/SaveLayer_lv.json +0 -1
  243. package/assets/esri/widgets/support/t9n/SaveLayer_nl.json +0 -1
  244. package/assets/esri/widgets/support/t9n/SaveLayer_no.json +0 -1
  245. package/assets/esri/widgets/support/t9n/SaveLayer_pl.json +0 -1
  246. package/assets/esri/widgets/support/t9n/SaveLayer_pt-BR.json +0 -1
  247. package/assets/esri/widgets/support/t9n/SaveLayer_pt-PT.json +0 -1
  248. package/assets/esri/widgets/support/t9n/SaveLayer_ro.json +0 -1
  249. package/assets/esri/widgets/support/t9n/SaveLayer_ru.json +0 -1
  250. package/assets/esri/widgets/support/t9n/SaveLayer_sk.json +0 -1
  251. package/assets/esri/widgets/support/t9n/SaveLayer_sl.json +0 -1
  252. package/assets/esri/widgets/support/t9n/SaveLayer_sr.json +0 -1
  253. package/assets/esri/widgets/support/t9n/SaveLayer_sv.json +0 -1
  254. package/assets/esri/widgets/support/t9n/SaveLayer_th.json +0 -1
  255. package/assets/esri/widgets/support/t9n/SaveLayer_tr.json +0 -1
  256. package/assets/esri/widgets/support/t9n/SaveLayer_uk.json +0 -1
  257. package/assets/esri/widgets/support/t9n/SaveLayer_vi.json +0 -1
  258. package/assets/esri/widgets/support/t9n/SaveLayer_zh-CN.json +0 -1
  259. package/assets/esri/widgets/support/t9n/SaveLayer_zh-HK.json +0 -1
  260. package/assets/esri/widgets/support/t9n/SaveLayer_zh-TW.json +0 -1
  261. package/widgets/Directions/components/SaveLayer.js +0 -5
  262. package/widgets/Directions/css.js +0 -5
  263. /package/{views/3d/webgl-engine/core/shaderLibrary/util → webscene/support}/AlphaCutoff.js +0 -0
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import"../../../../core/has.js";import s from"../../../../core/Logger.js";import{getOrCreateMapValue as i}from"../../../../core/MapUtils.js";import{isAbortError as r,throwIfAborted as a}from"../../../../core/promiseUtils.js";import n from"../../../../core/ReactiveMap.js";import{on as o,watch as u}from"../../../../core/reactiveUtils.js";import{schedule as l}from"../../../../core/scheduling.js";import{signal as h}from"../../../../core/signal.js";import{property as d}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/RandomLCG.js";import{subclass as c}from"../../../../core/accessorSupport/decorators/subclass.js";import{create as p,equals as f,clone as _,expand as m,toExtent as g}from"../../../../geometry/support/aaBoundingRect.js";import{getObjectId as F,hasVertices as y}from"../../../../layers/graphics/dehydratedFeatures.js";import T from"../../../../rest/support/QuantizationParameters.js";import x from"../../../../rest/support/Query.js";import{ViewingMode as E}from"../../../ViewingMode.js";import{MultiFeatureReference as R,SingleFeatureReference as v}from"./featureReference.js";import{failedFeatureCount as C,FetchStatus as b,FeatureTile as D}from"./FeatureTile.js";import{tilesAreRelated as M}from"../../terrain/tileUtils.js";import{ImmediateTask as w,TaskPriority as U}from"../../../support/Scheduler.js";let O=class extends t{set maximumNumberOfFeatures(e){e=e||1/0;const 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&&null!=this.context.query.queryFeatureCount}set useTileCount(e){this._useTileCount=e,this.notifyChange("useTileCount")}get updating(){return this._dirty||!!this._pendingEdits||this._isFetching||(this.tileDescriptors?.updating??!1)}get memoryForUnusedFeatures(){let e=0;return this._featureTiles.forEach((t=>e+=t.estimatedUnusedSize)),e}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 hasAllFeatures(){if(this._paused||this.dataUpdating)return!1;for(const e of this._featureTiles.values())if(!this.hasFullGeometries&&0!==e.emptyFeatureRatio||!e.hasAllFeatures)return!1;return!0}get hasFullGeometries(){if(!this._supportsResolution)return!0;return this.tileDescriptors.some(j)||!this.context.capabilities.supportsQuantization&&"polyline"!==this.context.geometryType}set filterExtent(e){if(null!=e&&this.context.tilingScheme&&!e.spatialReference.equals(this.context.tilingScheme.spatialReference))return void s.getLogger(this).error("#filterExtent=","extent needs to be in the same spatial reference as the tiling scheme");const t=this._get("filterExtent");if(t===e||null!=t&&e&&t.equals(e))return;const i=null!=e?e.clone():null;this._set("filterExtent",i),this._reclip(i,t)}_updateTileZQuantization(e){if(this.context.viewingMode===E.Global){const 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.running=!1,this.updatingTotal=0,this.updatingRemaining=0,this.expectedFeatureDiff=0,this.maximumNumberOfFeaturesExceeded=!1,this._fullRatio=1,this._farRatio=1,this._zQuantizationFactor=h(1),this._changes={updates:{adds:new Array,removes:new Array},adds:new Array,removes:new Array},this._frameTask=w,this._featureTiles=new n,this._displayingFeatureReferences=new Map,this._numDisplayingFeatureReferences=0,this._dirty=!1,this._suspended=!0,this._pendingEdits=null,this._applyEditsTilesUpdated=!1,this._isFetching=!1}initialize(){this.addHandles([o((()=>this.tileDescriptors),"change",(()=>this._setDirty()),{sync:!0,onListenerAdd:()=>this._setDirty()}),u((()=>this._tileZQuantization),(()=>this.refetch()))]),this._objectIdField=this.context.objectIdField,this.FeatureReferenceClass=this.context.capabilities.supportsMultipleResolutions?R:v;const e=this.context.scheduler;null!=e&&(this._frameTask=e.registerTask(U.FEATURE_TILE_FETCHER,this)),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)})),null!=this.context.memoryCache&&this.context.memoryCache.clear(),this._setDirty()}refetch(){this._featureTiles.forEach((e=>{this._cancelFetchTile(e),this._resetFetchTile(e)})),null!=this.context.memoryCache&&this.context.memoryCache.clear(),this._setDirty()}suspend(){this._suspended||(this._suspended=!0,this._pause(),this._setDirty())}resume(){this._suspended&&(this._suspended=!1,this._unpause())}getMissingAttributesForFeature(e){for(const t of this._featureTiles.values()){const s=t.missingAttributes?.get(e);if(null!=s)return s}}_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=>{null!=t.displayingFeatures&&0!==t.displayingFeatures.length&&(null==e?e=new Set(t.availableFields):e.forEach((s=>{t.availableFields?.has(s)||e.delete(s)})))})),null!=e?e:new Set}applyEdits(e){this._pendingEdits||(this._pendingEdits={edits:Promise.resolve(),count:0,controller:new AbortController},this._pause());const t=this._pendingEdits;t.count++;const s=t.edits.then((()=>e.result.catch((e=>{if(r(e))throw e;return null})).then((e=>e?(this._applyEditsDeleteFeatures(e.deletedFeatures),this._applyEditsAddUpdateFeatures(e.addedFeatures,e.updatedFeatures,t.controller.signal).then((()=>e))):e)).then((e=>(0==--t.count&&(this._pendingEdits===t&&(this._pendingEdits=null),null!=this.context.memoryCache&&this.context.memoryCache.clear(),this._applyEditsTilesUpdated=!1,this._unpause()),e)))));return t.edits=s,this._updated(),s}_applyEditsDeleteFeatures(e){if(0===e.length)return;const t=this.context.globalIdField,i=t&&this.availableFields.has(t),r=new Set,a=this._objectIdField;e.forEach((({objectId:e,globalId:n})=>{(!e||e<0)&&t&&n&&(i||s.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(n,a,t)),null!=e&&e>=0&&r.add(e)})),this._featureTiles.forEach((e=>{if(!e.features)return;const t=e.features.filter((e=>!r.has(F(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,s){if(null==e)return null;const i=this.features.find((t=>t.attributes?.[s]===e));return i?F(i,t):null}async _applyEditsAddUpdateFeatures(e,t,i){const{objectIdField:r,globalIdField:a}=this.context,n=a&&this.availableFields.has(a),o=new Set,u=new Set;for(const s of e){const e=s.objectId;null!=e&&o.add(e)}for(const{objectId:h,globalId:d}of t){let e=h;(null==e||e<0)&&a&&(n||s.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`),e=this._objectIdFromGlobalId(d,r,a)),null!=e&&e>=0&&(o.add(e),u.add(e))}if(0===o.size)return;const l=[];this._featureTiles.forEach((e=>{const t=this._applyEditsAddUpdateTile(e,o,u,i);t&&l.push(t)})),this._updated(),await Promise.allSettled(l)}async _applyEditsAddUpdateTile(e,t,s,i){if(!e.features)return;e.fetchingResolution=e.descriptor.resolution;const r=this._createQuery(e);r.resultType=void 0,r.cacheHint=!1,r.objectIds=Array.from(t);const a=await this._queryFeatures(r,i);let n=null;if(s.size>0){const t=e.features.filter((e=>!s.has(F(e,this._objectIdField))));t.length!==e.features.length&&(n=t)}if(a.features.length>0){n||(n=e.features.slice());for(const e of a.features)n.push(e)}n&&(e.hasPreciseFeatureCount&&(e.numFeatures=Math.max(e.numFeatures,n.length)),this._applyEditsTileUpdated(),e.setFeatures(n,0,N(e.availableFields,a.fields),Q(e.missingAttributes,a.missingAttributes)),this._updateTileZQuantization(e),this._invalidateCounts())}_applyEditsTileUpdated(){this._applyEditsTilesUpdated||(this._applyEditsTilesUpdated=!0,this._updated())}_queryFeatures(e,t){return this.context.query.queryFeaturesDehydrated(e,{signal:t,timeout:q})}_setDirty(){this._dirty=!0,this._updated()}runTask(e){const t=this._frameTask.processQueue(e);if(!this._dirty||!this.initialized)return t;this._dirty=!1;const s=this._getListOfTiles();if(this._markTilesNotAlive(s),!e.run((()=>this._addTiles(s,e)))||!e.run((()=>this._filterExtentTiles(s,e)))||!e.run((()=>this._removeTiles(s,e)))||e.done)return void this._setDirty();const i=this._sortTiles(s);e.run((()=>this._showTiles(i,e)))&&e.run((()=>this._fetchTiles(i,e)))&&e.run((()=>this._updateMemoryEstimates(i,e)))||this._setDirty(),this._updated(),this.updating||this._updateMaximumNumberOfFeaturesExceeded()}_markTilesNotAlive(e){for(const t of e)t.alive=!1}_addTiles(e,t){return!(this._suspended||!this.tileDescriptors)&&(this.tileDescriptors.forEach((s=>{const i=this._featureTiles.get(s.id);i?i.alive=!0:t.done||(e.push(this._addTile(s)),t.madeProgress())})),t.hasProgressed)}_filterExtentTiles(e,t){for(const s of e){if(t.done)break;s.alive&&(s.filtered=!s.intersects(this.filterExtent),s.filtered&&(this._clearTile(s),t.madeProgress()))}return t.hasProgressed}_removeTiles(e,t){for(let s=e.length-1;s>=0&&!t.done;s--){const i=e[s];i.alive||(this._removeTile(i),s!==e.length-1&&(e[s]=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){const s=this._updateRatio(e),i=e=>{const t=this._fullRatio<1?s(e)*this._farRatio:1;return e.reduceFeatures(t,this.memoryFactor,this._objectIdField)&&this._setDirty(),(e.features?.length??0)>0&&e.fetchingResolution!==e.descriptor.resolution&&e.fetchStatus===b.DONE&&(e.fetchStatus=b.REFETCH_NEEDED,this._setDirty()),this._showTile(e)};for(const r of e)if(!t.run((()=>i(r)))){this._setDirty();break}return t.hasProgressed}_fetchTiles(e,t){if(this._paused)return!1;let i=!1;for(const s of e){if(!s.needsFetching)continue;const e=null!=this.context.memoryCache?this.context.memoryCache.pop(s.id):null;if(null==e){if(this._needsNumFeatures(s)){const e=new AbortController,r=this._fetchTileCount(s,e.signal);this._handleRequest(s,r,e,(()=>s.numFeatures=C)),i=!0,t.madeProgress()}if(t.done)return!0}else s.cache=e,s.numFeatures&&this._notifyDataUpdating(),this._setDirty(),this._scheduleUpdated(),t.madeProgress()}if(i)return t.hasProgressed;for(const r of e)if(r.needsFetching){const e=new AbortController,i=this._fetchTile(r,e.signal);if(this._handleRequest(r,i,e,(e=>{r.setFeatures([],0,null,void 0),this._invalidateCounts(),r.featuresMissing=!1,r.fetchFailed=!0,this.context.logFetchError(s.getLogger(this),e)})),t.madeProgress())return!0}return t.hasProgressed}_updateMemoryEstimates(e,t){return e.some((e=>!t.run((()=>e.updateMemoryEstimates()))&&(this._setDirty(),!0))),t.hasProgressed}_reclip(e,t){if(!this.initialized)return;const s=new Array;this._featureTiles.forEach((i=>{null!=i.displayingFeatures&&0!==i.displayingFeatures.length&&(i.intersectionIncludingBorrowed(t,S),i.intersectionIncludingBorrowed(e,L),f(S,L)||s.push(i))})),this._refreshDisplayingFeatures(s),this._updated()}_refreshDisplayingFeatures(e){const t=new Set,s=this._changes.updates;for(const i of e)if(null!=i.displayingFeatures)for(const e of i.displayingFeatures){const i=F(e,this._objectIdField);if(t.has(i))continue;t.add(i);const r=this._displayingFeatureReferences.get(i).feature;s.removes.push(r),s.adds.push(r)}this._applyChanges()}_updated(){let e=0;if(this._paused||this._featureTiles.forEach((t=>t.isFetching?++e:0)),this._isFetching=e>0,this._set("running",this._dirty),e>0||this._applyEditsTilesUpdated?this._notifyDataUpdating():this._dirty||this._set("dataUpdating",!1),this.updating){let t=0,s=0,i=0,r=0,a=0;const n=this._displayingFeatureReferences.size/this._numDisplayingFeatureReferences;this._featureTiles.forEach((e=>{if(++s,e.isFetching&&e.hasPreciseFeatureCount){const t=this._maximumFeaturesForTile(e)*(1-e.emptyFeatureRatio),s=null!=e.displayingFeatures?e.displayingFeatures.length*n:0;a+=t-s}e.needsFetching?++r:e.numFeatures>0&&(++i,t+=e.numFeatures)})),r+=e;let o=0,u=0;t?(u=t,o=Math.min(r*t/i,t)):(u=s,o=r),a=Math.min(this.maximumNumberOfFeatures-this.features.length,a),this._set("updatingTotal",u),this._set("updatingRemaining",o),this._set("expectedFeatureDiff",a)}else this._set("updatingTotal",0),this._set("updatingRemaining",0),this._set("expectedFeatureDiff",0);this.debugger&&this.debugger.update()}_updateMaximumNumberOfFeaturesExceeded(){for(const{perTileMaximumNumberOfFeaturesExceeded:e}of this._featureTiles.values())if(e)return void this._set("maximumNumberOfFeaturesExceeded",!0);this._set("maximumNumberOfFeaturesExceeded",!1)}_updateRatio(e){const t=A(e),s=e=>1/(1<<Math.max(0,t-e.descriptor.lij[0]));let i=0,r=0;for(const a of e){const e=a.numFeatures;i+=e,r+=e*s(a)}return this._fullRatio=Math.min(1,this.maximumNumberOfFeatures/i),this._farRatio=this.maximumNumberOfFeatures/r,this._scheduleUpdated(),s}_maximumFeaturesUpdated(e,t){e!==t&&(t>e&&this._featureTiles.forEach((e=>{if(!e.featuresMissing)return;const t=this._maximumFeaturesForTile(e);e.features&&(e.features.length>=t||e.fetchStatus===b.FULL)||(this._cancelFetchTile(e),this._resetFetchTile(e))})),this._setDirty())}_addTile(e){const t=new D(e);return this._featureTiles.set(t.id,t),this._resetFetchTile(t),this._referenceDisplayingFeaturesFromRelatedTiles(t),t}_referenceDisplayingFeaturesFromRelatedTiles(e){const t=e.displayingResolution;this._featureTiles.forEach((s=>{if(null!=s.displayingFeatures&&e!==s&&M(e.descriptor.lij,s.descriptor.lij)){null==e.displayingFeatures&&(e.displayingFeatures=[]),e.descriptor.extent&&s.descriptor.extent&&(null==e.extentIncludingBorrowedFeatures&&(e.extentIncludingBorrowedFeatures=_(e.descriptor.extent)),m(e.extentIncludingBorrowedFeatures,s.descriptor.extent,e.extentIncludingBorrowedFeatures));for(const i of s.displayingFeatures){e.displayingFeatures.push(i);const s=this._displayingFeatureReferences.get(F(i,this._objectIdField));s.ref(s.feature,t),this._numDisplayingFeatureReferences++}}})),e.featureLimit=null!=e.displayingFeatures?e.displayingFeatures.length:0}_removeTile(e){this._clearTile(e),this._featureTiles.delete(e.id)}_resetFetchTile(e){e.filtered=!e.intersects(this.filterExtent),e.filtered?e.needsFetching&&(e.fetchStatus=b.DONE):e.fetchStatus=b.FETCH_NEEDED}_cancelFetchTile(e){const t=e.requestController;null!=t&&(e.requestController=null,e.resetFetching(),t.abort())}async _fetchTileCount(e,t){return e.numFeatures=await this._fetchCount(e,t),this._updateRatio(this._getListOfTiles()),e.fetchStatus===b.REFETCHING?b.REFETCH_NEEDED:b.FETCH_NEEDED}async _fetchTile(e,t){e.fetchFailed=!1;const s=this._maximumFeaturesForTile(e);if(s<=0)return e.hasPreciseFeatureCount&&0===e.numFeatures||(e.fetchFailed=!0),I(e);const i=this._getMaxRecordCount(e),r=Math.ceil(s/i);if(e.fetchingResolution=e.descriptor.resolution,j(e)||!this.context.capabilities.supportsMaxRecordCountFactor||e.numFeatures<=s&&r>x.MAX_MAX_RECORD_COUNT_FACTOR)return this._fetchPagedTile(e,t);const n=this._createQuery(e);if(n.maxRecordCountFactor=r,e.isRefetching&&e.features&&e.features.length>0){const t=Math.ceil(e.features.length/(1-e.emptyFeatureRatio)/i);n.maxRecordCountFactor=Math.max(t+1,n.maxRecordCountFactor)}const{features:o,exceededTransferLimit:u,fields:l,missingAttributes:h}=await this._queryFeatures(n,t),d=u?n.maxRecordCountFactor>=x.MAX_MAX_RECORD_COUNT_FACTOR?b.FULL:b.DONE:b.FULL;return await this._frameTask.schedule((()=>{e.featuresMissing=e.hasPreciseFeatureCount&&o.length<e.numFeatures||!!u;const t=this._removeEmptyFeatures(o);e.setFeatures(o,t,P(l),Q(void 0,h)),this._updateTileZQuantization(e)}),t),a(t),this._invalidateCounts(),d}async _fetchCount(e,t){return this.context.query.queryFeatureCount(this._createFeatureCountQuery(e),{signal:t})}async _fetchPagedTile(e,t){let s,i=0,r=0,n=0,o=this._maximumFeaturesForTile(e)-n;const u=this._getMaxRecordCount(e);let l,h=null;for(;;){const d=this._createQuery(e),c=this._setPagingParameters(d,i,o,u),{features:p,exceededTransferLimit:f,fields:_,missingAttributes:m}=await this._queryFeatures(d,t);if(await this._frameTask.schedule((()=>{c&&(i+=d.num),n+=p.length,r+=this._removeEmptyFeatures(p),e.featuresMissing=c&&e.hasPreciseFeatureCount&&i<e.numFeatures||!!f,s=s?s.concat(p):p,h=N(h,_),l=Q(l,m),e.setFeatures(s,r,h,l),this._updateTileZQuantization(e)}),t),a(t),this._invalidateCounts(),this._setDirty(),o=this._maximumFeaturesForTile(e)-n,!c||!f||o<=0)return f?b.DONE:b.FULL}}_createFeatureCountQuery(e){const t=this._createQuery(e);return this.context.capabilities.supportsCacheHint&&(t.resultType=void 0,t.cacheHint=!0),t}_createQuery(e){const t=this.context.createQuery();return j(e)||(t.geometry=g(e.descriptor.extent,this.context.tilingScheme.spatialReference)),this._setResolutionParams(t,e),this._useTileQuery(e)?t.resultType="tile":this.context.capabilities.supportsCacheHint&&(t.cacheHint=!0),t}_setPagingParameters(e,t,s,i){return!!this.context.capabilities.supportsPagination&&(e.start=t,s>0&&this.context.capabilities.supportsMaxRecordCountFactor?(e.maxRecordCountFactor=Math.ceil(s/i),e.num=Math.min(e.maxRecordCountFactor*i,s)):e.num=Math.min(i),!0)}_getEffectiveTileResolution(e){if(j(e))return null;const t=this.context.viewingMode===E.Global?this.context.tilingScheme.resolutionAtLevel(3):1/0;return Math.min(e.fetchingResolution,t)/this.lodFactor/this._tileZQuantization}get _supportsResolution(){return this.context.capabilities.supportsMultipleResolutions&&"point"!==this.context.geometryType}_setResolutionParams(e,t){if(!this._supportsResolution)return;const s=this._getEffectiveTileResolution(t);null!=s&&(this.context.capabilities.supportsQuantization?e.quantizationParameters=new T({mode:"view",originPosition:"upper-left",tolerance:s,extent:this.context.fullExtent}):"polyline"===this.context.geometryType&&(e.maxAllowableOffset=s))}_removeEmptyFeatures(e){const t=e.length;for(let s=0;s<e.length;){const t=e[s];y(t.geometry)?++s:(e[s]=e[e.length-1],--e.length)}return t-e.length}_needsNumFeatures(e){return this.useTileCount&&e.needsFeatureCount&&!j(e)}_getMaxRecordCount(e){const{tileMaxRecordCount:t,maxRecordCount:s}=this.context;return this._useTileQuery(e)&&null!=t&&t>0&&this.context.capabilities.supportsResultType?t:null!=s&&s>0?s:z}_useTileQuery(e){return(!j(e)||!this.context.capabilities.supportsCacheHint)&&this.context.capabilities.supportsResultType}_handleRequest(e,t,s,i){e.fetchStatus=e.needsRefetching?b.REFETCHING:b.FETCHING,e.requestController=s;let a=!1;t.then((t=>{e.requestController=null,e.fetchStatus=t})).catch((t=>{e.requestController===s&&(e.requestController=null,e.fetchStatus=b.DONE),r(t)?a=!0:i(t)})).then((()=>{a||this._setDirty(),this._scheduleUpdated()}))}_scheduleUpdated(){this.hasHandles("scheduleUpdated")||this.addHandles(l((()=>{this.removeHandles("scheduleUpdated"),this._updated()})),"scheduleUpdated")}_showTile(e){if(null!=e.displayingFeatures&&!e.needsDisplayUpdate)return!1;const{features:t}=e;if(0===e.featureLimit||!t){const t=null!=e.displayingFeatures&&e.displayingFeatures.length>0;return this._hideTileFeatures(e),e.displayingFeatures=[],t}const s=e.fetchingResolution,{adds:i,updates:r}=this._changes,a=Math.min(e.featureLimit,t.length);e.featureLimit=a;for(let n=0;n<a;++n){const e=t[n],a=F(e,this._objectIdField),o=this._displayingFeatureReferences.get(a);if(o){const{oldVersion:t,newVersion:i}=o.ref(e,s);t!==i&&(t&&r.removes.push(t),i&&r.adds.push(i))}else this._displayingFeatureReferences.set(a,new this.FeatureReferenceClass(e,s)),i.push(e);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(null==e.displayingFeatures)return;const{updates:t,removes:s}=this._changes;for(const i of e.displayingFeatures){const r=F(i,this._objectIdField),a=this._displayingFeatureReferences.get(r);if(!a)continue;const{oldVersion:n,newVersion:o}=a.unref(e.displayingResolution);this._numDisplayingFeatureReferences--,n!==o&&(null==o?(this._displayingFeatureReferences.delete(r),n&&s.push(n)):(t.adds.push(o),n&&t.removes.push(n)))}this._applyChanges(),e.displayingFeatures=null}_notifyDataUpdating(){this._get("dataUpdating")||this._set("dataUpdating",!0)}_applyChanges(){const 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);const t=this._changes.adds,s=this._changes.removes,i=Math.min(t.length,s.length);let r=0;for(;r<i;){const e=Math.min(r+H,i);this._notifyDataUpdating(),this.features.addMany(t.slice(r,e)),this.features.removeMany(s.slice(r,e)),r=e}t.length>i&&(this._notifyDataUpdating(),this.features.addMany(0===r?t:t.slice(r))),s.length>i&&(this._notifyDataUpdating(),this.features.removeMany(0===r?s:s.slice(r))),t.length=0,s.length=0}_clearTile(e){this._hideTile(e),e.features&&null!=this.context.memoryCache&&this.context.memoryCache.put(e.id,e.cache),e.setFeatures(null,0,null,void 0),this._invalidateCounts()}_invalidateCounts(){this.notifyChange("totalVertices"),this.notifyChange("totalFeatures"),this.notifyChange("memoryForUnusedFeatures")}_getListOfTiles(){return Array.from(this._featureTiles.values())}get storedFeatures(){return this._getListOfTiles().reduce(((e,t)=>e+(t.features?t.features.length:0)),0)}get missingTiles(){return Array.from(this._featureTiles.values()).reduce(((e,t)=>e+(t.needsFetching||t.isFetching?1:0)),0)}_maximumFeaturesForTile(e){const t=e.hasPreciseFeatureCount?e.numFeatures:1/0,s=e.hasPreciseFeatureCount?t:this.maximumNumberOfFeatures,i=this._fullRatio<1?this._farRatio:1;return Math.min(Math.ceil(s*i/(1-e.emptyFeatureRatio)),t)}get test(){}};function j(e){return"dummy-tile-full-extent"===e.id}function A(e){let t=0;for(const s of e)s.features&&s.features.length>0&&s.alive&&(t=Math.max(t,s.descriptor.lij[0]));return t}function I(e){return e.setFeatures([],0,null,void 0),e.featuresMissing=!1,b.DONE}function P(e){return null==e?new Set:new Set(e.map((e=>e.name)))}function N(e,t){if(null==e||null==t)return P(t);const s=new Set;for(const{name:i}of t)e.has(i)&&s.add(i);return s}function Q(e,t){if(!t?.length)return e;e??=new Map;const s=()=>new Set;for(const{objectId:r,attribute:a}of t)i(e,r,s).add(a);return e}e([d({constructOnly:!0})],O.prototype,"features",void 0),e([d()],O.prototype,"tileDescriptors",void 0),e([d({value:1/0})],O.prototype,"maximumNumberOfFeatures",null),e([d({value:1})],O.prototype,"memoryFactor",null),e([d({value:1})],O.prototype,"lodFactor",null),e([d()],O.prototype,"useTileCount",null),e([d({readOnly:!0})],O.prototype,"updating",null),e([d({readOnly:!0})],O.prototype,"dataUpdating",void 0),e([d({readOnly:!0})],O.prototype,"running",void 0),e([d({readOnly:!0})],O.prototype,"updatingTotal",void 0),e([d({readOnly:!0})],O.prototype,"updatingRemaining",void 0),e([d({readOnly:!0})],O.prototype,"expectedFeatureDiff",void 0),e([d({readOnly:!0})],O.prototype,"memoryForUnusedFeatures",null),e([d({readOnly:!0})],O.prototype,"maximumNumberOfFeaturesExceeded",void 0),e([d({readOnly:!0})],O.prototype,"totalVertices",null),e([d({readOnly:!0})],O.prototype,"totalFeatures",null),e([d({readOnly:!0})],O.prototype,"hasAllFeatures",null),e([d({readOnly:!0})],O.prototype,"hasFullGeometries",null),e([d()],O.prototype,"filterExtent",null),e([d({constructOnly:!0})],O.prototype,"context",void 0),e([d()],O.prototype,"_dirty",void 0),e([d()],O.prototype,"_suspended",void 0),e([d()],O.prototype,"_pendingEdits",void 0),e([d()],O.prototype,"_applyEditsTilesUpdated",void 0),e([d()],O.prototype,"_paused",null),e([d()],O.prototype,"_isFetching",void 0),O=e([c("esri.views.3d.layers.support.FeatureTileFetcher3D")],O);const z=2e3,S=p(),L=p(),q=6e5,H=200;export{O as FeatureTileFetcher3D};
5
+ import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import"../../../../core/has.js";import s from"../../../../core/Logger.js";import{getOrCreateMapValue as i}from"../../../../core/MapUtils.js";import{isAbortError as r,throwIfAborted as a}from"../../../../core/promiseUtils.js";import n from"../../../../core/ReactiveMap.js";import{on as o,watch as u}from"../../../../core/reactiveUtils.js";import{schedule as l}from"../../../../core/scheduling.js";import{signal as h}from"../../../../core/signal.js";import{sqlAnd as d}from"../../../../core/sql.js";import{property as c}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/RandomLCG.js";import{subclass as p}from"../../../../core/accessorSupport/decorators/subclass.js";import{create as f,equals as _,clone as m,expand as g,toExtent as F}from"../../../../geometry/support/aaBoundingRect.js";import{getObjectId as y,hasVertices as T}from"../../../../layers/graphics/dehydratedFeatures.js";import x from"../../../../rest/support/QuantizationParameters.js";import E from"../../../../rest/support/Query.js";import{ViewingMode as R}from"../../../ViewingMode.js";import{MultiFeatureReference as v,SingleFeatureReference as C}from"./featureReference.js";import{failedFeatureCount as b,FetchStatus as D,FeatureTile as w}from"./FeatureTile.js";import{tilesAreRelated as M}from"../../terrain/tileUtils.js";import{ImmediateTask as U,TaskPriority as O}from"../../../support/Scheduler.js";let j=class extends t{set maximumNumberOfFeatures(e){e=e||1/0;const 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&&null!=this.context.query.queryFeatureCount}set useTileCount(e){this._useTileCount=e,this.notifyChange("useTileCount")}get updating(){return this._dirty||!!this._pendingEdits||this._isFetching||(this.tileDescriptors?.updating??!1)}get memoryForUnusedFeatures(){let e=0;return this._featureTiles.forEach((t=>e+=t.estimatedUnusedSize)),e}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 hasAllFeatures(){if(this._paused||this.dataUpdating)return!1;for(const e of this._featureTiles.values())if(!this.hasFullGeometries&&0!==e.emptyFeatureRatio||!e.hasAllFeatures)return!1;return!0}get hasFullGeometries(){if(!this._supportsResolution)return!0;return this.tileDescriptors.some(A)||!this.context.capabilities.supportsQuantization&&"polyline"!==this.context.geometryType}set filterExtent(e){if(null!=e&&this.context.tilingScheme&&!e.spatialReference.equals(this.context.tilingScheme.spatialReference))return void s.getLogger(this).error("#filterExtent=","extent needs to be in the same spatial reference as the tiling scheme");const t=this._get("filterExtent");if(t===e||null!=t&&e&&t.equals(e))return;const i=null!=e?e.clone():null;this._set("filterExtent",i),this._reclip(i,t)}_updateTileZQuantization(e){if(this.context.viewingMode===R.Global){const 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.running=!1,this.updatingTotal=0,this.updatingRemaining=0,this.expectedFeatureDiff=0,this.maximumNumberOfFeaturesExceeded=!1,this._fullRatio=1,this._farRatio=1,this._zQuantizationFactor=h(1),this._changes={updates:{adds:new Array,removes:new Array},adds:new Array,removes:new Array},this._frameTask=U,this._featureTiles=new n,this._displayingFeatureReferences=new Map,this._numDisplayingFeatureReferences=0,this._dirty=!1,this._suspended=!0,this._pendingEdits=null,this._applyEditsTilesUpdated=!1,this._isFetching=!1}initialize(){this.addHandles([o((()=>this.tileDescriptors),"change",(()=>this._setDirty()),{sync:!0,onListenerAdd:()=>this._setDirty()}),u((()=>this._tileZQuantization),(()=>this.refetch()))]),this._objectIdField=this.context.objectIdField,this.FeatureReferenceClass=this.context.capabilities.supportsMultipleResolutions?v:C;const e=this.context.scheduler;null!=e&&(this._frameTask=e.registerTask(O.FEATURE_TILE_FETCHER,this)),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)})),null!=this.context.memoryCache&&this.context.memoryCache.clear(),this._setDirty()}refetch(){this._featureTiles.forEach((e=>{this._cancelFetchTile(e),this._resetFetchTile(e)})),null!=this.context.memoryCache&&this.context.memoryCache.clear(),this._setDirty()}suspend(){this._suspended||(this._suspended=!0,this._pause(),this._setDirty())}resume(){this._suspended&&(this._suspended=!1,this._unpause())}getMissingAttributesForFeature(e){for(const t of this._featureTiles.values()){const s=t.missingAttributes?.get(e);if(null!=s)return s}}_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=>{null!=t.displayingFeatures&&0!==t.displayingFeatures.length&&(null==e?e=new Set(t.availableFields):e.forEach((s=>{t.availableFields?.has(s)||e.delete(s)})))})),null!=e?e:new Set}applyEdits(e){this._pendingEdits||(this._pendingEdits={edits:Promise.resolve(),count:0,controller:new AbortController},this._pause());const t=this._pendingEdits;t.count++;const s=t.edits.then((()=>e.result.catch((e=>{if(r(e))throw e;return null})).then((e=>e?(this._applyEditsDeleteFeatures(e.deletedFeatures),this._applyEditsAddUpdateFeatures(e.addedFeatures,e.updatedFeatures,t.controller.signal).then((()=>e))):e)).then((e=>(0==--t.count&&(this._pendingEdits===t&&(this._pendingEdits=null),null!=this.context.memoryCache&&this.context.memoryCache.clear(),this._applyEditsTilesUpdated=!1,this._unpause()),e)))));return t.edits=s,this._updated(),s}_applyEditsDeleteFeatures(e){if(0===e.length)return;const t=this.context.globalIdField,i=t&&this.availableFields.has(t),r=new Set,a=this._objectIdField;e.forEach((({objectId:e,globalId:n})=>{(!e||e<0)&&t&&n&&(i||s.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(n,a,t)),null!=e&&e>=0&&r.add(e)})),this._featureTiles.forEach((e=>{if(!e.features)return;const t=e.features.filter((e=>!r.has(y(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,s){if(null==e)return null;const i=this.features.find((t=>t.attributes?.[s]===e));return i?y(i,t):null}async _applyEditsAddUpdateFeatures(e,t,i){const{objectIdField:r,globalIdField:a}=this.context,n=a&&this.availableFields.has(a),o=new Set,u=new Set;for(const s of e){const e=s.objectId;null!=e&&o.add(e)}for(const{objectId:h,globalId:d}of t){let e=h;(null==e||e<0)&&a&&(n||s.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`),e=this._objectIdFromGlobalId(d,r,a)),null!=e&&e>=0&&(o.add(e),u.add(e))}if(0===o.size)return;const l=[];this._featureTiles.forEach((e=>{const t=this._applyEditsAddUpdateTile(e,o,u,i);t&&l.push(t)})),this._updated(),await Promise.allSettled(l)}async _applyEditsAddUpdateTile(e,t,s,i){if(!e.features)return;e.fetchingResolution=e.descriptor.resolution;const r=this._createQuery(e);r.resultType=void 0,r.cacheHint=!1,r.objectIds=Array.from(t);const a=await this._queryFeatures(r,i);let n=null;if(s.size>0){const t=e.features.filter((e=>!s.has(y(e,this._objectIdField))));t.length!==e.features.length&&(n=t)}if(a.features.length>0){n||(n=e.features.slice());for(const e of a.features)n.push(e)}n&&(e.hasPreciseFeatureCount&&(e.numFeatures=Math.max(e.numFeatures,n.length)),this._applyEditsTileUpdated(),e.setFeatures(n,0,Q(e.availableFields,a.fields),z(e.missingAttributes,a.missingAttributes)),this._updateTileZQuantization(e),this._invalidateCounts())}_applyEditsTileUpdated(){this._applyEditsTilesUpdated||(this._applyEditsTilesUpdated=!0,this._updated())}_queryFeatures(e,t){return this.context.query.queryFeaturesDehydrated(e,{signal:t,timeout:H})}_setDirty(){this._dirty=!0,this._updated()}runTask(e){const t=this._frameTask.processQueue(e);if(!this._dirty||!this.initialized)return t;this._dirty=!1;const s=this._getListOfTiles();if(this._markTilesNotAlive(s),!e.run((()=>this._addTiles(s,e)))||!e.run((()=>this._filterExtentTiles(s,e)))||!e.run((()=>this._removeTiles(s,e)))||e.done)return void this._setDirty();const i=this._sortTiles(s);e.run((()=>this._showTiles(i,e)))&&e.run((()=>this._fetchTiles(i,e)))&&e.run((()=>this._updateMemoryEstimates(i,e)))||this._setDirty(),this._updated(),this.updating||this._updateMaximumNumberOfFeaturesExceeded()}_markTilesNotAlive(e){for(const t of e)t.alive=!1}_addTiles(e,t){return!(this._suspended||!this.tileDescriptors)&&(this.tileDescriptors.forEach((s=>{const i=this._featureTiles.get(s.id);i?i.alive=!0:t.done||(e.push(this._addTile(s)),t.madeProgress())})),t.hasProgressed)}_filterExtentTiles(e,t){for(const s of e){if(t.done)break;s.alive&&(s.filtered=!s.intersects(this.filterExtent),s.filtered&&(this._clearTile(s),t.madeProgress()))}return t.hasProgressed}_removeTiles(e,t){for(let s=e.length-1;s>=0&&!t.done;s--){const i=e[s];i.alive||(this._removeTile(i),s!==e.length-1&&(e[s]=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){const s=this._updateRatio(e),i=e=>{const t=this._fullRatio<1?s(e)*this._farRatio:1;return e.reduceFeatures(t,this.memoryFactor,this._objectIdField)&&this._setDirty(),(e.features?.length??0)>0&&e.fetchingResolution!==e.descriptor.resolution&&e.fetchStatus===D.DONE&&(e.fetchStatus=D.REFETCH_NEEDED,this._setDirty()),this._showTile(e)};for(const r of e)if(!t.run((()=>i(r)))){this._setDirty();break}return t.hasProgressed}_fetchTiles(e,t){if(this._paused)return!1;let i=!1;for(const s of e){if(!s.needsFetching)continue;const e=null!=this.context.memoryCache?this.context.memoryCache.pop(s.id):null;if(null==e){if(this._needsNumFeatures(s)){const e=new AbortController,r=this._fetchTileCount(s,e.signal);this._handleRequest(s,r,e,(()=>s.numFeatures=b)),i=!0,t.madeProgress()}if(t.done)return!0}else s.cache=e,s.numFeatures&&this._notifyDataUpdating(),this._setDirty(),this._scheduleUpdated(),t.madeProgress()}if(i)return t.hasProgressed;for(const r of e)if(r.needsFetching){const e=new AbortController,i=this._fetchTile(r,e.signal);if(this._handleRequest(r,i,e,(e=>{r.setFeatures([],0,null,void 0),this._invalidateCounts(),r.featuresMissing=!1,r.fetchFailed=!0,this.context.logFetchError(s.getLogger(this),e)})),t.madeProgress())return!0}return t.hasProgressed}_updateMemoryEstimates(e,t){return e.some((e=>!t.run((()=>e.updateMemoryEstimates()))&&(this._setDirty(),!0))),t.hasProgressed}_reclip(e,t){if(!this.initialized)return;const s=new Array;this._featureTiles.forEach((i=>{null!=i.displayingFeatures&&0!==i.displayingFeatures.length&&(i.intersectionIncludingBorrowed(t,L),i.intersectionIncludingBorrowed(e,q),_(L,q)||s.push(i))})),this._refreshDisplayingFeatures(s),this._updated()}_refreshDisplayingFeatures(e){const t=new Set,s=this._changes.updates;for(const i of e)if(null!=i.displayingFeatures)for(const e of i.displayingFeatures){const i=y(e,this._objectIdField);if(t.has(i))continue;t.add(i);const r=this._displayingFeatureReferences.get(i).feature;s.removes.push(r),s.adds.push(r)}this._applyChanges()}_updated(){let e=0;if(this._paused||this._featureTiles.forEach((t=>t.isFetching?++e:0)),this._isFetching=e>0,this._set("running",this._dirty),e>0||this._applyEditsTilesUpdated?this._notifyDataUpdating():this._dirty||this._set("dataUpdating",!1),this.updating){let t=0,s=0,i=0,r=0,a=0;const n=this._displayingFeatureReferences.size/this._numDisplayingFeatureReferences;this._featureTiles.forEach((e=>{if(++s,e.isFetching&&e.hasPreciseFeatureCount){const t=this._maximumFeaturesForTile(e)*(1-e.emptyFeatureRatio),s=null!=e.displayingFeatures?e.displayingFeatures.length*n:0;a+=t-s}e.needsFetching?++r:e.numFeatures>0&&(++i,t+=e.numFeatures)})),r+=e;let o=0,u=0;t?(u=t,o=Math.min(r*t/i,t)):(u=s,o=r),a=Math.min(this.maximumNumberOfFeatures-this.features.length,a),this._set("updatingTotal",u),this._set("updatingRemaining",o),this._set("expectedFeatureDiff",a)}else this._set("updatingTotal",0),this._set("updatingRemaining",0),this._set("expectedFeatureDiff",0);this.debugger&&this.debugger.update()}_updateMaximumNumberOfFeaturesExceeded(){for(const{perTileMaximumNumberOfFeaturesExceeded:e}of this._featureTiles.values())if(e)return void this._set("maximumNumberOfFeaturesExceeded",!0);this._set("maximumNumberOfFeaturesExceeded",!1)}_updateRatio(e){const t=I(e),s=e=>1/(1<<Math.max(0,t-e.descriptor.lij[0]));let i=0,r=0;for(const a of e){const e=a.numFeatures;i+=e,r+=e*s(a)}return this._fullRatio=Math.min(1,this.maximumNumberOfFeatures/i),this._farRatio=this.maximumNumberOfFeatures/r,this._scheduleUpdated(),s}_maximumFeaturesUpdated(e,t){e!==t&&(t>e&&this._featureTiles.forEach((e=>{if(!e.featuresMissing)return;const t=this._maximumFeaturesForTile(e);e.features&&(e.features.length>=t||e.fetchStatus===D.FULL)||(this._cancelFetchTile(e),this._resetFetchTile(e))})),this._setDirty())}_addTile(e){const t=new w(e);return this._featureTiles.set(t.id,t),this._resetFetchTile(t),this._referenceDisplayingFeaturesFromRelatedTiles(t),t}_referenceDisplayingFeaturesFromRelatedTiles(e){const t=e.displayingResolution;this._featureTiles.forEach((s=>{if(null!=s.displayingFeatures&&e!==s&&M(e.descriptor.lij,s.descriptor.lij)){null==e.displayingFeatures&&(e.displayingFeatures=[]),e.descriptor.extent&&s.descriptor.extent&&(null==e.extentIncludingBorrowedFeatures&&(e.extentIncludingBorrowedFeatures=m(e.descriptor.extent)),g(e.extentIncludingBorrowedFeatures,s.descriptor.extent,e.extentIncludingBorrowedFeatures));for(const i of s.displayingFeatures){e.displayingFeatures.push(i);const s=this._displayingFeatureReferences.get(y(i,this._objectIdField));s.ref(s.feature,t),this._numDisplayingFeatureReferences++}}})),e.featureLimit=null!=e.displayingFeatures?e.displayingFeatures.length:0}_removeTile(e){this._clearTile(e),this._featureTiles.delete(e.id)}_resetFetchTile(e){e.filtered=!e.intersects(this.filterExtent),e.filtered?e.needsFetching&&(e.fetchStatus=D.DONE):e.fetchStatus=D.FETCH_NEEDED}_cancelFetchTile(e){const t=e.requestController;null!=t&&(e.requestController=null,e.resetFetching(),t.abort())}async _fetchTileCount(e,t){return e.numFeatures=await this._fetchCount(e,t),this._updateRatio(this._getListOfTiles()),e.fetchStatus===D.REFETCHING?D.REFETCH_NEEDED:D.FETCH_NEEDED}async _fetchTile(e,t){e.fetchFailed=!1;const s=this._maximumFeaturesForTile(e);if(s<=0)return e.hasPreciseFeatureCount&&0===e.numFeatures||(e.fetchFailed=!0),P(e);const i=this._getMaxRecordCount(e),r=Math.ceil(s/i);if(e.fetchingResolution=e.descriptor.resolution,A(e)||!this.context.capabilities.supportsMaxRecordCountFactor||e.numFeatures<=s&&r>E.MAX_MAX_RECORD_COUNT_FACTOR)return this._fetchPagedTile(e,t);const n=this._createQuery(e);if(n.maxRecordCountFactor=r,e.isRefetching&&e.features&&e.features.length>0){const t=Math.ceil(e.features.length/(1-e.emptyFeatureRatio)/i);n.maxRecordCountFactor=Math.max(t+1,n.maxRecordCountFactor)}const{features:o,exceededTransferLimit:u,fields:l,missingAttributes:h}=await this._queryFeatures(n,t),d=u?n.maxRecordCountFactor>=E.MAX_MAX_RECORD_COUNT_FACTOR?D.FULL:D.DONE:D.FULL;return await this._frameTask.schedule((()=>{e.featuresMissing=e.hasPreciseFeatureCount&&o.length<e.numFeatures||!!u;const t=this._removeEmptyFeatures(o);e.setFeatures(o,t,N(l),z(void 0,h)),this._updateTileZQuantization(e)}),t),a(t),this._invalidateCounts(),d}async _fetchCount(e,t){return this.context.query.queryFeatureCount(this._createFeatureCountQuery(e),{signal:t})}async _fetchPagedTile(e,t){let s,i=0,r=0,n=0,o=this._maximumFeaturesForTile(e)-n;const u=this._getMaxRecordCount(e);let l,h=null;for(;;){const d=this._createQuery(e),c=this._setPagingParameters(d,i,o,u),{features:p,exceededTransferLimit:f,fields:_,missingAttributes:m}=await this._queryFeatures(d,t);if(await this._frameTask.schedule((()=>{c&&(i+=d.num),n+=p.length,r+=this._removeEmptyFeatures(p),e.featuresMissing=c&&e.hasPreciseFeatureCount&&i<e.numFeatures||!!f,s=s?s.concat(p):p,h=Q(h,_),l=z(l,m),e.setFeatures(s,r,h,l),this._updateTileZQuantization(e)}),t),a(t),this._invalidateCounts(),this._setDirty(),o=this._maximumFeaturesForTile(e)-n,!c||!f||o<=0)return f?D.DONE:D.FULL}}_createFeatureCountQuery(e){const t=this._createQuery(e);return this.context.capabilities.supportsCacheHint&&(t.resultType=void 0,t.cacheHint=!0),t}_createQuery(e){const t=this.context.createQuery();A(e)||(t.geometry=F(e.descriptor.extent,this.context.tilingScheme.spatialReference)),this._setResolutionParams(t,e);const s=this._useTileQuery(e);return s?t.resultType="tile":this.context.capabilities.supportsCacheHint&&(t.cacheHint=!0),s&&this.context.effectiveDisplayFilter&&(t.where=d(t.where,this.context.effectiveDisplayFilter.where)),t}_setPagingParameters(e,t,s,i){return!!this.context.capabilities.supportsPagination&&(e.start=t,s>0&&this.context.capabilities.supportsMaxRecordCountFactor?(e.maxRecordCountFactor=Math.ceil(s/i),e.num=Math.min(e.maxRecordCountFactor*i,s)):e.num=Math.min(i),!0)}_getEffectiveTileResolution(e){if(A(e))return null;const t=this.context.viewingMode===R.Global?this.context.tilingScheme.resolutionAtLevel(3):1/0;return Math.min(e.fetchingResolution,t)/this.lodFactor/this._tileZQuantization}get _supportsResolution(){return this.context.capabilities.supportsMultipleResolutions&&"point"!==this.context.geometryType}_setResolutionParams(e,t){if(!this._supportsResolution)return;const s=this._getEffectiveTileResolution(t);null!=s&&(this.context.capabilities.supportsQuantization?e.quantizationParameters=new x({mode:"view",originPosition:"upper-left",tolerance:s,extent:this.context.fullExtent}):"polyline"===this.context.geometryType&&(e.maxAllowableOffset=s))}_removeEmptyFeatures(e){const t=e.length;for(let s=0;s<e.length;){const t=e[s];T(t.geometry)?++s:(e[s]=e[e.length-1],--e.length)}return t-e.length}_needsNumFeatures(e){return this.useTileCount&&e.needsFeatureCount&&!A(e)}_getMaxRecordCount(e){const{tileMaxRecordCount:t,maxRecordCount:s}=this.context;return this._useTileQuery(e)&&null!=t&&t>0&&this.context.capabilities.supportsResultType?t:null!=s&&s>0?s:S}_useTileQuery(e){return(!A(e)||!this.context.capabilities.supportsCacheHint)&&this.context.capabilities.supportsResultType}_handleRequest(e,t,s,i){e.fetchStatus=e.needsRefetching?D.REFETCHING:D.FETCHING,e.requestController=s;let a=!1;t.then((t=>{e.requestController=null,e.fetchStatus=t})).catch((t=>{e.requestController===s&&(e.requestController=null,e.fetchStatus=D.DONE),r(t)?a=!0:i(t)})).then((()=>{a||this._setDirty(),this._scheduleUpdated()}))}_scheduleUpdated(){this.hasHandles("scheduleUpdated")||this.addHandles(l((()=>{this.removeHandles("scheduleUpdated"),this._updated()})),"scheduleUpdated")}_showTile(e){if(null!=e.displayingFeatures&&!e.needsDisplayUpdate)return!1;const{features:t}=e;if(0===e.featureLimit||!t){const t=null!=e.displayingFeatures&&e.displayingFeatures.length>0;return this._hideTileFeatures(e),e.displayingFeatures=[],t}const s=e.fetchingResolution,{adds:i,updates:r}=this._changes,a=Math.min(e.featureLimit,t.length);e.featureLimit=a;for(let n=0;n<a;++n){const e=t[n],a=y(e,this._objectIdField),o=this._displayingFeatureReferences.get(a);if(o){const{oldVersion:t,newVersion:i}=o.ref(e,s);t!==i&&(t&&r.removes.push(t),i&&r.adds.push(i))}else this._displayingFeatureReferences.set(a,new this.FeatureReferenceClass(e,s)),i.push(e);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(null==e.displayingFeatures)return;const{updates:t,removes:s}=this._changes;for(const i of e.displayingFeatures){const r=y(i,this._objectIdField),a=this._displayingFeatureReferences.get(r);if(!a)continue;const{oldVersion:n,newVersion:o}=a.unref(e.displayingResolution);this._numDisplayingFeatureReferences--,n!==o&&(null==o?(this._displayingFeatureReferences.delete(r),n&&s.push(n)):(t.adds.push(o),n&&t.removes.push(n)))}this._applyChanges(),e.displayingFeatures=null}_notifyDataUpdating(){this._get("dataUpdating")||this._set("dataUpdating",!0)}_applyChanges(){const 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);const t=this._changes.adds,s=this._changes.removes,i=Math.min(t.length,s.length);let r=0;for(;r<i;){const e=Math.min(r+k,i);this._notifyDataUpdating(),this.features.addMany(t.slice(r,e)),this.features.removeMany(s.slice(r,e)),r=e}t.length>i&&(this._notifyDataUpdating(),this.features.addMany(0===r?t:t.slice(r))),s.length>i&&(this._notifyDataUpdating(),this.features.removeMany(0===r?s:s.slice(r))),t.length=0,s.length=0}_clearTile(e){this._hideTile(e),e.features&&null!=this.context.memoryCache&&this.context.memoryCache.put(e.id,e.cache),e.setFeatures(null,0,null,void 0),this._invalidateCounts()}_invalidateCounts(){this.notifyChange("totalVertices"),this.notifyChange("totalFeatures"),this.notifyChange("memoryForUnusedFeatures")}_getListOfTiles(){return Array.from(this._featureTiles.values())}get storedFeatures(){return this._getListOfTiles().reduce(((e,t)=>e+(t.features?t.features.length:0)),0)}get missingTiles(){return Array.from(this._featureTiles.values()).reduce(((e,t)=>e+(t.needsFetching||t.isFetching?1:0)),0)}_maximumFeaturesForTile(e){const t=e.hasPreciseFeatureCount?e.numFeatures:1/0,s=e.hasPreciseFeatureCount?t:this.maximumNumberOfFeatures,i=this._fullRatio<1?this._farRatio:1;return Math.min(Math.ceil(s*i/(1-e.emptyFeatureRatio)),t)}get test(){}};function A(e){return"dummy-tile-full-extent"===e.id}function I(e){let t=0;for(const s of e)s.features&&s.features.length>0&&s.alive&&(t=Math.max(t,s.descriptor.lij[0]));return t}function P(e){return e.setFeatures([],0,null,void 0),e.featuresMissing=!1,D.DONE}function N(e){return null==e?new Set:new Set(e.map((e=>e.name)))}function Q(e,t){if(null==e||null==t)return N(t);const s=new Set;for(const{name:i}of t)e.has(i)&&s.add(i);return s}function z(e,t){if(!t?.length)return e;e??=new Map;const s=()=>new Set;for(const{objectId:r,attribute:a}of t)i(e,r,s).add(a);return e}e([c({constructOnly:!0})],j.prototype,"features",void 0),e([c()],j.prototype,"tileDescriptors",void 0),e([c({value:1/0})],j.prototype,"maximumNumberOfFeatures",null),e([c({value:1})],j.prototype,"memoryFactor",null),e([c({value:1})],j.prototype,"lodFactor",null),e([c()],j.prototype,"useTileCount",null),e([c({readOnly:!0})],j.prototype,"updating",null),e([c({readOnly:!0})],j.prototype,"dataUpdating",void 0),e([c({readOnly:!0})],j.prototype,"running",void 0),e([c({readOnly:!0})],j.prototype,"updatingTotal",void 0),e([c({readOnly:!0})],j.prototype,"updatingRemaining",void 0),e([c({readOnly:!0})],j.prototype,"expectedFeatureDiff",void 0),e([c({readOnly:!0})],j.prototype,"memoryForUnusedFeatures",null),e([c({readOnly:!0})],j.prototype,"maximumNumberOfFeaturesExceeded",void 0),e([c({readOnly:!0})],j.prototype,"totalVertices",null),e([c({readOnly:!0})],j.prototype,"totalFeatures",null),e([c({readOnly:!0})],j.prototype,"hasAllFeatures",null),e([c({readOnly:!0})],j.prototype,"hasFullGeometries",null),e([c()],j.prototype,"filterExtent",null),e([c({constructOnly:!0})],j.prototype,"context",void 0),e([c()],j.prototype,"_dirty",void 0),e([c()],j.prototype,"_suspended",void 0),e([c()],j.prototype,"_pendingEdits",void 0),e([c()],j.prototype,"_applyEditsTilesUpdated",void 0),e([c()],j.prototype,"_paused",null),e([c()],j.prototype,"_isFetching",void 0),j=e([p("esri.views.3d.layers.support.FeatureTileFetcher3D")],j);const S=2e3,L=f(),q=f(),H=6e5,k=200;export{j as FeatureTileFetcher3D};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{destroyMaybe as e}from"../../../../core/maybe.js";import{createFeatureTileQuery3D as t}from"./featureTileQuery3D.js";class r{constructor(e){this._memoryCache=null;const r=e.layerView.layer;this._layerView=e.layerView,this.objectIdField=r.objectIdField,this.globalIdField="globalIdField"in r?r.globalIdField:null,this._returnZ=e.returnZ,this._returnM=e.returnM;const i=this._layerView.view.resourceController;this.query=t(this._layerView,i.normal),i&&this._memoryCacheEnabled&&(this._memoryCache=i.memoryController.newCache(`fl-${r.uid}`))}get _memoryCacheEnabled(){switch(this._layerView.layer.source.type){case"feature-layer":case"ogc-feature":case"oriented-imagery":return!0;case"csv":case"parquet":case"geojson":case"memory":case"wfs":return!1}}destroy(){this._memoryCache=e(this._memoryCache),this.query.destroy()}createQuery(){const e=this._layerView.layer.createQuery();return e.outFields=this._layerView.availableFields,e.returnZ=this._returnZ,e.returnM=this._returnM,e.outSpatialReference=this.tilingScheme.spatialReference,e}get memoryCache(){return this._memoryCache}get viewingMode(){return this._layerView.view.state.viewingMode}get tilingScheme(){return this._layerView.view.featureTiles.tilingScheme}get scheduler(){return this._layerView.view.resourceController?.scheduler}get geometryType(){return this._layerView.layer.geometryType}get fullExtent(){return this._layerView.layer.fullExtent}get tileMaxRecordCount(){return this._layerView.layer.capabilities.query.tileMaxRecordCount}get maxRecordCount(){return this._layerView.layer.capabilities.query.maxRecordCount}get isDraped(){return"on-the-ground"===this._layerView.layer.elevationInfo?.mode}get capabilities(){return this._capabilities??=i(this._layerView.layer),this._capabilities}logFetchError(e,t){e.error("#fetchTile()",this._layerView.layer,t?.message??t)}}function i(e){const t=e.capabilities.query;return{supportsMultipleResolutions:a(e),supportsPagination:!(!t||!t.supportsPagination),supportsResultType:!(!t||!t.supportsResultType),supportsCacheHint:!(!t||!t.supportsCacheHint),supportsQuantization:!(!t||!t.supportsQuantization),supportsQuantizationEditMode:!(!t||!t.supportsQuantizationEditMode),supportsMaxRecordCountFactor:!(!t||!t.supportsMaxRecordCountFactor),supportsFormatPBF:!(!t||!t.supportsFormatPBF)}}function a(e){switch(e.geometryType){case"polyline":return!0;case"polygon":return e.capabilities&&e.capabilities.query&&e.capabilities.query.supportsQuantization;default:return!1}}export{r as FeatureTileFetcher3DContext,i as contextCapabilitiesFromLayer};
5
+ import{destroyMaybe as e}from"../../../../core/maybe.js";import{createFeatureTileQuery3D as t}from"./featureTileQuery3D.js";class r{constructor(e){this._memoryCache=null;const r=e.layerView.layer;this._layerView=e.layerView,this.objectIdField=r.objectIdField,this.globalIdField="globalIdField"in r?r.globalIdField:null,this._returnZ=e.returnZ,this._returnM=e.returnM;const i=this._layerView.view.resourceController;this.query=t(this._layerView,i.normal),i&&this._memoryCacheEnabled&&(this._memoryCache=i.memoryController.newCache(`fl-${r.uid}`))}get _memoryCacheEnabled(){switch(this._layerView.layer.source.type){case"feature-layer":case"ogc-feature":case"oriented-imagery":return!0;case"csv":case"parquet":case"geojson":case"memory":case"wfs":return!1}}destroy(){this._memoryCache=e(this._memoryCache),this.query.destroy()}createQuery(){const e=this._layerView.layer.createQuery();return e.outFields=this._layerView.availableFields,e.returnZ=this._returnZ,e.returnM=this._returnM,e.outSpatialReference=this.tilingScheme.spatialReference,e}get memoryCache(){return this._memoryCache}get viewingMode(){return this._layerView.view.state.viewingMode}get tilingScheme(){return this._layerView.view.featureTiles.tilingScheme}get scheduler(){return this._layerView.view.resourceController?.scheduler}get geometryType(){return this._layerView.layer.geometryType}get fullExtent(){return this._layerView.layer.fullExtent}get tileMaxRecordCount(){return this._layerView.layer.capabilities.query.tileMaxRecordCount}get maxRecordCount(){return this._layerView.layer.capabilities.query.maxRecordCount}get isDraped(){return"on-the-ground"===this._layerView.layer.elevationInfo?.mode}get effectiveDisplayFilter(){return this._layerView.displayFilterEnabled?this._layerView.effectiveDisplayFilter:null}get capabilities(){return this._capabilities??=i(this._layerView.layer),this._capabilities}logFetchError(e,t){e.error("#fetchTile()",this._layerView.layer,t?.message??t)}}function i(e){const t=e.capabilities.query;return{supportsMultipleResolutions:a(e),supportsPagination:!(!t||!t.supportsPagination),supportsResultType:!(!t||!t.supportsResultType),supportsCacheHint:!(!t||!t.supportsCacheHint),supportsQuantization:!(!t||!t.supportsQuantization),supportsQuantizationEditMode:!(!t||!t.supportsQuantizationEditMode),supportsMaxRecordCountFactor:!(!t||!t.supportsMaxRecordCountFactor),supportsFormatPBF:!(!t||!t.supportsFormatPBF)}}function a(e){switch(e.geometryType){case"polyline":return!0;case"polygon":return e.capabilities&&e.capabilities.query&&e.capabilities.query.supportsQuantization;default:return!1}}export{r as FeatureTileFetcher3DContext,i as contextCapabilitiesFromLayer};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import s from"../../../../core/Collection.js";import{makeHandle as i}from"../../../../core/handleUtils.js";import"../../../../core/has.js";import r from"../../../../core/Logger.js";import{removeMaybe as o}from"../../../../core/maybe.js";import l from"../../../../core/PooledArray.js";import{watch as n,syncAndInitial as a,sync as u}from"../../../../core/reactiveUtils.js";import{signal as h}from"../../../../core/signal.js";import{generateUID as d}from"../../../../core/uid.js";import{property as c}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/RandomLCG.js";import{subclass as m}from"../../../../core/accessorSupport/decorators/subclass.js";import{create as p,intersects as _}from"../../../../geometry/support/aaBoundingRect.js";import{FeatureTileDescriptor as f,getFeatureTileId as g}from"./FeatureTileDescriptor.js";import{FeatureTileMeasurements3D as T}from"./FeatureTileMeasurements3D.js";import{maxLODLevelDelta as y}from"./FeatureTileVisibility3D.js";import{toBoundingRect as v}from"../../support/extentUtils.js";import{TaskPriority as E,noBudget as w}from"../../../support/Scheduler.js";const S=60;let x=class extends t{constructor(e){super(e),this.tiles=new s,this.tileSize=512,this._idToTile=new Map,this._clients=new Set,this._dirty=h(!1),this._pendingTiles=h(null),this._newTiles=new l,this._tests=!1,this._measurements=new T(e.renderCoordsHelper,e.tilingSchemeOwner.tilingScheme,this._opaqueGround)}initialize(){const e=()=>this._setDirty(),t=()=>this._reset();this.addHandles([n((()=>this.tileSize),t,a),n((()=>this.cameraOnSurface?.location),e,a),n((()=>this.viewState?.contentCamera),e,a),n((()=>this.focus?.location),e,a),n((()=>this.terrain?.baseOpacity??1),e),n((()=>this.tilingScheme),(e=>{this._reset(),this._measurements=new T(this.renderCoordsHelper,e,this._opaqueGround)}),u),n((()=>this._opaqueGround),(e=>this._measurements.opaqueGround=e),u)]),this._frameWorker=this.scheduler?.registerTask(E.FEATURE_TILE_TREE,this)}destroy(){this._frameWorker=o(this._frameWorker)}get tilingScheme(){const e=this.tilingSchemeOwner.tilingScheme;if(!e)return null;return e.clone()}set filterExtent(e){if(null!=e&&!e.spatialReference.equals(this.viewState.spatialReference))return void r.getLogger(this).error("#extent","extent spatial reference needs to be in the same spatial reference as the view");const t=this._get("filterExtent");if(t===e||null!=t&&e&&t.equals(e))return;const s=null!=e?e.clone():null;this._set("filterExtent",s),this._setDirty()}get _filterExtentRect(){if(null==this.filterExtent)return null;const e=p();return v(this.filterExtent,e,this.tilingScheme.spatialReference),e}get _rootTileIds(){const{tilingScheme:e}=this;return this._filterExtentRect&&e?e.rootTilesInExtent(this._filterExtentRect):[[0,0,0]]}set suspended(e){e!==this._get("suspended")&&(this._set("suspended",e),this._setDirty())}get updating(){return this._dirty.value||!!this._pendingTiles.value}addClient(){const e=d();return this._clients.add(e),1===this._clients.size&&this._setDirty(),i((()=>this._removeClient(e)))}_removeClient(e){this._clients.delete(e),this._hasClients||this._clear()}get _hasClients(){return this._clients.size>0}get _opaqueGround(){return 1===(this.terrain?.baseOpacity??1)}_setDirty(){this._hasClients&&!this.suspended&&(this._frameWorker?this._dirty.value=!0:this.runTask(w))}_clear(){this.tiles.removeAll(),this._idToTile.clear(),this._reset(),this._dirty.value=!1}get running(){return this.updating}_reset(){this._newTiles.clear(),this._pendingTiles.value=null,this._setDirty()}_getRootTiles(){const e=this.tilingScheme;return this._rootTileIds.map((t=>new f(t[0],t[1],t[2],e)))}runTask(e){e=this._tests?w:e,this._dirty.value=!1,this._pendingTiles.value||(this._startUpdate(e),null!=this._frameWorker&&(this._frameWorker.priority=E.FEATURE_TILE_TREE_ACTIVE)),this._splitPendingTiles(e),this._pendingTiles.value||null==this._frameWorker||(this._frameWorker.priority=E.FEATURE_TILE_TREE)}_startUpdate(e){if(this.suspended)return;if(!this.tilingScheme)return void this._clear();const{_measurements:t,_filterExtentRect:s,_newTiles:i}=this;t.setup(this.viewState.contentCamera,this.focus.location,this.cameraOnSurface.location.z??0),this._pendingTiles.value=this._getRootTiles().filter((e=>{if(t.update(e),e.measures.visible&&(!s||_(e.extent,s))){if(e.measures.splitPriority>0)return!0;i.push(e)}return!1})).sort(j),this._newTiles.clear(),e.madeProgress()}_splitPendingTiles(e){const t=this._pendingTiles.value;if(!t)return;const{tilingScheme:s,_filterExtentRect:i,_newTiles:r,_measurements:o}=this;for(;t.length>0&&this._tileBudgetExceeded<1;){const l=t.pop();if(e.madeProgress(),l.measures.splitPriority>0){s.ensureMaxLod(l.level+1);const e=l.createChildren();for(const s of e)o.update(s),!s.measures.visible||i&&!_(s.extent,i)||(s.measures.splitPriority>0?t.push(s):r.push(s));t.sort(j),this._tileBudgetExceeded>=1&&(this._mergeNewTiles(),this._tileBudgetExceeded>=1&&this._mergeNewTiles(!0))}else r.push(l);if(e.done)return}r.pushArray(t),this._pendingTiles.value=null,this._updateTiles(),r.clear(),o.done()}get _tileBudgetExceeded(){return Math.max(0,(this._newTiles.length+(this._pendingTiles.value?.length??0))/S-1)}_mergeNewTiles(e=!1){const{_newTiles:t,_measurements:s}=this,i=new Map(t.map((e=>[e.id,e])));let r=!1;return i.forEach((o=>{const{lij:l,measures:n}=o;if(!n.mergeable||l[1]%2!=0||l[2]%2!=0||l[0]<=1||o.lodLevelDelta>=y)return;const a=n.lodLevel;let u=a,h=!0;const d=i.get(g(l[0],l[1]+1,l[2]));let c=Math.abs((d?.measures.lodLevel??0)-a),m=0===c||e&&d?.measures.mergeable&&c<=1;if(!d||!m)return;u+=d.measures.lodLevel,h&&=0===c;const p=i.get(g(l[0],l[1],l[2]+1));if(c=Math.abs((p?.measures.lodLevel??0)-a),m=0===c||e&&p?.measures.mergeable&&c<=1,!p||!m)return;u+=p.measures.lodLevel,h&&=0===c;const _=i.get(g(l[0],l[1]+1,l[2]+1));if(c=Math.abs((_?.measures.lodLevel??0)-a),m=0===c||e&&_?.measures.mergeable&&c<=1,!_||!m)return;u+=_.measures.lodLevel,h&&=0===c,t.removeUnordered(o),t.removeUnordered(d),t.removeUnordered(p),t.removeUnordered(_);const T=new f(l[0]-1,l[1]/2,l[2]/2,this.tilingScheme);s.update(T),T.measures.visible=!0,T.measures.lodLevel=u/4,T.measures.mergeable=h,t.push(T),r=!0})),r}_updateTiles(){for(;this._mergeNewTiles(););for(;this._tileBudgetExceeded&&this._mergeNewTiles(!0););for(const s of this.tiles.items)s.used=!1;const e=this._newTiles.filter((e=>{const t=this._idToTile.get(e.id);return t?(t.measures={...e.measures},t.used=!0):this._idToTile.set(e.id,e),!t})),t=this.tiles.items.filter((e=>!e.used&&(this._idToTile.delete(e.id),!0)));this.tiles.removeMany(t),this.tiles.addMany(e),this._sortTiles(),this.tiles.emit("change")}_sortTiles(){this.viewState.fixedContentCamera||this.tiles.sort(((e,t)=>e.measures.distance-t.measures.distance)),this.tiles.forEach(((e,t)=>e.loadPriority=t))}};function j(e,t){return e.lodLevelDelta-t.lodLevelDelta||e.measures.splitPriority-t.measures.splitPriority||t.measures.distance-e.measures.distance}e([c({constructOnly:!0})],x.prototype,"scheduler",void 0),e([c({constructOnly:!0})],x.prototype,"renderCoordsHelper",void 0),e([c({constructOnly:!0})],x.prototype,"tilingSchemeOwner",void 0),e([c({constructOnly:!0})],x.prototype,"cameraOnSurface",void 0),e([c({constructOnly:!0})],x.prototype,"focus",void 0),e([c({constructOnly:!0})],x.prototype,"viewState",void 0),e([c({constructOnly:!0})],x.prototype,"terrain",void 0),e([c()],x.prototype,"tiles",void 0),e([c()],x.prototype,"tileSize",void 0),e([c({readOnly:!0})],x.prototype,"tilingScheme",null),e([c()],x.prototype,"filterExtent",null),e([c({readOnly:!0})],x.prototype,"_filterExtentRect",null),e([c({readOnly:!0})],x.prototype,"_rootTileIds",null),e([c({value:!1})],x.prototype,"suspended",null),e([c({readOnly:!0})],x.prototype,"updating",null),x=e([m("esri.views.3d.layers.support.FeatureTileTree3D")],x);export{x as FeatureTileTree3D};
5
+ import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import s from"../../../../core/Collection.js";import{makeHandle as i}from"../../../../core/handleUtils.js";import"../../../../core/has.js";import r from"../../../../core/Logger.js";import{removeMaybe as l}from"../../../../core/maybe.js";import o from"../../../../core/PooledArray.js";import{watch as n,syncAndInitial as a,sync as u}from"../../../../core/reactiveUtils.js";import{signal as h}from"../../../../core/signal.js";import{generateUID as d}from"../../../../core/uid.js";import{property as c}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/RandomLCG.js";import{subclass as m}from"../../../../core/accessorSupport/decorators/subclass.js";import{create as p,intersects as _}from"../../../../geometry/support/aaBoundingRect.js";import{FeatureTileDescriptor as f,getFeatureTileId as g}from"./FeatureTileDescriptor.js";import{FeatureTileMeasurements3D as T}from"./FeatureTileMeasurements3D.js";import{maxLODLevelDelta as v}from"./FeatureTileVisibility3D.js";import{toBoundingRect as y}from"../../support/extentUtils.js";import{TaskPriority as E,noBudget as w}from"../../../support/Scheduler.js";const S=60;let x=class extends t{constructor(e){super(e),this.tiles=new s,this.tileSize=512,this._idToTile=new Map,this._clients=new Set,this._dirty=h(!1),this._pendingTiles=h(null),this._newTiles=new o,this._tests=!1,this._measurements=new T(e.renderCoordsHelper,e.tilingSchemeOwner.tilingScheme,this._opaqueGround)}initialize(){const e=()=>this._setDirty(),t=()=>this._reset();this.addHandles([n((()=>this.tileSize),t,a),n((()=>this.cameraOnSurface?.location),e,a),n((()=>this.viewState?.contentCamera),e,a),n((()=>this.focus?.location),e,a),n((()=>this.terrain?.baseOpacity??1),e),n((()=>this.tilingScheme),(e=>{this._reset(),this._measurements=new T(this.renderCoordsHelper,e,this._opaqueGround)}),u),n((()=>this._opaqueGround),(e=>this._measurements.opaqueGround=e),u)]),this._frameWorker=this.scheduler?.registerTask(E.FEATURE_TILE_TREE,this)}destroy(){this._frameWorker=l(this._frameWorker)}get tilingScheme(){const e=this.tilingSchemeOwner.tilingScheme;if(!e)return null;return e.clone()}set filterExtent(e){if(null!=e&&!e.spatialReference.equals(this.viewState.spatialReference))return void r.getLogger(this).error("#extent","extent spatial reference needs to be in the same spatial reference as the view");const t=this._get("filterExtent");if(t===e||null!=t&&e&&t.equals(e))return;const s=null!=e?e.clone():null;this._set("filterExtent",s),this._setDirty()}get _filterExtentRect(){if(null==this.filterExtent)return null;const e=p();return y(this.filterExtent,e,this.tilingScheme.spatialReference),e}get _rootTileIds(){const{tilingScheme:e}=this;return this._filterExtentRect&&e?e.rootTilesInExtent(this._filterExtentRect):[[0,0,0]]}set suspended(e){e!==this._get("suspended")&&(this._set("suspended",e),this._setDirty())}get updating(){return this._dirty.value||!!this._pendingTiles.value}addClient(){const e=d();return this._clients.add(e),1===this._clients.size&&this._setDirty(),i((()=>this._removeClient(e)))}_removeClient(e){this._clients.delete(e),this._hasClients||this._clear()}get _hasClients(){return this._clients.size>0}get _opaqueGround(){return 1===(this.terrain?.baseOpacity??1)}_setDirty(){this._hasClients&&!this.suspended&&(this._frameWorker?this._dirty.value=!0:this.runTask(w))}_clear(){this.tiles.removeAll(),this._idToTile.clear(),this._reset(),this._dirty.value=!1}get running(){return this.updating}_reset(){this._newTiles.clear(),this._pendingTiles.value=null,this._setDirty()}_getRootTiles(){const e=this.tilingScheme;return this._rootTileIds.map((t=>new f(t[0],t[1],t[2],e)))}runTask(e){e=this._tests?w:e,this._dirty.value=!1,this._pendingTiles.value||(this._startUpdate(e),null!=this._frameWorker&&(this._frameWorker.priority=E.FEATURE_TILE_TREE_ACTIVE)),this._splitPendingTiles(e),this._pendingTiles.value||null==this._frameWorker||(this._frameWorker.priority=E.FEATURE_TILE_TREE)}_startUpdate(e){if(this.suspended)return;if(!this.tilingScheme)return void this._clear();const{_measurements:t,_filterExtentRect:s,_newTiles:i}=this;t.setup(this.viewState.contentCamera,this.focus.location,this.cameraOnSurface.location.z??0),this._pendingTiles.value=this._getRootTiles().filter((e=>{if(t.update(e),e.measures.visible&&(!s||_(e.extent,s))){if(e.measures.splitPriority>0)return!0;i.push(e)}return!1})).sort(j),this._newTiles.clear(),e.madeProgress()}_splitPendingTiles(e){const t=this._pendingTiles.value;if(!t)return;const{tilingScheme:s,_filterExtentRect:i,_newTiles:r,_measurements:l}=this;for(;t.length>0&&this._tileBudgetExceeded<1;){const o=t.pop();if(e.madeProgress(),o.measures.splitPriority>0){s.ensureMaxLod(o.level+1);const e=o.createChildren();for(const s of e)l.update(s),!s.measures.visible||i&&!_(s.extent,i)||(s.measures.splitPriority>0?t.push(s):r.push(s));t.sort(j),this._tileBudgetExceeded>=1&&(this._mergeNewTiles(),this._tileBudgetExceeded>=1&&this._mergeNewTiles(!0))}else r.push(o);if(e.done)return}r.pushArray(t),this._pendingTiles.value=null,this._updateTiles(),r.clear(),l.done()}get _tileBudgetExceeded(){return Math.max(0,(this._newTiles.length+(this._pendingTiles.value?.length??0))/S-1)}_mergeNewTiles(e=!1){const{_newTiles:t,_measurements:s}=this,i=new Map(t.map((e=>[e.id,e])));let r=!1;return i.forEach((l=>{const{lij:o,measures:n}=l;if(!n.mergeable||o[1]%2!=0||o[2]%2!=0||o[0]<=1||l.lodLevelDelta>=v)return;const a=n.lodLevel;let u=a,h=!0;const d=i.get(g(o[0],o[1]+1,o[2]));let c=Math.abs((d?.measures.lodLevel??0)-a),m=0===c||e&&d?.measures.mergeable&&c<=1;if(!d||!m)return;u+=d.measures.lodLevel,h&&=0===c;const p=i.get(g(o[0],o[1],o[2]+1));if(c=Math.abs((p?.measures.lodLevel??0)-a),m=0===c||e&&p?.measures.mergeable&&c<=1,!p||!m)return;u+=p.measures.lodLevel,h&&=0===c;const _=i.get(g(o[0],o[1]+1,o[2]+1));if(c=Math.abs((_?.measures.lodLevel??0)-a),m=0===c||e&&_?.measures.mergeable&&c<=1,!_||!m)return;u+=_.measures.lodLevel,h&&=0===c,t.removeUnordered(l),t.removeUnordered(d),t.removeUnordered(p),t.removeUnordered(_);const T=new f(o[0]-1,o[1]/2,o[2]/2,this.tilingScheme);s.update(T),T.measures.visible=!0,T.measures.lodLevel=u/4,T.measures.mergeable=h,t.push(T),r=!0})),r}_updateTiles(){for(;this._mergeNewTiles(););for(;this._tileBudgetExceeded&&this._mergeNewTiles(!0););for(const i of this.tiles.items)i.used=!1;let e=!1;const t=this._newTiles.filter((t=>{const s=this._idToTile.get(t.id);return s?(e||=s.measures.lodLevel!==t.measures.lodLevel,s.measures={...t.measures},s.used=!0):this._idToTile.set(t.id,t),!s})),s=this.tiles.items.filter((e=>!e.used&&(this._idToTile.delete(e.id),!0)));this.tiles.removeMany(s),this.tiles.addMany(t),this._sortTiles(),!e||s.length||t.length||this.tiles.emit("change")}_sortTiles(){this.viewState.fixedContentCamera||this.tiles.sort(((e,t)=>e.measures.distance-t.measures.distance)),this.tiles.forEach(((e,t)=>e.loadPriority=t))}};function j(e,t){return e.lodLevelDelta-t.lodLevelDelta||e.measures.splitPriority-t.measures.splitPriority||t.measures.distance-e.measures.distance}e([c({constructOnly:!0})],x.prototype,"scheduler",void 0),e([c({constructOnly:!0})],x.prototype,"renderCoordsHelper",void 0),e([c({constructOnly:!0})],x.prototype,"tilingSchemeOwner",void 0),e([c({constructOnly:!0})],x.prototype,"cameraOnSurface",void 0),e([c({constructOnly:!0})],x.prototype,"focus",void 0),e([c({constructOnly:!0})],x.prototype,"viewState",void 0),e([c({constructOnly:!0})],x.prototype,"terrain",void 0),e([c()],x.prototype,"tiles",void 0),e([c()],x.prototype,"tileSize",void 0),e([c({readOnly:!0})],x.prototype,"tilingScheme",null),e([c()],x.prototype,"filterExtent",null),e([c({readOnly:!0})],x.prototype,"_filterExtentRect",null),e([c({readOnly:!0})],x.prototype,"_rootTileIds",null),e([c({value:!1})],x.prototype,"suspended",null),e([c({readOnly:!0})],x.prototype,"updating",null),x=e([m("esri.views.3d.layers.support.FeatureTileTree3D")],x);export{x as FeatureTileTree3D};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as t}from"../../../../chunks/tslib.es6.js";import e from"../../../../core/Accessor.js";import r from"../../../../core/Logger.js";import{removeMaybe as i,destroyMaybe as s}from"../../../../core/maybe.js";import{throwIfNotAbortError as o,throwIfAborted as n,throwIfAbortError as l}from"../../../../core/promiseUtils.js";import{initial as a}from"../../../../core/reactiveUtils.js";import{property as u}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/RandomLCG.js";import{subclass as p}from"../../../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as c}from"../../../../core/support/UpdatingHandles.js";import h from"../../../../layers/support/FeatureFilter.js";import{getFloorFilterClause as _}from"../../../../layers/support/floorFilterUtils.js";import{QueryEngine as d}from"../graphics/QueryEngine.js";import{QueryEngineContext as m}from"../graphics/QueryEngineContext.js";import{TaskPriority as f}from"../../../support/Scheduler.js";let g=class extends e{constructor(t){super(t),this._frameTask=null,this._queryEngine=null,this._updateRequested=!0,this._updatingHandles=new c,this._abortController=new AbortController}initialize(){const t=f.FILTER_VISIBILITY,{layer:e,view:r}=this._configuration,{featureStore:i}=this.context,{spatialReference:s,resourceController:n}=r,l=this._configuration.hasZ??!1,u=this._configuration.hasM??!1,p=new m(s,e,n,(()=>i),l,u);this._queryEngine=new d({context:p,priority:t}),this._frameTask=r.resourceController.scheduler.registerTask(t),this._updatingHandles.add((()=>[this._compositedFeatureFilter,this._sceneFilter]),(()=>this._updateRequested=!0),a),this._updatingHandles.addWhen((()=>!this._frameTask.updating&&this._updateRequested),(()=>{this._frameTask.schedule((()=>this._updateVisibility()),this._abortController.signal).catch(o),this._updateRequested=!1}),a)}destroy(){this._abortController.abort(),this._updatingHandles.destroy(),this.clear(),this._frameTask=i(this._frameTask),this._queryEngine=s(this._queryEngine),this._set("context",null)}get updating(){return this._updateRequested||this._updatingHandles.updating||this._frameTask.updating}get defaultVisibility(){return null==this._compositedFeatureFilter&&null==this._sceneFilter}get _featureFilter(){return"filter"in this._configuration?this._configuration.filter:null}get _sceneFilter(){return"layerFilter"in this._configuration?this._configuration.layerFilter:null}get _floorFilter(){return _(this._configuration)}get _timeExtent(){return"timeExtent"in this._configuration?this._configuration.timeExtent:null}get _compositedFeatureFilter(){const{_featureFilter:t,_timeExtent:e,_floorFilter:r}=this;if(null==e&&null==r)return t;const i=t?.clone()??new h;if(null!=e&&(i.timeExtent=i.timeExtent?.intersection(e)??e),null!=r){const t=null==i.where||""===i.where;i.where=t?r:`(${i.where}) AND (${r})`}return i}get _configuration(){return this.context.configuration}reapply(){this._updateRequested=!0}clear(){this._queryEngine.clear(),this.context.clearFeaturesVisibility()}async _updateVisibility(){const{signal:t}=this._abortController,{context:e,_frameTask:i,_sceneFilter:s,_compositedFeatureFilter:o}=this;if(n(t),null==o&&null==s||0===e.getFeatureCount())return await i.schedule((()=>this.clear()),t);try{const r=await this._queryEngine.executeQueryForIdSet(o,s,t);return n(t),await i.schedule((()=>{e.updateFeatureVisibilities((t=>r.has(t)))}),t)}catch(a){return l(a),r.getLogger(this).warn(`FeatureFilter query failed: ${a}`,{error:a}),await i.schedule((()=>{e.setAllFeaturesVisibility(!0)}),t)}}};t([u({constructOnly:!0})],g.prototype,"context",void 0),t([u()],g.prototype,"updating",null),t([u()],g.prototype,"defaultVisibility",null),t([u()],g.prototype,"_featureFilter",null),t([u()],g.prototype,"_sceneFilter",null),t([u()],g.prototype,"_floorFilter",null),t([u()],g.prototype,"_timeExtent",null),t([u()],g.prototype,"_compositedFeatureFilter",null),t([u()],g.prototype,"_configuration",null),t([u()],g.prototype,"_updateRequested",void 0),g=t([p("esri.views.3d.layers.support.FeatureVisibilityFilter")],g);export{g as FeatureVisibilityFilter};
5
+ import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import r from"../../../../core/Logger.js";import{removeMaybe as i,destroyMaybe as s}from"../../../../core/maybe.js";import{throwIfNotAbortError as o,throwIfAborted as n,throwIfAbortError as l}from"../../../../core/promiseUtils.js";import{initial as a}from"../../../../core/reactiveUtils.js";import{sqlAnd as u}from"../../../../core/sql.js";import{property as p}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/RandomLCG.js";import{subclass as c}from"../../../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as h}from"../../../../core/support/UpdatingHandles.js";import _ from"../../../../layers/support/FeatureFilter.js";import{getFloorFilterClause as f}from"../../../../layers/support/floorFilterUtils.js";import{QueryEngine as d}from"../graphics/QueryEngine.js";import{QueryEngineContext as m}from"../graphics/QueryEngineContext.js";import{TaskPriority as g}from"../../../support/Scheduler.js";let y=class extends t{constructor(e){super(e),this._frameTask=null,this._queryEngine=null,this._updateRequested=!0,this._updatingHandles=new h,this._abortController=new AbortController}initialize(){const e=g.FILTER_VISIBILITY,{layer:t,view:r}=this._configuration,{featureStore:i}=this.context,{spatialReference:s,resourceController:n}=r,l=this._configuration.hasZ??!1,u=this._configuration.hasM??!1,p=new m(s,t,n,(()=>i),l,u);this._queryEngine=new d({context:p,priority:e}),this._frameTask=r.resourceController.scheduler.registerTask(e),this._updatingHandles.add((()=>[this._compositedFeatureFilter,this._sceneFilter]),(()=>this._updateRequested=!0),a),this._updatingHandles.addWhen((()=>!this._frameTask.updating&&this._updateRequested),(()=>{this._frameTask.schedule((()=>this._updateVisibility()),this._abortController.signal).catch(o),this._updateRequested=!1}),a)}destroy(){this._abortController.abort(),this._updatingHandles.destroy(),this.clear(),this._frameTask=i(this._frameTask),this._queryEngine=s(this._queryEngine),this._set("context",null)}get updating(){return this._updateRequested||this._updatingHandles.updating||this._frameTask.updating}get defaultVisibility(){return null==this._compositedFeatureFilter&&null==this._sceneFilter}get _featureFilter(){return"filter"in this._configuration?this._configuration.filter:null}get _effectiveDisplayFilter(){return"effectiveDisplayFilter"in this._configuration?this._configuration.effectiveDisplayFilter:null}get _sceneFilter(){return"layerFilter"in this._configuration?this._configuration.layerFilter:null}get _floorFilter(){return f(this._configuration)}get _timeExtent(){return"timeExtent"in this._configuration?this._configuration.timeExtent:null}get _compositedFeatureFilter(){const{_featureFilter:e,_effectiveDisplayFilter:t,_timeExtent:r,_floorFilter:i}=this;let s=e?.clone();if(null!=t&&(s??=new _,s.where=u(s.where,t.where)),null!=r&&(s??=new _,s.timeExtent=s.timeExtent?.intersection(r)??r),null!=i){s??=new _;const e=null==s.where||""===s.where;s.where=e?i:u(s.where,i)}return s}get _configuration(){return this.context.configuration}reapply(){this._updateRequested=!0}clear(){this._queryEngine.clear(),this.context.clearFeaturesVisibility()}async _updateVisibility(){const{signal:e}=this._abortController,{context:t,_frameTask:i,_sceneFilter:s,_compositedFeatureFilter:o}=this;if(n(e),null==o&&null==s||0===t.getFeatureCount())return await i.schedule((()=>this.clear()),e);try{const r=await this._queryEngine.executeQueryForIdSet(o,s,e);return n(e),await i.schedule((()=>{t.updateFeatureVisibilities((e=>r.has(e)))}),e)}catch(a){return l(a),r.getLogger(this).warn(`FeatureFilter query failed: ${a}`,{error:a}),await i.schedule((()=>{t.setAllFeaturesVisibility(!0)}),e)}}};e([p({constructOnly:!0})],y.prototype,"context",void 0),e([p()],y.prototype,"updating",null),e([p()],y.prototype,"defaultVisibility",null),e([p()],y.prototype,"_featureFilter",null),e([p()],y.prototype,"_effectiveDisplayFilter",null),e([p()],y.prototype,"_sceneFilter",null),e([p()],y.prototype,"_floorFilter",null),e([p()],y.prototype,"_timeExtent",null),e([p()],y.prototype,"_compositedFeatureFilter",null),e([p()],y.prototype,"_configuration",null),e([p()],y.prototype,"_updateRequested",void 0),y=e([c("esri.views.3d.layers.support.FeatureVisibilityFilter")],y);export{y as FeatureVisibilityFilter};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{equals as e}from"../../../core/arrayUtils.js";import"../../../core/has.js";import{isPowerOfTwo as t}from"../../../core/mathUtils.js";import{disposeMaybe as r}from"../../../core/maybe.js";import{j as i,G as s,H as o,d as a,n,f as l,a as d,I as g}from"../../../chunks/vec32.js";import{create as h,clone as m}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{containsXY as u}from"../../../geometry/support/aaBoundingRect.js";import{earth as c}from"../../../geometry/support/Ellipsoid.js";import{glLayout as f}from"../support/buffer/glUtil.js";import{GeometryState as p}from"./GeometryState.js";import{TextureUpdate as y}from"./interfaces.js";import{LayerClass as x}from"./LayerClass.js";import{NeighborIndex as _}from"./NeighborIndex.js";import{PatchGeometry as v}from"./PatchGeometry.js";import{maxTileNeighborLevelDelta as E}from"./TerrainConst.js";import{enableTerrainInternalChecks as $,internalAssert as S,neighborEdgeIndices as C,oppositeEdge as D,neighborCornerIndices as b,v32s as T,lij2s as j}from"./terrainUtils.js";import{TextureFader as R,ActivationTime as A}from"./TextureFader.js";import{TextureReference as V}from"./TextureReference.js";import w from"./TileOverlayData.js";import{fallsWithinLayerView as N}from"./tileUtils.js";import{VertexArrayObject as F}from"../webgl-engine/lib/VertexArrayObject.js";import{vertexAttributeLocations as P}from"../webgl-engine/shaders/TerrainTechnique.js";import{BufferObject as G}from"../../webgl/BufferObject.js";import{PixelFormat as O}from"../../webgl/enums.js";class I{constructor(){this.geometry=new v,this.intersectionData=null,this.geometryState=null,this._vao=null,this._texture=null,this._textureOpacity=1,this._textureRef=new R((()=>this._tile.surface.fadeDuration)),this.overlay=new w,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 p,this._localOrigin=t,this.overlay.clear()}clear(){this.releaseGeometry(),this.releaseTexture(),this._textureRef.clear(),this._tile=null,this.intersectionData=null,this.geometryState=null}updateGeometryIfNeeded(e){if((!this._vao||this._geometryStateChangedSinceLastUpdate||this.wireframeChanged||this.clippingAreaChanged||this.samplerDataChanged||this.numVerticesPerSideChanged||this.dirtyCorners||this.dirtyEdgeResolutions||this.dirtyEdges)&&(this._updateGeometry(e),this._geometryStateChangedSinceLastUpdate=!1),$&&this.tile.intersectsClippingArea)for(let t=0;t<4;++t)S(this.geometry.getEdgeCount(t)===this.geometryState.edgeResolutions[t]+1)}_calculateEdgeResolution(e,t){const r=this.tile,i=this.geometryState.numVerticesPerSide-1;if(!r.surface.isGlobal){const t=r.surface.extent;if(null!=t&&(0===e&&r.extent[3]>t[3]||1===e&&r.extent[2]>t[2]||2===e&&r.extent[1]<t[1]||3===e&&r.extent[0]<t[0]))return i}const s=r.level,o=C[e];if(!t)return S(null==r.surface?.rootTiles||r.surface.updatingRootTiles||!r.shouldHaveNeighbor(o)),i;if(t.loaded){const r=t,o=r.renderData.geometryState,a=s-r.level;if(S(a>=0),0===a){const e=o.numVerticesPerSide-1;return Math.max(e,i)}const n=2**a,l=o.edgeResolutions[(e+2)%4]/n;return Math.max(1,l)}S(!t.leaf);let a=i;return t.forAllSubtreeOnSide(D(o),(e=>e===r||(e.loaded?(a=Math.max(a,2**(e.level-s)),!0):(S(!e.leaf),!1)))),a}updateNeighborData(){const e=this.tile;if(!e.intersectsClippingArea)return;const r=e.renderData.geometryState,i=t=>(t.loaded||t.level===e.level)&&t?.intersectsClippingArea,s=r.edgePeerNeighbors,o=r.edgePeerNeighborSamplerVersions;for(let a=0;a<4;++a){const n=e.findNeighborTile(C[a],i),l=q(e,n),d=l?.renderData?.geometryState.samplerDataVersion??-1,g=s[a],h=l!==q(e,g),m=o[a]!==d;$&&n&&(S(e.level>=n.level),S(e.level-n.level<=E)),s[a]=n,(h||m)&&(o[a]=d,this._markEdgeDirty(a));const u=r.edgeResolutions[a],c=this._calculateEdgeResolution(a,n);S(t(c)),S(c>=1),r.edgeResolutions[a]=c,u!==c&&this._markEdgeResolutionDirty(a)}for(let t=0;t<4;++t){const o=e.findNeighborTile(b[t],i);r.cornerPeerNeighbors[t]=o;const a=q(e,s[t]),n=q(e,s[(t+1)%4]),l=q(e,o);W[t]=l,W[(t+1)%4]=n,W[(t+2)%4]=e,W[(t+3)%4]=a,S(W.some((t=>t?.loaded||t===e)));const d=W.reduce(((e,t)=>Math.min(e,t?.level??1/0)),1/0);W.forEach(((e,t)=>{e&&e?.level>d&&(W[t]=null)})),S(W.some((t=>t?.loaded||t===e)));const g=r.cornerNeighborCornerTiles,h=r.cornerNeighborCornerTileSamplerVersions;for(let e=0;e<4;++e){const r=W[e],i=r?.renderData.geometryState.samplerDataVersion??-1,s=4*t+e,o=g[s]!==r,a=!o&&h[s]!==i;(o||a)&&(g[s]=r,h[s]=i,this._markCornerDirty(t))}$&&S(te.some((r=>g[4*t+r]?.loaded||g[4*t+r]===e)))}$&&S(this.geometryState.edgeResolutions.every((e=>e>0)));for(let t=0;t<4;++t)W[t]=null}_updateGeometry(e){if(!this.tile.intersectsClippingArea)return;$&&S(!this.tile.intersectsClippingArea||this.geometryState.edgeResolutions.every((e=>e>0))),this.intersectionData=null;const{tile:t,_vao:r,geometry:i,geometryState:s}=this,o=!r||!{geometry:i}||this.wireframeChanged||this.samplerDataChanged||this.clippingAreaChanged||this.numVerticesPerSideChanged,a=0!==this.dirtyEdgeResolutions,n=s.edgeResolutions.reduce(((e,t)=>e+t+1),0),l=o||a&&n>(i?.maxEdgeVertexCount??0),d=!l&&a,g=!d&&(0!==this.dirtyEdges||a),h=!g&&0!==this.dirtyCorners;l?(this.releaseGeometry(),this._createGeometry(e)):d?t.updateEdgeElevationsAndResolutions():g||h?t.updateEdgeElevations():h?t.updateCornerElevations():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=r(this._vao),this.geometry.release(),!0)}ensureTexture(e,t,r,i){const s=t?O.RGBA:O.RGB;return null!=this._texture&&(r===y.FADING&&this._tile.surface.fadeDuration>0&&this._isTextureVisible(this._texture)||this._texture.descriptor.width!==e||this._texture.descriptor.pixelFormat!==s)&&this.releaseTexture(),null==this._texture&&(this._texture=i(),this.tile.setMemoryDirty()),this._texture}releaseTexture(){null!=this._texture&&(this._texture.release(),this._texture=null,this.tile.setMemoryDirty())}reuseTexture(e,t){return!(!e||!this._texture)&&(e.setTextureReference(new V(this._texture,y.FADING,t,this._textureOpacity,0,1)),!0)}get numVerticesPerSideChanged(){return!!(this._modifiedFlags&z)}get samplerDataChanged(){return!!(this._modifiedFlags&J)}get clippingAreaChanged(){return!!(this._modifiedFlags&K)}get wireframeChanged(){return!!(this._modifiedFlags&Q)}get dirtyEdges(){return this._modifiedFlags>>Y&15}get dirtyCorners(){return this._modifiedFlags>>Z&15}get dirtyEdgeResolutions(){return this._modifiedFlags>>ee&15}_markCornerDirty(e){const t=1<<e<<Z;this._modifiedFlags|=t}_markEdgeDirty(e){const t=1<<e<<Y;this._modifiedFlags|=t,this._markCornerDirty((e+0)%4),this._markCornerDirty((e+3)%4)}_markEdgeResolutionDirty(e){const t=1<<e<<ee;this._modifiedFlags|=t,this._markEdgeDirty(e)}_markAllEdgesAndCornersDirty(){this._modifiedFlags|=15<<Z|15<<Y|15<<ee}updateGeometryState(){const t=this._elevationInfo,r=this.tile,i=t.samplerData?r.getElevationVerticesPerSide(t.maxTileLevel):r.minimumVerticesPerSide,s=Math.max(i,5);let o=r.clippingArea;r.intersectsClippingArea&&!r.withinClippingArea||(o=null);const a=this.geometryState;let n=!1;a.numVerticesPerSide!==s&&(this._modifiedFlags|=1,a.numVerticesPerSide=s,a.samplerDataVersion++,n=!0),t.changed&&(this._modifiedFlags|=2,a.samplerData=t.samplerData,a.samplerDataVersion++,n=!0),e(a.clippingArea,o)||(this._modifiedFlags=4,a.clippingArea=o,n=!0);const l=r.surface.wireframe;return a.wireframe!==l&&(this._modifiedFlags=8,a.wireframe=l,n=!0),this._geometryStateChangedSinceLastUpdate||=n,n&&this._markAllEdgesAndCornersDirty(),this._hasGeometry=!0,this._geometryStateChangedSinceLastUpdate}_createGeometry(e){this.tile.createGeometry();const t=this.geometry.vertexAttributes,r=this.geometry.indices,i=e.gl;this._vao=new F(e,P,new Map([["geometry",f(t.layout)]]),new Map([["geometry",G.createVertex(e,i.STATIC_DRAW,t.buffer)]]),G.createIndex(e,i.STATIC_DRAW,r)),this._hasGeometry=!0}get vao(){return this._vao}setTextureReference(e,t=A.Immediate){e?.texture===this._texture?this._textureOpacity=e.opacities[0]:this.releaseTexture(),this._textureRef.push(e,t)}get textureReference(){return this._textureRef.current}get nextTextureReference(){return this._textureRef.next}get textureFadeFactor(){return this._textureRef.fadeFactor}get textureIsFading(){return this._textureRef.isFading}_isTextureVisible(e){return this._textureRef.current?.texture===e||this._textureRef.next?.texture===e&&this._textureRef.fadeFactor<1}get _elevationInfo(){const e=this.geometryState.samplerData,t=this.tile.layerInfo[x.ELEVATION],r=t.length,i=new Array(r);let s=0,o=0,a=!1;for(let d=0;d<r;d++){const r=t[d],n=r.upsampleInfo?.tile;if(n){const t=n.layerInfo[x.ELEVATION][d].data,r=t&&t.samplerData;e&&e[s]===r||(a=!0),i[s++]=r,o=Math.max(o,n.lij[0])}else if(r.data){const t=this.tile.surface.layerViewByIndex(d,x.ELEVATION);if(N(this.tile,t)){const t=r.data;e&&e[s]===t.samplerData||(a=!0),i[s++]=t.samplerData,o=this.tile.level}}}null!=e&&e.length!==s&&(a=!0);const n=s>0,l=n?i:null;return n&&(i.length=s),{changed:a,samplerData:l,maxTileLevel:o}}get estimatedGeometryMemoryUsage(){const 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(){if(!$)return;const e=this.tile;if(!e.loaded||!e.intersectsClippingArea||0===e.level)return void S(e?.loaded);const r=e.surface.extent;if(null!=r&&!e.intersectsExtent(r))return;const f=C.map(((t,i)=>null!=r&&(i<2?-1:1)*(e.extent[3-i]-r[3-i])<0)),p=e.level;S(0===this.dirtyCorners),S(0===this.dirtyEdges),S(0===this.dirtyEdgeResolutions),S(!this.numVerticesPerSideChanged),S(!this.samplerDataChanged),S(!this.clippingAreaChanged),S(!this.wireframeChanged);const y=b.map((t=>e.findNeighborCornerTileExact(t,(t=>!t.intersectsClippingArea||t.loaded||t.level===e.level))??null)).map((e=>e?.intersectsClippingArea?e:null)),x=this.geometryState;for(let t=0;t<4;++t){const r=x.cornerPeerNeighbors[t],i=y[t];S(i===r,`Tile[${e.lij}].corner[${t}] out of date: cur=[${r?.lij}] exp=[${i?.lij}]`)}C.forEach(((r,y)=>{if(f[y])return;const x=e.findNeighborTile(r,(e=>(e.level===p||e?.loaded)&&e?.intersectsClippingArea));if(!x){const t=!e.surface.updatingRootTiles&&null!=e.surface.rootTiles&&e.surface.rootTiles.length>0&&e.shouldHaveNeighbor(r);return void S(!t)}S(x.loaded||x.level===e.level),S(x===this.geometryState.edgePeerNeighbors[y]);const v=p-x.level;if(!x.loaded)return S(!x.leaf),void S(0===v);const E=x.renderData;S(e.isEdgeNeighbor(x,r)),S(v>=0);const $=2**v;if(v<0)return void S(!1);const C=e.renderData,D=C.geometry,b=C.localOrigin,R=D.getEdgeCount(y),A=D.numVerticesPerSide-1,V=E.geometry;if(!V)return void S(!1);const w=E.localOrigin,N=this.geometryState.edgePeerNeighbors[y];if(N?.loaded){const e=N.renderData;S(C.geometryState.edgePeerNeighborSamplerVersions[y]===e.geometryState.samplerDataVersion),S(this.geometryState.edgePeerNeighborSamplerVersions[y]===e.geometryState.samplerDataVersion)}const F=(y+2)%4,P=V.getEdgeCount(F),G=R-1,O=P-1;S(G*$===O,`Tile[${e.lij}]:e${y},res=${G} edgeRes mismatch with Neighbor[${x.lij}]:e${F},res=${O} (expected:${G*$})`);const I=e.extent,W=r===_.NORTH||r===_.SOUTH,q=P-1,z=q>>v,J=R-1;if(z<1)return void S(1===J);S(z===J),S(t(z));const K=V.numVerticesPerSide-1;S(v>0||z===Math.max(K,A));const Q=e.getNeighborEdgeStartVertexIndex(y,x);S(0<=Q&&Q<$);const Y=Q*z;S(0<=Y&&Y<=q-z);let Z=0,ee=Y;D.getEdgeVertexPosition(y,M,b,0),D.getEdgeVertexPosition(y,U,b,R-1);const te=i(M,U),re=Math.max(B,1e-4*te);for(let t=0;t<=z;++t){D.getEdgeVertexPosition(y,M,b,Z),V.getEdgeVertexPosition(F,U,w,ee);const i=t/z,f=W?I[0]+i*(I[2]-I[0]):r===_.WEST?I[0]:I[2],p=W?r===_.SOUTH?I[1]:I[3]:I[1]+i*(I[3]-I[1]),v=e.surface.extent;if(null==v||u(v,f,p)){const t=s(M,U),r=o(M)-c.radius,i=o(U)-c.radius,u=t<re;if(!u){console.warn(`Tile edge vertex position mismatch: between [${e.lij}].edge${y}[${Z}/${R}] and [${x.lij}].edge${F}[${ee}/${P}]`),null!=v&&console.warn(" surface extent= ",v," x,y=",f,",",p);const s=h();a(s,C.localOrigin,E.localOrigin),o(s)>0&&console.warn(` localOrigins: ${C.localOrigin} vs ${E.localOrigin} d=${o(s)} [${s}]`);(()=>{const t=m(M),r=m(U);e.updateEdgeElevations(),x.updateEdgeElevations(),D.getEdgeVertexPosition(y,M,b,Z),V.getEdgeVertexPosition(F,U,w,ee);const i=h();d(i,M,t),o(i)>0&&console.warn(` XXX Tile[${e.lij}] edge out of date: ${t} vs ${M} d=${o(i)} [${i}]`),d(i,U,r),o(i)>0&&console.warn(` XXX Neighbor[${x.lij}] edge out of date: ${r} vs ${U} d=${o(i)} [${i}]`)})();const n=D.getEdgeCount(y),l=V.getEdgeCount(P);S(u,`Mismatch in tile [${e.lij}].edge[${y}][${Z}/${n}] vs neighbor [${x.lij}].edge[${F}][${ee}/${l}] ${T(M)} vs ${T(U)} dist=${t} h(t|n|d)=${r}|${i}|${i-r}`)}D.getEdgeNormal(y,k,Z),V.getEdgeNormal(F,L,ee),n(H,k),n(X,L);const _=l(H,X),$=1-_<.01||!1||e===x;if(!$){const t=h();d(t,k,L);const r=()=>`Mismatch in tile edge normal ${j(e.lij)} (${Z}/${R-1}) edge ${y} vs neighbor ${j(x.lij)} (${ee}/${P-1}) nedge ${F} :${T(k)} vs ${T(L)} dot = ${_} : ${T(t)}`;console.warn("Mismatch in tile edge normal: ",r());{e.updateEdgeElevations(),x.updateEdgeElevations();const t=h(),r=h();D.getEdgeNormal(y,t,Z),V.getEdgeNormal(F,r,ee),g(k,t)||console.warn("Missing update in tile normal: ",T(k)," => ",T(t)),g(L,r)||console.warn("Missing update in neighbor normal: ",T(L)," => ",T(r))}S($,r())}}Z+=1,ee+=1}}))}}const M=h(),U=h(),k=h(),L=h(),H=h(),X=h(),B=1,W=[null,null,null,null];function q(e,t){return t?.loaded||t===e?t:null}const z=1,J=2,K=4,Q=8,Y=4,Z=8,ee=12,te=[0,1,2,3];export{A as ActivationTime,I as PatchRenderData,q as neighborTileIfLoadedOrSelf,te as zeroToFour};
5
+ import{equals as e}from"../../../core/arrayUtils.js";import"../../../core/has.js";import{isPowerOfTwo as t}from"../../../core/mathUtils.js";import{disposeMaybe as r}from"../../../core/maybe.js";import{j as i,G as s,H as o,d as a,n,f as l,a as d,I as g}from"../../../chunks/vec32.js";import{create as h,clone as m}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{containsXY as u}from"../../../geometry/support/aaBoundingRect.js";import{earth as c}from"../../../geometry/support/Ellipsoid.js";import{glLayout as f}from"../support/buffer/glUtil.js";import{GeometryState as p}from"./GeometryState.js";import{TextureUpdate as y}from"./interfaces.js";import{LayerClass as x}from"./LayerClass.js";import{NeighborIndex as _}from"./NeighborIndex.js";import{PatchGeometry as v}from"./PatchGeometry.js";import{maxTileNeighborLevelDelta as E}from"./TerrainConst.js";import{enableTerrainInternalChecks as $,internalAssert as S,neighborEdgeIndices as C,oppositeEdge as D,neighborCornerIndices as b,v32s as T,lij2s as j}from"./terrainUtils.js";import{TextureFader as R,ActivationTime as A}from"./TextureFader.js";import{TextureReference as V}from"./TextureReference.js";import w from"./TileOverlayData.js";import{fallsWithinLayerView as N}from"./tileUtils.js";import{VertexArrayObject as F}from"../webgl-engine/lib/VertexArrayObject.js";import{vertexAttributeLocations as P}from"../webgl-engine/shaders/TerrainTechnique.js";import{BufferObject as G}from"../../webgl/BufferObject.js";import{PixelFormat as O}from"../../webgl/enums.js";class I{constructor(){this.geometry=new v,this.intersectionData=null,this.geometryState=null,this._vao=null,this._texture=null,this._textureOpacity=1,this._textureRef=new R((()=>this._tile.surface.fadeDuration)),this.overlay=new w,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 p,this._localOrigin=t,this.overlay.clear()}clear(){this.releaseGeometry(),this.releaseTexture(),this._textureRef.clear(),this._tile=null,this.intersectionData=null,this.geometryState=null}updateGeometryIfNeeded(e){if((!this._vao||this._geometryStateChangedSinceLastUpdate||this.wireframeChanged||this.clippingAreaChanged||this.samplerDataChanged||this.numVerticesPerSideChanged||this.dirtyCorners||this.dirtyEdgeResolutions||this.dirtyEdges)&&(this._updateGeometry(e),this._geometryStateChangedSinceLastUpdate=!1),$&&this.tile.intersectsClippingArea)for(let t=0;t<4;++t)S(this.geometry.getEdgeCount(t)===this.geometryState.edgeResolutions[t]+1)}_calculateEdgeResolution(e,t){const r=this.tile,i=this.geometryState.numVerticesPerSide-1;if(!r.surface.isGlobal){const t=r.surface.extent;if(null!=t&&(0===e&&r.extent[3]>t[3]||1===e&&r.extent[2]>t[2]||2===e&&r.extent[1]<t[1]||3===e&&r.extent[0]<t[0]))return i}const s=r.level,o=C[e];if(!t)return S(null==r.surface?.rootTiles||r.surface.updatingRootTiles||!r.shouldHaveNeighbor(o)),i;if(t.loaded){const r=t,o=r.renderData.geometryState,a=s-r.level;if(S(a>=0),0===a){const e=o.numVerticesPerSide-1;return Math.max(e,i)}const n=2**a,l=o.edgeResolutions[(e+2)%4]/n;return Math.max(1,l)}S(!t.leaf);let a=i;return t.forAllSubtreeOnSide(D(o),(e=>e===r||(e.loaded?(a=Math.max(a,2**(e.level-s)),!0):(S(!e.leaf),!1)))),a}updateNeighborData(){const e=this.tile;if(!e.intersectsClippingArea)return;const r=e.renderData.geometryState,i=t=>(t.loaded||t.level===e.level)&&t?.intersectsClippingArea,s=r.edgePeerNeighbors,o=r.edgePeerNeighborSamplerVersions;for(let a=0;a<4;++a){const n=e.findNeighborTile(C[a],i),l=q(e,n),d=l?.renderData?.geometryState.samplerDataVersion??-1,g=s[a],h=l!==q(e,g),m=o[a]!==d;$&&n&&(S(e.level>=n.level),S(e.level-n.level<=E)),s[a]=n,(h||m)&&(o[a]=d,this._markEdgeDirty(a));const u=r.edgeResolutions[a],c=this._calculateEdgeResolution(a,n);S(t(c)),S(c>=1),r.edgeResolutions[a]=c,u!==c&&this._markEdgeResolutionDirty(a)}for(let t=0;t<4;++t){const o=e.findNeighborTile(b[t],i);r.cornerPeerNeighbors[t]=o;const a=q(e,s[t]),n=q(e,s[(t+1)%4]),l=q(e,o);W[t]=l,W[(t+1)%4]=n,W[(t+2)%4]=e,W[(t+3)%4]=a,S(W.some((t=>t?.loaded||t===e)));const d=W.reduce(((e,t)=>Math.min(e,t?.level??1/0)),1/0);W.forEach(((e,t)=>{e&&e?.level>d&&(W[t]=null)})),S(W.some((t=>t?.loaded||t===e)));const g=r.cornerNeighborCornerTiles,h=r.cornerNeighborCornerTileSamplerVersions;for(let e=0;e<4;++e){const r=W[e],i=r?.renderData.geometryState.samplerDataVersion??-1,s=4*t+e,o=g[s]!==r,a=!o&&h[s]!==i;(o||a)&&(g[s]=r,h[s]=i,this._markCornerDirty(t))}$&&S(te.some((r=>g[4*t+r]?.loaded||g[4*t+r]===e)))}$&&S(this.geometryState.edgeResolutions.every((e=>e>0)));for(let t=0;t<4;++t)W[t]=null}_updateGeometry(e){if(!this.tile.intersectsClippingArea)return;$&&S(!this.tile.intersectsClippingArea||this.geometryState.edgeResolutions.every((e=>e>0))),this.intersectionData=null;const{tile:t,_vao:r,geometry:i,geometryState:s}=this,o=!r||this.wireframeChanged||this.samplerDataChanged||this.clippingAreaChanged||this.numVerticesPerSideChanged,a=0!==this.dirtyEdgeResolutions,n=s.edgeResolutions.reduce(((e,t)=>e+t+1),0),l=o||a&&n>(i?.maxEdgeVertexCount??0),d=!l&&a,g=!d&&(0!==this.dirtyEdges||a),h=!g&&0!==this.dirtyCorners;l?(this.releaseGeometry(),this._createGeometry(e)):d?t.updateEdgeElevationsAndResolutions():g||h?t.updateEdgeElevations():h?t.updateCornerElevations():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=r(this._vao),this.geometry.release(),!0)}ensureTexture(e,t,r,i){const s=t?O.RGBA:O.RGB;return null!=this._texture&&(r===y.FADING&&this._tile.surface.fadeDuration>0&&this._isTextureVisible(this._texture)||this._texture.descriptor.width!==e||this._texture.descriptor.pixelFormat!==s)&&this.releaseTexture(),null==this._texture&&(this._texture=i(),this.tile.setMemoryDirty()),this._texture}releaseTexture(){null!=this._texture&&(this._texture.release(),this._texture=null,this.tile.setMemoryDirty())}reuseTexture(e,t){return!(!e||!this._texture)&&(e.setTextureReference(new V(this._texture,y.FADING,t,this._textureOpacity,0,1)),!0)}get numVerticesPerSideChanged(){return!!(this._modifiedFlags&z)}get samplerDataChanged(){return!!(this._modifiedFlags&J)}get clippingAreaChanged(){return!!(this._modifiedFlags&K)}get wireframeChanged(){return!!(this._modifiedFlags&Q)}get dirtyEdges(){return this._modifiedFlags>>Y&15}get dirtyCorners(){return this._modifiedFlags>>Z&15}get dirtyEdgeResolutions(){return this._modifiedFlags>>ee&15}_markCornerDirty(e){const t=1<<e<<Z;this._modifiedFlags|=t}_markEdgeDirty(e){const t=1<<e<<Y;this._modifiedFlags|=t,this._markCornerDirty((e+0)%4),this._markCornerDirty((e+3)%4)}_markEdgeResolutionDirty(e){const t=1<<e<<ee;this._modifiedFlags|=t,this._markEdgeDirty(e)}_markAllEdgesAndCornersDirty(){this._modifiedFlags|=15<<Z|15<<Y|15<<ee}updateGeometryState(){const t=this._elevationInfo,r=this.tile,i=t.samplerData?r.getElevationVerticesPerSide(t.maxTileLevel):r.minimumVerticesPerSide,s=Math.max(i,5);let o=r.clippingArea;r.intersectsClippingArea&&!r.withinClippingArea||(o=null);const a=this.geometryState;let n=!1;a.numVerticesPerSide!==s&&(this._modifiedFlags|=1,a.numVerticesPerSide=s,a.samplerDataVersion++,n=!0),t.changed&&(this._modifiedFlags|=2,a.samplerData=t.samplerData,a.samplerDataVersion++,n=!0),e(a.clippingArea,o)||(this._modifiedFlags=4,a.clippingArea=o,n=!0);const l=r.surface.wireframe;return a.wireframe!==l&&(this._modifiedFlags=8,a.wireframe=l,n=!0),this._geometryStateChangedSinceLastUpdate||=n,n&&this._markAllEdgesAndCornersDirty(),this._hasGeometry=!0,this._geometryStateChangedSinceLastUpdate}_createGeometry(e){this.tile.createGeometry();const t=this.geometry.vertexAttributes,r=this.geometry.indices,i=e.gl;this._vao=new F(e,P,new Map([["geometry",f(t.layout)]]),new Map([["geometry",G.createVertex(e,i.STATIC_DRAW,t.buffer)]]),G.createIndex(e,i.STATIC_DRAW,r)),this._hasGeometry=!0}get vao(){return this._vao}setTextureReference(e,t=A.Immediate){e?.texture===this._texture?this._textureOpacity=e.opacities[0]:this.releaseTexture(),this._textureRef.push(e,t)}get textureReference(){return this._textureRef.current}get nextTextureReference(){return this._textureRef.next}get textureFadeFactor(){return this._textureRef.fadeFactor}get textureIsFading(){return this._textureRef.isFading}_isTextureVisible(e){return this._textureRef.current?.texture===e||this._textureRef.next?.texture===e&&this._textureRef.fadeFactor<1}get _elevationInfo(){const e=this.geometryState.samplerData,t=this.tile.layerInfo[x.ELEVATION],r=t.length,i=new Array(r);let s=0,o=0,a=!1;for(let d=0;d<r;d++){const r=t[d],n=r.upsampleInfo?.tile;if(n){const t=n.layerInfo[x.ELEVATION][d].data,r=t&&t.samplerData;e&&e[s]===r||(a=!0),i[s++]=r,o=Math.max(o,n.lij[0])}else if(r.data){const t=this.tile.surface.layerViewByIndex(d,x.ELEVATION);if(N(this.tile,t)){const t=r.data;e&&e[s]===t.samplerData||(a=!0),i[s++]=t.samplerData,o=this.tile.level}}}null!=e&&e.length!==s&&(a=!0);const n=s>0,l=n?i:null;return n&&(i.length=s),{changed:a,samplerData:l,maxTileLevel:o}}get estimatedGeometryMemoryUsage(){const 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(){if(!$)return;const e=this.tile;if(!e.loaded||!e.intersectsClippingArea||0===e.level)return void S(e?.loaded);const r=e.surface.extent;if(null!=r&&!e.intersectsExtent(r))return;const f=C.map(((t,i)=>null!=r&&(i<2?-1:1)*(e.extent[3-i]-r[3-i])<0)),p=e.level;S(0===this.dirtyCorners),S(0===this.dirtyEdges),S(0===this.dirtyEdgeResolutions),S(!this.numVerticesPerSideChanged),S(!this.samplerDataChanged),S(!this.clippingAreaChanged),S(!this.wireframeChanged);const y=b.map((t=>e.findNeighborCornerTileExact(t,(t=>!t.intersectsClippingArea||t.loaded||t.level===e.level))??null)).map((e=>e?.intersectsClippingArea?e:null)),x=this.geometryState;for(let t=0;t<4;++t){const r=x.cornerPeerNeighbors[t],i=y[t];S(i===r,`Tile[${e.lij}].corner[${t}] out of date: cur=[${r?.lij}] exp=[${i?.lij}]`)}C.forEach(((r,y)=>{if(f[y])return;const x=e.findNeighborTile(r,(e=>(e.level===p||e?.loaded)&&e?.intersectsClippingArea));if(!x){const t=!e.surface.updatingRootTiles&&null!=e.surface.rootTiles&&e.surface.rootTiles.length>0&&e.shouldHaveNeighbor(r);return void S(!t)}S(x.loaded||x.level===e.level),S(x===this.geometryState.edgePeerNeighbors[y]);const v=p-x.level;if(!x.loaded)return S(!x.leaf),void S(0===v);const E=x.renderData;S(e.isEdgeNeighbor(x,r)),S(v>=0);const $=2**v;if(v<0)return void S(!1);const C=e.renderData,D=C.geometry,b=C.localOrigin,R=D.getEdgeCount(y),A=D.numVerticesPerSide-1,V=E.geometry;if(!V)return void S(!1);const w=E.localOrigin,N=this.geometryState.edgePeerNeighbors[y];if(N?.loaded){const e=N.renderData;S(C.geometryState.edgePeerNeighborSamplerVersions[y]===e.geometryState.samplerDataVersion),S(this.geometryState.edgePeerNeighborSamplerVersions[y]===e.geometryState.samplerDataVersion)}const F=(y+2)%4,P=V.getEdgeCount(F),G=R-1,O=P-1;S(G*$===O,`Tile[${e.lij}]:e${y},res=${G} edgeRes mismatch with Neighbor[${x.lij}]:e${F},res=${O} (expected:${G*$})`);const I=e.extent,W=r===_.NORTH||r===_.SOUTH,q=P-1,z=q>>v,J=R-1;if(z<1)return void S(1===J);S(z===J),S(t(z));const K=V.numVerticesPerSide-1;S(v>0||z===Math.max(K,A));const Q=e.getNeighborEdgeStartVertexIndex(y,x);S(0<=Q&&Q<$);const Y=Q*z;S(0<=Y&&Y<=q-z);let Z=0,ee=Y;D.getEdgeVertexPosition(y,M,b,0),D.getEdgeVertexPosition(y,U,b,R-1);const te=i(M,U),re=Math.max(B,1e-4*te);for(let t=0;t<=z;++t){D.getEdgeVertexPosition(y,M,b,Z),V.getEdgeVertexPosition(F,U,w,ee);const i=t/z,f=W?I[0]+i*(I[2]-I[0]):r===_.WEST?I[0]:I[2],p=W?r===_.SOUTH?I[1]:I[3]:I[1]+i*(I[3]-I[1]),v=e.surface.extent;if(null==v||u(v,f,p)){const t=s(M,U),r=o(M)-c.radius,i=o(U)-c.radius,u=t<re;if(!u){console.warn(`Tile edge vertex position mismatch: between [${e.lij}].edge${y}[${Z}/${R}] and [${x.lij}].edge${F}[${ee}/${P}]`),null!=v&&console.warn(" surface extent= ",v," x,y=",f,",",p);const s=h();a(s,C.localOrigin,E.localOrigin),o(s)>0&&console.warn(` localOrigins: ${C.localOrigin} vs ${E.localOrigin} d=${o(s)} [${s}]`);(()=>{const t=m(M),r=m(U);e.updateEdgeElevations(),x.updateEdgeElevations(),D.getEdgeVertexPosition(y,M,b,Z),V.getEdgeVertexPosition(F,U,w,ee);const i=h();d(i,M,t),o(i)>0&&console.warn(` XXX Tile[${e.lij}] edge out of date: ${t} vs ${M} d=${o(i)} [${i}]`),d(i,U,r),o(i)>0&&console.warn(` XXX Neighbor[${x.lij}] edge out of date: ${r} vs ${U} d=${o(i)} [${i}]`)})();const n=D.getEdgeCount(y),l=V.getEdgeCount(P);S(u,`Mismatch in tile [${e.lij}].edge[${y}][${Z}/${n}] vs neighbor [${x.lij}].edge[${F}][${ee}/${l}] ${T(M)} vs ${T(U)} dist=${t} h(t|n|d)=${r}|${i}|${i-r}`)}D.getEdgeNormal(y,k,Z),V.getEdgeNormal(F,L,ee),n(H,k),n(X,L);const _=l(H,X),$=1-_<.01||!1||e===x;if(!$){const t=h();d(t,k,L);const r=()=>`Mismatch in tile edge normal ${j(e.lij)} (${Z}/${R-1}) edge ${y} vs neighbor ${j(x.lij)} (${ee}/${P-1}) nedge ${F} :${T(k)} vs ${T(L)} dot = ${_} : ${T(t)}`;console.warn("Mismatch in tile edge normal: ",r());{e.updateEdgeElevations(),x.updateEdgeElevations();const t=h(),r=h();D.getEdgeNormal(y,t,Z),V.getEdgeNormal(F,r,ee),g(k,t)||console.warn("Missing update in tile normal: ",T(k)," => ",T(t)),g(L,r)||console.warn("Missing update in neighbor normal: ",T(L)," => ",T(r))}S($,r())}}Z+=1,ee+=1}}))}}const M=h(),U=h(),k=h(),L=h(),H=h(),X=h(),B=1,W=[null,null,null,null];function q(e,t){return t?.loaded||t===e?t:null}const z=1,J=2,K=4,Q=8,Y=4,Z=8,ee=12,te=[0,1,2,3];export{A as ActivationTime,I as PatchRenderData,q as neighborTileIfLoadedOrSelf,te as zeroToFour};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../../../chunks/tslib.es6.js";import{invert as t,transpose as r}from"../../../../../../core/libs/gl-matrix-2/math/mat3.js";import{clone as o}from"../../../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{p as s,J as a}from"../../../../../../chunks/vec32.js";import{freeze as i,ZEROS as l}from"../../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{v as n}from"../../../../../../chunks/vec42.js";import{freeze as h,fromValues as u}from"../../../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{ColorMixModeEnum as p}from"../../../../layers/support/symbolColorUtils.js";import{OverlayContent as d}from"../../../../terrain/OverlayContent.js";import{ComponentTechnique as c}from"./ComponentTechnique.js";import{ComponentTechniqueConfiguration as m,IntegratedMeshMode as g}from"./ComponentTechniqueConfiguration.js";import{ComponentDataType as x}from"./shader/ComponentData.glsl.js";import{VertexDiscardMode as f}from"./shader/VertexDiscardMode.js";import{MaterialBase as v,parameter as b,parameterBlock as y,MaterialParameterBlock as M}from"../../../core/material/MaterialBase.js";import{RenderPassIdentifier as T}from"../../../core/renderPasses/AllRenderPasses.js";import{ShaderOutput as O}from"../../../core/shaderLibrary/ShaderOutput.js";import{NormalType as w}from"../../../core/shaderLibrary/attributes/NormalAttribute.glsl.js";import{EmissionSource as C}from"../../../core/shaderLibrary/output/Emissions.glsl.js";import{NormalsDoubleSidedMode as S}from"../../../core/shaderLibrary/shading/Normals.glsl.js";import{PBRMode as P}from"../../../core/shaderLibrary/shading/PhysicallyBasedRenderingParameters.glsl.js";import{alphaCutoff as N}from"../../../core/shaderLibrary/util/AlphaCutoff.js";import{EllipsoidMode as j}from"../../../core/shaderLibrary/util/EllipsoidMode.js";import{TwoVectorPosition as D}from"../../../core/util/TwoVectorPosition.js";import{AlphaDiscardMode as A,CullFaceOptions as q}from"../../../lib/basicInterfaces.js";import{OITPass as R}from"../../../lib/OITPass.js";import{advancedMRRFactors as F}from"../../../materials/pbrUtils.js";class I extends v{constructor(e,s){super(),this.toMapSpace=s,this.baseColor=h(1,1,1,1),this.usePBR=!1,this.hasParametersFromSource=!1,this.mrrFactors=F,this.emissiveFactor=i(0,0,0),this.baseColorTexture=null,this.metallicRoughnessTexture=null,this.emissionTexture=null,this.occlusionTexture=null,this.normalTexture=null,this.objectOpacity=1,this.commonMaterialParameters=new L,this.componentParameters=new k,this.textureAlphaCutoff=N,this.alphaDiscardMode=A.Opaque,this.isIntegratedMesh=!1,this.polygonOffsetEnabled=!1,this.ellipsoidMode=j.Earth,this.hasOccludees=!1;const a=new D(e.position),l=o(e.rotationScale);t(l,l),r(l,l),this.transformNormalGlobalFromModel=l,this.transformWorldFromModelTL=a.low,this.transformWorldFromModelTH=a.high,this.transformWorldFromModelRS=e.rotationScale}dispose(){this.baseColorTexture=null,this.metallicRoughnessTexture=null,this.emissionTexture=null,this.occlusionTexture=null,this.normalTexture=null}get texture(){return this.baseColorTexture?.glTexture}get textureMetallicRoughness(){return this.metallicRoughnessTexture?.glTexture}get textureEmissive(){return this.emissionTexture?.glTexture}get hasEmissions(){return null!=this.emissionTexture||!s(this.emissiveFactor,l)}get textureOcclusion(){return this.occlusionTexture?.glTexture}get textureNormal(){return this.normalTexture?.glTexture}acquireTechnique(e,t,r,o){const s=new m(e.context.spherical,e.context.doublePrecisionRequiresObfuscation);s.hasVertexColors=o.colors,s.hasNormals=o.hasNormals,s.textureCoordinateType=o.textureCoordinates,s.hasMetallicRoughnessTexture=null!=this.metallicRoughnessTexture,s.hasOcclusionTexture=null!=this.occlusionTexture,s.hasNormalTexture=null!=this.normalTexture,s.oitPass=t.identifier===T.Material&&null!=r.oitPass?r.oitPass:R.NONE,s.terrainDepthTest=t.identifier===T.Material&&r.terrainDepthTest,s.cullAboveTerrain=t.identifier===T.Material&&r.cullAboveTerrain,s.ellipsoidMode=this.ellipsoidMode,s.componentData=this.componentParameters.type,s.cullFace=this.commonMaterialParameters.cullFace,s.doubleSidedMode=this.commonMaterialParameters.doubleSided?S.View:S.None,s.hasColorTexture=null!=this.baseColorTexture;const a=this._computeWhichMaterialPass();if(s.blendingEnabled=a===E.Transparent||a===E.OpaqueAndTransparent,s.alphaDiscardMode=this.alphaDiscardMode,s.integratedMeshMode=this.isIntegratedMesh?_(r)?H(r)?g.ColorOverlayWithWater:g.ColorOverlay:g.NoOverlay:g.None,s.hasPolygonOffset=this.polygonOffsetEnabled,s.pbrMode=s.integratedMeshMode===g.ColorOverlayWithWater?P.WaterOnIntegratedMesh:this.usePBR?this.hasParametersFromSource?o.shadeNormals&&this.isIntegratedMesh?P.Disabled:P.Schematic:P.Normal:P.Disabled,s.emissionSource=null!=this.emissionTexture?C.Texture:s.pbrMode===P.Normal?C.Value:C.None,s.shadeNormals=o.shadeNormals,s.normalType=s.hasNormals?w.Compressed:w.ScreenDerivative,s.hasSlicePlane=null!=r.slicePlane&&this.commonMaterialParameters.hasSlicePlane,t.identifier===T.ShadowMap)s.output=O.Shadow,s.vertexDiscardMode=f.None;else if(t.identifier===T.ViewshedShadowMap)s.output=O.ViewshedShadow,s.vertexDiscardMode=f.None;else if(t.identifier===T.Highlight)s.output=O.Highlight,s.vertexDiscardMode=f.None;else{switch(a===E.OpaqueAndTransparent?s.vertexDiscardMode=t.transparent?f.Opaque:f.Transparent:s.vertexDiscardMode=f.None,s.output=t.output,s.receiveAmbientOcclusion=s.receiveShadows=!1,t.output){case O.Color:case O.ColorEmission:s.receiveAmbientOcclusion=o.applySSAO&&null!=r.ssao,s.hasOccludees=r.hasOccludees,s.receiveShadows=r.shadowMap.ready,s.screenSpaceReflections=null!=r.ssr.lastFrameColor,s.cloudReflections=null!=r.clouds.data;break;case O.ObjectAndLayerIdColor:s.objectAndLayerIdColor=!0}s.snowCover=this.hasSnowCover(r)}const i=e.get(c,s);return this._setClean(),i}hasSnowCover(e){return null!=e.weather&&e.weatherVisible&&"snowy"===e.weather.type&&"enabled"===e.weather.snowCover}submit(e,t,r){if(0===this.objectOpacity)return;const{componentData:o,renderable:s}=r,{geometry:a}=s,i=s.meta.cameraDepthSquared;o.updateHighlights(t.highlights);const{geometryRanges:l,highlightRangesMap:n,shadowmapRanges:h}=o;switch(this._computeWhichMaterialPass()){case E.Opaque:e.materialOpaque.submitDraw(this,a,l,i);break;case E.Transparent:e.materialTransparent.submitDraw(this,a,l,i);break;case E.OpaqueAndTransparent:e.materialOpaque.submitDraw(this,a,l,i),e.materialTransparent.submitDraw(this,a,l,i);break;case E.IntegratedMesh:e.materialIntegratedMesh.submitDraw(this,a,l,i),B(t)&&e.highlightIntegratedMesh.submitDraw(this,a,l,i)}const u=this.componentParameters.castShadows!==W.None;if(u&&e.shadowMap.submitDraw(this,a,l,i),null!=n)for(const p of n)e.highlight.submitDraw(this,a,p[1],i,p[0]),u&&e.highlightShadowMap.submitDraw(this,a,p[1],i,p[0]);t.viewshedEnabled&&e.viewshedShadowMap.submitDraw(this,a,l,i),u&&null!=h&&e.defaultShadowMap.submitDraw(this,a,h,i)}_computeWhichMaterialPass(){return this.isIntegratedMesh?E.IntegratedMesh:this.objectOpacity<1?E.Transparent:this.componentParameters.opaqueOverride===W.All?E.Opaque:this.baseColor[3]<1||this.alphaDiscardMode===A.Blend||this.alphaDiscardMode===A.MaskBlend?E.Transparent:this.componentParameters.transparent===W.None?E.Opaque:this.componentParameters.transparent===W.All?E.Transparent:E.OpaqueAndTransparent}}var E,W;e([b({vectorOps:n})],I.prototype,"baseColor",void 0),e([b()],I.prototype,"usePBR",void 0),e([b()],I.prototype,"hasParametersFromSource",void 0),e([b({vectorOps:a})],I.prototype,"mrrFactors",void 0),e([b({vectorOps:a})],I.prototype,"emissiveFactor",void 0),e([b({dispose:!0})],I.prototype,"baseColorTexture",void 0),e([b({dispose:!0})],I.prototype,"metallicRoughnessTexture",void 0),e([b({dispose:!0})],I.prototype,"emissionTexture",void 0),e([b({dispose:!0})],I.prototype,"occlusionTexture",void 0),e([b({dispose:!0})],I.prototype,"normalTexture",void 0),e([b()],I.prototype,"objectOpacity",void 0),e([y()],I.prototype,"commonMaterialParameters",void 0),e([y()],I.prototype,"componentParameters",void 0),e([b()],I.prototype,"textureAlphaCutoff",void 0),e([b()],I.prototype,"alphaDiscardMode",void 0),e([b()],I.prototype,"isIntegratedMesh",void 0),e([b()],I.prototype,"polygonOffsetEnabled",void 0),e([b()],I.prototype,"ellipsoidMode",void 0),e([b()],I.prototype,"hasOccludees",void 0),function(e){e[e.Opaque=0]="Opaque",e[e.Transparent=1]="Transparent",e[e.OpaqueAndTransparent=2]="OpaqueAndTransparent",e[e.IntegratedMesh=3]="IntegratedMesh"}(E||(E={}));class L extends M{constructor(){super(...arguments),this.doubleSided=!1,this.cullFace=q.Back,this.hasSlicePlane=!0}}e([b()],L.prototype,"doubleSided",void 0),e([b()],L.prototype,"cullFace",void 0),e([b()],L.prototype,"hasSlicePlane",void 0);class k extends M{constructor(){super(...arguments),this.externalColor=u(1,1,1,1),this.externalColorMixMode=p.Multiply,this.castShadows=W.All}get transparent(){return this.externalColor[3]<1?W.All:W.None}get opaqueOverride(){return this.externalColorMixMode===p.Replace&&1===this.externalColor[3]?W.All:W.None}get visible(){return this.externalColor[3]>0?W.All:W.None}get type(){return x.Uniform}}e([b({vectorOps:n})],k.prototype,"externalColor",void 0),e([b()],k.prototype,"externalColorMixMode",void 0),e([b()],k.prototype,"castShadows",void 0),function(e){e[e.All=0]="All",e[e.Some=1]="Some",e[e.None=2]="None"}(W||(W={}));class V extends M{constructor(){super(...arguments),this.texture=null,this.transparent=W.None,this.opaqueOverride=W.None,this.castShadows=W.None}get type(){return x.Varying}}function B(e){return null!=e.overlay?.getTexture(d.Highlight)}function H(e){return null!=e.overlay?.getTexture(d.WaterNormal)}function _(e){return null!=e.overlay?.getTexture(d.ColorNoRasterImage)}e([b()],V.prototype,"texture",void 0),e([b()],V.prototype,"transparent",void 0),e([b()],V.prototype,"opaqueOverride",void 0),e([b()],V.prototype,"castShadows",void 0);export{L as CommonMaterialParameters,I as ComponentMaterial,W as ComponentParameterSummary,k as ComponentParametersUniform,V as ComponentParametersVarying};
5
+ import{_ as e}from"../../../../../../chunks/tslib.es6.js";import{invert as t,transpose as r}from"../../../../../../core/libs/gl-matrix-2/math/mat3.js";import{clone as o}from"../../../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{p as s,J as a}from"../../../../../../chunks/vec32.js";import{freeze as i,ZEROS as l}from"../../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{v as n}from"../../../../../../chunks/vec42.js";import{freeze as h,fromValues as u}from"../../../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{ColorMixModeEnum as p}from"../../../../layers/support/symbolColorUtils.js";import{OverlayContent as d}from"../../../../terrain/OverlayContent.js";import{ComponentTechnique as c}from"./ComponentTechnique.js";import{ComponentTechniqueConfiguration as m,IntegratedMeshMode as g}from"./ComponentTechniqueConfiguration.js";import{ComponentDataType as x}from"./shader/ComponentData.glsl.js";import{VertexDiscardMode as f}from"./shader/VertexDiscardMode.js";import{MaterialBase as v,parameter as b,parameterBlock as M,MaterialParameterBlock as y}from"../../../core/material/MaterialBase.js";import{RenderPassIdentifier as T}from"../../../core/renderPasses/AllRenderPasses.js";import{ShaderOutput as w}from"../../../core/shaderLibrary/ShaderOutput.js";import{NormalType as O}from"../../../core/shaderLibrary/attributes/NormalAttribute.glsl.js";import{EmissionSource as C}from"../../../core/shaderLibrary/output/Emissions.glsl.js";import{NormalsDoubleSidedMode as S}from"../../../core/shaderLibrary/shading/Normals.glsl.js";import{PBRMode as P}from"../../../core/shaderLibrary/shading/PhysicallyBasedRenderingParameters.glsl.js";import{EllipsoidMode as N}from"../../../core/shaderLibrary/util/EllipsoidMode.js";import{TwoVectorPosition as j}from"../../../core/util/TwoVectorPosition.js";import{AlphaDiscardMode as D,CullFaceOptions as A}from"../../../lib/basicInterfaces.js";import{OITPass as q}from"../../../lib/OITPass.js";import{advancedMRRFactors as R}from"../../../materials/pbrUtils.js";import{alphaCutoff as F}from"../../../../../../webscene/support/AlphaCutoff.js";class I extends v{constructor(e,s){super(),this.toMapSpace=s,this.baseColor=h(1,1,1,1),this.usePBR=!1,this.hasParametersFromSource=!1,this.mrrFactors=R,this.emissiveFactor=i(0,0,0),this.baseColorTexture=null,this.metallicRoughnessTexture=null,this.emissionTexture=null,this.occlusionTexture=null,this.normalTexture=null,this.objectOpacity=1,this.commonMaterialParameters=new k,this.componentParameters=new L,this.textureAlphaCutoff=F,this.alphaDiscardMode=D.Opaque,this.isIntegratedMesh=!1,this.polygonOffsetEnabled=!1,this.ellipsoidMode=N.Earth,this.hasOccludees=!1;const a=new j(e.position),l=o(e.rotationScale);t(l,l),r(l,l),this.transformNormalGlobalFromModel=l,this.transformWorldFromModelTL=a.low,this.transformWorldFromModelTH=a.high,this.transformWorldFromModelRS=e.rotationScale}dispose(){this.baseColorTexture=null,this.metallicRoughnessTexture=null,this.emissionTexture=null,this.occlusionTexture=null,this.normalTexture=null}get texture(){return this.baseColorTexture?.glTexture}get textureMetallicRoughness(){return this.metallicRoughnessTexture?.glTexture}get textureEmissive(){return this.emissionTexture?.glTexture}get hasEmissions(){return null!=this.emissionTexture||!s(this.emissiveFactor,l)}get textureOcclusion(){return this.occlusionTexture?.glTexture}get textureNormal(){return this.normalTexture?.glTexture}acquireTechnique(e,t,r,o){const s=new m(e.context.spherical,e.context.doublePrecisionRequiresObfuscation);s.hasVertexColors=o.colors,s.hasNormals=o.hasNormals,s.textureCoordinateType=o.textureCoordinates,s.hasMetallicRoughnessTexture=null!=this.metallicRoughnessTexture,s.hasOcclusionTexture=null!=this.occlusionTexture,s.hasNormalTexture=null!=this.normalTexture,s.oitPass=t.identifier===T.Material&&null!=r.oitPass?r.oitPass:q.NONE,s.terrainDepthTest=t.identifier===T.Material&&r.terrainDepthTest,s.cullAboveTerrain=t.identifier===T.Material&&r.cullAboveTerrain,s.ellipsoidMode=this.ellipsoidMode,s.componentData=this.componentParameters.type,s.cullFace=this.commonMaterialParameters.cullFace,s.doubleSidedMode=this.commonMaterialParameters.doubleSided?S.View:S.None,s.hasColorTexture=null!=this.baseColorTexture;const a=this._computeWhichMaterialPass();if(s.blendingEnabled=a===E.Transparent||a===E.OpaqueAndTransparent,s.alphaDiscardMode=this.alphaDiscardMode,s.integratedMeshMode=this.isIntegratedMesh?_(r)?H(r)?g.ColorOverlayWithWater:g.ColorOverlay:g.NoOverlay:g.None,s.hasPolygonOffset=this.polygonOffsetEnabled,s.pbrMode=s.integratedMeshMode===g.ColorOverlayWithWater?P.WaterOnIntegratedMesh:this.usePBR?this.hasParametersFromSource?o.shadeNormals&&this.isIntegratedMesh?P.Disabled:P.Schematic:P.Normal:P.Disabled,s.emissionSource=null!=this.emissionTexture?C.Texture:s.pbrMode===P.Normal?C.Value:C.None,s.shadeNormals=o.shadeNormals,s.normalType=s.hasNormals?O.Compressed:O.ScreenDerivative,s.hasSlicePlane=null!=r.slicePlane&&this.commonMaterialParameters.hasSlicePlane,t.identifier===T.ShadowMap)s.output=w.Shadow,s.vertexDiscardMode=f.None;else if(t.identifier===T.ViewshedShadowMap)s.output=w.ViewshedShadow,s.vertexDiscardMode=f.None;else if(t.identifier===T.Highlight)s.output=w.Highlight,s.vertexDiscardMode=f.None;else{switch(a===E.OpaqueAndTransparent?s.vertexDiscardMode=t.transparent?f.Opaque:f.Transparent:s.vertexDiscardMode=f.None,s.output=t.output,s.receiveAmbientOcclusion=s.receiveShadows=!1,t.output){case w.Color:case w.ColorEmission:s.receiveAmbientOcclusion=o.applySSAO&&null!=r.ssao,s.hasOccludees=r.hasOccludees,s.receiveShadows=r.shadowMap.ready,s.screenSpaceReflections=null!=r.ssr.lastFrameColor,s.cloudReflections=null!=r.clouds.data;break;case w.ObjectAndLayerIdColor:s.objectAndLayerIdColor=!0}s.snowCover=this.hasSnowCover(r)}const i=e.get(c,s);return this._setClean(),i}hasSnowCover(e){return null!=e.weather&&e.weatherVisible&&"snowy"===e.weather.type&&"enabled"===e.weather.snowCover}submit(e,t,r){if(0===this.objectOpacity)return;const{componentData:o,renderable:s}=r,{geometry:a}=s,i=s.meta.cameraDepthSquared;o.updateHighlights(t.highlights);const{geometryRanges:l,highlightRangesMap:n,shadowmapRanges:h}=o;switch(this._computeWhichMaterialPass()){case E.Opaque:e.materialOpaque.submitDraw(this,a,l,i);break;case E.Transparent:e.materialTransparent.submitDraw(this,a,l,i);break;case E.OpaqueAndTransparent:e.materialOpaque.submitDraw(this,a,l,i),e.materialTransparent.submitDraw(this,a,l,i);break;case E.IntegratedMesh:e.materialIntegratedMesh.submitDraw(this,a,l,i),B(t)&&e.highlightIntegratedMesh.submitDraw(this,a,l,i)}const u=this.componentParameters.castShadows!==W.None;if(u&&e.shadowMap.submitDraw(this,a,l,i),null!=n)for(const p of n)e.highlight.submitDraw(this,a,p[1],i,p[0]),u&&e.highlightShadowMap.submitDraw(this,a,p[1],i,p[0]);t.viewshedEnabled&&e.viewshedShadowMap.submitDraw(this,a,l,i),u&&null!=h&&e.defaultShadowMap.submitDraw(this,a,h,i)}_computeWhichMaterialPass(){return this.isIntegratedMesh?E.IntegratedMesh:this.objectOpacity<1?E.Transparent:this.componentParameters.opaqueOverride===W.All?E.Opaque:this.baseColor[3]<1||this.alphaDiscardMode===D.Blend||this.alphaDiscardMode===D.MaskBlend?E.Transparent:this.componentParameters.transparent===W.None?E.Opaque:this.componentParameters.transparent===W.All?E.Transparent:E.OpaqueAndTransparent}}var E,W;e([b({vectorOps:n})],I.prototype,"baseColor",void 0),e([b()],I.prototype,"usePBR",void 0),e([b()],I.prototype,"hasParametersFromSource",void 0),e([b({vectorOps:a})],I.prototype,"mrrFactors",void 0),e([b({vectorOps:a})],I.prototype,"emissiveFactor",void 0),e([b({dispose:!0})],I.prototype,"baseColorTexture",void 0),e([b({dispose:!0})],I.prototype,"metallicRoughnessTexture",void 0),e([b({dispose:!0})],I.prototype,"emissionTexture",void 0),e([b({dispose:!0})],I.prototype,"occlusionTexture",void 0),e([b({dispose:!0})],I.prototype,"normalTexture",void 0),e([b()],I.prototype,"objectOpacity",void 0),e([M()],I.prototype,"commonMaterialParameters",void 0),e([M()],I.prototype,"componentParameters",void 0),e([b()],I.prototype,"textureAlphaCutoff",void 0),e([b()],I.prototype,"alphaDiscardMode",void 0),e([b()],I.prototype,"isIntegratedMesh",void 0),e([b()],I.prototype,"polygonOffsetEnabled",void 0),e([b()],I.prototype,"ellipsoidMode",void 0),e([b()],I.prototype,"hasOccludees",void 0),function(e){e[e.Opaque=0]="Opaque",e[e.Transparent=1]="Transparent",e[e.OpaqueAndTransparent=2]="OpaqueAndTransparent",e[e.IntegratedMesh=3]="IntegratedMesh"}(E||(E={}));class k extends y{constructor(){super(...arguments),this.doubleSided=!1,this.cullFace=A.Back,this.hasSlicePlane=!0}}e([b()],k.prototype,"doubleSided",void 0),e([b()],k.prototype,"cullFace",void 0),e([b()],k.prototype,"hasSlicePlane",void 0);class L extends y{constructor(){super(...arguments),this.externalColor=u(1,1,1,1),this.externalColorMixMode=p.Multiply,this.castShadows=W.All}get transparent(){return this.externalColor[3]<1?W.All:W.None}get opaqueOverride(){return this.externalColorMixMode===p.Replace&&1===this.externalColor[3]?W.All:W.None}get visible(){return this.externalColor[3]>0?W.All:W.None}get type(){return x.Uniform}}e([b({vectorOps:n})],L.prototype,"externalColor",void 0),e([b()],L.prototype,"externalColorMixMode",void 0),e([b()],L.prototype,"castShadows",void 0),function(e){e[e.All=0]="All",e[e.Some=1]="Some",e[e.None=2]="None"}(W||(W={}));class V extends y{constructor(){super(...arguments),this.texture=null,this.transparent=W.None,this.opaqueOverride=W.None,this.castShadows=W.None}get type(){return x.Varying}}function B(e){return null!=e.overlay?.getTexture(d.Highlight)}function H(e){return null!=e.overlay?.getTexture(d.WaterNormal)}function _(e){return null!=e.overlay?.getTexture(d.ColorNoRasterImage)}e([b()],V.prototype,"texture",void 0),e([b()],V.prototype,"transparent",void 0),e([b()],V.prototype,"opaqueOverride",void 0),e([b()],V.prototype,"castShadows",void 0);export{k as CommonMaterialParameters,I as ComponentMaterial,W as ComponentParameterSummary,L as ComponentParametersUniform,V as ComponentParametersVarying};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import"../../../../../../../geometry/support/Ellipsoid.js";import"../../../../../terrain/OverlayContent.js";import"../ComponentTechniqueConfiguration.js";import"./ComponentData.glsl.js";import"./VertexDiscardMode.js";import"../../../../core/shaderLibrary/ForwardLinearDepth.glsl.js";import"../../../../core/shaderLibrary/ShaderOutput.js";import"../../../../core/shaderLibrary/Slice.glsl.js";import"../../../../core/shaderLibrary/attributes/TextureCoordinateAttribute.glsl.js";import"../../../../core/shaderLibrary/attributes/VertexColor.glsl.js";import"../../../../core/shaderLibrary/attributes/VertexNormal.glsl.js";import"../../../../core/shaderLibrary/attributes/VertexPosition.glsl.js";import"../../../../core/shaderLibrary/output/OutputDepth.glsl.js";import"../../../../core/shaderLibrary/output/OutputHighlight.glsl.js";import"../../../../core/shaderLibrary/shading/ComputeFragmentNormals.glsl.js";import"../../../../core/shaderLibrary/shading/ComputeMaterialColor.glsl.js";import"../../../../core/shaderLibrary/shading/ComputeNormalTexture.glsl.js";import"../../../../core/shaderLibrary/shading/EvaluateSceneLighting.glsl.js";import"../../../../core/shaderLibrary/shading/MainLighting.glsl.js";import"../../../../core/shaderLibrary/shading/PhysicallyBasedRenderingParameters.glsl.js";import"../../../../core/shaderLibrary/shading/ReadBaseColorTexture.glsl.js";import"../../../../core/shaderLibrary/shading/ReadShadowMap.glsl.js";import"../../../../core/shaderLibrary/shading/TerrainDepthTest.glsl.js";import"../../../../core/shaderLibrary/terrain/Overlay.glsl.js";import"../../../../core/shaderLibrary/util/AlphaCutoff.js";import"../../../../core/shaderLibrary/util/DiscardOrAdjustAlpha.glsl.js";import"../../../../core/shaderLibrary/util/EllipsoidMode.js";import"../../../../core/shaderModules/glsl.js";import"../../../../core/shaderModules/Texture2DBindUniform.js";import"../../../../core/shaderModules/Texture2DPassUniform.js";import"../../../../shaders/OutputColorHighlightOID.glsl.js";import"../../../../../../webgl/ShaderBuilder.js";export{b as build}from"../../../../../../../chunks/ComponentShader.glsl.js";
5
+ import"../../../../../../../geometry/support/Ellipsoid.js";import"../../../../../terrain/OverlayContent.js";import"../ComponentTechniqueConfiguration.js";import"./ComponentData.glsl.js";import"./VertexDiscardMode.js";import"../../../../core/shaderLibrary/ForwardLinearDepth.glsl.js";import"../../../../core/shaderLibrary/ShaderOutput.js";import"../../../../core/shaderLibrary/Slice.glsl.js";import"../../../../core/shaderLibrary/attributes/TextureCoordinateAttribute.glsl.js";import"../../../../core/shaderLibrary/attributes/VertexColor.glsl.js";import"../../../../core/shaderLibrary/attributes/VertexNormal.glsl.js";import"../../../../core/shaderLibrary/attributes/VertexPosition.glsl.js";import"../../../../core/shaderLibrary/output/OutputDepth.glsl.js";import"../../../../core/shaderLibrary/output/OutputHighlight.glsl.js";import"../../../../core/shaderLibrary/shading/ComputeFragmentNormals.glsl.js";import"../../../../core/shaderLibrary/shading/ComputeMaterialColor.glsl.js";import"../../../../core/shaderLibrary/shading/ComputeNormalTexture.glsl.js";import"../../../../core/shaderLibrary/shading/EvaluateSceneLighting.glsl.js";import"../../../../core/shaderLibrary/shading/MainLighting.glsl.js";import"../../../../core/shaderLibrary/shading/PhysicallyBasedRenderingParameters.glsl.js";import"../../../../core/shaderLibrary/shading/ReadBaseColorTexture.glsl.js";import"../../../../core/shaderLibrary/shading/ReadShadowMap.glsl.js";import"../../../../core/shaderLibrary/shading/TerrainDepthTest.glsl.js";import"../../../../core/shaderLibrary/terrain/Overlay.glsl.js";import"../../../../core/shaderLibrary/util/DiscardOrAdjustAlpha.glsl.js";import"../../../../core/shaderLibrary/util/EllipsoidMode.js";import"../../../../core/shaderModules/glsl.js";import"../../../../core/shaderModules/Texture2DBindUniform.js";import"../../../../core/shaderModules/Texture2DPassUniform.js";import"../../../../shaders/OutputColorHighlightOID.glsl.js";import"../../../../../../webgl/ShaderBuilder.js";import"../../../../../../../webscene/support/AlphaCutoff.js";export{b as build}from"../../../../../../../chunks/ComponentShader.glsl.js";
@@ -2,8 +2,8 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{alphaCutoff as o}from"./AlphaCutoff.js";import{FloatDrawUniform as r}from"../../shaderModules/FloatDrawUniform.js";import{FloatPassUniform as t}from"../../shaderModules/FloatPassUniform.js";import{glsl as a,If as e}from"../../shaderModules/glsl.js";import{AlphaDiscardMode as f}from"../../../lib/basicInterfaces.js";function s(o,r){d(o,r,new t("textureAlphaCutoff",(o=>o.textureAlphaCutoff)))}function l(o,t){d(o,t,new r("textureAlphaCutoff",(o=>o.textureAlphaCutoff)))}function d(r,t,s){const l=r.fragment,d=t.alphaDiscardMode,u=d===f.Blend;d!==f.Mask&&d!==f.MaskBlend||l.uniforms.add(s),l.code.add(a`
5
+ import{FloatDrawUniform as o}from"../../shaderModules/FloatDrawUniform.js";import{FloatPassUniform as r}from"../../shaderModules/FloatPassUniform.js";import{glsl as t,If as e}from"../../shaderModules/glsl.js";import{AlphaDiscardMode as a}from"../../../lib/basicInterfaces.js";import{alphaCutoff as s}from"../../../../../../webscene/support/AlphaCutoff.js";function f(o,t){u(o,t,new r("textureAlphaCutoff",(o=>o.textureAlphaCutoff)))}function l(r,t){u(r,t,new o("textureAlphaCutoff",(o=>o.textureAlphaCutoff)))}function u(o,r,f){const l=o.fragment,u=r.alphaDiscardMode,d=u===a.Blend;u!==a.Mask&&u!==a.MaskBlend||l.uniforms.add(f),l.code.add(t`
6
6
  void discardOrAdjustAlpha(inout vec4 color) {
7
- ${d===f.Opaque?"color.a = 1.0;":`if (color.a < ${u?a.float(o):"textureAlphaCutoff"}) {\n discard;\n } ${e(d===f.Mask,"else { color.a = 1.0; }")}`}
7
+ ${u===a.Opaque?"color.a = 1.0;":`if (color.a < ${d?t.float(s):"textureAlphaCutoff"}) {\n discard;\n } ${e(u===a.Mask,"else { color.a = 1.0; }")}`}
8
8
  }
9
- `)}export{l as DiscardOrAdjustAlphaDraw,s as DiscardOrAdjustAlphaPass};
9
+ `)}export{l as DiscardOrAdjustAlphaDraw,f as DiscardOrAdjustAlphaPass};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../../chunks/tslib.es6.js";import{property as r}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/has.js";import"../../../../../core/Logger.js";import"../../../../../core/RandomLCG.js";import{subclass as o}from"../../../../../core/accessorSupport/decorators/subclass.js";import{ZEROS as t}from"../../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{RenderCategory as n}from"../../../webgl.js";import{ColorFormat as i}from"../../../webgl/formats.js";import s from"../../../webgl/RenderNode.js";import{alphaCutoff as c}from"../../core/shaderLibrary/util/AlphaCutoff.js";import{If as a,glsl as l}from"../../core/shaderModules/glsl.js";import{Default3D as u}from"../../lib/DefaultVertexAttributeLocations.js";import{FramebufferBit as h,ColorAttachment as p,BlendFactor as d,SizedPixelFormat as f,PixelFormat as m,DataType as v}from"../../../../webgl/enums.js";let x=class extends s{constructor(e){super(e),this.destroyedCB=null,this.produces=n.FINAL,this.consumes={required:[n.FINAL]},this.clearColor=t,this._focusedFBOType=0,this._program=new Map}destroy(){this._program.forEach((e=>e.dispose())),this._program.clear(),this.destroyedCB()}render(e){const r=e.find((({name:e})=>e===n.FINAL));if(!this._focusedFBO)return r;const o=this.renderingContext;o.bindFramebuffer(r.fbo),o.setClearColor(0,0,0,0),o.clear(h.COLOR);const t=this._ensureShader(o,!1,0);return o.useProgram(t),o.bindTexture(this._focusedFBO.getTexture(),0),t.setUniform1i("colorTex",0),t.setUniform1i("inputType",this._focusedFBOType),3===this._focusedFBOType&&t.setUniform2fv("nearFar",this.camera.nearFar),o.screen.draw(),r}getDownscaledFBO(e,r,o,t,n,s){o===g.ON&&(n=e.width,s=e.height);const c=this.renderingContext,{colorTexture:a,depthStencilTexture:l}=e,u=a?.descriptor,m=this._ensureShader(c,null!=l,r),v=this.fboCache.acquire(n,s,"fbo visualizer"),x=!u?.hasMipmap&&!u?.isImmutable;x&&a?.generateMipmap(),c.useProgram(m),c.bindFramebuffer(v.fbo);let T=0;const F=[p.COLOR_ATTACHMENT0],C=null!=l;if(c.bindTexture(a,T),m.setUniform1i("colorTex",T),l){T++,c.bindTexture(l,T),m.setUniform1i("depthTex",T);const e=p.COLOR_ATTACHMENT0+T;v.acquireColor(e,i.RGBA,"depth to color"),F.push(e)}for(let h=0;h<r;h++){T++;const r=p.COLOR_ATTACHMENT0+T,o=C?1:0;c.bindTexture(e.getColorTexture(r-o),T),m.setUniform1i("colorTex"+(T-o-1),T),v.acquireColor(r,i.RGBA),F.push(r)}c.gl.drawBuffers(F);const b=c.getViewport();c.setViewport(0,0,n,s),c.setClearColor(0,0,0,0),c.clear(h.COLOR),c.setBlendingEnabled(!0),c.setBlendFunction(d.ONE,d.ONE_MINUS_SRC_ALPHA);const O="linear-depth"===t||t.includes("shadow"),_="overlay highlight"===t||"highlights"===t||"highlight mix"===t,y="highlight coverage"===t,A=u?.internalFormat,B=O?3:_?5:y?6:A===f.R16F||A===f.R32F||A===f.R8?1:A===f.RG8?2:A===f.RGBA16F?4:0;return m.setUniform1i("inputType",B),O&&m.setUniform2fv("nearFar",this.camera.nearFar),c.screen.draw(),c.bindFramebuffer(null),c.setViewport(b.x,b.y,b.width,b.height),o===g.ON&&(this._focusedFBO=v,this._focusedFBOType=B),x&&e.colorTexture?.clearMipmap(),v}clearFocusedFBO(){this._focusedFBO=null}getPreviewContent(e,r,o,t){if(!o)return null;const n=this.renderingContext,i=this.fboCache.acquire(e,r,"fbo visualizer");n.bindFramebuffer(i?.fbo),n.setClearColor(this.clearColor[0],this.clearColor[1],this.clearColor[2],this.clearColor[3]),n.clear(h.COLOR),n.setBlendingEnabled(!0),n.setBlendFunction(d.ONE,d.ONE_MINUS_SRC_ALPHA),n.setViewport(0,0,e,r);const s=this._ensureShader(n,!1,0);n.useProgram(s),n.bindTexture(o.getColorTexture(t),0),s.setUniform1i("colorTex",0),s.setUniform1i("inputType",0),n.screen.draw();const c=new ImageData(new Uint8ClampedArray(e*r*4),e,r);return n.gl.readPixels(0,0,e,r,m.RGBA,v.UNSIGNED_BYTE,new Uint8Array(c.data.buffer)),n.bindFramebuffer(null),i?.release(),c}_ensureShader(e,r,o){const t={hasDepth:r,attachments:o},n=this._program.get(t);if(n)return n;const i="#version 300 es\n in vec2 position;\n out vec2 uv;\n\n void main() {\n gl_Position = vec4(position, 0.0, 1.0);\n uv = position * 0.5 + vec2(0.5);\n }",s=(e,r)=>{let o="";const t=e?2:1;for(let n=0;n<r;n++)o+=`layout(location = ${l.int(t+n)}) out vec4 fragColor${l.int(n)};\n uniform sampler2D colorTex${l.int(n)};`;return o},h=e=>{let r="";for(let o=0;o<e;o++)r+=`fragColor${l.int(o)} = texture(colorTex${l.int(o)}, uv);`;return r},p=`#version 300 es\n precision highp float;\n\n in vec2 uv;\n uniform sampler2D colorTex;\n layout(location = 0) out vec4 fragColor;\n ${a(r,"layout(location = 1) out vec4 fragDepth;\n uniform sampler2D depthTex;")}\n ${s(r,o)}\n uniform int inputType;\n uniform vec2 nearFar;\n\n // Factors to convert rgba back to float\n const vec4 RGBA_2_FLOAT_FACTORS = vec4(\n 255.0 / (256.0),\n 255.0 / (256.0 * 256.0),\n 255.0 / (256.0 * 256.0 * 256.0),\n 255.0 / (256.0 * 256.0 * 256.0 * 256.0)\n );\n\n\n float rgbaTofloat(vec4 rgba) {\n // Convert components from 0->1 back to 0->255 and then add the components together with their corresponding\n // fixed point factors, i.e. (256^1, 256^2, 256^3, 256^4)\n return dot(rgba, RGBA_2_FLOAT_FACTORS);\n }\n\n float linearDepthFromFloat(float depth) {\n depth = pow(depth, 0.2);\n return -(depth * (nearFar[1] - nearFar[0]) + nearFar[0]);\n }\n\n float linearDepthFromRGBA(vec4 depth) {\n return linearDepthFromFloat(rgbaTofloat(depth));\n }\n\n float linearDepthFromTexture(sampler2D depthTex, vec2 uv) {\n ivec2 iuv = ivec2(uv * vec2(textureSize(depthTex, 0)));\n return linearDepthFromRGBA(texelFetch(depthTex, iuv, 0));\n }\n\n void main() {\n vec4 color;\n if(inputType == 1) {\n color = vec4(vec3(texture(colorTex, uv).r), 1.0);\n } else if(inputType == 2) {\n color = vec4(texture(colorTex, uv).rg, 0.0, 1.0);\n } else if(inputType == 3) {\n float depth = 1.0 - ((-linearDepthFromTexture(colorTex, uv) - nearFar[0]) / (nearFar[1] - nearFar[0]));\n color = vec4(vec3(depth), depth >= 0.999 ? 0.0 : 1.0);\n } else if(inputType == 4) {\n color = texture(colorTex, uv);\n color = vec4(color.rgb / color.a, color.a);\n } else if(inputType == 5) {\n vec2 texDim = vec2(textureSize(colorTex, 0));\n ivec2 iuv = ivec2(uv*texDim);\n vec2 hh = texelFetch(colorTex,iuv,0).rg;\n uvec2 uhh = uvec2(vec2(hh) * 255.0);\n color = vec4(\n ((uhh.x & 0x3u) != 0u) ? 1.0 : 0.0,\n ((uhh.x & 0xcu) != 0u) ? 1.0 : 0.0,\n ((uhh.y & 0xfu) != 0u) ? 1.0 : 0.0,\n 1.0);\n } else if(inputType == 6) {\n vec2 texDim = vec2(textureSize(colorTex, 0));\n ivec2 iuv = ivec2(uv*texDim);\n uvec2 hh = uvec2(texelFetch(colorTex,iuv,0).rg * 255.0);\n color = vec4(\n ((hh & uvec2(0x55u)) != uvec2(0u)) ? 1.0 : 0.0,\n ((hh & uvec2(0xaau)) != uvec2(0u)) ? 1.0 : 0.0,\n 0.0,\n 1.0);\n } else {\n color = texture(colorTex, uv);\n }\n\n\n if(color.a < ${l.float(c)})\n discard;\n else {\n fragColor = color;\n ${a(r,"float depth = 1.0 - pow(texture(depthTex, uv).r, 10.0);\n fragDepth = vec4(vec3(depth), depth < 0.000001 ? 0.0 : 1.0);")}\n ${a(o>0,h(o))}\n }\n }`;return this._program.set(t,e.programCache.acquire(i,p,u)),this._program.get(t)}};var g;e([r()],x.prototype,"destroyedCB",void 0),e([r()],x.prototype,"produces",void 0),e([r()],x.prototype,"consumes",void 0),e([r()],x.prototype,"clearColor",void 0),x=e([o("esri.views.3d.webgl-engine.effects.debug.RenderNodeVisualizerNode")],x),function(e){e[e.ON=0]="ON",e[e.OFF=1]="OFF"}(g||(g={}));export{g as FocusState,x as RenderNodeVisualizerNode};
5
+ import{_ as e}from"../../../../../chunks/tslib.es6.js";import{property as r}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/has.js";import"../../../../../core/Logger.js";import"../../../../../core/RandomLCG.js";import{subclass as o}from"../../../../../core/accessorSupport/decorators/subclass.js";import{ZEROS as t}from"../../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{RenderCategory as n}from"../../../webgl.js";import{ColorFormat as i}from"../../../webgl/formats.js";import s from"../../../webgl/RenderNode.js";import{If as c,glsl as a}from"../../core/shaderModules/glsl.js";import{Default3D as l}from"../../lib/DefaultVertexAttributeLocations.js";import{FramebufferBit as u,ColorAttachment as h,BlendFactor as p,SizedPixelFormat as d,PixelFormat as f,DataType as m}from"../../../../webgl/enums.js";import{alphaCutoff as v}from"../../../../../webscene/support/AlphaCutoff.js";let x=class extends s{constructor(e){super(e),this.destroyedCB=null,this.produces=n.FINAL,this.consumes={required:[n.FINAL]},this.clearColor=t,this._focusedFBOType=0,this._program=new Map}destroy(){this._program.forEach((e=>e.dispose())),this._program.clear(),this.destroyedCB()}render(e){const r=e.find((({name:e})=>e===n.FINAL));if(!this._focusedFBO)return r;const o=this.renderingContext;o.bindFramebuffer(r.fbo),o.setClearColor(0,0,0,0),o.clear(u.COLOR);const t=this._ensureShader(o,!1,0);return o.useProgram(t),o.bindTexture(this._focusedFBO.getTexture(),0),t.setUniform1i("colorTex",0),t.setUniform1i("inputType",this._focusedFBOType),3===this._focusedFBOType&&t.setUniform2fv("nearFar",this.camera.nearFar),o.screen.draw(),r}getDownscaledFBO(e,r,o,t,n,s){o===g.ON&&(n=e.width,s=e.height);const c=this.renderingContext,{colorTexture:a,depthStencilTexture:l}=e,f=a?.descriptor,m=this._ensureShader(c,null!=l,r),v=this.fboCache.acquire(n,s,"fbo visualizer"),x=!f?.hasMipmap&&!f?.isImmutable;x&&a?.generateMipmap(),c.useProgram(m),c.bindFramebuffer(v.fbo);let T=0;const F=[h.COLOR_ATTACHMENT0],C=null!=l;if(c.bindTexture(a,T),m.setUniform1i("colorTex",T),l){T++,c.bindTexture(l,T),m.setUniform1i("depthTex",T);const e=h.COLOR_ATTACHMENT0+T;v.acquireColor(e,i.RGBA,"depth to color"),F.push(e)}for(let u=0;u<r;u++){T++;const r=h.COLOR_ATTACHMENT0+T,o=C?1:0;c.bindTexture(e.getColorTexture(r-o),T),m.setUniform1i("colorTex"+(T-o-1),T),v.acquireColor(r,i.RGBA),F.push(r)}c.gl.drawBuffers(F);const b=c.getViewport();c.setViewport(0,0,n,s),c.setClearColor(0,0,0,0),c.clear(u.COLOR),c.setBlendingEnabled(!0),c.setBlendFunction(p.ONE,p.ONE_MINUS_SRC_ALPHA);const O="linear-depth"===t||t.includes("shadow"),_="overlay highlight"===t||"highlights"===t||"highlight mix"===t,y="highlight coverage"===t,A=f?.internalFormat,w=O?3:_?5:y?6:A===d.R16F||A===d.R32F||A===d.R8?1:A===d.RG8?2:A===d.RGBA16F?4:0;return m.setUniform1i("inputType",w),O&&m.setUniform2fv("nearFar",this.camera.nearFar),c.screen.draw(),c.bindFramebuffer(null),c.setViewport(b.x,b.y,b.width,b.height),o===g.ON&&(this._focusedFBO=v,this._focusedFBOType=w),x&&e.colorTexture?.clearMipmap(),v}clearFocusedFBO(){this._focusedFBO=null}getPreviewContent(e,r,o,t){if(!o)return null;const n=this.renderingContext,i=this.fboCache.acquire(e,r,"fbo visualizer");n.bindFramebuffer(i?.fbo),n.setClearColor(this.clearColor[0],this.clearColor[1],this.clearColor[2],this.clearColor[3]),n.clear(u.COLOR),n.setBlendingEnabled(!0),n.setBlendFunction(p.ONE,p.ONE_MINUS_SRC_ALPHA),n.setViewport(0,0,e,r);const s=this._ensureShader(n,!1,0);n.useProgram(s),n.bindTexture(o.getColorTexture(t),0),s.setUniform1i("colorTex",0),s.setUniform1i("inputType",0),n.screen.draw();const c=new ImageData(new Uint8ClampedArray(e*r*4),e,r);return n.gl.readPixels(0,0,e,r,f.RGBA,m.UNSIGNED_BYTE,new Uint8Array(c.data.buffer)),n.bindFramebuffer(null),i?.release(),c}_ensureShader(e,r,o){const t={hasDepth:r,attachments:o},n=this._program.get(t);if(n)return n;const i="#version 300 es\n in vec2 position;\n out vec2 uv;\n\n void main() {\n gl_Position = vec4(position, 0.0, 1.0);\n uv = position * 0.5 + vec2(0.5);\n }",s=(e,r)=>{let o="";const t=e?2:1;for(let n=0;n<r;n++)o+=`layout(location = ${a.int(t+n)}) out vec4 fragColor${a.int(n)};\n uniform sampler2D colorTex${a.int(n)};`;return o},u=e=>{let r="";for(let o=0;o<e;o++)r+=`fragColor${a.int(o)} = texture(colorTex${a.int(o)}, uv);`;return r},h=`#version 300 es\n precision highp float;\n\n in vec2 uv;\n uniform sampler2D colorTex;\n layout(location = 0) out vec4 fragColor;\n ${c(r,"layout(location = 1) out vec4 fragDepth;\n uniform sampler2D depthTex;")}\n ${s(r,o)}\n uniform int inputType;\n uniform vec2 nearFar;\n\n // Factors to convert rgba back to float\n const vec4 RGBA_2_FLOAT_FACTORS = vec4(\n 255.0 / (256.0),\n 255.0 / (256.0 * 256.0),\n 255.0 / (256.0 * 256.0 * 256.0),\n 255.0 / (256.0 * 256.0 * 256.0 * 256.0)\n );\n\n\n float rgbaTofloat(vec4 rgba) {\n // Convert components from 0->1 back to 0->255 and then add the components together with their corresponding\n // fixed point factors, i.e. (256^1, 256^2, 256^3, 256^4)\n return dot(rgba, RGBA_2_FLOAT_FACTORS);\n }\n\n float linearDepthFromFloat(float depth) {\n depth = pow(depth, 0.2);\n return -(depth * (nearFar[1] - nearFar[0]) + nearFar[0]);\n }\n\n float linearDepthFromRGBA(vec4 depth) {\n return linearDepthFromFloat(rgbaTofloat(depth));\n }\n\n float linearDepthFromTexture(sampler2D depthTex, vec2 uv) {\n ivec2 iuv = ivec2(uv * vec2(textureSize(depthTex, 0)));\n return linearDepthFromRGBA(texelFetch(depthTex, iuv, 0));\n }\n\n void main() {\n vec4 color;\n if(inputType == 1) {\n color = vec4(vec3(texture(colorTex, uv).r), 1.0);\n } else if(inputType == 2) {\n color = vec4(texture(colorTex, uv).rg, 0.0, 1.0);\n } else if(inputType == 3) {\n float depth = 1.0 - ((-linearDepthFromTexture(colorTex, uv) - nearFar[0]) / (nearFar[1] - nearFar[0]));\n color = vec4(vec3(depth), depth >= 0.999 ? 0.0 : 1.0);\n } else if(inputType == 4) {\n color = texture(colorTex, uv);\n color = vec4(color.rgb / color.a, color.a);\n } else if(inputType == 5) {\n vec2 texDim = vec2(textureSize(colorTex, 0));\n ivec2 iuv = ivec2(uv*texDim);\n vec2 hh = texelFetch(colorTex,iuv,0).rg;\n uvec2 uhh = uvec2(vec2(hh) * 255.0);\n color = vec4(\n ((uhh.x & 0x3u) != 0u) ? 1.0 : 0.0,\n ((uhh.x & 0xcu) != 0u) ? 1.0 : 0.0,\n ((uhh.y & 0xfu) != 0u) ? 1.0 : 0.0,\n 1.0);\n } else if(inputType == 6) {\n vec2 texDim = vec2(textureSize(colorTex, 0));\n ivec2 iuv = ivec2(uv*texDim);\n uvec2 hh = uvec2(texelFetch(colorTex,iuv,0).rg * 255.0);\n color = vec4(\n ((hh & uvec2(0x55u)) != uvec2(0u)) ? 1.0 : 0.0,\n ((hh & uvec2(0xaau)) != uvec2(0u)) ? 1.0 : 0.0,\n 0.0,\n 1.0);\n } else {\n color = texture(colorTex, uv);\n }\n\n\n if(color.a < ${a.float(v)})\n discard;\n else {\n fragColor = color;\n ${c(r,"float depth = 1.0 - pow(texture(depthTex, uv).r, 10.0);\n fragDepth = vec4(vec3(depth), depth < 0.000001 ? 0.0 : 1.0);")}\n ${c(o>0,u(o))}\n }\n }`;return this._program.set(t,e.programCache.acquire(i,h,l)),this._program.get(t)}};var g;e([r()],x.prototype,"destroyedCB",void 0),e([r()],x.prototype,"produces",void 0),e([r()],x.prototype,"consumes",void 0),e([r()],x.prototype,"clearColor",void 0),x=e([o("esri.views.3d.webgl-engine.effects.debug.RenderNodeVisualizerNode")],x),function(e){e[e.ON=0]="ON",e[e.OFF=1]="OFF"}(g||(g={}));export{g as FocusState,x as RenderNodeVisualizerNode};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{fromValues as r}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{fromValues as t}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{isColor as e}from"../core/shaderLibrary/ShaderOutput.js";import{alphaCutoff as i}from"../core/shaderLibrary/util/AlphaCutoff.js";import s from"../lib/GLMaterial.js";import{MaterialParameters as o}from"../lib/Material.js";import{RenderSlot as a}from"../lib/RenderSlot.js";import{DefaultBufferWriter as n}from"./DefaultBufferWriter.js";import{PositionUVLayout as h}from"./DefaultLayouts.js";import{TriangleMaterial as p}from"./TriangleMaterial.js";import{CheckerBoardTechnique as f}from"../shaders/CheckerBoardTechnique.js";import{CheckerBoardTechniqueConfiguration as c}from"../shaders/CheckerBoardTechniqueConfiguration.js";class l extends p{constructor(r){super(r,m),this._configuration=new c,this.produces=new Map([[a.OPAQUE_MATERIAL,r=>e(r)&&!this.transparent],[a.TRANSPARENT_MATERIAL,r=>e(r)&&this.transparent&&this.parameters.writeDepth],[a.TRANSPARENT_MATERIAL_WITHOUT_DEPTH,r=>e(r)&&this.transparent&&!this.parameters.writeDepth]])}getConfiguration(r,t){return this._configuration.transparent=this.transparent,this._configuration.writeDepth=this.parameters.writeDepth,this._configuration.polygonOffset=this.parameters.polygonOffset,this._configuration.oitPass=t.oitPass,this._configuration.terrainDepthTest=t.terrainDepthTest,this._configuration.cullAboveTerrain=t.cullAboveTerrain,this._configuration}get visible(){return this.parameters.color1[3]>=i||this.parameters.color2[3]>=i}get transparent(){return this.parameters.color1[3]<1||this.parameters.color2[3]<1}createGLMaterial(r){return new u(r)}createBufferWriter(){return new n(h)}}class u extends s{beginSlot(r){return this.getTechnique(f,r)}}class m extends o{constructor(){super(...arguments),this.size=r(1,1),this.color1=t(.75,.75,.75,1),this.color2=t(.5,.5,.5,1),this.writeDepth=!0,this.polygonOffset=!1}}export{l as CheckerBoardMaterial,m as Parameters};
5
+ import{fromValues as r}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{fromValues as t}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{isColor as e}from"../core/shaderLibrary/ShaderOutput.js";import i from"../lib/GLMaterial.js";import{MaterialParameters as s}from"../lib/Material.js";import{RenderSlot as o}from"../lib/RenderSlot.js";import{DefaultBufferWriter as a}from"./DefaultBufferWriter.js";import{PositionUVLayout as n}from"./DefaultLayouts.js";import{TriangleMaterial as p}from"./TriangleMaterial.js";import{CheckerBoardTechnique as h}from"../shaders/CheckerBoardTechnique.js";import{CheckerBoardTechniqueConfiguration as f}from"../shaders/CheckerBoardTechniqueConfiguration.js";import{alphaCutoff as c}from"../../../../webscene/support/AlphaCutoff.js";class u extends p{constructor(r){super(r,m),this._configuration=new f,this.produces=new Map([[o.OPAQUE_MATERIAL,r=>e(r)&&!this.transparent],[o.TRANSPARENT_MATERIAL,r=>e(r)&&this.transparent&&this.parameters.writeDepth],[o.TRANSPARENT_MATERIAL_WITHOUT_DEPTH,r=>e(r)&&this.transparent&&!this.parameters.writeDepth]])}getConfiguration(r,t){return this._configuration.transparent=this.transparent,this._configuration.writeDepth=this.parameters.writeDepth,this._configuration.polygonOffset=this.parameters.polygonOffset,this._configuration.oitPass=t.oitPass,this._configuration.terrainDepthTest=t.terrainDepthTest,this._configuration.cullAboveTerrain=t.cullAboveTerrain,this._configuration}get visible(){return this.parameters.color1[3]>=c||this.parameters.color2[3]>=c}get transparent(){return this.parameters.color1[3]<1||this.parameters.color2[3]<1}createGLMaterial(r){return new l(r)}createBufferWriter(){return new a(n)}}class l extends i{beginSlot(r){return this.getTechnique(h,r)}}class m extends s{constructor(){super(...arguments),this.size=r(1,1),this.color1=t(.75,.75,.75,1),this.color2=t(.5,.5,.5,1),this.writeDepth=!0,this.polygonOffset=!1}}export{u as CheckerBoardMaterial,m as Parameters};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{ZEROS as t}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{newLayout as r}from"../../support/buffer/InterleavedLayout.js";import{isColorOrColorEmissionOrOID as e,isDepth as s,is2DGeometryOutput as i,isColorOrColorEmission as a,ShaderOutput as o}from"../core/shaderLibrary/ShaderOutput.js";import{alphaCutoff as n}from"../core/shaderLibrary/util/AlphaCutoff.js";import{olidEnabled as h}from"../effects/geometry/olidUtils.js";import{CullFaceOptions as p}from"../lib/basicInterfaces.js";import l from"../lib/GLMaterial.js";import{OITPolygonOffsetLimit as u}from"../lib/OrderIndependentTransparency.js";import{RenderSlot as c}from"../lib/RenderSlot.js";import{VertexAttribute as f}from"../lib/VertexAttribute.js";import{DefaultBufferWriter as m}from"./DefaultBufferWriter.js";import{TriangleMaterial as _}from"./TriangleMaterial.js";import{VisualVariablePassParameters as g}from"./VisualVariablePassParameters.js";import{ColorMaterialTechnique as T}from"../shaders/ColorMaterialTechnique.js";import{ColorMaterialTechniqueConfiguration as O}from"../shaders/ColorMaterialTechniqueConfiguration.js";class A extends _{constructor(t){super(t,P),this._configuration=new O,this.supportsEdges=!0,this.produces=new Map([[c.OPAQUE_MATERIAL,t=>this._isOpaqueMaterialPass(t)],[c.OPAQUE_MATERIAL_WITHOUT_NORMALS,t=>this._isOpaqueNoSSAODepthPass(t)],[c.TRANSPARENT_MATERIAL,t=>e(t)&&this._transparent&&this.parameters.writeDepth],[c.TRANSPARENT_MATERIAL_WITHOUT_NORMALS,t=>s(t)&&this._transparent&&this.parameters.writeDepth],[c.TRANSPARENT_MATERIAL_WITHOUT_DEPTH,t=>e(t)&&this._transparent&&!this.parameters.writeDepth],[c.DRAPED_MATERIAL,t=>i(t)]])}getConfiguration(t,r){return this._configuration.output=t,this._configuration.cullFace=this.parameters.cullFace,this._configuration.hasVertexColors=this.parameters.hasVertexColors&&!this.parameters.vvColor,this._configuration.hasSlicePlane=this.parameters.hasSlicePlane,this._configuration.transparent=this._transparent,this._configuration.discardInvisibleFragments=this._transparent&&!this._isOpaquePass(t)&&this.parameters.discardInvisibleFragments,this._configuration.polygonOffset=this.parameters.polygonOffset,this._configuration.writeDepth=this.parameters.writeDepth,this._configuration.hasOccludees=r.hasOccludees,this._configuration.oitPass=r.oitPass,this._configuration.enableOffset=r.camera.relativeElevation<u,this._configuration.terrainDepthTest=r.terrainDepthTest&&a(t),this._configuration.cullAboveTerrain=r.cullAboveTerrain,this._configuration.vvColor=!!this.parameters.vvColor,this._configuration.draped=this.parameters.draped,this._configuration}get visible(){return this.parameters.color[3]>=n}get _transparent(){return this.parameters.color[3]<1||this.parameters.forceTransparentMode}_isOpaquePass(t){return this._isOpaqueMaterialPass(t)||this._isOpaqueNoSSAODepthPass(t)}_isOpaqueMaterialPass(t){return t===o.Highlight||e(t)&&!this._transparent}_isOpaqueNoSSAODepthPass(t){return s(t)&&this.parameters.writeDepth&&!this._transparent}createGLMaterial(t){return new d(t)}createBufferWriter(){const t=r().vec3f(f.POSITION);return h()&&t.vec4u8(f.OBJECTANDLAYERIDCOLOR),this.parameters.vvColor?t.f32(f.COLORFEATUREATTRIBUTE):t.vec4u8(f.COLOR),new m(t)}}class d extends l{beginSlot(t){return this.getTechnique(T,t)}}class P extends g{constructor(){super(...arguments),this.color=t,this.forceTransparentMode=!1,this.writeDepth=!0,this.hasVertexColors=!1,this.polygonOffset=!1,this.hasSlicePlane=!1,this.cullFace=p.None,this.draped=!1,this.discardInvisibleFragments=!1}}export{A as ColorMaterial,P as Parameters};
5
+ import{ZEROS as t}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{newLayout as r}from"../../support/buffer/InterleavedLayout.js";import{isColorOrColorEmissionOrOID as e,isDepth as s,is2DGeometryOutput as i,isColorOrColorEmission as a,ShaderOutput as o}from"../core/shaderLibrary/ShaderOutput.js";import{olidEnabled as n}from"../effects/geometry/olidUtils.js";import{CullFaceOptions as h}from"../lib/basicInterfaces.js";import p from"../lib/GLMaterial.js";import{OITPolygonOffsetLimit as l}from"../lib/OrderIndependentTransparency.js";import{RenderSlot as u}from"../lib/RenderSlot.js";import{VertexAttribute as c}from"../lib/VertexAttribute.js";import{DefaultBufferWriter as f}from"./DefaultBufferWriter.js";import{TriangleMaterial as m}from"./TriangleMaterial.js";import{VisualVariablePassParameters as _}from"./VisualVariablePassParameters.js";import{ColorMaterialTechnique as g}from"../shaders/ColorMaterialTechnique.js";import{ColorMaterialTechniqueConfiguration as T}from"../shaders/ColorMaterialTechniqueConfiguration.js";import{alphaCutoff as O}from"../../../../webscene/support/AlphaCutoff.js";class A extends m{constructor(t){super(t,P),this._configuration=new T,this.supportsEdges=!0,this.produces=new Map([[u.OPAQUE_MATERIAL,t=>this._isOpaqueMaterialPass(t)],[u.OPAQUE_MATERIAL_WITHOUT_NORMALS,t=>this._isOpaqueNoSSAODepthPass(t)],[u.TRANSPARENT_MATERIAL,t=>e(t)&&this._transparent&&this.parameters.writeDepth],[u.TRANSPARENT_MATERIAL_WITHOUT_NORMALS,t=>s(t)&&this._transparent&&this.parameters.writeDepth],[u.TRANSPARENT_MATERIAL_WITHOUT_DEPTH,t=>e(t)&&this._transparent&&!this.parameters.writeDepth],[u.DRAPED_MATERIAL,t=>i(t)]])}getConfiguration(t,r){return this._configuration.output=t,this._configuration.cullFace=this.parameters.cullFace,this._configuration.hasVertexColors=this.parameters.hasVertexColors&&!this.parameters.vvColor,this._configuration.hasSlicePlane=this.parameters.hasSlicePlane,this._configuration.transparent=this._transparent,this._configuration.discardInvisibleFragments=this._transparent&&!this._isOpaquePass(t)&&this.parameters.discardInvisibleFragments,this._configuration.polygonOffset=this.parameters.polygonOffset,this._configuration.writeDepth=this.parameters.writeDepth,this._configuration.hasOccludees=r.hasOccludees,this._configuration.oitPass=r.oitPass,this._configuration.enableOffset=r.camera.relativeElevation<l,this._configuration.terrainDepthTest=r.terrainDepthTest&&a(t),this._configuration.cullAboveTerrain=r.cullAboveTerrain,this._configuration.vvColor=!!this.parameters.vvColor,this._configuration.draped=this.parameters.draped,this._configuration}get visible(){return this.parameters.color[3]>=O}get _transparent(){return this.parameters.color[3]<1||this.parameters.forceTransparentMode}_isOpaquePass(t){return this._isOpaqueMaterialPass(t)||this._isOpaqueNoSSAODepthPass(t)}_isOpaqueMaterialPass(t){return t===o.Highlight||e(t)&&!this._transparent}_isOpaqueNoSSAODepthPass(t){return s(t)&&this.parameters.writeDepth&&!this._transparent}createGLMaterial(t){return new d(t)}createBufferWriter(){const t=r().vec3f(c.POSITION);return n()&&t.vec4u8(c.OBJECTANDLAYERIDCOLOR),this.parameters.vvColor?t.f32(c.COLORFEATUREATTRIBUTE):t.vec4u8(c.COLOR),new f(t)}}class d extends p{beginSlot(t){return this.getTechnique(g,t)}}class P extends _{constructor(){super(...arguments),this.color=t,this.forceTransparentMode=!1,this.writeDepth=!0,this.hasVertexColors=!1,this.polygonOffset=!1,this.hasSlicePlane=!1,this.cullFace=h.None,this.draped=!1,this.discardInvisibleFragments=!1}}export{A as ColorMaterial,P as Parameters};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{p as e,i as r,c as t,n as i,d as s,l as a,h as o,f as n,q as c}from"../../../../chunks/vec32.js";import{ZEROS as l,create as u,fromValues as h}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ViewingMode as f}from"../../../ViewingMode.js";import{newLayout as m}from"../../support/buffer/InterleavedLayout.js";import{is3DGeometryOutputMRT as p,isShadowRelatedOutput as d,is3DGeometryOutput as g,ShaderOutput as T,isColorOrColorEmission as x}from"../core/shaderLibrary/ShaderOutput.js";import{NormalType as _}from"../core/shaderLibrary/attributes/NormalAttribute.glsl.js";import{EmissionSource as v}from"../core/shaderLibrary/output/Emissions.glsl.js";import{NormalsDoubleSidedMode as b}from"../core/shaderLibrary/shading/Normals.glsl.js";import{PBRMode as S}from"../core/shaderLibrary/shading/PhysicallyBasedRenderingParameters.glsl.js";import{alphaCutoff as O}from"../core/shaderLibrary/util/AlphaCutoff.js";import{olidEnabled as M}from"../effects/geometry/olidUtils.js";import{CullFaceOptions as w}from"../lib/basicInterfaces.js";import{GLTextureMaterial as R}from"../lib/GLTextureMaterial.js";import{Material as y}from"../lib/Material.js";import{OITPolygonOffsetLimit as C}from"../lib/OrderIndependentTransparency.js";import{intersectTriangleGeometry as A}from"../lib/RayIntersections.js";import{RenderSlot as I}from"../lib/RenderSlot.js";import{VertexAttribute as P}from"../lib/VertexAttribute.js";import{getVerticalOffsetObject3D as j}from"../lib/verticalOffsetUtils.js";import{DefaultBufferWriter as L}from"./DefaultBufferWriter.js";import{verticalOffsetAtDistance as D}from"./internal/MaterialUtil.js";import{DefaultMaterialTechnique as N,DefaultMaterialPassParameters as E}from"../shaders/DefaultMaterialTechnique.js";import{DefaultMaterialTechniqueConfiguration as V}from"../shaders/DefaultMaterialTechniqueConfiguration.js";import{RealisticTreeTechnique as B}from"../shaders/RealisticTreeTechnique.js";class z extends y{constructor(e,r){super(e,U),this.materialType="default",this.supportsEdges=!0,this.produces=new Map([[I.OPAQUE_MATERIAL,e=>(p(e)||d(e))&&!this.parameters.transparent],[I.TRANSPARENT_MATERIAL,e=>(p(e)||d(e))&&this.parameters.transparent&&this.parameters.writeDepth],[I.TRANSPARENT_MATERIAL_WITHOUT_DEPTH,e=>(g(e)||d(e))&&this.parameters.transparent&&!this.parameters.writeDepth]]),this._vertexBufferLayout=k(this.parameters),this._configuration=new V(r.spherical,r.doublePrecisionRequiresObfuscation)}isVisibleForOutput(e){return e!==T.Shadow&&e!==T.ShadowExcludeHighlight&&e!==T.ShadowHighlight||this.parameters.castShadows}get visible(){const e=this.parameters;if(e.layerOpacity<O)return!1;const{hasInstancedColor:r,hasVertexColors:t,hasSymbolColors:i,vvColor:s}=e,a=r||s||i,o="replace"===e.colorMixMode,n=e.opacity>=O;if(t&&a)return o||n;const c=e.externalColor&&e.externalColor[3]>=O;return t?o?c:n:a?o||n:o?c:n}get hasEmissions(){return!!this.parameters.emissiveTextureId||!e(this.parameters.emissiveFactor,l)}getConfiguration(e,r){const t=this.parameters,{treeRendering:i,doubleSided:s,doubleSidedType:a}=t;return this._configuration.output=e,this._configuration.hasNormalTexture=!i&&!!t.normalTextureId,this._configuration.hasColorTexture=!!t.textureId,this._configuration.hasVertexTangents=!i&&t.hasVertexTangents,this._configuration.instanced=t.isInstanced,this._configuration.instancedDoublePrecision=t.instancedDoublePrecision,this._configuration.vvSize=!!t.vvSize,this._configuration.hasVerticalOffset=null!=t.verticalOffset,this._configuration.hasScreenSizePerspective=null!=t.screenSizePerspective,this._configuration.hasSlicePlane=t.hasSlicePlane,this._configuration.alphaDiscardMode=t.textureAlphaMode,this._configuration.normalType=i?_.Attribute:t.normalType,this._configuration.transparent=t.transparent,this._configuration.writeDepth=t.writeDepth,null!=t.customDepthTest&&(this._configuration.customDepthTest=t.customDepthTest),this._configuration.hasOccludees=r.hasOccludees,this._configuration.cullFace=t.hasSlicePlane?w.None:t.cullFace,this._configuration.cullAboveTerrain=r.cullAboveTerrain,this._configuration.hasModelTransformation=!i&&null!=t.modelTransformation,this._configuration.hasVertexColors=t.hasVertexColors,this._configuration.hasSymbolColors=t.hasSymbolColors,this._configuration.doubleSidedMode=i?b.WindingOrder:s&&"normal"===a?b.View:s&&"winding-order"===a?b.WindingOrder:b.None,this._configuration.instancedColor=t.hasInstancedColor,x(e)?(this._configuration.terrainDepthTest=r.terrainDepthTest,this._configuration.receiveShadows=t.receiveShadows,this._configuration.receiveAmbientOcclusion=t.receiveAmbientOcclusion&&null!=r.ssao):(this._configuration.terrainDepthTest=!1,this._configuration.receiveShadows=this._configuration.receiveAmbientOcclusion=!1),this._configuration.vvColor=!!t.vvColor,this._configuration.textureAlphaPremultiplied=!!t.textureAlphaPremultiplied,this._configuration.pbrMode=t.usePBR?t.isSchematic?S.Schematic:S.Normal:S.Disabled,this._configuration.hasMetallicRoughnessTexture=!i&&!!t.metallicRoughnessTextureId,this._configuration.emissionSource=i?v.None:null!=t.emissiveTextureId?v.Texture:t.usePBR?v.Value:v.None,this._configuration.hasOcclusionTexture=!i&&!!t.occlusionTextureId,this._configuration.offsetBackfaces=!(!t.transparent||!t.offsetTransparentBackfaces),this._configuration.oitPass=r.oitPass,this._configuration.enableOffset=r.camera.relativeElevation<C,this._configuration.snowCover=W(r),this._configuration.hasColorTextureTransform=!!t.colorTextureTransformMatrix,this._configuration.hasNormalTextureTransform=!!t.normalTextureTransformMatrix,this._configuration.hasEmissionTextureTransform=!!t.emissiveTextureTransformMatrix,this._configuration.hasOcclusionTextureTransform=!!t.occlusionTextureTransformMatrix,this._configuration.hasMetallicRoughnessTextureTransform=!!t.metallicRoughnessTextureTransformMatrix,this._configuration}intersect(e,l,u,h,m,p){if(null!=this.parameters.verticalOffset){const e=u.camera;r(Q,l[12],l[13],l[14]);let p=null;switch(u.viewingMode){case f.Global:p=i(Y,Q);break;case f.Local:p=t(Y,H)}let d=0;const g=s(K,Q,e.eye),T=a(g),x=o(g,g,1/T);let _=null;this.parameters.screenSizePerspective&&(_=n(p,x)),d+=D(e,T,this.parameters.verticalOffset,_??0,this.parameters.screenSizePerspective),o(p,p,d),c(J,p,u.transform.inverseRotation),h=s(F,h,J),m=s(G,m,J)}A(e,u,h,m,j(u.verticalOffset),p)}createGLMaterial(e){return new q(e)}createBufferWriter(){return new L(this._vertexBufferLayout)}}class q extends R{constructor(e){super({...e,...e.material.parameters})}beginSlot(e){this._material.setParameters({receiveShadows:e.shadowMap.enabled});const t=this._material.parameters;this.updateTexture(t.textureId);const i=e.camera.viewInverseTransposeMatrix;return r(t.origin,i[3],i[7],i[11]),this._material.setParameters(this.textureBindParameters),this.getTechnique(t.treeRendering?B:N,e)}}class U extends E{constructor(){super(...arguments),this.initTextureTransparent=!1,this.treeRendering=!1,this.hasVertexTangents=!1}}function W(e){return null!=e.weather&&e.weatherVisible&&"snowy"===e.weather.type&&"enabled"===e.weather.snowCover}function k(e){const r=m().vec3f(P.POSITION);e.normalType===_.Compressed?r.vec2i16(P.NORMALCOMPRESSED,{glNormalized:!0}):r.vec3f(P.NORMAL),e.hasVertexTangents&&r.vec4f(P.TANGENT);return(e.textureId||e.normalTextureId||e.metallicRoughnessTextureId||e.emissiveTextureId||e.occlusionTextureId)&&r.vec2f(P.UV0),e.hasVertexColors&&r.vec4u8(P.COLOR),e.hasSymbolColors&&r.vec4u8(P.SYMBOLCOLOR),M()&&r.vec4u8(P.OBJECTANDLAYERIDCOLOR),r}const F=u(),G=u(),H=h(0,0,1),Y=u(),J=u(),Q=u(),K=u();export{q as DefaultGLMaterial,z as DefaultMaterial,U as DefaultMaterialParameters};
5
+ import{p as e,i as r,c as t,n as i,d as s,l as a,h as o,f as n,q as c}from"../../../../chunks/vec32.js";import{ZEROS as l,create as u,fromValues as h}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ViewingMode as f}from"../../../ViewingMode.js";import{newLayout as m}from"../../support/buffer/InterleavedLayout.js";import{is3DGeometryOutputMRT as p,isShadowRelatedOutput as d,is3DGeometryOutput as g,ShaderOutput as T,isColorOrColorEmission as x}from"../core/shaderLibrary/ShaderOutput.js";import{NormalType as _}from"../core/shaderLibrary/attributes/NormalAttribute.glsl.js";import{EmissionSource as v}from"../core/shaderLibrary/output/Emissions.glsl.js";import{NormalsDoubleSidedMode as b}from"../core/shaderLibrary/shading/Normals.glsl.js";import{PBRMode as S}from"../core/shaderLibrary/shading/PhysicallyBasedRenderingParameters.glsl.js";import{olidEnabled as O}from"../effects/geometry/olidUtils.js";import{CullFaceOptions as M}from"../lib/basicInterfaces.js";import{GLTextureMaterial as w}from"../lib/GLTextureMaterial.js";import{Material as R}from"../lib/Material.js";import{OITPolygonOffsetLimit as C}from"../lib/OrderIndependentTransparency.js";import{intersectTriangleGeometry as y}from"../lib/RayIntersections.js";import{RenderSlot as A}from"../lib/RenderSlot.js";import{VertexAttribute as I}from"../lib/VertexAttribute.js";import{getVerticalOffsetObject3D as P}from"../lib/verticalOffsetUtils.js";import{DefaultBufferWriter as j}from"./DefaultBufferWriter.js";import{verticalOffsetAtDistance as D}from"./internal/MaterialUtil.js";import{DefaultMaterialTechnique as L,DefaultMaterialPassParameters as N}from"../shaders/DefaultMaterialTechnique.js";import{DefaultMaterialTechniqueConfiguration as E}from"../shaders/DefaultMaterialTechniqueConfiguration.js";import{RealisticTreeTechnique as V}from"../shaders/RealisticTreeTechnique.js";import{alphaCutoff as B}from"../../../../webscene/support/AlphaCutoff.js";class z extends R{constructor(e,r){super(e,U),this.materialType="default",this.supportsEdges=!0,this.produces=new Map([[A.OPAQUE_MATERIAL,e=>(p(e)||d(e))&&!this.parameters.transparent],[A.TRANSPARENT_MATERIAL,e=>(p(e)||d(e))&&this.parameters.transparent&&this.parameters.writeDepth],[A.TRANSPARENT_MATERIAL_WITHOUT_DEPTH,e=>(g(e)||d(e))&&this.parameters.transparent&&!this.parameters.writeDepth]]),this._vertexBufferLayout=k(this.parameters),this._configuration=new E(r.spherical,r.doublePrecisionRequiresObfuscation)}isVisibleForOutput(e){return e!==T.Shadow&&e!==T.ShadowExcludeHighlight&&e!==T.ShadowHighlight||this.parameters.castShadows}get visible(){const e=this.parameters;if(e.layerOpacity<B)return!1;const{hasInstancedColor:r,hasVertexColors:t,hasSymbolColors:i,vvColor:s}=e,a=r||s||i,o="replace"===e.colorMixMode,n=e.opacity>=B;if(t&&a)return o||n;const c=e.externalColor&&e.externalColor[3]>=B;return t?o?c:n:a?o||n:o?c:n}get hasEmissions(){return!!this.parameters.emissiveTextureId||!e(this.parameters.emissiveFactor,l)}getConfiguration(e,r){const t=this.parameters,{treeRendering:i,doubleSided:s,doubleSidedType:a}=t;return this._configuration.output=e,this._configuration.hasNormalTexture=!i&&!!t.normalTextureId,this._configuration.hasColorTexture=!!t.textureId,this._configuration.hasVertexTangents=!i&&t.hasVertexTangents,this._configuration.instanced=t.isInstanced,this._configuration.instancedDoublePrecision=t.instancedDoublePrecision,this._configuration.vvSize=!!t.vvSize,this._configuration.hasVerticalOffset=null!=t.verticalOffset,this._configuration.hasScreenSizePerspective=null!=t.screenSizePerspective,this._configuration.hasSlicePlane=t.hasSlicePlane,this._configuration.alphaDiscardMode=t.textureAlphaMode,this._configuration.normalType=i?_.Attribute:t.normalType,this._configuration.transparent=t.transparent,this._configuration.writeDepth=t.writeDepth,null!=t.customDepthTest&&(this._configuration.customDepthTest=t.customDepthTest),this._configuration.hasOccludees=r.hasOccludees,this._configuration.cullFace=t.hasSlicePlane?M.None:t.cullFace,this._configuration.cullAboveTerrain=r.cullAboveTerrain,this._configuration.hasModelTransformation=!i&&null!=t.modelTransformation,this._configuration.hasVertexColors=t.hasVertexColors,this._configuration.hasSymbolColors=t.hasSymbolColors,this._configuration.doubleSidedMode=i?b.WindingOrder:s&&"normal"===a?b.View:s&&"winding-order"===a?b.WindingOrder:b.None,this._configuration.instancedColor=t.hasInstancedColor,x(e)?(this._configuration.terrainDepthTest=r.terrainDepthTest,this._configuration.receiveShadows=t.receiveShadows,this._configuration.receiveAmbientOcclusion=t.receiveAmbientOcclusion&&null!=r.ssao):(this._configuration.terrainDepthTest=!1,this._configuration.receiveShadows=this._configuration.receiveAmbientOcclusion=!1),this._configuration.vvColor=!!t.vvColor,this._configuration.textureAlphaPremultiplied=!!t.textureAlphaPremultiplied,this._configuration.pbrMode=t.usePBR?t.isSchematic?S.Schematic:S.Normal:S.Disabled,this._configuration.hasMetallicRoughnessTexture=!i&&!!t.metallicRoughnessTextureId,this._configuration.emissionSource=i?v.None:null!=t.emissiveTextureId?v.Texture:t.usePBR?v.Value:v.None,this._configuration.hasOcclusionTexture=!i&&!!t.occlusionTextureId,this._configuration.offsetBackfaces=!(!t.transparent||!t.offsetTransparentBackfaces),this._configuration.oitPass=r.oitPass,this._configuration.enableOffset=r.camera.relativeElevation<C,this._configuration.snowCover=W(r),this._configuration.hasColorTextureTransform=!!t.colorTextureTransformMatrix,this._configuration.hasNormalTextureTransform=!!t.normalTextureTransformMatrix,this._configuration.hasEmissionTextureTransform=!!t.emissiveTextureTransformMatrix,this._configuration.hasOcclusionTextureTransform=!!t.occlusionTextureTransformMatrix,this._configuration.hasMetallicRoughnessTextureTransform=!!t.metallicRoughnessTextureTransformMatrix,this._configuration}intersect(e,l,u,h,m,p){if(null!=this.parameters.verticalOffset){const e=u.camera;r(Q,l[12],l[13],l[14]);let p=null;switch(u.viewingMode){case f.Global:p=i(Y,Q);break;case f.Local:p=t(Y,H)}let d=0;const g=s(K,Q,e.eye),T=a(g),x=o(g,g,1/T);let _=null;this.parameters.screenSizePerspective&&(_=n(p,x)),d+=D(e,T,this.parameters.verticalOffset,_??0,this.parameters.screenSizePerspective),o(p,p,d),c(J,p,u.transform.inverseRotation),h=s(F,h,J),m=s(G,m,J)}y(e,u,h,m,P(u.verticalOffset),p)}createGLMaterial(e){return new q(e)}createBufferWriter(){return new j(this._vertexBufferLayout)}}class q extends w{constructor(e){super({...e,...e.material.parameters})}beginSlot(e){this._material.setParameters({receiveShadows:e.shadowMap.enabled});const t=this._material.parameters;this.updateTexture(t.textureId);const i=e.camera.viewInverseTransposeMatrix;return r(t.origin,i[3],i[7],i[11]),this._material.setParameters(this.textureBindParameters),this.getTechnique(t.treeRendering?V:L,e)}}class U extends N{constructor(){super(...arguments),this.initTextureTransparent=!1,this.treeRendering=!1,this.hasVertexTangents=!1}}function W(e){return null!=e.weather&&e.weatherVisible&&"snowy"===e.weather.type&&"enabled"===e.weather.snowCover}function k(e){const r=m().vec3f(I.POSITION);e.normalType===_.Compressed?r.vec2i16(I.NORMALCOMPRESSED,{glNormalized:!0}):r.vec3f(I.NORMAL),e.hasVertexTangents&&r.vec4f(I.TANGENT);return(e.textureId||e.normalTextureId||e.metallicRoughnessTextureId||e.emissiveTextureId||e.occlusionTextureId)&&r.vec2f(I.UV0),e.hasVertexColors&&r.vec4u8(I.COLOR),e.hasSymbolColors&&r.vec4u8(I.SYMBOLCOLOR),O()&&r.vec4u8(I.OBJECTANDLAYERIDCOLOR),r}const F=u(),G=u(),H=h(0,0,1),Y=u(),J=u(),Q=u(),K=u();export{q as DefaultGLMaterial,z as DefaultMaterial,U as DefaultMaterialParameters};