@arcgis/core 5.0.0-next.55 → 5.0.0-next.56

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 (392) hide show
  1. package/Color.d.ts +12 -4
  2. package/Ground.js +1 -1
  3. package/applications/Components/SelectionOperation.d.ts +5 -0
  4. package/applications/Components/SketchTooltipControls.d.ts +5 -0
  5. package/applications/Components/actionUtils.d.ts +5 -0
  6. package/applications/Components/analysisUtils.d.ts +5 -0
  7. package/applications/Components/arcadeEditorUtils.d.ts +5 -0
  8. package/applications/Components/arcadeFeatureUtils.d.ts +5 -0
  9. package/applications/Components/basemapUtils.d.ts +5 -0
  10. package/applications/Components/drawUtils.d.ts +5 -0
  11. package/applications/Components/featureUtils.d.ts +5 -0
  12. package/applications/Components/fontUtils.d.ts +5 -0
  13. package/applications/Components/formatUtils.d.ts +5 -0
  14. package/applications/Components/getDefaultUnits.d.ts +5 -0
  15. package/applications/Components/gfxUtils.d.ts +5 -0
  16. package/applications/Components/imageryUtils.d.ts +5 -0
  17. package/applications/Components/layerOriginUtils.d.ts +5 -0
  18. package/applications/Components/layersEffectsJsonUtils.d.ts +5 -0
  19. package/applications/Components/previewSymbol2D.d.ts +5 -0
  20. package/applications/Components/reactiveUtils.d.ts +6 -0
  21. package/applications/Components/sanitizerUtils.d.ts +5 -0
  22. package/applications/Components/stringUtils.d.ts +6 -2
  23. package/applications/Components/styleUtils.d.ts +5 -0
  24. package/applications/Components/svgUtils.d.ts +5 -0
  25. package/applications/Components/testUtils.d.ts +5 -0
  26. package/applications/Components/viewUtils.d.ts +5 -0
  27. package/applications/Components/webStyleSymbolUtils.d.ts +5 -0
  28. package/applications/Excalibur/videoViewUtils.d.ts +5 -0
  29. package/applications/ExperienceBuilder/sketchUtils.d.ts +5 -0
  30. package/applications/KnowledgeStudio/generalSdkInternalAccess.d.ts +10 -0
  31. package/applications/KnowledgeStudio/generalSharedKgUtils.d.ts +10 -0
  32. package/applications/KnowledgeStudio/layerInternalAccessUtils.d.ts +11 -1
  33. package/applications/KnowledgeStudio/reshape.d.ts +5 -0
  34. package/applications/KnowledgeStudio/resourceSerializationUtils.d.ts +5 -0
  35. package/applications/MapViewer/layerUtils.d.ts +5 -0
  36. package/applications/MapViewer/mediaUtils.d.ts +5 -0
  37. package/applications/MapViewer/templateUtils.d.ts +5 -0
  38. package/applications/PortalApp/layerUtils.d.ts +5 -0
  39. package/applications/SceneViewer/colorUtils.d.ts +5 -0
  40. package/applications/SceneViewer/devEnvironmentUtils.d.ts +5 -0
  41. package/applications/SceneViewer/layerUtils.d.ts +5 -0
  42. package/applications/SceneViewer/sceneViewerUtils.d.ts +5 -0
  43. package/applications/SceneViewer/symbolUtils.d.ts +5 -0
  44. package/applications/Urban/meshUtils.d.ts +5 -0
  45. package/applications/WebEditor/sketchUtils.d.ts +5 -0
  46. package/arcade.d.ts +22 -0
  47. package/assets/esri/core/workers/RemoteClient.js +1 -1
  48. package/assets/esri/core/workers/chunks/5340887a4a48bde3407a.js +1 -0
  49. package/assets/esri/core/workers/chunks/82ced9254b27707522ef.js +1 -0
  50. package/assets/esri/core/workers/chunks/8628bf45a33af786cd49.js +1 -0
  51. package/assets/esri/core/workers/chunks/{d63cf90d1356d1f10138.js → 8f4c480c418eba299c2b.js} +1 -1
  52. package/assets/esri/core/workers/chunks/{fa92a7c11befbad8739f.js → b4f944ef6c174b20b619.js} +1 -1
  53. package/assets/esri/core/workers/chunks/c531c0e3d420a1be0ad2.js +316 -0
  54. package/assets/esri/core/workers/chunks/{14765f98b8ea447498a1.js → da2c41ac0f82f32013c1.js} +4 -4
  55. package/assets/esri/libs/lyr3d/lyr3DMain.wasm +0 -0
  56. package/assets/esri/libs/lyr3d/lyr3DWorker.wasm +0 -0
  57. package/chunks/ChapmanAtmosphere.glsl.js +5 -7
  58. package/chunks/HUDMaterial.glsl.js +1 -1
  59. package/chunks/LineCallout.glsl.js +2 -2
  60. package/chunks/Precipitation.glsl.js +1 -1
  61. package/chunks/Terrain.glsl.js +1 -1
  62. package/chunks/lyr3DMain.js +1 -1
  63. package/chunks/vec32.js +1 -1
  64. package/config.d.ts +19 -1
  65. package/config.js +1 -1
  66. package/core/Error.d.ts +3 -4
  67. package/core/Error.js +1 -1
  68. package/core/Warning.js +1 -1
  69. package/core/accessorSupport/decorators.d.ts +11 -0
  70. package/core/accessorSupport/types.d.ts +2 -0
  71. package/core/has.js +1 -1
  72. package/core/lang.d.ts +6 -0
  73. package/core/libs/gl-matrix-2/math/vec3.js +1 -1
  74. package/core/libs/gl-matrix-2/vec3.js +1 -1
  75. package/core/promiseUtils.d.ts +5 -0
  76. package/core/quantity.d.ts +5 -0
  77. package/core/reactiveUtils.d.ts +142 -0
  78. package/core/scheduling.d.ts +26 -5
  79. package/core/scheduling.js +1 -1
  80. package/core/sql/WhereClause.d.ts +2 -13
  81. package/core/sql/{WhereGrammar.d.ts → types.d.ts} +22 -1
  82. package/core/sql.d.ts +8 -0
  83. package/core/string.js +1 -1
  84. package/core/types.d.ts +30 -1
  85. package/core/units.d.ts +8 -0
  86. package/core/urlUtils.d.ts +7 -0
  87. package/core/workers/loaderConfig.js +1 -1
  88. package/core/workers/workerFactory.js +1 -1
  89. package/core/workers.d.ts +26 -0
  90. package/form/elements/inputs.d.ts +55 -0
  91. package/form/elements.d.ts +43 -0
  92. package/geometry/coordinateFormatter.d.ts +33 -0
  93. package/geometry/geometryEngine.d.ts +16 -0
  94. package/geometry/operators/affineTransformOperator.d.ts +5 -0
  95. package/geometry/operators/alphaShapeOperator.d.ts +9 -0
  96. package/geometry/operators/areaOperator.d.ts +7 -0
  97. package/geometry/operators/autoCompleteOperator.d.ts +5 -0
  98. package/geometry/operators/boundaryOperator.d.ts +5 -0
  99. package/geometry/operators/bufferOperator.d.ts +11 -0
  100. package/geometry/operators/centroidOperator.d.ts +14 -0
  101. package/geometry/operators/clipOperator.d.ts +7 -0
  102. package/geometry/operators/containsOperator.d.ts +9 -0
  103. package/geometry/operators/convexHullOperator.d.ts +9 -0
  104. package/geometry/operators/crossesOperator.d.ts +7 -0
  105. package/geometry/operators/cutOperator.d.ts +18 -0
  106. package/geometry/operators/densifyOperator.d.ts +21 -0
  107. package/geometry/operators/differenceOperator.d.ts +7 -0
  108. package/geometry/operators/disjointOperator.d.ts +8 -0
  109. package/geometry/operators/distanceOperator.d.ts +8 -0
  110. package/geometry/operators/equalsOperator.d.ts +5 -0
  111. package/geometry/operators/extendOperator.d.ts +8 -0
  112. package/geometry/operators/generalizeOperator.d.ts +7 -0
  113. package/geometry/operators/geodesicBufferOperator.d.ts +13 -0
  114. package/geometry/operators/geodesicProximityOperator.d.ts +13 -0
  115. package/geometry/operators/geodeticAreaOperator.d.ts +11 -0
  116. package/geometry/operators/geodeticDensifyOperator.d.ts +12 -0
  117. package/geometry/operators/geodeticDistanceOperator.d.ts +14 -0
  118. package/geometry/operators/geodeticLengthOperator.d.ts +11 -0
  119. package/geometry/operators/geodeticUtilsOperator.d.ts +11 -0
  120. package/geometry/operators/graphicBufferOperator.d.ts +7 -0
  121. package/geometry/operators/integrateOperator.d.ts +9 -0
  122. package/geometry/operators/intersectionOperator.d.ts +7 -0
  123. package/geometry/operators/intersectsOperator.d.ts +9 -0
  124. package/geometry/operators/isNearOperator.d.ts +7 -0
  125. package/geometry/operators/labelPointOperator.d.ts +14 -0
  126. package/geometry/operators/lengthOperator.d.ts +7 -0
  127. package/geometry/operators/linesToPolygonsOperator.d.ts +5 -0
  128. package/geometry/operators/locateBetweenOperator.d.ts +10 -0
  129. package/geometry/operators/minimumBoundingCircleOperator.d.ts +13 -0
  130. package/geometry/operators/multiPartToSinglePartOperator.d.ts +7 -0
  131. package/geometry/operators/offsetOperator.d.ts +44 -0
  132. package/geometry/operators/overlapsOperator.d.ts +7 -0
  133. package/geometry/operators/polygonOverlayOperator.d.ts +6 -0
  134. package/geometry/operators/polygonSlicerOperator.d.ts +5 -0
  135. package/geometry/operators/projectOperator.d.ts +41 -0
  136. package/geometry/operators/proximityOperator.d.ts +8 -0
  137. package/geometry/operators/relateOperator.d.ts +7 -0
  138. package/geometry/operators/reshapeOperator.d.ts +5 -0
  139. package/geometry/operators/shapePreservingProjectOperator.d.ts +27 -0
  140. package/geometry/operators/simplifyOGCOperator.d.ts +8 -0
  141. package/geometry/operators/simplifyOperator.d.ts +9 -0
  142. package/geometry/operators/support/geographicTransformationUtils.d.ts +11 -0
  143. package/geometry/operators/symmetricDifferenceOperator.d.ts +12 -0
  144. package/geometry/operators/touchesOperator.d.ts +7 -0
  145. package/geometry/operators/unionOperator.d.ts +7 -0
  146. package/geometry/operators/withinOperator.d.ts +9 -0
  147. package/geometry/support/geodesicUtils.d.ts +8 -0
  148. package/geometry/support/jsonUtils.d.ts +7 -0
  149. package/geometry/support/meshUtils.d.ts +5 -0
  150. package/geometry/support/normalizeUtils.d.ts +7 -0
  151. package/geometry/support/webMercatorUtils.d.ts +12 -0
  152. package/geometry.d.ts +38 -0
  153. package/interfaces.d.ts +31 -32
  154. package/intl.d.ts +111 -0
  155. package/kernel.d.ts +5 -0
  156. package/kernel.js +1 -1
  157. package/layers/BaseDynamicLayer.d.ts +1 -1
  158. package/layers/CSVLayer.d.ts +2 -2
  159. package/layers/CatalogLayer.d.ts +2 -2
  160. package/layers/FeatureLayer.d.ts +2 -1
  161. package/layers/GeoJSONLayer.d.ts +2 -1
  162. package/layers/ILyr3DWasmPerSceneView.js +1 -1
  163. package/layers/Layer.d.ts +1 -1
  164. package/layers/Lyr3DWasmPerSceneView.js +1 -1
  165. package/layers/OGCFeatureLayer.d.ts +1 -1
  166. package/layers/ParquetLayer.d.ts +1 -1
  167. package/layers/RouteLayer.js +1 -1
  168. package/layers/SceneLayer.d.ts +2 -1
  169. package/layers/StreamLayer.d.ts +6 -5
  170. package/layers/SubtypeGroupLayer.d.ts +3 -4
  171. package/layers/VectorTileLayer.d.ts +1 -1
  172. package/layers/WFSLayer.d.ts +2 -1
  173. package/layers/WMSLayer.d.ts +2 -2
  174. package/layers/catalog/catalogUtils.d.ts +6 -0
  175. package/layers/ogc/wcsUtils.d.ts +6 -0
  176. package/layers/ogc/wfsUtils.d.ts +6 -0
  177. package/layers/orientedImagery/transformations/imageToWorld.d.ts +10 -0
  178. package/layers/orientedImagery/transformations/rectifyMapPoint.js +1 -1
  179. package/layers/orientedImagery/transformations/worldToImage.d.ts +10 -0
  180. package/layers/orientedImagery/types.d.ts +1 -1
  181. package/layers/support/arcadeUtils.d.ts +5 -0
  182. package/layers/support/csvUtils.d.ts +6 -0
  183. package/layers/support/fieldUtils.d.ts +9 -0
  184. package/layers/support/parquetUtils.d.ts +6 -0
  185. package/layers/support/rasterFunctionConstants.d.ts +9 -0
  186. package/layers/support/rasterFunctionUtils.d.ts +7 -0
  187. package/package.json +1 -1
  188. package/pointCloudRenderers.d.ts +44 -0
  189. package/popup/content.d.ts +48 -0
  190. package/rasterRenderers.d.ts +46 -0
  191. package/renderers/support/AuthoringInfo.d.ts +1 -1
  192. package/renderers/support/jsonUtils.d.ts +7 -0
  193. package/renderers/support/utils.d.ts +5 -0
  194. package/renderers/visualVariables/SizeVariable.d.ts +0 -3
  195. package/renderers/visualVariables/VisualVariable.d.ts +1 -1
  196. package/renderers/visualVariables/support/VisualVariableLegendOptions.d.ts +1 -1
  197. package/renderers.d.ts +46 -0
  198. package/request.d.ts +17 -0
  199. package/rest/closestFacility.d.ts +21 -0
  200. package/rest/featureService/utils.d.ts +5 -0
  201. package/rest/find.d.ts +21 -0
  202. package/rest/geometryService.d.ts +14 -0
  203. package/rest/geoprocessor.d.ts +16 -0
  204. package/rest/identify.d.ts +19 -0
  205. package/rest/imageService.d.ts +10 -0
  206. package/rest/knowledgeGraphService.d.ts +39 -0
  207. package/rest/lastMileDelivery.d.ts +12 -0
  208. package/rest/locator.d.ts +24 -0
  209. package/rest/networkService.d.ts +5 -0
  210. package/rest/networks/queryAssociations.d.ts +7 -0
  211. package/rest/networks/support/NetworkElement.d.ts +1 -1
  212. package/rest/networks/synthesizeAssociationGeometries.d.ts +7 -0
  213. package/rest/networks/trace.d.ts +6 -0
  214. package/rest/places.d.ts +34 -0
  215. package/rest/print.d.ts +74 -0
  216. package/rest/query.d.ts +33 -0
  217. package/rest/route.d.ts +18 -0
  218. package/rest/serviceArea.d.ts +18 -0
  219. package/rest/support/AreasAndLengthsParameters.d.ts +2 -2
  220. package/rest/support/AttachmentQuery.d.ts +0 -1
  221. package/rest/support/AttributeBinsQuery.d.ts +3 -3
  222. package/rest/support/AutoIntervalBinParameters.d.ts +4 -4
  223. package/rest/support/DateBinParameters.d.ts +2 -2
  224. package/rest/support/DateBinTimeInterval.d.ts +1 -1
  225. package/rest/support/DensifyParameters.d.ts +1 -1
  226. package/rest/support/DirectionsFeature.d.ts +1 -1
  227. package/rest/support/GPMessage.d.ts +1 -1
  228. package/rest/support/LastMileDeliveryParameters.d.ts +1 -1
  229. package/rest/support/QuantizationParameters.d.ts +3 -3
  230. package/rest/support/Query.d.ts +0 -1
  231. package/rest/support/QueryMixin.d.ts +1 -1
  232. package/rest/support/RelationshipQuery.d.ts +0 -1
  233. package/rest/support/interfaces.d.ts +1 -2
  234. package/rest/symbolService.d.ts +9 -0
  235. package/smartMapping/heuristics/binLevel.d.ts +12 -0
  236. package/smartMapping/heuristics/scaleRange.d.ts +15 -0
  237. package/smartMapping/heuristics/sizeRange.d.ts +12 -0
  238. package/smartMapping/labels/bins.d.ts +13 -0
  239. package/smartMapping/labels/clusters.d.ts +16 -0
  240. package/smartMapping/popup/clusters.d.ts +21 -0
  241. package/smartMapping/popup/templates.d.ts +18 -0
  242. package/smartMapping/raster/renderers/classBreaks.d.ts +7 -0
  243. package/smartMapping/raster/renderers/colormap.d.ts +7 -0
  244. package/smartMapping/raster/renderers/flow.d.ts +19 -0
  245. package/smartMapping/raster/renderers/rgb.d.ts +7 -0
  246. package/smartMapping/raster/renderers/shadedRelief.d.ts +7 -0
  247. package/smartMapping/raster/renderers/stretch.d.ts +7 -0
  248. package/smartMapping/raster/renderers/uniqueValue.d.ts +7 -0
  249. package/smartMapping/raster/renderers/vectorField.d.ts +20 -0
  250. package/smartMapping/raster/support/colorRamps.d.ts +7 -0
  251. package/smartMapping/raster/support/utils.d.ts +5 -0
  252. package/smartMapping/renderers/color.d.ts +17 -0
  253. package/smartMapping/renderers/dotDensity.d.ts +21 -0
  254. package/smartMapping/renderers/heatmap.d.ts +17 -0
  255. package/smartMapping/renderers/location.d.ts +10 -0
  256. package/smartMapping/renderers/opacity.d.ts +19 -0
  257. package/smartMapping/renderers/pieChart.d.ts +19 -0
  258. package/smartMapping/renderers/predominance.d.ts +27 -0
  259. package/smartMapping/renderers/relationship.d.ts +48 -0
  260. package/smartMapping/renderers/size.d.ts +18 -0
  261. package/smartMapping/renderers/support/rendererUtils.d.ts +8 -0
  262. package/smartMapping/renderers/support/spikeUtils.d.ts +6 -0
  263. package/smartMapping/renderers/type.d.ts +18 -0
  264. package/smartMapping/renderers/univariateColorSize.d.ts +29 -0
  265. package/smartMapping/statistics/classBreaks.d.ts +14 -0
  266. package/smartMapping/statistics/heatmapStatistics.d.ts +15 -0
  267. package/smartMapping/statistics/histogram.d.ts +17 -0
  268. package/smartMapping/statistics/predominantCategories.d.ts +6 -0
  269. package/smartMapping/statistics/summaryStatistics.d.ts +15 -0
  270. package/smartMapping/statistics/summaryStatisticsForAge.d.ts +8 -1
  271. package/smartMapping/statistics/support/ageUtils.d.ts +8 -0
  272. package/smartMapping/statistics/support/predominanceUtils.d.ts +8 -1
  273. package/smartMapping/statistics/types.d.ts +6 -1
  274. package/smartMapping/statistics/uniqueValues.d.ts +13 -0
  275. package/smartMapping/symbology/color.d.ts +8 -0
  276. package/smartMapping/symbology/dotDensity.d.ts +7 -0
  277. package/smartMapping/symbology/flow.d.ts +8 -0
  278. package/smartMapping/symbology/heatmap.d.ts +8 -0
  279. package/smartMapping/symbology/location.d.ts +8 -0
  280. package/smartMapping/symbology/pieChart.d.ts +7 -0
  281. package/smartMapping/symbology/predominance.d.ts +7 -0
  282. package/smartMapping/symbology/relationship.d.ts +7 -0
  283. package/smartMapping/symbology/size.d.ts +7 -0
  284. package/smartMapping/symbology/support/colorRamps.d.ts +7 -0
  285. package/smartMapping/symbology/type.d.ts +8 -0
  286. package/support/popupUtils.d.ts +5 -0
  287. package/support/revision.js +1 -1
  288. package/support/timeUtils.d.ts +9 -0
  289. package/symbols/CIMSymbol.d.ts +1 -1
  290. package/symbols/ExtrudeSymbol3DLayer.d.ts +2 -2
  291. package/symbols/FillSymbol3DLayer.d.ts +1 -1
  292. package/symbols/LineSymbol3DLayer.d.ts +2 -2
  293. package/symbols/ObjectSymbol3DLayer.d.ts +2 -2
  294. package/symbols/PathSymbol3DLayer.d.ts +2 -2
  295. package/symbols/TextSymbol.d.ts +2 -2
  296. package/symbols/support/Symbol3DFillMaterial.d.ts +1 -1
  297. package/symbols/support/Symbol3DFillMaterial.js +1 -1
  298. package/symbols/support/Symbol3DHalo.d.ts +8 -4
  299. package/symbols/support/Symbol3DHalo.js +1 -1
  300. package/symbols/support/cimConversionUtils.d.ts +9 -0
  301. package/symbols/support/cimSymbolUtils.d.ts +10 -0
  302. package/symbols/support/jsonUtils.d.ts +7 -0
  303. package/symbols/support/symbolUtils.d.ts +5 -0
  304. package/symbols.d.ts +59 -0
  305. package/tables/elements.d.ts +41 -0
  306. package/time/TimeExtent.d.ts +1 -1
  307. package/time/TimeInterval.d.ts +1 -1
  308. package/unionTypes.d.ts +5 -0
  309. package/versionManagement/utils.d.ts +5 -0
  310. package/versionManagement/versionAdapters/utils.d.ts +5 -0
  311. package/views/2d/MapViewConstraints.d.ts +18 -10
  312. package/views/2d/engine/vectorTiles/shaders/sources/shaderRepository.js +1 -1
  313. package/views/2d/layers/RouteLayerView2D.js +1 -1
  314. package/views/2d/layers/TileLayerView2D.js +1 -1
  315. package/views/2d/layers/support/RouteLayerInteraction.js +1 -1
  316. package/views/2d/layers/support/RouteLayerWaypointVisualization.js +5 -0
  317. package/views/3d/analysis/DirectLineMeasurement/types.d.ts +5 -0
  318. package/views/3d/analysis/LineOfSight/types.d.ts +5 -0
  319. package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementError.d.ts +1 -1
  320. package/views/3d/analysis/VolumeMeasurement/types.d.ts +5 -0
  321. package/views/3d/environment/ChapmanRaymarching.glsl.js +2 -1
  322. package/views/3d/interactive/visualElements/PointVisualElement.js +1 -1
  323. package/views/3d/layers/graphics/Deconflictor.js +1 -1
  324. package/views/3d/layers/graphics/Graphics3DCore.js +1 -1
  325. package/views/3d/layers/graphics/Graphics3DIconSymbolLayer.js +1 -1
  326. package/views/3d/layers/graphics/Graphics3DLineCalloutSymbolLayer.js +1 -1
  327. package/views/3d/layers/graphics/Graphics3DSymbolLayer.js +1 -1
  328. package/views/3d/layers/graphics/Graphics3DTextSymbolLayer.js +1 -1
  329. package/views/3d/layers/graphics/GraphicsDeconflictor.js +1 -1
  330. package/views/3d/layers/graphics/GraphicsProcessor.js +1 -1
  331. package/views/3d/layers/graphics/pipeline/symbolization/IconSymbolLayerRenderer.js +1 -1
  332. package/views/3d/state/helpers/SceneIntersectionHelper.js +1 -1
  333. package/views/3d/support/pointsOfInterest/StableSurfaceCenter.js +1 -1
  334. package/views/3d/terrain/TerrainSurface.js +1 -1
  335. package/views/3d/webgl-engine/collections/Component/Material/ComponentMaterial.js +1 -1
  336. package/views/3d/webgl-engine/core/shaderLibrary/Slice.glsl.js +2 -2
  337. package/views/3d/webgl-engine/lib/GaussianSplatRenderNode.js +1 -1
  338. package/views/3d/webgl-engine/materials/HUDMaterial.js +1 -1
  339. package/views/3d/webgl-engine/materials/LineCalloutMaterial.js +1 -1
  340. package/views/3d/webgl-engine/shaders/HUDMaterialTechniqueConfiguration.js +1 -1
  341. package/views/3d/webgl-engine/shaders/LineCalloutTechniqueConfiguration.js +1 -1
  342. package/views/3d/webgl-engine/shaders/OutputColorHighlightOLID.glsl.js +8 -8
  343. package/views/3d/webgl.d.ts +6 -0
  344. package/views/BreakpointsOwner.d.ts +16 -16
  345. package/views/IBreakpointsOwner.d.ts +15 -15
  346. package/views/MapView.d.ts +1 -1
  347. package/views/PopupView.d.ts +2 -2
  348. package/views/SelectionManager.d.ts +1 -0
  349. package/views/SelectionManager.js +1 -1
  350. package/views/VideoView.js +1 -1
  351. package/views/View.d.ts +6 -8
  352. package/views/analysis/AreaMeasurement/types.d.ts +6 -0
  353. package/views/analysis/DistanceMeasurement/types.d.ts +5 -0
  354. package/views/analysis/ElevationProfile/ElevationProfileError.d.ts +4 -4
  355. package/views/analysis/ElevationProfile/types.d.ts +6 -0
  356. package/views/analysis/types.d.ts +5 -0
  357. package/views/interactive/editGeometry/support/editPlaneUtils.js +1 -1
  358. package/views/interactive/snapping/GridSnappingEngine.js +1 -1
  359. package/views/layers/BuildingSceneLayerView.d.ts +1 -1
  360. package/views/layers/LayerView.d.ts +1 -1
  361. package/views/support/colorUtils.d.ts +5 -0
  362. package/views/support/selectionUtils.js +1 -1
  363. package/webscene/types.d.ts +5 -0
  364. package/widgets/FeatureForm/FeatureFormViewModel.d.ts +2 -2
  365. package/widgets/FeatureTable/FeatureTableViewModel.js +1 -1
  366. package/widgets/Features/FeaturesViewModel.d.ts +1 -1
  367. package/widgets/Home/HomeViewModel.d.ts +1 -1
  368. package/widgets/Locate/LocateViewModel.d.ts +2 -2
  369. package/widgets/Search/types.d.ts +5 -0
  370. package/widgets/TimeSlider/TimeSliderViewModel.d.ts +1 -1
  371. package/widgets/UtilityNetworkValidateTopology.js +1 -1
  372. package/widgets/smartMapping/support/utils.d.ts +6 -0
  373. package/widgets/support/SelectionList/FeatureItem.js +1 -1
  374. package/widgets/support/SelectionList/LayerItem.js +1 -1
  375. package/widgets/support/SelectionList/SelectionListViewModel.js +1 -1
  376. package/widgets/support/SelectionList.js +1 -1
  377. package/widgets/support/Selector2D/selectorUtils.js +1 -1
  378. package/widgets/support/symbolPreviewUtils.js +1 -1
  379. package/widgets/support/widget.d.ts +11 -0
  380. package/assets/esri/core/workers/chunks/0d1e8d5d9abee38e275e.js +0 -316
  381. package/assets/esri/core/workers/chunks/73c3ee2697265b0f7208.js +0 -1
  382. package/assets/esri/core/workers/chunks/cd2ea924cb91cdb6dde9.js +0 -1
  383. package/assets/esri/core/workers/chunks/d57577c02fb2932e8305.js +0 -1
  384. package/colorUtils.d.ts +0 -13
  385. package/core/Logger.d.ts +0 -29
  386. package/core/Message.d.ts +0 -2
  387. package/core/Message.js +0 -5
  388. package/core/accessorSupport/PropertyOrigin.d.ts +0 -2
  389. package/core/sql/sql92grammar.d.ts +0 -12
  390. package/core/string.d.ts +0 -3
  391. package/core/time.d.ts +0 -2
  392. package/core/timeUtils.d.ts +0 -2
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as i}from"tslib";import t from"../../../../Graphic.js";import e from"../../../../core/Accessor.js";import{makeHandle as r}from"../../../../core/handleUtils.js";import{destroyMaybe as s}from"../../../../core/maybe.js";import{isAbortError as n}from"../../../../core/promiseUtils.js";import{watch as o,sync as a,syncAndInitial as l}from"../../../../core/reactiveUtils.js";import{property as p,subclass as c}from"../../../../core/accessorSupport/decorators.js";import{diff as h}from"../../../../core/accessorSupport/diffUtils.js";import{UpdatingHandles as u}from"../../../../core/support/UpdatingHandles.js";import d from"../../../../layers/Layer.js";import{hydrateGraphic as y}from"../../../../layers/graphics/hydratedFeatures.js";import{getRenderingInfo as g,getRenderingInfoAsync as m}from"../../../../renderers/support/renderingInfoUtils.js";import{suspendResumeExtentOptimism as f}from"./constants.js";import{Graphics3DCore as b}from"./Graphics3DCore.js";import{Graphics3DElevationAlignment as C}from"./Graphics3DElevationAlignment.js";import{Graphics3DFrustumVisibility as w}from"./Graphics3DFrustumVisibility.js";import{Graphics3DObjectStates as V}from"./Graphics3DObjectStates.js";import{Graphics3DScaleVisibility as v}from"./Graphics3DScaleVisibility.js";import{enlargeExtent as G}from"./graphicUtils.js";import{normalizeHighlightTarget as j}from"../support/highlightUtils.js";import{hasLayerBasedScaleVisibility as E}from"../../../support/layerViewUtils.js";let S=class extends e{constructor(i){super(i),this.drapeSourcePriorityOffset=0,this.type="graphics-3d",this.graphicsCore=null,this.drapeSourceType=1,this.scaleVisibilityEnabled=!1,this.frustumVisibilityEnabled=!1,this._suspendResumeExtent=null,this._updatingHandles=new u}initialize(){const{layer:i}=this,t="effectiveScaleRange"in i?i:null,e=!E()&&this.scaleVisibilityEnabled&&null!=t,r=new b({owner:this,layer:this.owner.layer,preferredUpdatePolicy:1,graphicSymbolSupported:!0,componentFactories:{elevationAlignment:(i,t)=>new C({graphicsCoreOwner:this,graphicsCore:i,queryGraphicUIDsInExtent:t,elevationProvider:this.view.elevationProvider}),scaleVisibility:e?(i,e)=>new v({graphicsCoreOwner:this,layer:t,queryGraphicUIDsInExtent:e,graphicsCore:i,basemapTerrain:this.owner.view.basemapTerrain}):null,objectStates:i=>new V(i)}});if(this._set("graphicsCore",r),this.frustumVisibilityEnabled&&this._set("frustumVisibility",new w({graphicsCoreOwner:this})),"fullOpacity"in this.owner){const i=this.owner;this._updatingHandles.add(()=>i.fullOpacity,()=>this.graphicsCore.opacityChange())}if("elevationInfo"in i){const t=i;this._updatingHandles.add(()=>t.elevationInfo,(i,t)=>{h(i,t)&&this._updatingHandles.addPromise(this.graphicsCore.elevationInfoChange())})}this._set("initializePromise",this._initializeAsync()),this._updatingHandles.addPromise(this.initializePromise)}async _initializeAsync(){try{await this.graphicsCore.initializePromise}catch(i){if(n(i))return;throw i}this.destroyed||(this.addHandles(o(()=>this.view.clippingArea,()=>this._updateClippingExtent(),a)),this._updateClippingExtent(),this._setupSuspendResumeExtent(),this.graphicsCore.startCreateGraphics())}destroy(){this._updatingHandles.destroy(),this._set("frustumVisibility",s(this.frustumVisibility)),this._set("graphicsCore",s(this.graphicsCore))}get layer(){return this.owner.layer}get layerViewUid(){return this.owner.uid}get view(){return this.owner.view}get scaleVisibility(){return this.graphicsCore?.scaleVisibility}get elevationAlignment(){return this.graphicsCore?.elevationAlignment}get scaleVisibilitySuspended(){return!(null==this.scaleVisibility||!this.scaleVisibility.suspended)}get frustumVisibilitySuspended(){return null!=this.frustumVisibility&&this.frustumVisibility.suspended}get suspended(){return this.owner.suspended??!1}get updating(){return!!(this.graphicsCore?.updating||null!=this.scaleVisibility&&this.scaleVisibility.updating||null!=this.frustumVisibility&&this.frustumVisibility.updating||this._updatingHandles.updating)}get graphics3DGraphics(){return this.graphicsCore?.graphics3DGraphics}get graphics3DGraphicsByObjectID(){return this.graphicsCore?.graphics3DGraphicsByObjectID}get loadedGraphics(){return this.owner.loadedGraphics}get fullOpacity(){return this.owner.fullOpacity??1}get slicePlaneEnabled(){return this.owner.slicePlaneEnabled}get updatePolicy(){return this.owner.updatePolicy}notifyGraphicGeometryChanged(i){this.graphicsCore.notifyGraphicGeometryChanged(i)}notifyGraphicVisibilityChanged(i){this.graphicsCore.notifyGraphicVisibilityChanged(i)}notifyContentGeometryUpdate(){this.owner.notifyContentGeometryUpdate?.()}getRenderingInfo(i,t,e){const r=g(i,{renderer:t,arcade:e});if(r?.color){const i=r.color;i[0]=i[0]/255,i[1]=i[1]/255,i[2]=i[2]/255}return r}getRenderingInfoAsync(i,t,e,r){return m(i,{renderer:t,arcade:e,...r})}getHit(i,t){if(this.owner.loadedGraphics){const e=this.owner.loadedGraphics.find(t=>t.uid===i);if(e){const i=this.layer instanceof d?this.layer:null,r=y(e,i,t);return{type:"graphic",graphic:r,layer:r.layer}}}return null}whenGraphicBounds(i,t){return this.graphicsCore?this.graphicsCore.whenGraphicBounds(i,t):Promise.reject()}computeAttachmentOrigin(i,t){return this.graphicsCore?this.graphicsCore.computeAttachmentOrigin(i,t):null}getSymbolLayerSize(i,t){return this.graphicsCore?this.graphicsCore.getSymbolLayerSize(i,t):null}maskOccludee(i){const t=this.graphicsCore?.objectStates;if(!t)return r();const{set:e,handle:s}=t.acquireOccludeeSet(null);return t.setUid(e,i.uid),s}highlight(i,e){const r=this.graphicsCore?.objectStates;if(!r)return O;const s=j(i);if(0===s.length)return O;if(s[0]instanceof t){const i=s.map(i=>i.uid),{set:t,handle:n}=r.acquireHighlightSet(e,null);return r.setUids(t,i),n}if("number"==typeof s[0]){const i=s,{set:t,handle:n}=r.acquireHighlightSet(e,null);return r.setObjectIds(t,i),n}return O}_setupSuspendResumeExtent(){const{scaleVisibility:i,frustumVisibility:t}=this;if(null==i&&null==t)return;const e=({computedExtent:e,extentPadding:r})=>{this._suspendResumeExtent=G(e,this._suspendResumeExtent,f,r),null!=i&&i.setExtent(this._suspendResumeExtent),null!=t&&t.setExtent(this._suspendResumeExtent)};this.addHandles(o(()=>({computedExtent:this.graphicsCore?.computedExtent,extentPadding:this.graphicsCore?.extentPadding}),i=>e(i),l))}_updateClippingExtent(){const i=this.view.clippingArea;this.graphicsCore.setClippingExtent(i,this.view.spatialReference)&&this.graphicsCore.recreateAllGraphics()}};i([p()],S.prototype,"drapeSourcePriorityOffset",void 0),i([p()],S.prototype,"type",void 0),i([p({constructOnly:!0})],S.prototype,"owner",void 0),i([p()],S.prototype,"layer",null),i([p()],S.prototype,"layerViewUid",null),i([p()],S.prototype,"view",null),i([p({constructOnly:!0})],S.prototype,"graphicsCore",void 0),i([p()],S.prototype,"scaleVisibility",null),i([p({constructOnly:!0})],S.prototype,"frustumVisibility",void 0),i([p()],S.prototype,"elevationAlignment",null),i([p()],S.prototype,"scaleVisibilitySuspended",null),i([p({readOnly:!0})],S.prototype,"frustumVisibilitySuspended",null),i([p()],S.prototype,"suspended",null),i([p({readOnly:!0})],S.prototype,"updating",null),i([p()],S.prototype,"loadedGraphics",null),i([p()],S.prototype,"fullOpacity",null),i([p()],S.prototype,"slicePlaneEnabled",null),i([p()],S.prototype,"drapeSourceType",void 0),i([p()],S.prototype,"updatePolicy",null),i([p({constructOnly:!0})],S.prototype,"scaleVisibilityEnabled",void 0),i([p({constructOnly:!0})],S.prototype,"frustumVisibilityEnabled",void 0),i([p()],S.prototype,"initializePromise",void 0),S=i([c("esri.views.3d.layers.graphics.GraphicsProcessor")],S);const O=r();export{S as GraphicsProcessor};
5
+ import{__decorate as i}from"tslib";import t from"../../../../Graphic.js";import e from"../../../../core/Accessor.js";import{makeHandle as r}from"../../../../core/handleUtils.js";import{destroyMaybe as s}from"../../../../core/maybe.js";import{isAbortError as n}from"../../../../core/promiseUtils.js";import{watch as o,sync as a,syncAndInitial as l}from"../../../../core/reactiveUtils.js";import{property as p,subclass as c}from"../../../../core/accessorSupport/decorators.js";import{diff as h}from"../../../../core/accessorSupport/diffUtils.js";import{UpdatingHandles as u}from"../../../../core/support/UpdatingHandles.js";import d from"../../../../layers/Layer.js";import{hydrateGraphic as y}from"../../../../layers/graphics/hydratedFeatures.js";import{getRenderingInfo as g,getRenderingInfoAsync as m}from"../../../../renderers/support/renderingInfoUtils.js";import{suspendResumeExtentOptimism as f}from"./constants.js";import{Graphics3DCore as b}from"./Graphics3DCore.js";import{Graphics3DElevationAlignment as C}from"./Graphics3DElevationAlignment.js";import{Graphics3DFrustumVisibility as w}from"./Graphics3DFrustumVisibility.js";import{Graphics3DObjectStates as V}from"./Graphics3DObjectStates.js";import{Graphics3DScaleVisibility as v}from"./Graphics3DScaleVisibility.js";import{enlargeExtent as G}from"./graphicUtils.js";import{normalizeHighlightTarget as j}from"../support/highlightUtils.js";import{hasLayerBasedScaleVisibility as E}from"../../../support/layerViewUtils.js";let S=class extends e{constructor(i){super(i),this.drapeSourcePriorityOffset=0,this.type="graphics-3d",this.graphicsCore=null,this.drapeSourceType=1,this.scaleVisibilityEnabled=!1,this.frustumVisibilityEnabled=!1,this._suspendResumeExtent=null,this._updatingHandles=new u}initialize(){const{layer:i}=this,t="effectiveScaleRange"in i?i:null,e=!E()&&this.scaleVisibilityEnabled&&null!=t,r=new b({owner:this,layer:this.owner.layer,preferredUpdatePolicy:1,graphicSymbolSupported:!0,componentFactories:{deconflictor:i=>this.owner.view.deconflictor.addGraphicsOwner(i),elevationAlignment:(i,t)=>new C({graphicsCoreOwner:this,graphicsCore:i,queryGraphicUIDsInExtent:t,elevationProvider:this.view.elevationProvider}),scaleVisibility:e?(i,e)=>new v({graphicsCoreOwner:this,layer:t,queryGraphicUIDsInExtent:e,graphicsCore:i,basemapTerrain:this.owner.view.basemapTerrain}):null,objectStates:i=>new V(i)}});if(this._set("graphicsCore",r),this.frustumVisibilityEnabled&&this._set("frustumVisibility",new w({graphicsCoreOwner:this})),"fullOpacity"in this.owner){const i=this.owner;this._updatingHandles.add(()=>i.fullOpacity,()=>this.graphicsCore.opacityChange())}if("elevationInfo"in i){const t=i;this._updatingHandles.add(()=>t.elevationInfo,(i,t)=>{h(i,t)&&this._updatingHandles.addPromise(this.graphicsCore.elevationInfoChange())})}this._set("initializePromise",this._initializeAsync()),this._updatingHandles.addPromise(this.initializePromise)}async _initializeAsync(){try{await this.graphicsCore.initializePromise}catch(i){if(n(i))return;throw i}this.destroyed||(this.addHandles(o(()=>this.view.clippingArea,()=>this._updateClippingExtent(),a)),this._updateClippingExtent(),this._setupSuspendResumeExtent(),this.graphicsCore.startCreateGraphics())}destroy(){this._updatingHandles.destroy(),this._set("frustumVisibility",s(this.frustumVisibility)),this._set("graphicsCore",s(this.graphicsCore))}get layer(){return this.owner.layer}get layerViewUid(){return this.owner.uid}get view(){return this.owner.view}get scaleVisibility(){return this.graphicsCore?.scaleVisibility}get elevationAlignment(){return this.graphicsCore?.elevationAlignment}get scaleVisibilitySuspended(){return!(null==this.scaleVisibility||!this.scaleVisibility.suspended)}get frustumVisibilitySuspended(){return null!=this.frustumVisibility&&this.frustumVisibility.suspended}get suspended(){return this.owner.suspended??!1}get updating(){return!!(this.graphicsCore?.updating||null!=this.scaleVisibility&&this.scaleVisibility.updating||null!=this.frustumVisibility&&this.frustumVisibility.updating||this._updatingHandles.updating)}get graphics3DGraphics(){return this.graphicsCore?.graphics3DGraphics}get graphics3DGraphicsByObjectID(){return this.graphicsCore?.graphics3DGraphicsByObjectID}get loadedGraphics(){return this.owner.loadedGraphics}get fullOpacity(){return this.owner.fullOpacity??1}get slicePlaneEnabled(){return this.owner.slicePlaneEnabled}get updatePolicy(){return this.owner.updatePolicy}notifyGraphicGeometryChanged(i){this.graphicsCore.notifyGraphicGeometryChanged(i)}notifyGraphicVisibilityChanged(i){this.graphicsCore.notifyGraphicVisibilityChanged(i)}notifyContentGeometryUpdate(){this.owner.notifyContentGeometryUpdate?.()}getRenderingInfo(i,t,e){const r=g(i,{renderer:t,arcade:e});if(r?.color){const i=r.color;i[0]=i[0]/255,i[1]=i[1]/255,i[2]=i[2]/255}return r}getRenderingInfoAsync(i,t,e,r){return m(i,{renderer:t,arcade:e,...r})}getHit(i,t){if(this.owner.loadedGraphics){const e=this.owner.loadedGraphics.find(t=>t.uid===i);if(e){const i=this.layer instanceof d?this.layer:null,r=y(e,i,t);return{type:"graphic",graphic:r,layer:r.layer}}}return null}whenGraphicBounds(i,t){return this.graphicsCore?this.graphicsCore.whenGraphicBounds(i,t):Promise.reject()}computeAttachmentOrigin(i,t){return this.graphicsCore?this.graphicsCore.computeAttachmentOrigin(i,t):null}getSymbolLayerSize(i,t){return this.graphicsCore?this.graphicsCore.getSymbolLayerSize(i,t):null}maskOccludee(i){const t=this.graphicsCore?.objectStates;if(!t)return r();const{set:e,handle:s}=t.acquireOccludeeSet(null);return t.setUid(e,i.uid),s}highlight(i,e){const r=this.graphicsCore?.objectStates;if(!r)return O;const s=j(i);if(0===s.length)return O;if(s[0]instanceof t){const i=s.map(i=>i.uid),{set:t,handle:n}=r.acquireHighlightSet(e,null);return r.setUids(t,i),n}if("number"==typeof s[0]){const i=s,{set:t,handle:n}=r.acquireHighlightSet(e,null);return r.setObjectIds(t,i),n}return O}_setupSuspendResumeExtent(){const{scaleVisibility:i,frustumVisibility:t}=this;if(null==i&&null==t)return;const e=({computedExtent:e,extentPadding:r})=>{this._suspendResumeExtent=G(e,this._suspendResumeExtent,f,r),null!=i&&i.setExtent(this._suspendResumeExtent),null!=t&&t.setExtent(this._suspendResumeExtent)};this.addHandles(o(()=>({computedExtent:this.graphicsCore?.computedExtent,extentPadding:this.graphicsCore?.extentPadding}),i=>e(i),l))}_updateClippingExtent(){const i=this.view.clippingArea;this.graphicsCore.setClippingExtent(i,this.view.spatialReference)&&this.graphicsCore.recreateAllGraphics()}};i([p()],S.prototype,"drapeSourcePriorityOffset",void 0),i([p()],S.prototype,"type",void 0),i([p({constructOnly:!0})],S.prototype,"owner",void 0),i([p()],S.prototype,"layer",null),i([p()],S.prototype,"layerViewUid",null),i([p()],S.prototype,"view",null),i([p({constructOnly:!0})],S.prototype,"graphicsCore",void 0),i([p()],S.prototype,"scaleVisibility",null),i([p({constructOnly:!0})],S.prototype,"frustumVisibility",void 0),i([p()],S.prototype,"elevationAlignment",null),i([p()],S.prototype,"scaleVisibilitySuspended",null),i([p({readOnly:!0})],S.prototype,"frustumVisibilitySuspended",null),i([p()],S.prototype,"suspended",null),i([p({readOnly:!0})],S.prototype,"updating",null),i([p()],S.prototype,"loadedGraphics",null),i([p()],S.prototype,"fullOpacity",null),i([p()],S.prototype,"slicePlaneEnabled",null),i([p()],S.prototype,"drapeSourceType",void 0),i([p()],S.prototype,"updatePolicy",null),i([p({constructOnly:!0})],S.prototype,"scaleVisibilityEnabled",void 0),i([p({constructOnly:!0})],S.prototype,"frustumVisibilityEnabled",void 0),i([p()],S.prototype,"initializePromise",void 0),S=i([c("esri.views.3d.layers.graphics.GraphicsProcessor")],S);const O=r();export{S as GraphicsProcessor};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{create as e}from"../../../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{ONES as t}from"../../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ZEROS as r}from"../../../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{defaultPrimitive as i}from"../../../../../../symbols/support/IconSymbol3DLayerResource.js";import{mixinColorAndOpacity as n}from"../../graphicUtils.js";import{namedAnchorToHUDMaterialAnchorPos as o}from"../../placementUtils.js";import{PipelineCommand as a}from"../PipelineCommand.js";import{computeTileCenterRenderCoordinates as l,readObjectIds as s,readMapCoordinates as m,projectToRenderCoordinates as c}from"../featureData/processingUtils.js";import{inputAttributesToAttributesMap as d}from"./symbolizationUtils.js";import{createTextureInfo as u,requiresHalfTexelOffset as y,defaultBoundingBox as _}from"../../../../support/engineContent/sdfPrimitives.js";import{Attribute as p}from"../../../../webgl-engine/lib/Attribute.js";class h{constructor(e,t){this._context=null,this._symbolLayer=null,this._draped=!1,this._loaded=!1,this._loadingPromise=null,this._iconTextureID=null,this._materialId=null,this._context=t,this._symbolLayer=e}get loaded(){return this._loaded}load(){return null==this._loadingPromise&&(this._loadingPromise=this._load()),this._loadingPromise}_destroy(){this._iconTextureID=null}async _load(){const e=this._context.renderCommandContext,t=await e.createTexture(()=>u("circle"));this._iconTextureID=t;const r={anchorPosition:o.center,occlusionTest:!0,hasSlicePlane:!1,color:this._getFillColor(),outlineColor:this._getOutlineColor(),outlineSize:1,distanceFieldBoundingBox:_,textureId:t,textureIsSignedDistanceField:!0,sampleSignedDistanceFieldTexelCenter:y("circle")},i=new Uint8Array(8),n=0,a=255;i[0]=n,i[1]=n,i[2]=n,i[3]=a,i[4]=a,i[5]=n,i[6]=a,i[7]=a,this._materialId=await e.createMaterial({type:"hud",parameters:r}),await e.createDirectRenderer(this._materialId),await e.setBaseInstance(this._materialId,{data:i.buffer,elementCount:4}),this._loaded=!0}async createAddCommand(e){const{_materialId:t,_context:r}=this,{renderCommandContext:i}=r;if(null==t)throw new Error("expected material not to be null");const n=await this._createGeometry(e);if(null==n)return r.createPipelineCommand();const o=l(e,r);return r.createPipelineCommand(i.addDirectRendererGeometry(e.id,n,o))}async _createGeometry(t){const{_materialId:r,_context:i}=this,{mainThreadDelegate:n}=i,{featureCount:o}=t;if(0===o||null==r)return null;const a=s(t),l=m(t),u=await n.applyElevationAlignmentTo(l),y=c(u,i),_=new Float64Array([0,0,1]),h=new Float64Array([255,255,255,255]),C=new Float64Array([24,24]),f=new Float64Array([0,0,0,1]),g=new Float64Array([0]),x=new Uint32Array(o);for(let e=0;e<o;++e)x[e]=e;const w=new Uint32Array(o);for(let e=0;e<o;++e)w[e]=0;const b=[["position",new p(y,x,3,!0)],["normal",new p(_,w,3,!0)],["color",new p(h,w,4,!0)],["rotation",new p(g,w,1,!0)],["size",new p(C,w,2,!0)],["centerOffsetAndDistance",new p(f,w,4,!0)]],I=new Uint8Array(o);t.getVisibilityArray(I);return{attributes:d(b),olidColor:void 0,transformation:e(),materialId:r,objectIds:a,visibilities:I}}async createRemoveCommand(e){const{_materialId:t,_context:r}=this,i=r.renderCommandContext;return null==t?r.createPipelineCommand():r.createPipelineCommand(i.removeDirectRendererGeometryBuffer(t,e))}async createUpdateVisibilityCommand(e){const{_materialId:t,_context:r}=this,i=r.renderCommandContext;if(null==t)return r.createPipelineCommand();const n=new Uint8Array(e.featureCount);return e.getVisibilityArray(n),r.createPipelineCommand(i.updateVisibility(t,e.id,n))}async createUpdateLayerViewOpacityCommand(e){const{_context:t,_materialId:r}=this,i=t.renderCommandContext;return null==r?t.createPipelineCommand():t.createPipelineCommand(i.updateMaterial({type:"hud",materialId:r,parameters:{color:this._getFillColor(),outlineColor:this._getOutlineColor()}}))}async createUpdateElevationCommand(e){const{_materialId:t,_context:r}=this,{renderCommandContext:i}=r,{featureCount:n,id:o}=e;if(null==t||0===n)return r.createPipelineCommand();const a=await this._createGeometry(e);if(null==a)return r.createPipelineCommand();const s=l(e,r);return r.createPipelineCommand(i.updateDirectRendererGeometry(o,a,s))}async createDestroyCommand(){const{_iconTextureID:e,_context:t}=this,r=t.renderCommandContext;let i;return i=null!=e?await r.releaseTexture(e):a.create(r),i.appendPipelineStateCommand(()=>this._destroy()),i}_getOutlineColor(){const e=this._getLayerOpacity(),t=this._symbolLayer,r=t?.outline?.color;if(null!=r){const t=r.toUnitRGB(),i=r.a*e;return[t[0],t[1],t[2],i]}return[0,0,0,0]}_getFillColor(){if(C(this._getPrimitive()))return x;const e=null==this._getPrimitive(),t=this._symbolLayer?.material?.color;return this._getCombinedOpacityAndColor(t,{hasIntrinsicColor:e})}_getLayerOpacity(){return this._context.layerViewInfo.fullOpacity}_getCombinedOpacity(e,t=g){const r=this._draped?1:this._getLayerOpacity();return e?r*e.a:t.hasIntrinsicColor?r:0}_getCombinedOpacityAndColor(e,r=g){const i=this._getCombinedOpacity(e,r),o=e?.toUnitRGB()??t;return n(o,i)}_getPrimitive(){return f(this._symbolLayer)}}function C(e){return null!=e&&("cross"===e||"x"===e)}function f(e){return e.resource?.href?null:e.resource?.primitive??i}const g={hasIntrinsicColor:!1},x=r;export{h as IconSymbolLayerRenderer,g as defaultMaterialOptions,f as getPrimitive,C as isOutlineOnly,x as transparentUnit};
5
+ import{create as e}from"../../../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{ONES as t}from"../../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ZEROS as r}from"../../../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{defaultPrimitive as i}from"../../../../../../symbols/support/IconSymbol3DLayerResource.js";import{mixinColorAndOpacity as n}from"../../graphicUtils.js";import{namedAnchorToHUDMaterialAnchorPos as o}from"../../placementUtils.js";import{PipelineCommand as a}from"../PipelineCommand.js";import{computeTileCenterRenderCoordinates as l,readObjectIds as s,readMapCoordinates as m,projectToRenderCoordinates as c}from"../featureData/processingUtils.js";import{inputAttributesToAttributesMap as d}from"./symbolizationUtils.js";import{createTextureInfo as u,requiresHalfTexelOffset as y,defaultBoundingBox as _}from"../../../../support/engineContent/sdfPrimitives.js";import{Attribute as p}from"../../../../webgl-engine/lib/Attribute.js";class h{constructor(e,t){this._context=null,this._symbolLayer=null,this._draped=!1,this._loaded=!1,this._loadingPromise=null,this._iconTextureID=null,this._materialId=null,this._context=t,this._symbolLayer=e}get loaded(){return this._loaded}load(){return null==this._loadingPromise&&(this._loadingPromise=this._load()),this._loadingPromise}_destroy(){this._iconTextureID=null}async _load(){const e=this._context.renderCommandContext,t=await e.createTexture(()=>u("circle"));this._iconTextureID=t;const r={anchorPosition:o.center,useVisibilityPixel:!0,hasSlicePlane:!1,color:this._getFillColor(),outlineColor:this._getOutlineColor(),outlineSize:1,distanceFieldBoundingBox:_,textureId:t,textureIsSignedDistanceField:!0,sampleSignedDistanceFieldTexelCenter:y("circle")},i=new Uint8Array(8),n=0,a=255;i[0]=n,i[1]=n,i[2]=n,i[3]=a,i[4]=a,i[5]=n,i[6]=a,i[7]=a,this._materialId=await e.createMaterial({type:"hud",parameters:r}),await e.createDirectRenderer(this._materialId),await e.setBaseInstance(this._materialId,{data:i.buffer,elementCount:4}),this._loaded=!0}async createAddCommand(e){const{_materialId:t,_context:r}=this,{renderCommandContext:i}=r;if(null==t)throw new Error("expected material not to be null");const n=await this._createGeometry(e);if(null==n)return r.createPipelineCommand();const o=l(e,r);return r.createPipelineCommand(i.addDirectRendererGeometry(e.id,n,o))}async _createGeometry(t){const{_materialId:r,_context:i}=this,{mainThreadDelegate:n}=i,{featureCount:o}=t;if(0===o||null==r)return null;const a=s(t),l=m(t),u=await n.applyElevationAlignmentTo(l),y=c(u,i),_=new Float64Array([0,0,1]),h=new Float64Array([255,255,255,255]),C=new Float64Array([24,24]),f=new Float64Array([0,0,0,1]),g=new Float64Array([0]),x=new Uint32Array(o);for(let e=0;e<o;++e)x[e]=e;const w=new Uint32Array(o);for(let e=0;e<o;++e)w[e]=0;const b=[["position",new p(y,x,3,!0)],["normal",new p(_,w,3,!0)],["color",new p(h,w,4,!0)],["rotation",new p(g,w,1,!0)],["size",new p(C,w,2,!0)],["centerOffsetAndDistance",new p(f,w,4,!0)]],I=new Uint8Array(o);t.getVisibilityArray(I);return{attributes:d(b),olidColor:void 0,transformation:e(),materialId:r,objectIds:a,visibilities:I}}async createRemoveCommand(e){const{_materialId:t,_context:r}=this,i=r.renderCommandContext;return null==t?r.createPipelineCommand():r.createPipelineCommand(i.removeDirectRendererGeometryBuffer(t,e))}async createUpdateVisibilityCommand(e){const{_materialId:t,_context:r}=this,i=r.renderCommandContext;if(null==t)return r.createPipelineCommand();const n=new Uint8Array(e.featureCount);return e.getVisibilityArray(n),r.createPipelineCommand(i.updateVisibility(t,e.id,n))}async createUpdateLayerViewOpacityCommand(e){const{_context:t,_materialId:r}=this,i=t.renderCommandContext;return null==r?t.createPipelineCommand():t.createPipelineCommand(i.updateMaterial({type:"hud",materialId:r,parameters:{color:this._getFillColor(),outlineColor:this._getOutlineColor()}}))}async createUpdateElevationCommand(e){const{_materialId:t,_context:r}=this,{renderCommandContext:i}=r,{featureCount:n,id:o}=e;if(null==t||0===n)return r.createPipelineCommand();const a=await this._createGeometry(e);if(null==a)return r.createPipelineCommand();const s=l(e,r);return r.createPipelineCommand(i.updateDirectRendererGeometry(o,a,s))}async createDestroyCommand(){const{_iconTextureID:e,_context:t}=this,r=t.renderCommandContext;let i;return i=null!=e?await r.releaseTexture(e):a.create(r),i.appendPipelineStateCommand(()=>this._destroy()),i}_getOutlineColor(){const e=this._getLayerOpacity(),t=this._symbolLayer,r=t?.outline?.color;if(null!=r){const t=r.toUnitRGB(),i=r.a*e;return[t[0],t[1],t[2],i]}return[0,0,0,0]}_getFillColor(){if(C(this._getPrimitive()))return x;const e=null==this._getPrimitive(),t=this._symbolLayer?.material?.color;return this._getCombinedOpacityAndColor(t,{hasIntrinsicColor:e})}_getLayerOpacity(){return this._context.layerViewInfo.fullOpacity}_getCombinedOpacity(e,t=g){const r=this._draped?1:this._getLayerOpacity();return e?r*e.a:t.hasIntrinsicColor?r:0}_getCombinedOpacityAndColor(e,r=g){const i=this._getCombinedOpacity(e,r),o=e?.toUnitRGB()??t;return n(o,i)}_getPrimitive(){return f(this._symbolLayer)}}function C(e){return null!=e&&("cross"===e||"x"===e)}function f(e){return e.resource?.href?null:e.resource?.primitive??i}const g={hasIntrinsicColor:!1},x=r;export{h as IconSymbolLayerRenderer,g as defaultMaterialOptions,f as getPrimitive,C as isOutlineOnly,x as transparentUnit};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import"../../../../core/has.js";import e from"../../../../core/PooledArray.js";import{createRenderScreenPointArray3 as t,castRenderScreenPointArray3 as r}from"../../../../core/screenUtils.js";import{getMetersPerVerticalUnitForSR as n}from"../../../../core/units.js";import{i,n as s,g as o}from"../../../../chunks/vec32.js";import{create as l}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as a,copy as c,negativeInfinity as u,width as h,height as p,expandPointInPlace as d}from"../../../../geometry/support/aaBoundingRect.js";import{create as m}from"../../../../geometry/support/ray.js";import{sv3d as y}from"../../../../geometry/support/vectorStacks.js";import{getElevationOffsetInMeters as f}from"../../../../support/elevationInfoUtils.js";import{computeMapPointFromVec3d as g}from"../../support/hitTest.js";import{fromRenderAtEye as _,fromScreen as w}from"../../support/geometryUtils/ray.js";import{defaultTolerance as R,Intersector as b}from"../../webgl-engine/lib/Intersector.js";import{isValidIntersectorResult as v}from"../../webgl-engine/lib/IntersectorResult.js";import{sliceFilterPredicate as I}from"../../webgl-engine/lib/intersectorUtils.js";import{HUDMaterial as P}from"../../webgl-engine/materials/HUDMaterial.js";class j{constructor(t,r,n){this.viewingMode=t,this._forEachLayer=r,this._view=n,this._externalIntersectionHandlers=new e,this._tolerance=R,this._tmpRay=m(),this._tmpRegion=a(),this._validateHUDIntersector=new b(this.viewingMode),this._validateHUDIntersector.options.hud=!1}destroy(){this._externalIntersectionHandlers.prune()}intersectScreen(e,t,r){return this.intersectRay(this._getPickRay(e,this._tmpRay),L(this.viewingMode),t,r)}intersectScreenFreePointFallback(e,t,r){return this.intersectRayFreePointFallback(this._getPickRay(e,this._tmpRay),t,r)}intersectRayFreePointFallback(e,t,r){return this.intersectRay(e,L(this.viewingMode),t,r)||this._intersectRayFreePointLocal(e,t)}intersectRay(e,t,r,n){return t.options.selectionMode=!1,t.options.store=0,this.computeIntersection(e,t,!1,n),!!t.results.min&&t.results.min.getIntersectionPoint(r)}getCenterRayWithSubpixelOffset(e,t,r=.5,n=.5){return e.getRenderCenter(F,r,n),F[0]+=.0466,F[1]-=.0123,_(e,F,t)}intersectIntersectorScreen(e,t,r){this.computeIntersection(this._getPickRay(e,this._tmpRay),t,!1,r)}intersectToolIntersectorScreen(e,t,r){const n=this._getPickRay(e,this._tmpRay);this.intersectToolIntersectorRay(n,t,r)}intersectToolIntersectorRay(e,t,r){t.options.selectionMode=!0,this.computeIntersection(e,t,!1,r);const n=t.results.min;!!this._view.basemapTerrain&&this._view.basemapTerrain.opaque||v(n)&&7!==n.intersector||(t.options.selectionMode=!1,this.computeIntersection(e,t,!1,r))}setTolerance(e=R){this._tolerance=e}addIntersectionHandler(e){this._externalIntersectionHandlers.push(e),this._externalIntersectionHandlers.sort((e,t)=>7===e.type?1:7===t.type?-1:0)}removeIntersectionHandler(e){null!=this._externalIntersectionHandlers.removeUnordered(e)&&this._externalIntersectionHandlers.sort((e,t)=>7===e.type?1:7===t.type?-1:0)}_getPickRay(e,t){const r=this._view.state.camera;return w(r,e,t)}_intersectRayFreePointLocal(e,t){return 2!==this.viewingMode||null==e||i(t,e.origin,s(y.get(),e.direction)),!1}intersectElevationFromScreen(e,t,r=0,n=null){return this._intersectElevation(this._getPickRay(e,this._tmpRay),t,r,n)}_intersectElevation(e,t,l=0,a=null){if(null==e)return null;const c=this._view,{renderCoordsHelper:u}=c,h=n(c.spatialReference),p=null!=t?t.mode:"absolute-height",d=f(t)/h,m=("on-the-ground"!==p?d+l:0)*h/u.unitInMeters,{camera:_}=c.state;if("absolute-height"===p){const t=u?.getAltitude(_.eye),r=o(s(E,e.direction),u.worldUpAtPosition(_.eye,V));if(t<m&&r<0||t>=m&&r>0)return null;if(u.intersectInfiniteManifold(e,m,E)){const e=g(c,E);return e.z??=0,e.z-=d,e}return null}const w=_.projectToRenderScreen(e.origin,r(y.get())),R=new k(null,this._forEachLayer),v=c.slice.plane,P=v?I(v):null,j=new b(this.viewingMode);j.options.store=0,j.options.verticalOffset=m,j.options.normalRequired=!1;const x=e.origin,M=i(y.get(),x,e.direction);j.reset(x,M,_),j.point=w;let U=null;if(a&&"type"in a&&"graphics"===a.type){const e=c.allLayerViews.find(e=>e.layer===a)?.uid;U=e?t=>t.layerViewUid===e:null}else a&&(U=e=>e.graphicUid!==a.uid);switch(p){case"relative-to-scene":{const e=e=>(!U||U(e))&&!!e.lastValidElevationBB;j.intersect(R.layers,w,this._tolerance,null,e),this._externalIntersectionHandlers.forAll(e=>{if(2===e.type||7===e.type||8===e.type){const t=e.slicePlaneEnabled?P:null;e.intersect(j,t,j.rayBegin,j.rayEnd,w,!1)}});break}case"on-the-ground":case"relative-to-ground":this._externalIntersectionHandlers.forAll(e=>{if(e.isGround){const t=e.slicePlaneEnabled?P:null;e.intersect(j,t,j.rayBegin,j.rayEnd,w,!1)}})}if(j.results.min.getIntersectionPoint(E)){const e=g(c,E);return e.z=l,e}return null}computeIntersection(e,t,n,s){if(null==e)return;const o=this._view.state.camera,l=o.projectToRenderScreen(e.origin,r(y.get())),a=new k(s,this._forEachLayer);t.options.selectOpaqueTerrainOnly=!s||!("include"in s||"exclude"in s);const c=e.origin,u=i(y.get(),e.origin,e.direction);t.reset(c,u,o),t.intersect(a.layers,l,this._tolerance);const h=this._view.slice.plane,p=null!=h?I(h):null;t.intersect(a.sliceableLayers,l,this._tolerance,p);const d=s&&(s.requiresGroundFeedback||s.enableDraped);this._externalIntersectionHandlers.forAll(e=>{const r=e.layerViewUid,i=e.sublayerId,s=Array.isArray(r),o=s?r:[r];s&&(t.options.filteredLayerViewUids=[]);let h=!1;for(const n of o)a.filterLayerViewUid(n,i)?h=!0:s&&t.options.filteredLayerViewUids.push(n);if(t.options.isFiltered=!h,e.isGround&&d||!t.options.isFiltered){const r=e.slicePlaneEnabled?p:null;e.intersect(t,r,c,u,l,n)}});const m=y.get(),f=this._view,g=f.basemapTerrain;if(s&&s.enableDraped&&null!=g.spatialReference&&t.results.ground.getIntersectionPoint(m)){const e=f.overlayManager.renderer,r=f.renderCoordsHelper.spatialReference,n=y.get();f.renderCoordsHelper.fromRenderCoords(m,n,g.spatialReference),n[2]=f.elevationProvider?.getElevation(m[0],m[1],m[2],r,"ground")??0,e.intersect(t,n,t.results.ground,e=>a.filterRenderGeometry(e))}t.sortResults(),this._processHUDResults(t)}_processHUDResults(e){const t=e.results.hud;c(this._tmpRegion,u);const r=this._view.state.camera,n=[],i=this._tmpRegion,s=e=>{const t=new U(e),s=t.result.target.object.geometries.every(e=>e.material instanceof P&&e.material.parameters.occlusionTest);n.push({item:t,occlusionTest:s}),s&&(r.projectToRenderScreen(e.target.center,t.screenPoint),t.screenPoint[0]=Math.floor(t.screenPoint[0]),t.screenPoint[1]=Math.floor(t.screenPoint[1]),d(i,t.screenPoint))};e.sortResults(t.all),null!=t.min.distance&&s(t.min);for(const c of t.all)t.min.target.object!==c.target.object&&t.max.target.object!==c.target.object&&s(c);if(null!=t.max.distance&&t.max.target.object!==t.min.target.object&&s(t.max),!n.length)return;i[0]===i[2]&&(i[2]+=1),i[1]===i[3]&&(i[3]+=1);const o=r.fullWidth,l=r.fullHeight,a=Math.max(0,i[0]-x),m=Math.max(0,i[1]-x),y=Math.min(h(i)+2*x,o-a),f=Math.min(p(i)+2*x,l-m),g=y>0&&f>0?new Uint8Array(y*f*4):null;g&&this._view.stage.renderer.readHUDVisibility(a,m,y,f,g);let _=!0;const w=null==e.results.max.distance;let R=0;for(const{item:c,occlusionTest:u}of n){let t=!u;if(u&&g)for(const e of M){const r=4*(Math.min(c.screenPoint[0]+e[0],o)-i[0]+(Math.min(c.screenPoint[1]+e[1],l)-i[1])*y);if(r>=0&&r<g.length&&g[r]){t=!0;break}}t&&(_&&(e.results.min.copy(c.result),_=!1),w&&e.results.max.copy(c.result),2===e.options.store&&e.results.all.splice(R++,0,c.result))}}}const x=1,M=(()=>{const e=[],t=x;for(let r=-t;r<=t;r++)for(let n=-t;n<=t;n++)e.push([n+t,r+t]);return e})();class U{constructor(e){this.result=e,this.screenPoint=t()}}let H;function L(e){return H&&H.viewingMode===e||(H=new b(e)),H}class k{constructor(e,t){this.layers=new Array,this.sliceableLayers=new Array,this.include=e?.include,this.exclude=e?.exclude,t(e=>{e.pickable&&this.filterLayerViewUid(e.apiLayerViewUid)&&(e.sliceable?this.sliceableLayers:this.layers).push(e)})}filterLayerViewUid(e,t){const{include:r,exclude:n}=this;if(null==e)return null==r&&null==n;const i=r instanceof Map?r.get(e)??!1:r?.has(e),s=n instanceof Map?n.get(e)??!1:n?.has(e);return(null==i||("boolean"==typeof i?i:null!=t&&i.has(t)))&&(null==s||!("boolean"==typeof s?s:null!=t&&s.has(t)))}filterRenderGeometry(e){return this.filterLayerViewUid(e.layerViewUid)}}function T(e){return"object"==typeof e&&"intersect"in e}const E=l(),V=l(),F=t();export{j as SceneIntersectionHelper,T as isIntersectionHandler};
5
+ import"../../../../core/has.js";import e from"../../../../core/PooledArray.js";import{createRenderScreenPointArray3 as t,castRenderScreenPointArray3 as r}from"../../../../core/screenUtils.js";import{getMetersPerVerticalUnitForSR as i}from"../../../../core/units.js";import{i as n,n as s,g as o}from"../../../../chunks/vec32.js";import{create as l}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as a,copy as c,negativeInfinity as u,width as h,height as p,expandPointInPlace as d}from"../../../../geometry/support/aaBoundingRect.js";import{create as m}from"../../../../geometry/support/ray.js";import{sv3d as y}from"../../../../geometry/support/vectorStacks.js";import{getElevationOffsetInMeters as f}from"../../../../support/elevationInfoUtils.js";import{computeMapPointFromVec3d as g}from"../../support/hitTest.js";import{fromRenderAtEye as _,fromScreen as b}from"../../support/geometryUtils/ray.js";import{defaultTolerance as w,Intersector as R}from"../../webgl-engine/lib/Intersector.js";import{isValidIntersectorResult as v}from"../../webgl-engine/lib/IntersectorResult.js";import{sliceFilterPredicate as P}from"../../webgl-engine/lib/intersectorUtils.js";import{HUDMaterial as I}from"../../webgl-engine/materials/HUDMaterial.js";class j{constructor(t,r,i){this.viewingMode=t,this._forEachLayer=r,this._view=i,this._externalIntersectionHandlers=new e,this._tolerance=w,this._tmpRay=m(),this._tmpRegion=a(),this._validateHUDIntersector=new R(this.viewingMode),this._validateHUDIntersector.options.hud=!1}destroy(){this._externalIntersectionHandlers.prune()}intersectScreen(e,t,r){return this.intersectRay(this._getPickRay(e,this._tmpRay),L(this.viewingMode),t,r)}intersectScreenFreePointFallback(e,t,r){return this.intersectRayFreePointFallback(this._getPickRay(e,this._tmpRay),t,r)}intersectRayFreePointFallback(e,t,r){return this.intersectRay(e,L(this.viewingMode),t,r)||this._intersectRayFreePointLocal(e,t)}intersectRay(e,t,r,i){return t.options.selectionMode=!1,t.options.store=0,this.computeIntersection(e,t,!1,i),!!t.results.min&&t.results.min.getIntersectionPoint(r)}getCenterRayWithSubpixelOffset(e,t,r=.5,i=.5){return e.getRenderCenter(T,r,i),T[0]+=.0466,T[1]-=.0123,_(e,T,t)}intersectIntersectorScreen(e,t,r){this.computeIntersection(this._getPickRay(e,this._tmpRay),t,!1,r)}intersectToolIntersectorScreen(e,t,r){const i=this._getPickRay(e,this._tmpRay);this.intersectToolIntersectorRay(i,t,r)}intersectToolIntersectorRay(e,t,r){t.options.selectionMode=!0,this.computeIntersection(e,t,!1,r);const i=t.results.min;!!this._view.basemapTerrain&&this._view.basemapTerrain.opaque||v(i)&&7!==i.intersector||(t.options.selectionMode=!1,this.computeIntersection(e,t,!1,r))}setTolerance(e=w){this._tolerance=e}addIntersectionHandler(e){this._externalIntersectionHandlers.push(e),this._externalIntersectionHandlers.sort((e,t)=>7===e.type?1:7===t.type?-1:0)}removeIntersectionHandler(e){null!=this._externalIntersectionHandlers.removeUnordered(e)&&this._externalIntersectionHandlers.sort((e,t)=>7===e.type?1:7===t.type?-1:0)}_getPickRay(e,t){const r=this._view.state.camera;return b(r,e,t)}_intersectRayFreePointLocal(e,t){return 2!==this.viewingMode||null==e||n(t,e.origin,s(y.get(),e.direction)),!1}intersectElevationFromScreen(e,t,r=0,i=null){return this._intersectElevation(this._getPickRay(e,this._tmpRay),t,r,i)}_intersectElevation(e,t,l=0,a=null){if(null==e)return null;const c=this._view,{renderCoordsHelper:u}=c,h=i(c.spatialReference),p=null!=t?t.mode:"absolute-height",d=f(t)/h,m=("on-the-ground"!==p?d+l:0)*h/u.unitInMeters,{camera:_}=c.state;if("absolute-height"===p){const t=u?.getAltitude(_.eye),r=o(s(E,e.direction),u.worldUpAtPosition(_.eye,F));if(t<m&&r<0||t>=m&&r>0)return null;if(u.intersectInfiniteManifold(e,m,E)){const e=g(c,E);return e.z??=0,e.z-=d,e}return null}const b=_.projectToRenderScreen(e.origin,r(y.get())),w=new V(null,this._forEachLayer),v=c.slice.plane,I=v?P(v):null,j=new R(this.viewingMode);j.options.store=0,j.options.verticalOffset=m,j.options.normalRequired=!1;const x=e.origin,M=n(y.get(),x,e.direction);j.reset(x,M,_),j.point=b;let U=null;if(a&&"type"in a&&"graphics"===a.type){const e=c.allLayerViews.find(e=>e.layer===a)?.uid;U=e?t=>t.layerViewUid===e:null}else a&&(U=e=>e.graphicUid!==a.uid);switch(p){case"relative-to-scene":{const e=e=>(!U||U(e))&&!!e.lastValidElevationBB;j.intersect(w.layers,b,this._tolerance,null,e),this._externalIntersectionHandlers.forAll(e=>{if(2===e.type||7===e.type||8===e.type){const t=e.slicePlaneEnabled?I:null;e.intersect(j,t,j.rayBegin,j.rayEnd,b,!1)}});break}case"on-the-ground":case"relative-to-ground":this._externalIntersectionHandlers.forAll(e=>{if(e.isGround){const t=e.slicePlaneEnabled?I:null;e.intersect(j,t,j.rayBegin,j.rayEnd,b,!1)}})}if(j.results.min.getIntersectionPoint(E)){const e=g(c,E);return e.z=l,e}return null}computeIntersection(e,t,i,s){if(null==e)return;const o=this._view.state.camera,l=o.projectToRenderScreen(e.origin,r(y.get())),a=new V(s,this._forEachLayer);t.options.selectOpaqueTerrainOnly=!s||!("include"in s||"exclude"in s);const c=e.origin,u=n(y.get(),e.origin,e.direction);t.reset(c,u,o),t.intersect(a.layers,l,this._tolerance);const h=this._view.slice.plane,p=null!=h?P(h):null;t.intersect(a.sliceableLayers,l,this._tolerance,p);const d=s&&(s.requiresGroundFeedback||s.enableDraped);this._externalIntersectionHandlers.forAll(e=>{const r=e.layerViewUid,n=e.sublayerId,s=Array.isArray(r),o=s?r:[r];s&&(t.options.filteredLayerViewUids=[]);let h=!1;for(const i of o)a.filterLayerViewUid(i,n)?h=!0:s&&t.options.filteredLayerViewUids.push(i);if(t.options.isFiltered=!h,e.isGround&&d||!t.options.isFiltered){const r=e.slicePlaneEnabled?p:null;e.intersect(t,r,c,u,l,i)}});const m=y.get(),f=this._view,g=f.basemapTerrain;if(s&&s.enableDraped&&null!=g.spatialReference&&t.results.ground.getIntersectionPoint(m)){const e=f.overlayManager.renderer,r=f.renderCoordsHelper.spatialReference,i=y.get();f.renderCoordsHelper.fromRenderCoords(m,i,g.spatialReference),i[2]=f.elevationProvider?.getElevation(m[0],m[1],m[2],r,"ground")??0,e.intersect(t,i,t.results.ground,e=>a.filterRenderGeometry(e))}t.sortResults(),this._processHUDResults(t)}_processHUDResults(e){const t=e.results.hud;c(this._tmpRegion,u);const r=this._view.state.camera,i=[],n=this._tmpRegion,s=e=>{const t=new U(e),s=t.result.target.object.geometries.every(e=>e.material instanceof I&&e.material.parameters.useVisibilityPixel);i.push({item:t,useVisibilityPixel:s}),s&&(r.projectToRenderScreen(e.target.center,t.screenPoint),t.screenPoint[0]=Math.floor(t.screenPoint[0]),t.screenPoint[1]=Math.floor(t.screenPoint[1]),d(n,t.screenPoint))};e.sortResults(t.all),null!=t.min.distance&&s(t.min);for(const c of t.all)t.min.target.object!==c.target.object&&t.max.target.object!==c.target.object&&s(c);if(null!=t.max.distance&&t.max.target.object!==t.min.target.object&&s(t.max),!i.length)return;n[0]===n[2]&&(n[2]+=1),n[1]===n[3]&&(n[3]+=1);const o=r.fullWidth,l=r.fullHeight,a=Math.max(0,n[0]-x),m=Math.max(0,n[1]-x),y=Math.min(h(n)+2*x,o-a),f=Math.min(p(n)+2*x,l-m),g=y>0&&f>0?new Uint8Array(y*f*4):null;g&&this._view.stage.renderer.readHUDVisibility(a,m,y,f,g);let _=!0;const b=null==e.results.max.distance;let w=0;for(const{item:c,useVisibilityPixel:u}of i){let t=!u;if(u&&g)for(const e of M){const r=4*(Math.min(c.screenPoint[0]+e[0],o)-n[0]+(Math.min(c.screenPoint[1]+e[1],l)-n[1])*y);if(r>=0&&r<g.length&&g[r]){t=!0;break}}t&&(_&&(e.results.min.copy(c.result),_=!1),b&&e.results.max.copy(c.result),2===e.options.store&&e.results.all.splice(w++,0,c.result))}}}const x=1,M=(()=>{const e=[],t=x;for(let r=-t;r<=t;r++)for(let i=-t;i<=t;i++)e.push([i+t,r+t]);return e})();class U{constructor(e){this.result=e,this.screenPoint=t()}}let H;function L(e){return H&&H.viewingMode===e||(H=new R(e)),H}class V{constructor(e,t){this.layers=new Array,this.sliceableLayers=new Array,this.include=e?.include,this.exclude=e?.exclude,t(e=>{e.pickable&&this.filterLayerViewUid(e.apiLayerViewUid)&&(e.sliceable?this.sliceableLayers:this.layers).push(e)})}filterLayerViewUid(e,t){const{include:r,exclude:i}=this;if(null==e)return null==r&&null==i;const n=r instanceof Map?r.get(e)??!1:r?.has(e),s=i instanceof Map?i.get(e)??!1:i?.has(e);return(null==n||("boolean"==typeof n?n:null!=t&&n.has(t)))&&(null==s||!("boolean"==typeof s?s:null!=t&&s.has(t)))}filterRenderGeometry(e){return this.filterLayerViewUid(e.layerViewUid)}}function k(e){return"object"==typeof e&&"intersect"in e}const E=l(),F=l(),T=t();export{j as SceneIntersectionHelper,k as isIntersectionHandler};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as t}from"tslib";import e from"../../../../core/Accessor.js";import"../../../../core/has.js";import{abortMaybe as o}from"../../../../core/maybe.js";import"../../../../core/Error.js";import"../../../../core/Logger.js";import{watch as r,on as i}from"../../../../core/reactiveUtils.js";import{property as s,subclass as n}from"../../../../core/accessorSupport/decorators.js";import{create as l}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import p from"../../../../geometry/Point.js";import{center as a}from"../../../../geometry/support/aaBoundingRect.js";import"../../../../core/asyncUtils.js";import"../../../../core/units.js";import"../../../../core/RandomLCG.js";import"../../../../geometry/ellipsoidUtils.js";import"../../../../geometry/Extent.js";import"../../../../geometry/Geometry.js";import"../../../../geometry/Multipoint.js";import"../../../../geometry/Polygon.js";import"../../../../geometry/Polyline.js";import"../../../../geometry/SpatialReference.js";import"../../../../geometry/operators/support/GeographicTransformation.js";import"../../../../geometry/projection/projectors.js";import"../../../../geometry/support/spatialReferenceUtils.js";import"../../../../layers/support/TileElevationSampler.js";let u=class extends e{constructor(t){super(t),this.location=null,this._updateController=null}initialize(){this.view.state.isLocal&&(this.addHandles([r(()=>[this._groundView?.spatialReference,this._groundView?.groundExtent],()=>this._update()),i(()=>this._ground?.layers,"change",()=>this._update())]),this._update())}destroy(){this._updateController=o(this._updateController)}get renderLocation(){if(!this.location)return null;const t=l();return this.view.renderCoordsHelper.toRenderCoords(this.location,t),t}get _ground(){return this.view.map?.ground}get _groundView(){return this.view.groundView}_update(){if(this._updateController=o(this._updateController),null==this._groundView?.groundExtent||null==this._groundView?.spatialReference)return void this._set("location",null);const t=a(this._groundView.groundExtent),e=new p({x:t[0],y:t[1],z:0,spatialReference:this._groundView.spatialReference});this._ground&&this._ground.layers.length>0?(this._set("location",null),this._updateController=new AbortController,this._ground.queryElevation(e,{noDataValue:0,signal:this._updateController.signal,cache:this.cache}).then(t=>{this._updateController=null,this._set("location",t.geometry)}).catch(t=>{})):this._set("location",e)}};t([s({constructOnly:!0})],u.prototype,"view",void 0),t([s({constructOnly:!0})],u.prototype,"cache",void 0),t([s({readOnly:!0})],u.prototype,"location",void 0),t([s({readOnly:!0})],u.prototype,"renderLocation",null),t([s()],u.prototype,"_ground",null),t([s()],u.prototype,"_groundView",null),u=t([n("esri.views.3d.support.pointsOfInterest.StableSurfaceCenter")],u);export{u as StableSurfaceCenter};
5
+ import{__decorate as t}from"tslib";import e from"../../../../core/Accessor.js";import"../../../../core/has.js";import{abortMaybe as o}from"../../../../core/maybe.js";import"../../../../core/RandomLCG.js";import"../../../../core/Logger.js";import{watch as r,on as i}from"../../../../core/reactiveUtils.js";import{property as s,subclass as n}from"../../../../core/accessorSupport/decorators.js";import{create as l}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import p from"../../../../geometry/Point.js";import{center as a}from"../../../../geometry/support/aaBoundingRect.js";import"../../../../core/asyncUtils.js";import"../../../../core/units.js";import"../../../../geometry/ellipsoidUtils.js";import"../../../../geometry/Extent.js";import"../../../../geometry/Geometry.js";import"../../../../geometry/Multipoint.js";import"../../../../geometry/Polygon.js";import"../../../../geometry/Polyline.js";import"../../../../geometry/SpatialReference.js";import"../../../../geometry/operators/support/GeographicTransformation.js";import"../../../../geometry/projection/projectors.js";import"../../../../geometry/support/spatialReferenceUtils.js";import"../../../../layers/support/TileElevationSampler.js";let u=class extends e{constructor(t){super(t),this.location=null,this._updateController=null}initialize(){this.view.state.isLocal&&(this.addHandles([r(()=>[this._groundView?.spatialReference,this._groundView?.groundExtent],()=>this._update()),i(()=>this._ground?.layers,"change",()=>this._update())]),this._update())}destroy(){this._updateController=o(this._updateController)}get renderLocation(){if(!this.location)return null;const t=l();return this.view.renderCoordsHelper.toRenderCoords(this.location,t),t}get _ground(){return this.view.map?.ground}get _groundView(){return this.view.groundView}_update(){if(this._updateController=o(this._updateController),null==this._groundView?.groundExtent||null==this._groundView?.spatialReference)return void this._set("location",null);const t=a(this._groundView.groundExtent),e=new p({x:t[0],y:t[1],z:0,spatialReference:this._groundView.spatialReference});this._ground&&this._ground.layers.length>0?(this._set("location",null),this._updateController=new AbortController,this._ground.queryElevation(e,{noDataValue:0,signal:this._updateController.signal,cache:this.cache}).then(t=>{this._updateController=null,this._set("location",t.geometry)}).catch(t=>{})):this._set("location",e)}};t([s({constructOnly:!0})],u.prototype,"view",void 0),t([s({constructOnly:!0})],u.prototype,"cache",void 0),t([s({readOnly:!0})],u.prototype,"location",void 0),t([s({readOnly:!0})],u.prototype,"renderLocation",null),t([s()],u.prototype,"_ground",null),t([s()],u.prototype,"_groundView",null),u=t([n("esri.views.3d.support.pointsOfInterest.StableSurfaceCenter")],u);export{u as StableSurfaceCenter};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import t from"../../../Color.js";import{filterInPlace as i,difference as r}from"../../../core/arrayUtils.js";import s from"../../../core/CollectionFlattener.js";import{toConst as a}from"../../../core/compilerUtils.js";import{EventedAccessor as n}from"../../../core/Evented.js";import"../../../core/has.js";import l from"../../../core/Logger.js";import{clamp as o}from"../../../core/mathUtils.js";import{destroyMaybe as h}from"../../../core/maybe.js";import{MemCachePool as d}from"../../../core/MemCachePool.js";import p from"../../../core/ObjectPool.js";import u from"../../../core/PooledArray.js";import{throwIfAborted as c,isAbortError as g,isAborted as m}from"../../../core/promiseUtils.js";import{watch as _,syncAndInitial as f,sync as y,initial as T}from"../../../core/reactiveUtils.js";import{getMetersPerUnitForSR as v}from"../../../core/units.js";import{property as w,subclass as C}from"../../../core/accessorSupport/decorators.js";import{m as S,h as b,d as E}from"../../../chunks/vec32.js";import{create as x}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{UpdatingHandles as L}from"../../../core/support/UpdatingHandles.js";import{getReferenceEllipsoid as P,radiusModifier as R}from"../../../geometry/ellipsoidUtils.js";import U from"../../../geometry/SpatialReference.js";import{getProjector as M}from"../../../geometry/projection/projectors.js";import{projectPointToVector as D}from"../../../geometry/projection/projectPointToVector.js";import{projectVectorToVector as j}from"../../../geometry/projection/projectVectorToVector.js";import{create as I,equals as k,intersection as V,intersectsSphere as A,empty as B,expand as O}from"../../../geometry/support/aaBoundingRect.js";import{copy as G,create as N}from"../../../geometry/support/frustum.js";import{createSpatialReferenceCyclical as q}from"../../../geometry/support/normalizeUtils.js";import{isPlateCarree as F}from"../../../geometry/support/spatialReferenceUtils.js";import{Sphere as W}from"../../../geometry/support/sphere.js";import{ElevationQueryTileCache as H}from"../../../layers/support/ElevationQueryTileCache.js";import{isBaseLayer as $}from"../../../layers/support/layerUtils.js";import{debugFlags as Q}from"../support/debugFlags.js";import{ElevationRange as z}from"../support/ElevationRange.js";import{toBoundingRect as Y}from"../support/extentUtils.js";import{updatingProgress as X}from"../support/updatingProperties.js";import{ElevationBounds as K}from"./ElevationBounds.js";import{ElevationData as J,sampleElevation as Z}from"./ElevationData.js";import{ElevationUpdateEventImplementation as ee}from"./ElevationUpdateEvent.js";import{create as te}from"./ExtentHelper.js";import{LayerClasses as ie}from"./LayerClass.js";import{OverlayManager as re}from"./OverlayManager.js";import{PlanarPatch as se}from"./PlanarPatch.js";import{Queue as ae}from"./Queue.js";import{ScaleRangeQueries as ne}from"./ScaleRangeQueries.js";import{SphericalPatch as le}from"./SphericalPatch.js";import{SplitLimits as oe}from"./SplitLimits.js";import{maxRootTiles as he,tooManyRootTilesAfterChangeError as de,tooManyRootTilesForLayerError as pe,maxTileNeighborLevelDelta as ue,maxMemoryLodBias as ce}from"./TerrainConst.js";import{TerrainRenderer as ge}from"./TerrainRenderer.js";import me from"./TerrainSurfacePerformanceInfo.js";import{weakAssert as _e,isVectorTileLayerView as fe,neighborEdgeIndices as ye,internalAssert as Te,oppositeEdge as ve,isSurfaceLayerView as we,isGroupLayerView as Ce,isMapTileLayerView as Se,isBlendableLayerView as be,isElevationLayerView as Ee,releaseTerrainData as xe,enableTerrainInternalChecks as Le,oppositeCorner as Pe,enableWaterproofTests as Re,enableInternalTerrainChecks as Ue,enableTerrainWaterproofChecks as Me,neighborCornerIndices as De}from"./terrainUtils.js";import{Tile as je,lijEquals as Ie}from"./Tile.js";import{printAllocations as ke}from"./TilePerLayerInfo.js";import{sortTiles as Ve,IteratorPreorder as Ae,IteratorPostorder as Be,compareTilesByLij as Oe,hasLoadableSiblings as Ge,sortTilesByPOI as Ne}from"./tileUtils.js";import{TilingSchemeLogic as qe}from"./TilingSchemeLogic.js";import{UpsampleInfo as Fe}from"./UpsampleInfo.js";import{isCompositeBlendMode as We,blendModeFromString as He}from"../webgl-engine/core/shaderLibrary/output/BlendOptions.js";import{hasLayerBasedScaleVisibility as $e}from"../../support/layerViewUtils.js";import{ImmediateTask as Qe,TaskPriority as ze,noBudget as Ye}from"../../support/Scheduler.js";import{TextureCompressionTracker as Xe}from"../../support/TextureCompressionTracker.js";import{Yield as Ke}from"../../support/Yield.js";var Je;let Ze=class extends n{static{Je=this}get allTilesCreated(){return this._allTilesCreated}get allTiles(){return a(this._allTiles)}get renderedTiles(){return Ve(i(this._allTiles.toArray(),e=>e.visible&&e.rendered))}get demResolution(){const{_allTiles:e,tilingScheme:t}=this;if(0===e.length)return{min:1,max:1};const i=v(t.spatialReference);let r=Number.POSITIVE_INFINITY,s=Number.NEGATIVE_INFINITY;for(const a of e){const e=t.resolutionAtLevel(a.level)*i;r=Math.min(r,e),s=Math.max(s,e)}return{min:r,max:s}}constructor(e){super(e),this.terrainTextureCompressionTracker=new Xe,this._iteratorPool=new p(()=>new Ae,e=>e.remove=()=>this._iteratorPool.release(e)),this._postorderIterator=new Be,this._hasPendingUpdates=!1,this._pendingUpdates=0,this._asyncWorkItems=0,this._allTilesDirty=!0,this._allTilesSorted=!0,this._allTilesCreated=!1,this._usedMemory=null,this._performanceInfo=new me,this._viewChanged=!1,this.heading=0,this._inFrameTask=!1,this._viewChangeUpdateDirty=!1,this._eyePosRenderSR=x(),this._eyePosSurfaceSR=x(),this._splitLimits=new oe,this._layerViews=[new Array,new Array],this._layerIndexByUid=[new Map,new Map],this._basemapLayerViewHandles=new Map,this._watchUpdatingTracking=new L,this._frameTask=Qe,this._allTiles=new u,this._upsampleInfoPool=new p(()=>new Fe),this._shouldEmitChangeEvent=!1,this._rootTilesExtent=I(),this.updatingProgress=.5,this._maxNumUpdating=1,this.maxTextureScale=1.2,this._spatialReference=U.WebMercator,this._elevationProjectorCache=new Map,this.visibleElevationRange=new z(1/0,-1/0),this._rootTileElevationRange=new z(1/0,-1/0),this._projectorCache=new Map,this._tilingSchemeSpatialReference=null,this._updatingRootTiles=!1,this._pendingTilesForElevationUpdateEvent=new Set,this._pendingTilesToUpdate=new Set,this.totalGeometryUpdates=0,this.totalTileUpdates=0,this._oneBatchPerFrameTask=!0,this._layerViewsDirty=!1,this.unloadedMemory=0,this.ignoresMemoryFactor=!1,this._isWebMercator=!1,this._isWebMercatorOnPlateCarree=!1,this.enabled=!0;const{view:t}=e;this.overlayManager=new re({...e,terrainSurface:this}),this._isGlobal=!t.state?.isLocal,this._isGeographic=this._spatialReference?.isGeographic??!1,this._tileConstructor=this._isGlobal?le:se,this._ellipsoid=P(t.spatialReference),this._renderer=new ge(this.overlayManager.renderer,t.stage,this._allTiles,this.terrainTextureCompressionTracker,t.resourceController.memoryController),$e()||(this._scaleRangeQueries=new ne)}initialize(){const{view:e}=this,{resourceController:t}=e,{memoryController:i}=t;this._tileCache=new d((e,t)=>i.newCache(e,t),"terrain-tile"),this._upsampleMapCache=i.newCache("terrain-upsample",({tile:e})=>e.unloadMapData()),this._elevationQueryCache=new H(i.newCache("elevation-query"));const r=this.overlayManager;this.addHandles([_(()=>r.renderer.isEmpty,()=>this._evaluateTransparency()),_(()=>this.renderer.visible,e=>this.suspended=!e),_(()=>this.heading,e=>{this._renderer.updateHeading(e),this._updateTileTextures(0)}),_(()=>({heading:e.camera?.heading,state:e.state?.mode}),({heading:e,state:t})=>{if(null==e)return;if(this.isGlobal&&this.isGeographic||this.isWebMercatorOnPlateCarree)return void(this.heading=90*Math.round(e/90)%360);const i=Math.round(e)%360,r=Math.abs(i-this.heading);(2===t||Math.min(r,360-r)>=30)&&(this.heading=i)})],"overlayManager"),this.addHandles([_(()=>this.baseOpacity,()=>{this._handleLayerViewChanges(),this._updateTileTextures(this._evaluateTransparency()?1:2)},f),_(()=>this.hasCompositeBlendMode,()=>this._updateTileTextures(this._evaluateTransparency()?1:2),f),_(()=>this.backgroundColor,(e,t)=>{e?.equals(t)||(this._handleLayerViewChanges(),this._renderer.updateTileBackground(e))},y),_(()=>this.snapLevel,()=>this._viewChanged=!0,y),_(()=>this.view.pointsOfInterest,e=>{this._renderer.pointsOfInterest=e,this._watchUpdatingTracking.removeAll(),e&&this._watchUpdatingTracking.add(()=>e.focus?.renderLocation,()=>this._allTilesSorted=!1,{equals:S})}),_(()=>Q.TERRAIN_TILE_TREE_SHOW_TILES,t=>{t&&!this._treeDebugger?import("../layers/support/TerrainTileTree3DDebugger.js").then(({TerrainTileTree3DDebugger:t})=>{!this._treeDebugger&&Q.TERRAIN_TILE_TREE_SHOW_TILES&&(this._treeDebugger=new t({view:e}))}):t||(this._treeDebugger=h(this._treeDebugger))},T)]);const{spatialReference:a}=e;this._extentHelper=te(this.viewingMode,{layers:e.map.allLayers,layerViews:e.allLayerViews,viewSpatialReference:a});const n=new s({getCollections:()=>e.defaultsFromMap?.mapCollections?.map(({layers:e})=>e),getChildrenFunction:e=>e&&"layers"in e?e.layers:null}),l=new qe({layers:n,extentHelper:this._extentHelper,viewingMode:this.viewingMode,viewSpatialReference:a});this._set("tilingSchemeLogic",l),this._updateTilingScheme();const o=t.scheduler;this._frameTask=o.registerTask(ze.TERRAIN_SURFACE,this),this.addHandles([_(()=>this._extentHelper.stencilEnabledExtents,e=>this._renderer.setStencilEnabledLayerExtents(e),T),_(()=>this.tilingSchemeLogic.tilingScheme,()=>this._updateTilingScheme(),y),_(()=>this.groundExtent,()=>this._updateRootTiles(),T),e.on("resize",()=>this._viewChangeUpdate()),_(()=>{const t=e.state;return[this._lodBias,this.lodSnappingEnabled,e.quality,t.camera,t.contentCamera,t.fixedContentCamera]},()=>this._viewChangeUpdate(),f),_(()=>e.qualitySettings?.fadeDuration,e=>this._renderer.textureFadingEnabled=e>0,T),_(()=>e.qualitySettings?.physicallyBasedRenderingEnabled,e=>this._renderer.pbrMode=e?5:0,T),_(()=>e.qualitySettings?.tiledSurface.elevationLevelDelta,()=>this._updateAllTileGeometries()),_(()=>this.userClippingExtent,()=>this._updateClippingExtent(),y)]),this.addHandles(e.allLayerViews.on("after-changes",()=>this._layerViewsDirty=!0)),this._layerViewsDirty=!0,this._handleLayerViewChanges(),this._renderer.updateTileBackground(this.backgroundColor)}clearHandles(){this._watchUpdatingTracking?.removeAll(),this.removeAllHandles(),this._basemapLayerViewHandles.forEach((e,t)=>this._unregisterTiledLayerView(t)),this._basemapLayerViewHandles.clear()}destroy(){this._frameTask.remove(),this._frameTask=Qe,this._watchUpdatingTracking?.destroy(),this._removeAllTiles(),this._set("tilingSchemeLogic",h(this.tilingSchemeLogic)),this._basemapLayerViewHandles.forEach((e,t)=>this._unregisterTiledLayerView(t)),this._basemapLayerViewHandles.clear(),this._set("overlayManager",h(this.overlayManager)),this._tileCache=h(this._tileCache),this._allTiles.prune(),je.prune(),this._treeDebugger=h(this._treeDebugger),this._renderer.destroyed||this._renderer.destroy(),this._renderer=null,this._iteratorPool=h(this._iteratorPool),this._upsampleMapCache=h(this._upsampleMapCache),this._elevationQueryCache=h(this._elevationQueryCache),this._set("view",null),this._extentHelper=h(this._extentHelper),this._upsampleInfoPool=h(this._upsampleInfoPool),ke(),this._layerViews.forEach(e=>e.length=0),this._performanceInfo=null}get renderer(){return this._renderer}get frustum(){return this.view.state.camera.frustum}get snapLevel(){return this.lodSnappingEnabled?this.view.terrainLevel:null}get lodSnappingEnabled(){return this.view.qualitySettings.tiledSurface.reduceTileLevelDifferences}get upsampleInfoPool(){return this._upsampleInfoPool}get upsampleMapCache(){return this._upsampleMapCache}get elevationQueryCache(){return this._elevationQueryCache}get hasStencilEnabledExtents(){return this._extentHelper.stencilEnabledExtents.length>0}get userClippingExtent(){const{spatialReference:e}=this,t=this.view?.clippingArea;if(null==t||null==e)return null;const i=I(),r=Y(t,i,e)?i:null,s=this._get("userClippingExtent");return k(r,s)?s:r}get rootTilesExtent(){return this._rootTilesExtent}get groundExtent(){const e=V(this.fullGroundExtent,this.userClippingExtent,I()),t=this._get("groundExtent");return k(e,t)?t:e}get fullGroundExtent(){return null!=this._tilingSchemeExtent?this._tilingSchemeExtent:this._rootTilesExtent}get _tilingSchemeExtent(){return this.tilingSchemeLogic?.extent}get updating(){return this._hasPendingUpdates||(this._maxNumUpdating=1),this.enabled&&!!((this.readyToRun||this._watchUpdatingTracking?.updating||this._asyncWorkItems>0)&&this.ready&&!this.suspended||this.overlayManager?.updating||this.terrainTextureCompressionTracker.compressing)}get readyToRun(){return this.enabled&&(this._hasPendingUpdates||this._viewChanged||this._allTilesDirty||!this._allTilesSorted||this._layerViewsDirty||this._scaleRangeQueries?.updating||this._frameTask.updating)&&this.ready&&!this.suspended}get updatingProgressValue(){return this._maxNumUpdating=Math.max(this._pendingUpdates,this._maxNumUpdating),1-this._pendingUpdates/this._maxNumUpdating}get baseOpacity(){return this.view?.map?.ground?.opacity??1}set baseOpacity(e){this.view.map.ground.opacity=e}get viewingMode(){return this.view.state.viewingMode}get ready(){return!this.enabled||null!=this._rootTiles}get rootTiles(){return this._rootTiles}get spatialReference(){return this.tilingScheme?.spatialReference??null}get backgroundColor(){return this.view?.map?.ground?.surfaceColor}set backgroundColor(e){this.view.map.ground.surfaceColor=e}set slicePlaneEnabled(e){this._renderer.slicePlaneEnabled=e,this._set("slicePlaneEnabled",e),this._evaluateTransparency()}get tilingSchemeLocked(){return this.tilingSchemeLogic?.tilingSchemeLocked??!1}get wireframe(){return this._renderer?.wireframe}set wireframe(e){e!==this._renderer.wireframe&&(this._renderer.wireframe=e,this._updateAllTileGeometries())}get opaque(){return 0===this._renderer.transparency}get invisible(){return 3===this._renderer.transparency}set suspended(e){this._set("suspended",e),this._viewChangeUpdate()}get fadeDuration(){return this.view.qualitySettings.fadeDuration??0}intersect(e,t,i,r){this._renderer.intersect(e,t,i,r)}getElevationLevelDelta(e){return e<4?3:this.view.qualitySettings.tiledSurface.elevationLevelDelta}get _xNormalizer(){return q(this._spatialReference)}getElevation(e,t,i,r){const s=this._rootTiles;if(!s?.length||!this.enabled)return null;if(0===s[0].layerInfo[0].length)return null;let a=this._elevationProjectorCache.get(r);if(void 0===a&&(a=M(r,this._spatialReference)??null,this._elevationProjectorCache.set(r,a)),null==a)return l.getLogger(this).error("TerrainSurface.getElevation(): could not project given point to tiling scheme coordinate system"),null;const n=b(tt,e,t,i);a(n,0,n,0);return lt(s,this._xNormalizer?.normalize(n[0])??n[0],n[1])}getElevations(e,t,i){const r=this._rootTiles,s=r?r[0].layerInfo[0].length:0;if(r?.length&&0!==s&&this.enabled)for(let a=0;a<t;++a){const t=3*a;i(a,lt(r,e[t],e[t+1]))}else for(let a=0;a<t;++a)i(a,null)}getLayerIndexByUID(e,t){return this._layerIndexByUid[e].get(t)}getScale(e){if(!this.tilingScheme)return null;if(!D(e,tt,this.spatialReference))return l.getLogger(this).error("TerrainSurface.getScale(): could not project given point to tiling scheme coordinate system"),null;const t=this._rootTiles;if(null!=t)for(const i of t)if(i?.containsPoint(tt)){let e=i;for(;e.children[0]&&!e.rendered;){const t=e.children[0].extent;let i=0;tt[0]>t[2]&&(i+=1),tt[1]<t[1]&&(i+=2),e=e.children[i]}return this._getLodBiasCorrectedScale(e.level)}return 1/0}_ensureProjector(e){const t=this._projectorCache.get(e);if(t)return t;const i=M(e,this._tilingSchemeSpatialReference)??null;return this._projectorCache.set(e,i),i}getSphereElevationRange(e,t){if(!this.enabled||null==this._rootTiles)return null;const i=this._ensureProjector(t);if(null==i)return l.getLogger(this).error("TerrainSurface.getSphereElevationRange(): could not project given point to tiling scheme coordinate system"),null;it.copy(e),i(it.center,0,it.center,0);const r=new z,s=this._rootTiles;if(null!=s){const e=[];for(const i of s)e.push(i);let t=0;for(;t<e.length;){const i=e[t];if(++t,!A(i.extent,it))continue;const s=i.children;if(null==s[0]||i.rendered)r.expandElevationRangeValues(i.elevationBoundsMin,i.elevationBoundsMax);else for(const t of s)e.push(t)}}return r}getRootElevationRange(){return this.enabled&&null!=this._rootTiles?new z(this._rootTileElevationRange.minElevation,this._rootTileElevationRange.maxElevation):null}getLowerBoundRadius(){const e=(this._ellipsoid.radius+this.visibleElevationRange.minElevation)*R;return Math.min(e,this._ellipsoid.radius)}getSphereScale(e,t){if(!this.tilingScheme)return null;if(!D(e,it.center,this.spatialReference))return l.getLogger(this).error("TerrainSurface.getSphereScale(): could not project given point to tiling scheme coordinate system"),null;it.radius=t;let i=null;const r=e=>{if(e&&A(e.extent,it)){const t=e.children;if(t[0]&&!e.rendered)for(const e of t)r(e);else{const t=this._getLodBiasCorrectedScale(e.level);i=null==i?t:Math.min(i,t)}}},s=this._rootTiles;if(null!=s)for(const a of s)r(a);return i}queryVisibleScaleRange(e,t,i,r){if(!this._scaleRangeQueries)return;const s=t?this.tilingScheme.levelAtScale(t):0,a=i?this.tilingScheme.levelAtScale(i):1/0,n=this._lodBias;this._scaleRangeQueries.queryVisibleLevelRange(e,s+n,a+n,r)}_evaluateTransparency(){const e=this.baseOpacity,t=this.overlayManager.renderer.isEmpty,i=this._renderer.transparency,r=this._isFullyTransparent?t?3:2:e>=1&&!this.hasCompositeBlendMode&&!this._renderer.slicePlaneEnabled?0:1;return this._renderer.transparency=r,i!==r}_updateTilingScheme(){const{tilingScheme:e}=this.tilingSchemeLogic;if(!(e!==this.tilingScheme))return;_e(!!e,"tiling scheme cannot be reset to undefined"),this._isGlobal=!this.view?.state?.isLocal,this.tilingScheme&&this._removeAllTiles();const t=e?.spatialReference??U.WebMercator;this._spatialReference=t,this._isWebMercator=!!t?.isWebMercator,this._isWebMercatorOnPlateCarree=this._isWebMercator&&F(this.view?.renderSpatialReference),this._isGeographic=t?.isGeographic??!1,this._set("tilingScheme",e),this._tilingSchemeSpatialReference=this.tilingScheme?.spatialReference,this._projectorCache.clear(),this._updateClippingExtent(),e&&(this._updateTiledLayers(),this._renderer.tileSize=e.pixelSize,this.overlayManager.spatialReference=e.spatialReference,this._updateRootTiles())}static{this._tileMemcacheKey="TerrainTileMemcache"}_acquireTile(e,t,i,r){const s=this._tileCache.pop(Je._tileMemcacheKey);return s?(s.init(e,t,i,r,this),s):new this._tileConstructor(e,t,i,r,this)}get updatingRootTiles(){return this._updatingRootTiles}_updateRootTiles(){const{groundExtent:e,tilingScheme:t}=this;if(!t)return;if(!this.enabled)return void this._setRootTiles(null);const i=rt;let s=t.rootTilesInExtent(e,i,5*he);if(null!=this._rootTiles){if(s.length>he)return void l.getLogger(this).warn(de);const e=this._rootTiles.map(e=>e.lij),t=r(e,s,Ie);if(this._updatingRootTiles=!0,t.removed.length>0||t.added.length>0){const e=this._rootTiles.filter(e=>!(t.removed.findIndex(t=>Ie(t,e.lij))>-1)||(this._purgeTile(e),!1));t.added.forEach(t=>e.push(this._newRootTile(t))),this._setRootTiles(e)}}else this._updatingRootTiles=!0,s.length>he&&(l.getLogger(this).warn(pe),s=t.rootTilesInExtent(e,i,he)),this._setRootTiles(s.map(e=>this._newRootTile(e)));k(i,this._rootTilesExtent)||(this._rootTilesExtent=I(i)),this.renderer.visible=!0,this._viewChangeUpdate(),this.overlayManager.setPlacementDirty(),this.notifyChange("ready"),this._updateAllTileGeometries(),this._updatingRootTiles=!1,this.checkAllTilesWaterproofness()}_updateAllTileGeometries(){const e=this._allTiles.filter(e=>e.loaded&&e.intersectsClippingArea);e.sort(Oe),e.forEach(e=>this._renderer.updateTileGeometryState(e)),e.forEach(e=>e.renderData.updateNeighborData()),this._updateTilesGeometries(e),this._pendingTilesToUpdate.clear()}_updateTilesGeometries(e){if(0===e.length)return;e.sort(Oe);const t=this.renderer;e.forEach(e=>t.updateGeometryIfNeeded(e)),e.forEach(e=>this._pendingTilesForElevationUpdateEvent.add(e))}_shouldSplit(e){return 1===e.shouldSplit(this._splitLimits,this._eyePosRenderSR,this.snapLevel)}_newRootTile(e){const t=this._acquireTile(0,e[1],e[2],null);return this._shouldSplit(t)&&t.setPendingUpdate(1),this._loadTile(t),this._markTileToUpdate(t),this._updateRootTileElevationRange(),t}_setRootTiles(e){if(this._rootTiles=e,this._allTiles.clear(),null!=e){const t=this._iteratorPool.acquire();for(t.reset(e);!t.done;)this._allTiles.push(t.next());t.remove()}this._renderer.setRootTiles(this._rootTiles),this._updateTilesVisibility(e),this.notifyChange("demResolution"),this.emit("tiles-changed",{allTiles:this.allTiles})}_runViewChangeUpdateIfDirty(){this._viewChangeUpdateDirty&&(this._viewChangeUpdateDirty=!1,this._viewChangeUpdate())}_viewChangeUpdate(){this.view&&!this.suspended&&this.tilingScheme&&this.renderer.visible&&(this._inFrameTask?this._viewChangeUpdateDirty=!0:(this._viewChangeUpdateDirty=!1,this._updateViewDependentParameters(),this._updateTilesVisibility(this._rootTiles)))}_updateClippingStatus(e){e.updateClippingStatus(this.groundExtent)&&e.resetPendingUpdate(8)&&this._updateTileGeometryState(e)}_updateTilesVisibility(e){if(null==e)return;const t=Ge(e),i=this.visibleElevationRange;let r=t?i.minElevation:1/0,s=t?i.maxElevation:-1/0;const a=this.groundExtent,n=this.view.state.contentCamera.viewProjectionMatrix;this.setTileTreeDirty(!1);const l=this._iteratorPool.acquire();for(l.reset(e);!l.done;){const e=l.next();e.updateClippingStatus(a)&&e.resetPendingUpdate(8)&&this._updateTileGeometryState(e),e.computeVisibility(),e.updateScreenDepth(n),e.renderData&&(r=Math.min(e.elevationBoundsMin,r),s=Math.max(e.elevationBoundsMax,s))}l.remove(),this._viewChanged=!0,this._allTilesDirty=!0,this._updatePendingTileGeometries(),isFinite(r)&&isFinite(s)&&(i.minElevation!==r||i.maxElevation!==s)&&(this.visibleElevationRange=new K(r,s))}_updateRootTileElevationRange(){let e=1/0,t=-1/0;const i=this._rootTiles;null!=i&&i.forEach(({elevationBoundsMin:i,elevationBoundsMax:r})=>{e=Math.min(e,i),t=Math.max(t,r)});const r=this._rootTileElevationRange;r.minElevation===e&&r.maxElevation===t||(this._rootTileElevationRange=new K(e,t))}_updateViewDependentParameters(){const{camera:e,contentCamera:t}=this.view.state,i=Math.tan(.5*t.fovX),r=Math.tan(.5*t.fovY),s=this.tilingScheme.pixelSize,a=2**-this._lodBias*e.pixelRatio;this._splitLimits.aboveGround=e.aboveGround,this._splitLimits.fovX=i,this._splitLimits.fovY=r,this._splitLimits.relativeWidthLimit=s/e.width*this.maxTextureScale*a,this._splitLimits.relativeHeightLimit=s/e.height*this.maxTextureScale*a,this._splitLimits.maxLod=this.tilingScheme.getMaxLod(),this._splitLimits.angledSplitBias=this.view.qualitySettings.tiledSurface.angledSplitBias,this.view.state.fixedContentCamera?this._splitLimits.frustum=G(this._splitLimits.frustum??N(),t.frustum):this._splitLimits.frustum=null,E(this._eyePosRenderSR,t.eye),j(e.eye,this.view.renderSpatialReference,this._eyePosSurfaceSR,this.spatialReference)}_updateTileGeometryState(e){e.updateVisibility();this._renderer.updateTileGeometryState(e)&&this._markTileToUpdate(e),this.setMemoryDirty()}_markAllTileNeighborsForUpdate(e){e.forEachLoadedNeighbor(e=>{this._layerViews[1].some(fe)&&e.setPendingUpdate(32),this._pendingTilesToUpdate.add(e)})}_updateTileTexture(e,t){const i=e.resetPendingUpdate(32)?32:!!e.resetPendingUpdate(16)&&16;i&&(this._renderer.updateTileTexture(e,i),this._usedMemory=null,t.madeProgress())}_emitElevationUpdateEventForTiles(){if(!this._shouldEmitChangeEvent)return;const e=at.extent;B(e),this._pendingTilesForElevationUpdateEvent.forEach(t=>O(e,t.extent,e)),this._pendingTilesForElevationUpdateEvent.clear(),at.spatialReference=this.spatialReference,this.emit("elevation-change",at),this._shouldEmitChangeEvent=!1}runTask(e){this._handleLayerViewChanges(e),this._frameTask.processQueue(e),this.renderer.processScaleRangeQueries(this._scaleRangeQueries,e),this._inFrameTask=!0,this._pendingUpdates=0,this._hasPendingUpdates=!1,this._updateAllTilesStatus(e),this._sortTiles(e);const t=!this.view.state.fixedContentCamera;if(this._mergeAndSplit(e,t),this._updateElevation(e),this._updateTextures(e),t||this._mergeAndSplit(e,!0),this._inFrameTask=!1,this._runViewChangeUpdateIfDirty(),this._updatePendingTileGeometries(),this._emitElevationUpdateEventForTiles(),e.done&&e.hasProgressed&&this.requestUpdate(),this.notifyChange("updatingProgressValue"),Le&&this._checkTileInvariant(),!e.hasProgressed)return Ke}_checkTileInvariant(){const e=new Map;this._allTiles.forAll(t=>e.set(t,new Set)),this._allTiles.forAll(t=>{if(_e(t.rendered===t.leaf,` rendered ${t.rendered} != ${t.leaf} leaf`),!t.leaf){const e=e=>0===e.unmergableChildCount&&0===e.maxLevelDeltaNeighborCount,i=t.children.reduce((t,i)=>t+(e(i)?0:1),0);if(_e(t.unmergableChildCount===i,` Tile[${t.lij.toString()}] unmergeable child count mismatch: actual ${t.unmergableChildCount} vs ${i}`),t.hasPendingUpdate(4)){_e(!t.hasPendingUpdate(1),"Tile can be both split and merge at the same time");for(const e of t.children)_e(e.leaf||e.hasPendingUpdate(4),"Child of tile to merge must also merge")}}for(let i=0;i<4;++i){if(t.rendered){const e=t.renderData?.geometryState.edgePeerNeighbors[i];if(null!=e){{const r=t.level-e.level<=ue;r||(console.log(`tile level delta [${t.lij.toString()}] vs [${e.lij.toString()}] > ${ue} (edge[${i}])`),_e(r,`tile level delta [${t.level}] vs [${e.level}] > ${ue}`))}_e(t.level-e.level<=ue,`Max tile lod delta exceeded: [${t.lij.toString()}] vs [${e.lij.toString()}]`)}}const r=t.level-ue,s=e=>e.leaf||e.level===t.level,a=t.findNeighborTile(ye[i],s);if(null!=a){if(t.leaf&&t.level>=ue){let i=a;for(;t.level-i.level<ue;)i=i.parent;const s=[r,t.lij[1]>>ue,t.lij[2]>>ue];if(!Ie(s,i.lij)){const r=e.get(i);_e(!r.has(t),"Cannot already have neighbor"),r.add(t)}}_e(a.rendered||a.level===t.level,"Non-same-level-neighbor of rendered must be rendered"),_e(t.level-a.level<=ue,`Tile level delta [${t.level}] vs [${a.level}] > ${ue}`)}}}),this._allTiles.forAll(t=>{const i=t.maxLevelDeltaNeighborCount,r=e.get(t);_e(i===r.size,`Tile[${t.lij.toString()}] merge-blocker mismatch: actual ${i} vs ${r.size}`)})}_updateAllTilesStatus(e){if(!this._viewChanged||!this._rootTiles||e.done)return;this._viewChanged=!1;const t=new ae(this._allTiles.length);t.pushAll(this._rootTiles);const i=this.snapLevel,r=this._splitLimits,s=this._eyePosRenderSR;this._allTiles.forAll(e=>{e.maxLevelDeltaNeighborCount=0,e.unmergableChildCount=0});const a=this.view.state.contentCamera.viewProjectionMatrix;for(;!t.empty;){const e=t.pop(),n=e.parent,l=n?.hasPendingUpdate(4),o=l?4:e.shouldSplit(r,s,i),h=1===o;e.leaf?ot(e,h):t.pushAll(e.children),l?(e.resetPendingUpdate(1),e.leaf||e.setPendingUpdate(4),this._updateClippingStatus(e),e.updateVisibility(),e.updateScreenDepth(a)):h?(e.resetPendingUpdate(4),e.leaf&&e.setPendingUpdate(1)):(e.resetPendingUpdate(1)&&e.updateAgentSuspension(),2===o&&e.updateAgents(0),e.leaf||(e.setPendingUpdate(4),e.resetPendingUpdate(1)))}this.requestUpdate(),(this._shortBatches||!this._oneBatchPerFrameTask)&&this._updatePendingTileGeometries(),e.madeProgress()}_sortTiles(e){e.done||this._allTilesSorted||!this.view.pointsOfInterest?.focus||(Ne(this._allTiles,this.view.pointsOfInterest.focus.renderLocation),this._allTilesSorted=!0,this._treeDebugger?.update(),e.madeProgress())}_markTileToUpdate(e){Te(e.loaded),e.intersectsClippingArea&&(this._pendingTilesToUpdate.add(e),this._markAllTileNeighborsForUpdate(e))}_updatePendingTileGeometries(){const e=this._pendingTilesToUpdate,t=Array.from(e.keys()).filter(e=>e.loaded&&e.intersectsClippingArea);if(0===t.length)return void e.clear();const i=(i,r)=>{!r?.loaded||!r.intersectsClippingArea||r.level<i.level||e.has(r)||(e.add(r),t.push(r),r.renderData.updateNeighborData())};t.sort(Oe);const r=t.length;for(let s=0;s<r;++s){const r=t[s];Te(r.loaded),Te(r.intersectsClippingArea);const a=r.renderData;a.updateNeighborData();const n=a.dirtyEdgeResolutions,l=a.geometryState,o=e=>{const t=De[e];i(r,l.cornerPeerNeighbors[e]?.findCorner(Pe(t),e=>e.loaded))};for(let t=0;t<4;++t)if(n&1<<t){const s=a.geometryState.edgePeerNeighbors[t];s&&s?.level>=r.level&&s.forAllSubtreeOnSide(ve(ye[t]),t=>!(!t.loaded||!t.intersectsClippingArea)&&(Te(e.has(t)||Oe(r,t)<0),i(r,t),!0)),o((t+1)%4),o(t)}}e.clear(),this._updateTilesGeometries(t),this._shouldEmitChangeEvent=!0,Le&&Re&&this.checkAllTilesWaterproofness()}_mergeAndSplit(e,t){if(this.suspended||e.done||!this._allTilesDirty)return;this._allTilesDirty=!1,this.requestUpdate();let i=!1;const r=this.view.state.fixedContentCamera;let s=!1;for(;!e.done;){s=!0;let a=!1;const n=!this._allTiles.some(s=>{if(!i&&!r&&!s.visible)return e.done;let n=s;if(s.hasPendingUpdate(4)){if(!t||s.unmergableChildCount>0)return e.done;for(s.resetPendingUpdate(4);null!=n.parent&&0===n.parent.unmergableChildCount&&n.parent.resetPendingUpdate(4);)n=n.parent;this._mergeTile(n),a=!0,e.madeProgress()}else if(s.resetPendingUpdate(1)){let t=!0;const i=s.level;if(i>=ue){const e=e=>e.leaf||i-e.level<ue;for(let r=0;r<4;++r){const a=s.findNeighborTile(ye[r],e);null!=a&&i-a.level===ue&&(t=!1,Le&&(Te(a.leaf),Te(a.hasPendingUpdate(1))))}}t?(this._splitTile(s),e.madeProgress(),a=!0):s.setPendingUpdate(1)}return e.done});if(a&&(this._allTilesSorted=!1,this._allTilesDirty=!0,!this._oneBatchPerFrameTask&&this._updatePendingTileGeometries()),n){if(!i){i=!0;continue}if(!a)break}else this._allTilesDirty=!0}s?e.madeProgress():this._allTilesDirty=!0,!this._oneBatchPerFrameTask&&this._updatePendingTileGeometries(),this._allTilesCreated=!this.allTiles.some(e=>e.hasPendingUpdate(1)||e.hasPendingUpdate(4)),this._sortTiles(e)}_updateElevation(e){e.done||(this._allTiles.some(t=>(t.resetPendingUpdate(8)&&(this._updateTileGeometryState(t),this._shortBatches&&this._updatePendingTileGeometries(),e.madeProgress()),e.done)),!this._oneBatchPerFrameTask&&this._updatePendingTileGeometries())}_updateTextures(e){e.done||this._allTiles.some(t=>(this._updateTileTexture(t,e),e.done))}_updateClippingExtent(){this.spatialReference&&(this.updateOverlayParameters(),this.requestRender(1),this.overlayManager.setPlacementDirty(),this._updateRootTiles())}get _lodBias(){return this.view.qualitySettings.tiledSurface.lodBias-(1-this.view.quality)*ce}_getLodBiasCorrectedScale(e){const t=this.tilingScheme.levels,i=o(e-this._lodBias,0,t.length-1),r=i-Math.floor(i);return t[Math.floor(i)].scale*(1-r)+t[Math.ceil(i)].scale*r}_removeAllTiles(){null!=this._rootTiles&&(this._rootTiles.forEach(e=>this._purgeTile(e)),this._setRootTiles(null),this.notifyChange("ready")),this._allTiles.clear(),this.notifyChange("demResolution"),this.emit("tiles-changed",{allTiles:this.allTiles}),this.renderer.visible=!1}_purgeSubtree(e){const t=e.children;t[0]&&(this._purgeTile(t[0]),this._purgeTile(t[1]),this._purgeTile(t[2]),this._purgeTile(t[3]),e.clearChildren())}_purgeTile(e){e.leaf?dt(e):this._purgeSubtree(e),this._allTiles.removeUnordered(e),this._unloadTile(e),e.dispose(),this._tileCache.put(Je._tileMemcacheKey,e),this.notifyChange("demResolution"),this.emit("tiles-changed",{allTiles:this.allTiles})}_unloadTile(e){this._pendingTilesToUpdate.delete(e),this._pendingTilesForElevationUpdateEvent.delete(e),e.unload()}_splitTile(e){_e(e.leaf,"Tile that is already split should not be split again!"),_e(e.rendered,"Tile marked to split is not rendered"),dt(e);const t=e.createChildren();this._allTiles.pushArray(t),this.notifyChange("demResolution"),this.emit("tiles-changed",{allTiles:this.allTiles}),e.updateAgentSuspension(),_e(e.rendered,"parent should be rendered"),t.forEach(e=>this._loadTile(e)),t.forEach(e=>this._pendingTilesToUpdate.add(e)),this._unloadTile(e),this._markAllTileNeighborsForUpdate(e),this._emitTileScaleChange(e,e.level+1),this._allTilesDirty=!0,this._shortBatches&&this._updatePendingTileGeometries(),t.forEach(e=>ot(e,e.hasPendingUpdate(1))),++this._performanceInfo.numSplit}_emitTileScaleChange(e,t=e.level){nt.spatialReference=this.spatialReference,nt.extent=e.extent,nt.scale=this._getLodBiasCorrectedScale(t),this.emit("scale-change",nt)}createTile(e,t,i,r){_e(!!r,"createTile sanity check");const s=this._acquireTile(e,t,i,r);return s.updateClippingStatus(this.groundExtent),s.updateScreenDepth(this.view.state.contentCamera.viewProjectionMatrix),this._shouldSplit(s)&&s.setPendingUpdate(1),s}get _shortBatches(){return 2!==this.view.state.mode}_mergeTile(e){_e(!e.hasPendingUpdate(1),"_mergeTile sanity check"),_e(!e.leaf,"Cannot merge a leaf"),e.leaf||(this._purgeSubtree(e),_e(!e.renderData,"Merging tile with existing render data?"),this._loadTile(e),this._markTileToUpdate(e),this._emitTileScaleChange(e),this._shortBatches&&this._updatePendingTileGeometries(),ot(e,!1),this._allTilesDirty=!0,++this._performanceInfo.numMerged)}_loadTile(e){e.load(),this.requestUpdate(),this._allTilesDirty=!0,this.overlayManager?.hasOverlays&&e.updateOverlayParameters(this.overlayManager)}_handleLayerViewChanges(e=Ye){if(!this._layerViewsDirty)return;this._layerViewsDirty=!1;let t=!1;const i=new Set;let r=-1;for(let s=this.view.allLayerViews.length-1;s>=0;s--){const e=this.view.allLayerViews.items[s];if(i.add(e.uid),we(e)||Ce(e))if(this._basemapLayerViewHandles.has(e.uid)&&!Ce(e)){const i=this._layerClassFromLayerView(e),s=this.getLayerIndexByUID(i,e.uid);null!=s&&((s<r||null==r)&&(t=!0),r=s)}else this._registerTiledLayerView(e),e.layer.loaded&&(t=!0)}this._basemapLayerViewHandles.forEach((e,r)=>{i.has(r)||(this._unregisterTiledLayerView(r),t=!0)}),t&&this._updateTiledLayers(),this.hasCompositeBlendMode=this._hasCompositeBlendMode(),this._evaluateTransparency(),e.madeProgress()}get _isFullyTransparent(){if(this.view.map?.ground?.opacity>0)return!1;for(const e of this.view.allLayerViews.items)if(Se(e)&&!$(e.layer)&&0!==e.fullOpacity)return!1;return!0}_hasCompositeBlendMode(){for(const e of this.view.allLayerViews.items)if((be(e)||Ce(e))&&We(He[e.layer.blendMode]))return!0;return!1}_layerClassFromLayerView(e){return Ee(e)?0:1}_registerTiledLayerView(e){const t=[];if((be(e)||Ce(e))&&t.push(_(()=>e.layer.blendMode,()=>{this.hasCompositeBlendMode=this._hasCompositeBlendMode(),this._updateTileTextures(2)})),!Ce(e)){const i=this._layerClassFromLayerView(e);t.push(_(()=>!e.destroyed&&e.suspended,()=>this._updateTiledLayers())),t.push(_(()=>!e.destroyed&&e.fullOpacity,()=>this._updateTileTextures(2)));const{layer:r}=e;"effectiveScaleRange"in r&&t.push(_(()=>!e.destroyed&&r.effectiveScaleRange,()=>this._restartAllAgents(i))),t.push(e.on("data-changed",()=>{const t=this.getLayerIndexByUID(i,e.uid);null!=t&&this._invalidateLayerData(t,i)}))}this._unregisterTiledLayerView(e.uid),this._basemapLayerViewHandles.set(e.uid,t)}_unregisterTiledLayerView(e){const t=this._basemapLayerViewHandles.get(e);if(t){for(const e of t)e.remove();this._basemapLayerViewHandles.delete(e)}}_updateTiledLayers(){if(!this.tilingScheme||this.view.suspended)return;const e=this.view.allLayerViews,t=[[],[]];let i=null;e.forEach(e=>{if(!e.layer||e.suspended||!we(e)||!e.fullExtent)return;const r=this._layerClassFromLayerView(e);if(1===r){const t=e.displayLevelRange.maxLevel;t!==1/0&&(null===i||t>i)&&(i=t)}t[r].push(e)});for(const r of ie){const e=this._layerViews[r],i=t[r];i.reverse();const s=i.length;let a=e.length!==s;const n=new Array(s),l=new Array(e.length);this._layerIndexByUid[r].clear();for(let t=0;t<s;t++){const s=i[t].uid;this._layerIndexByUid[r].set(s,t);const o=e.indexOf(i[t]);n[t]=o,t!==o&&(a=!0),o>-1&&(l[o]=t)}if(a){const e=this._postorderIterator;for(e.reset(this._rootTiles);!e.done;)e.next().modifyLayers(l,n,r);this._layerViews[r]=i,this._restartAllAgents(r),this._updateTilesVisibility(this._rootTiles)}}this.tilingScheme.ensureMaxLod(i)&&(this._viewChangeUpdate(),this.notifyChange("tilingScheme"))}_restartAllAgents(e){const t=this._postorderIterator;for(t.reset(this._rootTiles);!t.done;){const i=t.next();i.restartAgents(e),0===e&&i.computeElevationBounds()}this._updateRootTileElevationRange()}layerViewByIndex(e,t){return this._layerViews[t][e]}numLayers(e){return this._layerViews[e].length}_updateTileTextures(e){this._allTiles.forAll(t=>{t.updateAgents(1),1===e?this.renderer.updateTileTexture(t,16):t.updateRenderData(1,e)}),this._evaluateTransparency()}_invalidateLayerData(e,t){this._allTiles.forAll(i=>i.removeLayerAgent(e,t)),this._allTiles.forAll(i=>i.invalidateLayerData(e,t))}setTileTreeDirty(e){this._allTilesDirty=!0,e&&(this._allTilesCreated=!1)}requestRender(e=1){this.renderer.setNeedsRender(e)}requestUpdate(){1===++this._pendingUpdates&&(this._hasPendingUpdates=!0)}requestTileData(e,t,i,r){const s=this.layerViewByIndex(t,i),a=s.layer;return!a.tilemapCache||fe(s)?this._requestTileData(e,i,s,r):(++this._asyncWorkItems,a.tilemapCache.fetchAvailability(e.level,e.lij[1],e.lij[2],{...r,timeout:6e3}).then(()=>--this._asyncWorkItems).catch(t=>{throw--this._asyncWorkItems,c(r),g(t)||this._dataMissing(e,i,s),t}).then(()=>this._frameTask.schedule(()=>this._requestTileData(e,i,s,r),r.signal)))}_requestTileData(e,t,i,r){if(this.destroying)return Promise.resolve();return 0===t?Ee(i)?this._requestElevationTileData(e,i,r):Promise.reject():Se(i)?this._requestMapTileData(e,i,r):Promise.reject()}_requestElevationTileData(e,t,i){++this._asyncWorkItems;const r=r=>{!m(i)&&r&&(this.setMemoryDirty(),this.requestUpdate(),this._elevationDataArrived(e,t,r))},s=i=>{g(i)||(l.getLogger(this).error(`Tile ${e.lij.toString()} layer 0/${t.uid} error ${i}`),this._dataMissing(e,0,t),this.requestUpdate())};return t.fetchElevationTile(e,i).then(e=>this._frameTask.schedule(()=>r(e)),s).finally(()=>--this._asyncWorkItems)}_elevationDataArrived(e,t,i){const r=this._layerIndexByUid[0].get(t.uid);if(null==r)return void l.getLogger(this).warn("TerrainSurface: received data from unknown layer %d %s",0,e.lij.toString());const s=new J(e.lij,e.extent,i);e.dataArrived(r,0,s),this.emit("tile-data-changed",{tile:e,layerIndex:r,layerClass:0});const a=[e],n=e.level,o=this._iteratorPool.acquire();for(o.reset(a);!o.done;){const e=o.next();e.findElevationBoundsForLayer(r,n),e.computeElevationBounds()}0===n&&this._updateRootTileElevationRange(),o.remove(),this._updateTilesVisibility(a)}_requestMapTileData(e,t,i){++this._asyncWorkItems;const r=(r,s)=>{xe(s),m(i)||(console.error(`Tile ${e.lij.toString()} layer 1/${t.uid} error ${r}`),this._dataMissing(e,1,t),this.requestUpdate())},s=e=>t=>r(t,e),a=r=>this._frameTask.schedule(()=>{this.requestUpdate(),m(i)?xe(r):this._mapTileDataArrived(e,t,r)},i.signal,s(r)).catch(s(r)),n=(e,t=null)=>this._frameTask.schedule(()=>r(e,t));return t.fetchTile(e.lij,i).then(a,n).finally(()=>--this._asyncWorkItems)}_mapTileDataArrived(e,t,i){const r=this.getLayerIndexByUID(1,t.uid);if(null==r)return xe(i),void l.getLogger(this).warn("TerrainSurface: received data from unknown layer");e.dataArrived(r,1,i),this.emit("tile-data-changed",{tile:e,layerIndex:r,layerClass:1})}_dataMissing(e,t,i){const r=this.getLayerIndexByUID(t,i.uid);null!=r?(e.dataMissing(r,t),this.emit("tile-data-changed",{tile:e,layerIndex:r,layerClass:t})):l.getLogger(this).warn("TerrainSurface: received data from unknown layer")}get performanceInfo(){const e=this._performanceInfo;return e.numNodes=this._allTiles.length,e.numLeaves=e.numVisible=e.numRendered=e.numLoadedPerLevel.length=e.numRenderedPerLevel.length=0,this._allTiles.forAll(t=>{t.leaf&&e.numLeaves++;const i=t.level;t.renderData&&(e.numLoadedPerLevel[i]=(e.numLoadedPerLevel[i]||0)+1),t.visible&&(e.numVisible++,t.rendered&&(e.numRenderedPerLevel[i]=(e.numRenderedPerLevel[i]||0)+1,e.numRendered++))}),e}setMemoryDirty(){this._usedMemory=null}get usedMemory(){return this.tilingScheme?(null==this._usedMemory&&(this._usedMemory=this._recalculateUsedMemory()),this._usedMemory??0):0}_recalculateUsedMemory(){return this.tilingScheme?Math.round(this._allTiles.reduce((e,t)=>e+t.usedMemory,0)):null}getUsedMemoryForLayerView(e){let t=0;const i=this._layerClassFromLayerView(e),r=this.getLayerIndexByUID(i,e.uid);return null!=r&&this._allTiles.forAll(e=>t+=e.getUsedMemoryForLayer(i,r)),t}get renderPatchBorders(){return this._renderer.renderPatchBorders}set renderPatchBorders(e){this._renderer.renderPatchBorders=e}get renderingDisabled(){return this._renderer.renderingDisabled}set renderingDisabled(e){this._renderer.renderingDisabled=e}get test(){}checkAllTilesWaterproofness(){if(!Re)return;const e=this._rootTiles;if(null==e)return;const t=e=>e?.renderData?.geometry?.indices?.length>0,i=(e,i)=>{t(e)&&console.error("Tile[",e.lij,"] has geometry although parent[",i.lij,"] has geom")},r=e=>{if(e.intersectsClippingArea)if(e.renderData&&!e.renderData.geometryState&&console.error("Tile[",e.lij,"] has renderData but not geometryState"),e.renderData&&!e.renderData.geometry&&console.error("Tile[",e.lij,"] has renderData but not geometryInfo"),!e.renderData?.geometry||(e.renderData.geometry.indices?.length??0)>0||console.error("Tile[",e.lij,"] has renderData but no indices - geometryInfo: ",e.renderData.geometry),t(e)){e.checkGeometryWaterproofness();for(const t of e.children)i(t,e)}else if(e.leaf)console.error("Tile[",e.lij,"] has no geometry and no children, from root to leaf");else for(const t of e.children)r(t)},s=e=>{const t=e.parent?.visible??!0,i=e.visible;e.computeVisibility();const r=e.visible;if(i!==r&&t&&console.error(" Tile[",e.lij,"] has out of date visibility: ",i," instead of ",r),!e.leaf)for(const a of e.children)s(a)};for(const a of e)r(a),s(a)}get isGlobal(){return this._isGlobal}get isGeographic(){return this._isGeographic}get isWebMercator(){return this._isWebMercator}get isWebMercatorOnPlateCarree(){return this._isWebMercatorOnPlateCarree}isEastEndWrap(e){return this._isGlobal&&e[2]===this.lijEastEnd(e[0])-1}isWestEndWrap(e){return this._isGlobal&&0===e[2]}lijEastEnd(e){return 1<<e+(this._isGeographic?1:0)}wrapEastWest(e){const t=this.lijEastEnd(e[0]),i=e[2];if(0<=i&&i<t)return e;if(!this._isGlobal)return null;const r=(i+(i<0?t:0))%t;return[e[0],e[1],r]}enableInternalChecks(e){Ue(e)}enableWaterproofnessChecks(e){Me(e)}static cleanupTerrainSurface(){st.prune()}enable(e){e!==this.enabled&&(this._set("enabled",e),e?(this._updateRootTiles(),this.suspended=!1):(this.suspended=!0,this._removeAllTiles(),this._setRootTiles(null)),this.notifyChange("ready"))}updateOverlayParameters(){const{overlayManager:e}=this;this.allTiles.forAll(t=>t.updateOverlayParameters(e))}};e([w()],Ze.prototype,"_renderer",void 0),e([w({constructOnly:!0})],Ze.prototype,"_scaleRangeQueries",void 0),e([w({constructOnly:!0})],Ze.prototype,"view",void 0),e([w({constructOnly:!0})],Ze.prototype,"overlayManager",void 0),e([w({constructOnly:!0})],Ze.prototype,"terrainTextureCompressionTracker",void 0),e([w()],Ze.prototype,"_hasPendingUpdates",void 0),e([w()],Ze.prototype,"_asyncWorkItems",void 0),e([w()],Ze.prototype,"_allTilesDirty",void 0),e([w()],Ze.prototype,"_allTilesSorted",void 0),e([w()],Ze.prototype,"allTilesCreated",null),e([w()],Ze.prototype,"_allTilesCreated",void 0),e([w()],Ze.prototype,"_viewChanged",void 0),e([w({type:Number})],Ze.prototype,"heading",void 0),e([w()],Ze.prototype,"_splitLimits",void 0),e([w({readOnly:!0})],Ze.prototype,"_watchUpdatingTracking",void 0),e([w()],Ze.prototype,"_frameTask",void 0),e([w()],Ze.prototype,"demResolution",null),e([w({readOnly:!0})],Ze.prototype,"snapLevel",null),e([w({readOnly:!0})],Ze.prototype,"lodSnappingEnabled",null),e([w({readOnly:!0})],Ze.prototype,"userClippingExtent",null),e([w()],Ze.prototype,"_rootTilesExtent",void 0),e([w({readOnly:!0})],Ze.prototype,"groundExtent",null),e([w({readOnly:!0})],Ze.prototype,"fullGroundExtent",null),e([w({readOnly:!0})],Ze.prototype,"_tilingSchemeExtent",null),e([w({readOnly:!0})],Ze.prototype,"updating",null),e([w({readOnly:!0})],Ze.prototype,"readyToRun",null),e([w(X)],Ze.prototype,"updatingProgress",void 0),e([w({readOnly:!0})],Ze.prototype,"updatingProgressValue",null),e([w()],Ze.prototype,"_maxNumUpdating",void 0),e([w()],Ze.prototype,"baseOpacity",null),e([w()],Ze.prototype,"hasCompositeBlendMode",void 0),e([w({readOnly:!0})],Ze.prototype,"viewingMode",null),e([w()],Ze.prototype,"maxTextureScale",void 0),e([w({readOnly:!0})],Ze.prototype,"ready",null),e([w({readOnly:!0})],Ze.prototype,"rootTiles",null),e([w()],Ze.prototype,"_rootTiles",void 0),e([w({readOnly:!0})],Ze.prototype,"spatialReference",null),e([w({type:t})],Ze.prototype,"backgroundColor",null),e([w({value:!1})],Ze.prototype,"slicePlaneEnabled",null),e([w({readOnly:!0})],Ze.prototype,"tilingScheme",void 0),e([w({readOnly:!0})],Ze.prototype,"tilingSchemeLocked",null),e([w({readOnly:!0})],Ze.prototype,"tilingSchemeLogic",void 0),e([w()],Ze.prototype,"wireframe",null),e([w({value:!1})],Ze.prototype,"suspended",null),e([w()],Ze.prototype,"fadeDuration",null),e([w()],Ze.prototype,"_xNormalizer",null),e([w()],Ze.prototype,"visibleElevationRange",void 0),e([w()],Ze.prototype,"_rootTileElevationRange",void 0),e([w()],Ze.prototype,"_layerViewsDirty",void 0),e([w()],Ze.prototype,"renderPatchBorders",null),e([w()],Ze.prototype,"renderingDisabled",null),e([w({readOnly:!0})],Ze.prototype,"enabled",void 0),Ze=Je=e([C("esri.views.3d.terrain.TerrainSurface")],Ze);const et=Ze,tt=x(),it=new W,rt=I(),st=new u,at=new ee("ground"),nt={spatialReference:null,extent:null,scale:0};function lt(e,t,i){for(const r of e){if(!r.containsPointXY(t,i))continue;let e=r;for(;e&&!e.renderData;){const r=(t>e.extentMidX?1:0)+(i<e.extentMidY?2:0);e=e.children[r]}const s=e?.renderData?.geometryState.samplerData??null;return Z(t,i,s)}return null}function ot(e,t){!e.leaf||e.level<ue||ut(e,e=>{t&&ht(e);const i=pt(e);if(e.maxLevelDeltaNeighborCount++,i){let t=e.parent;for(;t;){const e=pt(t);if(t.unmergableChildCount++,!e)break;t=t.parent}}})}function ht(e){if(e.hasPendingUpdate(1))return;let t=e.parent;for(;t?.resetPendingUpdate(4);)t=t.parent;e.resetPendingUpdate(4),e.leaf&&e.setPendingUpdate(1),e.level<ue||ut(e,e=>{ht(e)})}function dt(e){e.level<ue||ut(e,e=>{if(e.maxLevelDeltaNeighborCount--,0===e.maxLevelDeltaNeighborCount&&0===e.unmergableChildCount){let t=e.parent;for(;t&&(t.unmergableChildCount--,pt(t));)t=t.parent}})}function pt(e){return 0===e.maxLevelDeltaNeighborCount&&0===e.unmergableChildCount}function ut(e,t){if(e.level<ue)return;const i=e.level-ue,r=e.lij[1]>>ue,s=e.lij[2]>>ue,a=e=>e.leaf||e.level===i;for(let n=0;n<4;++n){const l=e.findNeighborTile(ye[n],a);if(!l||l.level!==i)continue;const o=l.lij;o[1]===r&&o[2]===s||t(l)}}export{et as default};
5
+ import{__decorate as e}from"tslib";import t from"../../../Color.js";import{filterInPlace as i,difference as r}from"../../../core/arrayUtils.js";import s from"../../../core/CollectionFlattener.js";import{toConst as a}from"../../../core/compilerUtils.js";import{EventedAccessor as n}from"../../../core/Evented.js";import"../../../core/has.js";import l from"../../../core/Logger.js";import{clamp as o}from"../../../core/mathUtils.js";import{destroyMaybe as h}from"../../../core/maybe.js";import{MemCachePool as d}from"../../../core/MemCachePool.js";import p from"../../../core/ObjectPool.js";import u from"../../../core/PooledArray.js";import{throwIfAborted as c,isAbortError as g,isAborted as m}from"../../../core/promiseUtils.js";import{watch as _,syncAndInitial as y,sync as f,initial as T}from"../../../core/reactiveUtils.js";import{getMetersPerUnitForSR as v}from"../../../core/units.js";import{property as w,subclass as C}from"../../../core/accessorSupport/decorators.js";import{m as S,h as b,d as E}from"../../../chunks/vec32.js";import{create as x}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{UpdatingHandles as L}from"../../../core/support/UpdatingHandles.js";import{getReferenceEllipsoid as P,radiusModifier as R}from"../../../geometry/ellipsoidUtils.js";import U from"../../../geometry/SpatialReference.js";import{getProjector as M}from"../../../geometry/projection/projectors.js";import{projectPointToVector as D}from"../../../geometry/projection/projectPointToVector.js";import{projectVectorToVector as j}from"../../../geometry/projection/projectVectorToVector.js";import{create as I,equals as k,intersection as V,intersectsSphere as A,empty as B,expand as O}from"../../../geometry/support/aaBoundingRect.js";import{copy as G,create as N}from"../../../geometry/support/frustum.js";import{createSpatialReferenceCyclical as q}from"../../../geometry/support/normalizeUtils.js";import{isPlateCarree as F}from"../../../geometry/support/spatialReferenceUtils.js";import{Sphere as W}from"../../../geometry/support/sphere.js";import{ElevationQueryTileCache as H}from"../../../layers/support/ElevationQueryTileCache.js";import{isBaseLayer as $}from"../../../layers/support/layerUtils.js";import{debugFlags as Q}from"../support/debugFlags.js";import{ElevationRange as z}from"../support/ElevationRange.js";import{toBoundingRect as Y}from"../support/extentUtils.js";import{updatingProgress as X}from"../support/updatingProperties.js";import{ElevationBounds as K}from"./ElevationBounds.js";import{ElevationData as J,sampleElevation as Z}from"./ElevationData.js";import{ElevationUpdateEventImplementation as ee}from"./ElevationUpdateEvent.js";import{create as te}from"./ExtentHelper.js";import{LayerClasses as ie}from"./LayerClass.js";import{OverlayManager as re}from"./OverlayManager.js";import{PlanarPatch as se}from"./PlanarPatch.js";import{Queue as ae}from"./Queue.js";import{ScaleRangeQueries as ne}from"./ScaleRangeQueries.js";import{SphericalPatch as le}from"./SphericalPatch.js";import{SplitLimits as oe}from"./SplitLimits.js";import{maxRootTiles as he,tooManyRootTilesAfterChangeError as de,tooManyRootTilesForLayerError as pe,maxTileNeighborLevelDelta as ue,maxMemoryLodBias as ce}from"./TerrainConst.js";import{TerrainRenderer as ge}from"./TerrainRenderer.js";import me from"./TerrainSurfacePerformanceInfo.js";import{weakAssert as _e,isVectorTileLayerView as ye,neighborEdgeIndices as fe,internalAssert as Te,oppositeEdge as ve,isSurfaceLayerView as we,isGroupLayerView as Ce,isMapTileLayerView as Se,isBlendableLayerView as be,isElevationLayerView as Ee,releaseTerrainData as xe,enableTerrainInternalChecks as Le,oppositeCorner as Pe,enableWaterproofTests as Re,enableInternalTerrainChecks as Ue,enableTerrainWaterproofChecks as Me,neighborCornerIndices as De}from"./terrainUtils.js";import{Tile as je,lijEquals as Ie}from"./Tile.js";import{printAllocations as ke}from"./TilePerLayerInfo.js";import{sortTiles as Ve,IteratorPreorder as Ae,IteratorPostorder as Be,compareTilesByLij as Oe,hasLoadableSiblings as Ge,sortTilesByPOI as Ne}from"./tileUtils.js";import{TilingSchemeLogic as qe}from"./TilingSchemeLogic.js";import{UpsampleInfo as Fe}from"./UpsampleInfo.js";import{isCompositeBlendMode as We,blendModeFromString as He}from"../webgl-engine/core/shaderLibrary/output/BlendOptions.js";import{hasLayerBasedScaleVisibility as $e}from"../../support/layerViewUtils.js";import{ImmediateTask as Qe,TaskPriority as ze,noBudget as Ye}from"../../support/Scheduler.js";import{TextureCompressionTracker as Xe}from"../../support/TextureCompressionTracker.js";import{Yield as Ke}from"../../support/Yield.js";var Je;let Ze=class extends n{static{Je=this}get allTilesCreated(){return this._allTilesCreated}get allTiles(){return a(this._allTiles)}get renderedTiles(){return Ve(i(this._allTiles.toArray(),e=>e.visible&&e.rendered))}get demResolution(){const{_allTiles:e,tilingScheme:t}=this;if(0===e.length)return{min:1,max:1};const i=v(t.spatialReference);let r=Number.POSITIVE_INFINITY,s=Number.NEGATIVE_INFINITY;for(const a of e){const e=t.resolutionAtLevel(a.level)*i;r=Math.min(r,e),s=Math.max(s,e)}return{min:r,max:s}}constructor(e){super(e),this.terrainTextureCompressionTracker=new Xe,this._iteratorPool=new p(()=>new Ae,e=>e.remove=()=>this._iteratorPool.release(e)),this._postorderIterator=new Be,this._hasPendingUpdates=!1,this._pendingUpdates=0,this._asyncWorkItems=0,this._allTilesDirty=!0,this._allTilesSorted=!0,this._allTilesCreated=!1,this._usedMemory=null,this._performanceInfo=new me,this._viewChanged=!1,this.heading=0,this._inFrameTask=!1,this._viewChangeUpdateDirty=!1,this._eyePosRenderSR=x(),this._eyePosSurfaceSR=x(),this._splitLimits=new oe,this._layerViews=[new Array,new Array],this._layerIndexByUid=[new Map,new Map],this._basemapLayerViewHandles=new Map,this._watchUpdatingTracking=new L,this._frameTask=Qe,this._allTiles=new u,this._upsampleInfoPool=new p(()=>new Fe),this._shouldEmitChangeEvent=!1,this._rootTilesExtent=I(),this.updatingProgress=.5,this._maxNumUpdating=1,this.maxTextureScale=1.2,this._spatialReference=U.WebMercator,this._elevationProjectorCache=new Map,this.visibleElevationRange=new z(1/0,-1/0),this._rootTileElevationRange=new z(1/0,-1/0),this._projectorCache=new Map,this._tilingSchemeSpatialReference=null,this._updatingRootTiles=!1,this._pendingTilesForElevationUpdateEvent=new Set,this._pendingTilesToUpdate=new Set,this.totalGeometryUpdates=0,this.totalTileUpdates=0,this._oneBatchPerFrameTask=!0,this._layerViewsDirty=!1,this.unloadedMemory=0,this.ignoresMemoryFactor=!1,this._isWebMercator=!1,this._isWebMercatorOnPlateCarree=!1,this.enabled=!0;const{view:t}=e;this.overlayManager=new re({...e,terrainSurface:this}),this._isGlobal=!t.state?.isLocal,this._isGeographic=this._spatialReference?.isGeographic??!1,this._tileConstructor=this._isGlobal?le:se,this._ellipsoid=P(t.spatialReference),this._renderer=new ge(this.overlayManager.renderer,t.stage,this._allTiles,this.terrainTextureCompressionTracker,t.resourceController.memoryController),$e()||(this._scaleRangeQueries=new ne)}initialize(){const{view:e}=this,{resourceController:t}=e,{memoryController:i}=t;this._tileCache=new d((e,t)=>i.newCache(e,t),"terrain-tile"),this._upsampleMapCache=i.newCache("terrain-upsample",({tile:e})=>e.unloadMapData()),this._elevationQueryCache=new H(i.newCache("elevation-query"));const r=this.overlayManager;this.addHandles([_(()=>r.renderer.isEmpty,()=>this._evaluateTransparency()),_(()=>this.renderer.visible,e=>this.suspended=!e),_(()=>this.heading,e=>{this._renderer.updateHeading(e),this._updateTileTextures(0)}),_(()=>({heading:e.camera?.heading,state:e.state?.mode}),({heading:e,state:t})=>{if(null==e)return;if(this.isGlobal&&this.isGeographic||this.isWebMercatorOnPlateCarree)return void(this.heading=90*Math.round(e/90)%360);const i=Math.round(e)%360,r=Math.abs(i-this.heading);(2===t||Math.min(r,360-r)>=30)&&(this.heading=i)})],"overlayManager"),this.addHandles([_(()=>this.baseOpacity,()=>{this._handleLayerViewChanges(),this._updateTileTextures(this._evaluateTransparency()?1:2)},y),_(()=>this.hasCompositeBlendMode,()=>this._updateTileTextures(this._evaluateTransparency()?1:2),y),_(()=>this.backgroundColor,(e,t)=>{e?.equals(t)||(this._handleLayerViewChanges(),this._renderer.updateTileBackground(e))},f),_(()=>this.snapLevel,()=>this._viewChanged=!0,f),_(()=>this.view.pointsOfInterest,e=>{this._renderer.pointsOfInterest=e,this._watchUpdatingTracking.removeAll(),e&&this._watchUpdatingTracking.add(()=>e.focus?.renderLocation,()=>this._allTilesSorted=!1,{equals:S})}),_(()=>Q.TERRAIN_TILE_TREE_SHOW_TILES,t=>{t&&!this._treeDebugger?import("../layers/support/TerrainTileTree3DDebugger.js").then(({TerrainTileTree3DDebugger:t})=>{!this._treeDebugger&&Q.TERRAIN_TILE_TREE_SHOW_TILES&&(this._treeDebugger=new t({view:e}))}):t||(this._treeDebugger=h(this._treeDebugger))},T)]);const{spatialReference:a}=e;this._extentHelper=te(this.viewingMode,{layers:e.map.allLayers,layerViews:e.allLayerViews,viewSpatialReference:a});const n=new s({getCollections:()=>e.defaultsFromMap?.mapCollections?.map(({layers:e})=>e),getChildrenFunction:e=>e&&"layers"in e?e.layers:null}),l=new qe({layers:n,extentHelper:this._extentHelper,viewingMode:this.viewingMode,viewSpatialReference:a});this._set("tilingSchemeLogic",l),this._updateTilingScheme();const o=t.scheduler;this._frameTask=o.registerTask(ze.TERRAIN_SURFACE,this),this.addHandles([_(()=>this._extentHelper.stencilEnabledExtents,e=>this._renderer.setStencilEnabledLayerExtents(e),T),_(()=>this.tilingSchemeLogic.tilingScheme,()=>this._updateTilingScheme(),f),_(()=>this.groundExtent,()=>this._updateRootTiles(),T),e.on("resize",()=>this._viewChangeUpdate()),_(()=>{const t=e.state;return[this._lodBias,this.lodSnappingEnabled,e.quality,t.camera,t.contentCamera,t.fixedContentCamera]},()=>this._viewChangeUpdate(),y),_(()=>e.qualitySettings?.fadeDuration,e=>this._renderer.textureFadingEnabled=e>0,T),_(()=>e.qualitySettings?.physicallyBasedRenderingEnabled,e=>this._renderer.pbrMode=e?5:0,T),_(()=>e.qualitySettings?.tiledSurface.elevationLevelDelta,()=>this._updateAllTileGeometries()),_(()=>this.userClippingExtent,()=>this._updateClippingExtent(),f)]),this.addHandles(e.allLayerViews.on("after-changes",()=>this._layerViewsDirty=!0)),this._layerViewsDirty=!0,this._handleLayerViewChanges(),this._renderer.updateTileBackground(this.backgroundColor)}clearHandles(){this._watchUpdatingTracking?.removeAll(),this.removeAllHandles(),this._basemapLayerViewHandles.forEach((e,t)=>this._unregisterTiledLayerView(t)),this._basemapLayerViewHandles.clear()}destroy(){this._frameTask.remove(),this._frameTask=Qe,this._watchUpdatingTracking?.destroy(),this._removeAllTiles(),this._set("tilingSchemeLogic",h(this.tilingSchemeLogic)),this._basemapLayerViewHandles.forEach((e,t)=>this._unregisterTiledLayerView(t)),this._basemapLayerViewHandles.clear(),this._set("overlayManager",h(this.overlayManager)),this._tileCache=h(this._tileCache),this._allTiles.prune(),je.prune(),this._treeDebugger=h(this._treeDebugger),this._renderer.destroyed||this._renderer.destroy(),this._renderer=null,this._iteratorPool=h(this._iteratorPool),this._upsampleMapCache=h(this._upsampleMapCache),this._elevationQueryCache=h(this._elevationQueryCache),this._set("view",null),this._extentHelper=h(this._extentHelper),this._upsampleInfoPool=h(this._upsampleInfoPool),ke(),this._layerViews.forEach(e=>e.length=0),this._performanceInfo=null}get renderer(){return this._renderer}get frustum(){return this.view.state.camera.frustum}get snapLevel(){return this.lodSnappingEnabled?this.view.terrainLevel:null}get lodSnappingEnabled(){return this.view.qualitySettings.tiledSurface.reduceTileLevelDifferences}get upsampleInfoPool(){return this._upsampleInfoPool}get upsampleMapCache(){return this._upsampleMapCache}get elevationQueryCache(){return this._elevationQueryCache}get hasStencilEnabledExtents(){return this._extentHelper.stencilEnabledExtents.length>0}get userClippingExtent(){const{spatialReference:e}=this,t=this.view?.clippingArea;if(null==t||null==e)return null;const i=I(),r=Y(t,i,e)?i:null,s=this._get("userClippingExtent");return k(r,s)?s:r}get rootTilesExtent(){return this._rootTilesExtent}get groundExtent(){const e=V(this.fullGroundExtent,this.userClippingExtent,I()),t=this._get("groundExtent");return k(e,t)?t:e}get fullGroundExtent(){return null!=this._tilingSchemeExtent?this._tilingSchemeExtent:this._rootTilesExtent}get _tilingSchemeExtent(){return this.tilingSchemeLogic?.extent}get updating(){return this._hasPendingUpdates||(this._maxNumUpdating=1),this.enabled&&!!((this.readyToRun||this._watchUpdatingTracking?.updating||this._asyncWorkItems>0)&&this.ready&&!this.suspended||this.overlayManager?.updating||this.terrainTextureCompressionTracker.compressing)}get readyToRun(){return this.enabled&&(this._hasPendingUpdates||this._viewChanged||this._allTilesDirty||!this._allTilesSorted||this._layerViewsDirty||this._scaleRangeQueries?.updating||this._frameTask.updating)&&this.ready&&!this.suspended}get updatingProgressValue(){return this._maxNumUpdating=Math.max(this._pendingUpdates,this._maxNumUpdating),1-this._pendingUpdates/this._maxNumUpdating}get baseOpacity(){return this.view?.map?.ground?.opacity??1}set baseOpacity(e){this.view.map.ground.opacity=e}get viewingMode(){return this.view.state.viewingMode}get ready(){return!this.enabled||null!=this._rootTiles}get rootTiles(){return this._rootTiles}get spatialReference(){return this.tilingScheme?.spatialReference??null}get backgroundColor(){return this.view?.map?.ground?.surfaceColor}set backgroundColor(e){this.view.map.ground.surfaceColor=e}set slicePlaneEnabled(e){this._renderer.slicePlaneEnabled=e,this._set("slicePlaneEnabled",e),this._evaluateTransparency()}get tilingSchemeLocked(){return this.tilingSchemeLogic?.tilingSchemeLocked??!1}get wireframe(){return this._renderer?.wireframe}set wireframe(e){e!==this._renderer.wireframe&&(this._renderer.wireframe=e,this._updateAllTileGeometries())}get opaque(){return 0===this._renderer.transparency}get invisible(){return 3===this._renderer.transparency}set suspended(e){this._set("suspended",e),this._viewChangeUpdate()}get fadeDuration(){return this.view.qualitySettings.fadeDuration??0}intersect(e,t,i,r){this._renderer.intersect(e,t,i,r)}getElevationLevelDelta(e){return e<4?3:this.view.qualitySettings.tiledSurface.elevationLevelDelta}get _xNormalizer(){return q(this._spatialReference)}getElevation(e,t,i,r){const s=this._rootTiles;if(!s?.length||!this.enabled)return null;if(0===s[0].layerInfo[0].length)return null;let a=this._elevationProjectorCache.get(r);if(void 0===a&&(a=M(r,this._spatialReference)??null,this._elevationProjectorCache.set(r,a)),null==a)return l.getLogger(this).error("TerrainSurface.getElevation(): could not project given point to tiling scheme coordinate system"),null;const n=b(tt,e,t,i);a(n,0,n,0);return lt(s,this._xNormalizer?.normalize(n[0])??n[0],n[1])}getElevations(e,t,i){const r=this._rootTiles,s=r?r[0].layerInfo[0].length:0;if(r?.length&&0!==s&&this.enabled)for(let a=0;a<t;++a){const t=3*a;i(a,lt(r,e[t],e[t+1]))}else for(let a=0;a<t;++a)i(a,null)}getLayerIndexByUID(e,t){return this._layerIndexByUid[e].get(t)}getScale(e){if(!this.tilingScheme)return null;if(!D(e,tt,this.spatialReference))return l.getLogger(this).error("TerrainSurface.getScale(): could not project given point to tiling scheme coordinate system"),null;const t=this._rootTiles;if(null!=t)for(const i of t)if(i?.containsPoint(tt)){let e=i;for(;e.children[0]&&!e.rendered;){const t=e.children[0].extent;let i=0;tt[0]>t[2]&&(i+=1),tt[1]<t[1]&&(i+=2),e=e.children[i]}return this._getLodBiasCorrectedScale(e.level)}return 1/0}_ensureProjector(e){const t=this._projectorCache.get(e);if(t)return t;const i=M(e,this._tilingSchemeSpatialReference)??null;return this._projectorCache.set(e,i),i}getSphereElevationRange(e,t){if(!this.enabled||null==this._rootTiles)return null;const i=this._ensureProjector(t);if(null==i)return l.getLogger(this).error("TerrainSurface.getSphereElevationRange(): could not project given point to tiling scheme coordinate system"),null;it.copy(e),i(it.center,0,it.center,0);const r=new z,s=this._rootTiles;if(null!=s){const e=[];for(const i of s)e.push(i);let t=0;for(;t<e.length;){const i=e[t];if(++t,!A(i.extent,it))continue;const s=i.children;if(null==s[0]||i.rendered)r.expandElevationRangeValues(i.elevationBoundsMin,i.elevationBoundsMax);else for(const t of s)e.push(t)}}return r}getRootElevationRange(){return this.enabled&&null!=this._rootTiles?new z(this._rootTileElevationRange.minElevation,this._rootTileElevationRange.maxElevation):null}getLowerBoundRadius(){const e=(this._ellipsoid.radius+this.visibleElevationRange.minElevation)*R;return Math.min(e,this._ellipsoid.radius)}getSphereScale(e,t){if(!this.tilingScheme)return null;if(!D(e,it.center,this.spatialReference))return l.getLogger(this).error("TerrainSurface.getSphereScale(): could not project given point to tiling scheme coordinate system"),null;it.radius=t;let i=null;const r=e=>{if(e&&A(e.extent,it)){const t=e.children;if(t[0]&&!e.rendered)for(const e of t)r(e);else{const t=this._getLodBiasCorrectedScale(e.level);i=null==i?t:Math.min(i,t)}}},s=this._rootTiles;if(null!=s)for(const a of s)r(a);return i}queryVisibleScaleRange(e,t,i,r){if(!this._scaleRangeQueries)return;const s=t?this.tilingScheme.levelAtScale(t):0,a=i?this.tilingScheme.levelAtScale(i):1/0,n=this._lodBias;this._scaleRangeQueries.queryVisibleLevelRange(e,s+n,a+n,r)}_evaluateTransparency(){const e=this.baseOpacity,t=this.overlayManager.renderer.isEmpty,i=this._renderer.transparency,r=this._isFullyTransparent?t?3:2:e>=1&&!this.hasCompositeBlendMode&&!this._renderer.slicePlaneEnabled?0:1;return this._renderer.transparency=r,i!==r&&(this.notifyChange("opaque"),this.notifyChange("invisible"),!0)}_updateTilingScheme(){const{tilingScheme:e}=this.tilingSchemeLogic;if(!(e!==this.tilingScheme))return;_e(!!e,"tiling scheme cannot be reset to undefined"),this._isGlobal=!this.view?.state?.isLocal,this.tilingScheme&&this._removeAllTiles();const t=e?.spatialReference??U.WebMercator;this._spatialReference=t,this._isWebMercator=!!t?.isWebMercator,this._isWebMercatorOnPlateCarree=this._isWebMercator&&F(this.view?.renderSpatialReference),this._isGeographic=t?.isGeographic??!1,this._set("tilingScheme",e),this._tilingSchemeSpatialReference=this.tilingScheme?.spatialReference,this._projectorCache.clear(),this._updateClippingExtent(),e&&(this._updateTiledLayers(),this._renderer.tileSize=e.pixelSize,this.overlayManager.spatialReference=e.spatialReference,this._updateRootTiles())}static{this._tileMemcacheKey="TerrainTileMemcache"}_acquireTile(e,t,i,r){const s=this._tileCache.pop(Je._tileMemcacheKey);return s?(s.init(e,t,i,r,this),s):new this._tileConstructor(e,t,i,r,this)}get updatingRootTiles(){return this._updatingRootTiles}_updateRootTiles(){const{groundExtent:e,tilingScheme:t}=this;if(!t)return;if(!this.enabled)return void this._setRootTiles(null);const i=rt;let s=t.rootTilesInExtent(e,i,5*he);if(null!=this._rootTiles){if(s.length>he)return void l.getLogger(this).warn(de);const e=this._rootTiles.map(e=>e.lij),t=r(e,s,Ie);if(this._updatingRootTiles=!0,t.removed.length>0||t.added.length>0){const e=this._rootTiles.filter(e=>!(t.removed.findIndex(t=>Ie(t,e.lij))>-1)||(this._purgeTile(e),!1));t.added.forEach(t=>e.push(this._newRootTile(t))),this._setRootTiles(e)}}else this._updatingRootTiles=!0,s.length>he&&(l.getLogger(this).warn(pe),s=t.rootTilesInExtent(e,i,he)),this._setRootTiles(s.map(e=>this._newRootTile(e)));k(i,this._rootTilesExtent)||(this._rootTilesExtent=I(i)),this.renderer.visible=!0,this._viewChangeUpdate(),this.overlayManager.setPlacementDirty(),this.notifyChange("ready"),this._updateAllTileGeometries(),this._updatingRootTiles=!1,this.checkAllTilesWaterproofness()}_updateAllTileGeometries(){const e=this._allTiles.filter(e=>e.loaded&&e.intersectsClippingArea);e.sort(Oe),e.forEach(e=>this._renderer.updateTileGeometryState(e)),e.forEach(e=>e.renderData.updateNeighborData()),this._updateTilesGeometries(e),this._pendingTilesToUpdate.clear()}_updateTilesGeometries(e){if(0===e.length)return;e.sort(Oe);const t=this.renderer;e.forEach(e=>t.updateGeometryIfNeeded(e)),e.forEach(e=>this._pendingTilesForElevationUpdateEvent.add(e))}_shouldSplit(e){return 1===e.shouldSplit(this._splitLimits,this._eyePosRenderSR,this.snapLevel)}_newRootTile(e){const t=this._acquireTile(0,e[1],e[2],null);return this._shouldSplit(t)&&t.setPendingUpdate(1),this._loadTile(t),this._markTileToUpdate(t),this._updateRootTileElevationRange(),t}_setRootTiles(e){if(this._rootTiles=e,this._allTiles.clear(),null!=e){const t=this._iteratorPool.acquire();for(t.reset(e);!t.done;)this._allTiles.push(t.next());t.remove()}this._renderer.setRootTiles(this._rootTiles),this._updateTilesVisibility(e),this.notifyChange("demResolution"),this.emit("tiles-changed",{allTiles:this.allTiles})}_runViewChangeUpdateIfDirty(){this._viewChangeUpdateDirty&&(this._viewChangeUpdateDirty=!1,this._viewChangeUpdate())}_viewChangeUpdate(){this.view&&!this.suspended&&this.tilingScheme&&this.renderer.visible&&(this._inFrameTask?this._viewChangeUpdateDirty=!0:(this._viewChangeUpdateDirty=!1,this._updateViewDependentParameters(),this._updateTilesVisibility(this._rootTiles)))}_updateClippingStatus(e){e.updateClippingStatus(this.groundExtent)&&e.resetPendingUpdate(8)&&this._updateTileGeometryState(e)}_updateTilesVisibility(e){if(null==e)return;const t=Ge(e),i=this.visibleElevationRange;let r=t?i.minElevation:1/0,s=t?i.maxElevation:-1/0;const a=this.groundExtent,n=this.view.state.contentCamera.viewProjectionMatrix;this.setTileTreeDirty(!1);const l=this._iteratorPool.acquire();for(l.reset(e);!l.done;){const e=l.next();e.updateClippingStatus(a)&&e.resetPendingUpdate(8)&&this._updateTileGeometryState(e),e.computeVisibility(),e.updateScreenDepth(n),e.renderData&&(r=Math.min(e.elevationBoundsMin,r),s=Math.max(e.elevationBoundsMax,s))}l.remove(),this._viewChanged=!0,this._allTilesDirty=!0,this._updatePendingTileGeometries(),isFinite(r)&&isFinite(s)&&(i.minElevation!==r||i.maxElevation!==s)&&(this.visibleElevationRange=new K(r,s))}_updateRootTileElevationRange(){let e=1/0,t=-1/0;const i=this._rootTiles;null!=i&&i.forEach(({elevationBoundsMin:i,elevationBoundsMax:r})=>{e=Math.min(e,i),t=Math.max(t,r)});const r=this._rootTileElevationRange;r.minElevation===e&&r.maxElevation===t||(this._rootTileElevationRange=new K(e,t))}_updateViewDependentParameters(){const{camera:e,contentCamera:t}=this.view.state,i=Math.tan(.5*t.fovX),r=Math.tan(.5*t.fovY),s=this.tilingScheme.pixelSize,a=2**-this._lodBias*e.pixelRatio;this._splitLimits.aboveGround=e.aboveGround,this._splitLimits.fovX=i,this._splitLimits.fovY=r,this._splitLimits.relativeWidthLimit=s/e.width*this.maxTextureScale*a,this._splitLimits.relativeHeightLimit=s/e.height*this.maxTextureScale*a,this._splitLimits.maxLod=this.tilingScheme.getMaxLod(),this._splitLimits.angledSplitBias=this.view.qualitySettings.tiledSurface.angledSplitBias,this.view.state.fixedContentCamera?this._splitLimits.frustum=G(this._splitLimits.frustum??N(),t.frustum):this._splitLimits.frustum=null,E(this._eyePosRenderSR,t.eye),j(e.eye,this.view.renderSpatialReference,this._eyePosSurfaceSR,this.spatialReference)}_updateTileGeometryState(e){e.updateVisibility();this._renderer.updateTileGeometryState(e)&&this._markTileToUpdate(e),this.setMemoryDirty()}_markAllTileNeighborsForUpdate(e){e.forEachLoadedNeighbor(e=>{this._layerViews[1].some(ye)&&e.setPendingUpdate(32),this._pendingTilesToUpdate.add(e)})}_updateTileTexture(e,t){const i=e.resetPendingUpdate(32)?32:!!e.resetPendingUpdate(16)&&16;i&&(this._renderer.updateTileTexture(e,i),this._usedMemory=null,t.madeProgress())}_emitElevationUpdateEventForTiles(){if(!this._shouldEmitChangeEvent)return;const e=at.extent;B(e),this._pendingTilesForElevationUpdateEvent.forEach(t=>O(e,t.extent,e)),this._pendingTilesForElevationUpdateEvent.clear(),at.spatialReference=this.spatialReference,this.emit("elevation-change",at),this._shouldEmitChangeEvent=!1}runTask(e){this._handleLayerViewChanges(e),this._frameTask.processQueue(e),this.renderer.processScaleRangeQueries(this._scaleRangeQueries,e),this._inFrameTask=!0,this._pendingUpdates=0,this._hasPendingUpdates=!1,this._updateAllTilesStatus(e),this._sortTiles(e);const t=!this.view.state.fixedContentCamera;if(this._mergeAndSplit(e,t),this._updateElevation(e),this._updateTextures(e),t||this._mergeAndSplit(e,!0),this._inFrameTask=!1,this._runViewChangeUpdateIfDirty(),this._updatePendingTileGeometries(),this._emitElevationUpdateEventForTiles(),e.done&&e.hasProgressed&&this.requestUpdate(),this.notifyChange("updatingProgressValue"),Le&&this._checkTileInvariant(),!e.hasProgressed)return Ke}_checkTileInvariant(){const e=new Map;this._allTiles.forAll(t=>e.set(t,new Set)),this._allTiles.forAll(t=>{if(_e(t.rendered===t.leaf,` rendered ${t.rendered} != ${t.leaf} leaf`),!t.leaf){const e=e=>0===e.unmergableChildCount&&0===e.maxLevelDeltaNeighborCount,i=t.children.reduce((t,i)=>t+(e(i)?0:1),0);if(_e(t.unmergableChildCount===i,` Tile[${t.lij.toString()}] unmergeable child count mismatch: actual ${t.unmergableChildCount} vs ${i}`),t.hasPendingUpdate(4)){_e(!t.hasPendingUpdate(1),"Tile can be both split and merge at the same time");for(const e of t.children)_e(e.leaf||e.hasPendingUpdate(4),"Child of tile to merge must also merge")}}for(let i=0;i<4;++i){if(t.rendered){const e=t.renderData?.geometryState.edgePeerNeighbors[i];if(null!=e){{const r=t.level-e.level<=ue;r||(console.log(`tile level delta [${t.lij.toString()}] vs [${e.lij.toString()}] > ${ue} (edge[${i}])`),_e(r,`tile level delta [${t.level}] vs [${e.level}] > ${ue}`))}_e(t.level-e.level<=ue,`Max tile lod delta exceeded: [${t.lij.toString()}] vs [${e.lij.toString()}]`)}}const r=t.level-ue,s=e=>e.leaf||e.level===t.level,a=t.findNeighborTile(fe[i],s);if(null!=a){if(t.leaf&&t.level>=ue){let i=a;for(;t.level-i.level<ue;)i=i.parent;const s=[r,t.lij[1]>>ue,t.lij[2]>>ue];if(!Ie(s,i.lij)){const r=e.get(i);_e(!r.has(t),"Cannot already have neighbor"),r.add(t)}}_e(a.rendered||a.level===t.level,"Non-same-level-neighbor of rendered must be rendered"),_e(t.level-a.level<=ue,`Tile level delta [${t.level}] vs [${a.level}] > ${ue}`)}}}),this._allTiles.forAll(t=>{const i=t.maxLevelDeltaNeighborCount,r=e.get(t);_e(i===r.size,`Tile[${t.lij.toString()}] merge-blocker mismatch: actual ${i} vs ${r.size}`)})}_updateAllTilesStatus(e){if(!this._viewChanged||!this._rootTiles||e.done)return;this._viewChanged=!1;const t=new ae(this._allTiles.length);t.pushAll(this._rootTiles);const i=this.snapLevel,r=this._splitLimits,s=this._eyePosRenderSR;this._allTiles.forAll(e=>{e.maxLevelDeltaNeighborCount=0,e.unmergableChildCount=0});const a=this.view.state.contentCamera.viewProjectionMatrix;for(;!t.empty;){const e=t.pop(),n=e.parent,l=n?.hasPendingUpdate(4),o=l?4:e.shouldSplit(r,s,i),h=1===o;e.leaf?ot(e,h):t.pushAll(e.children),l?(e.resetPendingUpdate(1),e.leaf||e.setPendingUpdate(4),this._updateClippingStatus(e),e.updateVisibility(),e.updateScreenDepth(a)):h?(e.resetPendingUpdate(4),e.leaf&&e.setPendingUpdate(1)):(e.resetPendingUpdate(1)&&e.updateAgentSuspension(),2===o&&e.updateAgents(0),e.leaf||(e.setPendingUpdate(4),e.resetPendingUpdate(1)))}this.requestUpdate(),(this._shortBatches||!this._oneBatchPerFrameTask)&&this._updatePendingTileGeometries(),e.madeProgress()}_sortTiles(e){e.done||this._allTilesSorted||!this.view.pointsOfInterest?.focus||(Ne(this._allTiles,this.view.pointsOfInterest.focus.renderLocation),this._allTilesSorted=!0,this._treeDebugger?.update(),e.madeProgress())}_markTileToUpdate(e){Te(e.loaded),e.intersectsClippingArea&&(this._pendingTilesToUpdate.add(e),this._markAllTileNeighborsForUpdate(e))}_updatePendingTileGeometries(){const e=this._pendingTilesToUpdate,t=Array.from(e.keys()).filter(e=>e.loaded&&e.intersectsClippingArea);if(0===t.length)return void e.clear();const i=(i,r)=>{!r?.loaded||!r.intersectsClippingArea||r.level<i.level||e.has(r)||(e.add(r),t.push(r),r.renderData.updateNeighborData())};t.sort(Oe);const r=t.length;for(let s=0;s<r;++s){const r=t[s];Te(r.loaded),Te(r.intersectsClippingArea);const a=r.renderData;a.updateNeighborData();const n=a.dirtyEdgeResolutions,l=a.geometryState,o=e=>{const t=De[e];i(r,l.cornerPeerNeighbors[e]?.findCorner(Pe(t),e=>e.loaded))};for(let t=0;t<4;++t)if(n&1<<t){const s=a.geometryState.edgePeerNeighbors[t];s&&s?.level>=r.level&&s.forAllSubtreeOnSide(ve(fe[t]),t=>!(!t.loaded||!t.intersectsClippingArea)&&(Te(e.has(t)||Oe(r,t)<0),i(r,t),!0)),o((t+1)%4),o(t)}}e.clear(),this._updateTilesGeometries(t),this._shouldEmitChangeEvent=!0,Le&&Re&&this.checkAllTilesWaterproofness()}_mergeAndSplit(e,t){if(this.suspended||e.done||!this._allTilesDirty)return;this._allTilesDirty=!1,this.requestUpdate();let i=!1;const r=this.view.state.fixedContentCamera;let s=!1;for(;!e.done;){s=!0;let a=!1;const n=!this._allTiles.some(s=>{if(!i&&!r&&!s.visible)return e.done;let n=s;if(s.hasPendingUpdate(4)){if(!t||s.unmergableChildCount>0)return e.done;for(s.resetPendingUpdate(4);null!=n.parent&&0===n.parent.unmergableChildCount&&n.parent.resetPendingUpdate(4);)n=n.parent;this._mergeTile(n),a=!0,e.madeProgress()}else if(s.resetPendingUpdate(1)){let t=!0;const i=s.level;if(i>=ue){const e=e=>e.leaf||i-e.level<ue;for(let r=0;r<4;++r){const a=s.findNeighborTile(fe[r],e);null!=a&&i-a.level===ue&&(t=!1,Le&&(Te(a.leaf),Te(a.hasPendingUpdate(1))))}}t?(this._splitTile(s),e.madeProgress(),a=!0):s.setPendingUpdate(1)}return e.done});if(a&&(this._allTilesSorted=!1,this._allTilesDirty=!0,!this._oneBatchPerFrameTask&&this._updatePendingTileGeometries()),n){if(!i){i=!0;continue}if(!a)break}else this._allTilesDirty=!0}s?e.madeProgress():this._allTilesDirty=!0,!this._oneBatchPerFrameTask&&this._updatePendingTileGeometries(),this._allTilesCreated=!this.allTiles.some(e=>e.hasPendingUpdate(1)||e.hasPendingUpdate(4)),this._sortTiles(e)}_updateElevation(e){e.done||(this._allTiles.some(t=>(t.resetPendingUpdate(8)&&(this._updateTileGeometryState(t),this._shortBatches&&this._updatePendingTileGeometries(),e.madeProgress()),e.done)),!this._oneBatchPerFrameTask&&this._updatePendingTileGeometries())}_updateTextures(e){e.done||this._allTiles.some(t=>(this._updateTileTexture(t,e),e.done))}_updateClippingExtent(){this.spatialReference&&(this.updateOverlayParameters(),this.requestRender(1),this.overlayManager.setPlacementDirty(),this._updateRootTiles())}get _lodBias(){return this.view.qualitySettings.tiledSurface.lodBias-(1-this.view.quality)*ce}_getLodBiasCorrectedScale(e){const t=this.tilingScheme.levels,i=o(e-this._lodBias,0,t.length-1),r=i-Math.floor(i);return t[Math.floor(i)].scale*(1-r)+t[Math.ceil(i)].scale*r}_removeAllTiles(){null!=this._rootTiles&&(this._rootTiles.forEach(e=>this._purgeTile(e)),this._setRootTiles(null),this.notifyChange("ready")),this._allTiles.clear(),this.notifyChange("demResolution"),this.emit("tiles-changed",{allTiles:this.allTiles}),this.renderer.visible=!1}_purgeSubtree(e){const t=e.children;t[0]&&(this._purgeTile(t[0]),this._purgeTile(t[1]),this._purgeTile(t[2]),this._purgeTile(t[3]),e.clearChildren())}_purgeTile(e){e.leaf?dt(e):this._purgeSubtree(e),this._allTiles.removeUnordered(e),this._unloadTile(e),e.dispose(),this._tileCache.put(Je._tileMemcacheKey,e),this.notifyChange("demResolution"),this.emit("tiles-changed",{allTiles:this.allTiles})}_unloadTile(e){this._pendingTilesToUpdate.delete(e),this._pendingTilesForElevationUpdateEvent.delete(e),e.unload()}_splitTile(e){_e(e.leaf,"Tile that is already split should not be split again!"),_e(e.rendered,"Tile marked to split is not rendered"),dt(e);const t=e.createChildren();this._allTiles.pushArray(t),this.notifyChange("demResolution"),this.emit("tiles-changed",{allTiles:this.allTiles}),e.updateAgentSuspension(),_e(e.rendered,"parent should be rendered"),t.forEach(e=>this._loadTile(e)),t.forEach(e=>this._pendingTilesToUpdate.add(e)),this._unloadTile(e),this._markAllTileNeighborsForUpdate(e),this._emitTileScaleChange(e,e.level+1),this._allTilesDirty=!0,this._shortBatches&&this._updatePendingTileGeometries(),t.forEach(e=>ot(e,e.hasPendingUpdate(1))),++this._performanceInfo.numSplit}_emitTileScaleChange(e,t=e.level){nt.spatialReference=this.spatialReference,nt.extent=e.extent,nt.scale=this._getLodBiasCorrectedScale(t),this.emit("scale-change",nt)}createTile(e,t,i,r){_e(!!r,"createTile sanity check");const s=this._acquireTile(e,t,i,r);return s.updateClippingStatus(this.groundExtent),s.updateScreenDepth(this.view.state.contentCamera.viewProjectionMatrix),this._shouldSplit(s)&&s.setPendingUpdate(1),s}get _shortBatches(){return 2!==this.view.state.mode}_mergeTile(e){_e(!e.hasPendingUpdate(1),"_mergeTile sanity check"),_e(!e.leaf,"Cannot merge a leaf"),e.leaf||(this._purgeSubtree(e),_e(!e.renderData,"Merging tile with existing render data?"),this._loadTile(e),this._markTileToUpdate(e),this._emitTileScaleChange(e),this._shortBatches&&this._updatePendingTileGeometries(),ot(e,!1),this._allTilesDirty=!0,++this._performanceInfo.numMerged)}_loadTile(e){e.load(),this.requestUpdate(),this._allTilesDirty=!0,this.overlayManager?.hasOverlays&&e.updateOverlayParameters(this.overlayManager)}_handleLayerViewChanges(e=Ye){if(!this._layerViewsDirty)return;this._layerViewsDirty=!1;let t=!1;const i=new Set;let r=-1;for(let s=this.view.allLayerViews.length-1;s>=0;s--){const e=this.view.allLayerViews.items[s];if(i.add(e.uid),we(e)||Ce(e))if(this._basemapLayerViewHandles.has(e.uid)&&!Ce(e)){const i=this._layerClassFromLayerView(e),s=this.getLayerIndexByUID(i,e.uid);null!=s&&((s<r||null==r)&&(t=!0),r=s)}else this._registerTiledLayerView(e),e.layer.loaded&&(t=!0)}this._basemapLayerViewHandles.forEach((e,r)=>{i.has(r)||(this._unregisterTiledLayerView(r),t=!0)}),t&&this._updateTiledLayers(),this.hasCompositeBlendMode=this._hasCompositeBlendMode(),this._evaluateTransparency(),e.madeProgress()}get _isFullyTransparent(){if(this.view.map?.ground?.opacity>0)return!1;for(const e of this.view.allLayerViews.items)if(Se(e)&&!$(e.layer)&&0!==e.fullOpacity)return!1;return!0}_hasCompositeBlendMode(){for(const e of this.view.allLayerViews.items)if((be(e)||Ce(e))&&We(He[e.layer.blendMode]))return!0;return!1}_layerClassFromLayerView(e){return Ee(e)?0:1}_registerTiledLayerView(e){const t=[];if((be(e)||Ce(e))&&t.push(_(()=>e.layer.blendMode,()=>{this.hasCompositeBlendMode=this._hasCompositeBlendMode(),this._updateTileTextures(2)})),!Ce(e)){const i=this._layerClassFromLayerView(e);t.push(_(()=>!e.destroyed&&e.suspended,()=>this._updateTiledLayers())),t.push(_(()=>!e.destroyed&&e.fullOpacity,()=>this._updateTileTextures(2)));const{layer:r}=e;"effectiveScaleRange"in r&&t.push(_(()=>!e.destroyed&&r.effectiveScaleRange,()=>this._restartAllAgents(i))),t.push(e.on("data-changed",()=>{const t=this.getLayerIndexByUID(i,e.uid);null!=t&&this._invalidateLayerData(t,i)}))}this._unregisterTiledLayerView(e.uid),this._basemapLayerViewHandles.set(e.uid,t)}_unregisterTiledLayerView(e){const t=this._basemapLayerViewHandles.get(e);if(t){for(const e of t)e.remove();this._basemapLayerViewHandles.delete(e)}}_updateTiledLayers(){if(!this.tilingScheme||this.view.suspended)return;const e=this.view.allLayerViews,t=[[],[]];let i=null;e.forEach(e=>{if(!e.layer||e.suspended||!we(e)||!e.fullExtent)return;const r=this._layerClassFromLayerView(e);if(1===r){const t=e.displayLevelRange.maxLevel;t!==1/0&&(null===i||t>i)&&(i=t)}t[r].push(e)});for(const r of ie){const e=this._layerViews[r],i=t[r];i.reverse();const s=i.length;let a=e.length!==s;const n=new Array(s),l=new Array(e.length);this._layerIndexByUid[r].clear();for(let t=0;t<s;t++){const s=i[t].uid;this._layerIndexByUid[r].set(s,t);const o=e.indexOf(i[t]);n[t]=o,t!==o&&(a=!0),o>-1&&(l[o]=t)}if(a){const e=this._postorderIterator;for(e.reset(this._rootTiles);!e.done;)e.next().modifyLayers(l,n,r);this._layerViews[r]=i,this._restartAllAgents(r),this._updateTilesVisibility(this._rootTiles)}}this.tilingScheme.ensureMaxLod(i)&&(this._viewChangeUpdate(),this.notifyChange("tilingScheme"))}_restartAllAgents(e){const t=this._postorderIterator;for(t.reset(this._rootTiles);!t.done;){const i=t.next();i.restartAgents(e),0===e&&i.computeElevationBounds()}this._updateRootTileElevationRange()}layerViewByIndex(e,t){return this._layerViews[t][e]}numLayers(e){return this._layerViews[e].length}_updateTileTextures(e){this._allTiles.forAll(t=>{t.updateAgents(1),1===e?this.renderer.updateTileTexture(t,16):t.updateRenderData(1,e)}),this._evaluateTransparency()}_invalidateLayerData(e,t){this._allTiles.forAll(i=>i.removeLayerAgent(e,t)),this._allTiles.forAll(i=>i.invalidateLayerData(e,t))}setTileTreeDirty(e){this._allTilesDirty=!0,e&&(this._allTilesCreated=!1)}requestRender(e=1){this.renderer.setNeedsRender(e)}requestUpdate(){1===++this._pendingUpdates&&(this._hasPendingUpdates=!0)}requestTileData(e,t,i,r){const s=this.layerViewByIndex(t,i),a=s.layer;return!a.tilemapCache||ye(s)?this._requestTileData(e,i,s,r):(++this._asyncWorkItems,a.tilemapCache.fetchAvailability(e.level,e.lij[1],e.lij[2],{...r,timeout:6e3}).then(()=>--this._asyncWorkItems).catch(t=>{throw--this._asyncWorkItems,c(r),g(t)||this._dataMissing(e,i,s),t}).then(()=>this._frameTask.schedule(()=>this._requestTileData(e,i,s,r),r.signal)))}_requestTileData(e,t,i,r){if(this.destroying)return Promise.resolve();return 0===t?Ee(i)?this._requestElevationTileData(e,i,r):Promise.reject():Se(i)?this._requestMapTileData(e,i,r):Promise.reject()}_requestElevationTileData(e,t,i){++this._asyncWorkItems;const r=r=>{!m(i)&&r&&(this.setMemoryDirty(),this.requestUpdate(),this._elevationDataArrived(e,t,r))},s=i=>{g(i)||(l.getLogger(this).error(`Tile ${e.lij.toString()} layer 0/${t.uid} error ${i}`),this._dataMissing(e,0,t),this.requestUpdate())};return t.fetchElevationTile(e,i).then(e=>this._frameTask.schedule(()=>r(e)),s).finally(()=>--this._asyncWorkItems)}_elevationDataArrived(e,t,i){const r=this._layerIndexByUid[0].get(t.uid);if(null==r)return void l.getLogger(this).warn("TerrainSurface: received data from unknown layer %d %s",0,e.lij.toString());const s=new J(e.lij,e.extent,i);e.dataArrived(r,0,s),this.emit("tile-data-changed",{tile:e,layerIndex:r,layerClass:0});const a=[e],n=e.level,o=this._iteratorPool.acquire();for(o.reset(a);!o.done;){const e=o.next();e.findElevationBoundsForLayer(r,n),e.computeElevationBounds()}0===n&&this._updateRootTileElevationRange(),o.remove(),this._updateTilesVisibility(a)}_requestMapTileData(e,t,i){++this._asyncWorkItems;const r=(r,s)=>{xe(s),m(i)||(console.error(`Tile ${e.lij.toString()} layer 1/${t.uid} error ${r}`),this._dataMissing(e,1,t),this.requestUpdate())},s=e=>t=>r(t,e),a=r=>this._frameTask.schedule(()=>{this.requestUpdate(),m(i)?xe(r):this._mapTileDataArrived(e,t,r)},i.signal,s(r)).catch(s(r)),n=(e,t=null)=>this._frameTask.schedule(()=>r(e,t));return t.fetchTile(e.lij,i).then(a,n).finally(()=>--this._asyncWorkItems)}_mapTileDataArrived(e,t,i){const r=this.getLayerIndexByUID(1,t.uid);if(null==r)return xe(i),void l.getLogger(this).warn("TerrainSurface: received data from unknown layer");e.dataArrived(r,1,i),this.emit("tile-data-changed",{tile:e,layerIndex:r,layerClass:1})}_dataMissing(e,t,i){const r=this.getLayerIndexByUID(t,i.uid);null!=r?(e.dataMissing(r,t),this.emit("tile-data-changed",{tile:e,layerIndex:r,layerClass:t})):l.getLogger(this).warn("TerrainSurface: received data from unknown layer")}get performanceInfo(){const e=this._performanceInfo;return e.numNodes=this._allTiles.length,e.numLeaves=e.numVisible=e.numRendered=e.numLoadedPerLevel.length=e.numRenderedPerLevel.length=0,this._allTiles.forAll(t=>{t.leaf&&e.numLeaves++;const i=t.level;t.renderData&&(e.numLoadedPerLevel[i]=(e.numLoadedPerLevel[i]||0)+1),t.visible&&(e.numVisible++,t.rendered&&(e.numRenderedPerLevel[i]=(e.numRenderedPerLevel[i]||0)+1,e.numRendered++))}),e}setMemoryDirty(){this._usedMemory=null}get usedMemory(){return this.tilingScheme?(null==this._usedMemory&&(this._usedMemory=this._recalculateUsedMemory()),this._usedMemory??0):0}_recalculateUsedMemory(){return this.tilingScheme?Math.round(this._allTiles.reduce((e,t)=>e+t.usedMemory,0)):null}getUsedMemoryForLayerView(e){let t=0;const i=this._layerClassFromLayerView(e),r=this.getLayerIndexByUID(i,e.uid);return null!=r&&this._allTiles.forAll(e=>t+=e.getUsedMemoryForLayer(i,r)),t}get renderPatchBorders(){return this._renderer.renderPatchBorders}set renderPatchBorders(e){this._renderer.renderPatchBorders=e}get renderingDisabled(){return this._renderer.renderingDisabled}set renderingDisabled(e){this._renderer.renderingDisabled=e}get test(){}checkAllTilesWaterproofness(){if(!Re)return;const e=this._rootTiles;if(null==e)return;const t=e=>e?.renderData?.geometry?.indices?.length>0,i=(e,i)=>{t(e)&&console.error("Tile[",e.lij,"] has geometry although parent[",i.lij,"] has geom")},r=e=>{if(e.intersectsClippingArea)if(e.renderData&&!e.renderData.geometryState&&console.error("Tile[",e.lij,"] has renderData but not geometryState"),e.renderData&&!e.renderData.geometry&&console.error("Tile[",e.lij,"] has renderData but not geometryInfo"),!e.renderData?.geometry||(e.renderData.geometry.indices?.length??0)>0||console.error("Tile[",e.lij,"] has renderData but no indices - geometryInfo: ",e.renderData.geometry),t(e)){e.checkGeometryWaterproofness();for(const t of e.children)i(t,e)}else if(e.leaf)console.error("Tile[",e.lij,"] has no geometry and no children, from root to leaf");else for(const t of e.children)r(t)},s=e=>{const t=e.parent?.visible??!0,i=e.visible;e.computeVisibility();const r=e.visible;if(i!==r&&t&&console.error(" Tile[",e.lij,"] has out of date visibility: ",i," instead of ",r),!e.leaf)for(const a of e.children)s(a)};for(const a of e)r(a),s(a)}get isGlobal(){return this._isGlobal}get isGeographic(){return this._isGeographic}get isWebMercator(){return this._isWebMercator}get isWebMercatorOnPlateCarree(){return this._isWebMercatorOnPlateCarree}isEastEndWrap(e){return this._isGlobal&&e[2]===this.lijEastEnd(e[0])-1}isWestEndWrap(e){return this._isGlobal&&0===e[2]}lijEastEnd(e){return 1<<e+(this._isGeographic?1:0)}wrapEastWest(e){const t=this.lijEastEnd(e[0]),i=e[2];if(0<=i&&i<t)return e;if(!this._isGlobal)return null;const r=(i+(i<0?t:0))%t;return[e[0],e[1],r]}enableInternalChecks(e){Ue(e)}enableWaterproofnessChecks(e){Me(e)}static cleanupTerrainSurface(){st.prune()}enable(e){e!==this.enabled&&(this._set("enabled",e),e?(this._updateRootTiles(),this.suspended=!1):(this.suspended=!0,this._removeAllTiles(),this._setRootTiles(null)),this.notifyChange("ready"))}updateOverlayParameters(){const{overlayManager:e}=this;this.allTiles.forAll(t=>t.updateOverlayParameters(e))}};e([w()],Ze.prototype,"_renderer",void 0),e([w({constructOnly:!0})],Ze.prototype,"_scaleRangeQueries",void 0),e([w({constructOnly:!0})],Ze.prototype,"view",void 0),e([w({constructOnly:!0})],Ze.prototype,"overlayManager",void 0),e([w({constructOnly:!0})],Ze.prototype,"terrainTextureCompressionTracker",void 0),e([w()],Ze.prototype,"_hasPendingUpdates",void 0),e([w()],Ze.prototype,"_asyncWorkItems",void 0),e([w()],Ze.prototype,"_allTilesDirty",void 0),e([w()],Ze.prototype,"_allTilesSorted",void 0),e([w()],Ze.prototype,"allTilesCreated",null),e([w()],Ze.prototype,"_allTilesCreated",void 0),e([w()],Ze.prototype,"_viewChanged",void 0),e([w({type:Number})],Ze.prototype,"heading",void 0),e([w()],Ze.prototype,"_splitLimits",void 0),e([w({readOnly:!0})],Ze.prototype,"_watchUpdatingTracking",void 0),e([w()],Ze.prototype,"_frameTask",void 0),e([w()],Ze.prototype,"demResolution",null),e([w({readOnly:!0})],Ze.prototype,"snapLevel",null),e([w({readOnly:!0})],Ze.prototype,"lodSnappingEnabled",null),e([w({readOnly:!0})],Ze.prototype,"userClippingExtent",null),e([w()],Ze.prototype,"_rootTilesExtent",void 0),e([w({readOnly:!0})],Ze.prototype,"groundExtent",null),e([w({readOnly:!0})],Ze.prototype,"fullGroundExtent",null),e([w({readOnly:!0})],Ze.prototype,"_tilingSchemeExtent",null),e([w({readOnly:!0})],Ze.prototype,"updating",null),e([w({readOnly:!0})],Ze.prototype,"readyToRun",null),e([w(X)],Ze.prototype,"updatingProgress",void 0),e([w({readOnly:!0})],Ze.prototype,"updatingProgressValue",null),e([w()],Ze.prototype,"_maxNumUpdating",void 0),e([w()],Ze.prototype,"baseOpacity",null),e([w()],Ze.prototype,"hasCompositeBlendMode",void 0),e([w({readOnly:!0})],Ze.prototype,"viewingMode",null),e([w()],Ze.prototype,"maxTextureScale",void 0),e([w({readOnly:!0})],Ze.prototype,"ready",null),e([w({readOnly:!0})],Ze.prototype,"rootTiles",null),e([w()],Ze.prototype,"_rootTiles",void 0),e([w({readOnly:!0})],Ze.prototype,"spatialReference",null),e([w({type:t})],Ze.prototype,"backgroundColor",null),e([w({value:!1})],Ze.prototype,"slicePlaneEnabled",null),e([w({readOnly:!0})],Ze.prototype,"tilingScheme",void 0),e([w({readOnly:!0})],Ze.prototype,"tilingSchemeLocked",null),e([w({readOnly:!0})],Ze.prototype,"tilingSchemeLogic",void 0),e([w()],Ze.prototype,"wireframe",null),e([w()],Ze.prototype,"opaque",null),e([w()],Ze.prototype,"invisible",null),e([w({value:!1})],Ze.prototype,"suspended",null),e([w()],Ze.prototype,"fadeDuration",null),e([w()],Ze.prototype,"_xNormalizer",null),e([w()],Ze.prototype,"visibleElevationRange",void 0),e([w()],Ze.prototype,"_rootTileElevationRange",void 0),e([w()],Ze.prototype,"_layerViewsDirty",void 0),e([w()],Ze.prototype,"renderPatchBorders",null),e([w()],Ze.prototype,"renderingDisabled",null),e([w({readOnly:!0})],Ze.prototype,"enabled",void 0),Ze=Je=e([C("esri.views.3d.terrain.TerrainSurface")],Ze);const et=Ze,tt=x(),it=new W,rt=I(),st=new u,at=new ee("ground"),nt={spatialReference:null,extent:null,scale:0};function lt(e,t,i){for(const r of e){if(!r.containsPointXY(t,i))continue;let e=r;for(;e&&!e.renderData;){const r=(t>e.extentMidX?1:0)+(i<e.extentMidY?2:0);e=e.children[r]}const s=e?.renderData?.geometryState.samplerData??null;return Z(t,i,s)}return null}function ot(e,t){!e.leaf||e.level<ue||ut(e,e=>{t&&ht(e);const i=pt(e);if(e.maxLevelDeltaNeighborCount++,i){let t=e.parent;for(;t;){const e=pt(t);if(t.unmergableChildCount++,!e)break;t=t.parent}}})}function ht(e){if(e.hasPendingUpdate(1))return;let t=e.parent;for(;t?.resetPendingUpdate(4);)t=t.parent;e.resetPendingUpdate(4),e.leaf&&e.setPendingUpdate(1),e.level<ue||ut(e,e=>{ht(e)})}function dt(e){e.level<ue||ut(e,e=>{if(e.maxLevelDeltaNeighborCount--,0===e.maxLevelDeltaNeighborCount&&0===e.unmergableChildCount){let t=e.parent;for(;t&&(t.unmergableChildCount--,pt(t));)t=t.parent}})}function pt(e){return 0===e.maxLevelDeltaNeighborCount&&0===e.unmergableChildCount}function ut(e,t){if(e.level<ue)return;const i=e.level-ue,r=e.lij[1]>>ue,s=e.lij[2]>>ue,a=e=>e.leaf||e.level===i;for(let n=0;n<4;++n){const l=e.findNeighborTile(fe[n],a);if(!l||l.level!==i)continue;const o=l.lij;o[1]===r&&o[2]===s||t(l)}}export{et as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import{invert as t,transpose as r}from"../../../../../../core/libs/gl-matrix-2/math/mat3.js";import{clone as s}from"../../../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{m as o,I as i}from"../../../../../../chunks/vec32.js";import{freeze as a,ZEROS as n}from"../../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{v as l}from"../../../../../../chunks/vec42.js";import{freeze as u,fromValues as h}from"../../../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{ComponentTechnique as p}from"./ComponentTechnique.js";import{ComponentTechniqueConfiguration as c}from"./ComponentTechniqueConfiguration.js";import{parameter as d,parameterBlock as m,MaterialBase as v,MaterialParameterBlock as g}from"../../../core/material/MaterialBase.js";import{isColor as x}from"../../../core/shaderLibrary/ShaderOutput.js";import{TwoVectorPosition as f}from"../../../core/util/TwoVectorPosition.js";import{advancedMRRFactors as y}from"../../../materials/pbrUtils.js";import{defaultHighlightName as M}from"../../../../../support/HighlightDefaults.js";import{alphaCutoff as T}from"../../../../../../webscene/support/AlphaCutoff.js";class b extends v{constructor(e,o,i,n){super(),this.toMapSpace=o,this.useENUForGlobalOverlayUV=i,this.baseColor=u(1,1,1,1),this.usePBR=!1,this.hasParametersFromSource=!1,this.sphereDepthInterpolate=!1,this.mrrFactors=y,this.baseColorTexture=null,this.metallicRoughnessTexture=null,this.normalTexture=null,this.occlusionTexture=null,this.emissionTexture=null,this.emissiveBaseColor=a(0,0,0),this.emissiveStrength=0,this.commonMaterialParameters=new S,this.componentParameters=new C,this.textureBackedBuffer=null,this.objectOpacity=1,this.textureAlphaCutoff=T,this.alphaDiscardMode=1,this.isIntegratedMesh=!1,this.polygonOffsetEnabled=!1,this.ellipsoidMode=1,this.hasOccludees=!1;const l=s(e.rotationScale);t(l,l),r(l,l),this.transformNormalGlobalFromModel=l;const h=new f(e.position);this.transformWorldFromModelTL=h.low,this.transformWorldFromModelTH=h.high,this.transformWorldFromModelRS=e.rotationScale,this._configuration=new c(n),this._updateMaterialConfiguration()}dispose(){this.baseColorTexture=null,this.metallicRoughnessTexture=null,this.emissionTexture=null,this.occlusionTexture=null,this.normalTexture=null}get _hasEmissiveBase(){return null!=this.emissionTexture||!o(this.emissiveBaseColor,n)}get _hasEmissiveStrength(){return 2!==this.componentParameters.emissiveOverride}get hasEmissions(){return this._hasEmissiveStrength&&(this._hasEmissiveBase||2!==this.componentParameters.emissiveSourceOverride)}get texture(){return this.baseColorTexture?.texture}get textureMetallicRoughness(){return this.metallicRoughnessTexture?.texture}get textureEmissive(){return this.emissionTexture?.texture}get textureOcclusion(){return this.occlusionTexture?.texture}get textureNormal(){return this.normalTexture?.texture}update(e){e(this)}acquireTechnique(e,t,r,s){const o=this._updateConfiguration(t,r,s);return e.get(p,o,s.layout)}_updateConfiguration(e,t,r){return this._updateMaterialConfiguration(),this._updateDrawConfiguration(e,t,r)}_updateMaterialConfiguration(){if(!this.dirty)return;const e=this._configuration;e.hasMetallicRoughnessTexture=null!=this.metallicRoughnessTexture,e.hasOcclusionTexture=null!=this.occlusionTexture,e.hasNormalTexture=null!=this.normalTexture,e.sphereDepthInterpolate=this.sphereDepthInterpolate&&e.spherical,e.ellipsoidMode=this.ellipsoidMode,e.componentData=this.componentParameters.type,e.cullFace=this.commonMaterialParameters.cullFace,e.doubleSidedMode=this.commonMaterialParameters.doubleSided?1:0,e.hasColorTexture=null!=this.baseColorTexture,e.alphaDiscardMode=this.alphaDiscardMode,e.hasPolygonOffset=this.polygonOffsetEnabled,this._setClean()}_updateDrawConfiguration(e,t,r){const s=this._configuration,o=e.identifier,i=0===o;s.hasEmission=t.hasEmission&&i,s.renderOccluded=10===t.slot,s.hasVertexColors=r.hasVertexColors,s.hasNormals=r.hasNormals,s.textureCoordinateType=r.textureCoordinateType,s.oitPass=i?t.oitPass:0,s.terrainDepthTest=i&&t.terrainDepthTest,s.cullAboveTerrain=!!i&&t.cullAboveTerrain,s.integratedMeshMode=this.isIntegratedMesh?D(t)?w(t)?3:2:1:0,s.pbrMode=3===s.integratedMeshMode?4:this.usePBR?this.hasParametersFromSource?r.shadeNormals&&this.isIntegratedMesh?0:2:1:0;const a=1===this.componentParameters.emissiveSourceOverride,n=2===this.componentParameters.emissiveSourceOverride,l=null!=this.emissionTexture;s.emissionSource=this.hasEmissions?this._hasEmissiveBase&&1===s.pbrMode?n?l?4:2:a?l?5:7:6:a?7:6:0,s.shadeNormals=r.shadeNormals,s.normalType=s.hasNormals?1:2;const u=null!=t.slicePlane&&this.commonMaterialParameters.hasSlicePlane;s.hasSlicePlane=u,s.isGroundSlice=u&&this.commonMaterialParameters.isGround;const h=this._computeMaterialPass();s.blendingEnabled=1===h||2===h||4===h||s.isGroundSlice,s.hasHighlightMixTexture=2===o&&null!=t.highlightMixTexture,s.output=e.output,s.snowCover=i&&t.snowCover>0,s.vertexDiscardMode=i&&2===h?e.transparent?2:1:0,s.olidColor=i&&9===e.output;const p=i&&x(e.output);return s.receiveAmbientOcclusion=p&&r.applySSAO&&null!=t.ssao?.getTexture(),s.hasOccludees=p&&t.hasOccludees,s.receiveShadows=p&&t.shadowMap.ready,s.screenSpaceReflections=p&&null!=t.ssr.lastFrameColor,s.cloudReflections=p&&null!=t.clouds.data?.cubeMap?.colorTexture,s}submit(e,t,r){if(this.objectOpacity<=0)return;const{componentData:s,renderable:o}=r,{geometry:i}=o,a=o.meta.cameraDepthSquared;s.updateHighlights(t.highlights);const{geometryRanges:n,highlightRangesMap:l,shadowmapRanges:u}=s,h=e=>e.submitDraw(this,i,n,a);switch(this._computeMaterialPass()){case 0:h(e.opaque);break;case 1:h(e.transparent);break;case 2:h(e.opaque),h(e.transparent);break;case 3:h(e.integratedMesh),j(t)&&h(e.occludedGround),P(t)&&h(e.highlightIntegratedMesh);break;case 4:h(e.transparentIntegratedMesh)}if(2!==this.componentParameters.castShadows){if(null!=l)for(const t of l)t[0]===M&&e.highlightShadowMap.submitDraw(this,i,t[1],a,t[0]);null!=u&&e.defaultShadowMap.submitDraw(this,i,u,a),h(e.shadowMap)}if(null!=l)for(const p of l)e.highlight.submitDraw(this,i,p[1],a,p[0]);t.viewshedEnabled&&h(e.viewshedShadowMap)}_computeMaterialPass(){if(this.isIntegratedMesh)return this.objectOpacity<1?4:3;if(this.objectOpacity<1)return this.isIntegratedMesh?4:1;if(0===this.componentParameters.opaqueOverride)return 0;if(this.baseColor[3]<1||0===this.alphaDiscardMode||3===this.alphaDiscardMode)return 1;switch(this.componentParameters.transparent){case 2:return 0;case 0:return 1;case 1:return 2}}}e([d({vectorOps:l})],b.prototype,"baseColor",void 0),e([d()],b.prototype,"usePBR",void 0),e([d()],b.prototype,"hasParametersFromSource",void 0),e([d()],b.prototype,"sphereDepthInterpolate",void 0),e([d({vectorOps:i})],b.prototype,"mrrFactors",void 0),e([d({dispose:!0})],b.prototype,"baseColorTexture",void 0),e([d({dispose:!0})],b.prototype,"metallicRoughnessTexture",void 0),e([d({dispose:!0})],b.prototype,"normalTexture",void 0),e([d({dispose:!0})],b.prototype,"occlusionTexture",void 0),e([d({dispose:!0})],b.prototype,"emissionTexture",void 0),e([d({vectorOps:i})],b.prototype,"emissiveBaseColor",void 0),e([d()],b.prototype,"emissiveStrength",void 0),e([m()],b.prototype,"commonMaterialParameters",void 0),e([m()],b.prototype,"componentParameters",void 0),e([d()],b.prototype,"textureBackedBuffer",void 0),e([d()],b.prototype,"objectOpacity",void 0),e([d()],b.prototype,"textureAlphaCutoff",void 0),e([d()],b.prototype,"alphaDiscardMode",void 0),e([d()],b.prototype,"isIntegratedMesh",void 0),e([d()],b.prototype,"polygonOffsetEnabled",void 0),e([d()],b.prototype,"ellipsoidMode",void 0),e([d()],b.prototype,"hasOccludees",void 0);class S extends g{constructor(){super(...arguments),this.doubleSided=!1,this.cullFace=2,this.isGround=!1,this.hasSlicePlane=!0}}e([d()],S.prototype,"doubleSided",void 0),e([d()],S.prototype,"cullFace",void 0),e([d()],S.prototype,"isGround",void 0),e([d()],S.prototype,"hasSlicePlane",void 0);class C extends g{constructor(){super(...arguments),this.externalColor=h(1,1,1,1),this.externalColorMixMode=1,this.emissiveStrength=0,this.emissiveSource=0,this.castShadows=0}get transparent(){return this.externalColor[3]<1?0:2}get opaqueOverride(){return 3===this.externalColorMixMode&&1===this.externalColor[3]?0:2}get emissiveOverride(){return this.emissiveStrength>0?0:2}get emissiveSourceOverride(){return 1===this.emissiveSource?0:2}get visible(){return this.externalColor[3]>0?0:2}get type(){return 0}}e([d({vectorOps:l})],C.prototype,"externalColor",void 0),e([d()],C.prototype,"externalColorMixMode",void 0),e([d()],C.prototype,"emissiveStrength",void 0),e([d()],C.prototype,"emissiveSource",void 0),e([d()],C.prototype,"castShadows",void 0);class O extends g{constructor(){super(...arguments),this.transparent=2,this.opaqueOverride=2,this.emissiveOverride=2,this.emissiveSourceOverride=2,this.castShadows=2}get type(){return 1}}function P(e){return null!=e.overlay?.getTexture(2)}function w(e){return null!=e.overlay?.getTexture(3)}function D(e){return null!=e.overlay?.getTexture(1)}function j(e){return null!=e.overlay?.getTexture(e.overlay?.allSourcesOccluders?1:4)}e([d()],O.prototype,"transparent",void 0),e([d()],O.prototype,"opaqueOverride",void 0),e([d()],O.prototype,"emissiveOverride",void 0),e([d()],O.prototype,"emissiveSourceOverride",void 0),e([d()],O.prototype,"castShadows",void 0);export{S as CommonMaterialParameters,b as ComponentMaterial,C as ComponentParametersUniform,O as ComponentParametersVarying};
5
+ import{__decorate as e}from"tslib";import{invert as t,transpose as r}from"../../../../../../core/libs/gl-matrix-2/math/mat3.js";import{clone as s}from"../../../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{m as o,J as i}from"../../../../../../chunks/vec32.js";import{freeze as a,ZEROS as n}from"../../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{v as l}from"../../../../../../chunks/vec42.js";import{freeze as u,fromValues as h}from"../../../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{ComponentTechnique as p}from"./ComponentTechnique.js";import{ComponentTechniqueConfiguration as c}from"./ComponentTechniqueConfiguration.js";import{parameter as d,parameterBlock as m,MaterialBase as v,MaterialParameterBlock as g}from"../../../core/material/MaterialBase.js";import{isColor as x}from"../../../core/shaderLibrary/ShaderOutput.js";import{TwoVectorPosition as f}from"../../../core/util/TwoVectorPosition.js";import{advancedMRRFactors as y}from"../../../materials/pbrUtils.js";import{defaultHighlightName as M}from"../../../../../support/HighlightDefaults.js";import{alphaCutoff as T}from"../../../../../../webscene/support/AlphaCutoff.js";class b extends v{constructor(e,o,i,n){super(),this.toMapSpace=o,this.useENUForGlobalOverlayUV=i,this.baseColor=u(1,1,1,1),this.usePBR=!1,this.hasParametersFromSource=!1,this.sphereDepthInterpolate=!1,this.mrrFactors=y,this.baseColorTexture=null,this.metallicRoughnessTexture=null,this.normalTexture=null,this.occlusionTexture=null,this.emissionTexture=null,this.emissiveBaseColor=a(0,0,0),this.emissiveStrength=0,this.commonMaterialParameters=new S,this.componentParameters=new C,this.textureBackedBuffer=null,this.objectOpacity=1,this.textureAlphaCutoff=T,this.alphaDiscardMode=1,this.isIntegratedMesh=!1,this.polygonOffsetEnabled=!1,this.ellipsoidMode=1,this.hasOccludees=!1;const l=s(e.rotationScale);t(l,l),r(l,l),this.transformNormalGlobalFromModel=l;const h=new f(e.position);this.transformWorldFromModelTL=h.low,this.transformWorldFromModelTH=h.high,this.transformWorldFromModelRS=e.rotationScale,this._configuration=new c(n),this._updateMaterialConfiguration()}dispose(){this.baseColorTexture=null,this.metallicRoughnessTexture=null,this.emissionTexture=null,this.occlusionTexture=null,this.normalTexture=null}get _hasEmissiveBase(){return null!=this.emissionTexture||!o(this.emissiveBaseColor,n)}get _hasEmissiveStrength(){return 2!==this.componentParameters.emissiveOverride}get hasEmissions(){return this._hasEmissiveStrength&&(this._hasEmissiveBase||2!==this.componentParameters.emissiveSourceOverride)}get texture(){return this.baseColorTexture?.texture}get textureMetallicRoughness(){return this.metallicRoughnessTexture?.texture}get textureEmissive(){return this.emissionTexture?.texture}get textureOcclusion(){return this.occlusionTexture?.texture}get textureNormal(){return this.normalTexture?.texture}update(e){e(this)}acquireTechnique(e,t,r,s){const o=this._updateConfiguration(t,r,s);return e.get(p,o,s.layout)}_updateConfiguration(e,t,r){return this._updateMaterialConfiguration(),this._updateDrawConfiguration(e,t,r)}_updateMaterialConfiguration(){if(!this.dirty)return;const e=this._configuration;e.hasMetallicRoughnessTexture=null!=this.metallicRoughnessTexture,e.hasOcclusionTexture=null!=this.occlusionTexture,e.hasNormalTexture=null!=this.normalTexture,e.sphereDepthInterpolate=this.sphereDepthInterpolate&&e.spherical,e.ellipsoidMode=this.ellipsoidMode,e.componentData=this.componentParameters.type,e.cullFace=this.commonMaterialParameters.cullFace,e.doubleSidedMode=this.commonMaterialParameters.doubleSided?1:0,e.hasColorTexture=null!=this.baseColorTexture,e.alphaDiscardMode=this.alphaDiscardMode,e.hasPolygonOffset=this.polygonOffsetEnabled,this._setClean()}_updateDrawConfiguration(e,t,r){const s=this._configuration,o=e.identifier,i=0===o;s.hasEmission=t.hasEmission&&i,s.renderOccluded=10===t.slot,s.hasVertexColors=r.hasVertexColors,s.hasNormals=r.hasNormals,s.textureCoordinateType=r.textureCoordinateType,s.oitPass=i?t.oitPass:0,s.terrainDepthTest=i&&t.terrainDepthTest,s.cullAboveTerrain=!!i&&t.cullAboveTerrain,s.integratedMeshMode=this.isIntegratedMesh?D(t)?w(t)?3:2:1:0,s.pbrMode=3===s.integratedMeshMode?4:this.usePBR?this.hasParametersFromSource?r.shadeNormals&&this.isIntegratedMesh?0:2:1:0;const a=1===this.componentParameters.emissiveSourceOverride,n=2===this.componentParameters.emissiveSourceOverride,l=null!=this.emissionTexture;s.emissionSource=this.hasEmissions?this._hasEmissiveBase&&1===s.pbrMode?n?l?4:2:a?l?5:7:6:a?7:6:0,s.shadeNormals=r.shadeNormals,s.normalType=s.hasNormals?1:2;const u=null!=t.slicePlane&&this.commonMaterialParameters.hasSlicePlane;s.hasSlicePlane=u,s.isGroundSlice=u&&this.commonMaterialParameters.isGround;const h=this._computeMaterialPass();s.blendingEnabled=1===h||2===h||4===h||s.isGroundSlice,s.hasHighlightMixTexture=2===o&&null!=t.highlightMixTexture,s.output=e.output,s.snowCover=i&&t.snowCover>0,s.vertexDiscardMode=i&&2===h?e.transparent?2:1:0,s.olidColor=i&&9===e.output;const p=i&&x(e.output);return s.receiveAmbientOcclusion=p&&r.applySSAO&&null!=t.ssao?.getTexture(),s.hasOccludees=p&&t.hasOccludees,s.receiveShadows=p&&t.shadowMap.ready,s.screenSpaceReflections=p&&null!=t.ssr.lastFrameColor,s.cloudReflections=p&&null!=t.clouds.data?.cubeMap?.colorTexture,s}submit(e,t,r){if(this.objectOpacity<=0)return;const{componentData:s,renderable:o}=r,{geometry:i}=o,a=o.meta.cameraDepthSquared;s.updateHighlights(t.highlights);const{geometryRanges:n,highlightRangesMap:l,shadowmapRanges:u}=s,h=e=>e.submitDraw(this,i,n,a);switch(this._computeMaterialPass()){case 0:h(e.opaque);break;case 1:h(e.transparent);break;case 2:h(e.opaque),h(e.transparent);break;case 3:h(e.integratedMesh),j(t)&&h(e.occludedGround),P(t)&&h(e.highlightIntegratedMesh);break;case 4:h(e.transparentIntegratedMesh)}if(2!==this.componentParameters.castShadows){if(null!=l)for(const t of l)t[0]===M&&e.highlightShadowMap.submitDraw(this,i,t[1],a,t[0]);null!=u&&e.defaultShadowMap.submitDraw(this,i,u,a),h(e.shadowMap)}if(null!=l)for(const p of l)e.highlight.submitDraw(this,i,p[1],a,p[0]);t.viewshedEnabled&&h(e.viewshedShadowMap)}_computeMaterialPass(){if(this.isIntegratedMesh)return this.objectOpacity<1?4:3;if(this.objectOpacity<1)return this.isIntegratedMesh?4:1;if(0===this.componentParameters.opaqueOverride)return 0;if(this.baseColor[3]<1||0===this.alphaDiscardMode||3===this.alphaDiscardMode)return 1;switch(this.componentParameters.transparent){case 2:return 0;case 0:return 1;case 1:return 2}}}e([d({vectorOps:l})],b.prototype,"baseColor",void 0),e([d()],b.prototype,"usePBR",void 0),e([d()],b.prototype,"hasParametersFromSource",void 0),e([d()],b.prototype,"sphereDepthInterpolate",void 0),e([d({vectorOps:i})],b.prototype,"mrrFactors",void 0),e([d({dispose:!0})],b.prototype,"baseColorTexture",void 0),e([d({dispose:!0})],b.prototype,"metallicRoughnessTexture",void 0),e([d({dispose:!0})],b.prototype,"normalTexture",void 0),e([d({dispose:!0})],b.prototype,"occlusionTexture",void 0),e([d({dispose:!0})],b.prototype,"emissionTexture",void 0),e([d({vectorOps:i})],b.prototype,"emissiveBaseColor",void 0),e([d()],b.prototype,"emissiveStrength",void 0),e([m()],b.prototype,"commonMaterialParameters",void 0),e([m()],b.prototype,"componentParameters",void 0),e([d()],b.prototype,"textureBackedBuffer",void 0),e([d()],b.prototype,"objectOpacity",void 0),e([d()],b.prototype,"textureAlphaCutoff",void 0),e([d()],b.prototype,"alphaDiscardMode",void 0),e([d()],b.prototype,"isIntegratedMesh",void 0),e([d()],b.prototype,"polygonOffsetEnabled",void 0),e([d()],b.prototype,"ellipsoidMode",void 0),e([d()],b.prototype,"hasOccludees",void 0);class S extends g{constructor(){super(...arguments),this.doubleSided=!1,this.cullFace=2,this.isGround=!1,this.hasSlicePlane=!0}}e([d()],S.prototype,"doubleSided",void 0),e([d()],S.prototype,"cullFace",void 0),e([d()],S.prototype,"isGround",void 0),e([d()],S.prototype,"hasSlicePlane",void 0);class C extends g{constructor(){super(...arguments),this.externalColor=h(1,1,1,1),this.externalColorMixMode=1,this.emissiveStrength=0,this.emissiveSource=0,this.castShadows=0}get transparent(){return this.externalColor[3]<1?0:2}get opaqueOverride(){return 3===this.externalColorMixMode&&1===this.externalColor[3]?0:2}get emissiveOverride(){return this.emissiveStrength>0?0:2}get emissiveSourceOverride(){return 1===this.emissiveSource?0:2}get visible(){return this.externalColor[3]>0?0:2}get type(){return 0}}e([d({vectorOps:l})],C.prototype,"externalColor",void 0),e([d()],C.prototype,"externalColorMixMode",void 0),e([d()],C.prototype,"emissiveStrength",void 0),e([d()],C.prototype,"emissiveSource",void 0),e([d()],C.prototype,"castShadows",void 0);class O extends g{constructor(){super(...arguments),this.transparent=2,this.opaqueOverride=2,this.emissiveOverride=2,this.emissiveSourceOverride=2,this.castShadows=2}get type(){return 1}}function P(e){return null!=e.overlay?.getTexture(2)}function w(e){return null!=e.overlay?.getTexture(3)}function D(e){return null!=e.overlay?.getTexture(1)}function j(e){return null!=e.overlay?.getTexture(e.overlay?.allSourcesOccluders?1:4)}e([d()],O.prototype,"transparent",void 0),e([d()],O.prototype,"opaqueOverride",void 0),e([d()],O.prototype,"emissiveOverride",void 0),e([d()],O.prototype,"emissiveSourceOverride",void 0),e([d()],O.prototype,"castShadows",void 0);export{S as CommonMaterialParameters,b as ComponentMaterial,C as ComponentParametersUniform,O as ComponentParametersVarying};
@@ -2,7 +2,7 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{translate as e}from"../../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as s}from"../../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{i,p as a,e as l,h as c}from"../../../../../chunks/vec32.js";import{ZEROS as n,create as o}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{Float3DrawUniform as r}from"../shaderModules/Float3DrawUniform.js";import{Float3PassUniform as t}from"../shaderModules/Float3PassUniform.js";import{glsl as f}from"../shaderModules/glsl.js";import{NoParameters as d}from"../../../../webgl/NoParameters.js";class u extends d{constructor(e){super(),this.slicePlaneLocalOrigin=e}}function p(e,s){w(e,s,new t("slicePlaneOrigin",(e,i)=>g(s,e,i)),new t("slicePlaneBasis1",(e,i)=>F(s,e,i,i.slicePlane?.basis1)),new t("slicePlaneBasis2",(e,i)=>F(s,e,i,i.slicePlane?.basis2)))}function P(e,s){w(e,s,new r("slicePlaneOrigin",(e,i)=>g(s,e,i)),new r("slicePlaneBasis1",(e,i)=>F(s,e,i,i.slicePlane?.basis1)),new r("slicePlaneBasis2",(e,i)=>F(s,e,i,i.slicePlane?.basis2)))}function m(e,s){v(e,s,new r("slicePlaneOrigin",(e,i)=>g(s,e,i)),new r("slicePlaneBasis1",(e,i)=>F(s,e,i,i.slicePlane?.basis1)),new r("slicePlaneBasis2",(e,i)=>F(s,e,i,i.slicePlane?.basis2)))}const b=f`struct SliceFactors {
5
+ import has from"../../../../../core/has.js";import{translate as e}from"../../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as s}from"../../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{i,p as a,e as l,h as c}from"../../../../../chunks/vec32.js";import{ZEROS as n,create as o}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{Float3DrawUniform as r}from"../shaderModules/Float3DrawUniform.js";import{Float3PassUniform as t}from"../shaderModules/Float3PassUniform.js";import{glsl as f}from"../shaderModules/glsl.js";import{NoParameters as d}from"../../../../webgl/NoParameters.js";class u extends d{constructor(e){super(),this.slicePlaneLocalOrigin=e}}function p(e,s){w(e,s,new t("slicePlaneOrigin",(e,i)=>g(s,e,i)),new t("slicePlaneBasis1",(e,i)=>F(s,e,i,i.slicePlane?.basis1)),new t("slicePlaneBasis2",(e,i)=>F(s,e,i,i.slicePlane?.basis2)))}function P(e,s){w(e,s,new r("slicePlaneOrigin",(e,i)=>g(s,e,i)),new r("slicePlaneBasis1",(e,i)=>F(s,e,i,i.slicePlane?.basis1)),new r("slicePlaneBasis2",(e,i)=>F(s,e,i,i.slicePlane?.basis2)))}function m(e,s){v(e,s,new r("slicePlaneOrigin",(e,i)=>g(s,e,i)),new r("slicePlaneBasis1",(e,i)=>F(s,e,i,i.slicePlane?.basis1)),new r("slicePlaneBasis2",(e,i)=>F(s,e,i,i.slicePlane?.basis2)))}const b=f`struct SliceFactors {
6
6
  float front;
7
7
  float side0;
8
8
  float side1;
@@ -37,5 +37,5 @@ return dot(slicePlaneBasis1, slicePlaneBasis1) != 0.0;
37
37
  }
38
38
  bool rejectBySlice(vec3 pos) {
39
39
  return sliceEnabled() && sliceByFactors(calculateSliceFactors(pos));
40
- }`;function v(e,s,...i){s.hasSlicePlane?(e.uniforms.add(...i),e.code.add(b)):e.code.add("bool rejectBySlice(vec3 pos) { return false; }")}function w(e,s,...i){e.constants.add("groundSliceOpacity","float",.2),v(e,s,...i),s.hasSlicePlane?e.code.add("\n void discardBySlice(vec3 pos) {\n if (rejectBySlice(pos)) {\n discard;\n }\n }\n\n vec4 applySliceOutline(vec4 color, vec3 pos) {\n SliceFactors factors = calculateSliceFactors(pos);\n\n factors.front /= 2.0 * fwidth(factors.front);\n factors.side0 /= 2.0 * fwidth(factors.side0);\n factors.side1 /= 2.0 * fwidth(factors.side1);\n factors.side2 /= 2.0 * fwidth(factors.side2);\n factors.side3 /= 2.0 * fwidth(factors.side3);\n\n // return after calling fwidth, to avoid aliasing caused by discontinuities in the input to fwidth\n if (sliceByFactors(factors)) {\n return color;\n }\n\n float outlineFactor = (1.0 - step(0.5, factors.front))\n * (1.0 - step(0.5, factors.side0))\n * (1.0 - step(0.5, factors.side1))\n * (1.0 - step(0.5, factors.side2))\n * (1.0 - step(0.5, factors.side3));\n\n return mix(color, vec4(vec3(0.0), color.a), outlineFactor * 0.3);\n }\n\n vec4 applySlice(vec4 color, vec3 pos) {\n return sliceEnabled() ? applySliceOutline(color, pos) : color;\n }\n "):e.code.add(f`void discardBySlice(vec3 pos) { }
40
+ }`;function v(e,s,...i){s.hasSlicePlane?(e.uniforms.add(...i),e.code.add(b)):e.code.add("bool rejectBySlice(vec3 pos) { return false; }")}function w(e,s,...i){e.constants.add("groundSliceOpacity","float",has("enable-feature:oit-ground")?.25:.2),v(e,s,...i),s.hasSlicePlane?e.code.add("\n void discardBySlice(vec3 pos) {\n if (rejectBySlice(pos)) {\n discard;\n }\n }\n\n vec4 applySliceOutline(vec4 color, vec3 pos) {\n SliceFactors factors = calculateSliceFactors(pos);\n\n factors.front /= 2.0 * fwidth(factors.front);\n factors.side0 /= 2.0 * fwidth(factors.side0);\n factors.side1 /= 2.0 * fwidth(factors.side1);\n factors.side2 /= 2.0 * fwidth(factors.side2);\n factors.side3 /= 2.0 * fwidth(factors.side3);\n\n // return after calling fwidth, to avoid aliasing caused by discontinuities in the input to fwidth\n if (sliceByFactors(factors)) {\n return color;\n }\n\n float outlineFactor = (1.0 - step(0.5, factors.front))\n * (1.0 - step(0.5, factors.side0))\n * (1.0 - step(0.5, factors.side1))\n * (1.0 - step(0.5, factors.side2))\n * (1.0 - step(0.5, factors.side3));\n\n return mix(color, vec4(vec3(0.0), color.a), outlineFactor * 0.3);\n }\n\n vec4 applySlice(vec4 color, vec3 pos) {\n return sliceEnabled() ? applySliceOutline(color, pos) : color;\n }\n "):e.code.add(f`void discardBySlice(vec3 pos) { }
41
41
  vec4 applySlice(vec4 color, vec3 pos) { return color; }`)}function B(e,s,i){return e.instancedDoublePrecision?c(y,i.camera.viewInverseTransposeMatrix[3],i.camera.viewInverseTransposeMatrix[7],i.camera.viewInverseTransposeMatrix[11]):s.slicePlaneLocalOrigin}function S(e,s){return null!=e?l(j,s.origin,e):s.origin}function h(s,i,a){return s.hasSliceTranslatedView?null!=i?e(O,a.camera.viewMatrix,i):a.camera.viewMatrix:null}function g(e,s,i){if(null==i.slicePlane)return n;const l=B(e,s,i),c=S(l,i.slicePlane),o=h(e,l,i);return null!=o?a(j,c,o):c}function F(e,s,c,o){if(null==o||null==c.slicePlane)return n;const r=B(e,s,c),t=S(r,c.slicePlane),f=h(e,r,c);return null!=f?(i(x,o,t),a(j,t,f),a(x,x,f),l(x,x,j)):o}const y=o(),j=o(),x=o(),O=s();export{m as RejectBySlice,P as SliceDraw,p as SlicePass,u as SlicePlaneParameters};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import{watch as t}from"../../../../core/reactiveUtils.js";import{property as s,subclass as i}from"../../../../core/accessorSupport/decorators.js";import{set as a}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{e as r,b as n,j as o,q as l,g as h,F as u,d as c,J as p}from"../../../../chunks/vec32.js";import{create as d,clone as m}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{c as _}from"../../../../chunks/vec42.js";import{create as f}from"../../../../geometry/support/plane.js";import{fromPoints as g}from"../../../../geometry/support/ray.js";import{Sphere as b}from"../../../../geometry/support/sphere.js";import{RenderCategory as P}from"../../webgl.js";import{GaussianSplatTarget as C}from"../../layers/i3s/Intersector.js";import{GaussianSplatDataStore as S}from"../../support/gaussianSplatting/GaussianSplatDataStore.js";import w from"../../webgl/RenderNode.js";import{IntersectorResult as x}from"./IntersectorResult.js";import{G as v}from"../../../../chunks/GaussianSplat.glsl.js";import{GaussianSplatColorTechnique as y}from"../shaders/GaussianSplatColorTechnique.js";import{G as D}from"../../../../chunks/GaussianSplatComposition.glsl.js";import{GaussianSplatCompositionTechnique as q}from"../shaders/GaussianSplatCompositionTechnique.js";import{G as T}from"../../../../chunks/GaussianSplatDepthComposition.glsl.js";import{GaussianSplatDepthCompositionTechnique as A}from"../shaders/GaussianSplatDepthCompositionTechnique.js";import{GaussianSplatDepthTechnique as E}from"../shaders/GaussianSplatDepthTechnique.js";import{GaussianSplatTechnique as G}from"../shaders/GaussianSplatTechnique.js";import{GaussianSplatTechniqueConfiguration as O}from"../shaders/GaussianSplatTechniqueConfiguration.js";import{DepthStencilAttachment as j,ColorAttachment1 as F,PrimitiveType as N}from"../../../webgl/enums.js";var I;let H=class extends w{static{I=this}constructor(e){super(e),this.gaussianPosition=d(),this.intersectionRayDir=d(),this.intersectionPlane=f(),this._slicePlaneEnabled=!1,this._data=null,this.produces=P.OPAQUE,this.type=0,this.isGround=!1,this.layerViewUid="",this._passParameters=new v,this._compositionPassParameters=new D,this._depthCompositionPassParameters=new T,this._previousCameraPosition=d(),this._previousCameraDirection=d(),this.fadeHelper=null,this._configuration=new O(e.view.state.isGlobal),this._colorOnlyConfiguration=new O(e.view.state.isGlobal,!0),this._depthOnlyConfiguration=new O(e.view.state.isGlobal,!1,!0)}async initialize(){this._data=new S(this),this.view.sceneIntersectionHelper.addIntersectionHandler(this),this.addHandles([t(()=>this.view.state.camera,()=>this._onCameraChange())])}precompile(){const e=this.view.qualitySettings.gaussianSplat.minimumOpacity,t=this.bindParameters.terrainDepthTest,s=this.fadeHelper.fadingEnabled,i=s=>{s.alphaCutoff=e,s.terrainDepthTest=t};this.renderingContext.capabilities.drawBuffersIndexed?(i(this._configuration),this._configuration.fadingEnabled=s,this.techniques.precompile(G,this._configuration)):(i(this._colorOnlyConfiguration),this._colorOnlyConfiguration.fadingEnabled=s,this.techniques.precompile(y,this._colorOnlyConfiguration),i(this._depthOnlyConfiguration),this.techniques.precompile(E,this._depthOnlyConfiguration)),this.techniques.precompile(q),this.techniques.precompile(A)}render(e){const t=e.find(({name:e})=>e===P.OPAQUE);if(this._handleFading(),!this._data.visibleGaussians||!this._data.orderTexture.texture||!this._data.textureAtlas.texture)return t;const s=!!this.renderingContext.capabilities.drawBuffersIndexed,i=s?this.techniques.get(G,this._configuration):null,a=s?null:this.techniques.get(y,this._colorOnlyConfiguration),r=s?null:this.techniques.get(E,this._depthOnlyConfiguration),n=this.techniques.get(q),o=this.techniques.get(A);if(!(i?.compiled||a?.compiled&&r?.compiled)||!o.compiled||!n.compiled)return this.requestRender(1),t;const{fullWidth:l,fullHeight:h}=this.bindParameters.camera;this._prepareParameters(h,l);const u=this.renderingContext,c=this.fboCache,p=c.acquire(l,h,"gaussian color output"),d=t.getAttachment(j);p.attachDepth(d);let m=null;s?this._singlePass(p,i):m=this._multiPass(p,d,a,r);const _=c.acquire(l,h,this.produces);return this._depthCompositionPassParameters.splatDepth=m?m.getTexture():p.getTexture(F),_.attachDepth(t.getAttachment(j)),u.bindFramebuffer(_.fbo),u.bindTechnique(o,this.bindParameters,this._depthCompositionPassParameters),u.screen.draw(),this._compositionPassParameters.color=t.getTexture(),this._compositionPassParameters.splatColor=p.getTexture(),u.bindFramebuffer(_.fbo),u.bindTechnique(n,this.bindParameters,this._compositionPassParameters),u.screen.draw(),p.release(),m?.release(),_}intersect(e,t,s,i){const{gaussianPosition:a,intersectionRayDir:c,intersectionPlane:p,layerViewUid:f}=this,P=g(s,i);r(c,i,s);const S=1/n(c);o(c,c,S);const w=d();l(w,c),_(p,c[0],c[1],c[2],-h(c,s));const v=new U,y=new U,D=new Array;this._data.visibleGaussianTiles.forEach(r=>{const{maxScale:n}=r,o=r.obb.minimumDistancePlane(p),l=r.obb.maximumDistancePlane(p),d=l<0,_=null!=v.dist&&null!=y.dist&&v.dist<o*S&&y.dist>l*S;if(d||_)return;if(!new b(r.obb.center,r.obb.radius+n).intersectRay(P,null))return;if(!r.obb.intersectRay(s,c,n))return;const{positions:g,squaredScales:C,gaussianAtlasIndices:x}=r,q=x.length;for(let p=0;p<q;p++){const r=3*p;a[0]=g[r]-s[0],a[1]=g[r+1]-s[1],a[2]=g[r+2]-s[2];const n=C[p],o=h(a,c),l=o*o;if(u(a)-l>n)continue;const d=o*S,_=e=>(e.point=e.point?e.point.fill(a[0],a[1],a[2]):m(a),e.dist=d,e.normal=w,e.layerViewUid=f,e);if((null==v.dist||d<v.dist)&&(null==t||t(s,i,d))&&_(v),0!==e.options.store&&(null==y.dist||d>y.dist)&&(null==t||t(s,i,d))&&_(y),2===e.options.store&&(null==t||t(s,i,d))){const e=new U;D.push(_(e))}}});const q=(e,t)=>{const{layerViewUid:s}=t,i=new C(t.point,s);e.set(0,i,t.dist,t.normal)};if(R(v)){const t=e.results.min;(null==t.distance||v.dist<t.distance)&&q(t,v)}if(R(y)&&0!==e.options.store){const t=e.results.max;(null==t.distance||y.dist>t.distance)&&q(t,y)}if(2===e.options.store)for(const r of D){const t=new x(P);q(t,r),e.results.all.push(t)}}get slicePlaneEnabled(){return this._slicePlaneEnabled}set slicePlaneEnabled(e){this._slicePlaneEnabled!==e&&(this._slicePlaneEnabled=e,this.requestRender(1))}get data(){return this._data}destroy(){this._data.destroy(),super.destroy()}_onCameraChange(){const e=this.view.state.camera.eye,t=this.view.state.camera.ray.direction,s=.001;(Math.abs(e[0]-this._previousCameraPosition[0])>s||Math.abs(e[1]-this._previousCameraPosition[1])>s||Math.abs(e[2]-this._previousCameraPosition[2])>s||Math.abs(t[0]-this._previousCameraDirection[0])>s||Math.abs(t[1]-this._previousCameraDirection[1])>s||Math.abs(t[2]-this._previousCameraDirection[2])>s)&&(c(this._previousCameraPosition,e),c(this._previousCameraDirection,t),this._data.requestSort())}_prepareParameters(e,t){this._passParameters.totalGaussians=this._data.visibleGaussians,this._passParameters.splatOrder=this._data.orderTexture.texture,this._passParameters.splatFading=this._data.fadingTexture.texture,this._passParameters.splatAtlas=this._data.textureAtlas.texture;const s=Math.tan(.5*this.camera.fovY),i=s/e*t;a(this._passParameters.tanFov,i,s),this._passParameters.focalLength=e/(2*s);const r=this.view.qualitySettings.gaussianSplat.minimumSplatPixelRadius;this._passParameters.minSplatRadius=r*Math.sqrt(t*e)/Math.sqrt(2073600),this._prepareHighPrecisionCameraPosition()}_singlePass(e,t){const s=this.renderingContext,i=this.renderingContext.gl,a=this.renderingContext.capabilities.drawBuffersIndexed;e.acquireColor(F,8,"gaussian depth output"),s.bindFramebuffer(e.fbo),s.setClearColor(0,0,0,0),s.clear(16384),this.renderingContext.bindTechnique(t,this.bindParameters,this._passParameters),a.enableiOES(i.BLEND,0),a.blendEquationSeparateiOES(0,i.FUNC_ADD,i.FUNC_ADD),a.blendFuncSeparateiOES(0,i.ONE_MINUS_DST_ALPHA,i.ONE,i.ONE_MINUS_DST_ALPHA,i.ONE),a.enableiOES(i.BLEND,1),a.blendEquationSeparateiOES(1,i.FUNC_ADD,i.FUNC_ADD),a.blendFuncSeparateiOES(1,i.ONE_MINUS_DST_ALPHA,i.DST_ALPHA,i.ONE_MINUS_DST_ALPHA,i.ONE),this.renderingContext.drawArraysInstanced(N.TRIANGLE_STRIP,0,4,this._data.visibleGaussians)}_multiPass(e,t,s,i){const{fullWidth:a,fullHeight:r}=this.bindParameters.camera,n=this.renderingContext;n.bindFramebuffer(e.fbo),n.setClearColor(0,0,0,0),n.clear(16384),this.renderingContext.bindTechnique(s,this.bindParameters,this._passParameters),this.renderingContext.drawArraysInstanced(N.TRIANGLE_STRIP,0,4,this._data.visibleGaussians);const o=this.fboCache.acquire(a,r,"gaussian depth output",8);return o.attachDepth(t),n.bindFramebuffer(o.fbo),n.setClearColor(0,0,0,0),n.clear(16384),this.renderingContext.bindTechnique(i,this.bindParameters,this._passParameters),this.renderingContext.drawArraysInstanced(N.TRIANGLE_STRIP,0,4,this._data.visibleGaussians),o}_prepareHighPrecisionCameraPosition(){o(this._passParameters.tileCameraPosition,this.camera.eye,1/I.tileSize),p(this._passParameters.tileCameraPosition,this._passParameters.tileCameraPosition),o(this._passParameters.cameraDelta,this._passParameters.tileCameraPosition,I.tileSize),r(this._passParameters.cameraDelta,this.camera.eye,this._passParameters.cameraDelta)}_handleFading(){if(0===this.fadeHelper.numFadingTiles)return void(this._previousFrameStart=null);this._previousFrameStart??=this.view.stage.renderer.renderContext.time;const e=this.view.stage?.renderer.renderContext.time-this._previousFrameStart;this.fadeHelper.updateAllTileFading(e),this._previousFrameStart=this.view.stage.renderer.renderContext.time,this._data.fadingTexture.updateTexture(this._data.textureAtlas.pageAllocator.pageCount)}static{this.tileSize=2.048}};function R(e){return null!=e.dist&&null!=e.point}e([s({constructOnly:!0})],H.prototype,"fadeHelper",void 0),H=I=e([i("esri.views.3d.webgl-engine.lib.GaussianSplatRenderNode")],H);class U{constructor(){this.point=null,this.dist=null,this.normal=null,this.layerViewUid=""}}export{H as GaussianSplatRenderNode};
5
+ import{__decorate as e}from"tslib";import{watch as t}from"../../../../core/reactiveUtils.js";import{property as s,subclass as i}from"../../../../core/accessorSupport/decorators.js";import{set as a}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{e as r,b as n,j as o,q as l,g as h,F as u,d as c,K as p}from"../../../../chunks/vec32.js";import{create as d,clone as m}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{c as _}from"../../../../chunks/vec42.js";import{create as f}from"../../../../geometry/support/plane.js";import{fromPoints as g}from"../../../../geometry/support/ray.js";import{Sphere as b}from"../../../../geometry/support/sphere.js";import{RenderCategory as P}from"../../webgl.js";import{GaussianSplatTarget as C}from"../../layers/i3s/Intersector.js";import{GaussianSplatDataStore as S}from"../../support/gaussianSplatting/GaussianSplatDataStore.js";import w from"../../webgl/RenderNode.js";import{IntersectorResult as x}from"./IntersectorResult.js";import{G as v}from"../../../../chunks/GaussianSplat.glsl.js";import{GaussianSplatColorTechnique as y}from"../shaders/GaussianSplatColorTechnique.js";import{G as D}from"../../../../chunks/GaussianSplatComposition.glsl.js";import{GaussianSplatCompositionTechnique as q}from"../shaders/GaussianSplatCompositionTechnique.js";import{G as T}from"../../../../chunks/GaussianSplatDepthComposition.glsl.js";import{GaussianSplatDepthCompositionTechnique as A}from"../shaders/GaussianSplatDepthCompositionTechnique.js";import{GaussianSplatDepthTechnique as E}from"../shaders/GaussianSplatDepthTechnique.js";import{GaussianSplatTechnique as G}from"../shaders/GaussianSplatTechnique.js";import{GaussianSplatTechniqueConfiguration as O}from"../shaders/GaussianSplatTechniqueConfiguration.js";import{DepthStencilAttachment as j,ColorAttachment1 as F,PrimitiveType as N}from"../../../webgl/enums.js";var I;let H=class extends w{static{I=this}constructor(e){super(e),this.gaussianPosition=d(),this.intersectionRayDir=d(),this.intersectionPlane=f(),this._slicePlaneEnabled=!1,this._data=null,this.produces=P.OPAQUE,this.type=0,this.isGround=!1,this.layerViewUid="",this._passParameters=new v,this._compositionPassParameters=new D,this._depthCompositionPassParameters=new T,this._previousCameraPosition=d(),this._previousCameraDirection=d(),this.fadeHelper=null,this._configuration=new O(e.view.state.isGlobal),this._colorOnlyConfiguration=new O(e.view.state.isGlobal,!0),this._depthOnlyConfiguration=new O(e.view.state.isGlobal,!1,!0)}async initialize(){this._data=new S(this),this.view.sceneIntersectionHelper.addIntersectionHandler(this),this.addHandles([t(()=>this.view.state.camera,()=>this._onCameraChange())])}precompile(){const e=this.view.qualitySettings.gaussianSplat.minimumOpacity,t=this.bindParameters.terrainDepthTest,s=this.fadeHelper.fadingEnabled,i=s=>{s.alphaCutoff=e,s.terrainDepthTest=t};this.renderingContext.capabilities.drawBuffersIndexed?(i(this._configuration),this._configuration.fadingEnabled=s,this.techniques.precompile(G,this._configuration)):(i(this._colorOnlyConfiguration),this._colorOnlyConfiguration.fadingEnabled=s,this.techniques.precompile(y,this._colorOnlyConfiguration),i(this._depthOnlyConfiguration),this.techniques.precompile(E,this._depthOnlyConfiguration)),this.techniques.precompile(q),this.techniques.precompile(A)}render(e){const t=e.find(({name:e})=>e===P.OPAQUE);if(this._handleFading(),!this._data.visibleGaussians||!this._data.orderTexture.texture||!this._data.textureAtlas.texture)return t;const s=!!this.renderingContext.capabilities.drawBuffersIndexed,i=s?this.techniques.get(G,this._configuration):null,a=s?null:this.techniques.get(y,this._colorOnlyConfiguration),r=s?null:this.techniques.get(E,this._depthOnlyConfiguration),n=this.techniques.get(q),o=this.techniques.get(A);if(!(i?.compiled||a?.compiled&&r?.compiled)||!o.compiled||!n.compiled)return this.requestRender(1),t;const{fullWidth:l,fullHeight:h}=this.bindParameters.camera;this._prepareParameters(h,l);const u=this.renderingContext,c=this.fboCache,p=c.acquire(l,h,"gaussian color output"),d=t.getAttachment(j);p.attachDepth(d);let m=null;s?this._singlePass(p,i):m=this._multiPass(p,d,a,r);const _=c.acquire(l,h,this.produces);return this._depthCompositionPassParameters.splatDepth=m?m.getTexture():p.getTexture(F),_.attachDepth(t.getAttachment(j)),u.bindFramebuffer(_.fbo),u.bindTechnique(o,this.bindParameters,this._depthCompositionPassParameters),u.screen.draw(),this._compositionPassParameters.color=t.getTexture(),this._compositionPassParameters.splatColor=p.getTexture(),u.bindFramebuffer(_.fbo),u.bindTechnique(n,this.bindParameters,this._compositionPassParameters),u.screen.draw(),p.release(),m?.release(),_}intersect(e,t,s,i){const{gaussianPosition:a,intersectionRayDir:c,intersectionPlane:p,layerViewUid:f}=this,P=g(s,i);r(c,i,s);const S=1/n(c);o(c,c,S);const w=d();l(w,c),_(p,c[0],c[1],c[2],-h(c,s));const v=new U,y=new U,D=new Array;this._data.visibleGaussianTiles.forEach(r=>{const{maxScale:n}=r,o=r.obb.minimumDistancePlane(p),l=r.obb.maximumDistancePlane(p),d=l<0,_=null!=v.dist&&null!=y.dist&&v.dist<o*S&&y.dist>l*S;if(d||_)return;if(!new b(r.obb.center,r.obb.radius+n).intersectRay(P,null))return;if(!r.obb.intersectRay(s,c,n))return;const{positions:g,squaredScales:C,gaussianAtlasIndices:x}=r,q=x.length;for(let p=0;p<q;p++){const r=3*p;a[0]=g[r]-s[0],a[1]=g[r+1]-s[1],a[2]=g[r+2]-s[2];const n=C[p],o=h(a,c),l=o*o;if(u(a)-l>n)continue;const d=o*S,_=e=>(e.point=e.point?e.point.fill(a[0],a[1],a[2]):m(a),e.dist=d,e.normal=w,e.layerViewUid=f,e);if((null==v.dist||d<v.dist)&&(null==t||t(s,i,d))&&_(v),0!==e.options.store&&(null==y.dist||d>y.dist)&&(null==t||t(s,i,d))&&_(y),2===e.options.store&&(null==t||t(s,i,d))){const e=new U;D.push(_(e))}}});const q=(e,t)=>{const{layerViewUid:s}=t,i=new C(t.point,s);e.set(0,i,t.dist,t.normal)};if(R(v)){const t=e.results.min;(null==t.distance||v.dist<t.distance)&&q(t,v)}if(R(y)&&0!==e.options.store){const t=e.results.max;(null==t.distance||y.dist>t.distance)&&q(t,y)}if(2===e.options.store)for(const r of D){const t=new x(P);q(t,r),e.results.all.push(t)}}get slicePlaneEnabled(){return this._slicePlaneEnabled}set slicePlaneEnabled(e){this._slicePlaneEnabled!==e&&(this._slicePlaneEnabled=e,this.requestRender(1))}get data(){return this._data}destroy(){this._data.destroy(),super.destroy()}_onCameraChange(){const e=this.view.state.camera.eye,t=this.view.state.camera.ray.direction,s=.001;(Math.abs(e[0]-this._previousCameraPosition[0])>s||Math.abs(e[1]-this._previousCameraPosition[1])>s||Math.abs(e[2]-this._previousCameraPosition[2])>s||Math.abs(t[0]-this._previousCameraDirection[0])>s||Math.abs(t[1]-this._previousCameraDirection[1])>s||Math.abs(t[2]-this._previousCameraDirection[2])>s)&&(c(this._previousCameraPosition,e),c(this._previousCameraDirection,t),this._data.requestSort())}_prepareParameters(e,t){this._passParameters.totalGaussians=this._data.visibleGaussians,this._passParameters.splatOrder=this._data.orderTexture.texture,this._passParameters.splatFading=this._data.fadingTexture.texture,this._passParameters.splatAtlas=this._data.textureAtlas.texture;const s=Math.tan(.5*this.camera.fovY),i=s/e*t;a(this._passParameters.tanFov,i,s),this._passParameters.focalLength=e/(2*s);const r=this.view.qualitySettings.gaussianSplat.minimumSplatPixelRadius;this._passParameters.minSplatRadius=r*Math.sqrt(t*e)/Math.sqrt(2073600),this._prepareHighPrecisionCameraPosition()}_singlePass(e,t){const s=this.renderingContext,i=this.renderingContext.gl,a=this.renderingContext.capabilities.drawBuffersIndexed;e.acquireColor(F,8,"gaussian depth output"),s.bindFramebuffer(e.fbo),s.setClearColor(0,0,0,0),s.clear(16384),this.renderingContext.bindTechnique(t,this.bindParameters,this._passParameters),a.enableiOES(i.BLEND,0),a.blendEquationSeparateiOES(0,i.FUNC_ADD,i.FUNC_ADD),a.blendFuncSeparateiOES(0,i.ONE_MINUS_DST_ALPHA,i.ONE,i.ONE_MINUS_DST_ALPHA,i.ONE),a.enableiOES(i.BLEND,1),a.blendEquationSeparateiOES(1,i.FUNC_ADD,i.FUNC_ADD),a.blendFuncSeparateiOES(1,i.ONE_MINUS_DST_ALPHA,i.DST_ALPHA,i.ONE_MINUS_DST_ALPHA,i.ONE),this.renderingContext.drawArraysInstanced(N.TRIANGLE_STRIP,0,4,this._data.visibleGaussians)}_multiPass(e,t,s,i){const{fullWidth:a,fullHeight:r}=this.bindParameters.camera,n=this.renderingContext;n.bindFramebuffer(e.fbo),n.setClearColor(0,0,0,0),n.clear(16384),this.renderingContext.bindTechnique(s,this.bindParameters,this._passParameters),this.renderingContext.drawArraysInstanced(N.TRIANGLE_STRIP,0,4,this._data.visibleGaussians);const o=this.fboCache.acquire(a,r,"gaussian depth output",8);return o.attachDepth(t),n.bindFramebuffer(o.fbo),n.setClearColor(0,0,0,0),n.clear(16384),this.renderingContext.bindTechnique(i,this.bindParameters,this._passParameters),this.renderingContext.drawArraysInstanced(N.TRIANGLE_STRIP,0,4,this._data.visibleGaussians),o}_prepareHighPrecisionCameraPosition(){o(this._passParameters.tileCameraPosition,this.camera.eye,1/I.tileSize),p(this._passParameters.tileCameraPosition,this._passParameters.tileCameraPosition),o(this._passParameters.cameraDelta,this._passParameters.tileCameraPosition,I.tileSize),r(this._passParameters.cameraDelta,this.camera.eye,this._passParameters.cameraDelta)}_handleFading(){if(0===this.fadeHelper.numFadingTiles)return void(this._previousFrameStart=null);this._previousFrameStart??=this.view.stage.renderer.renderContext.time;const e=this.view.stage?.renderer.renderContext.time-this._previousFrameStart;this.fadeHelper.updateAllTileFading(e),this._previousFrameStart=this.view.stage.renderer.renderContext.time,this._data.fadingTexture.updateTexture(this._data.textureAtlas.pageAllocator.pageCount)}static{this.tileSize=2.048}};function R(e){return null!=e.dist&&null!=e.point}e([s({constructOnly:!0})],H.prototype,"fadeHelper",void 0),H=I=e([i("esri.views.3d.webgl-engine.lib.GaussianSplatRenderNode")],H);class U{constructor(){this.point=null,this.dist=null,this.normal=null,this.layerViewUid=""}}export{H as GaussianSplatRenderNode};