@arcgis/core 5.0.0-next.36 → 5.0.0-next.38

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 (270) hide show
  1. package/WebLinkChart.js +1 -1
  2. package/analysis/ShadowCast/types.d.ts +2 -0
  3. package/applications/Components/analysisUtils.d.ts +1 -0
  4. package/applications/Components/analysisUtils.js +1 -1
  5. package/applications/Components/testUtils.d.ts +4 -0
  6. package/applications/Components/testUtils.js +5 -0
  7. package/arcade/arcadeAsyncRuntime.js +1 -1
  8. package/arcade/arcadeCompiler.js +1 -1
  9. package/arcade/featureSetUtils.js +1 -1
  10. package/arcade/featureset/actions/Adapted.js +1 -1
  11. package/arcade/featureset/actions/AttributeFilter.js +1 -1
  12. package/arcade/featureset/actions/GroupBy.js +1 -1
  13. package/arcade/featureset/actions/SpatialFilter.js +1 -1
  14. package/arcade/featureset/sources/FeatureLayerDynamic.js +1 -1
  15. package/arcade/featureset/sources/FeatureLayerMemory.js +1 -1
  16. package/arcade/featureset/sources/FeatureLayerOGC.js +1 -1
  17. package/arcade/featureset/sources/FeatureLayerRelated.js +1 -1
  18. package/arcade/featureset/support/FeatureSet.js +1 -1
  19. package/arcade/featureset/support/FeatureSetIterator.js +1 -1
  20. package/assets/esri/core/workers/RemoteClient.js +1 -1
  21. package/assets/esri/core/workers/chunks/014dbe6fa93a277b08f7.js +1 -0
  22. package/assets/esri/core/workers/chunks/{51355866a0dcf41cfded.js → 0a5427127634738aa239.js} +1 -1
  23. package/assets/esri/core/workers/chunks/{c7c721de93bc8688e13c.js → 1d4ea8db272655c0608c.js} +1 -1
  24. package/assets/esri/core/workers/chunks/1d566539ff6fb6ac798c.js +1 -0
  25. package/assets/esri/core/workers/chunks/1de216d9850c39c1735d.js +1 -0
  26. package/assets/esri/core/workers/chunks/262232437d37a7460b11.js +1 -0
  27. package/assets/esri/core/workers/chunks/2795e491f803654413d2.js +1 -0
  28. package/assets/esri/core/workers/chunks/2f9129003f77bfeab2f9.js +1 -0
  29. package/assets/esri/core/workers/chunks/{1817cf11e85afca947d3.js → 328106e181e5957ceaa5.js} +1 -1
  30. package/assets/esri/core/workers/chunks/{d3db7244fac7398cc700.js → 4b6a44c6265c8959abd8.js} +1 -1
  31. package/assets/esri/core/workers/chunks/50ffb22c48fadd36c748.js +1 -0
  32. package/assets/esri/core/workers/chunks/{f1ac1c8b1331ec79e898.js → 59ce992d3a5e7c32b9fb.js} +1 -1
  33. package/assets/esri/core/workers/chunks/{8a946cbc816f373c136b.js → 5e30acfda04f7fc2b676.js} +1 -1
  34. package/assets/esri/core/workers/chunks/6330d8767ba1d5329daa.js +1 -0
  35. package/assets/esri/core/workers/chunks/{3f03165487c1c2340fff.js → 690a40d2eef52bfc149f.js} +1 -1
  36. package/assets/esri/core/workers/chunks/{dd34d56caafa38d4b8e4.js → 7aa730e5ac7b268e3c98.js} +1 -1
  37. package/assets/esri/core/workers/chunks/{b451dc416eebd0931ef8.js → 7ab237d19b84d89ff483.js} +7 -7
  38. package/assets/esri/core/workers/chunks/{1fa55d4c4b092a98bdd7.js → b56c07c0b43cb1999070.js} +1 -1
  39. package/assets/esri/core/workers/chunks/{bfb9cbe59d36d18f9157.js → cda5c95fd49b8901f7d4.js} +1 -1
  40. package/assets/esri/core/workers/chunks/{c9e7cc5d853908ab5b2f.js → ce99abfdcd71ff9e4e36.js} +1 -1
  41. package/assets/esri/core/workers/chunks/{726a797f5df7eeee0b3d.js → d786b17cc9062b1450ac.js} +1 -1
  42. package/assets/esri/core/workers/chunks/{52c8687b473c9953c2f2.js → d9958654c6438f28237b.js} +1 -1
  43. package/assets/esri/core/workers/chunks/{2e76fbd3c874300fc4a7.js → de3da4d31a7529761565.js} +1 -1
  44. package/assets/esri/core/workers/chunks/{eb6218634a492667506a.js → e501d68a1464805c4b4e.js} +1 -1
  45. package/assets/esri/core/workers/chunks/{33431e8131f6017de2f9.js → e7f4d135ef9665de1468.js} +1 -1
  46. package/assets/esri/core/workers/chunks/{d8623f5f13a084e439c2.js → e9bc3c6482ba778c9349.js} +37 -37
  47. package/assets/esri/core/workers/chunks/{7420fa18ba12014b22ea.js → ee67c8a7c1f8b482cd99.js} +1 -1
  48. package/assets/esri/core/workers/chunks/{abb05a903440d97a6a74.js → f441fc74451330384fb0.js} +1 -1
  49. package/assets/esri/core/workers/chunks/f609b256df9eb3803464.js +1 -0
  50. package/assets/esri/core/workers/chunks/f97a7cb367634353177d.js +1 -0
  51. package/chunks/CloudsComposition.glsl.js +1 -1
  52. package/chunks/ComponentShader.glsl.js +2 -2
  53. package/chunks/DefaultMaterial.glsl.js +1 -1
  54. package/chunks/GaussianSplat.glsl.js +2 -2
  55. package/chunks/Laserlines.glsl.js +1 -1
  56. package/chunks/Path.glsl.js +1 -1
  57. package/chunks/RealisticTree.glsl.js +1 -1
  58. package/chunks/Terrain.glsl.js +34 -36
  59. package/chunks/WaterSurface.glsl.js +1 -1
  60. package/chunks/boundedPlane.js +1 -1
  61. package/chunks/cameraUtilsSpherical.js +1 -1
  62. package/chunks/vec32.js +1 -1
  63. package/config.js +1 -1
  64. package/core/has.js +1 -1
  65. package/core/iteratorUtils.js +1 -1
  66. package/core/libs/gl-matrix-2/math/quat.js +1 -1
  67. package/core/libs/gl-matrix-2/math/vec3.js +1 -1
  68. package/geometry/support/buffer/BufferView.js +1 -1
  69. package/geometry/support/curves/densifyCurvedGeometry.js +1 -1
  70. package/geometry/support/lineSegment.js +1 -1
  71. package/geometry/support/meshUtils/merge.js +1 -1
  72. package/geometry/support/sphere.js +1 -1
  73. package/interfaces.d.ts +59 -5
  74. package/kernel.js +1 -1
  75. package/layers/Lyr3DWasmPerSceneView.js +1 -1
  76. package/layers/VoxelWasmPerSceneView.js +1 -1
  77. package/layers/knowledgeGraph/layerUtils.js +1 -1
  78. package/layers/orientedImagery/transformations/worldToImage.js +1 -1
  79. package/layers/support/csvUtils.js +1 -1
  80. package/layers/video/VideoController.js +1 -1
  81. package/layers/voxel/VoxelVolume.js +1 -1
  82. package/package.json +5 -5
  83. package/support/revision.js +1 -1
  84. package/support/tests/meshUtils.js +5 -0
  85. package/support/tests/serviceMockDependencies.js +5 -0
  86. package/support/tests/setupServiceMocksMesh.js +5 -0
  87. package/views/2d/analysis/ElevationProfile/ElevationProfileLineVisualization2D.js +1 -1
  88. package/views/2d/interactive/SegmentLabels2D.js +1 -1
  89. package/views/2d/layers/features/FeaturePipelineWorker.js +1 -1
  90. package/views/3d/FocusAreasView.js +1 -1
  91. package/views/3d/analysis/AreaMeasurement/support/MeasurementData.js +1 -1
  92. package/views/3d/analysis/Dimension/DimensionTool.js +1 -1
  93. package/views/3d/analysis/Dimension/lengthDimensionConstraintUtils.js +1 -1
  94. package/views/3d/analysis/Dimension/lengthDimensionUtils.js +1 -1
  95. package/views/3d/analysis/ElevationProfile/ElevationProfileLineVisualization3D.js +1 -1
  96. package/views/3d/analysis/ElevationProfile/ElevationProfileVisualization3D.js +1 -1
  97. package/views/3d/analysis/ElevationProfileAnalysisView3D.js +1 -1
  98. package/views/3d/analysis/LineOfSight/LineOfSightController.js +1 -1
  99. package/views/3d/analysis/LineOfSight/LineOfSightIntersectionResult.js +1 -1
  100. package/views/3d/analysis/Slice/SliceTool.js +1 -1
  101. package/views/3d/analysis/Slice/sliceToolUtils.js +1 -1
  102. package/views/3d/analysis/Viewshed/ViewshedScaleOrientManipulation.js +1 -1
  103. package/views/3d/analysis/Viewshed/ViewshedSubTool.js +1 -1
  104. package/views/3d/analysis/Viewshed/ViewshedSubVisualization.js +1 -1
  105. package/views/3d/analysis/Viewshed/ViewshedTool.js +1 -1
  106. package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementCutFillVisualization.js +1 -1
  107. package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementShiftTool.js +1 -1
  108. package/views/3d/animation/pointToPoint/Camera.js +1 -1
  109. package/views/3d/camera/constraintUtils/distance.js +1 -1
  110. package/views/3d/camera/constraintUtils/tilt.js +1 -1
  111. package/views/3d/environment/ChapmanAtmosphere.js +1 -1
  112. package/views/3d/environment/CloudsParameters.js +1 -1
  113. package/views/3d/environment/EnvironmentManager.js +1 -1
  114. package/views/3d/environment/MarsAtmosphere.js +1 -1
  115. package/views/3d/interactive/SegmentLabels3D.js +1 -1
  116. package/views/3d/interactive/editingTools/manipulations/MoveZManipulation.js +1 -1
  117. package/views/3d/interactive/editingTools/media/MediaElementManipulator3D.js +1 -1
  118. package/views/3d/interactive/editingTools/reshape/edgeOffsetUtils.js +1 -1
  119. package/views/3d/interactive/measurementTools/directLineMeasurement3D/DirectLineMeasurement3DTool.js +1 -1
  120. package/views/3d/interactive/visualElements/MeasurementArrowVisualElement.js +1 -1
  121. package/views/3d/interactive/visualElements/RightAngleQuadVisualElement.js +1 -1
  122. package/views/3d/layers/FeatureLikeLayerView3D.js +1 -1
  123. package/views/3d/layers/FlowSubView3D.js +1 -1
  124. package/views/3d/layers/GraphicsLayerView3D.js +1 -1
  125. package/views/3d/layers/I3SMeshView3D.js +1 -1
  126. package/views/3d/layers/ImagerySubView3D.js +1 -1
  127. package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
  128. package/views/3d/layers/PointCloudWorker.js +1 -1
  129. package/views/3d/layers/RouteLayerView3D.js +1 -1
  130. package/views/3d/layers/graphics/Graphics3DGraphicsPipeline.js +1 -1
  131. package/views/3d/layers/graphics/Graphics3DObject3DGraphicLayer.js +1 -1
  132. package/views/3d/layers/graphics/Graphics3DScaleVisibility.js +1 -1
  133. package/views/3d/layers/graphics/objectResourceUtils.js +1 -1
  134. package/views/3d/layers/graphics/pipeline/rendering/DirectRenderer.js +1 -1
  135. package/views/3d/layers/i3s/I3SViewportQueries.js +1 -1
  136. package/views/3d/layers/i3s/PointCloudRenderer.js +1 -1
  137. package/views/3d/layers/support/FeatureTileMeasurements3D.js +1 -1
  138. package/views/3d/layers/support/FeatureTileVisibility3D.js +1 -1
  139. package/views/3d/state/Frustum.js +1 -1
  140. package/views/3d/state/ViewStateManager.js +1 -1
  141. package/views/3d/state/controllers/FovController.js +1 -1
  142. package/views/3d/state/controllers/GamepadKeyboardController.js +1 -1
  143. package/views/3d/state/controllers/momentum/ZoomPlanarMomentumController.js +1 -1
  144. package/views/3d/support/FrustumExtentIntersection.js +1 -1
  145. package/views/3d/support/cameraUtils.js +1 -1
  146. package/views/3d/support/flow/FlowSubViewTiles3D.js +1 -1
  147. package/views/3d/support/gaussianSplatting/GaussianSplatDataStore.js +1 -1
  148. package/views/3d/support/gaussianSplatting/GaussianSplatFadeHelper.js +1 -1
  149. package/views/3d/support/intersectionUtils.js +1 -1
  150. package/views/3d/support/pointsOfInterest/CameraOnSurface.js +1 -1
  151. package/views/3d/support/pointsOfInterest/CenterOnSurface.js +1 -1
  152. package/views/3d/support/pointsOfInterest/Focus.js +1 -1
  153. package/views/3d/support/viewpointUtils.js +1 -1
  154. package/views/3d/terrain/OverlayManager.js +1 -1
  155. package/views/3d/terrain/OverlayRenderer.js +1 -1
  156. package/views/3d/terrain/PatchRenderData.js +1 -1
  157. package/views/3d/terrain/SphericalPatch.js +1 -1
  158. package/views/3d/terrain/TerrainRenderer.js +1 -1
  159. package/views/3d/terrain/TerrainSurface.js +1 -1
  160. package/views/3d/terrain/Tile.js +1 -1
  161. package/views/3d/terrain/TileCompositor.js +1 -1
  162. package/views/3d/webgl/RenderCamera.js +1 -1
  163. package/views/3d/webgl-engine/collections/Component/Material/ComponentMaterial.js +1 -1
  164. package/views/3d/webgl-engine/collections/Component/Material/ComponentTechnique.js +1 -1
  165. package/views/3d/webgl-engine/collections/Component/Material/ComponentTechniqueConfiguration.js +1 -1
  166. package/views/3d/webgl-engine/core/renderPasses/RenderPassManager.js +1 -1
  167. package/views/3d/webgl-engine/core/shaderLibrary/Slice.glsl.js +4 -7
  168. package/views/3d/webgl-engine/core/shaderLibrary/TextureBackedBuffer.glsl.js +4 -4
  169. package/views/3d/webgl-engine/core/shaderLibrary/TextureBackedBufferFields.glsl.js +1 -1
  170. package/views/3d/webgl-engine/core/shaderLibrary/hud/HUD.glsl.js +6 -6
  171. package/views/3d/webgl-engine/core/shaderLibrary/shading/EvaluateAmbientLighting.glsl.js +4 -4
  172. package/views/3d/webgl-engine/core/shaderLibrary/shading/EvaluateSceneLighting.glsl.js +19 -15
  173. package/views/3d/webgl-engine/core/shaderLibrary/shading/MainLighting.glsl.js +2 -2
  174. package/views/3d/webgl-engine/core/shaderLibrary/terrain/Overlay.glsl.js +1 -1
  175. package/views/3d/webgl-engine/core/shaderLibrary/terrain/TerrainTexture.glsl.js +5 -5
  176. package/views/3d/webgl-engine/core/shaderLibrary/terrain/TileBackground.glsl.js +14 -14
  177. package/views/3d/webgl-engine/core/shaderLibrary/util/BlendModes.glsl.js +16 -37
  178. package/views/3d/webgl-engine/core/shaderLibrary/util/GaussianSplatUnpacking.glsl.js +8 -8
  179. package/views/3d/webgl-engine/effects/RenderPluginManager.js +1 -1
  180. package/views/3d/webgl-engine/effects/debug/RenderNodeVisualizerNode.js +1 -1
  181. package/views/3d/webgl-engine/effects/geometry/RenderOccludedRenderNode.js +1 -1
  182. package/views/3d/webgl-engine/effects/haze/Haze.js +1 -1
  183. package/views/3d/webgl-engine/effects/transparency/OITBlend.js +1 -1
  184. package/views/3d/webgl-engine/lib/BindParameters.js +1 -1
  185. package/views/3d/webgl-engine/lib/CutFillColor.js +1 -1
  186. package/views/3d/webgl-engine/lib/GaussianSplatRenderNode.js +1 -1
  187. package/views/3d/webgl-engine/lib/Normals.js +1 -1
  188. package/views/3d/webgl-engine/lib/Object3D.js +1 -1
  189. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  190. package/views/3d/webgl-engine/lib/RenderingContext.js +1 -1
  191. package/views/3d/webgl-engine/lib/ShadowAccumulator.js +1 -1
  192. package/views/3d/webgl-engine/lib/SortedRenderGeometryRenderer.js +1 -1
  193. package/views/3d/webgl-engine/lib/TextureBackedBuffer/TextureBackedBuffer.js +1 -1
  194. package/views/3d/webgl-engine/lib/TextureBackedBuffer/TextureBackedBufferFieldCreation.js +5 -0
  195. package/views/3d/webgl-engine/lib/TextureBackedBuffer/TextureBackedBufferFields.js +1 -1
  196. package/views/3d/webgl-engine/lib/TextureBackedBuffer/TextureBackedBufferLayout.js +1 -1
  197. package/views/3d/webgl-engine/lib/TextureBackedBuffer/TextureBackedBufferLayoutField.js +5 -0
  198. package/views/3d/webgl-engine/lib/TextureBackedBuffer/TextureBufferView.js +5 -0
  199. package/views/3d/webgl-engine/lib/Viewshed.js +1 -1
  200. package/views/3d/webgl-engine/lib/edgeRendering/edgePreprocessing.js +1 -1
  201. package/views/3d/webgl-engine/lib/geometryDataUtils.js +1 -1
  202. package/views/3d/webgl-engine/lib/triangleIntersectionUtils.js +1 -1
  203. package/views/3d/webgl-engine/materials/CheckerBoardMaterial.js +1 -1
  204. package/views/3d/webgl-engine/materials/ColorMaterial.js +1 -1
  205. package/views/3d/webgl-engine/materials/DefaultMaterial.js +1 -1
  206. package/views/3d/webgl-engine/materials/DefaultTechniqueConfiguration.js +1 -1
  207. package/views/3d/webgl-engine/materials/HUDMaterial.js +1 -1
  208. package/views/3d/webgl-engine/materials/HeatmapDensityMaterial.js +1 -1
  209. package/views/3d/webgl-engine/materials/ImageMaterial.js +1 -1
  210. package/views/3d/webgl-engine/materials/LineCalloutMaterial.js +1 -1
  211. package/views/3d/webgl-engine/materials/LineMarkerMaterial.js +1 -1
  212. package/views/3d/webgl-engine/materials/MeasurementArrowMaterial.js +1 -1
  213. package/views/3d/webgl-engine/materials/NativeLineMaterial.js +1 -1
  214. package/views/3d/webgl-engine/materials/PatternMaterial.js +1 -1
  215. package/views/3d/webgl-engine/materials/RibbonLineMaterial.js +1 -1
  216. package/views/3d/webgl-engine/materials/ShadedColorMaterial.js +1 -1
  217. package/views/3d/webgl-engine/materials/SlicePlaneMaterial.js +1 -1
  218. package/views/3d/webgl-engine/materials/WaterMaterial.js +1 -1
  219. package/views/3d/webgl-engine/materials/renderers/VaoRenderer.js +1 -1
  220. package/views/3d/webgl-engine/materials/renderers/VaoWriter.js +1 -1
  221. package/views/3d/webgl-engine/shaders/ColorMaterialTechnique.js +1 -1
  222. package/views/3d/webgl-engine/shaders/DefaultMaterialTechnique.js +1 -1
  223. package/views/3d/webgl-engine/shaders/GaussianSplat.glsl.js +1 -1
  224. package/views/3d/webgl-engine/shaders/GaussianSplatTechniqueConfiguration.js +1 -1
  225. package/views/3d/webgl-engine/shaders/ImageMaterialTechnique.js +1 -1
  226. package/views/3d/webgl-engine/shaders/LineMarkerTechnique.js +1 -1
  227. package/views/3d/webgl-engine/shaders/NativeLineTechnique.js +1 -1
  228. package/views/3d/webgl-engine/shaders/OutputColorHighlightOLID.glsl.js +9 -10
  229. package/views/3d/webgl-engine/shaders/PatternTechnique.js +1 -1
  230. package/views/3d/webgl-engine/shaders/RibbonLineTechnique.js +1 -1
  231. package/views/3d/webgl-engine/shaders/SphereDepthInterpolate.glsl.js +1 -1
  232. package/views/3d/webgl-engine/shaders/Terrain.glsl.js +1 -1
  233. package/views/3d/webgl-engine/shaders/TerrainTechnique.js +1 -1
  234. package/views/3d/webgl-engine/shaders/TerrainTechniqueConfiguration.js +1 -1
  235. package/views/BreakpointsOwner.js +1 -1
  236. package/views/GroundView.js +1 -1
  237. package/views/SceneView.js +1 -1
  238. package/views/ToolViewManager.js +1 -1
  239. package/views/analysis/ElevationProfile/elevationProfileVisualizationUtils.js +1 -1
  240. package/views/interactive/GraphicManipulator.js +1 -1
  241. package/views/interactive/InteractiveToolBase.js +1 -1
  242. package/views/interactive/ToolViewManagerManipulatorState.js +1 -1
  243. package/views/interactive/coordinateHelper.js +1 -1
  244. package/views/interactive/editGeometry/operations/OffsetEdgeVertex.js +1 -1
  245. package/views/interactive/sketch/constraints.js +1 -1
  246. package/views/interactive/snapping/featureSources/sceneLayerSource/SceneLayerSnappingSourceWorker.js +1 -1
  247. package/views/interactive/snapping/featureSources/sceneLayerSource/sceneLayerSnappingUtils.js +1 -1
  248. package/views/interactive/snapping/hints/LineSnappingHint.js +1 -1
  249. package/views/interactive/tooltip/tooltipCommonUtils.js +1 -1
  250. package/views/layers/LayerView.js +1 -1
  251. package/views/navigation/PanSphericalMomentumEstimator.js +1 -1
  252. package/views/support/LayerViewManager.js +1 -1
  253. package/views/support/euclideanAreaMeasurementUtils.js +1 -1
  254. package/views/support/euclideanLengthMeasurementUtils.js +1 -1
  255. package/views/support/geodesicLengthMeasurementUtils.js +1 -1
  256. package/views/support/geometry3dUtils.js +1 -1
  257. package/webmap/utils.js +1 -1
  258. package/widgets/Sketch/SketchViewModel.js +1 -1
  259. package/widgets/Slider.js +1 -1
  260. package/assets/esri/core/workers/chunks/11687718c8635eb7bf37.js +0 -1
  261. package/assets/esri/core/workers/chunks/15c1a48e8cd2a8882d85.js +0 -1
  262. package/assets/esri/core/workers/chunks/1b9e7d416c9f00e020bb.js +0 -1
  263. package/assets/esri/core/workers/chunks/24a3c6f0154787968724.js +0 -1
  264. package/assets/esri/core/workers/chunks/5000a37fba27464d10ca.js +0 -1
  265. package/assets/esri/core/workers/chunks/951a3442d4342539f2ea.js +0 -1
  266. package/assets/esri/core/workers/chunks/b075d3714fab0591d67c.js +0 -1
  267. package/assets/esri/core/workers/chunks/d8975dd7b85b5d065ee4.js +0 -1
  268. package/assets/esri/core/workers/chunks/e0a74250d22fa1d7dc18.js +0 -1
  269. package/assets/esri/core/workers/chunks/f43e1e1a1b2eb737e00c.js +0 -1
  270. package/views/3d/webgl-engine/core/shaderLibrary/util/FastApproximateTrigonometry.glsl.js +0 -26
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{neverReached as t}from"../../../core/compilerUtils.js";import{lerp as e}from"../../../core/mathUtils.js";import{invert as i}from"../../../core/libs/gl-matrix-2/math/mat4.js";import{create as r}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{i as n,j as o,E as s,p as a,h as c,g as l}from"../../../chunks/vec32.js";import{create as p}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as h}from"../../../geometry/ellipsoidUtils.js";import{computeTranslationToOriginAndRotation as d}from"../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{projectBoundingRect as _}from"../../../geometry/projection/projectBoundingRect.js";import{projectVectorToVector as m}from"../../../geometry/projection/projectVectorToVector.js";import{empty as g,create as x,expandWithVec3 as f}from"../../../geometry/support/aaBoundingBox.js";import{center as u,create as y}from"../../../geometry/support/aaBoundingRect.js";import{fromPoints as j,create as R}from"../../../geometry/support/lineSegment.js";import{create as b,fromVectorsAndPoint as S,copy as B,negate as C,signedDistance as H}from"../../../geometry/support/plane.js";import{wrap as w}from"../../../geometry/support/ray.js";import{frustumLineSegment as M}from"./intersectionUtils.js";const A=.5*Math.PI,E=A/Math.PI*180;class G{constructor(t){this._extent=new Array(4),this._planes=new Array(6),this._maxSpan=0,this._center={origin:p(),direction:p()},this._renderCoordsHelper=t.renderCoordsHelper;for(let e=0;e<4;e++)this._extent[e]={origin:p(),direction:p(),cap:{next:null,direction:p()}},this._planes[e]=b();this._planes[4]=b(),this._planes[5]=b(),this._planesWithoutFar=this._planes.slice(0,5)}update(t,e,i,r=!0){const a=this._extent;this._toRenderBoundingExtent(t,e,i),n(this._center.origin,a[0].origin,a[2].origin),o(this._center.origin,this._center.origin,.5),this._renderCoordsHelper.worldUpAtPosition(this._center.origin,this._center.direction),r||o(this._center.direction,this._center.direction,-1);for(let n=0;n<4;n++){const t=a[n];this._renderCoordsHelper.worldUpAtPosition(t.origin,t.direction);const e=a[3===n?0:n+1];t.cap.next=e.origin,s(t.cap.direction,t.origin,e.origin),S(t.direction,t.cap.direction,t.origin,this._planes[n]),r||o(t.direction,t.direction,-1)}S(a[0].cap.direction,a[1].cap.direction,a[0].origin,this._planes[4]),r?C(this._planes[4],this._planes[5]):(B(this._planes[5],this._planes[4]),C(this._planes[4],this._planes[4])),this._maxSpan=Math.max(Math.abs(t[0]-t[2]),Math.abs(t[1]-t[3])),this._maxSpanSpatialReference=e,this._minGlobalAltitude=.9*h(this._maxSpanSpatialReference).radius}isVisibleInFrustum(t,e,i=!1){if(null==t)return!1;if(1===this._renderCoordsHelper.viewingMode){const i=this._maxSpanSpatialReference.isGeographic?E:A*e;if(this._maxSpan>i)return!0;if(null!=t.altitude&&t.altitude>=this._minGlobalAltitude)return this._isVisibleInFrustumGlobal(t)}if(0===this._maxSpan){const e=this._extent[0];return!(i||!t.intersectsRay(w(e.origin,e.direction)))}for(let n=0;n<this._extent.length;n++){const e=this._extent[n];if(!i&&t.intersectsRay(w(e.origin,e.direction)))return!0;if(t.intersectsLineSegment(j(e.origin,e.cap.next,k),e.cap.direction))return!0}const r=i?this._planes:this._planesWithoutFar;for(let n=0;n<t.lines.length;n++){const e=t.lines[n];if(M(r,e.origin,e.endpoint,e.direction))return!0}return!1}_toRenderBoundingExtentGlobal(t,r,n){const o=5;u(t,v),v[2]=n,d(r,v,F,this._renderCoordsHelper.spatialReference),i(I,F),g(V);for(const{x0:i,x1:s,y0:c,y1:l}of U)for(let p=0;p<o;p++){const h=p/(o-1);v[0]=e(t[i],t[s],h),v[1]=e(t[c],t[l],h),v[2]=n,m(v,r,v,this._renderCoordsHelper.spatialReference),a(v,v,I),f(V,v)}c(this._extent[0].origin,V[0],V[1],V[2]),c(this._extent[1].origin,V[3],V[1],V[2]),c(this._extent[2].origin,V[3],V[4],V[2]),c(this._extent[3].origin,V[0],V[4],V[2]);for(let e=0;e<4;++e)a(this._extent[e].origin,this._extent[e].origin,F)}_toRenderBoundingExtentLocal(t,e,i){_(t,e,P,this._renderCoordsHelper.spatialReference),c(this._extent[0].origin,P[0],P[1],i),c(this._extent[1].origin,P[2],P[1],i),c(this._extent[2].origin,P[2],P[3],i),c(this._extent[3].origin,P[0],P[3],i)}_toRenderBoundingExtent(e,i,r){switch(this._renderCoordsHelper.viewingMode){case 1:this._toRenderBoundingExtentGlobal(e,i,r);break;case 2:this._toRenderBoundingExtentLocal(e,i,r);break;default:t(this._renderCoordsHelper.viewingMode)}}_isVisibleInFrustumGlobal(t){if(H(t.planes[4],this._center.origin)<0&&l(this._center.direction,t.direction)<0)return!0;for(let e=0;e<4;e++){const i=this._extent[e];if(H(t.planes[4],i.origin)<0&&l(i.direction,t.direction)<0)return!0}return!1}}const U=[{x0:0,y0:1,x1:2,y1:1},{x0:0,y0:3,x1:2,y1:3},{x0:0,y0:1,x1:0,y1:3},{x0:2,y0:1,x1:2,y1:3}],v=p(),F=r(),I=r(),V=x(),P=y(),k=R();export{G as FrustumExtentIntersection};
5
+ import{neverReached as t}from"../../../core/compilerUtils.js";import{lerp as e}from"../../../core/mathUtils.js";import{invert as i}from"../../../core/libs/gl-matrix-2/math/mat4.js";import{create as r}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{i as n,j as o,D as s,p as a,h as c,g as l}from"../../../chunks/vec32.js";import{create as p}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as h}from"../../../geometry/ellipsoidUtils.js";import{computeTranslationToOriginAndRotation as d}from"../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{projectBoundingRect as _}from"../../../geometry/projection/projectBoundingRect.js";import{projectVectorToVector as m}from"../../../geometry/projection/projectVectorToVector.js";import{empty as g,create as x,expandWithVec3 as f}from"../../../geometry/support/aaBoundingBox.js";import{center as u,create as y}from"../../../geometry/support/aaBoundingRect.js";import{fromPoints as j,create as R}from"../../../geometry/support/lineSegment.js";import{create as b,fromVectorsAndPoint as S,copy as B,negate as C,signedDistance as H}from"../../../geometry/support/plane.js";import{wrap as w}from"../../../geometry/support/ray.js";import{frustumLineSegment as M}from"./intersectionUtils.js";const A=.5*Math.PI,G=A/Math.PI*180;class E{constructor(t){this._extent=new Array(4),this._planes=new Array(6),this._maxSpan=0,this._center={origin:p(),direction:p()},this._renderCoordsHelper=t.renderCoordsHelper;for(let e=0;e<4;e++)this._extent[e]={origin:p(),direction:p(),cap:{next:null,direction:p()}},this._planes[e]=b();this._planes[4]=b(),this._planes[5]=b(),this._planesWithoutFar=this._planes.slice(0,5)}update(t,e,i,r=!0){const a=this._extent;this._toRenderBoundingExtent(t,e,i),n(this._center.origin,a[0].origin,a[2].origin),o(this._center.origin,this._center.origin,.5),this._renderCoordsHelper.worldUpAtPosition(this._center.origin,this._center.direction),r||o(this._center.direction,this._center.direction,-1);for(let n=0;n<4;n++){const t=a[n];this._renderCoordsHelper.worldUpAtPosition(t.origin,t.direction);const e=a[3===n?0:n+1];t.cap.next=e.origin,s(t.cap.direction,t.origin,e.origin),S(t.direction,t.cap.direction,t.origin,this._planes[n]),r||o(t.direction,t.direction,-1)}S(a[0].cap.direction,a[1].cap.direction,a[0].origin,this._planes[4]),r?C(this._planes[4],this._planes[5]):(B(this._planes[5],this._planes[4]),C(this._planes[4],this._planes[4])),this._maxSpan=Math.max(Math.abs(t[0]-t[2]),Math.abs(t[1]-t[3])),this._maxSpanSpatialReference=e,this._minGlobalAltitude=.9*h(this._maxSpanSpatialReference).radius}isVisibleInFrustum(t,e,i=!1){if(null==t)return!1;if(1===this._renderCoordsHelper.viewingMode){const i=this._maxSpanSpatialReference.isGeographic?G:A*e;if(this._maxSpan>i)return!0;if(null!=t.altitude&&t.altitude>=this._minGlobalAltitude)return this._isVisibleInFrustumGlobal(t)}if(0===this._maxSpan){const e=this._extent[0];return!(i||!t.intersectsRay(w(e.origin,e.direction)))}for(let n=0;n<this._extent.length;n++){const e=this._extent[n];if(!i&&t.intersectsRay(w(e.origin,e.direction)))return!0;if(t.intersectsLineSegment(j(e.origin,e.cap.next,k),e.cap.direction))return!0}const r=i?this._planes:this._planesWithoutFar;for(let n=0;n<t.lines.length;n++){const e=t.lines[n];if(M(r,e.origin,e.endpoint,e.direction))return!0}return!1}_toRenderBoundingExtentGlobal(t,r,n){const o=5;u(t,v),v[2]=n,d(r,v,F,this._renderCoordsHelper.spatialReference),i(I,F),g(V);for(const{x0:i,x1:s,y0:c,y1:l}of U)for(let p=0;p<o;p++){const h=p/(o-1);v[0]=e(t[i],t[s],h),v[1]=e(t[c],t[l],h),v[2]=n,m(v,r,v,this._renderCoordsHelper.spatialReference),a(v,v,I),f(V,v)}c(this._extent[0].origin,V[0],V[1],V[2]),c(this._extent[1].origin,V[3],V[1],V[2]),c(this._extent[2].origin,V[3],V[4],V[2]),c(this._extent[3].origin,V[0],V[4],V[2]);for(let e=0;e<4;++e)a(this._extent[e].origin,this._extent[e].origin,F)}_toRenderBoundingExtentLocal(t,e,i){_(t,e,P,this._renderCoordsHelper.spatialReference),c(this._extent[0].origin,P[0],P[1],i),c(this._extent[1].origin,P[2],P[1],i),c(this._extent[2].origin,P[2],P[3],i),c(this._extent[3].origin,P[0],P[3],i)}_toRenderBoundingExtent(e,i,r){switch(this._renderCoordsHelper.viewingMode){case 1:this._toRenderBoundingExtentGlobal(e,i,r);break;case 2:this._toRenderBoundingExtentLocal(e,i,r);break;default:t(this._renderCoordsHelper.viewingMode)}}_isVisibleInFrustumGlobal(t){if(H(t.planes[4],this._center.origin)<0&&l(this._center.direction,t.direction)<0)return!0;for(let e=0;e<4;e++){const i=this._extent[e];if(H(t.planes[4],i.origin)<0&&l(i.direction,t.direction)<0)return!0}return!1}}const U=[{x0:0,y0:1,x1:2,y1:1},{x0:0,y0:3,x1:2,y1:3},{x0:0,y0:1,x1:0,y1:3},{x0:2,y0:1,x1:2,y1:3}],v=p(),F=r(),I=r(),V=x(),P=y(),k=R();export{E as FrustumExtentIntersection};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../Camera.js";import t from"../../../core/Logger.js";import{deg2rad as n,rad2deg as r,asinClamped as i}from"../../../core/mathUtils.js";import{throwIfAborted as a}from"../../../core/promiseUtils.js";import{d as o,D as c,H as s,b as l}from"../../../chunks/vec32.js";import{create as u,clone as f}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as m}from"../../../geometry/ellipsoidUtils.js";import p from"../../../geometry/Point.js";import{projectWithZConversion as d,project as h}from"../../../geometry/projectionUtils.js";import g from"../../../geometry/SpatialReference.js";import{projectPointToVectorAsync as y,projectPointToVector as v}from"../../../geometry/projection/projectPointToVector.js";import{projectVectorToPointAsync as R,projectVectorToPoint as w}from"../../../geometry/projection/projectVectorToPoint.js";import{gcsCyclical as x,webMercatorCyclical as M}from"../../../geometry/support/normalizeUtils.js";import{toRenderCamera as j}from"../webgl.js";import{getGreatCircleSpanAt as T}from"./earthUtils.js";import{getElevationAtPoint as z}from"./ElevationProvider.js";import{viewModeDependentUtil as S,directionToHeadingTilt as C}from"./viewingModeUtils.js";import{isSpatialReferenceSupported as b}from"../../support/spatialReferenceSupport.js";const P=()=>t.getLogger("esri.views.3d.support.cameraUtils"),A=96*39.37,L=1,U=8,H=5,q=1,I=u();function E(e){return e.spatialReference??g.WGS84}function F(e,t,n,r,i){return S(e).headingTiltToDirectionUp(t,n,r,i)}function G(e,t){const{camera:n}=e.state,{unitInMeters:r}=e.renderCoordsHelper;t/=r;return n.width/2/n.pixelRatio/(A/t)/Math.tan(n.fovX/2)}function D(e,t){const{camera:n}=e.state,{unitInMeters:r}=e.renderCoordsHelper,i=t*Math.tan(n.fovX/2),a=n.width/2/n.pixelRatio;return A/(a/i)*r}function O(e,t,n,r){const i=r.levelAtScale(t),a=k(C(e,n.eye,n.viewForward,n.up).tilt),o=Math.max(i-a,0);return r.scaleAtLevel(o)}function X(e,t,n){const r=n.levelAtScale(e),i=k(t);return n.scaleAtLevel(r+i)}function k(e){return 2*((e>90?180-e:e)/90)**2}function V(e,t,n=0){const r=e.basemapTerrain?.tilingScheme;if(!r)return 0;const i=m(e.spatialReference).radius,a=2===e.state.viewingMode?t.eye[2]:l(t.eye)-i;return O(e,D(e,Math.abs(a-n)),t,r)}function W(e,t,n=0){const r=j(e,t);return r?V(e,r,n):0}const Y=1,N=100;function Z(e,t,a,o){if(0===t)return 0;const s=e.state.contentCamera,u=c(s.eye,a),f=e.basemapTerrain?.tilingScheme;if(!f)return P().error("#scaleToTargetDistance()","Cannot compute distance from scale without a tiling scheme"),u;let p=u;const d=C(e,s.eye,s.viewForward,s.up),h=d.tilt>90;if(e.state.isLocal){const r=(G(e,X(t,d.tilt,f))-Math.abs(s.eye[2]-o[2]))/Math.cos(n(d.tilt));return p=h?p-r:p+r,p}let g=1/0,y=0,v=te(e,d.heading,d.tilt,a,u,1);if(!v)return p;const R=l(o);for(;g>Y&&y<N;){const o=l(v.eye),u=h?180-v.tilt:v.tilt,w=n(u),x=Math.sin(w)*o,M=Math.cos(w)*o,j=G(e,X(t,v.tilt,f)),T=h?R-j:R+j,z=i(x/T),S=Math.cos(z)*T-M,C=c(v.eye,a);p=h?C-S:C+S,v=te(e,d.heading,d.tilt,a,p,1);const b=Me(e,v,r(s.fov));if(!v||!b)return p;const P=W(e,b,R-m(e.spatialReference).radius);g=Math.abs(t-P),++y}return p}async function B(e,t,n,r,i,a){return K(e,t,G(e,n),r,i,a)}function J(e,t,n,r,i,a){return Me(e,te(e,r.heading,r.tilt,t,n,i),r.fov,a)}async function K(e,t,n,r,i,o){const c=await ne(e,r.heading,r.tilt,t,n,i,o);return a(o),je(e,c,r.fov,o)}function Q(e,t){return!!(e.basemapTerrain&&e.renderCoordsHelper.fromRenderCoords(t,I,e.spatialReference)&&e.elevationProvider&&(z(e.elevationProvider,I)??0)>I[2]-q)}async function $(e,t,n){if(Q(e,t))return!0;const{elevationProvider:r,spatialReference:i,renderCoordsHelper:o}=e;if(null==r||!o.fromRenderCoords(t,I,i))return!1;const[c,s,l]=I,u=await r.queryElevation(c,s,l,i,"ground",n)??0;return a(n),u>l-q}async function _(e,t,n){const r=u();if(null==t)return o(r,e.state.camera.center);if(t instanceof p){const{renderSpatialReference:i,basemapTerrain:o,elevationProvider:c}=e,s=t.spatialReference;if(await y(t,r,i,{signal:n}),a(n),null==t.z&&null!=o&&null!=c){const i=await c.queryElevation(t.x,t.y,t.z??0,s,"ground",n);a(n),null!=i&&e.renderCoordsHelper.setAltitude(r,i)}return r}return o(r,t)}function ee(e,t){const n=u();if(null==t)return o(n,e.state.camera.center);if(t instanceof p){if(!v(t,n,e.renderSpatialReference))return null;const{basemapTerrain:r,elevationProvider:i}=e;if(null==t.z&&null!=r&&null!=i){const r=z(i,t);null!=r&&e.renderCoordsHelper.setAltitude(n,r)}return n}return o(n,t)}function te(e,t,n,r,i,a){return re(e,t,n,r instanceof p?r:null,ee(e,r),i,a)}async function ne(e,t,n,r,i,o,c){const s=r instanceof p?r:null,l=await _(e,r,c);return a(c),ie(e,t,n,s,l,i,o,c)}function re(e,t,n,r,i,a,o){if(null==i)return null;if(!r&&(r=new p({spatialReference:E(e)}),!w(i,e.renderSpatialReference,r)))return null;const c=ae(e,t,n,i,a,o);if(oe(e,n,o)&&Q(e,c.eye)){const{tilt:o,mode:c}=ce(e,n,i,a);return re(e,t,o,r,i,a,c)}return se(c,i)}async function ie(e,t,n,r,i,o,c,s){r||(r=new p({spatialReference:E(e)}),await R(i,e.renderSpatialReference,r,{signal:s})||(r=null)),a(s);const l=ae(e,t,n,i,o,c);if(oe(e,n,c)&&await $(e,l.eye,s)){a(s);const{tilt:c,mode:l}=ce(e,n,i,o);return ie(e,t,c,r,i,o,l,s)}return se(l,i)}function ae(e,t,n,r,i,a){const o=ge(e,t,n,r,i=Math.max(i,e.state.constraints.minimumPoiDistance),a);return(0,S(e).eyeForCenterWithHeadingTilt)(r,i,o.heading,o.tilt)}function oe(e,t,n){const r=e.map.ground.navigationConstraint;return 1===n&&e.state.isGlobal&&t>0&&(null==r||"stay-above"===r.type)}function ce(e,t,n,r){const i=we(e,n,r,Re(e,r,t,n));return{tilt:i,mode:t-i<1?0:1}}function se(e,t){return{...e,center:f(t)}}function le(e,t){const{state:n,spatialReference:r}=e,i=t.spatialReference;return n.isGlobal&&b(i,1)||n.isLocal&&r.equals(i)}function ue(e,t){let n,r,i;if(e.state.isGlobal){const e=new p(t.xmin,t.ymin,t.spatialReference),a=new p(t.xmax,t.ymax,t.spatialReference),o=t.spatialReference.isGeographic?x:M;n=new p({x:o.center(e.x,a.x),y:(a.y+e.y)/2,z:null!=t.zmax&&null!=t.zmin?(t.zmax+t.zmin)/2:void 0,spatialReference:t.spatialReference});const c=m(t.spatialReference),s=T(n,e,a);r=s.lon,i=s.lat,o.diff(e.x,a.x)>o.range/2&&(r+=c.halfCircumference),r=Math.min(r,c.halfCircumference),i=Math.min(i,c.halfCircumference)}else{const a=e.renderSpatialReference??t.spatialReference;a.equals(t.spatialReference)||(t=h(t,a)),r=t.xmax-t.xmin,i=t.ymax-t.ymin;const o=null!=t.zmax&&null!=t.zmin?(t.zmax+t.zmin)/2:void 0;n=new p({x:t.xmin+.5*r,y:t.ymin+.5*i,z:o,spatialReference:a})}const a=null!=t.zmax&&null!=t.zmin?t.zmax-t.zmin:0,o=e.state.camera,c=1/Math.tan(o.fovX/2),s=1/Math.tan(o.fovY/2),l=1/Math.tan(o.fov/2);return{center:n,distance:Math.max(.5*r*c,.5*i*s,.5*a*l)/L}}async function fe(e,t,n,r,i,o){const c=le(e,t)?t:await d(t,e.spatialReference,{signal:o});a(o);const{center:s,distance:l}=ue(e,c),u=await ne(e,n,r,s,l,i,o);return a(o),je(e,u,e.camera.fov,o)}function me(e,t,n,r,i,a){let o;try{o=le(e,t)?t:h(t,e.spatialReference)}catch(u){return null}const{center:c,distance:s}=ue(e,o),l=te(e,n,r,c,s,i);return null==l?null:Me(e,l,e.camera.fov,a)}function pe(e,t,n){const r=e.renderSpatialReference,i=new p({spatialReference:E(e)});if(!w(n,r,i))return null;const a=Math.tan(t.fovX/2),o=Math.tan(t.fovY/2),c=s(t.eye,n),l=2*c*a*L,u=2*c*o*L;return S(e).toExtent(e,i,l,u)}function de(e,t){return S(e).toArea(e,t)}function he(e,t,n){const r=e.pointsOfInterest.centerOnSurfaceFrequent.distance;if(Math.log(n/r)/Math.LN2>U)return!0;const i=t,a=e.pointsOfInterest.centerOnSurfaceFrequent.renderLocation;return c(i,a)/(Math.tan(.5*e.state.camera.fov)*r)>H}function ge(e,t,n,r,i,a){let o=0;return 1===a&&he(e,r,i)?(t=0,o=ve(e,i,n,r)):o=xe(e,r,i,n),o=e.state.constraints.clampTilt(i,o),{heading:t,tilt:n=we(e,r,i,o)}}const ye=.7;function ve(e,t,n,r){const i=xe(e,r,t,n);if(!e.state.constraints.tilt)return i;const a=e.state.constraints.tilt(t);a.max=Math.min(a.max,.5*Math.PI);const o=a.min*(1-ye)+a.max*ye;return Math.min(i,o)}function Re(e,t,n,r){let i=xe(e,r,t,n);if(!e.state.constraints.tilt)return i;const a=e.state.constraints.tilt(t);return i=Math.min(i,.5*Math.PI),a.min*(1-ye)+i*ye}function we(e,t,n,r){return S(e).lookAtTiltToEyeTilt(r,t,n)}function xe(e,t,n,r){return S(e).eyeTiltToLookAtTilt(r,t,n)}function Me(t,n,r,i){if(null==n)return null;const a=t.renderSpatialReference,o=new p({spatialReference:E(t)});return w(n.eye,a,o)?(i??=new e,i.position=o,i.heading=n.heading,i.tilt=n.tilt,i.fov=r,i):null}async function je(t,n,r,i){const o=t.renderSpatialReference,c=new p({spatialReference:E(t)});return await R(n.eye,o,c,{signal:i}),a(i),new e(c,n.heading,n.tilt,r)}function Te(e,t){const n=e.basemapTerrain?.tilingScheme;if(n)return n.levelAtScale(t);P().error("#scaleToZoom()","Cannot compute zoom from scale without a tiling scheme")}function ze(e,t){const n=e.basemapTerrain?.tilingScheme;if(n)return n.scaleAtLevel(t);P().error("#zoomToScale()","Cannot compute scale from zoom without a tiling scheme")}export{O as applyTiltAdjustToScale,D as distanceToScale,K as fromCenterDistanceAsync,J as fromCenterDistanceSync,B as fromCenterScale,fe as fromExtentAsync,me as fromExtentSync,ne as getObserverForPointAtDistanceAsync,te as getObserverForPointAtDistanceSync,E as getViewSR,F as headingTiltToDirectionUp,X as removeTiltAdjustFromScale,Y as scaleErrorThreshold,G as scaleToDistance,Te as scaleToZoom,de as toArea,pe as toExtent,Z as viewScaleToCameraDistance,ze as zoomToScale};
5
+ import e from"../../../Camera.js";import t from"../../../core/Logger.js";import{deg2rad as n,rad2deg as r,asinClamped as i}from"../../../core/mathUtils.js";import{throwIfAborted as a}from"../../../core/promiseUtils.js";import{d as o,C as c,G as s,b as l}from"../../../chunks/vec32.js";import{create as u,clone as f}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as m}from"../../../geometry/ellipsoidUtils.js";import p from"../../../geometry/Point.js";import{projectWithZConversion as d,project as h}from"../../../geometry/projectionUtils.js";import g from"../../../geometry/SpatialReference.js";import{projectPointToVectorAsync as y,projectPointToVector as v}from"../../../geometry/projection/projectPointToVector.js";import{projectVectorToPointAsync as R,projectVectorToPoint as w}from"../../../geometry/projection/projectVectorToPoint.js";import{gcsCyclical as x,webMercatorCyclical as M}from"../../../geometry/support/normalizeUtils.js";import{toRenderCamera as j}from"../webgl.js";import{getGreatCircleSpanAt as T}from"./earthUtils.js";import{getElevationAtPoint as z}from"./ElevationProvider.js";import{viewModeDependentUtil as S,directionToHeadingTilt as C}from"./viewingModeUtils.js";import{isSpatialReferenceSupported as b}from"../../support/spatialReferenceSupport.js";const P=()=>t.getLogger("esri.views.3d.support.cameraUtils"),A=96*39.37,L=1,U=8,H=5,q=1,G=u();function I(e){return e.spatialReference??g.WGS84}function E(e,t,n,r,i){return S(e).headingTiltToDirectionUp(t,n,r,i)}function F(e,t){const{camera:n}=e.state,{unitInMeters:r}=e.renderCoordsHelper;t/=r;return n.width/2/n.pixelRatio/(A/t)/Math.tan(n.fovX/2)}function O(e,t){const{camera:n}=e.state,{unitInMeters:r}=e.renderCoordsHelper,i=t*Math.tan(n.fovX/2),a=n.width/2/n.pixelRatio;return A/(a/i)*r}function X(e,t,n,r){const i=r.levelAtScale(t),a=D(C(e,n.eye,n.viewForward,n.up).tilt),o=Math.max(i-a,0);return r.scaleAtLevel(o)}function k(e,t,n){const r=n.levelAtScale(e),i=D(t);return n.scaleAtLevel(r+i)}function D(e){return 2*((e>90?180-e:e)/90)**2}function V(e,t,n=0){const r=e.basemapTerrain?.tilingScheme;if(!r)return 0;const i=m(e.spatialReference).radius,a=2===e.state.viewingMode?t.eye[2]:l(t.eye)-i;return X(e,O(e,Math.abs(a-n)),t,r)}function W(e,t,n=0){const r=j(e,t);return r?V(e,r,n):0}const Y=1,N=100;function Z(e,t,a,o){if(0===t)return 0;const s=e.state.contentCamera,u=c(s.eye,a),f=e.basemapTerrain?.tilingScheme;if(!f)return P().error("#scaleToTargetDistance()","Cannot compute distance from scale without a tiling scheme"),u;let p=u;const d=C(e,s.eye,s.viewForward,s.up),h=d.tilt>90;if(e.state.isLocal){const r=(F(e,k(t,d.tilt,f))-Math.abs(s.eye[2]-o[2]))/Math.cos(n(d.tilt));return p=h?p-r:p+r,p}let g=1/0,y=0,v=te(e,d.heading,d.tilt,a,u,1);if(!v)return p;const R=l(o);for(;g>Y&&y<N;){const o=l(v.eye),u=h?180-v.tilt:v.tilt,w=n(u),x=Math.sin(w)*o,M=Math.cos(w)*o,j=F(e,k(t,v.tilt,f)),T=h?R-j:R+j,z=i(x/T),S=Math.cos(z)*T-M,C=c(v.eye,a);p=h?C-S:C+S,v=te(e,d.heading,d.tilt,a,p,1);const b=Me(e,v,r(s.fov));if(!v||!b)return p;const P=W(e,b,R-m(e.spatialReference).radius);g=Math.abs(t-P),++y}return p}async function B(e,t,n,r,i,a){return K(e,t,F(e,n),r,i,a)}function J(e,t,n,r,i,a){return Me(e,te(e,r.heading,r.tilt,t,n,i),r.fov,a)}async function K(e,t,n,r,i,o){const c=await ne(e,r.heading,r.tilt,t,n,i,o);return a(o),je(e,c,r.fov,o)}function Q(e,t){return!!(e.basemapTerrain&&e.renderCoordsHelper.fromRenderCoords(t,G,e.spatialReference)&&e.elevationProvider&&(z(e.elevationProvider,G)??0)>G[2]-q)}async function $(e,t,n){if(Q(e,t))return!0;const{elevationProvider:r,spatialReference:i,renderCoordsHelper:o}=e;if(null==r||!o.fromRenderCoords(t,G,i))return!1;const[c,s,l]=G,u=await r.queryElevation(c,s,l,i,"ground",n)??0;return a(n),u>l-q}async function _(e,t,n){const r=u();if(null==t)return o(r,e.state.camera.center);if(t instanceof p){const{renderSpatialReference:i,basemapTerrain:o,elevationProvider:c}=e,s=t.spatialReference;if(await y(t,r,i,{signal:n}),a(n),null==t.z&&null!=o&&null!=c){const i=await c.queryElevation(t.x,t.y,t.z??0,s,"ground",n);a(n),null!=i&&e.renderCoordsHelper.setAltitude(r,i)}return r}return o(r,t)}function ee(e,t){const n=u();if(null==t)return o(n,e.state.camera.center);if(t instanceof p){if(!v(t,n,e.renderSpatialReference))return null;const{basemapTerrain:r,elevationProvider:i}=e;if(null==t.z&&null!=r&&null!=i){const r=z(i,t);null!=r&&e.renderCoordsHelper.setAltitude(n,r)}return n}return o(n,t)}function te(e,t,n,r,i,a){return re(e,t,n,r instanceof p?r:null,ee(e,r),i,a)}async function ne(e,t,n,r,i,o,c){const s=r instanceof p?r:null,l=await _(e,r,c);return a(c),ie(e,t,n,s,l,i,o,c)}function re(e,t,n,r,i,a,o){if(null==i)return null;if(!r&&(r=new p({spatialReference:I(e)}),!w(i,e.renderSpatialReference,r)))return null;const c=ae(e,t,n,i,a,o);if(oe(e,n,o)&&Q(e,c.eye)){const{tilt:o,mode:c}=ce(e,n,i,a);return re(e,t,o,r,i,a,c)}return se(c,i)}async function ie(e,t,n,r,i,o,c,s){r||(r=new p({spatialReference:I(e)}),await R(i,e.renderSpatialReference,r,{signal:s})||(r=null)),a(s);const l=ae(e,t,n,i,o,c);if(oe(e,n,c)&&await $(e,l.eye,s)){a(s);const{tilt:c,mode:l}=ce(e,n,i,o);return ie(e,t,c,r,i,o,l,s)}return se(l,i)}function ae(e,t,n,r,i,a){const o=ge(e,t,n,r,i=Math.max(i,e.state.constraints.minimumPoiDistance),a);return(0,S(e).eyeForCenterWithHeadingTilt)(r,i,o.heading,o.tilt)}function oe(e,t,n){const r=e.map.ground.navigationConstraint;return 1===n&&e.state.isGlobal&&t>0&&(null==r||"stay-above"===r.type)}function ce(e,t,n,r){const i=we(e,n,r,Re(e,r,t,n));return{tilt:i,mode:t-i<1?0:1}}function se(e,t){return{...e,center:f(t)}}function le(e,t){const{state:n,spatialReference:r}=e,i=t.spatialReference;return n.isGlobal&&b(i,1)||n.isLocal&&r.equals(i)}function ue(e,t){let n,r,i;if(e.state.isGlobal){const e=new p(t.xmin,t.ymin,t.spatialReference),a=new p(t.xmax,t.ymax,t.spatialReference),o=t.spatialReference.isGeographic?x:M;n=new p({x:o.center(e.x,a.x),y:(a.y+e.y)/2,z:null!=t.zmax&&null!=t.zmin?(t.zmax+t.zmin)/2:void 0,spatialReference:t.spatialReference});const c=m(t.spatialReference),s=T(n,e,a);r=s.lon,i=s.lat,o.diff(e.x,a.x)>o.range/2&&(r+=c.halfCircumference),r=Math.min(r,c.halfCircumference),i=Math.min(i,c.halfCircumference)}else{const a=e.renderSpatialReference??t.spatialReference;a.equals(t.spatialReference)||(t=h(t,a)),r=t.xmax-t.xmin,i=t.ymax-t.ymin;const o=null!=t.zmax&&null!=t.zmin?(t.zmax+t.zmin)/2:void 0;n=new p({x:t.xmin+.5*r,y:t.ymin+.5*i,z:o,spatialReference:a})}const a=null!=t.zmax&&null!=t.zmin?t.zmax-t.zmin:0,o=e.state.camera,c=1/Math.tan(o.fovX/2),s=1/Math.tan(o.fovY/2),l=1/Math.tan(o.fov/2);return{center:n,distance:Math.max(.5*r*c,.5*i*s,.5*a*l)/L}}async function fe(e,t,n,r,i,o){const c=le(e,t)?t:await d(t,e.spatialReference,{signal:o});a(o);const{center:s,distance:l}=ue(e,c),u=await ne(e,n,r,s,l,i,o);return a(o),je(e,u,e.camera.fov,o)}function me(e,t,n,r,i,a){let o;try{o=le(e,t)?t:h(t,e.spatialReference)}catch(u){return null}const{center:c,distance:s}=ue(e,o),l=te(e,n,r,c,s,i);return null==l?null:Me(e,l,e.camera.fov,a)}function pe(e,t,n){const r=e.renderSpatialReference,i=new p({spatialReference:I(e)});if(!w(n,r,i))return null;const a=Math.tan(t.fovX/2),o=Math.tan(t.fovY/2),c=s(t.eye,n),l=2*c*a*L,u=2*c*o*L;return S(e).toExtent(e,i,l,u)}function de(e,t){return S(e).toArea(e,t)}function he(e,t,n){const r=e.pointsOfInterest.centerOnSurfaceFrequent.distance;if(Math.log(n/r)/Math.LN2>U)return!0;const i=t,a=e.pointsOfInterest.centerOnSurfaceFrequent.renderLocation;return c(i,a)/(Math.tan(.5*e.state.camera.fov)*r)>H}function ge(e,t,n,r,i,a){let o=0;return 1===a&&he(e,r,i)?(t=0,o=ve(e,i,n,r)):o=xe(e,r,i,n),o=e.state.constraints.clampTilt(i,o),{heading:t,tilt:n=we(e,r,i,o)}}const ye=.7;function ve(e,t,n,r){const i=xe(e,r,t,n);if(!e.state.constraints.tilt)return i;const a=e.state.constraints.tilt(t);a.max=Math.min(a.max,.5*Math.PI);const o=a.min*(1-ye)+a.max*ye;return Math.min(i,o)}function Re(e,t,n,r){let i=xe(e,r,t,n);if(!e.state.constraints.tilt)return i;const a=e.state.constraints.tilt(t);return i=Math.min(i,.5*Math.PI),a.min*(1-ye)+i*ye}function we(e,t,n,r){return S(e).lookAtTiltToEyeTilt(r,t,n)}function xe(e,t,n,r){return S(e).eyeTiltToLookAtTilt(r,t,n)}function Me(t,n,r,i){if(null==n)return null;const a=t.renderSpatialReference,o=new p({spatialReference:I(t)});return w(n.eye,a,o)?(i??=new e,i.position=o,i.heading=n.heading,i.tilt=n.tilt,i.fov=r,i):null}async function je(t,n,r,i){const o=t.renderSpatialReference,c=new p({spatialReference:I(t)});return await R(n.eye,o,c,{signal:i}),a(i),new e(c,n.heading,n.tilt,r)}function Te(e,t){const n=e.basemapTerrain?.tilingScheme;if(n)return n.levelAtScale(t);P().error("#scaleToZoom()","Cannot compute zoom from scale without a tiling scheme")}function ze(e,t){const n=e.basemapTerrain?.tilingScheme;if(n)return n.scaleAtLevel(t);P().error("#zoomToScale()","Cannot compute scale from zoom without a tiling scheme")}export{X as applyTiltAdjustToScale,O as distanceToScale,K as fromCenterDistanceAsync,J as fromCenterDistanceSync,B as fromCenterScale,fe as fromExtentAsync,me as fromExtentSync,ne as getObserverForPointAtDistanceAsync,te as getObserverForPointAtDistanceSync,I as getViewSR,E as headingTiltToDirectionUp,k as removeTiltAdjustFromScale,Y as scaleErrorThreshold,F as scaleToDistance,Te as scaleToZoom,de as toArea,pe as toExtent,Z as viewScaleToCameraDistance,ze as zoomToScale};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import{watch as t,when as s,syncAndInitial as i,sync as l}from"../../../../core/reactiveUtils.js";import{throttle as a}from"../../../../core/throttle.js";import{property as r,subclass as o}from"../../../../core/accessorSupport/decorators.js";import{clone as n,create as d}from"../../../../geometry/support/aaBoundingRect.js";import{toFlowData as h}from"../../../2d/engine/flow/dataUtils.js";import u from"../../layers/FlowSubView3D.js";import{getFeatureTileId as p}from"../../layers/support/FeatureTileDescriptor.js";import{tilesWaitingTime as c}from"./constants.js";import{FlowDataTile as f}from"./loadUtils.js";import{isRasterTile as T}from"../../terrain/TerrainData.js";import{descendantsAtLevel as g}from"../../terrain/tileUtils.js";const _={type:"delete"},y={type:"invalid"};let m=class extends u{constructor(e){super(e),this._flowDataTiles=D(),this._resetTileData=!0,this._throttledTriggerLoad=null,this._throttling=!1}initialize(){this.addHandles([this.surface.on("tile-data-changed",({tile:e,layerIndex:t,layerClass:s})=>{if(t!==this._layerIndex||1!==s)return;const i=this.frameTask.schedule(()=>{this._applyTileDataUpdate(e)&&this.triggerLoad()});this.updatingHandles.addPromise(i)}),t(()=>this.renderedTiles,e=>{const t=this.frameTask.scheduleGenerator(this.loadAllTiles?t=>this._applyTileDataUpdates(e,t):t=>this._syncToTiles(e,t));this.updatingHandles.addPromise(t)},i),s(()=>this.loadAllTiles,()=>{const e=this.frameTask.scheduleGenerator(e=>this._enterAllTilesMode(e));this.updatingHandles.addPromise(e)},i),t(()=>this._pixelSize,()=>{this.invalidateTileData(),this._resetTileData=!0},l),this.layerView.on("data-changed",()=>{this.invalidateTileData(),this._resetTileData=!0})]),this._throttledTriggerLoad=a(()=>{super.triggerLoad(),this._throttling=!1},()=>this._throttling=!0,c,this),this.addHandles(this._throttledTriggerLoad)}*_enterAllTilesMode(e){const{targetTiles:t,_flowDataTiles:s}=this,i=D();for(const[l,a]of s)t.has(l)&&i.set(l,a);this._flowDataTiles=i,this._resetTileData=!0,e.madeProgress(),e.done&&(e=yield),yield*this._applyTileDataUpdates(new Set(this.surface.allTiles),e),this.triggerLoad()}*_syncToTiles(e,t){const s=D();for(const i of e??[]){const e=this._flowDataTiles.get(i.key),l=null==e||"delete"===e.type||"invalid"===e.type?this._getLoadedState(i):e;null!=l&&s.set(i.key,l),t.madeProgress(),t.done&&(t=yield)}this._flowDataTiles=s,this._resetTileData=!0,this.triggerLoad()}*_applyTileDataUpdates(e,t){let s=!1;for(const i of e??[]){const e=this._applyTileDataUpdate(i);s||=e,t.madeProgress(),t.done&&(t=yield)}s&&this.triggerLoad()}abort(){super.abort(),this._throttling=!1}get _layerIndex(){return this.surface.getLayerIndexByUID(1,this.layerView.uid)}get _pixelSize(){return this.surface.tilingScheme.pixelSize}doRefresh(){this.invalidateTileData(),super.doRefresh()}triggerLoad(){const{_throttledTriggerLoad:e}=this;this._allTilesLoaded?(e.hasPendingUpdates()||e(),e.forceUpdate()):e()}async fetchDataAndGenerateStreamlines(e,t){const{_flowDataTiles:s,needsMagnitude:i,workerHandle:l}=this,a=this.getSimulationSettings(e);if(null==a||null==l)return;const r=this._resetTileData;this._resetTileData=!1;const o=D();s.forEach((e,t)=>{"delete"===e.type?(o.set(t,_),s.delete(t)):(r||"on-worker"!==e.type&&"invalid"!==e.type)&&(o.set(t,e),s.set(t,"invalid"===e.type?y:{type:"on-worker",sourceLevel:e.sourceLevel}))});const n={simulationSettings:a,flowExtentInfo:e.flowExtentInfo,flowDataTiles:o,reset:r,needsMagnitude:i,startPositions:this.startPositions(e)},{streamlines:d}=await l.generateTiledStreamlines(n,t);return d}getUpdating(){return super.getUpdating()||this._throttling}_getLoadedState(e){const{_layerIndex:t}=this,s=e.isDisposed;if(null==t||s)return null;const i=e.getLayerInfo(t,1);if(null==i)return null;const l=this._getRasterTile(i,e,t);return null==l?this._upsampleFlowData(t,i.upsampleInfo,e.lij,e.extent):{type:"loaded",data:this._createFlowDataTile(l,e.lij,e.extent,this._pixelSize),sourceLevel:e.level}}_upsampleFlowData(e,t,s,i){if(null==t)return null;const l=t.tile;if(null==l)return null;const a=l.getLayerInfo(e,1);if(null==a)return null;const r=this._getRasterTile(a,l,e);if(null==r)return null;const{scale:o,offset:n}=t,d=Math.max(Math.floor(this._pixelSize*o),1),h=r.source,u=Math.floor(n[0]*h.width),p=Math.floor((1-n[1]-o)*h.height);return{type:"loaded",data:this._createFlowDataTile(r,s,i,d,u,p),sourceLevel:l.level}}_getRasterTile(e,t,s){const{data:i}=e;return!e.dataMissing&&t.hasLayerData(s,1)&&T(i)?i:null}_createFlowDataTile(e,t,s,i,l,a){const r=h(this.layer.serviceRasterInfo.dataType,e.source,i,i,l,a),o=r.mask.slice();return new f(r.data,o,r.width,r.height,t,n(s))}_applyTileDataUpdate(e){const{renderedTiles:t,_layerIndex:s,loadAllTiles:i,loadAllTilesLevel:l}=this;if(null==t||null==s||i&&e.level>l)return!1;if(t.has(e))return this._updateRenderedTile(e);const a=e.key;let r=this._setTileData(a,_);const o=this._updateUpsampledTiles(t,e,s);r||=o;const n=i&&this._updateDescendants(e,s);return r||=n,r}_updateRenderedTile(e){const t=e.key,{_flowDataTiles:s}=this;if(w(s.get(t),e))return!1;const i=this._getLoadedState(e);return this._setTileData(t,i)}_updateUpsampledTiles(e,t,s){const{_flowDataTiles:i}=this;let l=!1;for(const a of e.values()){const e=a.key;if(w(i.get(e),t))continue;const r=a.getLayerInfo(s,1);if(null==r)continue;if(null!=this._getRasterTile(r,a,s))continue;const o=r.upsampleInfo?.tile;if(o!==t)continue;const n=this._getLoadedState(a),d=this._setTileData(e,n);l||=d}return l}_updateDescendants(e,t){let s=!1;const{tilingScheme:i,upsampleInfoPool:l}=this.surface,{targetTiles:a,_flowDataTiles:r,loadAllTilesLevel:o}=this,n=e.lij,h=g(n,o).map(e=>[p(e[0],e[1],e[2]),e]).filter(([e])=>a.has(e));if(0===h.length)return s;const u=1<<o-n[0],c=1/u,f=n[1]*u,T=n[2]*u,_=l.acquire();for(const[p,g]of h){if(w(r.get(p),e))continue;const l=d();i.getExtent(g[0],g[1],g[2],l);const a=1-(g[1]-f)*c-c,o=(g[2]-T)*c;_.init(e,o,a,c);const n=this._upsampleFlowData(t,_,g,l),h=this._setTileData(p,n);s||=h}return l.release(_),s}_setTileData(e,t){if(null==t)return!1;const{_flowDataTiles:s}=this;return(null!=s.get(e)||"delete"!==t.type)&&(s.set(e,t),!0)}get _allTilesLoaded(){let e=0;for(const t of this._flowDataTiles.values()??[])"delete"!==t.type&&"invalid"!==t.type&&e++;return this.loadAllTiles?e===this.targetTiles.size:e===this.renderedTiles?.size}invalidateTileData(){const{_flowDataTiles:e}=this;for(const t of e.keys())e.set(t,y)}get usedMemory(){const e=9*this._pixelSize**2,t=(this._flowDataTiles.size??0)*e;return super.usedMemory+t}get test(){return{...super.test,loadedTiles:this._flowDataTiles}}};function D(){return new Map}function w(e,t){return null!=e&&("loaded"===e.type||"on-worker"===e.type)&&e.sourceLevel>=t.level}e([r()],m.prototype,"_throttling",void 0),m=e([o("esri.views.3d.support.flow.FlowSubViewTiles3D")],m);export{m as default};
5
+ import{__decorate as e}from"tslib";import{watch as t,when as s,syncAndInitial as i,sync as l}from"../../../../core/reactiveUtils.js";import{throttle as a}from"../../../../core/throttle.js";import{property as r,subclass as o}from"../../../../core/accessorSupport/decorators.js";import{clone as n,create as d}from"../../../../geometry/support/aaBoundingRect.js";import{toFlowData as h}from"../../../2d/engine/flow/dataUtils.js";import u from"../../layers/FlowSubView3D.js";import{getFeatureTileId as p}from"../../layers/support/FeatureTileDescriptor.js";import{tilesWaitingTime as c}from"./constants.js";import{FlowDataTile as f}from"./loadUtils.js";import{isRasterTile as T}from"../../terrain/TerrainData.js";import{descendantsAtLevel as g}from"../../terrain/tileUtils.js";const _={type:"delete"},y={type:"invalid"};let D=class extends u{constructor(e){super(e),this._flowDataTiles=m(),this._resetTileData=!0,this._flowDataTilesSet=!1,this._throttledTriggerLoad=null,this._throttling=!1}initialize(){this.addHandles([this.surface.on("tile-data-changed",({tile:e,layerIndex:t,layerClass:s})=>{if(t!==this._layerIndex||1!==s)return;const i=this.frameTask.schedule(()=>{this._applyTileDataUpdate(e)&&this.triggerLoad()});this.updatingHandles.addPromise(i)}),t(()=>this.renderedTiles,e=>{const t=this.frameTask.scheduleGenerator(this.loadAllTiles?t=>this._applyTileDataUpdates(e,t):t=>this._syncToTiles(e,t));this.updatingHandles.addPromise(t)},i),s(()=>null!=this.renderedTiles&&null!=this.extent&&this.loadAllTiles,()=>{const e=this.frameTask.scheduleGenerator(e=>this._enterAllTilesMode(e));this.updatingHandles.addPromise(e)},i),t(()=>this._pixelSize,()=>{this.invalidateTileData(),this._resetTileData=!0},l),this.layerView.on("data-changed",()=>{this.invalidateTileData(),this._resetTileData=!0})]),this._throttledTriggerLoad=a(()=>{super.triggerLoad(),this._throttling=!1},()=>this._throttling=!0,c,this),this.addHandles(this._throttledTriggerLoad)}*_enterAllTilesMode(e){const{targetTiles:t,_flowDataTiles:s}=this,i=m();for(const[l,a]of s)t.has(l)&&i.set(l,a);this._setFlowDataTiles(i),e.madeProgress(),e.done&&(e=yield),yield*this._applyTileDataUpdates(new Set(this.surface.allTiles),e),this.triggerLoad()}*_syncToTiles(e,t){const s=m();for(const i of e??[]){const e=this._flowDataTiles.get(i.key),l=null==e||"delete"===e.type||"invalid"===e.type?this._getLoadedState(i):e;null!=l&&s.set(i.key,l),t.madeProgress(),t.done&&(t=yield)}this._setFlowDataTiles(s),this.triggerLoad()}*_applyTileDataUpdates(e,t){let s=!1;for(const i of e??[]){const e=this._applyTileDataUpdate(i);s||=e,t.madeProgress(),t.done&&(t=yield)}s&&this.triggerLoad()}abort(){super.abort(),this._throttling=!1}get _layerIndex(){return this.surface.getLayerIndexByUID(1,this.layerView.uid)}get _pixelSize(){return this.surface.tilingScheme.pixelSize}doRefresh(){this.invalidateTileData(),super.doRefresh()}triggerLoad(){const{_throttledTriggerLoad:e}=this;this._allTilesLoaded?(e.hasPendingUpdates()||e(),e.forceUpdate()):e()}async fetchDataAndGenerateStreamlines(e,t){const{_flowDataTiles:s,needsMagnitude:i,workerHandle:l}=this,a=this.getSimulationSettings(e);if(null==a||null==l||0===s.size)return;const r=this._resetTileData;this._resetTileData=!1;const o=m();s.forEach((e,t)=>{"delete"===e.type?(o.set(t,_),s.delete(t)):(r||"on-worker"!==e.type&&"invalid"!==e.type)&&(o.set(t,e),s.set(t,"invalid"===e.type?y:{type:"on-worker",sourceLevel:e.sourceLevel}))});const n={simulationSettings:a,flowExtentInfo:e.flowExtentInfo,flowDataTiles:o,reset:r,needsMagnitude:i,startPositions:this.startPositions(e)},{streamlines:d}=await l.generateTiledStreamlines(n,t);return d}getUpdating(){return super.getUpdating()||this._throttling}get loadRequirementsMet(){return super.loadRequirementsMet&&this._flowDataTilesSet}_getLoadedState(e){const{_layerIndex:t}=this,s=e.isDisposed;if(null==t||s)return null;const i=e.getLayerInfo(t,1);if(null==i)return null;const l=this._getRasterTile(i,e,t);return null==l?this._upsampleFlowData(t,i.upsampleInfo,e.lij,e.extent):{type:"loaded",data:this._createFlowDataTile(l,e.lij,e.extent,this._pixelSize),sourceLevel:e.level}}_upsampleFlowData(e,t,s,i){if(null==t)return null;const l=t.tile;if(null==l)return null;const a=l.getLayerInfo(e,1);if(null==a)return null;const r=this._getRasterTile(a,l,e);if(null==r)return null;const{scale:o,offset:n}=t,d=Math.max(Math.floor(this._pixelSize*o),1),h=r.source,u=Math.floor(n[0]*h.width),p=Math.floor((1-n[1]-o)*h.height);return{type:"loaded",data:this._createFlowDataTile(r,s,i,d,u,p),sourceLevel:l.level}}_getRasterTile(e,t,s){const{data:i}=e;return!e.dataMissing&&t.hasLayerData(s,1)&&T(i)?i:null}_createFlowDataTile(e,t,s,i,l,a){const r=h(this.layer.serviceRasterInfo.dataType,e.source,i,i,l,a),o=r.mask.slice();return new f(r.data,o,r.width,r.height,t,n(s))}_applyTileDataUpdate(e){const{renderedTiles:t,_layerIndex:s,loadAllTiles:i,loadAllTilesLevel:l}=this;if(null==t||null==s||i&&e.level>l)return!1;if(t.has(e))return this._updateRenderedTile(e);const a=e.key;let r=this._setTileData(a,_);const o=this._updateUpsampledTiles(t,e,s);r||=o;const n=i&&this._updateDescendants(e,s);return r||=n,r}_updateRenderedTile(e){const t=e.key,{_flowDataTiles:s}=this;if(w(s.get(t),e))return!1;const i=this._getLoadedState(e);return this._setTileData(t,i)}_updateUpsampledTiles(e,t,s){const{_flowDataTiles:i}=this;let l=!1;for(const a of e.values()){const e=a.key;if(w(i.get(e),t))continue;const r=a.getLayerInfo(s,1);if(null==r)continue;if(null!=this._getRasterTile(r,a,s))continue;const o=r.upsampleInfo?.tile;if(o!==t)continue;const n=this._getLoadedState(a),d=this._setTileData(e,n);l||=d}return l}_updateDescendants(e,t){let s=!1;const{tilingScheme:i,upsampleInfoPool:l}=this.surface,{targetTiles:a,_flowDataTiles:r,loadAllTilesLevel:o}=this,n=e.lij,h=g(n,o).map(e=>[p(e[0],e[1],e[2]),e]).filter(([e])=>a.has(e));if(0===h.length)return s;const u=1<<o-n[0],c=1/u,f=n[1]*u,T=n[2]*u,_=l.acquire();for(const[p,g]of h){if(w(r.get(p),e))continue;const l=d();i.getExtent(g[0],g[1],g[2],l);const a=1-(g[1]-f)*c-c,o=(g[2]-T)*c;_.init(e,o,a,c);const n=this._upsampleFlowData(t,_,g,l),h=this._setTileData(p,n);s||=h}return l.release(_),s}_setTileData(e,t){if(null==t)return!1;const{_flowDataTiles:s}=this;return(null!=s.get(e)||"delete"!==t.type)&&(s.set(e,t),!0)}_setFlowDataTiles(e){this._flowDataTiles=e,this._resetTileData=!0,this._flowDataTilesSet=!0}get _allTilesLoaded(){let e=0;for(const t of this._flowDataTiles.values()??[])"delete"!==t.type&&"invalid"!==t.type&&e++;return this.loadAllTiles?e===this.targetTiles.size:e===this.renderedTiles?.size}invalidateTileData(){const{_flowDataTiles:e}=this;for(const t of e.keys())e.set(t,y)}get usedMemory(){const e=9*this._pixelSize**2,t=(this._flowDataTiles.size??0)*e;return super.usedMemory+t}get test(){return{...super.test,loadedTiles:this._flowDataTiles}}};function m(){return new Map}function w(e,t){return null!=e&&("loaded"===e.type||"on-worker"===e.type)&&e.sourceLevel>=t.level}e([r()],D.prototype,"_throttling",void 0),D=e([o("esri.views.3d.support.flow.FlowSubViewTiles3D")],D);export{D as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{reallocGrowthFactor as e}from"../../../../core/arrayUtils.js";import"../../../../core/has.js";import{signal as t}from"../../../../core/signal.js";import{makeScheduleFunction as r}from"../../layers/support/makeScheduleFunction.js";import{GaussianSplatSortWorkerHandle as s}from"../GaussianSplatWorkerHandle.js";import{GaussianSplatFadeTexture as i}from"./GaussianSplatFadeTexture.js";import{GaussianSplatOrderTexture as a}from"./GaussianSplatOrderTexture.js";import{GaussianSplatTextureAtlas as n}from"./GaussianSplatTextureAtlas.js";class o{constructor(e){this._updating=t(!1),this.visibleGaussians=0,this._visibleGaussianTiles=new Array,this._workerHandle=null,this._isSorting=!1,this._pendingSortTask=!1,this._bufferCapacity=0,this._renderer=e,this._orderTexture=new a(this._renderer.renderingContext),this._fadingTexture=new i(this._renderer.renderingContext),this._textureAtlas=new n(this._renderer.renderingContext,this._renderer.view.resourceController.memoryController,this._renderer.fboCache);const{resourceController:o}=this._renderer.view;this._workerHandle=new s(r(o))}get textureAtlas(){return this._textureAtlas}get orderTexture(){return this._orderTexture}get fadingTexture(){return this._fadingTexture}get visibleGaussianTiles(){return this._visibleGaussianTiles}updateGaussianVisibility(e){this._visibleGaussianTiles=e,this.requestSort()}isUpdating(){return this._updating.value}destroy(){this._pendingSortTask=!1,this._workerHandle?.destroyWorkerAndSelf(),this._textureAtlas.destroy(),this._orderTexture.destroy(),this._fadingTexture.destroy()}requestSort(){this._updating.value=!0,this._isSorting?this._pendingSortTask=!0:(this._isSorting=!0,this._pendingSortTask=!1,this._sortOnWorker().then(()=>this._handleSortComplete()).catch(()=>this._handleSortComplete()))}_handleSortComplete(){this._isSorting=!1,this._pendingSortTask?this.requestSort():this._updating.value=!1}_clearBuffersAndTextures(){this._bufferCapacity=0,this._orderTexture.clear(),this._textureAtlas.clear()}_ensureBufferCapacity(t){if(this._bufferCapacity<t){const r=Math.ceil(t*e);this._atlasIndicesBuffer=new Uint32Array(r),this._sortedAtlasIndicesBuffer=new Uint32Array(r),this._distancesBuffer=new Float64Array(r),this._sortOrderBuffer=new Uint32Array(r),this._bufferCapacity=r}}async _sortOnWorker(){let e=0;if(this._visibleGaussianTiles.forEach(t=>e+=t.gaussianAtlasIndices.length),0===e)return this.visibleGaussians=0,this._clearBuffersAndTextures(),void this._renderer.requestRender(1);this._ensureBufferCapacity(e),this._textureAtlas.ensureTextureAtlas();const t=this._renderer.camera.eye,r=t[0],s=t[1],i=t[2],a=this._atlasIndicesBuffer.subarray(0,e);let n=0;this._visibleGaussianTiles.forEach(e=>{const t=e.gaussianAtlasIndices,o=e.positions;for(let u=0;u<t.length;u++){a[n]=t[u];const e=3*u,h=o[e],d=o[e+1],l=o[e+2],_=h-r,f=d-s,c=l-i;this._distancesBuffer[n]=_*_+f*f+c*c,n++}});for(let u=0;u<e;u++)this._sortOrderBuffer[u]=u;const o={distances:this._distancesBuffer,sortOrderIndices:this._sortOrderBuffer,numGaussians:e,preciseSort:!1};await(this._workerHandle?.sort(o).then(t=>{this._distancesBuffer=t.distances,this._sortOrderBuffer=t.sortedOrderIndices;const r=this._sortedAtlasIndicesBuffer.subarray(0,e);for(let i=0;i<e;i++)r[i]=a[t.sortedOrderIndices[i]];this._orderTexture.setData(r,e);const s=this._renderer.view.qualitySettings.gaussianSplat.maxAllowedVisibleGaussians;this.visibleGaussians=Math.min(e,s),this._renderer.requestRender(1)}))}}export{o as GaussianSplatDataStore};
5
+ import{reallocGrowthFactor as e}from"../../../../core/arrayUtils.js";import"../../../../core/has.js";import{signal as r}from"../../../../core/signal.js";import{intersectsSphere as s}from"../../../../geometry/support/frustum.js";import{Sphere as t}from"../../../../geometry/support/sphere.js";import{makeScheduleFunction as i}from"../../layers/support/makeScheduleFunction.js";import{GaussianSplatSortWorkerHandle as n}from"../GaussianSplatWorkerHandle.js";import{GaussianSplatFadeTexture as a}from"./GaussianSplatFadeTexture.js";import{GaussianSplatOrderTexture as o}from"./GaussianSplatOrderTexture.js";import{GaussianSplatTextureAtlas as u}from"./GaussianSplatTextureAtlas.js";class h{constructor(e){this._updating=r(!1),this.visibleGaussians=0,this._visibleGaussianTiles=new Array,this._workerHandle=null,this._isSorting=!1,this._pendingSortTask=!1,this._bufferCapacity=0,this._minimumBoundingSphere=new t,this._renderer=e,this._orderTexture=new o(this._renderer.renderingContext),this._fadingTexture=new a(this._renderer.renderingContext),this._textureAtlas=new u(this._renderer.renderingContext,this._renderer.view.resourceController.memoryController,this._renderer.fboCache);const{resourceController:s}=this._renderer.view;this._workerHandle=new n(i(s))}get textureAtlas(){return this._textureAtlas}get orderTexture(){return this._orderTexture}get fadingTexture(){return this._fadingTexture}get visibleGaussianTiles(){return this._visibleGaussianTiles}updateGaussianVisibility(e){this._visibleGaussianTiles=e,this.requestSort()}isUpdating(){return this._updating.value}destroy(){this._pendingSortTask=!1,this._workerHandle?.destroyWorkerAndSelf(),this._textureAtlas.destroy(),this._orderTexture.destroy(),this._fadingTexture.destroy()}requestSort(){this._updating.value=!0,this._isSorting?this._pendingSortTask=!0:(this._isSorting=!0,this._pendingSortTask=!1,this._sortOnWorker().then(()=>this._handleSortComplete()).catch(()=>this._handleSortComplete()))}_handleSortComplete(){this._isSorting=!1,this._pendingSortTask?this.requestSort():this._updating.value=!1}_clearBuffersAndTextures(){this._bufferCapacity=0,this._orderTexture.clear(),this._textureAtlas.clear()}_ensureBufferCapacity(r){if(this._bufferCapacity<r){const s=Math.ceil(r*e);this._atlasIndicesBuffer=new Uint32Array(s),this._sortedAtlasIndicesBuffer=new Uint32Array(s),this._distancesBuffer=new Float64Array(s),this._sortOrderBuffer=new Uint32Array(s),this._bufferCapacity=s}}async _sortOnWorker(){if(0===this._visibleGaussianTiles.length)return this.visibleGaussians=0,this._clearBuffersAndTextures(),void this._renderer.requestRender(1);let e=this._visibleGaussianTiles.reduce((e,r)=>e+r.gaussianAtlasIndices.length,0);this._ensureBufferCapacity(e),this._textureAtlas.ensureTextureAtlas();const r=this._renderer.camera.frustum,t=this._renderer.camera.eye,i=t[0],n=t[1],a=t[2];let o=0;if(this._visibleGaussianTiles.forEach(t=>{const u=t.gaussianAtlasIndices,h=t.positions;if(this._minimumBoundingSphere.center=t.obb.center,this._minimumBoundingSphere.radius=t.obb.radius+t.maxScale,s(r,this._minimumBoundingSphere))for(let e=0;e<u.length;e++){this._atlasIndicesBuffer[o]=u[e];const r=3*e,s=h[r]-i,t=h[r+1]-n,d=h[r+2]-a;this._distancesBuffer[o]=s*s+t*t+d*d,this._sortOrderBuffer[o]=o,o++}else e-=u.length}),0===e)return this.visibleGaussians=0,this._clearBuffersAndTextures(),void this._renderer.requestRender(1);const u={distances:this._distancesBuffer,sortOrderIndices:this._sortOrderBuffer,numGaussians:e,preciseSort:!1};await(this._workerHandle?.sort(u).then(r=>{this._distancesBuffer=r.distances,this._sortOrderBuffer=r.sortedOrderIndices;const s=this._sortedAtlasIndicesBuffer.subarray(0,e);for(let i=0;i<e;i++)s[i]=this._atlasIndicesBuffer[r.sortedOrderIndices[i]];this._orderTexture.setData(s,e);const t=this._renderer.view.qualitySettings.gaussianSplat.maxAllowedVisibleGaussians;this.visibleGaussians=Math.min(e,t),this._renderer.requestRender(1)}))}}export{h as GaussianSplatDataStore};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{signal as i}from"../../../../core/signal.js";class e{static{this.fadeInEase=i=>i*(2-i)}static{this.fadeOutEase=i=>i*i}constructor(e){this.layerView=e,this._numFadingTiles=i(0)}get numFadingTiles(){return this._numFadingTiles.value}fadeTile(i,e){const t=this._getTargetOpacity(e);if(i.fadeDirection=e,0===this.fadeDuration)return void this._instantTileFading(i,t);const a=i.opacityModifier;if(a!==t){const e=1-Math.abs(t-a);this._startTileFading(i,e)}else this._stopTileFading(i)}updateAllTileFading(i){this.layerView.tileHandles.forEach(e=>this._updateTileFading(e,i)),this.layerView.updateGaussians()}onFadeDurationChanged(i){0===i&&this.numFadingTiles>0&&this._instantlyFullyFadeAllTiles()}isTileFadingOut(i){return null!=i.fadeProgress&&1===i.fadeDirection}isUpdating(){return this._numFadingTiles.value>0}get fadeDuration(){return 2*this.layerView.view.qualitySettings.fadeDuration}get fadingEnabled(){return 0!==this.fadeDuration}_startTileFading(i,e){null==i.fadeProgress&&this._numFadingTiles.value++,i.fadeProgress=e}_stopTileFading(i){null!=i.fadeProgress&&(1===i.fadeDirection&&this._onTileFullyFadedOut(i),this._numFadingTiles.value--,i.fadeProgress=null)}_updateTileFading(i,t){const{fadeProgress:a,fadeDirection:s}=i;if(null==a)return;const n=this._fadeDirectionToSign(s),l=n*this.fadeDuration,d=this._getTargetOpacity(s),r=t/Math.abs(l||1),o=Math.min(a+r,1),u=n*(1-(0===s?e.fadeInEase:e.fadeOutEase)(o)),g=1===o;i.opacityModifier=g?d:d-u,g?this._stopTileFading(i):i.fadeProgress=o,this._updateOpacityModifier(i)}_updateOpacityModifier(i){const e=255*i.opacityModifier;for(let t=0;t<i.pageIds.length;t++){const a=i.pageIds[t];this.layerView.data.fadingTexture.updateBuffer(e,a)}}_instantTileFading(i,e){i.fadeProgress=null,i.opacityModifier=e,this._updateOpacityModifier(i),1===i.fadeDirection&&this._onTileFullyFadedOut(i)}_instantlyFullyFadeAllTiles(){this.layerView.tileHandles.forEach(i=>{null!=i.fadeProgress&&this._instantTileFading(i,this._getTargetOpacity(i.fadeDirection))}),this.layerView.updateGaussians(),this._numFadingTiles.value=0}_onTileFullyFadedOut(i){i.isVisible=!1,this.layerView.moveTileToCache(i)}_fadeDirectionToSign(i){return 0===i?1:-1}_getTargetOpacity(i){return 0===i?1:0}}export{e as GaussianSplatFadeHelper};
5
+ import{signal as i}from"../../../../core/signal.js";class e{static{this.fadeInEase=i=>i*(2-i)}static{this.fadeOutEase=i=>i*i}constructor(e){this.layerView=e,this._numFadingTiles=i(0)}get numFadingTiles(){return this._numFadingTiles.value}fadeTile(i,e){const t=this._getTargetOpacity(e);if(i.fadeDirection=e,0===this.fadeDuration)return void this._instantTileFading(i,t);const a=i.opacityModifier;if(a!==t){const e=1-Math.abs(t-a);this._startTileFading(i,e)}else this._stopTileFading(i)}updateAllTileFading(i){this.layerView.tileHandles.forEach(e=>this._updateTileFading(e,i)),this.layerView.updateGaussians()}onFadeDurationChanged(i){0===i&&this.numFadingTiles>0&&this._instantlyFullyFadeAllTiles()}isTileFadingOut(i){return null!=i.fadeProgress&&1===i.fadeDirection}isUpdating(){return this._numFadingTiles.value>0}get fadeDuration(){return this.layerView.view.qualitySettings.fadeDuration}get fadingEnabled(){return 0!==this.fadeDuration}_startTileFading(i,e){null==i.fadeProgress&&this._numFadingTiles.value++,i.fadeProgress=e}_stopTileFading(i){null!=i.fadeProgress&&(1===i.fadeDirection&&this._onTileFullyFadedOut(i),this._numFadingTiles.value--,i.fadeProgress=null)}_updateTileFading(i,t){const{fadeProgress:a,fadeDirection:s}=i;if(null==a)return;const n=this._fadeDirectionToSign(s),l=n*this.fadeDuration,d=this._getTargetOpacity(s),r=t/Math.abs(l||1),o=Math.min(a+r,1),u=n*(1-(0===s?e.fadeInEase:e.fadeOutEase)(o)),g=1===o;i.opacityModifier=g?d:d-u,g?this._stopTileFading(i):i.fadeProgress=o,this._updateOpacityModifier(i)}_updateOpacityModifier(i){const e=255*i.opacityModifier;for(let t=0;t<i.pageIds.length;t++){const a=i.pageIds[t];this.layerView.data.fadingTexture.updateBuffer(e,a)}}_instantTileFading(i,e){i.fadeProgress=null,i.opacityModifier=e,this._updateOpacityModifier(i),1===i.fadeDirection&&this._onTileFullyFadedOut(i)}_instantlyFullyFadeAllTiles(){this.layerView.tileHandles.forEach(i=>{null!=i.fadeProgress&&this._instantTileFading(i,this._getTargetOpacity(i.fadeDirection))}),this.layerView.updateGaussians(),this._numFadingTiles.value=0}_onTileFullyFadedOut(i){i.isVisible=!1,this.layerView.moveTileToCache(i)}_fadeDirectionToSign(i){return 0===i?1:-1}_getTargetOpacity(i){return 0===i?1:0}}export{e as GaussianSplatFadeHelper};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{create as r}from"../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{D as n,d as t,e as i,j as e,g as c,i as o,n as u}from"../../../chunks/vec32.js";import{create as f}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getNormal as l,signedDistance as s}from"../../../geometry/support/plane.js";function p(r,n,t){return r[0]*n[0]+r[1]*n[1]+r[2]*n[2]+r[3]<t}function a(r,n,t){const i=n[0],e=n[1],c=n[2];return!(r[0][0]*i+r[0][1]*e+r[0][2]*c+r[0][3]>t)&&(!(r[1][0]*i+r[1][1]*e+r[1][2]*c+r[1][3]>t)&&(!(r[2][0]*i+r[2][1]*e+r[2][2]*c+r[2][3]>t)&&(!(r[3][0]*i+r[3][1]*e+r[3][2]*c+r[3][3]>t)&&(!(r[4][0]*i+r[4][1]*e+r[4][2]*c+r[4][3]>t)&&!(r[5][0]*i+r[5][1]*e+r[5][2]*c+r[5][3]>t)))))}function m(r,n,t,i){return h(r,n,null,v(i,n,t,!1))}function d(r,n){for(let t=0;t<6;t++){if(s(r[t],n)>0)return!1}return!0}function g(r,n,t,i){return h(r,n,t,v(i,n,t,!0))}function j(r,n,t,u){const f=c(t,i(r,u,n));return o(r,n,e(r,t,f))}const b={dir:f(),len:0,clip:r()};function v(r,c,o,f){const l=b;return r?(o&&f&&(l.len=n(c,o)),t(l.dir,r)):f?(l.len=n(c,o),i(l.dir,o,c),e(l.dir,l.dir,1/l.len)):(i(l.dir,o,c),u(l.dir,l.dir)),l}function x(r,n,t){const i=c(l(r),t.dir),e=-s(r,n);if(e<0&&i>=0)return!1;if(i>-1e-6&&i<1e-6)return e>0;if((e<0||i<0)&&!(e<0&&i<0))return!0;const o=e/i;return i>0?o<t.clip[1]&&(t.clip[1]=o):o>t.clip[0]&&(t.clip[0]=o),t.clip[0]<=t.clip[1]}function h(r,n,t,i){i.clip[0]=0,i.clip[1]=t?i.len:Number.MAX_VALUE;for(let e=0;e<r.length;e++)if(!x(r[e],n,i))return!1;return!0}export{j as closestPointOnRay,g as frustumLineSegment,d as frustumPoint,m as frustumRay,a as frustumSphere,p as planeSphere};
5
+ import{create as r}from"../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{C as n,d as t,e as i,j as e,g as c,i as o,n as u}from"../../../chunks/vec32.js";import{create as f}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getNormal as l,signedDistance as s}from"../../../geometry/support/plane.js";function p(r,n,t){return r[0]*n[0]+r[1]*n[1]+r[2]*n[2]+r[3]<t}function a(r,n,t){const i=n[0],e=n[1],c=n[2];return!(r[0][0]*i+r[0][1]*e+r[0][2]*c+r[0][3]>t)&&(!(r[1][0]*i+r[1][1]*e+r[1][2]*c+r[1][3]>t)&&(!(r[2][0]*i+r[2][1]*e+r[2][2]*c+r[2][3]>t)&&(!(r[3][0]*i+r[3][1]*e+r[3][2]*c+r[3][3]>t)&&(!(r[4][0]*i+r[4][1]*e+r[4][2]*c+r[4][3]>t)&&!(r[5][0]*i+r[5][1]*e+r[5][2]*c+r[5][3]>t)))))}function m(r,n,t,i){return h(r,n,null,v(i,n,t,!1))}function d(r,n){for(let t=0;t<6;t++){if(s(r[t],n)>0)return!1}return!0}function g(r,n,t,i){return h(r,n,t,v(i,n,t,!0))}function j(r,n,t,u){const f=c(t,i(r,u,n));return o(r,n,e(r,t,f))}const b={dir:f(),len:0,clip:r()};function v(r,c,o,f){const l=b;return r?(o&&f&&(l.len=n(c,o)),t(l.dir,r)):f?(l.len=n(c,o),i(l.dir,o,c),e(l.dir,l.dir,1/l.len)):(i(l.dir,o,c),u(l.dir,l.dir)),l}function x(r,n,t){const i=c(l(r),t.dir),e=-s(r,n);if(e<0&&i>=0)return!1;if(i>-1e-6&&i<1e-6)return e>0;if((e<0||i<0)&&!(e<0&&i<0))return!0;const o=e/i;return i>0?o<t.clip[1]&&(t.clip[1]=o):o>t.clip[0]&&(t.clip[0]=o),t.clip[0]<=t.clip[1]}function h(r,n,t,i){i.clip[0]=0,i.clip[1]=t?i.len:Number.MAX_VALUE;for(let e=0;e<r.length;e++)if(!x(r[e],n,i))return!1;return!0}export{j as closestPointOnRay,g as frustumLineSegment,d as frustumPoint,m as frustumRay,a as frustumSphere,p as planeSphere};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as t}from"tslib";import{destroyMaybe as e}from"../../../../core/maybe.js";import{on as r}from"../../../../core/reactiveUtils.js";import{property as i,subclass as o}from"../../../../core/accessorSupport/decorators.js";import{D as s,m as n,d as a}from"../../../../chunks/vec32.js";import{create as l}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import d from"../../../../geometry/Point.js";import{InvalidLayerError as h}from"../../../../layers/support/ElevationQuery.js";import{distanceToScale as p}from"../cameraUtils.js";import{PointOfInterest as c}from"./PointOfInterest.js";import{PropertiesPool as u}from"../../../support/PropertiesPool.js";import{Yield as m}from"../../../support/Yield.js";let _=class extends c{constructor(t){super(t),this._dirty=!1,this._propertiesPool=new u({location:()=>new d,renderLocation:()=>l()},this),this._estimatedSurfaceAltitude=0,this._elevationQueryController=null,this.renderLocation=l(),this._tmpPoint=new d}initialize(){if(this.scheduler&&this.addHandles(this.scheduler.registerTask(this.task,this)),this.runTask(),this.map){const t=()=>this._setDirty();this.addHandles(r(()=>this.map?.ground?.layers,"change",t,{onListenerAdd:t,onListenerRemove:t}))}this._updateRenderLocation()}destroy(){this._cancelPendingRequest(),this._propertiesPool=e(this._propertiesPool)}get _camera(){return this.state.contentCamera}get location(){const t=this._propertiesPool.get("location");return t.spatialReference=this.state.spatialReference,this.renderCoordsHelper.fromRenderCoords(this.renderLocation,t),t}get scale(){const t=this._camera,e=s(t.eye,this.renderLocation),r={renderCoordsHelper:this.renderCoordsHelper,state:{camera:t}};return p(r,e)}get updating(){return this._dirty||null!=this._elevationQueryController}updateRenderLocation(){this._setDirty(),this._updateRenderLocation()}_setDirty(){this._dirty||(this._dirty=!0,this.notifyChange("updating"))}_cancelPendingRequest(){const t=this._elevationQueryController;t&&(this._elevationQueryController=null,t.abort(),this.notifyChange("updating"))}get readyToRun(){return!this._elevationQueryController&&this._dirty}runTask(){if(this._cancelPendingRequest(),this._dirty=!1,this.notifyChange("updating"),!this.map?.ground)return this._updateSurfaceAltitude(0),m;const t=this.state.spatialReference;this._tmpPoint.spatialReference=t,this.renderCoordsHelper.fromRenderCoords(this._camera.eye,this._tmpPoint);const e=(this._tmpPoint.z??0)>f&&1===this.renderCoordsHelper.viewingMode&&(t.isWGS84||t.isWebMercator);let r=new AbortController;return this.map.ground.queryElevation(this._tmpPoint,{signal:r.signal,cache:this.cache,minDemResolution:e?g:0}).then(t=>this._updateSurfaceAltitude(t.geometry.z??0)).catch(t=>{if(t.name===h)if(this.integratedMeshElevationSampler){this._tmpPoint.spatialReference=this.integratedMeshElevationSampler.spatialReference,this.renderCoordsHelper.fromRenderCoords(this._camera.eye,this._tmpPoint);const t=this.integratedMeshElevationSampler.elevationAt(this._tmpPoint.x,this._tmpPoint.y)??0;this._updateSurfaceAltitude(t===this.integratedMeshElevationSampler.noDataValue?0:t)}else this._updateSurfaceAltitude(0)}).catch(()=>{}).then(()=>{this._elevationQueryController===r&&(this._elevationQueryController=null,this.notifyChange("updating")),r=null}),this._elevationQueryController=r,m}_updateSurfaceAltitude(t){this._estimatedSurfaceAltitude!==t&&(this._estimatedSurfaceAltitude=t,this._updateRenderLocation())}_updateRenderLocation(){this.renderCoordsHelper.setAltitude(y,this._estimatedSurfaceAltitude,this._camera.eye),n(this._get("renderLocation"),y)||(this._set("renderLocation",a(this._propertiesPool.get("renderLocation"),y)),this.notifyChange("renderLocation"))}};t([i({constructOnly:!0})],_.prototype,"scheduler",void 0),t([i({constructOnly:!0})],_.prototype,"cache",void 0),t([i({constructOnly:!0})],_.prototype,"map",void 0),t([i({constructOnly:!0})],_.prototype,"task",void 0),t([i({constructOnly:!0})],_.prototype,"integratedMeshElevationSampler",void 0),t([i()],_.prototype,"location",null),t([i()],_.prototype,"renderLocation",void 0),t([i()],_.prototype,"scale",null),t([i()],_.prototype,"updating",null),_=t([o("esri.views.3d.support.pointsOfInterest.CameraOnSurface")],_);const y=l(),f=1e5,g=1e6;export{_ as CameraOnSurface};
5
+ import{__decorate as t}from"tslib";import{destroyMaybe as e}from"../../../../core/maybe.js";import{on as r}from"../../../../core/reactiveUtils.js";import{property as i,subclass as o}from"../../../../core/accessorSupport/decorators.js";import{C as s,m as n,d as a}from"../../../../chunks/vec32.js";import{create as l}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import d from"../../../../geometry/Point.js";import{InvalidLayerError as h}from"../../../../layers/support/ElevationQuery.js";import{distanceToScale as p}from"../cameraUtils.js";import{PointOfInterest as c}from"./PointOfInterest.js";import{PropertiesPool as u}from"../../../support/PropertiesPool.js";import{Yield as m}from"../../../support/Yield.js";let _=class extends c{constructor(t){super(t),this._dirty=!1,this._propertiesPool=new u({location:()=>new d,renderLocation:()=>l()},this),this._estimatedSurfaceAltitude=0,this._elevationQueryController=null,this.renderLocation=l(),this._tmpPoint=new d}initialize(){if(this.scheduler&&this.addHandles(this.scheduler.registerTask(this.task,this)),this.runTask(),this.map){const t=()=>this._setDirty();this.addHandles(r(()=>this.map?.ground?.layers,"change",t,{onListenerAdd:t,onListenerRemove:t}))}this._updateRenderLocation()}destroy(){this._cancelPendingRequest(),this._propertiesPool=e(this._propertiesPool)}get _camera(){return this.state.contentCamera}get location(){const t=this._propertiesPool.get("location");return t.spatialReference=this.state.spatialReference,this.renderCoordsHelper.fromRenderCoords(this.renderLocation,t),t}get scale(){const t=this._camera,e=s(t.eye,this.renderLocation),r={renderCoordsHelper:this.renderCoordsHelper,state:{camera:t}};return p(r,e)}get updating(){return this._dirty||null!=this._elevationQueryController}updateRenderLocation(){this._setDirty(),this._updateRenderLocation()}_setDirty(){this._dirty||(this._dirty=!0,this.notifyChange("updating"))}_cancelPendingRequest(){const t=this._elevationQueryController;t&&(this._elevationQueryController=null,t.abort(),this.notifyChange("updating"))}get readyToRun(){return!this._elevationQueryController&&this._dirty}runTask(){if(this._cancelPendingRequest(),this._dirty=!1,this.notifyChange("updating"),!this.map?.ground)return this._updateSurfaceAltitude(0),m;const t=this.state.spatialReference;this._tmpPoint.spatialReference=t,this.renderCoordsHelper.fromRenderCoords(this._camera.eye,this._tmpPoint);const e=(this._tmpPoint.z??0)>f&&1===this.renderCoordsHelper.viewingMode&&(t.isWGS84||t.isWebMercator);let r=new AbortController;return this.map.ground.queryElevation(this._tmpPoint,{signal:r.signal,cache:this.cache,minDemResolution:e?g:0}).then(t=>this._updateSurfaceAltitude(t.geometry.z??0)).catch(t=>{if(t.name===h)if(this.integratedMeshElevationSampler){this._tmpPoint.spatialReference=this.integratedMeshElevationSampler.spatialReference,this.renderCoordsHelper.fromRenderCoords(this._camera.eye,this._tmpPoint);const t=this.integratedMeshElevationSampler.elevationAt(this._tmpPoint.x,this._tmpPoint.y)??0;this._updateSurfaceAltitude(t===this.integratedMeshElevationSampler.noDataValue?0:t)}else this._updateSurfaceAltitude(0)}).catch(()=>{}).then(()=>{this._elevationQueryController===r&&(this._elevationQueryController=null,this.notifyChange("updating")),r=null}),this._elevationQueryController=r,m}_updateSurfaceAltitude(t){this._estimatedSurfaceAltitude!==t&&(this._estimatedSurfaceAltitude=t,this._updateRenderLocation())}_updateRenderLocation(){this.renderCoordsHelper.setAltitude(y,this._estimatedSurfaceAltitude,this._camera.eye),n(this._get("renderLocation"),y)||(this._set("renderLocation",a(this._propertiesPool.get("renderLocation"),y)),this.notifyChange("renderLocation"))}};t([i({constructOnly:!0})],_.prototype,"scheduler",void 0),t([i({constructOnly:!0})],_.prototype,"cache",void 0),t([i({constructOnly:!0})],_.prototype,"map",void 0),t([i({constructOnly:!0})],_.prototype,"task",void 0),t([i({constructOnly:!0})],_.prototype,"integratedMeshElevationSampler",void 0),t([i()],_.prototype,"location",null),t([i()],_.prototype,"renderLocation",void 0),t([i()],_.prototype,"scale",null),t([i()],_.prototype,"updating",null),_=t([o("esri.views.3d.support.pointsOfInterest.CameraOnSurface")],_);const y=l(),f=1e5,g=1e6;export{_ as CameraOnSurface};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as t}from"tslib";import{clamp as e}from"../../../../core/mathUtils.js";import{removeMaybe as r,destroyMaybe as i}from"../../../../core/maybe.js";import{property as s,subclass as o}from"../../../../core/accessorSupport/decorators.js";import{d as a,D as n,j as c,i as u,m as l,F as d}from"../../../../chunks/vec32.js";import{create as p}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as h}from"../../../../geometry/ellipsoidUtils.js";import f from"../../../../geometry/Point.js";import{projectBoundingRect as m}from"../../../../geometry/projection/projectBoundingRect.js";import{create as _}from"../../../../geometry/support/aaBoundingRect.js";import{debugFlags as S}from"../debugFlags.js";import{PointOfInterest as y}from"./PointOfInterest.js";import{PropertiesPool as g}from"../../../support/PropertiesPool.js";import{Yield as A}from"../../../support/Yield.js";let j=class extends y{constructor(t){super(t),this._propertiesPool=new g({location:()=>new f,renderLocation:()=>p()},this),this._currentSurfaceAltitude=0,this._latestSurfaceAltitude=0,this.distance=0,this.renderLocation=p(),this.updating=!1}initialize(){this._frameWorker=this.scheduler.registerTask(this.task,this),this.runTask()}destroy(){this._frameWorker=r(this._frameWorker),this._propertiesPool=i(this._propertiesPool)}get _camera(){return this.state.contentCamera}get location(){const t=this._propertiesPool?.get("location");return t?(t.spatialReference=this.state.spatialReference,this.renderCoordsHelper.fromRenderCoords(this.renderLocation,t),t):new f}updateRenderLocation(){this.updating=!0,this._updateRenderLocation()}get estimatedSurfaceAltitude(){return this._latestSurfaceAltitude}get readyToRun(){return this.updating}runTask(){return this._latestSurfaceAltitude=this.estimateSurfaceAltitudeAtCenter(),this._updateRenderLocation(),this.updating=!1,A}_updateRenderLocation(){const t=L;let e=this._calculateSurfaceIntersection(this._currentSurfaceAltitude,t);const r=this._currentSurfaceAltitude!==this._latestSurfaceAltitude;!e&&r&&(e=this._calculateSurfaceIntersection(this._latestSurfaceAltitude,t),e&&(this._currentSurfaceAltitude=this._latestSurfaceAltitude));const i=v;e&&this._latestSurfaceAltitudeChangesDistanceSignificantly(t,i)&&(a(t,i),this._currentSurfaceAltitude=this._latestSurfaceAltitude),e?this.distance=n(this._camera.eye,t):(c(t,this._camera.viewForward,this._get("distance")),u(t,t,this._camera.eye)),l(this._get("renderLocation"),t)||this._set("renderLocation",a(this._propertiesPool.get("renderLocation"),t))}_calculateSurfaceIntersection(t,r){const i=this._camera;if(!this.renderCoordsHelper.intersectInfiniteManifold(i.ray,t,r))return!1;if(this.state.isGlobal){const e=h(this.renderCoordsHelper.spatialReference).radius,s=e+t,o=d(i.eye),a=o<s*s,l=n(i.eye,r);if(a&&l>e/4){const t=s-Math.sqrt(o);return c(r,i.viewForward,t),u(r,r,i.eye),!0}}else{const t=this.surface?.ready?this.surface.groundExtent:null;null!=t&&m(t,this.surface?.spatialReference,C,this.renderCoordsHelper.spatialReference)&&(r[0]=e(r[0],C[0],C[2]),r[1]=e(r[1],C[1],C[3]))}return!0}_latestSurfaceAltitudeChangesDistanceSignificantly(t,e){if(this._latestSurfaceAltitude===this._currentSurfaceAltitude||null==t)return!1;if(this._calculateSurfaceIntersection(this._latestSurfaceAltitude,e)){if(S.TESTS_DISABLE_OPTIMIZATIONS)return!0;const r=this._camera.eye,i=n(r,t),s=n(r,e);if(Math.abs(s-i)/i>R)return!0}return!1}};t([s({constructOnly:!0})],j.prototype,"scheduler",void 0),t([s({constructOnly:!0})],j.prototype,"task",void 0),t([s()],j.prototype,"distance",void 0),t([s({constructOnly:!0})],j.prototype,"estimateSurfaceAltitudeAtCenter",void 0),t([s({readOnly:!0})],j.prototype,"location",null),t([s({readOnly:!0})],j.prototype,"renderLocation",void 0),t([s()],j.prototype,"updating",void 0),j=t([o("esri.views.3d.support.pointsOfInterest.CenterOnSurface")],j);const R=.05,L=p(),v=p(),C=_();export{j as CenterOnSurface};
5
+ import{__decorate as t}from"tslib";import{clamp as e}from"../../../../core/mathUtils.js";import{removeMaybe as r,destroyMaybe as i}from"../../../../core/maybe.js";import{property as s,subclass as o}from"../../../../core/accessorSupport/decorators.js";import{d as a,C as n,j as c,i as u,m as l,E as d}from"../../../../chunks/vec32.js";import{create as p}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as h}from"../../../../geometry/ellipsoidUtils.js";import f from"../../../../geometry/Point.js";import{projectBoundingRect as m}from"../../../../geometry/projection/projectBoundingRect.js";import{create as _}from"../../../../geometry/support/aaBoundingRect.js";import{debugFlags as S}from"../debugFlags.js";import{PointOfInterest as y}from"./PointOfInterest.js";import{PropertiesPool as g}from"../../../support/PropertiesPool.js";import{Yield as A}from"../../../support/Yield.js";let j=class extends y{constructor(t){super(t),this._propertiesPool=new g({location:()=>new f,renderLocation:()=>p()},this),this._currentSurfaceAltitude=0,this._latestSurfaceAltitude=0,this.distance=0,this.renderLocation=p(),this.updating=!1}initialize(){this._frameWorker=this.scheduler.registerTask(this.task,this),this.runTask()}destroy(){this._frameWorker=r(this._frameWorker),this._propertiesPool=i(this._propertiesPool)}get _camera(){return this.state.contentCamera}get location(){const t=this._propertiesPool?.get("location");return t?(t.spatialReference=this.state.spatialReference,this.renderCoordsHelper.fromRenderCoords(this.renderLocation,t),t):new f}updateRenderLocation(){this.updating=!0,this._updateRenderLocation()}get estimatedSurfaceAltitude(){return this._latestSurfaceAltitude}get readyToRun(){return this.updating}runTask(){return this._latestSurfaceAltitude=this.estimateSurfaceAltitudeAtCenter(),this._updateRenderLocation(),this.updating=!1,A}_updateRenderLocation(){const t=C;let e=this._calculateSurfaceIntersection(this._currentSurfaceAltitude,t);const r=this._currentSurfaceAltitude!==this._latestSurfaceAltitude;!e&&r&&(e=this._calculateSurfaceIntersection(this._latestSurfaceAltitude,t),e&&(this._currentSurfaceAltitude=this._latestSurfaceAltitude));const i=L;e&&this._latestSurfaceAltitudeChangesDistanceSignificantly(t,i)&&(a(t,i),this._currentSurfaceAltitude=this._latestSurfaceAltitude),e?this.distance=n(this._camera.eye,t):(c(t,this._camera.viewForward,this._get("distance")),u(t,t,this._camera.eye)),l(this._get("renderLocation"),t)||this._set("renderLocation",a(this._propertiesPool.get("renderLocation"),t))}_calculateSurfaceIntersection(t,r){const i=this._camera;if(!this.renderCoordsHelper.intersectInfiniteManifold(i.ray,t,r))return!1;if(this.state.isGlobal){const e=h(this.renderCoordsHelper.spatialReference).radius,s=e+t,o=d(i.eye),a=o<s*s,l=n(i.eye,r);if(a&&l>e/4){const t=s-Math.sqrt(o);return c(r,i.viewForward,t),u(r,r,i.eye),!0}}else{const t=this.surface?.ready?this.surface.groundExtent:null;null!=t&&m(t,this.surface?.spatialReference,v,this.renderCoordsHelper.spatialReference)&&(r[0]=e(r[0],v[0],v[2]),r[1]=e(r[1],v[1],v[3]))}return!0}_latestSurfaceAltitudeChangesDistanceSignificantly(t,e){if(this._latestSurfaceAltitude===this._currentSurfaceAltitude||null==t)return!1;if(this._calculateSurfaceIntersection(this._latestSurfaceAltitude,e)){if(S.TESTS_DISABLE_OPTIMIZATIONS)return!0;const r=this._camera.eye,i=n(r,t),s=n(r,e);if(Math.abs(s-i)/i>R)return!0}return!1}};t([s({constructOnly:!0})],j.prototype,"scheduler",void 0),t([s({constructOnly:!0})],j.prototype,"task",void 0),t([s()],j.prototype,"distance",void 0),t([s({constructOnly:!0})],j.prototype,"estimateSurfaceAltitudeAtCenter",void 0),t([s({readOnly:!0})],j.prototype,"location",null),t([s({readOnly:!0})],j.prototype,"renderLocation",void 0),t([s()],j.prototype,"updating",void 0),j=t([o("esri.views.3d.support.pointsOfInterest.CenterOnSurface")],j);const R=.05,C=p(),L=p(),v=_();export{j as CenterOnSurface};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import{clamp as t}from"../../../../core/mathUtils.js";import{destroyMaybe as r}from"../../../../core/maybe.js";import{watch as o}from"../../../../core/reactiveUtils.js";import{createRenderScreenPointArray3 as i}from"../../../../core/screenUtils.js";import{property as n,subclass as s}from"../../../../core/accessorSupport/decorators.js";import{m as a,g as c,G as d,d as p,l,e as u,n as h}from"../../../../chunks/vec32.js";import{create as m}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import f from"../../../../geometry/Point.js";import{wrap as y}from"../../../../geometry/support/ray.js";import{PointOfInterest as g}from"./PointOfInterest.js";import{PropertiesPool as P}from"../../../support/PropertiesPool.js";import{TaskPriority as _}from"../../../support/Scheduler.js";import{Yield as L}from"../../../support/Yield.js";let R=class extends g{constructor(e){super(e),this._propertiesPool=new P({location:()=>new f,renderLocation:()=>m()},this),this._dirty=!0,this.renderLocation=this._propertiesPool.get("renderLocation")}initialize(){this.addHandles([o(()=>this.centerOnSurface.renderLocation,()=>this.updateRenderLocation(),{equals:a}),o(()=>this.state.contentCamera,()=>this.updateRenderLocation())]),this.scheduler&&this.addHandles(this.scheduler.registerTask(_.POINT_OF_INTEREST_FREQUENT,this))}destroy(){this._propertiesPool=r(this._propertiesPool)}get updating(){return this._dirty||this.centerOnSurface.updating}get location(){const e=this._propertiesPool.get("location");return e.spatialReference=this.state.spatialReference,this.renderCoordsHelper.fromRenderCoords(this.renderLocation,e),e}get worldUnitsPerContentPixel(){const{camera:e,contentPixelRatio:t}=this.state;return e.computeRenderPixelSizeAt(this.renderLocation)*(e.pixelRatio/t)}get readyToRun(){return this._dirty}runTask(){const e=this._get("renderLocation"),r=this.centerOnSurface.renderLocation,o=this.renderCoordsHelper,i=this.state.contentCamera;this._dirty=!1,o.worldUpAtPosition(r,S);const n=Math.max(0,(Math.acos(c(S,i.viewForward))-.5*Math.PI)*(i.aboveGround?1:-1));if(Number.isNaN(n)){if(!e||!d(e,r)){const e=this._propertiesPool.get("renderLocation");p(e,r),this._set("renderLocation",e)}return L}const s=1-t(n/(.5*Math.PI),0,1),a=s*s*s;this._calculateScreenHorizontalEdgeOnSurface(O);const u=this._propertiesPool.get("renderLocation");return l(u,r,O,a),e&&d(e,u)||this._set("renderLocation",u),L}_calculateScreenHorizontalEdgeOnSurface(e){const t=this.state.contentCamera,r=t.getRenderCenter(i());if(r[1]=t.aboveGround?t.padding[2]:t.fullHeight-t.padding[0],this.estimateSurfaceIntersectionAtRenderPoint(r,e))return e;const o=this.renderCoordsHelper.getAltitude(this.centerOnSurface.renderLocation);if(t.unprojectFromRenderScreen(r,j)){u(j,j,t.eye);const r=h(j,j);if(this.renderCoordsHelper.intersectInfiniteManifold(y(t.eye,r),o,e))return e}return this.renderCoordsHelper.setAltitude(e,o,t.eye)}updateRenderLocation(){this._dirty=!0}};e([n()],R.prototype,"_dirty",void 0),e([n({constructOnly:!0})],R.prototype,"scheduler",void 0),e([n({constructOnly:!0})],R.prototype,"centerOnSurface",void 0),e([n({constructOnly:!0})],R.prototype,"estimateSurfaceIntersectionAtRenderPoint",void 0),e([n()],R.prototype,"updating",null),e([n()],R.prototype,"location",null),e([n()],R.prototype,"renderLocation",void 0),e([n()],R.prototype,"worldUnitsPerContentPixel",null),R=e([s("esri.views.3d.support.pointsOfInterest.Focus")],R);const S=m(),j=m(),O=m();export{R as Focus};
5
+ import{__decorate as e}from"tslib";import{clamp as t}from"../../../../core/mathUtils.js";import{destroyMaybe as r}from"../../../../core/maybe.js";import{watch as o}from"../../../../core/reactiveUtils.js";import{createRenderScreenPointArray3 as i}from"../../../../core/screenUtils.js";import{property as n,subclass as s}from"../../../../core/accessorSupport/decorators.js";import{m as a,g as c,F as d,d as p,l,e as u,n as h}from"../../../../chunks/vec32.js";import{create as m}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import f from"../../../../geometry/Point.js";import{wrap as y}from"../../../../geometry/support/ray.js";import{PointOfInterest as g}from"./PointOfInterest.js";import{PropertiesPool as P}from"../../../support/PropertiesPool.js";import{TaskPriority as _}from"../../../support/Scheduler.js";import{Yield as L}from"../../../support/Yield.js";let R=class extends g{constructor(e){super(e),this._propertiesPool=new P({location:()=>new f,renderLocation:()=>m()},this),this._dirty=!0,this.renderLocation=this._propertiesPool.get("renderLocation")}initialize(){this.addHandles([o(()=>this.centerOnSurface.renderLocation,()=>this.updateRenderLocation(),{equals:a}),o(()=>this.state.contentCamera,()=>this.updateRenderLocation())]),this.scheduler&&this.addHandles(this.scheduler.registerTask(_.POINT_OF_INTEREST_FREQUENT,this))}destroy(){this._propertiesPool=r(this._propertiesPool)}get updating(){return this._dirty||this.centerOnSurface.updating}get location(){const e=this._propertiesPool.get("location");return e.spatialReference=this.state.spatialReference,this.renderCoordsHelper.fromRenderCoords(this.renderLocation,e),e}get worldUnitsPerContentPixel(){const{camera:e,contentPixelRatio:t}=this.state;return e.computeRenderPixelSizeAt(this.renderLocation)*(e.pixelRatio/t)}get readyToRun(){return this._dirty}runTask(){const e=this._get("renderLocation"),r=this.centerOnSurface.renderLocation,o=this.renderCoordsHelper,i=this.state.contentCamera;this._dirty=!1,o.worldUpAtPosition(r,S);const n=Math.max(0,(Math.acos(c(S,i.viewForward))-.5*Math.PI)*(i.aboveGround?1:-1));if(Number.isNaN(n)){if(!e||!d(e,r)){const e=this._propertiesPool.get("renderLocation");p(e,r),this._set("renderLocation",e)}return L}const s=1-t(n/(.5*Math.PI),0,1),a=s*s*s;this._calculateScreenHorizontalEdgeOnSurface(O);const u=this._propertiesPool.get("renderLocation");return l(u,r,O,a),e&&d(e,u)||this._set("renderLocation",u),L}_calculateScreenHorizontalEdgeOnSurface(e){const t=this.state.contentCamera,r=t.getRenderCenter(i());if(r[1]=t.aboveGround?t.padding[2]:t.fullHeight-t.padding[0],this.estimateSurfaceIntersectionAtRenderPoint(r,e))return e;const o=this.renderCoordsHelper.getAltitude(this.centerOnSurface.renderLocation);if(t.unprojectFromRenderScreen(r,j)){u(j,j,t.eye);const r=h(j,j);if(this.renderCoordsHelper.intersectInfiniteManifold(y(t.eye,r),o,e))return e}return this.renderCoordsHelper.setAltitude(e,o,t.eye)}updateRenderLocation(){this._dirty=!0}};e([n()],R.prototype,"_dirty",void 0),e([n({constructOnly:!0})],R.prototype,"scheduler",void 0),e([n({constructOnly:!0})],R.prototype,"centerOnSurface",void 0),e([n({constructOnly:!0})],R.prototype,"estimateSurfaceIntersectionAtRenderPoint",void 0),e([n()],R.prototype,"updating",null),e([n()],R.prototype,"location",null),e([n()],R.prototype,"renderLocation",void 0),e([n()],R.prototype,"worldUnitsPerContentPixel",null),R=e([s("esri.views.3d.support.pointsOfInterest.Focus")],R);const S=m(),j=m(),O=m();export{R as Focus};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import t from"../../../Camera.js";import e from"../../../Graphic.js";import n from"../../../Viewpoint.js";import{result as r}from"../../../core/asyncUtils.js";import"../../../core/has.js";import{cyclicalDegrees as a}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,i as f,D as p,d as g,e as y,h,t as d}from"../../../chunks/vec32.js";import{create as w}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import x from"../../../geometry/Extent.js";import j from"../../../geometry/Geometry.js";import v from"../../../geometry/Multipoint.js";import b from"../../../geometry/Point.js";import{projectWithZConversion as R,tryProjectWithZConversion as z}from"../../../geometry/projectionUtils.js";import G from"../../../geometry/SpatialReference.js";import{computeTranslationToOriginAndRotation as B}from"../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{projectPointToVectorAsync as M}from"../../../geometry/projection/projectPointToVector.js";import{projectVectorToPoint as S}from"../../../geometry/projection/projectVectorToPoint.js";import{projectVectorToVector as Z}from"../../../geometry/projection/projectVectorToVector.js";import{create as F,center as T,toRect as P,isPoint as A,empty as E,expandWithVec3 as V,expandWithAABB as k,width as O,height as U,depth as N}from"../../../geometry/support/aaBoundingBox.js";import{create as I,isPoint as C}from"../../../geometry/support/aaBoundingRect.js";import{polygonCentroidPoint as D}from"../../../geometry/support/centroid.js";import{intersectsPoint as W}from"../../../geometry/support/frustum.js";import{getResolutionInMetersForScale as Y}from"../../../geometry/support/scaleUtils.js";import{fromRenderCamera as q,toRenderCamera as J}from"../webgl.js";import{cameraOnContentAlongViewDirection as X}from"../camera/intersectionUtils.js";import{getViewSR as _,fromExtentAsync as H,scaleToDistance as K,fromCenterDistanceAsync as L,fromExtentSync as Q,distanceToScale as $,fromCenterDistanceSync as tt,fromCenterScale as et,zoomToScale as nt}from"./cameraUtils.js";import{getElevationAtPoint as rt}from"./ElevationProvider.js";import{directionToHeadingTilt as at}from"./viewingModeUtils.js";const ot=.66;function it(t){return 360-a.normalize(t)}function st(t){return a.normalize(360-t)}function ct(t,e,n){const r=e.camera;if(null!=r)return mt(r,_(t));const{targetGeometry:a}=e;if(null==a)return null;const{camera:o,mode:i}=ft(t,e.rotation,n);if("point"===a.type)return pt(t,e,a,o,i);const s=a.extent;return null==s?null:Q(t,s,o.heading,o.tilt,i)}async function lt(t,e,n,r){const a=e.camera;if(null!=a)return ut(a,_(t),r);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,r);const c=o.extent;if(null==c)throw new Error("Target geometry has no extent!");return H(t,c,i.heading,i.tilt,s,r)}function mt(t,e){const n=t.position;let r;try{r=z(n,e)}catch(o){return null}if(!r)return null;const a=t.clone();return a.position=r.clone(),a}async function ut(t,e,n){const r=t.position,a=await R(r,e,{signal:n});i(n);const o=t.clone();return o.position=a.clone(),o}function ft(t,e,n){const r=q(t,t.state.camera);let a=1;return null!=e&&(r.heading=it(e),a=0),null!=n&&(r.tilt=n),{camera:r,mode:a}}function pt(t,e,n,r,a){const o=t.spatialReference;let i;try{i=z(n.clone(),o)}catch(c){return null}if(!i)return null;const s=null!=e.scale?K(t,e.scale):t.state.camera.distance;return tt(t,i,s,r,a)}async function gt(t,e,n,r,a,o){const s=t.spatialReference,c=await R(n.clone(),s,{signal:o});i(o);const l=null!=e.scale?K(t,e.scale):t.state.camera.distance;return L(t,c,l,r,a,o)}function yt(t,e,r=null){return null==r&&(r=new n),jt(t,null,e.clone(),r)}async function ht(e,r,a){const i=At(e,r);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 Et(await zt(e,i.target,i,a,c))}if(i.target instanceof t)return Et(await Gt(e,i.target,a,c));const l=null!=i.scale||null!=i.zoom;if(i.target instanceof x){const t=i.target.xmin===i.target.xmax||i.target.ymin===i.target.ymax;return Et(l||t?await Mt(e,i,i.target.center,s,a,c):await Ft(e,i,i.target,s,a,c))}const m=new kt,u=l?wt(e,i):void 0;if(await Rt(e,i.target,u,m,a),isFinite(m.boundingBox[0])){let t;if(T(m.boundingBox,Ot),Jt.x=Ot[0],Jt.y=Ot[1],Jt.z=Ot[2],Jt.spatialReference=e.spatialReference,isFinite(Jt.z)&&m.hasZ?t=A(m.boundingBox):(Jt.z=void 0,t=C(P(m.boundingBox,Ct))),l||t)return Et(await Mt(e,i,Jt,s,a,c));const n=Vt(e,m.screenSpaceObjects);return Et(await Pt(e,i,Jt,m.boundingBox,n,s,a,c))}return i.position?Et(await St(e,i,s,c,a)):Et(await Zt(e,i,s,a,c))}function dt(t,e){return null==e.scale&&null!=e.zoom?nt(t,e.zoom):e.scale}function wt(t,e){const n=dt(t,e);return n?Y(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,r){const a=t.spatialReference||G.WGS84;if(e??=J(t,n),null==e)return r;const o=new b({spatialReference:a});return S(e.center,t.renderSpatialReference,o)?(r.targetGeometry=o,r.scale=$(t,e.distance),r.rotation=st(n.heading),r.camera=n,r):r}async function vt(t,e,n,r){const a=()=>new o("viewpointutils:invalid-geometry","The target is missing a valid geometry");if(!e)throw a();"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":{const t=D(e);n=t?b.fromJSON(t):null;break}}null!=n&&i&&t.elevationProvider?(n=await R(n,i,{signal:r}),Ot[2]=rt(t.elevationProvider,n)??0):Ot[2]=0}const s=Xt[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]])},Ot),0===c.length)throw a();const l=e.spatialReference,m=t.spatialReference,u=await R(new v({spatialReference:l,hasZ:e.hasZ,hasM:!1,points:c}),m,{signal:r});if(e.hasZ&&(n.hasZ=!0),e.hasZ)for(const[o,f,p]of u.points)Ot[0]=o,Ot[1]=f,Ot[2]=p,V(n.boundingBox,Ot);else for(const[o,f]of u.points)Ot[0]=o,Ot[1]=f,V(n.boundingBox,Ot)}async function bt(t,e,n,a,o){const i=await r(t.whenViewForGraphic(e));if(!1===i.ok||null==i.value||!("whenGraphicBounds"in i.value))return void await vt(t,e.geometry,a,o);const s=i.value,c=await r(s.whenGraphicBounds(e,{minDemResolution:n}));if(!1===c.ok||!c.value)return void await vt(t,e.geometry,a,o);const{screenSpaceObjects:l,boundingBox:m}=c.value;k(a.boundingBox,m),l&&l.forEach(t=>{a.screenSpaceObjects.push(t)}),isFinite(m[2])&&(a.hasZ=!0)}async function Rt(t,n,r,a,o){if(Array.isArray(n)&&2===n.length){const e=n[0],r=n[1];if("number"==typeof e&&"number"==typeof r)return Jt.x=e,Jt.y=r,Jt.z=void 0,Jt.spatialReference=t.spatialReference?.isGeographic?t.spatialReference:G.WGS84,void await vt(t,Jt,a,o)}n&&"map"in n&&"function"==typeof n.map?await Promise.allSettled(n.map(e=>Rt(t,e,r,a,o))):n instanceof j?await vt(t,n,a,o):n instanceof e&&await bt(t,n,r,a,o)}async function zt(t,e,n,r,a){if(e.camera)return Gt(t,e.camera,r,a);a.scale=e.scale,a.rotation=e.rotation,a.targetGeometry=null!=e.targetGeometry?e.targetGeometry.clone():null,a.camera=null,null!=n.heading?a.rotation=st(n.heading):null!=n.rotation&&(a.rotation=n.rotation);const o=dt(t,n);return null!=o&&(a.scale=o),a.camera=await lt(t,a,n.tilt,r),a}async function Gt(t,e,n,r){const a=t.spatialReference,o=await R(e.position,a,{signal:n}),i=e.clone();return i.position=o,jt(t,null,i,r)}async function Bt(t,e,n,r,a,o,i){const s=t.renderSpatialReference;return await M(e,Yt,s,{signal:i}),await M(n,Wt,s,{signal:i}),o.targetGeometry=new b(e),a.position=new b(n),y(Dt,Yt,Wt),at(t,Wt,Dt,r.up,a),o.scale=$(t,p(Wt,Yt)),o.rotation=st(a.heading),o.camera=a,o}async function Mt(t,e,n,r,a,o){o.targetGeometry=n.clone();const i=X(t);if(e.position)return Bt(t,o.targetGeometry,e.position,i,r,o,a);if(e.zoomFactor){const n=i.distance/e.zoomFactor,r=u(Ot,i.viewForward,-n);i.eye=f(Ot,i.center,r),o.scale=$(t,n)}q(t,i,r);const s=xt(r,e)?0:1;if(!e.zoomFactor){const n=dt(t,e);if(null==n){await M(o.targetGeometry,Ot,t.renderSpatialReference,{signal:a});const e=W(i.frustum,Ot)?p(i.eye,Ot):i.distance;o.camera=await L(t,o.targetGeometry,e,r,s),o.scale=$(t,e)}else o.scale=n,o.camera=await et(t,o.targetGeometry,o.scale,r,s,a)}return o}async function St(t,e,n,r,a){const o=X(t);g(Dt,o.viewForward),at(t,o.eye,Dt,o.up,qt);const i=t.spatialReference,{position:s}=e;if(s){const t=await R(s,i,{signal:a});n.position=t}else n.position=new b;return n.heading=null!=e.heading?e.heading:qt.heading,n.tilt=null!=e.tilt?e.tilt:qt.tilt,jt(t,null,n,r)}async function Zt(t,e,n,r,a){if(null!=e.heading||null!=e.rotation||null!=e.scale||null!=e.tilt||null!=e.zoom||null!=e.zoomFactor){const o=X(t),{spatialReference:i,renderSpatialReference:s}=t,c=new b({spatialReference:i});return S(o.center,s,c)?Mt(t,e,c,n,r,a):a}return a.scale=t.scale,a.camera=t.camera.clone(),xt(a.camera,e),a}async function Ft(t,e,n,r,a,o){o.targetGeometry=n.clone();const i=X(t);q(t,i,r);const s=xt(r,e)?0:1;return o.camera=await H(t,n,r.heading,r.tilt,s,a),o}function Tt(t,e,n,r,a){let o=0;null!=n.z?o=n.z:t.basemapTerrain&&t.elevationProvider&&(o=rt(t.elevationProvider,n)),h(Ot,n.x,n.y,o),B(t.spatialReference,Ot,Ut,t.renderSpatialReference),s(Nt,Ut),c(Nt,Nt),E(It);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=r[e[2]];isFinite(n)||(n=o),h(Ot,r[e[0]],r[e[1]],n),Z(Ot,t.spatialReference,Ot,t.renderSpatialReference),V(It,d(Ot,Ot,Nt))}const l=O(It),m=U(It),u=N(It),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)/a}async function Pt(t,e,n,r,a,o,i,s){s.targetGeometry=n.clone();const c=X(t),l=Tt(t,c,n,r,a);q(t,c,o);const m=xt(o,e)?0:1;return s.camera=await L(t,s.targetGeometry,l,o,m,i),s.scale=$(t,l),s}function At(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 Et(t){return null!=t?.camera&&(t.rotation=st(t.camera.heading)),t}function Vt(t,e){const n=ot;if(!e.length)return n;let r=Number.NEGATIVE_INFINITY;for(let a=0;a<e.length;a++){const t=e[a].screenSpaceBoundingRect;r=Math.max(r,Math.abs(t[0]),Math.abs(t[1]),Math.abs(t[2]),Math.abs(t[3]))}return n-r/Math.min(t.width,t.height)*2}class kt{constructor(){this.hasZ=!1,this.boundingBox=E(),this.screenSpaceObjects=new Array}}const Ot=w(),Ut=m(),Nt=l(),It=F(),Ct=I(),Dt=w(),Wt=w(),Yt=w(),qt={heading:0,tilt:0},Jt=new b,Xt={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 r=t.hasZ;for(let a=0;a<t.rings.length;a++){const o=t.rings[a];for(let t=0;t<o.length;t++)n[0]=o[t][0],n[1]=o[t][1],r&&(n[2]=o[t][2]),e(n)}},polyline(t,e,n){const r=t.hasZ;for(let a=0;a<t.paths.length;a++){const o=t.paths[a];for(let t=0;t<o.length;t++)n[0]=o[t][0],n[1]=o[t][1],r&&(n[2]=o[t][2]),e(n)}},multipoint(t,e,n){const r=t.points,a=t.hasZ;for(let o=0;o<r.length;o++)n[0]=r[o][0],n[1]=r[o][1],a&&(n[2]=r[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 e from"../../../Graphic.js";import n from"../../../Viewpoint.js";import{result as r}from"../../../core/asyncUtils.js";import"../../../core/has.js";import{cyclicalDegrees as a}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,i as f,C as p,d as g,e as y,h,t as d}from"../../../chunks/vec32.js";import{create as w}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import x from"../../../geometry/Extent.js";import j from"../../../geometry/Geometry.js";import v from"../../../geometry/Multipoint.js";import b from"../../../geometry/Point.js";import{projectWithZConversion as R,tryProjectWithZConversion as z}from"../../../geometry/projectionUtils.js";import G from"../../../geometry/SpatialReference.js";import{computeTranslationToOriginAndRotation as B}from"../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{projectPointToVectorAsync as M}from"../../../geometry/projection/projectPointToVector.js";import{projectVectorToPoint as S}from"../../../geometry/projection/projectVectorToPoint.js";import{projectVectorToVector as Z}from"../../../geometry/projection/projectVectorToVector.js";import{create as F,center as T,toRect as P,isPoint as A,empty as E,expandWithVec3 as V,expandWithAABB as k,width as O,height as U,depth as N}from"../../../geometry/support/aaBoundingBox.js";import{create as C,isPoint as I}from"../../../geometry/support/aaBoundingRect.js";import{polygonCentroidPoint as W}from"../../../geometry/support/centroid.js";import{intersectsPoint as Y}from"../../../geometry/support/frustum.js";import{getResolutionInMetersForScale as q}from"../../../geometry/support/scaleUtils.js";import{fromRenderCamera as D,toRenderCamera as J}from"../webgl.js";import{cameraOnContentAlongViewDirection as X}from"../camera/intersectionUtils.js";import{getViewSR as _,fromExtentAsync as H,scaleToDistance as K,fromCenterDistanceAsync as L,fromExtentSync as Q,distanceToScale as $,fromCenterDistanceSync as tt,fromCenterScale as et,zoomToScale as nt}from"./cameraUtils.js";import{getElevationAtPoint as rt}from"./ElevationProvider.js";import{directionToHeadingTilt as at}from"./viewingModeUtils.js";const ot=.66;function it(t){return 360-a.normalize(t)}function st(t){return a.normalize(360-t)}function ct(t,e,n){const r=e.camera;if(null!=r)return mt(r,_(t));const{targetGeometry:a}=e;if(null==a)return null;const{camera:o,mode:i}=ft(t,e.rotation,n);if("point"===a.type)return pt(t,e,a,o,i);const s=a.extent;return null==s?null:Q(t,s,o.heading,o.tilt,i)}async function lt(t,e,n,r){const a=e.camera;if(null!=a)return ut(a,_(t),r);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,r);const c=o.extent;if(null==c)throw new Error("Target geometry has no extent!");return H(t,c,i.heading,i.tilt,s,r)}function mt(t,e){const n=t.position;let r;try{r=z(n,e)}catch(o){return null}if(!r)return null;const a=t.clone();return a.position=r.clone(),a}async function ut(t,e,n){const r=t.position,a=await R(r,e,{signal:n});i(n);const o=t.clone();return o.position=a.clone(),o}function ft(t,e,n){const r=D(t,t.state.camera);let a=1;return null!=e&&(r.heading=it(e),a=0),null!=n&&(r.tilt=n),{camera:r,mode:a}}function pt(t,e,n,r,a){const o=t.spatialReference;let i;try{i=z(n.clone(),o)}catch(c){return null}if(!i)return null;const s=null!=e.scale?K(t,e.scale):t.state.camera.distance;return tt(t,i,s,r,a)}async function gt(t,e,n,r,a,o){const s=t.spatialReference,c=await R(n.clone(),s,{signal:o});i(o);const l=null!=e.scale?K(t,e.scale):t.state.camera.distance;return L(t,c,l,r,a,o)}function yt(t,e,r=null){return null==r&&(r=new n),jt(t,null,e.clone(),r)}async function ht(e,r,a){const i=At(e,r);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 Et(await zt(e,i.target,i,a,c))}if(i.target instanceof t)return Et(await Gt(e,i.target,a,c));const l=null!=i.scale||null!=i.zoom;if(i.target instanceof x){const t=i.target.xmin===i.target.xmax||i.target.ymin===i.target.ymax;return Et(l||t?await Mt(e,i,i.target.center,s,a,c):await Ft(e,i,i.target,s,a,c))}const m=new kt,u=l?wt(e,i):void 0;if(await Rt(e,i.target,u,m,a),isFinite(m.boundingBox[0])){let t;if(T(m.boundingBox,Ot),Jt.x=Ot[0],Jt.y=Ot[1],Jt.z=Ot[2],Jt.spatialReference=e.spatialReference,isFinite(Jt.z)&&m.hasZ?t=A(m.boundingBox):(Jt.z=void 0,t=I(P(m.boundingBox,It))),l||t)return Et(await Mt(e,i,Jt,s,a,c));const n=Vt(e,m.screenSpaceObjects);return Et(await Pt(e,i,Jt,m.boundingBox,n,s,a,c))}return i.position?Et(await St(e,i,s,c,a)):Et(await Zt(e,i,s,a,c))}function dt(t,e){return null==e.scale&&null!=e.zoom?nt(t,e.zoom):e.scale}function wt(t,e){const n=dt(t,e);return n?q(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,r){const a=t.spatialReference||G.WGS84;if(e??=J(t,n),null==e)return r;const o=new b({spatialReference:a});return S(e.center,t.renderSpatialReference,o)?(r.targetGeometry=o,r.scale=$(t,e.distance),r.rotation=st(n.heading),r.camera=n,r):r}async function vt(t,e,n,r){const a=()=>new o("viewpointutils:invalid-geometry","The target is missing a valid geometry");if(!e)throw a();"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":{const t=W(e);n=t?b.fromJSON(t):null;break}}null!=n&&i&&t.elevationProvider?(n=await R(n,i,{signal:r}),Ot[2]=rt(t.elevationProvider,n)??0):Ot[2]=0}const s=Xt[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]])},Ot),0===c.length)throw a();const l=e.spatialReference,m=t.spatialReference,u=await R(new v({spatialReference:l,hasZ:e.hasZ,hasM:!1,points:c}),m,{signal:r});if(e.hasZ&&(n.hasZ=!0),e.hasZ)for(const[o,f,p]of u.points)Ot[0]=o,Ot[1]=f,Ot[2]=p,V(n.boundingBox,Ot);else for(const[o,f]of u.points)Ot[0]=o,Ot[1]=f,V(n.boundingBox,Ot)}async function bt(t,e,n,a,o){const i=await r(t.whenViewForGraphic(e));if(!1===i.ok||null==i.value||!("whenGraphicBounds"in i.value))return void await vt(t,e.geometry,a,o);const s=i.value,c=await r(s.whenGraphicBounds(e,{minDemResolution:n}));if(!1===c.ok||!c.value)return void await vt(t,e.geometry,a,o);const{screenSpaceObjects:l,boundingBox:m}=c.value;k(a.boundingBox,m),l&&l.forEach(t=>{a.screenSpaceObjects.push(t)}),isFinite(m[2])&&(a.hasZ=!0)}async function Rt(t,n,r,a,o){if(Array.isArray(n)&&2===n.length){const e=n[0],r=n[1];if("number"==typeof e&&"number"==typeof r)return Jt.x=e,Jt.y=r,Jt.z=void 0,Jt.spatialReference=t.spatialReference?.isGeographic?t.spatialReference:G.WGS84,void await vt(t,Jt,a,o)}n&&"map"in n&&"function"==typeof n.map?await Promise.allSettled(n.map(e=>Rt(t,e,r,a,o))):n instanceof j?await vt(t,n,a,o):n instanceof e&&await bt(t,n,r,a,o)}async function zt(t,e,n,r,a){if(e.camera)return Gt(t,e.camera,r,a);a.scale=e.scale,a.rotation=e.rotation,a.targetGeometry=null!=e.targetGeometry?e.targetGeometry.clone():null,a.camera=null,null!=n.heading?a.rotation=st(n.heading):null!=n.rotation&&(a.rotation=n.rotation);const o=dt(t,n);return null!=o&&(a.scale=o),a.camera=await lt(t,a,n.tilt,r),a}async function Gt(t,e,n,r){const a=t.spatialReference,o=await R(e.position,a,{signal:n}),i=e.clone();return i.position=o,jt(t,null,i,r)}async function Bt(t,e,n,r,a,o,i){const s=t.renderSpatialReference;return await M(e,qt,s,{signal:i}),await M(n,Yt,s,{signal:i}),o.targetGeometry=new b(e),a.position=new b(n),y(Wt,qt,Yt),at(t,Yt,Wt,r.up,a),o.scale=$(t,p(Yt,qt)),o.rotation=st(a.heading),o.camera=a,o}async function Mt(t,e,n,r,a,o){o.targetGeometry=n.clone();const i=X(t);if(e.position)return Bt(t,o.targetGeometry,e.position,i,r,o,a);if(e.zoomFactor){const n=i.distance/e.zoomFactor,r=u(Ot,i.viewForward,-n);i.eye=f(Ot,i.center,r),o.scale=$(t,n)}D(t,i,r);const s=xt(r,e)?0:1;if(!e.zoomFactor){const n=dt(t,e);if(null==n){await M(o.targetGeometry,Ot,t.renderSpatialReference,{signal:a});const e=Y(i.frustum,Ot)?p(i.eye,Ot):i.distance;o.camera=await L(t,o.targetGeometry,e,r,s),o.scale=$(t,e)}else o.scale=n,o.camera=await et(t,o.targetGeometry,o.scale,r,s,a)}return o}async function St(t,e,n,r,a){const o=X(t);g(Wt,o.viewForward),at(t,o.eye,Wt,o.up,Dt);const i=t.spatialReference,{position:s}=e;if(s){const t=await R(s,i,{signal:a});n.position=t}else n.position=new b;return n.heading=null!=e.heading?e.heading:Dt.heading,n.tilt=null!=e.tilt?e.tilt:Dt.tilt,jt(t,null,n,r)}async function Zt(t,e,n,r,a){if(null!=e.heading||null!=e.rotation||null!=e.scale||null!=e.tilt||null!=e.zoom||null!=e.zoomFactor){const o=X(t),{spatialReference:i,renderSpatialReference:s}=t,c=new b({spatialReference:i});return S(o.center,s,c)?Mt(t,e,c,n,r,a):a}return a.scale=t.scale,a.camera=t.camera.clone(),xt(a.camera,e),a}async function Ft(t,e,n,r,a,o){o.targetGeometry=n.clone();const i=X(t);D(t,i,r);const s=xt(r,e)?0:1;return o.camera=await H(t,n,r.heading,r.tilt,s,a),o}function Tt(t,e,n,r,a){let o=0;null!=n.z?o=n.z:t.basemapTerrain&&t.elevationProvider&&(o=rt(t.elevationProvider,n)),h(Ot,n.x,n.y,o),B(t.spatialReference,Ot,Ut,t.renderSpatialReference),s(Nt,Ut),c(Nt,Nt),E(Ct);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=r[e[2]];isFinite(n)||(n=o),h(Ot,r[e[0]],r[e[1]],n),Z(Ot,t.spatialReference,Ot,t.renderSpatialReference),V(Ct,d(Ot,Ot,Nt))}const l=O(Ct),m=U(Ct),u=N(Ct),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)/a}async function Pt(t,e,n,r,a,o,i,s){s.targetGeometry=n.clone();const c=X(t),l=Tt(t,c,n,r,a);D(t,c,o);const m=xt(o,e)?0:1;return s.camera=await L(t,s.targetGeometry,l,o,m,i),s.scale=$(t,l),s}function At(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 Et(t){return null!=t?.camera&&(t.rotation=st(t.camera.heading)),t}function Vt(t,e){const n=ot;if(!e.length)return n;let r=Number.NEGATIVE_INFINITY;for(let a=0;a<e.length;a++){const t=e[a].screenSpaceBoundingRect;r=Math.max(r,Math.abs(t[0]),Math.abs(t[1]),Math.abs(t[2]),Math.abs(t[3]))}return n-r/Math.min(t.width,t.height)*2}class kt{constructor(){this.hasZ=!1,this.boundingBox=E(),this.screenSpaceObjects=new Array}}const Ot=w(),Ut=m(),Nt=l(),Ct=F(),It=C(),Wt=w(),Yt=w(),qt=w(),Dt={heading:0,tilt:0},Jt=new b,Xt={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 r=t.hasZ;for(let a=0;a<t.rings.length;a++){const o=t.rings[a];for(let t=0;t<o.length;t++)n[0]=o[t][0],n[1]=o[t][1],r&&(n[2]=o[t][2]),e(n)}},polyline(t,e,n){const r=t.hasZ;for(let a=0;a<t.paths.length;a++){const o=t.paths[a];for(let t=0;t<o.length;t++)n[0]=o[t][0],n[1]=o[t][1],r&&(n[2]=o[t][2]),e(n)}},multipoint(t,e,n){const r=t.points,a=t.hasZ;for(let o=0;o<r.length;o++)n[0]=r[o][0],n[1]=r[o][1],a&&(n[2]=r[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/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import t from"../../../core/Accessor.js";import{cyclicalPI as r}from"../../../core/Cyclical.js";import"../../../core/has.js";import{clamp as s,deg2rad as i}from"../../../core/mathUtils.js";import{destroyMaybe as n}from"../../../core/maybe.js";import{watch as a,when as o,sync as l}from"../../../core/reactiveUtils.js";import{property as h,subclass as d}from"../../../core/accessorSupport/decorators.js";import{subtract as c}from"../../../core/libs/gl-matrix-2/math/vec2.js";import{i as u,e as p,d as m,D as g}from"../../../chunks/vec32.js";import{create as y}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{t as _,s as v,i as f}from"../../../chunks/vec42.js";import{fromValues as w,create as x}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{getReferenceEllipsoid as R}from"../../../geometry/ellipsoidUtils.js";import{projectVectorToVector as S}from"../../../geometry/projection/projectVectorToVector.js";import{create as P,width as O,center as D,copy as T,intersection as M,contains as b,offset as j}from"../../../geometry/support/aaBoundingRect.js";import{createSpatialReferenceCyclical as I}from"../../../geometry/support/normalizeUtils.js";import{create as E,wrap as U}from"../../../geometry/support/ray.js";import{Sphere as V}from"../../../geometry/support/sphere.js";import{angleAroundAxis as C}from"../../../geometry/support/vector.js";import{y2lat as q}from"../../../geometry/support/webMercatorUtils.js";import{viewAngle as A}from"../state/utils/viewUtils.js";import{debugFlags as F}from"../support/debugFlags.js";import{DebugPoint as H}from"../support/debugUtils.js";import{OverlayRenderer as G}from"./OverlayRenderer.js";import{Intersector as z}from"../webgl-engine/lib/Intersector.js";import{fromValues as L}from"../webgl-engine/lib/LocalOriginFactory.js";import{SortedRenderGeometryRenderer as B}from"../webgl-engine/lib/SortedRenderGeometryRenderer.js";import{applyTextureResizeModulo as k,ensureTextureSize as W}from"../webgl-engine/lib/textureUtils.js";import{removeLoadedShaderModules as Y}from"../webgl-engine/parts/renderUtils.js";import{TaskPriority as N,noBudget as X}from"../../support/Scheduler.js";import{Yield as Z}from"../../support/Yield.js";const J=1.3,K=[[-.1,-2,3.9,2],[-.1,-3.9,3.9,.1],[-2,-3.9,2,.1],[-3.9,-3.9,.1,.1],[-3.9,-2,.1,2],[-3.9,-.1,.1,3.9],[-2,-.1,2,3.9],[-.1,-.1,3.9,3.9]];let Q,$=class extends t{constructor(e){super(e),this._renderSR=null,this._overlaySREqualsRenderSR=!0,this._drapeSources=new Set,this._drapeTargets=new Set,this._placementDirty=!1,this._contentUpdated=!1,this._drawTexturesDirty=!1,this._drawTexturesAnimateDirty=!1,this._latestOriginId=0,this.groundView=e.view.groundView}initialize(){const{view:e}=this;this.renderer=new G({parent:this}),e.stage.renderer.plugins.add(this.renderer);const t=()=>this.requestRender();this._groundIntersector=new z(e.state.viewingMode),this._groundIntersector.options.backfacesTerrain=!0,this._groundIntersector.options.invisibleTerrain=!0,this._groundIntersector.options.hud=!1,this.addHandles([a(()=>this.renderer.hasHighlights,t),this.renderer.events.on("has-water",()=>e.stage?.renderer.updateHasFlags()),this.renderer.events.on("content-changed",t),a(()=>e.state.camera.pixelRatio,t),a(()=>e.state.alignPixelEnabled,t),this.renderer.events.on("textures-disposed",()=>this.groundView.requestRender(1)),a(()=>[e.pointsOfInterest?.renderPointOfView,e.pointsOfInterest?.centerOnSurfaceFrequent?.location],()=>this.setPlacementDirty()),a(()=>[e.state?.pixelRatio,e.state?.contentPixelRatio],()=>this.setPlacementDirty(),l),o(()=>this.groundView,e=>e.on("elevation-change",()=>this.setPlacementDirty())),e.on("resize",()=>this.setPlacementDirty()),e.resourceController.scheduler.registerTask(N.OVERLAY,this)]),e.stage.renderer.overlay=this}destroy(){this.view?.stage&&(this.view.stage.renderer.plugins.remove(this.renderer),this.view.stage.renderer.overlay=null,n(this.renderer)),Q&&(Q.hide(),Q=null),this.renderer=null}get spatialReference(){return this._spatialReference}set spatialReference(e){this._spatialReference=e,this.renderer.longitudeCyclical=null;const t=this.view.renderSpatialReference;null!=e&&null!=t?(this._renderSR=t,this._overlaySREqualsRenderSR=e.equals(this._renderSR),this._isSpherical&&(this.renderer.longitudeCyclical=I(e))):this.renderer.disposeOverlays()}get readyToRun(){return this._placementDirty&&(this._drapeSources.size>0||this.view.graphics.length>0||F.OVERLAY_DRAW_DEBUG_TEXTURE)&&!!this._spatialReference&&!this.suspended&&(this.terrainSurface.ready||!this.terrainSurface.enabled)}get _isSpherical(){return this.view.state.isGlobal}get worldToPCSRatio(){return null!=this._spatialReference&&this._spatialReference.isGeographic&&!this.view.state.isLocal?R(this._spatialReference).metersPerDegree:1}get _overlayStretch(){return J/this.view.resolutionScale}get longitudeCyclical(){return this.renderer.longitudeCyclical}get suspended(){return this.terrainSurface.enabled&&this.terrainSurface.suspended}get updating(){return this.readyToRun||!!this.renderer?.updating||this._contentUpdated}render(){return this._contentUpdated=!1,this.renderer.processSyncDrapeSources(),this.renderer.precompileShaders(this.view.state)?this._drawOverlays():null}get hasOverlays(){return this.renderer.hasOverlays}registerDrapeSource(e,t){this._drapeSources.add(e),this.renderer.ensureOverlays(this._drapeTargets,this._drapeSources),this.renderer.registerDrapeSource(e,t),this._updateDrapeSourceExtent(e),this._setContentDirty(),this.notifyChange("readyToRun")}registerGeometryDrapeSource(e){const t=new B({stage:this.view.stage,drapeSource:e,rendererContext:this.renderer});return this.registerDrapeSource(e,t),t}_updateDrapeSourceExtent(e){2===this.renderer.overlays.length&&null!=e.setDrapingExtent&&null!=this._spatialReference&&e.setDrapingExtent(this.renderer.overlays,this._spatialReference)}unregisterDrapeSource(e){this._drapeSources.has(e)&&(this._drapeSources.delete(e),this.renderer.removeDrapeSourceRenderer(e),this.renderer.ensureDrapeSources(this._drapeSources),this._setContentDirty(),this.notifyChange("readyToRun"))}registerDrapeTarget(e){this._drapeTargets.add(e),this.renderer.ensureOverlays(this._drapeTargets,this._drapeSources)}unregisterDrapeTarget(e){this._drapeTargets.delete(e),this.renderer.ensureDrapeTargets(this._drapeTargets)}_setContentDirty(){this.setPlacementDirty(),this.requestRender()}setPlacementDirty(){this._placementDirty=!0}runTask(e){return this.updateOverlays(e,this.view.state.contentCamera,1)}updateOverlays(e,t,r){if(!this._spatialReference)return Z;const s=this._computeOverlayHeight(t);this._computeOverlayExtents(t,s,ie),this.renderer.ensureOverlays(this._drapeTargets,this._drapeSources,ie.stretch);const i=this._updateOverlay(0,ie.inner,s,1*ie.pixelRatioAdjustment,ie.mapUnitsPerPixel),n=O(ie.inner)/O(ie.outer),a=this._updateOverlay(1,ie.outer,s,n*ie.pixelRatioAdjustment,ie.mapUnitsPerPixel);1!==i&&1!==a||(this._drapeSources.forEach(e=>this._updateDrapeSourceExtent(e)),this.groundView.updateOverlayParameters(),this.groundView.requestRender(r)),0===i&&0===a||this.requestRender(),this._placementDirty=!1,e.madeProgress()}_computeOverlayHeight(e){const t=this.view.state.contentPixelRatio*this.view.resolutionScale,r=e.fullWidth/e.pixelRatio*t,s=e.fullHeight/e.pixelRatio*t,i=Math.ceil(1.5*Math.max(r,s)),{maxPreferredTexturePixels:n,maxTextureSize:a}=this.view.stage.renderView.renderingContext.parameters,o=.5*a;return k(W({width:i,height:i},{maxPreferredTexturePixels:2*n,maxTextureSize:o})[1],o)}get overlays(){return this.renderer.overlays}_updateOverlay(e,t,r,s,i){if(0===this.renderer.overlays.length)return 0;const n=this.renderer.overlays[e],a=n.mapUnitsPerPixel;if(n.mapUnitsPerPixel=i,n.pixelRatio=s,ee(t,n.extent)&&r===n.resolution)return a===i?0:2;n.setExtent(t),n.resolution=r;const o=D(n.extent);return n.renderLocalOrigin=L(o[0],o[1],0,"OV_"+this._latestOriginId++),1}overlayPixelSizeInMapUnits(e,t){if(0===this.renderer.overlays.length)return t();const r=this.renderer.overlays[0],s=this.renderer.overlays[1],i=this._pointIsInExtent(e,r.extent)?r:s;return(i.extent[2]-i.extent[0])/i.resolution}reloadShaders(){Y(),this.requestRender(),this.runTask(X)}requestRender(e=1){this.renderer.hasOverlays?(1===e?(this._contentUpdated=!0,this._drawTexturesDirty=!0):this._drawTexturesAnimateDirty=!0,this.view.stage.renderView.requestRender(e)):this.setPlacementDirty()}_intersectGroundFromView(e,t,r,s,i){const n=this.view.sceneIntersectionHelper.getCenterRayWithSubpixelOffset(e,oe,t,r);if(null==n)return!1;const a=n.origin,o=u(se,n.origin,n.direction);this._groundIntersector.reset(a,o,e),this._groundIntersector.intersect([]),this.view.groundView.intersect(this._groundIntersector,null,a,o);const l=this._groundIntersector.results.min;return l.getIntersectionPoint(i)&&l.withinDistance(s)}_findHorizonBasedPointOfInterest(e,t){let i=.5;const n=.55,a=this.view.renderCoordsHelper.getAltitude(e.eye),o=this.view.pointsOfInterest.centerOnSurfaceFrequent,l=1e-5,h=s(o.estimatedSurfaceAltitude,e.aboveGround?-1/0:a+l,e.aboveGround?a-l:1/0),d=e.aboveGround;if("global"===this.view.viewingMode){const t=se;le.radius=R(this.view.spatialReference).radius+h,le.closestPointOnSilhouette(U(e.eye,e.viewForward),t),p(t,t,e.eye);const s=r.normalize(C(e.viewForward,t,e.viewRight))/e.fovY+.5,a=s<=0||s>=1?.5:n;i=d?a*s:s+a*(1-s)}else{const t=.5*Math.PI-Math.acos(-e.viewForward[2]),r=Math.tan(t),a=w(0,r,1,0),o=_(a,a,e.projectionMatrix)[1],l=s(.5+.5*o,0,1);i=1===l||0===l?.5:d?l*n:1-(1-l)*n}return this._intersectGroundFromView(e,.5,i,o.distance,t)}_computeOverlayExtents(e,t,r){const{view:s}=this,n=s.pointsOfInterest.centerOnSurfaceFrequent.renderLocation,a=y();this._findHorizonBasedPointOfInterest(e,a)||m(a,n);const o=this._renderSR;F.OVERLAY_SHOW_CENTER?(null==Q&&(Q=new H(s.graphics,"red")),Q.show(a,o)):null!=Q&&Q.hide();const l=Math.max(.1,g(e.eye,a)),h=A(s.renderCoordsHelper,n,e.eye),d=this._spatialReference;this._overlaySREqualsRenderSR||S(a,o,a,d);const u=this._isSpherical,p=this.groundView.groundExtent,_=!u&&d?.isGeographic,w=_&&d?1/R(d).metersPerDegree:1,x=s.state.contentPixelRatio,P=e.perScreenPixelRatio/x*l*w;r.mapUnitsPerPixel=P/this.worldToPCSRatio,r.stretch=this._overlayStretch;let D=t*P/2*r.stretch,j=!1,I=_?90:1/0;u&&p&&d&&(d.isWebMercator?(D/=Math.cos(q(a[1])),I=p[3]):(j=!0,D/=R(d).metersPerDegree,I=90),D>=I&&(D=I,a[1]=0,d.isWebMercator&&(a[0]=0)));let E=1;j&&(E=1/Math.max(.2,Math.cos(Math.abs(i(a[1])))),D*E>180&&(E=180/D),r.mapUnitsPerPixel*=E);const U=Math.log(2)/12;D=Math.exp(Math.round(Math.log(D)/U)*U);const V=D*E,C=32,G=.5*t/(C*V),z=.5*t/(C*D);a[0]=Math.round(a[0]*G)/G,a[1]=Math.round(a[1]*z)/z;const L=r.inner;L[0]=a[0]-V,L[1]=a[1]-D,L[2]=a[0]+V,L[3]=a[1]+D,u&&this._shiftExtentToFitBounds(L,1/0,I);const B=r.outer;if(6*V>O(p))T(B,p);else{if(Math.PI/2-Math.abs(h-Math.PI/2)<=.25*Math.PI)B[0]=L[0]-V,B[1]=L[1]-D,B[2]=L[2]+V,B[3]=L[3]+D;else{S(e.eye,o,se,d),c(re,a,se);let t=-Math.atan2(re[1],re[0])+.125*Math.PI;t<0&&(t+=2*Math.PI);const r=Math.floor(t/(.25*Math.PI));v(re,K[r],2*D),re[0]*=E,re[2]*=E,f(B,L,re)}}if(u)B[0]=this.longitudeCyclical.clamp(B[0]),B[2]=this.longitudeCyclical.clamp(B[2]),B[1]=Math.max(B[1],-I),B[3]=Math.min(B[3],I);else{const e=M(L,p,ne),t=M(B,p,ae);b(e,t)&&(B[2]=B[0],B[3]=B[1])}const k=Math.abs(L[2]-L[0])/t;r.mapUnitsPerPixel=Math.max(r.mapUnitsPerPixel,k),r.pixelRatioAdjustment=r.mapUnitsPerPixel/k}_drawOverlays(e=this.view.state){if(!this._drawTexturesDirty&&!this._drawTexturesAnimateDirty)return this.renderer;const t=!this._drawTexturesDirty&&this._drawTexturesAnimateDirty?0:1;this._drawTexturesDirty=this._drawTexturesAnimateDirty=!1;const r=this.renderer.computeValidity();this.renderer.releaseRenderTargets(t),this.renderer.drawOverlays(e,t);return r!==this.renderer.computeValidity()&&(this.groundView.updateOverlayParameters(),this.groundView.requestRender(1)),this.groundView.requestRender(t),1===t&&this.terrainSurface.requestUpdate(),this.renderer}_pointIsInExtent(e,t){if(this.longitudeCyclical)return this.longitudeCyclical.contains(t[0],t[2],e.x)&&e.y>=t[1]&&e.y<=t[3];const r=e.x,s=e.y;return r>t[0]&&r<t[2]&&s>t[1]&&s<t[3]}_shiftExtentToFitBounds(e,t,r){let s=0,i=0;e[0]<-t?s=e[0]+t:e[2]>t&&(s=t-e[2]),e[1]<-r?i=e[1]+r:e[3]>r&&(i=r-e[3]),j(e,s,i)}get test(){}};function ee(e,t){const r=1e-5,s=F.TESTS_DISABLE_OPTIMIZATIONS?0:r*Math.max(e[2]-e[0],e[3]-e[1],t[2]-t[0],t[3]-t[1]);return Math.abs(t[0]-e[0])<=s&&Math.abs(t[1]-e[1])<=s&&Math.abs(t[2]-e[2])<=s&&Math.abs(t[3]-e[3])<=s}e([h()],$.prototype,"_spatialReference",void 0),e([h({readOnly:!0})],$.prototype,"readyToRun",null),e([h()],$.prototype,"_placementDirty",void 0),e([h()],$.prototype,"_contentUpdated",void 0),e([h()],$.prototype,"_isSpherical",null),e([h()],$.prototype,"worldToPCSRatio",null),e([h()],$.prototype,"renderer",void 0),e([h({constructOnly:!0})],$.prototype,"view",void 0),e([h({constructOnly:!0})],$.prototype,"groundView",void 0),e([h({constructOnly:!0})],$.prototype,"terrainSurface",void 0),e([h()],$.prototype,"suspended",null),e([h()],$.prototype,"updating",null),$=e([d("esri.views.3d.terrain.OverlayManager")],$);class te{constructor(){this.inner=P(),this.outer=P(),this.mapUnitsPerPixel=0,this.pixelRatioAdjustment=1,this.stretch=J}}const re=x(),se=y(),ie=new te,ne=P(),ae=P(),oe=E(),le=new V;export{$ as OverlayManager};
5
+ import{__decorate as e}from"tslib";import t from"../../../core/Accessor.js";import{cyclicalPI as r}from"../../../core/Cyclical.js";import"../../../core/has.js";import{clamp as s,deg2rad as i}from"../../../core/mathUtils.js";import{destroyMaybe as n}from"../../../core/maybe.js";import{watch as a,when as o,sync as l}from"../../../core/reactiveUtils.js";import{property as h,subclass as d}from"../../../core/accessorSupport/decorators.js";import{subtract as u}from"../../../core/libs/gl-matrix-2/math/vec2.js";import{i as c,e as p,d as m,C as g}from"../../../chunks/vec32.js";import{create as y}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{t as _,s as v,i as f}from"../../../chunks/vec42.js";import{fromValues as w,create as x}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{getReferenceEllipsoid as R}from"../../../geometry/ellipsoidUtils.js";import{projectVectorToVector as S}from"../../../geometry/projection/projectVectorToVector.js";import{create as P,width as O,center as D,copy as T,intersection as M,contains as j,offset as b}from"../../../geometry/support/aaBoundingRect.js";import{createSpatialReferenceCyclical as I}from"../../../geometry/support/normalizeUtils.js";import{create as E,wrap as U}from"../../../geometry/support/ray.js";import{Sphere as V}from"../../../geometry/support/sphere.js";import{angleAroundAxis as C}from"../../../geometry/support/vector.js";import{y2lat as q}from"../../../geometry/support/webMercatorUtils.js";import{viewAngle as A}from"../state/utils/viewUtils.js";import{debugFlags as F}from"../support/debugFlags.js";import{DebugPoint as H}from"../support/debugUtils.js";import{OverlayRenderer as G}from"./OverlayRenderer.js";import{Intersector as z}from"../webgl-engine/lib/Intersector.js";import{fromValues as L}from"../webgl-engine/lib/LocalOriginFactory.js";import{SortedRenderGeometryRenderer as B}from"../webgl-engine/lib/SortedRenderGeometryRenderer.js";import{applyTextureResizeModulo as k,ensureTextureSize as W}from"../webgl-engine/lib/textureUtils.js";import{removeLoadedShaderModules as Y}from"../webgl-engine/parts/renderUtils.js";import{TaskPriority as N,noBudget as X}from"../../support/Scheduler.js";import{Yield as Z}from"../../support/Yield.js";const J=1.3,K=[[-.1,-2,3.9,2],[-.1,-3.9,3.9,.1],[-2,-3.9,2,.1],[-3.9,-3.9,.1,.1],[-3.9,-2,.1,2],[-3.9,-.1,.1,3.9],[-2,-.1,2,3.9],[-.1,-.1,3.9,3.9]];let Q,$=class extends t{constructor(e){super(e),this._renderSR=null,this._overlaySREqualsRenderSR=!0,this._drapeSources=new Set,this._drapeTargets=new Set,this._placementDirty=!1,this._contentUpdated=!1,this._drawTexturesDirty=!1,this._drawTexturesAnimateDirty=!1,this._latestOriginId=0,this.groundView=e.view.groundView}initialize(){const{view:e}=this;this.renderer=new G({parent:this}),e.stage.renderer.plugins.add(this.renderer);const t=()=>this.requestRender();this._groundIntersector=new z(e.state.viewingMode),this._groundIntersector.options.backfacesTerrain=!0,this._groundIntersector.options.invisibleTerrain=!0,this._groundIntersector.options.hud=!1,this.addHandles([a(()=>this.renderer.hasHighlights,t),this.renderer.events.on("has-water",()=>e.stage?.renderer.updateHasFlags()),this.renderer.events.on("content-changed",t),a(()=>e.state.camera.pixelRatio,t),a(()=>e.state.alignPixelEnabled,t),this.renderer.events.on("textures-disposed",()=>this.groundView.requestRender(1)),a(()=>[e.pointsOfInterest?.renderPointOfView,e.pointsOfInterest?.centerOnSurfaceFrequent?.location],()=>this.setPlacementDirty()),a(()=>[e.state?.pixelRatio,e.state?.contentPixelRatio],()=>this.setPlacementDirty(),l),o(()=>this.groundView,e=>e.on("elevation-change",()=>this.setPlacementDirty())),e.on("resize",()=>this.setPlacementDirty()),e.resourceController.scheduler.registerTask(N.OVERLAY,this)]),e.stage.renderer.overlay=this}destroy(){this.view?.stage&&(this.view.stage.renderer.plugins.remove(this.renderer),this.view.stage.renderer.overlay=null,n(this.renderer)),Q&&(Q.hide(),Q=null),this.renderer=null}get spatialReference(){return this._spatialReference}set spatialReference(e){this._spatialReference=e,this.renderer.longitudeCyclical=null;const t=this.view.renderSpatialReference;null!=e&&null!=t?(this._renderSR=t,this._overlaySREqualsRenderSR=e.equals(this._renderSR),this._isSpherical&&(this.renderer.longitudeCyclical=I(e))):this.renderer.disposeOverlays()}get readyToRun(){return this._placementDirty&&(this._drapeSources.size>0||this.view.graphics.length>0||F.OVERLAY_DRAW_DEBUG_TEXTURE)&&!!this._spatialReference&&!this.suspended&&this.groundView.ready}get _isSpherical(){return this.view.state.isGlobal}get worldToPCSRatio(){return null!=this._spatialReference&&this._spatialReference.isGeographic&&!this.view.state.isLocal?R(this._spatialReference).metersPerDegree:1}get _overlayStretch(){return J/this.view.resolutionScale}get longitudeCyclical(){return this.renderer.longitudeCyclical}get suspended(){return this.terrainSurface.enabled&&this.terrainSurface.suspended}get updating(){return this.readyToRun||!!this.renderer?.updating||this._contentUpdated}render(){return this._contentUpdated=!1,this.renderer.processSyncDrapeSources(),this.renderer.precompileShaders(this.view.state)?this._drawOverlays():null}get hasOverlays(){return this.renderer.hasOverlays}registerDrapeSource(e,t){this._drapeSources.add(e),this.renderer.ensureOverlays(this._drapeTargets,this._drapeSources),this.renderer.registerDrapeSource(e,t),this._updateDrapeSourceExtent(e),this._setContentDirty(),this.notifyChange("readyToRun")}registerGeometryDrapeSource(e){const t=new B({stage:this.view.stage,drapeSource:e,rendererContext:this.renderer});return this.registerDrapeSource(e,t),t}_updateDrapeSourceExtent(e){2===this.renderer.overlays.length&&null!=e.setDrapingExtent&&null!=this._spatialReference&&e.setDrapingExtent(this.renderer.overlays,this._spatialReference)}unregisterDrapeSource(e){this._drapeSources.has(e)&&(this._drapeSources.delete(e),this.renderer.removeDrapeSourceRenderer(e),this.renderer.ensureDrapeSources(this._drapeSources),this._setContentDirty(),this.notifyChange("readyToRun"))}registerDrapeTarget(e){this._drapeTargets.add(e),this.renderer.ensureOverlays(this._drapeTargets,this._drapeSources)}unregisterDrapeTarget(e){this._drapeTargets.delete(e),this.renderer.ensureDrapeTargets(this._drapeTargets)}_setContentDirty(){this.setPlacementDirty(),this.requestRender()}setPlacementDirty(){this._placementDirty=!0}runTask(e){return this.updateOverlays(e,this.view.state.contentCamera,1)}updateOverlays(e,t,r){if(!this._spatialReference)return Z;const s=this._computeOverlayHeight(t);this._computeOverlayExtents(t,s,ie),this.renderer.ensureOverlays(this._drapeTargets,this._drapeSources,ie.stretch);const i=this._updateOverlay(0,ie.inner,s,1*ie.pixelRatioAdjustment,ie.mapUnitsPerPixel),n=O(ie.inner)/O(ie.outer),a=this._updateOverlay(1,ie.outer,s,n*ie.pixelRatioAdjustment,ie.mapUnitsPerPixel);1!==i&&1!==a||(this._drapeSources.forEach(e=>this._updateDrapeSourceExtent(e)),this.groundView.updateOverlayParameters(),this.groundView.requestRender(r)),0===i&&0===a||this.requestRender(),this._placementDirty=!1,e.madeProgress()}_computeOverlayHeight(e){const t=this.view.state.contentPixelRatio*this.view.resolutionScale,r=e.fullWidth/e.pixelRatio*t,s=e.fullHeight/e.pixelRatio*t,i=Math.ceil(1.5*Math.max(r,s)),{maxPreferredTexturePixels:n,maxTextureSize:a}=this.view.stage.renderView.renderingContext.parameters,o=.5*a;return k(W({width:i,height:i},{maxPreferredTexturePixels:2*n,maxTextureSize:o})[1],o)}get overlays(){return this.renderer.overlays}_updateOverlay(e,t,r,s,i){if(0===this.renderer.overlays.length)return 0;const n=this.renderer.overlays[e],a=n.mapUnitsPerPixel;if(n.mapUnitsPerPixel=i,n.pixelRatio=s,ee(t,n.extent)&&r===n.resolution)return a===i?0:2;n.setExtent(t),n.resolution=r;const o=D(n.extent);return n.renderLocalOrigin=L(o[0],o[1],0,"OV_"+this._latestOriginId++),1}overlayPixelSizeInMapUnits(e,t){if(0===this.renderer.overlays.length)return t();const r=this.renderer.overlays[0],s=this.renderer.overlays[1],i=this._pointIsInExtent(e,r.extent)?r:s;return(i.extent[2]-i.extent[0])/i.resolution}reloadShaders(){Y(),this.requestRender(),this.runTask(X)}requestRender(e=1){this.renderer.hasOverlays?(1===e?(this._contentUpdated=!0,this._drawTexturesDirty=!0):this._drawTexturesAnimateDirty=!0,this.view.stage.renderView.requestRender(e)):this.setPlacementDirty()}_intersectGroundFromView(e,t,r,s,i){const n=this.view.sceneIntersectionHelper.getCenterRayWithSubpixelOffset(e,oe,t,r);if(null==n)return!1;const a=n.origin,o=c(se,n.origin,n.direction);this._groundIntersector.reset(a,o,e),this._groundIntersector.intersect([]),this.view.groundView.intersect(this._groundIntersector,null,a,o);const l=this._groundIntersector.results.min;return l.getIntersectionPoint(i)&&l.withinDistance(s)}_findHorizonBasedPointOfInterest(e,t){let i=.5;const n=.55,a=this.view.renderCoordsHelper.getAltitude(e.eye),o=this.view.pointsOfInterest.centerOnSurfaceFrequent,l=1e-5,h=s(o.estimatedSurfaceAltitude,e.aboveGround?-1/0:a+l,e.aboveGround?a-l:1/0),d=e.aboveGround;if("global"===this.view.viewingMode){const t=se;le.radius=R(this.view.spatialReference).radius+h,le.closestPointOnSilhouette(U(e.eye,e.viewForward),t),p(t,t,e.eye);const s=r.normalize(C(e.viewForward,t,e.viewRight))/e.fovY+.5,a=s<=0||s>=1?.5:n;i=d?a*s:s+a*(1-s)}else{const t=.5*Math.PI-Math.acos(-e.viewForward[2]),r=Math.tan(t),a=w(0,r,1,0),o=_(a,a,e.projectionMatrix)[1],l=s(.5+.5*o,0,1);i=1===l||0===l?.5:d?l*n:1-(1-l)*n}return this._intersectGroundFromView(e,.5,i,o.distance,t)}_computeOverlayExtents(e,t,r){const{view:s}=this,n=s.pointsOfInterest.centerOnSurfaceFrequent.renderLocation,a=y();this._findHorizonBasedPointOfInterest(e,a)||m(a,n);const o=this._renderSR;F.OVERLAY_SHOW_CENTER?(null==Q&&(Q=new H(s.graphics,"red")),Q.show(a,o)):null!=Q&&Q.hide();const l=Math.max(.1,g(e.eye,a)),h=A(s.renderCoordsHelper,n,e.eye),d=this._spatialReference;this._overlaySREqualsRenderSR||S(a,o,a,d);const c=this._isSpherical,p=this.groundView.groundExtent,_=!c&&d?.isGeographic,w=_&&d?1/R(d).metersPerDegree:1,x=s.state.contentPixelRatio,P=e.perScreenPixelRatio/x*l*w;r.mapUnitsPerPixel=P/this.worldToPCSRatio,r.stretch=this._overlayStretch;let D=t*P/2*r.stretch,b=!1,I=_?90:1/0;c&&p&&d&&(d.isWebMercator?(D/=Math.cos(q(a[1])),I=p[3]):(b=!0,D/=R(d).metersPerDegree,I=90),D>=I&&(D=I,a[1]=0,d.isWebMercator&&(a[0]=0)));let E=1;b&&(E=1/Math.max(.2,Math.cos(Math.abs(i(a[1])))),D*E>180&&(E=180/D),r.mapUnitsPerPixel*=E);const U=Math.log(2)/12;D=Math.exp(Math.round(Math.log(D)/U)*U);const V=D*E,C=32,G=.5*t/(C*V),z=.5*t/(C*D);a[0]=Math.round(a[0]*G)/G,a[1]=Math.round(a[1]*z)/z;const L=r.inner;L[0]=a[0]-V,L[1]=a[1]-D,L[2]=a[0]+V,L[3]=a[1]+D,c&&this._shiftExtentToFitBounds(L,1/0,I);const B=r.outer;if(p&&6*V>O(p))T(B,p);else{if(Math.PI/2-Math.abs(h-Math.PI/2)<=.25*Math.PI)B[0]=L[0]-V,B[1]=L[1]-D,B[2]=L[2]+V,B[3]=L[3]+D;else{S(e.eye,o,se,d),u(re,a,se);let t=-Math.atan2(re[1],re[0])+.125*Math.PI;t<0&&(t+=2*Math.PI);const r=Math.floor(t/(.25*Math.PI));v(re,K[r],2*D),re[0]*=E,re[2]*=E,f(B,L,re)}}if(c)B[0]=this.longitudeCyclical.clamp(B[0]),B[2]=this.longitudeCyclical.clamp(B[2]),B[1]=Math.max(B[1],-I),B[3]=Math.min(B[3],I);else{const e=M(L,p,ne),t=M(B,p,ae);j(e,t)&&(B[2]=B[0],B[3]=B[1])}const k=Math.abs(L[2]-L[0])/t;r.mapUnitsPerPixel=Math.max(r.mapUnitsPerPixel,k),r.pixelRatioAdjustment=r.mapUnitsPerPixel/k}_drawOverlays(e=this.view.state){if(!this._drawTexturesDirty&&!this._drawTexturesAnimateDirty)return this.renderer;const t=!this._drawTexturesDirty&&this._drawTexturesAnimateDirty?0:1;this._drawTexturesDirty=this._drawTexturesAnimateDirty=!1;const r=this.renderer.computeValidity();this.renderer.releaseRenderTargets(t),this.renderer.drawOverlays(e,t);return r!==this.renderer.computeValidity()&&(this.groundView.updateOverlayParameters(),this.groundView.requestRender(1)),this.groundView.requestRender(t),1===t&&this.terrainSurface.requestUpdate(),this.renderer}_pointIsInExtent(e,t){if(this.longitudeCyclical)return this.longitudeCyclical.contains(t[0],t[2],e.x)&&e.y>=t[1]&&e.y<=t[3];const r=e.x,s=e.y;return r>t[0]&&r<t[2]&&s>t[1]&&s<t[3]}_shiftExtentToFitBounds(e,t,r){let s=0,i=0;e[0]<-t?s=e[0]+t:e[2]>t&&(s=t-e[2]),e[1]<-r?i=e[1]+r:e[3]>r&&(i=r-e[3]),b(e,s,i)}get test(){}};function ee(e,t){const r=1e-5,s=F.TESTS_DISABLE_OPTIMIZATIONS?0:r*Math.max(e[2]-e[0],e[3]-e[1],t[2]-t[0],t[3]-t[1]);return Math.abs(t[0]-e[0])<=s&&Math.abs(t[1]-e[1])<=s&&Math.abs(t[2]-e[2])<=s&&Math.abs(t[3]-e[3])<=s}e([h()],$.prototype,"_spatialReference",void 0),e([h({readOnly:!0})],$.prototype,"readyToRun",null),e([h()],$.prototype,"_placementDirty",void 0),e([h()],$.prototype,"_contentUpdated",void 0),e([h()],$.prototype,"_isSpherical",null),e([h()],$.prototype,"worldToPCSRatio",null),e([h()],$.prototype,"renderer",void 0),e([h({constructOnly:!0})],$.prototype,"view",void 0),e([h({constructOnly:!0})],$.prototype,"groundView",void 0),e([h({constructOnly:!0})],$.prototype,"terrainSurface",void 0),e([h()],$.prototype,"suspended",null),e([h()],$.prototype,"updating",null),$=e([d("esri.views.3d.terrain.OverlayManager")],$);class te{constructor(){this.inner=P(),this.outer=P(),this.mapUnitsPerPixel=0,this.pixelRatioAdjustment=1,this.stretch=J}}const re=x(),se=y(),ie=new te,ne=P(),ae=P(),oe=E(),le=new V;export{$ as OverlayManager};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import{unique as r}from"../../../core/arrayUtils.js";import{EventEmitter as t}from"../../../core/Evented.js";import"../../../core/has.js";import{someMap as s,everyMap as i}from"../../../core/MapUtils.js";import{disposeMaybe as n}from"../../../core/maybe.js";import o from"../../../core/PooledArray.js";import{watch as a,on as h,syncAndInitial as d,initial as l}from"../../../core/reactiveUtils.js";import{someSet as c}from"../../../core/SetUtils.js";import{property as u,subclass as p}from"../../../core/accessorSupport/decorators.js";import{ortho as _,fromTranslation as g}from"../../../core/libs/gl-matrix-2/math/mat4.js";import{h as m}from"../../../chunks/vec32.js";import{ones as y}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{debugFlags as f}from"../support/debugFlags.js";import{Overlay as R}from"./Overlay.js";import{OverlayRenderTargets as v}from"./OverlayRenderTargets.js";import x from"../webgl/RenderCamera.js";import{T as w}from"../../../chunks/TextureOnly.glsl.js";import{SyncRenderPlugin as T}from"../webgl-engine/effects/RenderPlugin.js";import{trackHighlightOptions as S,renderHighlightBuffer as b}from"../webgl-engine/effects/highlight/Highlight.js";import{GLMaterialRepository as O}from"../webgl-engine/lib/GLMaterialRepository.js";import{GridLocalOriginFactory as D}from"../webgl-engine/lib/GridLocalOriginFactory.js";import{RenderContext as C,defaultRenderOccludedMask as P}from"../webgl-engine/lib/RenderContext.js";import{ShadowMap as j}from"../webgl-engine/lib/ShadowMap.js";import{TextureTechnique as E}from"../webgl-engine/lib/TextureTechnique.js";import{TextureTechniqueConfiguration as M}from"../webgl-engine/lib/TextureTechniqueConfiguration.js";import{AmbientLight as F}from"../webgl-engine/lighting/Lightsources.js";import{O as W}from"../../../chunks/OverlayCompositing.glsl.js";import{OverlayCompositingTechnique as q}from"../webgl-engine/shaders/OverlayCompositingTechnique.js";import{TaskPriority as V,noBudget as A}from"../../support/Scheduler.js";import{Texture as k}from"../../webgl/Texture.js";import{TextureDescriptor as G}from"../../webgl/TextureDescriptor.js";let I=class extends T{constructor(e){super(e),this._overlays=null,this._renderTargets=null,this._overlayParameters=new W,this.hasHighlights=!1,this.renderOccludedFlags=1,this._hasWater=!1,this._renderers=new Map,this._sortedDrapeSourceRenderersDirty=!1,this._sortedRenderers=new o,this._passParameters=new w,this._screenToWorldRatio=1,this._localOriginFactory=null,this.unloadedMemory=0,this.ignoresMemoryFactor=!1,this._camera=new x,this.events=new t,this.longitudeCyclical=null,this.produces=new Map([[18,e=>8!==e||this.hasHighlights],[19,()=>this._hasWater]]),this._hasTargetWithoutRasterImage=!1,this._hasDrapedFeatureSource=!1,this._hasDrapedRasterSource=!1,this._hasDrapedFlowSource=!1}initialize(){const e=this._view,r=e.stage,t=r.renderer.fboCache,{waterTextures:s,techniques:i}=r.renderView;this._renderContext=new C(this._rctx,new j(t,e.state.viewingMode),i),this.addHandles([a(()=>s.updating,()=>this.events.emit("content-changed"),d),a(()=>this._spatialReference,e=>this._localOriginFactory=new D(e),d),h(()=>e.allLayerViews,"after-changes",()=>this._sortedDrapeSourceRenderersDirty=!0),a(()=>S(e.state.highlights),()=>this._sortedDrapeSourceRenderersDirty=!0,l),a(()=>e.state.highlights,r=>{this._bindParameters.highlights=r,this._bindParameters.highlightOrderMap=e.state.highlightOrderMap},l),e.resourceController.scheduler.registerTask(V.OVERLAY_RENDERER,this)]);const{_bindParameters:n,_camera:o}=this;o.near=1,o.far=1e4,o.relativeElevation=null,n.slot=18,n.mainDepth=null,n.camera=o,n.oitPass=0,n.updateLighting([new F(y())],0,0,0)}destroy(){this._renderers.forEach(e=>e.destroy()),this._renderers.clear(),this._passParameters.texture=n(this._passParameters.texture),this.disposeOverlays(),this._renderContext=null,this._sortedRenderers.prune()}get _bindParameters(){return this._renderContext.bind}get _rctx(){return this._stage.renderView.renderingContext}get _view(){return this.parent.view}get _stage(){return this.parent.view.stage}get _spatialReference(){return this.parent.spatialReference}get _techniques(){return this._stage.renderView.techniques}get rctx(){return this._rctx}get materials(){return this._pluginContext.materials}get screenToWorldRatio(){return this._screenToWorldRatio}get localOriginFactory(){return this._localOriginFactory}get pluginContext(){return this._pluginContext}initializeRenderContext(e){const r=new O(this._view.stage.renderView.textures,this._techniques,()=>{this._onMaterialOrContentChanged(),this.events.emit("content-changed"),this.notifyChange("updating"),this.notifyChange("isEmpty")},()=>this.events.emit("content-changed"));this._pluginContext={...e,materials:r},this._techniques.precompile(q)}uninitializeRenderContext(){}acquireTechniques(){return[]}render(){}get updating(){return this._sortedDrapeSourceRenderersDirty||s(this._renderers,e=>e.updating||e.canCompact)}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(),r(this._sortedRenderers.map(e=>e.drapeSource.layer).filter(e=>!!e))}registerDrapeSource(e,r){const t=this._renderers.get(e);null!=t&&t.destroy(),this._renderers.set(e,r),this._sortedDrapeSourceRenderersDirty=!0,"fullOpacity"in e&&this.addHandles(a(()=>e.fullOpacity,()=>this.events.emit("content-changed")),e)}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(e){this._renderTargets?.dispose(e)}get overlays(){return this._overlays??[]}ensureDrapeTargets(e){this._hasTargetWithoutRasterImage=!!this._overlays&&c(e,e=>1===e.drapeTargetType)}ensureDrapeSources(e){this._overlays?(this._hasDrapedFeatureSource=c(e,e=>1===e.drapeSourceType),this._hasDrapedRasterSource=c(e,e=>0===e.drapeSourceType),this._hasDrapedFlowSource=c(e,e=>2===e.drapeSourceType)):this._hasDrapedFeatureSource=this._hasDrapedRasterSource=this._hasDrapedFlowSource=!1}get _needsColorWithoutRasterImage(){return this._hasDrapedRasterSource&&this._hasDrapedFeatureSource&&this._hasTargetWithoutRasterImage}ensureOverlays(e,r,t=this._bindParameters.overlayStretch){null==this._overlays&&(this._renderTargets=new v(this._stage.renderer.fboCache),this._overlays=[new R,new R]),this.ensureDrapeTargets(e),this.ensureDrapeSources(r),this._bindParameters.overlayStretch=t}disposeOverlays(){this._overlays=null,this._renderTargets?.dispose(1),this._renderTargets=null,this.events.emit("textures-disposed")}_useOverlayColorInsteadOfColorNoRasterImage(e){return 1===e&&!this._needsColorWithoutRasterImage&&this._hasDrapedFeatureSource}getTexture(e){const r=this._useOverlayColorInsteadOfColorNoRasterImage(e);return this._renderTargets?.getTexture(r?0:e)}get readyToRun(){return this.updating}runTask(e){this._processDrapeSources(e,()=>!0)}_onMaterialOrContentChanged(){this.renderOccludedFlags=s(this._renderers,e=>e.hasOccluders)?L:1}_processDrapeSources(e,r){let t=!1;for(const[s,i]of this._renderers){if(e.done)break;(s.destroyed||r(s))&&(i.commitChanges()&&(t=!0,e.madeProgress()))}this._sortedDrapeSourceRenderersDirty&&(this._sortedDrapeSourceRenderersDirty=!1,t=!0,this._updateSortedDrapeSourceRenderers(),e.madeProgress()),this.compact(e),t&&(null!=this._overlays&&0===this._renderers.size&&this.disposeOverlays(),this.notifyChange("updating"),this.notifyChange("isEmpty"),this._onMaterialOrContentChanged(),this.hasHighlights=s(this._renderers,e=>e.hasHighlights),this.events.emit("content-changed"))}compact(e){let r=!1;for(const t of this._renderers.values()){if(e.done)break;r=t.compact(e)||r}return r&&this.notifyChange("updating"),r}hasHighlight(e){return s(this._renderers,r=>r.hasHighlight(e))}processSyncDrapeSources(){this._processDrapeSources(A,e=>1===e.updatePolicy)}get isEmpty(){return!f.OVERLAY_DRAW_DEBUG_TEXTURE&&i(this._renderers,e=>e.isEmpty)}get hasWater(){const e=s(this._renderers,({hasWater:e})=>e);return e!==this._hasWater&&(this._hasWater=e,this.events.emit("has-water")),this._hasWater}renders(e){if(f.OVERLAY_DRAW_DEBUG_TEXTURE&&4!==e&&2!==e)return!0;if(!this._overlays)return!1;const r=this._overlays[0];for(const i of this._overlays)i.setupGeometryViews(this.longitudeCyclical);if(!r.hasSomeSizedView())return!1;const t=this._renderContext.output;this._renderContext.output=this._renderTargets?.targets.find(r=>r.content===e)?.output??0,++this._techniques.precompiling;const s=this._sortedRenderers.some(({renderer:e})=>e.precompile(this._renderContext));return--this._techniques.precompiling,this._renderContext.output=t,s}get mode(){return this.isEmpty?0:this.hasWater&&this.renders(3)?2:this._renderTargets?.getTexture(0)?1:0}updateAnimation(e){let r=!1;return this._renderers.forEach(t=>r=t.updateAnimation(e)||r),r&&this.parent.requestRender(0),r}updateDrapeSourceOrder(){this._sortedDrapeSourceRenderersDirty=!0}precompileShaders(e){if(!this._overlays||!this._renderTargets)return!1;const r=this._bindParameters;r.alignPixelEnabled=e.alignPixelEnabled,++this._techniques.precompiling;for(const t of this._renderTargets.targets){if(1===t.content&&!this._needsColorWithoutRasterImage)continue;const{output:e}=t;this._renderContext.output=e,r.slot=2===e?19:18,8===e&&(r.highlightMixTexture=r.highlights.length>1?this._rctx.emptyTexture:null);const s=this._renderContext.renderOccludedMask;4===t.content&&(this._renderContext.renderOccludedMask=L),this._sortedRenderers.forAll(({drapeSource:e,renderer:r})=>{1===t.content&&0===e.drapeSourceType||4===t.content&&r.hasOnlyOccluders||r.precompile(this._renderContext)}),this._renderContext.renderOccludedMask=s,r.highlightMixTexture=null}return--this._techniques.precompiling,!0}drawOverlays(e,r){if(!this._overlays||!this._renderTargets)return;for(const s of this._overlays)s.setupGeometryViews(this.longitudeCyclical);this._bindParameters.alignPixelEnabled=e.alignPixelEnabled;const t=this.allSourcesOccluders;for(const s of this._renderTargets.targets){if(!(0===s.content&&this._hasDrapedFlowSource)&&!s.handleRenderRequest(r)||1===s.content&&!this._needsColorWithoutRasterImage||4===s.content&&t)continue;const e=this._drawTarget(0,s),i=this._drawTarget(1,s);(e||i)&&s.fbo.generateMipMap()}}_drawTarget(e,r){const t=this._overlays[e],s=t.canvasGeometries;if(0===s.numViews)return!1;const i=this._view.state.contentPixelRatio;this._screenToWorldRatio=i*t.mapUnitsPerPixel/this._bindParameters.overlayStretch;const{output:n}=r;if(this.isEmpty||2===n&&!this.hasWater||!t.hasSomeSizedView())return!1;const{_rctx:o,_camera:a,_renderContext:h,_bindParameters:d}=this;if(a.pixelRatio=t.pixelRatio*i,h.output=n,d.screenToWorldRatio=this._screenToWorldRatio,d.screenToPCSRatio=this._screenToWorldRatio*this.parent.worldToPCSRatio,d.slot=2===n?19:18,4===r.content&&(h.renderOccludedMask=L),!this.renders(r.content))return h.renderOccludedMask=P,!1;const{resolution:l}=t,c=0===e,u=c?0:l;if(o.setViewport(u,0,l,l),this._bindTargetFBO(r),c)if(8!==r.output)o.setClearColor(0,0,0,0),o.clear(16384);else{const{gl:e}=o;e.clearBufferuiv(e.COLOR,0,[0,0,0,0])}if(f.OVERLAY_DRAW_DEBUG_TEXTURE&&4!==r.content&&2!==r.content){this._techniques.precompile(E,z);const r=this._techniques.get(E,z);for(let i=0;i<s.numViews;i++)this._setViewParameters(s.extents[i],t),this._ensureDebugPatternResources(t.resolution,B[e]),o.bindTechnique(r,d,this._passParameters),o.screen.draw()}if(8===r.output){const{fboCache:t}=this._stage.renderer,s=this._resolution;this._bindTargetFBO(r),b(o,t,{width:s,height:s},d,()=>this._renderAllGeometry(e,r),u)}else this._renderAllGeometry(e,r);return o.bindFramebuffer(null),h.renderOccludedMask=P,!0}get allSourcesOccluders(){return i(this._renderers,e=>e.hasOnlyOccluders)}_renderAllGeometry(e,r){const t=this._overlays[e],s=t.canvasGeometries;this._sortedRenderers.forAll(({drapeSource:i,renderer:n})=>{if(1===r.content&&0===i.drapeSourceType)return;const{fullOpacity:o}=i,a=null!=o&&o<1&&0===r.output&&this._bindTemporaryFBO();for(let e=0;e<s.numViews;e++)this._setViewParameters(s.extents[e],t),n.render(this._renderContext);if(a){this._bindTargetFBO(r),this._overlayParameters.texture=a.getTexture(),this._overlayParameters.opacity=o,this._overlayParameters.overlayIndex=e;const t=this._techniques.get(q);this._rctx.bindTechnique(t,this._bindParameters,this._overlayParameters),this._rctx.screen.draw(),a.release()}})}_bindTargetFBO(e){const r=this._resolution,t=2*r;e.fbo.ensureFramebuffer(t,r),e.fbo.bind(this._rctx)}_bindTemporaryFBO(){const e=this._resolution,r=2*e,t=this._stage.renderer.fboCache,s=t.acquire(r,e,"overlay tmp");return t.rctx.bindFramebuffer(s.fbo),t.rctx.clear(16384),s}get _resolution(){return this._overlays?.[0].resolution??0}notifyContentChanged(){this.events.emit("content-changed")}intersect(e,r,t,s){this._sortedDrapeSourceRenderersDirty&&this._updateSortedDrapeSourceRenderers();let i=0;for(const{renderer:n}of this._sortedRenderers)i=n.intersect?.(e,r,t,s,i)??i}_updateSortedDrapeSourceRenderers(){if(this._sortedRenderers.clear(),0===this._renderers.size)return;const e=this._view.map.allLayers.map(e=>e.uid),r=e.length;this._renderers.forEach((t,s)=>{const i=e.indexOf(s.layer?.uid),n=i>=0,o=s.renderGroup??(n?0:1),a=s.drapeSourcePriorityOffset??0,h=r*o+(n?i:0)+a;this._sortedRenderers.push(new U(s,t,h))}),this._sortedRenderers.sort((e,r)=>e.index-r.index)}_setViewParameters(e,r){const t=this._camera;t.viewport=[0,0,r.resolution,r.resolution],_(t.projectionMatrix,0,e[2]-e[0],0,e[3]-e[1],t.near,t.far),g(t.viewMatrix,[-e[0],-e[1],0])}_ensureDebugPatternResources(e,r){if(m(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 n=0;n<e;n++)for(let r=0;r<e;r++){const i=Math.floor(r/10),o=Math.floor(n/10);i<2||o<2||10*i>e-20||10*o>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&o?1&r^1&n?0:255:1&i^1&o?0:128)}const i=new G(e);i.samplingMode=9728,this._passParameters.texture=new k(this._rctx,i,t)}get test(){}};e([u()],I.prototype,"hasHighlights",void 0),e([u()],I.prototype,"renderOccludedFlags",void 0),e([u()],I.prototype,"_sortedDrapeSourceRenderersDirty",void 0),e([u({constructOnly:!0})],I.prototype,"parent",void 0),e([u({readOnly:!0})],I.prototype,"_techniques",null),e([u({type:Boolean,readOnly:!0})],I.prototype,"updating",null),e([u()],I.prototype,"isEmpty",null),I=e([p("esri.views.3d.terrain.OverlayRenderer")],I);class U{constructor(e,r,t){this.drapeSource=e,this.renderer=r,this.index=t}}const B=[[1,.5,.5],[.5,.5,1]],H=-2,L=4,z=new M;z.hasAlpha=!0;export{I as OverlayRenderer,H as drapedZ,L as overlayRenderOccludedFlag};
5
+ import{__decorate as e}from"tslib";import{unique as r}from"../../../core/arrayUtils.js";import{EventEmitter as t}from"../../../core/Evented.js";import"../../../core/has.js";import{someMap as s,everyMap as i}from"../../../core/MapUtils.js";import{disposeMaybe as n}from"../../../core/maybe.js";import o from"../../../core/PooledArray.js";import{watch as a,on as h,syncAndInitial as d,initial as l}from"../../../core/reactiveUtils.js";import{someSet as c}from"../../../core/SetUtils.js";import{property as u,subclass as p}from"../../../core/accessorSupport/decorators.js";import{ortho as _,fromTranslation as g}from"../../../core/libs/gl-matrix-2/math/mat4.js";import{h as m}from"../../../chunks/vec32.js";import{ones as y}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{debugFlags as f}from"../support/debugFlags.js";import{Overlay as R}from"./Overlay.js";import{OverlayRenderTargets as v}from"./OverlayRenderTargets.js";import w from"../webgl/RenderCamera.js";import{T as x}from"../../../chunks/TextureOnly.glsl.js";import{SyncRenderPlugin as T}from"../webgl-engine/effects/RenderPlugin.js";import{trackHighlightOptions as O,renderHighlightBuffer as S}from"../webgl-engine/effects/highlight/Highlight.js";import{GLMaterialRepository as b}from"../webgl-engine/lib/GLMaterialRepository.js";import{GridLocalOriginFactory as D}from"../webgl-engine/lib/GridLocalOriginFactory.js";import{RenderContext as C,defaultRenderOccludedMask as P}from"../webgl-engine/lib/RenderContext.js";import{ShadowMap as j}from"../webgl-engine/lib/ShadowMap.js";import{TextureTechnique as E}from"../webgl-engine/lib/TextureTechnique.js";import{TextureTechniqueConfiguration as M}from"../webgl-engine/lib/TextureTechniqueConfiguration.js";import{AmbientLight as F}from"../webgl-engine/lighting/Lightsources.js";import{O as W}from"../../../chunks/OverlayCompositing.glsl.js";import{OverlayCompositingTechnique as q}from"../webgl-engine/shaders/OverlayCompositingTechnique.js";import{TaskPriority as V,noBudget as A}from"../../support/Scheduler.js";import{Texture as k}from"../../webgl/Texture.js";import{TextureDescriptor as G}from"../../webgl/TextureDescriptor.js";let I=class extends T{constructor(e){super(e),this._overlays=null,this._renderTargets=null,this._overlayParameters=new W,this.hasHighlights=!1,this.renderOccludedFlags=1,this._hasWater=!1,this._renderers=new Map,this._sortedDrapeSourceRenderersDirty=!1,this._sortedRenderers=new o,this._passParameters=new x,this._screenToWorldRatio=1,this._localOriginFactory=null,this.unloadedMemory=0,this.ignoresMemoryFactor=!1,this._camera=new w,this.events=new t,this.longitudeCyclical=null,this.produces=new Map([[19,e=>8!==e||this.hasHighlights],[20,()=>this._hasWater]]),this._hasTargetWithoutRasterImage=!1,this._hasDrapedFeatureSource=!1,this._hasDrapedRasterSource=!1,this._hasDrapedFlowSource=!1}initialize(){const e=this._view,r=e.stage,t=r.renderer.fboCache,{waterTextures:s,techniques:i}=r.renderView;this._renderContext=new C(this._rctx,new j(t,e.state.viewingMode),i);const n=this._bindParameters;this.addHandles([a(()=>s.updating,()=>this.events.emit("content-changed"),d),a(()=>this._spatialReference,e=>this._localOriginFactory=new D(e),d),h(()=>e.allLayerViews,"after-changes",()=>this._sortedDrapeSourceRenderersDirty=!0),a(()=>O(e.state.highlights),()=>this._sortedDrapeSourceRenderersDirty=!0,l),a(()=>e.state.highlights,r=>{n.highlights=r,n.highlightOrderMap=e.state.highlightOrderMap},l),e.resourceController.scheduler.registerTask(V.OVERLAY_RENDERER,this)]);const o=this._camera;o.near=1,o.far=1e4,o.relativeElevation=null,n.slot=19,n.camera=o,n.updateLighting([new F(y())],0,0,0)}destroy(){this._renderers.forEach(e=>e.destroy()),this._renderers.clear(),this._passParameters.texture=n(this._passParameters.texture),this.disposeOverlays(),this._renderContext=null,this._sortedRenderers.prune()}get _bindParameters(){return this._renderContext.bind}get _rctx(){return this._stage.renderView.renderingContext}get _view(){return this.parent.view}get _stage(){return this.parent.view.stage}get _spatialReference(){return this.parent.spatialReference}get _techniques(){return this._stage.renderView.techniques}get rctx(){return this._rctx}get materials(){return this._pluginContext.materials}get screenToWorldRatio(){return this._screenToWorldRatio}get localOriginFactory(){return this._localOriginFactory}get pluginContext(){return this._pluginContext}initializeRenderContext(e){const r=new b(this._view.stage.renderView.textures,this._techniques,()=>{this._onMaterialOrContentChanged(),this.events.emit("content-changed"),this.notifyChange("updating"),this.notifyChange("isEmpty")},()=>this.events.emit("content-changed"));this._pluginContext={...e,materials:r},this._techniques.precompile(q)}uninitializeRenderContext(){}acquireTechniques(){return[]}render(){}get updating(){return this._sortedDrapeSourceRenderersDirty||s(this._renderers,e=>e.updating||e.canCompact)}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(),r(this._sortedRenderers.map(e=>e.drapeSource.layer).filter(e=>!!e))}registerDrapeSource(e,r){const t=this._renderers.get(e);null!=t&&t.destroy(),this._renderers.set(e,r),this._sortedDrapeSourceRenderersDirty=!0,"fullOpacity"in e&&this.addHandles(a(()=>e.fullOpacity,()=>this.events.emit("content-changed")),e)}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(e){this._renderTargets?.dispose(e)}get overlays(){return this._overlays??[]}ensureDrapeTargets(e){this._hasTargetWithoutRasterImage=!!this._overlays&&c(e,e=>1===e.drapeTargetType)}ensureDrapeSources(e){this._overlays?(this._hasDrapedFeatureSource=c(e,e=>1===e.drapeSourceType),this._hasDrapedRasterSource=c(e,e=>0===e.drapeSourceType),this._hasDrapedFlowSource=c(e,e=>2===e.drapeSourceType)):this._hasDrapedFeatureSource=this._hasDrapedRasterSource=this._hasDrapedFlowSource=!1}get _needsColorWithoutRasterImage(){return this._hasDrapedRasterSource&&this._hasDrapedFeatureSource&&this._hasTargetWithoutRasterImage}ensureOverlays(e,r,t=this._bindParameters.overlayStretch){null==this._overlays&&(this._renderTargets=new v(this._stage.renderer.fboCache),this._overlays=[new R,new R]),this.ensureDrapeTargets(e),this.ensureDrapeSources(r),this._bindParameters.overlayStretch=t}disposeOverlays(){this._overlays=null,this._renderTargets?.dispose(1),this._renderTargets=null,this.events.emit("textures-disposed")}_useOverlayColorInsteadOfColorNoRasterImage(e){return 1===e&&!this._needsColorWithoutRasterImage&&this._hasDrapedFeatureSource}getTexture(e){const r=this._useOverlayColorInsteadOfColorNoRasterImage(e);return this._renderTargets?.getTexture(r?0:e)}get readyToRun(){return this.updating}runTask(e){this._processDrapeSources(e,()=>!0)}_onMaterialOrContentChanged(){this.renderOccludedFlags=s(this._renderers,e=>e.hasOccluders)?L:1}_processDrapeSources(e,r){let t=!1;for(const[s,i]of this._renderers){if(e.done)break;(s.destroyed||r(s))&&(i.commitChanges()&&(t=!0,e.madeProgress()))}this._sortedDrapeSourceRenderersDirty&&(this._sortedDrapeSourceRenderersDirty=!1,t=!0,this._updateSortedDrapeSourceRenderers(),e.madeProgress()),this.compact(e),t&&(null!=this._overlays&&0===this._renderers.size&&this.disposeOverlays(),this.notifyChange("updating"),this.notifyChange("isEmpty"),this._onMaterialOrContentChanged(),this.hasHighlights=s(this._renderers,e=>e.hasHighlights),this.events.emit("content-changed"))}compact(e){let r=!1;for(const t of this._renderers.values()){if(e.done)break;r=t.compact(e)||r}return r&&this.notifyChange("updating"),r}hasHighlight(e){return s(this._renderers,r=>r.hasHighlight(e))}processSyncDrapeSources(){this._processDrapeSources(A,e=>1===e.updatePolicy)}get isEmpty(){return!f.OVERLAY_DRAW_DEBUG_TEXTURE&&i(this._renderers,e=>e.isEmpty)}get hasWater(){const e=s(this._renderers,({hasWater:e})=>e);return e!==this._hasWater&&(this._hasWater=e,this.events.emit("has-water")),this._hasWater}renders(e){if(f.OVERLAY_DRAW_DEBUG_TEXTURE&&4!==e&&2!==e)return!0;if(!this._overlays)return!1;const r=this._overlays[0];for(const i of this._overlays)i.setupGeometryViews(this.longitudeCyclical);if(!r.hasSomeSizedView())return!1;const t=this._setOutput(this._renderTargets?.targets.find(r=>r.content===e)?.output??0);++this._techniques.precompiling;const s=this._sortedRenderers.some(({renderer:e})=>e.precompile(this._renderContext));return--this._techniques.precompiling,this._setOutput(t),s}_setOutput(e){const r=this._renderContext.output;return this._renderContext.output=e,this._bindParameters.slot=2===e?20:19,r}get mode(){return this.isEmpty?0:this.hasWater&&this.renders(3)?2:this._renderTargets?.getTexture(0)?1:0}updateAnimation(e){let r=!1;return this._renderers.forEach(t=>r=t.updateAnimation(e)||r),r&&this.parent.requestRender(0),r}updateDrapeSourceOrder(){this._sortedDrapeSourceRenderersDirty=!0}precompileShaders(e){if(!this._overlays||!this._renderTargets)return!1;const r=this._bindParameters;r.alignPixelEnabled=e.alignPixelEnabled,++this._techniques.precompiling;for(const t of this._renderTargets.targets){if(1===t.content&&!this._needsColorWithoutRasterImage)continue;const{output:e}=t;this._setOutput(e),8===e&&(r.highlightMixTexture=r.highlights.length>1?this._rctx.emptyTexture:null);const s=this._renderContext.renderOccludedMask;4===t.content&&(this._renderContext.renderOccludedMask=L),this._sortedRenderers.forAll(({drapeSource:e,renderer:r})=>{1===t.content&&0===e.drapeSourceType||4===t.content&&r.hasOnlyOccluders||r.precompile(this._renderContext)}),this._renderContext.renderOccludedMask=s,r.highlightMixTexture=null}return--this._techniques.precompiling,!0}drawOverlays(e,r){if(!this._overlays||!this._renderTargets)return;for(const s of this._overlays)s.setupGeometryViews(this.longitudeCyclical);this._bindParameters.alignPixelEnabled=e.alignPixelEnabled;const t=this.allSourcesOccluders;for(const s of this._renderTargets.targets){if(!(0===s.content&&this._hasDrapedFlowSource)&&!s.handleRenderRequest(r)||1===s.content&&!this._needsColorWithoutRasterImage||4===s.content&&t)continue;const e=this._drawTarget(0,s),i=this._drawTarget(1,s);(e||i)&&s.fbo.generateMipMap()}}_drawTarget(e,r){const t=this._overlays[e],s=t.canvasGeometries;if(0===s.numViews)return!1;const i=this._view.state.contentPixelRatio;this._screenToWorldRatio=i*t.mapUnitsPerPixel/this._bindParameters.overlayStretch;const{output:n,content:o}=r;if(this.isEmpty||2===n&&!this.hasWater||!t.hasSomeSizedView())return!1;const{_rctx:a,_camera:h,_renderContext:d,_bindParameters:l}=this;if(h.pixelRatio=t.pixelRatio*i,this._setOutput(n),l.screenToWorldRatio=this._screenToWorldRatio,l.screenToPCSRatio=this._screenToWorldRatio*this.parent.worldToPCSRatio,4===o&&(d.renderOccludedMask=L),!this.renders(o))return d.renderOccludedMask=P,!1;const{resolution:c}=t,u=0===e,p=u?0:c;a.setViewport(p,0,c,c),this._bindTargetFBO(r),u&&(8===n?a.gl.clearBufferuiv(a.gl.COLOR,0,[0,0,0,0]):(a.setClearColor(0,0,0,0),a.clear(16384)));if(f.OVERLAY_DRAW_DEBUG_TEXTURE&&4!==o&&2!==o){this._techniques.precompile(E,z);const r=this._techniques.get(E,z);for(let i=0;i<s.numViews;i++)this._setViewParameters(s.extents[i],t),this._ensureDebugPatternResources(t.resolution,B[e]),a.bindTechnique(r,l,this._passParameters),a.screen.draw()}if(8===n){const{fboCache:t}=this._stage.renderer,s=this._resolution;this._bindTargetFBO(r),S(a,t,{width:s,height:s},l,()=>this._renderAllGeometry(e,r),p)}else this._renderAllGeometry(e,r);return a.bindFramebuffer(null),d.renderOccludedMask=P,!0}get allSourcesOccluders(){return i(this._renderers,e=>e.hasOnlyOccluders)}_renderAllGeometry(e,r){const t=this._overlays[e],s=t.canvasGeometries;this._sortedRenderers.forAll(({drapeSource:i,renderer:n})=>{if(1===r.content&&0===i.drapeSourceType)return;const{fullOpacity:o}=i,a=null!=o&&o<1&&0===r.output&&this._bindTemporaryFBO();for(let e=0;e<s.numViews;e++)this._setViewParameters(s.extents[e],t),n.render(this._renderContext);if(a){this._bindTargetFBO(r),this._overlayParameters.texture=a.getTexture(),this._overlayParameters.opacity=o,this._overlayParameters.overlayIndex=e;const t=this._techniques.get(q);this._rctx.bindTechnique(t,this._bindParameters,this._overlayParameters),this._rctx.screen.draw(),a.release()}})}_bindTargetFBO(e){const r=this._resolution,t=2*r;e.fbo.ensureFramebuffer(t,r),e.fbo.bind(this._rctx)}_bindTemporaryFBO(){const e=this._resolution,r=2*e,t=this._stage.renderer.fboCache,s=t.acquire(r,e,"overlay tmp");return t.rctx.bindFramebuffer(s.fbo),t.rctx.clear(16384),s}get _resolution(){return this._overlays?.[0].resolution??0}notifyContentChanged(){this.events.emit("content-changed")}intersect(e,r,t,s){this._sortedDrapeSourceRenderersDirty&&this._updateSortedDrapeSourceRenderers();let i=0;for(const{renderer:n}of this._sortedRenderers)i=n.intersect?.(e,r,t,s,i)??i}_updateSortedDrapeSourceRenderers(){if(this._sortedRenderers.clear(),0===this._renderers.size)return;const e=this._view.map.allLayers.map(e=>e.uid),r=e.length;this._renderers.forEach((t,s)=>{const i=e.indexOf(s.layer?.uid),n=i>=0,o=s.renderGroup??(n?0:1),a=s.drapeSourcePriorityOffset??0,h=r*o+(n?i:0)+a;this._sortedRenderers.push(new U(s,t,h))}),this._sortedRenderers.sort((e,r)=>e.index-r.index)}_setViewParameters(e,r){const t=this._camera;t.viewport=[0,0,r.resolution,r.resolution],_(t.projectionMatrix,0,e[2]-e[0],0,e[3]-e[1],t.near,t.far),g(t.viewMatrix,[-e[0],-e[1],0])}_ensureDebugPatternResources(e,r){if(m(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 n=0;n<e;n++)for(let r=0;r<e;r++){const i=Math.floor(r/10),o=Math.floor(n/10);i<2||o<2||10*i>e-20||10*o>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&o?1&r^1&n?0:255:1&i^1&o?0:128)}const i=new G(e);i.samplingMode=9728,this._passParameters.texture=new k(this._rctx,i,t)}get test(){}};e([u()],I.prototype,"hasHighlights",void 0),e([u()],I.prototype,"renderOccludedFlags",void 0),e([u()],I.prototype,"_sortedDrapeSourceRenderersDirty",void 0),e([u({constructOnly:!0})],I.prototype,"parent",void 0),e([u({readOnly:!0})],I.prototype,"_techniques",null),e([u({type:Boolean,readOnly:!0})],I.prototype,"updating",null),e([u()],I.prototype,"isEmpty",null),I=e([p("esri.views.3d.terrain.OverlayRenderer")],I);class U{constructor(e,r,t){this.drapeSource=e,this.renderer=r,this.index=t}}const B=[[1,.5,.5],[.5,.5,1]],H=-2,L=4,z=new M;z.hasAlpha=!0;export{I as OverlayRenderer,H as drapedZ,L 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/5.0/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,releaseMaybe as i}from"../../../core/maybe.js";import{D as s,H as o,B as a,e as n,n as l,g as d,a as g,G as h}from"../../../chunks/vec32.js";import{create as u,clone as m}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{containsXY as c}from"../../../geometry/support/aaBoundingRect.js";import{earth as f}from"../../../geometry/support/Ellipsoid.js";import{glLayout as p}from"../support/buffer/glUtil.js";import{GeometryState as y}from"./GeometryState.js";import{PatchGeometry as x}from"./PatchGeometry.js";import{maxTileNeighborLevelDelta as _}from"./TerrainConst.js";import{internalAssert as v,neighborEdgeIndices as $,oppositeEdge as E,neighborCornerIndices as C,enableTerrainInternalChecks as S,v32s as D,lij2s as b}from"./terrainUtils.js";import{TextureFader as j}from"./TextureFader.js";import{TextureReference as R}from"./TextureReference.js";import V from"./TileOverlayData.js";import{fallsWithinLayerView as T}from"./tileUtils.js";import{VertexArrayObject as w}from"../webgl-engine/lib/VertexArrayObject.js";import{BufferObject as A}from"../../webgl/BufferObject.js";import{VertexBuffer as P}from"../../webgl/VertexBuffer.js";class N{constructor(){this.geometry=new x,this.geometryState=null,this._texture=null,this._textureOpacity=1,this._textureRef=new j(()=>this._tile.surface.fadeDuration),this.overlay=new V,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 y,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),S&&this.tile.intersectsClippingArea)for(let t=0;t<4;++t)v(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.groundExtent;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=$[e];if(!t)return v(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(v(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)}v(!t.leaf);let a=i;return t.forAllSubtreeOnSide(E(o),e=>e===r||(e.loaded?(a=Math.max(a,2**(e.level-s)),!0):(v(!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($[a],i),l=X(e,n),d=l?.renderData?.geometryState.samplerDataVersion??-1,g=s[a],h=l!==X(e,g),u=o[a]!==d;S&&n&&(v(e.level>=n.level),v(e.level-n.level<=_)),s[a]=n,(h||u)&&(o[a]=d,this._markEdgeDirty(a));const m=r.edgeResolutions[a],c=this._calculateEdgeResolution(a,n);v(t(c)),v(c>=1),r.edgeResolutions[a]=c,m!==c&&this._markEdgeResolutionDirty(a)}for(let t=0;t<4;++t){const o=e.findNeighborTile(C[t],i);r.cornerPeerNeighbors[t]=o;const a=X(e,s[t]),n=X(e,s[(t+1)%4]),l=X(e,o);L[t]=l,L[(t+1)%4]=n,L[(t+2)%4]=e,L[(t+3)%4]=a,v(L.some(t=>t?.loaded||t===e));const d=L.reduce((e,t)=>Math.min(e,t?.level??1/0),1/0);L.forEach((e,t)=>{e&&e?.level>d&&(L[t]=null)}),v(L.some(t=>t?.loaded||t===e));const g=r.cornerNeighborCornerTiles,h=r.cornerNeighborCornerTileSamplerVersions;for(let e=0;e<4;++e){const r=L[e],i=r?.renderData.geometryState.samplerDataVersion??-1,s=4*t+e,o=g[s]!==r,a=!o&&h[s]!==i;(o||a)&&(g[s]=r,h[s]=i,this._markCornerDirty(t))}S&&v(Q.some(r=>g[4*t+r]?.loaded||g[4*t+r]===e))}S&&v(this.geometryState.edgeResolutions.every(e=>e>0));for(let t=0;t<4;++t)L[t]=null}_updateGeometry(e){if(!this.tile.intersectsClippingArea)return;S&&v(!this.tile.intersectsClippingArea||this.geometryState.edgeResolutions.every(e=>e>0)),this.intersectionData=null;const{tile:t,_vao:r,geometry:i,geometryState:s}=this,o=!r||!{}||this.wireframeChanged||this.samplerDataChanged||this.clippingAreaChanged||this.numVerticesPerSideChanged,a=0!==this.dirtyEdgeResolutions,n=s.edgeResolutions.reduce((e,t)=>e+t+1,0),l=o||a&&n>(i?.maxEdgeVertexCount??0),d=!l&&a,g=!d&&(0!==this.dirtyEdges||a),h=!g&&0!==this.dirtyCorners;l?(this.releaseGeometry(),this._createGeometry(e)):d?t.updateEdgeElevationsAndResolutions():g||h?t.updateEdgeElevations():h?t.updateCornerElevations():console.warn("Update for no reason?"),this._modifiedFlags=0}get hasGeometry(){return this._hasGeometry}releaseGeometry(){return this._hasGeometry=!1,this.intersectionData=null,!!this._vao&&(this._vao=r(this._vao),this.geometry.release(),!0)}ensureTexture(e,t,r,i){const s=t?6408:6407;return null!=this._texture&&(0===r&&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(){this._texture&&(this._texture=i(this._texture),this.tile.setMemoryDirty())}reuseTexture(e,t){return!(!e||!this._texture)&&(e.setTextureReference(new R(this._texture,0,t,this._textureOpacity,0,1)),!0)}get numVerticesPerSideChanged(){return 0!==(this._modifiedFlags&B)}get samplerDataChanged(){return 0!==(this._modifiedFlags&H)}get clippingAreaChanged(){return 0!==(this._modifiedFlags&W)}get wireframeChanged(){return 0!==(this._modifiedFlags&q)}get dirtyEdges(){return this._modifiedFlags>>z&15}get dirtyCorners(){return this._modifiedFlags>>J&15}get dirtyEdgeResolutions(){return this._modifiedFlags>>K&15}_markCornerDirty(e){const t=1<<e<<J;this._modifiedFlags|=t}_markEdgeDirty(e){const t=1<<e<<z;this._modifiedFlags|=t,this._markCornerDirty((e+0)%4),this._markCornerDirty((e+3)%4)}_markEdgeResolutionDirty(e){const t=1<<e<<K;this._modifiedFlags|=t,this._markEdgeDirty(e)}_markAllEdgesAndCornersDirty(){this._modifiedFlags|=15<<J|15<<z|15<<K}updateGeometryState(){const t=this._elevationInfo,r=this.tile,i=t.samplerData?r.getElevationVerticesPerSide(t.maxTileLevel):r.minimumVerticesPerSide,s=Math.max(i,5);let o=r.clippingArea;r.intersectsClippingArea&&!r.withinClippingArea||(o=null);const a=this.geometryState;let n=!1;a.numVerticesPerSide!==s&&(this._modifiedFlags|=1,a.numVerticesPerSide=s,a.samplerDataVersion++,n=!0),t.changed&&(this._modifiedFlags|=2,a.samplerData=t.samplerData,a.samplerDataVersion++,n=!0),e(a.clippingArea,o)||(this._modifiedFlags=4,a.clippingArea=o,n=!0);const l=r.surface.wireframe;return a.wireframe!==l&&(this._modifiedFlags=8,a.wireframe=l,n=!0),this._geometryStateChangedSinceLastUpdate||=n,n&&this._markAllEdgesAndCornersDirty(),this._hasGeometry=!0,this._geometryStateChangedSinceLastUpdate}_createGeometry(e){this.tile.createGeometry();const{vertexAttributes:t,indices:r}=this.geometry,i=e.gl;this._vao=new w(e,new P(e,p(t.layout),t.buffer),A.createIndex(e,i.STATIC_DRAW,r)),this._hasGeometry=!0}get vao(){return this._vao}setTextureReference(e,t=0){e?.texture===this._texture?this._textureOpacity=e.opacities[0]:this.releaseTexture(),this._textureRef.push(e,t)}get textureReference(){return this._textureRef.current}get nextTextureReference(){return this._textureRef.next}get textureFadeFactor(){return this._textureRef.fadeFactor}get textureIsFading(){return this._textureRef.isFading}_isTextureVisible(e){return this._textureRef.current?.texture===e||this._textureRef.next?.texture===e&&this._textureRef.fadeFactor<1}get _elevationInfo(){const e=this.geometryState.samplerData,t=this.tile.layerInfo[0],r=t.length,i=new Array(r);let s=0,o=0,a=!1;for(let d=0;d<r;d++){const r=t[d],n=r.upsampleInfo?.tile;if(n){const t=n.layerInfo[0][d].data,r=t&&t.samplerData;e&&e[s]===r||(a=!0),i[s++]=r,o=Math.max(o,n.lij[0])}else if(r.data){const t=this.tile.surface.layerViewByIndex(d,0);if(T(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(!S)return;const e=this.tile;if(!e.loaded||!e.intersectsClippingArea||0===e.level)return void v(e?.loaded);const r=e.surface.groundExtent;if(null!=r&&!e.intersectsExtent(r))return;const i=$.map((t,i)=>null!=r&&(i<2?-1:1)*(e.extent[3-i]-r[3-i])<0),p=e.level;v(0===this.dirtyCorners),v(0===this.dirtyEdges),v(0===this.dirtyEdgeResolutions),v(!this.numVerticesPerSideChanged),v(!this.samplerDataChanged),v(!this.clippingAreaChanged),v(!this.wireframeChanged);const y=C.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];v(i===r,`Tile[${e.lij}].corner[${t}] out of date: cur=[${r?.lij}] exp=[${i?.lij}]`)}$.forEach((r,y)=>{if(i[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 v(!t)}v(x.loaded||x.level===e.level),v(x===this.geometryState.edgePeerNeighbors[y]);const _=p-x.level;if(!x.loaded)return v(!x.leaf),void v(0===_);const $=x.renderData;v(e.isEdgeNeighbor(x,r)),v(_>=0);const E=2**_;if(_<0)return void v(!1);const C=e.renderData,S=C.geometry,j=C.localOrigin,R=S.getEdgeCount(y),V=S.numVerticesPerSide-1,T=$.geometry;if(!T)return void v(!1);const w=$.localOrigin,A=this.geometryState.edgePeerNeighbors[y];if(A?.loaded){const e=A.renderData;v(C.geometryState.edgePeerNeighborSamplerVersions[y]===e.geometryState.samplerDataVersion),v(this.geometryState.edgePeerNeighborSamplerVersions[y]===e.geometryState.samplerDataVersion)}const P=(y+2)%4,N=T.getEdgeCount(P),L=R-1,X=N-1;v(L*E===X,`Tile[${e.lij}]:e${y},res=${L} edgeRes mismatch with Neighbor[${x.lij}]:e${P},res=${X} (expected:${L*E})`);const B=e.extent,H=0===r||4===r,W=N-1,q=W>>_,z=R-1;if(q<1)return void v(1===z);v(q===z),v(t(q));const J=T.numVerticesPerSide-1;v(_>0||q===Math.max(J,V));const K=e.getNeighborEdgeStartVertexIndex(y,x);v(0<=K&&K<E);const Q=K*q;v(0<=Q&&Q<=W-q);let Y=0,Z=Q;S.getEdgeVertexPosition(y,F,j,0),S.getEdgeVertexPosition(y,G,j,R-1);const ee=s(F,G),te=Math.max(I,1e-4*ee);for(let t=0;t<=q;++t){S.getEdgeVertexPosition(y,F,j,Y),T.getEdgeVertexPosition(P,G,w,Z);const i=t/q,s=H?B[0]+i*(B[2]-B[0]):6===r?B[0]:B[2],p=H?4===r?B[1]:B[3]:B[1]+i*(B[3]-B[1]),_=e.surface.groundExtent;if(null==_||c(_,s,p)){const t=o(F,G),r=a(F)-f.radius,i=a(G)-f.radius,c=t<te;if(!c){console.warn(`Tile edge vertex position mismatch: between [${e.lij}].edge${y}[${Y}/${R}] and [${x.lij}].edge${P}[${Z}/${N}]`),null!=_&&console.warn(" surface extent= ",_," x,y=",s,",",p);const o=u();n(o,C.localOrigin,$.localOrigin),a(o)>0&&console.warn(` localOrigins: ${C.localOrigin} vs ${$.localOrigin} d=${a(o)} [${o}]`);(()=>{const t=m(F),r=m(G);e.updateEdgeElevations(),x.updateEdgeElevations(),S.getEdgeVertexPosition(y,F,j,Y),T.getEdgeVertexPosition(P,G,w,Z);const i=u();g(i,F,t),a(i)>0&&console.warn(` XXX Tile[${e.lij}] edge out of date: ${t} vs ${F} d=${a(i)} [${i}]`),g(i,G,r),a(i)>0&&console.warn(` XXX Neighbor[${x.lij}] edge out of date: ${r} vs ${G} d=${a(i)} [${i}]`)})();const l=S.getEdgeCount(y),d=T.getEdgeCount(N);v(c,`Mismatch in tile [${e.lij}].edge[${y}][${Y}/${l}] vs neighbor [${x.lij}].edge[${P}][${Z}/${d}] ${D(F)} vs ${D(G)} dist=${t} h(t|n|d)=${r}|${i}|${i-r}`)}S.getEdgeNormal(y,O,Y),T.getEdgeNormal(P,M,Z),l(k,O),l(U,M);const E=d(k,U),V=1-E<.01||!1||e===x;if(!V){const t=u();g(t,O,M);const r=()=>`Mismatch in tile edge normal ${b(e.lij)} (${Y}/${R-1}) edge ${y} vs neighbor ${b(x.lij)} (${Z}/${N-1}) nedge ${P} :${D(O)} vs ${D(M)} dot = ${E} : ${D(t)}`;console.warn("Mismatch in tile edge normal: ",r());{e.updateEdgeElevations(),x.updateEdgeElevations();const t=u(),r=u();S.getEdgeNormal(y,t,Y),T.getEdgeNormal(P,r,Z),h(O,t)||console.warn("Missing update in tile normal: ",D(O)," => ",D(t)),h(M,r)||console.warn("Missing update in neighbor normal: ",D(M)," => ",D(r))}v(V,r())}}Y+=1,Z+=1}})}}const F=u(),G=u(),O=u(),M=u(),k=u(),U=u(),I=1,L=[null,null,null,null];function X(e,t){return t?.loaded||t===e?t:null}const B=1,H=2,W=4,q=8,z=4,J=8,K=12,Q=[0,1,2,3];export{N as PatchRenderData,X as neighborTileIfLoadedOrSelf,Q 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,releaseMaybe as i}from"../../../core/maybe.js";import{C as s,G as o,H as a,e as n,n as l,g as d,a as g,F as h}from"../../../chunks/vec32.js";import{create as u,clone as m}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{containsXY as c}from"../../../geometry/support/aaBoundingRect.js";import{earth as f}from"../../../geometry/support/Ellipsoid.js";import{glLayout as p}from"../support/buffer/glUtil.js";import{GeometryState as y}from"./GeometryState.js";import{PatchGeometry as x}from"./PatchGeometry.js";import{maxTileNeighborLevelDelta as _}from"./TerrainConst.js";import{internalAssert as v,neighborEdgeIndices as $,oppositeEdge as E,neighborCornerIndices as C,enableTerrainInternalChecks as S,v32s as D,lij2s as b}from"./terrainUtils.js";import{TextureFader as j}from"./TextureFader.js";import{TextureReference as R}from"./TextureReference.js";import V from"./TileOverlayData.js";import{fallsWithinLayerView as T}from"./tileUtils.js";import{VertexArrayObject as w}from"../webgl-engine/lib/VertexArrayObject.js";import{BufferObject as A}from"../../webgl/BufferObject.js";import{VertexBuffer as P}from"../../webgl/VertexBuffer.js";class F{constructor(){this.geometry=new x,this.geometryState=null,this._texture=null,this._textureOpacity=1,this._textureRef=new j(()=>this._tile.surface.fadeDuration),this.overlay=new V,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 y,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),S&&this.tile.intersectsClippingArea)for(let t=0;t<4;++t)v(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.groundExtent;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=$[e];if(!t)return v(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(v(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)}v(!t.leaf);let a=i;return t.forAllSubtreeOnSide(E(o),e=>e===r||(e.loaded?(a=Math.max(a,2**(e.level-s)),!0):(v(!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($[a],i),l=X(e,n),d=l?.renderData?.geometryState.samplerDataVersion??-1,g=s[a],h=l!==X(e,g),u=o[a]!==d;S&&n&&(v(e.level>=n.level),v(e.level-n.level<=_)),s[a]=n,(h||u)&&(o[a]=d,this._markEdgeDirty(a));const m=r.edgeResolutions[a],c=this._calculateEdgeResolution(a,n);v(t(c)),v(c>=1),r.edgeResolutions[a]=c,m!==c&&this._markEdgeResolutionDirty(a)}for(let t=0;t<4;++t){const o=e.findNeighborTile(C[t],i);r.cornerPeerNeighbors[t]=o;const a=X(e,s[t]),n=X(e,s[(t+1)%4]),l=X(e,o);L[t]=l,L[(t+1)%4]=n,L[(t+2)%4]=e,L[(t+3)%4]=a,v(L.some(t=>t?.loaded||t===e));const d=L.reduce((e,t)=>Math.min(e,t?.level??1/0),1/0);L.forEach((e,t)=>{e&&e?.level>d&&(L[t]=null)}),v(L.some(t=>t?.loaded||t===e));const g=r.cornerNeighborCornerTiles,h=r.cornerNeighborCornerTileSamplerVersions;for(let e=0;e<4;++e){const r=L[e],i=r?.renderData.geometryState.samplerDataVersion??-1,s=4*t+e,o=g[s]!==r,a=!o&&h[s]!==i;(o||a)&&(g[s]=r,h[s]=i,this._markCornerDirty(t))}S&&v(Q.some(r=>g[4*t+r]?.loaded||g[4*t+r]===e))}S&&v(this.geometryState.edgeResolutions.every(e=>e>0));for(let t=0;t<4;++t)L[t]=null}_updateGeometry(e){if(!this.tile.intersectsClippingArea)return;S&&v(!this.tile.intersectsClippingArea||this.geometryState.edgeResolutions.every(e=>e>0)),this.intersectionData=null;const{tile:t,_vao:r,geometry:i,geometryState:s}=this,o=!r||!{}||this.wireframeChanged||this.samplerDataChanged||this.clippingAreaChanged||this.numVerticesPerSideChanged,a=0!==this.dirtyEdgeResolutions,n=s.edgeResolutions.reduce((e,t)=>e+t+1,0),l=o||a&&n>(i?.maxEdgeVertexCount??0),d=!l&&a,g=!d&&(0!==this.dirtyEdges||a),h=!g&&0!==this.dirtyCorners;l?(this.releaseGeometry(),this._createGeometry(e)):d?t.updateEdgeElevationsAndResolutions():g||h?t.updateEdgeElevations():h?t.updateCornerElevations():console.warn("Update for no reason?"),this._modifiedFlags=0}get hasGeometry(){return this._hasGeometry}releaseGeometry(){return this._hasGeometry=!1,this.intersectionData=null,!!this._vao&&(this._vao=r(this._vao),this.geometry.release(),!0)}ensureTexture(e,t,r,i){const s=t?6408:6407;return null!=this._texture&&(0===r&&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(){this._texture&&(this._texture=i(this._texture),this.tile.setMemoryDirty())}reuseTexture(e,t){return!(!e||!this._texture)&&(e.setTextureReference(new R(this._texture,0,t,this._textureOpacity,0,1)),!0)}get numVerticesPerSideChanged(){return 0!==(this._modifiedFlags&B)}get samplerDataChanged(){return 0!==(this._modifiedFlags&H)}get clippingAreaChanged(){return 0!==(this._modifiedFlags&W)}get wireframeChanged(){return 0!==(this._modifiedFlags&q)}get dirtyEdges(){return this._modifiedFlags>>z&15}get dirtyCorners(){return this._modifiedFlags>>J&15}get dirtyEdgeResolutions(){return this._modifiedFlags>>K&15}_markCornerDirty(e){const t=1<<e<<J;this._modifiedFlags|=t}_markEdgeDirty(e){const t=1<<e<<z;this._modifiedFlags|=t,this._markCornerDirty((e+0)%4),this._markCornerDirty((e+3)%4)}_markEdgeResolutionDirty(e){const t=1<<e<<K;this._modifiedFlags|=t,this._markEdgeDirty(e)}_markAllEdgesAndCornersDirty(){this._modifiedFlags|=15<<J|15<<z|15<<K}updateGeometryState(){const t=this._elevationInfo,r=this.tile,i=t.samplerData?r.getElevationVerticesPerSide(t.maxTileLevel):r.minimumVerticesPerSide,s=Math.max(i,5);let o=r.clippingArea;r.intersectsClippingArea&&!r.withinClippingArea||(o=null);const a=this.geometryState;let n=!1;a.numVerticesPerSide!==s&&(this._modifiedFlags|=1,a.numVerticesPerSide=s,a.samplerDataVersion++,n=!0),t.changed&&(this._modifiedFlags|=2,a.samplerData=t.samplerData,a.samplerDataVersion++,n=!0),e(a.clippingArea,o)||(this._modifiedFlags=4,a.clippingArea=o,n=!0);const l=r.surface.wireframe;return a.wireframe!==l&&(this._modifiedFlags=8,a.wireframe=l,n=!0),this._geometryStateChangedSinceLastUpdate||=n,n&&this._markAllEdgesAndCornersDirty(),this._hasGeometry=!0,this._geometryStateChangedSinceLastUpdate}_createGeometry(e){this.tile.createGeometry();const{vertexAttributes:t,indices:r}=this.geometry,i=e.gl;this._vao=new w(e,new P(e,p(t.layout),t.buffer),A.createIndex(e,i.STATIC_DRAW,r)),this._hasGeometry=!0}get vao(){return this._vao}setTextureReference(e,t=0){e?.texture===this._texture?this._textureOpacity=e.opacities[0]:this.releaseTexture(),this._textureRef.push(e,t)}get textureReference(){return this._textureRef.current}get nextTextureReference(){return this._textureRef.next}get textureFadeFactor(){return this._textureRef.fadeFactor}get textureIsFading(){return this._textureRef.isFading}_isTextureVisible(e){return this._textureRef.current?.texture===e||this._textureRef.next?.texture===e&&this._textureRef.fadeFactor<1}get _elevationInfo(){const e=this.geometryState.samplerData,t=this.tile.layerInfo[0],r=t.length,i=new Array(r);let s=0,o=0,a=!1;for(let d=0;d<r;d++){const r=t[d],n=r.upsampleInfo?.tile;if(n){const t=n.layerInfo[0][d].data,r=t&&t.samplerData;e&&e[s]===r||(a=!0),i[s++]=r,o=Math.max(o,n.lij[0])}else if(r.data){const t=this.tile.surface.layerViewByIndex(d,0);if(T(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(!S)return;const e=this.tile;if(!e.loaded||!e.intersectsClippingArea||0===e.level)return void v(e?.loaded);const r=e.surface.groundExtent;if(null!=r&&!e.intersectsExtent(r))return;const i=$.map((t,i)=>null!=r&&(i<2?-1:1)*(e.extent[3-i]-r[3-i])<0),p=e.level;v(0===this.dirtyCorners),v(0===this.dirtyEdges),v(0===this.dirtyEdgeResolutions),v(!this.numVerticesPerSideChanged),v(!this.samplerDataChanged),v(!this.clippingAreaChanged),v(!this.wireframeChanged);const y=C.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];v(i===r,`Tile[${e.lij}].corner[${t}] out of date: cur=[${r?.lij}] exp=[${i?.lij}]`)}$.forEach((r,y)=>{if(i[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 v(!t)}v(x.loaded||x.level===e.level),v(x===this.geometryState.edgePeerNeighbors[y]);const _=p-x.level;if(!x.loaded)return v(!x.leaf),void v(0===_);const $=x.renderData;v(e.isEdgeNeighbor(x,r)),v(_>=0);const E=2**_;if(_<0)return void v(!1);const C=e.renderData,S=C.geometry,j=C.localOrigin,R=S.getEdgeCount(y),V=S.numVerticesPerSide-1,T=$.geometry;if(!T)return void v(!1);const w=$.localOrigin,A=this.geometryState.edgePeerNeighbors[y];if(A?.loaded){const e=A.renderData;v(C.geometryState.edgePeerNeighborSamplerVersions[y]===e.geometryState.samplerDataVersion),v(this.geometryState.edgePeerNeighborSamplerVersions[y]===e.geometryState.samplerDataVersion)}const P=(y+2)%4,F=T.getEdgeCount(P),L=R-1,X=F-1;v(L*E===X,`Tile[${e.lij}]:e${y},res=${L} edgeRes mismatch with Neighbor[${x.lij}]:e${P},res=${X} (expected:${L*E})`);const B=e.extent,H=0===r||4===r,W=F-1,q=W>>_,z=R-1;if(q<1)return void v(1===z);v(q===z),v(t(q));const J=T.numVerticesPerSide-1;v(_>0||q===Math.max(J,V));const K=e.getNeighborEdgeStartVertexIndex(y,x);v(0<=K&&K<E);const Q=K*q;v(0<=Q&&Q<=W-q);let Y=0,Z=Q;S.getEdgeVertexPosition(y,N,j,0),S.getEdgeVertexPosition(y,G,j,R-1);const ee=s(N,G),te=Math.max(I,1e-4*ee);for(let t=0;t<=q;++t){S.getEdgeVertexPosition(y,N,j,Y),T.getEdgeVertexPosition(P,G,w,Z);const i=t/q,s=H?B[0]+i*(B[2]-B[0]):6===r?B[0]:B[2],p=H?4===r?B[1]:B[3]:B[1]+i*(B[3]-B[1]),_=e.surface.groundExtent;if(null==_||c(_,s,p)){const t=o(N,G),r=a(N)-f.radius,i=a(G)-f.radius,c=t<te;if(!c){console.warn(`Tile edge vertex position mismatch: between [${e.lij}].edge${y}[${Y}/${R}] and [${x.lij}].edge${P}[${Z}/${F}]`),null!=_&&console.warn(" surface extent= ",_," x,y=",s,",",p);const o=u();n(o,C.localOrigin,$.localOrigin),a(o)>0&&console.warn(` localOrigins: ${C.localOrigin} vs ${$.localOrigin} d=${a(o)} [${o}]`);(()=>{const t=m(N),r=m(G);e.updateEdgeElevations(),x.updateEdgeElevations(),S.getEdgeVertexPosition(y,N,j,Y),T.getEdgeVertexPosition(P,G,w,Z);const i=u();g(i,N,t),a(i)>0&&console.warn(` XXX Tile[${e.lij}] edge out of date: ${t} vs ${N} d=${a(i)} [${i}]`),g(i,G,r),a(i)>0&&console.warn(` XXX Neighbor[${x.lij}] edge out of date: ${r} vs ${G} d=${a(i)} [${i}]`)})();const l=S.getEdgeCount(y),d=T.getEdgeCount(F);v(c,`Mismatch in tile [${e.lij}].edge[${y}][${Y}/${l}] vs neighbor [${x.lij}].edge[${P}][${Z}/${d}] ${D(N)} vs ${D(G)} dist=${t} h(t|n|d)=${r}|${i}|${i-r}`)}S.getEdgeNormal(y,O,Y),T.getEdgeNormal(P,M,Z),l(k,O),l(U,M);const E=d(k,U),V=1-E<.01||!1||e===x;if(!V){const t=u();g(t,O,M);const r=()=>`Mismatch in tile edge normal ${b(e.lij)} (${Y}/${R-1}) edge ${y} vs neighbor ${b(x.lij)} (${Z}/${F-1}) nedge ${P} :${D(O)} vs ${D(M)} dot = ${E} : ${D(t)}`;console.warn("Mismatch in tile edge normal: ",r());{e.updateEdgeElevations(),x.updateEdgeElevations();const t=u(),r=u();S.getEdgeNormal(y,t,Y),T.getEdgeNormal(P,r,Z),h(O,t)||console.warn("Missing update in tile normal: ",D(O)," => ",D(t)),h(M,r)||console.warn("Missing update in neighbor normal: ",D(M)," => ",D(r))}v(V,r())}}Y+=1,Z+=1}})}}const N=u(),G=u(),O=u(),M=u(),k=u(),U=u(),I=1,L=[null,null,null,null];function X(e,t){return t?.loaded||t===e?t:null}const B=1,H=2,W=4,q=8,z=4,J=8,K=12,Q=[0,1,2,3];export{F as PatchRenderData,X as neighborTileIfLoadedOrSelf,Q as zeroToFour};