@arcgis/core 5.0.0-next.60 → 5.0.0-next.61

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 (192) hide show
  1. package/analysis/VolumeMeasurement/volumeMeasurementConfiguration.js +1 -1
  2. package/assets/esri/core/workers/RemoteClient.js +1 -1
  3. package/assets/esri/core/workers/chunks/{1e8ceed33a3657ac02b3.js → 153ff2ceefccd946498b.js} +1 -1
  4. package/assets/esri/core/workers/chunks/{7147fc7502b385b302b2.js → 23b623637126f8411a30.js} +1 -1
  5. package/assets/esri/core/workers/chunks/{a7aa87e2c4197ba595ef.js → 2abc205f81f26fc4852b.js} +2 -2
  6. package/assets/esri/core/workers/chunks/{492d575894c7905bb70c.js → 3d49c6427120edc8eac9.js} +1 -1
  7. package/assets/esri/core/workers/chunks/{23a9dd9454d5249bbd59.js → 3da53c017f9c5d2d778a.js} +1 -1
  8. package/assets/esri/core/workers/chunks/{60362c5651ef41fa7e5f.js → 4cf2bec636dd8ceecf0c.js} +1 -1
  9. package/assets/esri/core/workers/chunks/{3d1a5a3467f3a6585b3e.js → 4f03d19a70dca6c507be.js} +1 -1
  10. package/assets/esri/core/workers/chunks/{5d31fbabaa875f8627c0.js → 631a11a2b2001c708527.js} +1 -1
  11. package/assets/esri/core/workers/chunks/{fa95c9248fbfab338f2e.js → 63b8cd7d5cafbaeed894.js} +1 -1
  12. package/assets/esri/core/workers/chunks/6b4a24248182245167ca.js +1 -0
  13. package/assets/esri/core/workers/chunks/{352c674730c7b7258ae3.js → 76086517591d0eb35156.js} +1 -1
  14. package/assets/esri/core/workers/chunks/{436f206898306df019ac.js → 7c47fefbf4c93b63200f.js} +1 -1
  15. package/assets/esri/core/workers/chunks/7e8573749a02e1f54fb1.js +1 -0
  16. package/assets/esri/core/workers/chunks/{424daef7b5dec1b99aba.js → af3e93a4ac3ff2addc90.js} +1 -1
  17. package/assets/esri/core/workers/chunks/{bf82bb1cdd8b31e7f2aa.js → bb08359610a41e304b55.js} +1 -1
  18. package/assets/esri/core/workers/chunks/{495b11fdecc3ba90d454.js → bfc063d4431bfa162160.js} +1 -1
  19. package/assets/esri/core/workers/chunks/d13b2ce8a89938b0472b.js +1 -0
  20. package/assets/esri/core/workers/chunks/{0483a2cfdb8c7158e73a.js → e85da52d9cc7d9396872.js} +1 -1
  21. package/assets/esri/core/workers/chunks/{1ced78750c61600b2d4e.js → f351007cdcd0938d3b6c.js} +1 -1
  22. package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_ar.json +1 -1
  23. package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_bg.json +1 -1
  24. package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_bs.json +1 -1
  25. package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_ca.json +1 -1
  26. package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_cs.json +1 -1
  27. package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_da.json +1 -1
  28. package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_de.json +1 -1
  29. package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_el.json +1 -1
  30. package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_es.json +1 -1
  31. package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_et.json +1 -1
  32. package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_fi.json +1 -1
  33. package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_fr.json +1 -1
  34. package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_he.json +1 -1
  35. package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_hr.json +1 -1
  36. package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_hu.json +1 -1
  37. package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_id.json +1 -1
  38. package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_it.json +1 -1
  39. package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_ja.json +1 -1
  40. package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_ko.json +1 -1
  41. package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_lt.json +1 -1
  42. package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_lv.json +1 -1
  43. package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_nl.json +1 -1
  44. package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_no.json +1 -1
  45. package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_pl.json +1 -1
  46. package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_pt-BR.json +1 -1
  47. package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_pt-PT.json +1 -1
  48. package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_ro.json +1 -1
  49. package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_ru.json +1 -1
  50. package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_sk.json +1 -1
  51. package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_sl.json +1 -1
  52. package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_sr.json +1 -1
  53. package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_sv.json +1 -1
  54. package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_th.json +1 -1
  55. package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_tr.json +1 -1
  56. package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_uk.json +1 -1
  57. package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_vi.json +1 -1
  58. package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_zh-CN.json +1 -1
  59. package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_zh-HK.json +1 -1
  60. package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_zh-TW.json +1 -1
  61. package/chunks/CutFillDepth.glsl.js +13 -10
  62. package/chunks/CutFillReduction.glsl.js +14 -8
  63. package/chunks/GaussianSplat.glsl.js +1 -1
  64. package/chunks/Laserlines.glsl.js +2 -2
  65. package/chunks/boundedPlane.js +1 -1
  66. package/chunks/cameraUtilsSpherical.js +1 -1
  67. package/chunks/vec32.js +1 -1
  68. package/config.js +1 -1
  69. package/core/libs/gl-matrix-2/math/vec3.js +1 -1
  70. package/effects/FocusAreas.d.ts +1 -1
  71. package/geometry/support/lineSegment.js +1 -1
  72. package/geometry/support/meshUtils/merge.js +1 -1
  73. package/geometry/support/sphere.js +1 -1
  74. package/kernel.js +1 -1
  75. package/layers/VoxelWasmPerSceneView.js +1 -1
  76. package/layers/orientedImagery/transformations/worldToImage.js +1 -1
  77. package/layers/support/FieldsIndex.d.ts +2 -1
  78. package/layers/support/tiles3DUtils.js +1 -1
  79. package/layers/voxel/VoxelVolume.js +1 -1
  80. package/package.json +1 -1
  81. package/support/revision.js +1 -1
  82. package/views/2d/engine/flow/dataUtils.js +1 -1
  83. package/views/2d/engine/flow/utils.js +1 -1
  84. package/views/2d/engine/vectorTiles/shaders/sources/shaderRepository.js +1 -1
  85. package/views/2d/engine/webgl/shaders/sources/shaderRepository.js +1 -1
  86. package/views/2d/interactive/SegmentLabels2D.js +1 -1
  87. package/views/3d/analysis/AreaMeasurement/support/AreaMeasurementVisualization.js +1 -1
  88. package/views/3d/analysis/AreaMeasurement/support/MeasurementData.js +1 -1
  89. package/views/3d/analysis/Dimension/lengthDimensionConstraintUtils.js +1 -1
  90. package/views/3d/analysis/Dimension/lengthDimensionUtils.js +1 -1
  91. package/views/3d/analysis/LineOfSight/LineOfSightController.js +1 -1
  92. package/views/3d/analysis/LineOfSight/LineOfSightIntersectionResult.js +1 -1
  93. package/views/3d/analysis/Slice/sliceToolUtils.js +1 -1
  94. package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementCutFillComputation.js +1 -1
  95. package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementCutFillController.js +1 -1
  96. package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementCutFillVisualization.js +1 -1
  97. package/views/3d/analysis/VolumeMeasurementAnalysisView3D.js +1 -1
  98. package/views/3d/animation/pointToPoint/Camera.js +1 -1
  99. package/views/3d/camera/constraintUtils/distance.js +1 -1
  100. package/views/3d/camera/constraintUtils/tilt.js +1 -1
  101. package/views/3d/environment/ChapmanApproximation.glsl.js +1 -1
  102. package/views/3d/environment/CloudsParameters.js +1 -1
  103. package/views/3d/environment/EnvironmentManager.js +1 -1
  104. package/views/3d/environment/MarsAtmosphere.js +1 -1
  105. package/views/3d/interactive/SegmentLabels3D.js +1 -1
  106. package/views/3d/interactive/editingTools/manipulations/MoveZManipulation.js +1 -1
  107. package/views/3d/interactive/editingTools/media/MediaElementManipulator3D.js +1 -1
  108. package/views/3d/interactive/editingTools/reshape/edgeOffsetUtils.js +1 -1
  109. package/views/3d/interactive/visualElements/LabelVisualElement.js +1 -1
  110. package/views/3d/interactive/visualElements/RightAngleQuadVisualElement.js +1 -1
  111. package/views/3d/layers/FlowSubView3D.js +1 -1
  112. package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
  113. package/views/3d/layers/graphics/Graphics3DObjectSymbolLayer.js +1 -1
  114. package/views/3d/layers/graphics/objectResourceUtils.js +1 -1
  115. package/views/3d/layers/i3s/I3SViewportQueries.js +1 -1
  116. package/views/3d/layers/i3s/PointCloudRenderer.js +1 -1
  117. package/views/3d/layers/support/FeatureTileMeasurements3D.js +1 -1
  118. package/views/3d/layers/support/FeatureTileVisibility3D.js +1 -1
  119. package/views/3d/state/Frustum.js +1 -1
  120. package/views/3d/state/controllers/FovController.js +1 -1
  121. package/views/3d/state/controllers/GamepadKeyboardController.js +1 -1
  122. package/views/3d/state/controllers/momentum/ZoomPlanarMomentumController.js +1 -1
  123. package/views/3d/support/FrustumExtentIntersection.js +1 -1
  124. package/views/3d/support/cameraUtils.js +1 -1
  125. package/views/3d/support/engineContent/line.js +1 -1
  126. package/views/3d/support/flow/FlowWorker.js +1 -1
  127. package/views/3d/support/flow/StreamlineResources3D.js +1 -1
  128. package/views/3d/support/flow/constants.js +1 -1
  129. package/views/3d/support/flow/geometryUtils.js +1 -1
  130. package/views/3d/support/gaussianSplatting/GaussianSplatDataStore.js +1 -1
  131. package/views/3d/support/gaussianSplatting/GaussianSplatTextureAtlas.js +1 -1
  132. package/views/3d/support/intersectionUtils.js +1 -1
  133. package/views/3d/support/orientedBoundingBox.js +1 -1
  134. package/views/3d/support/pointsOfInterest/CameraOnSurface.js +1 -1
  135. package/views/3d/support/pointsOfInterest/CenterOnSurface.js +1 -1
  136. package/views/3d/support/pointsOfInterest/Focus.js +1 -1
  137. package/views/3d/support/viewpointUtils.js +1 -1
  138. package/views/3d/terrain/OverlayManager.js +1 -1
  139. package/views/3d/terrain/OverlayRenderer.js +1 -1
  140. package/views/3d/terrain/PatchRenderData.js +1 -1
  141. package/views/3d/terrain/SphericalPatch.js +1 -1
  142. package/views/3d/terrain/Tile.js +1 -1
  143. package/views/3d/webgl/RenderCamera.js +1 -1
  144. package/views/3d/webgl-engine/core/FBOCache.js +1 -1
  145. package/views/3d/webgl-engine/core/FBOCacheFormats.js +1 -1
  146. package/views/3d/webgl-engine/effects/focusArea/FocusAreaMaskNode.js +1 -1
  147. package/views/3d/webgl-engine/effects/geometry/RenderOccludedRenderNode.js +1 -1
  148. package/views/3d/webgl-engine/lib/CutFillDepth.js +1 -1
  149. package/views/3d/webgl-engine/lib/GPUPointOcclusionQuery.js +1 -1
  150. package/views/3d/webgl-engine/lib/GaussianSplatRenderNode.js +1 -1
  151. package/views/3d/webgl-engine/lib/MainFramebuffer.js +1 -1
  152. package/views/3d/webgl-engine/lib/Object3D.js +1 -1
  153. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  154. package/views/3d/webgl-engine/lib/ShadowAccumulator.js +1 -1
  155. package/views/3d/webgl-engine/lib/ShadowMap.js +1 -1
  156. package/views/3d/webgl-engine/lib/Viewshed.js +1 -1
  157. package/views/3d/webgl-engine/lib/ViewshedShadowMap.js +1 -1
  158. package/views/3d/webgl-engine/lib/edgeRendering/edgePreprocessing.js +1 -1
  159. package/views/3d/webgl-engine/lib/geometryDataUtils.js +1 -1
  160. package/views/3d/webgl-engine/lib/triangleIntersectionUtils.js +1 -1
  161. package/views/3d/webgl-engine/materials/HUDMaterial.js +1 -1
  162. package/views/3d/webgl-engine/materials/LineMarkerMaterial.js +1 -1
  163. package/views/3d/webgl-engine/materials/MeasurementArrowMaterial.js +1 -1
  164. package/views/3d/webgl-engine/materials/NativeLineMaterial.js +1 -1
  165. package/views/3d/webgl-engine/materials/RibbonLineMaterial.js +1 -1
  166. package/views/3d/webgl-engine/shaders/AnimatedLine.glsl.js +13 -12
  167. package/views/3d/webgl-engine/shaders/CutFillDepthTechniqueConfiguration.js +5 -0
  168. package/views/3d/webgl-engine/shaders/CutFillReductionTechniqueConfiguration.js +5 -0
  169. package/views/3d/webgl-engine/shaders/RibbonLineTechniqueConfiguration.js +1 -1
  170. package/views/3d/webgl-engine/shaders/SphereDepthInterpolate.glsl.js +1 -1
  171. package/views/interactive/GraphicManipulator.js +1 -1
  172. package/views/interactive/coordinateHelper.js +1 -1
  173. package/views/interactive/editGeometry/operations/OffsetEdgeVertex.js +1 -1
  174. package/views/interactive/sketch/constraints.js +1 -1
  175. package/views/interactive/snapping/featureSources/sceneLayerSource/SceneLayerSnappingSourceWorker.js +1 -1
  176. package/views/interactive/snapping/featureSources/sceneLayerSource/sceneLayerSnappingUtils.js +1 -1
  177. package/views/interactive/snapping/hints/LineSnappingHint.js +1 -1
  178. package/views/interactive/tooltip/tooltipCommonUtils.js +1 -1
  179. package/views/navigation/PanSphericalMomentumEstimator.js +1 -1
  180. package/views/support/Scheduler.js +1 -1
  181. package/views/support/euclideanAreaMeasurementUtils.js +1 -1
  182. package/views/support/euclideanLengthMeasurementUtils.js +1 -1
  183. package/views/support/geometry3dUtils.js +1 -1
  184. package/webdoc/widgets/FloorFilter.js +1 -1
  185. package/widgets/Expand/ExpandViewModel.d.ts +1 -0
  186. package/widgets/Expand/ExpandViewModel.js +1 -1
  187. package/widgets/Expand.js +1 -1
  188. package/widgets/FloorFilter/FloorFilterViewModel.js +1 -1
  189. package/assets/esri/core/workers/chunks/1e17ad6cdffa5016a3db.js +0 -1
  190. package/assets/esri/core/workers/chunks/21ebd234cf32ae52b3ea.js +0 -1
  191. package/assets/esri/core/workers/chunks/262c5794650853457acc.js +0 -1
  192. /package/effects/{FocusAreaStyle.d.ts → types.d.ts} +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/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{lerp as t}from"../../../core/mathUtils.js";import{n as e,h as i,i as s,j as n,u as o,f as r,g as a,H as l,a as h}from"../../../chunks/vec32.js";import{ZEROS as u,create as c}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{lonLatToSphericalPCPF as d}from"../../../geometry/projection/lonLatToSphericalPCPF.js";import{newDoubleArray as p}from"../../../geometry/support/DoubleArray.js";import{intersectsSphere as f,numPlanes as m}from"../../../geometry/support/frustum.js";import{Sphere as g}from"../../../geometry/support/sphere.js";import{createSphericalGlobePatch as x,updateCornerSpherical as $,updateEdgesAndCornersSpherical as v,updateEdgeElevationsAndResolutionsSpherical as M}from"./PatchGeometryFactory.js";import{enableTerrainInternalChecks as _,internalAssert as b,almostEquals as j}from"./terrainUtils.js";import{Tile as y}from"./Tile.js";import{compareTilesByLij as B}from"./tileUtils.js";class S extends y{constructor(t,e,i,s,n){super(),this._convexHull=new Array(24),this._boundingSphere=new g,this._baseUsedMemory=1816,this.init(t,e,i,s,n)}init(i,s,n,o,r){super.init(i,s,n,o,r);const a=this.ellipsoid.radius,l=this.extentInRadians[0],h=this.extentInRadians[1],u=this.extentInRadians[2],c=this.extentInRadians[3],p=t(h,c,.5),f=t(l,u,.5),m=0===i?0:Math.min(Math.abs(h),Math.abs(c));this._edgeLen=(u-l)*Math.cos(m)*a,this._edgeLen2=this._edgeLen*this._edgeLen,this._curvatureHeight=a-Math.sqrt(a*a-this._edgeLen2/4),d(this.centerAtSeaLevel,f,p,this.ellipsoid.radius),e(this.up,this.centerAtSeaLevel),this.updateRadiusAndCenter()}updateRadiusAndCenter(){this._updateBoundingVolumes();const t=this._center;if(0===this.lij[0])t[1].center=u,i(t[0],0,0,0),i(t[2],0,0,0),t[1].radius=this.ellipsoid.radius+this.elevationBoundsMax;else{this._updateCenter();const e=t[1],i=this.convexHull;let s=0;const n=e.center;for(let t=0;t<8;++t)s=Math.max(s,H(n,i,3*t));t[1].radius=Math.sqrt(s)}}_calculateFrustumVisibility(t){if(!f(t,this._boundingSphere))return 2;if(this.lij[0]<10)return 1;const e=this.convexHull,i=this.surface.view.state.camera.near;let s=!0;for(let n=0;n<m;n++){const o=4===n,r=t[n],a=r[0],l=r[1],h=r[2],u=r[3]-(o?i:0);let c=!1;for(let t=0;t<8;++t){const i=3*t;if(a*e[i]+l*e[i+1]+h*e[i+2]+u<0){if(c=!0,!s)break}else s=!1}if(!c)return 2}return s?0:1}computeElevationBounds(){super.computeElevationBounds(),this._updateBoundingVolumes()}createGeometry(){x(this.renderData,this._getPatchType()),this._updateBoundingVolumes(),this.setMemoryDirty()}_updateBoundingVolumes(){this._updateConvexHull(),this._updateBoundingSphere(),_&&this._checkBVs()}_updateBoundingSphere(){const t=this._boundingSphere,e=this.elevationBoundsMin,i=this.elevationBoundsMax,r=this.ellipsoid.radius,a=i;if(0===this.level)t.center=u,t.radius=r+a;else{const a=this.extentInRadians,l=.5*(a[0]+a[2]),h=a[1],u=a[3];T(I,l,h,r),T(L,l,u,r),s(t.center,I,L);const c=r+.5*(e+i);n(t.center,t.center,c/o(t.center));const d=this.convexHull;let p=0;const f=(t,e)=>{const i=t[0]-d[3*e],s=t[1]-d[3*e+1],n=t[2]-d[3*e+2];return Math.sqrt(i*i+s*s+n*n)};for(let e=0;e<8;++e){const i=f(t.center,e);p=Math.max(p,i)}const m=p;t.radius=m+2}}_updateConvexHull(){const t=this.extentInRadians,i=this.ellipsoid.radius;if(0===this.level)return;const l=this.elevationBoundsMin,u=this.elevationBoundsMax,d=this._getPatchType(),p=this.surface.isWebMercator,f=p&&1===d,m=p&&2===d,g=m||f,x=Math.PI/2,$=t[0],v=t[2],M=m?-x:t[1],_=f?x:t[3],y=.5*($+v),B=l,S=i+(g?Math.min(0,B-1):B),V=(t,e,i)=>T(t,e,i,S),H=c(),R=c(),I=c(),L=c();V(H,$,M),V(R,$,_),V(I,v,_),V(L,v,M);const P=(t,e)=>{for(let i=0;i<3;++i)this._convexHull[3*e+i]=t[i]};P(H,0),P(R,1),P(I,2),P(L,3);const F=u,A=i+(g?Math.max(0,F+1):F),k=c(),D=c(),E=c();T(D,y,_,S),T(E,y,M,S),s(k,D,E),e(k,k);const w=c(),U=c(),q=(t,i)=>{h(U,t,i),e(U,U);const o=-a(t,w)/a(U,w);b(o>=0),n(U,U,o),s(t,t,U)};if(2**this.lij[0]>2*this.lij[1]){const t=E,i=c();r(i,C,t),e(i,i),r(w,t,i),e(w,w),b(j(a(w,t)/o(t),0)),q(H,R),q(L,I),P(H,0),P(L,3)}else if(2**this.lij[0]!==2*this.lij[1]){const t=D,i=c();r(i,C,t),e(i,i),r(w,i,t),e(w,w),q(R,H),q(I,L),P(R,1),P(I,2)}const N=(t,e)=>{const i=A/a(e,k);for(let s=0;s<3;++s)this._convexHull[3*t+s]=e[s]*i};N(4,H),N(5,R),N(6,I),N(7,L)}_getPatchType(){const t=this.lij[1],e=0===t,i=t===(1<<this.level)-1;return e?i?3:1:i?2:0}intersectsRay(t,e,i,s){const n=this._boundingSphere,o=n.radius+i,r=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],a=n.center[0]-t[0],l=n.center[1]-t[1],h=n.center[2]-t[2],u=(a*e[0]+l*e[1]+h*e[2])/r,c=e[0]*u-a,d=e[1]*u-l,p=e[2]*u-h;return c*c+d*d+p*p<o*o}get minimumVerticesPerSide(){return this.level<V.length?V[this.level]+1:2}updateCornerElevations(){$(this.renderData),this._updateBoundingVolumes()}updateEdgeElevations(){v(this.renderData),this._updateBoundingVolumes()}updateEdgeElevationsAndResolutions(){M(this.renderData),this._updateBoundingVolumes()}_checkBVs(){if(!_)return;if(this.level<=2)return;const t=this._boundingSphere,i=t.radius,n=t.center,u=c(),d=this.ellipsoid.radius,f=this.elevationBoundsMin,m=this.elevationBoundsMax,g=d+f,x=1,$=0,v=this._center[1];v.center;const M=v.radius,y=this.convexHull,S=(t,e)=>{for(let i=0;i<3;++i)t[i]=y[3*e+i]};{const t=c(),i=c(),s=c(),n=c(),o=c(),l=(l,u,c,d)=>{S(i,l),S(s,u),S(n,c),h(i,i,s),h(n,n,s),r(t,i,n),e(t,t);const p=a(t,s);S(o,d);const f=a(t,o),m=Math.abs(f-p);b(j(m,0),`Non coplanar ${l},${u},${c},${d} diff = ${m}`)};l(0,1,2,3),l(4,5,6,7),l(0,1,4,5),l(1,2,5,6),l(2,3,6,7),l(3,0,7,4)}const V=p(24),H=(t,e,i)=>{const s=4*t;for(let n=0;n<3;++n)V[s+n]=e[n];V[s+3]=i},C=c(),I=c(),L=c(),P=c(),F=(t,i,s,n)=>{S(C,i),S(I,s),S(L,n),h(C,C,I),e(C,C),h(L,L,I),e(L,L),r(P,C,L),e(P,P);const o=a(P,I);H(t,P,o)};F(0,0,1,2),F(1,1,0,4),F(2,1,5,2),F(3,3,2,6),F(4,4,0,3),F(5,4,6,5);const A=(t,e,i,s)=>{const n=4*t;return V[n]*e+V[n+1]*i+V[n+2]*s-V[n+3]},k=(t,e,i,s)=>A(t,e,i,s)>=-1,D=(t,e)=>k(t,e[0],e[1],e[2]),E=2**this.lij[0]>2*this.lij[1],w=(t,e,s)=>Math.sqrt(R(t,e,s,n[0],n[1],n[2]))<i,U=t=>w(t[0],t[1],t[2]),q=(t,e)=>w(t[e],t[e+1],t[e+2]),N=this.extentInRadians,G=.5*(N[0]+N[2]),z=N[1],O=N[3],W=c(),J=c();T(W,G,O,g),T(J,G,z,g);const K=E?"Upper":"Lower";let Q=!0;for(let e=0;e<6;++e){for(let t=0;t<8;++t){const i=3*t,s=k(e,y[i],y[i+1],y[i+2]);Q&&=s,b(s,`Tile[${this.lij}] Convex hull point ${t} outside of plane ${e}`)}b(D(e,J),`Tile[${this.lij}] (${K}) bottom mid outside of plane ${e}`),b(D(e,W),`Tile[${this.lij}] (${K}) top mid outside of plane ${e}`)}b(Q,"Not all convex hull points are inside convex hull polyhedron"),b(U(J),`Tile[${this.lij}] (${K}) bottom mid outside of bounding sphere`),b(U(W),`Tile[${this.lij}] (${K}) top mid outside of bounding sphere`);for(let e=0;e<8;++e){const t=q(y,3*e);b(t,`Tile[${this.lij}] Convex hull point ${e} outside of bounding sphere`)}for(let e=0;e<6;++e)for(let t=0;t<8;++t){const i=3*t;k(e,y[i],y[i+1],y[i+2])||console.error(`Tile[${this.lij}] Convex hull point ${t} outside of plane ${e}`)}const{extentInRadians:X}=this,Y=Math.max(X[2]-X[0],X[3]-X[1]),Z=Math.round(Y*d),{renderData:tt}=this;if(!tt)return;const{geometry:et,geometryState:it,localOrigin:st}=tt,nt=et.vertexAttributes?.position;if(!nt)return;const ot=c(),rt=et.numVerticesPerSide-2,{indices:at,indexCount:lt,edgeVerticesStartIndex:ht,poleVerticesStartIndex:ut}=et;if(!at)return;const ct=new Set;for(let e=0;e<lt;++e){const t=at[e];if(ct.has(t))continue;ct.add(t);const r=t<ut,a=t>=ht;let h=!1,c=-1;if(a){let e=ht;for(let i=0;i<4;++i){const s=it.edgeResolutions[i];if(t===e||t===e+s-1){h=!0;break}if(e+=s,t<e){c=i;break}}}const p=a?it.edgePeerNeighbors[c]:null,g=a&&p&&B(this,p)>0;nt.getVec(t,u),s(ot,u,st);const v=o(ot)-d;let _=0,b=!1;const j=f-v,y=v-m,S=j>x,V=y>x,H=S||V,R=()=>{const e=r?"internal":a&&!h?"edge":h?"corner":"pole";return`Tile[${this.lij}].vertex[${t}]:${e}`+(S?"(below)":V?"(above)":"")+(g?"(Neighbor)":"")},T=l(ot,n);if(T>=i+$){const t=T-i;H||(console.error(`${R()} is out of the bounding sphere by ${t.toFixed(0)} / ${i.toFixed(0)}[tol=${$}] h=${v.toFixed(0)} / [${f.toFixed(0)}..${m.toFixed(0)}] (${(t/i).toFixed(0)})`),b=!0)}for(let e=0;e<6;++e)if(!k(e,ot[0],ot[1],ot[2])){const s=A(e,ot[0],ot[1],ot[2]),n=t%rt,o=(t-n)/rt;0===e&&j||5===e&&y||(console.error(`${R()} (${n},${o})|${rt}] is out of the bounding trapezoid plane ${e} h=${Math.round(v)} / [${Math.round(f)}..${Math.round(m)}] dist=${Math.round(s)} radii = ${Math.round(i)}/${Math.round(M)}} : maxL = ${Z}`),++_)}if(b||_>0)break}}get convexHull(){return this._convexHull}}const V=[128,64,64,32,16,8,8,4];function H(t,e,i){return R(t[0],t[1],t[2],e[i],e[i+1],e[i+2])}function R(t,e,i,s,n,o){const r=s-t,a=n-e,l=o-i;return r*r+a*a+l*l}const T=(t,e,i,s)=>{const n=Math.cos(e),o=Math.sin(e),r=Math.cos(i),a=Math.sin(i);t[0]=s*r*n,t[1]=s*r*o,t[2]=s*a},C=[0,0,1],I=c(),L=c();export{S as SphericalPatch};
5
+ import{lerp as t}from"../../../core/mathUtils.js";import{n as e,h as i,i as s,j as n,u as o,f as r,g as a,F as l,a as h}from"../../../chunks/vec32.js";import{ZEROS as u,create as c}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{lonLatToSphericalPCPF as d}from"../../../geometry/projection/lonLatToSphericalPCPF.js";import{newDoubleArray as p}from"../../../geometry/support/DoubleArray.js";import{intersectsSphere as f,numPlanes as m}from"../../../geometry/support/frustum.js";import{Sphere as g}from"../../../geometry/support/sphere.js";import{createSphericalGlobePatch as x,updateCornerSpherical as $,updateEdgesAndCornersSpherical as v,updateEdgeElevationsAndResolutionsSpherical as M}from"./PatchGeometryFactory.js";import{enableTerrainInternalChecks as _,internalAssert as b,almostEquals as j}from"./terrainUtils.js";import{Tile as y}from"./Tile.js";import{compareTilesByLij as B}from"./tileUtils.js";class S extends y{constructor(t,e,i,s,n){super(),this._convexHull=new Array(24),this._boundingSphere=new g,this._baseUsedMemory=1816,this.init(t,e,i,s,n)}init(i,s,n,o,r){super.init(i,s,n,o,r);const a=this.ellipsoid.radius,l=this.extentInRadians[0],h=this.extentInRadians[1],u=this.extentInRadians[2],c=this.extentInRadians[3],p=t(h,c,.5),f=t(l,u,.5),m=0===i?0:Math.min(Math.abs(h),Math.abs(c));this._edgeLen=(u-l)*Math.cos(m)*a,this._edgeLen2=this._edgeLen*this._edgeLen,this._curvatureHeight=a-Math.sqrt(a*a-this._edgeLen2/4),d(this.centerAtSeaLevel,f,p,this.ellipsoid.radius),e(this.up,this.centerAtSeaLevel),this.updateRadiusAndCenter()}updateRadiusAndCenter(){this._updateBoundingVolumes();const t=this._center;if(0===this.lij[0])t[1].center=u,i(t[0],0,0,0),i(t[2],0,0,0),t[1].radius=this.ellipsoid.radius+this.elevationBoundsMax;else{this._updateCenter();const e=t[1],i=this.convexHull;let s=0;const n=e.center;for(let t=0;t<8;++t)s=Math.max(s,R(n,i,3*t));t[1].radius=Math.sqrt(s)}}_calculateFrustumVisibility(t){if(!f(t,this._boundingSphere))return 2;if(this.lij[0]<10)return 1;const e=this.convexHull,i=this.surface.view.state.camera.near;let s=!0;for(let n=0;n<m;n++){const o=4===n,r=t[n],a=r[0],l=r[1],h=r[2],u=r[3]-(o?i:0);let c=!1;for(let t=0;t<8;++t){const i=3*t;if(a*e[i]+l*e[i+1]+h*e[i+2]+u<0){if(c=!0,!s)break}else s=!1}if(!c)return 2}return s?0:1}computeElevationBounds(){super.computeElevationBounds(),this._updateBoundingVolumes()}createGeometry(){x(this.renderData,this._getPatchType()),this._updateBoundingVolumes(),this.setMemoryDirty()}_updateBoundingVolumes(){this._updateConvexHull(),this._updateBoundingSphere(),_&&this._checkBVs()}_updateBoundingSphere(){const t=this._boundingSphere,e=this.elevationBoundsMin,i=this.elevationBoundsMax,r=this.ellipsoid.radius,a=i;if(0===this.level)t.center=u,t.radius=r+a;else{const a=this.extentInRadians,l=.5*(a[0]+a[2]),h=a[1],u=a[3];H(I,l,h,r),H(F,l,u,r),s(t.center,I,F);const c=r+.5*(e+i);n(t.center,t.center,c/o(t.center));const d=this.convexHull;let p=0;const f=(t,e)=>{const i=t[0]-d[3*e],s=t[1]-d[3*e+1],n=t[2]-d[3*e+2];return Math.sqrt(i*i+s*s+n*n)};for(let e=0;e<8;++e){const i=f(t.center,e);p=Math.max(p,i)}const m=p;t.radius=m+2}}_updateConvexHull(){const t=this.extentInRadians,i=this.ellipsoid.radius;if(0===this.level)return;const l=this.elevationBoundsMin,u=this.elevationBoundsMax,d=this._getPatchType(),p=this.surface.isWebMercator,f=p&&1===d,m=p&&2===d,g=m||f,x=Math.PI/2,$=t[0],v=t[2],M=m?-x:t[1],_=f?x:t[3],y=.5*($+v),B=l,S=i+(g?Math.min(0,B-1):B),V=(t,e,i)=>H(t,e,i,S),R=c(),T=c(),I=c(),F=c();V(R,$,M),V(T,$,_),V(I,v,_),V(F,v,M);const L=(t,e)=>{for(let i=0;i<3;++i)this._convexHull[3*e+i]=t[i]};L(R,0),L(T,1),L(I,2),L(F,3);const P=u,A=i+(g?Math.max(0,P+1):P),k=c(),D=c(),E=c();H(D,y,_,S),H(E,y,M,S),s(k,D,E),e(k,k);const w=c(),U=c(),q=(t,i)=>{h(U,t,i),e(U,U);const o=-a(t,w)/a(U,w);b(o>=0),n(U,U,o),s(t,t,U)};if(2**this.lij[0]>2*this.lij[1]){const t=E,i=c();r(i,C,t),e(i,i),r(w,t,i),e(w,w),b(j(a(w,t)/o(t),0)),q(R,T),q(F,I),L(R,0),L(F,3)}else if(2**this.lij[0]!==2*this.lij[1]){const t=D,i=c();r(i,C,t),e(i,i),r(w,i,t),e(w,w),q(T,R),q(I,F),L(T,1),L(I,2)}const N=(t,e)=>{const i=A/a(e,k);for(let s=0;s<3;++s)this._convexHull[3*t+s]=e[s]*i};N(4,R),N(5,T),N(6,I),N(7,F)}_getPatchType(){const t=this.lij[1],e=0===t,i=t===(1<<this.level)-1;return e?i?3:1:i?2:0}intersectsRay(t,e,i,s){const n=this._boundingSphere,o=n.radius+i,r=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],a=n.center[0]-t[0],l=n.center[1]-t[1],h=n.center[2]-t[2],u=(a*e[0]+l*e[1]+h*e[2])/r,c=e[0]*u-a,d=e[1]*u-l,p=e[2]*u-h;return c*c+d*d+p*p<o*o}get minimumVerticesPerSide(){return this.level<V.length?V[this.level]+1:2}updateCornerElevations(){$(this.renderData),this._updateBoundingVolumes()}updateEdgeElevations(){v(this.renderData),this._updateBoundingVolumes()}updateEdgeElevationsAndResolutions(){M(this.renderData),this._updateBoundingVolumes()}_checkBVs(){if(!_)return;if(this.level<=2)return;const t=this._boundingSphere,i=t.radius,n=t.center,u=c(),d=this.ellipsoid.radius,f=this.elevationBoundsMin,m=this.elevationBoundsMax,g=d+f,x=1,$=0,v=this._center[1];v.center;const M=v.radius,y=this.convexHull,S=(t,e)=>{for(let i=0;i<3;++i)t[i]=y[3*e+i]};{const t=c(),i=c(),s=c(),n=c(),o=c(),l=(l,u,c,d)=>{S(i,l),S(s,u),S(n,c),h(i,i,s),h(n,n,s),r(t,i,n),e(t,t);const p=a(t,s);S(o,d);const f=a(t,o),m=Math.abs(f-p);b(j(m,0),`Non coplanar ${l},${u},${c},${d} diff = ${m}`)};l(0,1,2,3),l(4,5,6,7),l(0,1,4,5),l(1,2,5,6),l(2,3,6,7),l(3,0,7,4)}const V=p(24),R=(t,e,i)=>{const s=4*t;for(let n=0;n<3;++n)V[s+n]=e[n];V[s+3]=i},C=c(),I=c(),F=c(),L=c(),P=(t,i,s,n)=>{S(C,i),S(I,s),S(F,n),h(C,C,I),e(C,C),h(F,F,I),e(F,F),r(L,C,F),e(L,L);const o=a(L,I);R(t,L,o)};P(0,0,1,2),P(1,1,0,4),P(2,1,5,2),P(3,3,2,6),P(4,4,0,3),P(5,4,6,5);const A=(t,e,i,s)=>{const n=4*t;return V[n]*e+V[n+1]*i+V[n+2]*s-V[n+3]},k=(t,e,i,s)=>A(t,e,i,s)>=-1,D=(t,e)=>k(t,e[0],e[1],e[2]),E=2**this.lij[0]>2*this.lij[1],w=(t,e,s)=>Math.sqrt(T(t,e,s,n[0],n[1],n[2]))<i,U=t=>w(t[0],t[1],t[2]),q=(t,e)=>w(t[e],t[e+1],t[e+2]),N=this.extentInRadians,G=.5*(N[0]+N[2]),z=N[1],O=N[3],W=c(),J=c();H(W,G,O,g),H(J,G,z,g);const K=E?"Upper":"Lower";let Q=!0;for(let e=0;e<6;++e){for(let t=0;t<8;++t){const i=3*t,s=k(e,y[i],y[i+1],y[i+2]);Q&&=s,b(s,`Tile[${this.lij}] Convex hull point ${t} outside of plane ${e}`)}b(D(e,J),`Tile[${this.lij}] (${K}) bottom mid outside of plane ${e}`),b(D(e,W),`Tile[${this.lij}] (${K}) top mid outside of plane ${e}`)}b(Q,"Not all convex hull points are inside convex hull polyhedron"),b(U(J),`Tile[${this.lij}] (${K}) bottom mid outside of bounding sphere`),b(U(W),`Tile[${this.lij}] (${K}) top mid outside of bounding sphere`);for(let e=0;e<8;++e){const t=q(y,3*e);b(t,`Tile[${this.lij}] Convex hull point ${e} outside of bounding sphere`)}for(let e=0;e<6;++e)for(let t=0;t<8;++t){const i=3*t;k(e,y[i],y[i+1],y[i+2])||console.error(`Tile[${this.lij}] Convex hull point ${t} outside of plane ${e}`)}const{extentInRadians:X}=this,Y=Math.max(X[2]-X[0],X[3]-X[1]),Z=Math.round(Y*d),{renderData:tt}=this;if(!tt)return;const{geometry:et,geometryState:it,localOrigin:st}=tt,nt=et.vertexAttributes?.position;if(!nt)return;const ot=c(),rt=et.numVerticesPerSide-2,{indices:at,indexCount:lt,edgeVerticesStartIndex:ht,poleVerticesStartIndex:ut}=et;if(!at)return;const ct=new Set;for(let e=0;e<lt;++e){const t=at[e];if(ct.has(t))continue;ct.add(t);const r=t<ut,a=t>=ht;let h=!1,c=-1;if(a){let e=ht;for(let i=0;i<4;++i){const s=it.edgeResolutions[i];if(t===e||t===e+s-1){h=!0;break}if(e+=s,t<e){c=i;break}}}const p=a?it.edgePeerNeighbors[c]:null,g=a&&p&&B(this,p)>0;nt.getVec(t,u),s(ot,u,st);const v=o(ot)-d;let _=0,b=!1;const j=f-v,y=v-m,S=j>x,V=y>x,R=S||V,T=()=>{const e=r?"internal":a&&!h?"edge":h?"corner":"pole";return`Tile[${this.lij}].vertex[${t}]:${e}`+(S?"(below)":V?"(above)":"")+(g?"(Neighbor)":"")},H=l(ot,n);if(H>=i+$){const t=H-i;R||(console.error(`${T()} is out of the bounding sphere by ${t.toFixed(0)} / ${i.toFixed(0)}[tol=${$}] h=${v.toFixed(0)} / [${f.toFixed(0)}..${m.toFixed(0)}] (${(t/i).toFixed(0)})`),b=!0)}for(let e=0;e<6;++e)if(!k(e,ot[0],ot[1],ot[2])){const s=A(e,ot[0],ot[1],ot[2]),n=t%rt,o=(t-n)/rt;0===e&&j||5===e&&y||(console.error(`${T()} (${n},${o})|${rt}] is out of the bounding trapezoid plane ${e} h=${Math.round(v)} / [${Math.round(f)}..${Math.round(m)}] dist=${Math.round(s)} radii = ${Math.round(i)}/${Math.round(M)}} : maxL = ${Z}`),++_)}if(b||_>0)break}}get convexHull(){return this._convexHull}}const V=[128,64,64,32,16,8,8,4];function R(t,e,i){return T(t[0],t[1],t[2],e[i],e[i+1],e[i+2])}function T(t,e,i,s,n,o){const r=s-t,a=n-e,l=o-i;return r*r+a*a+l*l}const H=(t,e,i,s)=>{const n=Math.cos(e),o=Math.sin(e),r=Math.cos(i),a=Math.sin(i);t[0]=s*r*n,t[1]=s*r*o,t[2]=s*a},C=[0,0,1],I=c(),F=c();export{S as SphericalPatch};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{toConst as e}from"../../../core/compilerUtils.js";import{clamp as t}from"../../../core/mathUtils.js";import{abortMaybe as i}from"../../../core/maybe.js";import s from"../../../core/ObjectPool.js";import{e as n,F as r,g as a,j as l,i as o,b as h,d}from"../../../chunks/vec32.js";import{create as u,unitZ as c}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as g}from"../../../geometry/ellipsoidUtils.js";import{create as p,equals as f,rectangleContainsRectangleCyclicalAware as _,rectanglesIntersectCyclicalAware as m,width as y,height as v}from"../../../geometry/support/aaBoundingRect.js";import{Sphere as M}from"../../../geometry/support/sphere.js";import{isGroupLayer as A}from"../../../layers/support/layerUtils.js";import{ElevationBounds as x}from"./ElevationBounds.js";import{ElevationTileAgent as D,isElevationTileAgent as b}from"./ElevationTileAgent.js";import{LayerClasses as L}from"./LayerClass.js";import{MapDataCacheItem as I}from"./MapDataCacheItem.js";import{MapTileAgent as j,isMapTileAgent as T}from"./MapTileAgent.js";import{maxPatchTesselation as C}from"./TerrainConst.js";import{isVectorTile as B,isTileTexture as U,isRasterTile as S,isImageWithType as w}from"./TerrainData.js";import{weakAssert as E,isBlendableLayerView as P,oppositeCorner as O,internalAssert as R,enableTerrainInternalChecks as q,neighborEdgeIndices as V,oppositeEdge as N,neighborCornerIndices as G,almostEquals as k,enableWaterproofTests as F,isNorth as z,isSouth as W,isWest as H,isEast as J,isWestCorner as X,isNorthCorner as Y}from"./terrainUtils.js";import{tileAgentDone as $}from"./TileAgent.js";import{TilePerLayerInfo as Q}from"./TilePerLayerInfo.js";import{fallsWithinLayerView as K}from"./tileUtils.js";const Z=.1;class ee{constructor(){this._lij=[0,0,0],this._children=[null,null,null,null],this._pendingUpdates=0,this._dirty=!0,this._previouslyRendered=!1,this.extent=p(),this._elevationBoundsMin=NaN,this._elevationBoundsMax=0,this.layerInfo=[[],[]],this.extentInRadians=p(),this.centerAtSeaLevel=u(),this._center=[u(),new M,u()],this.up=c(),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=u(),this.maxLevelDeltaNeighborCount=0,this.unmergableChildCount=0}get lij(){return this._lij}get spatialReference(){return this._surface.spatialReference??this._surface.tilingScheme.spatialReference}get isDisposed(){return null==this._surface}get elevationLevelDelta(){return this._surface.getElevationLevelDelta(this.level)}static prune(){se.prune(0),ne.prune(0),Q.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].radius}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=g(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].radius=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 L){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]=Q.acquire(this._surface.upsampleInfoPool),0===r&&this.findElevationBoundsForLayer(i,-1)}this.computeElevationBounds(),this._maxTesselation=Math.min(n.tilingScheme.pixelSize,C)}dispose(){E(!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,new I(e(this)))}setMemoryDirty(){this._usedMemory=0}get usedMemory(){return this._ensureUsedMemory()+(this._cached?0:this.mapDataMemory)}get cachedMemory(){return this._ensureUsedMemory(),null==this._surface?this.usedMemory:this._cached?this.mapDataMemory:0}get mapDataMemory(){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+(B(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])B(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?.usedMemory??0),this._cached&&this._surface.upsampleMapCache.updateSize(this.key),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 U(e)?e.texture.usedMemory:S(e)?e.memoryUsage:B(e)?e.usedMemoryPerReference:w(e)||e instanceof HTMLImageElement?this._cpuImageMemorySize:0}updateScreenDepth(e){const[t,i,s]=this._center[1].center,n=e,r=n[2]*t+n[6]*i+n[10]*s+n[14];this.screenDepth=r<0?0:r/(n[3]*t+n[7]*i+n[11]*s+n[15])}shouldSplit(e,t,i){if(!this.visible)return 0;if(e.frustum&&(!this._intersectsClippingArea||2===this._calculateFrustumVisibility(e.frustum)))return 0;const s=this.level;n(ue,this._center[1].center,t);let d=r(ue),u=ue,c=this._center[1].center;n(ce,this._center[0],t);const g=r(ce);g<d&&(d=g,u=ce,c=this._center[0]),n(ge,this._center[2],t);const p=r(ge);if(p<d&&(d=p,u=ge,c=this._center[2]),this._edgeLen2>d&&s<e.maxLod)return 1;const f=Math.sqrt(d),_=e.fovX*f*2,m=this._edgeLen/_,y=()=>{if(s<e.maxLod)return this.elevationLevel=s,0;const t=s+Math.ceil(-Math.log2(e.relativeWidthLimit/m));return t!==this.elevationLevel?(this.elevationLevel=t,2):0},v=null!=i?i-s:1/0;if(v<=.5)return y();const M=a(this.up,ue),A=this._elevationBoundsMax-this._elevationBoundsMin,x=A/this.edgeLen;if(e.aboveGround&&M>0&&x<.001){if(M/f-Math.sin(this._curvatureHeight/(this.edgeLen*Math.SQRT1_2)*Math.PI)-x>0)return 0}const D=null!=i?3-Math.min(v,2):1;if(m*D<e.relativeWidthLimit||s>=e.maxLod)return y();if(s<7)return 1;l(pe,this.up,M),n(pe,pe,u);const b=r(pe);if(b<=this.radius*this.radius)return 1;l(pe,pe,this.radius/Math.sqrt(b)),o(pe,pe,c),n(pe,t,pe);const L=Math.min(1,(Math.abs(a(pe,this.up))+.5*A+this._curvatureHeight)/h(pe)),I=Z/e.angledSplitBias,j=e.fovY*f*2;return L*(this._edgeLen/j*D)<I*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 L)this._createOrUpdateAgents(0,e);this.surface.renderer.loadTile(this)}unload(){this.renderData&&this.unrefMapData(),this.surface.renderer.unloadTile(this);for(const e of L){const t=this.layerInfo[e];for(const e of t)e.loadingAgent&&e.loadingAgent!==$&&(ie(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!==$&&(ie(t.loadingAgent),t.loadingAgent=null),t.pendingUpdates=0,t.invalidateSourceData();this.renderData?.releaseTexture(),this.setMemoryDirty()}updateClippingStatus(e){if(f(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(!1)}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 L){const t=this.layerInfo[e];for(const e of t)if(e.loadingAgent&&e.loadingAgent!==$&&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(!0):this._surface.requestUpdate(),t!==this._pendingUpdates}resetPendingUpdate(e){return!!this.hasPendingUpdate(e)&&(this._pendingUpdates&=~e,!0)}requestLayerData(e,t,s){const n=this.layerInfo[t][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(),t,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(),t,e);const i=B(n.data);return s.dataArrived(this,i),!0}if(n.requestPromise)return!0;i(n.requestAbort),n.requestAbort=new AbortController;const r=this._surface.requestTileData(this,e,t,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 r(n(pe,this._center[1].center,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);E(r,"agent has not requested this piece of map data"),n.length<1&&(s.abortRequest(),this.setMemoryDirty())}dataArrived(e,t,i){const s=B(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.minElevation),s=Math.max(s,a.elevationBounds.maxElevation),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(!1))}_updateCenter(){const e=this._elevationBoundsMin,t=this._elevationBoundsMax,i=.5*(e+t),s=this._center;l(pe,this.up,i),o(s[1].center,this.centerAtSeaLevel,pe),l(pe,this.up,e),o(s[0],this.centerAtSeaLevel,pe),l(pe,this.up,t),o(s[2],this.centerAtSeaLevel,pe)}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(!K(this,a))return;const l=re;let o=!1;const h=i.data;if(h&&h.level<=n){const e=i.data;l.minElevation=e.samplerData.data.minValue,l.maxElevation=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.minElevation!==1/0&&(l.level=i.level,o=!0))}o&&(null==i.elevationBounds&&(i.elevationBounds=new x),i.elevationBounds.copyFrom(l))}modifyLayers(e,t,i){const s=this.layerInfo[i];for(const a of s)a.loadingAgent&&a.loadingAgent!==$&&(ie(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]:Q.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===$&&(e.loadingAgent=null);this._createOrUpdateAgents(0,e)}}updateAgentSuspension(){for(const e of L){const t=this._isSuspended(e);for(const i of this.layerInfo[e])i.loadingAgent&&i.loadingAgent!==$&&(i.loadingAgent.setSuspension(t),i.loadingAgent===$&&this.updateRenderData(e,0))}}removeLayerAgent(e,t){const i=this.layerInfo[t][e];i.loadingAgent&&i.loadingAgent!==$&&i.loadingAgent.dispose(),i.loadingAgent=null}agentDone(e,t){const i=this.layerInfo[t][e];i.loadingAgent=$,i.data||null!=i.upsampleInfo||this._createOrUpdateAgents(e+1,t)}_hasBlendableAncestor(e){return"normal"!==e.blendMode||A(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(P(e)&&"normal"!==e?.layer?.blendMode||A(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?K(this,a)?(r.loadingAgent!==$&&r.loadingAgent.setSuspension(s),r.loadingAgent!==$&&(l=r.loadingAgent.update())):r.dispose():K(this,a)&&(r.loadingAgent=te(this,n,t,s),l=r.loadingAgent.startLoading(),l?r.loadingAgent===$&&this.setPendingUpdate(8):(ie(r.loadingAgent),r.loadingAgent=$)),r.loadingAgent===$&&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(e){const i=this.elevationLevel-this.level,s=Math.max(this.level-e,this.elevationLevelDelta-i),n=t(1+(this._maxTesselation>>s),2,this._maxTesselation+1),r=this.minimumVerticesPerSide;return Math.max(n,r)}_findLIJ(e,t){if(!e)return null;const{rootTiles:i}=this.surface;if(null!=i)for(const s of i)if(ae(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?le(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(O(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(R(!q||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 q&&(R(a<=l&&l<a+s),R(0<=h&&h<s)),h}forEachLoadedNeighbor(e){const t=this.level,i=e=>e.level===t||e.loaded;V.forEach(t=>{const s=this.findNeighborTile(t,i);null!=s&&s!==this&&s.forAllSubtreeOnSide(N(t),i=>!!i.loaded&&(e(i,t),!0))}),G.forEach(t=>{const s=this.findNeighborTile(t,i)?.findCorner(O(t),e=>e.loaded);R(!s||oe(this,s,t)),s?.loaded&&e(s,t)})}_getNeighborLIJ(e,t){const i=z(t)?-1:W(t)?1:0,s=H(t)?-1:J(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 k(this.extent[3],e.extent[1],i);case 4:return k(this.extent[1],e.extent[3],i);case 2:return k(this.extent[2],e.extent[0],i)||k(this.extent[2],-e.extent[0],i);case 6:return k(this.extent[0],e.extent[2],i)||k(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(){F&&(R(this.loaded),this.renderData?.checkGeometryWaterproofness())}shouldHaveNeighbor(e){const t=this.extent,{rootTilesExtent:i}=this._surface,s=.25*(t[2]-t[0]);if(z(e)&&t[3]+s>=i[3])return!1;if(W(e)&&t[1]-s<=i[1])return!1;const n=this.surface.isGlobal;return!(!n&&H(e)&&t[0]-s<=i[0])&&!(!n&&J(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;d(this._lastPOI,e);const i=this._center[1].center,s=e[0]-i[0],n=e[1]-i[1],r=e[2]-i[2];this.distanceToPOI=s*s+n*n+r*r}updateOverlayParameters(e){const{renderData:t}=this;if(!t)return;const{overlays:i,longitudeCyclical:s}=e,n=t.overlay;if(0===i.length)this._clearTileOverlayData(0,n),this._clearTileOverlayData(1,n);else{const[e,t]=i,r=this.extent;_(e.extent,r,s)||m(r,e.extent,s)||m(r,t.extent,s)?(this._setOverlayData(i,s,r,0,n),this._setOverlayData(i,s,r,1,n)):(this._clearTileOverlayData(0,n),this._clearTileOverlayData(1,n))}}_setOverlayData(e,t,i,s,n){const r=e[s].extent,a=y(r),l=v(r);let o=i[0];if(t){o=t.minimalMonotonic(r[0],o);const e=t.minimalMonotonic(r[0],i[2]);o>e&&(o=e-(i[2]-i[0]))}if(0===a||0===l)return void n.setOffsetAndScale(s,0,0,1,1);const h=y(i)/a,d=v(i)/l,u=(o-r[0])/a,c=(i[1]-r[1])/l;n.setOffsetAndScale(s,u,c,h,d)}_clearTileOverlayData(e,t){t.setOffsetAndScale(e,-1,-1,-1,-1)}}function te(e,t,i,s){const n=0===i?ne.acquire():se.acquire();return n.init(e,t,i,s),n}function ie(e){e.dispose(),b(e)?ne.release(e):T(e)&&se.release(e)}const se=new s(()=>new j),ne=new s(()=>new D),re=new x;function ae(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 le(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]}function oe(e,t,i){return null!=e&&null!=t&&t!==e&&(e.level>=t.level?he(e,t,i):he(t,e,O(i)))}function he(e,t,i){R(e.level>=t.level);const s=X(i),n=Y(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=k(l[0],o[0],h)||e.surface.isGlobal&&k(l[0],-o[0],h),u=k(l[1],o[1],h);if(d&&u)return!0;if(e.level===t.level)return R(!1),!1;if(!d&&!u)return R(!1),!1;const c=d?de(a[1],a[3],r[1],r[3],h):de(a[0],a[2],r[0],r[2],h);return R(c),c}function de(e,t,i,s,n){return e-n<=i&&i<=s&&s<=t+n}const ue=u(),ce=u(),ge=u(),pe=u();export{ee as Tile,oe as isCornerNeighbor,le as lijEquals};
5
+ import{toConst as e}from"../../../core/compilerUtils.js";import{clamp as t}from"../../../core/mathUtils.js";import{abortMaybe as i}from"../../../core/maybe.js";import s from"../../../core/ObjectPool.js";import{e as n,D as r,g as a,j as l,i as o,b as h,d}from"../../../chunks/vec32.js";import{create as u,unitZ as c}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as g}from"../../../geometry/ellipsoidUtils.js";import{create as p,equals as f,rectangleContainsRectangleCyclicalAware as _,rectanglesIntersectCyclicalAware as m,width as y,height as v}from"../../../geometry/support/aaBoundingRect.js";import{Sphere as M}from"../../../geometry/support/sphere.js";import{isGroupLayer as A}from"../../../layers/support/layerUtils.js";import{ElevationBounds as x}from"./ElevationBounds.js";import{ElevationTileAgent as D,isElevationTileAgent as b}from"./ElevationTileAgent.js";import{LayerClasses as L}from"./LayerClass.js";import{MapDataCacheItem as I}from"./MapDataCacheItem.js";import{MapTileAgent as j,isMapTileAgent as T}from"./MapTileAgent.js";import{maxPatchTesselation as C}from"./TerrainConst.js";import{isVectorTile as B,isTileTexture as U,isRasterTile as S,isImageWithType as w}from"./TerrainData.js";import{weakAssert as E,isBlendableLayerView as P,oppositeCorner as O,internalAssert as R,enableTerrainInternalChecks as q,neighborEdgeIndices as V,oppositeEdge as N,neighborCornerIndices as G,almostEquals as k,enableWaterproofTests as z,isNorth as F,isSouth as W,isWest as H,isEast as J,isWestCorner as X,isNorthCorner as Y}from"./terrainUtils.js";import{tileAgentDone as $}from"./TileAgent.js";import{TilePerLayerInfo as Q}from"./TilePerLayerInfo.js";import{fallsWithinLayerView as K}from"./tileUtils.js";const Z=.1;class ee{constructor(){this._lij=[0,0,0],this._children=[null,null,null,null],this._pendingUpdates=0,this._dirty=!0,this._previouslyRendered=!1,this.extent=p(),this._elevationBoundsMin=NaN,this._elevationBoundsMax=0,this.layerInfo=[[],[]],this.extentInRadians=p(),this.centerAtSeaLevel=u(),this._center=[u(),new M,u()],this.up=c(),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=u(),this.maxLevelDeltaNeighborCount=0,this.unmergableChildCount=0}get lij(){return this._lij}get spatialReference(){return this._surface.spatialReference??this._surface.tilingScheme.spatialReference}get isDisposed(){return null==this._surface}get elevationLevelDelta(){return this._surface.getElevationLevelDelta(this.level)}static prune(){se.prune(0),ne.prune(0),Q.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].radius}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=g(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].radius=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 L){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]=Q.acquire(this._surface.upsampleInfoPool),0===r&&this.findElevationBoundsForLayer(i,-1)}this.computeElevationBounds(),this._maxTesselation=Math.min(n.tilingScheme.pixelSize,C)}dispose(){E(!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,new I(e(this)))}setMemoryDirty(){this._usedMemory=0}get usedMemory(){return this._ensureUsedMemory()+(this._cached?0:this.mapDataMemory)}get cachedMemory(){return this._ensureUsedMemory(),null==this._surface?this.usedMemory:this._cached?this.mapDataMemory:0}get mapDataMemory(){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+(B(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])B(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?.usedMemory??0),this._cached&&this._surface.upsampleMapCache.updateSize(this.key),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 U(e)?e.texture.usedMemory:S(e)?e.memoryUsage:B(e)?e.usedMemoryPerReference:w(e)||e instanceof HTMLImageElement?this._cpuImageMemorySize:0}updateScreenDepth(e){const[t,i,s]=this._center[1].center,n=e,r=n[2]*t+n[6]*i+n[10]*s+n[14];this.screenDepth=r<0?0:r/(n[3]*t+n[7]*i+n[11]*s+n[15])}shouldSplit(e,t,i){if(!this.visible)return 0;if(e.frustum&&(!this._intersectsClippingArea||2===this._calculateFrustumVisibility(e.frustum)))return 0;const s=this.level;n(ue,this._center[1].center,t);let d=r(ue),u=ue,c=this._center[1].center;n(ce,this._center[0],t);const g=r(ce);g<d&&(d=g,u=ce,c=this._center[0]),n(ge,this._center[2],t);const p=r(ge);if(p<d&&(d=p,u=ge,c=this._center[2]),this._edgeLen2>d&&s<e.maxLod)return 1;const f=Math.sqrt(d),_=e.fovX*f*2,m=this._edgeLen/_,y=()=>{if(s<e.maxLod)return this.elevationLevel=s,0;const t=s+Math.ceil(-Math.log2(e.relativeWidthLimit/m));return t!==this.elevationLevel?(this.elevationLevel=t,2):0},v=null!=i?i-s:1/0;if(v<=.5)return y();const M=a(this.up,ue),A=this._elevationBoundsMax-this._elevationBoundsMin,x=A/this.edgeLen;if(e.aboveGround&&M>0&&x<.001){if(M/f-Math.sin(this._curvatureHeight/(this.edgeLen*Math.SQRT1_2)*Math.PI)-x>0)return 0}const D=null!=i?3-Math.min(v,2):1;if(m*D<e.relativeWidthLimit||s>=e.maxLod)return y();if(s<7)return 1;l(pe,this.up,M),n(pe,pe,u);const b=r(pe);if(b<=this.radius*this.radius)return 1;l(pe,pe,this.radius/Math.sqrt(b)),o(pe,pe,c),n(pe,t,pe);const L=Math.min(1,(Math.abs(a(pe,this.up))+.5*A+this._curvatureHeight)/h(pe)),I=Z/e.angledSplitBias,j=e.fovY*f*2;return L*(this._edgeLen/j*D)<I*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 L)this._createOrUpdateAgents(0,e);this.surface.renderer.loadTile(this)}unload(){this.renderData&&this.unrefMapData(),this.surface.renderer.unloadTile(this);for(const e of L){const t=this.layerInfo[e];for(const e of t)e.loadingAgent&&e.loadingAgent!==$&&(ie(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!==$&&(ie(t.loadingAgent),t.loadingAgent=null),t.pendingUpdates=0,t.invalidateSourceData();this.renderData?.releaseTexture(),this.setMemoryDirty()}updateClippingStatus(e){if(f(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(!1)}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 L){const t=this.layerInfo[e];for(const e of t)if(e.loadingAgent&&e.loadingAgent!==$&&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(!0):this._surface.requestUpdate(),t!==this._pendingUpdates}resetPendingUpdate(e){return!!this.hasPendingUpdate(e)&&(this._pendingUpdates&=~e,!0)}requestLayerData(e,t,s){const n=this.layerInfo[t][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(),t,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(),t,e);const i=B(n.data);return s.dataArrived(this,i),!0}if(n.requestPromise)return!0;i(n.requestAbort),n.requestAbort=new AbortController;const r=this._surface.requestTileData(this,e,t,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 r(n(pe,this._center[1].center,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);E(r,"agent has not requested this piece of map data"),n.length<1&&(s.abortRequest(),this.setMemoryDirty())}dataArrived(e,t,i){const s=B(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.minElevation),s=Math.max(s,a.elevationBounds.maxElevation),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(!1))}_updateCenter(){const e=this._elevationBoundsMin,t=this._elevationBoundsMax,i=.5*(e+t),s=this._center;l(pe,this.up,i),o(s[1].center,this.centerAtSeaLevel,pe),l(pe,this.up,e),o(s[0],this.centerAtSeaLevel,pe),l(pe,this.up,t),o(s[2],this.centerAtSeaLevel,pe)}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(!K(this,a))return;const l=re;let o=!1;const h=i.data;if(h&&h.level<=n){const e=i.data;l.minElevation=e.samplerData.data.minValue,l.maxElevation=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.minElevation!==1/0&&(l.level=i.level,o=!0))}o&&(null==i.elevationBounds&&(i.elevationBounds=new x),i.elevationBounds.copyFrom(l))}modifyLayers(e,t,i){const s=this.layerInfo[i];for(const a of s)a.loadingAgent&&a.loadingAgent!==$&&(ie(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]:Q.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===$&&(e.loadingAgent=null);this._createOrUpdateAgents(0,e)}}updateAgentSuspension(){for(const e of L){const t=this._isSuspended(e);for(const i of this.layerInfo[e])i.loadingAgent&&i.loadingAgent!==$&&(i.loadingAgent.setSuspension(t),i.loadingAgent===$&&this.updateRenderData(e,0))}}removeLayerAgent(e,t){const i=this.layerInfo[t][e];i.loadingAgent&&i.loadingAgent!==$&&i.loadingAgent.dispose(),i.loadingAgent=null}agentDone(e,t){const i=this.layerInfo[t][e];i.loadingAgent=$,i.data||null!=i.upsampleInfo||this._createOrUpdateAgents(e+1,t)}_hasBlendableAncestor(e){return"normal"!==e.blendMode||A(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(P(e)&&"normal"!==e?.layer?.blendMode||A(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?K(this,a)?(r.loadingAgent!==$&&r.loadingAgent.setSuspension(s),r.loadingAgent!==$&&(l=r.loadingAgent.update())):r.dispose():K(this,a)&&(r.loadingAgent=te(this,n,t,s),l=r.loadingAgent.startLoading(),l?r.loadingAgent===$&&this.setPendingUpdate(8):(ie(r.loadingAgent),r.loadingAgent=$)),r.loadingAgent===$&&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(e){const i=this.elevationLevel-this.level,s=Math.max(this.level-e,this.elevationLevelDelta-i),n=t(1+(this._maxTesselation>>s),2,this._maxTesselation+1),r=this.minimumVerticesPerSide;return Math.max(n,r)}_findLIJ(e,t){if(!e)return null;const{rootTiles:i}=this.surface;if(null!=i)for(const s of i)if(ae(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?le(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(O(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(R(!q||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 q&&(R(a<=l&&l<a+s),R(0<=h&&h<s)),h}forEachLoadedNeighbor(e){const t=this.level,i=e=>e.level===t||e.loaded;V.forEach(t=>{const s=this.findNeighborTile(t,i);null!=s&&s!==this&&s.forAllSubtreeOnSide(N(t),i=>!!i.loaded&&(e(i,t),!0))}),G.forEach(t=>{const s=this.findNeighborTile(t,i)?.findCorner(O(t),e=>e.loaded);R(!s||oe(this,s,t)),s?.loaded&&e(s,t)})}_getNeighborLIJ(e,t){const i=F(t)?-1:W(t)?1:0,s=H(t)?-1:J(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 k(this.extent[3],e.extent[1],i);case 4:return k(this.extent[1],e.extent[3],i);case 2:return k(this.extent[2],e.extent[0],i)||k(this.extent[2],-e.extent[0],i);case 6:return k(this.extent[0],e.extent[2],i)||k(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(){z&&(R(this.loaded),this.renderData?.checkGeometryWaterproofness())}shouldHaveNeighbor(e){const t=this.extent,{rootTilesExtent:i}=this._surface,s=.25*(t[2]-t[0]);if(F(e)&&t[3]+s>=i[3])return!1;if(W(e)&&t[1]-s<=i[1])return!1;const n=this.surface.isGlobal;return!(!n&&H(e)&&t[0]-s<=i[0])&&!(!n&&J(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;d(this._lastPOI,e);const i=this._center[1].center,s=e[0]-i[0],n=e[1]-i[1],r=e[2]-i[2];this.distanceToPOI=s*s+n*n+r*r}updateOverlayParameters(e){const{renderData:t}=this;if(!t)return;const{overlays:i,longitudeCyclical:s}=e,n=t.overlay;if(0===i.length)this._clearTileOverlayData(0,n),this._clearTileOverlayData(1,n);else{const[e,t]=i,r=this.extent;_(e.extent,r,s)||m(r,e.extent,s)||m(r,t.extent,s)?(this._setOverlayData(i,s,r,0,n),this._setOverlayData(i,s,r,1,n)):(this._clearTileOverlayData(0,n),this._clearTileOverlayData(1,n))}}_setOverlayData(e,t,i,s,n){const r=e[s].extent,a=y(r),l=v(r);let o=i[0];if(t){o=t.minimalMonotonic(r[0],o);const e=t.minimalMonotonic(r[0],i[2]);o>e&&(o=e-(i[2]-i[0]))}if(0===a||0===l)return void n.setOffsetAndScale(s,0,0,1,1);const h=y(i)/a,d=v(i)/l,u=(o-r[0])/a,c=(i[1]-r[1])/l;n.setOffsetAndScale(s,u,c,h,d)}_clearTileOverlayData(e,t){t.setOffsetAndScale(e,-1,-1,-1,-1)}}function te(e,t,i,s){const n=0===i?ne.acquire():se.acquire();return n.init(e,t,i,s),n}function ie(e){e.dispose(),b(e)?ne.release(e):T(e)&&se.release(e)}const se=new s(()=>new j),ne=new s(()=>new D),re=new x;function ae(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 le(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]}function oe(e,t,i){return null!=e&&null!=t&&t!==e&&(e.level>=t.level?he(e,t,i):he(t,e,O(i)))}function he(e,t,i){R(e.level>=t.level);const s=X(i),n=Y(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=k(l[0],o[0],h)||e.surface.isGlobal&&k(l[0],-o[0],h),u=k(l[1],o[1],h);if(d&&u)return!0;if(e.level===t.level)return R(!1),!1;if(!d&&!u)return R(!1),!1;const c=d?de(a[1],a[3],r[1],r[3],h):de(a[0],a[2],r[0],r[2],h);return R(c),c}function de(e,t,i,s,n){return e-n<=i&&i<=s&&s<=t+n}const ue=u(),ce=u(),ge=u(),pe=u();export{ee as Tile,oe as isCornerNeighbor,le 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/5.0/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,subclass as h}from"../../../core/accessorSupport/decorators.js";import{copy as a,multiply as p,invert as u,transpose as l,frustum as _,equals as v,lookAt as c}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{e as m,h as f,D as x,d as M,m as D,a as j,g as R,x as P,w as V,j as F,b as C,f as b,n as S,E as T}from"../../../chunks/vec32.js";import{create as I,UNIT_Z as A}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{s as E,e as O,a as U,f as H,g as k,t as z}from"../../../chunks/vec42.js";import{fromValues as W,create as Y}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{create as L,copy as X,fromMatrix as q}from"../../../geometry/support/frustum.js";import{create as G}from"../../../geometry/support/ray.js";import{projectPointSignedLength as N}from"../../../geometry/support/vector.js";import{viewAngle as B}from"../state/utils/viewUtils.js";import{fovd2fovx as J,fovx2fovd as K,fovd2fovy as Q,fovy2fovd as Z}from"../webgl-engine/lib/fov.js";var $;let tt=$=class extends i{constructor(t){super(t),this._ray=G(),this._viewport=W(0,0,1,1),this._padding=W(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=Y(),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=E(Y(),this._viewport,1/this.pixelRatio),i=this._get("screenViewport");return i&&O(t,i)?i:t}get screenPadding(){if(1===this.pixelRatio)return this._padding;const t=E(Y(),this._padding,1/this.pixelRatio),i=this._get("screenPadding");return i&&O(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){U(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]),H(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 J(this._fov,this.width,this.height)}set fovX(t){this._fov=K(t,this.width,this.height),this._viewProjectionDirty=!0,this._frustumDirty=!0}get fovY(){return Q(this._fov,this.width,this.height)}set fovY(t){this._fov=Z(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&&v(l,u)?l:u}copyFrom(t){M(this._ray.origin,t.eye),this.center=t.center,this.up=t.up,H(this._viewport,t.viewport),this.notifyChange("_viewport"),H(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||(X(this._frustum,t.frustum),this._frustumDirty=!1),i._viewInverseTransposeMatrixDirty?this._viewInverseTransposeMatrixDirty=!0:(a(this._viewInverseTransposeMatrix,t.viewInverseTransposeMatrix),this._viewInverseTransposeMatrixDirty=!1),H(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 $).copyFrom(this)}equals(t){return D(this.eye,t.eye)&&D(this.center,t.center)&&D(this.up,t.up)&&U(this._viewport,t.viewport)&&U(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||k(t.screenPadding,this.screenPadding)>=i||k(this.screenViewport,t.screenViewport)>=i||this.row!==t.row||this.column!==t.column||this.rows!==t.rows||this.columns!==t.columns)return!1;j(st,t.eye,t.center),j(ot,this.eye,this.center);const e=R(st,ot),r=P(st),s=P(ot),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(N(this.viewForward,m(st,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!==et&&M(et,t),et[3]=1,z(et,et,this.projectionMatrix);const e=Math.abs(et[3]);F(et,et,1/e);const s=this.fullViewport;i[0]=r(0,s[0]+s[2],.5+.5*et[0]),i[1]=r(0,s[1]+s[3],.5+.5*et[1]),i[2]=.5*(et[2]+1),i[3]=e}unapplyProjection(t,i){const e=this.fullViewport;et[0]=(t[0]/(e[0]+e[2])*2-1)*t[3],et[1]=(t[1]/(e[1]+e[3])*2-1)*t[3],et[2]=(2*t[2]-1)*t[3],et[3]=t[3],null!=this.inverseProjectionMatrix&&(z(et,et,this.inverseProjectionMatrix),i[0]=et[0],i[1]=et[1],i[2]=et[2])}projectToScreen(t,i){return this.projectToRenderScreen(t,nt),this.renderToScreen(nt,i),i}projectToRenderScreen(t,i){if(et[0]=t[0],et[1]=t[1],et[2]=t[2],et[3]=1,z(et,et,this.viewProjectionMatrix),0===et[3])return null;const e=et;F(e,e,1/Math.abs(et[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,nt),i)}unprojectFromRenderScreen(t,i){if(p(rt,this.projectionMatrix,this.viewMatrix),!u(rt,rt))return null;const e=this.fullViewport;return et[0]=2*(t[0]-e[0])/e[2]-1,et[1]=2*(t[1]-e[1])/e[3]-1,et[2]=2*t[2]-1,et[3]=1,z(et,et,rt),0===et[3]?null:(i[0]=et[0]/et[3],i[1]=et[1]/et[3],i[2]=et[2]/et[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}sphereFrustumCoverage(t,i){const{center:e,eye:r,distance:s,fovY:o}=this,n=Math.abs(Math.PI/2-B(i,e,r));return t.frustumCoverage(n,s,o)}_computeUpGlobal(){m(st,this.center,this.eye);const t=C(this.center);t<1?D(this._up,A)&&(M(this._up,A),this._markViewDirty(),this.notifyChange("_up")):Math.abs(R(st,this.center))>.9999*C(st)*t||(b(ot,st,this.center),b(ot,ot,st),S(ot,ot),D(this._up,ot)||(M(this._up,ot),this.notifyChange("_up"),this._markViewDirty()))}_computeUpLocal(){T(st,this.eye,this.center),Math.abs(st[2])<=.9999&&(F(st,st,st[2]),f(st,-st[0],-st[1],1-st[2]),S(st,st),D(this._up,st)||(M(this._up,st),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&&(q(this.viewMatrix,this.projectionMatrix,this._frustum),this._frustumDirty=!1)}_ensureViewClean(){this._viewDirty&&(c(this._viewMatrix,this.eye,this.center,this.up),this.notifyChange("_viewMatrix"),this._viewDirty=!1,this._viewInverseTransposeMatrixDirty=!0)}};t([n()],tt.prototype,"_viewport",void 0),t([n()],tt.prototype,"_padding",void 0),t([n()],tt.prototype,"_fov",void 0),t([n()],tt.prototype,"_nearFar",void 0),t([n()],tt.prototype,"_viewDirty",void 0),t([n()],tt.prototype,"_viewMatrix",void 0),t([n()],tt.prototype,"_pixelRatio",void 0),t([n()],tt.prototype,"pixelRatio",null),t([n()],tt.prototype,"row",void 0),t([n()],tt.prototype,"column",void 0),t([n()],tt.prototype,"_rows",void 0),t([n()],tt.prototype,"rows",null),t([n()],tt.prototype,"_columns",void 0),t([n()],tt.prototype,"columns",null),t([n()],tt.prototype,"eye",null),t([n()],tt.prototype,"center",null),t([n()],tt.prototype,"_center",void 0),t([n()],tt.prototype,"up",null),t([n()],tt.prototype,"_up",void 0),t([n()],tt.prototype,"viewMatrix",null),t([n({readOnly:!0})],tt.prototype,"viewForward",null),t([n({readOnly:!0})],tt.prototype,"viewUp",null),t([n({readOnly:!0})],tt.prototype,"viewRight",null),t([n({readOnly:!0})],tt.prototype,"nearFar",null),t([n()],tt.prototype,"near",null),t([n()],tt.prototype,"far",null),t([n()],tt.prototype,"viewport",null),t([n({readOnly:!0})],tt.prototype,"screenViewport",null),t([n({readOnly:!0})],tt.prototype,"screenPadding",null),t([n()],tt.prototype,"x",null),t([n()],tt.prototype,"y",null),t([n()],tt.prototype,"width",null),t([n()],tt.prototype,"height",null),t([n()],tt.prototype,"fullWidth",null),t([n()],tt.prototype,"fullHeight",null),t([n({readOnly:!0})],tt.prototype,"_aspect",null),t([n()],tt.prototype,"padding",null),t([n({readOnly:!0})],tt.prototype,"projectionMatrix",null),t([n({readOnly:!0})],tt.prototype,"inverseProjectionMatrix",null),t([n()],tt.prototype,"fov",null),t([n()],tt.prototype,"fovX",null),t([n()],tt.prototype,"fovY",null),t([n()],tt.prototype,"viewInverseTransposeMatrix",null),t([n({readOnly:!0})],tt.prototype,"_projectionMatrixInternal",null),t([n()],tt.prototype,"relativeElevation",void 0),tt=$=t([h("esri.views.3d.webgl.RenderCamera")],tt);const it=tt,et=Y(),rt=w(),st=I(),ot=I(),nt=o();export{it 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,subclass as h}from"../../../core/accessorSupport/decorators.js";import{copy as a,multiply as p,invert as u,transpose as l,frustum as _,equals as v,lookAt as c}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{e as m,h as f,B as x,d as M,m as D,a as j,g as R,H as P,G as V,j as F,b as C,f as b,n as S,C as T}from"../../../chunks/vec32.js";import{create as I,UNIT_Z as A}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{s as E,e as O,a as U,f as H,g as k,t as z}from"../../../chunks/vec42.js";import{fromValues as W,create as Y}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{create as G,copy as L,fromMatrix as X}from"../../../geometry/support/frustum.js";import{create as q}from"../../../geometry/support/ray.js";import{projectPointSignedLength as B}from"../../../geometry/support/vector.js";import{viewAngle as N}from"../state/utils/viewUtils.js";import{fovd2fovx as J,fovx2fovd as K,fovd2fovy as Q,fovy2fovd as Z}from"../webgl-engine/lib/fov.js";var $;let tt=$=class extends i{constructor(t){super(t),this._ray=q(),this._viewport=W(0,0,1,1),this._padding=W(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=G(),this._fullViewport=Y(),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=E(Y(),this._viewport,1/this.pixelRatio),i=this._get("screenViewport");return i&&O(t,i)?i:t}get screenPadding(){if(1===this.pixelRatio)return this._padding;const t=E(Y(),this._padding,1/this.pixelRatio),i=this._get("screenPadding");return i&&O(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){U(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]),H(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 J(this._fov,this.width,this.height)}set fovX(t){this._fov=K(t,this.width,this.height),this._viewProjectionDirty=!0,this._frustumDirty=!0}get fovY(){return Q(this._fov,this.width,this.height)}set fovY(t){this._fov=Z(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&&v(l,u)?l:u}copyFrom(t){M(this._ray.origin,t.eye),this.center=t.center,this.up=t.up,H(this._viewport,t.viewport),this.notifyChange("_viewport"),H(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||(L(this._frustum,t.frustum),this._frustumDirty=!1),i._viewInverseTransposeMatrixDirty?this._viewInverseTransposeMatrixDirty=!0:(a(this._viewInverseTransposeMatrix,t.viewInverseTransposeMatrix),this._viewInverseTransposeMatrixDirty=!1),H(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 $).copyFrom(this)}equals(t){return D(this.eye,t.eye)&&D(this.center,t.center)&&D(this.up,t.up)&&U(this._viewport,t.viewport)&&U(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||k(t.screenPadding,this.screenPadding)>=i||k(this.screenViewport,t.screenViewport)>=i||this.row!==t.row||this.column!==t.column||this.rows!==t.rows||this.columns!==t.columns)return!1;j(st,t.eye,t.center),j(ot,this.eye,this.center);const e=R(st,ot),r=P(st),s=P(ot),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(B(this.viewForward,m(st,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!==et&&M(et,t),et[3]=1,z(et,et,this.projectionMatrix);const e=Math.abs(et[3]);F(et,et,1/e);const s=this.fullViewport;i[0]=r(0,s[0]+s[2],.5+.5*et[0]),i[1]=r(0,s[1]+s[3],.5+.5*et[1]),i[2]=.5*(et[2]+1),i[3]=e}unapplyProjection(t,i){const e=this.fullViewport;et[0]=(t[0]/(e[0]+e[2])*2-1)*t[3],et[1]=(t[1]/(e[1]+e[3])*2-1)*t[3],et[2]=(2*t[2]-1)*t[3],et[3]=t[3],null!=this.inverseProjectionMatrix&&(z(et,et,this.inverseProjectionMatrix),i[0]=et[0],i[1]=et[1],i[2]=et[2])}projectToScreen(t,i){return this.projectToRenderScreen(t,nt),this.renderToScreen(nt,i),i}projectToRenderScreen(t,i){if(et[0]=t[0],et[1]=t[1],et[2]=t[2],et[3]=1,z(et,et,this.viewProjectionMatrix),0===et[3])return null;const e=et;F(e,e,1/Math.abs(et[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,nt),i)}unprojectFromRenderScreen(t,i){if(p(rt,this.projectionMatrix,this.viewMatrix),!u(rt,rt))return null;const e=this.fullViewport;return et[0]=2*(t[0]-e[0])/e[2]-1,et[1]=2*(t[1]-e[1])/e[3]-1,et[2]=2*t[2]-1,et[3]=1,z(et,et,rt),0===et[3]?null:(i[0]=et[0]/et[3],i[1]=et[1]/et[3],i[2]=et[2]/et[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}sphereFrustumCoverage(t,i){const{center:e,eye:r,distance:s,fovY:o}=this,n=Math.abs(Math.PI/2-N(i,e,r));return t.frustumCoverage(n,s,o)}_computeUpGlobal(){m(st,this.center,this.eye);const t=C(this.center);t<1?D(this._up,A)&&(M(this._up,A),this._markViewDirty(),this.notifyChange("_up")):Math.abs(R(st,this.center))>.9999*C(st)*t||(b(ot,st,this.center),b(ot,ot,st),S(ot,ot),D(this._up,ot)||(M(this._up,ot),this.notifyChange("_up"),this._markViewDirty()))}_computeUpLocal(){T(st,this.eye,this.center),Math.abs(st[2])<=.9999&&(F(st,st,st[2]),f(st,-st[0],-st[1],1-st[2]),S(st,st),D(this._up,st)||(M(this._up,st),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&&(X(this.viewMatrix,this.projectionMatrix,this._frustum),this._frustumDirty=!1)}_ensureViewClean(){this._viewDirty&&(c(this._viewMatrix,this.eye,this.center,this.up),this.notifyChange("_viewMatrix"),this._viewDirty=!1,this._viewInverseTransposeMatrixDirty=!0)}};t([n()],tt.prototype,"_viewport",void 0),t([n()],tt.prototype,"_padding",void 0),t([n()],tt.prototype,"_fov",void 0),t([n()],tt.prototype,"_nearFar",void 0),t([n()],tt.prototype,"_viewDirty",void 0),t([n()],tt.prototype,"_viewMatrix",void 0),t([n()],tt.prototype,"_pixelRatio",void 0),t([n()],tt.prototype,"pixelRatio",null),t([n()],tt.prototype,"row",void 0),t([n()],tt.prototype,"column",void 0),t([n()],tt.prototype,"_rows",void 0),t([n()],tt.prototype,"rows",null),t([n()],tt.prototype,"_columns",void 0),t([n()],tt.prototype,"columns",null),t([n()],tt.prototype,"eye",null),t([n()],tt.prototype,"center",null),t([n()],tt.prototype,"_center",void 0),t([n()],tt.prototype,"up",null),t([n()],tt.prototype,"_up",void 0),t([n()],tt.prototype,"viewMatrix",null),t([n({readOnly:!0})],tt.prototype,"viewForward",null),t([n({readOnly:!0})],tt.prototype,"viewUp",null),t([n({readOnly:!0})],tt.prototype,"viewRight",null),t([n({readOnly:!0})],tt.prototype,"nearFar",null),t([n()],tt.prototype,"near",null),t([n()],tt.prototype,"far",null),t([n()],tt.prototype,"viewport",null),t([n({readOnly:!0})],tt.prototype,"screenViewport",null),t([n({readOnly:!0})],tt.prototype,"screenPadding",null),t([n()],tt.prototype,"x",null),t([n()],tt.prototype,"y",null),t([n()],tt.prototype,"width",null),t([n()],tt.prototype,"height",null),t([n()],tt.prototype,"fullWidth",null),t([n()],tt.prototype,"fullHeight",null),t([n({readOnly:!0})],tt.prototype,"_aspect",null),t([n()],tt.prototype,"padding",null),t([n({readOnly:!0})],tt.prototype,"projectionMatrix",null),t([n({readOnly:!0})],tt.prototype,"inverseProjectionMatrix",null),t([n()],tt.prototype,"fov",null),t([n()],tt.prototype,"fovX",null),t([n()],tt.prototype,"fovY",null),t([n()],tt.prototype,"viewInverseTransposeMatrix",null),t([n({readOnly:!0})],tt.prototype,"_projectionMatrixInternal",null),t([n()],tt.prototype,"relativeElevation",void 0),tt=$=t([h("esri.views.3d.webgl.RenderCamera")],tt);const it=tt,et=Y(),rt=w(),st=I(),ot=I(),nt=o();export{it as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import"../../../../core/has.js";import e from"../../../../core/Logger.js";import{ManagedColorAttachment as t}from"../../webgl/ManagedColorAttachment.js";import{ManagedDepthTexture as a}from"../../webgl/ManagedDepthTexture.js";import r from"../../webgl/ManagedFBO.js";import{isDepthFormat as c,formatString as h,DepthTextureFormats as s,ColorFormats as i}from"./FBOCacheFormats.js";import{FBOPool as o}from"./FBOPool.js";import{DepthStencilAttachment as n,ColorAttachment0 as l}from"../../../webgl/enums.js";import{FramebufferObject as u}from"../../../webgl/FramebufferObject.js";import{Texture as m}from"../../../webgl/Texture.js";class d{constructor(e){this.rctx=e,this._interactive=!1,this._usage=new Map,this._acquired=new Set,this._cache=new o(e.newCache,"FBOCache"),this._depthCache=new o(e.newCache,"DepthAttachmentCache"),this._colorCache=new o(e.newCache,"ColorAttachmentCache")}destroy(){this._cache.destroy(),this._depthCache.destroy(),this._colorCache.destroy()}clean(){this._cache.clean(),this._colorCache.clean(),this._depthCache.clean()}frameStart(){this._cache.frame(),this._colorCache.frame(),this._depthCache.frame(),this.debugCallback?.(),this._usage.clear()}frameEnd(){const{debugCallback:e}=this;e&&this._acquired.forEach(t=>e(t.name,t.fbo,this._usage))}get usedMemory(){return Array.from(this._acquired.values()).reduce((e,t)=>e+t.usedMemory,this._cache.usedMemory+this._colorCache.usedMemory+this._depthCache.usedMemory)}set interactive(e){this._cache.interactive=this._colorCache.interactive=this._depthCache.interactive=e,this._interactive=e}get interactive(){return this._interactive}acquire(t,a,s,i=5){const o=f(i,t,a);let m=this._cache.pop(o);const{rctx:d}=this;if(m){m.retain(),m.setName(s);const t=m.getAttachment(n);t&&(t.name=g);const a=m.getAttachment(l);a&&(a.name=_(0));const r=m.fbo;r?d.temporaryBindFramebufferObject(r,()=>{d.setDrawBuffers([l]),d.unbindTexture(r.colorTexture)}):e.getLogger("esri.views.3d.webgl-engine.core.FBOCache").errorOnce("Encountered an invalid cached framebuffer")}else{const e=new u(d),h=(e,r,c)=>{r??=5;const h=this._acquireColor(r,t,a,c??_(e-l));return this.rctx.unbindTexture(h.attachment),m.attachColor(h,e),h.release(),m},p=e=>{e??=13;const r=this.acquireDepth(e,t,a,g);return m.attachDepth(r),r.release(),m},f=()=>{if(!m)return;this.debugCallback?.(m.name,m.fbo),this._acquired.delete(m);const e=c(i);e&&null!=m.getAttachment(n)||!e&&null!=m.getAttachment(l)?(e?(m.fbo?.invalidateAttachments([n]),m.detachAllColors()):(m.fbo?.invalidateAttachments([l]),m.detachAllButColor0()),this._cache.put(m)):m.dispose()};m=new r(o,s,e,h,p,f),c(i)?m.acquireDepth(i):m.acquireColor(l,i)}return this._trackUsage(m,"fbo "+h(i),t,a),this._trackHandle(m)}acquireDepth(e,t,r,c){const i=f(e,t,r);let o=this._depthCache.pop(i);if(o)o.retain(),o.attachment.setShadowFiltering(!1);else{const c=new m(this.rctx,{...s[e],width:t,height:r});o=new a(i,c,()=>this._depthCache.put(o))}return o.name=c,this._trackUsage(o,"depth "+h(e),t,r),o}_acquireColor(e,a,r,c){const s=f(e,a,r);let o=this._colorCache.pop(s);if(o)o.retain();else{const c=new m(this.rctx,{...i[e],width:a,height:r,isImmutable:!0});o=new t(s,c,()=>this._colorCache.put(o))}return o.name=c,this._trackUsage(o,"color "+h(e),a,r),o}_trackHandle(e){return this._acquired.add(e),e}_trackUsage(e,t,a,r){this.debugCallback&&(this._usage.has(e)?this._usage.get(e)[2].push(e.name):this._usage.set(e,[t,`${a}x${r}`,[e.name]]))}get test(){return null}}function _(e=0){return`color${e}`}const g="depth",p=new r("default","default",null,()=>p,()=>p,()=>{});function f(e,t,a){return`${t}x${a}:${e}`}p.release=()=>!1;export{d as FBOCache,p as defaultWebGLFBO};
5
+ import"../../../../core/has.js";import e from"../../../../core/Logger.js";import{ManagedColorAttachment as t}from"../../webgl/ManagedColorAttachment.js";import{ManagedDepthTexture as a}from"../../webgl/ManagedDepthTexture.js";import r from"../../webgl/ManagedFBO.js";import{isDepthFormat as c,formatString as h,DepthTextureFormats as s,ColorFormats as i}from"./FBOCacheFormats.js";import{FBOPool as o}from"./FBOPool.js";import{DepthStencilAttachment as n,ColorAttachment0 as l}from"../../../webgl/enums.js";import{FramebufferObject as u}from"../../../webgl/FramebufferObject.js";import{Texture as m}from"../../../webgl/Texture.js";class d{constructor(e){this.rctx=e,this._interactive=!1,this._usage=new Map,this._acquired=new Set,this._cache=new o(e.newCache,"FBOCache"),this._depthCache=new o(e.newCache,"DepthAttachmentCache"),this._colorCache=new o(e.newCache,"ColorAttachmentCache")}destroy(){this._cache.destroy(),this._depthCache.destroy(),this._colorCache.destroy()}clean(){this._cache.clean(),this._colorCache.clean(),this._depthCache.clean()}frameStart(){this._cache.frame(),this._colorCache.frame(),this._depthCache.frame(),this.debugCallback?.(),this._usage.clear()}frameEnd(){const{debugCallback:e}=this;e&&this._acquired.forEach(t=>e(t.name,t.fbo,this._usage))}get usedMemory(){return Array.from(this._acquired.values()).reduce((e,t)=>e+t.usedMemory,this._cache.usedMemory+this._colorCache.usedMemory+this._depthCache.usedMemory)}set interactive(e){this._cache.interactive=this._colorCache.interactive=this._depthCache.interactive=e,this._interactive=e}get interactive(){return this._interactive}acquire(t,a,s,i=5){const o=f(i,t,a);let m=this._cache.pop(o);const{rctx:d}=this;if(m){m.retain(),m.setName(s);const t=m.getAttachment(n);t&&(t.name=g);const a=m.getAttachment(l);a&&(a.name=_(0));const r=m.fbo;r?d.temporaryBindFramebufferObject(r,()=>{d.setDrawBuffers([l]),d.unbindTexture(r.colorTexture)}):e.getLogger("esri.views.3d.webgl-engine.core.FBOCache").errorOnce("Encountered an invalid cached framebuffer")}else{const e=new u(d),h=(e,r,c)=>{r??=5;const h=this._acquireColor(r,t,a,c??_(e-l));return this.rctx.unbindTexture(h.attachment),m.attachColor(h,e),h.release(),m},p=e=>{e??=14;const r=this.acquireDepth(e,t,a,g);return m.attachDepth(r),r.release(),m},f=()=>{if(!m)return;this.debugCallback?.(m.name,m.fbo),this._acquired.delete(m);const e=c(i);e&&null!=m.getAttachment(n)||!e&&null!=m.getAttachment(l)?(e?(m.fbo?.invalidateAttachments([n]),m.detachAllColors()):(m.fbo?.invalidateAttachments([l]),m.detachAllButColor0()),this._cache.put(m)):m.dispose()};m=new r(o,s,e,h,p,f),c(i)?m.acquireDepth(i):m.acquireColor(l,i)}return this._trackUsage(m,"fbo "+h(i),t,a),this._trackHandle(m)}acquireDepth(e,t,r,c){const i=f(e,t,r);let o=this._depthCache.pop(i);if(o)o.retain(),o.attachment.setShadowFiltering(!1);else{const c=new m(this.rctx,{...s[e],width:t,height:r});o=new a(i,c,()=>this._depthCache.put(o))}return o.name=c,this._trackUsage(o,"depth "+h(e),t,r),o}_acquireColor(e,a,r,c){const s=f(e,a,r);let o=this._colorCache.pop(s);if(o)o.retain();else{const c=new m(this.rctx,{...i[e],width:a,height:r,isImmutable:!0});o=new t(s,c,()=>this._colorCache.put(o))}return o.name=c,this._trackUsage(o,"color "+h(e),a,r),o}_trackHandle(e){return this._acquired.add(e),e}_trackUsage(e,t,a,r){this.debugCallback&&(this._usage.has(e)?this._usage.get(e)[2].push(e.name):this._usage.set(e,[t,`${a}x${r}`,[e.name]]))}get test(){return null}}function _(e=0){return`color${e}`}const g="depth",p=new r("default","default",null,()=>p,()=>p,()=>{});function f(e,t,a){return`${t}x${a}:${e}`}p.release=()=>!1;export{d as FBOCache,p as defaultWebGLFBO};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{SizedPixelFormat as e,PixelType as r,SizedDepthStencilFormat as n,SizedDepthFormat as t}from"../../../webgl/enums.js";import{TextureDescriptor as a}from"../../../webgl/TextureDescriptor.js";import{isSizedDepthFormat as o}from"../../../webgl/textureUtils.js";function s(e){switch(e){case 0:return"R8UNORM";case 1:return"R8UINT";case 2:return"RG8UNORM";case 3:return"RG8UINT";case 4:return"RGBA4UNORM";case 5:return"RGBA8UNORM";case 6:return"RGBA8UNORM_MIPMAP";case 7:return"R16FLOAT";case 8:return"RGBA16FLOAT";case 9:return"R32FLOAT";case 10:return"RG32FLOAT";case 11:return"RGBA32UINT";case 12:return"COUNT"}}function T(e){switch(e){case 12:return"DEPTH16";case 13:return"DEPTH24_STENCIL8"}}function i(e){return p(e)?T(e):s(e)}function p(e){return e>=12}const m=new a;m.pixelFormat=6403,m.internalFormat=e.R8,m.wrapMode=33071;const F=new a;F.pixelFormat=36244,F.internalFormat=e.R8UI,F.wrapMode=33071,F.samplingMode=9728;const c=new a;c.pixelFormat=33319,c.internalFormat=e.RG8,c.wrapMode=33071;const N=new a;N.pixelFormat=33320,N.internalFormat=e.RG8UI,N.wrapMode=33071,N.samplingMode=9728;const l=new a;l.internalFormat=e.RGBA4,l.dataType=r.UNSIGNED_SHORT_4_4_4_4,l.wrapMode=33071;const M=new a;M.wrapMode=33071;const R=new a;R.wrapMode=33071,R.samplingMode=9987,R.hasMipmap=!0,R.maxAnisotropy=8;const u=new a;u.pixelFormat=6403,u.dataType=r.HALF_FLOAT,u.internalFormat=e.R16F,u.samplingMode=9728;const w=new a;w.dataType=r.HALF_FLOAT,w.internalFormat=e.RGBA16F,w.wrapMode=33071;const _=new a;_.pixelFormat=6403,_.dataType=r.FLOAT,_.internalFormat=e.R32F,_.samplingMode=9728;const O=new a;O.pixelFormat=33319,O.dataType=r.FLOAT,O.internalFormat=e.RG32F,O.samplingMode=9728;const d=new a;d.pixelFormat=36249,d.dataType=r.UNSIGNED_INT,d.internalFormat=e.RGBA32UI,d.samplingMode=9728,d.wrapMode=33071;const E={0:m,1:F,2:c,3:N,4:l,5:M,6:R,7:u,8:w,9:_,10:O,11:d,12:null},A={[t.DEPTH_COMPONENT16]:r.UNSIGNED_SHORT,[t.DEPTH_COMPONENT24]:r.UNSIGNED_INT,[t.DEPTH_COMPONENT32F]:r.FLOAT,[n.DEPTH24_STENCIL8]:r.UNSIGNED_INT_24_8,[n.DEPTH32F_STENCIL8]:r.FLOAT_32_UNSIGNED_INT_24_8_REV},I={13:G(n.DEPTH24_STENCIL8),12:G(t.DEPTH_COMPONENT16)};function G(e){const r=new a;return r.pixelFormat=o(e)?6402:34041,r.dataType=A[e],r.samplingMode=9728,r.wrapMode=33071,r.internalFormat=e,r.hasMipmap=!1,r.isImmutable=!0,r}export{E as ColorFormats,I as DepthTextureFormats,i as formatString,p as isDepthFormat};
5
+ import{SizedPixelFormat as e,PixelType as r,SizedDepthStencilFormat as n,SizedDepthFormat as t}from"../../../webgl/enums.js";import{TextureDescriptor as a}from"../../../webgl/TextureDescriptor.js";import{isSizedDepthFormat as o}from"../../../webgl/textureUtils.js";function s(e){switch(e){case 0:return"R8UNORM";case 1:return"R8UINT";case 2:return"RG8UNORM";case 3:return"RG8UINT";case 4:return"RGBA4UNORM";case 5:return"RGBA8UNORM";case 6:return"RGBA8UNORM_MIPMAP";case 7:return"R16FLOAT";case 8:return"RGBA16FLOAT";case 9:return"RGBA32FLOAT";case 10:return"R32FLOAT";case 11:return"RG32FLOAT";case 12:return"RGBA32UINT";case 13:return"COUNT"}}function T(e){switch(e){case 13:return"DEPTH16";case 14:return"DEPTH24_STENCIL8"}}function p(e){return i(e)?T(e):s(e)}function i(e){return e>=13}const F=new a;F.pixelFormat=6403,F.internalFormat=e.R8,F.wrapMode=33071;const m=new a;m.pixelFormat=36244,m.internalFormat=e.R8UI,m.wrapMode=33071,m.samplingMode=9728;const c=new a;c.pixelFormat=33319,c.internalFormat=e.RG8,c.wrapMode=33071;const N=new a;N.pixelFormat=33320,N.internalFormat=e.RG8UI,N.wrapMode=33071,N.samplingMode=9728;const l=new a;l.internalFormat=e.RGBA4,l.dataType=r.UNSIGNED_SHORT_4_4_4_4,l.wrapMode=33071;const M=new a;M.wrapMode=33071;const R=new a;R.wrapMode=33071,R.samplingMode=9987,R.hasMipmap=!0,R.maxAnisotropy=8;const w=new a;w.pixelFormat=6403,w.dataType=r.HALF_FLOAT,w.internalFormat=e.R16F,w.samplingMode=9728;const u=new a;u.dataType=r.HALF_FLOAT,u.internalFormat=e.RGBA16F,u.wrapMode=33071;const O=new a;O.dataType=r.FLOAT,O.internalFormat=e.RGBA32F,O.wrapMode=33071;const _=new a;_.pixelFormat=6403,_.dataType=r.FLOAT,_.internalFormat=e.R32F,_.samplingMode=9728;const d=new a;d.pixelFormat=33319,d.dataType=r.FLOAT,d.internalFormat=e.RG32F,d.samplingMode=9728;const A=new a;A.pixelFormat=36249,A.dataType=r.UNSIGNED_INT,A.internalFormat=e.RGBA32UI,A.samplingMode=9728,A.wrapMode=33071;const E={0:F,1:m,2:c,3:N,4:l,5:M,6:R,7:w,8:u,9:O,10:_,11:d,12:A,13:null},G={[t.DEPTH_COMPONENT16]:r.UNSIGNED_SHORT,[t.DEPTH_COMPONENT24]:r.UNSIGNED_INT,[t.DEPTH_COMPONENT32F]:r.FLOAT,[n.DEPTH24_STENCIL8]:r.UNSIGNED_INT_24_8,[n.DEPTH32F_STENCIL8]:r.FLOAT_32_UNSIGNED_INT_24_8_REV},I={14:U(n.DEPTH24_STENCIL8),13:U(t.DEPTH_COMPONENT16)};function U(e){const r=new a;return r.pixelFormat=o(e)?6402:34041,r.dataType=G[e],r.samplingMode=9728,r.wrapMode=33071,r.internalFormat=e,r.hasMipmap=!1,r.isImmutable=!0,r}export{E as ColorFormats,I as DepthTextureFormats,p as formatString,i as isDepthFormat};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import{property as t,subclass as s}from"../../../../../core/accessorSupport/decorators.js";import{RenderCategory as r,InternalRenderCategory as i}from"../../../webgl.js";import o from"../../../webgl/RenderNode.js";import{F as n}from"../../../../../chunks/FocusAreaMask.glsl.js";import{FocusAreaMaskTechnique as a}from"./FocusAreaMaskTechnique.js";import{Pos3 as h}from"../../lib/DefaultVertexBufferLayouts.js";import{VertexArrayObject as c}from"../../lib/VertexArrayObject.js";import{DepthStencilAttachment as l,PrimitiveType as u}from"../../../../webgl/enums.js";import{noParameters as p}from"../../../../webgl/NoParameters.js";import{VertexBuffer as m}from"../../../../webgl/VertexBuffer.js";let d=class extends o{constructor(e){super({...e,view:e.focusAreasView.view}),this.consumes={required:[r.TRANSPARENT]},this.produces=i.FOCUSAREA,this._vaos=new Array,this._counts=new Array,this._origins=new Array,this._maskParameters=new n}initialize(){this.updateGeometries()}destroy(){this._vaos.forEach(e=>e.dispose()),this._vaos.length=this._counts.length=this._origins.length=0}precompile(){this.techniques.precompile(a)}render(e){const t=this.techniques.get(a),s=this.bindParameters,o=s.camera,n=o.fullViewport[2],h=o.fullViewport[3];if(!t.compiled||!this._vaos)return void this.requestRender(1);const c=e.find(({name:e})=>e===r.TRANSPARENT),m=this.renderingContext,d=this.fboCache.acquire(n,h,i.FOCUSAREA,2);this.view.stage.renderer.occludedRequiresStencil?(d.acquireDepth(13),m.blitFramebuffer(c.fbo,d.fbo,256)):d.attachDepth(c.getAttachment(l)),m.bindFramebuffer(d.fbo),m.setClearColor(0,0,0,1),m.clear(17408),m.setViewport(0,0,n,h);const f=m.bindTechnique(t,s);m.setFaceCullingEnabled(!1),m.setStencilTestEnabled(!0),m.setStencilOpSeparate(1028,7680,34055,7680),m.setStencilOpSeparate(1029,7680,34056,7680),m.setDepthWriteEnabled(!1);for(let r=0;r<this._vaos.length;r++){const e=this._vaos[r],t=this._counts[r];this._maskParameters.origin=this._origins[r],f.bindDraw(s,p,this._maskParameters),m.bindVAO(e),m.setDepthTestEnabled(!0),m.setStencilWriteMask(255),m.setStencilFunction(519,0,255),m.setColorMask(!1,!1,!1,!1),m.drawArrays(u.TRIANGLES,0,t),m.setDepthTestEnabled(!1),m.setStencilWriteMask(0),m.setStencilFunction(517,0,255),m.setColorMask(!0,!0,!0,!0),m.drawArrays(u.TRIANGLES,0,t)}return d}updateGeometries(){if(!this.view.stage)return;this._vaos.forEach(e=>e.dispose()),this._vaos.length=this._counts.length=this._origins.length=0;this.focusAreasView.volumes.forEach(e=>{const t=new Array;let s=0,r=0;e.geometryVolumes.forEach(e=>{const i=e.indicesBottom;s+=i.length;for(let s=0;s<i.length;s++)t.push(e.positions[3*(i[s]-1)]),t.push(e.positions[3*(i[s]-1)+1]),t.push(e.positions[3*(i[s]-1)+2]);const o=e.indicesExtruded;r+=o.length;for(let s=0;s<o.length;s++)t.push(e.positions[3*o[s]]),t.push(e.positions[3*o[s]+1]),t.push(e.positions[3*o[s]+2])});const i=new c(this.renderingContext,new m(this.renderingContext,h,new Float32Array(t)));this._vaos.push(i),this._counts.push(s+r),this._origins.push(e.origin)}),this.requestRender(1)}};e([t()],d.prototype,"consumes",void 0),e([t()],d.prototype,"produces",void 0),e([t({constructOnly:!0})],d.prototype,"focusAreasView",void 0),d=e([s("esri.views.3d.webgl-engine.effects.focusArea.FocusAreaMaskNode")],d);export{d as FocusAreaMaskNode};
5
+ import{__decorate as e}from"tslib";import{property as t,subclass as s}from"../../../../../core/accessorSupport/decorators.js";import{RenderCategory as r,InternalRenderCategory as i}from"../../../webgl.js";import o from"../../../webgl/RenderNode.js";import{F as n}from"../../../../../chunks/FocusAreaMask.glsl.js";import{FocusAreaMaskTechnique as a}from"./FocusAreaMaskTechnique.js";import{Pos3 as h}from"../../lib/DefaultVertexBufferLayouts.js";import{VertexArrayObject as c}from"../../lib/VertexArrayObject.js";import{DepthStencilAttachment as l,PrimitiveType as u}from"../../../../webgl/enums.js";import{noParameters as p}from"../../../../webgl/NoParameters.js";import{VertexBuffer as m}from"../../../../webgl/VertexBuffer.js";let d=class extends o{constructor(e){super({...e,view:e.focusAreasView.view}),this.consumes={required:[r.TRANSPARENT]},this.produces=i.FOCUSAREA,this._vaos=new Array,this._counts=new Array,this._origins=new Array,this._maskParameters=new n}initialize(){this.updateGeometries()}destroy(){this._vaos.forEach(e=>e.dispose()),this._vaos.length=this._counts.length=this._origins.length=0}precompile(){this.techniques.precompile(a)}render(e){const t=this.techniques.get(a),s=this.bindParameters,o=s.camera,n=o.fullViewport[2],h=o.fullViewport[3];if(!t.compiled||!this._vaos)return void this.requestRender(1);const c=e.find(({name:e})=>e===r.TRANSPARENT),m=this.renderingContext,d=this.fboCache.acquire(n,h,i.FOCUSAREA,2);this.view.stage.renderer.occludedRequiresStencil?(d.acquireDepth(14),m.blitFramebuffer(c.fbo,d.fbo,256)):d.attachDepth(c.getAttachment(l)),m.bindFramebuffer(d.fbo),m.setClearColor(0,0,0,1),m.clear(17408),m.setViewport(0,0,n,h);const f=m.bindTechnique(t,s);m.setFaceCullingEnabled(!1),m.setStencilTestEnabled(!0),m.setStencilOpSeparate(1028,7680,34055,7680),m.setStencilOpSeparate(1029,7680,34056,7680),m.setDepthWriteEnabled(!1);for(let r=0;r<this._vaos.length;r++){const e=this._vaos[r],t=this._counts[r];this._maskParameters.origin=this._origins[r],f.bindDraw(s,p,this._maskParameters),m.bindVAO(e),m.setDepthTestEnabled(!0),m.setStencilWriteMask(255),m.setStencilFunction(519,0,255),m.setColorMask(!1,!1,!1,!1),m.drawArrays(u.TRIANGLES,0,t),m.setDepthTestEnabled(!1),m.setStencilWriteMask(0),m.setStencilFunction(517,0,255),m.setColorMask(!0,!0,!0,!0),m.drawArrays(u.TRIANGLES,0,t)}return d}updateGeometries(){if(!this.view.stage)return;this._vaos.forEach(e=>e.dispose()),this._vaos.length=this._counts.length=this._origins.length=0;this.focusAreasView.volumes.forEach(e=>{const t=new Array;let s=0,r=0;e.geometryVolumes.forEach(e=>{const i=e.indicesBottom;s+=i.length;for(let s=0;s<i.length;s++)t.push(e.positions[3*(i[s]-1)]),t.push(e.positions[3*(i[s]-1)+1]),t.push(e.positions[3*(i[s]-1)+2]);const o=e.indicesExtruded;r+=o.length;for(let s=0;s<o.length;s++)t.push(e.positions[3*o[s]]),t.push(e.positions[3*o[s]+1]),t.push(e.positions[3*o[s]+2])});const i=new c(this.renderingContext,new m(this.renderingContext,h,new Float32Array(t)));this._vaos.push(i),this._counts.push(s+r),this._origins.push(e.origin)}),this.requestRender(1)}};e([t()],d.prototype,"consumes",void 0),e([t()],d.prototype,"produces",void 0),e([t({constructOnly:!0})],d.prototype,"focusAreasView",void 0),d=e([s("esri.views.3d.webgl-engine.effects.focusArea.FocusAreaMaskNode")],d);export{d as FocusAreaMaskNode};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import t from"../../../../../core/PooledArray.js";import{property as r,subclass as s}from"../../../../../core/accessorSupport/decorators.js";import{ZEROS as o}from"../../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{InternalRenderCategory as n}from"../../../webgl.js";import i from"../../../webgl/RenderNode.js";import{Blit as c}from"../blit/Blit.js";import{DepthStencilAttachment as d}from"../../../../webgl/enums.js";let l=class extends i{constructor(e){super(e),this.consumes={required:[n.OCCLUDED]},this.produces=n.OCCLUDED,this._blit=new c(e.view.stage.renderView.techniques,2)}precompile(){const e=this.view.stage.renderer;e.plugins.plugins.forEach(t=>{e.precompileSlots(t,10,12),t.material&&e.precompileOccludedSlots(t,h)})}render(e){const t=e.find(({name:e})=>e===this.produces);return this._renderOccludedAndTransparentStencil(t),this._renderOccludedComposite(t),t}_renderOccludedAndTransparentStencil(e){const t=this.view.stage.renderer,r=a;r.clear();for(const s of t.plugins.plugins)8&s.renderOccludedFlags&&r.push(s);0!==r.length&&(t.renderSlots(r,11),this._renderAndComposite(e,e.getAttachment(d),.5,()=>t.renderSlots(r,12),!1,!1),r.clear())}_renderOccludedComposite(e){const t=this.view.stage.renderer,r=a;r.clear();let s=0;for(const i of t.plugins.plugins){const e=i.renderOccludedFlags&u;s|=e,e&&r.push(i)}if(!s)return void r.clear();const o=this._getDepthStencilAttachment(e);let n=o.clearStencil;for(const i of h)s&i&&(this._renderAndComposite(e,o.depth,16===i?1:.5,()=>t.renderOccludedSlots(r,i),!0,n),n=!1);o.release(),r.clear()}_renderAndComposite(e,t,r,s,n,i){const c=this.renderingContext,{width:d,height:l}=e.fbo,a=this.fboCache.acquire(d,l,"tmp color");a.attachDepth(t),c.bindFramebuffer(a.fbo),c.clearFramebuffer(o,n,i),s(),a.detachDepth(),this._blit.blend(c,a,e,this.bindParameters,r),a.release()}_getDepthStencilAttachment(e){const{width:t,height:r}=e.fbo;if(!this.view.stage.renderer.occludedRequiresIntegratedMeshStencil){const e=this.fboCache.acquireDepth(13,t,r,"retained stencil");return{depth:e,release:()=>e.release(),clearStencil:!0}}const s=this.fboCache.acquire(t,r,"retained stencil",13);return this.renderingContext.blitFramebuffer(e.fbo,s.fbo,1024),{depth:s.getAttachment(d),release:()=>s.release(),clearStencil:!1}}};e([r()],l.prototype,"consumes",void 0),e([r()],l.prototype,"produces",void 0),l=e([s("esri.views.3d.webgl-engine.effects.geometry.RenderOccludedRenderNode")],l);const a=new t;function p(){a.prune()}const h=[4,2,16],u=h.reduce((e,t)=>e|t,0);export{l as RenderOccludedRenderNode,p as cleanupRenderOccluded};
5
+ import{__decorate as e}from"tslib";import t from"../../../../../core/PooledArray.js";import{property as r,subclass as s}from"../../../../../core/accessorSupport/decorators.js";import{ZEROS as o}from"../../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{InternalRenderCategory as n}from"../../../webgl.js";import i from"../../../webgl/RenderNode.js";import{Blit as c}from"../blit/Blit.js";import{DepthStencilAttachment as d}from"../../../../webgl/enums.js";let l=class extends i{constructor(e){super(e),this.consumes={required:[n.OCCLUDED]},this.produces=n.OCCLUDED,this._blit=new c(e.view.stage.renderView.techniques,2)}precompile(){const e=this.view.stage.renderer;e.plugins.plugins.forEach(t=>{e.precompileSlots(t,10,12),t.material&&e.precompileOccludedSlots(t,h)})}render(e){const t=e.find(({name:e})=>e===this.produces);return this._renderOccludedAndTransparentStencil(t),this._renderOccludedComposite(t),t}_renderOccludedAndTransparentStencil(e){const t=this.view.stage.renderer,r=a;r.clear();for(const s of t.plugins.plugins)8&s.renderOccludedFlags&&r.push(s);0!==r.length&&(t.renderSlots(r,11),this._renderAndComposite(e,e.getAttachment(d),.5,()=>t.renderSlots(r,12),!1,!1),r.clear())}_renderOccludedComposite(e){const t=this.view.stage.renderer,r=a;r.clear();let s=0;for(const i of t.plugins.plugins){const e=i.renderOccludedFlags&u;s|=e,e&&r.push(i)}if(!s)return void r.clear();const o=this._getDepthStencilAttachment(e);let n=o.clearStencil;for(const i of h)s&i&&(this._renderAndComposite(e,o.depth,16===i?1:.5,()=>t.renderOccludedSlots(r,i),!0,n),n=!1);o.release(),r.clear()}_renderAndComposite(e,t,r,s,n,i){const c=this.renderingContext,{width:d,height:l}=e.fbo,a=this.fboCache.acquire(d,l,"tmp color");a.attachDepth(t),c.bindFramebuffer(a.fbo),c.clearFramebuffer(o,n,i),s(),a.detachDepth(),this._blit.blend(c,a,e,this.bindParameters,r),a.release()}_getDepthStencilAttachment(e){const{width:t,height:r}=e.fbo;if(!this.view.stage.renderer.occludedRequiresIntegratedMeshStencil){const e=this.fboCache.acquireDepth(14,t,r,"retained stencil");return{depth:e,release:()=>e.release(),clearStencil:!0}}const s=this.fboCache.acquire(t,r,"retained stencil",14);return this.renderingContext.blitFramebuffer(e.fbo,s.fbo,1024),{depth:s.getAttachment(d),release:()=>s.release(),clearStencil:!1}}};e([r()],l.prototype,"consumes",void 0),e([r()],l.prototype,"produces",void 0),l=e([s("esri.views.3d.webgl-engine.effects.geometry.RenderOccludedRenderNode")],l);const a=new t;function p(){a.prune()}const h=[4,2,16],u=h.reduce((e,t)=>e|t,0);export{l as RenderOccludedRenderNode,p as cleanupRenderOccluded};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import has from"../../../../core/has.js";import{nextPowerOfTwo as t}from"../../../../core/mathUtils.js";import{disposeMaybe as i}from"../../../../core/maybe.js";import{property as r,subclass as s}from"../../../../core/accessorSupport/decorators.js";import{ortho as h}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as o}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{RenderCategory as a,InternalRenderCategory as n}from"../../webgl.js";import{glLayout as c}from"../../support/buffer/glUtil.js";import{newLayout as l}from"../../support/buffer/InterleavedLayout.js";import u from"../../webgl/RenderCamera.js";import d from"../../webgl/RenderNode.js";import{ShaderOutputConfiguration as p}from"../core/shaderLibrary/ShaderOutputConfiguration.js";import{VertexArrayObject as m}from"./VertexArrayObject.js";import{C as g}from"../../../../chunks/CutFillDepth.glsl.js";import{CutFillDepthTechnique as f}from"../shaders/CutFillDepthTechnique.js";import{C as _}from"../../../../chunks/CutFillReduction.glsl.js";import{CutFillReductionTechnique as b}from"../shaders/CutFillReductionTechnique.js";import{C as w}from"../../../../chunks/CutFillTargetDepth.glsl.js";import{CutFillTargetDepthTechnique as F}from"../shaders/CutFillTargetDepthTechnique.js";import{PrimitiveType as C,DataType as T}from"../../../webgl/enums.js";import{VertexBuffer as x}from"../../../webgl/VertexBuffer.js";let D=class extends d{constructor(e){super(e),this.consumes={required:[a.TRANSPARENT]},this.produces=n.CUTFILL_DEPTH,this._cutFillTargetDepthConfiguration=new p,this._cutFillTargetDepthParameters=new w,this._cutFillDepthParameters=new g,this._cutFillReductionParameters=new _,this.needsRender=!1,this.done=!0,this._localOrigin=o(),this._maxTextureSize=4096,this._width=0,this._height=0,this._reducedWidth=0,this._reducedHeight=0,this._depthFormat=13,this._colorFormat=10,this._targetVao=null}initialize(){this._maxTextureSize=Math.min(has("esri-mobile")?1024:this._maxTextureSize,this.fboCache.rctx.parameters.maxTextureSize),this._cutFillTargetDepthConfiguration.output=7}destroy(){this._targetVao=i(this._targetVao)}precompile(){this.techniques.precompile(F,this._cutFillTargetDepthConfiguration),this.techniques.precompile(f),this.techniques.precompile(b),this.view.stage.renderer.precompileCutFill()}render(e){const t=e.find(({name:e})=>e===n.CUTFILL_DEPTH);if(!this._orthographicCamera||!this._targetVao||!this.needsRender)return t;const i=this.techniques.get(F,this._cutFillTargetDepthConfiguration),r=this.techniques.get(f),s=this.techniques.get(b);if(!i.compiled||!r.compiled||!s.compiled)return this.requestRender(1),t;this.needsRender=!1;const h=this.renderingContext,o=this.fboCache,a=h.getViewport(),c=o.acquire(this._width,this._height,"cutfill reference depth",this._depthFormat);h.bindFramebuffer(c.fbo),h.setViewport(0,0,this._width,this._height),h.clear(1280),this.view.stage.renderer.renderCutFillReferenceDepth(this._orthographicCamera);const l=o.acquire(this._width,this._height,"cutfill target depth",this._depthFormat);h.bindFramebuffer(l.fbo),h.setViewport(0,0,this._width,this._height),h.setClearDepth(1),h.clear(256),this._cutFillTargetDepthParameters.origin=this._localOrigin,this._cutFillTargetDepthParameters.cutFillCamera=this._orthographicCamera,h.bindTechnique(i,this.bindParameters,this._cutFillTargetDepthParameters),h.bindVAO(this._targetVao),h.drawArrays(C.TRIANGLES,0,this._targetVao.vertexCount("geometry"));let u=o.acquire(this._width,this._height,"cutfill reduction even",this._colorFormat),d=o.acquire(this._width,this._height,"cutfill reduction odd",this._colorFormat);this._cutFillDepthParameters.referenceDepthTexture=c.depthTexture,this._cutFillDepthParameters.targetDepthTexture=l.depthTexture,h.bindFramebuffer(u.fbo),h.bindTechnique(r,this.bindParameters,this._cutFillDepthParameters),h.setClearColor(0,0,0,0),h.clear(16384),h.screen.draw(),c.release(),l.release();let p=this._width,m=this._height;const g=Math.ceil(Math.log2(Math.min(p,m)));for(let n=0;n<g;n++)p=Math.ceil(p/2),m=Math.ceil(m/2),this._cutFillReductionParameters.depthTexture=u.getTexture(),this._prepareFBO(d,p,m),h.bindTechnique(s,this.bindParameters,this._cutFillReductionParameters),h.screen.draw(),[u,d]=[d,u];return this._buffer=new Float32Array(p*m*2),u.fbo?.readPixels(0,0,p,m,33319,T.FLOAT,this._buffer),this._reducedWidth=p,this._reducedHeight=m,u.release(),d.release(),h.setViewport(a.x,a.y,a.width,a.height),this.done=!0,t}setup(e,r){const s=this.renderingContext,{cameraDimensions:{width:h,height:o},localOriginRenderSpace:a}=e,n=this._maxTextureSize,c=o/h,l=h>o?n:n/c,u=h>o?n*c:n;this._width=t(l),this._height=t(u);const d=[this._width,this._height];this._orthographicCamera=this._createCamera(e,d),this._targetVao=i(this._targetVao),this._targetVao=R(s,r),this._localOrigin=a,this.done=!1}start(){0!==this._width&&0!==this._height&&(this.needsRender=!0)}getDepth(){let e=0,t=0;for(let i=0;i<this._reducedWidth;i++)for(let r=0;r<this._reducedHeight;r++){const s=i+r*this._reducedWidth;e+=this._buffer?.[2*s]??0,t+=this._buffer?.[2*s+1]??0}return{cut:e,fill:t}}get width(){return this._width}get height(){return this._height}get updating(){return this.needsRender||!this.done}_prepareFBO(e,t,i){const r=this.renderingContext;r.bindFramebuffer(e.fbo),r.setViewport(0,0,t,i),r.setClearColor(0,0,0,0),r.clear(16384)}_createCamera(e,t){const{cameraPositionRenderSpace:i,localOriginRenderSpace:r,northVector:s,cameraDimensions:{width:o,height:a},cameraNearFar:{near:n,far:c}}=e,l=new u({eye:i,center:r,up:s,near:n,far:c});return l.viewport=[0,0,t[0],t[1]],h(l.projectionMatrix,-o/2,o/2,-a/2,a/2,n,c),l}};e([r()],D.prototype,"consumes",void 0),e([r()],D.prototype,"produces",void 0),e([r()],D.prototype,"needsRender",void 0),e([r()],D.prototype,"done",void 0),e([r()],D.prototype,"updating",null),D=e([s("esri.views.3d.webgl-engine.lib.CutFillDepth")],D);const j=l().vec3f("position").freeze();function R(e,t){const{positions:i,indices:r}=t,s=j.createBuffer(r.length),h=s.position;for(let a=0;a<r.length;++a){const e=3*r[a];h.set(a,0,i[e]),h.set(a,1,i[e+1]),h.set(a,2,i[e+2])}const o=new x(e,c(j),s.buffer);return new m(e,o)}class P{constructor(e,t){this.positions=e,this.indices=t}}export{D as CutFillDepth,P as TargetGeometryRenderInfo};
5
+ import{__decorate as t}from"tslib";import has from"../../../../core/has.js";import{nextPowerOfTwo as e}from"../../../../core/mathUtils.js";import{disposeMaybe as i,destroyMaybe as r}from"../../../../core/maybe.js";import{property as s,subclass as h}from"../../../../core/accessorSupport/decorators.js";import{ortho as o}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{set 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{create as u}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{UNIT_X as l,ZEROS as c}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{RenderCategory as d,InternalRenderCategory as p}from"../../webgl.js";import{glLayout as _}from"../../support/buffer/glUtil.js";import{newLayout as f}from"../../support/buffer/InterleavedLayout.js";import m from"../../webgl/RenderCamera.js";import g from"../../webgl/RenderNode.js";import{ShaderOutputConfiguration as F}from"../core/shaderLibrary/ShaderOutputConfiguration.js";import{VertexArrayObject as C}from"./VertexArrayObject.js";import{C as w}from"../../../../chunks/CutFillDepth.glsl.js";import{CutFillDepthTechnique as R}from"../shaders/CutFillDepthTechnique.js";import{CutFillDepthTechniqueConfiguration as P}from"../shaders/CutFillDepthTechniqueConfiguration.js";import{C as b}from"../../../../chunks/CutFillReduction.glsl.js";import{CutFillReductionTechnique as T}from"../shaders/CutFillReductionTechnique.js";import{CutFillReductionTechniqueConfiguration as x}from"../shaders/CutFillReductionTechniqueConfiguration.js";import{C as D}from"../../../../chunks/CutFillTargetDepth.glsl.js";import{CutFillTargetDepthTechnique as B}from"../shaders/CutFillTargetDepthTechnique.js";import{ImmediateTask as y,TaskPriority as j}from"../../../support/Scheduler.js";import{Yield as q}from"../../../support/Yield.js";import{PrimitiveType as S,DataType as E}from"../../../webgl/enums.js";import{Sync as v}from"../../../webgl/Sync.js";import{VertexBuffer as O}from"../../../webgl/VertexBuffer.js";let V=class extends g{constructor(t){super(t),this.consumes={required:[d.TRANSPARENT]},this.produces=p.CUTFILL_DEPTH,this._cutFillTargetDepthConfiguration=new F,this._cutFillDepthConfiguration=new P,this._cutFillReductionConfiguration=new x,this._cutFillTargetDepthParameters=new D,this._cutFillDepthParameters=new w,this._cutFillReductionParameters=new b,this.needsRender=!1,this.readyToRun=!1,this.done=!0,this._frameTask=y,this._results=new k,this._localOrigin=u(),this._maxTextureSize=4096,this._width=0,this._height=0,this._reducedWidth=0,this._reducedHeight=0,this._depthFormat=14,this._colorFormat=11,this._numChannels=2,this._targetVao=null,this._numReductions=3,this._reductionPasses=0,this._pixelBufferSize=0,this._pixelBufferOffset=0,this._perReductionPixelBufferSize=0}initialize(){this._frameTask=this.view.resourceController.scheduler.registerTask(j.VOLUME_MEASUREMENT,this),this.addHandles(this._frameTask),this._maxTextureSize=Math.min(has("esri-mobile")?1024:this._maxTextureSize,this.fboCache.rctx.parameters.maxTextureSize),this._cutFillTargetDepthConfiguration.output=7}destroy(){this._targetVao=i(this._targetVao);const t=this.gl;this._sync=r(this._sync),this._pixelBuffer&&(t.deleteBuffer(this._pixelBuffer),this._pixelBuffer=null,this._pixelBufferSize=0)}precompile(){this.techniques.precompile(B,this._cutFillTargetDepthConfiguration),this._cutFillDepthConfiguration.preparePass=0,this.techniques.precompile(R,this._cutFillDepthConfiguration),this._cutFillDepthConfiguration.preparePass=1,this.techniques.precompile(R,this._cutFillDepthConfiguration),this._cutFillReductionConfiguration.reductionPass=0,this.techniques.precompile(T,this._cutFillReductionConfiguration),this._cutFillReductionConfiguration.reductionPass=1,this.techniques.precompile(T,this._cutFillReductionConfiguration),this._cutFillReductionConfiguration.reductionPass=2,this.techniques.precompile(T,this._cutFillReductionConfiguration),this.view.stage.renderer.precompileCutFill()}render(t){const e=t.find(({name:t})=>t===p.CUTFILL_DEPTH);if(!this._orthographicCamera||!this._targetVao||!this.needsRender||this._sync)return e;const i=this.techniques.get(B,this._cutFillTargetDepthConfiguration);this._cutFillDepthConfiguration.preparePass=0;const r=this.techniques.get(R,this._cutFillDepthConfiguration);this._cutFillDepthConfiguration.preparePass=1;const s=this.techniques.get(R,this._cutFillDepthConfiguration);this._cutFillReductionConfiguration.reductionPass=0;const h=this.techniques.get(T,this._cutFillReductionConfiguration);this._cutFillReductionConfiguration.reductionPass=1;const o=this.techniques.get(T,this._cutFillReductionConfiguration);this._cutFillReductionConfiguration.reductionPass=2;const n=this.techniques.get(T,this._cutFillReductionConfiguration);if(!(i.compiled&&r.compiled&&s.compiled&&h.compiled&&o.compiled&&n.compiled))return this.requestRender(1),e;this.needsRender=!1;const a=this.renderingContext,u=this.fboCache,d=this.gl,_=a.getViewport(),f=u.acquire(this._width,this._height,"cutfill reference depth",this._depthFormat);a.bindFramebuffer(f.fbo),a.setViewport(0,0,this._width,this._height),a.clear(1280),this.view.stage.renderer.renderCutFillReferenceDepth(this._orthographicCamera);const m=u.acquire(this._width,this._height,"cutfill target depth",this._depthFormat);a.bindFramebuffer(m.fbo),a.setViewport(0,0,this._width,this._height),a.setClearDepth(1),a.clear(256),this._cutFillTargetDepthParameters.origin=this._localOrigin,this._cutFillTargetDepthParameters.cutFillCamera=this._orthographicCamera,a.bindTechnique(i,this.bindParameters,this._cutFillTargetDepthParameters),a.bindVAO(this._targetVao),a.drawArrays(S.TRIANGLES,0,this._targetVao.vertexCount("geometry"));const g=u.acquire(this._width,this._height,"cutfill reduction even",this._colorFormat),F=u.acquire(this._width,this._height,"cutfill reduction odd",this._colorFormat);return this._cutFillDepthParameters.referenceDepthTexture=f.depthTexture,this._cutFillDepthParameters.targetDepthTexture=m.depthTexture,this._pixelBuffer||(this._pixelBuffer=d.createBuffer()),d.bindBuffer(d.PIXEL_PACK_BUFFER,this._pixelBuffer),d.bufferData(d.PIXEL_PACK_BUFFER,this._pixelBufferSize,d.STREAM_READ),this._prepareFBO(g,this.width,this.height),a.bindTechnique(r,this.bindParameters,this._cutFillDepthParameters),a.screen.draw(),this._runPyramidReduction(g,F,h),this._prepareFBO(g,this.width,this.height,l),a.bindTechnique(s,this.bindParameters,this._cutFillDepthParameters),a.screen.draw(),this._runPyramidReduction(g,F,o),this._prepareFBO(g,this.width,this.height,c),a.bindTechnique(s,this.bindParameters,this._cutFillDepthParameters),a.screen.draw(),this._runPyramidReduction(g,F,n),f.release(),m.release(),g.release(),F.release(),d.bindBuffer(d.PIXEL_PACK_BUFFER,null),a.setViewport(_.x,_.y,_.width,_.height),this._sync=new v(d),setTimeout(()=>this.readyToRun=!0,0),e}setup(t,r){if(!this.done)return;this.done=!1;const s=this.renderingContext,{cameraDimensions:{width:h,height:o},localOriginRenderSpace:n}=t,a=this._maxTextureSize,u=o/h,l=h>o?a:a/u,c=h>o?a*u:a;this._width=e(l),this._height=e(c);const d=[this._width,this._height];this._orthographicCamera=this._createCamera(t,d),this._targetVao=i(this._targetVao),this._targetVao=z(s,r),this._localOrigin=n,this._reductionPasses=Math.ceil(Math.log2(Math.min(this._width,this._height))),this._reducedWidth=Math.ceil(this._width/2**this._reductionPasses),this._reducedHeight=Math.ceil(this._height/2**this._reductionPasses),this._perReductionPixelBufferSize=this._reducedWidth*this._reducedHeight*this._numChannels*4,this._pixelBufferSize=this._perReductionPixelBufferSize*this._numReductions,this._pixelBufferOffset=0}runTask(){if(!this._sync)return void(this.readyToRun=!1);try{if(!this._sync.poll())return q}catch(e){return this.readyToRun=!1,void(this._sync=r(this._sync))}this.readyToRun=!1,this._sync=r(this._sync);const t=this.gl;this._cpuBuffer=new Float32Array(this._pixelBufferSize/4),t.bindBuffer(t.PIXEL_PACK_BUFFER,this._pixelBuffer),t.getBufferSubData(t.PIXEL_PACK_BUFFER,0,this._cpuBuffer),t.bindBuffer(t.PIXEL_PACK_BUFFER,null),this._updateResults(this._cpuBuffer),this.done=!0}start(){0!==this._width&&0!==this._height&&(this.needsRender=!0,this.requestRender(1))}getResults(){return this._results}get width(){return this._width}get height(){return this._height}get updating(){return this.readyToRun||!this.done||this._frameTask.updating}_runPyramidReduction(t,e,i){const r=this.renderingContext,s=this.gl;let h=this._width,o=this._height;for(let n=0;n<this._reductionPasses;n++)h=Math.ceil(h/2),o=Math.ceil(o/2),this._cutFillReductionParameters.depthTexture=t.getTexture(),this._prepareFBO(e,h,o),r.bindTechnique(i,this.bindParameters,this._cutFillReductionParameters),r.screen.draw(),[t,e]=[e,t];s.readPixels(0,0,h,o,33319,E.FLOAT,this._pixelBufferOffset),this._pixelBufferOffset+=this._perReductionPixelBufferSize}_updateResults(t){const e=new U(0,1,a()),i=new U(0,0,a());for(let r=0;r<this._reducedWidth;r++)for(let s=0;s<this._reducedHeight;s++){let h=(r+s*this._reducedWidth)*this._numChannels;const o=this._reducedWidth*this._reducedHeight*this._numChannels;e.totalDepth+=t[h],i.totalDepth+=t[h+1],h+=o;const n=t[h];n<e.labelDepth&&(e.labelDepth=n,L(e.labelCoords,t[h+1],this._width)),h+=o;const a=t[h];a>i.labelDepth&&(i.labelDepth=a,L(i.labelCoords,t[h+1],this._width))}this._results=new k(this._width,this._height,e,i)}_prepareFBO(t,e,i,r=c){const s=this.renderingContext;s.bindFramebuffer(t.fbo),s.setViewport(0,0,e,i),s.setClearColor(r[0],r[1],r[2],r[3]),s.clear(16384)}_createCamera(t,e){const{cameraPositionRenderSpace:i,localOriginRenderSpace:r,northVector:s,cameraDimensions:{width:h,height:n},cameraNearFar:{near:a,far:u}}=t,l=new m({eye:i,center:r,up:s,near:a,far:u});return l.viewport=[0,0,e[0],e[1]],o(l.projectionMatrix,-h/2,h/2,-n/2,n/2,a,u),l}};t([s()],V.prototype,"consumes",void 0),t([s()],V.prototype,"produces",void 0),t([s()],V.prototype,"needsRender",void 0),t([s()],V.prototype,"readyToRun",void 0),t([s()],V.prototype,"done",void 0),t([s()],V.prototype,"updating",null),t([s()],V.prototype,"_frameTask",void 0),V=t([h("esri.views.3d.webgl-engine.lib.CutFillDepth")],V);const A=f().vec3f("position").freeze();function z(t,e){const{positions:i,indices:r}=e,s=A.createBuffer(r.length),h=s.position;for(let n=0;n<r.length;++n){const t=3*r[n];h.set(n,0,i[t]),h.set(n,1,i[t+1]),h.set(n,2,i[t+2])}const o=new O(t,_(A),s.buffer);return new C(t,o)}function L(t,e,i){const r=e%i,s=Math.floor(e/i);n(t,r,s)}class M{constructor(t,e){this.positions=t,this.indices=e}}class U{constructor(t,e,i){this.totalDepth=t,this.labelDepth=e,this.labelCoords=i}}class k{constructor(t=0,e=0,i=new U(0,1,a()),r=new U(0,0,a())){this.width=t,this.height=e,this.cut=i,this.fill=r}}export{V as CutFillDepth,U as DepthResult,k as RenderResult,M as TargetGeometryRenderInfo};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as t}from"tslib";import"../../../../core/has.js";import{disposeMaybe as e,destroyMaybe as i}from"../../../../core/maybe.js";import{property as r,subclass as o}from"../../../../core/accessorSupport/decorators.js";import{multiply as s,fromTranslation as n}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as h}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{h as u,a}from"../../../../chunks/vec32.js";import{create as p}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{RenderCategory as f}from"../../webgl.js";import{debugFlags as c}from"../../support/debugFlags.js";import{glLayout as _}from"../../support/buffer/glUtil.js";import{newLayout as d}from"../../support/buffer/InterleavedLayout.js";import l from"../../webgl/RenderNode.js";import{Pos2Locations as m}from"./DefaultVertexBufferLayouts.js";import{VertexArrayObject as g}from"./VertexArrayObject.js";import{TaskPriority as x}from"../../../support/Scheduler.js";import{Yield as v}from"../../../support/Yield.js";import{DataType as b,PixelType as w}from"../../../webgl/enums.js";import{makePipelineState as y,defaultColorWrite as P}from"../../../webgl/renderState.js";import{Sync as T}from"../../../webgl/Sync.js";import{Texture as j}from"../../../webgl/Texture.js";import{TextureDescriptor as B}from"../../../webgl/TextureDescriptor.js";import{fromLayout as C}from"../../../webgl/VertexAttributeLocations.js";import{VertexBuffer as E}from"../../../webgl/VertexBuffer.js";let F=class extends l{constructor(t){super(t),this.category=f.COMPOSITE,this._debugVao=null,this._debugVaoLength=0,this.readyToRun=!1,this.done=!0,this._start=!1,this._origin=p(),this._textureWidth=256,this._uploadBuffer=new Float32Array(3*this._textureWidth),this._counter=0,this._width=0,this._height=0,this._pixelBufferSize=0,this._pipeline=y({colorWrite:P}),this._format=0}initialize(){const t=this.view.resourceController.scheduler.registerTask(x.GRAPHICS_CORE,this);this.addHandles(t),this.produces="disabled",this.consumes.required=[this.category],this.formatOverride&&(this._format=this.formatOverride)}destroy(){this._program=e(this._program),this._debugProgram=e(this._debugProgram),this._debugVao=e(this._debugVao);const t=this.gl;this._sync=i(this._sync),this._pixelBuffer&&(t.deleteBuffer(this._pixelBuffer),this._pixelBuffer=null,this._pixelBufferSize=0),this._texture=e(this._texture)}precompile(){this._ensureProgram(this.renderingContext)}render(t){const e=t.find(({name:t})=>t===this.category),i=this.renderingContext,r=this.gl,o=e.getTexture(r.DEPTH_STENCIL_ATTACHMENT),s=this.view.stage?.renderer.fboCache;if(!o||!s||this._sync||!this._start)return e;this._start=!1,this.produces=c.OCCLUSION_QUERY_DEBUG_PIXEL?this.category:"disabled";const n=s.acquire(this._width,this._height,"hud visibility",9);i.bindFramebuffer(n.fbo),i.setPipelineState(this._pipeline);const h=this._ensureProgram(i);return i.useProgram(h),L(h,this.camera,this._origin),i.bindTexture(o,0),h.setUniform1i("depthTex",0),i.bindTexture(this._texture,1),h.setUniform1i("positionTex",1),h.setUniform1i("count",this._counter),i.screen.draw(),this._pixelBuffer||(this._pixelBuffer=r.createBuffer()),0===this._format&&(this._format=6403===r.getParameter(r.IMPLEMENTATION_COLOR_READ_FORMAT)&&r.getParameter(r.IMPLEMENTATION_COLOR_READ_TYPE)===b.FLOAT?6403:6408),this._pixelBufferSize=this._width*this._height*(6403===this._format?4:16),r.bindBuffer(r.PIXEL_PACK_BUFFER,this._pixelBuffer),r.bufferData(r.PIXEL_PACK_BUFFER,this._pixelBufferSize,r.STREAM_READ),r.readPixels(0,0,this._width,this._height,this._format,b.FLOAT,0),this._sync=new T(r),n.release(),setTimeout(()=>this.readyToRun=!0,0),e}runTask(){if(!this._sync)return void(this.readyToRun=!1);try{if(!this._sync.poll())return v}catch(e){return this.readyToRun=!1,void(this._sync=i(this._sync))}this.readyToRun=!1,this._sync=i(this._sync);const t=this.gl;t.bindBuffer(t.PIXEL_PACK_BUFFER,this._pixelBuffer),this._cpuBuffer=new Float32Array(this._width*this._height*(6403===this._format?1:4)),t.getBufferSubData(t.PIXEL_PACK_BUFFER,0,this._cpuBuffer),t.bindBuffer(t.PIXEL_PACK_BUFFER,null),this.done=!0}init(t,e){const i=this._textureWidth;if(this._width=i,this._height=Math.ceil(t/i),this._counter=0,this._texture?.dispose(),0===this._height)return;const r=new B(this._width,this._height);r.pixelFormat=6407,r.dataType=w.FLOAT,r.samplingMode=9728,this._texture=new j(this.renderingContext,r),this.done=!1,u(this._origin,Math.fround(e[0]),Math.fround(e[1]),Math.fround(e[2]))}addPosition(t){const e=this._width;if(this._counter>=e*this._height)return-1;const i=this._counter%e;return a(M,t,this._origin),this._uploadBuffer[3*i+0]=M[0],this._uploadBuffer[3*i+1]=M[1],this._uploadBuffer[3*i+2]=M[2],i===e-1&&this._flush(),this._counter++}start(){if(0===this._width||0===this._height)return;const t=this._width;this._counter%t>0&&this._flush(),this.produces=this.category,this._start=!0,this.requestRender(1)}getOcclusion(t){return this._cpuBuffer?.[6403===this._format?t:4*t]??-1}get usedMemory(){return(this._texture?.usedMemory??0)+this._pixelBufferSize+4*(this._uploadBuffer?.length??0)+4*(this._cpuBuffer?.length??0)}_flush(){const t=this._width,e=Math.floor(this._counter/t);this._texture?.updateData(0,0,e,t,1,this._uploadBuffer)}_ensureProgram(t){return this._program??=t.programCache.acquire(D,O,m),this._program}_ensureDebugProgram(t){return this._debugProgram??=t.programCache.acquire(A,R,V),this._debugProgram}_ensureDebugVao(t,i){if(!this._debugVao||this._debugVaoLength<i){const r=new Float32Array(i);for(let t=0;t<i;t++)r[t]=t;this._debugVao=e(this._debugVao),this._debugVao=new g(t,new E(t,S,r))}return this._debugVao}};t([r()],F.prototype,"category",void 0),t([r()],F.prototype,"formatOverride",void 0),t([r()],F.prototype,"readyToRun",void 0),t([r()],F.prototype,"done",void 0),F=t([o("esri.views.3d.webgl-engine.lib.GPUPointOcclusionQuery")],F);const A="#version 300 es\nprecision highp float;\nprecision highp int;\n\nin highp float componentIndex;\n\nuniform highp mat4 proj;\nuniform highp mat4 view;\n\nuniform highp sampler2D positionTex;\n\nvoid main() {\n int width = textureSize(positionTex, 0).x;\n int u = int(componentIndex) % width;\n int v = int(componentIndex) / width;\n\n vec4 posWorld = vec4(texelFetch(positionTex, ivec2(u, v), 0).rgb, 1.0);\n vec4 posView = view * posWorld;\n vec4 projected = proj * posView;\n\n gl_Position = projected;\n gl_PointSize = 1.0;\n}",R="#version 300 es\nout highp vec4 fragColor;\nuniform lowp vec4 color;\nvoid main() {\n fragColor = color;\n}\n",D="#version 300 es\nprecision highp float;\nin vec2 position;\n\nvoid main() {\n gl_Position = vec4(position, 0.0, 1.0);\n}",O="#version 300 es\nprecision highp float;\nout highp vec4 fragColor;\n\nuniform highp mat4 proj;\nuniform highp mat4 view;\n\nuniform highp int count;\n\nuniform highp sampler2D depthTex;\nuniform highp sampler2D positionTex;\n\nfloat linearizeDepth(float depth) {\n float depthNdc = depth * 2.0 - 1.0;\n float c1 = proj[3][2];\n float c2 = proj[2][2];\n return -c1 / (depthNdc + c2 + 1e-7);\n}\n\nvoid main() {\n int u = int(floor(gl_FragCoord.x));\n int v = int(floor(gl_FragCoord.y));\n if (u + v * textureSize(positionTex, 0).x >= count) {\n fragColor = vec4(-1);\n return;\n }\n vec4 posWorld = vec4(texelFetch(positionTex, ivec2(u, v), 0).rgb, 1.0);\n vec4 posView = view * posWorld;\n vec4 projected = proj * posView;\n\n vec3 clipPos = projected.xyz / projected.w;\n\n if (clipPos.x < -1.0 || clipPos.x > 1.0 || clipPos.y < -1.0 || clipPos.y > 1.0) {\n fragColor = vec4(-1);\n return;\n }\n\n vec3 uvDepth = 0.5 * clipPos + vec3(0.5);\n\n float depth = texture(depthTex, uvDepth.xy).r;\n\n if (uvDepth.z <= depth) {\n fragColor = vec4(0);\n return;\n }\n\n fragColor = vec4(linearizeDepth(depth) - linearizeDepth(uvDepth.z));\n}\n";function L(t,e,i){s(I,e.viewMatrix,n(I,i)),t.setUniformMatrix4fv("view",I),t.setUniformMatrix4fv("proj",e.projectionMatrix)}const M=p(),I=h(),S=_(d().f32("componentIndex")),V=C(S);export{F as GPUPointOcclusionQuery};
5
+ import{__decorate as t}from"tslib";import"../../../../core/has.js";import{disposeMaybe as e,destroyMaybe as i}from"../../../../core/maybe.js";import{property as r,subclass as o}from"../../../../core/accessorSupport/decorators.js";import{multiply as s,fromTranslation as n}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as h}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{h as u,a}from"../../../../chunks/vec32.js";import{create as p}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{RenderCategory as f}from"../../webgl.js";import{debugFlags as c}from"../../support/debugFlags.js";import{glLayout as _}from"../../support/buffer/glUtil.js";import{newLayout as d}from"../../support/buffer/InterleavedLayout.js";import l from"../../webgl/RenderNode.js";import{Pos2Locations as m}from"./DefaultVertexBufferLayouts.js";import{VertexArrayObject as g}from"./VertexArrayObject.js";import{TaskPriority as x}from"../../../support/Scheduler.js";import{Yield as v}from"../../../support/Yield.js";import{DataType as b,PixelType as w}from"../../../webgl/enums.js";import{makePipelineState as y,defaultColorWrite as P}from"../../../webgl/renderState.js";import{Sync as T}from"../../../webgl/Sync.js";import{Texture as j}from"../../../webgl/Texture.js";import{TextureDescriptor as B}from"../../../webgl/TextureDescriptor.js";import{fromLayout as C}from"../../../webgl/VertexAttributeLocations.js";import{VertexBuffer as E}from"../../../webgl/VertexBuffer.js";let F=class extends l{constructor(t){super(t),this.category=f.COMPOSITE,this._debugVao=null,this._debugVaoLength=0,this.readyToRun=!1,this.done=!0,this._start=!1,this._origin=p(),this._textureWidth=256,this._uploadBuffer=new Float32Array(3*this._textureWidth),this._counter=0,this._width=0,this._height=0,this._pixelBufferSize=0,this._pipeline=y({colorWrite:P}),this._format=0}initialize(){const t=this.view.resourceController.scheduler.registerTask(x.GRAPHICS_CORE,this);this.addHandles(t),this.produces="disabled",this.consumes.required=[this.category],this.formatOverride&&(this._format=this.formatOverride)}destroy(){this._program=e(this._program),this._debugProgram=e(this._debugProgram),this._debugVao=e(this._debugVao);const t=this.gl;this._sync=i(this._sync),this._pixelBuffer&&(t.deleteBuffer(this._pixelBuffer),this._pixelBuffer=null,this._pixelBufferSize=0),this._texture=e(this._texture)}precompile(){this._ensureProgram(this.renderingContext)}render(t){const e=t.find(({name:t})=>t===this.category),i=this.renderingContext,r=this.gl,o=e.getTexture(r.DEPTH_STENCIL_ATTACHMENT),s=this.view.stage?.renderer.fboCache;if(!o||!s||this._sync||!this._start)return e;this._start=!1,this.produces=c.OCCLUSION_QUERY_DEBUG_PIXEL?this.category:"disabled";const n=s.acquire(this._width,this._height,"hud visibility",10);i.bindFramebuffer(n.fbo),i.setPipelineState(this._pipeline);const h=this._ensureProgram(i);return i.useProgram(h),L(h,this.camera,this._origin),i.bindTexture(o,0),h.setUniform1i("depthTex",0),i.bindTexture(this._texture,1),h.setUniform1i("positionTex",1),h.setUniform1i("count",this._counter),i.screen.draw(),this._pixelBuffer||(this._pixelBuffer=r.createBuffer()),0===this._format&&(this._format=6403===r.getParameter(r.IMPLEMENTATION_COLOR_READ_FORMAT)&&r.getParameter(r.IMPLEMENTATION_COLOR_READ_TYPE)===b.FLOAT?6403:6408),this._pixelBufferSize=this._width*this._height*(6403===this._format?4:16),r.bindBuffer(r.PIXEL_PACK_BUFFER,this._pixelBuffer),r.bufferData(r.PIXEL_PACK_BUFFER,this._pixelBufferSize,r.STREAM_READ),r.readPixels(0,0,this._width,this._height,this._format,b.FLOAT,0),this._sync=new T(r),n.release(),setTimeout(()=>this.readyToRun=!0,0),e}runTask(){if(!this._sync)return void(this.readyToRun=!1);try{if(!this._sync.poll())return v}catch(e){return this.readyToRun=!1,void(this._sync=i(this._sync))}this.readyToRun=!1,this._sync=i(this._sync);const t=this.gl;t.bindBuffer(t.PIXEL_PACK_BUFFER,this._pixelBuffer),this._cpuBuffer=new Float32Array(this._width*this._height*(6403===this._format?1:4)),t.getBufferSubData(t.PIXEL_PACK_BUFFER,0,this._cpuBuffer),t.bindBuffer(t.PIXEL_PACK_BUFFER,null),this.done=!0}init(t,e){const i=this._textureWidth;if(this._width=i,this._height=Math.ceil(t/i),this._counter=0,this._texture?.dispose(),0===this._height)return;const r=new B(this._width,this._height);r.pixelFormat=6407,r.dataType=w.FLOAT,r.samplingMode=9728,this._texture=new j(this.renderingContext,r),this.done=!1,u(this._origin,Math.fround(e[0]),Math.fround(e[1]),Math.fround(e[2]))}addPosition(t){const e=this._width;if(this._counter>=e*this._height)return-1;const i=this._counter%e;return a(M,t,this._origin),this._uploadBuffer[3*i+0]=M[0],this._uploadBuffer[3*i+1]=M[1],this._uploadBuffer[3*i+2]=M[2],i===e-1&&this._flush(),this._counter++}start(){if(0===this._width||0===this._height)return;const t=this._width;this._counter%t>0&&this._flush(),this.produces=this.category,this._start=!0,this.requestRender(1)}getOcclusion(t){return this._cpuBuffer?.[6403===this._format?t:4*t]??-1}get usedMemory(){return(this._texture?.usedMemory??0)+this._pixelBufferSize+4*(this._uploadBuffer?.length??0)+4*(this._cpuBuffer?.length??0)}_flush(){const t=this._width,e=Math.floor(this._counter/t);this._texture?.updateData(0,0,e,t,1,this._uploadBuffer)}_ensureProgram(t){return this._program??=t.programCache.acquire(D,O,m),this._program}_ensureDebugProgram(t){return this._debugProgram??=t.programCache.acquire(A,R,V),this._debugProgram}_ensureDebugVao(t,i){if(!this._debugVao||this._debugVaoLength<i){const r=new Float32Array(i);for(let t=0;t<i;t++)r[t]=t;this._debugVao=e(this._debugVao),this._debugVao=new g(t,new E(t,S,r))}return this._debugVao}};t([r()],F.prototype,"category",void 0),t([r()],F.prototype,"formatOverride",void 0),t([r()],F.prototype,"readyToRun",void 0),t([r()],F.prototype,"done",void 0),F=t([o("esri.views.3d.webgl-engine.lib.GPUPointOcclusionQuery")],F);const A="#version 300 es\nprecision highp float;\nprecision highp int;\n\nin highp float componentIndex;\n\nuniform highp mat4 proj;\nuniform highp mat4 view;\n\nuniform highp sampler2D positionTex;\n\nvoid main() {\n int width = textureSize(positionTex, 0).x;\n int u = int(componentIndex) % width;\n int v = int(componentIndex) / width;\n\n vec4 posWorld = vec4(texelFetch(positionTex, ivec2(u, v), 0).rgb, 1.0);\n vec4 posView = view * posWorld;\n vec4 projected = proj * posView;\n\n gl_Position = projected;\n gl_PointSize = 1.0;\n}",R="#version 300 es\nout highp vec4 fragColor;\nuniform lowp vec4 color;\nvoid main() {\n fragColor = color;\n}\n",D="#version 300 es\nprecision highp float;\nin vec2 position;\n\nvoid main() {\n gl_Position = vec4(position, 0.0, 1.0);\n}",O="#version 300 es\nprecision highp float;\nout highp vec4 fragColor;\n\nuniform highp mat4 proj;\nuniform highp mat4 view;\n\nuniform highp int count;\n\nuniform highp sampler2D depthTex;\nuniform highp sampler2D positionTex;\n\nfloat linearizeDepth(float depth) {\n float depthNdc = depth * 2.0 - 1.0;\n float c1 = proj[3][2];\n float c2 = proj[2][2];\n return -c1 / (depthNdc + c2 + 1e-7);\n}\n\nvoid main() {\n int u = int(floor(gl_FragCoord.x));\n int v = int(floor(gl_FragCoord.y));\n if (u + v * textureSize(positionTex, 0).x >= count) {\n fragColor = vec4(-1);\n return;\n }\n vec4 posWorld = vec4(texelFetch(positionTex, ivec2(u, v), 0).rgb, 1.0);\n vec4 posView = view * posWorld;\n vec4 projected = proj * posView;\n\n vec3 clipPos = projected.xyz / projected.w;\n\n if (clipPos.x < -1.0 || clipPos.x > 1.0 || clipPos.y < -1.0 || clipPos.y > 1.0) {\n fragColor = vec4(-1);\n return;\n }\n\n vec3 uvDepth = 0.5 * clipPos + vec3(0.5);\n\n float depth = texture(depthTex, uvDepth.xy).r;\n\n if (uvDepth.z <= depth) {\n fragColor = vec4(0);\n return;\n }\n\n fragColor = vec4(linearizeDepth(depth) - linearizeDepth(uvDepth.z));\n}\n";function L(t,e,i){s(I,e.viewMatrix,n(I,i)),t.setUniformMatrix4fv("view",I),t.setUniformMatrix4fv("proj",e.projectionMatrix)}const M=p(),I=h(),S=_(d().f32("componentIndex")),V=C(S);export{F as GPUPointOcclusionQuery};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import{watch as t}from"../../../../core/reactiveUtils.js";import{property as s,subclass as i}from"../../../../core/accessorSupport/decorators.js";import{set as a}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{e as r,b as n,j as o,q as l,g as h,F as u,d as c,K as p}from"../../../../chunks/vec32.js";import{create as d,clone as m}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{c as _}from"../../../../chunks/vec42.js";import{create as f}from"../../../../geometry/support/plane.js";import{fromPoints as g}from"../../../../geometry/support/ray.js";import{Sphere as b}from"../../../../geometry/support/sphere.js";import{RenderCategory as P}from"../../webgl.js";import{GaussianSplatTarget as C}from"../../layers/i3s/Intersector.js";import{GaussianSplatDataStore as S}from"../../support/gaussianSplatting/GaussianSplatDataStore.js";import w from"../../webgl/RenderNode.js";import{IntersectorResult as x}from"./IntersectorResult.js";import{G as v}from"../../../../chunks/GaussianSplat.glsl.js";import{GaussianSplatColorTechnique as y}from"../shaders/GaussianSplatColorTechnique.js";import{G as D}from"../../../../chunks/GaussianSplatComposition.glsl.js";import{GaussianSplatCompositionTechnique as q}from"../shaders/GaussianSplatCompositionTechnique.js";import{G as T}from"../../../../chunks/GaussianSplatDepthComposition.glsl.js";import{GaussianSplatDepthCompositionTechnique as A}from"../shaders/GaussianSplatDepthCompositionTechnique.js";import{GaussianSplatDepthTechnique as E}from"../shaders/GaussianSplatDepthTechnique.js";import{GaussianSplatTechnique as G}from"../shaders/GaussianSplatTechnique.js";import{GaussianSplatTechniqueConfiguration as O}from"../shaders/GaussianSplatTechniqueConfiguration.js";import{DepthStencilAttachment as j,ColorAttachment1 as F,PrimitiveType as N}from"../../../webgl/enums.js";var I;let H=class extends w{static{I=this}constructor(e){super(e),this.gaussianPosition=d(),this.intersectionRayDir=d(),this.intersectionPlane=f(),this._slicePlaneEnabled=!1,this._data=null,this.produces=P.OPAQUE,this.type=0,this.isGround=!1,this.layerViewUid="",this._passParameters=new v,this._compositionPassParameters=new D,this._depthCompositionPassParameters=new T,this._previousCameraPosition=d(),this._previousCameraDirection=d(),this.fadeHelper=null,this._configuration=new O(e.view.state.isGlobal),this._colorOnlyConfiguration=new O(e.view.state.isGlobal,!0),this._depthOnlyConfiguration=new O(e.view.state.isGlobal,!1,!0)}async initialize(){this._data=new S(this),this.view.sceneIntersectionHelper.addIntersectionHandler(this),this.addHandles([t(()=>this.view.state.camera,()=>this._onCameraChange())])}precompile(){const e=this.view.qualitySettings.gaussianSplat.minimumOpacity,t=this.bindParameters.terrainDepthTest,s=this.fadeHelper.fadingEnabled,i=s=>{s.alphaCutoff=e,s.terrainDepthTest=t};this.renderingContext.capabilities.drawBuffersIndexed?(i(this._configuration),this._configuration.fadingEnabled=s,this.techniques.precompile(G,this._configuration)):(i(this._colorOnlyConfiguration),this._colorOnlyConfiguration.fadingEnabled=s,this.techniques.precompile(y,this._colorOnlyConfiguration),i(this._depthOnlyConfiguration),this.techniques.precompile(E,this._depthOnlyConfiguration)),this.techniques.precompile(q),this.techniques.precompile(A)}render(e){const t=e.find(({name:e})=>e===P.OPAQUE);if(this._handleFading(),!this._data.visibleGaussians||!this._data.orderTexture.texture||!this._data.textureAtlas.texture)return t;const s=!!this.renderingContext.capabilities.drawBuffersIndexed,i=s?this.techniques.get(G,this._configuration):null,a=s?null:this.techniques.get(y,this._colorOnlyConfiguration),r=s?null:this.techniques.get(E,this._depthOnlyConfiguration),n=this.techniques.get(q),o=this.techniques.get(A);if(!(i?.compiled||a?.compiled&&r?.compiled)||!o.compiled||!n.compiled)return this.requestRender(1),t;const{fullWidth:l,fullHeight:h}=this.bindParameters.camera;this._prepareParameters(h,l);const u=this.renderingContext,c=this.fboCache,p=c.acquire(l,h,"gaussian color output"),d=t.getAttachment(j);p.attachDepth(d);let m=null;s?this._singlePass(p,i):m=this._multiPass(p,d,a,r);const _=c.acquire(l,h,this.produces);return this._depthCompositionPassParameters.splatDepth=m?m.getTexture():p.getTexture(F),_.attachDepth(t.getAttachment(j)),u.bindFramebuffer(_.fbo),u.bindTechnique(o,this.bindParameters,this._depthCompositionPassParameters),u.screen.draw(),this._compositionPassParameters.color=t.getTexture(),this._compositionPassParameters.splatColor=p.getTexture(),u.bindFramebuffer(_.fbo),u.bindTechnique(n,this.bindParameters,this._compositionPassParameters),u.screen.draw(),p.release(),m?.release(),_}intersect(e,t,s,i){const{gaussianPosition:a,intersectionRayDir:c,intersectionPlane:p,layerViewUid:f}=this,P=g(s,i);r(c,i,s);const S=1/n(c);o(c,c,S);const w=d();l(w,c),_(p,c[0],c[1],c[2],-h(c,s));const v=new U,y=new U,D=new Array;this._data.visibleGaussianTiles.forEach(r=>{const{maxScale:n}=r,o=r.obb.minimumDistancePlane(p),l=r.obb.maximumDistancePlane(p),d=l<0,_=null!=v.dist&&null!=y.dist&&v.dist<o*S&&y.dist>l*S;if(d||_)return;if(!new b(r.obb.center,r.obb.radius+n).intersectRay(P,null))return;if(!r.obb.intersectRay(s,c,n))return;const{positions:g,squaredScales:C,gaussianAtlasIndices:x}=r,q=x.length;for(let p=0;p<q;p++){const r=3*p;a[0]=g[r]-s[0],a[1]=g[r+1]-s[1],a[2]=g[r+2]-s[2];const n=C[p],o=h(a,c),l=o*o;if(u(a)-l>n)continue;const d=o*S,_=e=>(e.point=e.point?e.point.fill(a[0],a[1],a[2]):m(a),e.dist=d,e.normal=w,e.layerViewUid=f,e);if((null==v.dist||d<v.dist)&&(null==t||t(s,i,d))&&_(v),0!==e.options.store&&(null==y.dist||d>y.dist)&&(null==t||t(s,i,d))&&_(y),2===e.options.store&&(null==t||t(s,i,d))){const e=new U;D.push(_(e))}}});const q=(e,t)=>{const{layerViewUid:s}=t,i=new C(t.point,s);e.set(0,i,t.dist,t.normal)};if(R(v)){const t=e.results.min;(null==t.distance||v.dist<t.distance)&&q(t,v)}if(R(y)&&0!==e.options.store){const t=e.results.max;(null==t.distance||y.dist>t.distance)&&q(t,y)}if(2===e.options.store)for(const r of D){const t=new x(P);q(t,r),e.results.all.push(t)}}get slicePlaneEnabled(){return this._slicePlaneEnabled}set slicePlaneEnabled(e){this._slicePlaneEnabled!==e&&(this._slicePlaneEnabled=e,this.requestRender(1))}get data(){return this._data}destroy(){this._data.destroy(),super.destroy()}_onCameraChange(){const e=this.view.state.camera.eye,t=this.view.state.camera.ray.direction,s=.001;(Math.abs(e[0]-this._previousCameraPosition[0])>s||Math.abs(e[1]-this._previousCameraPosition[1])>s||Math.abs(e[2]-this._previousCameraPosition[2])>s||Math.abs(t[0]-this._previousCameraDirection[0])>s||Math.abs(t[1]-this._previousCameraDirection[1])>s||Math.abs(t[2]-this._previousCameraDirection[2])>s)&&(c(this._previousCameraPosition,e),c(this._previousCameraDirection,t),this._data.requestSort())}_prepareParameters(e,t){this._passParameters.totalGaussians=this._data.visibleGaussians,this._passParameters.splatOrder=this._data.orderTexture.texture,this._passParameters.splatFading=this._data.fadingTexture.texture,this._passParameters.splatAtlas=this._data.textureAtlas.texture;const s=Math.tan(.5*this.camera.fovY),i=s/e*t;a(this._passParameters.tanFov,i,s),this._passParameters.focalLength=e/(2*s);const r=this.view.qualitySettings.gaussianSplat.minimumSplatPixelRadius;this._passParameters.minSplatRadius=r*Math.sqrt(t*e)/Math.sqrt(2073600),this._prepareHighPrecisionCameraPosition()}_singlePass(e,t){const s=this.renderingContext,i=this.renderingContext.gl,a=this.renderingContext.capabilities.drawBuffersIndexed;e.acquireColor(F,8,"gaussian depth output"),s.bindFramebuffer(e.fbo),s.setClearColor(0,0,0,0),s.clear(16384),this.renderingContext.bindTechnique(t,this.bindParameters,this._passParameters),a.enableiOES(i.BLEND,0),a.blendEquationSeparateiOES(0,i.FUNC_ADD,i.FUNC_ADD),a.blendFuncSeparateiOES(0,i.ONE_MINUS_DST_ALPHA,i.ONE,i.ONE_MINUS_DST_ALPHA,i.ONE),a.enableiOES(i.BLEND,1),a.blendEquationSeparateiOES(1,i.FUNC_ADD,i.FUNC_ADD),a.blendFuncSeparateiOES(1,i.ONE_MINUS_DST_ALPHA,i.DST_ALPHA,i.ONE_MINUS_DST_ALPHA,i.ONE),this.renderingContext.drawArraysInstanced(N.TRIANGLE_STRIP,0,4,this._data.visibleGaussians)}_multiPass(e,t,s,i){const{fullWidth:a,fullHeight:r}=this.bindParameters.camera,n=this.renderingContext;n.bindFramebuffer(e.fbo),n.setClearColor(0,0,0,0),n.clear(16384),this.renderingContext.bindTechnique(s,this.bindParameters,this._passParameters),this.renderingContext.drawArraysInstanced(N.TRIANGLE_STRIP,0,4,this._data.visibleGaussians);const o=this.fboCache.acquire(a,r,"gaussian depth output",8);return o.attachDepth(t),n.bindFramebuffer(o.fbo),n.setClearColor(0,0,0,0),n.clear(16384),this.renderingContext.bindTechnique(i,this.bindParameters,this._passParameters),this.renderingContext.drawArraysInstanced(N.TRIANGLE_STRIP,0,4,this._data.visibleGaussians),o}_prepareHighPrecisionCameraPosition(){o(this._passParameters.tileCameraPosition,this.camera.eye,1/I.tileSize),p(this._passParameters.tileCameraPosition,this._passParameters.tileCameraPosition),o(this._passParameters.cameraDelta,this._passParameters.tileCameraPosition,I.tileSize),r(this._passParameters.cameraDelta,this.camera.eye,this._passParameters.cameraDelta)}_handleFading(){if(0===this.fadeHelper.numFadingTiles)return void(this._previousFrameStart=null);this._previousFrameStart??=this.view.stage.renderer.renderContext.time;const e=this.view.stage?.renderer.renderContext.time-this._previousFrameStart;this.fadeHelper.updateAllTileFading(e),this._previousFrameStart=this.view.stage.renderer.renderContext.time,this._data.fadingTexture.updateTexture(this._data.textureAtlas.pageAllocator.pageCount)}static{this.tileSize=2.048}};function R(e){return null!=e.dist&&null!=e.point}e([s({constructOnly:!0})],H.prototype,"fadeHelper",void 0),H=I=e([i("esri.views.3d.webgl-engine.lib.GaussianSplatRenderNode")],H);class U{constructor(){this.point=null,this.dist=null,this.normal=null,this.layerViewUid=""}}export{H as GaussianSplatRenderNode};
5
+ import{__decorate as e}from"tslib";import{watch as t}from"../../../../core/reactiveUtils.js";import{property as s,subclass as i}from"../../../../core/accessorSupport/decorators.js";import{set as a}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{e as r,b as n,j as o,q as l,g as h,D as u,d as p,K as c}from"../../../../chunks/vec32.js";import{create as d,clone as m}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{c as _}from"../../../../chunks/vec42.js";import{create as f}from"../../../../geometry/support/plane.js";import{fromPoints as g}from"../../../../geometry/support/ray.js";import{Sphere as b}from"../../../../geometry/support/sphere.js";import{RenderCategory as P}from"../../webgl.js";import{GaussianSplatTarget as C}from"../../layers/i3s/Intersector.js";import{GaussianSplatDataStore as S}from"../../support/gaussianSplatting/GaussianSplatDataStore.js";import x from"../../webgl/RenderNode.js";import{IntersectorResult as w}from"./IntersectorResult.js";import{G as v}from"../../../../chunks/GaussianSplat.glsl.js";import{GaussianSplatColorTechnique as y}from"../shaders/GaussianSplatColorTechnique.js";import{G as D}from"../../../../chunks/GaussianSplatComposition.glsl.js";import{GaussianSplatCompositionTechnique as T}from"../shaders/GaussianSplatCompositionTechnique.js";import{G as q}from"../../../../chunks/GaussianSplatDepthComposition.glsl.js";import{GaussianSplatDepthCompositionTechnique as A}from"../shaders/GaussianSplatDepthCompositionTechnique.js";import{GaussianSplatDepthTechnique as E}from"../shaders/GaussianSplatDepthTechnique.js";import{GaussianSplatTechnique as G}from"../shaders/GaussianSplatTechnique.js";import{GaussianSplatTechniqueConfiguration as O}from"../shaders/GaussianSplatTechniqueConfiguration.js";import{DepthStencilAttachment as j,ColorAttachment1 as F,PrimitiveType as N}from"../../../webgl/enums.js";var I;let H=class extends x{static{I=this}constructor(e){super(e),this.gaussianPosition=d(),this.intersectionRayDir=d(),this.intersectionPlane=f(),this._slicePlaneEnabled=!1,this._data=null,this.produces=P.OPAQUE,this.type=0,this.isGround=!1,this.layerViewUid="",this._passParameters=new v,this._compositionPassParameters=new D,this._depthCompositionPassParameters=new q,this._previousCameraPosition=d(),this._previousCameraDirection=d(),this.fadeHelper=null,this._configuration=new O(e.view.state.isGlobal),this._colorOnlyConfiguration=new O(e.view.state.isGlobal,!0),this._depthOnlyConfiguration=new O(e.view.state.isGlobal,!1,!0)}async initialize(){this._data=new S(this),this.view.sceneIntersectionHelper.addIntersectionHandler(this),this.addHandles([t(()=>this.view.state.camera,()=>this._onCameraChange())])}precompile(){const e=this.view.qualitySettings.gaussianSplat.minimumOpacity,t=this.bindParameters.terrainDepthTest,s=this.fadeHelper.fadingEnabled,i=s=>{s.alphaCutoff=e,s.terrainDepthTest=t};this.renderingContext.capabilities.drawBuffersIndexed?(i(this._configuration),this._configuration.fadingEnabled=s,this.techniques.precompile(G,this._configuration)):(i(this._colorOnlyConfiguration),this._colorOnlyConfiguration.fadingEnabled=s,this.techniques.precompile(y,this._colorOnlyConfiguration),i(this._depthOnlyConfiguration),this.techniques.precompile(E,this._depthOnlyConfiguration)),this.techniques.precompile(T),this.techniques.precompile(A)}render(e){const t=e.find(({name:e})=>e===P.OPAQUE);if(this._handleFading(),!this._data.visibleGaussians||!this._data.orderTexture.texture||!this._data.textureAtlas.texture)return t;const s=!!this.renderingContext.capabilities.drawBuffersIndexed,i=s?this.techniques.get(G,this._configuration):null,a=s?null:this.techniques.get(y,this._colorOnlyConfiguration),r=s?null:this.techniques.get(E,this._depthOnlyConfiguration),n=this.techniques.get(T),o=this.techniques.get(A);if(!(i?.compiled||a?.compiled&&r?.compiled)||!o.compiled||!n.compiled)return this.requestRender(1),t;const{fullWidth:l,fullHeight:h}=this.bindParameters.camera;this._prepareParameters(h,l);const u=this.renderingContext,p=this.fboCache,c=p.acquire(l,h,"gaussian color output"),d=t.getAttachment(j);c.attachDepth(d);let m=null;s?this._singlePass(c,i):m=this._multiPass(c,d,a,r);const _=p.acquire(l,h,this.produces);return this._depthCompositionPassParameters.splatDepth=m?m.getTexture():c.getTexture(F),_.attachDepth(t.getAttachment(j)),u.bindFramebuffer(_.fbo),u.bindTechnique(o,this.bindParameters,this._depthCompositionPassParameters),u.screen.draw(),this._compositionPassParameters.color=t.getTexture(),this._compositionPassParameters.splatColor=c.getTexture(),u.bindFramebuffer(_.fbo),u.bindTechnique(n,this.bindParameters,this._compositionPassParameters),u.screen.draw(),c.release(),m?.release(),_}intersect(e,t,s,i){const{gaussianPosition:a,intersectionRayDir:p,intersectionPlane:c,layerViewUid:f}=this,P=g(s,i);r(p,i,s);const S=1/n(p);o(p,p,S);const x=d();l(x,p),_(c,p[0],p[1],p[2],-h(p,s));const v=new U,y=new U,D=new Array;this._data.visibleGaussianTiles.forEach(r=>{const{maxScale:n}=r,o=r.obb.minimumDistancePlane(c),l=r.obb.maximumDistancePlane(c),d=l<0,_=null!=v.dist&&null!=y.dist&&v.dist<o*S&&y.dist>l*S;if(d||_)return;if(!new b(r.obb.center,r.obb.radius+n).intersectRay(P,null))return;if(!r.obb.intersectRay(s,p,n))return;const{positions:g,squaredScales:C,gaussianAtlasIndices:w}=r,T=w.length;for(let c=0;c<T;c++){const r=3*c;a[0]=g[r]-s[0],a[1]=g[r+1]-s[1],a[2]=g[r+2]-s[2];const n=C[c],o=h(a,p),l=o*o;if(u(a)-l>n)continue;const d=o*S,_=e=>(e.point=e.point?e.point.fill(a[0],a[1],a[2]):m(a),e.dist=d,e.normal=x,e.layerViewUid=f,e);if((null==v.dist||d<v.dist)&&(null==t||t(s,i,d))&&_(v),0!==e.options.store&&(null==y.dist||d>y.dist)&&(null==t||t(s,i,d))&&_(y),2===e.options.store&&(null==t||t(s,i,d))){const e=new U;D.push(_(e))}}});const T=(e,t)=>{const{layerViewUid:s}=t,i=new C(t.point,s);e.set(0,i,t.dist,t.normal)};if(R(v)){const t=e.results.min;(null==t.distance||v.dist<t.distance)&&T(t,v)}if(R(y)&&0!==e.options.store){const t=e.results.max;(null==t.distance||y.dist>t.distance)&&T(t,y)}if(2===e.options.store)for(const r of D){const t=new w(P);T(t,r),e.results.all.push(t)}}get slicePlaneEnabled(){return this._slicePlaneEnabled}set slicePlaneEnabled(e){this._slicePlaneEnabled!==e&&(this._slicePlaneEnabled=e,this.requestRender(1))}get data(){return this._data}destroy(){this._data.destroy(),super.destroy()}_onCameraChange(){const e=this.view.state.camera.eye,t=this.view.state.camera.ray.direction,s=.001;(Math.abs(e[0]-this._previousCameraPosition[0])>s||Math.abs(e[1]-this._previousCameraPosition[1])>s||Math.abs(e[2]-this._previousCameraPosition[2])>s||Math.abs(t[0]-this._previousCameraDirection[0])>s||Math.abs(t[1]-this._previousCameraDirection[1])>s||Math.abs(t[2]-this._previousCameraDirection[2])>s)&&(p(this._previousCameraPosition,e),p(this._previousCameraDirection,t),this._data.requestSort())}_prepareParameters(e,t){this._passParameters.totalGaussians=this._data.visibleGaussians,this._passParameters.splatOrder=this._data.orderTexture.texture,this._passParameters.splatFading=this._data.fadingTexture.texture,this._passParameters.splatAtlas=this._data.textureAtlas.texture;const s=Math.tan(.5*this.camera.fovY),i=s/e*t;a(this._passParameters.tanFov,i,s),this._passParameters.focalLength=e/(2*s);const r=this.view.qualitySettings.gaussianSplat.minimumSplatPixelRadius;this._passParameters.minSplatRadius=r*Math.sqrt(t*e)/Math.sqrt(2073600),this._prepareHighPrecisionCameraPosition()}_singlePass(e,t){const s=this.renderingContext,i=this.renderingContext.gl,a=this.renderingContext.capabilities.drawBuffersIndexed;e.acquireColor(F,this._getDepthTextureFormat(),"gaussian depth output"),s.bindFramebuffer(e.fbo),s.setClearColor(0,0,0,0),s.clear(16384),this.renderingContext.bindTechnique(t,this.bindParameters,this._passParameters),a.enableiOES(i.BLEND,0),a.blendEquationSeparateiOES(0,i.FUNC_ADD,i.FUNC_ADD),a.blendFuncSeparateiOES(0,i.ONE_MINUS_DST_ALPHA,i.ONE,i.ONE_MINUS_DST_ALPHA,i.ONE),a.enableiOES(i.BLEND,1),a.blendEquationSeparateiOES(1,i.FUNC_ADD,i.FUNC_ADD),a.blendFuncSeparateiOES(1,i.ONE_MINUS_DST_ALPHA,i.DST_ALPHA,i.ONE_MINUS_DST_ALPHA,i.ONE),this.renderingContext.drawArraysInstanced(N.TRIANGLE_STRIP,0,4,this._data.visibleGaussians)}_multiPass(e,t,s,i){const{fullWidth:a,fullHeight:r}=this.bindParameters.camera,n=this.renderingContext;n.bindFramebuffer(e.fbo),n.setClearColor(0,0,0,0),n.clear(16384),this.renderingContext.bindTechnique(s,this.bindParameters,this._passParameters),this.renderingContext.drawArraysInstanced(N.TRIANGLE_STRIP,0,4,this._data.visibleGaussians);const o=this.fboCache.acquire(a,r,"gaussian depth output",this._getDepthTextureFormat());return o.attachDepth(t),n.bindFramebuffer(o.fbo),n.setClearColor(0,0,0,0),n.clear(16384),this.renderingContext.bindTechnique(i,this.bindParameters,this._passParameters),this.renderingContext.drawArraysInstanced(N.TRIANGLE_STRIP,0,4,this._data.visibleGaussians),o}_prepareHighPrecisionCameraPosition(){o(this._passParameters.tileCameraPosition,this.camera.eye,1/I.tileSize),c(this._passParameters.tileCameraPosition,this._passParameters.tileCameraPosition),o(this._passParameters.cameraDelta,this._passParameters.tileCameraPosition,I.tileSize),r(this._passParameters.cameraDelta,this.camera.eye,this._passParameters.cameraDelta)}_handleFading(){if(0===this.fadeHelper.numFadingTiles)return void(this._previousFrameStart=null);this._previousFrameStart??=this.view.stage.renderer.renderContext.time;const e=this.view.stage?.renderer.renderContext.time-this._previousFrameStart;this.fadeHelper.updateAllTileFading(e),this._previousFrameStart=this.view.stage.renderer.renderContext.time,this._data.fadingTexture.updateTexture(this._data.textureAtlas.pageAllocator.pageCount)}_getDepthTextureFormat(){return this.renderingContext.capabilities.colorBufferFloat?.floatBlend?9:8}static{this.tileSize=2.048}};function R(e){return null!=e.dist&&null!=e.point}e([s({constructOnly:!0})],H.prototype,"fadeHelper",void 0),H=I=e([i("esri.views.3d.webgl-engine.lib.GaussianSplatRenderNode")],H);class U{constructor(){this.point=null,this.dist=null,this.normal=null,this.layerViewUid=""}}export{H as GaussianSplatRenderNode};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{releaseMaybe as e}from"../../../../core/maybe.js";import{f as i}from"../../../../chunks/vec42.js";import{ZEROS as t}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 l{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,t,s,r){this._size.width=e,this._size.height=t,h(this._size,this._fbos.rctx.parameters.maxTextureSize);const o=this._color;return this._color=null,this.releaseDepth(),this._requiresEmission=r,i(this._clearColor,s),o}releaseDepth(){this._color?.detachDepth(),this._depth=e(this._depth)}update(e){const i=this._ensureColor();i.attachDepth(this.depth),this._color=e(i)}bind(){const{rctx:e}=this._fbos,i=null==this._color;this.color.attachDepth(this.depth),e.bindFramebuffer(this.color.fbo),i&&(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,t))}_acquireColor(){return this._requiresEmission?this._fbos.acquire(this._size.width,this._size.height,"main color").acquireColor(o,8,"emissive"):this._fbos.acquire(this._size.width,this._size.height,"main color")}_acquireDepth(){return this._fbos.acquireDepth(13,this._size.width,this._size.height,"main 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{l as MainFramebuffer};
5
+ import{releaseMaybe as e}from"../../../../core/maybe.js";import{f as i}from"../../../../chunks/vec42.js";import{ZEROS as t}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 l{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,t,s,r){this._size.width=e,this._size.height=t,h(this._size,this._fbos.rctx.parameters.maxTextureSize);const o=this._color;return this._color=null,this.releaseDepth(),this._requiresEmission=r,i(this._clearColor,s),o}releaseDepth(){this._color?.detachDepth(),this._depth=e(this._depth)}update(e){const i=this._ensureColor();i.attachDepth(this.depth),this._color=e(i)}bind(){const{rctx:e}=this._fbos,i=null==this._color;this.color.attachDepth(this.depth),e.bindFramebuffer(this.color.fbo),i&&(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,t))}_acquireColor(){return this._requiresEmission?this._fbos.acquire(this._size.width,this._size.height,"main color").acquireColor(o,8,"emissive"):this._fbos.acquire(this._size.width,this._size.height,"main color")}_acquireDepth(){return this._fbos.acquireDepth(14,this._size.width,this._size.height,"main 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{l 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/5.0/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{l as a,p as h,D as n,h as m,i as d,m as l,d as c}from"../../../../chunks/vec32.js";import{create as g,fromValues as _}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{Sphere as u}from"../../../../geometry/support/sphere.js";import{maxScale as f}from"../../support/mathUtils.js";import{Object3DOccludeeStateID as b,Object3DHighlightStateID as v}from"./Object3DStateID.js";import{assert as p}from"./Util.js";import{affectsGeometry as y}from"./VertexAttribute.js";import{addObject3DStateID as j,removeObject3DStateID as V}from"../materials/renderers/utils.js";class S{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 x),this._geometries=i.geometries?Array.from(i.geometries):[]}dispose(){this._geometries.length=0}get layer(){return this._layer}set layer(t){p(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}),y(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 b;for(const i of this._geometries)i.occludees=j(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 v(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=new W,this._validateBoundingVolume(this._bvWorldSpace,0)),this._bvWorldSpace}get boundingVolumeObjectSpace(){return this._bvObjectSpace||(this._bvObjectSpace=new W,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&&A(i,t,e?s.transformation:this.getCombinedShaderTransformation(s))}a(t.bounds.center,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=f(o);h(B,i.center,o);const a=n(B,t.bounds.center),m=i.radius*r;t.bounds.radius=Math.max(t.bounds.radius,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 x{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 W extends x{constructor(){super(...arguments),this.bounds=new u}}function A(t,i,e){const o=t.bbMin,r=t.bbMax;if(s(e)){const t=m(M,e[12],e[13],e[14]);return d(T,o,t),d(C,r,t),i.minWith(T),void i.maxWith(C)}if(h(T,o,e),l(o,r))return i.minWith(T),void i.maxWith(T);h(C,r,e),i.minWith(T),i.minWith(C),i.maxWith(T),i.maxWith(C);for(let s=0;s<3;++s)c(T,o),c(C,r),T[s]=r[s],C[s]=o[s],h(T,T,e),h(C,C,e),i.minWith(T),i.minWith(C),i.maxWith(T),i.maxWith(C)}const M=g(),T=g(),C=g(),B=g();export{W as BoundingVolume,S 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{l as a,p as h,B as n,h as m,i as d,m as l,d as c}from"../../../../chunks/vec32.js";import{create as g,fromValues as _}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{Sphere as u}from"../../../../geometry/support/sphere.js";import{maxScale as f}from"../../support/mathUtils.js";import{Object3DOccludeeStateID as b,Object3DHighlightStateID as v}from"./Object3DStateID.js";import{assert as p}from"./Util.js";import{affectsGeometry as y}from"./VertexAttribute.js";import{addObject3DStateID as j,removeObject3DStateID as V}from"../materials/renderers/utils.js";class S{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 x),this._geometries=i.geometries?Array.from(i.geometries):[]}dispose(){this._geometries.length=0}get layer(){return this._layer}set layer(t){p(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}),y(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 b;for(const i of this._geometries)i.occludees=j(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 v(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=new W,this._validateBoundingVolume(this._bvWorldSpace,0)),this._bvWorldSpace}get boundingVolumeObjectSpace(){return this._bvObjectSpace||(this._bvObjectSpace=new W,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&&A(i,t,e?s.transformation:this.getCombinedShaderTransformation(s))}a(t.bounds.center,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=f(o);h(B,i.center,o);const a=n(B,t.bounds.center),m=i.radius*r;t.bounds.radius=Math.max(t.bounds.radius,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 x{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 W extends x{constructor(){super(...arguments),this.bounds=new u}}function A(t,i,e){const o=t.bbMin,r=t.bbMax;if(s(e)){const t=m(M,e[12],e[13],e[14]);return d(T,o,t),d(C,r,t),i.minWith(T),void i.maxWith(C)}if(h(T,o,e),l(o,r))return i.minWith(T),void i.maxWith(T);h(C,r,e),i.minWith(T),i.minWith(C),i.maxWith(T),i.maxWith(C);for(let s=0;s<3;++s)c(T,o),c(C,r),T[s]=r[s],C[s]=o[s],h(T,T,e),h(C,C,e),i.minWith(T),i.minWith(C),i.maxWith(T),i.maxWith(C)}const M=g(),T=g(),C=g(),B=g();export{W as BoundingVolume,S as Object3D};