@arcgis/core 4.34.0-next.50 → 4.34.0-next.51

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 (256) hide show
  1. package/analysis/ElevationProfile/GroundLine.d.ts +4 -0
  2. package/analysis/ElevationProfile/GroundLine.js +5 -0
  3. package/analysis/ElevationProfile/InputLine.d.ts +4 -0
  4. package/analysis/ElevationProfile/InputLine.js +5 -0
  5. package/analysis/ElevationProfile/Line.d.ts +4 -0
  6. package/analysis/ElevationProfile/Line.js +5 -0
  7. package/analysis/ElevationProfile/LineChartOptions.d.ts +4 -0
  8. package/analysis/ElevationProfile/LineChartOptions.js +5 -0
  9. package/analysis/ElevationProfile/LineViewOptions.d.ts +4 -0
  10. package/analysis/ElevationProfile/LineViewOptions.js +5 -0
  11. package/analysis/ElevationProfile/QueryLine.d.ts +4 -0
  12. package/analysis/ElevationProfile/QueryLine.js +5 -0
  13. package/analysis/ElevationProfile/SceneLine.d.ts +4 -0
  14. package/analysis/ElevationProfile/SceneLine.js +5 -0
  15. package/analysis/ElevationProfile/Units.d.ts +4 -0
  16. package/analysis/ElevationProfile/Units.js +5 -0
  17. package/analysis/ElevationProfile/ViewOptions.d.ts +4 -0
  18. package/analysis/ElevationProfile/ViewOptions.js +5 -0
  19. package/analysis/ElevationProfile/elevationProfileLineTypes.js +5 -0
  20. package/analysis/ElevationProfileAnalysis.js +1 -1
  21. package/assets/esri/core/workers/RemoteClient.js +1 -1
  22. package/assets/esri/core/workers/chunks/{7bd672e534cde0d5787d.js → 0021118bafefd1e47ff7.js} +1 -1
  23. package/assets/esri/core/workers/chunks/{0b52c0ca432761076076.js → 081b22fa73ef7b696409.js} +2 -2
  24. package/assets/esri/core/workers/chunks/0a6d33d013628f671aea.js +1 -0
  25. package/assets/esri/core/workers/chunks/0ce671588de2858516d2.js +1 -0
  26. package/assets/esri/core/workers/chunks/14c6ae4feb4859cfa7c5.js +1 -0
  27. package/assets/esri/core/workers/chunks/20a2b3d1f826e9059884.js +1 -0
  28. package/assets/esri/core/workers/chunks/{c4651243525026e6ddde.js → 2da12a64d3baef4aaaa1.js} +1 -1
  29. package/assets/esri/core/workers/chunks/{3610357c8fa9bec9e0dc.js → 30169cf969d36ea8654e.js} +1 -1
  30. package/assets/esri/core/workers/chunks/{5b0c42bb95d81085061d.js → 35fc8a64674005b1d1d7.js} +1 -1
  31. package/assets/esri/core/workers/chunks/37a97e690786814bf0b3.js +1 -0
  32. package/assets/esri/core/workers/chunks/38f84294fb2fb4663ba5.js +1 -0
  33. package/assets/esri/core/workers/chunks/3eb3af0b6cf3c2f28131.js +1 -0
  34. package/assets/esri/core/workers/chunks/48e64f99720907017778.js +1 -0
  35. package/assets/esri/core/workers/chunks/4bd92232928b832dea76.js +1 -0
  36. package/assets/esri/core/workers/chunks/50e9eafb118d2a221f10.js +1 -0
  37. package/assets/esri/core/workers/chunks/55588e668b6acb6aa390.js +1 -0
  38. package/assets/esri/core/workers/chunks/5b112471dca94b2e8462.js +1 -0
  39. package/assets/esri/core/workers/chunks/5dfe1aed10095385c066.js +1 -0
  40. package/assets/esri/core/workers/chunks/7389841fabe0f319f1e5.js +1 -0
  41. package/assets/esri/core/workers/chunks/77493aa2118d462612a0.js +1 -0
  42. package/assets/esri/core/workers/chunks/7a8d740d1226719a578a.js +1 -0
  43. package/assets/esri/core/workers/chunks/8e0559cc6295008fcdf7.js +1 -0
  44. package/assets/esri/core/workers/chunks/{69e37365c17e7cc4168f.js → 93af38d29d066f27ed28.js} +1 -1
  45. package/assets/esri/core/workers/chunks/944fa8261aad94ae0542.js +1 -0
  46. package/assets/esri/core/workers/chunks/{6775d2ab5faf1fa161db.js → 97a38d700f2cb8807d51.js} +1 -1
  47. package/assets/esri/core/workers/chunks/{45121b7258333c8ebbdb.js → 98ea12c7a000a30f3dc0.js} +1 -1
  48. package/assets/esri/core/workers/chunks/9e479e7e2e51476c3d27.js +1 -0
  49. package/assets/esri/core/workers/chunks/a1e179dd6de9c8769b02.js +1 -0
  50. package/assets/esri/core/workers/chunks/a829969ed44cdb814f27.js +1 -0
  51. package/assets/esri/core/workers/chunks/ac41b882f9cbf8d56f0c.js +1 -0
  52. package/assets/esri/core/workers/chunks/b0ee061747bef6729bb9.js +1 -0
  53. package/assets/esri/core/workers/chunks/b2a035befeeff1a55ad8.js +1 -0
  54. package/assets/esri/core/workers/chunks/ba45dccb4dab5a74d224.js +1 -0
  55. package/assets/esri/core/workers/chunks/c5b2a261d8c216ca4a10.js +1 -0
  56. package/assets/esri/core/workers/chunks/{edc4f230a5bdf928f9fd.js → d1aeb9fe9eb573beefcc.js} +2 -2
  57. package/assets/esri/core/workers/chunks/e3f68f7b408a08d7cd5d.js +1 -0
  58. package/assets/esri/core/workers/chunks/e9716995ce0c3683eafc.js +1 -0
  59. package/assets/esri/core/workers/chunks/{4cc982c99d84e896d535.js → ed25bf087f52e5d3e71b.js} +1 -1
  60. package/assets/esri/core/workers/chunks/f92e608931b1c168cb45.js +1 -0
  61. package/assets/esri/core/workers/chunks/f9f94b5efa9a64cdb407.js +1 -0
  62. package/assets/esri/core/workers/chunks/fb4950995f6780f6c22a.js +1 -0
  63. package/assets/esri/themes/base/widgets/_VideoPlayer.scss +16 -2
  64. package/assets/esri/themes/dark/main.css +1 -1
  65. package/assets/esri/themes/light/main.css +1 -1
  66. package/assets/esri/themes/light/view.css +1 -1
  67. package/chunks/Laserlines.glsl.js +12 -12
  68. package/chunks/sphere.js +1 -1
  69. package/chunks/vec42.js +1 -1
  70. package/config.js +1 -1
  71. package/core/libs/gl-matrix-2/math/quat.js +1 -1
  72. package/core/libs/gl-matrix-2/math/vec4.js +1 -1
  73. package/geometry/projection/projectBoundingSphere.js +1 -1
  74. package/geometry/support/DoubleArray.js +1 -1
  75. package/geometry/support/aaBoundingRect.js +1 -1
  76. package/geometry/support/curves/bezierCurveUtils.js +1 -1
  77. package/geometry/support/curves/circleUtils.js +1 -1
  78. package/geometry/support/curves/ellipticArc4Utils.js +1 -1
  79. package/geometry/support/curves/ellipticArc7Utils.js +1 -1
  80. package/geometry/support/curves/mathUtils.js +1 -1
  81. package/geometry/support/sphere.js +1 -1
  82. package/interfaces.d.ts +271 -279
  83. package/kernel.js +1 -1
  84. package/layers/graphics/sources/support/ParquetSourceWorker.js +1 -1
  85. package/layers/mixins/ArcGISImageService.js +1 -1
  86. package/layers/support/rasterFunctions/pixelUtils.js +1 -1
  87. package/package.json +1 -1
  88. package/support/revision.js +1 -1
  89. package/views/2d/engine/imagery/RasterBitmap.js +1 -1
  90. package/views/2d/engine/imagery/RasterTileContainer.js +1 -1
  91. package/views/2d/engine/webgl/shaderGraph/techniques/raster/RasterColorizerTechnique.js +1 -1
  92. package/views/2d/engine/webgl/shaderGraph/techniques/raster/RasterHighlightTechnique.js +5 -0
  93. package/views/2d/engine/webgl/shaderGraph/techniques/raster/processor/AspectTechnique.js +1 -1
  94. package/views/2d/engine/webgl/shaderGraph/techniques/raster/processor/BandArithmeticTechnique.js +1 -1
  95. package/views/2d/engine/webgl/shaderGraph/techniques/raster/processor/BaseRasterProcessorTechnique.js +1 -1
  96. package/views/2d/engine/webgl/shaderGraph/techniques/raster/processor/ColormapToRGBTechnique.js +1 -1
  97. package/views/2d/engine/webgl/shaderGraph/techniques/raster/processor/CompositeBandTechnique.js +1 -1
  98. package/views/2d/engine/webgl/shaderGraph/techniques/raster/processor/ComputeChangeTechnique.js +1 -1
  99. package/views/2d/engine/webgl/shaderGraph/techniques/raster/processor/ContrastBrightnessTechnique.js +1 -1
  100. package/views/2d/engine/webgl/shaderGraph/techniques/raster/processor/ConvolutionTechnique.js +1 -1
  101. package/views/2d/engine/webgl/shaderGraph/techniques/raster/processor/CurvatureTechnique.js +1 -1
  102. package/views/2d/engine/webgl/shaderGraph/techniques/raster/processor/ExtractBandTechnique.js +1 -1
  103. package/views/2d/engine/webgl/shaderGraph/techniques/raster/processor/FocalStatisticsTechnique.js +1 -1
  104. package/views/2d/engine/webgl/shaderGraph/techniques/raster/processor/GrayscaleTechnique.js +1 -1
  105. package/views/2d/engine/webgl/shaderGraph/techniques/raster/processor/HillshadeTechnique.js +1 -1
  106. package/views/2d/engine/webgl/shaderGraph/techniques/raster/processor/LocalTechnique.js +1 -1
  107. package/views/2d/engine/webgl/shaderGraph/techniques/raster/processor/MaskTechnique.js +1 -1
  108. package/views/2d/engine/webgl/shaderGraph/techniques/raster/processor/NDVITechnique.js +1 -1
  109. package/views/2d/engine/webgl/shaderGraph/techniques/raster/processor/RemapTechnique.js +1 -1
  110. package/views/2d/engine/webgl/shaderGraph/techniques/raster/processor/ReprojectTechnique.js +1 -1
  111. package/views/2d/engine/webgl/shaderGraph/techniques/raster/processor/ShadedReliefTechnique.js +1 -1
  112. package/views/2d/engine/webgl/shaderGraph/techniques/raster/processor/SlopeTechnique.js +1 -1
  113. package/views/2d/engine/webgl/shaderGraph/techniques/raster/processor/StretchTechnique.js +1 -1
  114. package/views/2d/engine/webgl/shaderGraph/techniques/raster/processor/textureUtils.js +1 -1
  115. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/raster/BaseRasterColorizerShader.js +1 -1
  116. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/raster/RasterRangeHighlightShader.js +5 -0
  117. package/views/2d/layers/ImageryLayerView2D.js +1 -1
  118. package/views/2d/layers/ImageryTileLayerView2D.js +1 -1
  119. package/views/2d/layers/imagery/ImageryTileView2D.js +1 -1
  120. package/views/2d/layers/imagery/ImageryView2D.js +1 -1
  121. package/views/3d/analysis/ElevationProfile/ProfileLinesVisualization.js +1 -1
  122. package/views/3d/analysis/ElevationProfile/SceneLineComputation.js +5 -0
  123. package/views/3d/analysis/ElevationProfileAnalysisView3D.js +1 -1
  124. package/views/3d/analysis/VolumeMeasurement/CutFillVolumeMeasurementController.js +1 -1
  125. package/views/3d/analysis/support/measurementUtils.js +1 -1
  126. package/views/3d/camera/constraintUtils/distance.js +1 -1
  127. package/views/3d/camera/constraintUtils/tilt.js +1 -1
  128. package/views/3d/interactive/visualElements/ExtendedLineVisualElement.js +1 -1
  129. package/views/3d/interactive/visualElements/MeasurementAreaVisualElement.js +1 -1
  130. package/views/3d/interactive/visualElements/MeasurementArrowVisualElement.js +1 -1
  131. package/views/3d/interactive/visualElements/OutlineVisualElement.js +1 -1
  132. package/views/3d/interactive/visualElements/ParallelLineVisualElement.js +1 -1
  133. package/views/3d/interactive/visualElements/PointVisualElement.js +1 -1
  134. package/views/3d/interactive/visualElements/RightAngleQuadVisualElement.js +1 -1
  135. package/views/3d/interactive/visualElements/SlicePlaneVisualElement.js +1 -1
  136. package/views/3d/interactive/visualElements/VerticesVisualElement.js +1 -1
  137. package/views/3d/layers/I3SMeshView3D.js +1 -1
  138. package/views/3d/layers/SceneLayerWorker.js +1 -1
  139. package/views/3d/layers/graphics/Deconflictor.js +1 -1
  140. package/views/3d/layers/graphics/Graphics3DLineSymbolLayer.js +1 -1
  141. package/views/3d/layers/graphics/Graphics3DSymbolLayer.js +1 -1
  142. package/views/3d/layers/graphics/Graphics3DWaterSymbolLayer.js +1 -1
  143. package/views/3d/layers/graphics/graphicUtils.js +1 -1
  144. package/views/3d/layers/i3s/I3SClientNodeLoader.js +1 -1
  145. package/views/3d/layers/i3s/I3SIndex.js +1 -1
  146. package/views/3d/layers/i3s/I3SProjectionUtil.js +1 -1
  147. package/views/3d/layers/i3s/I3SViewportQueries.js +1 -1
  148. package/views/3d/layers/support/FastSymbolUpdates.js +1 -1
  149. package/views/3d/state/NearFarHeuristic.js +1 -1
  150. package/views/3d/state/ViewStateManager.js +1 -1
  151. package/views/3d/state/controllers/GamepadKeyboardController.js +1 -1
  152. package/views/3d/state/utils/navigationUtils.js +1 -1
  153. package/views/3d/support/flow/FlowSubViewTiles3D.js +1 -1
  154. package/views/3d/support/orientedBoundingBox.js +1 -1
  155. package/views/3d/terrain/OverlayManager.js +1 -1
  156. package/views/3d/terrain/ScaleRangeQueries.js +1 -1
  157. package/views/3d/terrain/SphericalPatch.js +1 -1
  158. package/views/3d/terrain/TerrainSurface.js +1 -1
  159. package/views/3d/terrain/Tile.js +1 -1
  160. package/views/3d/webgl/RenderCamera.js +1 -1
  161. package/views/3d/webgl-engine/Stage.js +1 -1
  162. package/views/3d/webgl-engine/lib/MainFramebuffer.js +1 -1
  163. package/views/3d/webgl-engine/lib/Object3D.js +1 -1
  164. package/views/3d/webgl-engine/lib/Octree.js +1 -1
  165. package/views/3d/webgl-engine/lib/PathGeometryData.js +1 -1
  166. package/views/3d/webgl-engine/lib/RenderGeometry.js +1 -1
  167. package/views/3d/webgl-engine/lib/ShadowCastRenderer.js +1 -1
  168. package/views/3d/webgl-engine/lib/Viewshed.js +1 -1
  169. package/views/3d/webgl-engine/lib/depthRangeUtils.js +1 -1
  170. package/views/3d/webgl-engine/lib/lodRendering/InstanceOctree.js +1 -1
  171. package/views/3d/webgl-engine/lib/screenSizePerspectiveUtils.js +1 -1
  172. package/views/3d/webgl-engine/lib/verticalOffsetUtils.js +1 -1
  173. package/views/analysis/ElevationProfile/Controller.js +5 -0
  174. package/views/analysis/ElevationProfile/GroundLineComputation.js +5 -0
  175. package/views/analysis/ElevationProfile/InputLineComputation.js +5 -0
  176. package/views/analysis/ElevationProfile/LineComputation.js +5 -0
  177. package/views/analysis/ElevationProfile/QueryLineComputation.js +5 -0
  178. package/views/analysis/ElevationProfile/Result.d.ts +4 -0
  179. package/views/analysis/{ElevationProfileResult.js → ElevationProfile/Result.js} +1 -1
  180. package/views/interactive/coordinateHelper.js +1 -1
  181. package/views/interactive/editGeometry/operations/curveOperationUtils.js +1 -1
  182. package/views/interactive/sketch/constraints.js +1 -1
  183. package/views/interactive/snapping/featureSources/sceneLayerSource/SceneLayerSnappingSourceWorker.js +1 -1
  184. package/views/interactive/snapping/featureSources/sceneLayerSource/sceneLayerSnappingUtils.js +1 -1
  185. package/views/support/LayerLayerViewInfo.js +1 -1
  186. package/views/support/LayerViewManager.js +1 -1
  187. package/widgets/ElevationProfile/ElevationProfileLine.d.ts +2 -2
  188. package/widgets/ElevationProfile/ElevationProfileLineGround.d.ts +2 -2
  189. package/widgets/ElevationProfile/ElevationProfileLineInput.d.ts +2 -2
  190. package/widgets/ElevationProfile/ElevationProfileLineQuery.d.ts +2 -2
  191. package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
  192. package/widgets/OrientedImageryViewer/imageMeasurementUtils.js +1 -1
  193. package/widgets/OrientedImageryViewer/services/ImageMeasurementService.js +5 -0
  194. package/widgets/VideoPlayer/components/PlayerActionsGroup.js +1 -1
  195. package/widgets/VideoPlayer/css.js +1 -1
  196. package/widgets/VideoPlayer.js +1 -1
  197. package/analysis/ElevationProfileLine.d.ts +0 -4
  198. package/analysis/ElevationProfileLine.js +0 -5
  199. package/analysis/ElevationProfileLineChartOptions.d.ts +0 -4
  200. package/analysis/ElevationProfileLineChartOptions.js +0 -5
  201. package/analysis/ElevationProfileLineGround.d.ts +0 -4
  202. package/analysis/ElevationProfileLineGround.js +0 -5
  203. package/analysis/ElevationProfileLineInput.d.ts +0 -4
  204. package/analysis/ElevationProfileLineInput.js +0 -5
  205. package/analysis/ElevationProfileLineQuery.d.ts +0 -4
  206. package/analysis/ElevationProfileLineQuery.js +0 -5
  207. package/analysis/ElevationProfileLineScene.d.ts +0 -4
  208. package/analysis/ElevationProfileLineScene.js +0 -5
  209. package/analysis/ElevationProfileLineViewOptions.d.ts +0 -4
  210. package/analysis/ElevationProfileLineViewOptions.js +0 -5
  211. package/analysis/ElevationProfileUnits.d.ts +0 -4
  212. package/analysis/ElevationProfileUnits.js +0 -5
  213. package/analysis/ElevationProfileViewOptions.d.ts +0 -4
  214. package/analysis/ElevationProfileViewOptions.js +0 -5
  215. package/analysis/support/elevationProfileLineTypes.js +0 -5
  216. package/assets/esri/core/workers/chunks/21a90083f29e44ccd735.js +0 -1
  217. package/assets/esri/core/workers/chunks/224872bfd923cf4c9d78.js +0 -1
  218. package/assets/esri/core/workers/chunks/237c96d946efa5ed0386.js +0 -1
  219. package/assets/esri/core/workers/chunks/2942ab268f24cea2e722.js +0 -1
  220. package/assets/esri/core/workers/chunks/32789077e37d5c8191e7.js +0 -1
  221. package/assets/esri/core/workers/chunks/3e3886a51c0f8c86df75.js +0 -1
  222. package/assets/esri/core/workers/chunks/6d786fac4bb5efcb7acc.js +0 -1
  223. package/assets/esri/core/workers/chunks/7b95da70d39ba316b051.js +0 -1
  224. package/assets/esri/core/workers/chunks/7df8c78e36b04ad657d2.js +0 -1
  225. package/assets/esri/core/workers/chunks/838c7fd37b2e78b1d582.js +0 -1
  226. package/assets/esri/core/workers/chunks/8c6119dde0eead8d90d9.js +0 -1
  227. package/assets/esri/core/workers/chunks/8c8c8f1058a4b58a3181.js +0 -1
  228. package/assets/esri/core/workers/chunks/8f70650aba8e55eb7a96.js +0 -1
  229. package/assets/esri/core/workers/chunks/96a34b240d17147902f4.js +0 -1
  230. package/assets/esri/core/workers/chunks/9af47a4da3a0b84f1add.js +0 -1
  231. package/assets/esri/core/workers/chunks/9affcf990ea810fa426b.js +0 -1
  232. package/assets/esri/core/workers/chunks/a3dce23ca98c9b0f945f.js +0 -1
  233. package/assets/esri/core/workers/chunks/a50026e567b1edff87c6.js +0 -1
  234. package/assets/esri/core/workers/chunks/a7ff44157b8cf19de37e.js +0 -1
  235. package/assets/esri/core/workers/chunks/b884bd2f50aaccfa24c5.js +0 -1
  236. package/assets/esri/core/workers/chunks/c483d2149d9d0099bfdb.js +0 -1
  237. package/assets/esri/core/workers/chunks/cfc3f202e7313ca56823.js +0 -1
  238. package/assets/esri/core/workers/chunks/d1c97fdcba6eb443cb1c.js +0 -1
  239. package/assets/esri/core/workers/chunks/d7c679374aa2d256becf.js +0 -1
  240. package/assets/esri/core/workers/chunks/d8d17e3ecccec7e99f0b.js +0 -1
  241. package/assets/esri/core/workers/chunks/e4069352d5d1104749ae.js +0 -1
  242. package/assets/esri/core/workers/chunks/e408ccee12bfe089c913.js +0 -1
  243. package/assets/esri/core/workers/chunks/e5522c85ca4f0efab8ea.js +0 -1
  244. package/assets/esri/core/workers/chunks/e59e09766b130a05c617.js +0 -1
  245. package/assets/esri/core/workers/chunks/ef02e33ea53b46b566cb.js +0 -1
  246. package/assets/esri/core/workers/chunks/ff79a8df1b1941ae350d.js +0 -1
  247. package/views/3d/analysis/ElevationProfile/ElevationProfileLineSceneComputation.js +0 -5
  248. package/views/analysis/ElevationProfile/ElevationProfileController.js +0 -5
  249. package/views/analysis/ElevationProfile/ElevationProfileLineComputation.js +0 -5
  250. package/views/analysis/ElevationProfile/ElevationProfileLineGroundComputation.js +0 -5
  251. package/views/analysis/ElevationProfile/ElevationProfileLineInputComputation.js +0 -5
  252. package/views/analysis/ElevationProfile/ElevationProfileLineQueryComputation.js +0 -5
  253. package/views/analysis/ElevationProfileResult.d.ts +0 -4
  254. package/views/support/PixelHighlightOptions.js +0 -5
  255. /package/assets/esri/core/workers/chunks/{edc4f230a5bdf928f9fd.js.LICENSE.txt → d1aeb9fe9eb573beefcc.js.LICENSE.txt} +0 -0
  256. /package/views/analysis/ElevationProfile/{profileUtils.js → profileGenerationUtils.js} +0 -0
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{clamp as e}from"../../../core/mathUtils.js";import{abortMaybe as t}from"../../../core/maybe.js";import i from"../../../core/ObjectPool.js";import{d as s,k as n,e as r,g as a,f as l,l as o,c as h}from"../../../chunks/vec32.js";import{create as d,unitZ as u}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as c}from"../../../geometry/ellipsoidUtils.js";import{create as g,equals as p}from"../../../geometry/support/aaBoundingRect.js";import{c as f,a as _}from"../../../chunks/sphere.js";import{isGroupLayer as m}from"../../../layers/support/layerUtils.js";import{ElevationBounds as y}from"./ElevationBounds.js";import{ElevationTileAgent as v,isElevationTileAgent as M}from"./ElevationTileAgent.js";import{LayerClasses as A}from"./LayerClass.js";import{MapTileAgent as x,isMapTileAgent as D}from"./MapTileAgent.js";import{maxPatchTesselation as b}from"./TerrainConst.js";import{isVectorTile as L,isTileTexture as I,isRasterTile as j,isImageWithType as T}from"./TerrainData.js";import{weakAssert as C,isBlendableLayerView as B,oppositeCorner as U,internalAssert as S,enableTerrainInternalChecks as P,neighborEdgeIndices as w,oppositeEdge as E,neighborCornerIndices as R,almostEquals as q,enableWaterproofTests as V,isNorth as N,isSouth as O,isWest as k,isEast as G,isWestCorner as z,isNorthCorner as F}from"./terrainUtils.js";import{tileAgentDone as W}from"./TileAgent.js";import{TilePerLayerInfo as H}from"./TilePerLayerInfo.js";import{fallsWithinLayerView as J}from"./tileUtils.js";const X=.1;class Y{constructor(){this._lij=[0,0,0],this._children=[null,null,null,null],this._pendingUpdates=0,this._dirty=!0,this._previouslyRendered=!1,this.extent=g(),this._elevationBoundsMin=NaN,this._elevationBoundsMax=0,this.layerInfo=[[],[]],this.extentInRadians=g(),this.centerAtSeaLevel=d(),this._center=[d(),f(),d()],this.up=u(),this._withinClippingArea=!0,this._intersectsClippingArea=!0,this._maxTesselation=0,this._usedMemory=0,this._rasterTileMemory=0,this._vectorTileMemory=0,this._mapDataRefCount=0,this.screenDepth=0,this.renderOrder=0,this._edgeLen=0,this._edgeLen2=0,this._curvatureHeight=0,this.onCompressionFinished=()=>{this.setPendingUpdate(16),this.setMemoryDirty()},this.extentMidX=0,this.extentMidY=0,this.distanceToPOI=-1,this._lastPOI=d(),this.maxLevelDeltaNeighborCount=0,this.unmergableChildCount=0}get lij(){return this._lij}get spatialReference(){return this._surface.spatialReference??this._surface.tilingScheme.spatialReference}get elevationLevelDelta(){return this._surface.getElevationLevelDelta(this.level)}static prune(){K.prune(0),Z.prune(0),H.prune()}get _cached(){return!this.leaf&&this._mapDataRefCount<=0}get withinClippingArea(){return this._withinClippingArea}get intersectsClippingArea(){return this._intersectsClippingArea}get clippingArea(){return this._clippingArea}get parent(){return this._parent}get children(){return this._children}get surface(){return this._surface}get elevationBoundsMin(){return this._elevationBoundsMin}get elevationBoundsMax(){return this._elevationBoundsMax}get level(){return this._lij[0]}get key(){return`${this._lij[0]}/${this._lij[1]}/${this._lij[2]}`}get edgeLen(){return this._edgeLen}get radius(){return this._center[1][3]}get visible(){return this._dirty&&this.computeVisibility(),this._visible}get frustumVisibility(){return this._dirty&&this.computeVisibility(),this._frustumVisibility}computeVisibility(){this._dirty=!1;const e=this.parent,t=e?.frustumVisibility??1;this._frustumVisibility=0===t?0:2===t?2:this._calculateFrustumVisibility(this.surface.frustum);const i=2!==this._frustumVisibility&&this._intersectsClippingArea;i!==this._visible&&(this._visible=i,this._surface.emit("tiles-visibility-changed"),this._surface.renderer.setDirty(),this.updateAgentSuspension())}get _loadable(){return this.visible||this._surface.view.state.fixedContentCamera}get rendered(){const e=!!this.renderData;return e!==this._previouslyRendered&&(this._surface.emit("tiles-visibility-changed"),this._previouslyRendered=e,this._surface.renderer.setDirty()),e}init(e,t,i,s,n){this._lij[0]=e,this._lij[1]=t,this._lij[2]=i,this.ellipsoid=c(n.tilingScheme.spatialReference),n.tilingScheme.getExtent(e,t,i,this.extent),n.tilingScheme.convertExtentToRadians(this.extent,this.extentInRadians),this.extentMidX=.5*(this.extent[0]+this.extent[2]),this.extentMidY=.5*(this.extent[1]+this.extent[3]),this._withinClippingArea=!0,this._intersectsClippingArea=!0,this._clippingArea=null,this._mapDataRefCount=0,n.upsampleMapCache.pop(this.key),this._edgeLen=0,this._edgeLen2=0,this._center[1][3]=0,this.elevationLevel=e,s&&!Number.isNaN(s.elevationBoundsMin)?(this._elevationBoundsMin=s.elevationBoundsMin,this._elevationBoundsMax=s.elevationBoundsMax):(this._elevationBoundsMin=0,this._elevationBoundsMax=0),this._pendingUpdates=0,this.renderData=null,this.screenDepth=0,this._visible=!1,this._previouslyRendered=!1,this._parent=s,this.clearChildren(),this._surface=n,this.updateVisibility(),this.maxLevelDeltaNeighborCount=0,this.unmergableChildCount=0;for(const r of A){const e=n.numLayers(r),t=this.layerInfo[r];for(const i of t)i.release();t.length=e;for(let i=0;i<e;i++)t[i]=H.acquire(this._surface.upsampleInfoPool),0===r&&this.findElevationBoundsForLayer(i,-1)}this.computeElevationBounds(),this._maxTesselation=Math.min(n.tilingScheme.pixelSize,b)}dispose(){C(!this.renderData,"tile.renderData was not unloaded"),this._surface?.upsampleMapCache.pop(this.key),this.layerInfo.forEach(e=>{e.forEach(e=>e.release()),e.length=0}),this._surface=this._parent=null,this.clearChildren(),this.setMemoryDirty()}refMapData(){++this._mapDataRefCount,this._cached||this._surface.upsampleMapCache.pop(this.key)}unrefMapData(){--this._mapDataRefCount,this._cached&&this.cachedMemory>0&&this._surface.upsampleMapCache.put(this.key,this)}setMemoryDirty(){this._usedMemory=0}get usedMemory(){return this._ensureUsedMemory()+(this._cached?0:this._mapTileMemory)}get cachedMemory(){return this._ensureUsedMemory(),null==this._surface?this.usedMemory:this._cached?this._mapTileMemory:0}get _mapTileMemory(){return this._rasterTileMemory+this._vectorTileMemory}get _cpuImageMemorySize(){const e=4,t=this._surface.tilingScheme.pixelSize;return t*t*e}_ensureUsedMemory(){if(this._usedMemory>0)return this._vectorTileMemory=this.layerInfo[1].reduce((e,{data:t})=>e+(L(t)?t.usedMemoryPerReference:0),0),this._usedMemory;this._usedMemory=this._baseUsedMemory,this._rasterTileMemory=0,this._vectorTileMemory=0;for(const{data:e}of this.layerInfo[1])L(e)?this._vectorTileMemory+=e.usedMemoryPerReference:this._rasterTileMemory+=this.getTerrainDataMemory(e);for(const e of this.layerInfo[0])this._usedMemory+=e.data?this._cpuImageMemorySize:0;return this.renderData&&(this._usedMemory+=this.renderData.estimatedGeometryMemoryUsage,this._rasterTileMemory+=this.renderData.texture?.cachedMemory??0),this._cached&&this._surface.upsampleMapCache.updateSize(this.key,this),this._usedMemory}getUsedMemoryForLayer(e,t){const i=this.layerInfo[e][t];return i?.data?1===e?this._cached?0:this.getTerrainDataMemory(i.data):0===e?this._cpuImageMemorySize:0:0}getTerrainDataMemory(e){return I(e)?e.texture.usedMemory:j(e)?e.memoryUsage:L(e)?e.usedMemoryPerReference:T(e)||e instanceof HTMLImageElement?this._cpuImageMemorySize:0}updateScreenDepth(e){const t=this._center[1],i=e,s=t[0],n=t[1],r=t[2],a=i[2]*s+i[6]*n+i[10]*r+i[14];this.screenDepth=a<0?0:a/(i[3]*s+i[7]*n+i[11]*r+i[15])}shouldSplit(e,t,i){if(!this.visible)return 0;if(e.frustum&&(!this._intersectsClippingArea||2===this._calculateFrustumVisibility(e.frustum)))return 0;const h=this.level;s(ae,_(this._center[1]),t);let d=n(ae),u=ae,c=_(this._center[1]);s(le,this._center[0],t);const g=n(le);g<d&&(d=g,u=le,c=this._center[0]),s(oe,this._center[2],t);const p=n(oe);if(p<d&&(d=p,u=oe,c=this._center[2]),this._edgeLen2>d&&h<e.maxLod)return 1;const f=Math.sqrt(d),m=e.fovX*f*2,y=this._edgeLen/m,v=()=>{if(h<e.maxLod)return this.elevationLevel=h,0;const t=h+Math.ceil(-Math.log2(e.relativeWidthLimit/y));return t!==this.elevationLevel?(this.elevationLevel=t,2):0},M=null!=i?i-h:1/0;if(M<=.5)return v();const A=r(this.up,ae),x=this._elevationBoundsMax-this._elevationBoundsMin,D=x/this.edgeLen;if(e.aboveGround&&A>0&&D<.001){if(A/f-Math.sin(this._curvatureHeight/(this.edgeLen*Math.SQRT1_2)*Math.PI)-D>0)return 0}const b=null!=i?3-Math.min(M,2):1;if(y*b<e.relativeWidthLimit||h>=e.maxLod)return v();if(h<7)return 1;a(he,this.up,A),s(he,he,u);const L=n(he);if(L<=this.radius*this.radius)return 1;a(he,he,this.radius/Math.sqrt(L)),l(he,he,c),s(he,t,he);const I=Math.min(1,(Math.abs(r(he,this.up))+.5*x+this._curvatureHeight)/o(he)),j=X/e.angledSplitBias,T=e.fovY*f*2;return I*(this._edgeLen/T*b)<j*e.relativeHeightLimit?0:1}createChildren(){const e=this._children,t=this.lij[0]+1,i=2*this.lij[1],s=2*this.lij[2];return e[0]=this.surface.createTile(t,i,s,this),e[1]=this.surface.createTile(t,i,s+1,this),e[2]=this.surface.createTile(t,i+1,s,this),e[3]=this.surface.createTile(t,i+1,s+1,this),e}clearChildren(){this._children[0]=this._children[1]=this._children[2]=this._children[3]=null}get loaded(){return this.renderData?.hasGeometry??!1}load(){this.refMapData();for(const e of A)this._createOrUpdateAgents(0,e);this.surface.renderer.loadTile(this)}unload(){this.renderData&&this.unrefMapData(),this.surface.renderer.unloadTile(this);for(const e of A){const t=this.layerInfo[e];for(const e of t)e.loadingAgent&&e.loadingAgent!==W&&(Q(e.loadingAgent),e.loadingAgent=null),e.pendingUpdates=0}this.resetPendingUpdate(8),this.resetPendingUpdate(16),this.resetPendingUpdate(32)}unloadMapData(){const e=this.layerInfo[1];for(const t of e)t.loadingAgent&&t.loadingAgent!==W&&(Q(t.loadingAgent),t.loadingAgent=null),t.pendingUpdates=0,t.invalidateSourceData();this.renderData&&this.renderData.releaseTexture(),this.setMemoryDirty()}updateClippingStatus(e){if(p(e,this._clippingArea))return!1;const t=this._intersectsClippingArea,i=this._withinClippingArea;null!=e?(this._intersectsClippingArea=this.intersectsExtent(e),this._withinClippingArea=this._isWithinExtent(e)):(this._intersectsClippingArea=!0,this._withinClippingArea=!0),this._clippingArea=e,this.updateVisibility();const s=i&&this._withinClippingArea,n=!(i||t||this._withinClippingArea||this._intersectsClippingArea);return!this.renderData||s||n||this.setPendingUpdate(8),!0}updateVisibility(){this._dirty=!0,this._surface.setTileTreeDirty()}getLayerInfo(e,t){return this.layerInfo[t][e]}hasLayerData(e,t){const i=this.layerInfo[t][e];return!(!i?.data||i.dataInvalidated)}get updating(){if(this.hasPendingUpdates)return!0;for(const e of A){const t=this.layerInfo[e];for(const e of t)if(e.loadingAgent&&e.loadingAgent!==W&&e.loadingAgent.updating)return!0}return!1}_isSuspended(e){return!!this.hasPendingUpdate(1)||0!==e&&!this._loadable}get hasPendingUpdates(){return 0!==this._pendingUpdates}hasPendingUpdate(e){return(this._pendingUpdates&e)===e}setPendingUpdate(e){const t=this._pendingUpdates;return this._pendingUpdates|=e,1===e||4===e?this._surface.setTileTreeDirty():this._surface.requestUpdate(),t!==this._pendingUpdates}resetPendingUpdate(e){return!!this.hasPendingUpdate(e)&&(this._pendingUpdates&=~e,!0)}requestLayerData(e,i,s){const n=this.layerInfo[i][e];if(n.waitingAgents.has(s))return console.warn("agent already requested this piece of map data (tile %s, agent tile %s, layer: %d/%d)",this._lij.toString(),s.tile.lij.toString(),i,e),!0;if(n.waitingAgents.push(s),n.data&&!n.dataInvalidated){console.warn("agent requested existing data (tile %s, agent tile %s, layer: %d/%d)",this._lij.toString(),s.tile.lij.toString(),i,e);const t=L(n.data);return s.dataArrived(this,t),!0}if(n.requestPromise)return!0;t(n.requestAbort),n.requestAbort=new AbortController;const r=this._surface.requestTileData(this,e,i,n.requestAbort);if(!r)return n.requestAbort=null,!1;const a=()=>{n.requestPromise===r&&(n.requestPromise=null,n.requestAbort=null)};return n.requestPromise=r,r.then(a,a),!0}get leaf(){return null==this._children[0]}hasLij(e){return this._lij[0]===e[0]&&this._lij[1]===e[1]&&this._lij[2]===e[2]}findByLij(e){if(this.hasLij(e))return this;const t=this._children;if(!t[0])return null;return t[0].findByLij(e)||t[1].findByLij(e)||t[2].findByLij(e)||t[3].findByLij(e)}distanceToSquared(e){return n(s(he,_(this._center[1]),e))}containsPoint(e){const t=this.extent;return e[0]>=t[0]&&e[1]>=t[1]&&e[0]<=t[2]&&e[1]<=t[3]}containsPointXY(e,t){const i=this.extent;return e>=i[0]&&t>=i[1]&&e<=i[2]&&t<=i[3]}unrequestLayerData(e,t,i){const s=this.layerInfo[t][e],n=s.waitingAgents,r=null!=n.removeUnordered(i);C(r,"agent has not requested this piece of map data"),n.length<1&&(s.abortRequest(),this.setMemoryDirty())}dataArrived(e,t,i){const s=L(i),n=this.layerInfo[t][e];n.data=i,n.dataInvalidated=!1,n.waitingAgents.forAll(e=>e.dataArrived(this,s)),n.waitingAgents.clear(),this.setMemoryDirty()}dataMissing(e,t){const i=this.layerInfo[t][e];i.dataMissing=!0,i.waitingAgents.forAll(e=>e.dataMissing()),i.waitingAgents.clear(),this.setMemoryDirty()}updateRenderData(e,t,i){switch(i&&this.forEachLoadedNeighbor(i=>i.updateRenderData(e,t)),e){case 1:return this._updateTexture(t);case 0:return this._updateGeometry()}}_updateTexture(e){this.renderData&&(this.resetPendingUpdate(0===e?16:32),this.setPendingUpdate(0===e?32:16))}_updateGeometry(){this.setPendingUpdate(8);for(const e of this.layerInfo[0])e.pendingUpdates|=8}invalidateLayerData(e,t){this.layerInfo[t][e].invalidateSourceData(),this.restartAgents(t)}computeElevationBounds(){const e=this._elevationBoundsMin,t=this._elevationBoundsMax;let i=1/0,s=-1/0;const n=this.layerInfo[0];let r=!0;for(const a of n)null!=a.elevationBounds&&(i=Math.min(i,a.elevationBounds.min),s=Math.max(s,a.elevationBounds.max),a.elevationBounds.hasNoDataValues||(r=!1));r&&(i=Math.min(i,0),s=Math.max(s,0)),e===i&&t===s||(this._elevationBoundsMin=i,this._elevationBoundsMax=s,this.updateRadiusAndCenter(),this._surface.setTileTreeDirty())}_updateCenter(){const e=this._elevationBoundsMin,t=this._elevationBoundsMax,i=.5*(e+t),s=this._center;a(he,this.up,i),l(_(s[1]),this.centerAtSeaLevel,he),a(he,this.up,e),l(s[0],this.centerAtSeaLevel,he),a(he,this.up,t),l(s[2],this.centerAtSeaLevel,he)}findElevationBoundsForLayer(e,t){const i=this.layerInfo[0][e],s=this.elevationLevelDelta,n=Math.max(this.elevationLevel-s,0),r=i.elevationBounds;if(null!=r&&r.level>=t&&r.level<=n)return;const a=this._surface.layerViewByIndex(e,0);if(!J(this,a))return;const l=ee;let o=!1;const h=i.data;if(h&&h.level<=n){const e=i.data;l.min=e.samplerData.data.minValue,l.max=e.samplerData.data.maxValue,l.hasNoDataValues=e.samplerData.data.hasNoDataValues,l.level=this.level,o=!0}else{let t,i,r=0;for(let a=this._parent;a&&(!i||r<s)&&(r=this.elevationLevel-a.level,t=i||t,i=a.layerInfo[0][e].data,!(!i&&t&&a.level<=n));a=a.parent);i=i||t,i&&(i.computeMinMaxValue(this._lij[0],this._lij[1],this._lij[2],l),l.min!==1/0&&(l.level=i.level,o=!0))}o&&(null==i.elevationBounds&&(i.elevationBounds=new y),i.elevationBounds.copyFrom(l))}modifyLayers(e,t,i){const s=this.layerInfo[i];for(const a of s)a.loadingAgent&&a.loadingAgent!==W&&(Q(a.loadingAgent),a.loadingAgent=null),a.waitingAgents.clear();for(let a=0;a<s.length;++a)void 0===e[a]&&s[a].release();const n=new Array(...s),r=t.length;s.length=r;for(let a=0;a<r;a++){const e=t[a];s[a]=e>-1?n[e]:H.acquire(this._surface.upsampleInfoPool)}this.setMemoryDirty()}restartAgents(e){this.renderData&&(this._createOrUpdateAgents(0,e),this.updateRenderData(e,0))}updateAgents(e){if(this.renderData){const t=this.layerInfo[e];for(const e of t)e.loadingAgent===W&&(e.loadingAgent=null);this._createOrUpdateAgents(0,e)}}updateAgentSuspension(){for(const e of A){const t=this._isSuspended(e);for(const i of this.layerInfo[e])i.loadingAgent&&i.loadingAgent!==W&&(i.loadingAgent.setSuspension(t),i.loadingAgent===W&&this.updateRenderData(e,0))}}removeLayerAgent(e,t){const i=this.layerInfo[t][e];i.loadingAgent&&i.loadingAgent!==W&&i.loadingAgent.dispose(),i.loadingAgent=null}agentDone(e,t){const i=this.layerInfo[t][e];i.loadingAgent=W,i.data||null!=i.upsampleInfo||this._createOrUpdateAgents(e+1,t)}_hasBlendableAncestor(e){return"normal"!==e.blendMode||m(e.parent)&&this._hasBlendableAncestor(e.parent)}_hasBlendModes(e,t,i){for(let s=e;s<t;++s){const e=this._surface.layerViewByIndex(s,i);if(B(e)&&"normal"!==e?.layer?.blendMode||m(e?.layer?.parent)&&this._hasBlendableAncestor(e?.layer?.parent))return!0}return!1}_createOrUpdateAgents(e,t){const i=this.layerInfo[t];if(0===i.length)return;const s=this._isSuspended(t);for(let n=e;n<i.length;++n){const r=i[n],a=this._surface.layerViewByIndex(n,t);let l=!1;if(r.loadingAgent?J(this,a)?(r.loadingAgent!==W&&r.loadingAgent.setSuspension(s),r.loadingAgent!==W&&(l=r.loadingAgent.update())):r.dispose():J(this,a)&&(r.loadingAgent=$(this,n,t,s),l=r.loadingAgent.startLoading(),l?r.loadingAgent===W&&this.setPendingUpdate(8):(Q(r.loadingAgent),r.loadingAgent=W)),r.loadingAgent===W&&this.updateRenderData(t,0),!a.destroyed&&!this._hasBlendModes(e,i.length,t)&&l&&a.isOpaque)return}}_isWithinExtent(e){const t=this.extent;return t[0]>=e[0]&&e[2]>=t[2]&&t[1]>=e[1]&&e[3]>=t[3]}intersectsExtent(e){const t=this.extent;return t[2]>=e[0]&&e[2]>=t[0]&&t[3]>=e[1]&&e[3]>=t[1]}getElevationVerticesPerSide(t){const i=this.elevationLevel-this.level,s=Math.max(this.level-t,this.elevationLevelDelta-i),n=e(1+(this._maxTesselation>>s),2,this._maxTesselation+1),r=this.minimumVerticesPerSide;return Math.max(n,r)}_findLIJ(e,t){if(!e)return null;const i=this.surface.rootTiles;if(null!=i)for(const s of i)if(te(s,e)){let i=s,n=e[0]-i.level-1;for(;n>=0&&!i.leaf&&!t(i);){const t=e[1]>>n&1,s=e[2]>>n&1;i=i.children[2*t+s],n--}return t(i)?i:null}return null}findNeighborTile(e,t){const i=this._lij,s=this._getNeighborLIJ(i,e);return s?ie(i,s)?t(this)?this:null:this._findLIJ(s,t):null}findCorner(e,t){const i=1===e?1:7===e?0:5===e?2:3;let s=this;for(;s.children[0]&&(!t||!t(s));)s=s.children[i];return s}findNeighborCornerTileExact(e,t){return this.findNeighborTile(e,e=>t(e)||e.level===this.level)?.findCorner(U(e),t)||null}forAllSubtreeOnSide(e,t){const i=0===e?[0,1]:1===e?[1]:2===e?[1,3]:3===e?[3]:4===e?[2,3]:5===e?[2]:6===e?[0,2]:[0],s=e=>{const n=e.children;!t(e)&&n[0]&&i.forEach(e=>s(n[e]))};s(this)}getNeighborEdgeStartVertexIndex(e,t){if(!t)return 0;const i=this.level-t.level;if(S(!P||i>=0),0===i)return 0;const s=2**i,n=!(1&~e),r=n?0:1,a=t.lij[r+1]*s,l=this._lij[r+1],o=l-a,h=n?s-1-o:o;return P&&(S(a<=l&&l<a+s),S(0<=h&&h<s)),h}forEachLoadedNeighbor(e){const t=this.level,i=e=>e.level===t||e.loaded;w.forEach(t=>{const s=this.findNeighborTile(t,i);null!=s&&s!==this&&s.forAllSubtreeOnSide(E(t),i=>!!i.loaded&&(e(i,t),!0))}),R.forEach(t=>{const s=this.findNeighborTile(t,i)?.findCorner(U(t),e=>e.loaded);S(!s||se(this,s,t)),s?.loaded&&e(s,t)})}_getNeighborLIJ(e,t){const i=N(t)?-1:O(t)?1:0,s=k(t)?-1:G(t)?1:0,n=[e[0],e[1]+i,e[2]+s];return n[1]<0?null:this.surface.isGlobal?this._wrapLIJ(n):n[2]<0?null:n}_wrapLIJ(e){return!e||e[1]<0||e[1]>=2**e[0]?null:this.surface.wrapEastWest(e)}isEdgeNeighbor(e,t){if(null==e)return!1;if(0===this.level&&0===e.level){if(this._eastEnd&&e._westEnd&&2===t)return!0;if(this._westEnd&&e._eastEnd&&6===t)return!0}const i=Math.max(1e-6*(this.extent[2]-this.extent[0]),1);switch(t){case 0:return q(this.extent[3],e.extent[1],i);case 4:return q(this.extent[1],e.extent[3],i);case 2:return q(this.extent[2],e.extent[0],i)||q(this.extent[2],-e.extent[0],i);case 6:return q(this.extent[0],e.extent[2],i)||q(this.extent[0],-e.extent[2],i)}}get _eastEnd(){return this._lij[2]===this.surface.lijEastEnd(this.level)-1}get _westEnd(){return 0===this._lij[2]}checkGeometryWaterproofness(){V&&(S(this.loaded),this.renderData?.checkGeometryWaterproofness())}shouldHaveNeighbor(e){const t=this.extent,i=this.surface.rootTilesExtent,s=.25*(t[2]-t[0]);if(N(e)&&t[3]+s>=i[3])return!1;if(O(e)&&t[1]-s<=i[1])return!1;const n=this.surface.isGlobal;return!(!n&&k(e)&&t[0]-s<=i[0])&&!(!n&&G(e)&&t[2]+s>=i[2])}updateDistanceToPOI(e){const t=this._lastPOI;if(this.distanceToPOI>=0&&t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2])return;h(this._lastPOI,e);const i=this._center[1],s=e[0]-i[0],n=e[1]-i[1],r=e[2]-i[2];this.distanceToPOI=s*s+n*n+r*r}}function $(e,t,i,s){const n=0===i?Z.acquire():K.acquire();return n.init(e,t,i,s),n}function Q(e){e.dispose(),M(e)?Z.release(e):D(e)&&K.release(e)}const K=new i(x),Z=new i(v),ee=new y;function te(e,t){const i=e.lij,s=t[0]-i[0];return!(s<0)&&(t[1]>>s===i[1]&&t[2]>>s===i[2])}function ie(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]}function se(e,t,i){return null!=e&&null!=t&&t!==e&&(e.level>=t.level?ne(e,t,i):ne(t,e,U(i)))}function ne(e,t,i){S(e.level>=t.level);const s=z(i),n=F(i),r=e.extent,a=t.extent,l=[s?r[0]:r[2],n?r[3]:r[1]],o=[s?a[2]:a[0],n?a[1]:a[3]],h=1e-5*(r[2]-r[0]),d=q(l[0],o[0],h)||e.surface.isGlobal&&q(l[0],-o[0],h),u=q(l[1],o[1],h);if(d&&u)return!0;if(e.level===t.level)return S(!1),!1;if(!d&&!u)return S(!1),!1;const c=d?re(a[1],a[3],r[1],r[3],h):re(a[0],a[2],r[0],r[2],h);return S(c),c}function re(e,t,i,s,n){return e-n<=i&&i<=s&&s<=t+n}const ae=d(),le=d(),oe=d(),he=d();export{Y as Tile,se as isCornerNeighbor,ie as lijEquals};
5
+ import{clamp as e}from"../../../core/mathUtils.js";import{abortMaybe as t}from"../../../core/maybe.js";import i from"../../../core/ObjectPool.js";import{d as s,k as n,e as r,g as a,f as l,l as o,c as h}from"../../../chunks/vec32.js";import{create as d,unitZ as u}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as c}from"../../../geometry/ellipsoidUtils.js";import{create as g,equals as p}from"../../../geometry/support/aaBoundingRect.js";import{c as f,a as _,k as m}from"../../../chunks/sphere.js";import{isGroupLayer as y}from"../../../layers/support/layerUtils.js";import{ElevationBounds as v}from"./ElevationBounds.js";import{ElevationTileAgent as M,isElevationTileAgent as A}from"./ElevationTileAgent.js";import{LayerClasses as x}from"./LayerClass.js";import{MapTileAgent as D,isMapTileAgent as b}from"./MapTileAgent.js";import{maxPatchTesselation as L}from"./TerrainConst.js";import{isVectorTile as I,isTileTexture as j,isRasterTile as T,isImageWithType as C}from"./TerrainData.js";import{weakAssert as B,isBlendableLayerView as U,oppositeCorner as S,internalAssert as P,enableTerrainInternalChecks as w,neighborEdgeIndices as E,oppositeEdge as R,neighborCornerIndices as q,almostEquals as V,enableWaterproofTests as N,isNorth as O,isSouth as k,isWest as G,isEast as z,isWestCorner as F,isNorthCorner as W}from"./terrainUtils.js";import{tileAgentDone as H}from"./TileAgent.js";import{TilePerLayerInfo as J}from"./TilePerLayerInfo.js";import{fallsWithinLayerView as X}from"./tileUtils.js";const Y=.1;class ${constructor(){this._lij=[0,0,0],this._children=[null,null,null,null],this._pendingUpdates=0,this._dirty=!0,this._previouslyRendered=!1,this.extent=g(),this._elevationBoundsMin=NaN,this._elevationBoundsMax=0,this.layerInfo=[[],[]],this.extentInRadians=g(),this.centerAtSeaLevel=d(),this._center=[d(),f(),d()],this.up=u(),this._withinClippingArea=!0,this._intersectsClippingArea=!0,this._maxTesselation=0,this._usedMemory=0,this._rasterTileMemory=0,this._vectorTileMemory=0,this._mapDataRefCount=0,this.screenDepth=0,this.renderOrder=0,this._edgeLen=0,this._edgeLen2=0,this._curvatureHeight=0,this.onCompressionFinished=()=>{this.setPendingUpdate(16),this.setMemoryDirty()},this.extentMidX=0,this.extentMidY=0,this.distanceToPOI=-1,this._lastPOI=d(),this.maxLevelDeltaNeighborCount=0,this.unmergableChildCount=0}get lij(){return this._lij}get spatialReference(){return this._surface.spatialReference??this._surface.tilingScheme.spatialReference}get elevationLevelDelta(){return this._surface.getElevationLevelDelta(this.level)}static prune(){Z.prune(0),ee.prune(0),J.prune()}get _cached(){return!this.leaf&&this._mapDataRefCount<=0}get withinClippingArea(){return this._withinClippingArea}get intersectsClippingArea(){return this._intersectsClippingArea}get clippingArea(){return this._clippingArea}get parent(){return this._parent}get children(){return this._children}get surface(){return this._surface}get elevationBoundsMin(){return this._elevationBoundsMin}get elevationBoundsMax(){return this._elevationBoundsMax}get level(){return this._lij[0]}get key(){return`${this._lij[0]}/${this._lij[1]}/${this._lij[2]}`}get edgeLen(){return this._edgeLen}get radius(){return this._center[1][3]}get visible(){return this._dirty&&this.computeVisibility(),this._visible}get frustumVisibility(){return this._dirty&&this.computeVisibility(),this._frustumVisibility}computeVisibility(){this._dirty=!1;const e=this.parent,t=e?.frustumVisibility??1;this._frustumVisibility=0===t?0:2===t?2:this._calculateFrustumVisibility(this.surface.frustum);const i=2!==this._frustumVisibility&&this._intersectsClippingArea;i!==this._visible&&(this._visible=i,this._surface.emit("tiles-visibility-changed"),this._surface.renderer.setDirty(),this.updateAgentSuspension())}get _loadable(){return this.visible||this._surface.view.state.fixedContentCamera}get rendered(){const e=!!this.renderData;return e!==this._previouslyRendered&&(this._surface.emit("tiles-visibility-changed"),this._previouslyRendered=e,this._surface.renderer.setDirty()),e}init(e,t,i,s,n){this._lij[0]=e,this._lij[1]=t,this._lij[2]=i,this.ellipsoid=c(n.tilingScheme.spatialReference),n.tilingScheme.getExtent(e,t,i,this.extent),n.tilingScheme.convertExtentToRadians(this.extent,this.extentInRadians),this.extentMidX=.5*(this.extent[0]+this.extent[2]),this.extentMidY=.5*(this.extent[1]+this.extent[3]),this._withinClippingArea=!0,this._intersectsClippingArea=!0,this._clippingArea=null,this._mapDataRefCount=0,n.upsampleMapCache.pop(this.key),this._edgeLen=0,this._edgeLen2=0,this._center[1][3]=0,this.elevationLevel=e,s&&!Number.isNaN(s.elevationBoundsMin)?(this._elevationBoundsMin=s.elevationBoundsMin,this._elevationBoundsMax=s.elevationBoundsMax):(this._elevationBoundsMin=0,this._elevationBoundsMax=0),this._pendingUpdates=0,this.renderData=null,this.screenDepth=0,this._visible=!1,this._previouslyRendered=!1,this._parent=s,this.clearChildren(),this._surface=n,this.updateVisibility(),this.maxLevelDeltaNeighborCount=0,this.unmergableChildCount=0;for(const r of x){const e=n.numLayers(r),t=this.layerInfo[r];for(const i of t)i.release();t.length=e;for(let i=0;i<e;i++)t[i]=J.acquire(this._surface.upsampleInfoPool),0===r&&this.findElevationBoundsForLayer(i,-1)}this.computeElevationBounds(),this._maxTesselation=Math.min(n.tilingScheme.pixelSize,L)}dispose(){B(!this.renderData,"tile.renderData was not unloaded"),this._surface?.upsampleMapCache.pop(this.key),this.layerInfo.forEach(e=>{e.forEach(e=>e.release()),e.length=0}),this._surface=this._parent=null,this.clearChildren(),this.setMemoryDirty()}refMapData(){++this._mapDataRefCount,this._cached||this._surface.upsampleMapCache.pop(this.key)}unrefMapData(){--this._mapDataRefCount,this._cached&&this.cachedMemory>0&&this._surface.upsampleMapCache.put(this.key,this)}setMemoryDirty(){this._usedMemory=0}get usedMemory(){return this._ensureUsedMemory()+(this._cached?0:this._mapTileMemory)}get cachedMemory(){return this._ensureUsedMemory(),null==this._surface?this.usedMemory:this._cached?this._mapTileMemory:0}get _mapTileMemory(){return this._rasterTileMemory+this._vectorTileMemory}get _cpuImageMemorySize(){const e=4,t=this._surface.tilingScheme.pixelSize;return t*t*e}_ensureUsedMemory(){if(this._usedMemory>0)return this._vectorTileMemory=this.layerInfo[1].reduce((e,{data:t})=>e+(I(t)?t.usedMemoryPerReference:0),0),this._usedMemory;this._usedMemory=this._baseUsedMemory,this._rasterTileMemory=0,this._vectorTileMemory=0;for(const{data:e}of this.layerInfo[1])I(e)?this._vectorTileMemory+=e.usedMemoryPerReference:this._rasterTileMemory+=this.getTerrainDataMemory(e);for(const e of this.layerInfo[0])this._usedMemory+=e.data?this._cpuImageMemorySize:0;return this.renderData&&(this._usedMemory+=this.renderData.estimatedGeometryMemoryUsage,this._rasterTileMemory+=this.renderData.texture?.cachedMemory??0),this._cached&&this._surface.upsampleMapCache.updateSize(this.key,this),this._usedMemory}getUsedMemoryForLayer(e,t){const i=this.layerInfo[e][t];return i?.data?1===e?this._cached?0:this.getTerrainDataMemory(i.data):0===e?this._cpuImageMemorySize:0:0}getTerrainDataMemory(e){return j(e)?e.texture.usedMemory:T(e)?e.memoryUsage:I(e)?e.usedMemoryPerReference:C(e)||e instanceof HTMLImageElement?this._cpuImageMemorySize:0}updateScreenDepth(e){const t=this._center[1],i=e,s=t[0],n=t[1],r=t[2],a=i[2]*s+i[6]*n+i[10]*r+i[14];this.screenDepth=a<0?0:a/(i[3]*s+i[7]*n+i[11]*r+i[15])}shouldSplit(e,t,i){if(!this.visible)return 0;if(e.frustum&&(!this._intersectsClippingArea||2===this._calculateFrustumVisibility(e.frustum)))return 0;const h=this.level;s(le,_(this._center[1]),t);let d=n(le),u=le,c=_(this._center[1]);s(oe,this._center[0],t);const g=n(oe);g<d&&(d=g,u=oe,c=this._center[0]),s(he,this._center[2],t);const p=n(he);if(p<d&&(d=p,u=he,c=this._center[2]),this._edgeLen2>d&&h<e.maxLod)return 1;const f=Math.sqrt(d),m=e.fovX*f*2,y=this._edgeLen/m,v=()=>{if(h<e.maxLod)return this.elevationLevel=h,0;const t=h+Math.ceil(-Math.log2(e.relativeWidthLimit/y));return t!==this.elevationLevel?(this.elevationLevel=t,2):0},M=null!=i?i-h:1/0;if(M<=.5)return v();const A=r(this.up,le),x=this._elevationBoundsMax-this._elevationBoundsMin,D=x/this.edgeLen;if(e.aboveGround&&A>0&&D<.001){if(A/f-Math.sin(this._curvatureHeight/(this.edgeLen*Math.SQRT1_2)*Math.PI)-D>0)return 0}const b=null!=i?3-Math.min(M,2):1;if(y*b<e.relativeWidthLimit||h>=e.maxLod)return v();if(h<7)return 1;a(de,this.up,A),s(de,de,u);const L=n(de);if(L<=this.radius*this.radius)return 1;a(de,de,this.radius/Math.sqrt(L)),l(de,de,c),s(de,t,de);const I=Math.min(1,(Math.abs(r(de,this.up))+.5*x+this._curvatureHeight)/o(de)),j=Y/e.angledSplitBias,T=e.fovY*f*2;return I*(this._edgeLen/T*b)<j*e.relativeHeightLimit?0:1}createChildren(){const e=this._children,t=this.lij[0]+1,i=2*this.lij[1],s=2*this.lij[2];return e[0]=this.surface.createTile(t,i,s,this),e[1]=this.surface.createTile(t,i,s+1,this),e[2]=this.surface.createTile(t,i+1,s,this),e[3]=this.surface.createTile(t,i+1,s+1,this),e}clearChildren(){this._children[0]=this._children[1]=this._children[2]=this._children[3]=null}get loaded(){return this.renderData?.hasGeometry??!1}load(){this.refMapData();for(const e of x)this._createOrUpdateAgents(0,e);this.surface.renderer.loadTile(this)}unload(){this.renderData&&this.unrefMapData(),this.surface.renderer.unloadTile(this);for(const e of x){const t=this.layerInfo[e];for(const e of t)e.loadingAgent&&e.loadingAgent!==H&&(K(e.loadingAgent),e.loadingAgent=null),e.pendingUpdates=0}this.resetPendingUpdate(8),this.resetPendingUpdate(16),this.resetPendingUpdate(32)}unloadMapData(){const e=this.layerInfo[1];for(const t of e)t.loadingAgent&&t.loadingAgent!==H&&(K(t.loadingAgent),t.loadingAgent=null),t.pendingUpdates=0,t.invalidateSourceData();this.renderData&&this.renderData.releaseTexture(),this.setMemoryDirty()}updateClippingStatus(e){if(p(e,this._clippingArea))return!1;const t=this._intersectsClippingArea,i=this._withinClippingArea;null!=e?(this._intersectsClippingArea=this.intersectsExtent(e),this._withinClippingArea=this._isWithinExtent(e)):(this._intersectsClippingArea=!0,this._withinClippingArea=!0),this._clippingArea=e,this.updateVisibility();const s=i&&this._withinClippingArea,n=!(i||t||this._withinClippingArea||this._intersectsClippingArea);return!this.renderData||s||n||this.setPendingUpdate(8),!0}updateVisibility(){this._dirty=!0,this._surface.setTileTreeDirty()}getLayerInfo(e,t){return this.layerInfo[t][e]}hasLayerData(e,t){const i=this.layerInfo[t][e];return!(!i?.data||i.dataInvalidated)}get updating(){if(this.hasPendingUpdates)return!0;for(const e of x){const t=this.layerInfo[e];for(const e of t)if(e.loadingAgent&&e.loadingAgent!==H&&e.loadingAgent.updating)return!0}return!1}_isSuspended(e){return!!this.hasPendingUpdate(1)||0!==e&&!this._loadable}get hasPendingUpdates(){return 0!==this._pendingUpdates}hasPendingUpdate(e){return(this._pendingUpdates&e)===e}setPendingUpdate(e){const t=this._pendingUpdates;return this._pendingUpdates|=e,1===e||4===e?this._surface.setTileTreeDirty():this._surface.requestUpdate(),t!==this._pendingUpdates}resetPendingUpdate(e){return!!this.hasPendingUpdate(e)&&(this._pendingUpdates&=~e,!0)}requestLayerData(e,i,s){const n=this.layerInfo[i][e];if(n.waitingAgents.has(s))return console.warn("agent already requested this piece of map data (tile %s, agent tile %s, layer: %d/%d)",this._lij.toString(),s.tile.lij.toString(),i,e),!0;if(n.waitingAgents.push(s),n.data&&!n.dataInvalidated){console.warn("agent requested existing data (tile %s, agent tile %s, layer: %d/%d)",this._lij.toString(),s.tile.lij.toString(),i,e);const t=I(n.data);return s.dataArrived(this,t),!0}if(n.requestPromise)return!0;t(n.requestAbort),n.requestAbort=new AbortController;const r=this._surface.requestTileData(this,e,i,n.requestAbort);if(!r)return n.requestAbort=null,!1;const a=()=>{n.requestPromise===r&&(n.requestPromise=null,n.requestAbort=null)};return n.requestPromise=r,r.then(a,a),!0}get leaf(){return null==this._children[0]}hasLij(e){return this._lij[0]===e[0]&&this._lij[1]===e[1]&&this._lij[2]===e[2]}findByLij(e){if(this.hasLij(e))return this;const t=this._children;if(!t[0])return null;return t[0].findByLij(e)||t[1].findByLij(e)||t[2].findByLij(e)||t[3].findByLij(e)}distanceToSquared(e){return n(s(de,_(this._center[1]),e))}containsPoint(e){const t=this.extent;return e[0]>=t[0]&&e[1]>=t[1]&&e[0]<=t[2]&&e[1]<=t[3]}containsPointXY(e,t){const i=this.extent;return e>=i[0]&&t>=i[1]&&e<=i[2]&&t<=i[3]}unrequestLayerData(e,t,i){const s=this.layerInfo[t][e],n=s.waitingAgents,r=null!=n.removeUnordered(i);B(r,"agent has not requested this piece of map data"),n.length<1&&(s.abortRequest(),this.setMemoryDirty())}dataArrived(e,t,i){const s=I(i),n=this.layerInfo[t][e];n.data=i,n.dataInvalidated=!1,n.waitingAgents.forAll(e=>e.dataArrived(this,s)),n.waitingAgents.clear(),this.setMemoryDirty()}dataMissing(e,t){const i=this.layerInfo[t][e];i.dataMissing=!0,i.waitingAgents.forAll(e=>e.dataMissing()),i.waitingAgents.clear(),this.setMemoryDirty()}updateRenderData(e,t,i){switch(i&&this.forEachLoadedNeighbor(i=>i.updateRenderData(e,t)),e){case 1:return this._updateTexture(t);case 0:return this._updateGeometry()}}_updateTexture(e){this.renderData&&(this.resetPendingUpdate(0===e?16:32),this.setPendingUpdate(0===e?32:16))}_updateGeometry(){this.setPendingUpdate(8);for(const e of this.layerInfo[0])e.pendingUpdates|=8}invalidateLayerData(e,t){this.layerInfo[t][e].invalidateSourceData(),this.restartAgents(t)}computeElevationBounds(){const e=this._elevationBoundsMin,t=this._elevationBoundsMax;let i=1/0,s=-1/0;const n=this.layerInfo[0];let r=!0;for(const a of n)null!=a.elevationBounds&&(i=Math.min(i,a.elevationBounds.min),s=Math.max(s,a.elevationBounds.max),a.elevationBounds.hasNoDataValues||(r=!1));r&&(i=Math.min(i,0),s=Math.max(s,0)),e===i&&t===s||(this._elevationBoundsMin=i,this._elevationBoundsMax=s,this.updateRadiusAndCenter(),this._surface.setTileTreeDirty())}_updateCenter(){const e=this._elevationBoundsMin,t=this._elevationBoundsMax,i=.5*(e+t),s=this._center;a(de,this.up,i),m(s[1],l(ue,this.centerAtSeaLevel,de)),a(de,this.up,e),l(s[0],this.centerAtSeaLevel,de),a(de,this.up,t),l(s[2],this.centerAtSeaLevel,de)}findElevationBoundsForLayer(e,t){const i=this.layerInfo[0][e],s=this.elevationLevelDelta,n=Math.max(this.elevationLevel-s,0),r=i.elevationBounds;if(null!=r&&r.level>=t&&r.level<=n)return;const a=this._surface.layerViewByIndex(e,0);if(!X(this,a))return;const l=te;let o=!1;const h=i.data;if(h&&h.level<=n){const e=i.data;l.min=e.samplerData.data.minValue,l.max=e.samplerData.data.maxValue,l.hasNoDataValues=e.samplerData.data.hasNoDataValues,l.level=this.level,o=!0}else{let t,i,r=0;for(let a=this._parent;a&&(!i||r<s)&&(r=this.elevationLevel-a.level,t=i||t,i=a.layerInfo[0][e].data,!(!i&&t&&a.level<=n));a=a.parent);i=i||t,i&&(i.computeMinMaxValue(this._lij[0],this._lij[1],this._lij[2],l),l.min!==1/0&&(l.level=i.level,o=!0))}o&&(null==i.elevationBounds&&(i.elevationBounds=new v),i.elevationBounds.copyFrom(l))}modifyLayers(e,t,i){const s=this.layerInfo[i];for(const a of s)a.loadingAgent&&a.loadingAgent!==H&&(K(a.loadingAgent),a.loadingAgent=null),a.waitingAgents.clear();for(let a=0;a<s.length;++a)void 0===e[a]&&s[a].release();const n=new Array(...s),r=t.length;s.length=r;for(let a=0;a<r;a++){const e=t[a];s[a]=e>-1?n[e]:J.acquire(this._surface.upsampleInfoPool)}this.setMemoryDirty()}restartAgents(e){this.renderData&&(this._createOrUpdateAgents(0,e),this.updateRenderData(e,0))}updateAgents(e){if(this.renderData){const t=this.layerInfo[e];for(const e of t)e.loadingAgent===H&&(e.loadingAgent=null);this._createOrUpdateAgents(0,e)}}updateAgentSuspension(){for(const e of x){const t=this._isSuspended(e);for(const i of this.layerInfo[e])i.loadingAgent&&i.loadingAgent!==H&&(i.loadingAgent.setSuspension(t),i.loadingAgent===H&&this.updateRenderData(e,0))}}removeLayerAgent(e,t){const i=this.layerInfo[t][e];i.loadingAgent&&i.loadingAgent!==H&&i.loadingAgent.dispose(),i.loadingAgent=null}agentDone(e,t){const i=this.layerInfo[t][e];i.loadingAgent=H,i.data||null!=i.upsampleInfo||this._createOrUpdateAgents(e+1,t)}_hasBlendableAncestor(e){return"normal"!==e.blendMode||y(e.parent)&&this._hasBlendableAncestor(e.parent)}_hasBlendModes(e,t,i){for(let s=e;s<t;++s){const e=this._surface.layerViewByIndex(s,i);if(U(e)&&"normal"!==e?.layer?.blendMode||y(e?.layer?.parent)&&this._hasBlendableAncestor(e?.layer?.parent))return!0}return!1}_createOrUpdateAgents(e,t){const i=this.layerInfo[t];if(0===i.length)return;const s=this._isSuspended(t);for(let n=e;n<i.length;++n){const r=i[n],a=this._surface.layerViewByIndex(n,t);let l=!1;if(r.loadingAgent?X(this,a)?(r.loadingAgent!==H&&r.loadingAgent.setSuspension(s),r.loadingAgent!==H&&(l=r.loadingAgent.update())):r.dispose():X(this,a)&&(r.loadingAgent=Q(this,n,t,s),l=r.loadingAgent.startLoading(),l?r.loadingAgent===H&&this.setPendingUpdate(8):(K(r.loadingAgent),r.loadingAgent=H)),r.loadingAgent===H&&this.updateRenderData(t,0),!a.destroyed&&!this._hasBlendModes(e,i.length,t)&&l&&a.isOpaque)return}}_isWithinExtent(e){const t=this.extent;return t[0]>=e[0]&&e[2]>=t[2]&&t[1]>=e[1]&&e[3]>=t[3]}intersectsExtent(e){const t=this.extent;return t[2]>=e[0]&&e[2]>=t[0]&&t[3]>=e[1]&&e[3]>=t[1]}getElevationVerticesPerSide(t){const i=this.elevationLevel-this.level,s=Math.max(this.level-t,this.elevationLevelDelta-i),n=e(1+(this._maxTesselation>>s),2,this._maxTesselation+1),r=this.minimumVerticesPerSide;return Math.max(n,r)}_findLIJ(e,t){if(!e)return null;const i=this.surface.rootTiles;if(null!=i)for(const s of i)if(ie(s,e)){let i=s,n=e[0]-i.level-1;for(;n>=0&&!i.leaf&&!t(i);){const t=e[1]>>n&1,s=e[2]>>n&1;i=i.children[2*t+s],n--}return t(i)?i:null}return null}findNeighborTile(e,t){const i=this._lij,s=this._getNeighborLIJ(i,e);return s?se(i,s)?t(this)?this:null:this._findLIJ(s,t):null}findCorner(e,t){const i=1===e?1:7===e?0:5===e?2:3;let s=this;for(;s.children[0]&&(!t||!t(s));)s=s.children[i];return s}findNeighborCornerTileExact(e,t){return this.findNeighborTile(e,e=>t(e)||e.level===this.level)?.findCorner(S(e),t)||null}forAllSubtreeOnSide(e,t){const i=0===e?[0,1]:1===e?[1]:2===e?[1,3]:3===e?[3]:4===e?[2,3]:5===e?[2]:6===e?[0,2]:[0],s=e=>{const n=e.children;!t(e)&&n[0]&&i.forEach(e=>s(n[e]))};s(this)}getNeighborEdgeStartVertexIndex(e,t){if(!t)return 0;const i=this.level-t.level;if(P(!w||i>=0),0===i)return 0;const s=2**i,n=!(1&~e),r=n?0:1,a=t.lij[r+1]*s,l=this._lij[r+1],o=l-a,h=n?s-1-o:o;return w&&(P(a<=l&&l<a+s),P(0<=h&&h<s)),h}forEachLoadedNeighbor(e){const t=this.level,i=e=>e.level===t||e.loaded;E.forEach(t=>{const s=this.findNeighborTile(t,i);null!=s&&s!==this&&s.forAllSubtreeOnSide(R(t),i=>!!i.loaded&&(e(i,t),!0))}),q.forEach(t=>{const s=this.findNeighborTile(t,i)?.findCorner(S(t),e=>e.loaded);P(!s||ne(this,s,t)),s?.loaded&&e(s,t)})}_getNeighborLIJ(e,t){const i=O(t)?-1:k(t)?1:0,s=G(t)?-1:z(t)?1:0,n=[e[0],e[1]+i,e[2]+s];return n[1]<0?null:this.surface.isGlobal?this._wrapLIJ(n):n[2]<0?null:n}_wrapLIJ(e){return!e||e[1]<0||e[1]>=2**e[0]?null:this.surface.wrapEastWest(e)}isEdgeNeighbor(e,t){if(null==e)return!1;if(0===this.level&&0===e.level){if(this._eastEnd&&e._westEnd&&2===t)return!0;if(this._westEnd&&e._eastEnd&&6===t)return!0}const i=Math.max(1e-6*(this.extent[2]-this.extent[0]),1);switch(t){case 0:return V(this.extent[3],e.extent[1],i);case 4:return V(this.extent[1],e.extent[3],i);case 2:return V(this.extent[2],e.extent[0],i)||V(this.extent[2],-e.extent[0],i);case 6:return V(this.extent[0],e.extent[2],i)||V(this.extent[0],-e.extent[2],i)}}get _eastEnd(){return this._lij[2]===this.surface.lijEastEnd(this.level)-1}get _westEnd(){return 0===this._lij[2]}checkGeometryWaterproofness(){N&&(P(this.loaded),this.renderData?.checkGeometryWaterproofness())}shouldHaveNeighbor(e){const t=this.extent,i=this.surface.rootTilesExtent,s=.25*(t[2]-t[0]);if(O(e)&&t[3]+s>=i[3])return!1;if(k(e)&&t[1]-s<=i[1])return!1;const n=this.surface.isGlobal;return!(!n&&G(e)&&t[0]-s<=i[0])&&!(!n&&z(e)&&t[2]+s>=i[2])}updateDistanceToPOI(e){const t=this._lastPOI;if(this.distanceToPOI>=0&&t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2])return;h(this._lastPOI,e);const i=this._center[1],s=e[0]-i[0],n=e[1]-i[1],r=e[2]-i[2];this.distanceToPOI=s*s+n*n+r*r}}function Q(e,t,i,s){const n=0===i?ee.acquire():Z.acquire();return n.init(e,t,i,s),n}function K(e){e.dispose(),A(e)?ee.release(e):b(e)&&Z.release(e)}const Z=new i(D),ee=new i(M),te=new v;function ie(e,t){const i=e.lij,s=t[0]-i[0];return!(s<0)&&(t[1]>>s===i[1]&&t[2]>>s===i[2])}function se(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]}function ne(e,t,i){return null!=e&&null!=t&&t!==e&&(e.level>=t.level?re(e,t,i):re(t,e,S(i)))}function re(e,t,i){P(e.level>=t.level);const s=F(i),n=W(i),r=e.extent,a=t.extent,l=[s?r[0]:r[2],n?r[3]:r[1]],o=[s?a[2]:a[0],n?a[1]:a[3]],h=1e-5*(r[2]-r[0]),d=V(l[0],o[0],h)||e.surface.isGlobal&&V(l[0],-o[0],h),u=V(l[1],o[1],h);if(d&&u)return!0;if(e.level===t.level)return P(!1),!1;if(!d&&!u)return P(!1),!1;const c=d?ae(a[1],a[3],r[1],r[3],h):ae(a[0],a[2],r[0],r[2],h);return P(c),c}function ae(e,t,i,s,n){return e-n<=i&&i<=s&&s<=t+n}const le=d(),oe=d(),he=d(),de=d(),ue=d();export{$ as Tile,ne as isCornerNeighbor,se as lijEquals};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as t}from"tslib";import i from"../../../core/Accessor.js";import e from"../../../core/Logger.js";import{lerp as r}from"../../../core/mathUtils.js";import{createScreenPointArray as s,createRenderScreenPointArray3 as o}from"../../../core/screenUtils.js";import{property as n}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/RandomLCG.js";import{subclass as h}from"../../../core/accessorSupport/decorators/subclass.js";import{copy as a,multiply as p,invert as u,transpose as l,frustum as _,equals as c,lookAt as v}from"../../../core/libs/gl-matrix-2/math/mat4.js";import{create as w}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{copy as d,exactEquals as y}from"../../../core/libs/gl-matrix-2/math/vec2.js";import{fromValues as g}from"../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{d as m,i as f,j as x,c as M,q as D,a as j,e as R,y as P,x as V,g as F,l as C,h as S,n as b,E as T}from"../../../chunks/vec32.js";import{create as I}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{d as A,e as E,a as O,c as U,f as H,t as k}from"../../../chunks/vec42.js";import{fromValues as z,create as W}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{create as L,copy as q,fromMatrix as G}from"../../../geometry/support/frustum.js";import{create as X}from"../../../geometry/support/ray.js";import{projectPointSignedLength as Y}from"../../../geometry/support/vector.js";import{fovd2fovx as N,fovx2fovd as B,fovd2fovy as J,fovy2fovd as K}from"../webgl-engine/lib/fov.js";var Q;let Z=Q=class extends i{constructor(t){super(t),this._ray=X(),this._viewport=z(0,0,1,1),this._padding=z(0,0,0,0),this._fov=55/180*Math.PI,this._nearFar=g(1,1e3),this._viewDirty=!0,this._viewMatrix=w(),this._viewProjectionDirty=!0,this._viewProjectionMatrix=w(),this._viewInverseTransposeMatrixDirty=!0,this._viewInverseTransposeMatrix=w(),this._frustumDirty=!0,this._frustum=L(),this._fullViewport=W(),this._pixelRatio=1,this.row=0,this.column=0,this._rows=1,this._columns=1,this._center=I(),this._up=I(),this.relativeElevation=0}get pixelRatio(){return this._pixelRatio}set pixelRatio(t){this._pixelRatio=t>0?t:1}get rows(){return this._rows}set rows(t){this._rows=Math.max(1,t)}get columns(){return this._columns}set columns(t){this._columns=Math.max(1,t)}get eye(){return this._ray.origin}set eye(t){this._compareAndSetView(t,this._ray.origin)}get center(){return this._center}set center(t){this._compareAndSetView(t,this._center,"_center")}get ray(){return m(this._ray.direction,this.center,this.eye),this._ray}get up(){return this._up}set up(t){this._compareAndSetView(t,this._up,"_up")}get viewMatrix(){return this._ensureViewClean(),this._viewMatrix}set viewMatrix(t){a(this._viewMatrix,t),this.notifyChange("_viewMatrix"),this._viewDirty=!1,this._viewInverseTransposeMatrixDirty=!0,this._viewProjectionDirty=!0,this._frustumDirty=!0}get viewForward(){return this._ensureViewClean(),f(I(),-this._viewMatrix[2],-this._viewMatrix[6],-this._viewMatrix[10])}get viewUp(){return this._ensureViewClean(),f(I(),this._viewMatrix[1],this._viewMatrix[5],this._viewMatrix[9])}get viewRight(){return this._ensureViewClean(),f(I(),this._viewMatrix[0],this._viewMatrix[4],this._viewMatrix[8])}get nearFar(){return this._nearFar}get near(){return this._nearFar[0]}set near(t){this._nearFar[0]!==t&&(this._nearFar[0]=t,this._viewProjectionDirty=!0,this._frustumDirty=!0,this.notifyChange("_nearFar"))}get far(){return this._nearFar[1]}set far(t){this._nearFar[1]!==t&&(this._nearFar[1]=t,this._viewProjectionDirty=!0,this._frustumDirty=!0,this.notifyChange("_nearFar"))}get viewport(){return this._viewport}set viewport(t){this.x=t[0],this.y=t[1],this.width=t[2],this.height=t[3]}get screenViewport(){if(1===this.pixelRatio)return this._viewport;const t=A(W(),this._viewport,1/this.pixelRatio),i=this._get("screenViewport");return i&&E(t,i)?i:t}get screenPadding(){if(1===this.pixelRatio)return this._padding;const t=A(W(),this._padding,1/this.pixelRatio),i=this._get("screenPadding");return i&&E(t,i)?i:t}get x(){return this._viewport[0]}set x(t){t+=this._padding[3],this._viewport[0]!==t&&(this._viewport[0]=t,this._viewProjectionDirty=!0,this._frustumDirty=!0,this.notifyChange("_viewport"))}get y(){return this._viewport[1]}set y(t){t+=this._padding[2],this._viewport[1]!==t&&(this._viewport[1]=t,this._viewProjectionDirty=!0,this._frustumDirty=!0,this.notifyChange("_viewport"))}get width(){return this._viewport[2]}set width(t){this._viewport[2]!==t&&(this._viewport[2]=t,this._viewProjectionDirty=!0,this._frustumDirty=!0,this.notifyChange("_viewport"))}get height(){return this._viewport[3]}set height(t){this._viewport[3]!==t&&(this._viewport[3]=t,this._viewProjectionDirty=!0,this._frustumDirty=!0,this.notifyChange("_viewport"))}get fullWidth(){return this._viewport[2]+this._padding[1]+this._padding[3]}set fullWidth(t){this.width=t-(this._padding[1]+this._padding[3])}get fullHeight(){return this._viewport[3]+this._padding[0]+this._padding[2]}set fullHeight(t){this.height=t-(this._padding[0]+this._padding[2])}get fullViewport(){return this._fullViewport[0]=this._viewport[0]-this._padding[3],this._fullViewport[1]=this._viewport[1]-this._padding[2],this._fullViewport[2]=this.fullWidth,this._fullViewport[3]=this.fullHeight,this._fullViewport}get _aspect(){return this.width/this.height}get padding(){return this._padding}set padding(t){O(this._padding,t)||(this._viewport[0]+=t[3]-this._padding[3],this._viewport[1]+=t[2]-this._padding[2],this._viewport[2]-=t[1]+t[3]-(this._padding[1]+this._padding[3]),this._viewport[3]-=t[0]+t[2]-(this._padding[0]+this._padding[2]),U(this._padding,t),this._viewProjectionDirty=!0,this._frustumDirty=!0,this.notifyChange("_padding"),this.notifyChange("_viewport"))}get viewProjectionMatrix(){return this._viewProjectionDirty&&(p(this._viewProjectionMatrix,this.projectionMatrix,this.viewMatrix),this._viewProjectionDirty=!1),this._viewProjectionMatrix}get projectionMatrix(){return this._projectionMatrixInternal}get inverseProjectionMatrix(){return u(w(),this.projectionMatrix)||this._get("inverseProjectionMatrix")||w()}get fov(){return this._fov}set fov(t){this._fov=t,this._viewProjectionDirty=!0,this._frustumDirty=!0}get fovX(){return N(this._fov,this.width,this.height)}set fovX(t){this._fov=B(t,this.width,this.height),this._viewProjectionDirty=!0,this._frustumDirty=!0}get fovY(){return J(this._fov,this.width,this.height)}set fovY(t){this._fov=K(t,this.width,this.height),this._viewProjectionDirty=!0,this._frustumDirty=!0}get distance(){return x(this.center,this.eye)}get frustum(){return this._recomputeFrustum(),this._frustum}get viewInverseTransposeMatrix(){return(this._viewInverseTransposeMatrixDirty||this._viewDirty)&&(u(this._viewInverseTransposeMatrix,this.viewMatrix),l(this._viewInverseTransposeMatrix,this._viewInverseTransposeMatrix),this._viewInverseTransposeMatrixDirty=!1),this._viewInverseTransposeMatrix}depthNDCToWorld(t){const{near:i,far:e}=this;return 2*i*e/(e+i-t*(e-i))}get perRenderPixelRatio(){return Math.tan(this.fovX/2)/(this.width/2)}get perScreenPixelRatio(){return this.perRenderPixelRatio*this.pixelRatio}get aboveGround(){return null!=this.relativeElevation&&this.relativeElevation>=0}get _projectionMatrixInternal(){const t=this.width,i=this.height,e=this.near*Math.tan(this.fovY/2)*2,r=e*this._aspect,s=e/this.rows,o=r/this.columns,n=-r/2+this.column*o,h=n+o,a=-e/2+this.row*s,p=a+s,u=_(w(),n*(1+2*this._padding[3]/t),h*(1+2*this._padding[1]/t),a*(1+2*this._padding[2]/i),p*(1+2*this._padding[0]/i),this.near,this.far),l=this._get("projectionMatrix");return l&&c(l,u)?l:u}copyFrom(t){M(this._ray.origin,t.eye),this.center=t.center,this.up=t.up,U(this._viewport,t.viewport),this.notifyChange("_viewport"),U(this._padding,t.padding),this.notifyChange("_padding"),d(this._nearFar,t.nearFar),this.notifyChange("_nearFar"),this._fov=t.fov,this.row=t.row,this.column=t.column,this.rows=t.rows,this.columns=t.columns,this.relativeElevation=t.relativeElevation;const i=t;return this._viewDirty=i._viewDirty,this._viewDirty||(a(this._viewMatrix,t.viewMatrix),this.notifyChange("_viewMatrix")),this._viewProjectionDirty=!0,this._frustumDirty=i._frustumDirty,this._frustumDirty||(q(this._frustum,t.frustum),this._frustumDirty=!1),i._viewInverseTransposeMatrixDirty?this._viewInverseTransposeMatrixDirty=!0:(a(this._viewInverseTransposeMatrix,t.viewInverseTransposeMatrix),this._viewInverseTransposeMatrixDirty=!1),U(this._fullViewport,t.fullViewport),this.pixelRatio=t.pixelRatio,this}copyViewFrom(t){this.eye=t.eye,this.center=t.center,this.up=t.up,this.fov=t.fov}clone(){return(new Q).copyFrom(this)}equals(t){return D(this.eye,t.eye)&&D(this.center,t.center)&&D(this.up,t.up)&&O(this._viewport,t.viewport)&&O(this._padding,t.padding)&&y(this.nearFar,t.nearFar)&&this._fov===t.fov&&this.pixelRatio===t.pixelRatio&&this.relativeElevation===t.relativeElevation&&this.row===t.row&&this.column===t.column&&this.rows===t.rows&&this.columns===t.columns}almostEquals(t){const i=Math.max(1,1/this.pixelRatio,1/t.pixelRatio);if(Math.abs(t.fov-this._fov)>=.001||H(t.screenPadding,this.screenPadding)>=i||H(this.screenViewport,t.screenViewport)>=i||this.row!==t.row||this.column!==t.column||this.rows!==t.rows||this.columns!==t.columns)return!1;j(et,t.eye,t.center),j(rt,this.eye,this.center);const e=R(et,rt),r=P(et),s=P(rt),o=5e-4;return e*e>=(1-1e-10)*r*s&&V(t.eye,this.eye)<Math.max(r,s)*o*o}computeRenderPixelSizeAt(t){return this.computeRenderPixelSizeAtDist(this._viewDirectionDistance(t))}computeRenderPixelSizeAtDist(t){return t*this.perRenderPixelRatio}computeScreenPixelSizeAt(t){return this.computeScreenPixelSizeAtDist(this._viewDirectionDistance(t))}_viewDirectionDistance(t){return Math.abs(Y(this.viewForward,m(et,t,this.eye)))}computeScreenPixelSizeAtDist(t){return t*this.perScreenPixelRatio}computeDistanceFromRadius(t,i){return t/Math.tan(Math.min(this.fovX,this.fovY)/(2*(i||1)))}getScreenCenter(t=s()){return t[0]=(this.padding[3]+this.width/2)/this.pixelRatio,t[1]=(this.padding[0]+this.height/2)/this.pixelRatio,t}getRenderCenter(t,i=.5,e=.5){return t[0]=this.padding[3]+this.width*i,t[1]=this.padding[2]+this.height*e,t[2]=.5,t}setGLViewport(t){const i=this.viewport,e=this.padding;t.setViewport(i[0]-e[3],i[1]-e[2],i[2]+e[1]+e[3],i[3]+e[0]+e[2])}applyProjection(t,i){t!==tt&&M(tt,t),tt[3]=1,k(tt,tt,this.projectionMatrix);const e=Math.abs(tt[3]);F(tt,tt,1/e);const s=this.fullViewport;i[0]=r(0,s[0]+s[2],.5+.5*tt[0]),i[1]=r(0,s[1]+s[3],.5+.5*tt[1]),i[2]=.5*(tt[2]+1),i[3]=e}unapplyProjection(t,i){const e=this.fullViewport;tt[0]=(t[0]/(e[0]+e[2])*2-1)*t[3],tt[1]=(t[1]/(e[1]+e[3])*2-1)*t[3],tt[2]=(2*t[2]-1)*t[3],tt[3]=t[3],null!=this.inverseProjectionMatrix&&(k(tt,tt,this.inverseProjectionMatrix),i[0]=tt[0],i[1]=tt[1],i[2]=tt[2])}projectToScreen(t,i){return this.projectToRenderScreen(t,st),this.renderToScreen(st,i),i}projectToRenderScreen(t,i){if(tt[0]=t[0],tt[1]=t[1],tt[2]=t[2],tt[3]=1,k(tt,tt,this.viewProjectionMatrix),0===tt[3])return null;const e=tt;F(e,e,1/Math.abs(tt[3]));const s=this.fullViewport,o=r(0,s[0]+s[2],.5+.5*e[0]),n=r(0,s[1]+s[3],.5+.5*e[1]);return"x"in i?(i.x=o,i.y=n):(i[0]=o,i[1]=n,i.length>2&&(i[2]=.5*(e[2]+1))),i}unprojectFromScreen(t,i){return this.unprojectFromRenderScreen(this.screenToRender(t,st),i)}unprojectFromRenderScreen(t,i){if(p(it,this.projectionMatrix,this.viewMatrix),!u(it,it))return null;const e=this.fullViewport;return tt[0]=2*(t[0]-e[0])/e[2]-1,tt[1]=2*(t[1]-e[1])/e[3]-1,tt[2]=2*t[2]-1,tt[3]=1,k(tt,tt,it),0===tt[3]?null:(i[0]=tt[0]/tt[3],i[1]=tt[1]/tt[3],i[2]=tt[2]/tt[3],i)}constrainWindowSize(t,i,e,r){const s=t*this.pixelRatio,o=i*this.pixelRatio,n=Math.max(s-e/2,0),h=Math.max(this.fullHeight-o-r/2,0),a=-Math.min(s-e/2,0),p=-Math.min(this.fullHeight-o-r/2,0),u=e-a- -Math.min(this.fullWidth-s-e/2,0),l=r-p- -Math.min(o-r/2,0);return[Math.round(n),Math.round(h),Math.round(u),Math.round(l)]}computeUp(t){1===t?this._computeUpGlobal():this._computeUpLocal()}screenToRender(t,i){const e=t[0]*this.pixelRatio,r=this.fullHeight-t[1]*this.pixelRatio;return i[0]=e,i[1]=r,i}renderToScreen(t,i){const e=t[0]/this.pixelRatio,r=(this.fullHeight-t[1])/this.pixelRatio;i[0]=e,i[1]=r}_computeUpGlobal(){m(et,this.center,this.eye);const t=C(this.center);t<1?(f(this._up,0,0,1),this._markViewDirty(),this.notifyChange("_up")):Math.abs(R(et,this.center))>.9999*C(et)*t||(S(this._up,et,this.center),S(this._up,this._up,et),b(this._up,this._up),this.notifyChange("_up"),this._markViewDirty())}_computeUpLocal(){T(et,this.eye,this.center),Math.abs(et[2])<=.9999&&(F(et,et,et[2]),f(this._up,-et[0],-et[1],1-et[2]),b(this._up,this._up),this.notifyChange("_up"),this._markViewDirty())}_compareAndSetView(t,i,r=""){"number"==typeof t[0]&&isFinite(t[0])&&"number"==typeof t[1]&&isFinite(t[1])&&"number"==typeof t[2]&&isFinite(t[2])?D(t,i)||(M(i,t),this._markViewDirty(),r.length&&this.notifyChange(r)):e.getLogger("esri.views.3d.webgl-engine.lib.RenderCamera").warn("RenderCamera vector contains invalid number, ignoring value")}_markViewDirty(){this._viewDirty=!0,this._frustumDirty=!0,this._viewProjectionDirty=!0}_recomputeFrustum(){this._frustumDirty&&(G(this.viewMatrix,this.projectionMatrix,this._frustum),this._frustumDirty=!1)}_ensureViewClean(){this._viewDirty&&(v(this._viewMatrix,this.eye,this.center,this.up),this.notifyChange("_viewMatrix"),this._viewDirty=!1,this._viewInverseTransposeMatrixDirty=!0)}};t([n()],Z.prototype,"_viewport",void 0),t([n()],Z.prototype,"_padding",void 0),t([n()],Z.prototype,"_fov",void 0),t([n()],Z.prototype,"_nearFar",void 0),t([n()],Z.prototype,"_viewDirty",void 0),t([n()],Z.prototype,"_viewMatrix",void 0),t([n()],Z.prototype,"_pixelRatio",void 0),t([n()],Z.prototype,"pixelRatio",null),t([n()],Z.prototype,"row",void 0),t([n()],Z.prototype,"column",void 0),t([n()],Z.prototype,"_rows",void 0),t([n()],Z.prototype,"rows",null),t([n()],Z.prototype,"_columns",void 0),t([n()],Z.prototype,"columns",null),t([n()],Z.prototype,"eye",null),t([n()],Z.prototype,"center",null),t([n()],Z.prototype,"_center",void 0),t([n()],Z.prototype,"up",null),t([n()],Z.prototype,"_up",void 0),t([n()],Z.prototype,"viewMatrix",null),t([n({readOnly:!0})],Z.prototype,"viewForward",null),t([n({readOnly:!0})],Z.prototype,"viewUp",null),t([n({readOnly:!0})],Z.prototype,"viewRight",null),t([n({readOnly:!0})],Z.prototype,"nearFar",null),t([n()],Z.prototype,"near",null),t([n()],Z.prototype,"far",null),t([n()],Z.prototype,"viewport",null),t([n({readOnly:!0})],Z.prototype,"screenViewport",null),t([n({readOnly:!0})],Z.prototype,"screenPadding",null),t([n()],Z.prototype,"x",null),t([n()],Z.prototype,"y",null),t([n()],Z.prototype,"width",null),t([n()],Z.prototype,"height",null),t([n()],Z.prototype,"fullWidth",null),t([n()],Z.prototype,"fullHeight",null),t([n({readOnly:!0})],Z.prototype,"_aspect",null),t([n()],Z.prototype,"padding",null),t([n({readOnly:!0})],Z.prototype,"projectionMatrix",null),t([n({readOnly:!0})],Z.prototype,"inverseProjectionMatrix",null),t([n()],Z.prototype,"fov",null),t([n()],Z.prototype,"fovX",null),t([n()],Z.prototype,"fovY",null),t([n()],Z.prototype,"viewInverseTransposeMatrix",null),t([n({readOnly:!0})],Z.prototype,"_projectionMatrixInternal",null),t([n()],Z.prototype,"relativeElevation",void 0),Z=Q=t([h("esri.views.3d.webgl.RenderCamera")],Z);const $=Z,tt=W(),it=w(),et=I(),rt=I(),st=o();export{$ as default};
5
+ import{__decorate as t}from"tslib";import i from"../../../core/Accessor.js";import e from"../../../core/Logger.js";import{lerp as r}from"../../../core/mathUtils.js";import{createScreenPointArray as s,createRenderScreenPointArray3 as o}from"../../../core/screenUtils.js";import{property as n}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/RandomLCG.js";import{subclass as h}from"../../../core/accessorSupport/decorators/subclass.js";import{copy as a,multiply as p,invert as u,transpose as l,frustum as _,equals as c,lookAt as v}from"../../../core/libs/gl-matrix-2/math/mat4.js";import{create as w}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{copy as d,exactEquals as y}from"../../../core/libs/gl-matrix-2/math/vec2.js";import{fromValues as g}from"../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{d as m,i as f,j as x,c as M,q as D,a as j,e as R,y as P,x as V,g as F,l as C,h as S,n as b,E as T}from"../../../chunks/vec32.js";import{create as I}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{c as A,e as E,a as O,d as U,f as H,t as k}from"../../../chunks/vec42.js";import{fromValues as z,create as W}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{create as L,copy as q,fromMatrix as G}from"../../../geometry/support/frustum.js";import{create as X}from"../../../geometry/support/ray.js";import{projectPointSignedLength as Y}from"../../../geometry/support/vector.js";import{fovd2fovx as N,fovx2fovd as B,fovd2fovy as J,fovy2fovd as K}from"../webgl-engine/lib/fov.js";var Q;let Z=Q=class extends i{constructor(t){super(t),this._ray=X(),this._viewport=z(0,0,1,1),this._padding=z(0,0,0,0),this._fov=55/180*Math.PI,this._nearFar=g(1,1e3),this._viewDirty=!0,this._viewMatrix=w(),this._viewProjectionDirty=!0,this._viewProjectionMatrix=w(),this._viewInverseTransposeMatrixDirty=!0,this._viewInverseTransposeMatrix=w(),this._frustumDirty=!0,this._frustum=L(),this._fullViewport=W(),this._pixelRatio=1,this.row=0,this.column=0,this._rows=1,this._columns=1,this._center=I(),this._up=I(),this.relativeElevation=0}get pixelRatio(){return this._pixelRatio}set pixelRatio(t){this._pixelRatio=t>0?t:1}get rows(){return this._rows}set rows(t){this._rows=Math.max(1,t)}get columns(){return this._columns}set columns(t){this._columns=Math.max(1,t)}get eye(){return this._ray.origin}set eye(t){this._compareAndSetView(t,this._ray.origin)}get center(){return this._center}set center(t){this._compareAndSetView(t,this._center,"_center")}get ray(){return m(this._ray.direction,this.center,this.eye),this._ray}get up(){return this._up}set up(t){this._compareAndSetView(t,this._up,"_up")}get viewMatrix(){return this._ensureViewClean(),this._viewMatrix}set viewMatrix(t){a(this._viewMatrix,t),this.notifyChange("_viewMatrix"),this._viewDirty=!1,this._viewInverseTransposeMatrixDirty=!0,this._viewProjectionDirty=!0,this._frustumDirty=!0}get viewForward(){return this._ensureViewClean(),f(I(),-this._viewMatrix[2],-this._viewMatrix[6],-this._viewMatrix[10])}get viewUp(){return this._ensureViewClean(),f(I(),this._viewMatrix[1],this._viewMatrix[5],this._viewMatrix[9])}get viewRight(){return this._ensureViewClean(),f(I(),this._viewMatrix[0],this._viewMatrix[4],this._viewMatrix[8])}get nearFar(){return this._nearFar}get near(){return this._nearFar[0]}set near(t){this._nearFar[0]!==t&&(this._nearFar[0]=t,this._viewProjectionDirty=!0,this._frustumDirty=!0,this.notifyChange("_nearFar"))}get far(){return this._nearFar[1]}set far(t){this._nearFar[1]!==t&&(this._nearFar[1]=t,this._viewProjectionDirty=!0,this._frustumDirty=!0,this.notifyChange("_nearFar"))}get viewport(){return this._viewport}set viewport(t){this.x=t[0],this.y=t[1],this.width=t[2],this.height=t[3]}get screenViewport(){if(1===this.pixelRatio)return this._viewport;const t=A(W(),this._viewport,1/this.pixelRatio),i=this._get("screenViewport");return i&&E(t,i)?i:t}get screenPadding(){if(1===this.pixelRatio)return this._padding;const t=A(W(),this._padding,1/this.pixelRatio),i=this._get("screenPadding");return i&&E(t,i)?i:t}get x(){return this._viewport[0]}set x(t){t+=this._padding[3],this._viewport[0]!==t&&(this._viewport[0]=t,this._viewProjectionDirty=!0,this._frustumDirty=!0,this.notifyChange("_viewport"))}get y(){return this._viewport[1]}set y(t){t+=this._padding[2],this._viewport[1]!==t&&(this._viewport[1]=t,this._viewProjectionDirty=!0,this._frustumDirty=!0,this.notifyChange("_viewport"))}get width(){return this._viewport[2]}set width(t){this._viewport[2]!==t&&(this._viewport[2]=t,this._viewProjectionDirty=!0,this._frustumDirty=!0,this.notifyChange("_viewport"))}get height(){return this._viewport[3]}set height(t){this._viewport[3]!==t&&(this._viewport[3]=t,this._viewProjectionDirty=!0,this._frustumDirty=!0,this.notifyChange("_viewport"))}get fullWidth(){return this._viewport[2]+this._padding[1]+this._padding[3]}set fullWidth(t){this.width=t-(this._padding[1]+this._padding[3])}get fullHeight(){return this._viewport[3]+this._padding[0]+this._padding[2]}set fullHeight(t){this.height=t-(this._padding[0]+this._padding[2])}get fullViewport(){return this._fullViewport[0]=this._viewport[0]-this._padding[3],this._fullViewport[1]=this._viewport[1]-this._padding[2],this._fullViewport[2]=this.fullWidth,this._fullViewport[3]=this.fullHeight,this._fullViewport}get _aspect(){return this.width/this.height}get padding(){return this._padding}set padding(t){O(this._padding,t)||(this._viewport[0]+=t[3]-this._padding[3],this._viewport[1]+=t[2]-this._padding[2],this._viewport[2]-=t[1]+t[3]-(this._padding[1]+this._padding[3]),this._viewport[3]-=t[0]+t[2]-(this._padding[0]+this._padding[2]),U(this._padding,t),this._viewProjectionDirty=!0,this._frustumDirty=!0,this.notifyChange("_padding"),this.notifyChange("_viewport"))}get viewProjectionMatrix(){return this._viewProjectionDirty&&(p(this._viewProjectionMatrix,this.projectionMatrix,this.viewMatrix),this._viewProjectionDirty=!1),this._viewProjectionMatrix}get projectionMatrix(){return this._projectionMatrixInternal}get inverseProjectionMatrix(){return u(w(),this.projectionMatrix)||this._get("inverseProjectionMatrix")||w()}get fov(){return this._fov}set fov(t){this._fov=t,this._viewProjectionDirty=!0,this._frustumDirty=!0}get fovX(){return N(this._fov,this.width,this.height)}set fovX(t){this._fov=B(t,this.width,this.height),this._viewProjectionDirty=!0,this._frustumDirty=!0}get fovY(){return J(this._fov,this.width,this.height)}set fovY(t){this._fov=K(t,this.width,this.height),this._viewProjectionDirty=!0,this._frustumDirty=!0}get distance(){return x(this.center,this.eye)}get frustum(){return this._recomputeFrustum(),this._frustum}get viewInverseTransposeMatrix(){return(this._viewInverseTransposeMatrixDirty||this._viewDirty)&&(u(this._viewInverseTransposeMatrix,this.viewMatrix),l(this._viewInverseTransposeMatrix,this._viewInverseTransposeMatrix),this._viewInverseTransposeMatrixDirty=!1),this._viewInverseTransposeMatrix}depthNDCToWorld(t){const{near:i,far:e}=this;return 2*i*e/(e+i-t*(e-i))}get perRenderPixelRatio(){return Math.tan(this.fovX/2)/(this.width/2)}get perScreenPixelRatio(){return this.perRenderPixelRatio*this.pixelRatio}get aboveGround(){return null!=this.relativeElevation&&this.relativeElevation>=0}get _projectionMatrixInternal(){const t=this.width,i=this.height,e=this.near*Math.tan(this.fovY/2)*2,r=e*this._aspect,s=e/this.rows,o=r/this.columns,n=-r/2+this.column*o,h=n+o,a=-e/2+this.row*s,p=a+s,u=_(w(),n*(1+2*this._padding[3]/t),h*(1+2*this._padding[1]/t),a*(1+2*this._padding[2]/i),p*(1+2*this._padding[0]/i),this.near,this.far),l=this._get("projectionMatrix");return l&&c(l,u)?l:u}copyFrom(t){M(this._ray.origin,t.eye),this.center=t.center,this.up=t.up,U(this._viewport,t.viewport),this.notifyChange("_viewport"),U(this._padding,t.padding),this.notifyChange("_padding"),d(this._nearFar,t.nearFar),this.notifyChange("_nearFar"),this._fov=t.fov,this.row=t.row,this.column=t.column,this.rows=t.rows,this.columns=t.columns,this.relativeElevation=t.relativeElevation;const i=t;return this._viewDirty=i._viewDirty,this._viewDirty||(a(this._viewMatrix,t.viewMatrix),this.notifyChange("_viewMatrix")),this._viewProjectionDirty=!0,this._frustumDirty=i._frustumDirty,this._frustumDirty||(q(this._frustum,t.frustum),this._frustumDirty=!1),i._viewInverseTransposeMatrixDirty?this._viewInverseTransposeMatrixDirty=!0:(a(this._viewInverseTransposeMatrix,t.viewInverseTransposeMatrix),this._viewInverseTransposeMatrixDirty=!1),U(this._fullViewport,t.fullViewport),this.pixelRatio=t.pixelRatio,this}copyViewFrom(t){this.eye=t.eye,this.center=t.center,this.up=t.up,this.fov=t.fov}clone(){return(new Q).copyFrom(this)}equals(t){return D(this.eye,t.eye)&&D(this.center,t.center)&&D(this.up,t.up)&&O(this._viewport,t.viewport)&&O(this._padding,t.padding)&&y(this.nearFar,t.nearFar)&&this._fov===t.fov&&this.pixelRatio===t.pixelRatio&&this.relativeElevation===t.relativeElevation&&this.row===t.row&&this.column===t.column&&this.rows===t.rows&&this.columns===t.columns}almostEquals(t){const i=Math.max(1,1/this.pixelRatio,1/t.pixelRatio);if(Math.abs(t.fov-this._fov)>=.001||H(t.screenPadding,this.screenPadding)>=i||H(this.screenViewport,t.screenViewport)>=i||this.row!==t.row||this.column!==t.column||this.rows!==t.rows||this.columns!==t.columns)return!1;j(et,t.eye,t.center),j(rt,this.eye,this.center);const e=R(et,rt),r=P(et),s=P(rt),o=5e-4;return e*e>=(1-1e-10)*r*s&&V(t.eye,this.eye)<Math.max(r,s)*o*o}computeRenderPixelSizeAt(t){return this.computeRenderPixelSizeAtDist(this._viewDirectionDistance(t))}computeRenderPixelSizeAtDist(t){return t*this.perRenderPixelRatio}computeScreenPixelSizeAt(t){return this.computeScreenPixelSizeAtDist(this._viewDirectionDistance(t))}_viewDirectionDistance(t){return Math.abs(Y(this.viewForward,m(et,t,this.eye)))}computeScreenPixelSizeAtDist(t){return t*this.perScreenPixelRatio}computeDistanceFromRadius(t,i){return t/Math.tan(Math.min(this.fovX,this.fovY)/(2*(i||1)))}getScreenCenter(t=s()){return t[0]=(this.padding[3]+this.width/2)/this.pixelRatio,t[1]=(this.padding[0]+this.height/2)/this.pixelRatio,t}getRenderCenter(t,i=.5,e=.5){return t[0]=this.padding[3]+this.width*i,t[1]=this.padding[2]+this.height*e,t[2]=.5,t}setGLViewport(t){const i=this.viewport,e=this.padding;t.setViewport(i[0]-e[3],i[1]-e[2],i[2]+e[1]+e[3],i[3]+e[0]+e[2])}applyProjection(t,i){t!==tt&&M(tt,t),tt[3]=1,k(tt,tt,this.projectionMatrix);const e=Math.abs(tt[3]);F(tt,tt,1/e);const s=this.fullViewport;i[0]=r(0,s[0]+s[2],.5+.5*tt[0]),i[1]=r(0,s[1]+s[3],.5+.5*tt[1]),i[2]=.5*(tt[2]+1),i[3]=e}unapplyProjection(t,i){const e=this.fullViewport;tt[0]=(t[0]/(e[0]+e[2])*2-1)*t[3],tt[1]=(t[1]/(e[1]+e[3])*2-1)*t[3],tt[2]=(2*t[2]-1)*t[3],tt[3]=t[3],null!=this.inverseProjectionMatrix&&(k(tt,tt,this.inverseProjectionMatrix),i[0]=tt[0],i[1]=tt[1],i[2]=tt[2])}projectToScreen(t,i){return this.projectToRenderScreen(t,st),this.renderToScreen(st,i),i}projectToRenderScreen(t,i){if(tt[0]=t[0],tt[1]=t[1],tt[2]=t[2],tt[3]=1,k(tt,tt,this.viewProjectionMatrix),0===tt[3])return null;const e=tt;F(e,e,1/Math.abs(tt[3]));const s=this.fullViewport,o=r(0,s[0]+s[2],.5+.5*e[0]),n=r(0,s[1]+s[3],.5+.5*e[1]);return"x"in i?(i.x=o,i.y=n):(i[0]=o,i[1]=n,i.length>2&&(i[2]=.5*(e[2]+1))),i}unprojectFromScreen(t,i){return this.unprojectFromRenderScreen(this.screenToRender(t,st),i)}unprojectFromRenderScreen(t,i){if(p(it,this.projectionMatrix,this.viewMatrix),!u(it,it))return null;const e=this.fullViewport;return tt[0]=2*(t[0]-e[0])/e[2]-1,tt[1]=2*(t[1]-e[1])/e[3]-1,tt[2]=2*t[2]-1,tt[3]=1,k(tt,tt,it),0===tt[3]?null:(i[0]=tt[0]/tt[3],i[1]=tt[1]/tt[3],i[2]=tt[2]/tt[3],i)}constrainWindowSize(t,i,e,r){const s=t*this.pixelRatio,o=i*this.pixelRatio,n=Math.max(s-e/2,0),h=Math.max(this.fullHeight-o-r/2,0),a=-Math.min(s-e/2,0),p=-Math.min(this.fullHeight-o-r/2,0),u=e-a- -Math.min(this.fullWidth-s-e/2,0),l=r-p- -Math.min(o-r/2,0);return[Math.round(n),Math.round(h),Math.round(u),Math.round(l)]}computeUp(t){1===t?this._computeUpGlobal():this._computeUpLocal()}screenToRender(t,i){const e=t[0]*this.pixelRatio,r=this.fullHeight-t[1]*this.pixelRatio;return i[0]=e,i[1]=r,i}renderToScreen(t,i){const e=t[0]/this.pixelRatio,r=(this.fullHeight-t[1])/this.pixelRatio;i[0]=e,i[1]=r}_computeUpGlobal(){m(et,this.center,this.eye);const t=C(this.center);t<1?(f(this._up,0,0,1),this._markViewDirty(),this.notifyChange("_up")):Math.abs(R(et,this.center))>.9999*C(et)*t||(S(this._up,et,this.center),S(this._up,this._up,et),b(this._up,this._up),this.notifyChange("_up"),this._markViewDirty())}_computeUpLocal(){T(et,this.eye,this.center),Math.abs(et[2])<=.9999&&(F(et,et,et[2]),f(this._up,-et[0],-et[1],1-et[2]),b(this._up,this._up),this.notifyChange("_up"),this._markViewDirty())}_compareAndSetView(t,i,r=""){"number"==typeof t[0]&&isFinite(t[0])&&"number"==typeof t[1]&&isFinite(t[1])&&"number"==typeof t[2]&&isFinite(t[2])?D(t,i)||(M(i,t),this._markViewDirty(),r.length&&this.notifyChange(r)):e.getLogger("esri.views.3d.webgl-engine.lib.RenderCamera").warn("RenderCamera vector contains invalid number, ignoring value")}_markViewDirty(){this._viewDirty=!0,this._frustumDirty=!0,this._viewProjectionDirty=!0}_recomputeFrustum(){this._frustumDirty&&(G(this.viewMatrix,this.projectionMatrix,this._frustum),this._frustumDirty=!1)}_ensureViewClean(){this._viewDirty&&(v(this._viewMatrix,this.eye,this.center,this.up),this.notifyChange("_viewMatrix"),this._viewDirty=!1,this._viewInverseTransposeMatrixDirty=!0)}};t([n()],Z.prototype,"_viewport",void 0),t([n()],Z.prototype,"_padding",void 0),t([n()],Z.prototype,"_fov",void 0),t([n()],Z.prototype,"_nearFar",void 0),t([n()],Z.prototype,"_viewDirty",void 0),t([n()],Z.prototype,"_viewMatrix",void 0),t([n()],Z.prototype,"_pixelRatio",void 0),t([n()],Z.prototype,"pixelRatio",null),t([n()],Z.prototype,"row",void 0),t([n()],Z.prototype,"column",void 0),t([n()],Z.prototype,"_rows",void 0),t([n()],Z.prototype,"rows",null),t([n()],Z.prototype,"_columns",void 0),t([n()],Z.prototype,"columns",null),t([n()],Z.prototype,"eye",null),t([n()],Z.prototype,"center",null),t([n()],Z.prototype,"_center",void 0),t([n()],Z.prototype,"up",null),t([n()],Z.prototype,"_up",void 0),t([n()],Z.prototype,"viewMatrix",null),t([n({readOnly:!0})],Z.prototype,"viewForward",null),t([n({readOnly:!0})],Z.prototype,"viewUp",null),t([n({readOnly:!0})],Z.prototype,"viewRight",null),t([n({readOnly:!0})],Z.prototype,"nearFar",null),t([n()],Z.prototype,"near",null),t([n()],Z.prototype,"far",null),t([n()],Z.prototype,"viewport",null),t([n({readOnly:!0})],Z.prototype,"screenViewport",null),t([n({readOnly:!0})],Z.prototype,"screenPadding",null),t([n()],Z.prototype,"x",null),t([n()],Z.prototype,"y",null),t([n()],Z.prototype,"width",null),t([n()],Z.prototype,"height",null),t([n()],Z.prototype,"fullWidth",null),t([n()],Z.prototype,"fullHeight",null),t([n({readOnly:!0})],Z.prototype,"_aspect",null),t([n()],Z.prototype,"padding",null),t([n({readOnly:!0})],Z.prototype,"projectionMatrix",null),t([n({readOnly:!0})],Z.prototype,"inverseProjectionMatrix",null),t([n()],Z.prototype,"fov",null),t([n()],Z.prototype,"fovX",null),t([n()],Z.prototype,"fovY",null),t([n()],Z.prototype,"viewInverseTransposeMatrix",null),t([n({readOnly:!0})],Z.prototype,"_projectionMatrixInternal",null),t([n()],Z.prototype,"relativeElevation",void 0),Z=Q=t([h("esri.views.3d.webgl.RenderCamera")],Z);const $=Z,tt=W(),it=w(),et=I(),rt=I(),st=o();export{$ 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/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import t from"../../../core/Accessor.js";import{removeUnordered as r}from"../../../core/arrayUtils.js";import{toConst as s}from"../../../core/compilerUtils.js";import"../../../core/has.js";import{destroyMaybe as i}from"../../../core/maybe.js";import{isPromiseLike as n}from"../../../core/promiseUtils.js";import{signal as o}from"../../../core/signal.js";import{property as d}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/Logger.js";import{subclass as a}from"../../../core/accessorSupport/decorators/subclass.js";import{isIntersectionHandler as h}from"../state/helpers/SceneIntersectionHelper.js";import{TextureCollection as l}from"../support/TextureCollection.js";import{ChangeSet as c}from"./lib/ChangeSet.js";import{Model as m}from"./parts/Model.js";import{RenderView as y}from"./parts/RenderView.js";import{TaskPriority as u,noBudget as p}from"../../support/Scheduler.js";import{Yield as _}from"../../support/Yield.js";let g=class extends t{constructor(e){super(e),this._model=new m,this._canCompact=o(!1),this._layers=new Array,this._asyncChangeSet=new c,this._syncChangeSet=new c,this._layerSyncSet=new Set,this._textures=new l(this,e.view.resourceController.scheduler),this._frameTask=e.view.resourceController.scheduler.registerTask(u.STAGE,this),this.addHandles(this._frameTask)}initialize(){this._renderView=new y({stage:this})}destroy(){this.removeAllHandles(),this._textures.destroy(),this._set("textures",null),this._renderView=i(this._renderView),this._set("renderView",null),this._layers.length=0,this._model=null,this._set("renderer",null),this.options.canvas=null,this._set("options",null)}get viewingMode(){return this.view.state.viewingMode}get updating(){return this.readyToRun||this.renderView.updating||this._frameTask.updating||this.textures.updating}get renderView(){return this._renderView}get renderer(){return this.renderView?.renderer}get textures(){return this._textures}addTexture(e){this._model.addTexture(e),this.renderView.requestRender()}removeTexture(e){null!=e&&!this.destroyed&&this._model.hasTexture(e)&&(this._model.removeTexture(e),this.renderView.requestRender())}addTextures(e){null!=e&&(this._model.addTextures(e),this.renderView.requestRender())}removeTextures(e){null!=e&&(this._model?.removeTextures(e),this.renderView.requestRender())}forEachTexture(e){this._model.forEachTexture(e)}getTexture(e){return this._model.getTexture(e)}addLayer(e){this._layers.includes(e)||(this._model.addLayer(e),this._layers.push(e),this._model.dirtySet.layerAdded(e),this.renderView.requestRender())}removeLayer(e){null!=e&&!this.destroyed&&this._model.hasLayer(s(e))&&(this._model.dirtySet.layerRemoved(e),this._commitLayer(e),r(this._layers,e),this._model.dirtySet.assertLayerClean(e.id),this._model.removeLayer(e),this.renderView.requestRender())}getLayer(e){return this._model.getLayer(e)}handleEvent(e,t){this.destroyed||(this._model.dirtySet[e](t),this.renderView.requestRender())}get readyToRun(){return this._model.dirtySet.dirty||!this._asyncChangeSet.empty||this._canCompact.value}runTask(e){if(this._frameTask.processQueue(e),this._commit(e),this.renderer.compact(e),this._canCompact.value=this.renderer.canCompact,!e.hasProgressed)return _}compact(e){return this._canCompact.value=!1,this.renderer.compact(e)}_commit(e){const t=this._model.dirtySet;this._asyncChangeSet.empty||e.done||(this.renderer.commit(this._asyncChangeSet,e),this.renderView.requestRender(),e.madeProgress()),this._layers.forEach(r=>{if(e.done)return;const s=this._layerSyncSet.has(r.id)||1===r.updatePolicy,i=s?this._syncChangeSet:this._asyncChangeSet;t.commitLayer(r.id,i),this._layerSyncSet.delete(r.id),i.empty||(this.renderer.commit(i,s?p:e),this.renderView.requestRender(),e.madeProgress())}),this._syncChangeSet.empty||(this.renderer.commit(this._syncChangeSet,p),this.renderView.requestRender(),e.madeProgress()),this._layers.forEach(r=>{e.done||this._layerSyncSet.has(r.id)||0!==r.updatePolicy||(t.commitLayer(r.id,this._asyncChangeSet),this._asyncChangeSet.empty||(this.renderer.commit(this._asyncChangeSet,e),this.renderView.requestRender(),e.madeProgress()))}),this._layerSyncSet.clear(),this.notifyChange("readyToRun")}commitSyncLayers(){const e=this._model.dirtySet;this._layers.forEach(t=>{this._layerSyncSet.has(t.id)||1===t.updatePolicy?(e.commitLayer(t.id,this._syncChangeSet),this._layerSyncSet.delete(t.id)):e.commitSyncUpdates(t.id,this._syncChangeSet)});for(const t of this._layerSyncSet)e.commitLayer(t,this._syncChangeSet);this._layerSyncSet.clear(),this._syncChangeSet.empty||(this.renderer.commit(this._syncChangeSet,p),this.renderView.requestRender())}_commitLayer(e){this._model.dirtySet.commitLayer(e.id,this._syncChangeSet),this._layerSyncSet.delete(e.id),this._syncChangeSet.empty||(this.renderer.commit(this._syncChangeSet,p),this.renderView.requestRender())}schedule(e,t){return this._frameTask.schedule(e,t)}reschedule(e,t){return this._frameTask.reschedule(e,t)}syncLayer(e){this._layerSyncSet.add(e),this.renderView.requestRender()}get layers(){return this._layers}addRenderPlugin(e,t){const r=this.renderer.plugins.add(e,t),s=()=>{h(e)&&this.view.sceneIntersectionHelper.addIntersectionHandler(e)};if(n(r))return r.then(s);s()}removeRenderPlugin(e){this.destroyed||(h(e)&&this.view.sceneIntersectionHelper.removeIntersectionHandler(e),this.renderer.plugins.remove(e))}get test(){}};e([d({constructOnly:!0})],g.prototype,"view",void 0),e([d({constructOnly:!0})],g.prototype,"options",void 0),e([d({readOnly:!0})],g.prototype,"viewingMode",null),e([d({constructOnly:!0})],g.prototype,"container",void 0),e([d({readOnly:!0})],g.prototype,"updating",null),e([d({readOnly:!0})],g.prototype,"renderView",null),e([d({readOnly:!0})],g.prototype,"renderer",null),e([d({readOnly:!0})],g.prototype,"textures",null),e([d({readOnly:!0})],g.prototype,"readyToRun",null),g=e([a("esri.views.3d.webgl-engine.Stage")],g);export{g as Stage};
5
+ import{__decorate as e}from"tslib";import t from"../../../core/Accessor.js";import{removeUnordered as r}from"../../../core/arrayUtils.js";import{toConst as s}from"../../../core/compilerUtils.js";import"../../../core/has.js";import{destroyMaybe as i}from"../../../core/maybe.js";import{isPromiseLike as n}from"../../../core/promiseUtils.js";import{signal as o}from"../../../core/signal.js";import{property as d}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/Logger.js";import{subclass as a}from"../../../core/accessorSupport/decorators/subclass.js";import{isIntersectionHandler as h}from"../state/helpers/SceneIntersectionHelper.js";import{TextureCollection as l}from"../support/TextureCollection.js";import{ChangeSet as c}from"./lib/ChangeSet.js";import{Model as m}from"./parts/Model.js";import{RenderView as y}from"./parts/RenderView.js";import{TaskPriority as u,noBudget as p}from"../../support/Scheduler.js";import{Yield as _}from"../../support/Yield.js";let g=class extends t{constructor(e){super(e),this._model=new m,this._canCompact=o(!1),this._layers=new Array,this._asyncChangeSet=new c,this._syncChangeSet=new c,this._layerSyncSet=new Set,this._textures=new l(this,e.view.resourceController.scheduler),this._frameTask=e.view.resourceController.scheduler.registerTask(u.STAGE,this),this.addHandles(this._frameTask)}initialize(){this._renderView=new y({stage:this})}destroy(){this.removeAllHandles(),this._textures.destroy(),this._set("textures",null),this._renderView=i(this._renderView),this._set("renderView",null),this._layers.length=0,this._model=null,this._set("renderer",null),this.options.canvas=null,this._set("options",null)}get viewingMode(){return this.view.state.viewingMode}get updating(){return!this.destroyed&&!this.destroying&&(this.readyToRun||this.renderView.updating||this._frameTask.updating||this.textures.updating)}get renderView(){return this._renderView}get renderer(){return this.renderView?.renderer}get textures(){return this._textures}addTexture(e){this._model.addTexture(e),this.renderView.requestRender()}removeTexture(e){null!=e&&!this.destroyed&&this._model.hasTexture(e)&&(this._model.removeTexture(e),this.renderView.requestRender())}addTextures(e){null!=e&&(this._model.addTextures(e),this.renderView.requestRender())}removeTextures(e){null!=e&&(this._model?.removeTextures(e),this.renderView.requestRender())}forEachTexture(e){this._model.forEachTexture(e)}getTexture(e){return this._model.getTexture(e)}addLayer(e){this._layers.includes(e)||(this._model.addLayer(e),this._layers.push(e),this._model.dirtySet.layerAdded(e),this.renderView.requestRender())}removeLayer(e){null!=e&&!this.destroyed&&this._model.hasLayer(s(e))&&(this._model.dirtySet.layerRemoved(e),this._commitLayer(e),r(this._layers,e),this._model.dirtySet.assertLayerClean(e.id),this._model.removeLayer(e),this.renderView.requestRender())}getLayer(e){return this._model.getLayer(e)}handleEvent(e,t){this.destroyed||(this._model.dirtySet[e](t),this.renderView.requestRender())}get readyToRun(){return this._model.dirtySet.dirty||!this._asyncChangeSet.empty||this._canCompact.value}runTask(e){if(this._frameTask.processQueue(e),this._commit(e),this.renderer.compact(e),this._canCompact.value=this.renderer.canCompact,!e.hasProgressed)return _}compact(e){return this._canCompact.value=!1,this.renderer.compact(e)}_commit(e){const t=this._model.dirtySet;this._asyncChangeSet.empty||e.done||(this.renderer.commit(this._asyncChangeSet,e),this.renderView.requestRender(),e.madeProgress()),this._layers.forEach(r=>{if(e.done)return;const s=this._layerSyncSet.has(r.id)||1===r.updatePolicy,i=s?this._syncChangeSet:this._asyncChangeSet;t.commitLayer(r.id,i),this._layerSyncSet.delete(r.id),i.empty||(this.renderer.commit(i,s?p:e),this.renderView.requestRender(),e.madeProgress())}),this._syncChangeSet.empty||(this.renderer.commit(this._syncChangeSet,p),this.renderView.requestRender(),e.madeProgress()),this._layers.forEach(r=>{e.done||this._layerSyncSet.has(r.id)||0!==r.updatePolicy||(t.commitLayer(r.id,this._asyncChangeSet),this._asyncChangeSet.empty||(this.renderer.commit(this._asyncChangeSet,e),this.renderView.requestRender(),e.madeProgress()))}),this._layerSyncSet.clear(),this.notifyChange("readyToRun")}commitSyncLayers(){const e=this._model.dirtySet;this._layers.forEach(t=>{this._layerSyncSet.has(t.id)||1===t.updatePolicy?(e.commitLayer(t.id,this._syncChangeSet),this._layerSyncSet.delete(t.id)):e.commitSyncUpdates(t.id,this._syncChangeSet)});for(const t of this._layerSyncSet)e.commitLayer(t,this._syncChangeSet);this._layerSyncSet.clear(),this._syncChangeSet.empty||(this.renderer.commit(this._syncChangeSet,p),this.renderView.requestRender())}_commitLayer(e){this._model.dirtySet.commitLayer(e.id,this._syncChangeSet),this._layerSyncSet.delete(e.id),this._syncChangeSet.empty||(this.renderer.commit(this._syncChangeSet,p),this.renderView.requestRender())}schedule(e,t){return this._frameTask.schedule(e,t)}reschedule(e,t){return this._frameTask.reschedule(e,t)}syncLayer(e){this._layerSyncSet.add(e),this.renderView.requestRender()}get layers(){return this._layers}addRenderPlugin(e,t){const r=this.renderer.plugins.add(e,t),s=()=>{h(e)&&this.view.sceneIntersectionHelper.addIntersectionHandler(e)};if(n(r))return r.then(s);s()}removeRenderPlugin(e){this.destroyed||(h(e)&&this.view.sceneIntersectionHelper.removeIntersectionHandler(e),this.renderer.plugins.remove(e))}get test(){}};e([d({constructOnly:!0})],g.prototype,"view",void 0),e([d({constructOnly:!0})],g.prototype,"options",void 0),e([d({readOnly:!0})],g.prototype,"viewingMode",null),e([d({constructOnly:!0})],g.prototype,"container",void 0),e([d({readOnly:!0})],g.prototype,"updating",null),e([d({readOnly:!0})],g.prototype,"renderView",null),e([d({readOnly:!0})],g.prototype,"renderer",null),e([d({readOnly:!0})],g.prototype,"textures",null),e([d({readOnly:!0})],g.prototype,"readyToRun",null),g=e([a("esri.views.3d.webgl-engine.Stage")],g);export{g as Stage};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{releaseMaybe as e}from"../../../../core/maybe.js";import{c as t}from"../../../../chunks/vec42.js";import{ZEROS as i}from"../../../../core/libs/gl-matrix-2/factories/vec4f32.js";import{create as s}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{ViewportSize as r}from"./BindParameters.js";import{ColorAttachment1 as o}from"../../../webgl/enums.js";import{ensureAttachmentMaxSize as h}from"../../../webgl/FramebufferObject.js";class c{constructor(e){this._fbos=e,this._requiresEmission=!1,this._size=new r(0,0),this._clearColor=s()}dispose(){this._color=e(this._color),this.releaseDepth()}initialize(e,i,s,r){this._size.width=e,this._size.height=i,h(this._size,this._fbos.rctx.parameters.maxTextureSize);const o=this._color;return this._color=null,this.releaseDepth(),this._requiresEmission=r,t(this._clearColor,s),o}releaseDepth(){this._color?.detachDepth(),this._depth=e(this._depth)}update(e){const t=this._ensureColor();t.attachDepth(this.depth),this._color=e(t)}bind(){const{rctx:e}=this._fbos,t=null==this._color;this.color.attachDepth(this.depth),e.bindFramebuffer(this.color.fbo),t&&(e.setClearStencil(0),e.setClearColor(this._clearColor[0],this._clearColor[1],this._clearColor[2],this._clearColor[3]),e.clear(17664),this._requiresEmission&&e.clearBuffer(1,i))}_acquireColor(){return this._requiresEmission?this._fbos.acquire(this._size.width,this._size.height,"acquired-color").acquireColor(o,8,"emissive"):this._fbos.acquire(this._size.width,this._size.height,"acquired-color")}_acquireDepth(){return this._fbos.acquireDepth(11,this._size.width,this._size.height,"depth")}get size(){return this._size}get color(){return this._ensureColor()}get depth(){return this._depth??=this._acquireDepth(),this._depth}_ensureColor(){return this._color??=this._acquireColor(),this._color}}export{c as MainFramebuffer};
5
+ import{releaseMaybe as e}from"../../../../core/maybe.js";import{d as t}from"../../../../chunks/vec42.js";import{ZEROS as i}from"../../../../core/libs/gl-matrix-2/factories/vec4f32.js";import{create as s}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{ViewportSize as r}from"./BindParameters.js";import{ColorAttachment1 as o}from"../../../webgl/enums.js";import{ensureAttachmentMaxSize as h}from"../../../webgl/FramebufferObject.js";class c{constructor(e){this._fbos=e,this._requiresEmission=!1,this._size=new r(0,0),this._clearColor=s()}dispose(){this._color=e(this._color),this.releaseDepth()}initialize(e,i,s,r){this._size.width=e,this._size.height=i,h(this._size,this._fbos.rctx.parameters.maxTextureSize);const o=this._color;return this._color=null,this.releaseDepth(),this._requiresEmission=r,t(this._clearColor,s),o}releaseDepth(){this._color?.detachDepth(),this._depth=e(this._depth)}update(e){const t=this._ensureColor();t.attachDepth(this.depth),this._color=e(t)}bind(){const{rctx:e}=this._fbos,t=null==this._color;this.color.attachDepth(this.depth),e.bindFramebuffer(this.color.fbo),t&&(e.setClearStencil(0),e.setClearColor(this._clearColor[0],this._clearColor[1],this._clearColor[2],this._clearColor[3]),e.clear(17664),this._requiresEmission&&e.clearBuffer(1,i))}_acquireColor(){return this._requiresEmission?this._fbos.acquire(this._size.width,this._size.height,"acquired-color").acquireColor(o,8,"emissive"):this._fbos.acquire(this._size.width,this._size.height,"acquired-color")}_acquireDepth(){return this._fbos.acquireDepth(11,this._size.width,this._size.height,"depth")}get size(){return this._size}get color(){return this._ensureColor()}get depth(){return this._depth??=this._acquireDepth(),this._depth}_ensureColor(){return this._color??=this._acquireColor(),this._color}}export{c as MainFramebuffer};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import"../../../../core/has.js";import{generateUID as t}from"../../../../core/uid.js";import{multiply as i,copy as e,hasIdentityRotation as s}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as o,IDENTITY as r}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{m as a,t as h,j as n,i as m,f as d,q as l,c}from"../../../../chunks/vec32.js";import{create as g,fromValues as _}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{a as u,c as f}from"../../../../chunks/sphere.js";import{maxScale as b}from"../../support/mathUtils.js";import{Object3DOccludeeStateID as v,Object3DHighlightStateID as p}from"./Object3DStateID.js";import{assert as y}from"./Util.js";import{affectsGeometry as j}from"./VertexAttribute.js";import{addObject3DStateID as S,removeObject3DStateID as V}from"../materials/renderers/utils.js";class x{constructor(i={}){this.id=t(),this._highlightIds=new Set,this._shaderTransformation=null,this._visible=!0,this.castShadow=i.castShadow??!0,this.usesVerticalDistanceToGround=i.usesVerticalDistanceToGround??!1,this.graphicUid=i.graphicUid,this.layerViewUid=i.layerViewUid,i.isElevationSource&&(this.lastValidElevationBB=new W),this._geometries=i.geometries?Array.from(i.geometries):new Array}dispose(){this._geometries.length=0}get layer(){return this._layer}set layer(t){y(null==this._layer||null==t,"Object3D can only be added to a single Layer"),this._layer=t}addGeometry(t){t.visible=this._visible,this._geometries.push(t);for(const i of this._highlightIds)t.addHighlight(i);this._emit("geometryAdded",{object:this,geometry:t}),this._highlightIds.size&&this._emit("highlightChanged",this),this._invalidateBoundingVolume()}removeGeometry(t){const i=this._geometries.splice(t,1)[0];if(i){for(const t of this._highlightIds)i.removeHighlight(t);this._emit("geometryRemoved",{object:this,geometry:i}),this._highlightIds.size&&this._emit("highlightChanged",this),this._invalidateBoundingVolume()}}removeAllGeometries(){for(;this._geometries.length>0;)this.removeGeometry(0)}geometryVertexAttributeUpdated(t,i,e=!1){this._emit("attributesChanged",{object:this,geometry:t,attribute:i,sync:e}),j(i)&&this._invalidateBoundingVolume()}get visible(){return this._visible}set visible(t){if(this._visible!==t){this._visible=t;for(const t of this._geometries)t.visible=this._visible;this._emit("visibilityChanged",this)}}maskOccludee(){const t=new v;for(const i of this._geometries)i.occludees=S(i.occludees,t);return this._emit("occlusionChanged",this),t}removeOcclude(t){for(const i of this._geometries)i.occludees=V(i.occludees,t);this._emit("occlusionChanged",this)}highlight(t){const i=new p(t);for(const e of this._geometries)e.addHighlight(i);return this._emit("highlightChanged",this),this._highlightIds.add(i),i}removeHighlight(t){this._highlightIds.delete(t);for(const i of this._geometries)i.removeHighlight(t);this._emit("highlightChanged",this)}removeStateID(t){0===t.channel?this.removeHighlight(t):this.removeOcclude(t)}getCombinedStaticTransformation(t,e){return i(e,this.transformation,t.transformation)}getCombinedShaderTransformation(t,e=o()){return i(e,this.effectiveTransformation,t.transformation)}get boundingVolumeWorldSpace(){return this._bvWorldSpace||(this._bvWorldSpace=this._bvWorldSpace||new A,this._validateBoundingVolume(this._bvWorldSpace,0)),this._bvWorldSpace}get boundingVolumeObjectSpace(){return this._bvObjectSpace||(this._bvObjectSpace=this._bvObjectSpace||new A,this._validateBoundingVolume(this._bvObjectSpace,1)),this._bvObjectSpace}_validateBoundingVolume(t,i){const e=1===i;for(const s of this._geometries){const i=s.boundingInfo;i&&M(i,t,e?s.transformation:this.getCombinedShaderTransformation(s))}a(u(t.bounds),t.min,t.max,.5);for(const s of this._geometries){const i=s.boundingInfo;if(null==i)continue;const o=e?s.transformation:this.getCombinedShaderTransformation(s),r=b(o);h(O,i.center,o);const a=n(O,u(t.bounds)),m=i.radius*r;t.bounds[3]=Math.max(t.bounds[3],a+m)}}_invalidateBoundingVolume(){const t=this._bvWorldSpace?.bounds;this._bvObjectSpace=this._bvWorldSpace=void 0,this.layer&&t&&this.layer.notifyObjectBBChanged(this,t)}_emit(t,i){this.layer?.events.emit(t,i)}get geometries(){return this._geometries}get transformation(){return this._transformation??r}set transformation(t){this._transformation=e(this._transformation??o(),t),this._invalidateBoundingVolume(),this._emit("transformationChanged",this)}get shaderTransformation(){return this._shaderTransformation}set shaderTransformation(t){this._shaderTransformation=t?e(this._shaderTransformation??o(),t):null,this._invalidateBoundingVolume(),this._emit("shaderTransformationChanged",this)}get effectiveTransformation(){return this.shaderTransformation??this.transformation}get test(){}}class W{constructor(){this._data=[Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE]}get min(){return _(this._data[0],this._data[1],this._data[2])}get max(){return _(this._data[3],this._data[4],this._data[5])}minWith(t){const{_data:i}=this;i[0]=Math.min(i[0],t[0]),i[1]=Math.min(i[1],t[1]),i[2]=Math.min(i[2],t[2])}maxWith(t){const{_data:i}=this;i[3]=Math.max(i[3],t[0]),i[4]=Math.max(i[4],t[1]),i[5]=Math.max(i[5],t[2])}assignMinMax(t,i){for(let e=0;e<3;++e)this._data[0+e]=t[e],this._data[3+e]=i[e]}isEmpty(){return this._data[3]<this._data[0]&&this._data[4]<this._data[1]&&this._data[5]<this._data[2]}}class A extends W{constructor(){super(...arguments),this.bounds=f()}}function M(t,i,e){const o=t.bbMin,r=t.bbMax;if(s(e)){const t=m(T,e[12],e[13],e[14]);return d(C,o,t),d(B,r,t),i.minWith(C),void i.maxWith(B)}if(h(C,o,e),l(o,r))return i.minWith(C),void i.maxWith(C);h(B,r,e),i.minWith(C),i.minWith(B),i.maxWith(C),i.maxWith(B);for(let s=0;s<3;++s)c(C,o),c(B,r),C[s]=r[s],B[s]=o[s],h(C,C,e),h(B,B,e),i.minWith(C),i.minWith(B),i.maxWith(C),i.maxWith(B)}const T=g(),C=g(),B=g(),O=g();export{A as BoundingVolume,x as Object3D};
5
+ import"../../../../core/has.js";import{generateUID as t}from"../../../../core/uid.js";import{multiply as i,copy as e,hasIdentityRotation as s}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as o,IDENTITY as r}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{m as a,t as h,j as n,i as m,f as d,q as l,c}from"../../../../chunks/vec32.js";import{create as g,fromValues as _}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{k as u,a as f,c as b}from"../../../../chunks/sphere.js";import{maxScale as v}from"../../support/mathUtils.js";import{Object3DOccludeeStateID as p,Object3DHighlightStateID as y}from"./Object3DStateID.js";import{assert as j}from"./Util.js";import{affectsGeometry as S}from"./VertexAttribute.js";import{addObject3DStateID as V,removeObject3DStateID as x}from"../materials/renderers/utils.js";class W{constructor(i={}){this.id=t(),this._highlightIds=new Set,this._shaderTransformation=null,this._visible=!0,this.castShadow=i.castShadow??!0,this.usesVerticalDistanceToGround=i.usesVerticalDistanceToGround??!1,this.graphicUid=i.graphicUid,this.layerViewUid=i.layerViewUid,i.isElevationSource&&(this.lastValidElevationBB=new A),this._geometries=i.geometries?Array.from(i.geometries):new Array}dispose(){this._geometries.length=0}get layer(){return this._layer}set layer(t){j(null==this._layer||null==t,"Object3D can only be added to a single Layer"),this._layer=t}addGeometry(t){t.visible=this._visible,this._geometries.push(t);for(const i of this._highlightIds)t.addHighlight(i);this._emit("geometryAdded",{object:this,geometry:t}),this._highlightIds.size&&this._emit("highlightChanged",this),this._invalidateBoundingVolume()}removeGeometry(t){const i=this._geometries.splice(t,1)[0];if(i){for(const t of this._highlightIds)i.removeHighlight(t);this._emit("geometryRemoved",{object:this,geometry:i}),this._highlightIds.size&&this._emit("highlightChanged",this),this._invalidateBoundingVolume()}}removeAllGeometries(){for(;this._geometries.length>0;)this.removeGeometry(0)}geometryVertexAttributeUpdated(t,i,e=!1){this._emit("attributesChanged",{object:this,geometry:t,attribute:i,sync:e}),S(i)&&this._invalidateBoundingVolume()}get visible(){return this._visible}set visible(t){if(this._visible!==t){this._visible=t;for(const t of this._geometries)t.visible=this._visible;this._emit("visibilityChanged",this)}}maskOccludee(){const t=new p;for(const i of this._geometries)i.occludees=V(i.occludees,t);return this._emit("occlusionChanged",this),t}removeOcclude(t){for(const i of this._geometries)i.occludees=x(i.occludees,t);this._emit("occlusionChanged",this)}highlight(t){const i=new y(t);for(const e of this._geometries)e.addHighlight(i);return this._emit("highlightChanged",this),this._highlightIds.add(i),i}removeHighlight(t){this._highlightIds.delete(t);for(const i of this._geometries)i.removeHighlight(t);this._emit("highlightChanged",this)}removeStateID(t){0===t.channel?this.removeHighlight(t):this.removeOcclude(t)}getCombinedStaticTransformation(t,e){return i(e,this.transformation,t.transformation)}getCombinedShaderTransformation(t,e=o()){return i(e,this.effectiveTransformation,t.transformation)}get boundingVolumeWorldSpace(){return this._bvWorldSpace||(this._bvWorldSpace=this._bvWorldSpace||new M,this._validateBoundingVolume(this._bvWorldSpace,0)),this._bvWorldSpace}get boundingVolumeObjectSpace(){return this._bvObjectSpace||(this._bvObjectSpace=this._bvObjectSpace||new M,this._validateBoundingVolume(this._bvObjectSpace,1)),this._bvObjectSpace}_validateBoundingVolume(t,i){const e=1===i;for(const s of this._geometries){const i=s.boundingInfo;i&&T(i,t,e?s.transformation:this.getCombinedShaderTransformation(s))}u(t.bounds,a(U,t.min,t.max,.5));for(const s of this._geometries){const i=s.boundingInfo;if(null==i)continue;const o=e?s.transformation:this.getCombinedShaderTransformation(s),r=v(o);h(U,i.center,o);const a=n(U,f(t.bounds)),m=i.radius*r;t.bounds[3]=Math.max(t.bounds[3],a+m)}}_invalidateBoundingVolume(){const t=this._bvWorldSpace?.bounds;this._bvObjectSpace=this._bvWorldSpace=void 0,this.layer&&t&&this.layer.notifyObjectBBChanged(this,t)}_emit(t,i){this.layer?.events.emit(t,i)}get geometries(){return this._geometries}get transformation(){return this._transformation??r}set transformation(t){this._transformation=e(this._transformation??o(),t),this._invalidateBoundingVolume(),this._emit("transformationChanged",this)}get shaderTransformation(){return this._shaderTransformation}set shaderTransformation(t){this._shaderTransformation=t?e(this._shaderTransformation??o(),t):null,this._invalidateBoundingVolume(),this._emit("shaderTransformationChanged",this)}get effectiveTransformation(){return this.shaderTransformation??this.transformation}get test(){}}class A{constructor(){this._data=[Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE]}get min(){return _(this._data[0],this._data[1],this._data[2])}get max(){return _(this._data[3],this._data[4],this._data[5])}minWith(t){const{_data:i}=this;i[0]=Math.min(i[0],t[0]),i[1]=Math.min(i[1],t[1]),i[2]=Math.min(i[2],t[2])}maxWith(t){const{_data:i}=this;i[3]=Math.max(i[3],t[0]),i[4]=Math.max(i[4],t[1]),i[5]=Math.max(i[5],t[2])}assignMinMax(t,i){for(let e=0;e<3;++e)this._data[0+e]=t[e],this._data[3+e]=i[e]}isEmpty(){return this._data[3]<this._data[0]&&this._data[4]<this._data[1]&&this._data[5]<this._data[2]}}class M extends A{constructor(){super(...arguments),this.bounds=b()}}function T(t,i,e){const o=t.bbMin,r=t.bbMax;if(s(e)){const t=m(C,e[12],e[13],e[14]);return d(B,o,t),d(O,r,t),i.minWith(B),void i.maxWith(O)}if(h(B,o,e),l(o,r))return i.minWith(B),void i.maxWith(B);h(O,r,e),i.minWith(B),i.minWith(O),i.maxWith(B),i.maxWith(O);for(let s=0;s<3;++s)c(B,o),c(O,r),B[s]=r[s],O[s]=o[s],h(B,B,e),h(O,O,e),i.minWith(B),i.minWith(O),i.maxWith(B),i.maxWith(O)}const C=g(),B=g(),O=g(),U=g();export{M as BoundingVolume,W as Object3D};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import t from"../../../../core/ObjectPool.js";import e from"../../../../core/PooledArray.js";import{c as n,m as o,s as i,g as s,f as r}from"../../../../chunks/vec32.js";import{fromValues as h,create as a}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{intersectsSphere as l}from"../../../../geometry/support/frustum.js";import{wrap as d}from"../../../../geometry/support/ray.js";import{h as u,g as c,k as f,c as m,a as _}from"../../../../chunks/sphere.js";import{rayBoxTest as p}from"./Util.js";class b{get bounds(){return this._root.bounds}get halfSize(){return this._root.halfSize}get root(){return this._root.node}get maximumObjectsPerNode(){return this._maximumObjectsPerNode}get maximumDepth(){return this._maximumDepth}get objectCount(){return this._objectCount}constructor(t,e){this.objectToBoundingSphere=t,this._maximumObjectsPerNode=10,this._maximumDepth=20,this._degenerateObjects=new Set,this._root=new g,this._objectCount=0,e&&(void 0!==e.maximumObjectsPerNode&&(this._maximumObjectsPerNode=e.maximumObjectsPerNode),void 0!==e.maximumDepth&&(this._maximumDepth=e.maximumDepth))}destroy(){this._degenerateObjects.clear(),g.clearPool(),k[0]=null,J.prune(),Q.prune()}add(t){const e=Array.from(t);this._grow(e);const n=g.acquire();for(const o of e)++this._objectCount,this._isDegenerate(o)?this._degenerateObjects.add(o):(n.init(this._root),this._add(o,n));g.release(n)}remove(t,e=null){this._objectCount-=t.length;const n=g.acquire();for(const o of t){const t=e??u(this.objectToBoundingSphere(o),W);R(t[3])?(n.init(this._root),x(o,t,n)):this._degenerateObjects.delete(o)}g.release(n),this._shrink()}update(t,e){if(!R(e[3])&&this._isDegenerate(t))return;const n=q(t);this.remove(n,e),this.add(n)}forEachAlongRay(t,e,n){const o=d(t,e);S(this._root,t=>{if(!z(o,t))return!1;const e=t.node;return e.terminals.forAll(t=>{this._intersectsObject(o,t)&&n(t)}),null!==e.residents&&e.residents.forAll(t=>{this._intersectsObject(o,t)&&n(t)}),!0})}forEachAlongRayWithVerticalOffset(t,e,n,o){const i=d(t,e);S(this._root,t=>{if(!M(i,t,o))return!1;const e=t.node;return e.terminals.forAll(t=>{this._intersectsObjectWithOffset(i,t,o)&&n(t)}),null!==e.residents&&e.residents.forAll(t=>{this._intersectsObjectWithOffset(i,t,o)&&n(t)}),!0})}forEach(t){S(this._root,e=>{const n=e.node;return n.terminals.forAll(t),null!==n.residents&&n.residents.forAll(t),!0}),this._degenerateObjects.forEach(t)}forEachDegenerateObject(t){this._degenerateObjects.forEach(t)}findClosest(t,e,n,o=()=>!0,i=1/0){let h=1/0,a=1/0,d=null;const u=E(t,e),c=s=>{if(--i,!o(s))return;const r=this.objectToBoundingSphere(s);if(!l(n,r))return;const u=P(t,e,_(r)),c=u-r[3],f=u+r[3];c<h&&(h=c,a=f,d=s)};return j(this._root,o=>{if(i<=0||!l(n,o.bounds))return!1;s(I,u,o.halfSize),r(I,I,_(o.bounds));if(P(t,e,I)>a)return!1;const h=o.node;return h.terminals.forAll(t=>c(t)),null!==h.residents&&h.residents.forAll(t=>c(t)),!0},t,e),d}forEachInDepthRange(t,e,n,o,i,h,a){let d=-1/0,u=1/0;const c={setRange:t=>{1===n?(d=Math.max(d,t.near),u=Math.min(u,t.far)):(d=Math.max(d,-t.far),u=Math.min(u,-t.near))}};c.setRange(o);const f=P(e,n,t),m=E(e,n),p=E(e,-n),b=t=>{if(!a(t))return;const o=this.objectToBoundingSphere(t),s=_(o),r=P(e,n,s)-f,m=r-o[3],p=r+o[3];m>u||p<d||!l(h,o)||i(t,c)};j(this._root,t=>{if(!l(h,t.bounds))return!1;s(I,m,t.halfSize),r(I,I,_(t.bounds));if(P(e,n,I)-f>u)return!1;s(I,p,t.halfSize),r(I,I,_(t.bounds));if(P(e,n,I)-f<d)return!1;const o=t.node;return o.terminals.forAll(t=>b(t)),null!==o.residents&&o.residents.forAll(t=>b(t)),!0},e,n)}forEachNode(t){S(this._root,e=>t(e.node,e.bounds,e.halfSize,e.depth))}forEachNeighbor(t,e){const n=c(e),o=_(e),s=e=>{const s=this.objectToBoundingSphere(e),r=c(s),h=n+r;return!(i(_(s),o)-h*h<=0)||t(e)};let r=!0;const h=t=>{r&&(r=s(t))};S(this._root,t=>{const e=c(t.bounds),s=n+e;if(i(_(t.bounds),o)-s*s>0)return!1;const a=t.node;return a.terminals.forAll(h),r&&null!==a.residents&&a.residents.forAll(h),r}),r&&this.forEachDegenerateObject(h)}_intersectsObject(t,e){const n=this.objectToBoundingSphere(e);return!(n[3]>0)||f(n,t)}_intersectsObjectWithOffset(t,e,n){const o=this.objectToBoundingSphere(e);return!(o[3]>0)||f(n.applyToBoundingSphere(o),t)}_add(t,e){e.advanceTo(this.objectToBoundingSphere(t))?e.node.terminals.push(t):(e.node.residents.push(t),e.node.residents.length>this._maximumObjectsPerNode&&e.depth<this._maximumDepth&&this._split(e))}_split(t){const e=t.node.residents;t.node.residents=null;for(let n=0;n<e.length;n++){const o=g.acquire().init(t);this._add(e.at(n),o),g.release(o)}}_grow(t){if(B(t,t=>this.objectToBoundingSphere(t),V),R(V[3])&&!this._fitsInsideTree(V))if(N(this._root.node))u(V,this._root.bounds),this._root.halfSize=1.25*this._root.bounds[3],this._root.updateBoundsRadiusFromHalfSize();else{const t=this._rootBoundsForRootAsSubNode(V);this._placingRootViolatesMaxDepth(t)?this._rebuildTree(V,t):this._growRootAsSubNode(t),g.release(t)}}_rebuildTree(t,e){n(_(G),_(e.bounds)),G[3]=e.halfSize,B([t,G],t=>t,U);const o=g.acquire().init(this._root);this._root.initFrom(null,U,U[3]),this._root.increaseHalfSize(1.25),S(o,t=>(this.add(t.node.terminals.data),null!==t.node.residents&&this.add(t.node.residents.data),!0)),g.release(o)}_placingRootViolatesMaxDepth(t){const e=Math.log(t.halfSize/this._root.halfSize)*Math.LOG2E;let n=0;return S(this._root,t=>(n=Math.max(n,t.depth),n+e<=this._maximumDepth)),n+e>this._maximumDepth}_rootBoundsForRootAsSubNode(t){const e=t[3],n=t;let o=-1/0;const i=this._root.bounds,s=this._root.halfSize;for(let h=0;h<3;h++){const t=i[h]-s-(n[h]-e),r=n[h]+e-(i[h]+s),a=Math.max(0,Math.ceil(t/(2*s))),l=Math.max(0,Math.ceil(r/(2*s)))+1,d=2**Math.ceil(Math.log(a+l)*Math.LOG2E);o=Math.max(o,d),K[h].min=a,K[h].max=l}for(let h=0;h<3;h++){let t=K[h].min,e=K[h].max;const n=(o-(t+e))/2;t+=Math.ceil(n),e+=Math.floor(n);const r=i[h]-s-t*s*2;C[h]=r+(e+t)*s}const r=o*s;return C[3]=r*y,g.acquire().initFrom(null,C,r,0)}_growRootAsSubNode(t){const e=this._root.node;n(_(V),_(this._root.bounds)),V[3]=this._root.halfSize,this._root.init(t),t.advanceTo(V,null,!0),t.node.children=e.children,t.node.residents=e.residents,t.node.terminals=e.terminals}_shrink(){for(;;){const t=this._findShrinkIndex();if(-1===t)break;this._root.advance(t),this._root.depth=0}}_findShrinkIndex(){if(0!==this._root.node.terminals.length||this._root.isLeaf())return-1;let t=null;const e=this._root.node.children;let n=0,o=0;for(;o<e.length&&null==t;)n=o++,t=e[n];for(;o<e.length;)if(e[o++])return-1;return n}_isDegenerate(t){return!R(this.objectToBoundingSphere(t)[3])}_fitsInsideTree(t){const e=this._root.bounds,n=this._root.halfSize;return t[3]<=n&&t[0]>=e[0]-n&&t[0]<=e[0]+n&&t[1]>=e[1]-n&&t[1]<=e[1]+n&&t[2]>=e[2]-n&&t[2]<=e[2]+n}toJSON(){const{maximumDepth:t,maximumObjectsPerNode:e,_objectCount:n}=this,o=this._nodeToJSON(this._root.node);return{maximumDepth:t,maximumObjectsPerNode:e,objectCount:n,root:{bounds:this._root.bounds,halfSize:this._root.halfSize,depth:this._root.depth,node:o}}}_nodeToJSON(t){const e=t.children.map(t=>t?this._nodeToJSON(t):null),n=t.residents?.map(t=>this.objectToBoundingSphere(t)),o=t.terminals?.map(t=>this.objectToBoundingSphere(t));return{children:e,residents:n,terminals:o}}static fromJSON(t){const e=new b(t=>t,{maximumDepth:t.maximumDepth,maximumObjectsPerNode:t.maximumObjectsPerNode});return e._objectCount=t.objectCount,e._root.initFrom(t.root.node,t.root.bounds,t.root.halfSize,t.root.depth),e}}class g{constructor(){this.bounds=m(),this.halfSize=0,this.initFrom(null,null,0,0)}init(t){return this.initFrom(t.node,t.bounds,t.halfSize,t.depth)}initFrom(t,e,n,o=this.depth){return this.node=null!=t?t:g.createEmptyNode(),e&&u(e,this.bounds),this.halfSize=n,this.depth=o,this}increaseHalfSize(t){this.halfSize*=t,this.updateBoundsRadiusFromHalfSize()}updateBoundsRadiusFromHalfSize(){this.bounds[3]=this.halfSize*y}advance(t){let e=this.node.children[t];e||(e=g.createEmptyNode(),this.node.children[t]=e),this.node=e,this.halfSize/=2,this.depth++;const n=F[t];return this.bounds[0]+=n[0]*this.halfSize,this.bounds[1]+=n[1]*this.halfSize,this.bounds[2]+=n[2]*this.halfSize,this.updateBoundsRadiusFromHalfSize(),this}advanceTo(t,e,n=!1){for(;;){if(this.isTerminalFor(t))return e&&e(this,-1),!0;if(this.isLeaf()){if(!n)return e&&e(this,-1),!1;this.node.residents=null}const o=this._childIndex(t);e&&e(this,o),this.advance(o)}}isLeaf(){return null!=this.node.residents}isTerminalFor(t){return t[3]>this.halfSize/2}_childIndex(t){const e=this.bounds;return(e[0]<t[0]?1:0)+(e[1]<t[1]?2:0)+(e[2]<t[2]?4:0)}static createEmptyNode(){return{children:[null,null,null,null,null,null,null,null],terminals:new e({shrink:!0}),residents:new e({shrink:!0})}}static{this._pool=new t(g)}static acquire(){return g._pool.acquire()}static release(t){g._pool.release(t)}static clearPool(){g._pool.prune()}}function S(t,e){let n=g.acquire().init(t);const o=[n];for(;0!==o.length;){if(n=o.pop(),e(n)&&!n.isLeaf())for(let t=0;t<n.node.children.length;t++){n.node.children[t]&&o.push(g.acquire().init(n).advance(t))}g.release(n)}}function j(t,e,n,o=1){let i=g.acquire().init(t);const s=[i];for(v(n,o,X);0!==s.length;){if(i=s.pop(),e(i)&&!i.isLeaf())for(let t=7;t>=0;--t){const e=X[t];i.node.children[e]&&s.push(g.acquire().init(i).advance(e))}g.release(i)}}function x(t,e,n){J.clear();const o=n.advanceTo(e,(t,e)=>{J.push(t.node),J.push(e)})?n.node.terminals:n.node.residents;if(o.removeUnordered(t),0===o.length)for(let i=J.length-2;i>=0;i-=2){if(!O(J.data[i],J.data[i+1]))break}}function O(t,n){return n>=0&&(t.children[n]=null),!!N(t)&&(null===t.residents&&(t.residents=new e({shrink:!0})),!0)}function z(t,e){return A(_(e.bounds),2*-e.halfSize,L),A(_(e.bounds),2*e.halfSize,H),p(t.origin,t.direction,L,H)}function M(t,e,n){return A(_(e.bounds),2*-e.halfSize,L),A(_(e.bounds),2*e.halfSize,H),n.applyToMinMax(L,H),p(t.origin,t.direction,L,H)}function N(t){if(0!==t.terminals.length)return!1;if(null!==t.residents)return 0===t.residents.length;for(let e=0;e<t.children.length;e++)if(t.children[e])return!1;return!0}function T(t,e){t[0]=Math.min(t[0],e[0]-e[3]),t[1]=Math.min(t[1],e[1]-e[3]),t[2]=Math.min(t[2],e[2]-e[3])}function D(t,e){t[0]=Math.max(t[0],e[0]+e[3]),t[1]=Math.max(t[1],e[1]+e[3]),t[2]=Math.max(t[2],e[2]+e[3])}function A(t,e,n){n[0]=t[0]+e,n[1]=t[1]+e,n[2]=t[2]+e}function B(t,e,n){L[0]=1/0,L[1]=1/0,L[2]=1/0,H[0]=-1/0,H[1]=-1/0,H[2]=-1/0;for(const o of t){const t=e(o);R(t[3])&&(T(L,t),D(H,t))}o(_(n),L,H,.5),n[3]=Math.max(H[0]-L[0],H[1]-L[1],H[2]-L[2])/2}function v(t,e,n){if(!Q.length)for(let o=0;o<8;++o)Q.push({index:0,distance:0});for(let o=0;o<8;++o){const n=F[o];Q.data[o].index=o,Q.data[o].distance=P(t,e,n)}Q.sort((t,e)=>t.distance-e.distance);for(let o=0;o<8;++o)n[o]=Q.data[o].index}function E(t,e){let n,o=1/0;for(let i=0;i<8;++i){const s=P(t,e,w[i]);s<o&&(o=s,n=w[i])}return n}function P(t,e,n){return e*(t[0]*n[0]+t[1]*n[1]+t[2]*n[2])}function R(t){return!isNaN(t)&&t!==-1/0&&t!==1/0&&t>0}const F=[h(-1,-1,-1),h(1,-1,-1),h(-1,1,-1),h(1,1,-1),h(-1,-1,1),h(1,-1,1),h(-1,1,1),h(1,1,1)],w=[h(-1,-1,-1),h(-1,-1,1),h(-1,1,-1),h(-1,1,1),h(1,-1,-1),h(1,-1,1),h(1,1,-1),h(1,1,1)],y=Math.sqrt(3),k=[null];function q(t){return k[0]=t,k}const C=m(),I=a(),L=a(),H=a(),J=new e,W=m(),V=m(),G=m(),U=m(),K=[{min:0,max:0},{min:0,max:0},{min:0,max:0}],Q=new e,X=[0,0,0,0,0,0,0,0];export{b as Octree};
5
+ import t from"../../../../core/ObjectPool.js";import e from"../../../../core/PooledArray.js";import{m as n,s as o,g as i,f as s}from"../../../../chunks/vec32.js";import{fromValues as r,create as h}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{intersectsSphere as a}from"../../../../geometry/support/frustum.js";import{wrap as l}from"../../../../geometry/support/ray.js";import{j as d,g as u,a as c,p as f,c as m,q as _,k as p}from"../../../../chunks/sphere.js";import{rayBoxTest as b}from"./Util.js";class g{get bounds(){return this._root.bounds}get halfSize(){return this._root.halfSize}get root(){return this._root.node}get maximumObjectsPerNode(){return this._maximumObjectsPerNode}get maximumDepth(){return this._maximumDepth}get objectCount(){return this._objectCount}constructor(t,e){this.objectToBoundingSphere=t,this._maximumObjectsPerNode=10,this._maximumDepth=20,this._degenerateObjects=new Set,this._root=new S,this._objectCount=0,e&&(void 0!==e.maximumObjectsPerNode&&(this._maximumObjectsPerNode=e.maximumObjectsPerNode),void 0!==e.maximumDepth&&(this._maximumDepth=e.maximumDepth))}destroy(){this._degenerateObjects.clear(),S.clearPool(),k[0]=null,W.prune(),X.prune()}add(t){const e=Array.from(t);this._grow(e);const n=S.acquire();for(const o of e)++this._objectCount,this._isDegenerate(o)?this._degenerateObjects.add(o):(n.init(this._root),this._add(o,n));S.release(n)}remove(t,e=null){this._objectCount-=t.length;const n=S.acquire();for(const o of t){const t=e??d(this.objectToBoundingSphere(o),V);F(t[3])?(n.init(this._root),O(o,t,n)):this._degenerateObjects.delete(o)}S.release(n),this._shrink()}update(t,e){if(!F(e[3])&&this._isDegenerate(t))return;const n=C(t);this.remove(n,e),this.add(n)}forEachAlongRay(t,e,n){const o=l(t,e);j(this._root,t=>{if(!M(o,t))return!1;const e=t.node;return e.terminals.forAll(t=>{this._intersectsObject(o,t)&&n(t)}),null!==e.residents&&e.residents.forAll(t=>{this._intersectsObject(o,t)&&n(t)}),!0})}forEachAlongRayWithVerticalOffset(t,e,n,o){const i=l(t,e);j(this._root,t=>{if(!N(i,t,o))return!1;const e=t.node;return e.terminals.forAll(t=>{this._intersectsObjectWithOffset(i,t,o)&&n(t)}),null!==e.residents&&e.residents.forAll(t=>{this._intersectsObjectWithOffset(i,t,o)&&n(t)}),!0})}forEach(t){j(this._root,e=>{const n=e.node;return n.terminals.forAll(t),null!==n.residents&&n.residents.forAll(t),!0}),this._degenerateObjects.forEach(t)}forEachDegenerateObject(t){this._degenerateObjects.forEach(t)}findClosest(t,e,n,o=()=>!0,r=1/0){let h=1/0,l=1/0,d=null;const u=P(t,e),f=i=>{if(--r,!o(i))return;const s=this.objectToBoundingSphere(i);if(!a(n,s))return;const u=R(t,e,c(s)),f=u-s[3],m=u+s[3];f<h&&(h=f,l=m,d=i)};return x(this._root,o=>{if(r<=0||!a(n,o.bounds))return!1;i(L,u,o.halfSize),s(L,L,c(o.bounds));if(R(t,e,L)>l)return!1;const h=o.node;return h.terminals.forAll(t=>f(t)),null!==h.residents&&h.residents.forAll(t=>f(t)),!0},t,e),d}forEachInDepthRange(t,e,n,o,r,h,l){let d=-1/0,u=1/0;const f={setRange:t=>{1===n?(d=Math.max(d,t.near),u=Math.min(u,t.far)):(d=Math.max(d,-t.far),u=Math.min(u,-t.near))}};f.setRange(o);const m=R(e,n,t),_=P(e,n),p=P(e,-n),b=t=>{if(!l(t))return;const o=this.objectToBoundingSphere(t),i=c(o),s=R(e,n,i)-m,_=s-o[3],p=s+o[3];_>u||p<d||!a(h,o)||r(t,f)};x(this._root,t=>{if(!a(h,t.bounds))return!1;i(L,_,t.halfSize),s(L,L,c(t.bounds));if(R(e,n,L)-m>u)return!1;i(L,p,t.halfSize),s(L,L,c(t.bounds));if(R(e,n,L)-m<d)return!1;const o=t.node;return o.terminals.forAll(t=>b(t)),null!==o.residents&&o.residents.forAll(t=>b(t)),!0},e,n)}forEachNode(t){j(this._root,e=>t(e.node,e.bounds,e.halfSize,e.depth))}forEachNeighbor(t,e){const n=u(e),i=c(e),s=e=>{const s=this.objectToBoundingSphere(e),r=u(s),h=n+r;return!(o(c(s),i)-h*h<=0)||t(e)};let r=!0;const h=t=>{r&&(r=s(t))};j(this._root,t=>{const e=u(t.bounds),s=n+e;if(o(c(t.bounds),i)-s*s>0)return!1;const a=t.node;return a.terminals.forAll(h),r&&null!==a.residents&&a.residents.forAll(h),r}),r&&this.forEachDegenerateObject(h)}_intersectsObject(t,e){const n=this.objectToBoundingSphere(e);return!(n[3]>0)||f(n,t)}_intersectsObjectWithOffset(t,e,n){const o=this.objectToBoundingSphere(e);return!(o[3]>0)||f(n.applyToBoundingSphere(o),t)}_add(t,e){e.advanceTo(this.objectToBoundingSphere(t))?e.node.terminals.push(t):(e.node.residents.push(t),e.node.residents.length>this._maximumObjectsPerNode&&e.depth<this._maximumDepth&&this._split(e))}_split(t){const e=t.node.residents;t.node.residents=null;for(let n=0;n<e.length;n++){const o=S.acquire().init(t);this._add(e.at(n),o),S.release(o)}}_grow(t){if(v(t,t=>this.objectToBoundingSphere(t),G),F(G[3])&&!this._fitsInsideTree(G))if(T(this._root.node))d(G,this._root.bounds),this._root.halfSize=1.25*this._root.bounds[3],this._root.updateBoundsRadiusFromHalfSize();else{const t=this._rootBoundsForRootAsSubNode(G);this._placingRootViolatesMaxDepth(t)?this._rebuildTree(G,t):this._growRootAsSubNode(t),S.release(t)}}_rebuildTree(t,e){_(U,e.bounds),U[3]=e.halfSize,v([t,U],t=>t,K);const n=S.acquire().init(this._root);this._root.initFrom(null,K,K[3]),this._root.increaseHalfSize(1.25),j(n,t=>(this.add(t.node.terminals.data),null!==t.node.residents&&this.add(t.node.residents.data),!0)),S.release(n)}_placingRootViolatesMaxDepth(t){const e=Math.log(t.halfSize/this._root.halfSize)*Math.LOG2E;let n=0;return j(this._root,t=>(n=Math.max(n,t.depth),n+e<=this._maximumDepth)),n+e>this._maximumDepth}_rootBoundsForRootAsSubNode(t){const e=t[3],n=t;let o=-1/0;const i=this._root.bounds,s=this._root.halfSize;for(let h=0;h<3;h++){const t=i[h]-s-(n[h]-e),r=n[h]+e-(i[h]+s),a=Math.max(0,Math.ceil(t/(2*s))),l=Math.max(0,Math.ceil(r/(2*s)))+1,d=2**Math.ceil(Math.log(a+l)*Math.LOG2E);o=Math.max(o,d),Q[h].min=a,Q[h].max=l}for(let h=0;h<3;h++){let t=Q[h].min,e=Q[h].max;const n=(o-(t+e))/2;t+=Math.ceil(n),e+=Math.floor(n);const r=i[h]-s-t*s*2;I[h]=r+(e+t)*s}const r=o*s;return I[3]=r*y,S.acquire().initFrom(null,I,r,0)}_growRootAsSubNode(t){const e=this._root.node;_(G,this._root.bounds),G[3]=this._root.halfSize,this._root.init(t),t.advanceTo(G,null,!0),t.node.children=e.children,t.node.residents=e.residents,t.node.terminals=e.terminals}_shrink(){for(;;){const t=this._findShrinkIndex();if(-1===t)break;this._root.advance(t),this._root.depth=0}}_findShrinkIndex(){if(0!==this._root.node.terminals.length||this._root.isLeaf())return-1;let t=null;const e=this._root.node.children;let n=0,o=0;for(;o<e.length&&null==t;)n=o++,t=e[n];for(;o<e.length;)if(e[o++])return-1;return n}_isDegenerate(t){return!F(this.objectToBoundingSphere(t)[3])}_fitsInsideTree(t){const e=this._root.bounds,n=this._root.halfSize;return t[3]<=n&&t[0]>=e[0]-n&&t[0]<=e[0]+n&&t[1]>=e[1]-n&&t[1]<=e[1]+n&&t[2]>=e[2]-n&&t[2]<=e[2]+n}toJSON(){const{maximumDepth:t,maximumObjectsPerNode:e,_objectCount:n}=this,o=this._nodeToJSON(this._root.node);return{maximumDepth:t,maximumObjectsPerNode:e,objectCount:n,root:{bounds:this._root.bounds,halfSize:this._root.halfSize,depth:this._root.depth,node:o}}}_nodeToJSON(t){const e=t.children.map(t=>t?this._nodeToJSON(t):null),n=t.residents?.map(t=>this.objectToBoundingSphere(t)),o=t.terminals?.map(t=>this.objectToBoundingSphere(t));return{children:e,residents:n,terminals:o}}static fromJSON(t){const e=new g(t=>t,{maximumDepth:t.maximumDepth,maximumObjectsPerNode:t.maximumObjectsPerNode});return e._objectCount=t.objectCount,e._root.initFrom(t.root.node,t.root.bounds,t.root.halfSize,t.root.depth),e}}class S{constructor(){this.bounds=m(),this.halfSize=0,this.initFrom(null,null,0,0)}init(t){return this.initFrom(t.node,t.bounds,t.halfSize,t.depth)}initFrom(t,e,n,o=this.depth){return this.node=null!=t?t:S.createEmptyNode(),e&&d(e,this.bounds),this.halfSize=n,this.depth=o,this}increaseHalfSize(t){this.halfSize*=t,this.updateBoundsRadiusFromHalfSize()}updateBoundsRadiusFromHalfSize(){this.bounds[3]=this.halfSize*y}advance(t){let e=this.node.children[t];e||(e=S.createEmptyNode(),this.node.children[t]=e),this.node=e,this.halfSize/=2,this.depth++;const n=q[t];return this.bounds[0]+=n[0]*this.halfSize,this.bounds[1]+=n[1]*this.halfSize,this.bounds[2]+=n[2]*this.halfSize,this.updateBoundsRadiusFromHalfSize(),this}advanceTo(t,e,n=!1){for(;;){if(this.isTerminalFor(t))return e&&e(this,-1),!0;if(this.isLeaf()){if(!n)return e&&e(this,-1),!1;this.node.residents=null}const o=this._childIndex(t);e&&e(this,o),this.advance(o)}}isLeaf(){return null!=this.node.residents}isTerminalFor(t){return t[3]>this.halfSize/2}_childIndex(t){const e=this.bounds;return(e[0]<t[0]?1:0)+(e[1]<t[1]?2:0)+(e[2]<t[2]?4:0)}static createEmptyNode(){return{children:[null,null,null,null,null,null,null,null],terminals:new e({shrink:!0}),residents:new e({shrink:!0})}}static{this._pool=new t(S)}static acquire(){return S._pool.acquire()}static release(t){S._pool.release(t)}static clearPool(){S._pool.prune()}}function j(t,e){let n=S.acquire().init(t);const o=[n];for(;0!==o.length;){if(n=o.pop(),e(n)&&!n.isLeaf())for(let t=0;t<n.node.children.length;t++){n.node.children[t]&&o.push(S.acquire().init(n).advance(t))}S.release(n)}}function x(t,e,n,o=1){let i=S.acquire().init(t);const s=[i];for(E(n,o,Y);0!==s.length;){if(i=s.pop(),e(i)&&!i.isLeaf())for(let t=7;t>=0;--t){const e=Y[t];i.node.children[e]&&s.push(S.acquire().init(i).advance(e))}S.release(i)}}function O(t,e,n){W.clear();const o=n.advanceTo(e,(t,e)=>{W.push(t.node),W.push(e)})?n.node.terminals:n.node.residents;if(o.removeUnordered(t),0===o.length)for(let i=W.length-2;i>=0;i-=2){if(!z(W.data[i],W.data[i+1]))break}}function z(t,n){return n>=0&&(t.children[n]=null),!!T(t)&&(null===t.residents&&(t.residents=new e({shrink:!0})),!0)}function M(t,e){return B(c(e.bounds),2*-e.halfSize,H),B(c(e.bounds),2*e.halfSize,J),b(t.origin,t.direction,H,J)}function N(t,e,n){return B(c(e.bounds),2*-e.halfSize,H),B(c(e.bounds),2*e.halfSize,J),n.applyToMinMax(H,J),b(t.origin,t.direction,H,J)}function T(t){if(0!==t.terminals.length)return!1;if(null!==t.residents)return 0===t.residents.length;for(let e=0;e<t.children.length;e++)if(t.children[e])return!1;return!0}function D(t,e){t[0]=Math.min(t[0],e[0]-e[3]),t[1]=Math.min(t[1],e[1]-e[3]),t[2]=Math.min(t[2],e[2]-e[3])}function A(t,e){t[0]=Math.max(t[0],e[0]+e[3]),t[1]=Math.max(t[1],e[1]+e[3]),t[2]=Math.max(t[2],e[2]+e[3])}function B(t,e,n){n[0]=t[0]+e,n[1]=t[1]+e,n[2]=t[2]+e}function v(t,e,o){H[0]=1/0,H[1]=1/0,H[2]=1/0,J[0]=-1/0,J[1]=-1/0,J[2]=-1/0;for(const n of t){const t=e(n);F(t[3])&&(D(H,t),A(J,t))}p(o,n(Z,H,J,.5)),o[3]=Math.max(J[0]-H[0],J[1]-H[1],J[2]-H[2])/2}function E(t,e,n){if(!X.length)for(let o=0;o<8;++o)X.push({index:0,distance:0});for(let o=0;o<8;++o){const n=q[o];X.data[o].index=o,X.data[o].distance=R(t,e,n)}X.sort((t,e)=>t.distance-e.distance);for(let o=0;o<8;++o)n[o]=X.data[o].index}function P(t,e){let n,o=1/0;for(let i=0;i<8;++i){const s=R(t,e,w[i]);s<o&&(o=s,n=w[i])}return n}function R(t,e,n){return e*(t[0]*n[0]+t[1]*n[1]+t[2]*n[2])}function F(t){return!isNaN(t)&&t!==-1/0&&t!==1/0&&t>0}const q=[r(-1,-1,-1),r(1,-1,-1),r(-1,1,-1),r(1,1,-1),r(-1,-1,1),r(1,-1,1),r(-1,1,1),r(1,1,1)],w=[r(-1,-1,-1),r(-1,-1,1),r(-1,1,-1),r(-1,1,1),r(1,-1,-1),r(1,-1,1),r(1,1,-1),r(1,1,1)],y=Math.sqrt(3),k=[null];function C(t){return k[0]=t,k}const I=m(),L=h(),H=h(),J=h(),W=new e,V=m(),G=m(),U=m(),K=m(),Q=[{min:0,max:0},{min:0,max:0},{min:0,max:0}],X=new e,Y=[0,0,0,0,0,0,0,0],Z=h();export{g as Octree};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{copy as t,set as e,length as i,normalize as s,dot as o,scale as r,add as n}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{create as a}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{h as l,i as h}from"../../../../chunks/vec32.js";import{create as c}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{c as p}from"../../../../chunks/vec42.js";import{fromValues as u}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{newFloatArray as m}from"../../../../geometry/support/FloatArray.js";import{newHalfFloatArray as f}from"../../../../geometry/support/HalfFloatArray.js";import{getZeroIndexArray as d}from"../../../../geometry/support/Indices.js";import{Attribute as b,Vertices as v}from"./Attribute.js";import{decompressNormal as g,compressNormal as x}from"./Normals.js";import{intersectTriangles as A}from"./RayIntersections.js";class w{constructor(t){this.builder=t}onPathChanged(t){this.builder.onPathChanged()}}class y extends w{constructor(t){super(t),this.color=u(255,255,255,255),this._size=a(),this.positions=m(3*this.builder.numVerticesTotal),this.normals=new Int16Array(2*this.builder.numVerticesTotal)}bakeVertexColors(t){p(this.color,t)}bake(a){t(this._size,a);const{numVerticesTotal:c,pathVertexData:p,positions:u,profileRightAxes:m,profileUpAxes:f,profileVertexAndNormals:d,profileAuxData:b}=this.builder;for(let t=0;t<c;++t){let c=p[t];c*=3;const v=_;let A=0,w=0;const y=g(I,m,t),j=g(k,f,t),D=4*t,P=e(V,d[D]*a[0],d[D+1]*a[1]),F=3*t;if(1===b[F+2])l(v,j,y),A=b[F]*a[0],w=b[F+1];else{const t=C,a=z;e(t,b[F],b[F+1]);const l=i(t);s(t,t);const c=o(P,t);if(Math.abs(c)>l){e(a,-t[1],t[0]);const i=o(P,a);r(t,t,l*Math.sign(c)),r(a,a,i),n(P,t,a)}h(v,0,0,0)}const N=y[0]*P[0]+j[0]*P[1],R=y[1]*P[0]+j[1]*P[1],M=y[2]*P[0]+j[2]*P[1];this.positions[F]=u[c]+N+v[0]*A,this.positions[F+1]=u[c+1]+R+v[1]*A,this.positions[F+2]=u[c+2]+M+v[2]*A;const T=d[D+2],U=d[D+3];x(this.normals,t,y[0]*T+j[0]*U+v[0]*w,y[1]*T+j[1]*U+v[1]*w,y[2]*T+j[2]*U+v[2]*w)}}createGeometryData(){const t=this.builder.vertexIndices;return[["position",new b(this.positions,t,3,!0)],["normalCompressed",new b(this.normals,t,2,!0)],["color",new b(this.color,d(t.length),4,!0)]]}onPathChanged(t){super.onPathChanged(t),this.bake(this.size)}intersect(t,e,i,s){const o=this.builder.vertexIndices,r=new v(this.positions,3),n=o.length/3;A(t,e,0,n,o,r,void 0,i,(t,e,i)=>s(t,i,e))}get size(){return this._size}}class j extends w{constructor(t,e,i,s){super(t),this.sizeAttributeValue=e,this.colorAttributeValue=i,this.opacityAttributeValue=s,this.baked=new y(t),this._vvSize=m(this.builder.path.vertices.length).fill(e),this._vvColor=f(this.builder.path.vertices.length).fill(i),this._vvOpacity=f(this.builder.path.vertices.length).fill(s)}createGeometryData(){const t=this.builder,{pathVertexIndices:e,vertexIndices:i}=t;return[["position",new b(t.positions,e,3,!0)],["profileVertexAndNormal",new b(t.profileVertexAndNormals,i,4,!0)],["profileAuxData",new b(t.profileAuxData,i,3,!0)],["profileRight",new b(t.profileRightAxes,i,2,!0)],["profileUp",new b(t.profileUpAxes,i,2,!0)],["sizeFeatureAttribute",new b(this._vvSize,e,1,!0)],["colorFeatureAttribute",new b(this._vvColor,e,1,!0)],["opacityFeatureAttribute",new b(this._vvOpacity,e,1,!0)]]}onPathChanged(t){super.onPathChanged(t);const e=t.getMutableAttribute("position");e&&(e.data=this.builder.positions)}}const V=a(),C=a(),z=a(),_=c(),I=c(),k=c();export{j as FastUpdatePathGeometry,w as PathGeometryData,y as StaticPathGeometry};
5
+ import{copy as t,set as e,length as i,normalize as s,dot as o,scale as r,add as n}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{create as a}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{h as l,i as h}from"../../../../chunks/vec32.js";import{create as c}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{d as p}from"../../../../chunks/vec42.js";import{fromValues as u}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{newFloatArray as m}from"../../../../geometry/support/FloatArray.js";import{newHalfFloatArray as f}from"../../../../geometry/support/HalfFloatArray.js";import{getZeroIndexArray as d}from"../../../../geometry/support/Indices.js";import{Attribute as b,Vertices as v}from"./Attribute.js";import{decompressNormal as g,compressNormal as x}from"./Normals.js";import{intersectTriangles as A}from"./RayIntersections.js";class w{constructor(t){this.builder=t}onPathChanged(t){this.builder.onPathChanged()}}class y extends w{constructor(t){super(t),this.color=u(255,255,255,255),this._size=a(),this.positions=m(3*this.builder.numVerticesTotal),this.normals=new Int16Array(2*this.builder.numVerticesTotal)}bakeVertexColors(t){p(this.color,t)}bake(a){t(this._size,a);const{numVerticesTotal:c,pathVertexData:p,positions:u,profileRightAxes:m,profileUpAxes:f,profileVertexAndNormals:d,profileAuxData:b}=this.builder;for(let t=0;t<c;++t){let c=p[t];c*=3;const v=_;let A=0,w=0;const y=g(I,m,t),j=g(k,f,t),D=4*t,P=e(V,d[D]*a[0],d[D+1]*a[1]),F=3*t;if(1===b[F+2])l(v,j,y),A=b[F]*a[0],w=b[F+1];else{const t=C,a=z;e(t,b[F],b[F+1]);const l=i(t);s(t,t);const c=o(P,t);if(Math.abs(c)>l){e(a,-t[1],t[0]);const i=o(P,a);r(t,t,l*Math.sign(c)),r(a,a,i),n(P,t,a)}h(v,0,0,0)}const N=y[0]*P[0]+j[0]*P[1],R=y[1]*P[0]+j[1]*P[1],M=y[2]*P[0]+j[2]*P[1];this.positions[F]=u[c]+N+v[0]*A,this.positions[F+1]=u[c+1]+R+v[1]*A,this.positions[F+2]=u[c+2]+M+v[2]*A;const T=d[D+2],U=d[D+3];x(this.normals,t,y[0]*T+j[0]*U+v[0]*w,y[1]*T+j[1]*U+v[1]*w,y[2]*T+j[2]*U+v[2]*w)}}createGeometryData(){const t=this.builder.vertexIndices;return[["position",new b(this.positions,t,3,!0)],["normalCompressed",new b(this.normals,t,2,!0)],["color",new b(this.color,d(t.length),4,!0)]]}onPathChanged(t){super.onPathChanged(t),this.bake(this.size)}intersect(t,e,i,s){const o=this.builder.vertexIndices,r=new v(this.positions,3),n=o.length/3;A(t,e,0,n,o,r,void 0,i,(t,e,i)=>s(t,i,e))}get size(){return this._size}}class j extends w{constructor(t,e,i,s){super(t),this.sizeAttributeValue=e,this.colorAttributeValue=i,this.opacityAttributeValue=s,this.baked=new y(t),this._vvSize=m(this.builder.path.vertices.length).fill(e),this._vvColor=f(this.builder.path.vertices.length).fill(i),this._vvOpacity=f(this.builder.path.vertices.length).fill(s)}createGeometryData(){const t=this.builder,{pathVertexIndices:e,vertexIndices:i}=t;return[["position",new b(t.positions,e,3,!0)],["profileVertexAndNormal",new b(t.profileVertexAndNormals,i,4,!0)],["profileAuxData",new b(t.profileAuxData,i,3,!0)],["profileRight",new b(t.profileRightAxes,i,2,!0)],["profileUp",new b(t.profileUpAxes,i,2,!0)],["sizeFeatureAttribute",new b(this._vvSize,e,1,!0)],["colorFeatureAttribute",new b(this._vvColor,e,1,!0)],["opacityFeatureAttribute",new b(this._vvOpacity,e,1,!0)]]}onPathChanged(t){super.onPathChanged(t);const e=t.getMutableAttribute("position");e&&(e.data=this.builder.positions)}}const V=a(),C=a(),z=a(),_=c(),I=c(),k=c();export{j as FastUpdatePathGeometry,w as PathGeometryData,y as StaticPathGeometry};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{generateUID as t}from"../../../../core/uid.js";import{copy as r,multiply as i}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as e}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{t as s}from"../../../../chunks/vec32.js";import{N as o,c as n,a}from"../../../../chunks/sphere.js";import{maxScale as h}from"../../support/mathUtils.js";class m{constructor(r,i={}){this.geometry=r,this.screenToWorldRatio=1,this._transformation=e(),this._shaderTransformation=null,this._boundingSphere=null,this.id=t(),this.layerViewUid=i.layerViewUid,this.graphicUid=i.graphicUid,this.castShadow=i.castShadow??!1,i.objectShaderTransformation&&this.objectShaderTransformationChanged(i.objectShaderTransformation)}get transformation(){return this._transformation}set transformation(t){r(this._transformation,t),this._boundingSphere=null}get boundingInfo(){return this.geometry.boundingInfo}objectShaderTransformationChanged(t){null==t?this._shaderTransformation=null:(this._shaderTransformation??=e(),i(this._shaderTransformation,t,this.geometry.transformation)),this._boundingSphere=null}get boundingSphere(){return this.boundingInfo?(null==this._boundingSphere&&(this._boundingSphere??=n(),s(a(this._boundingSphere),this.boundingInfo.center,this.shaderTransformation),this._boundingSphere[3]=this.boundingInfo.radius*h(this.shaderTransformation)),this._boundingSphere):o}get material(){return this.geometry.material}get type(){return this.geometry.type}get shaderTransformation(){return this._shaderTransformation??this.transformation}get attributes(){return this.geometry.attributes}foreachHighlightOptions(t){this.geometry.foreachHighlightOptions(t)}get hasHighlights(){return this.geometry.hasHighlights}get occludees(){return this.geometry.occludees}get visible(){return this.geometry.visible}set visible(t){this.geometry.visible=t}}class g extends m{}export{m as RenderGeometry,g as ValidatedRenderGeometry};
5
+ import{generateUID as t}from"../../../../core/uid.js";import{copy as r,multiply as i}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as e}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{N as s,c as o,l as n}from"../../../../chunks/sphere.js";import{maxScale as a}from"../../support/mathUtils.js";class h{constructor(r,i={}){this.geometry=r,this.screenToWorldRatio=1,this._transformation=e(),this._shaderTransformation=null,this._boundingSphere=null,this.id=t(),this.layerViewUid=i.layerViewUid,this.graphicUid=i.graphicUid,this.castShadow=i.castShadow??!1,i.objectShaderTransformation&&this.objectShaderTransformationChanged(i.objectShaderTransformation)}get transformation(){return this._transformation}set transformation(t){r(this._transformation,t),this._boundingSphere=null}get boundingInfo(){return this.geometry.boundingInfo}objectShaderTransformationChanged(t){null==t?this._shaderTransformation=null:(this._shaderTransformation??=e(),i(this._shaderTransformation,t,this.geometry.transformation)),this._boundingSphere=null}get boundingSphere(){return this.boundingInfo?(null==this._boundingSphere&&(this._boundingSphere??=o(),n(this._boundingSphere,this.boundingInfo.center,this.shaderTransformation),this._boundingSphere[3]=this.boundingInfo.radius*a(this.shaderTransformation)),this._boundingSphere):s}get material(){return this.geometry.material}get type(){return this.geometry.type}get shaderTransformation(){return this._shaderTransformation??this.transformation}get attributes(){return this.geometry.attributes}foreachHighlightOptions(t){this.geometry.foreachHighlightOptions(t)}get hasHighlights(){return this.geometry.hasHighlights}get occludees(){return this.geometry.occludees}get visible(){return this.geometry.visible}set visible(t){this.geometry.visible=t}}class g extends h{}export{h as RenderGeometry,g as ValidatedRenderGeometry};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import t from"../../../../core/Accessor.js";import{disposeMaybe as s}from"../../../../core/maybe.js";import{property as i}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/Logger.js";import"../../../../core/RandomLCG.js";import{subclass as r}from"../../../../core/accessorSupport/decorators/subclass.js";import{a,c as o}from"../../../../chunks/vec42.js";import{createQuadVAO as n}from"./glUtil3D.js";import{S as h}from"../../../../chunks/ShadowCastVisualize.glsl.js";import{ShadowCastVisualizeTechnique as d}from"../shaders/ShadowCastVisualizeTechnique.js";import{ShadowCastVisualizeTechniqueConfiguration as l}from"../shaders/ShadowCastVisualizeTechniqueConfiguration.js";const _=4e4,p=5e4,m=1/512;let c=class extends t{constructor(e,t,s,i){super({}),this._techniques=e,this._rctx=t,this._data=s,this._requestRender=i,this._passParameters=new h(this._data),this._configuration=new l,this._enabled=!1,this._vao=n(t)}dispose(){this._stop(),this._vao=s(this._vao)}precompile(){this._showVisualization&&this._techniques.precompile(d,this._configuration)}render(e){if(!this._showVisualization)return;const[t,s]=this._data.computedSamples;this._passParameters.sampleScale=[t?1/t:0,s?1/s:0];const i=this._techniques.get(d,this._configuration);this._rctx.bindVAO(this._vao),this._rctx.bindTechnique(i,e,this._passParameters),this._rctx.drawArrays(i.primitiveType,0,this._vao.vertexCount("geometry"))}setOptions(e){void 0!==e.enabled&&this._setEnabled(e.enabled),void 0!==e.thresholdColor&&this._setThresholdColor(e.thresholdColor),void 0!==e.gradientColor&&this._setGradientColor(e.gradientColor),void 0!==e.bandedGradientColor&&this._setBandedGradientColor(e.bandedGradientColor),void 0!==e.threshold&&(this._threshold=e.threshold),void 0!==e.visualization&&(this._visualization=e.visualization),void 0!==e.bandSize&&(this._bandSize=e.bandSize)}get opacityFromElevation(){return this._passParameters.opacityFromElevation}set opacityFromElevation(e){this._passParameters.opacityFromElevation!==e&&(this._passParameters.opacityFromElevation=e,this.notifyChange("opacityFromElevation"))}get _showVisualization(){return this._enabled&&(this._data.computedSamples[0]>0||this._data.computedSamples[1]>0)&&this.opacityFromElevation>m}get _threshold(){return this._passParameters.threshold}set _threshold(e){this._threshold!==e&&(this._passParameters.threshold=e,this._requestRenderIfEnabled())}get _visualization(){return this._configuration.visualization}set _visualization(e){e!==this._visualization&&(this._configuration.visualization=e,this._requestRenderIfEnabled())}get _bandSize(){return this._passParameters.bandSize}set _bandSize(e){e!==this._bandSize&&(this._passParameters.bandSize=e,this._requestRenderIfEnabled())}_setThresholdColor(e){const t=this._passParameters.thresholdColor;a(e,t)||(o(this._passParameters.thresholdColor,e),this._requestRenderIfEnabled())}_setGradientColor(e){const t=this._passParameters.gradientColor;a(e,t)||(o(this._passParameters.gradientColor,e),this._requestRenderIfEnabled())}_setBandedGradientColor(e){const t=this._passParameters.bandedGradientColor;a(e,t)||(o(this._passParameters.bandedGradientColor,e),this._requestRenderIfEnabled())}_setEnabled(e){e!==this._enabled&&(e?this._start():this._stop())}_requestRenderIfEnabled(){this._enabled&&this._requestRender()}_start(){this._enabled=!0,this._requestRender()}_stop(){this._enabled=!1,this._requestRender()}};e([i()],c.prototype,"opacityFromElevation",null),c=e([r("esri.views.3d.webgl-engine.lib.ShadowCastRenderer")],c);export{c as ShadowCastRenderer,p as shadowCastDisableElevationMax,_ as shadowCastDisableElevationMin,m as shadowCastDisabledElevationThreshold};
5
+ import{__decorate as e}from"tslib";import t from"../../../../core/Accessor.js";import{disposeMaybe as s}from"../../../../core/maybe.js";import{property as i}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/Logger.js";import"../../../../core/RandomLCG.js";import{subclass as r}from"../../../../core/accessorSupport/decorators/subclass.js";import{a,d as o}from"../../../../chunks/vec42.js";import{createQuadVAO as n}from"./glUtil3D.js";import{S as h}from"../../../../chunks/ShadowCastVisualize.glsl.js";import{ShadowCastVisualizeTechnique as d}from"../shaders/ShadowCastVisualizeTechnique.js";import{ShadowCastVisualizeTechniqueConfiguration as l}from"../shaders/ShadowCastVisualizeTechniqueConfiguration.js";const _=4e4,p=5e4,m=1/512;let c=class extends t{constructor(e,t,s,i){super({}),this._techniques=e,this._rctx=t,this._data=s,this._requestRender=i,this._passParameters=new h(this._data),this._configuration=new l,this._enabled=!1,this._vao=n(t)}dispose(){this._stop(),this._vao=s(this._vao)}precompile(){this._showVisualization&&this._techniques.precompile(d,this._configuration)}render(e){if(!this._showVisualization)return;const[t,s]=this._data.computedSamples;this._passParameters.sampleScale=[t?1/t:0,s?1/s:0];const i=this._techniques.get(d,this._configuration);this._rctx.bindVAO(this._vao),this._rctx.bindTechnique(i,e,this._passParameters),this._rctx.drawArrays(i.primitiveType,0,this._vao.vertexCount("geometry"))}setOptions(e){void 0!==e.enabled&&this._setEnabled(e.enabled),void 0!==e.thresholdColor&&this._setThresholdColor(e.thresholdColor),void 0!==e.gradientColor&&this._setGradientColor(e.gradientColor),void 0!==e.bandedGradientColor&&this._setBandedGradientColor(e.bandedGradientColor),void 0!==e.threshold&&(this._threshold=e.threshold),void 0!==e.visualization&&(this._visualization=e.visualization),void 0!==e.bandSize&&(this._bandSize=e.bandSize)}get opacityFromElevation(){return this._passParameters.opacityFromElevation}set opacityFromElevation(e){this._passParameters.opacityFromElevation!==e&&(this._passParameters.opacityFromElevation=e,this.notifyChange("opacityFromElevation"))}get _showVisualization(){return this._enabled&&(this._data.computedSamples[0]>0||this._data.computedSamples[1]>0)&&this.opacityFromElevation>m}get _threshold(){return this._passParameters.threshold}set _threshold(e){this._threshold!==e&&(this._passParameters.threshold=e,this._requestRenderIfEnabled())}get _visualization(){return this._configuration.visualization}set _visualization(e){e!==this._visualization&&(this._configuration.visualization=e,this._requestRenderIfEnabled())}get _bandSize(){return this._passParameters.bandSize}set _bandSize(e){e!==this._bandSize&&(this._passParameters.bandSize=e,this._requestRenderIfEnabled())}_setThresholdColor(e){const t=this._passParameters.thresholdColor;a(e,t)||(o(this._passParameters.thresholdColor,e),this._requestRenderIfEnabled())}_setGradientColor(e){const t=this._passParameters.gradientColor;a(e,t)||(o(this._passParameters.gradientColor,e),this._requestRenderIfEnabled())}_setBandedGradientColor(e){const t=this._passParameters.bandedGradientColor;a(e,t)||(o(this._passParameters.bandedGradientColor,e),this._requestRenderIfEnabled())}_setEnabled(e){e!==this._enabled&&(e?this._start():this._stop())}_requestRenderIfEnabled(){this._enabled&&this._requestRender()}_start(){this._enabled=!0,this._requestRender()}_stop(){this._enabled=!1,this._requestRender()}};e([i()],c.prototype,"opacityFromElevation",null),c=e([r("esri.views.3d.webgl-engine.lib.ShadowCastRenderer")],c);export{c as ShadowCastRenderer,p as shadowCastDisableElevationMax,_ as shadowCastDisableElevationMin,m as shadowCastDisabledElevationThreshold};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import s from"../../../../core/Collection.js";import{deg2rad as t}from"../../../../core/mathUtils.js";import{disposeMaybe as r}from"../../../../core/maybe.js";import{watch as i,when as o,initial as a,sync as n}from"../../../../core/reactiveUtils.js";import{property as h}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/Logger.js";import"../../../../core/RandomLCG.js";import{subclass as d}from"../../../../core/accessorSupport/decorators/subclass.js";import{translate as c,fromTranslation as p,scale as w,mul as l}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as m}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{a as u,j as f}from"../../../../chunks/vec32.js";import{create as v,fromValues as _}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{l as V}from"../../../../chunks/sphere.js";import{InternalRenderCategory as g}from"../../webgl.js";import M from"../../webgl/RenderNode.js";import{ViewshedShadowMap as b}from"./ViewshedShadowMap.js";import{V as S}from"../../../../chunks/Viewshed.glsl.js";import{ViewshedTechnique as y}from"../shaders/ViewshedTechnique.js";let j=class extends M{get shadowMap(){return this._shadowMap}get hasViewsheds(){return this._viewsheds.length>0}get _contentPixelRatio(){return this.view.state.contentPixelRatio}get _viewshedsInView(){return this._viewsheds.items.filter(e=>x(this.view,e))}constructor(e){super(e),this.isDecoration=!1,this._passParameters=new S,this._viewsheds=new s,this._shadowMap=null,this.consumes={required:[g.VIEWSHED,"normals"]},this.produces=g.VIEWSHED,this.requireGeometryDepth=!0}initialize(){this._shadowMap=new b(this.fboCache),this.addHandles([i(()=>this.view.resolutionScale,e=>{const s=this._shadowMap;s&&(s.settings.textureSizeQuality=e)},a),o(()=>!this.hasViewsheds,()=>this._shadowMap?.dispose()),i(()=>this._viewshedsInView.map(e=>[e.observerRenderSpace,e.heading,e.tilt,e.farDistance,e.horizontalFieldOfView,e.verticalFieldOfView]),()=>this.requestRender(1),n)])}destroy(){this._shadowMap=r(this._shadowMap)}precompile(){if(this.hasViewsheds){this.techniques.precompile(y);for(const e of this._viewshedsInView)if(this._shadowMap?.isActive(e))return void this.view.stage.renderer.precompileViewshedShadowMap()}}render(e){const s=this.bindParameters,t=this.renderingContext,r=e.find(({name:e})=>e===g.VIEWSHED);if(!this.hasViewsheds||!s.depth||this.isDecoration&&!s.decorations)return r;this._passParameters.shadowMap=this._shadowMap??this._passParameters.shadowMap,this._passParameters.normals=e.find(({name:e})=>"normals"===e)?.getTexture();const i=this.techniques.get(y);if(!i?.compiled)return this.requestRender(1),r;const o=this.view.stage.renderer.isFeatureEnabled(7);for(const a of this._viewshedsInView){if(!this._renderShadowCubeMap(s,a,o)||!this._shadowMap?.ready)continue;const e=this._setupViewshedParameters(a,s.camera);t.bindTechnique(i,s,e),t.bindFramebuffer(r.fbo),t.screen.draw()}return this.shadowMap?.dispose(),r}updateViewsheds(e){const s=this._viewsheds,{removes:t,adds:r}=e;if(t&&(Array.isArray(t)?s.removeMany(t):s.remove(t)),r)if(Array.isArray(r)){const e=r.filter(e=>!s.includes(e));s.addMany(e)}else s.includes(r)||s.add(r)}_renderShadowCubeMap(e,s,t){const r=this._shadowMap;if(!r)return!1;const i=this.view.basemapTerrain.hasStencilEnabledExtents,o=r.start(e.camera,s,t,this._contentPixelRatio,i);return o&&r.faces.forEach(e=>this.view.stage.renderer.renderViewshedShadowMap(e)),r.finish(),o}_setupViewshedParameters(e,s){const r=this._shadowMap;if(!r)return this._passParameters;const i=this._passParameters,o=e.effectiveObserverRenderSpace;i.localOrigin=o,i.observerOffset=u(E,e.observerRenderSpace,e.effectiveObserverRenderSpace),i.fovs=[t(e.horizontalFieldOfView),t(e.verticalFieldOfView)],i.headingAndTilt=[t(e.heading),t(e.tiltParallelToSurface)],i.upVector=e.tiltedUpVector;const a=R(e.targetRenderSpace,o);i.targetVector=a;const n=new Array,h=new Array;for(let t=0;t<r.numActiveFaces;t++)c(I,r.viewshedViewMatrices[t],o),n.push(...I),P(r.viewshedProjectionMatrices[t],I,D),h.push(...D);return i.viewMatrices=n,i.projectionMatrices=h,i.volumeOffset=this.selectedViewshed?.()===e.viewshed?A(e,this.view,s.eye):0,i}get test(){return{viewsheds:this._viewsheds,shadowMap:this._shadowMap,viewshedsInView:this._viewshedsInView}}};function R(e,s){const t=v();return u(t,e,s)}function P(e,s,t){const r=_(.5,.5,.5);return p(t,r),w(t,t,r),l(t,t,e),l(t,t,s),t}function x(e,s){const t=V(s.observerRenderSpace,s.farDistanceRenderSpace);return!!e.ready&&e.frustum.intersectsSphere(t)}function A(e,s,t){if(null==e)return 0;const{observerRenderSpace:r,targetRenderSpace:i}=e,o=f(t,r)>f(t,i)?e.observer:e.target;return s.pixelSizeAt(o)}e([h()],j.prototype,"selectedViewshed",void 0),e([h()],j.prototype,"isDecoration",void 0),e([h()],j.prototype,"shadowMap",null),e([h()],j.prototype,"hasViewsheds",null),e([h()],j.prototype,"_contentPixelRatio",null),e([h()],j.prototype,"_viewshedsInView",null),e([h()],j.prototype,"consumes",void 0),e([h()],j.prototype,"produces",void 0),j=e([d("esri.views.3d.webgl-engine.lib.Viewshed")],j);const E=v(),I=m(),D=m();export{j as Viewshed,A as computeOffsetScale};
5
+ import{__decorate as e}from"tslib";import s from"../../../../core/Collection.js";import{deg2rad as t}from"../../../../core/mathUtils.js";import{disposeMaybe as r}from"../../../../core/maybe.js";import{watch as i,when as o,initial as a,sync as n}from"../../../../core/reactiveUtils.js";import{property as h}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/Logger.js";import"../../../../core/RandomLCG.js";import{subclass as d}from"../../../../core/accessorSupport/decorators/subclass.js";import{translate as c,fromTranslation as p,scale as w,mul as l}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as m}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{a as u,j as f}from"../../../../chunks/vec32.js";import{create as v,fromValues as _}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{r as V}from"../../../../chunks/sphere.js";import{InternalRenderCategory as g}from"../../webgl.js";import M from"../../webgl/RenderNode.js";import{ViewshedShadowMap as b}from"./ViewshedShadowMap.js";import{V as S}from"../../../../chunks/Viewshed.glsl.js";import{ViewshedTechnique as y}from"../shaders/ViewshedTechnique.js";let j=class extends M{get shadowMap(){return this._shadowMap}get hasViewsheds(){return this._viewsheds.length>0}get _contentPixelRatio(){return this.view.state.contentPixelRatio}get _viewshedsInView(){return this._viewsheds.items.filter(e=>x(this.view,e))}constructor(e){super(e),this.isDecoration=!1,this._passParameters=new S,this._viewsheds=new s,this._shadowMap=null,this.consumes={required:[g.VIEWSHED,"normals"]},this.produces=g.VIEWSHED,this.requireGeometryDepth=!0}initialize(){this._shadowMap=new b(this.fboCache),this.addHandles([i(()=>this.view.resolutionScale,e=>{const s=this._shadowMap;s&&(s.settings.textureSizeQuality=e)},a),o(()=>!this.hasViewsheds,()=>this._shadowMap?.dispose()),i(()=>this._viewshedsInView.map(e=>[e.observerRenderSpace,e.heading,e.tilt,e.farDistance,e.horizontalFieldOfView,e.verticalFieldOfView]),()=>this.requestRender(1),n)])}destroy(){this._shadowMap=r(this._shadowMap)}precompile(){if(this.hasViewsheds){this.techniques.precompile(y);for(const e of this._viewshedsInView)if(this._shadowMap?.isActive(e))return void this.view.stage.renderer.precompileViewshedShadowMap()}}render(e){const s=this.bindParameters,t=this.renderingContext,r=e.find(({name:e})=>e===g.VIEWSHED);if(!this.hasViewsheds||!s.depth||this.isDecoration&&!s.decorations)return r;this._passParameters.shadowMap=this._shadowMap??this._passParameters.shadowMap,this._passParameters.normals=e.find(({name:e})=>"normals"===e)?.getTexture();const i=this.techniques.get(y);if(!i?.compiled)return this.requestRender(1),r;const o=this.view.stage.renderer.isFeatureEnabled(7);for(const a of this._viewshedsInView){if(!this._renderShadowCubeMap(s,a,o)||!this._shadowMap?.ready)continue;const e=this._setupViewshedParameters(a,s.camera);t.bindTechnique(i,s,e),t.bindFramebuffer(r.fbo),t.screen.draw()}return this.shadowMap?.dispose(),r}updateViewsheds(e){const s=this._viewsheds,{removes:t,adds:r}=e;if(t&&(Array.isArray(t)?s.removeMany(t):s.remove(t)),r)if(Array.isArray(r)){const e=r.filter(e=>!s.includes(e));s.addMany(e)}else s.includes(r)||s.add(r)}_renderShadowCubeMap(e,s,t){const r=this._shadowMap;if(!r)return!1;const i=this.view.basemapTerrain.hasStencilEnabledExtents,o=r.start(e.camera,s,t,this._contentPixelRatio,i);return o&&r.faces.forEach(e=>this.view.stage.renderer.renderViewshedShadowMap(e)),r.finish(),o}_setupViewshedParameters(e,s){const r=this._shadowMap;if(!r)return this._passParameters;const i=this._passParameters,o=e.effectiveObserverRenderSpace;i.localOrigin=o,i.observerOffset=u(E,e.observerRenderSpace,e.effectiveObserverRenderSpace),i.fovs=[t(e.horizontalFieldOfView),t(e.verticalFieldOfView)],i.headingAndTilt=[t(e.heading),t(e.tiltParallelToSurface)],i.upVector=e.tiltedUpVector;const a=R(e.targetRenderSpace,o);i.targetVector=a;const n=new Array,h=new Array;for(let t=0;t<r.numActiveFaces;t++)c(I,r.viewshedViewMatrices[t],o),n.push(...I),P(r.viewshedProjectionMatrices[t],I,D),h.push(...D);return i.viewMatrices=n,i.projectionMatrices=h,i.volumeOffset=this.selectedViewshed?.()===e.viewshed?A(e,this.view,s.eye):0,i}get test(){return{viewsheds:this._viewsheds,shadowMap:this._shadowMap,viewshedsInView:this._viewshedsInView}}};function R(e,s){const t=v();return u(t,e,s)}function P(e,s,t){const r=_(.5,.5,.5);return p(t,r),w(t,t,r),l(t,t,e),l(t,t,s),t}function x(e,s){const t=V(s.observerRenderSpace,s.farDistanceRenderSpace);return!!e.ready&&e.frustum.intersectsSphere(t)}function A(e,s,t){if(null==e)return 0;const{observerRenderSpace:r,targetRenderSpace:i}=e,o=f(t,r)>f(t,i)?e.observer:e.target;return s.pixelSizeAt(o)}e([h()],j.prototype,"selectedViewshed",void 0),e([h()],j.prototype,"isDecoration",void 0),e([h()],j.prototype,"shadowMap",null),e([h()],j.prototype,"hasViewsheds",null),e([h()],j.prototype,"_contentPixelRatio",null),e([h()],j.prototype,"_viewshedsInView",null),e([h()],j.prototype,"consumes",void 0),e([h()],j.prototype,"produces",void 0),j=e([d("esri.views.3d.webgl-engine.lib.Viewshed")],j);const E=v(),I=m(),D=m();export{j as Viewshed,A as computeOffsetScale};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../../core/PooledArray.js";import{multiply as t}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as r}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{t as n}from"../../../../chunks/vec32.js";import{l as i}from"../../../../chunks/vec42.js";import{create as s}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{intersectsSphere as a}from"../../../../geometry/support/frustum.js";import{g as o,a as h,c as f}from"../../../../chunks/sphere.js";import{maxScale as c}from"../../support/mathUtils.js";import{DepthRange as l}from"./DepthRange.js";import{assert as u}from"./Util.js";const d=1e4,m=100,_=500,g=500,p=.1;function b(e,t,r,n){let i=0;if(!t.some(e=>!!e.material&&(i+=e.numGeometries,i>=d)))return V.compute(e,t,n);const s=new l;return r.forEach(t=>s.union(w(e,t))),s}function w(e,t){if(!t.visible)return;const r=new l,n=t.getSpatialQueryAccelerator();return n?M(r,e,n):j(r,e,t.objects),r}function M(e,t,r){const{eye:n,viewForward:i,frustum:s}=t,a=e=>e.visible,o=r.objectCount;if(o<_)F.set(t.near,Math.min(e.near,t.far)),r.forEachInDepthRange(n,i,1,F,(r,n)=>{R(e,t,r),F.far=e.near,n.setRange(F)},s,a),F.set(Math.max(e.far,t.near),t.far),r.forEachInDepthRange(n,i,-1,F,(r,n)=>{R(e,t,r),F.near=e.far,n.setRange(F)},s,a);else{const n=Math.max(Math.min(o,g),Math.ceil(o*p)),h=r.findClosest(i,1,s,a,n),f=r.findClosest(i,-1,s,a,n);h&&f&&(C(e,t,h.boundingVolumeWorldSpace.bounds),C(e,t,f.boundingVolumeWorldSpace.bounds))}}function j(e,t,r){W.clear(),r.forEach(e=>{e.visible&&0!==e.geometries.length&&W.add(e)}),W.empty||(W.sort(t),F.set(t.near,Math.min(e.near,t.far)),W.forEachInDepthRange(F,1,(r,n)=>{n<e.near&&R(e,t,r)}),F.set(Math.max(e.far,t.near),t.far),W.forEachInDepthRange(F,-1,(t,r,n)=>{e.far=Math.max(e.far,n)}))}function R(e,r,n){if(!n.visible)return;if(!a(r.frustum,n.boundingVolumeWorldSpace.bounds))return;const i=n.transformation,s=S;n.geometries.forEach(n=>{t(s,i,n.transformation);const a=c(s);v(e,r,n.boundingInfo,s,a)})}function v(e,t,r,i,s){if(null==r)return;n(h(E),r.center,i);const{eye:o,viewForward:f}=t,c=f[0]*(E[0]-o[0])+f[1]*(E[1]-o[1])+f[2]*(E[2]-o[2]);if(E[3]=r.radius*s,!(c-E[3]>e.near&&c+E[3]<e.far)&&a(t.frustum,E))if(r.radius>m&&r.getChildren())for(const n of r.getChildren())v(e,t,n,i,s);else N.unionDepthRangeWithAABB(e,t.viewProjectionMatrix,i,r.bbMin,r.bbMax)}function C(e,t,r){const n=t.eye,i=t.viewForward,s=(r[0]-n[0])*i[0]+(r[1]-n[1])*i[1]+(r[2]-n[2])*i[2];e.near=Math.min(e.near,s-r[3]),e.far=Math.max(e.far,s+r[3])}class x{constructor(){this._items=new e({allocator:e=>e||{object:null,distance:0,near:0,far:0},deallocator:e=>(e.object=null,e.distance=0,e.near=0,e.far=0,e)})}get length(){return this._items.length}get empty(){return 0===this._items.length}clear(){this._items.clear()}add(e){this._items.pushNew().object=e}sort(e){const t=e.eye,r=e.viewForward;this._items.forAll(e=>{const n=e.object.boundingVolumeWorldSpace.bounds,i=(n[0]-t[0])*r[0]+(n[1]-t[1])*r[1]+(n[2]-t[2])*r[2];e.distance=i,e.near=i-n[3],e.far=i+n[3]}),this._items.sort((e,t)=>e.distance-t.distance)}forEachInDepthRange(e,t,r){if(1===t)for(let n=0;n<this._items.length;++n){const t=this._items.data[n];t.far<e.near||t.near>e.far||r(t.object,t.near,t.far)}else for(let n=this._items.length-1;n>=0;--n){const t=this._items.data[n];t.far<e.near||t.near>e.far||r(t.object,t.near,t.far)}}}class B{constructor(){this._geometries=new Array,this._near=[],this._far=[],this._nearCandidates=[],this._farCandidates=[],this._looseRange=new l(0,0)}compute(e,t,r){this._reset();const{viewMatrix:n}=e;t.forEach(e=>{e.forEachGeometry(e=>{if(!e.visible||0===r&&!e.castShadow)return;const t=e.boundingSphere,i=n[2]*t[0]+n[6]*t[1]+n[10]*t[2]+n[14],s=i-t[3],a=i+t[3];this._geometries.push(e),this._near.push(-a),this._far.push(-s)})});const i=new l;if(0===this._geometries.length)return i;for(let h=0;h<this._geometries.length;++h)this._near[h]>i.far&&(i.far=this._near[h]),this._near[h]>2&&this._far[h]<i.near&&(i.near=this._far[h]);const s=this._looseRange;s.near=Math.max(.5*i.near,2),s.far=2*i.far;let a=0,o=0;for(let h=0;h<this._geometries.length;++h)this._near[h]<i.near&&(this._near[h]>=s.near?i.near=this._near[h]:this._nearCandidates[a++]=h),this._far[h]>i.far&&(this._far[h]<=s.far?i.far=this._far[h]:this._farCandidates[o++]=h);if(0===this._nearCandidates.length&&0===this._farCandidates.length)return i;this._nearCandidates.sort((e,t)=>this._near[e]<this._near[t]?-1:this._near[e]>this._near[t]?1:0),this._farCandidates.sort((e,t)=>this._far[e]<this._far[t]?1:this._far[e]>this._far[t]?-1:0);for(let h=0;h<this._nearCandidates.length;++h){const t=this._nearCandidates[h];if(this._near[t]<i.near){const r=this._geometries[t],{boundingInfo:n,shaderTransformation:s}=r;this._includeNearBoundingInfoRec(e,n,s,i)}}for(let h=0;h<this._farCandidates.length;++h){const t=this._farCandidates[h];if(this._far[t]>i.far){const r=this._geometries[t],{boundingInfo:n,shaderTransformation:s}=r;this._includeFarBoundingInfoRec(e,n,s,i)}}return this._reset(),i}_reset(){this._geometries.length=0,this._near.length=0,this._far.length=0,this._nearCandidates.length=0,this._farCandidates.length=0}_isOutsideSidePlanes(e,t){const r=h(e),n=o(e);return t[0][0]*r[0]+t[0][1]*r[1]+t[0][2]*r[2]+t[0][3]>n||t[1][0]*r[0]+t[1][1]*r[1]+t[1][2]*r[2]+t[1][3]>n||t[2][0]*r[0]+t[2][1]*r[1]+t[2][2]*r[2]+t[2][3]>n||t[3][0]*r[0]+t[3][1]*r[1]+t[3][2]*r[2]+t[3][3]>n}_includeNearBoundingInfoRec(e,t,r,i){if(null==t)return;const s=t.center;n(h(E),s,r),E[3]=t.radius*c(r);const{frustum:a}=e;if(this._isOutsideSidePlanes(E,a))return;const o=E[0],f=E[1],l=E[2],u=E[3],{viewMatrix:d}=e,_=d[2]*o+d[6]*f+d[10]*l+d[14],g=_+u;if(!(-(_-u)<2||-g>=i.near))if(-g>this._looseRange.near)i.near=-g;else{if(u>m){const n=t.getChildren();if(void 0!==n){for(const t of n)this._includeNearBoundingInfoRec(e,t,r,i);return}}N.unionDepthRangeWithAABB(i,e.viewProjectionMatrix,r,t.bbMin,t.bbMax)}}_includeFarBoundingInfoRec(e,t,r,i){if(null==t)return;const s=t.center;n(h(E),s,r),E[3]=t.radius*c(r);const{frustum:a}=e;if(this._isOutsideSidePlanes(E,a))return;const[o,f,l,u]=E,{viewMatrix:d}=e,_=d[2]*o+d[6]*f+d[10]*l+d[14]-u;if(!(-_<=i.far))if(-_<this._looseRange.far)i.far=-_;else{if(u>m){const n=t.getChildren();if(void 0!==n){for(const t of n)this._includeFarBoundingInfoRec(e,t,r,i);return}}N.unionDepthRangeWithAABB(i,e.viewProjectionMatrix,r,t.bbMin,t.bbMax)}}}class I{constructor(){this._modelViewProj=r(),this._clipPosition=[s(),s(),s(),s(),s(),s(),s(),s()]}unionDepthRangeWithAABB(e,r,n,i,s){const a=this._modelViewProj;t(a,r,n);let o=!1;for(let t=0;t<8;++t){const e=this._clipPosition[t],r=0===t||3===t||4===t||7===t?i[0]:s[0],n=0===t||1===t||4===t||5===t?i[1]:s[1],o=t<4?i[2]:s[2];e[0]=a[0]*r+a[4]*n+a[8]*o+a[12],e[1]=a[1]*r+a[5]*n+a[9]*o+a[13],e[2]=a[2]*r+a[6]*n+a[10]*o+a[14],e[3]=a[3]*r+a[7]*n+a[11]*o+a[15]}for(let t=0;t<12;++t){const r=P(this._clipPosition[D[t][0]],this._clipPosition[D[t][1]],this._clipPosition[D[t][2]]);let n=!0;for(let e=0;e<r.length;++e){if(r[e][3]>=2){n=!1;break}}if(!n){o=!0;for(let t=0;t<r.length;++t){const n=r[t][3];Number.isFinite(n)&&(e.near=Math.min(n,e.near),e.far=Math.max(n,e.far))}}}return o}}function P(e,t,r){let n=[e,t,r];for(let i=0;i<4;++i){const e=n;n=[];for(let t=0;t<e.length;++t){const r=e[t],s=e[(t+1)%e.length];A(s,i)?(A(r,i)||n.push(y(r,s,i)),n.push(s)):A(r,i)&&n.push(y(r,s,i))}}return n}function A(e,t){return 0===t?e[0]>=-e[3]:1===t?e[1]>=-e[3]:2===t?e[0]<=e[3]:3===t?e[1]<=e[3]:void u(!1)}function y(e,t,r){let n=0;return 0===r?n=(-e[3]-e[0])/(t[0]-e[0]+t[3]-e[3]):1===r?n=(-e[3]-e[1])/(t[1]-e[1]+t[3]-e[3]):2===r?n=(e[3]-e[0])/(t[0]-e[0]-t[3]+e[3]):3===r&&(n=(e[3]-e[1])/(t[1]-e[1]-t[3]+e[3])),i(s(),e,t,n)}const D=[[0,1,3],[2,3,1],[1,5,2],[6,2,5],[5,4,6],[7,6,4],[4,0,7],[3,7,0],[3,2,7],[6,7,2],[4,5,0],[1,0,5]],E=f(),S=r(),F=new l,W=new x,V=new B,N=new I;export{B as DepthRangeFromRenderGeometries,b as depthRangeFromScene};
5
+ import e from"../../../../core/PooledArray.js";import{multiply as t}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as r}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{l as n}from"../../../../chunks/vec42.js";import{create as i}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{intersectsSphere as a}from"../../../../geometry/support/frustum.js";import{c as s,a as o,g as h,l as f}from"../../../../chunks/sphere.js";import{maxScale as c}from"../../support/mathUtils.js";import{DepthRange as l}from"./DepthRange.js";import{assert as u}from"./Util.js";const d=1e4,m=100,_=500,g=500,p=.1;function b(e,t,r,n){let i=0;if(!t.some(e=>!!e.material&&(i+=e.numGeometries,i>=d)))return V.compute(e,t,n);const a=new l;return r.forEach(t=>a.union(w(e,t))),a}function w(e,t){if(!t.visible)return;const r=new l,n=t.getSpatialQueryAccelerator();return n?M(r,e,n):j(r,e,t.objects),r}function M(e,t,r){const{eye:n,viewForward:i,frustum:a}=t,s=e=>e.visible,o=r.objectCount;if(o<_)F.set(t.near,Math.min(e.near,t.far)),r.forEachInDepthRange(n,i,1,F,(r,n)=>{R(e,t,r),F.far=e.near,n.setRange(F)},a,s),F.set(Math.max(e.far,t.near),t.far),r.forEachInDepthRange(n,i,-1,F,(r,n)=>{R(e,t,r),F.near=e.far,n.setRange(F)},a,s);else{const n=Math.max(Math.min(o,g),Math.ceil(o*p)),h=r.findClosest(i,1,a,s,n),f=r.findClosest(i,-1,a,s,n);h&&f&&(v(e,t,h.boundingVolumeWorldSpace.bounds),v(e,t,f.boundingVolumeWorldSpace.bounds))}}function j(e,t,r){W.clear(),r.forEach(e=>{e.visible&&0!==e.geometries.length&&W.add(e)}),W.empty||(W.sort(t),F.set(t.near,Math.min(e.near,t.far)),W.forEachInDepthRange(F,1,(r,n)=>{n<e.near&&R(e,t,r)}),F.set(Math.max(e.far,t.near),t.far),W.forEachInDepthRange(F,-1,(t,r,n)=>{e.far=Math.max(e.far,n)}))}function R(e,r,n){if(!n.visible)return;if(!a(r.frustum,n.boundingVolumeWorldSpace.bounds))return;const i=n.transformation,s=S;n.geometries.forEach(n=>{t(s,i,n.transformation);const a=c(s);C(e,r,n.boundingInfo,s,a)})}function C(e,t,r,n,i){if(null==r)return;f(E,r.center,n);const{eye:s,viewForward:o}=t,h=o[0]*(E[0]-s[0])+o[1]*(E[1]-s[1])+o[2]*(E[2]-s[2]);if(E[3]=r.radius*i,!(h-E[3]>e.near&&h+E[3]<e.far)&&a(t.frustum,E))if(r.radius>m&&r.getChildren())for(const a of r.getChildren())C(e,t,a,n,i);else N.unionDepthRangeWithAABB(e,t.viewProjectionMatrix,n,r.bbMin,r.bbMax)}function v(e,t,r){const n=t.eye,i=t.viewForward,a=(r[0]-n[0])*i[0]+(r[1]-n[1])*i[1]+(r[2]-n[2])*i[2];e.near=Math.min(e.near,a-r[3]),e.far=Math.max(e.far,a+r[3])}class x{constructor(){this._items=new e({allocator:e=>e||{object:null,distance:0,near:0,far:0},deallocator:e=>(e.object=null,e.distance=0,e.near=0,e.far=0,e)})}get length(){return this._items.length}get empty(){return 0===this._items.length}clear(){this._items.clear()}add(e){this._items.pushNew().object=e}sort(e){const t=e.eye,r=e.viewForward;this._items.forAll(e=>{const n=e.object.boundingVolumeWorldSpace.bounds,i=(n[0]-t[0])*r[0]+(n[1]-t[1])*r[1]+(n[2]-t[2])*r[2];e.distance=i,e.near=i-n[3],e.far=i+n[3]}),this._items.sort((e,t)=>e.distance-t.distance)}forEachInDepthRange(e,t,r){if(1===t)for(let n=0;n<this._items.length;++n){const t=this._items.data[n];t.far<e.near||t.near>e.far||r(t.object,t.near,t.far)}else for(let n=this._items.length-1;n>=0;--n){const t=this._items.data[n];t.far<e.near||t.near>e.far||r(t.object,t.near,t.far)}}}class B{constructor(){this._geometries=new Array,this._near=[],this._far=[],this._nearCandidates=[],this._farCandidates=[],this._looseRange=new l(0,0)}compute(e,t,r){this._reset();const{viewMatrix:n}=e;t.forEach(e=>{e.forEachGeometry(e=>{if(!e.visible||0===r&&!e.castShadow)return;const t=e.boundingSphere,i=n[2]*t[0]+n[6]*t[1]+n[10]*t[2]+n[14],a=i-t[3],s=i+t[3];this._geometries.push(e),this._near.push(-s),this._far.push(-a)})});const i=new l;if(0===this._geometries.length)return i;for(let h=0;h<this._geometries.length;++h)this._near[h]>i.far&&(i.far=this._near[h]),this._near[h]>2&&this._far[h]<i.near&&(i.near=this._far[h]);const a=this._looseRange;a.near=Math.max(.5*i.near,2),a.far=2*i.far;let s=0,o=0;for(let h=0;h<this._geometries.length;++h)this._near[h]<i.near&&(this._near[h]>=a.near?i.near=this._near[h]:this._nearCandidates[s++]=h),this._far[h]>i.far&&(this._far[h]<=a.far?i.far=this._far[h]:this._farCandidates[o++]=h);if(0===this._nearCandidates.length&&0===this._farCandidates.length)return i;this._nearCandidates.sort((e,t)=>this._near[e]<this._near[t]?-1:this._near[e]>this._near[t]?1:0),this._farCandidates.sort((e,t)=>this._far[e]<this._far[t]?1:this._far[e]>this._far[t]?-1:0);for(let h=0;h<this._nearCandidates.length;++h){const t=this._nearCandidates[h];if(this._near[t]<i.near){const r=this._geometries[t],{boundingInfo:n,shaderTransformation:a}=r;this._includeNearBoundingInfoRec(e,n,a,i)}}for(let h=0;h<this._farCandidates.length;++h){const t=this._farCandidates[h];if(this._far[t]>i.far){const r=this._geometries[t],{boundingInfo:n,shaderTransformation:a}=r;this._includeFarBoundingInfoRec(e,n,a,i)}}return this._reset(),i}_reset(){this._geometries.length=0,this._near.length=0,this._far.length=0,this._nearCandidates.length=0,this._farCandidates.length=0}_isOutsideSidePlanes(e,t){const r=o(e),n=h(e);return t[0][0]*r[0]+t[0][1]*r[1]+t[0][2]*r[2]+t[0][3]>n||t[1][0]*r[0]+t[1][1]*r[1]+t[1][2]*r[2]+t[1][3]>n||t[2][0]*r[0]+t[2][1]*r[1]+t[2][2]*r[2]+t[2][3]>n||t[3][0]*r[0]+t[3][1]*r[1]+t[3][2]*r[2]+t[3][3]>n}_includeNearBoundingInfoRec(e,t,r,n){if(null==t)return;const i=t.center;f(E,i,r),E[3]=t.radius*c(r);const{frustum:a}=e;if(this._isOutsideSidePlanes(E,a))return;const s=E[0],o=E[1],h=E[2],l=E[3],{viewMatrix:u}=e,d=u[2]*s+u[6]*o+u[10]*h+u[14],_=d+l;if(!(-(d-l)<2||-_>=n.near))if(-_>this._looseRange.near)n.near=-_;else{if(l>m){const i=t.getChildren();if(void 0!==i){for(const t of i)this._includeNearBoundingInfoRec(e,t,r,n);return}}N.unionDepthRangeWithAABB(n,e.viewProjectionMatrix,r,t.bbMin,t.bbMax)}}_includeFarBoundingInfoRec(e,t,r,n){if(null==t)return;const i=t.center;f(E,i,r),E[3]=t.radius*c(r);const{frustum:a}=e;if(this._isOutsideSidePlanes(E,a))return;const[s,o,h,l]=E,{viewMatrix:u}=e,d=u[2]*s+u[6]*o+u[10]*h+u[14]-l;if(!(-d<=n.far))if(-d<this._looseRange.far)n.far=-d;else{if(l>m){const i=t.getChildren();if(void 0!==i){for(const t of i)this._includeFarBoundingInfoRec(e,t,r,n);return}}N.unionDepthRangeWithAABB(n,e.viewProjectionMatrix,r,t.bbMin,t.bbMax)}}}class I{constructor(){this._modelViewProj=r(),this._clipPosition=[i(),i(),i(),i(),i(),i(),i(),i()]}unionDepthRangeWithAABB(e,r,n,i,a){const s=this._modelViewProj;t(s,r,n);let o=!1;for(let t=0;t<8;++t){const e=this._clipPosition[t],r=0===t||3===t||4===t||7===t?i[0]:a[0],n=0===t||1===t||4===t||5===t?i[1]:a[1],o=t<4?i[2]:a[2];e[0]=s[0]*r+s[4]*n+s[8]*o+s[12],e[1]=s[1]*r+s[5]*n+s[9]*o+s[13],e[2]=s[2]*r+s[6]*n+s[10]*o+s[14],e[3]=s[3]*r+s[7]*n+s[11]*o+s[15]}for(let t=0;t<12;++t){const r=P(this._clipPosition[D[t][0]],this._clipPosition[D[t][1]],this._clipPosition[D[t][2]]);let n=!0;for(let e=0;e<r.length;++e){if(r[e][3]>=2){n=!1;break}}if(!n){o=!0;for(let t=0;t<r.length;++t){const n=r[t][3];Number.isFinite(n)&&(e.near=Math.min(n,e.near),e.far=Math.max(n,e.far))}}}return o}}function P(e,t,r){let n=[e,t,r];for(let i=0;i<4;++i){const e=n;n=[];for(let t=0;t<e.length;++t){const r=e[t],a=e[(t+1)%e.length];A(a,i)?(A(r,i)||n.push(y(r,a,i)),n.push(a)):A(r,i)&&n.push(y(r,a,i))}}return n}function A(e,t){return 0===t?e[0]>=-e[3]:1===t?e[1]>=-e[3]:2===t?e[0]<=e[3]:3===t?e[1]<=e[3]:void u(!1)}function y(e,t,r){let a=0;return 0===r?a=(-e[3]-e[0])/(t[0]-e[0]+t[3]-e[3]):1===r?a=(-e[3]-e[1])/(t[1]-e[1]+t[3]-e[3]):2===r?a=(e[3]-e[0])/(t[0]-e[0]-t[3]+e[3]):3===r&&(a=(e[3]-e[1])/(t[1]-e[1]-t[3]+e[3])),n(i(),e,t,a)}const D=[[0,1,3],[2,3,1],[1,5,2],[6,2,5],[5,4,6],[7,6,4],[4,0,7],[3,7,0],[3,2,7],[6,7,2],[4,5,0],[1,0,5]],E=s(),S=r(),F=new l,W=new x,V=new B,N=new I;export{B as DepthRangeFromRenderGeometries,b as depthRangeFromScene};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{create as t}from"../../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{t as e}from"../../../../../chunks/vec32.js";import{w as s,c as i,a as r}from"../../../../../chunks/sphere.js";import{maxScale as a}from"../../../support/mathUtils.js";import{Octree as h}from"../Octree.js";class n extends h{constructor(e,r){super(t=>s(this._instanceData.view.boundingSphere.getVec(t,this._tmpSphere)),{maximumDepth:25}),this._instanceData=e,this._boundingSphere=r,this._tmpSphere=i(),this._tmpMat4=t()}addInstance(t){const s=this._instanceData.view.boundingSphere,i=this._instanceData.getCombinedModelTransform(t,this._tmpMat4);e(r(this._tmpSphere),this._boundingSphere.center,i),this._tmpSphere[3]=this._boundingSphere.radius*a(i),s.setVec(t,this._tmpSphere),this.add([t])}removeInstance(t){this.remove([t])}}export{n as InstanceOctree};
5
+ import{create as t}from"../../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{create as e}from"../../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{z as s,c as i,l as r,x as a}from"../../../../../chunks/sphere.js";import{maxScale as n}from"../../../support/mathUtils.js";import{Octree as o}from"../Octree.js";class h extends o{constructor(e,r){super(t=>s(this._instanceData.view.boundingSphere.getVec(t,m)),{maximumDepth:25}),this._instanceData=e,this._boundingSphere=r,this._tmpSphere=i(),this._tmpMat4=t()}addInstance(t){const e=this._instanceData.view.boundingSphere,s=this._instanceData.getCombinedModelTransform(t,this._tmpMat4);r(this._tmpSphere,this._boundingSphere.center,s),this._tmpSphere[3]=this._boundingSphere.radius*n(s),e.setVec(t,a(this._tmpSphere)),this.add([t])}removeInstance(t){this.remove([t])}}const m=e();export{h as InstanceOctree};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{lerp as e,deg2rad as t,clamp as a}from"../../../../core/mathUtils.js";import{d as r}from"../../../../chunks/boundedPlane.js";import{b as n,c as i,d as c}from"../../../../chunks/sphere.js";function l(e,t){return new v(e,F,t)}function s(e,t){const{curvatureDependent:a,scaleStart:r,scaleFallOffRange:n}=F;return new v(e,{curvatureDependent:{min:{curvature:a.min.curvature,tiltAngle:a.min.tiltAngle,scaleFallOffFactor:g.curvatureDependent.min.scaleFallOffFactor},max:{curvature:a.max.curvature,tiltAngle:a.max.tiltAngle,scaleFallOffFactor:g.curvatureDependent.max.scaleFallOffFactor}},scaleStart:r,scaleFallOffRange:n,minPixelSize:g.minPixelSize},t)}function o(e){return Math.abs(e*e*e)}function u(e,t,a){const r=a.parameters;return O.scale=Math.min(r.divisor/(t-r.offset),1),O.factor=o(e),O}function f(t,a){return e(t*Math.max(a.scale,a.minScaleFactor),t,a.factor)}function m(e,t,a){const r=u(e,t,a);return r.minScaleFactor=0,f(1,r)}function h(e,t,a,r){r.scale=m(e,t,a),r.factor=0,r.minScaleFactor=a.minScaleFactor}function d(e,t,a=[0,0]){const r=Math.min(Math.max(t.scale,t.minScaleFactor),1);return a[0]=e[0]*r,a[1]=e[1]*r,a}function p(e,t,a,r){return f(e,u(t,a,r))}class v{get minScaleFactor(){return null!=this._fontHeight?Math.min(this._description.minPixelSize/this._fontHeight,1):0}constructor(e,t,a,r=_(),n){this._viewingMode=e,this._description=t,this._ellipsoidRadius=a,this.parameters=r,this._fontHeight=n,2===this._viewingMode?(this._coverageCompensation=this._surfaceCoverageCompensationLocal,this._calculateCurvatureDependentParameters=this._calculateCurvatureDependentParametersLocal):(this._coverageCompensation=this._surfaceCoverageCompensationGlobal,this._calculateCurvatureDependentParameters=this._calculateCurvatureDependentParametersGlobal)}update(e){return(!this.parameters||this.parameters.camera.fovY!==e.fovY||this.parameters.camera.distance!==e.distance)&&(this._calculateParameters(e,this._ellipsoidRadius,this.parameters),!0)}overrideFontHeight(e){return e!==this._fontHeight?new v(this._viewingMode,this._description,this._ellipsoidRadius,this.parameters,e):this}_calculateParameters(e,t,a){const{scaleStart:r,scaleFallOffRange:n}=this._description,{fovY:i,distance:c}=e,l=this._calculateCurvatureDependentParameters(e,t),s=this._coverageCompensation(e,t,l),{tiltAngle:o,scaleFallOffFactor:u}=l,f=Math.sin(o)*c,m=.5*Math.PI-o-i*(.5-r*s),h=f/Math.cos(m),d=m+i*n*s,p=(h-u*(f/Math.cos(d)))/(1-u);return a.camera.fovY=e.fovY,a.camera.distance=e.distance,a.offset=p,a.divisor=h-p,a}_calculateCurvatureDependentParametersLocal(e,t,a=C){return a.tiltAngle=this._description.curvatureDependent.min.tiltAngle,a.scaleFallOffFactor=this._description.curvatureDependent.min.scaleFallOffFactor,a}_calculateCurvatureDependentParametersGlobal(t,r,n=C){const i=this._description.curvatureDependent,c=1+t.distance/r,l=Math.sqrt(c*c-1),[s,o]=[i.min.curvature,i.max.curvature],u=a((l-s)/(o-s),0,1),[f,m]=[i.min,i.max];return n.tiltAngle=e(f.tiltAngle,m.tiltAngle,u),n.scaleFallOffFactor=e(f.scaleFallOffFactor,m.scaleFallOffFactor,u),n}_surfaceCoverageCompensationLocal(e,t,a){return r(a.tiltAngle,e.fovY)}_surfaceCoverageCompensationGlobal(e,t,a){return n(x,t),c(x,a.tiltAngle,e.distance,e.fovY)}}const F={curvatureDependent:{min:{curvature:t(10),tiltAngle:t(12),scaleFallOffFactor:.5},max:{curvature:t(70),tiltAngle:t(40),scaleFallOffFactor:.8}},scaleStart:.3,scaleFallOffRange:.65,minPixelSize:0},g={curvatureDependent:{min:{scaleFallOffFactor:.7},max:{scaleFallOffFactor:.95}},minPixelSize:14};function _(){return{camera:{distance:0,fovY:0},divisor:0,offset:0}}const O={scale:0,factor:0,minScaleFactor:0},C={tiltAngle:0,scaleFallOffFactor:0},x=i();export{d as applyPrecomputedScaleFactor,f as applyScaleFactor,s as getLabelSettings,l as getSettings,h as precomputeScaleFactor,p as scale};
5
+ import{lerp as e,deg2rad as t,clamp as a}from"../../../../core/mathUtils.js";import{d as r}from"../../../../chunks/boundedPlane.js";import{c as n,b as i,d as c}from"../../../../chunks/sphere.js";function l(e,t){return new v(e,F,t)}function s(e,t){const{curvatureDependent:a,scaleStart:r,scaleFallOffRange:n}=F;return new v(e,{curvatureDependent:{min:{curvature:a.min.curvature,tiltAngle:a.min.tiltAngle,scaleFallOffFactor:g.curvatureDependent.min.scaleFallOffFactor},max:{curvature:a.max.curvature,tiltAngle:a.max.tiltAngle,scaleFallOffFactor:g.curvatureDependent.max.scaleFallOffFactor}},scaleStart:r,scaleFallOffRange:n,minPixelSize:g.minPixelSize},t)}function o(e){return Math.abs(e*e*e)}function u(e,t,a){const r=a.parameters;return O.scale=Math.min(r.divisor/(t-r.offset),1),O.factor=o(e),O}function f(t,a){return e(t*Math.max(a.scale,a.minScaleFactor),t,a.factor)}function m(e,t,a){const r=u(e,t,a);return r.minScaleFactor=0,f(1,r)}function h(e,t,a,r){r.scale=m(e,t,a),r.factor=0,r.minScaleFactor=a.minScaleFactor}function d(e,t,a=[0,0]){const r=Math.min(Math.max(t.scale,t.minScaleFactor),1);return a[0]=e[0]*r,a[1]=e[1]*r,a}function p(e,t,a,r){return f(e,u(t,a,r))}class v{get minScaleFactor(){return null!=this._fontHeight?Math.min(this._description.minPixelSize/this._fontHeight,1):0}constructor(e,t,a,r=_(),n){this._viewingMode=e,this._description=t,this._ellipsoidRadius=a,this.parameters=r,this._fontHeight=n,2===this._viewingMode?(this._coverageCompensation=this._surfaceCoverageCompensationLocal,this._calculateCurvatureDependentParameters=this._calculateCurvatureDependentParametersLocal):(this._coverageCompensation=this._surfaceCoverageCompensationGlobal,this._calculateCurvatureDependentParameters=this._calculateCurvatureDependentParametersGlobal)}update(e){return(!this.parameters||this.parameters.camera.fovY!==e.fovY||this.parameters.camera.distance!==e.distance)&&(this._calculateParameters(e,this._ellipsoidRadius,this.parameters),!0)}overrideFontHeight(e){return e!==this._fontHeight?new v(this._viewingMode,this._description,this._ellipsoidRadius,this.parameters,e):this}_calculateParameters(e,t,a){const{scaleStart:r,scaleFallOffRange:n}=this._description,{fovY:i,distance:c}=e,l=this._calculateCurvatureDependentParameters(e,t),s=this._coverageCompensation(e,t,l),{tiltAngle:o,scaleFallOffFactor:u}=l,f=Math.sin(o)*c,m=.5*Math.PI-o-i*(.5-r*s),h=f/Math.cos(m),d=m+i*n*s,p=(h-u*(f/Math.cos(d)))/(1-u);return a.camera.fovY=e.fovY,a.camera.distance=e.distance,a.offset=p,a.divisor=h-p,a}_calculateCurvatureDependentParametersLocal(e,t,a=C){return a.tiltAngle=this._description.curvatureDependent.min.tiltAngle,a.scaleFallOffFactor=this._description.curvatureDependent.min.scaleFallOffFactor,a}_calculateCurvatureDependentParametersGlobal(t,r,n=C){const i=this._description.curvatureDependent,c=1+t.distance/r,l=Math.sqrt(c*c-1),[s,o]=[i.min.curvature,i.max.curvature],u=a((l-s)/(o-s),0,1),[f,m]=[i.min,i.max];return n.tiltAngle=e(f.tiltAngle,m.tiltAngle,u),n.scaleFallOffFactor=e(f.scaleFallOffFactor,m.scaleFallOffFactor,u),n}_surfaceCoverageCompensationLocal(e,t,a){return r(a.tiltAngle,e.fovY)}_surfaceCoverageCompensationGlobal(e,t,a){return i(x,t),c(x,a.tiltAngle,e.distance,e.fovY)}}const F={curvatureDependent:{min:{curvature:t(10),tiltAngle:t(12),scaleFallOffFactor:.5},max:{curvature:t(70),tiltAngle:t(40),scaleFallOffFactor:.8}},scaleStart:.3,scaleFallOffRange:.65,minPixelSize:0},g={curvatureDependent:{min:{scaleFallOffFactor:.7},max:{scaleFallOffFactor:.95}},minPixelSize:14};function _(){return{camera:{distance:0,fovY:0},divisor:0,offset:0}}const O={scale:0,factor:0,minScaleFactor:0},C={tiltAngle:0,scaleFallOffFactor:0},x=n();export{d as applyPrecomputedScaleFactor,f as applyScaleFactor,s as getLabelSettings,l as getSettings,h as precomputeScaleFactor,p as scale};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{normalFromMat4Legacy as t}from"../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as s}from"../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{invert as r,transpose as e,copy as i,multiply as a}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as o}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{i as n,t as h,l as f,b as l,f as m}from"../../../../chunks/vec32.js";import{create as p}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{c,a as _}from"../../../../chunks/sphere.js";import{Obb as u,computeOffsetObb as g}from"../../support/orientedBoundingBox.js";class M{constructor(){this._transform=o(),this._transformInverse=new v({value:this._transform},r,o),this._transformInverseTranspose=new v(this._transformInverse,e,o),this._transformTranspose=new v({value:this._transform},e,o),this._transformInverseRotation=new v({value:this._transform},t,s)}_invalidateLazyTransforms(){this._transformInverse.invalidate(),this._transformInverseTranspose.invalidate(),this._transformTranspose.invalidate(),this._transformInverseRotation.invalidate()}get transform(){return this._transform}get inverse(){return this._transformInverse.value}get inverseTranspose(){return this._transformInverseTranspose.value}get inverseRotation(){return this._transformInverseRotation.value}get transpose(){return this._transformTranspose.value}setTransformMatrix(t){i(this._transform,t)}multiplyTransform(t){a(this._transform,this._transform,t)}set(t){i(this._transform,t),this._invalidateLazyTransforms()}setAndInvalidateLazyTransforms(t,s){this.setTransformMatrix(t),this.multiplyTransform(s),this._invalidateLazyTransforms()}}class v{constructor(t,s,r){this._original=t,this._update=s,this._dirty=!0,this._transform=r()}invalidate(){this._dirty=!0}get value(){return this._dirty&&(this._update(this._transform,this._original.value),this._dirty=!1),this._transform}}class b{constructor(t=0){this.offset=t,this.tmpVertex=p()}applyToVertex(t,s,r){const e=n(w,t,s,r),i=m(q,e,this.localOrigin),a=this.offset/f(i);return l(this.tmpVertex,e,i,a),this.tmpVertex}applyToAabb(t){const s=z,r=A,e=R;for(let n=0;n<3;++n)s[n]=t[0+n]+this.localOrigin[n],r[n]=t[3+n]+this.localOrigin[n],e[n]=s[n];const i=this.applyToVertex(s[0],s[1],s[2]);for(let n=0;n<3;++n)t[n]=i[n],t[n+3]=i[n];const a=s=>{const r=this.applyToVertex(s[0],s[1],s[2]);for(let e=0;e<3;++e)t[e]=Math.min(t[e],r[e]),t[e+3]=Math.max(t[e+3],r[e])};for(let n=1;n<8;++n){for(let t=0;t<3;++t)e[t]=n&1<<t?r[t]:s[t];a(e)}let o=0;for(let n=0;n<3;++n){s[n]*r[n]<0&&(o|=1<<n)}if(0!==o&&7!==o)for(let n=0;n<8;++n)if(0===(o&n)){for(let t=0;t<3;++t)e[t]=o&1<<t?0:n&1<<t?s[t]:r[t];a(e)}for(let n=0;n<3;++n)t[n]-=this.localOrigin[n],t[n+3]-=this.localOrigin[n];return t}}class T{constructor(t=0){this.componentLocalOriginLength=0,this._totalOffset=0,this._offset=0,this._tmpVertex=p(),this._tmpMbs=c(),this._tmpObb=new u,this._resetOffset(t)}_resetOffset(t){this._offset=t,this._totalOffset=t}set offset(t){this._resetOffset(t)}get offset(){return this._offset}set componentOffset(t){this._totalOffset=this._offset+t}set localOrigin(t){this.componentLocalOriginLength=f(t)}applyToVertex(t,s,r){const e=n(w,t,s,r),i=n(q,t,s,r+this.componentLocalOriginLength),a=this._totalOffset/f(i);return l(this._tmpVertex,e,i,a),this._tmpVertex}applyToAabb(t){const s=this.componentLocalOriginLength,r=t[0],e=t[1],i=t[2]+s,a=t[3],o=t[4],n=t[5]+s,h=Math.abs(r),f=Math.abs(e),l=Math.abs(i),m=Math.abs(a),p=Math.abs(o),c=Math.abs(n),_=.5*(1+Math.sign(r*a))*Math.min(h,m),u=.5*(1+Math.sign(e*o))*Math.min(f,p),g=.5*(1+Math.sign(i*n))*Math.min(l,c),M=Math.max(h,m),v=Math.max(f,p),b=Math.max(l,c),T=Math.sqrt(_*_+u*u+g*g),x=Math.sign(h+r),O=Math.sign(f+e),y=Math.sign(l+i),d=Math.sign(m+a),V=Math.sign(p+o),L=Math.sign(c+n),I=this._totalOffset;if(T<I)return t[0]-=(1-x)*I,t[1]-=(1-O)*I,t[2]-=(1-y)*I,t[3]+=d*I,t[4]+=V*I,t[5]+=L*I,t;const j=I/Math.sqrt(M*M+v*v+b*b),w=I/T,q=w-j,z=-q;return t[0]+=r*(x*z+w),t[1]+=e*(O*z+w),t[2]+=i*(y*z+w),t[3]+=a*(d*q+j),t[4]+=o*(V*q+j),t[5]+=n*(L*q+j),t}applyToMbs(t){const s=f(_(t)),r=this._totalOffset/s;return l(_(this._tmpMbs),_(t),_(t),r),this._tmpMbs[3]=t[3]+t[3]*this._totalOffset/s,this._tmpMbs}applyToObb(t){return g(t,this._totalOffset,this._totalOffset,1,this._tmpObb),this._tmpObb}}class x{constructor(t=0){this.offset=t,this.sphere=c(),this.tmpVertex=p()}applyToVertex(t,s,r){const e=this.objectTransform.transform,i=n(w,t,s,r),a=h(i,i,e),o=this.offset/f(a);l(a,a,a,o);const m=this.objectTransform.inverse;return h(this.tmpVertex,a,m),this.tmpVertex}applyToMinMax(t,s){const r=this.offset/f(t);l(t,t,t,r);const e=this.offset/f(s);l(s,s,s,e)}applyToAabb(t){const s=this.offset/Math.sqrt(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]);t[0]+=t[0]*s,t[1]+=t[1]*s,t[2]+=t[2]*s;const r=this.offset/Math.sqrt(t[3]*t[3]+t[4]*t[4]+t[5]*t[5]);return t[3]+=t[3]*r,t[4]+=t[4]*r,t[5]+=t[5]*r,t}applyToBoundingSphere(t){const s=f(_(t)),r=this.offset/s;return l(_(this.sphere),_(t),_(t),r),this.sphere[3]=t[3]+t[3]*this.offset/s,this.sphere}}const O=new x;function y(t){return null!=t?(O.offset=t,O):null}const d=new T;function V(t){return null!=t?(d.offset=t,d):null}const L=new b;function I(t){return null!=t?(L.offset=t,L):null}const j="terrain",w=p(),q=p(),z=p(),A=p(),R=p();export{T as I3SVerticalOffsetGlobalViewingMode,M as IntersectorTransform,x as Object3DVerticalOffsetGlobalViewingMode,b as TerrainVerticalOffsetGlobalViewingMode,V as getVerticalOffsetI3S,y as getVerticalOffsetObject3D,I as getVerticalOffsetTerrain,j as terrainId};
5
+ import{normalFromMat4Legacy as t}from"../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as s}from"../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{invert as r,transpose as e,copy as i,multiply as a}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as o}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{i as n,t as h,l as f,b as l,f as m}from"../../../../chunks/vec32.js";import{create as p}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{c,a as _,e as u}from"../../../../chunks/sphere.js";import{Obb as g,computeOffsetObb as M}from"../../support/orientedBoundingBox.js";class v{constructor(){this._transform=o(),this._transformInverse=new b({value:this._transform},r,o),this._transformInverseTranspose=new b(this._transformInverse,e,o),this._transformTranspose=new b({value:this._transform},e,o),this._transformInverseRotation=new b({value:this._transform},t,s)}_invalidateLazyTransforms(){this._transformInverse.invalidate(),this._transformInverseTranspose.invalidate(),this._transformTranspose.invalidate(),this._transformInverseRotation.invalidate()}get transform(){return this._transform}get inverse(){return this._transformInverse.value}get inverseTranspose(){return this._transformInverseTranspose.value}get inverseRotation(){return this._transformInverseRotation.value}get transpose(){return this._transformTranspose.value}setTransformMatrix(t){i(this._transform,t)}multiplyTransform(t){a(this._transform,this._transform,t)}set(t){i(this._transform,t),this._invalidateLazyTransforms()}setAndInvalidateLazyTransforms(t,s){this.setTransformMatrix(t),this.multiplyTransform(s),this._invalidateLazyTransforms()}}class b{constructor(t,s,r){this._original=t,this._update=s,this._dirty=!0,this._transform=r()}invalidate(){this._dirty=!0}get value(){return this._dirty&&(this._update(this._transform,this._original.value),this._dirty=!1),this._transform}}class T{constructor(t=0){this.offset=t,this.tmpVertex=p()}applyToVertex(t,s,r){const e=n(q,t,s,r),i=m(z,e,this.localOrigin),a=this.offset/f(i);return l(this.tmpVertex,e,i,a),this.tmpVertex}applyToAabb(t){const s=A,r=R,e=B;for(let n=0;n<3;++n)s[n]=t[0+n]+this.localOrigin[n],r[n]=t[3+n]+this.localOrigin[n],e[n]=s[n];const i=this.applyToVertex(s[0],s[1],s[2]);for(let n=0;n<3;++n)t[n]=i[n],t[n+3]=i[n];const a=s=>{const r=this.applyToVertex(s[0],s[1],s[2]);for(let e=0;e<3;++e)t[e]=Math.min(t[e],r[e]),t[e+3]=Math.max(t[e+3],r[e])};for(let n=1;n<8;++n){for(let t=0;t<3;++t)e[t]=n&1<<t?r[t]:s[t];a(e)}let o=0;for(let n=0;n<3;++n){s[n]*r[n]<0&&(o|=1<<n)}if(0!==o&&7!==o)for(let n=0;n<8;++n)if(0===(o&n)){for(let t=0;t<3;++t)e[t]=o&1<<t?0:n&1<<t?s[t]:r[t];a(e)}for(let n=0;n<3;++n)t[n]-=this.localOrigin[n],t[n+3]-=this.localOrigin[n];return t}}class x{constructor(t=0){this.componentLocalOriginLength=0,this._totalOffset=0,this._offset=0,this._tmpVertex=p(),this._tmpMbs=c(),this._tmpObb=new g,this._resetOffset(t)}_resetOffset(t){this._offset=t,this._totalOffset=t}set offset(t){this._resetOffset(t)}get offset(){return this._offset}set componentOffset(t){this._totalOffset=this._offset+t}set localOrigin(t){this.componentLocalOriginLength=f(t)}applyToVertex(t,s,r){const e=n(q,t,s,r),i=n(z,t,s,r+this.componentLocalOriginLength),a=this._totalOffset/f(i);return l(this._tmpVertex,e,i,a),this._tmpVertex}applyToAabb(t){const s=this.componentLocalOriginLength,r=t[0],e=t[1],i=t[2]+s,a=t[3],o=t[4],n=t[5]+s,h=Math.abs(r),f=Math.abs(e),l=Math.abs(i),m=Math.abs(a),p=Math.abs(o),c=Math.abs(n),_=.5*(1+Math.sign(r*a))*Math.min(h,m),u=.5*(1+Math.sign(e*o))*Math.min(f,p),g=.5*(1+Math.sign(i*n))*Math.min(l,c),M=Math.max(h,m),v=Math.max(f,p),b=Math.max(l,c),T=Math.sqrt(_*_+u*u+g*g),x=Math.sign(h+r),O=Math.sign(f+e),y=Math.sign(l+i),d=Math.sign(m+a),V=Math.sign(p+o),L=Math.sign(c+n),I=this._totalOffset;if(T<I)return t[0]-=(1-x)*I,t[1]-=(1-O)*I,t[2]-=(1-y)*I,t[3]+=d*I,t[4]+=V*I,t[5]+=L*I,t;const j=I/Math.sqrt(M*M+v*v+b*b),w=I/T,q=w-j,z=-q;return t[0]+=r*(x*z+w),t[1]+=e*(O*z+w),t[2]+=i*(y*z+w),t[3]+=a*(d*q+j),t[4]+=o*(V*q+j),t[5]+=n*(L*q+j),t}applyToMbs(t){const s=_(t),r=f(s),e=this._totalOffset/r,i=l(k,s,s,e),a=t[3]+t[3]*this._totalOffset/r;return u(this._tmpMbs,i,a),this._tmpMbs}applyToObb(t){return M(t,this._totalOffset,this._totalOffset,1,this._tmpObb),this._tmpObb}}class O{constructor(t=0){this.offset=t,this.sphere=c(),this.tmpVertex=p()}applyToVertex(t,s,r){const e=this.objectTransform.transform,i=n(q,t,s,r),a=h(i,i,e),o=this.offset/f(a);l(a,a,a,o);const m=this.objectTransform.inverse;return h(this.tmpVertex,a,m),this.tmpVertex}applyToMinMax(t,s){const r=this.offset/f(t);l(t,t,t,r);const e=this.offset/f(s);l(s,s,s,e)}applyToAabb(t){const s=this.offset/Math.sqrt(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]);t[0]+=t[0]*s,t[1]+=t[1]*s,t[2]+=t[2]*s;const r=this.offset/Math.sqrt(t[3]*t[3]+t[4]*t[4]+t[5]*t[5]);return t[3]+=t[3]*r,t[4]+=t[4]*r,t[5]+=t[5]*r,t}applyToBoundingSphere(t){const s=_(t),r=f(s),e=this.offset/r,i=l(k,s,s,e),a=t[3]+t[3]*this.offset/r;return u(this.sphere,i,a),this.sphere}}const y=new O;function d(t){return null!=t?(y.offset=t,y):null}const V=new x;function L(t){return null!=t?(V.offset=t,V):null}const I=new T;function j(t){return null!=t?(I.offset=t,I):null}const w="terrain",q=p(),z=p(),A=p(),R=p(),B=p(),k=p();export{x as I3SVerticalOffsetGlobalViewingMode,v as IntersectorTransform,O as Object3DVerticalOffsetGlobalViewingMode,T as TerrainVerticalOffsetGlobalViewingMode,L as getVerticalOffsetI3S,d as getVerticalOffsetObject3D,j as getVerticalOffsetTerrain,w as terrainId};