@arcgis/core 4.31.0-next.20240821 → 4.31.0-next.20240823

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 (376) hide show
  1. package/assets/esri/core/workers/RemoteClient.js +1 -1
  2. package/assets/esri/core/workers/chunks/{24e38b7d1e9984a1472e.js → 033032715c3b04e0fc7d.js} +1 -1
  3. package/assets/esri/core/workers/chunks/{cfc93bbd35cc4bfde7c0.js → 045336db17aae6eef68f.js} +1 -1
  4. package/assets/esri/core/workers/chunks/04de7b2937d5ca7c23e2.js +1 -0
  5. package/assets/esri/core/workers/chunks/12a4b3706162872c2b41.js +769 -0
  6. package/assets/esri/core/workers/chunks/142b1336533fa2ac470b.js +47 -0
  7. package/assets/esri/core/workers/chunks/185e596f86767c22f951.js +1 -0
  8. package/assets/esri/core/workers/chunks/{cd8d595d577b74817623.js → 1a4b3820136fb615b730.js} +1 -1
  9. package/assets/esri/core/workers/chunks/29b157b41dfa16da886b.js +1 -0
  10. package/assets/esri/core/workers/chunks/300b57846114fedd12be.js +1 -0
  11. package/assets/esri/core/workers/chunks/{3f75b7ed24b440b4508a.js → 3d5f37c2f355260e6dc6.js} +1 -1
  12. package/assets/esri/core/workers/chunks/{a9eba26d62b62592cee1.js → 42861d54a336146753d8.js} +1 -1
  13. package/assets/esri/core/workers/chunks/4c8deac4bf72a5e2597a.js +1 -0
  14. package/assets/esri/core/workers/chunks/52107d450c55450f5c04.js +274 -0
  15. package/assets/esri/core/workers/chunks/6d54222301b6d819c904.js +1 -0
  16. package/assets/esri/core/workers/chunks/{eb0f180ed20af220a82e.js → 6ddece9cd94b60efe3d7.js} +1 -1
  17. package/assets/esri/core/workers/chunks/{566844774388a031fd74.js → 7125cff7fd288ff7bd5f.js} +1 -1
  18. package/assets/esri/core/workers/chunks/74de734a20b4cd2d7efb.js +1 -0
  19. package/assets/esri/core/workers/chunks/7712a23dc68220edaa64.js +1 -0
  20. package/assets/esri/core/workers/chunks/{ea561b2460e634a643fc.js → 7f35380809e7de99c302.js} +1 -1
  21. package/assets/esri/core/workers/chunks/7f3d49b667e9b46449e7.js +1 -0
  22. package/assets/esri/core/workers/chunks/8a2faf12938e811a9fc9.js +1 -0
  23. package/assets/esri/core/workers/chunks/{796c64b9caa1303e26ed.js → 8af503fa88c1668872eb.js} +1 -1
  24. package/assets/esri/core/workers/chunks/{e2a6f77c05d0818e3f74.js → 8e42ce8305cefba5debc.js} +1 -1
  25. package/assets/esri/core/workers/chunks/93169e55e472fec4bc50.js +1 -0
  26. package/assets/esri/core/workers/chunks/985c1f42aab564008c0d.js +1 -0
  27. package/assets/esri/core/workers/chunks/9a32d9d720cb81abfba2.js +1 -0
  28. package/assets/esri/core/workers/chunks/b171d57b4d0142f687d0.js +1 -0
  29. package/assets/esri/core/workers/chunks/d5e376893cd47605a438.js +1 -0
  30. package/assets/esri/core/workers/chunks/df9daac7ea581e9e5ca4.js +1 -0
  31. package/assets/esri/core/workers/chunks/f11ae249cc8e995bbccc.js +1 -0
  32. package/assets/esri/core/workers/chunks/{65d8011cf756b066cade.js → f218316de8b4635653b2.js} +1 -1
  33. package/assets/esri/libs/linkchartlayout/lclayout.wasm +0 -0
  34. package/assets/esri/libs/vxl/vxlLayer.wasm +0 -0
  35. package/assets/esri/themes/base/_core.scss +2 -0
  36. package/assets/esri/themes/base/widgets/_Grid.scss +0 -8
  37. package/assets/esri/themes/base/widgets/_GridControls.scss +86 -0
  38. package/assets/esri/themes/base/widgets/_Print.scss +13 -15
  39. package/assets/esri/themes/dark/main.css +1 -1
  40. package/assets/esri/themes/light/main.css +1 -1
  41. package/assets/esri/themes/light/view.css +1 -1
  42. package/assets/esri/widgets/Print/t9n/Print.json +1 -1
  43. package/assets/esri/widgets/Print/t9n/Print_ar.json +1 -1
  44. package/assets/esri/widgets/Print/t9n/Print_bg.json +1 -1
  45. package/assets/esri/widgets/Print/t9n/Print_bs.json +1 -1
  46. package/assets/esri/widgets/Print/t9n/Print_ca.json +1 -1
  47. package/assets/esri/widgets/Print/t9n/Print_cs.json +1 -1
  48. package/assets/esri/widgets/Print/t9n/Print_da.json +1 -1
  49. package/assets/esri/widgets/Print/t9n/Print_de.json +1 -1
  50. package/assets/esri/widgets/Print/t9n/Print_el.json +1 -1
  51. package/assets/esri/widgets/Print/t9n/Print_en.json +1 -1
  52. package/assets/esri/widgets/Print/t9n/Print_es.json +1 -1
  53. package/assets/esri/widgets/Print/t9n/Print_et.json +1 -1
  54. package/assets/esri/widgets/Print/t9n/Print_fi.json +1 -1
  55. package/assets/esri/widgets/Print/t9n/Print_fr.json +1 -1
  56. package/assets/esri/widgets/Print/t9n/Print_he.json +1 -1
  57. package/assets/esri/widgets/Print/t9n/Print_hr.json +1 -1
  58. package/assets/esri/widgets/Print/t9n/Print_hu.json +1 -1
  59. package/assets/esri/widgets/Print/t9n/Print_id.json +1 -1
  60. package/assets/esri/widgets/Print/t9n/Print_it.json +1 -1
  61. package/assets/esri/widgets/Print/t9n/Print_ja.json +1 -1
  62. package/assets/esri/widgets/Print/t9n/Print_ko.json +1 -1
  63. package/assets/esri/widgets/Print/t9n/Print_lt.json +1 -1
  64. package/assets/esri/widgets/Print/t9n/Print_lv.json +1 -1
  65. package/assets/esri/widgets/Print/t9n/Print_nb.json +1 -1
  66. package/assets/esri/widgets/Print/t9n/Print_nl.json +1 -1
  67. package/assets/esri/widgets/Print/t9n/Print_pl.json +1 -1
  68. package/assets/esri/widgets/Print/t9n/Print_pt-BR.json +1 -1
  69. package/assets/esri/widgets/Print/t9n/Print_pt-PT.json +1 -1
  70. package/assets/esri/widgets/Print/t9n/Print_ro.json +1 -1
  71. package/assets/esri/widgets/Print/t9n/Print_ru.json +1 -1
  72. package/assets/esri/widgets/Print/t9n/Print_sk.json +1 -1
  73. package/assets/esri/widgets/Print/t9n/Print_sl.json +1 -1
  74. package/assets/esri/widgets/Print/t9n/Print_sr.json +1 -1
  75. package/assets/esri/widgets/Print/t9n/Print_sv.json +1 -1
  76. package/assets/esri/widgets/Print/t9n/Print_th.json +1 -1
  77. package/assets/esri/widgets/Print/t9n/Print_tr.json +1 -1
  78. package/assets/esri/widgets/Print/t9n/Print_uk.json +1 -1
  79. package/assets/esri/widgets/Print/t9n/Print_vi.json +1 -1
  80. package/assets/esri/widgets/Print/t9n/Print_zh-CN.json +1 -1
  81. package/assets/esri/widgets/Print/t9n/Print_zh-HK.json +1 -1
  82. package/assets/esri/widgets/Print/t9n/Print_zh-TW.json +1 -1
  83. package/assets/esri/widgets/support/GridControls/t9n/GridControls.json +1 -0
  84. package/assets/esri/widgets/support/GridControls/t9n/GridControls_en.json +1 -0
  85. package/chunks/CloudsComposition.glsl.js +3 -3
  86. package/chunks/ComponentShader.glsl.js +53 -61
  87. package/chunks/DefaultMaterial.glsl.js +1 -1
  88. package/chunks/FocusAreaColor.glsl.js +12 -0
  89. package/chunks/FocusAreaMask.glsl.js +5 -0
  90. package/chunks/Laserlines.glsl.js +1 -1
  91. package/chunks/Path.glsl.js +22 -17
  92. package/chunks/PointRenderer.glsl.js +3 -3
  93. package/chunks/Precipitation.glsl.js +1 -1
  94. package/chunks/Terrain.glsl.js +1 -1
  95. package/chunks/WaterSurface.glsl.js +18 -18
  96. package/chunks/boundedPlane.js +1 -1
  97. package/chunks/cameraUtilsPlanar.js +1 -1
  98. package/chunks/cameraUtilsSpherical.js +1 -1
  99. package/chunks/sphere.js +1 -1
  100. package/chunks/terrainUtilsPlanar.js +1 -1
  101. package/chunks/vec32.js +1 -1
  102. package/chunks/vxlLayer.js +1 -1
  103. package/core/libs/gl-matrix-2/math/quat.js +1 -1
  104. package/core/libs/gl-matrix-2/math/vec3.js +1 -1
  105. package/core/mathUtils.js +1 -1
  106. package/core/perspectiveUtils.js +1 -1
  107. package/exports/csv.js +1 -1
  108. package/geometry/operators/support/converterAPI.js +1 -1
  109. package/geometry/projection/localLinearScaleFactors.js +1 -1
  110. package/geometry/support/buffer/internals/Vec3.js +1 -1
  111. package/geometry/support/clipRay.js +1 -1
  112. package/geometry/support/coordinateSystem.js +1 -1
  113. package/geometry/support/frustum.js +1 -1
  114. package/geometry/support/heightModelInfoUtils.js +1 -1
  115. package/geometry/support/lineSegment.js +1 -1
  116. package/geometry/support/meshUtils/exporters/gltf/geometry.js +1 -1
  117. package/geometry/support/meshUtils/rotate.js +1 -1
  118. package/geometry/support/meshUtils/scale.js +1 -1
  119. package/geometry/support/plane.js +1 -1
  120. package/geometry/support/polygonUtils.js +1 -1
  121. package/geometry/support/ray.js +1 -1
  122. package/geometry/support/sphere.js +1 -1
  123. package/geometry/support/sphereUtils.js +5 -0
  124. package/geometry/support/triangle.js +1 -1
  125. package/geometry/support/vector.js +1 -1
  126. package/interfaces.d.ts +68 -9
  127. package/layers/FocusAreaLayer.js +5 -0
  128. package/layers/VoxelLayer.js +1 -1
  129. package/layers/VoxelWasmPerSceneView.js +1 -1
  130. package/layers/mixins/operationalLayerModuleMap.js +1 -1
  131. package/layers/orientedImagery/transformations/imageToGroundUtils.js +1 -1
  132. package/layers/video/VideoCameraSensorModel.js +1 -1
  133. package/package.json +1 -1
  134. package/support/revision.js +1 -1
  135. package/symbols/cim/CIMSymbolDrawHelper.js +1 -1
  136. package/symbols/support/Symbol3DFillMaterial.js +1 -1
  137. package/symbols/support/Symbol3DMaterial.js +1 -1
  138. package/views/2d/engine/webgl/AFeatureTile.js +1 -1
  139. package/views/2d/engine/webgl/WorldExtentClipRenderer.js +1 -1
  140. package/views/2d/grid/GridView2D.js +1 -1
  141. package/views/2d/grid/constants.js +5 -0
  142. package/views/2d/interactive/editingTools/TransformTool.js +1 -1
  143. package/views/2d/interactive/editingTools/manipulations/ScaleManipulation.js +1 -1
  144. package/views/2d/layerViewModuleImportUtils.js +1 -1
  145. package/views/2d/support/highlightGroupUtils.js +1 -1
  146. package/views/3d/analysis/AreaMeasurement/support/MeasurementData.js +1 -1
  147. package/views/3d/analysis/Dimension/lengthDimensionConstraintUtils.js +1 -1
  148. package/views/3d/analysis/Dimension/lengthDimensionManipulatorUtils.js +1 -1
  149. package/views/3d/analysis/Dimension/lengthDimensionUtils.js +1 -1
  150. package/views/3d/analysis/LineOfSight/LineOfSightRayIntersector.js +1 -1
  151. package/views/3d/analysis/Slice/ShiftManipulator.js +1 -1
  152. package/views/3d/analysis/Slice/SliceTool.js +1 -1
  153. package/views/3d/analysis/Slice/SliceVisualization.js +1 -1
  154. package/views/3d/analysis/Slice/sliceToolUtils.js +1 -1
  155. package/views/3d/analysis/Viewshed/FieldOfViewManipulation.js +1 -1
  156. package/views/3d/analysis/Viewshed/ScaleOrientManipulation.js +1 -1
  157. package/views/3d/analysis/Viewshed/ViewshedSubTool.js +1 -1
  158. package/views/3d/analysis/Viewshed/ViewshedTool.js +1 -1
  159. package/views/3d/analysis/Viewshed/ViewshedVisualization.js +1 -1
  160. package/views/3d/analysis/Viewshed/viewshedToolUtils.js +1 -1
  161. package/views/3d/analysis/support/measurementUtils.js +1 -1
  162. package/views/3d/animation/pointToPoint/Animation.js +1 -1
  163. package/views/3d/animation/pointToPoint/Camera.js +1 -1
  164. package/views/3d/camera/constraintUtils/common.js +1 -1
  165. package/views/3d/camera/constraintUtils/surfaceCollision.js +1 -1
  166. package/views/3d/camera/constraintUtils/tilt.js +1 -1
  167. package/views/3d/camera/intersectionUtils.js +1 -1
  168. package/views/3d/environment/ChapmanAtmosphere.js +1 -1
  169. package/views/3d/environment/CloudsComposition.glsl.js +1 -1
  170. package/views/3d/environment/CloudsParameters.js +1 -1
  171. package/views/3d/environment/EnvironmentRenderer.js +1 -1
  172. package/views/3d/environment/Fog.js +1 -1
  173. package/views/3d/environment/MarsAtmosphere.js +1 -1
  174. package/views/3d/interactive/Manipulator3D.js +1 -1
  175. package/views/3d/interactive/editingTools/dragEventPipeline3D.js +1 -1
  176. package/views/3d/interactive/editingTools/draw/DrawGraphicTool3D.js +1 -1
  177. package/views/3d/interactive/editingTools/lineObjectVisualElementUtils.js +1 -1
  178. package/views/3d/interactive/editingTools/manipulations/MoveXYAxisManipulation.js +1 -1
  179. package/views/3d/interactive/editingTools/manipulations/MoveXYDiscManipulation.js +1 -1
  180. package/views/3d/interactive/editingTools/manipulations/MoveZManipulation.js +1 -1
  181. package/views/3d/interactive/editingTools/originGeometryVisualElementUtils.js +1 -1
  182. package/views/3d/interactive/editingTools/reshape/ReshapeOperation.js +1 -1
  183. package/views/3d/interactive/editingTools/transform/ScaleRotateTransform.js +1 -1
  184. package/views/3d/interactive/editingTools/transform/extentTransform/ExtentScale.js +1 -1
  185. package/views/3d/interactive/editingTools/transform/extentTransform/extentUtils.js +1 -1
  186. package/views/3d/interactive/visualElements/LineVisualElement.js +1 -1
  187. package/views/3d/interactive/visualElements/OutlineVisualElement.js +1 -1
  188. package/views/3d/interactive/visualElements/PointVisualElement.js +1 -1
  189. package/views/3d/interactive/visualElements/VerticesVisualElement.js +1 -1
  190. package/views/3d/layerViewModuleImportUtils.js +1 -1
  191. package/views/3d/layers/FocusAreaLayerView3D.js +5 -0
  192. package/views/3d/layers/I3SMeshView3D.js +1 -1
  193. package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
  194. package/views/3d/layers/IntegratedMeshLayerView3D.js +1 -1
  195. package/views/3d/layers/PointCloudLayerView3D.js +1 -1
  196. package/views/3d/layers/SceneLayerGraphicsView3D.js +1 -1
  197. package/views/3d/layers/VoxelGraphic.js +5 -0
  198. package/views/3d/layers/VoxelLayerView3D.js +1 -1
  199. package/views/3d/layers/graphics/Deconflictor.js +1 -1
  200. package/views/3d/layers/graphics/ElevationAligners.js +1 -1
  201. package/views/3d/layers/graphics/Graphics3DCore.js +1 -1
  202. package/views/3d/layers/graphics/Graphics3DDrapedGraphicLayer.js +1 -1
  203. package/views/3d/layers/graphics/Graphics3DExtrudeSymbolLayer.js +1 -1
  204. package/views/3d/layers/graphics/Graphics3DLodInstanceGraphicLayer.js +1 -1
  205. package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
  206. package/views/3d/layers/graphics/Graphics3DObjectSymbolLayer.js +1 -1
  207. package/views/3d/layers/graphics/Graphics3DPathSymbolLayer.js +1 -1
  208. package/views/3d/layers/graphics/elevationAlignmentUtils.js +1 -1
  209. package/views/3d/layers/graphics/labelPlacement.js +1 -1
  210. package/views/3d/layers/graphics/objectResourceUtils.js +1 -1
  211. package/views/3d/layers/i3s/I3SMeshViewFilter.js +1 -1
  212. package/views/3d/layers/i3s/I3SUtil.js +1 -1
  213. package/views/3d/layers/i3s/I3SViewportQueries.js +1 -1
  214. package/views/3d/layers/i3s/LayerElevationProvider.js +1 -1
  215. package/views/3d/layers/i3s/LoDUtil.js +1 -1
  216. package/views/3d/layers/i3s/PointRenderer.js +1 -1
  217. package/views/3d/layers/support/FastSymbolUpdates.js +1 -1
  218. package/views/3d/layers/support/FeatureTileMeasurements3D.js +1 -1
  219. package/views/3d/layers/support/FeatureTileVisibility3D.js +1 -1
  220. package/views/3d/layers/support/uvUtils.js +1 -1
  221. package/views/3d/state/NearFarHeuristic.js +1 -1
  222. package/views/3d/state/ViewStateManager.js +1 -1
  223. package/views/3d/state/controllers/GamepadKeyboardController.js +1 -1
  224. package/views/3d/state/controllers/PinchAndPanControllerGlobal.js +1 -1
  225. package/views/3d/state/controllers/PinchAndPanControllerLocal.js +1 -1
  226. package/views/3d/state/controllers/RotateController.js +1 -1
  227. package/views/3d/state/controllers/ZoomControllerGlobal.js +1 -1
  228. package/views/3d/state/controllers/ZoomControllerLocal.js +1 -1
  229. package/views/3d/state/controllers/ZoomStepControllerGlobal.js +1 -1
  230. package/views/3d/state/controllers/ZoomStepControllerLocal.js +1 -1
  231. package/views/3d/state/helpers/SceneIntersectionHelper.js +1 -1
  232. package/views/3d/state/utils/navigationUtils.js +1 -1
  233. package/views/3d/state/utils/viewUtils.js +1 -1
  234. package/views/3d/support/FrustumExtentIntersection.js +1 -1
  235. package/views/3d/support/cameraUtilsInternal.js +1 -1
  236. package/views/3d/support/geometryUtils/ray.js +1 -1
  237. package/views/3d/support/intersectionUtils.js +1 -1
  238. package/views/3d/support/mathUtils.js +1 -1
  239. package/views/3d/support/orientedBoundingBox.js +1 -1
  240. package/views/3d/support/pointsOfInterest/Focus.js +1 -1
  241. package/views/3d/support/sunUtils.js +1 -1
  242. package/views/3d/support/viewpointUtils.js +1 -1
  243. package/views/3d/terrain/OverlayRenderer.js +1 -1
  244. package/views/3d/terrain/PatchRenderData.js +1 -1
  245. package/views/3d/terrain/SphericalPatch.js +1 -1
  246. package/views/3d/terrain/TerrainRenderer.js +1 -1
  247. package/views/3d/terrain/TerrainSurface.js +1 -1
  248. package/views/3d/terrain/Tile.js +1 -1
  249. package/views/3d/terrain/isTerrainSurfaceLayer.js +1 -1
  250. package/views/3d/webgl/RenderCamera.js +1 -1
  251. package/views/3d/webgl-engine/collections/Component/ComponentObjectCollection.js +1 -1
  252. package/views/3d/webgl-engine/collections/Component/DepthRange.js +1 -1
  253. package/views/3d/webgl-engine/collections/Component/Material/ComponentMaterial.js +1 -1
  254. package/views/3d/webgl-engine/collections/Component/Material/ComponentTechnique.js +1 -1
  255. package/views/3d/webgl-engine/collections/Component/Material/ComponentTechniqueConfiguration.js +1 -1
  256. package/views/3d/webgl-engine/collections/Component/Material/shader/ComponentShader.glsl.js +1 -1
  257. package/views/3d/webgl-engine/core/renderPasses/RenderPassManager.js +1 -1
  258. package/views/3d/webgl-engine/core/shaderLibrary/ShaderOutput.js +1 -1
  259. package/views/3d/webgl-engine/core/shaderLibrary/Slice.glsl.js +1 -1
  260. package/views/3d/webgl-engine/core/shaderLibrary/attributes/InstancedDoublePrecision.glsl.js +1 -1
  261. package/views/3d/webgl-engine/core/shaderLibrary/attributes/NormalAttribute.glsl.js +1 -1
  262. package/views/3d/webgl-engine/core/shaderLibrary/attributes/VertexNormal.glsl.js +2 -6
  263. package/views/3d/webgl-engine/core/shaderLibrary/output/Emissions.glsl.js +2 -2
  264. package/views/3d/webgl-engine/core/shaderLibrary/shading/ComputeFragmentNormals.glsl.js +13 -0
  265. package/views/3d/webgl-engine/core/shaderLibrary/shading/EvaluateAmbientLighting.glsl.js +1 -1
  266. package/views/3d/webgl-engine/core/shaderLibrary/shading/EvaluateSceneLighting.glsl.js +11 -13
  267. package/views/3d/webgl-engine/core/shaderLibrary/shading/MainLighting.glsl.js +4 -4
  268. package/views/3d/webgl-engine/core/shaderLibrary/shading/PhysicallyBasedRendering.glsl.js +1 -4
  269. package/views/3d/webgl-engine/core/shaderLibrary/shading/ReadBaseColorTexture.glsl.js +3 -3
  270. package/views/3d/webgl-engine/core/shaderLibrary/shading/ReadShadowMap.glsl.js +1 -1
  271. package/views/3d/webgl-engine/core/shaderLibrary/shading/Water.glsl.js +2 -2
  272. package/views/3d/webgl-engine/core/shaderLibrary/util/ScreenSizePerspective.glsl.js +1 -1
  273. package/views/3d/webgl-engine/core/shaderLibrary/util/View.glsl.js +1 -1
  274. package/views/3d/webgl-engine/effects/focusArea/FocusAreaColorRenderNodeTechnique.js +5 -0
  275. package/views/3d/webgl-engine/effects/focusArea/FocusAreaMaskRenderNodeTechnique.js +5 -0
  276. package/views/3d/webgl-engine/effects/focusArea/FocusAreaParameters.js +5 -0
  277. package/views/3d/webgl-engine/effects/focusArea/FocusAreaRenderNode.js +5 -0
  278. package/views/3d/webgl-engine/effects/highlight/ShadowHighlight.js +1 -1
  279. package/views/3d/webgl-engine/effects/laserlines/LaserlinePathData.js +1 -1
  280. package/views/3d/webgl-engine/lib/BoundingInfo.js +1 -1
  281. package/views/3d/webgl-engine/lib/GeometryUtil.js +1 -1
  282. package/views/3d/webgl-engine/lib/Intersector.js +1 -1
  283. package/views/3d/webgl-engine/lib/Object3D.js +1 -1
  284. package/views/3d/webgl-engine/lib/Octree.js +1 -1
  285. package/views/3d/webgl-engine/lib/OrderIndependentTransparency.js +1 -1
  286. package/views/3d/webgl-engine/lib/Path.js +1 -1
  287. package/views/3d/webgl-engine/lib/PathGeometryData.js +1 -1
  288. package/views/3d/webgl-engine/lib/PathVertex.js +1 -1
  289. package/views/3d/webgl-engine/lib/RayIntersections.js +1 -1
  290. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  291. package/views/3d/webgl-engine/lib/ShadowMap.js +1 -1
  292. package/views/3d/webgl-engine/lib/edgeRendering/EdgeRenderer.js +1 -1
  293. package/views/3d/webgl-engine/lib/edgeRendering/EdgeView.js +1 -1
  294. package/views/3d/webgl-engine/lib/edgeRendering/edgePreprocessing.js +1 -1
  295. package/views/3d/webgl-engine/lib/geometryDataUtils.js +1 -1
  296. package/views/3d/webgl-engine/lib/lodRendering/InstanceData.js +1 -1
  297. package/views/3d/webgl-engine/lib/lodRendering/LodRenderer.js +1 -1
  298. package/views/3d/webgl-engine/lib/pathGeometryUtils.js +1 -1
  299. package/views/3d/webgl-engine/lib/triangleIntersectionUtils.js +1 -1
  300. package/views/3d/webgl-engine/lib/verticalOffsetUtils.js +1 -1
  301. package/views/3d/webgl-engine/lighting/SphericalHarmonics.js +1 -1
  302. package/views/3d/webgl-engine/materials/DefaultMaterial.js +1 -1
  303. package/views/3d/webgl-engine/materials/HUDMaterial.js +1 -1
  304. package/views/3d/webgl-engine/materials/LineMarkerMaterial.js +1 -1
  305. package/views/3d/webgl-engine/materials/MeasurementArrowMaterial.js +1 -1
  306. package/views/3d/webgl-engine/materials/NativeLineMaterial.js +1 -1
  307. package/views/3d/webgl-engine/materials/PathMaterial.js +1 -1
  308. package/views/3d/webgl-engine/materials/PathTechnique.js +1 -1
  309. package/views/3d/webgl-engine/materials/RibbonLineMaterial.js +1 -1
  310. package/views/3d/webgl-engine/materials/ShadedColorMaterial.js +1 -1
  311. package/views/3d/webgl-engine/shaders/DefaultMaterialTechnique.js +1 -1
  312. package/views/3d/webgl-engine/shaders/FocusAreaColor.glsl.js +5 -0
  313. package/views/3d/webgl-engine/shaders/FocusAreaMask.glsl.js +5 -0
  314. package/views/3d/webgl-engine/shaders/OutputColorHighlightOID.glsl.js +8 -8
  315. package/views/3d/webgl-engine/shaders/Path.glsl.js +1 -1
  316. package/views/draw/support/helpMessageUtils3d.js +1 -1
  317. package/views/draw/support/surfaceCoordinateSystems.js +1 -1
  318. package/views/input/gamepad/GamepadSource.js +1 -1
  319. package/views/interactive/coordinateHelper.js +1 -1
  320. package/views/interactive/editGeometry/operations/OffsetEdgeVertex.js +1 -1
  321. package/views/interactive/sketch/constraints.js +1 -1
  322. package/views/interactive/snapping/FeatureSnappingEngine.js +1 -1
  323. package/views/interactive/snapping/GridSnappingEngine.js +5 -0
  324. package/views/interactive/snapping/RightAngleSnapper.js +1 -1
  325. package/views/interactive/snapping/SnappingOptions.js +1 -1
  326. package/views/interactive/snapping/featureSources/featureServiceSource/tileUtils.js +1 -1
  327. package/views/interactive/snapping/snappingUtils.js +1 -1
  328. package/views/navigation/PanPlanarMomentumEstimator.js +1 -1
  329. package/views/support/angularMeasurementUtils.js +1 -1
  330. package/views/support/euclideanAreaMeasurementUtils.js +1 -1
  331. package/views/support/euclideanLengthMeasurementUtils.js +1 -1
  332. package/views/support/geometry3dUtils.js +1 -1
  333. package/webscene/Slide.js +1 -1
  334. package/widgets/CoordinateConversion/support/formatUtils.js +1 -1
  335. package/widgets/ElevationProfile/ElevationProfileLineView.js +1 -1
  336. package/widgets/Feature/FeatureMedia.js +1 -1
  337. package/widgets/FeatureTable/FeatureTableViewModel.js +1 -1
  338. package/widgets/FeatureTable/Grid/Column.js +1 -1
  339. package/widgets/FeatureTable.js +1 -1
  340. package/widgets/GridControls/GridControlsViewModel.d.ts +4 -0
  341. package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
  342. package/widgets/PanoramicViewer/PanoramicViewerViewModel.js +1 -1
  343. package/widgets/Print/CustomTemplate.js +1 -1
  344. package/widgets/Print/PrintViewModel.js +1 -1
  345. package/widgets/Print/TemplateOptions.js +1 -1
  346. package/widgets/Print/utils.js +5 -0
  347. package/widgets/Print.js +1 -1
  348. package/widgets/ShadowCast/ShadowCastViewModel.js +1 -1
  349. package/widgets/support/GridControls/GridControlsViewModel.d.ts +4 -0
  350. package/widgets/support/GridControls/GridControlsViewModel.js +5 -0
  351. package/widgets/support/GridControls/VisibleElements.js +5 -0
  352. package/widgets/support/GridControls/gridUtils.js +5 -0
  353. package/widgets/support/GridControls.d.ts +4 -0
  354. package/widgets/support/GridControls.js +5 -0
  355. package/widgets/support/exportUtils.js +1 -1
  356. package/assets/esri/core/workers/chunks/14dc47896456e3c66b24.js +0 -1
  357. package/assets/esri/core/workers/chunks/2e88af8ab1e2713e7655.js +0 -1
  358. package/assets/esri/core/workers/chunks/3b204e75b613bcfbc8b9.js +0 -1
  359. package/assets/esri/core/workers/chunks/3e57f493d5a9d7aa7a48.js +0 -1
  360. package/assets/esri/core/workers/chunks/4e5ae81c612543130d9a.js +0 -1
  361. package/assets/esri/core/workers/chunks/4e746f8fca1d932dd684.js +0 -1
  362. package/assets/esri/core/workers/chunks/544eec13338b2d71680f.js +0 -1
  363. package/assets/esri/core/workers/chunks/5e7e12863cbed07451d0.js +0 -1
  364. package/assets/esri/core/workers/chunks/6c129767cda74aa672e0.js +0 -1
  365. package/assets/esri/core/workers/chunks/6f7c2d02fbd29870f6ee.js +0 -1
  366. package/assets/esri/core/workers/chunks/7802e70422f4151b95bc.js +0 -1
  367. package/assets/esri/core/workers/chunks/920557db2bd107a3c579.js +0 -1
  368. package/assets/esri/core/workers/chunks/9443b9ec03f25c723c2c.js +0 -47
  369. package/assets/esri/core/workers/chunks/991295637f51e8207efe.js +0 -1
  370. package/assets/esri/core/workers/chunks/ace8b6351ed35b03499b.js +0 -1
  371. package/assets/esri/core/workers/chunks/b1e4896acfae0bf9a9a8.js +0 -1
  372. package/assets/esri/core/workers/chunks/ca12b1c470e67ca7b30e.js +0 -1
  373. package/assets/esri/core/workers/chunks/cd9f48dcee2a1fc261ed.js +0 -774
  374. package/assets/esri/core/workers/chunks/d3626c01d2569d84e01e.js +0 -1
  375. package/assets/esri/core/workers/chunks/e5474bcde5b8fa037b56.js +0 -278
  376. package/views/3d/webgl-engine/core/shaderLibrary/shading/ComputeShadingNormal.glsl.js +0 -31
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.31/esri/copyright.txt for details.
4
4
  */
5
- import t from"../../../Camera.js";import"../../../geometry.js";import e from"../../../Graphic.js";import n from"../../../Viewpoint.js";import{result as a}from"../../../core/asyncUtils.js";import"../../../core/has.js";import{cyclicalDegrees as r}from"../../../core/Cyclical.js";import o from"../../../core/Error.js";import{throwIfAborted as i}from"../../../core/promiseUtils.js";import{fromMat4 as s,transpose as c}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{create as l}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{create as m}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{j as u,g as f,p,c as g,f as y,s as h,t as d}from"../../../chunks/vec32.js";import{create as w}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{projectWithZConversion as x,tryProjectWithZConversion as j}from"../../../geometry/projection.js";import{computeTranslationToOriginAndRotation as v}from"../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{projectPointToVectorAsync as b}from"../../../geometry/projection/projectPointToVector.js";import{projectVectorToPoint as R}from"../../../geometry/projection/projectVectorToPoint.js";import{projectVectorToVector as z}from"../../../geometry/projection/projectVectorToVector.js";import{create as G,center as S,toRect as B,isPoint as T,empty as M,expandWithVec3 as Z,expandWithAABB as A,width as E,height as F,depth as O}from"../../../geometry/support/aaBoundingBox.js";import{create as P,isPoint as D}from"../../../geometry/support/aaBoundingRect.js";import{intersectsPoint as U}from"../../../geometry/support/frustum.js";import{getResolutionInMetersForScale as V}from"../../../geometry/support/scaleUtils.js";import{cameraOnContentAlongViewDirection as C}from"../camera/intersectionUtils.js";import{getViewSR as k,fromExtentAsync as I,internalToExternal as J,OrientationMode as K,scaleToDistance as L,fromCenterDistanceAsync as N,fromExtentSync as W,fromCenterDistanceSync as Y,externalToInternal as q,distanceToScale as X,fromCenterScale as _,directionToHeadingTilt as H,zoomToScale as Q}from"./cameraUtils.js";import{getElevationAtPoint as $}from"./ElevationProvider.js";import tt from"../../../geometry/Point.js";import et from"../../../geometry/Extent.js";import nt from"../../../geometry/SpatialReference.js";import at from"../../../geometry/Geometry.js";import rt from"../../../geometry/Multipoint.js";const ot=.66;function it(t){return 360-r.normalize(t)}function st(t){return r.normalize(360-t)}function ct(t,e,n){const a=e.camera;if(null!=a)return mt(a,k(t));const{targetGeometry:r}=e;if(null==r)return null;const{camera:o,mode:i}=ft(t,e.rotation,n);if("point"===r.type)return pt(t,e,r,o,i);const s=r.extent;return null==s?null:W(t,s,o.heading,o.tilt,i)}async function lt(t,e,n,a){const r=e.camera;if(null!=r)return ut(r,k(t),a);const{targetGeometry:o}=e;if(null==o)throw new Error("Viewpoint has no targetGeometry!");const{camera:i,mode:s}=ft(t,e.rotation,n);if("point"===o.type)return gt(t,e,o,i,s,a);const c=o.extent;if(null==c)throw new Error("Target geometry has no extent!");return I(t,c,i.heading,i.tilt,s,a)}function mt(t,e){const n=t.position;let a;try{a=j(n,e)}catch(o){return null}if(!a)return null;const r=t.clone();return r.position=a.clone(),r}async function ut(t,e,n){const a=t.position,r=await x(a,e,{signal:n});i(n);const o=t.clone();return o.position=r.clone(),o}function ft(t,e,n){const a=J(t,t.state.camera);let r=K.ADJUST;return null!=e&&(a.heading=it(e),r=K.LOCKED),null!=n&&(a.tilt=n),{camera:a,mode:r}}function pt(t,e,n,a,r){const o=t.spatialReference;let i;try{i=j(n.clone(),o)}catch(c){return null}if(!i)return null;const s=null!=e.scale?L(t,e.scale):t.state.camera.distance;return Y(t,i,s,a,r)}async function gt(t,e,n,a,r,o){const s=t.spatialReference,c=await x(n.clone(),s,{signal:o});i(o);const l=null!=e.scale?L(t,e.scale):t.state.camera.distance;return N(t,c,l,a,r,o)}function yt(t,e,a=null){return null==a&&(a=new n),jt(t,null,e.clone(),a)}async function ht(e,a,r){const i=Ft(e,a);if(!i)throw new o("viewpointutils-create:no-target","Missing target for creating viewpoint");const s=new t({fov:e.camera.fov}),c=new n({camera:s});if(i.target instanceof n){return Ot(await zt(e,i.target,i,r,c))}if(i.target instanceof t)return Ot(await Gt(e,i.target,r,c));const l=null!=i.scale||null!=i.zoom;if(i.target instanceof et){const t=i.target.xmin===i.target.xmax||i.target.ymin===i.target.ymax;return Ot(l||t?await Bt(e,i,i.target.center,s,r,c):await Zt(e,i,i.target,s,r,c))}const m=new Dt,u=l?wt(e,i):void 0;if(await Rt(e,i.target,u,m,r),isFinite(m.boundingBox[0])){let t;if(S(m.boundingBox,Ut),Wt.x=Ut[0],Wt.y=Ut[1],Wt.z=Ut[2],Wt.spatialReference=e.spatialReference,isFinite(Wt.z)&&m.hasZ?t=T(m.boundingBox):(Wt.z=void 0,t=D(B(m.boundingBox,It))),l||t)return Ot(await Bt(e,i,Wt,s,r,c));const n=Pt(e,m.screenSpaceObjects);return Ot(await Et(e,i,Wt,m.boundingBox,n,s,r,c))}return i.position?Ot(await Tt(e,i,s,c,r)):Ot(await Mt(e,i,s,r,c))}function dt(t,e){return null==e.scale&&null!=e.zoom?Q(t,e.zoom):e.scale}function wt(t,e){const n=dt(t,e);return n?V(n):void 0}function xt(t,e){let n=!1;return null!=e.heading?(t.heading=e.heading,n=!0):null!=e.rotation&&(t.heading=it(e.rotation),n=!0),null!=e.tilt&&(t.tilt=e.tilt,n=!0),null!=e.fov&&(t.fov=e.fov),n}function jt(t,e,n,a){const r=t.spatialReference||nt.WGS84;if(e??=q(t,n),null==e)return a;const o=new tt({spatialReference:r});return R(e.center,t.renderSpatialReference,o)?(a.targetGeometry=o,a.scale=X(t,e.distance),a.rotation=st(n.heading),a.camera=n,a):a}async function vt(t,e,n,a){const r=()=>new o("viewpointutils:invalid-geometry","The target is missing a valid geometry");if(!e)throw r();"mesh"===e.type&&(e=e.extent);const i=t.basemapTerrain.spatialReference;if(!e.hasZ&&t.basemapTerrain){let n;switch(e.type){case"point":n=e;break;case"multipoint":case"polyline":n=e.extent?.center;break;case"extent":n=e.center;break;case"polygon":n=e.centroid}null!=n&&i&&t.elevationProvider?(n=await x(n,i,{signal:a}),Ut[2]=$(t.elevationProvider,n)??0):Ut[2]=0}const s=Yt[e.type],c=new Array;if(s(e,e.hasZ?t=>{c.push([t[0],t[1],t[2]])}:t=>{c.push([t[0],t[1]])},Ut),0===c.length)throw r();const l=e.spatialReference,m=t.spatialReference,u=await x(new rt({spatialReference:l,hasZ:e.hasZ,hasM:!1,points:c}),m,{signal:a});if(e.hasZ&&(n.hasZ=!0),e.hasZ)for(const[o,f,p]of u.points)Ut[0]=o,Ut[1]=f,Ut[2]=p,Z(n.boundingBox,Ut);else for(const[o,f]of u.points)Ut[0]=o,Ut[1]=f,Z(n.boundingBox,Ut)}async function bt(t,e,n,r,o){const i=await a(t.whenViewForGraphic(e));if(!1===i.ok||null==i.value||!("whenGraphicBounds"in i.value))return void await vt(t,e.geometry,r,o);const s=i.value,c=await a(s.whenGraphicBounds(e,{minDemResolution:n}));if(!1===c.ok||!c.value)return void await vt(t,e.geometry,r,o);const{screenSpaceObjects:l,boundingBox:m}=c.value;A(r.boundingBox,m),l&&l.forEach((t=>{r.screenSpaceObjects.push(t)})),isFinite(m[2])&&(r.hasZ=!0)}async function Rt(t,n,a,r,o){if(Array.isArray(n)&&2===n.length){const e=n[0],a=n[1];if("number"==typeof e&&"number"==typeof a)return Wt.x=e,Wt.y=a,Wt.z=void 0,Wt.spatialReference=t.spatialReference?.isGeographic?t.spatialReference:nt.WGS84,void await vt(t,Wt,r,o)}n&&"map"in n&&"function"==typeof n.map?await Promise.allSettled(n.map((e=>Rt(t,e,a,r,o)))):n instanceof at?await vt(t,n,r,o):n instanceof e&&await bt(t,n,a,r,o)}async function zt(t,e,n,a,r){if(e.camera)return Gt(t,e.camera,a,r);r.scale=e.scale,r.rotation=e.rotation,r.targetGeometry=null!=e.targetGeometry?e.targetGeometry.clone():null,r.camera=null,null!=n.heading?r.rotation=st(n.heading):null!=n.rotation&&(r.rotation=n.rotation);const o=dt(t,n);return null!=o&&(r.scale=o),r.camera=await lt(t,r,n.tilt,a),r}async function Gt(t,e,n,a){const r=t.spatialReference,o=await x(e.position,r,{signal:n}),i=e.clone();return i.position=o,jt(t,null,i,a)}async function St(t,e,n,a,r,o,i){const s=t.renderSpatialReference;return await b(e,Lt,s,0,{signal:i}),await b(n,Kt,s,0,{signal:i}),o.targetGeometry=new tt(e),r.position=new tt(n),y(Jt,Lt,Kt),H(t,Kt,Jt,a.up,r),o.scale=X(t,p(Kt,Lt)),o.rotation=st(r.heading),o.camera=r,o}async function Bt(t,e,n,a,r,o){o.targetGeometry=n.clone();const i=C(t);if(e.position)return St(t,o.targetGeometry,e.position,i,a,o,r);if(e.zoomFactor){const n=i.distance/e.zoomFactor,a=u(Ut,i.viewForward,-n);i.eye=f(Ut,i.center,a),o.scale=X(t,n)}J(t,i,a);const s=xt(a,e)?K.LOCKED:K.ADJUST;if(!e.zoomFactor){const c=dt(t,e);null==c?(await b(n,Ut,t.renderSpatialReference,0,{signal:r}),U(i.frustum,Ut)?o.scale=X(t,p(i.eye,Ut)):o.scale=X(t,i.distance)):o.scale=c,o.camera=await _(t,o.targetGeometry,o.scale,a,s,r)}return o}async function Tt(t,e,n,a,r){const o=C(t);g(Jt,o.viewForward),H(t,o.eye,Jt,o.up,Nt);const i=t.spatialReference,{position:s}=e;if(s){const t=await x(s,i,{signal:r});n.position=t}else n.position=new tt;return n.heading=null!=e.heading?e.heading:Nt.heading,n.tilt=null!=e.tilt?e.tilt:Nt.tilt,jt(t,null,n,a)}async function Mt(t,e,n,a,r){if(null!=e.heading||null!=e.rotation||null!=e.scale||null!=e.tilt||null!=e.zoom||null!=e.zoomFactor){const o=C(t),{spatialReference:i,renderSpatialReference:s}=t,c=new tt({spatialReference:i});return R(o.center,s,c)?Bt(t,e,c,n,a,r):r}return r.scale=t.scale,r.camera=t.camera.clone(),xt(r.camera,e),r}async function Zt(t,e,n,a,r,o){o.targetGeometry=n.clone();const i=C(t);J(t,i,a);const s=xt(a,e)?K.LOCKED:K.ADJUST;return o.camera=await I(t,n,a.heading,a.tilt,s,r),o}function At(t,e,n,a,r){let o=0;null!=n.z?o=n.z:t.basemapTerrain&&t.elevationProvider&&(o=$(t.elevationProvider,n)),h(Ut,n.x,n.y,o),v(t.spatialReference,Ut,Vt,t.renderSpatialReference),s(Ct,Vt),c(Ct,Ct),M(kt);const i=[[0,1,2],[3,1,2],[0,4,2],[3,4,2],[0,1,5],[3,1,5],[0,4,5],[3,4,5]];for(let s=0;s<i.length;s++){const e=i[s];let n=a[e[2]];isFinite(n)||(n=o),h(Ut,a[e[0]],a[e[1]],n),z(Ut,t.spatialReference,Ut,t.renderSpatialReference),Z(kt,d(Ut,Ut,Ct))}const l=E(kt),m=F(kt),u=O(kt),f=1/Math.tan(e.fovX/2),p=1/Math.tan(e.fovY/2),g=.5*Math.sqrt(l*l+u*u)*Math.max(p,f)+.5*m,y=.5*m*p+.5*Math.max(l,u);return Math.max(g,y)/r}async function Et(t,e,n,a,r,o,i,s){s.targetGeometry=n.clone();const c=C(t),l=At(t,c,n,a,r);J(t,c,o);const m=xt(o,e)?K.LOCKED:K.ADJUST;return s.scale=X(t,l),s.camera=await _(t,s.targetGeometry,s.scale,o,m,i),s}function Ft(t,e){if(!e||!t.spatialReference)return null;const n={target:void 0};return"declaredClass"in e||Array.isArray(e)?n.target=e:(Object.assign(n,e),!n.target&&"center"in e&&e.center&&(n.target=e.center)),n}function Ot(t){return null!=t?.camera&&(t.rotation=st(t.camera.heading)),t}function Pt(t,e){const n=ot;if(!e.length)return n;let a=Number.NEGATIVE_INFINITY;for(let r=0;r<e.length;r++){const t=e[r].screenSpaceBoundingRect;a=Math.max(a,Math.abs(t[0]),Math.abs(t[1]),Math.abs(t[2]),Math.abs(t[3]))}return n-a/Math.min(t.width,t.height)*2}class Dt{constructor(){this.hasZ=!1,this.boundingBox=M(),this.screenSpaceObjects=new Array}}const Ut=w(),Vt=m(),Ct=l(),kt=G(),It=P(),Jt=w(),Kt=w(),Lt=w(),Nt={heading:0,tilt:0},Wt=new tt,Yt={point(t,e,n){n[0]=t.x,n[1]=t.y,null!=t.z&&(n[2]=t.z),e(n)},polygon(t,e,n){const a=t.hasZ;for(let r=0;r<t.rings.length;r++){const o=t.rings[r];for(let t=0;t<o.length;t++)n[0]=o[t][0],n[1]=o[t][1],a&&(n[2]=o[t][2]),e(n)}},polyline(t,e,n){const a=t.hasZ;for(let r=0;r<t.paths.length;r++){const o=t.paths[r];for(let t=0;t<o.length;t++)n[0]=o[t][0],n[1]=o[t][1],a&&(n[2]=o[t][2]),e(n)}},multipoint(t,e,n){const a=t.points,r=t.hasZ;for(let o=0;o<a.length;o++)n[0]=a[o][0],n[1]=a[o][1],r&&(n[2]=a[o][2]),e(n)},extent(t,e,n){null!=t.zmin&&null!=t.zmax?(e(h(n,t.xmin,t.ymin,t.zmin)),e(h(n,t.xmax,t.ymin,t.zmin)),e(h(n,t.xmin,t.ymax,t.zmin)),e(h(n,t.xmax,t.ymax,t.zmin)),e(h(n,t.xmin,t.ymin,t.zmax)),e(h(n,t.xmax,t.ymin,t.zmax)),e(h(n,t.xmin,t.ymax,t.zmax)),e(h(n,t.xmax,t.ymax,t.zmax))):(e(h(n,t.xmin,t.ymin,n[2])),e(h(n,t.xmax,t.ymin,n[2])),e(h(n,t.xmin,t.ymax,n[2])),e(h(n,t.xmax,t.ymax,n[2])))}};export{ht as create,yt as fromCamera,lt as toCameraAsync,ct as toCameraSync};
5
+ import t from"../../../Camera.js";import"../../../geometry.js";import e from"../../../Graphic.js";import n from"../../../Viewpoint.js";import{result as a}from"../../../core/asyncUtils.js";import"../../../core/has.js";import{cyclicalDegrees as r}from"../../../core/Cyclical.js";import o from"../../../core/Error.js";import{throwIfAborted as i}from"../../../core/promiseUtils.js";import{fromMat4 as s,transpose as c}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{create as l}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{create as m}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{j as u,g as f,p,c as g,f as y,a as h,t as d}from"../../../chunks/vec32.js";import{create as w}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{projectWithZConversion as x,tryProjectWithZConversion as j}from"../../../geometry/projection.js";import{computeTranslationToOriginAndRotation as v}from"../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{projectPointToVectorAsync as b}from"../../../geometry/projection/projectPointToVector.js";import{projectVectorToPoint as R}from"../../../geometry/projection/projectVectorToPoint.js";import{projectVectorToVector as z}from"../../../geometry/projection/projectVectorToVector.js";import{create as G,center as S,toRect as B,isPoint as T,empty as M,expandWithVec3 as Z,expandWithAABB as A,width as E,height as F,depth as O}from"../../../geometry/support/aaBoundingBox.js";import{create as P,isPoint as D}from"../../../geometry/support/aaBoundingRect.js";import{intersectsPoint as U}from"../../../geometry/support/frustum.js";import{getResolutionInMetersForScale as V}from"../../../geometry/support/scaleUtils.js";import{cameraOnContentAlongViewDirection as C}from"../camera/intersectionUtils.js";import{getViewSR as k,fromExtentAsync as I,internalToExternal as J,OrientationMode as K,scaleToDistance as L,fromCenterDistanceAsync as N,fromExtentSync as W,fromCenterDistanceSync as Y,externalToInternal as q,distanceToScale as X,fromCenterScale as _,directionToHeadingTilt as H,zoomToScale as Q}from"./cameraUtils.js";import{getElevationAtPoint as $}from"./ElevationProvider.js";import tt from"../../../geometry/Point.js";import et from"../../../geometry/Extent.js";import nt from"../../../geometry/SpatialReference.js";import at from"../../../geometry/Geometry.js";import rt from"../../../geometry/Multipoint.js";const ot=.66;function it(t){return 360-r.normalize(t)}function st(t){return r.normalize(360-t)}function ct(t,e,n){const a=e.camera;if(null!=a)return mt(a,k(t));const{targetGeometry:r}=e;if(null==r)return null;const{camera:o,mode:i}=ft(t,e.rotation,n);if("point"===r.type)return pt(t,e,r,o,i);const s=r.extent;return null==s?null:W(t,s,o.heading,o.tilt,i)}async function lt(t,e,n,a){const r=e.camera;if(null!=r)return ut(r,k(t),a);const{targetGeometry:o}=e;if(null==o)throw new Error("Viewpoint has no targetGeometry!");const{camera:i,mode:s}=ft(t,e.rotation,n);if("point"===o.type)return gt(t,e,o,i,s,a);const c=o.extent;if(null==c)throw new Error("Target geometry has no extent!");return I(t,c,i.heading,i.tilt,s,a)}function mt(t,e){const n=t.position;let a;try{a=j(n,e)}catch(o){return null}if(!a)return null;const r=t.clone();return r.position=a.clone(),r}async function ut(t,e,n){const a=t.position,r=await x(a,e,{signal:n});i(n);const o=t.clone();return o.position=r.clone(),o}function ft(t,e,n){const a=J(t,t.state.camera);let r=K.ADJUST;return null!=e&&(a.heading=it(e),r=K.LOCKED),null!=n&&(a.tilt=n),{camera:a,mode:r}}function pt(t,e,n,a,r){const o=t.spatialReference;let i;try{i=j(n.clone(),o)}catch(c){return null}if(!i)return null;const s=null!=e.scale?L(t,e.scale):t.state.camera.distance;return Y(t,i,s,a,r)}async function gt(t,e,n,a,r,o){const s=t.spatialReference,c=await x(n.clone(),s,{signal:o});i(o);const l=null!=e.scale?L(t,e.scale):t.state.camera.distance;return N(t,c,l,a,r,o)}function yt(t,e,a=null){return null==a&&(a=new n),jt(t,null,e.clone(),a)}async function ht(e,a,r){const i=Ft(e,a);if(!i)throw new o("viewpointutils-create:no-target","Missing target for creating viewpoint");const s=new t({fov:e.camera.fov}),c=new n({camera:s});if(i.target instanceof n){return Ot(await zt(e,i.target,i,r,c))}if(i.target instanceof t)return Ot(await Gt(e,i.target,r,c));const l=null!=i.scale||null!=i.zoom;if(i.target instanceof et){const t=i.target.xmin===i.target.xmax||i.target.ymin===i.target.ymax;return Ot(l||t?await Bt(e,i,i.target.center,s,r,c):await Zt(e,i,i.target,s,r,c))}const m=new Dt,u=l?wt(e,i):void 0;if(await Rt(e,i.target,u,m,r),isFinite(m.boundingBox[0])){let t;if(S(m.boundingBox,Ut),Wt.x=Ut[0],Wt.y=Ut[1],Wt.z=Ut[2],Wt.spatialReference=e.spatialReference,isFinite(Wt.z)&&m.hasZ?t=T(m.boundingBox):(Wt.z=void 0,t=D(B(m.boundingBox,It))),l||t)return Ot(await Bt(e,i,Wt,s,r,c));const n=Pt(e,m.screenSpaceObjects);return Ot(await Et(e,i,Wt,m.boundingBox,n,s,r,c))}return i.position?Ot(await Tt(e,i,s,c,r)):Ot(await Mt(e,i,s,r,c))}function dt(t,e){return null==e.scale&&null!=e.zoom?Q(t,e.zoom):e.scale}function wt(t,e){const n=dt(t,e);return n?V(n):void 0}function xt(t,e){let n=!1;return null!=e.heading?(t.heading=e.heading,n=!0):null!=e.rotation&&(t.heading=it(e.rotation),n=!0),null!=e.tilt&&(t.tilt=e.tilt,n=!0),null!=e.fov&&(t.fov=e.fov),n}function jt(t,e,n,a){const r=t.spatialReference||nt.WGS84;if(e??=q(t,n),null==e)return a;const o=new tt({spatialReference:r});return R(e.center,t.renderSpatialReference,o)?(a.targetGeometry=o,a.scale=X(t,e.distance),a.rotation=st(n.heading),a.camera=n,a):a}async function vt(t,e,n,a){const r=()=>new o("viewpointutils:invalid-geometry","The target is missing a valid geometry");if(!e)throw r();"mesh"===e.type&&(e=e.extent);const i=t.basemapTerrain.spatialReference;if(!e.hasZ&&t.basemapTerrain){let n;switch(e.type){case"point":n=e;break;case"multipoint":case"polyline":n=e.extent?.center;break;case"extent":n=e.center;break;case"polygon":n=e.centroid}null!=n&&i&&t.elevationProvider?(n=await x(n,i,{signal:a}),Ut[2]=$(t.elevationProvider,n)??0):Ut[2]=0}const s=Yt[e.type],c=new Array;if(s(e,e.hasZ?t=>{c.push([t[0],t[1],t[2]])}:t=>{c.push([t[0],t[1]])},Ut),0===c.length)throw r();const l=e.spatialReference,m=t.spatialReference,u=await x(new rt({spatialReference:l,hasZ:e.hasZ,hasM:!1,points:c}),m,{signal:a});if(e.hasZ&&(n.hasZ=!0),e.hasZ)for(const[o,f,p]of u.points)Ut[0]=o,Ut[1]=f,Ut[2]=p,Z(n.boundingBox,Ut);else for(const[o,f]of u.points)Ut[0]=o,Ut[1]=f,Z(n.boundingBox,Ut)}async function bt(t,e,n,r,o){const i=await a(t.whenViewForGraphic(e));if(!1===i.ok||null==i.value||!("whenGraphicBounds"in i.value))return void await vt(t,e.geometry,r,o);const s=i.value,c=await a(s.whenGraphicBounds(e,{minDemResolution:n}));if(!1===c.ok||!c.value)return void await vt(t,e.geometry,r,o);const{screenSpaceObjects:l,boundingBox:m}=c.value;A(r.boundingBox,m),l&&l.forEach((t=>{r.screenSpaceObjects.push(t)})),isFinite(m[2])&&(r.hasZ=!0)}async function Rt(t,n,a,r,o){if(Array.isArray(n)&&2===n.length){const e=n[0],a=n[1];if("number"==typeof e&&"number"==typeof a)return Wt.x=e,Wt.y=a,Wt.z=void 0,Wt.spatialReference=t.spatialReference?.isGeographic?t.spatialReference:nt.WGS84,void await vt(t,Wt,r,o)}n&&"map"in n&&"function"==typeof n.map?await Promise.allSettled(n.map((e=>Rt(t,e,a,r,o)))):n instanceof at?await vt(t,n,r,o):n instanceof e&&await bt(t,n,a,r,o)}async function zt(t,e,n,a,r){if(e.camera)return Gt(t,e.camera,a,r);r.scale=e.scale,r.rotation=e.rotation,r.targetGeometry=null!=e.targetGeometry?e.targetGeometry.clone():null,r.camera=null,null!=n.heading?r.rotation=st(n.heading):null!=n.rotation&&(r.rotation=n.rotation);const o=dt(t,n);return null!=o&&(r.scale=o),r.camera=await lt(t,r,n.tilt,a),r}async function Gt(t,e,n,a){const r=t.spatialReference,o=await x(e.position,r,{signal:n}),i=e.clone();return i.position=o,jt(t,null,i,a)}async function St(t,e,n,a,r,o,i){const s=t.renderSpatialReference;return await b(e,Lt,s,0,{signal:i}),await b(n,Kt,s,0,{signal:i}),o.targetGeometry=new tt(e),r.position=new tt(n),y(Jt,Lt,Kt),H(t,Kt,Jt,a.up,r),o.scale=X(t,p(Kt,Lt)),o.rotation=st(r.heading),o.camera=r,o}async function Bt(t,e,n,a,r,o){o.targetGeometry=n.clone();const i=C(t);if(e.position)return St(t,o.targetGeometry,e.position,i,a,o,r);if(e.zoomFactor){const n=i.distance/e.zoomFactor,a=u(Ut,i.viewForward,-n);i.eye=f(Ut,i.center,a),o.scale=X(t,n)}J(t,i,a);const s=xt(a,e)?K.LOCKED:K.ADJUST;if(!e.zoomFactor){const c=dt(t,e);null==c?(await b(n,Ut,t.renderSpatialReference,0,{signal:r}),U(i.frustum,Ut)?o.scale=X(t,p(i.eye,Ut)):o.scale=X(t,i.distance)):o.scale=c,o.camera=await _(t,o.targetGeometry,o.scale,a,s,r)}return o}async function Tt(t,e,n,a,r){const o=C(t);g(Jt,o.viewForward),H(t,o.eye,Jt,o.up,Nt);const i=t.spatialReference,{position:s}=e;if(s){const t=await x(s,i,{signal:r});n.position=t}else n.position=new tt;return n.heading=null!=e.heading?e.heading:Nt.heading,n.tilt=null!=e.tilt?e.tilt:Nt.tilt,jt(t,null,n,a)}async function Mt(t,e,n,a,r){if(null!=e.heading||null!=e.rotation||null!=e.scale||null!=e.tilt||null!=e.zoom||null!=e.zoomFactor){const o=C(t),{spatialReference:i,renderSpatialReference:s}=t,c=new tt({spatialReference:i});return R(o.center,s,c)?Bt(t,e,c,n,a,r):r}return r.scale=t.scale,r.camera=t.camera.clone(),xt(r.camera,e),r}async function Zt(t,e,n,a,r,o){o.targetGeometry=n.clone();const i=C(t);J(t,i,a);const s=xt(a,e)?K.LOCKED:K.ADJUST;return o.camera=await I(t,n,a.heading,a.tilt,s,r),o}function At(t,e,n,a,r){let o=0;null!=n.z?o=n.z:t.basemapTerrain&&t.elevationProvider&&(o=$(t.elevationProvider,n)),h(Ut,n.x,n.y,o),v(t.spatialReference,Ut,Vt,t.renderSpatialReference),s(Ct,Vt),c(Ct,Ct),M(kt);const i=[[0,1,2],[3,1,2],[0,4,2],[3,4,2],[0,1,5],[3,1,5],[0,4,5],[3,4,5]];for(let s=0;s<i.length;s++){const e=i[s];let n=a[e[2]];isFinite(n)||(n=o),h(Ut,a[e[0]],a[e[1]],n),z(Ut,t.spatialReference,Ut,t.renderSpatialReference),Z(kt,d(Ut,Ut,Ct))}const l=E(kt),m=F(kt),u=O(kt),f=1/Math.tan(e.fovX/2),p=1/Math.tan(e.fovY/2),g=.5*Math.sqrt(l*l+u*u)*Math.max(p,f)+.5*m,y=.5*m*p+.5*Math.max(l,u);return Math.max(g,y)/r}async function Et(t,e,n,a,r,o,i,s){s.targetGeometry=n.clone();const c=C(t),l=At(t,c,n,a,r);J(t,c,o);const m=xt(o,e)?K.LOCKED:K.ADJUST;return s.scale=X(t,l),s.camera=await _(t,s.targetGeometry,s.scale,o,m,i),s}function Ft(t,e){if(!e||!t.spatialReference)return null;const n={target:void 0};return"declaredClass"in e||Array.isArray(e)?n.target=e:(Object.assign(n,e),!n.target&&"center"in e&&e.center&&(n.target=e.center)),n}function Ot(t){return null!=t?.camera&&(t.rotation=st(t.camera.heading)),t}function Pt(t,e){const n=ot;if(!e.length)return n;let a=Number.NEGATIVE_INFINITY;for(let r=0;r<e.length;r++){const t=e[r].screenSpaceBoundingRect;a=Math.max(a,Math.abs(t[0]),Math.abs(t[1]),Math.abs(t[2]),Math.abs(t[3]))}return n-a/Math.min(t.width,t.height)*2}class Dt{constructor(){this.hasZ=!1,this.boundingBox=M(),this.screenSpaceObjects=new Array}}const Ut=w(),Vt=m(),Ct=l(),kt=G(),It=P(),Jt=w(),Kt=w(),Lt=w(),Nt={heading:0,tilt:0},Wt=new tt,Yt={point(t,e,n){n[0]=t.x,n[1]=t.y,null!=t.z&&(n[2]=t.z),e(n)},polygon(t,e,n){const a=t.hasZ;for(let r=0;r<t.rings.length;r++){const o=t.rings[r];for(let t=0;t<o.length;t++)n[0]=o[t][0],n[1]=o[t][1],a&&(n[2]=o[t][2]),e(n)}},polyline(t,e,n){const a=t.hasZ;for(let r=0;r<t.paths.length;r++){const o=t.paths[r];for(let t=0;t<o.length;t++)n[0]=o[t][0],n[1]=o[t][1],a&&(n[2]=o[t][2]),e(n)}},multipoint(t,e,n){const a=t.points,r=t.hasZ;for(let o=0;o<a.length;o++)n[0]=a[o][0],n[1]=a[o][1],r&&(n[2]=a[o][2]),e(n)},extent(t,e,n){null!=t.zmin&&null!=t.zmax?(e(h(n,t.xmin,t.ymin,t.zmin)),e(h(n,t.xmax,t.ymin,t.zmin)),e(h(n,t.xmin,t.ymax,t.zmin)),e(h(n,t.xmax,t.ymax,t.zmin)),e(h(n,t.xmin,t.ymin,t.zmax)),e(h(n,t.xmax,t.ymin,t.zmax)),e(h(n,t.xmin,t.ymax,t.zmax)),e(h(n,t.xmax,t.ymax,t.zmax))):(e(h(n,t.xmin,t.ymin,n[2])),e(h(n,t.xmax,t.ymin,n[2])),e(h(n,t.xmin,t.ymax,n[2])),e(h(n,t.xmax,t.ymax,n[2])))}};export{ht as create,yt as fromCamera,lt as toCameraAsync,ct as toCameraSync};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.31/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import r from"../../../core/Evented.js";import"../../../core/has.js";import{someMap as t}from"../../../core/MapUtils.js";import{releaseMaybe as s,disposeMaybe as i,destroyMaybe as a}from"../../../core/maybe.js";import o from"../../../core/PooledArray.js";import{watch as n,syncAndInitial as h,on as d}from"../../../core/reactiveUtils.js";import{someSet as l}from"../../../core/SetUtils.js";import{property as c}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as u}from"../../../core/accessorSupport/decorators/subclass.js";import{ortho as p,fromTranslation as m}from"../../../core/libs/gl-matrix-2/math/mat4.js";import{s as _}from"../../../chunks/vec32.js";import{fromValues as g}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ViewingMode as y}from"../../ViewingMode.js";import{DrapeTargetType as f,DrapeSourceType as R,DrapedRenderGroup as T}from"../layers/interfaces.js";import{debugFlags as b}from"../support/debugFlags.js";import{OverlayIndex as w}from"./interfaces.js";import{Overlay as x}from"./Overlay.js";import{OverlayContent as v}from"./OverlayContent.js";import{OverlayRenderTargets as D}from"./OverlayRenderTargets.js";import S from"../webgl/RenderCamera.js";import{ShaderOutput as C}from"../webgl-engine/core/shaderLibrary/ShaderOutput.js";import{OverlayMode as P}from"../webgl-engine/core/shaderLibrary/terrain/Overlay.glsl.js";import{T as O}from"../../../chunks/TextureOnly.glsl.js";import{ShaderTechniqueRepository as j}from"../webgl-engine/core/shaderTechnique/ShaderTechniqueRepository.js";import{SyncRenderPlugin as E}from"../webgl-engine/effects/RenderPlugin.js";import{GLMaterialRepository as W}from"../webgl-engine/lib/GLMaterialRepository.js";import{GridLocalOriginFactory as M}from"../webgl-engine/lib/GridLocalOriginFactory.js";import{RenderOccludedFlag as A}from"../webgl-engine/lib/Material.js";import{OverlayRenderContext as q,defaultRenderOccludedMask as L}from"../webgl-engine/lib/RenderContext.js";import{RenderSlot as I}from"../webgl-engine/lib/RenderSlot.js";import{ShadowMap as V}from"../webgl-engine/lib/ShadowMap.js";import{SortedRenderGeometryRenderer as F}from"../webgl-engine/lib/SortedRenderGeometryRenderer.js";import{TextureTechnique as N}from"../webgl-engine/lib/TextureTechnique.js";import{TextureTechniqueConfiguration as k}from"../webgl-engine/lib/TextureTechniqueConfiguration.js";import{TransparencyPassType as H}from"../webgl-engine/lib/TransparencyPassType.js";import{Update as U}from"../webgl-engine/lib/Update.js";import{UpdatePolicy as G}from"../webgl-engine/lib/UpdatePolicy.js";import{AmbientLight as z}from"../webgl-engine/lighting/Lightsources.js";import{O as B}from"../../../chunks/OverlayCompositing.glsl.js";import{OverlayCompositingTechnique as Y}from"../webgl-engine/shaders/OverlayCompositingTechnique.js";import{TaskPriority as X,noBudget as J}from"../../support/Scheduler.js";import{FramebufferBit as K,TextureSamplingMode as Q}from"../../webgl/enums.js";import{Texture as Z}from"../../webgl/Texture.js";import{TextureDescriptor as $}from"../../webgl/TextureDescriptor.js";let ee=class extends E{constructor(e){super(e),this._overlays=null,this._renderTargets=null,this._overlayParameters=new B,this.hasHighlights=!1,this._hasWater=!1,this._renderers=new Map,this._sortedDrapeSourceRenderersDirty=!1,this._sortedRenderers=new o,this._passParameters=new O,this._materials=null,this._screenToWorldRatio=1,this._localOriginFactory=null,this.unloadedMemory=0,this.ignoresMemoryFactor=!1,this._camera=new S,this.worldToPCSRatio=1,this.events=new r,this.longitudeCyclical=null,this.produces=new Map([[I.DRAPED_MATERIAL,e=>e!==C.Highlight||this.hasHighlights],[I.DRAPED_WATER,()=>this._hasWater]]),this._hasTargetWithoutRasterImage=!1,this._hasDrapedFeatureSource=!1,this._hasDrapedRasterSource=!1}initialize(){const e=this.view._stage.renderer.fboCache,r=this.view._stage.renderView,{waterTextures:t,stippleTextures:s,markerTextures:i}=r;this._techniques=new j({rctx:this._rctx,viewingMode:y.Local,stippleTextures:s,markerTextures:i,waterTextures:t}),this._renderContext=new q(this._rctx,new V(e,this.view.state.viewingMode),null),this.addHandles([n((()=>t.updating),(()=>this.events.emit("content-changed")),h),n((()=>this.spatialReference),(e=>this._localOriginFactory=new M(e)),h),d((()=>this.view.allLayerViews),"after-changes",(()=>this._sortedDrapeSourceRenderersDirty=!0))]),this._materials=new W(r.textures,this._techniques,(()=>{this.notifyChange("rendersOccludedDraped"),this.events.emit("content-changed"),this.notifyChange("updating"),this.notifyChange("isEmpty")}),(()=>this.events.emit("content-changed"))),this._bindParameters.slot=I.DRAPED_MATERIAL,this._bindParameters.mainDepth=null,this._camera.near=1,this._camera.far=1e4,this._camera.relativeElevation=null,this._bindParameters.camera=this._camera,this._bindParameters.transparencyPassType=H.NONE,this._bindParameters.updateLighting([new z(g(1,1,1))],0,0,U.Immediate),this.addHandles(this.view.resourceController.scheduler.registerTask(X.STAGE,this))}destroy(){this._renderers.forEach((e=>e.destroy())),this._renderers.clear(),this._debugTextureTechnique=s(this._debugTextureTechnique),this._passParameters.texture=i(this._passParameters.texture),this._techniques=a(this._techniques),this.disposeOverlays()}get _bindParameters(){return this._renderContext.bindParameters}get _rctx(){return this.view._stage.renderView.renderingContext}get rctx(){return this._rctx}get materials(){return this._materials}get screenToWorldRatio(){return this._screenToWorldRatio}get localOriginFactory(){return this._localOriginFactory}initializeRenderContext(e){this.pluginContext=e}uninitializeRenderContext(){}renderNode(){}get updating(){return this._sortedDrapeSourceRenderersDirty||t(this._renderers,(e=>e.updating))}get hasOverlays(){return null!=this._overlays&&null!=this._renderTargets}getMaterialRenderer(e){for(const r of this._renderers.values()){const t=r.getMaterialRenderer(e);if(t)return t}return null}get layers(){return this._sortedDrapeSourceRenderersDirty&&this._updateSortedDrapeSourceRenderers(),this._sortedRenderers.map((e=>e.drapeSource.layer)).filter((e=>!!e))}createGeometryDrapeSourceRenderer(e){return this.createDrapeSourceRenderer(e,F)}createDrapeSourceRenderer(e,r,t){const s=this._renderers.get(e);null!=s&&s.destroy();const i=new r({...t,rendererContext:this,drapeSource:e});return this._renderers.set(e,i),this._sortedDrapeSourceRenderersDirty=!0,"fullOpacity"in e&&this.addHandles(n((()=>e.fullOpacity),(()=>this.events.emit("content-changed"))),e),i}removeDrapeSourceRenderer(e){if(null==e)return;const r=this._renderers.get(e);null!=r&&(this._sortedDrapeSourceRenderersDirty=!0,this._renderers.delete(e),this.removeHandles(e),r.destroy())}computeValidity(){return this._renderTargets?.computeValidity()??0}releaseRenderTargets(){this._renderTargets?.dispose()}get overlays(){return this._overlays??[]}ensureDrapeTargets(e){this._hasTargetWithoutRasterImage=!!this._overlays&&l(e,(e=>e.drapeTargetType===f.WithoutRasterImage))}ensureDrapeSources(e){this._overlays?(this._hasDrapedFeatureSource=l(e,(e=>e.drapeSourceType===R.Features)),this._hasDrapedRasterSource=l(e,(e=>e.drapeSourceType===R.RasterImage))):this._hasDrapedFeatureSource=this._hasDrapedRasterSource=!1}get _needsColorWithoutRasterImage(){return this._hasDrapedRasterSource&&this._hasDrapedFeatureSource&&this._hasTargetWithoutRasterImage}ensureOverlays(e,r,t=this._bindParameters.overlayStretch){null==this._overlays&&(this._renderTargets=new D(this.view._stage.renderer.fboCache),this._overlays=[new x,new x]),this.ensureDrapeTargets(e),this.ensureDrapeSources(r),this._bindParameters.overlayStretch=t}disposeOverlays(){this._overlays=null,this._renderTargets=i(this._renderTargets),this.events.emit("textures-disposed")}getTexture(e){if(null!=e)return e===v.ColorNoRasterImage&&!this._needsColorWithoutRasterImage&&this._hasDrapedFeatureSource?this._renderTargets?.getTexture(v.Color):this._renderTargets?.getTexture(e)}get running(){return this.updating}runTask(e){this._processDrapeSources(e,(()=>!0))}_processDrapeSources(e,r){let s=!1;for(const[t,i]of this._renderers){if(e.done)break;(t.destroyed||r(t))&&(i.commitChanges()&&(s=!0,e.madeProgress()))}this._sortedDrapeSourceRenderersDirty&&(this._sortedDrapeSourceRenderersDirty=!1,s=!0,this._updateSortedDrapeSourceRenderers()),s&&(null!=this._overlays&&0===this._renderers.size&&this.disposeOverlays(),this.notifyChange("updating"),this.notifyChange("isEmpty"),this.events.emit("content-changed"),this.hasHighlights=t(this._renderers,(e=>e.hasHighlights)),this.notifyChange("rendersOccludedDraped"),this._updateHasWater())}processSyncDrapeSources(){this._processDrapeSources(J,(e=>e.updatePolicy===G.SYNC))}get isEmpty(){return!b.OVERLAY_DRAW_DEBUG_TEXTURE&&!t(this._renderers,(e=>!e.isEmpty))}get hasWater(){return this._hasWater}get rendersOccludedDraped(){const e=this._renderContext.renderOccludedMask;this._renderContext.renderOccludedMask=ie;const r=this._sortedRenderers.some((({renderer:e})=>e.shouldRender(this._renderContext)));return this._renderContext.renderOccludedMask=e,r}renders(e){return b.OVERLAY_DRAW_DEBUG_TEXTURE&&e!==v.Occluded||this._sortedRenderers.some((({renderer:e})=>e.shouldRender(this._renderContext)))}get mode(){return this.isEmpty?P.Disabled:this._renderTargets?.getTexture(v.WaterNormal)?P.EnabledWithWater:this._renderTargets?.getTexture(v.Color)?P.Enabled:P.Disabled}updateAnimation(e){let r=!1;return this._renderers.forEach((t=>r=t.updateAnimation(e)||r)),r}updateDrapeSourceOrder(){this._sortedDrapeSourceRenderersDirty=!0}drawOverlays(e){if(this._overlays&&this._renderTargets){for(const e of this._overlays)this.longitudeCyclical?e.setupGeometryViewsCyclical(this.longitudeCyclical):e.setupGeometryViewsDirect();for(const r of this._renderTargets.targets){if(r.content===v.ColorNoRasterImage&&!this._needsColorWithoutRasterImage)continue;const t=this._drawTarget(w.INNER,r,e),s=this._drawTarget(w.OUTER,r,e);(t||s)&&r.fbo.generateMipMap()}}}_drawTarget(e,r,t){const s=this._overlays[e],i=s.canvasGeometries;if(0===i.numViews)return!1;const{alignPixelEnabled:a,contentPixelRatio:o}=t;this._screenToWorldRatio=o*s.mapUnitsPerPixel/this._bindParameters.overlayStretch;const n=r.output;if(this.isEmpty||n===C.Highlight&&!this.hasHighlights||n===C.Normal&&!this.hasWater||!s.hasSomeSizedView())return!1;const h=this._rctx;if(this._camera.pixelRatio=s.pixelRatio*o,this._renderContext.output=n,this._bindParameters.alignPixelEnabled=a,this._bindParameters.screenToWorldRatio=this._screenToWorldRatio,this._bindParameters.screenToPCSRatio=this._screenToWorldRatio*this.worldToPCSRatio,this._bindParameters.slot=n===C.Normal?I.DRAPED_WATER:I.DRAPED_MATERIAL,r.content===v.Occluded&&(this._renderContext.renderOccludedMask=ie),!this.renders(r.content))return this._renderContext.renderOccludedMask=L,!1;const d=s.resolution;this._rctx.setViewport(e===w.INNER?0:d,0,d,d);const l=2*s.resolution,c=s.resolution,u=r.fbo;u.bind(h,l,c),e===w.INNER&&(h.setClearColor(0,0,0,0),h.clear(K.COLOR));if(b.OVERLAY_DRAW_DEBUG_TEXTURE&&r.content!==v.Occluded)for(let p=0;p<i.numViews;p++)this._setViewParameters(i.extents[p],s),this._ensureDebugPatternResources(s.resolution,te[e]),this._rctx.bindTechnique(this._debugTextureTechnique,this._renderContext.bindParameters,this._passParameters),this._rctx.screen.draw();return this._sortedRenderers.forAll((({drapeSource:t,renderer:a})=>{if(r.content===v.ColorNoRasterImage&&t.drapeSourceType===R.RasterImage)return;const{fullOpacity:o}=t,d=null!=o&&o<1&&n===C.Color?this.bindTemporaryFramebuffer(l,c):null;for(let e=0;e<i.numViews;e++)this._setViewParameters(i.extents[e],s),a.render(this._renderContext);if(d){u.bind(h,l,c),this._overlayParameters.texture=d.getTexture(),this._overlayParameters.opacity=o,this._overlayParameters.overlayIndex=e;const r=this.pluginContext.techniques.acquire(Y);this._rctx.bindTechnique(r,this._renderContext.bindParameters,this._overlayParameters),this._rctx.screen.draw(),r.release(),d.release()}})),h.bindFramebuffer(null),this._renderContext.renderOccludedMask=L,!0}bindTemporaryFramebuffer(e,r){const t=this.view._stage.renderer.fboCache,s=t.acquire(e,r,"overlay tmp");return t.rctx.bindFramebuffer(s.fbo),t.rctx.clear(K.COLOR),s}async reloadShaders(){await this._techniques.reloadAll()}notifyContentChanged(){this.events.emit("content-changed")}intersect(e,r,t,s){this._sortedDrapeSourceRenderersDirty&&this._updateSortedDrapeSourceRenderers();let i=0;for(const{renderer:a}of this._sortedRenderers)i=a.intersect?.(e,r,t,s,i)??i}_updateSortedDrapeSourceRenderers(){if(this._sortedRenderers.clear(),0===this._renderers.size)return;const e=this.view.map.allLayers,r=e.length;this._renderers.forEach(((t,s)=>{const i=e.indexOf(s.layer),a=i>=0,o=s.renderGroup??(a?T.MapLayer:T.ViewLayer),n=r*o+(a?i:0);this._sortedRenderers.push(new re(s,t,n))})),this._sortedRenderers.sort(((e,r)=>e.index-r.index))}_setViewParameters(e,r){const t=this._camera;t.viewport=[0,0,r.resolution,r.resolution],p(t.projectionMatrix,0,e[2]-e[0],0,e[3]-e[1],t.near,t.far),m(t.viewMatrix,[-e[0],-e[1],0])}_updateHasWater(){const e=t(this._renderers,(e=>e.hasWater));e!==this._hasWater&&(this._hasWater=e,this.events.emit("has-water",e))}_ensureDebugPatternResources(e,r){if(_(this._passParameters.color,r[0],r[1],r[2]),this._passParameters.texture)return;const t=new Uint8Array(e*e*4);let s=0;for(let o=0;o<e;o++)for(let r=0;r<e;r++){const i=Math.floor(r/10),a=Math.floor(o/10);i<2||a<2||10*i>e-20||10*a>e-20?(t[s++]=255,t[s++]=255,t[s++]=255,t[s++]=255):(t[s++]=255,t[s++]=255,t[s++]=255,t[s++]=1&i&&1&a?1&r^1&o?0:255:1&i^1&a?0:128)}const i=new $(e);i.samplingMode=Q.NEAREST,this._passParameters.texture=new Z(this._rctx,i,t);const a=new k;a.hasAlpha=!0,this._debugTextureTechnique=this._techniques.acquire(N,a)}get test(){}};e([c()],ee.prototype,"hasHighlights",void 0),e([c()],ee.prototype,"_sortedDrapeSourceRenderersDirty",void 0),e([c()],ee.prototype,"_techniques",void 0),e([c({constructOnly:!0})],ee.prototype,"view",void 0),e([c()],ee.prototype,"worldToPCSRatio",void 0),e([c()],ee.prototype,"spatialReference",void 0),e([c({type:Boolean,readOnly:!0})],ee.prototype,"updating",null),e([c()],ee.prototype,"isEmpty",null),e([c({readOnly:!0})],ee.prototype,"rendersOccludedDraped",null),ee=e([u("esri.views.3d.terrain.OverlayRenderer")],ee);class re{constructor(e,r,t){this.drapeSource=e,this.renderer=r,this.index=t}}const te=[[1,.5,.5],[.5,.5,1]],se=-2,ie=A.OccludeAndTransparent;export{ee as OverlayRenderer,se as drapedZ,ie as overlayRenderOccludedFlag};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import r from"../../../core/Evented.js";import"../../../core/has.js";import{someMap as t}from"../../../core/MapUtils.js";import{releaseMaybe as s,disposeMaybe as i,destroyMaybe as a}from"../../../core/maybe.js";import o from"../../../core/PooledArray.js";import{watch as n,syncAndInitial as h,on as d}from"../../../core/reactiveUtils.js";import{someSet as l}from"../../../core/SetUtils.js";import{property as c}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as u}from"../../../core/accessorSupport/decorators/subclass.js";import{ortho as p,fromTranslation as m}from"../../../core/libs/gl-matrix-2/math/mat4.js";import{a as _}from"../../../chunks/vec32.js";import{fromValues as g}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ViewingMode as y}from"../../ViewingMode.js";import{DrapeTargetType as f,DrapeSourceType as R,DrapedRenderGroup as T}from"../layers/interfaces.js";import{debugFlags as b}from"../support/debugFlags.js";import{OverlayIndex as w}from"./interfaces.js";import{Overlay as x}from"./Overlay.js";import{OverlayContent as v}from"./OverlayContent.js";import{OverlayRenderTargets as D}from"./OverlayRenderTargets.js";import S from"../webgl/RenderCamera.js";import{ShaderOutput as C}from"../webgl-engine/core/shaderLibrary/ShaderOutput.js";import{OverlayMode as P}from"../webgl-engine/core/shaderLibrary/terrain/Overlay.glsl.js";import{T as O}from"../../../chunks/TextureOnly.glsl.js";import{ShaderTechniqueRepository as j}from"../webgl-engine/core/shaderTechnique/ShaderTechniqueRepository.js";import{SyncRenderPlugin as E}from"../webgl-engine/effects/RenderPlugin.js";import{GLMaterialRepository as W}from"../webgl-engine/lib/GLMaterialRepository.js";import{GridLocalOriginFactory as M}from"../webgl-engine/lib/GridLocalOriginFactory.js";import{RenderOccludedFlag as A}from"../webgl-engine/lib/Material.js";import{OverlayRenderContext as q,defaultRenderOccludedMask as L}from"../webgl-engine/lib/RenderContext.js";import{RenderSlot as I}from"../webgl-engine/lib/RenderSlot.js";import{ShadowMap as V}from"../webgl-engine/lib/ShadowMap.js";import{SortedRenderGeometryRenderer as F}from"../webgl-engine/lib/SortedRenderGeometryRenderer.js";import{TextureTechnique as N}from"../webgl-engine/lib/TextureTechnique.js";import{TextureTechniqueConfiguration as k}from"../webgl-engine/lib/TextureTechniqueConfiguration.js";import{TransparencyPassType as H}from"../webgl-engine/lib/TransparencyPassType.js";import{Update as U}from"../webgl-engine/lib/Update.js";import{UpdatePolicy as G}from"../webgl-engine/lib/UpdatePolicy.js";import{AmbientLight as z}from"../webgl-engine/lighting/Lightsources.js";import{O as B}from"../../../chunks/OverlayCompositing.glsl.js";import{OverlayCompositingTechnique as Y}from"../webgl-engine/shaders/OverlayCompositingTechnique.js";import{TaskPriority as X,noBudget as J}from"../../support/Scheduler.js";import{FramebufferBit as K,TextureSamplingMode as Q}from"../../webgl/enums.js";import{Texture as Z}from"../../webgl/Texture.js";import{TextureDescriptor as $}from"../../webgl/TextureDescriptor.js";let ee=class extends E{constructor(e){super(e),this._overlays=null,this._renderTargets=null,this._overlayParameters=new B,this.hasHighlights=!1,this._hasWater=!1,this._renderers=new Map,this._sortedDrapeSourceRenderersDirty=!1,this._sortedRenderers=new o,this._passParameters=new O,this._materials=null,this._screenToWorldRatio=1,this._localOriginFactory=null,this.unloadedMemory=0,this.ignoresMemoryFactor=!1,this._camera=new S,this.worldToPCSRatio=1,this.events=new r,this.longitudeCyclical=null,this.produces=new Map([[I.DRAPED_MATERIAL,e=>e!==C.Highlight||this.hasHighlights],[I.DRAPED_WATER,()=>this._hasWater]]),this._hasTargetWithoutRasterImage=!1,this._hasDrapedFeatureSource=!1,this._hasDrapedRasterSource=!1}initialize(){const e=this.view._stage.renderer.fboCache,r=this.view._stage.renderView,{waterTextures:t,stippleTextures:s,markerTextures:i}=r;this._techniques=new j({rctx:this._rctx,viewingMode:y.Local,stippleTextures:s,markerTextures:i,waterTextures:t}),this._renderContext=new q(this._rctx,new V(e,this.view.state.viewingMode),null),this.addHandles([n((()=>t.updating),(()=>this.events.emit("content-changed")),h),n((()=>this.spatialReference),(e=>this._localOriginFactory=new M(e)),h),d((()=>this.view.allLayerViews),"after-changes",(()=>this._sortedDrapeSourceRenderersDirty=!0))]),this._materials=new W(r.textures,this._techniques,(()=>{this.notifyChange("rendersOccludedDraped"),this.events.emit("content-changed"),this.notifyChange("updating"),this.notifyChange("isEmpty")}),(()=>this.events.emit("content-changed"))),this._bindParameters.slot=I.DRAPED_MATERIAL,this._bindParameters.mainDepth=null,this._camera.near=1,this._camera.far=1e4,this._camera.relativeElevation=null,this._bindParameters.camera=this._camera,this._bindParameters.transparencyPassType=H.NONE,this._bindParameters.updateLighting([new z(g(1,1,1))],0,0,U.Immediate),this.addHandles(this.view.resourceController.scheduler.registerTask(X.STAGE,this))}destroy(){this._renderers.forEach((e=>e.destroy())),this._renderers.clear(),this._debugTextureTechnique=s(this._debugTextureTechnique),this._passParameters.texture=i(this._passParameters.texture),this._techniques=a(this._techniques),this.disposeOverlays()}get _bindParameters(){return this._renderContext.bindParameters}get _rctx(){return this.view._stage.renderView.renderingContext}get rctx(){return this._rctx}get materials(){return this._materials}get screenToWorldRatio(){return this._screenToWorldRatio}get localOriginFactory(){return this._localOriginFactory}initializeRenderContext(e){this.pluginContext=e}uninitializeRenderContext(){}renderNode(){}get updating(){return this._sortedDrapeSourceRenderersDirty||t(this._renderers,(e=>e.updating))}get hasOverlays(){return null!=this._overlays&&null!=this._renderTargets}getMaterialRenderer(e){for(const r of this._renderers.values()){const t=r.getMaterialRenderer(e);if(t)return t}return null}get layers(){return this._sortedDrapeSourceRenderersDirty&&this._updateSortedDrapeSourceRenderers(),this._sortedRenderers.map((e=>e.drapeSource.layer)).filter((e=>!!e))}createGeometryDrapeSourceRenderer(e){return this.createDrapeSourceRenderer(e,F)}createDrapeSourceRenderer(e,r,t){const s=this._renderers.get(e);null!=s&&s.destroy();const i=new r({...t,rendererContext:this,drapeSource:e});return this._renderers.set(e,i),this._sortedDrapeSourceRenderersDirty=!0,"fullOpacity"in e&&this.addHandles(n((()=>e.fullOpacity),(()=>this.events.emit("content-changed"))),e),i}removeDrapeSourceRenderer(e){if(null==e)return;const r=this._renderers.get(e);null!=r&&(this._sortedDrapeSourceRenderersDirty=!0,this._renderers.delete(e),this.removeHandles(e),r.destroy())}computeValidity(){return this._renderTargets?.computeValidity()??0}releaseRenderTargets(){this._renderTargets?.dispose()}get overlays(){return this._overlays??[]}ensureDrapeTargets(e){this._hasTargetWithoutRasterImage=!!this._overlays&&l(e,(e=>e.drapeTargetType===f.WithoutRasterImage))}ensureDrapeSources(e){this._overlays?(this._hasDrapedFeatureSource=l(e,(e=>e.drapeSourceType===R.Features)),this._hasDrapedRasterSource=l(e,(e=>e.drapeSourceType===R.RasterImage))):this._hasDrapedFeatureSource=this._hasDrapedRasterSource=!1}get _needsColorWithoutRasterImage(){return this._hasDrapedRasterSource&&this._hasDrapedFeatureSource&&this._hasTargetWithoutRasterImage}ensureOverlays(e,r,t=this._bindParameters.overlayStretch){null==this._overlays&&(this._renderTargets=new D(this.view._stage.renderer.fboCache),this._overlays=[new x,new x]),this.ensureDrapeTargets(e),this.ensureDrapeSources(r),this._bindParameters.overlayStretch=t}disposeOverlays(){this._overlays=null,this._renderTargets=i(this._renderTargets),this.events.emit("textures-disposed")}getTexture(e){if(null!=e)return e===v.ColorNoRasterImage&&!this._needsColorWithoutRasterImage&&this._hasDrapedFeatureSource?this._renderTargets?.getTexture(v.Color):this._renderTargets?.getTexture(e)}get running(){return this.updating}runTask(e){this._processDrapeSources(e,(()=>!0))}_processDrapeSources(e,r){let s=!1;for(const[t,i]of this._renderers){if(e.done)break;(t.destroyed||r(t))&&(i.commitChanges()&&(s=!0,e.madeProgress()))}this._sortedDrapeSourceRenderersDirty&&(this._sortedDrapeSourceRenderersDirty=!1,s=!0,this._updateSortedDrapeSourceRenderers()),s&&(null!=this._overlays&&0===this._renderers.size&&this.disposeOverlays(),this.notifyChange("updating"),this.notifyChange("isEmpty"),this.events.emit("content-changed"),this.hasHighlights=t(this._renderers,(e=>e.hasHighlights)),this.notifyChange("rendersOccludedDraped"),this._updateHasWater())}processSyncDrapeSources(){this._processDrapeSources(J,(e=>e.updatePolicy===G.SYNC))}get isEmpty(){return!b.OVERLAY_DRAW_DEBUG_TEXTURE&&!t(this._renderers,(e=>!e.isEmpty))}get hasWater(){return this._hasWater}get rendersOccludedDraped(){const e=this._renderContext.renderOccludedMask;this._renderContext.renderOccludedMask=ie;const r=this._sortedRenderers.some((({renderer:e})=>e.shouldRender(this._renderContext)));return this._renderContext.renderOccludedMask=e,r}renders(e){return b.OVERLAY_DRAW_DEBUG_TEXTURE&&e!==v.Occluded||this._sortedRenderers.some((({renderer:e})=>e.shouldRender(this._renderContext)))}get mode(){return this.isEmpty?P.Disabled:this._renderTargets?.getTexture(v.WaterNormal)?P.EnabledWithWater:this._renderTargets?.getTexture(v.Color)?P.Enabled:P.Disabled}updateAnimation(e){let r=!1;return this._renderers.forEach((t=>r=t.updateAnimation(e)||r)),r}updateDrapeSourceOrder(){this._sortedDrapeSourceRenderersDirty=!0}drawOverlays(e){if(this._overlays&&this._renderTargets){for(const e of this._overlays)this.longitudeCyclical?e.setupGeometryViewsCyclical(this.longitudeCyclical):e.setupGeometryViewsDirect();for(const r of this._renderTargets.targets){if(r.content===v.ColorNoRasterImage&&!this._needsColorWithoutRasterImage)continue;const t=this._drawTarget(w.INNER,r,e),s=this._drawTarget(w.OUTER,r,e);(t||s)&&r.fbo.generateMipMap()}}}_drawTarget(e,r,t){const s=this._overlays[e],i=s.canvasGeometries;if(0===i.numViews)return!1;const{alignPixelEnabled:a,contentPixelRatio:o}=t;this._screenToWorldRatio=o*s.mapUnitsPerPixel/this._bindParameters.overlayStretch;const n=r.output;if(this.isEmpty||n===C.Highlight&&!this.hasHighlights||n===C.Normal&&!this.hasWater||!s.hasSomeSizedView())return!1;const h=this._rctx;if(this._camera.pixelRatio=s.pixelRatio*o,this._renderContext.output=n,this._bindParameters.alignPixelEnabled=a,this._bindParameters.screenToWorldRatio=this._screenToWorldRatio,this._bindParameters.screenToPCSRatio=this._screenToWorldRatio*this.worldToPCSRatio,this._bindParameters.slot=n===C.Normal?I.DRAPED_WATER:I.DRAPED_MATERIAL,r.content===v.Occluded&&(this._renderContext.renderOccludedMask=ie),!this.renders(r.content))return this._renderContext.renderOccludedMask=L,!1;const d=s.resolution;this._rctx.setViewport(e===w.INNER?0:d,0,d,d);const l=2*s.resolution,c=s.resolution,u=r.fbo;u.bind(h,l,c),e===w.INNER&&(h.setClearColor(0,0,0,0),h.clear(K.COLOR));if(b.OVERLAY_DRAW_DEBUG_TEXTURE&&r.content!==v.Occluded)for(let p=0;p<i.numViews;p++)this._setViewParameters(i.extents[p],s),this._ensureDebugPatternResources(s.resolution,te[e]),this._rctx.bindTechnique(this._debugTextureTechnique,this._renderContext.bindParameters,this._passParameters),this._rctx.screen.draw();return this._sortedRenderers.forAll((({drapeSource:t,renderer:a})=>{if(r.content===v.ColorNoRasterImage&&t.drapeSourceType===R.RasterImage)return;const{fullOpacity:o}=t,d=null!=o&&o<1&&n===C.Color?this.bindTemporaryFramebuffer(l,c):null;for(let e=0;e<i.numViews;e++)this._setViewParameters(i.extents[e],s),a.render(this._renderContext);if(d){u.bind(h,l,c),this._overlayParameters.texture=d.getTexture(),this._overlayParameters.opacity=o,this._overlayParameters.overlayIndex=e;const r=this.pluginContext.techniques.acquire(Y);this._rctx.bindTechnique(r,this._renderContext.bindParameters,this._overlayParameters),this._rctx.screen.draw(),r.release(),d.release()}})),h.bindFramebuffer(null),this._renderContext.renderOccludedMask=L,!0}bindTemporaryFramebuffer(e,r){const t=this.view._stage.renderer.fboCache,s=t.acquire(e,r,"overlay tmp");return t.rctx.bindFramebuffer(s.fbo),t.rctx.clear(K.COLOR),s}async reloadShaders(){await this._techniques.reloadAll()}notifyContentChanged(){this.events.emit("content-changed")}intersect(e,r,t,s){this._sortedDrapeSourceRenderersDirty&&this._updateSortedDrapeSourceRenderers();let i=0;for(const{renderer:a}of this._sortedRenderers)i=a.intersect?.(e,r,t,s,i)??i}_updateSortedDrapeSourceRenderers(){if(this._sortedRenderers.clear(),0===this._renderers.size)return;const e=this.view.map.allLayers,r=e.length;this._renderers.forEach(((t,s)=>{const i=e.indexOf(s.layer),a=i>=0,o=s.renderGroup??(a?T.MapLayer:T.ViewLayer),n=r*o+(a?i:0);this._sortedRenderers.push(new re(s,t,n))})),this._sortedRenderers.sort(((e,r)=>e.index-r.index))}_setViewParameters(e,r){const t=this._camera;t.viewport=[0,0,r.resolution,r.resolution],p(t.projectionMatrix,0,e[2]-e[0],0,e[3]-e[1],t.near,t.far),m(t.viewMatrix,[-e[0],-e[1],0])}_updateHasWater(){const e=t(this._renderers,(e=>e.hasWater));e!==this._hasWater&&(this._hasWater=e,this.events.emit("has-water",e))}_ensureDebugPatternResources(e,r){if(_(this._passParameters.color,r[0],r[1],r[2]),this._passParameters.texture)return;const t=new Uint8Array(e*e*4);let s=0;for(let o=0;o<e;o++)for(let r=0;r<e;r++){const i=Math.floor(r/10),a=Math.floor(o/10);i<2||a<2||10*i>e-20||10*a>e-20?(t[s++]=255,t[s++]=255,t[s++]=255,t[s++]=255):(t[s++]=255,t[s++]=255,t[s++]=255,t[s++]=1&i&&1&a?1&r^1&o?0:255:1&i^1&a?0:128)}const i=new $(e);i.samplingMode=Q.NEAREST,this._passParameters.texture=new Z(this._rctx,i,t);const a=new k;a.hasAlpha=!0,this._debugTextureTechnique=this._techniques.acquire(N,a)}get test(){}};e([c()],ee.prototype,"hasHighlights",void 0),e([c()],ee.prototype,"_sortedDrapeSourceRenderersDirty",void 0),e([c()],ee.prototype,"_techniques",void 0),e([c({constructOnly:!0})],ee.prototype,"view",void 0),e([c()],ee.prototype,"worldToPCSRatio",void 0),e([c()],ee.prototype,"spatialReference",void 0),e([c({type:Boolean,readOnly:!0})],ee.prototype,"updating",null),e([c()],ee.prototype,"isEmpty",null),e([c({readOnly:!0})],ee.prototype,"rendersOccludedDraped",null),ee=e([u("esri.views.3d.terrain.OverlayRenderer")],ee);class re{constructor(e,r,t){this.drapeSource=e,this.renderer=r,this.index=t}}const te=[[1,.5,.5],[.5,.5,1]],se=-2,ie=A.OccludeAndTransparent;export{ee as OverlayRenderer,se as drapedZ,ie as overlayRenderOccludedFlag};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.31/esri/copyright.txt for details.
4
4
  */
5
- import{equals as e}from"../../../core/arrayUtils.js";import"../../../core/has.js";import{isPowerOfTwo as t}from"../../../core/mathUtils.js";import{disposeMaybe as r}from"../../../core/maybe.js";import{p as i,F as s,G as o,f as a,n,m as l,z as g,H as d}from"../../../chunks/vec32.js";import{create as h,clone as m}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{containsXY as u}from"../../../geometry/support/aaBoundingRect.js";import{earth as c}from"../../../geometry/support/Ellipsoid.js";import{glLayout as f}from"../support/buffer/glUtil.js";import{GeometryState as p}from"./GeometryState.js";import{TextureUpdate as y}from"./interfaces.js";import{LayerClass as x}from"./LayerClass.js";import{NeighborIndex as _}from"./NeighborIndex.js";import{PatchGeometry as v}from"./PatchGeometry.js";import{maxTileNeighborLevelDelta as E}from"./TerrainConst.js";import{enableTerrainInternalChecks as $,internalAssert as S,neighborEdgeIndices as C,oppositeEdge as D,neighborCornerIndices as b,v32s as T,lij2s as j}from"./terrainUtils.js";import{TextureFader as R,ActivationTime as A}from"./TextureFader.js";import{TextureReference as V}from"./TextureReference.js";import w from"./TileOverlayData.js";import{fallsWithinLayerView as N}from"./tileUtils.js";import{VertexArrayObject as F}from"../webgl-engine/lib/VertexArrayObject.js";import{terrainVertexAttributeLocations as P}from"../webgl-engine/shaders/TerrainTechnique.js";import{BufferObject as G}from"../../webgl/BufferObject.js";import{PixelFormat as O}from"../../webgl/enums.js";class I{constructor(){this.geometry=new v,this.intersectionData=null,this.geometryState=null,this._vao=null,this._texture=null,this._textureOpacity=1,this._textureRef=new R((()=>this._tile.surface.fadeDuration)),this.overlay=new w,this._localOrigin=null,this._geometryStateChangedSinceLastUpdate=!0,this._hasGeometry=!1,this._modifiedFlags=0}get tile(){return this._tile}get localOrigin(){return this._localOrigin}init(e,t){this.clear(),this._tile=e,this.geometry.reset(),this.intersectionData=null,this.geometryState=new p,this._localOrigin=t,this.overlay.clear()}clear(){this.releaseGeometry(),this.releaseTexture(),this._textureRef.clear(),this._tile=null,this.intersectionData=null,this.geometryState=null}updateGeometryIfNeeded(e){if((!this._vao||this._geometryStateChangedSinceLastUpdate||this.wireframeChanged||this.clippingAreaChanged||this.samplerDataChanged||this.numVerticesPerSideChanged||this.dirtyCorners||this.dirtyEdgeResolutions||this.dirtyEdges)&&(this._updateGeometry(e),this._geometryStateChangedSinceLastUpdate=!1),$&&this.tile.intersectsClippingArea)for(let t=0;t<4;++t)S(this.geometry.getEdgeCount(t)===this.geometryState.edgeResolutions[t]+1)}_calculateEdgeResolution(e,t){const r=this.tile,i=this.geometryState.numVerticesPerSide-1;if(!r.surface.isGlobal){const t=r.surface.extent;if(null!=t&&(0===e&&r.extent[3]>t[3]||1===e&&r.extent[2]>t[2]||2===e&&r.extent[1]<t[1]||3===e&&r.extent[0]<t[0]))return i}const s=r.level,o=C[e];if(!t)return S(null==r.surface?.rootTiles||r.surface.updatingRootTiles||!r.shouldHaveNeighbor(o)),i;if(t.loaded){const r=t,o=r.renderData.geometryState,a=s-r.level;if(S(a>=0),0===a){const e=o.numVerticesPerSide-1;return Math.max(e,i)}const n=2**a,l=o.edgeResolutions[(e+2)%4]/n;return Math.max(1,l)}S(!t.leaf);let a=i;return t.forAllSubtreeOnSide(D(o),(e=>e===r||(e.loaded?(a=Math.max(a,2**(e.level-s)),!0):(S(!e.leaf),!1)))),a}updateNeighborData(){const e=this.tile;if(!e.intersectsClippingArea)return;const r=e.renderData.geometryState,i=t=>(t.loaded||t.level===e.level)&&t?.intersectsClippingArea,s=r.edgePeerNeighbors,o=r.edgePeerNeighborSamplerVersions;for(let a=0;a<4;++a){const n=e.findNeighborTile(C[a],i),l=q(e,n),g=l?.renderData?.geometryState.samplerDataVersion??-1,d=s[a],h=l!==q(e,d),m=o[a]!==g;$&&n&&(S(e.level>=n.level),S(e.level-n.level<=E)),s[a]=n,(h||m)&&(o[a]=g,this._markEdgeDirty(a));const u=r.edgeResolutions[a],c=this._calculateEdgeResolution(a,n);S(t(c)),S(c>=1),r.edgeResolutions[a]=c,u!==c&&this._markEdgeResolutionDirty(a)}for(let t=0;t<4;++t){const o=e.findNeighborTile(b[t],i);r.cornerPeerNeighbors[t]=o;const a=q(e,s[t]),n=q(e,s[(t+1)%4]),l=q(e,o);W[t]=l,W[(t+1)%4]=n,W[(t+2)%4]=e,W[(t+3)%4]=a,S(W.some((t=>t?.loaded||t===e)));const g=W.reduce(((e,t)=>Math.min(e,t?.level??1/0)),1/0);W.forEach(((e,t)=>{e&&e?.level>g&&(W[t]=null)})),S(W.some((t=>t?.loaded||t===e)));const d=r.cornerNeighborCornerTiles,h=r.cornerNeighborCornerTileSamplerVersions;for(let e=0;e<4;++e){const r=W[e],i=r?.renderData.geometryState.samplerDataVersion??-1,s=4*t+e,o=d[s]!==r,a=!o&&h[s]!==i;(o||a)&&(d[s]=r,h[s]=i,this._markCornerDirty(t))}$&&S(te.some((r=>d[4*t+r]?.loaded||d[4*t+r]===e)))}$&&S(this.geometryState.edgeResolutions.every((e=>e>0)));for(let t=0;t<4;++t)W[t]=null}_updateGeometry(e){if(!this.tile.intersectsClippingArea)return;$&&S(!this.tile.intersectsClippingArea||this.geometryState.edgeResolutions.every((e=>e>0))),this.intersectionData=null;const{tile:t,_vao:r,geometry:i,geometryState:s}=this,o=!r||!{geometry:i}||this.wireframeChanged||this.samplerDataChanged||this.clippingAreaChanged||this.numVerticesPerSideChanged,a=0!==this.dirtyEdgeResolutions,n=s.edgeResolutions.reduce(((e,t)=>e+t+1),0),l=o||a&&n>(i?.maxEdgeVertexCount??0),g=!l&&a,d=!g&&(0!==this.dirtyEdges||a),h=!d&&0!==this.dirtyCorners;l?(this.releaseGeometry(),this._createGeometry(e)):g?t.updateEdgeElevationsAndResolutions():d||h?t.updateEdgeElevations():h?t.updateCornerElevations():console.warn("Update for no reason?"),this._modifiedFlags=0}get hasGeometry(){return this._hasGeometry}releaseGeometry(){return this._hasGeometry=!1,this.intersectionData=null,!!this._vao&&(this._vao=r(this._vao),this.geometry.release(),!0)}ensureTexture(e,t,r,i){const s=t?O.RGBA:O.RGB;return null!=this._texture&&(r===y.FADING&&this._tile.surface.fadeDuration>0&&this._isTextureVisible(this._texture)||this._texture.descriptor.width!==e||this._texture.descriptor.pixelFormat!==s)&&this.releaseTexture(),null==this._texture&&(this._texture=i(),this.tile.setMemoryDirty()),this._texture}releaseTexture(){null!=this._texture&&(this._texture.release(),this._texture=null,this.tile.setMemoryDirty())}reuseTexture(e,t){return!(!e||!this._texture)&&(e.setTextureReference(new V(this._texture,y.FADING,t,this._textureOpacity,0,1)),!0)}get numVerticesPerSideChanged(){return!!(this._modifiedFlags&z)}get samplerDataChanged(){return!!(this._modifiedFlags&J)}get clippingAreaChanged(){return!!(this._modifiedFlags&K)}get wireframeChanged(){return!!(this._modifiedFlags&Q)}get dirtyEdges(){return this._modifiedFlags>>Y&15}get dirtyCorners(){return this._modifiedFlags>>Z&15}get dirtyEdgeResolutions(){return this._modifiedFlags>>ee&15}_markCornerDirty(e){const t=1<<e<<Z;this._modifiedFlags|=t}_markEdgeDirty(e){const t=1<<e<<Y;this._modifiedFlags|=t,this._markCornerDirty((e+0)%4),this._markCornerDirty((e+3)%4)}_markEdgeResolutionDirty(e){const t=1<<e<<ee;this._modifiedFlags|=t,this._markEdgeDirty(e)}_markAllEdgesAndCornersDirty(){this._modifiedFlags|=15<<Z|15<<Y|15<<ee}updateGeometryState(){const t=this._getElevationInfo(),r=this.tile,i=t.samplerData?r.getElevationVerticesPerSide(t.maxTileLevel):r.getDefaultVerticesPerSide(),s=Math.max(i,5);let o=r.clippingArea;r.intersectsClippingArea&&!r.withinClippingArea||(o=null);const a=this.geometryState;let n=!1;a.numVerticesPerSide!==s&&(this._modifiedFlags|=1,a.numVerticesPerSide=s,a.samplerDataVersion++,n=!0),t.changed&&(this._modifiedFlags|=2,a.samplerData=t.samplerData,a.samplerDataVersion++,n=!0),e(a.clippingArea,o)||(this._modifiedFlags=4,a.clippingArea=o,n=!0);const l=r.surface.wireframe;return a.wireframe!==l&&(this._modifiedFlags=8,a.wireframe=l,n=!0),this._geometryStateChangedSinceLastUpdate||=n,n&&this._markAllEdgesAndCornersDirty(),this._hasGeometry=!0,this._geometryStateChangedSinceLastUpdate}_createGeometry(e){this.tile.createGeometry();const t=this.geometry.vertexAttributes,r=this.geometry.indices,i=e.gl;this._vao=new F(e,P,new Map([["geometry",f(t.layout)]]),new Map([["geometry",G.createVertex(e,i.STATIC_DRAW,t.buffer)]]),G.createIndex(e,i.STATIC_DRAW,r)),this._hasGeometry=!0}get vao(){return this._vao}setTextureReference(e,t=A.Immediate){e?.texture===this._texture?this._textureOpacity=e.opacities[0]:this.releaseTexture(),this._textureRef.push(e,t)}get textureReference(){return this._textureRef.current}get nextTextureReference(){return this._textureRef.next}get textureFadeFactor(){return this._textureRef.fadeFactor}get textureIsFading(){return this._textureRef.isFading}_isTextureVisible(e){return this._textureRef.current?.texture===e||this._textureRef.next?.texture===e&&this._textureRef.fadeFactor<1}_getElevationInfo(){const e=this.geometryState.samplerData,t=this.tile.layerInfo[x.ELEVATION],r=t.length,i=new Array(r);let s=0,o=0,a=!1;for(let g=0;g<r;g++){const r=t[g],n=r.upsampleInfo?.tile;if(n){const t=n.layerInfo[x.ELEVATION][g].data,r=t&&t.samplerData;e&&e[s]===r||(a=!0),i[s++]=r,o=Math.max(o,n.lij[0])}else if(r.data){const t=this.tile.surface.layerViewByIndex(g,x.ELEVATION);if(N(this.tile,t)){const t=r.data;e&&e[s]===t.samplerData||(a=!0),i[s++]=t.samplerData,o=this.tile.level}}}null!=e&&e.length!==s&&(a=!0);const n=s>0,l=n?i:null;return n&&(i.length=s),{changed:a,samplerData:l,maxTileLevel:o}}get estimatedGeometryMemoryUsage(){const e=this.intersectionData?.estimatedMemoryUsage??0;return(this.geometry.indices?.byteLength??0)+(this.geometry.vertexAttributes?.byteLength??0)+e}get texture(){return this._texture}get test(){}checkGeometryWaterproofness(){if(!$)return;const e=this.tile;if(!e.loaded||!e.intersectsClippingArea||0===e.level)return void S(e?.loaded);const r=e.surface.extent;if(null!=r&&!e.intersectsExtent(r))return;const f=C.map(((t,i)=>null!=r&&(i<2?-1:1)*(e.extent[3-i]-r[3-i])<0)),p=e.level;S(0===this.dirtyCorners),S(0===this.dirtyEdges),S(0===this.dirtyEdgeResolutions),S(!this.numVerticesPerSideChanged),S(!this.samplerDataChanged),S(!this.clippingAreaChanged),S(!this.wireframeChanged);const y=b.map((t=>e.findNeighborCornerTileExact(t,(t=>!t.intersectsClippingArea||t.loaded||t.level===e.level))??null)).map((e=>e?.intersectsClippingArea?e:null)),x=this.geometryState;for(let t=0;t<4;++t){const r=x.cornerPeerNeighbors[t],i=y[t];S(i===r,`Tile[${e.lij}].corner[${t}] out of date: cur=[${r?.lij}] exp=[${i?.lij}]`)}C.forEach(((r,y)=>{if(f[y])return;const x=e.findNeighborTile(r,(e=>(e.level===p||e?.loaded)&&e?.intersectsClippingArea));if(!x){const t=!e.surface.updatingRootTiles&&null!=e.surface.rootTiles&&e.surface.rootTiles.length>0&&e.shouldHaveNeighbor(r);return void S(!t)}S(x.loaded||x.level===e.level),S(x===this.geometryState.edgePeerNeighbors[y]);const v=p-x.level;if(!x.loaded)return S(!x.leaf),void S(0===v);const E=x.renderData;S(e.isEdgeNeighbor(x,r)),S(v>=0);const $=2**v;if(v<0)return void S(!1);const C=e.renderData,D=C.geometry,b=C.localOrigin,R=D.getEdgeCount(y),A=D.numVerticesPerSide-1,V=E.geometry;if(!V)return void S(!1);const w=E.localOrigin,N=this.geometryState.edgePeerNeighbors[y];if(N?.loaded){const e=N.renderData;S(C.geometryState.edgePeerNeighborSamplerVersions[y]===e.geometryState.samplerDataVersion),S(this.geometryState.edgePeerNeighborSamplerVersions[y]===e.geometryState.samplerDataVersion)}const F=(y+2)%4,P=V.getEdgeCount(F),G=R-1,O=P-1;S(G*$===O,`Tile[${e.lij}]:e${y},res=${G} edgeRes mismatch with Neighbor[${x.lij}]:e${F},res=${O} (expected:${G*$})`);const I=e.extent,W=r===_.NORTH||r===_.SOUTH,q=P-1,z=q>>v,J=R-1;if(z<1)return void S(1===J);S(z===J),S(t(z));const K=V.numVerticesPerSide-1;S(v>0||z===Math.max(K,A));const Q=e.getNeighborEdgeStartVertexIndex(y,x);S(0<=Q&&Q<$);const Y=Q*z;S(0<=Y&&Y<=q-z);let Z=0,ee=Y;D.getEdgeVertexPosition(y,M,b,0),D.getEdgeVertexPosition(y,U,b,R-1);const te=i(M,U),re=Math.max(B,1e-4*te);for(let t=0;t<=z;++t){D.getEdgeVertexPosition(y,M,b,Z),V.getEdgeVertexPosition(F,U,w,ee);const i=t/z,f=W?I[0]+i*(I[2]-I[0]):r===_.WEST?I[0]:I[2],p=W?r===_.SOUTH?I[1]:I[3]:I[1]+i*(I[3]-I[1]),v=e.surface.extent;if(null==v||u(v,f,p)){const t=s(M,U),r=o(M)-c.radius,i=o(U)-c.radius,u=t<re;if(!u){console.warn(`Tile edge vertex position mismatch: between [${e.lij}].edge${y}[${Z}/${R}] and [${x.lij}].edge${F}[${ee}/${P}]`),null!=v&&console.warn(" surface extent= ",v," x,y=",f,",",p);const s=h();a(s,C.localOrigin,E.localOrigin),o(s)>0&&console.warn(` localOrigins: ${C.localOrigin} vs ${E.localOrigin} d=${o(s)} [${s}]`);(()=>{const t=m(M),r=m(U);e.updateEdgeElevations(),x.updateEdgeElevations(),D.getEdgeVertexPosition(y,M,b,Z),V.getEdgeVertexPosition(F,U,w,ee);const i=h();g(i,M,t),o(i)>0&&console.warn(` XXX Tile[${e.lij}] edge out of date: ${t} vs ${M} d=${o(i)} [${i}]`),g(i,U,r),o(i)>0&&console.warn(` XXX Neighbor[${x.lij}] edge out of date: ${r} vs ${U} d=${o(i)} [${i}]`)})();const n=D.getEdgeCount(y),l=V.getEdgeCount(P);S(u,`Mismatch in tile [${e.lij}].edge[${y}][${Z}/${n}] vs neighbor [${x.lij}].edge[${F}][${ee}/${l}] ${T(M)} vs ${T(U)} dist=${t} h(t|n|d)=${r}|${i}|${i-r}`)}D.getEdgeNormal(y,k,Z),V.getEdgeNormal(F,L,ee),n(H,k),n(X,L);const _=l(H,X),$=1-_<.01||!1||e===x;if(!$){const t=h();g(t,k,L);const r=()=>`Mismatch in tile edge normal ${j(e.lij)} (${Z}/${R-1}) edge ${y} vs neighbor ${j(x.lij)} (${ee}/${P-1}) nedge ${F} :${T(k)} vs ${T(L)} dot = ${_} : ${T(t)}`;console.warn("Mismatch in tile edge normal: ",r());{e.updateEdgeElevations(),x.updateEdgeElevations();const t=h(),r=h();D.getEdgeNormal(y,t,Z),V.getEdgeNormal(F,r,ee),d(k,t)||console.warn("Missing update in tile normal: ",T(k)," => ",T(t)),d(L,r)||console.warn("Missing update in neighbor normal: ",T(L)," => ",T(r))}S($,r())}}Z+=1,ee+=1}}))}}const M=h(),U=h(),k=h(),L=h(),H=h(),X=h(),B=1,W=[null,null,null,null];function q(e,t){return t?.loaded||t===e?t:null}const z=1,J=2,K=4,Q=8,Y=4,Z=8,ee=12,te=[0,1,2,3];export{A as ActivationTime,I as PatchRenderData,q as neighborTileIfLoadedOrSelf,te as zeroToFour};
5
+ import{equals as e}from"../../../core/arrayUtils.js";import"../../../core/has.js";import{isPowerOfTwo as t}from"../../../core/mathUtils.js";import{disposeMaybe as r}from"../../../core/maybe.js";import{p as i,F as s,G as o,f as a,n,l,z as g,H as d}from"../../../chunks/vec32.js";import{create as h,clone as m}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{containsXY as u}from"../../../geometry/support/aaBoundingRect.js";import{earth as c}from"../../../geometry/support/Ellipsoid.js";import{glLayout as f}from"../support/buffer/glUtil.js";import{GeometryState as p}from"./GeometryState.js";import{TextureUpdate as y}from"./interfaces.js";import{LayerClass as x}from"./LayerClass.js";import{NeighborIndex as _}from"./NeighborIndex.js";import{PatchGeometry as v}from"./PatchGeometry.js";import{maxTileNeighborLevelDelta as E}from"./TerrainConst.js";import{enableTerrainInternalChecks as $,internalAssert as S,neighborEdgeIndices as C,oppositeEdge as D,neighborCornerIndices as b,v32s as T,lij2s as j}from"./terrainUtils.js";import{TextureFader as R,ActivationTime as A}from"./TextureFader.js";import{TextureReference as V}from"./TextureReference.js";import w from"./TileOverlayData.js";import{fallsWithinLayerView as N}from"./tileUtils.js";import{VertexArrayObject as F}from"../webgl-engine/lib/VertexArrayObject.js";import{terrainVertexAttributeLocations as P}from"../webgl-engine/shaders/TerrainTechnique.js";import{BufferObject as G}from"../../webgl/BufferObject.js";import{PixelFormat as O}from"../../webgl/enums.js";class I{constructor(){this.geometry=new v,this.intersectionData=null,this.geometryState=null,this._vao=null,this._texture=null,this._textureOpacity=1,this._textureRef=new R((()=>this._tile.surface.fadeDuration)),this.overlay=new w,this._localOrigin=null,this._geometryStateChangedSinceLastUpdate=!0,this._hasGeometry=!1,this._modifiedFlags=0}get tile(){return this._tile}get localOrigin(){return this._localOrigin}init(e,t){this.clear(),this._tile=e,this.geometry.reset(),this.intersectionData=null,this.geometryState=new p,this._localOrigin=t,this.overlay.clear()}clear(){this.releaseGeometry(),this.releaseTexture(),this._textureRef.clear(),this._tile=null,this.intersectionData=null,this.geometryState=null}updateGeometryIfNeeded(e){if((!this._vao||this._geometryStateChangedSinceLastUpdate||this.wireframeChanged||this.clippingAreaChanged||this.samplerDataChanged||this.numVerticesPerSideChanged||this.dirtyCorners||this.dirtyEdgeResolutions||this.dirtyEdges)&&(this._updateGeometry(e),this._geometryStateChangedSinceLastUpdate=!1),$&&this.tile.intersectsClippingArea)for(let t=0;t<4;++t)S(this.geometry.getEdgeCount(t)===this.geometryState.edgeResolutions[t]+1)}_calculateEdgeResolution(e,t){const r=this.tile,i=this.geometryState.numVerticesPerSide-1;if(!r.surface.isGlobal){const t=r.surface.extent;if(null!=t&&(0===e&&r.extent[3]>t[3]||1===e&&r.extent[2]>t[2]||2===e&&r.extent[1]<t[1]||3===e&&r.extent[0]<t[0]))return i}const s=r.level,o=C[e];if(!t)return S(null==r.surface?.rootTiles||r.surface.updatingRootTiles||!r.shouldHaveNeighbor(o)),i;if(t.loaded){const r=t,o=r.renderData.geometryState,a=s-r.level;if(S(a>=0),0===a){const e=o.numVerticesPerSide-1;return Math.max(e,i)}const n=2**a,l=o.edgeResolutions[(e+2)%4]/n;return Math.max(1,l)}S(!t.leaf);let a=i;return t.forAllSubtreeOnSide(D(o),(e=>e===r||(e.loaded?(a=Math.max(a,2**(e.level-s)),!0):(S(!e.leaf),!1)))),a}updateNeighborData(){const e=this.tile;if(!e.intersectsClippingArea)return;const r=e.renderData.geometryState,i=t=>(t.loaded||t.level===e.level)&&t?.intersectsClippingArea,s=r.edgePeerNeighbors,o=r.edgePeerNeighborSamplerVersions;for(let a=0;a<4;++a){const n=e.findNeighborTile(C[a],i),l=q(e,n),g=l?.renderData?.geometryState.samplerDataVersion??-1,d=s[a],h=l!==q(e,d),m=o[a]!==g;$&&n&&(S(e.level>=n.level),S(e.level-n.level<=E)),s[a]=n,(h||m)&&(o[a]=g,this._markEdgeDirty(a));const u=r.edgeResolutions[a],c=this._calculateEdgeResolution(a,n);S(t(c)),S(c>=1),r.edgeResolutions[a]=c,u!==c&&this._markEdgeResolutionDirty(a)}for(let t=0;t<4;++t){const o=e.findNeighborTile(b[t],i);r.cornerPeerNeighbors[t]=o;const a=q(e,s[t]),n=q(e,s[(t+1)%4]),l=q(e,o);W[t]=l,W[(t+1)%4]=n,W[(t+2)%4]=e,W[(t+3)%4]=a,S(W.some((t=>t?.loaded||t===e)));const g=W.reduce(((e,t)=>Math.min(e,t?.level??1/0)),1/0);W.forEach(((e,t)=>{e&&e?.level>g&&(W[t]=null)})),S(W.some((t=>t?.loaded||t===e)));const d=r.cornerNeighborCornerTiles,h=r.cornerNeighborCornerTileSamplerVersions;for(let e=0;e<4;++e){const r=W[e],i=r?.renderData.geometryState.samplerDataVersion??-1,s=4*t+e,o=d[s]!==r,a=!o&&h[s]!==i;(o||a)&&(d[s]=r,h[s]=i,this._markCornerDirty(t))}$&&S(te.some((r=>d[4*t+r]?.loaded||d[4*t+r]===e)))}$&&S(this.geometryState.edgeResolutions.every((e=>e>0)));for(let t=0;t<4;++t)W[t]=null}_updateGeometry(e){if(!this.tile.intersectsClippingArea)return;$&&S(!this.tile.intersectsClippingArea||this.geometryState.edgeResolutions.every((e=>e>0))),this.intersectionData=null;const{tile:t,_vao:r,geometry:i,geometryState:s}=this,o=!r||!{geometry:i}||this.wireframeChanged||this.samplerDataChanged||this.clippingAreaChanged||this.numVerticesPerSideChanged,a=0!==this.dirtyEdgeResolutions,n=s.edgeResolutions.reduce(((e,t)=>e+t+1),0),l=o||a&&n>(i?.maxEdgeVertexCount??0),g=!l&&a,d=!g&&(0!==this.dirtyEdges||a),h=!d&&0!==this.dirtyCorners;l?(this.releaseGeometry(),this._createGeometry(e)):g?t.updateEdgeElevationsAndResolutions():d||h?t.updateEdgeElevations():h?t.updateCornerElevations():console.warn("Update for no reason?"),this._modifiedFlags=0}get hasGeometry(){return this._hasGeometry}releaseGeometry(){return this._hasGeometry=!1,this.intersectionData=null,!!this._vao&&(this._vao=r(this._vao),this.geometry.release(),!0)}ensureTexture(e,t,r,i){const s=t?O.RGBA:O.RGB;return null!=this._texture&&(r===y.FADING&&this._tile.surface.fadeDuration>0&&this._isTextureVisible(this._texture)||this._texture.descriptor.width!==e||this._texture.descriptor.pixelFormat!==s)&&this.releaseTexture(),null==this._texture&&(this._texture=i(),this.tile.setMemoryDirty()),this._texture}releaseTexture(){null!=this._texture&&(this._texture.release(),this._texture=null,this.tile.setMemoryDirty())}reuseTexture(e,t){return!(!e||!this._texture)&&(e.setTextureReference(new V(this._texture,y.FADING,t,this._textureOpacity,0,1)),!0)}get numVerticesPerSideChanged(){return!!(this._modifiedFlags&z)}get samplerDataChanged(){return!!(this._modifiedFlags&J)}get clippingAreaChanged(){return!!(this._modifiedFlags&K)}get wireframeChanged(){return!!(this._modifiedFlags&Q)}get dirtyEdges(){return this._modifiedFlags>>Y&15}get dirtyCorners(){return this._modifiedFlags>>Z&15}get dirtyEdgeResolutions(){return this._modifiedFlags>>ee&15}_markCornerDirty(e){const t=1<<e<<Z;this._modifiedFlags|=t}_markEdgeDirty(e){const t=1<<e<<Y;this._modifiedFlags|=t,this._markCornerDirty((e+0)%4),this._markCornerDirty((e+3)%4)}_markEdgeResolutionDirty(e){const t=1<<e<<ee;this._modifiedFlags|=t,this._markEdgeDirty(e)}_markAllEdgesAndCornersDirty(){this._modifiedFlags|=15<<Z|15<<Y|15<<ee}updateGeometryState(){const t=this._getElevationInfo(),r=this.tile,i=t.samplerData?r.getElevationVerticesPerSide(t.maxTileLevel):r.getDefaultVerticesPerSide(),s=Math.max(i,5);let o=r.clippingArea;r.intersectsClippingArea&&!r.withinClippingArea||(o=null);const a=this.geometryState;let n=!1;a.numVerticesPerSide!==s&&(this._modifiedFlags|=1,a.numVerticesPerSide=s,a.samplerDataVersion++,n=!0),t.changed&&(this._modifiedFlags|=2,a.samplerData=t.samplerData,a.samplerDataVersion++,n=!0),e(a.clippingArea,o)||(this._modifiedFlags=4,a.clippingArea=o,n=!0);const l=r.surface.wireframe;return a.wireframe!==l&&(this._modifiedFlags=8,a.wireframe=l,n=!0),this._geometryStateChangedSinceLastUpdate||=n,n&&this._markAllEdgesAndCornersDirty(),this._hasGeometry=!0,this._geometryStateChangedSinceLastUpdate}_createGeometry(e){this.tile.createGeometry();const t=this.geometry.vertexAttributes,r=this.geometry.indices,i=e.gl;this._vao=new F(e,P,new Map([["geometry",f(t.layout)]]),new Map([["geometry",G.createVertex(e,i.STATIC_DRAW,t.buffer)]]),G.createIndex(e,i.STATIC_DRAW,r)),this._hasGeometry=!0}get vao(){return this._vao}setTextureReference(e,t=A.Immediate){e?.texture===this._texture?this._textureOpacity=e.opacities[0]:this.releaseTexture(),this._textureRef.push(e,t)}get textureReference(){return this._textureRef.current}get nextTextureReference(){return this._textureRef.next}get textureFadeFactor(){return this._textureRef.fadeFactor}get textureIsFading(){return this._textureRef.isFading}_isTextureVisible(e){return this._textureRef.current?.texture===e||this._textureRef.next?.texture===e&&this._textureRef.fadeFactor<1}_getElevationInfo(){const e=this.geometryState.samplerData,t=this.tile.layerInfo[x.ELEVATION],r=t.length,i=new Array(r);let s=0,o=0,a=!1;for(let g=0;g<r;g++){const r=t[g],n=r.upsampleInfo?.tile;if(n){const t=n.layerInfo[x.ELEVATION][g].data,r=t&&t.samplerData;e&&e[s]===r||(a=!0),i[s++]=r,o=Math.max(o,n.lij[0])}else if(r.data){const t=this.tile.surface.layerViewByIndex(g,x.ELEVATION);if(N(this.tile,t)){const t=r.data;e&&e[s]===t.samplerData||(a=!0),i[s++]=t.samplerData,o=this.tile.level}}}null!=e&&e.length!==s&&(a=!0);const n=s>0,l=n?i:null;return n&&(i.length=s),{changed:a,samplerData:l,maxTileLevel:o}}get estimatedGeometryMemoryUsage(){const e=this.intersectionData?.estimatedMemoryUsage??0;return(this.geometry.indices?.byteLength??0)+(this.geometry.vertexAttributes?.byteLength??0)+e}get texture(){return this._texture}get test(){}checkGeometryWaterproofness(){if(!$)return;const e=this.tile;if(!e.loaded||!e.intersectsClippingArea||0===e.level)return void S(e?.loaded);const r=e.surface.extent;if(null!=r&&!e.intersectsExtent(r))return;const f=C.map(((t,i)=>null!=r&&(i<2?-1:1)*(e.extent[3-i]-r[3-i])<0)),p=e.level;S(0===this.dirtyCorners),S(0===this.dirtyEdges),S(0===this.dirtyEdgeResolutions),S(!this.numVerticesPerSideChanged),S(!this.samplerDataChanged),S(!this.clippingAreaChanged),S(!this.wireframeChanged);const y=b.map((t=>e.findNeighborCornerTileExact(t,(t=>!t.intersectsClippingArea||t.loaded||t.level===e.level))??null)).map((e=>e?.intersectsClippingArea?e:null)),x=this.geometryState;for(let t=0;t<4;++t){const r=x.cornerPeerNeighbors[t],i=y[t];S(i===r,`Tile[${e.lij}].corner[${t}] out of date: cur=[${r?.lij}] exp=[${i?.lij}]`)}C.forEach(((r,y)=>{if(f[y])return;const x=e.findNeighborTile(r,(e=>(e.level===p||e?.loaded)&&e?.intersectsClippingArea));if(!x){const t=!e.surface.updatingRootTiles&&null!=e.surface.rootTiles&&e.surface.rootTiles.length>0&&e.shouldHaveNeighbor(r);return void S(!t)}S(x.loaded||x.level===e.level),S(x===this.geometryState.edgePeerNeighbors[y]);const v=p-x.level;if(!x.loaded)return S(!x.leaf),void S(0===v);const E=x.renderData;S(e.isEdgeNeighbor(x,r)),S(v>=0);const $=2**v;if(v<0)return void S(!1);const C=e.renderData,D=C.geometry,b=C.localOrigin,R=D.getEdgeCount(y),A=D.numVerticesPerSide-1,V=E.geometry;if(!V)return void S(!1);const w=E.localOrigin,N=this.geometryState.edgePeerNeighbors[y];if(N?.loaded){const e=N.renderData;S(C.geometryState.edgePeerNeighborSamplerVersions[y]===e.geometryState.samplerDataVersion),S(this.geometryState.edgePeerNeighborSamplerVersions[y]===e.geometryState.samplerDataVersion)}const F=(y+2)%4,P=V.getEdgeCount(F),G=R-1,O=P-1;S(G*$===O,`Tile[${e.lij}]:e${y},res=${G} edgeRes mismatch with Neighbor[${x.lij}]:e${F},res=${O} (expected:${G*$})`);const I=e.extent,W=r===_.NORTH||r===_.SOUTH,q=P-1,z=q>>v,J=R-1;if(z<1)return void S(1===J);S(z===J),S(t(z));const K=V.numVerticesPerSide-1;S(v>0||z===Math.max(K,A));const Q=e.getNeighborEdgeStartVertexIndex(y,x);S(0<=Q&&Q<$);const Y=Q*z;S(0<=Y&&Y<=q-z);let Z=0,ee=Y;D.getEdgeVertexPosition(y,M,b,0),D.getEdgeVertexPosition(y,U,b,R-1);const te=i(M,U),re=Math.max(B,1e-4*te);for(let t=0;t<=z;++t){D.getEdgeVertexPosition(y,M,b,Z),V.getEdgeVertexPosition(F,U,w,ee);const i=t/z,f=W?I[0]+i*(I[2]-I[0]):r===_.WEST?I[0]:I[2],p=W?r===_.SOUTH?I[1]:I[3]:I[1]+i*(I[3]-I[1]),v=e.surface.extent;if(null==v||u(v,f,p)){const t=s(M,U),r=o(M)-c.radius,i=o(U)-c.radius,u=t<re;if(!u){console.warn(`Tile edge vertex position mismatch: between [${e.lij}].edge${y}[${Z}/${R}] and [${x.lij}].edge${F}[${ee}/${P}]`),null!=v&&console.warn(" surface extent= ",v," x,y=",f,",",p);const s=h();a(s,C.localOrigin,E.localOrigin),o(s)>0&&console.warn(` localOrigins: ${C.localOrigin} vs ${E.localOrigin} d=${o(s)} [${s}]`);(()=>{const t=m(M),r=m(U);e.updateEdgeElevations(),x.updateEdgeElevations(),D.getEdgeVertexPosition(y,M,b,Z),V.getEdgeVertexPosition(F,U,w,ee);const i=h();g(i,M,t),o(i)>0&&console.warn(` XXX Tile[${e.lij}] edge out of date: ${t} vs ${M} d=${o(i)} [${i}]`),g(i,U,r),o(i)>0&&console.warn(` XXX Neighbor[${x.lij}] edge out of date: ${r} vs ${U} d=${o(i)} [${i}]`)})();const n=D.getEdgeCount(y),l=V.getEdgeCount(P);S(u,`Mismatch in tile [${e.lij}].edge[${y}][${Z}/${n}] vs neighbor [${x.lij}].edge[${F}][${ee}/${l}] ${T(M)} vs ${T(U)} dist=${t} h(t|n|d)=${r}|${i}|${i-r}`)}D.getEdgeNormal(y,k,Z),V.getEdgeNormal(F,L,ee),n(H,k),n(X,L);const _=l(H,X),$=1-_<.01||!1||e===x;if(!$){const t=h();g(t,k,L);const r=()=>`Mismatch in tile edge normal ${j(e.lij)} (${Z}/${R-1}) edge ${y} vs neighbor ${j(x.lij)} (${ee}/${P-1}) nedge ${F} :${T(k)} vs ${T(L)} dot = ${_} : ${T(t)}`;console.warn("Mismatch in tile edge normal: ",r());{e.updateEdgeElevations(),x.updateEdgeElevations();const t=h(),r=h();D.getEdgeNormal(y,t,Z),V.getEdgeNormal(F,r,ee),d(k,t)||console.warn("Missing update in tile normal: ",T(k)," => ",T(t)),d(L,r)||console.warn("Missing update in neighbor normal: ",T(L)," => ",T(r))}S($,r())}}Z+=1,ee+=1}}))}}const M=h(),U=h(),k=h(),L=h(),H=h(),X=h(),B=1,W=[null,null,null,null];function q(e,t){return t?.loaded||t===e?t:null}const z=1,J=2,K=4,Q=8,Y=4,Z=8,ee=12,te=[0,1,2,3];export{A as ActivationTime,I as PatchRenderData,q as neighborTileIfLoadedOrSelf,te as zeroToFour};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.31/esri/copyright.txt for details.
4
4
  */
5
- import{lerp as t}from"../../../core/mathUtils.js";import{n as e,s as i,g as s,j as o,G as n,b as r,m as l,F as a,z as h}from"../../../chunks/vec32.js";import{create as u}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{lonLatToSphericalPCPF as d}from"../../../geometry/projection/lonLatToSphericalPCPF.js";import{newDoubleArray as c}from"../../../geometry/support/DoubleArray.js";import{intersectsSphere as p,numPlanes as f,PlaneIndex as m}from"../../../geometry/support/frustum.js";import{c as g,g as x}from"../../../chunks/sphere.js";import{PatchType as $}from"./interfaces.js";import{createSphericalGlobePatch as _,updateCornerSpherical as v,updateEdgesAndCornersSpherical as M,updateEdgeElevationsAndResolutionsSpherical as b}from"./PatchGeometryFactory.js";import{enableTerrainInternalChecks as j,internalAssert as S,almostEquals as T}from"./terrainUtils.js";import{Tile as E,CenterPosition as B}from"./Tile.js";import{TileFrustumVisibility as H}from"./TileFrustumVisibility.js";import{compareTilesByLij as I}from"./tileUtils.js";class y extends E{constructor(t,e,i,s,o){super(),this._convexHull=new Array(24),this._boundingSphere=g(),this._baseUsedMemory=1816,this.init(t,e,i,s,o)}init(i,s,o,n,r){super.init(i,s,o,n,r);const l=this.ellipsoid.radius,a=this.extentInRadians[0],h=this.extentInRadians[1],u=this.extentInRadians[2],c=this.extentInRadians[3],p=t(h,c,.5),f=t(a,u,.5),m=0===i?0:Math.min(Math.abs(h),Math.abs(c));this._edgeLen=(u-a)*Math.cos(m)*l,this._edgeLen2=this._edgeLen*this._edgeLen,this._curvatureHeight=l-Math.sqrt(l*l-this._edgeLen2/4),d(this.centerAtSeaLevel,f,p,this.ellipsoid.radius),e(this.up,this.centerAtSeaLevel),this.updateRadiusAndCenter()}updateRadiusAndCenter(){this._updateBoundingVolumes();const t=this._center;if(0===this.lij[0])i(x(t[B.MIDDLE]),0,0,0),i(t[B.TOP],0,0,0),i(t[B.BOTTOM],0,0,0),t[B.MIDDLE][3]=this.ellipsoid.radius+this.elevationBoundsMax;else{this._updateCenter();const e=t[B.MIDDLE],i=this.convexHull;let s=0;for(let t=0;t<8;++t)s=Math.max(s,L(x(e),i,3*t));t[B.MIDDLE][3]=Math.sqrt(s)}}_calculateFrustumVisibilityStatus(t){if(!p(t,this._boundingSphere))return H.OUTSIDE;if(this.lij[0]<10)return H.INTERSECTS;const e=this.convexHull,i=this.surface.view.state.camera.near;let s=!0;for(let o=0;o<f;o++){const n=o===m.NEAR,r=t[o],l=r[0],a=r[1],h=r[2],u=r[3]-(n?i:0);let d=!1;for(let t=0;t<8;++t){const i=3*t;if(l*e[i]+a*e[i+1]+h*e[i+2]+u<0){if(d=!0,!s)break}else s=!1}if(!d)return H.OUTSIDE}return s?H.INSIDE:H.INTERSECTS}computeElevationBounds(){super.computeElevationBounds(),this._updateBoundingVolumes()}createGeometry(){_(this.renderData,this._getPatchType()),this._updateBoundingVolumes(),this.setMemoryDirty()}_updateBoundingVolumes(){this._updateConvexHull(),this._updateBoundingSphere(),j&&this._checkBVs()}_updateBoundingSphere(){const t=this._boundingSphere,e=x(t),r=this.elevationBoundsMin,l=this.elevationBoundsMax,a=this.ellipsoid.radius,h=l;if(0===this.level)i(e,0,0,0),t[3]=a+h;else{const i=this.extentInRadians,h=.5*(i[0]+i[2]),u=i[1],d=i[3];O(V,h,u,a),O(A,h,d,a),s(e,V,A);o(e,e,(a+.5*(r+l))/n(e));const c=this.convexHull;let p=0;const f=(t,e)=>{const i=t[0]-c[3*e],s=t[1]-c[3*e+1],o=t[2]-c[3*e+2];return Math.sqrt(i*i+s*s+o*o)};for(let t=0;t<8;++t){const i=f(e,t);p=Math.max(p,i)}const m=p;t[3]=m+2}}_updateConvexHull(){const t=this.extentInRadians,i=this.ellipsoid.radius;if(0===this.level)return;const a=this.elevationBoundsMin,d=this.elevationBoundsMax,c=this._getPatchType(),p=this.surface.isWebMercator,f=p&&c===$.HAS_NORTH_POLE,m=p&&c===$.HAS_SOUTH_POLE,g=m||f,x=Math.PI/2,_=t[0],v=t[2],M=m?-x:t[1],b=f?x:t[3],j=.5*(_+v),E=a,B=i+(g?Math.min(0,E-1):E),H=(t,e,i)=>O(t,e,i,B),I=u(),y=u(),D=u(),L=u();H(I,_,M),H(y,_,b),H(D,v,b),H(L,v,M);const R=(t,e)=>{for(let i=0;i<3;++i)this._convexHull[3*e+i]=t[i]};R(I,0),R(y,1),R(D,2),R(L,3);const V=d,A=i+(g?Math.max(0,V+1):V),C=u(),F=u(),N=u();O(F,j,b,B),O(N,j,M,B),s(C,F,N),e(C,C);const U=u(),k=u(),w=(t,i)=>{h(k,t,i),e(k,k);const n=-l(t,U)/l(k,U);S(n>=0),o(k,k,n),s(t,t,k)};if(2**this.lij[0]>2*this.lij[1]){const t=N,i=u();r(i,P,t),e(i,i),r(U,t,i),e(U,U),S(T(l(U,t)/n(t),0)),w(I,y),w(L,D),R(I,0),R(L,3)}else if(2**this.lij[0]!==2*this.lij[1]){const t=F,i=u();r(i,P,t),e(i,i),r(U,i,t),e(U,U),w(y,I),w(D,L),R(y,1),R(D,2)}const q=(t,e)=>{const i=A/l(e,C);for(let s=0;s<3;++s)this._convexHull[3*t+s]=e[s]*i};q(4,I),q(5,y),q(6,D),q(7,L)}_getPatchType(){const t=this.lij[1],e=0===t,i=t===(1<<this.level)-1;return e?i?$.HAS_BOTH_POLES:$.HAS_NORTH_POLE:i?$.HAS_SOUTH_POLE:$.REGULAR}intersectsRay(t,e,i,s){const o=this._boundingSphere,n=o[3]+i,r=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],l=o[0]-t[0],a=o[1]-t[1],h=o[2]-t[2],u=(l*e[0]+a*e[1]+h*e[2])/r,d=e[0]*u-l,c=e[1]*u-a,p=e[2]*u-h;return d*d+c*c+p*p<n*n}getDefaultVerticesPerSide(){return this.level<D.length?D[this.level]+1:2}updateCornerElevations(){v(this.renderData),this._updateBoundingVolumes()}updateEdgeElevations(){M(this.renderData),this._updateBoundingVolumes()}updateEdgeElevationsAndResolutions(){b(this.renderData),this._updateBoundingVolumes()}_checkBVs(){if(!j)return;if(this.level<=2)return;const t=this._boundingSphere,i=t[3],o=x(t),d=u(),p=this.ellipsoid.radius,f=this.elevationBoundsMin,m=this.elevationBoundsMax,g=p+f,$=1,_=0,v=this._center[B.MIDDLE][3],M=this.convexHull,b=(t,e)=>{for(let i=0;i<3;++i)t[i]=M[3*e+i]};{const t=u(),i=u(),s=u(),o=u(),n=u(),a=(a,u,d,c)=>{b(i,a),b(s,u),b(o,d),h(i,i,s),h(o,o,s),r(t,i,o),e(t,t);const p=l(t,s);b(n,c);const f=l(t,n),m=Math.abs(f-p);S(T(m,0),`Non coplanar ${a},${u},${d},${c} diff = ${m}`)};a(0,1,2,3),a(4,5,6,7),a(0,1,4,5),a(1,2,5,6),a(2,3,6,7),a(3,0,7,4)}const E=c(24),H=(t,e,i)=>{const s=4*t;for(let o=0;o<3;++o)E[s+o]=e[o];E[s+3]=i},y=u(),D=u(),L=u(),P=u(),V=(t,i,s,o)=>{b(y,i),b(D,s),b(L,o),h(y,y,D),e(y,y),h(L,L,D),e(L,L),r(P,y,L),e(P,P);const n=l(P,D);H(t,P,n)};V(0,0,1,2),V(1,1,0,4),V(2,1,5,2),V(3,3,2,6),V(4,4,0,3),V(5,4,6,5);const A=1,C=(t,e,i,s)=>{const o=4*t;return E[o]*e+E[o+1]*i+E[o+2]*s-E[o+3]},F=(t,e,i,s)=>C(t,e,i,s)>=-A,N=(t,e)=>F(t,e[0],e[1],e[2]),U=2**this.lij[0]>2*this.lij[1],k=(t,e,s)=>Math.sqrt(R(t,e,s,o[0],o[1],o[2]))<i,w=t=>k(t[0],t[1],t[2]),q=(t,e)=>k(t[e],t[e+1],t[e+2]),G=this.extentInRadians,z=.5*(G[0]+G[2]),W=G[1],J=G[3],K=u(),Q=u();O(K,z,J,g),O(Q,z,W,g);const X=U?"Upper":"Lower";let Y=!0;for(let e=0;e<6;++e){for(let t=0;t<8;++t){const i=3*t,s=F(e,M[i],M[i+1],M[i+2]);Y&&=s,S(s,`Tile[${this.lij}] Convex hull point ${t} outside of plane ${e}`)}S(N(e,Q),`Tile[${this.lij}] (${X}) bottom mid outside of plane ${e}`),S(N(e,K),`Tile[${this.lij}] (${X}) top mid outside of plane ${e}`)}S(Y,"Not all convex hull points are inside convex hull polyhedron"),S(w(Q),`Tile[${this.lij}] (${X}) bottom mid outside of bounding sphere`),S(w(K),`Tile[${this.lij}] (${X}) top mid outside of bounding sphere`);for(let e=0;e<8;++e){const t=q(M,3*e);S(t,`Tile[${this.lij}] Convex hull point ${e} outside of bounding sphere`)}for(let e=0;e<6;++e)for(let t=0;t<8;++t){const i=3*t;F(e,M[i],M[i+1],M[i+2])||console.error(`Tile[${this.lij}] Convex hull point ${t} outside of plane ${e}`)}const{extentInRadians:Z}=this,tt=Math.max(Z[2]-Z[0],Z[3]-Z[1]),et=Math.round(tt*p),{renderData:it}=this;if(!it)return;const{geometry:st,geometryState:ot,localOrigin:nt}=it,rt=st.vertexAttributes?.position;if(!rt)return;const lt=u(),at=st.numVerticesPerSide-2,{indices:ht,indexCount:ut,edgeVerticesStartIndex:dt,poleVerticesStartIndex:ct}=st;if(!ht)return;const pt=new Set;for(let e=0;e<ut;++e){const t=ht[e];if(pt.has(t))continue;pt.add(t);const r=t<ct,l=t>=dt;let h=!1,u=-1;if(l){let e=dt;for(let i=0;i<4;++i){const s=ot.edgeResolutions[i];if(t===e||t===e+s-1){h=!0;break}if(e+=s,t<e){u=i;break}}}const c=l?ot.edgePeerNeighbors[u]:null,g=l&&c&&I(this,c)>0;rt.getVec(t,d),s(lt,d,nt);const x=n(lt)-p;let M=0,b=!1;const j=f-x,S=x-m,T=j>$,E=S>$,B=T||E,H=()=>{const e=r?"internal":l&&!h?"edge":h?"corner":"pole";return`Tile[${this.lij}].vertex[${t}]:${e}`+(T?"(below)":E?"(above)":"")+(g?"(Neighbor)":"")},y=a(lt,o);if(y>=i+_){const t=y-i;B||(console.error(`${H()} is out of the bounding sphere by ${t.toFixed(0)} / ${i.toFixed(0)}[tol=${_}] h=${x.toFixed(0)} / [${f.toFixed(0)}..${m.toFixed(0)}] (${(t/i).toFixed(0)})`),b=!0)}for(let e=0;e<6;++e)if(!F(e,lt[0],lt[1],lt[2])){const s=C(e,lt[0],lt[1],lt[2]),o=t%at,n=(t-o)/at;0===e&&j||5===e&&S||(console.error(`${H()} (${o},${n})|${at}] is out of the bounding trapezoid plane ${e} h=${Math.round(x)} / [${Math.round(f)}..${Math.round(m)}] dist=${Math.round(s)} radii = ${Math.round(i)}/${Math.round(v)}} : maxL = ${et}`),++M)}if(b||M>0)break}}get convexHull(){return this._convexHull}}const D=[128,64,64,32,16,8,8,4];function L(t,e,i){return R(t[0],t[1],t[2],e[i],e[i+1],e[i+2])}function R(t,e,i,s,o,n){const r=s-t,l=o-e,a=n-i;return r*r+l*l+a*a}const O=(t,e,i,s)=>{const o=Math.cos(e),n=Math.sin(e),r=Math.cos(i),l=Math.sin(i);t[0]=s*r*o,t[1]=s*r*n,t[2]=s*l},P=[0,0,1],V=u(),A=u();export{y as SphericalPatch};
5
+ import{lerp as t}from"../../../core/mathUtils.js";import{n as e,a as i,g as s,j as o,G as n,b as r,l,F as a,z as h}from"../../../chunks/vec32.js";import{create as u}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{lonLatToSphericalPCPF as d}from"../../../geometry/projection/lonLatToSphericalPCPF.js";import{newDoubleArray as c}from"../../../geometry/support/DoubleArray.js";import{intersectsSphere as p,numPlanes as f,PlaneIndex as m}from"../../../geometry/support/frustum.js";import{c as g,g as x}from"../../../chunks/sphere.js";import{PatchType as $}from"./interfaces.js";import{createSphericalGlobePatch as _,updateCornerSpherical as v,updateEdgesAndCornersSpherical as M,updateEdgeElevationsAndResolutionsSpherical as b}from"./PatchGeometryFactory.js";import{enableTerrainInternalChecks as j,internalAssert as S,almostEquals as T}from"./terrainUtils.js";import{Tile as E,CenterPosition as B}from"./Tile.js";import{TileFrustumVisibility as H}from"./TileFrustumVisibility.js";import{compareTilesByLij as I}from"./tileUtils.js";class y extends E{constructor(t,e,i,s,o){super(),this._convexHull=new Array(24),this._boundingSphere=g(),this._baseUsedMemory=1816,this.init(t,e,i,s,o)}init(i,s,o,n,r){super.init(i,s,o,n,r);const l=this.ellipsoid.radius,a=this.extentInRadians[0],h=this.extentInRadians[1],u=this.extentInRadians[2],c=this.extentInRadians[3],p=t(h,c,.5),f=t(a,u,.5),m=0===i?0:Math.min(Math.abs(h),Math.abs(c));this._edgeLen=(u-a)*Math.cos(m)*l,this._edgeLen2=this._edgeLen*this._edgeLen,this._curvatureHeight=l-Math.sqrt(l*l-this._edgeLen2/4),d(this.centerAtSeaLevel,f,p,this.ellipsoid.radius),e(this.up,this.centerAtSeaLevel),this.updateRadiusAndCenter()}updateRadiusAndCenter(){this._updateBoundingVolumes();const t=this._center;if(0===this.lij[0])i(x(t[B.MIDDLE]),0,0,0),i(t[B.TOP],0,0,0),i(t[B.BOTTOM],0,0,0),t[B.MIDDLE][3]=this.ellipsoid.radius+this.elevationBoundsMax;else{this._updateCenter();const e=t[B.MIDDLE],i=this.convexHull;let s=0;for(let t=0;t<8;++t)s=Math.max(s,L(x(e),i,3*t));t[B.MIDDLE][3]=Math.sqrt(s)}}_calculateFrustumVisibilityStatus(t){if(!p(t,this._boundingSphere))return H.OUTSIDE;if(this.lij[0]<10)return H.INTERSECTS;const e=this.convexHull,i=this.surface.view.state.camera.near;let s=!0;for(let o=0;o<f;o++){const n=o===m.NEAR,r=t[o],l=r[0],a=r[1],h=r[2],u=r[3]-(n?i:0);let d=!1;for(let t=0;t<8;++t){const i=3*t;if(l*e[i]+a*e[i+1]+h*e[i+2]+u<0){if(d=!0,!s)break}else s=!1}if(!d)return H.OUTSIDE}return s?H.INSIDE:H.INTERSECTS}computeElevationBounds(){super.computeElevationBounds(),this._updateBoundingVolumes()}createGeometry(){_(this.renderData,this._getPatchType()),this._updateBoundingVolumes(),this.setMemoryDirty()}_updateBoundingVolumes(){this._updateConvexHull(),this._updateBoundingSphere(),j&&this._checkBVs()}_updateBoundingSphere(){const t=this._boundingSphere,e=x(t),r=this.elevationBoundsMin,l=this.elevationBoundsMax,a=this.ellipsoid.radius,h=l;if(0===this.level)i(e,0,0,0),t[3]=a+h;else{const i=this.extentInRadians,h=.5*(i[0]+i[2]),u=i[1],d=i[3];O(V,h,u,a),O(A,h,d,a),s(e,V,A);o(e,e,(a+.5*(r+l))/n(e));const c=this.convexHull;let p=0;const f=(t,e)=>{const i=t[0]-c[3*e],s=t[1]-c[3*e+1],o=t[2]-c[3*e+2];return Math.sqrt(i*i+s*s+o*o)};for(let t=0;t<8;++t){const i=f(e,t);p=Math.max(p,i)}const m=p;t[3]=m+2}}_updateConvexHull(){const t=this.extentInRadians,i=this.ellipsoid.radius;if(0===this.level)return;const a=this.elevationBoundsMin,d=this.elevationBoundsMax,c=this._getPatchType(),p=this.surface.isWebMercator,f=p&&c===$.HAS_NORTH_POLE,m=p&&c===$.HAS_SOUTH_POLE,g=m||f,x=Math.PI/2,_=t[0],v=t[2],M=m?-x:t[1],b=f?x:t[3],j=.5*(_+v),E=a,B=i+(g?Math.min(0,E-1):E),H=(t,e,i)=>O(t,e,i,B),I=u(),y=u(),D=u(),L=u();H(I,_,M),H(y,_,b),H(D,v,b),H(L,v,M);const R=(t,e)=>{for(let i=0;i<3;++i)this._convexHull[3*e+i]=t[i]};R(I,0),R(y,1),R(D,2),R(L,3);const V=d,A=i+(g?Math.max(0,V+1):V),C=u(),F=u(),N=u();O(F,j,b,B),O(N,j,M,B),s(C,F,N),e(C,C);const U=u(),k=u(),w=(t,i)=>{h(k,t,i),e(k,k);const n=-l(t,U)/l(k,U);S(n>=0),o(k,k,n),s(t,t,k)};if(2**this.lij[0]>2*this.lij[1]){const t=N,i=u();r(i,P,t),e(i,i),r(U,t,i),e(U,U),S(T(l(U,t)/n(t),0)),w(I,y),w(L,D),R(I,0),R(L,3)}else if(2**this.lij[0]!==2*this.lij[1]){const t=F,i=u();r(i,P,t),e(i,i),r(U,i,t),e(U,U),w(y,I),w(D,L),R(y,1),R(D,2)}const q=(t,e)=>{const i=A/l(e,C);for(let s=0;s<3;++s)this._convexHull[3*t+s]=e[s]*i};q(4,I),q(5,y),q(6,D),q(7,L)}_getPatchType(){const t=this.lij[1],e=0===t,i=t===(1<<this.level)-1;return e?i?$.HAS_BOTH_POLES:$.HAS_NORTH_POLE:i?$.HAS_SOUTH_POLE:$.REGULAR}intersectsRay(t,e,i,s){const o=this._boundingSphere,n=o[3]+i,r=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],l=o[0]-t[0],a=o[1]-t[1],h=o[2]-t[2],u=(l*e[0]+a*e[1]+h*e[2])/r,d=e[0]*u-l,c=e[1]*u-a,p=e[2]*u-h;return d*d+c*c+p*p<n*n}getDefaultVerticesPerSide(){return this.level<D.length?D[this.level]+1:2}updateCornerElevations(){v(this.renderData),this._updateBoundingVolumes()}updateEdgeElevations(){M(this.renderData),this._updateBoundingVolumes()}updateEdgeElevationsAndResolutions(){b(this.renderData),this._updateBoundingVolumes()}_checkBVs(){if(!j)return;if(this.level<=2)return;const t=this._boundingSphere,i=t[3],o=x(t),d=u(),p=this.ellipsoid.radius,f=this.elevationBoundsMin,m=this.elevationBoundsMax,g=p+f,$=1,_=0,v=this._center[B.MIDDLE][3],M=this.convexHull,b=(t,e)=>{for(let i=0;i<3;++i)t[i]=M[3*e+i]};{const t=u(),i=u(),s=u(),o=u(),n=u(),a=(a,u,d,c)=>{b(i,a),b(s,u),b(o,d),h(i,i,s),h(o,o,s),r(t,i,o),e(t,t);const p=l(t,s);b(n,c);const f=l(t,n),m=Math.abs(f-p);S(T(m,0),`Non coplanar ${a},${u},${d},${c} diff = ${m}`)};a(0,1,2,3),a(4,5,6,7),a(0,1,4,5),a(1,2,5,6),a(2,3,6,7),a(3,0,7,4)}const E=c(24),H=(t,e,i)=>{const s=4*t;for(let o=0;o<3;++o)E[s+o]=e[o];E[s+3]=i},y=u(),D=u(),L=u(),P=u(),V=(t,i,s,o)=>{b(y,i),b(D,s),b(L,o),h(y,y,D),e(y,y),h(L,L,D),e(L,L),r(P,y,L),e(P,P);const n=l(P,D);H(t,P,n)};V(0,0,1,2),V(1,1,0,4),V(2,1,5,2),V(3,3,2,6),V(4,4,0,3),V(5,4,6,5);const A=1,C=(t,e,i,s)=>{const o=4*t;return E[o]*e+E[o+1]*i+E[o+2]*s-E[o+3]},F=(t,e,i,s)=>C(t,e,i,s)>=-A,N=(t,e)=>F(t,e[0],e[1],e[2]),U=2**this.lij[0]>2*this.lij[1],k=(t,e,s)=>Math.sqrt(R(t,e,s,o[0],o[1],o[2]))<i,w=t=>k(t[0],t[1],t[2]),q=(t,e)=>k(t[e],t[e+1],t[e+2]),G=this.extentInRadians,z=.5*(G[0]+G[2]),W=G[1],J=G[3],K=u(),Q=u();O(K,z,J,g),O(Q,z,W,g);const X=U?"Upper":"Lower";let Y=!0;for(let e=0;e<6;++e){for(let t=0;t<8;++t){const i=3*t,s=F(e,M[i],M[i+1],M[i+2]);Y&&=s,S(s,`Tile[${this.lij}] Convex hull point ${t} outside of plane ${e}`)}S(N(e,Q),`Tile[${this.lij}] (${X}) bottom mid outside of plane ${e}`),S(N(e,K),`Tile[${this.lij}] (${X}) top mid outside of plane ${e}`)}S(Y,"Not all convex hull points are inside convex hull polyhedron"),S(w(Q),`Tile[${this.lij}] (${X}) bottom mid outside of bounding sphere`),S(w(K),`Tile[${this.lij}] (${X}) top mid outside of bounding sphere`);for(let e=0;e<8;++e){const t=q(M,3*e);S(t,`Tile[${this.lij}] Convex hull point ${e} outside of bounding sphere`)}for(let e=0;e<6;++e)for(let t=0;t<8;++t){const i=3*t;F(e,M[i],M[i+1],M[i+2])||console.error(`Tile[${this.lij}] Convex hull point ${t} outside of plane ${e}`)}const{extentInRadians:Z}=this,tt=Math.max(Z[2]-Z[0],Z[3]-Z[1]),et=Math.round(tt*p),{renderData:it}=this;if(!it)return;const{geometry:st,geometryState:ot,localOrigin:nt}=it,rt=st.vertexAttributes?.position;if(!rt)return;const lt=u(),at=st.numVerticesPerSide-2,{indices:ht,indexCount:ut,edgeVerticesStartIndex:dt,poleVerticesStartIndex:ct}=st;if(!ht)return;const pt=new Set;for(let e=0;e<ut;++e){const t=ht[e];if(pt.has(t))continue;pt.add(t);const r=t<ct,l=t>=dt;let h=!1,u=-1;if(l){let e=dt;for(let i=0;i<4;++i){const s=ot.edgeResolutions[i];if(t===e||t===e+s-1){h=!0;break}if(e+=s,t<e){u=i;break}}}const c=l?ot.edgePeerNeighbors[u]:null,g=l&&c&&I(this,c)>0;rt.getVec(t,d),s(lt,d,nt);const x=n(lt)-p;let M=0,b=!1;const j=f-x,S=x-m,T=j>$,E=S>$,B=T||E,H=()=>{const e=r?"internal":l&&!h?"edge":h?"corner":"pole";return`Tile[${this.lij}].vertex[${t}]:${e}`+(T?"(below)":E?"(above)":"")+(g?"(Neighbor)":"")},y=a(lt,o);if(y>=i+_){const t=y-i;B||(console.error(`${H()} is out of the bounding sphere by ${t.toFixed(0)} / ${i.toFixed(0)}[tol=${_}] h=${x.toFixed(0)} / [${f.toFixed(0)}..${m.toFixed(0)}] (${(t/i).toFixed(0)})`),b=!0)}for(let e=0;e<6;++e)if(!F(e,lt[0],lt[1],lt[2])){const s=C(e,lt[0],lt[1],lt[2]),o=t%at,n=(t-o)/at;0===e&&j||5===e&&S||(console.error(`${H()} (${o},${n})|${at}] is out of the bounding trapezoid plane ${e} h=${Math.round(x)} / [${Math.round(f)}..${Math.round(m)}] dist=${Math.round(s)} radii = ${Math.round(i)}/${Math.round(v)}} : maxL = ${et}`),++M)}if(b||M>0)break}}get convexHull(){return this._convexHull}}const D=[128,64,64,32,16,8,8,4];function L(t,e,i){return R(t[0],t[1],t[2],e[i],e[i+1],e[i+2])}function R(t,e,i,s,o,n){const r=s-t,l=o-e,a=n-i;return r*r+l*l+a*a}const O=(t,e,i,s)=>{const o=Math.cos(e),n=Math.sin(e),r=Math.cos(i),l=Math.sin(i);t[0]=s*r*o,t[1]=s*r*n,t[2]=s*l},P=[0,0,1],V=u(),A=u();export{y as SphericalPatch};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.31/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Color.js";import has from"../../../core/has.js";import{disposeMaybe as i}from"../../../core/maybe.js";import{MemCachePool as r}from"../../../core/MemCachePool.js";import s from"../../../core/ObjectPool.js";import{watch as n,sync as a}from"../../../core/reactiveUtils.js";import{property as o}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as l}from"../../../core/accessorSupport/decorators/subclass.js";import{IDENTITY as c}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{f as d,s as h,m as u}from"../../../chunks/vec32.js";import{ZEROS as _,fromValues as f,create as p}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as g,ZEROS as m}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{create as b,set as y}from"../../../geometry/support/aaBoundingBox.js";import{BufferViewVec3f as T}from"../../../geometry/support/buffer/BufferView.js";import{ViewingMode as O}from"../../ViewingMode.js";import{TextureUpdate as R}from"./interfaces.js";import{LayerClass as x}from"./LayerClass.js";import{OverlayContent as P}from"./OverlayContent.js";import{overlayRenderOccludedFlag as v}from"./OverlayRenderer.js";import{PatchRenderData as w}from"./PatchRenderData.js";import{RenderOrder as D}from"./RenderOrder.js";import{TerrainAttributesCache as S}from"./TerrainAttributesCache.js";import{enableTerrainInternalChecks as E}from"./terrainUtils.js";import{TileRenderer as A}from"./TileRenderer.js";import{TileUpdate as C}from"./TileUpdate.js";import{IteratorPreorder as j,sortTiles as N,compareTiles as B}from"./tileUtils.js";import{TransparencyMode as I}from"./TransparencyMode.js";import{componentMinimalSizeForIntersectionData as F,ComponentIntersectionData as U}from"../webgl-engine/collections/Component/ComponentIntersectionData.js";import{ShaderOutput as L}from"../webgl-engine/core/shaderLibrary/ShaderOutput.js";import{T as G}from"../../../chunks/Terrain.glsl.js";import{TileBlendInput as q}from"../webgl-engine/core/shaderLibrary/terrain/TileBlendInput.js";import{SyncPrepareRenderPlugin as M,ConsumesDepth as k,ConsumesNone as z}from"../webgl-engine/effects/RenderPlugin.js";import{Vertices as V}from"../webgl-engine/lib/Attribute.js";import{RenderRequestType as H}from"../webgl-engine/lib/basicInterfaces.js";import{createEmptyTexture as Y}from"../webgl-engine/lib/glUtil3D.js";import{newIntersectorResult as Q}from"../webgl-engine/lib/Intersector.js";import{IntersectorType as W,StoreResults as X}from"../webgl-engine/lib/IntersectorInterfaces.js";import{RenderOccludedFlag as K}from"../webgl-engine/lib/Material.js";import{intersectAabbInvDirBefore as Z,intersectTriangles as J,MeshIntersectionOptions as $}from"../webgl-engine/lib/RayIntersections.js";import{RenderSlot as ee}from"../webgl-engine/lib/RenderSlot.js";import{getSettings as te}from"../webgl-engine/lib/screenSizePerspectiveUtils.js";import{VertexAttribute as ie}from"../webgl-engine/lib/VertexAttribute.js";import{terrainId as re,getVerticalOffsetTerrain as se}from"../webgl-engine/lib/verticalOffsetUtils.js";import{DrawParameters as ne}from"../webgl-engine/materials/DrawParameters.js";import{TerrainTechnique as ae}from"../webgl-engine/shaders/TerrainTechnique.js";import{TerrainTechniqueConfiguration as oe}from"../webgl-engine/shaders/TerrainTechniqueConfiguration.js";import{PrimitiveType as le}from"../../webgl/enums.js";const ce=7,de=10,he=b();let ue=class extends M{get _isGlobal(){return this._stage.viewingMode===O.Global}get _techniques(){return this._context.techniques}get _rctx(){return this._context.renderContext.rctx}constructor(e,t,i,n,a){super({}),this._overlayRenderer=e,this._stage=t,this._allTiles=i,this._ellipsoidRadius=n,this.type=W.TERRAIN,this.isGround=!0,this._tileSize=256,this._configuration=new oe,this._passParameters=new G,this._drawParameters=new ne,this._renderDataPool=new s(w),this._visiblePatchesByOrigin=new Map,this._allPatchesByOrigin=new Map,this._patchesByOriginDirty=!0,this._patchSortingDirty=!0,this._tileIterator=new j,this._castShadows=!1,this._inViewshed=!1,this._emptyTex=null,this._tileRenderer=null,this._stencilEnabledLayerExtents=new Array,this._numTilesRendered=0,this._numTilesCulled=0,this._numOriginsRendered=0,this.renderOccludedFlags=K.Occlude,this.produces=new Map([[ee.OPAQUE_TERRAIN,()=>this._produces()],[ee.TRANSPARENT_TERRAIN,()=>this._produces()],[ee.OCCLUDED_TERRAIN,()=>this._produces()]]),this._tileTextureCache=new r(((e,t)=>a.newCache(e,t)),"TileTexture"),this.tileGeometryCache=new S(a)}normalizeCtorArgs(){return{}}initialize(){this._stage.addRenderPlugin(this),this.addHandles(n((()=>this._overlayRenderer.rendersOccludedDraped),(e=>{this.renderOccludedFlags=e?v:K.Occlude,this.setNeedsRender()}),a))}destroy(){this._stage.removeRenderPlugin(this),this._tileTextureCache.destroy(),this.tileGeometryCache.destroy()}_produces(){return this.visible&&!!this._rootTiles&&!this.renderingDisabled}consumes(){return this._overlayRenderer.hasWater?k:z}set renderingDisabled(e){this._set("renderingDisabled",!!e),this.setDirty()}set visible(e){this._set("visible",!!e),this.setDirty()}updateHeading(e){this._tileRenderer?.updateHeading(e)}set transparency(e){this._configuration.transparencyMode!==e&&(this._configuration.transparencyMode=e,this.setNeedsRender())}get transparency(){return this._configuration.transparencyMode}get renderPatchBorders(){return!!this._configuration.tileBorders}set renderPatchBorders(e){this._configuration.tileBorders!==e&&(this._configuration.tileBorders=e,this.setNeedsRender(),this.notifyChange("renderPatchBorders"))}get visualizeNormals(){return!!this._configuration.visualizeNormals}set visualizeNormals(e){this._configuration.visualizeNormals!==e&&(this._configuration.visualizeNormals=e,this.setNeedsRender(),this.notifyChange("visualizeNormals"))}get cullBackFaces(){return this._configuration.backfaceCullingEnabled}set cullBackFaces(e){this._configuration.backfaceCullingEnabled!==e&&(this._configuration.backfaceCullingEnabled=e,this.notifyChange("cullBackFaces"),this.setNeedsRender())}set renderOrder(e){this._set("renderOrder",e),this._setSortingDirty()}get layerUid(){return re}get slicePlaneEnabled(){return this._configuration.hasSlicePlane}set slicePlaneEnabled(e){this._configuration.hasSlicePlane!==e&&(this._configuration.hasSlicePlane=e,this.setNeedsRender())}set textureFadingEnabled(e){this._configuration.textureFadingEnabled!==e&&(this._configuration.textureFadingEnabled=e,this.setNeedsRender())}set pbrMode(e){this._configuration.pbrMode!==e&&(this._configuration.pbrMode=e,this.setNeedsRender())}setDebugScreenSizePerspective(e){this._configuration.screenSizePerspective!==e&&(this._configuration.screenSizePerspective=e,this.setNeedsRender())}setRootTiles(e){this._rootTiles=e,this.setDirty()}setStencilEnabledLayerExtents(e){this._stencilEnabledLayerExtents=e,this._setSortingDirty()}setTileSize(e){this._tileSize=e,null!=this._tileRenderer&&(this._tileRenderer.tileSize=e),this.setDirty()}_ensureRenderData(e){e.renderData||(e.renderData=this._renderDataPool.acquire(),e.renderData.init(e,this._getLocalOriginOfTile(e)))}loadTile(e){this._ensureRenderData(e),this.updateTileGeometryState(e),this.reuseTextureFromParent(e)||this.updateTileTexture(e,C.TEXTURE_FADING)}reuseTextureFromParent(e){const t=e.parent;if(!t)return!1;const i=g(1&e.lij[2]?.5:0,1&e.lij[1]?0:.5,.5,.5);return t.renderData?.reuseTexture(e.renderData,i)??!1}updateTileTexture(e,t){null!=this._tileRenderer&&(this._tileRenderer.updateTileTexture(e,t===C.TEXTURE_FADING?R.FADING:R.UNFADED),this.setNeedsRender(),e.resetPendingUpdate(t))}updateTileGeometryState(e){for(const i of e.layerInfo[x.ELEVATION])i.pendingUpdates&=~C.GEOMETRY;e.resetPendingUpdate(C.GEOMETRY);const t=e.renderData.updateGeometryState();return t&&this.setDirty(),t}updateGeometryIfNeeded(e){e.loaded&&e.renderData.updateGeometryIfNeeded(this._rctx)}unloadTile(e){const t=e.renderData;t&&(t.releaseGeometry(),this._renderDataPool.release(t),t.clear(),e.renderData=null,e.setMemoryDirty(),this.setDirty())}_getLocalOriginOfTile(e){const t=de-ce,i=Math.max(0,Math.floor((e.level-t)/ce)*ce);if(this._isGlobal&&0===i)return _;for(;e.parent&&e.level>i;)e=e.parent;return e.centerAtSeaLevel}getStats(){return{numTilesRendered:this._numTilesRendered,numTilesCulled:this._numTilesCulled,numOriginsRendered:this._numOriginsRendered}}set wireframe(e){this._get("wireframe")!==e&&(this._set("wireframe",e),this.setNeedsRender())}setDirty(e=H.UPDATE){this._patchesByOriginDirty=!0,this._context.requestRender(e)}_setSortingDirty(e=H.UPDATE){this._patchSortingDirty=!0,this._context.requestRender(e)}setNeedsRender(e=H.UPDATE){this._context.requestRender(e)}initializeRenderContext(e){this._context=e,this._tileRenderer=new A(this._rctx,this._tileSize,this._techniques,this._tileTextureCache),this.updateTileBackground(),this._emptyTex=Y(this._rctx)}uninitializeRenderContext(){this._emptyTex=i(this._emptyTex),this._tileRenderer=i(this._tileRenderer)}intersect(e,t,i,r){if(!this._rootTiles||e.options.selectOpaqueTerrainOnly&&e.options.selectionMode&&this.transparency!==I.Opaque)return;const s=_e,n=fe;d(s,r,i),h(n,1/s[0],1/s[1],1/s[2]);const a=e.results.min,o=e.results.max,l=e.results.ground,_=e.options.store===X.MIN,f=!!e.results.ground.target,p=se(e.verticalOffset),g=e.tolerance;let m,b=_&&null!=a.dist?a.dist:1/0;const O=e.options,R=O.normalRequired||!O.backfacesTerrain,x=new $(!1,R),P=h=>{const f=h.renderData;if(!f?.vao)return;const P=f.geometry;y(he,P.boundingBox);const v=f.localOrigin;null!=p&&(p.localOrigin=v,p.applyToAabb(he));const w=he;if(pe[0]=i[0]-v[0],pe[1]=i[1]-v[1],pe[2]=i[2]-v[2],!Z(w,pe,n,g,b))return;const D=(e,t,i)=>{e.set(this.type,h,t,i,c),b=_&&null!=a.dist?a.dist:1/0},S=(n,c,d)=>{if((!R||null!=d)&&n>=0&&(O.backfacesTerrain||u(d,s)<0)&&(O.invisibleTerrain||!O.selectionMode||null==t||t(i,r,n))){if((null==l.dist||n<l.dist)&&D(l,n,d),O.isFiltered)return;O.store===X.ALL&&(null==m?(m=Q(e.ray),D(m,n,d),e.results.all.push(m)):n<m.dist&&D(m,n,d)),(null==a.dist||n<a.dist)&&D(a,n,d),O.store!==X.MIN&&(null==o.dist||n>o.dist)&&D(o,n,d)}},E=ge;d(E,r,v);const{indices:A,indexCount:C}=P,j=P.vertexAttributes,N=j.getField(ie.POSITION,T),B=new V(N.typedBuffer,3,j.stride/4),I=C/3;if(!p&&I>F){const e=h.renderData;null==e.intersectionData&&(e.intersectionData=new U(A,0,I,B)),e.intersectionData.intersectRay(pe,E,x,S)}else J(pe,E,0,I,A,B,p,x,S)},v=this._rootTiles;if(null!=v){(()=>{const t=this._tileIterator;t.reset(v);const r=e.options.invisibleTerrain;for(let e=t.next();e;e=t.next())!(e.visible||r&&e.intersectsClippingArea)||null==p&&!e.intersectsRay(i,s,g,b)||f&&this._useStencilForTile(e)?t.skipSubtree():P(e)})()}}processScaleRangeQueries(e,t){if(!t.done)for(this._updatePatchGroups();e.updating&&!t.done;){e.prepare();for(const t of this._visiblePatchesByOrigin.values())for(const i of t)null!=i.renderData?.textureReference&&e.queriesForTile(i);e.process(),t.madeProgress()}}prepareTechnique(e){const t=has("enable-feature:terrain-shadows")&&e.bindParameters.shadowMap.enabled;t!==this._castShadows&&(this._castShadows=t,this._patchesByOriginDirty=!0);const i=e.bindParameters.viewshedEnabled;if(this._inViewshed!==i&&(this._inViewshed=i,this._patchesByOriginDirty=!0),e.bindParameters.slot===ee.OCCLUDED_TERRAIN){if(!(e.renderOccludedMask&v))return null}else{const t=this.transparency===I.Opaque?ee.OPAQUE_TERRAIN:ee.TRANSPARENT_TERRAIN;if(e.bindParameters.slot!==t)return null}if(this.transparency===I.Invisible)return null;switch(e.output){case L.Color:case L.ColorEmission:return this._configuration.hasScreenSpaceReflections=null!=e.bindParameters.ssr.lastFrameColor,this._configuration.hasCloudsReflections=null!=e.bindParameters.cloudsFade.data,this._configuration.receiveShadows=e.bindParameters.shadowMap.ready,this._configuration.receiveAmbientOcclusion=null!=e.bindParameters.ssao,this._configuration.overlayMode=this._overlayRenderer.mode,this._updateTechnique(e.output,e.bindParameters.slot===ee.OCCLUDED_TERRAIN);case L.Shadow:case L.ShadowExcludeHighlight:return this._castShadows?(this._configuration.receiveShadows=this._configuration.receiveAmbientOcclusion=!1,this._updateTechnique(L.Shadow,!1)):null;case L.ViewshedShadow:return this._inViewshed?(this._configuration.receiveShadows=this._configuration.receiveAmbientOcclusion=!1,this._updateTechnique(L.ViewshedShadow,!1)):null;case L.Depth:return this._configuration.receiveShadows=this._configuration.receiveAmbientOcclusion=!1,this._updateTechnique(L.Depth,!1);case L.Normal:return this._configuration.receiveShadows=this._configuration.receiveAmbientOcclusion=!1,this._updateTechnique(L.Normal,!1);case L.ObjectAndLayerIdColor:return this._updateTechnique(L.ObjectAndLayerIdColor,!1);case L.Highlight:return this._overlayRenderer.hasHighlights&&0===e.bindParameters.highlightLevel?(this._configuration.receiveShadows=this._configuration.receiveAmbientOcclusion=!1,this._updateTechnique(L.Highlight,!1)):null}return null}renderNode(e,t){switch(this._updatePatchGroups(),t.useStencil=!1,e.output){case L.Color:case L.ColorEmission:{const i=e.bindParameters.slot===ee.OCCLUDED_TERRAIN?P.Occluded:P.Color;this._renderMaterialPass(e,t,i);break}case L.Depth:case L.Normal:this._renderAuxiliaryPass(e,t,P.Color,this._visiblePatchesByOrigin);break;case L.Highlight:0===e.bindParameters.highlightLevel&&this._renderAuxiliaryPass(e,t,P.Highlight,this._visiblePatchesByOrigin);break;case L.Shadow:case L.ShadowExcludeHighlight:case L.ViewshedShadow:this._renderAuxiliaryPass(e,t,null,this._allPatchesByOrigin);break;case L.ObjectAndLayerIdColor:this._renderAuxiliaryPass(e,t,P.ObjectAndLayerIdColor,this._visiblePatchesByOrigin)}}updateTileBackground(e){if(null==this._tileRenderer)return;const i=this._tileRenderer;let r;if(null!=e){const i=t.toUnitRGBA(e);r=f(i[0]||0,i[1]||0,i[2]||0)}i.setBackground(r),this._allTiles.forAll((e=>i.updateTileTexture(e,R.FADING))),this._configuration.tileBlendInput=i.backgroundIsGrid?q.GridComposite:null!=i.backgroundColor?q.ColorComposite:q.LayerOnly,this.setNeedsRender()}_updatePatchGroups(){if(this._patchesByOriginDirty&&(this._rebuildPatchGroups(),this._patchesByOriginDirty=!1,this._patchSortingDirty=!0),this._patchSortingDirty&&this.renderOrder!==D.NONE){const e=Array.from(this._visiblePatchesByOrigin.values()),t=this._stencilEnabledLayerExtents;for(const i of e)N(this.renderOrder,i,t);e.sort(((e,t)=>B(e[0],t[0],this.renderOrder))),this._visiblePatchesByOrigin=new Map(e.map((e=>[e[0].renderData.localOrigin,e]))),this._patchSortingDirty=!1}}_rebuildPatchGroups(){const e=this._rootTiles;if(null!=e){e[0]?.surface.checkAllTilesWaterproofness(),this._visiblePatchesByOrigin.clear(),this._allPatchesByOrigin.clear();for(const t of e)this._rebuildPatchGroupsForRootTile(t)}}_rebuildPatchGroupsForRootTile(e){const t=this._tileIterator;for(t.resetOne(e);!t.done;){const e=t.next(),i=e.renderData;if(!i){this._numTilesCulled++;continue}const r=i.localOrigin;if(this._castShadows||this._inViewshed){let t=this._allPatchesByOrigin.get(r);t||(t=[],this._allPatchesByOrigin.set(r,t)),t.push(e)}if(!e.visible){this._numTilesCulled++,t.skipSubtree();continue}let s=this._visiblePatchesByOrigin.get(r);s||(s=[],this._visiblePatchesByOrigin.set(r,s)),s.push(e),t.skipSubtree()}}_useStencilForTile(e){for(const t of this._stencilEnabledLayerExtents)if(e.intersectsExtent(t))return!0;return!1}_renderAuxiliaryPass(e,t,i,r){const s=e.rctx;this._passParameters.overlayContent=i,s.bindTechnique(t,e.bindParameters,this._passParameters);const n=this._stencilEnabledLayerExtents.length>0;r.forEach((r=>{this._drawParameters.origin=r[0].renderData.localOrigin,t.program.bindDraw(e.bindParameters,this._passParameters,this._drawParameters);for(let s=0;s<r.length;s++)this._renderPatch(e,t,r[s],le.TRIANGLES,n,i)})),e.rctx.bindVAO(null)}_renderMaterialPass(e,t,i){const{rctx:r}=e;this._passParameters.overlayContent=i,r.bindTechnique(t,e.bindParameters,this._passParameters),this._numTilesRendered=0,this._numTilesCulled=0,this._numOriginsRendered=0;const s=e.bindParameters.camera,n=t.program;if(this._configuration.screenSizePerspective&&this.pointsOfInterest){const e=te(this._stage.viewingMode,this._ellipsoidRadius),t=this.pointsOfInterest.centerOnSurfaceFrequent.distance;e.update({distance:t,fovY:s.fovY})}const a=this._stencilEnabledLayerExtents.length>0,o=i===P.Occluded;o&&(n.bindTexture("tex",this._emptyTex),n.setUniform3fv("textureOpacities",_),n.setUniform4fv("texOffsetAndScale",m));const l=null!=this._tileRenderer?.backgroundColor?this._tileRenderer.backgroundColor:_;this._configuration.tileBlendInput===q.ColorComposite&&n.setUniform3fv("backgroundColor",l);const c=this.wireframe?le.LINES:le.TRIANGLES;this._configuration.textureFadingEnabled&&n.bindTexture("texNext",this._emptyTex);const d=this._visiblePatchesByOrigin;for(const h of d.values()){const r=h[0].renderData.localOrigin;this._drawParameters.origin=r,t.program.bindDraw(e.bindParameters,this._passParameters,this._drawParameters),this._numOriginsRendered++;for(const s of h){const r=s.renderData,l=r.textureReference;if(null!=l){if(!o){n.setUniform4fv("texOffsetAndScale",l.offsetAndScale),n.bindTexture("tex",l.texture.texture);const e=r.textureFadeFactor,t=e<1?r.nextTextureReference:null;this._configuration.textureFadingEnabled&&null!=t&&e<1?(n.setUniform1f("fadeFactor",e),n.setUniform4fv("nextTexOffsetAndScale",t.offsetAndScale),n.setUniform3fv("nextTexOpacities",t.opacities),n.bindTexture("texNext",t.texture.texture)):n.setUniform1f("fadeFactor",1),r.textureIsFading&&this.setNeedsRender(),n.setUniform3fv("textureOpacities",l.opacities)}this._renderPatch(e,t,s,c,a,i),s.renderOrder=this._numTilesRendered,this._numTilesRendered++}}}e.rctx.bindVAO(null)}_renderPatch(e,t,i,r,s,n){const a=i.renderData,o=a.vao,l=o?.indexBuffer;if(!o||null==l)return void(E&&console.error("Rendered tile with no indices: ",i.lij," : ",a));const c=t.program;null==n||this._overlayRenderer.isEmpty||this._bindOverlayPatchData(c,a.overlay),s&&(t.useStencil=this._useStencilForTile(i),e.rctx.setPipelineState(t.getPipeline()));const d=a.geometry.indexCount;e.rctx.bindVAO(o),c.assertCompatibleVertexAttributeLocations(o),e.rctx.drawElements(r,d,l.indexType,0)}_bindOverlayPatchData(e,t){e.setUniform4fv("overlayTexOffset",t.offsets),e.setUniform4fv("overlayTexScale",t.scales)}_updateTechnique(e,t){return this._configuration.output=e,this._configuration.renderOccluded=t,this._shaderTechnique=this._techniques.releaseAndAcquire(ae,this._configuration,this._shaderTechnique),this._shaderTechnique}get test(){}};e([o({readOnly:!0})],ue.prototype,"_isGlobal",null),e([o()],ue.prototype,"renderOccludedFlags",void 0),e([o({value:!1})],ue.prototype,"renderingDisabled",null),e([o({value:!0})],ue.prototype,"visible",null),e([o()],ue.prototype,"renderPatchBorders",null),e([o()],ue.prototype,"visualizeNormals",null),e([o()],ue.prototype,"cullBackFaces",null),e([o({value:D.FRONT_TO_BACK})],ue.prototype,"renderOrder",null),e([o()],ue.prototype,"wireframe",null),ue=e([l("esri.views.3d.terrain.TerrainRenderer")],ue);const _e=p(),fe=p(),pe=p(),ge=p();export{ue as TerrainRenderer};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Color.js";import has from"../../../core/has.js";import{disposeMaybe as i}from"../../../core/maybe.js";import{MemCachePool as r}from"../../../core/MemCachePool.js";import s from"../../../core/ObjectPool.js";import{watch as n,sync as a}from"../../../core/reactiveUtils.js";import{property as o}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as l}from"../../../core/accessorSupport/decorators/subclass.js";import{IDENTITY as c}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{f as d,a as h,l as u}from"../../../chunks/vec32.js";import{ZEROS as _,fromValues as f,create as p}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as g,ZEROS as m}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{create as b,set as y}from"../../../geometry/support/aaBoundingBox.js";import{BufferViewVec3f as T}from"../../../geometry/support/buffer/BufferView.js";import{ViewingMode as R}from"../../ViewingMode.js";import{TextureUpdate as x}from"./interfaces.js";import{LayerClass as O}from"./LayerClass.js";import{OverlayContent as P}from"./OverlayContent.js";import{overlayRenderOccludedFlag as v}from"./OverlayRenderer.js";import{PatchRenderData as w}from"./PatchRenderData.js";import{RenderOrder as D}from"./RenderOrder.js";import{TerrainAttributesCache as S}from"./TerrainAttributesCache.js";import{enableTerrainInternalChecks as E}from"./terrainUtils.js";import{TileRenderer as C}from"./TileRenderer.js";import{TileUpdate as A}from"./TileUpdate.js";import{IteratorPreorder as j,sortTiles as N,compareTiles as B}from"./tileUtils.js";import{TransparencyMode as I}from"./TransparencyMode.js";import{componentMinimalSizeForIntersectionData as F,ComponentIntersectionData as U}from"../webgl-engine/collections/Component/ComponentIntersectionData.js";import{ShaderOutput as L}from"../webgl-engine/core/shaderLibrary/ShaderOutput.js";import{T as G}from"../../../chunks/Terrain.glsl.js";import{TileBlendInput as M}from"../webgl-engine/core/shaderLibrary/terrain/TileBlendInput.js";import{SyncPrepareRenderPlugin as q,ConsumesDepth as k,ConsumesNone as z}from"../webgl-engine/effects/RenderPlugin.js";import{Vertices as V}from"../webgl-engine/lib/Attribute.js";import{RenderRequestType as H}from"../webgl-engine/lib/basicInterfaces.js";import{createEmptyTexture as Y}from"../webgl-engine/lib/glUtil3D.js";import{newIntersectorResult as Q}from"../webgl-engine/lib/Intersector.js";import{IntersectorType as W,StoreResults as X}from"../webgl-engine/lib/IntersectorInterfaces.js";import{RenderOccludedFlag as K}from"../webgl-engine/lib/Material.js";import{intersectAabbInvDirBefore as Z,intersectTriangles as J,MeshIntersectionOptions as $}from"../webgl-engine/lib/RayIntersections.js";import{RenderSlot as ee}from"../webgl-engine/lib/RenderSlot.js";import{getSettings as te}from"../webgl-engine/lib/screenSizePerspectiveUtils.js";import{VertexAttribute as ie}from"../webgl-engine/lib/VertexAttribute.js";import{terrainId as re,getVerticalOffsetTerrain as se}from"../webgl-engine/lib/verticalOffsetUtils.js";import{DrawParameters as ne}from"../webgl-engine/materials/DrawParameters.js";import{TerrainTechnique as ae}from"../webgl-engine/shaders/TerrainTechnique.js";import{TerrainTechniqueConfiguration as oe}from"../webgl-engine/shaders/TerrainTechniqueConfiguration.js";import{PrimitiveType as le}from"../../webgl/enums.js";const ce=7,de=10,he=b();let ue=class extends q{get _isGlobal(){return this._stage.viewingMode===R.Global}get _techniques(){return this._context.techniques}get _rctx(){return this._context.renderContext.rctx}constructor(e,t,i,n,a){super({}),this._overlayRenderer=e,this._stage=t,this._allTiles=i,this._ellipsoidRadius=n,this.type=W.TERRAIN,this.isGround=!0,this._tileSize=256,this._configuration=new oe,this._passParameters=new G,this._drawParameters=new ne,this._renderDataPool=new s(w),this._visiblePatchesByOrigin=new Map,this._allPatchesByOrigin=new Map,this._patchesByOriginDirty=!0,this._patchSortingDirty=!0,this._tileIterator=new j,this._castShadows=!1,this._inViewshed=!1,this._emptyTex=null,this._tileRenderer=null,this._stencilEnabledLayerExtents=new Array,this._numTilesRendered=0,this._numTilesCulled=0,this._numOriginsRendered=0,this.renderOccludedFlags=K.Occlude,this.produces=new Map([[ee.OPAQUE_TERRAIN,()=>this._produces()],[ee.TRANSPARENT_TERRAIN,()=>this._produces()],[ee.OCCLUDED_TERRAIN,()=>this._produces()]]),this._tileTextureCache=new r(((e,t)=>a.newCache(e,t)),"TileTexture"),this.tileGeometryCache=new S(a)}normalizeCtorArgs(){return{}}initialize(){this._stage.addRenderPlugin(this),this.addHandles(n((()=>this._overlayRenderer.rendersOccludedDraped),(e=>{this.renderOccludedFlags=e?v:K.Occlude,this.setNeedsRender()}),a))}destroy(){this._stage.removeRenderPlugin(this),this._tileTextureCache.destroy(),this.tileGeometryCache.destroy()}_produces(){return this.visible&&!!this._rootTiles&&!this.renderingDisabled}consumes(){return this._overlayRenderer.hasWater?k:z}set renderingDisabled(e){this._set("renderingDisabled",!!e),this.setDirty()}set visible(e){this._set("visible",!!e),this.setDirty()}updateHeading(e){this._tileRenderer?.updateHeading(e)}set transparency(e){this._configuration.transparencyMode!==e&&(this._configuration.transparencyMode=e,this.setNeedsRender())}get transparency(){return this._configuration.transparencyMode}get renderPatchBorders(){return!!this._configuration.tileBorders}set renderPatchBorders(e){this._configuration.tileBorders!==e&&(this._configuration.tileBorders=e,this.setNeedsRender(),this.notifyChange("renderPatchBorders"))}get visualizeNormals(){return!!this._configuration.visualizeNormals}set visualizeNormals(e){this._configuration.visualizeNormals!==e&&(this._configuration.visualizeNormals=e,this.setNeedsRender(),this.notifyChange("visualizeNormals"))}get cullBackFaces(){return this._configuration.backfaceCullingEnabled}set cullBackFaces(e){this._configuration.backfaceCullingEnabled!==e&&(this._configuration.backfaceCullingEnabled=e,this.notifyChange("cullBackFaces"),this.setNeedsRender())}set renderOrder(e){this._set("renderOrder",e),this._setSortingDirty()}get layerUid(){return re}get slicePlaneEnabled(){return this._configuration.hasSlicePlane}set slicePlaneEnabled(e){this._configuration.hasSlicePlane!==e&&(this._configuration.hasSlicePlane=e,this.setNeedsRender())}set textureFadingEnabled(e){this._configuration.textureFadingEnabled!==e&&(this._configuration.textureFadingEnabled=e,this.setNeedsRender())}set pbrMode(e){this._configuration.pbrMode!==e&&(this._configuration.pbrMode=e,this.setNeedsRender())}setDebugScreenSizePerspective(e){this._configuration.screenSizePerspective!==e&&(this._configuration.screenSizePerspective=e,this.setNeedsRender())}setRootTiles(e){this._rootTiles=e,this.setDirty()}setStencilEnabledLayerExtents(e){this._stencilEnabledLayerExtents=e,this._setSortingDirty()}setTileSize(e){this._tileSize=e,null!=this._tileRenderer&&(this._tileRenderer.tileSize=e),this.setDirty()}_ensureRenderData(e){e.renderData||(e.renderData=this._renderDataPool.acquire(),e.renderData.init(e,this._getLocalOriginOfTile(e)))}loadTile(e){this._ensureRenderData(e),this.updateTileGeometryState(e),this.reuseTextureFromParent(e)||this.updateTileTexture(e,A.TEXTURE_FADING)}reuseTextureFromParent(e){const t=e.parent;if(!t)return!1;const i=g(1&e.lij[2]?.5:0,1&e.lij[1]?0:.5,.5,.5);return t.renderData?.reuseTexture(e.renderData,i)??!1}updateTileTexture(e,t){null!=this._tileRenderer&&(this._tileRenderer.updateTileTexture(e,t===A.TEXTURE_FADING?x.FADING:x.UNFADED),this.setNeedsRender(),e.resetPendingUpdate(t))}updateTileGeometryState(e){for(const i of e.layerInfo[O.ELEVATION])i.pendingUpdates&=~A.GEOMETRY;e.resetPendingUpdate(A.GEOMETRY);const t=e.renderData.updateGeometryState();return t&&this.setDirty(),t}updateGeometryIfNeeded(e){e.loaded&&e.renderData.updateGeometryIfNeeded(this._rctx)}unloadTile(e){const t=e.renderData;t&&(t.releaseGeometry(),this._renderDataPool.release(t),t.clear(),e.renderData=null,e.setMemoryDirty(),this.setDirty())}_getLocalOriginOfTile(e){const t=de-ce,i=Math.max(0,Math.floor((e.level-t)/ce)*ce);if(this._isGlobal&&0===i)return _;for(;e.parent&&e.level>i;)e=e.parent;return e.centerAtSeaLevel}getStats(){return{numTilesRendered:this._numTilesRendered,numTilesCulled:this._numTilesCulled,numOriginsRendered:this._numOriginsRendered}}set wireframe(e){this._get("wireframe")!==e&&(this._set("wireframe",e),this.setNeedsRender())}setDirty(e=H.UPDATE){this._patchesByOriginDirty=!0,this._context.requestRender(e)}_setSortingDirty(e=H.UPDATE){this._patchSortingDirty=!0,this._context.requestRender(e)}setNeedsRender(e=H.UPDATE){this._context.requestRender(e)}initializeRenderContext(e){this._context=e,this._tileRenderer=new C(this._rctx,this._tileSize,this._techniques,this._tileTextureCache),this.updateTileBackground(),this._emptyTex=Y(this._rctx)}uninitializeRenderContext(){this._emptyTex=i(this._emptyTex),this._tileRenderer=i(this._tileRenderer)}intersect(e,t,i,r){if(!this._rootTiles||e.options.selectOpaqueTerrainOnly&&e.options.selectionMode&&this.transparency!==I.Opaque)return;const s=_e,n=fe;d(s,r,i),h(n,1/s[0],1/s[1],1/s[2]);const a=e.results.min,o=e.results.max,l=e.results.ground,_=e.options.store===X.MIN,f=!!e.results.ground.target,p=se(e.verticalOffset),g=e.tolerance;let m,b=_&&null!=a.dist?a.dist:1/0;const R=e.options,x=R.normalRequired||!R.backfacesTerrain,O=new $(!1,x),P=h=>{const f=h.renderData;if(!f?.vao)return;const P=f.geometry;y(he,P.boundingBox);const v=f.localOrigin;null!=p&&(p.localOrigin=v,p.applyToAabb(he));const w=he;if(pe[0]=i[0]-v[0],pe[1]=i[1]-v[1],pe[2]=i[2]-v[2],!Z(w,pe,n,g,b))return;const D=(e,t,i)=>{e.set(this.type,h,t,i,c),b=_&&null!=a.dist?a.dist:1/0},S=(n,c,d)=>{if((!x||null!=d)&&n>=0&&(R.backfacesTerrain||u(d,s)<0)&&(R.invisibleTerrain||!R.selectionMode||null==t||t(i,r,n))){if((null==l.dist||n<l.dist)&&D(l,n,d),R.isFiltered)return;R.store===X.ALL&&(null==m?(m=Q(e.ray),D(m,n,d),e.results.all.push(m)):n<m.dist&&D(m,n,d)),(null==a.dist||n<a.dist)&&D(a,n,d),R.store!==X.MIN&&(null==o.dist||n>o.dist)&&D(o,n,d)}},E=ge;d(E,r,v);const{indices:C,indexCount:A}=P,j=P.vertexAttributes,N=j.getField(ie.POSITION,T),B=new V(N.typedBuffer,3,j.stride/4),I=A/3;if(!p&&I>F){const e=h.renderData;null==e.intersectionData&&(e.intersectionData=new U(C,0,I,B)),e.intersectionData.intersectRay(pe,E,O,S)}else J(pe,E,0,I,C,B,p,O,S)},v=this._rootTiles;if(null!=v){(()=>{const t=this._tileIterator;t.reset(v);const r=e.options.invisibleTerrain;for(let e=t.next();e;e=t.next())!(e.visible||r&&e.intersectsClippingArea)||null==p&&!e.intersectsRay(i,s,g,b)||f&&this._useStencilForTile(e)?t.skipSubtree():P(e)})()}}processScaleRangeQueries(e,t){if(!t.done)for(this._updatePatchGroups();e.updating&&!t.done;){e.prepare();for(const t of this._visiblePatchesByOrigin.values())for(const i of t)null!=i.renderData?.textureReference&&e.queriesForTile(i);e.process(),t.madeProgress()}}prepareTechnique(e){const t=has("enable-feature:terrain-shadows")&&e.bindParameters.shadowMap.enabled;t!==this._castShadows&&(this._castShadows=t,this._patchesByOriginDirty=!0);const i=e.bindParameters.viewshedEnabled;if(this._inViewshed!==i&&(this._inViewshed=i,this._patchesByOriginDirty=!0),e.bindParameters.slot===ee.OCCLUDED_TERRAIN){if(!(e.renderOccludedMask&v))return null}else{const t=this.transparency===I.Opaque?ee.OPAQUE_TERRAIN:ee.TRANSPARENT_TERRAIN;if(e.bindParameters.slot!==t)return null}if(this.transparency===I.Invisible)return null;switch(e.output){case L.Color:case L.ColorEmission:return this._configuration.hasScreenSpaceReflections=null!=e.bindParameters.ssr.lastFrameColor,this._configuration.hasCloudsReflections=null!=e.bindParameters.cloudsFade.data,this._configuration.receiveShadows=e.bindParameters.shadowMap.ready,this._configuration.receiveAmbientOcclusion=null!=e.bindParameters.ssao,this._configuration.overlayMode=this._overlayRenderer.mode,this._updateTechnique(e.output,e.bindParameters.slot===ee.OCCLUDED_TERRAIN);case L.Shadow:case L.ShadowExcludeHighlight:return this._castShadows?(this._configuration.receiveShadows=this._configuration.receiveAmbientOcclusion=!1,this._updateTechnique(L.Shadow,!1)):null;case L.ViewshedShadow:return this._inViewshed?(this._configuration.receiveShadows=this._configuration.receiveAmbientOcclusion=!1,this._updateTechnique(L.ViewshedShadow,!1)):null;case L.Depth:case L.Normal:return this._configuration.receiveShadows=this._configuration.receiveAmbientOcclusion=!1,this._updateTechnique(e.output,!1);case L.ObjectAndLayerIdColor:return this._updateTechnique(L.ObjectAndLayerIdColor,!1);case L.Highlight:return this._overlayRenderer.hasHighlights&&0===e.bindParameters.highlightLevel?(this._configuration.receiveShadows=this._configuration.receiveAmbientOcclusion=!1,this._updateTechnique(L.Highlight,!1)):null}return null}renderNode(e,t){switch(this._updatePatchGroups(),t.useStencil=!1,e.output){case L.Color:case L.ColorEmission:{const i=e.bindParameters.slot===ee.OCCLUDED_TERRAIN?P.Occluded:P.Color;this._renderMaterialPass(e,t,i);break}case L.Depth:case L.Normal:this._renderAuxiliaryPass(e,t,P.Color,this._visiblePatchesByOrigin);break;case L.Highlight:0===e.bindParameters.highlightLevel&&this._renderAuxiliaryPass(e,t,P.Highlight,this._visiblePatchesByOrigin);break;case L.Shadow:case L.ShadowExcludeHighlight:case L.ViewshedShadow:this._renderAuxiliaryPass(e,t,null,this._allPatchesByOrigin);break;case L.ObjectAndLayerIdColor:this._renderAuxiliaryPass(e,t,P.ObjectAndLayerIdColor,this._visiblePatchesByOrigin)}}updateTileBackground(e){if(null==this._tileRenderer)return;const i=this._tileRenderer;let r;if(null!=e){const i=t.toUnitRGBA(e);r=f(i[0]||0,i[1]||0,i[2]||0)}i.setBackground(r),this._allTiles.forAll((e=>i.updateTileTexture(e,x.FADING))),this._configuration.tileBlendInput=i.backgroundIsGrid?M.GridComposite:null!=i.backgroundColor?M.ColorComposite:M.LayerOnly,this.setNeedsRender()}_updatePatchGroups(){if(this._patchesByOriginDirty&&(this._rebuildPatchGroups(),this._patchesByOriginDirty=!1,this._patchSortingDirty=!0),this._patchSortingDirty&&this.renderOrder!==D.NONE){const e=Array.from(this._visiblePatchesByOrigin.values()),t=this._stencilEnabledLayerExtents;for(const i of e)N(this.renderOrder,i,t);e.sort(((e,t)=>B(e[0],t[0],this.renderOrder))),this._visiblePatchesByOrigin=new Map(e.map((e=>[e[0].renderData.localOrigin,e]))),this._patchSortingDirty=!1}}_rebuildPatchGroups(){const e=this._rootTiles;if(null!=e){e[0]?.surface.checkAllTilesWaterproofness(),this._visiblePatchesByOrigin.clear(),this._allPatchesByOrigin.clear();for(const t of e)this._rebuildPatchGroupsForRootTile(t)}}_rebuildPatchGroupsForRootTile(e){const t=this._tileIterator;for(t.resetOne(e);!t.done;){const e=t.next(),i=e.renderData;if(!i){this._numTilesCulled++;continue}const r=i.localOrigin;if(this._castShadows||this._inViewshed){let t=this._allPatchesByOrigin.get(r);t||(t=[],this._allPatchesByOrigin.set(r,t)),t.push(e)}if(!e.visible){this._numTilesCulled++,t.skipSubtree();continue}let s=this._visiblePatchesByOrigin.get(r);s||(s=[],this._visiblePatchesByOrigin.set(r,s)),s.push(e),t.skipSubtree()}}_useStencilForTile(e){for(const t of this._stencilEnabledLayerExtents)if(e.intersectsExtent(t))return!0;return!1}_renderAuxiliaryPass(e,t,i,r){const s=e.rctx;this._passParameters.overlayContent=i,s.bindTechnique(t,e.bindParameters,this._passParameters);const n=this._stencilEnabledLayerExtents.length>0;r.forEach((r=>{this._drawParameters.origin=r[0].renderData.localOrigin,t.program.bindDraw(e.bindParameters,this._passParameters,this._drawParameters);for(let s=0;s<r.length;s++)this._renderPatch(e,t,r[s],le.TRIANGLES,n,i)})),e.rctx.bindVAO(null)}_renderMaterialPass(e,t,i){const{rctx:r}=e;this._passParameters.overlayContent=i,r.bindTechnique(t,e.bindParameters,this._passParameters),this._numTilesRendered=0,this._numTilesCulled=0,this._numOriginsRendered=0;const s=e.bindParameters.camera,n=t.program;if(this._configuration.screenSizePerspective&&this.pointsOfInterest){const e=te(this._stage.viewingMode,this._ellipsoidRadius),t=this.pointsOfInterest.centerOnSurfaceFrequent.distance;e.update({distance:t,fovY:s.fovY})}const a=this._stencilEnabledLayerExtents.length>0,o=i===P.Occluded;o&&(n.bindTexture("tex",this._emptyTex),n.setUniform3fv("textureOpacities",_),n.setUniform4fv("texOffsetAndScale",m));const l=null!=this._tileRenderer?.backgroundColor?this._tileRenderer.backgroundColor:_;this._configuration.tileBlendInput===M.ColorComposite&&n.setUniform3fv("backgroundColor",l);const c=this.wireframe?le.LINES:le.TRIANGLES;this._configuration.textureFadingEnabled&&n.bindTexture("texNext",this._emptyTex);const d=this._visiblePatchesByOrigin;for(const h of d.values()){const r=h[0].renderData.localOrigin;this._drawParameters.origin=r,t.program.bindDraw(e.bindParameters,this._passParameters,this._drawParameters),this._numOriginsRendered++;for(const s of h){const r=s.renderData,l=r.textureReference;if(null!=l){if(!o){n.setUniform4fv("texOffsetAndScale",l.offsetAndScale),n.bindTexture("tex",l.texture.texture);const e=r.textureFadeFactor,t=e<1?r.nextTextureReference:null;this._configuration.textureFadingEnabled&&null!=t&&e<1?(n.setUniform1f("fadeFactor",e),n.setUniform4fv("nextTexOffsetAndScale",t.offsetAndScale),n.setUniform3fv("nextTexOpacities",t.opacities),n.bindTexture("texNext",t.texture.texture)):n.setUniform1f("fadeFactor",1),r.textureIsFading&&this.setNeedsRender(),n.setUniform3fv("textureOpacities",l.opacities)}this._renderPatch(e,t,s,c,a,i),s.renderOrder=this._numTilesRendered,this._numTilesRendered++}}}e.rctx.bindVAO(null)}_renderPatch(e,t,i,r,s,n){const a=i.renderData,o=a.vao,l=o?.indexBuffer;if(!o||null==l)return void(E&&console.error("Rendered tile with no indices: ",i.lij," : ",a));const c=t.program;null==n||this._overlayRenderer.isEmpty||this._bindOverlayPatchData(c,a.overlay),s&&(t.useStencil=this._useStencilForTile(i),e.rctx.setPipelineState(t.getPipeline()));const d=a.geometry.indexCount;e.rctx.bindVAO(o),c.assertCompatibleVertexAttributeLocations(o),e.rctx.drawElements(r,d,l.indexType,0)}_bindOverlayPatchData(e,t){e.setUniform4fv("overlayTexOffset",t.offsets),e.setUniform4fv("overlayTexScale",t.scales)}_updateTechnique(e,t){return this._configuration.output=e,this._configuration.renderOccluded=t,this._shaderTechnique=this._techniques.releaseAndAcquire(ae,this._configuration,this._shaderTechnique),this._shaderTechnique}get test(){}};e([o({readOnly:!0})],ue.prototype,"_isGlobal",null),e([o()],ue.prototype,"renderOccludedFlags",void 0),e([o({value:!1})],ue.prototype,"renderingDisabled",null),e([o({value:!0})],ue.prototype,"visible",null),e([o()],ue.prototype,"renderPatchBorders",null),e([o()],ue.prototype,"visualizeNormals",null),e([o()],ue.prototype,"cullBackFaces",null),e([o({value:D.FRONT_TO_BACK})],ue.prototype,"renderOrder",null),e([o()],ue.prototype,"wireframe",null),ue=e([l("esri.views.3d.terrain.TerrainRenderer")],ue);const _e=p(),fe=p(),pe=p(),ge=p();export{ue as TerrainRenderer};