@arcgis/core 5.2.0-next.89 → 5.2.0-next.90

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 (140) hide show
  1. package/assets/esri/core/workers/RemoteClient.js +1 -1
  2. package/assets/esri/core/workers/chunks/05fbd1f373cfa3724f0c.js +1 -0
  3. package/assets/esri/core/workers/chunks/{f7f2102b16d201e5f531.js → 0d2e2d90a4e4a28e2c0c.js} +1 -1
  4. package/assets/esri/core/workers/chunks/1554feab934e8e1bcd28.js +1 -0
  5. package/assets/esri/core/workers/chunks/{823dd85b008ae4db6793.js → 188c6ff5f4664827c254.js} +2 -2
  6. package/assets/esri/core/workers/chunks/{d30a7fc8dab4ebb8893b.js → 1ab8307ba9981124f669.js} +1 -1
  7. package/assets/esri/core/workers/chunks/{5ed89c862eee1345e3af.js → 20f7b5fe64a217cb3d3d.js} +1 -1
  8. package/assets/esri/core/workers/chunks/{013a4ee14c44eb824c7c.js → 24c44541046576fee7e0.js} +2 -2
  9. package/assets/esri/core/workers/chunks/{f3716ce04d09af31cfb1.js → 2754ba5cc094028a7a3c.js} +1 -1
  10. package/assets/esri/core/workers/chunks/{e8b4f12dfbf568377cef.js → 3a65693964e3976d8035.js} +1 -1
  11. package/assets/esri/core/workers/chunks/423c2692df662b3dddd4.js +1 -0
  12. package/assets/esri/core/workers/chunks/{996211727ed1617162da.js → 48726010778d6004e347.js} +2 -2
  13. package/assets/esri/core/workers/chunks/{680557b8832fbdab7f46.js → 4bf7c0c874d30b1c0760.js} +1 -1
  14. package/assets/esri/core/workers/chunks/{db180f8d25471cfa48af.js → 545bec045167c433af8f.js} +1 -1
  15. package/assets/esri/core/workers/chunks/5782c0362a1799ceef41.js +1 -0
  16. package/assets/esri/core/workers/chunks/{5bf65dbfd9c7a5ea187d.js → 5aa23b0f4521ba9a07ad.js} +1 -1
  17. package/assets/esri/core/workers/chunks/{eda04911553cf99fb99b.js → 606ac9358f508bda94f2.js} +1 -1
  18. package/assets/esri/core/workers/chunks/625a692f00357629f609.js +1 -0
  19. package/assets/esri/core/workers/chunks/{bd2602195e265f8fdb15.js → 69c9a12c97ead8963817.js} +1 -1
  20. package/assets/esri/core/workers/chunks/{2f3bbc1f7d4abbbeec2f.js → 6ab7bb3834841834f839.js} +1 -1
  21. package/assets/esri/core/workers/chunks/{afa6b74d9ca9ed0154af.js → 6fd0d9431b141f2a3252.js} +1 -1
  22. package/assets/esri/core/workers/chunks/{3f82410d9f701e7ad8eb.js → 76e7d3cde2da4bdd7820.js} +1 -1
  23. package/assets/esri/core/workers/chunks/{ea75c23c44452f45a949.js → 7cf903db44f3647c8fd4.js} +1 -1
  24. package/assets/esri/core/workers/chunks/848a9f0e5373bbf289a5.js +1 -0
  25. package/assets/esri/core/workers/chunks/{a88bf8ae93077e1b48cf.js → 8a87e1a89a0d8c6203a7.js} +1 -1
  26. package/assets/esri/core/workers/chunks/{a3b403f8acb90af19adb.js → 91ac9328afff8a51bd96.js} +1 -1
  27. package/assets/esri/core/workers/chunks/{00181785a180e934bf7c.js → 91de343844ac578e7c93.js} +1 -1
  28. package/assets/esri/core/workers/chunks/{d871572997600930e017.js → 95a3f09751bff63f4fab.js} +1 -1
  29. package/assets/esri/core/workers/chunks/{ffe749d790320dddfa74.js → 97e41500fc2d24a88938.js} +1 -1
  30. package/assets/esri/core/workers/chunks/{6fe7060235f601b180ea.js → 98d614d6fc9de8ebaf94.js} +1 -1
  31. package/assets/esri/core/workers/chunks/{1e087fb13b7b0a5d6fec.js → 9d3cdfa08ef4d2805625.js} +1 -1
  32. package/assets/esri/core/workers/chunks/{0460ea5a85e9c3c2e1b7.js → a89dbef8155d7c4354da.js} +2 -2
  33. package/assets/esri/core/workers/chunks/{e9f29019aa78f07ace66.js → aed7b80145b22c246098.js} +1 -1
  34. package/assets/esri/core/workers/chunks/{4aefe6fd4d725a107758.js → b7ed5f130661e9ca00b9.js} +1 -1
  35. package/assets/esri/core/workers/chunks/c07d2fb9940b2c6eda9f.js +1 -0
  36. package/assets/esri/core/workers/chunks/{a8b878c12cb1a6ea012b.js → c4a0d3149947a1d2c484.js} +1 -1
  37. package/assets/esri/core/workers/chunks/{31a0620a6028e94c7532.js → c6ec0e966106f66360d9.js} +2 -2
  38. package/assets/esri/core/workers/chunks/{5df0639839a354cb2751.js → c7f69d010f1cb32f5d37.js} +1 -1
  39. package/assets/esri/core/workers/chunks/{23addf8b11938e0c96e9.js → cb983f65995e57fff7a1.js} +1 -1
  40. package/assets/esri/core/workers/chunks/{f665fb4c5633e0a459d8.js → d24125a791247019e2ca.js} +1 -1
  41. package/assets/esri/core/workers/chunks/{7b7d0e93689aab8da83d.js → d44338bf5edafa3ca926.js} +1 -1
  42. package/assets/esri/core/workers/chunks/{2ceb07b125c84b51f02a.js → d7d5275d8b3c9430de1f.js} +1 -1
  43. package/assets/esri/core/workers/chunks/{ce227146fcaabf088da1.js → da8a314800944706511b.js} +1 -1
  44. package/assets/esri/core/workers/chunks/{705f459aab890fda134b.js → e018cbd97e6e0e4ca5c4.js} +1 -1
  45. package/assets/esri/core/workers/chunks/e55507e4114b34d1ef4e.js +1 -0
  46. package/assets/esri/core/workers/chunks/{6b06858bb9e976c1ef33.js → e594b6db9caee1f7b9fc.js} +1 -1
  47. package/assets/esri/core/workers/chunks/{4057d97a4ec234978697.js → e90076ac1cf88a83a7f9.js} +1 -1
  48. package/assets/esri/core/workers/chunks/{e40e08029325f43452d0.js → f4d351b4cd9d1aa10632.js} +1 -1
  49. package/assets/esri/core/workers/chunks/f5f5b54cab722abe88e0.js +1 -0
  50. package/assets/esri/core/workers/chunks/{d8e2d78fc4526612aad6.js → ff83d0337ac489ab08de.js} +2 -2
  51. package/config.js +1 -1
  52. package/core/EuclideanDistanceTransform.js +2 -0
  53. package/geometry/support/convexPolyhedron.js +1 -1
  54. package/geometry/support/frustumPlanes.js +2 -0
  55. package/kernel.js +1 -1
  56. package/layers/ParquetLayer.d.ts +3 -2
  57. package/layers/ParquetLayer.js +1 -1
  58. package/layers/support/dataSeriesUtils.js +1 -1
  59. package/package.json +3 -3
  60. package/popup/FeatureContentCollection.d.ts +6 -0
  61. package/popup/FeatureContentCollection.js +1 -1
  62. package/rest/support/AlgorithmicColorRamp.d.ts +2 -2
  63. package/rest/support/types.d.ts +2 -2
  64. package/smartMapping/raster/support/colorRamps.d.ts +4 -3
  65. package/support/revision.js +1 -1
  66. package/symbols/cim/CIMSymbolDrawHelper.js +1 -1
  67. package/symbols/cim/CIMSymbolHelper.js +1 -1
  68. package/symbols/cim/CIMSymbolRasterizer.js +1 -1
  69. package/symbols/cim/Rasterizer.js +1 -1
  70. package/symbols/cim/cimAnalyzer.js +1 -1
  71. package/symbols/cim/rasterizingUtils.js +1 -1
  72. package/symbols/cim/utils.js +1 -1
  73. package/views/2d/engine/webgl/GlyphSDFCreator.js +1 -1
  74. package/views/2d/engine/webgl/SDFConverter.js +1 -1
  75. package/views/2d/engine/webgl/SpriteMosaic.js +1 -1
  76. package/views/2d/engine/webgl/TextureManager.js +1 -1
  77. package/views/2d/engine/webgl/shaderGraph/techniques/animated/AnimatedTechnique.js +1 -1
  78. package/views/2d/engine/webgl/shaderGraph/techniques/fill/ComplexFillTechnique.js +1 -1
  79. package/views/2d/engine/webgl/shaderGraph/techniques/fill/ComplexOutlineFillTechnique.js +1 -1
  80. package/views/2d/engine/webgl/shaderGraph/techniques/fill/GradientFillTechnique.js +1 -1
  81. package/views/2d/engine/webgl/shaderGraph/techniques/fill/PatternFillTechnique.js +1 -1
  82. package/views/2d/engine/webgl/shaderGraph/techniques/fill/PatternOutlineFillTechnique.js +1 -1
  83. package/views/2d/engine/webgl/shaderGraph/techniques/labels/LabelTechnique.js +1 -1
  84. package/views/2d/engine/webgl/shaderGraph/techniques/line/GradientStrokeTechnique.js +1 -1
  85. package/views/2d/engine/webgl/shaderGraph/techniques/line/LineMeshWriter.js +1 -1
  86. package/views/2d/engine/webgl/shaderGraph/techniques/line/TexturedLineTechnique.js +1 -1
  87. package/views/2d/engine/webgl/shaderGraph/techniques/markers/MarkerTechnique.js +1 -1
  88. package/views/2d/engine/webgl/shaderGraph/techniques/mesh/MeshWriterInputEvaluator.js +1 -1
  89. package/views/2d/engine/webgl/shaderGraph/techniques/text/TextTechnique.js +1 -1
  90. package/views/2d/layers/features/schema/processor/symbols/ComplexSymbolSchema.js +1 -1
  91. package/views/2d/tiling/LODInfo.js +1 -1
  92. package/views/3d/interactive/visualElements/ExtendedLineVisualElement.js +1 -1
  93. package/views/3d/layers/i3s/I3SIntersectionHandler.js +1 -1
  94. package/views/3d/layers/i3s/I3SViewportQueries.js +1 -1
  95. package/views/3d/layers/support/FeatureTileMeasurements3D.js +1 -1
  96. package/views/3d/layers/support/FeatureTileVisibility3D.js +1 -1
  97. package/views/3d/state/Frustum.js +1 -1
  98. package/views/3d/state/controllers/RopePullController.js +1 -1
  99. package/views/3d/state/controllers/momentum/RopePullMomentumController.js +2 -0
  100. package/views/3d/support/SweptSphereVolume.js +2 -0
  101. package/views/3d/support/viewpointUtils.js +1 -1
  102. package/views/3d/terrain/PatchRenderData.js +1 -1
  103. package/views/3d/terrain/PatchRenderDataWaterproofness.js +1 -1
  104. package/views/3d/terrain/PlanarPatch.js +1 -1
  105. package/views/3d/terrain/SphericalPatch.js +1 -1
  106. package/views/3d/terrain/TerrainSurface.js +1 -1
  107. package/views/3d/terrain/Tile.js +1 -1
  108. package/views/3d/webgl/RenderCamera.js +1 -1
  109. package/views/3d/webgl-engine/collections/Component/ComponentObjectElevationAgnosticBVH.js +1 -1
  110. package/views/3d/webgl-engine/collections/Component/ComponentObjectElevationAgnosticComponentGeometryBVH.js +1 -1
  111. package/views/3d/webgl-engine/effects/laserlines/LaserLineRenderer.js +1 -1
  112. package/views/3d/webgl-engine/lib/Intersector.js +1 -1
  113. package/views/3d/webgl-engine/lib/Octree.js +1 -1
  114. package/views/3d/webgl-engine/lib/TriangleIntersectionData.js +1 -1
  115. package/views/3d/webgl-engine/lib/depthRangeUtils.js +1 -1
  116. package/views/3d/webgl-engine/lib/screenPolygonIntersectionUtils.js +1 -1
  117. package/views/3d/webgl-engine/lib/screenPolygonTriangleIntersections.js +1 -1
  118. package/views/draw/support/managers/InteractiveHandleManager.js +1 -1
  119. package/views/navigation/RopePullMomentumEstimator.js +2 -0
  120. package/views/support/LayerLayerViewInfo.js +1 -1
  121. package/views/support/LayerViewManager.js +1 -1
  122. package/widgets/Features/FeaturesViewModel.d.ts +6 -0
  123. package/widgets/Features/FeaturesViewModel.js +1 -1
  124. package/widgets/Features.js +1 -1
  125. package/assets/esri/core/workers/chunks/028bee58f7bc19e5e39e.js +0 -1
  126. package/assets/esri/core/workers/chunks/39b6a5222f45cb8dbc94.js +0 -1
  127. package/assets/esri/core/workers/chunks/51c9bd7c03d780fadebc.js +0 -1
  128. package/assets/esri/core/workers/chunks/71308dca3fd05687e7bd.js +0 -1
  129. package/assets/esri/core/workers/chunks/8d8708789843844eb9e1.js +0 -1
  130. package/assets/esri/core/workers/chunks/9246e2468528650bdc7c.js +0 -1
  131. package/assets/esri/core/workers/chunks/94453d075ce02eff4844.js +0 -1
  132. package/assets/esri/core/workers/chunks/a176727a1148ca4fb432.js +0 -1
  133. package/assets/esri/core/workers/chunks/f106cc7f559856f69b9f.js +0 -1
  134. package/geometry/support/frustum.js +0 -2
  135. package/views/3d/layers/i3s/SweptSphereVolume.js +0 -2
  136. /package/assets/esri/core/workers/chunks/{823dd85b008ae4db6793.js.LICENSE.txt → 188c6ff5f4664827c254.js.LICENSE.txt} +0 -0
  137. /package/assets/esri/core/workers/chunks/{013a4ee14c44eb824c7c.js.LICENSE.txt → 24c44541046576fee7e0.js.LICENSE.txt} +0 -0
  138. /package/assets/esri/core/workers/chunks/{996211727ed1617162da.js.LICENSE.txt → 48726010778d6004e347.js.LICENSE.txt} +0 -0
  139. /package/assets/esri/core/workers/chunks/{0460ea5a85e9c3c2e1b7.js.LICENSE.txt → a89dbef8155d7c4354da.js.LICENSE.txt} +0 -0
  140. /package/assets/esri/core/workers/chunks/{d8e2d78fc4526612aad6.js.LICENSE.txt → ff83d0337ac489ab08de.js.LICENSE.txt} +0 -0
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{copy as e,subtract as t,exactEquals as i,negate as r}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as s,fromValues as n}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{exactEquals as a,copy as o}from"../../../../core/libs/gl-matrix-2/math/vec4.js";import{fromValues as l,clone as h}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{fromRay as d,getStart as _,getEnd as p,create as c}from"../../../../geometry/support/clipRay.js";import{intersectClipRay as u}from"../../../../geometry/support/frustum.js";import{fromPoints as m,pointAt as f,create as y}from"../../../../geometry/support/lineSegment.js";import{create as g,fromPoints as b}from"../../../../geometry/support/ray.js";import{EngineVisualElement as D}from"./EngineVisualElement.js";import{LaserlineVisualElement as w}from"./LaserlineVisualElement.js";import{drapedZ as O}from"../../terrain/DrapedZ.js";import{createPolylineGeometry as j}from"../../webgl-engine/lib/GeometryUtil.js";import{RenderGeometry as x}from"../../webgl-engine/lib/RenderGeometry.js";import{RibbonLineMaterial as C}from"../../webgl-engine/materials/RibbonLineMaterial.js";class E extends D{constructor(e){super(e),this._ray=g(),this._isWorldDown=!1,this._start=s(),this._end=n(1,0,0),this._width=1,this._color=l(1,0,1,1),this._polygonOffset=!1,this._writeDepthEnabled=!0,this._innerWidth=0,this._innerColor=l(1,1,1,1),this._stipplePattern=null,this._stippleOffColor=null,this._stipplePreferContinuous=!0,this._falloff=0,this._extensionType=0,this._laserlineStyle=null,this._laserlineEnabled=!1,this._renderOccluded=4,this._fadedExtensions=A,this._laserline=new w({view:this.view,isDecoration:e.isDecoration}),this.applyProperties(e)}destroy(){this._laserline.destroy(),super.destroy()}createObject3DResourceFactory(e){return{view:e,createResources:e=>this._createObject3DResources(e),destroyResources:G,recreateGeometry:(e,t)=>this._recreateObject3DGeometry(e,t),cameraChanged:()=>this._updateGeometry(),forEachMaterial:(e,t)=>t(e.material)}}createDrapedResourceFactory(e){return{view:e,createResources:()=>this._createDrapedResources(),destroyResources:G,recreateGeometry:e=>this._recreateDrapedGeometry(e),forEachMaterial:(e,t)=>t(e.material)}}updateVisibility(e){super.updateVisibility(e),this._laserline.visible=e}onAttachedChange(){this._laserline.attached=this._laserlineAttached}setStartEndFromWorldDownAtLocation(i){this._isWorldDown=!0,e(this._start,i),this.view.renderCoordsHelper.worldUpAtPosition(i,this._end),t(this._end,i,this._end),b(this._start,this._end,this._ray),this._updateGeometry()}get start(){return this._start}set start(t){this._isWorldDown=!1,i(this._start,t)||(e(this._start,t),b(this._start,this._end,this._ray),this._updateGeometry())}get end(){return this._end}set end(t){this._isWorldDown=!1,i(this._end,t)||(e(this._end,t),b(this._start,this._end,this._ray),this._updateGeometry())}get width(){return this._width}set width(e){e!==this._width&&(this._width=e,this._updateMaterial())}get color(){return this._color}set color(e){a(e,this._color)||(o(this._color,e),this._updateMaterial())}get polygonOffset(){return this._polygonOffset}set polygonOffset(e){e!==this._polygonOffset&&(this._polygonOffset=e,this._updateMaterial())}get writeDepthEnabled(){return this._writeDepthEnabled}set writeDepthEnabled(e){this._writeDepthEnabled!==e&&(this._writeDepthEnabled=e,this._updateMaterial())}get innerWidth(){return this._innerWidth}set innerWidth(e){e!==this._innerWidth&&(this._innerWidth=e,this._updateMaterial())}get innerColor(){return this._innerColor}set innerColor(e){a(e,this._innerColor)||(o(this._innerColor,e),this._updateMaterial())}get stipplePattern(){return this._stipplePattern}set stipplePattern(e){const t=null!=e!=(null!=this._stipplePattern);this._stipplePattern=e,t?this.recreate():this._updateMaterial()}get stippleOffColor(){return this._stippleOffColor}set stippleOffColor(e){null!=e&&null!=this._stippleOffColor&&a(e,this._stippleOffColor)||(this._stippleOffColor=null!=e?h(e):null,this._updateMaterial())}get stipplePreferContinuous(){return this._stipplePreferContinuous}set stipplePreferContinuous(e){e!==this._stipplePreferContinuous&&(this._stipplePreferContinuous=e,this._updateMaterial())}get falloff(){return this._falloff}set falloff(e){e!==this._falloff&&(this._falloff=e,this._updateMaterial())}get extensionType(){return this._extensionType}set extensionType(e){e!==this._extensionType&&(this._extensionType=e,this.recreateGeometry())}get _laserlineAttached(){return this._laserlineEnabled&&null!=this._laserlineStyle&&this.attached&&!this.isDraped}get laserlineStyle(){return this._laserlineStyle}set laserlineStyle(e){this._laserlineStyle=e,this._laserline.attached=this._laserlineAttached,null!=e&&(this._laserline.style=e)}get laserlineEnabled(){return this._laserlineEnabled}set laserlineEnabled(e){this._laserlineEnabled!==e&&(this._laserlineEnabled=e,this._laserline.attached=this._laserlineAttached)}get renderOccluded(){return this._renderOccluded}set renderOccluded(e){e!==this._renderOccluded&&(this._renderOccluded=e,this._updateMaterial())}get _normalizedRenderOccluded(){return this.isDraped&&8===this._renderOccluded?4:this._renderOccluded}get fadedExtensions(){return this._fadedExtensions}set fadedExtensions(e){this._fadedExtensions=e??A,this.recreateGeometry()}_updateMaterial(){const{materialParameters:e}=this;this.object3dResources.resources?.material.setParameters(e),this.drapedResources.resources?.material.setParameters(e)}get materialParameters(){return{width:this._width,color:this._color,stippleOffColor:this._stippleOffColor,stipplePattern:this._stipplePattern,stipplePreferContinuous:this._stipplePreferContinuous,innerWidth:this._innerWidth,innerColor:this._innerColor,falloff:this._falloff,polygonOffset:this._polygonOffset?3:0,renderOccluded:this._normalizedRenderOccluded,isDecoration:this.isDecoration,writeDepth:this._writeDepthEnabled}}_createObject3DResources(e){const t=new C(this.materialParameters,this.view.state.isGlobal),i=new Array;return this._createObject3DGeometry(t,e,i),{material:t,geometries:i}}_recreateObject3DGeometry(e,t){e.geometries.length=0,this._createObject3DGeometry(e.material,t,e.geometries)}_createObject3DGeometry(e,t,i){const r=this._createGeometry(e);i.push(r),t.addGeometry(r),this._updateVerticesObject3D(t)}_createDrapedResources(){const e=new C(this.materialParameters,this.view.state.isGlobal);return{material:e,geometries:[this._createDrapedGeometry(e)]}}_recreateDrapedGeometry(e){e.geometries=[this._createDrapedGeometry(e.material)]}_createDrapedGeometry(e){const t=this._createGeometry(e);return this._updateVerticesDraped(t),new x(t)}_createGeometry(e){const t=3===this.extensionType,i=t?[s(),s(),s(),s()]:[s(),s()];return j(e,i,null,t?[1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,0]:null)}_updateGeometry(){if(this.isDraped)this.drapedResources.recreateGeometry();else{const e=this.object3dResources.object;e&&this._updateVerticesObject3D(e)}}_updateVerticesObject3D(e){const t=this._lineSegment;this._updateVertexAttributesObject3D(e,t),this._laserline.intersectsLine=t}_updateVerticesDraped(e){this._updateVertexAttributesDraped(e,this._lineSegment)}get _lineSegment(){return 3===this._extensionType?this._updateLineSegmentFinite(M):this._updateLineSegmentInfinite(this._extensionType,M)}_updateLineSegmentFinite(e){return m(this._start,this._end,e)}_updateLineSegmentInfinite(e,t){const i=this.view.state.camera;switch(d(this._ray,P),e){case 0:P.c0=-Number.MAX_VALUE;break;case 1:case 2:{const e=this._ray.origin,t=this.view.elevationProvider.getElevation(e[0],e[1],e[2],this.view.renderCoordsHelper.spatialReference,"ground")??0,i=this.view.renderCoordsHelper.getAltitude(e);this._isWorldDown&&i<t&&r(P.ray.direction,P.ray.direction),2===this._extensionType&&null!=t&&(P.c1=Math.abs(i-t));break}}if(!u(i.frustum,P))return this._updateLineSegmentFinite(t);const s=_(P,v),n=p(P,R);return m(s,n,t)}_updateVertexAttributesObject3D(e,t){const i=e.geometries[0].getMutableAttribute("position")?.data;if(!i)return;let r=0;for(const s of this._lineVertices(t))i[r++]=s[0],i[r++]=s[1],i[r++]=s[2];e.geometryVertexAttributeUpdated(e.geometries[0],"position")}_updateVertexAttributesDraped(e,t){const i=e.getMutableAttribute("position")?.data;if(!i)return;let r=0;for(const s of this._lineVertices(t))i[r++]=s[0],i[r++]=s[1],i[r++]=O;e.invalidateBoundingInfo()}*_lineVertices(e){3===this.extensionType?(yield f(e,-this.fadedExtensions.start,v),yield f(e,0,v),yield f(e,1,v),yield f(e,1+this.fadedExtensions.end,v)):(yield f(e,0,v),yield f(e,1,v))}}function G(e){e.geometries=[]}const P=c(),v=s(),R=s(),M=y(),V=1/3,A={start:V,end:V};export{E as ExtendedLineVisualElement};
2
+ import{copy as e,subtract as t,exactEquals as i,negate as r}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as s,fromValues as n}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{exactEquals as a,copy as o}from"../../../../core/libs/gl-matrix-2/math/vec4.js";import{fromValues as l,clone as h}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{fromRay as d,getStart as _,getEnd as p,create as c}from"../../../../geometry/support/clipRay.js";import{intersectClipRay as u}from"../../../../geometry/support/frustumPlanes.js";import{fromPoints as m,pointAt as f,create as y}from"../../../../geometry/support/lineSegment.js";import{create as g,fromPoints as b}from"../../../../geometry/support/ray.js";import{EngineVisualElement as D}from"./EngineVisualElement.js";import{LaserlineVisualElement as w}from"./LaserlineVisualElement.js";import{drapedZ as O}from"../../terrain/DrapedZ.js";import{createPolylineGeometry as j}from"../../webgl-engine/lib/GeometryUtil.js";import{RenderGeometry as x}from"../../webgl-engine/lib/RenderGeometry.js";import{RibbonLineMaterial as C}from"../../webgl-engine/materials/RibbonLineMaterial.js";class E extends D{constructor(e){super(e),this._ray=g(),this._isWorldDown=!1,this._start=s(),this._end=n(1,0,0),this._width=1,this._color=l(1,0,1,1),this._polygonOffset=!1,this._writeDepthEnabled=!0,this._innerWidth=0,this._innerColor=l(1,1,1,1),this._stipplePattern=null,this._stippleOffColor=null,this._stipplePreferContinuous=!0,this._falloff=0,this._extensionType=0,this._laserlineStyle=null,this._laserlineEnabled=!1,this._renderOccluded=4,this._fadedExtensions=A,this._laserline=new w({view:this.view,isDecoration:e.isDecoration}),this.applyProperties(e)}destroy(){this._laserline.destroy(),super.destroy()}createObject3DResourceFactory(e){return{view:e,createResources:e=>this._createObject3DResources(e),destroyResources:G,recreateGeometry:(e,t)=>this._recreateObject3DGeometry(e,t),cameraChanged:()=>this._updateGeometry(),forEachMaterial:(e,t)=>t(e.material)}}createDrapedResourceFactory(e){return{view:e,createResources:()=>this._createDrapedResources(),destroyResources:G,recreateGeometry:e=>this._recreateDrapedGeometry(e),forEachMaterial:(e,t)=>t(e.material)}}updateVisibility(e){super.updateVisibility(e),this._laserline.visible=e}onAttachedChange(){this._laserline.attached=this._laserlineAttached}setStartEndFromWorldDownAtLocation(i){this._isWorldDown=!0,e(this._start,i),this.view.renderCoordsHelper.worldUpAtPosition(i,this._end),t(this._end,i,this._end),b(this._start,this._end,this._ray),this._updateGeometry()}get start(){return this._start}set start(t){this._isWorldDown=!1,i(this._start,t)||(e(this._start,t),b(this._start,this._end,this._ray),this._updateGeometry())}get end(){return this._end}set end(t){this._isWorldDown=!1,i(this._end,t)||(e(this._end,t),b(this._start,this._end,this._ray),this._updateGeometry())}get width(){return this._width}set width(e){e!==this._width&&(this._width=e,this._updateMaterial())}get color(){return this._color}set color(e){a(e,this._color)||(o(this._color,e),this._updateMaterial())}get polygonOffset(){return this._polygonOffset}set polygonOffset(e){e!==this._polygonOffset&&(this._polygonOffset=e,this._updateMaterial())}get writeDepthEnabled(){return this._writeDepthEnabled}set writeDepthEnabled(e){this._writeDepthEnabled!==e&&(this._writeDepthEnabled=e,this._updateMaterial())}get innerWidth(){return this._innerWidth}set innerWidth(e){e!==this._innerWidth&&(this._innerWidth=e,this._updateMaterial())}get innerColor(){return this._innerColor}set innerColor(e){a(e,this._innerColor)||(o(this._innerColor,e),this._updateMaterial())}get stipplePattern(){return this._stipplePattern}set stipplePattern(e){const t=null!=e!=(null!=this._stipplePattern);this._stipplePattern=e,t?this.recreate():this._updateMaterial()}get stippleOffColor(){return this._stippleOffColor}set stippleOffColor(e){null!=e&&null!=this._stippleOffColor&&a(e,this._stippleOffColor)||(this._stippleOffColor=null!=e?h(e):null,this._updateMaterial())}get stipplePreferContinuous(){return this._stipplePreferContinuous}set stipplePreferContinuous(e){e!==this._stipplePreferContinuous&&(this._stipplePreferContinuous=e,this._updateMaterial())}get falloff(){return this._falloff}set falloff(e){e!==this._falloff&&(this._falloff=e,this._updateMaterial())}get extensionType(){return this._extensionType}set extensionType(e){e!==this._extensionType&&(this._extensionType=e,this.recreateGeometry())}get _laserlineAttached(){return this._laserlineEnabled&&null!=this._laserlineStyle&&this.attached&&!this.isDraped}get laserlineStyle(){return this._laserlineStyle}set laserlineStyle(e){this._laserlineStyle=e,this._laserline.attached=this._laserlineAttached,null!=e&&(this._laserline.style=e)}get laserlineEnabled(){return this._laserlineEnabled}set laserlineEnabled(e){this._laserlineEnabled!==e&&(this._laserlineEnabled=e,this._laserline.attached=this._laserlineAttached)}get renderOccluded(){return this._renderOccluded}set renderOccluded(e){e!==this._renderOccluded&&(this._renderOccluded=e,this._updateMaterial())}get _normalizedRenderOccluded(){return this.isDraped&&8===this._renderOccluded?4:this._renderOccluded}get fadedExtensions(){return this._fadedExtensions}set fadedExtensions(e){this._fadedExtensions=e??A,this.recreateGeometry()}_updateMaterial(){const{materialParameters:e}=this;this.object3dResources.resources?.material.setParameters(e),this.drapedResources.resources?.material.setParameters(e)}get materialParameters(){return{width:this._width,color:this._color,stippleOffColor:this._stippleOffColor,stipplePattern:this._stipplePattern,stipplePreferContinuous:this._stipplePreferContinuous,innerWidth:this._innerWidth,innerColor:this._innerColor,falloff:this._falloff,polygonOffset:this._polygonOffset?3:0,renderOccluded:this._normalizedRenderOccluded,isDecoration:this.isDecoration,writeDepth:this._writeDepthEnabled}}_createObject3DResources(e){const t=new C(this.materialParameters,this.view.state.isGlobal),i=new Array;return this._createObject3DGeometry(t,e,i),{material:t,geometries:i}}_recreateObject3DGeometry(e,t){e.geometries.length=0,this._createObject3DGeometry(e.material,t,e.geometries)}_createObject3DGeometry(e,t,i){const r=this._createGeometry(e);i.push(r),t.addGeometry(r),this._updateVerticesObject3D(t)}_createDrapedResources(){const e=new C(this.materialParameters,this.view.state.isGlobal);return{material:e,geometries:[this._createDrapedGeometry(e)]}}_recreateDrapedGeometry(e){e.geometries=[this._createDrapedGeometry(e.material)]}_createDrapedGeometry(e){const t=this._createGeometry(e);return this._updateVerticesDraped(t),new x(t)}_createGeometry(e){const t=3===this.extensionType,i=t?[s(),s(),s(),s()]:[s(),s()];return j(e,i,null,t?[1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,0]:null)}_updateGeometry(){if(this.isDraped)this.drapedResources.recreateGeometry();else{const e=this.object3dResources.object;e&&this._updateVerticesObject3D(e)}}_updateVerticesObject3D(e){const t=this._lineSegment;this._updateVertexAttributesObject3D(e,t),this._laserline.intersectsLine=t}_updateVerticesDraped(e){this._updateVertexAttributesDraped(e,this._lineSegment)}get _lineSegment(){return 3===this._extensionType?this._updateLineSegmentFinite(M):this._updateLineSegmentInfinite(this._extensionType,M)}_updateLineSegmentFinite(e){return m(this._start,this._end,e)}_updateLineSegmentInfinite(e,t){const i=this.view.state.camera;switch(d(this._ray,P),e){case 0:P.c0=-Number.MAX_VALUE;break;case 1:case 2:{const e=this._ray.origin,t=this.view.elevationProvider.getElevation(e[0],e[1],e[2],this.view.renderCoordsHelper.spatialReference,"ground")??0,i=this.view.renderCoordsHelper.getAltitude(e);this._isWorldDown&&i<t&&r(P.ray.direction,P.ray.direction),2===this._extensionType&&null!=t&&(P.c1=Math.abs(i-t));break}}if(!u(i.frustum,P))return this._updateLineSegmentFinite(t);const s=_(P,v),n=p(P,R);return m(s,n,t)}_updateVertexAttributesObject3D(e,t){const i=e.geometries[0].getMutableAttribute("position")?.data;if(!i)return;let r=0;for(const s of this._lineVertices(t))i[r++]=s[0],i[r++]=s[1],i[r++]=s[2];e.geometryVertexAttributeUpdated(e.geometries[0],"position")}_updateVertexAttributesDraped(e,t){const i=e.getMutableAttribute("position")?.data;if(!i)return;let r=0;for(const s of this._lineVertices(t))i[r++]=s[0],i[r++]=s[1],i[r++]=O;e.invalidateBoundingInfo()}*_lineVertices(e){3===this.extensionType?(yield f(e,-this.fadedExtensions.start,v),yield f(e,0,v),yield f(e,1,v),yield f(e,1+this.fadedExtensions.end,v)):(yield f(e,0,v),yield f(e,1,v))}}function G(e){e.geometries=[]}const P=c(),v=s(),R=s(),M=y(),V=1/3,A={start:V,end:V};export{E as ExtendedLineVisualElement};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{intersectsSphere as e}from"../../../../geometry/support/frustum.js";import{I3sTarget as r}from"./Intersector.js";import{IntersectorResultRay as t}from"../../webgl-engine/lib/IntersectorResult.js";import{MeshIntersectionOptions as n}from"../../webgl-engine/lib/RayIntersections.js";import{getVerticalOffsetI3S as s}from"../../webgl-engine/lib/verticalOffsetUtils.js";class i{constructor(e,r){this.node=e,this.objectHandle=r}}class l{constructor(e){this.type=2,this._needVerticalOffset=!1,this.layerViewUid=e.layerViewUid,this.sublayerId=e.sublayerId,this._collection=e.collection,this._traverseNodeHierarchy=e.traverseNodeHierarchy,this.slicePlaneEnabled=e.slicePlaneEnabled,this.isGround=e.isGround}updateElevationAlignState(e,r){this._needVerticalOffset=e&&1===r}intersectRay(e,i,l,c,a,d){const u=2===e.options.store,b=e.ray.direction;let h=e=>e,f=e=>e;const y=s(e.verticalOffset??(this._needVerticalOffset?0:null));null!=e.verticalOffset&&null!=y&&(h=e=>y.applyToMbs(e),f=e=>y.applyToObb(e));const{results:R,tolerance:m}=e,p=new n(m,d,e.options.normalRequired),v=e=>{if(0===e.childrenLoaded)return!1;const r=e.serviceObbInRenderSR?.isValid?e.serviceObbInRenderSR:null;return!(r&&!f(r).intersectRay(l,b,m))};for(const{node:n,objectHandle:s}of this._traverseNodeHierarchy(v)){const a=n.serviceObbInRenderSR?.isValid?n.serviceObbInRenderSR:null,{serviceMbsInRenderSRElevationAdjusted:d}=n;!s||!a&&d.isValid&&!o(h(d),l,b,m)||null!=n.geometryObbInRenderSR&&!f(n.geometryObbInRenderSR).intersectRay(l,b,m)||this._collection.intersectRay(s,l,c,y,p,(s,o,a,d,b)=>{if(o<0||null!=i&&!i(l,c,o))return;const h=e=>{const t=new r(this.layerViewUid,this.sublayerId,n.index,b,d);e.set(this.type,t,s,o,a)};if(this.isGround&&(null==R.ground.renderDistance||o<R.ground.renderDistance)&&h(R.ground),!e.options.isFiltered&&((null==R.min.renderDistance||o<R.min.renderDistance)&&h(R.min),(null==R.max.renderDistance||s>R.max.renderDistance)&&h(R.max),u)){const r=new t(e.ray);h(r),e.results.all.push(r)}})}}*intersectScreenPolygon(t,n){if(null==t.camera)return;const i=s(this._needVerticalOffset?0:null),l=r=>{if(0===r.childrenLoaded)return!1;const t=r.serviceObbInRenderSR?.isValid?r.serviceObbInRenderSR:null;if(null!=t){if(!t.intersectsFrustumConservativeApproximation(n.broadPhaseFrustum))return!1}else{const t=r.serviceMbsInRenderSRElevationAdjusted;if(t.isValid&&!e(n.broadPhaseFrustum,t))return!1}return!0};for(const{node:e,objectHandle:s}of this._traverseNodeHierarchy(l))null!=s&&s.visible&&(null==e.geometryObbInRenderSR||e.geometryObbInRenderSR.intersectsFrustumConservativeApproximation(n.broadPhaseFrustum))&&(yield*this._collection.intersectScreenPolygon(s,t,n,i,(n,s,i,l)=>{t.polygonResults.add(this.type,new r(this.layerViewUid,this.sublayerId,e.index,n,l),s)}))}}function o(e,r,t,n=0){const s=e.radius+n,i=r[0]-e.center[0],l=r[1]-e.center[1],o=r[2]-e.center[2],[c,a,d]=t,u=c*i+a*l+d*o;return u*u-(c*c+a*a+d*d)*(i*i+l*l+o*o-s*s)>=0}export{l as I3SIntersectionHandler,i as TraversedIntersectionNode};
2
+ import{intersectsSphere as e}from"../../../../geometry/support/frustumPlanes.js";import{I3sTarget as n}from"./Intersector.js";import{IntersectorResultRay as r}from"../../webgl-engine/lib/IntersectorResult.js";import{MeshIntersectionOptions as t}from"../../webgl-engine/lib/RayIntersections.js";import{getVerticalOffsetI3S as s}from"../../webgl-engine/lib/verticalOffsetUtils.js";class i{constructor(e,n){this.node=e,this.objectHandle=n}}class l{constructor(e){this.type=2,this._needVerticalOffset=!1,this.layerViewUid=e.layerViewUid,this.sublayerId=e.sublayerId,this._collection=e.collection,this._traverseNodeHierarchy=e.traverseNodeHierarchy,this.slicePlaneEnabled=e.slicePlaneEnabled,this.isGround=e.isGround}updateElevationAlignState(e,n){this._needVerticalOffset=e&&1===n}intersectRay(e,i,l,a,c,d){const u=2===e.options.store,b=e.ray.direction;let h=e=>e,f=e=>e;const y=s(e.verticalOffset??(this._needVerticalOffset?0:null));null!=e.verticalOffset&&null!=y&&(h=e=>y.applyToMbs(e),f=e=>y.applyToObb(e));const{results:R,tolerance:m}=e,p=new t(m,d,e.options.normalRequired),v=e=>{if(0===e.childrenLoaded)return!1;const n=e.serviceObbInRenderSR?.isValid?e.serviceObbInRenderSR:null;return!(n&&!f(n).intersectRay(l,b,m))};for(const{node:t,objectHandle:s}of this._traverseNodeHierarchy(v)){const c=t.serviceObbInRenderSR?.isValid?t.serviceObbInRenderSR:null,{serviceMbsInRenderSRElevationAdjusted:d}=t;!s||!c&&d.isValid&&!o(h(d),l,b,m)||null!=t.geometryObbInRenderSR&&!f(t.geometryObbInRenderSR).intersectRay(l,b,m)||this._collection.intersectRay(s,l,a,y,p,(s,o,c,d,b)=>{if(o<0||null!=i&&!i(l,a,o))return;const h=e=>{const r=new n(this.layerViewUid,this.sublayerId,t.index,b,d);e.set(this.type,r,s,o,c)};if(this.isGround&&(null==R.ground.renderDistance||o<R.ground.renderDistance)&&h(R.ground),!e.options.isFiltered&&((null==R.min.renderDistance||o<R.min.renderDistance)&&h(R.min),(null==R.max.renderDistance||s>R.max.renderDistance)&&h(R.max),u)){const n=new r(e.ray);h(n),e.results.all.push(n)}})}}*intersectScreenPolygon(r,t){if(null==r.camera)return;const i=s(this._needVerticalOffset?0:null),l=n=>{if(0===n.childrenLoaded)return!1;const r=n.serviceObbInRenderSR?.isValid?n.serviceObbInRenderSR:null;if(null!=r){if(!r.intersectsFrustumConservativeApproximation(t.broadPhaseFrustum))return!1}else{const r=n.serviceMbsInRenderSRElevationAdjusted;if(r.isValid&&!e(t.broadPhaseFrustum,r))return!1}return!0};for(const{node:e,objectHandle:s}of this._traverseNodeHierarchy(l))null!=s&&s.visible&&(null==e.geometryObbInRenderSR||e.geometryObbInRenderSR.intersectsFrustumConservativeApproximation(t.broadPhaseFrustum))&&(yield*this._collection.intersectScreenPolygon(s,r,t,i,(t,s,i,l)=>{r.polygonResults.add(this.type,new n(this.layerViewUid,this.sublayerId,e.index,t,l),s)}))}}function o(e,n,r,t=0){const s=e.radius+t,i=n[0]-e.center[0],l=n[1]-e.center[1],o=n[2]-e.center[2],[a,c,d]=r,u=a*i+c*l+d*o;return u*u-(a*a+c*c+d*d)*(i*i+l*l+o*o-s*s)>=0}export{l as I3SIntersectionHandler,i as TraversedIntersectionNode};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{normalize as e,length as t,set as i,equals as n,subtract as r,dot as s,len as o,sqrDist as a,copy as c,scale as l,sub as u,scaleAndAdd as d,distance as h,squaredLength as m,squaredDistance as p,add as _}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as f}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as v}from"../../../../geometry/ellipsoidUtils.js";import{getSphericalPCPF as S}from"../../../../geometry/spatialReferenceEllipsoidUtils.js";import{projectBoundingSphere as g}from"../../../../geometry/projection/projectBoundingSphere.js";import{getProjector as R}from"../../../../geometry/projection/projectors.js";import{intersectsSphere as C}from"../../../../geometry/support/frustum.js";import{signedDistance as b,getNormal as M}from"../../../../geometry/support/plane.js";import{isPlateCarree as x}from"../../../../geometry/support/spatialReferenceUtils.js";import{Sphere as I}from"../../../../geometry/support/sphere.js";import{evaluateElevationAlignmentAtPoint as D}from"../graphics/elevationAlignmentUtils.js";import{ElevationContext as P}from"../graphics/ElevationContext.js";import{createContextWithoutExpressionSupport as E,extractExpressionInfo as A}from"../graphics/featureExpressionInfoUtils.js";import{intersectBoundingRectWithMbs as F}from"./I3SUtil.js";import{SweptSphereCylindricalVolume as O,SphereGlobal as V,SweptSphereConicalVolume as j}from"./SweptSphereVolume.js";import{Frustum as w}from"../../state/Frustum.js";import{Obb as L,computeOffsetObb as B}from"../../support/orientedBoundingBox.js";const T=1e5,y=1;class U{get _frustumPlanes(){return this._frustum.planes}constructor(e,t,i,n,r,s,o,a,c={}){this._indexSR=e,this._renderCoordsHelper=t,this._clippingArea=r,this._elevationProvider=s,this._viewingMode=o,this._options=c,this._viewDirection=f(),this._useFrustumCulling=!1,this._poi=f(),this._cameraPOIDirection=f(),this._elevationContext=null,this.minCenterDistance=1/0,this.maxCenterDistance=0,this.maxLodLevel=2,this._screenspaceErrorBias=c.screenspaceErrorBias||1,this._progressiveLoadFactor=c.progressiveLoadFactor||1,this._frustum=new w(t),this.updateCamera(i,n);const l=this._renderCoordsHelper.spatialReference;this._renderSR=l,this._renderSRSphericalPCPF=S(l),this._isGlobalMode=l===this._renderSRSphericalPCPF,this.updateElevationInfo(a),this._isECEFOBBInLocalMode=this._indexSR.isWGS84&&(l.isWebMercator||x(l)),this._indexSREllipsoidRadius=v(this._indexSR).radius,this._indexSRSphericalPCPF=S(e),this._projectorIndexSRToIndexSRSphericalPCPF=R(this._indexSR,this._indexSRSphericalPCPF)}updateElevationInfo(e){null!=e?(this._elevationContext=P.fromElevationInfo(e),this._elevationContext.setFeatureExpressionInfoContext(E(A(e,!1)))):this._elevationContext=null}updateCamera(t,i){this._useFrustumCulling=i,e(this._viewDirection,t.viewForward),i&&this._frustum.update(t),this._screenSizeFactor=1/(t.perScreenPixelRatio/2),this._camPos=t.eye,this._updateCameraPOIDirection(),this.minCenterDistance=1/0,this.maxCenterDistance=0}setPointOfInterest(e){this._poi=e,this._updateCameraPOIDirection()}updateScreenSpaceErrorBias(e){const t=this._screenspaceErrorBias;return this._screenspaceErrorBias=e,t}updateClippingArea(e){this._clippingArea=e}expandElevationRange(e,t,i){if(null==this._elevationContext)return;const n=e.serviceMbsInIndexSR;if(!n)return;const r="relative-to-scene"===this._elevationContext.mode?"scene":"ground",s=this._elevationProvider;if(s.getSphereElevationRange){const e=s.getSphereElevationRange(n,this._indexSR,r);if(e)return void i.expandElevationRange(e)}const[o,a,c]=n.center,l=s.getElevation(o,a,c,this._indexSR,r);l&&i.expandElevationRangeValues(l,l);const u=t?null:s.getRootElevationRange?.();u&&i.expandElevationRange(u)}calculateServiceMbsInRenderSR(e){const{serviceMbsInRenderSR:t}=e;if(t.isValid)return t;const{serviceMbsInIndexSR:i}=e;if(!i?.isValid)return t;const n=Q;return g(i,this._indexSR,n,this._renderSR),e.updateServiceMbsInRenderSR(n)}calculateServiceMbsInRenderSRElevationAdjusted(e){const{serviceMbsInRenderSRElevationAdjusted:t}=e;if(t.isValid)return t;const{serviceMbsInIndexSR:i}=e,n=this.calculateServiceMbsInRenderSR(e);if(!n.isValid||!i?.isValid)return t;const r=Q;r.copyFrom(n);const{_elevationContext:s}=this;if(s){const{minElevation:t}=e,{_renderCoordsHelper:n}=this,o=i.center;let a=0;if(Number.isFinite(t)){let i=0,c=0;const{maxElevation:l}=e,u=o[2];switch(s.mode){case"relative-to-ground":case"relative-to-scene":i=s.geometryZWithOffset(u,n)+t-u,c=l-t;break;case"on-the-ground":i=t-u,c=l-t}a=i+.5*c,r.radius+=.5*c}else r.radius<T&&(a=D(o,this._elevationProvider,s,n)-o[2]);a&&ne(r,a,this._viewingMode)}return e.updateServiceMbsInRenderSRElevationAdjusted(r)}_isGlobalMbsContainingPlanetCenter(e){return 1===this._viewingMode&&t(e.center)<=e.radius}calculateMbsConeInRenderSR(e){const{mbsConeInRenderSR:t}=e;if(t)return t;if(!e.elevationRangeValid)return null;let{minElevation:i,maxElevation:n}=e;if(!(Number.isFinite(i)&&i<n))return null;const r=this.calculateServiceMbsInRenderSR(e);if(!r.isValid)return null;const s=this._elevationContext;if("relative-to-ground"===s?.mode||"relative-to-scene"===s?.mode){const t=e.serviceMbsInIndexSR;if(!t?.isValid)return null;const r=t.center[2],o=s.geometryZWithOffset(r,this._renderCoordsHelper);if(2===this._viewingMode)i+=o,n+=o;else{const e=o-r;i+=e,n+=e}}const o=this._renderCoordsHelper.referenceEllipsoid.radius,a=2===this._viewingMode?new O(r,i,n):this._isGlobalMbsContainingPlanetCenter(r)?new V(r,o+i,o+n):new j(r,o+i,o+n);return e.updateMbsConeInRenderSR(a)}getAndUpdateVisibilityObbInRenderSR(e){{const t=e.visibilityObbInRenderSR;if(t)return t}const t=.01*this._indexSREllipsoidRadius,{serviceMbsInIndexSR:n,serviceObbInIndexSR:r}=e;if(null==r||!n||!r.isValid||this._isECEFOBBInLocalMode&&(r.halfSizeX>t||r.halfSizeY>t||r.halfSizeZ>t))return null;{let t=e.serviceObbInRenderSR;if(null==t)t=new L,e.serviceObbInRenderSR=t;else if(t.isValid)return t;const s=n.radius;let o=0,a=0;const c=r.centerZ,l=this._renderCoordsHelper,u=this._elevationContext;if(u&&e.elevationRangeValid){const{minElevation:t,maxElevation:i}=e;switch(u.mode){case"relative-to-ground":case"relative-to-scene":o=u.geometryZWithOffset(c,l)+t-c,a=i-t;break;case"on-the-ground":o=t-c,a=i-t}}else if(u&&s<T){const e=i(q,r.centerX,r.centerY,c);o=D(e,this._elevationProvider,u,l)-c}const d=a>0,h=d?N:t;return r.transform(h,this._indexSR,this._renderSR,o,this._renderSRSphericalPCPF,this._indexSRSphericalPCPF,this._projectorIndexSRToIndexSRSphericalPCPF),d&&B(h,0,a,this._viewingMode,t),t}}getNodeObbInRenderSRIndependentOfElevationOffset(e){{const t=e.visibilityObbInRenderSR??e.serviceObbInRenderSR??null;if(t?.isValid)return t}const t=e.serviceObbInIndexSR;if(!t)return null;const i=.2;return 2===this._viewingMode&&Math.max(t.halfSizeX,t.halfSizeY,t.halfSizeZ)>i*this._indexSREllipsoidRadius?null:(t.transform(N,this._indexSR,this._renderSR,void 0,this._renderSRSphericalPCPF,this._indexSRSphericalPCPF,this._projectorIndexSRToIndexSRSphericalPCPF),N)}ensureElevationAgnosticBoundingVolume(e){return!e.elevationAgnosticBoundingVolume.valid&&e.level>0&&(1===this._viewingMode?this._updateElevationAgnosticBoundingVolumeGlobal(e):this._updateElevationAgnosticBoundingVolumeLocal(e)),e.elevationAgnosticBoundingVolume}_updateCameraPOIDirection(){n(this._poi,this._camPos)?this._cameraPOIDirection=this._viewDirection:(r(this._cameraPOIDirection,this._camPos,this._poi),e(this._cameraPOIDirection,this._cameraPOIDirection))}_updateElevationAgnosticBoundingVolumeGlobal(t){const i=this.getNodeObbInRenderSRIndependentOfElevationOffset(t),n=t.elevationAgnosticBoundingVolume;let r,a=-1;if(i){const t=q;i.getCenter(t),e(t,t),r=t,i.getCorners(Z);for(const i of Z){e(i,i);const r=s(i,t);if(r<=0)return void n.invalidate();const o=Math.sqrt(Math.max(0,1-r*r));a=Math.max(a,o)}}else{const i=t.serviceMbsInRenderSR;if(!i.isValid)return void n.invalidate();const{center:s,radius:c}=i,l=o(s);if(l<c)return void n.invalidate();a=c/l,r=e(K,s)}n.set(r,a+de)}_updateElevationAgnosticBoundingVolumeLocal(e){const t=e.elevationAgnosticBoundingVolume,i=this.getNodeObbInRenderSRIndependentOfElevationOffset(e);if(i){const e=i.getCenter(q);e[2]=0;let n=0;const r=k;i.getCorners(Z);for(const t of Z){t[2]=0;const e=a(r,t);n=Math.max(n,e)}t.set(e,Math.sqrt(n))}else{const i=e.serviceMbsInRenderSR;if(i.isValid){const e=c(q,i.center);e[2]=0,t.set(e,i.radius)}}}isNodeVisible(e){if(!this._isMBSinClippingArea(this.calculateServiceMbsInRenderSR(e)))return!1;if(!this._useFrustumCulling)return!0;const t=this.getAndUpdateVisibilityObbInRenderSR(e);return t?t.intersectsFrustumConservativeApproximation(this._frustumPlanes):C(this._frustum.planes,this.calculateServiceMbsInRenderSRElevationAdjusted(e))}isElevationAgnosticBoundingVolumeVisible(e){return!this._useFrustumCulling||(!e.valid||!!e.intersectsFrustumConservative(this._frustum,this._viewingMode,y)&&(1!==this._viewingMode||this._isConeVisibleInFrustum(e)))}_isConeVisibleInFrustum(t){const i=t.radius;if(i>le)return!0;const n=this._frustumPlanes,{center:r,radius:o}=this._frustum.boundingSphere,a=t.getAxis(K),c=s(a,r),h=o+y,m=c-h,p=c+h;if(m<=0)return!0;const _=l(G,a,m),f=l(z,a,p),v=i/Math.sqrt(1-i*i);for(const S of n){const t=M(S),i=e(W,t),n=s(i,a);if(Math.abs(1-n)<ue)continue;const r=X;l(r,a,n),u(r,r,i),e(r,r);const o=Y;d(o,_,r,m*v);if(b(S,o)<=0)continue;d(o,f,r,p*v);if(b(S,o)<=0)continue;return!1}return!0}isObbVisibleIndependentOfElevation(e,t){if(!this._useFrustumCulling)return!0;if(!e.valid)return!0;const{center:i,radius:n}=this._frustum.boundingSphere,r=n+y,o=this._frustumPlanes,a=Z;if(t.getCorners(a),1===this._viewingMode){const t=e.getAxis(K),n=s(t,i),c=n-r,u=n+r;if(c<=0)return!0;for(const e of o){let i=!0;for(const n of a){const r=s(n,t),o=J;if(l(o,n,c/r),b(e,o)<=0){i=!1;break}const a=J;if(l(a,n,u/r),b(e,a)<=0){i=!1;break}}if(i)return!1}}else{const e=i[2]-r,t=i[2]+r;for(const i of o){let n=!0;const r=M(i),s=r[0],o=r[1],c=r[2],l=i[3];for(const i of a){const r=s*i[0]+o*i[1]+l;if(r+c*e<=0||r+c*t<=0){n=!1;break}}if(n)return!1}}return!0}isGeometryVisible(e){if(!this._useFrustumCulling)return!0;const t=e.geometryObbInRenderSR;return t?.intersectsFrustumConservativeApproximation(this._frustumPlanes)??this.isNodeVisible(e)}_isMBSinClippingArea(e){return null==this._clippingArea||0!==F(this._clippingArea,e)}_screenSpaceDiameterMbs(e,t){const i=this.calcCameraDistanceToSurfaceAndUpdateMinmaxWithCenterDistance(e);return i<0?re:t/i*this._screenSizeFactor}calcCameraDistanceToSurfaceAndUpdateMinmaxWithCenterDistance(e){const t=this.calculateMbsConeInRenderSR(e);if(null==t)return this.calcCameraDistanceToSurfaceAndUpdateMinmaxWithSphere(e);const i=t.calculateSurfaceDistanceFromPoint(this._camPos),n=t.calculateCenterDistanceFromPoint(this._camPos);return this._updateMinMaxDistanceToCenter(n),i}calcCameraDistanceToSurfaceAndUpdateMinmaxWithSphere(e){return this.calcCameraDistanceToCenterAndUpdateMinmax(e)-this.calculateServiceMbsInRenderSRElevationAdjusted(e).radius}calcCameraDistanceToCenterAndUpdateMinmax(e){const t=this.calculateServiceMbsInRenderSRElevationAdjusted(e),i=h(t.center,this._camPos);return this._updateMinMaxDistanceToCenter(i),i}_calculateAngleDependentLoDForSphere(e,i){const n=u(k,e,this._camPos),r=t(e),o=t(n);if(0===r||0===o)return 1;const a=(Math.abs(s(e,n))/r+i)/o;return Math.min(1,a)}calcAngleDependentLoD(e){const i=this.calculateMbsConeInRenderSR(e);if(null==i){const{center:t,radius:i}=this.calculateServiceMbsInRenderSRElevationAdjusted(e);return this._calculateAngleDependentLoDForSphere(t,i)}const{center:n,radius:r}=this.calculateServiceMbsInRenderSR(e);if(2===this._viewingMode)c($,n),$[2]=i.lowerCenterHeight,c(ee,n),ee[2]=i.upperCenterHeight;else{const e=t(n);if(0===e)return 1;l($,n,i.lowerCenterHeight/e),l(ee,n,i.upperCenterHeight/e)}const o=this._calculateAngleDependentLoDForSphere($,r),a=this._calculateAngleDependentLoDForSphere(ee,r);if(2===this._viewingMode)c(te,n),te[2]=Math.max(i.lowerCenterHeight,Math.min(i.upperCenterHeight,this._camPos[2]));else{const e=t(n);if(0===e)return Math.max(o,a);const r=Math.max(i.lowerCenterHeight,Math.min(i.upperCenterHeight,s(this._camPos,n)/e));l(te,n,r/e)}return Math.max(o,a,this._calculateAngleDependentLoDForSphere(te,r))}hasLOD(e){return 0!==e.lodMetric}_getDistanceToSurfaceGlobeMode(e,i){const n=t(i.center),o=t(e)-n;l($,e,s(e,i.center)/m(e));const a=p(i.center,$),c=i.radius;if(a<=c*c)return Math.abs(o);const u=l($,i.center,1/n),d=l(ee,u,n-c*c/(2*n)),f=r(te,e,d),v=r(te,f,l(ie,u,s(u,f))),S=_(te,d,l(te,v,c/t(v)));let g=h(e,S);if(o>=oe){const i=r(ee,e,S);let n=s(i,u)/t(i);n<ae&&(n=ce),g/=n}return g}_getDistanceToSurface(e,t){return this._isGlobalMode?this._getDistanceToSurfaceGlobeMode(e,t):H(e,t)}_applyGlobalFlatAngleCorrectionToConeDistance(e,i){i.calculateClosestCenterToPoint(this._camPos,ie);const n=t(ie);if(0===n)return e;if(t(this._camPos)-n<oe)return e;const o=r(te,this._camPos,ie),a=t(o);if(0===a)return e;const c=s(o,ie)/(a*n);return e/(c<ae?ce:c)}calculateScreenSpaceRelativeSphere(e){const t=this.calculateServiceMbsInRenderSRElevationAdjusted(e),i=this._getDistanceToSurface(this._camPos,t),n=i+t.radius;return this._updateMinMaxDistanceToCenter(n),2*i/this._screenSizeFactor}calculateScreenSpaceRelativeCone(e){const t=e.calculateCenterDistanceFromPoint(this._camPos);this._updateMinMaxDistanceToCenter(t);const i=e.calculateSurfaceDistanceFromPoint(this._camPos);return 2*(this._isGlobalMode?this._applyGlobalFlatAngleCorrectionToConeDistance(i,e):i)/this._screenSizeFactor}_updateMinMaxDistanceToCenter(e){e>0?(this.minCenterDistance=Math.min(this.minCenterDistance,e),this.maxCenterDistance=Math.max(this.maxCenterDistance,e)):(this.minCenterDistance=0,this.maxCenterDistance=Math.max(this.maxCenterDistance,-e))}getLodLevel(e){if(0===e.lodMetric)return 0;if(0===e.childCount)return this.maxLodLevel;if(this._useFrustumCulling&&this._progressiveLoadFactor<1){const t=this._progressiveLoadFactor*this._screenspaceErrorBias,i=this._screenspaceErrorBias;return this.evaluateLODmetric(e,t)?this.evaluateLODmetric(e,i)?2:1:0}return this.evaluateLODmetric(e,this._screenspaceErrorBias)?this.maxLodLevel:0}evaluateLODmetric(e,t){switch(e.lodMetric){case 1:{let i=this._screenSpaceDiameterMbs(e,(e.serviceMbsInIndexSR?.radius??0)*t);return this._options.angleDependentLoD&&(i*=this.calcAngleDependentLoD(e)),i<e.maxError}case 2:{const i=this.calculateMbsConeInRenderSR(e),n=i?this.calculateScreenSpaceRelativeCone(i):this.calculateScreenSpaceRelativeSphere(e);return e.maxError*t<=n}case 3:return this._screenSpaceDiameterMbs(e,e.maxError)*t<se;case 4:return this.calcCameraDistanceToSurfaceAndUpdateMinmaxWithCenterDistance(e)>e.maxError*t}return!1}distToCameraPOIRay(e){if(null==e)return 0;const t=this.calculateServiceMbsInRenderSRElevationAdjusted(e),i=t.center,n=s(i,this._cameraPOIDirection),r=n*n,o=m(i)-r;return Math.sqrt(o)-t.radius}distCameraToPOI(){return h(this._camPos,this._poi)}}function H(e,t){const i=e[0]-t.center[0],n=e[1]-t.center[1],r=e[2]-t.center[2],s=i*i+n*n,o=t.radius;if(s<=o*o)return Math.abs(r);const a=Math.sqrt(s)-o;return Math.sqrt(r*r+a*a)}const G=f(),z=f(),W=f(),N=new L,q=f(),Z=[f(),f(),f(),f(),f(),f(),f(),f()],k=f(),X=f(),Y=f(),J=f(),K=f(),Q=new I,$=f(),ee=f(),te=f(),ie=f();function ne(e,i,n){if(2===n)e.center[2]+=i;else{const n=t(e.center);if(0===n)return void(e.radius+=Math.abs(i));l(e.center,e.center,1+i/n)}}const re=.5*Number.MAX_VALUE,se=10,oe=2e5,ae=.08,ce=1e-4,le=.9,ue=.01,de=.001;export{U as default};
2
+ import{normalize as e,length as t,set as i,equals as n,subtract as r,dot as s,len as o,sqrDist as a,copy as c,scale as l,sub as u,scaleAndAdd as d,distance as h,squaredLength as m,squaredDistance as p,add as _}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as f}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as S}from"../../../../geometry/ellipsoidUtils.js";import{getSphericalPCPF as v}from"../../../../geometry/spatialReferenceEllipsoidUtils.js";import{projectBoundingSphere as R}from"../../../../geometry/projection/projectBoundingSphere.js";import{getProjector as g}from"../../../../geometry/projection/projectors.js";import{signedDistance as C,getNormal as b}from"../../../../geometry/support/plane.js";import{isPlateCarree as M}from"../../../../geometry/support/spatialReferenceUtils.js";import{Sphere as x}from"../../../../geometry/support/sphere.js";import{evaluateElevationAlignmentAtPoint as I}from"../graphics/elevationAlignmentUtils.js";import{ElevationContext as D}from"../graphics/ElevationContext.js";import{createContextWithoutExpressionSupport as P,extractExpressionInfo as E}from"../graphics/featureExpressionInfoUtils.js";import{intersectBoundingRectWithMbs as A}from"./I3SUtil.js";import{Frustum as F}from"../../state/Frustum.js";import{Obb as O,computeOffsetObb as V}from"../../support/orientedBoundingBox.js";import{SweptSphereCylindricalVolume as w,SphereGlobal as j,SweptSphereConicalVolume as L}from"../../support/SweptSphereVolume.js";const B=1e5,T=1;class y{get _frustumPlanes(){return this._frustum.planes}constructor(e,t,i,n,r,s,o,a,c={}){this._indexSR=e,this._renderCoordsHelper=t,this._clippingArea=r,this._elevationProvider=s,this._viewingMode=o,this._options=c,this._viewDirection=f(),this._useFrustumCulling=!1,this._poi=f(),this._cameraPOIDirection=f(),this._elevationContext=null,this.minCenterDistance=1/0,this.maxCenterDistance=0,this.maxLodLevel=2,this._screenspaceErrorBias=c.screenspaceErrorBias||1,this._progressiveLoadFactor=c.progressiveLoadFactor||1,this._frustum=new F(t),this.updateCamera(i,n);const l=this._renderCoordsHelper.spatialReference;this._renderSR=l,this._renderSRSphericalPCPF=v(l),this._isGlobalMode=l===this._renderSRSphericalPCPF,this.updateElevationInfo(a),this._isECEFOBBInLocalMode=this._indexSR.isWGS84&&(l.isWebMercator||M(l)),this._indexSREllipsoidRadius=S(this._indexSR).radius,this._indexSRSphericalPCPF=v(e),this._projectorIndexSRToIndexSRSphericalPCPF=g(this._indexSR,this._indexSRSphericalPCPF)}updateElevationInfo(e){null!=e?(this._elevationContext=D.fromElevationInfo(e),this._elevationContext.setFeatureExpressionInfoContext(P(E(e,!1)))):this._elevationContext=null}updateCamera(t,i){this._useFrustumCulling=i,e(this._viewDirection,t.viewForward),i&&this._frustum.update(t),this._screenSizeFactor=1/(t.perScreenPixelRatio/2),this._camPos=t.eye,this._updateCameraPOIDirection(),this.minCenterDistance=1/0,this.maxCenterDistance=0}setPointOfInterest(e){this._poi=e,this._updateCameraPOIDirection()}updateScreenSpaceErrorBias(e){const t=this._screenspaceErrorBias;return this._screenspaceErrorBias=e,t}updateClippingArea(e){this._clippingArea=e}expandElevationRange(e,t,i){if(null==this._elevationContext)return;const n=e.serviceMbsInIndexSR;if(!n)return;const r="relative-to-scene"===this._elevationContext.mode?"scene":"ground",s=this._elevationProvider;if(s.getSphereElevationRange){const e=s.getSphereElevationRange(n,this._indexSR,r);if(e)return void i.expandElevationRange(e)}const[o,a,c]=n.center,l=s.getElevation(o,a,c,this._indexSR,r);l&&i.expandElevationRangeValues(l,l);const u=t?null:s.getRootElevationRange?.();u&&i.expandElevationRange(u)}calculateServiceMbsInRenderSR(e){const{serviceMbsInRenderSR:t}=e;if(t.isValid)return t;const{serviceMbsInIndexSR:i}=e;if(!i?.isValid)return t;const n=K;return R(i,this._indexSR,n,this._renderSR),e.updateServiceMbsInRenderSR(n)}calculateServiceMbsInRenderSRElevationAdjusted(e){const{serviceMbsInRenderSRElevationAdjusted:t}=e;if(t.isValid)return t;const{serviceMbsInIndexSR:i}=e,n=this.calculateServiceMbsInRenderSR(e);if(!n.isValid||!i?.isValid)return t;const r=K;r.copyFrom(n);const{_elevationContext:s}=this;if(s){const{minElevation:t}=e,{_renderCoordsHelper:n}=this,o=i.center;let a=0;if(Number.isFinite(t)){let i=0,c=0;const{maxElevation:l}=e,u=o[2];switch(s.mode){case"relative-to-ground":case"relative-to-scene":i=s.geometryZWithOffset(u,n)+t-u,c=l-t;break;case"on-the-ground":i=t-u,c=l-t}a=i+.5*c,r.radius+=.5*c}else r.radius<B&&(a=I(o,this._elevationProvider,s,n)-o[2]);a&&ie(r,a,this._viewingMode)}return e.updateServiceMbsInRenderSRElevationAdjusted(r)}_isGlobalMbsContainingPlanetCenter(e){return 1===this._viewingMode&&t(e.center)<=e.radius}calculateMbsConeInRenderSR(e){const{mbsConeInRenderSR:t}=e;if(t)return t;if(!e.elevationRangeValid)return null;let{minElevation:i,maxElevation:n}=e;if(!(Number.isFinite(i)&&i<n))return null;const r=this.calculateServiceMbsInRenderSR(e);if(!r.isValid)return null;const s=this._elevationContext;if("relative-to-ground"===s?.mode||"relative-to-scene"===s?.mode){const t=e.serviceMbsInIndexSR;if(!t?.isValid)return null;const r=t.center[2],o=s.geometryZWithOffset(r,this._renderCoordsHelper);if(2===this._viewingMode)i+=o,n+=o;else{const e=o-r;i+=e,n+=e}}const o=this._renderCoordsHelper.referenceEllipsoid.radius,a=2===this._viewingMode?new w(r,i,n):this._isGlobalMbsContainingPlanetCenter(r)?new j(r,o+i,o+n):new L(r,o+i,o+n);return e.updateMbsConeInRenderSR(a)}getAndUpdateVisibilityObbInRenderSR(e){{const t=e.visibilityObbInRenderSR;if(t)return t}const t=.01*this._indexSREllipsoidRadius,{serviceMbsInIndexSR:n,serviceObbInIndexSR:r}=e;if(null==r||!n||!r.isValid||this._isECEFOBBInLocalMode&&(r.halfSizeX>t||r.halfSizeY>t||r.halfSizeZ>t))return null;{let t=e.serviceObbInRenderSR;if(null==t)t=new O,e.serviceObbInRenderSR=t;else if(t.isValid)return t;const s=n.radius;let o=0,a=0;const c=r.centerZ,l=this._renderCoordsHelper,u=this._elevationContext;if(u&&e.elevationRangeValid){const{minElevation:t,maxElevation:i}=e;switch(u.mode){case"relative-to-ground":case"relative-to-scene":o=u.geometryZWithOffset(c,l)+t-c,a=i-t;break;case"on-the-ground":o=t-c,a=i-t}}else if(u&&s<B){const e=i(N,r.centerX,r.centerY,c);o=I(e,this._elevationProvider,u,l)-c}const d=a>0,h=d?W:t;return r.transform(h,this._indexSR,this._renderSR,o,this._renderSRSphericalPCPF,this._indexSRSphericalPCPF,this._projectorIndexSRToIndexSRSphericalPCPF),d&&V(h,0,a,this._viewingMode,t),t}}getNodeObbInRenderSRIndependentOfElevationOffset(e){{const t=e.visibilityObbInRenderSR??e.serviceObbInRenderSR??null;if(t?.isValid)return t}const t=e.serviceObbInIndexSR;if(!t)return null;const i=.2;return 2===this._viewingMode&&Math.max(t.halfSizeX,t.halfSizeY,t.halfSizeZ)>i*this._indexSREllipsoidRadius?null:(t.transform(W,this._indexSR,this._renderSR,void 0,this._renderSRSphericalPCPF,this._indexSRSphericalPCPF,this._projectorIndexSRToIndexSRSphericalPCPF),W)}ensureElevationAgnosticBoundingVolume(e){return!e.elevationAgnosticBoundingVolume.valid&&e.level>0&&(1===this._viewingMode?this._updateElevationAgnosticBoundingVolumeGlobal(e):this._updateElevationAgnosticBoundingVolumeLocal(e)),e.elevationAgnosticBoundingVolume}_updateCameraPOIDirection(){n(this._poi,this._camPos)?this._cameraPOIDirection=this._viewDirection:(r(this._cameraPOIDirection,this._camPos,this._poi),e(this._cameraPOIDirection,this._cameraPOIDirection))}_updateElevationAgnosticBoundingVolumeGlobal(t){const i=this.getNodeObbInRenderSRIndependentOfElevationOffset(t),n=t.elevationAgnosticBoundingVolume;let r,a=-1;if(i){const t=N;i.getCenter(t),e(t,t),r=t,i.getCorners(q);for(const i of q){e(i,i);const r=s(i,t);if(r<=0)return void n.invalidate();const o=Math.sqrt(Math.max(0,1-r*r));a=Math.max(a,o)}}else{const i=t.serviceMbsInRenderSR;if(!i.isValid)return void n.invalidate();const{center:s,radius:c}=i,l=o(s);if(l<c)return void n.invalidate();a=c/l,r=e(J,s)}n.set(r,a+ue)}_updateElevationAgnosticBoundingVolumeLocal(e){const t=e.elevationAgnosticBoundingVolume,i=this.getNodeObbInRenderSRIndependentOfElevationOffset(e);if(i){const e=i.getCenter(N);e[2]=0;let n=0;const r=Z;i.getCorners(q);for(const t of q){t[2]=0;const e=a(r,t);n=Math.max(n,e)}t.set(e,Math.sqrt(n))}else{const i=e.serviceMbsInRenderSR;if(i.isValid){const e=c(N,i.center);e[2]=0,t.set(e,i.radius)}}}isNodeVisible(e){if(!this._isMBSinClippingArea(this.calculateServiceMbsInRenderSR(e)))return!1;if(!this._useFrustumCulling)return!0;const t=this.getAndUpdateVisibilityObbInRenderSR(e);return t?t.intersectsFrustumConservativeApproximation(this._frustumPlanes):this._frustum.intersectsSphere(this.calculateServiceMbsInRenderSRElevationAdjusted(e))}isElevationAgnosticBoundingVolumeVisible(e){return!this._useFrustumCulling||(!e.valid||!!e.intersectsFrustumConservative(this._frustum,this._viewingMode,T)&&(1!==this._viewingMode||this._isConeVisibleInFrustum(e)))}_isConeVisibleInFrustum(t){const i=t.radius;if(i>ce)return!0;const n=this._frustumPlanes,{center:r,radius:o}=this._frustum.boundingSphere,a=t.getAxis(J),c=s(a,r),h=o+T,m=c-h,p=c+h;if(m<=0)return!0;const _=l(H,a,m),f=l(G,a,p),S=i/Math.sqrt(1-i*i);for(const v of n){const t=b(v),i=e(z,t),n=s(i,a);if(Math.abs(1-n)<le)continue;const r=k;l(r,a,n),u(r,r,i),e(r,r);const o=X;d(o,_,r,m*S);if(C(v,o)<=0)continue;d(o,f,r,p*S);if(C(v,o)<=0)continue;return!1}return!0}isObbVisibleIndependentOfElevation(e,t){if(!this._useFrustumCulling)return!0;if(!e.valid)return!0;const{center:i,radius:n}=this._frustum.boundingSphere,r=n+T,o=this._frustumPlanes,a=q;if(t.getCorners(a),1===this._viewingMode){const t=e.getAxis(J),n=s(t,i),c=n-r,u=n+r;if(c<=0)return!0;for(const e of o){let i=!0;for(const n of a){const r=s(n,t),o=Y;if(l(o,n,c/r),C(e,o)<=0){i=!1;break}const a=Y;if(l(a,n,u/r),C(e,a)<=0){i=!1;break}}if(i)return!1}}else{const e=i[2]-r,t=i[2]+r;for(const i of o){let n=!0;const r=b(i),s=r[0],o=r[1],c=r[2],l=i[3];for(const i of a){const r=s*i[0]+o*i[1]+l;if(r+c*e<=0||r+c*t<=0){n=!1;break}}if(n)return!1}}return!0}isGeometryVisible(e){if(!this._useFrustumCulling)return!0;const t=e.geometryObbInRenderSR;return t?.intersectsFrustumConservativeApproximation(this._frustumPlanes)??this.isNodeVisible(e)}_isMBSinClippingArea(e){return null==this._clippingArea||0!==A(this._clippingArea,e)}_screenSpaceDiameterMbs(e,t){const i=this.calcCameraDistanceToSurfaceAndUpdateMinmaxWithCenterDistance(e);return i<0?ne:t/i*this._screenSizeFactor}calcCameraDistanceToSurfaceAndUpdateMinmaxWithCenterDistance(e){const t=this.calculateMbsConeInRenderSR(e);if(null==t)return this.calcCameraDistanceToSurfaceAndUpdateMinmaxWithSphere(e);const i=t.calculateSurfaceDistanceFromPoint(this._camPos),n=t.calculateCenterDistanceFromPoint(this._camPos);return this._updateMinMaxDistanceToCenter(n),i}calcCameraDistanceToSurfaceAndUpdateMinmaxWithSphere(e){return this.calcCameraDistanceToCenterAndUpdateMinmax(e)-this.calculateServiceMbsInRenderSRElevationAdjusted(e).radius}calcCameraDistanceToCenterAndUpdateMinmax(e){const t=this.calculateServiceMbsInRenderSRElevationAdjusted(e),i=h(t.center,this._camPos);return this._updateMinMaxDistanceToCenter(i),i}_calculateAngleDependentLoDForSphere(e,i){const n=u(Z,e,this._camPos),r=t(e),o=t(n);if(0===r||0===o)return 1;const a=(Math.abs(s(e,n))/r+i)/o;return Math.min(1,a)}calcAngleDependentLoD(e){const i=this.calculateMbsConeInRenderSR(e);if(null==i){const{center:t,radius:i}=this.calculateServiceMbsInRenderSRElevationAdjusted(e);return this._calculateAngleDependentLoDForSphere(t,i)}const{center:n,radius:r}=this.calculateServiceMbsInRenderSR(e);if(2===this._viewingMode)c(Q,n),Q[2]=i.lowerCenterHeight,c($,n),$[2]=i.upperCenterHeight;else{const e=t(n);if(0===e)return 1;l(Q,n,i.lowerCenterHeight/e),l($,n,i.upperCenterHeight/e)}const o=this._calculateAngleDependentLoDForSphere(Q,r),a=this._calculateAngleDependentLoDForSphere($,r);if(2===this._viewingMode)c(ee,n),ee[2]=Math.max(i.lowerCenterHeight,Math.min(i.upperCenterHeight,this._camPos[2]));else{const e=t(n);if(0===e)return Math.max(o,a);const r=Math.max(i.lowerCenterHeight,Math.min(i.upperCenterHeight,s(this._camPos,n)/e));l(ee,n,r/e)}return Math.max(o,a,this._calculateAngleDependentLoDForSphere(ee,r))}hasLOD(e){return 0!==e.lodMetric}_getDistanceToSurfaceGlobeMode(e,i){const n=t(i.center),o=t(e)-n;l(Q,e,s(e,i.center)/m(e));const a=p(i.center,Q),c=i.radius;if(a<=c*c)return Math.abs(o);const u=l(Q,i.center,1/n),d=l($,u,n-c*c/(2*n)),f=r(ee,e,d),S=r(ee,f,l(te,u,s(u,f))),v=_(ee,d,l(ee,S,c/t(S)));let R=h(e,v);if(o>=se){const i=r($,e,v);let n=s(i,u)/t(i);n<oe&&(n=ae),R/=n}return R}_getDistanceToSurface(e,t){return this._isGlobalMode?this._getDistanceToSurfaceGlobeMode(e,t):U(e,t)}_applyGlobalFlatAngleCorrectionToConeDistance(e,i){i.calculateClosestCenterToPoint(this._camPos,te);const n=t(te);if(0===n)return e;if(t(this._camPos)-n<se)return e;const o=r(ee,this._camPos,te),a=t(o);if(0===a)return e;const c=s(o,te)/(a*n);return e/(c<oe?ae:c)}calculateScreenSpaceRelativeSphere(e){const t=this.calculateServiceMbsInRenderSRElevationAdjusted(e),i=this._getDistanceToSurface(this._camPos,t),n=i+t.radius;return this._updateMinMaxDistanceToCenter(n),2*i/this._screenSizeFactor}calculateScreenSpaceRelativeCone(e){const t=e.calculateCenterDistanceFromPoint(this._camPos);this._updateMinMaxDistanceToCenter(t);const i=e.calculateSurfaceDistanceFromPoint(this._camPos);return 2*(this._isGlobalMode?this._applyGlobalFlatAngleCorrectionToConeDistance(i,e):i)/this._screenSizeFactor}_updateMinMaxDistanceToCenter(e){e>0?(this.minCenterDistance=Math.min(this.minCenterDistance,e),this.maxCenterDistance=Math.max(this.maxCenterDistance,e)):(this.minCenterDistance=0,this.maxCenterDistance=Math.max(this.maxCenterDistance,-e))}getLodLevel(e){if(0===e.lodMetric)return 0;if(0===e.childCount)return this.maxLodLevel;if(this._useFrustumCulling&&this._progressiveLoadFactor<1){const t=this._progressiveLoadFactor*this._screenspaceErrorBias,i=this._screenspaceErrorBias;return this.evaluateLODmetric(e,t)?this.evaluateLODmetric(e,i)?2:1:0}return this.evaluateLODmetric(e,this._screenspaceErrorBias)?this.maxLodLevel:0}evaluateLODmetric(e,t){switch(e.lodMetric){case 1:{let i=this._screenSpaceDiameterMbs(e,(e.serviceMbsInIndexSR?.radius??0)*t);return this._options.angleDependentLoD&&(i*=this.calcAngleDependentLoD(e)),i<e.maxError}case 2:{const i=this.calculateMbsConeInRenderSR(e),n=i?this.calculateScreenSpaceRelativeCone(i):this.calculateScreenSpaceRelativeSphere(e);return e.maxError*t<=n}case 3:return this._screenSpaceDiameterMbs(e,e.maxError)*t<re;case 4:return this.calcCameraDistanceToSurfaceAndUpdateMinmaxWithCenterDistance(e)>e.maxError*t}return!1}distToCameraPOIRay(e){if(null==e)return 0;const t=this.calculateServiceMbsInRenderSRElevationAdjusted(e),i=t.center,n=s(i,this._cameraPOIDirection),r=n*n,o=m(i)-r;return Math.sqrt(o)-t.radius}distCameraToPOI(){return h(this._camPos,this._poi)}}function U(e,t){const i=e[0]-t.center[0],n=e[1]-t.center[1],r=e[2]-t.center[2],s=i*i+n*n,o=t.radius;if(s<=o*o)return Math.abs(r);const a=Math.sqrt(s)-o;return Math.sqrt(r*r+a*a)}const H=f(),G=f(),z=f(),W=new O,N=f(),q=[f(),f(),f(),f(),f(),f(),f(),f()],Z=f(),k=f(),X=f(),Y=f(),J=f(),K=new x,Q=f(),$=f(),ee=f(),te=f();function ie(e,i,n){if(2===n)e.center[2]+=i;else{const n=t(e.center);if(0===n)return void(e.radius+=Math.abs(i));l(e.center,e.center,1+i/n)}}const ne=.5*Number.MAX_VALUE,re=10,se=2e5,oe=.08,ae=1e-4,ce=.9,le=.01,ue=.001;export{y as default};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{len as t,set as e,normalize as i,dot as s,scale as o,copy as r,dist as a}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{ZEROS as n,freeze as l,create as c}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{distance as d}from"../../../../geometry/support/aaBoundingRect.js";import{intersectsPoint as h}from"../../../../geometry/support/frustum.js";import{fromValues as m}from"../../../../geometry/support/ray.js";import{FeatureTileVisibility3D as p,minTileLOD as u}from"./FeatureTileVisibility3D.js";import _ from"../../webgl/RenderCamera.js";class f{constructor(t,e,i){this._renderCoordsHelper=t,this._tilingScheme=e,this._camera=new _,this._surfaceElevation=0,this._focusOnMap=[0,0],this._visibility=new p(t,i)}set opaqueGround(t){this._visibility.opaqueGround=t}setup(t,e,i){this._camera.copyFrom(t),this._surfaceElevation=i,this._focusOnMap[0]=e.x,this._focusOnMap[1]=e.y,this._visibility.setup(this._camera)}done(){this._visibility.done()}update(t){const{measures:e,extent:i,level:s}=t;i&&(e.visible=this._visibility.compute(t),e.distance=d(i,this._focusOnMap),e.mergeable=!0,e.lodLevel=u,e.splitPriority=Math.max(0,u-s),e.visible&&(this._isGlobal?this._updateSplitAndLodGlobal(t):this._updateSplitAndLodLocal(t)))}_updateSplitAndLodGlobal(r){const a=r.level,n=this._renderCoordsHelper,{eye:l,fov:c}=this._camera,d=n.referenceEllipsoid.radius,h=t(l)-d;if(2*Math.atan(d/h)<c&&h>0)return void(r.measures.lodLevel=Math.max(a,u));const m=v,{extent:p}=r;if(!p)return;const{_surfaceElevation:_}=this;e(m[0],p[0],p[1],_),e(m[1],p[2],p[1],_),e(m[2],p[2],p[3],_),e(m[3],p[0],p[3],_);const f=e(M,.5*(p[0]+p[2]),.5*(p[1]+p[3]),_),y=this._tilingScheme.spatialReference;for(let t=0;t<4;++t)n.toRenderCoords(m[t],y,m[t]);n.toRenderCoords(f,y,f);const b=i(g.direction,f),L=s(l,b),S=o(x,b,L);this._updateSplitAndLod(r,m,f,S)}_updateSplitAndLodLocal(t){const i=v,{extent:s}=t;if(!s)return;const{_surfaceElevation:o}=this;e(i[0],s[0],s[1],o),e(i[1],s[2],s[1],o),e(i[2],s[2],s[3],o),e(i[3],s[0],s[3],o);const a=this._tilingScheme.spatialReference;for(let e=0;e<4;++e)this._renderCoordsHelper.toRenderCoords(i[e],a,i[e]);const n=e(M,.5*(i[0][0]+i[2][0]),.5*(i[0][1]+i[2][1]),.25*(i[0][2]+i[1][2]+i[2][2]+i[3][2])),l=e(y,n[0],n[1],0),{eye:c,far:d}=this._camera,h=e(x,l[0],l[1],c[2]);e(g.origin,l[0],l[1],c[2]-2*d),r(g.direction,b),this._updateSplitAndLod(t,i,n,h)}_updateSplitAndLod(t,e,i,o){const r=Math.max(a(e[0],e[2]),a(e[1],e[3]),a(e[0],i)+a(i,e[2]),a(e[1],i)+a(i,e[3])),{eye:n,near:l,fov:c,viewForward:d,width:m,height:p,pixelRatio:u,frustum:_}=this._camera,f=s(n,d),v=s(i,d)-f,M=a(i,n);let y=v,x=v,b=M,g=M;const R=(t,e)=>e<l?1:Math.sqrt(t*t-e*e)/e;let j=R(M,v);for(const h of e){const t=s(h,d)-f;y=Math.min(y,t),x=Math.max(x,t);const e=a(h,n);g=Math.max(g,e),b=Math.min(b,e);const i=R(e,t);j=Math.min(j,i)}if(x<l)return void(t.measures.lodLevel=0);const w=Math.cos(.5*c),A=a(n,o);j>w&&A>S*r&&(x=C*g,y=C*b);const G=.5*Math.sqrt(m*m+p*p)/u,E=2*Math.tan(.5*c),q=t=>Math.max(l,t)*L/G*E,H=t.level,O=r*2**H*Math.max(1,E),P=q(y),F=Math.ceil(Math.log2(Math.max(1,O/P)));if(t.measures.lodLevel=Math.max(F,t.measures.lodLevel),t.measures.splitPriority+=t.measures.lodLevel-H,H<F){const i=+h(_,e[0])+ +h(_,e[1])+ +h(_,e[2])+ +h(_,e[3]);t.measures.splitPriority+=i}const B=q(x)/P;B>2.5&&(t.measures.splitPriority+=B)}get _isGlobal(){return 1===this._renderCoordsHelper.viewingMode}}const v=[c(),c(),c(),c()],M=c(),y=c(),x=c(),b=l(0,0,1),g=m(n,b),L=312,S=.5,C=2;export{f as FeatureTileMeasurements3D};
2
+ import{len as e,set as t,normalize as i,dot as s,scale as o,copy as r,dist as a}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{ZEROS as n,freeze as l,create as c}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{distance as d}from"../../../../geometry/support/aaBoundingRect.js";import{intersectsPoint as h}from"../../../../geometry/support/frustumPlanes.js";import{fromValues as m}from"../../../../geometry/support/ray.js";import{FeatureTileVisibility3D as p,minTileLOD as u}from"./FeatureTileVisibility3D.js";import _ from"../../webgl/RenderCamera.js";class f{constructor(e,t,i){this._renderCoordsHelper=e,this._tilingScheme=t,this._camera=new _,this._surfaceElevation=0,this._focusOnMap=[0,0],this._visibility=new p(e,i)}set opaqueGround(e){this._visibility.opaqueGround=e}setup(e,t,i){this._camera.copyFrom(e),this._surfaceElevation=i,this._focusOnMap[0]=t.x,this._focusOnMap[1]=t.y,this._visibility.setup(this._camera)}done(){this._visibility.done()}update(e){const{measures:t,extent:i,level:s}=e;i&&(t.visible=this._visibility.compute(e),t.distance=d(i,this._focusOnMap),t.mergeable=!0,t.lodLevel=u,t.splitPriority=Math.max(0,u-s),t.visible&&(this._isGlobal?this._updateSplitAndLodGlobal(e):this._updateSplitAndLodLocal(e)))}_updateSplitAndLodGlobal(r){const a=r.level,n=this._renderCoordsHelper,{eye:l,fov:c}=this._camera,d=n.referenceEllipsoid.radius,h=e(l)-d;if(2*Math.atan(d/h)<c&&h>0)return void(r.measures.lodLevel=Math.max(a,u));const m=v,{extent:p}=r;if(!p)return;const{_surfaceElevation:_}=this;t(m[0],p[0],p[1],_),t(m[1],p[2],p[1],_),t(m[2],p[2],p[3],_),t(m[3],p[0],p[3],_);const f=t(M,.5*(p[0]+p[2]),.5*(p[1]+p[3]),_),y=this._tilingScheme.spatialReference;for(let e=0;e<4;++e)n.toRenderCoords(m[e],y,m[e]);n.toRenderCoords(f,y,f);const b=i(g.direction,f),L=s(l,b),S=o(x,b,L);this._updateSplitAndLod(r,m,f,S)}_updateSplitAndLodLocal(e){const i=v,{extent:s}=e;if(!s)return;const{_surfaceElevation:o}=this;t(i[0],s[0],s[1],o),t(i[1],s[2],s[1],o),t(i[2],s[2],s[3],o),t(i[3],s[0],s[3],o);const a=this._tilingScheme.spatialReference;for(let t=0;t<4;++t)this._renderCoordsHelper.toRenderCoords(i[t],a,i[t]);const n=t(M,.5*(i[0][0]+i[2][0]),.5*(i[0][1]+i[2][1]),.25*(i[0][2]+i[1][2]+i[2][2]+i[3][2])),l=t(y,n[0],n[1],0),{eye:c,far:d}=this._camera,h=t(x,l[0],l[1],c[2]);t(g.origin,l[0],l[1],c[2]-2*d),r(g.direction,b),this._updateSplitAndLod(e,i,n,h)}_updateSplitAndLod(e,t,i,o){const r=Math.max(a(t[0],t[2]),a(t[1],t[3]),a(t[0],i)+a(i,t[2]),a(t[1],i)+a(i,t[3])),{eye:n,near:l,fov:c,viewForward:d,width:m,height:p,pixelRatio:u,frustum:_}=this._camera,f=s(n,d),v=s(i,d)-f,M=a(i,n);let y=v,x=v,b=M,g=M;const R=(e,t)=>t<l?1:Math.sqrt(e*e-t*t)/t;let j=R(M,v);for(const h of t){const e=s(h,d)-f;y=Math.min(y,e),x=Math.max(x,e);const t=a(h,n);g=Math.max(g,t),b=Math.min(b,t);const i=R(t,e);j=Math.min(j,i)}if(x<l)return void(e.measures.lodLevel=0);const w=Math.cos(.5*c),A=a(n,o);j>w&&A>S*r&&(x=C*g,y=C*b);const G=.5*Math.sqrt(m*m+p*p)/u,E=2*Math.tan(.5*c),P=e=>Math.max(l,e)*L/G*E,q=e.level,H=r*2**q*Math.max(1,E),O=P(y),F=Math.ceil(Math.log2(Math.max(1,H/O)));if(e.measures.lodLevel=Math.max(F,e.measures.lodLevel),e.measures.splitPriority+=e.measures.lodLevel-q,q<F){const i=+h(_,t[0])+ +h(_,t[1])+ +h(_,t[2])+ +h(_,t[3]);e.measures.splitPriority+=i}const B=P(x)/O;B>2.5&&(e.measures.splitPriority+=B)}get _isGlobal(){return 1===this._renderCoordsHelper.viewingMode}}const v=[c(),c(),c(),c()],M=c(),y=c(),x=c(),b=l(0,0,1),g=m(n,b),L=312,S=.5,C=2;export{f as FeatureTileMeasurements3D};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{normalize as t,copy as r,set as e,dist as o,sub as s,dot as i,scaleAndAdd as n,scale as c,cross as u,len as a,direction as f,crossAndNormalize as l}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as h,fromValues as m,freeze as p}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as d}from"../../../../geometry/ellipsoidUtils.js";import{getSphericalPCPF as _}from"../../../../geometry/spatialReferenceEllipsoidUtils.js";import{projectBuffer as b}from"../../../../geometry/projection/projectBuffer.js";import{projectVec3Array as g}from"../../../../geometry/projection/projectVec3Array.js";import{isAnyVertexInPolyhedron as j,edgeIntersectsPolyhedron as v}from"../../../../geometry/support/convexPolyhedron.js";import{isConvexHullOutsideOfFrustum as M,edgeIntersectsFrustum as y}from"../../../../geometry/support/frustum.js";import{fromValues as F,signedDistance as G}from"../../../../geometry/support/plane.js";import{Frustum as R}from"../../state/Frustum.js";import{sphereIntersectsInfiniteVerticalCylinderConservative as x,sphereIntersectsInfiniteRadialConeConservative as V}from"../../support/ElevationAgnosticVisibility.js";import{correctSphericalTileCornersForLatitude as w,computeSmallestSphericalTileCone as I,getSphericalTilePole as S}from"../../support/sphericalTileUtils.js";class E{constructor(t,r){this._renderCoordsHelper=t,this.opaqueGround=r,this._cache=new Map,this._cameraForward=h(),this._cameraEye=h(),this._cameraFovY=55*Math.PI/180,this._frustum=new R(t),this._renderSR=t.spatialReference;const e=_(this._renderSR);this._renderSREllipsoidRadius=d(e).radius}setup(e){this._aboveGround=e.aboveGround,this._frustum.update(e),t(this._cameraForward,e.viewForward),r(this._cameraEye,e.eye),this._cameraFovY=e.fovY}done(){this._cache.clear()}compute(t){if(this._cache.has(t.id))return this._cache.get(t.id);const r=this._isVisibleInFrustum(t);return this._cache.set(t.id,r),r}_isVisibleInFrustum(t){return 2===this._renderCoordsHelper.viewingMode?this._isTileVisibleInFrustumLocal(t):this._isTileVisibleInFrustumGlobal(t)}_isTileVisibleInFrustumLocal(t){const r=t.spatialReference,c=t.extent,u=this._renderSR;if(!c)return!0;if(U[0]=c[0],U[1]=c[1],U[2]=0,U[3]=c[2],U[4]=c[3],U[5]=0,!b(U,r,0,U,u,0))return!1;e(k[0],U[0],U[1],0),e(k[1],U[3],U[1],0),e(k[2],U[3],U[4],0),e(k[3],U[0],U[4],0),e(A,.5*(U[0]+U[3]),.5*(U[1]+U[4]),.5*(U[2]+U[5]));const a=_t,f=.5*o(k[0],k[2]),l=this._frustum,{center:h,radius:m}=l.boundingSphere,p=m+jt,d=B;s(d,h,A);const _=i(a,d);if(n(L,A,a,_),!x(A,f,h,p))return!1;const g=this._cameraForward,F=i(g,_t),G=this._cameraFovY,R=this._cameraEye;if(Math.abs(F)<Math.abs(Math.cos(.5*G))){let t=!0;const r=e(bt,g[0],g[1],0),o=i(R,r);for(let e=0;e<4;++e){const s=k[e];if(i(s,r)-o>0){t=!1;break}}if(t)return!1}{const t=k[0],r=k[2];if(t[0]<=R[0]&&R[0]<=r[0]&&t[1]<=R[1]&&R[1]<=r[1])return!0}const V=Y,w=this.opaqueGround&&this._aboveGround,I=this.opaqueGround&&!this._aboveGround,S=Math.min(I?at:1/0,_+p),E=Math.max(w?-at:-1/0,_-p);for(let e=0;e<4;++e)n(V[e],k[e],a,S),n(V[e+4],k[e],a,E);if(M(l.planes,V,8))return!1;if(j(l.planes,V,8))return!0;for(let e=0;e<4;++e){const t=V[e],r=V[e+4];if(y(l.planes,t,r))return!0;const o=V[(e+1)%4];if(y(l.planes,t,o))return!0;const s=V[4+(e+1)%4];if(y(l.planes,r,s))return!0}if(gt[0][3]=+k[0][0],gt[1][3]=-k[2][0],gt[2][3]=+k[0][1],gt[3][3]=-k[2][1],gt[4][3]=+E,gt[5][3]=-S,j(gt,l.points))return!0;for(let e=0;e<4;++e){const t=R,r=l.points[e+4];if(v(gt,t,r))return!0;const o=l.points[4+(e+1)%4];if(v(gt,r,o))return!0}return!1}_isTileVisibleInFrustumGlobal(r){if(r.level<q)return!0;const n=r.spatialReference,h=r.extent;if(!h||!n)return!0;const m=this.opaqueGround&&this._aboveGround,p=this.opaqueGround&&!this._aboveGround,d=k,_=.5*(h[0]+h[2]);if(e(d[0],h[0],h[1],0),e(d[1],h[2],h[1],0),e(d[2],h[2],h[3],0),e(d[3],h[0],h[3],0),e(d[4],_,h[1],0),e(d[5],_,h[3],0),!g(d,n,0,d,this._renderSR,0,6))return!1;const b=this._renderSREllipsoidRadius;w(d,b);const j=A,v=this._frustum,{center:y,radius:F}=v.boundingSphere,R=F+jt,x=v.planes,E=C,P=I(d[0],d[1],d[2],d[3],E);c(j,E,b);const Y=Math.sqrt(1-P*P),U=v.origin,L=v.points;let B=!1;if(m){B=!0;const r=t(ft,U);for(let e=0;e<4;++e){const o=L[4+e],n=s(ht,o,U);t(n,n);const c=u(mt,r,n);t(c,c);const a=u(pt,n,c);t(a,a);if(i(U,a)>b){B=!1;break}}if(B){if(i(U,E)<b*Y-at)return!1}if(i(r,E)<-P)return!1;{const r=t(lt,v.direction);if(i(r,E)>dt)return!1}}if(P>.9)return!0;let X=!1;if(a(y)<=R&&!x.some(t=>G(t,z)>0)){if(!m)return!0;X=!0}if(!X&&!V(E,P,y,R))return!1;if(!B){if(d.some(t=>v.intersectsPoint(t)))return!0;if(v.intersectsPoint(j))return!0}const it=D;s(it,y,z);const nt=i(it,E),ct=H;c(ct,E,nt);const _t=o(ct,y),bt=S(r.lij,n),gt=1===bt||3===bt,vt=2===bt||3===bt,Mt=vt?et:gt?tt:Z,yt=vt?ot:gt?rt:$;if(!X){const t=d,r=st,e=N,o=O,s=z;for(const n of Mt){const u=t[n],a=t[(n+1)%4];if(f(e,a,u),f(o,s,u),l(r,o,e),i(r,E)>0&&c(r,r,-1),T(r,L,1))return!1}}let Ft=null;if(!m&&nt<1.01*R){const t=2.5*R;if(_t>Y*t+R)return!1;const r=K,o=t/Y;for(let e=0;e<4;++e)c(r[e],d[e],o/b);e(r[4],0,0,0),Ft=r}else{const t=(p?b+at:nt+R)/Y,r=m?b-at:(nt-R)/Y,e=J;for(let o=0;o<4;++o){const s=d[o];c(e[o],s,r/b),c(e[o+4],s,t/b)}Ft=e}if(M(v.planes,Ft,Ft.length))return!1;const Gt=v.lines,Rt=Q,xt=W;for(const e of Gt){t(xt,e.direction);for(const r of yt){const e=Ft[r];if(t(Rt,e),ut(xt,Rt,Ft,L))return!1;const o=(r+1)%4;if(m){const r=Ft[o];if(s(Rt,r,e),t(Rt,Rt),ut(xt,Rt,Ft,L))return!1}if(p){const e=Ft[4+r],i=Ft[4+o];if(s(Rt,i,e),t(Rt,Rt),ut(xt,Rt,Ft,L))return!1}}}return!0}}const q=2,P=4;function T(t,r,e){for(const o of r)if(i(o,t)<e)return!1;return!0}const Y=[h(),h(),h(),h(),h(),h(),h(),h()],U=[0,0,0,0,0,0],k=[h(),h(),h(),h(),h(),h()],A=h(),C=h(),H=h(),L=h(),B=h(),z=p(0,0,0),D=h(),J=[h(),h(),h(),h(),h(),h(),h(),h()],K=[h(),h(),h(),h(),h()],N=h(),O=h(),Q=h(),W=h(),X=h(),Z=[0,1,2,3],$=[0,1,2,3],tt=[0,1,3],rt=[0,1,3],et=[1,2,3],ot=[1,2,3],st=h();function it(t,r,e){let o=1/0,s=-1/0;for(const n of e){const t=i(r,n);o=Math.min(o,t),s=Math.max(s,t)}t[0]=o,t[1]=s}function nt(t,r,e,o){let s=1/0,n=-1/0;for(const c of o){const o=i(e,c);if(s=Math.min(s,o),n=Math.max(n,o),s<=r&&n>=t)return!1}return!0}const ct=[0,0];function ut(t,r,e,o){const s=e.length,i=o.length;if(0===s||0===i)return!0;const n=X;l(n,t,r);const c=i<s,u=c?e:o,a=ct;return it(a,n,c?o:e),nt(a[0],a[1],n,u)}const at=430,ft=h(),lt=h(),ht=h(),mt=h(),pt=h(),dt=Math.cos(.25*Math.PI),_t=m(0,0,1),bt=h(),gt=[F(-1,0,0,1),F(1,0,0,-1),F(0,-1,0,1),F(0,1,0,-1),F(0,0,-1,1),F(0,0,1,-1)],jt=1;export{E as FeatureTileVisibility3D,P as maxLODLevelDelta,q as minTileLOD};
2
+ import{normalize as t,copy as r,set as e,dist as i,sub as s,dot as o,scaleAndAdd as n,scale as c,cross as u,len as a,direction as f,crossAndNormalize as l}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as m,fromValues as h,freeze as p}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as d}from"../../../../geometry/ellipsoidUtils.js";import{getSphericalPCPF as _}from"../../../../geometry/spatialReferenceEllipsoidUtils.js";import{projectBuffer as b}from"../../../../geometry/projection/projectBuffer.js";import{projectVec3Array as g}from"../../../../geometry/projection/projectVec3Array.js";import{isAnyPointInConvexPolyhedron as v,lineSegmentIntersectsConvexPolyhedron as y}from"../../../../geometry/support/convexPolyhedron.js";import{fromValues as j,signedDistance as M}from"../../../../geometry/support/plane.js";import{Frustum as F}from"../../state/Frustum.js";import{sphereIntersectsInfiniteVerticalCylinderConservative as V,sphereIntersectsInfiniteRadialConeConservative as w}from"../../support/ElevationAgnosticVisibility.js";import{correctSphericalTileCornersForLatitude as G,computeSmallestSphericalTileCone as R,getSphericalTilePole as x}from"../../support/sphericalTileUtils.js";class I{constructor(t,r){this._renderCoordsHelper=t,this.opaqueGround=r,this._cache=new Map,this._cameraForward=m(),this._cameraEye=m(),this._cameraFovY=55*Math.PI/180,this._frustum=new F(t),this._renderSR=t.spatialReference;const e=_(this._renderSR);this._renderSREllipsoidRadius=d(e).radius}setup(e){this._aboveGround=e.aboveGround,this._frustum.update(e),t(this._cameraForward,e.viewForward),r(this._cameraEye,e.eye),this._cameraFovY=e.fovY}done(){this._cache.clear()}compute(t){if(this._cache.has(t.id))return this._cache.get(t.id);const r=this._isVisibleInFrustum(t);return this._cache.set(t.id,r),r}_isVisibleInFrustum(t){return 2===this._renderCoordsHelper.viewingMode?this._isTileVisibleInFrustumLocal(t):this._isTileVisibleInFrustumGlobal(t)}_isTileVisibleInFrustumLocal(t){const r=t.spatialReference,c=t.extent,u=this._renderSR;if(!c)return!0;if(T[0]=c[0],T[1]=c[1],T[2]=0,T[3]=c[2],T[4]=c[3],T[5]=0,!b(T,r,0,T,u,0))return!1;e(C[0],T[0],T[1],0),e(C[1],T[3],T[1],0),e(C[2],T[3],T[4],0),e(C[3],T[0],T[4],0),e(H,.5*(T[0]+T[3]),.5*(T[1]+T[4]),.5*(T[2]+T[5]));const a=pt,f=.5*i(C[0],C[2]),l=this._frustum,{center:m,radius:h}=l.boundingSphere,p=h+bt,d=A;s(d,m,H);const _=o(a,d);if(n(k,H,a,_),!V(H,f,m,p))return!1;const g=this._cameraForward,j=o(g,pt),M=this._cameraFovY,F=this._cameraEye;if(Math.abs(j)<Math.abs(Math.cos(.5*M))){let t=!0;const r=e(dt,g[0],g[1],0),i=o(F,r);for(let e=0;e<4;++e){const s=C[e];if(o(s,r)-i>0){t=!1;break}}if(t)return!1}{const t=C[0],r=C[2];if(t[0]<=F[0]&&F[0]<=r[0]&&t[1]<=F[1]&&F[1]<=r[1])return!0}const w=q,G=this.opaqueGround&&this._aboveGround,R=this.opaqueGround&&!this._aboveGround,x=Math.min(R?ct:1/0,_+p),I=Math.max(G?-ct:-1/0,_-p);for(let e=0;e<4;++e)n(w[e],C[e],a,x),n(w[e+4],C[e],a,I);if(l.isConvexHullOutsideViewPyramid(w,8))return!1;if(v(l.planes,w,8))return!0;for(let e=0;e<4;++e){const t=w[e],r=w[e+4];if(l.lineSegmentIntersectsViewPyramid(t,r))return!0;const i=w[(e+1)%4];if(l.lineSegmentIntersectsViewPyramid(t,i))return!0;const s=w[4+(e+1)%4];if(l.lineSegmentIntersectsViewPyramid(r,s))return!0}if(_t[0][3]=+C[0][0],_t[1][3]=-C[2][0],_t[2][3]=+C[0][1],_t[3][3]=-C[2][1],_t[4][3]=+I,_t[5][3]=-x,v(_t,l.points))return!0;for(let e=0;e<4;++e){const t=F,r=l.points[e+4];if(y(_t,t,r))return!0;const i=l.points[4+(e+1)%4];if(y(_t,r,i))return!0}return!1}_isTileVisibleInFrustumGlobal(r){if(r.level<S)return!0;const n=r.spatialReference,m=r.extent;if(!m||!n)return!0;const h=this.opaqueGround&&this._aboveGround,p=this.opaqueGround&&!this._aboveGround,d=C,_=.5*(m[0]+m[2]);if(e(d[0],m[0],m[1],0),e(d[1],m[2],m[1],0),e(d[2],m[2],m[3],0),e(d[3],m[0],m[3],0),e(d[4],_,m[1],0),e(d[5],_,m[3],0),!g(d,n,0,d,this._renderSR,0,6))return!1;const b=this._renderSREllipsoidRadius;G(d,b);const v=H,y=this._frustum,{center:j,radius:F}=y.boundingSphere,V=F+bt,I=y.planes,P=Y,q=R(d[0],d[1],d[2],d[3],P);c(v,P,b);const T=Math.sqrt(1-q*q),k=y.origin,A=y.points;let Q=!1;if(h){Q=!0;const r=t(ut,k);for(let e=0;e<4;++e){const i=A[4+e],n=s(ft,i,k);t(n,n);const c=u(lt,r,n);t(c,c);const a=u(mt,n,c);t(a,a);if(o(k,a)>b){Q=!1;break}}if(Q){if(o(k,P)<b*T-ct)return!1}if(o(r,P)<-q)return!1;{const r=t(at,y.direction);if(o(r,P)>ht)return!1}}if(q>.9)return!0;let it=!1;if(a(j)<=V&&!I.some(t=>M(t,L)>0)){if(!h)return!0;it=!0}if(!it&&!w(P,q,j,V))return!1;if(!Q){if(d.some(t=>y.intersectsPoint(t)))return!0;if(y.intersectsPoint(v))return!0}const st=O;s(st,j,L);const ot=o(st,P),pt=U;c(pt,P,ot);const dt=i(pt,j),_t=x(r.lij,n),gt=1===_t||3===_t,vt=2===_t||3===_t,yt=vt?tt:gt?Z:W,jt=vt?rt:gt?$:X;if(!it){const t=d,r=et,e=D,i=J,s=L;for(const n of yt){const u=t[n],a=t[(n+1)%4];if(f(e,a,u),f(i,s,u),l(r,i,e),o(r,P)>0&&c(r,r,-1),E(r,A,1))return!1}}let Mt=null;if(!h&&ot<1.01*V){const t=2.5*V;if(dt>T*t+V)return!1;const r=z,i=t/T;for(let e=0;e<4;++e)c(r[e],d[e],i/b);e(r[4],0,0,0),Mt=r}else{const t=(p?b+ct:ot+V)/T,r=h?b-ct:(ot-V)/T,e=B;for(let i=0;i<4;++i){const s=d[i];c(e[i],s,r/b),c(e[i+4],s,t/b)}Mt=e}if(y.isConvexHullOutsideViewPyramid(Mt,Mt.length))return!1;const Ft=y.lines,Vt=K,wt=N;for(const e of Ft){t(wt,e.direction);for(const r of jt){const e=Mt[r];if(t(Vt,e),nt(wt,Vt,Mt,A))return!1;const i=(r+1)%4;if(h){const r=Mt[i];if(s(Vt,r,e),t(Vt,Vt),nt(wt,Vt,Mt,A))return!1}if(p){const e=Mt[4+r],o=Mt[4+i];if(s(Vt,o,e),t(Vt,Vt),nt(wt,Vt,Mt,A))return!1}}}return!0}}const S=2,P=4;function E(t,r,e){for(const i of r)if(o(i,t)<e)return!1;return!0}const q=[m(),m(),m(),m(),m(),m(),m(),m()],T=[0,0,0,0,0,0],C=[m(),m(),m(),m(),m(),m()],H=m(),Y=m(),U=m(),k=m(),A=m(),L=p(0,0,0),O=m(),B=[m(),m(),m(),m(),m(),m(),m(),m()],z=[m(),m(),m(),m(),m()],D=m(),J=m(),K=m(),N=m(),Q=m(),W=[0,1,2,3],X=[0,1,2,3],Z=[0,1,3],$=[0,1,3],tt=[1,2,3],rt=[1,2,3],et=m();function it(t,r,e){let i=1/0,s=-1/0;for(const n of e){const t=o(r,n);i=Math.min(i,t),s=Math.max(s,t)}t[0]=i,t[1]=s}function st(t,r,e,i){let s=1/0,n=-1/0;for(const c of i){const i=o(e,c);if(s=Math.min(s,i),n=Math.max(n,i),s<=r&&n>=t)return!1}return!0}const ot=[0,0];function nt(t,r,e,i){const s=e.length,o=i.length;if(0===s||0===o)return!0;const n=Q;l(n,t,r);const c=o<s,u=c?e:i,a=ot;return it(a,n,c?i:e),st(a[0],a[1],n,u)}const ct=430,ut=m(),at=m(),ft=m(),lt=m(),mt=m(),ht=Math.cos(.25*Math.PI),pt=h(0,0,1),dt=m(),_t=[j(-1,0,0,1),j(1,0,0,-1),j(0,-1,0,1),j(0,1,0,-1),j(0,0,-1,1),j(0,0,1,-1)],bt=1;export{I as FeatureTileVisibility3D,P as maxLODLevelDelta,S as minTileLOD};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{copy as t,normalize as i,sub as e,dot as r,scaleAndAdd as s,direction as n}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{create as o}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as u,createPoints as h,fromMatrix as p,intersectsSphere as d,intersectsRay as c,intersectsLineSegment as g,edgeIntersectsFrustum as a,intersectsPoint as l,planePointIndices as m}from"../../../geometry/support/frustum.js";import{Sphere as _}from"../../../geometry/support/sphere.js";class f{get planes(){return this.frustum}get points(){return this._points}get direction(){return this._direction}get origin(){return this._origin}get boundingSphere(){return this._boundingSphereDirty&&this._updateBoundingSphere(),this._boundingSphere}constructor(t){this.renderCoordsHelper=t,this.frustum=u(),this._points=h(),this.lines=new Array(12),this._origin=o(),this._direction=o(),this._boundingSphere=new _,this._altitude=null,this._boundingSphereDirty=!0;for(let i=0;i<12;i++)this.lines[i]={origin:null,direction:o(),endpoint:null}}update(i){p(i.viewMatrix,i.projectionMatrix,this.frustum,this._points),t(this._origin,i.eye),t(this._direction,i.viewForward),this._altitude=this.renderCoordsHelper.getAltitude(this._origin),this._updateLines(),this._boundingSphereDirty=!0}get altitude(){return this._altitude}intersectsSphere(t){return d(this.frustum,t)}intersectsRay(t){return c(this.frustum,t)}intersectsLineSegment(t,i){return g(this.frustum,t,i)}lineSegmentIntersectsViewPyramid(t,i){return a(this.frustum,t,i)}intersectsPoint(t){return l(this.frustum,t)}_updateLines(){const t=this._points;for(let i=0;i<4;i++){const e=i+4;S(this.lines[i],t[i],t[e]),S(this.lines[i+4],t[i],3===i?t[0]:t[i+1]),S(this.lines[i+8],t[e],3===i?t[4]:t[e+1])}}_updateBoundingSphere(){const{origin:t}=this,n=y;i(n,this.direction);const o=b;e(o,this.points[4],t);const u=.5*r(o,o)/r(n,o),h=this._boundingSphere,p=s(w,t,n,u);h.center=p,h.radius=u}static{this.planePointIndices=m}static{this.nearFarLineIndices=[[0,4],[1,5],[2,6],[3,7]]}}function S(t,i,e){t.origin=i,t.endpoint=e,n(t.direction,i,e)}const b=o(),y=o(),w=o();export{f as Frustum};
2
+ import{copy as t,normalize as i,sub as e,dot as r,scaleAndAdd as s,direction as n}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{create as o}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as u,createPoints as h,fromMatrix as d,intersectsSphere as p,isConvexHullOutsideViewPyramid as c,intersectsRay as a,intersectsLineSegment as l,lineSegmentIntersectsViewPyramid as g,intersectsPoint as m,planePointIndices as _}from"../../../geometry/support/frustumPlanes.js";import{Sphere as f}from"../../../geometry/support/sphere.js";class S{get planes(){return this.frustum}get points(){return this._points}get direction(){return this._direction}get origin(){return this._origin}get boundingSphere(){return this._boundingSphereDirty&&this._updateBoundingSphere(),this._boundingSphere}constructor(t){this.renderCoordsHelper=t,this.frustum=u(),this._points=h(),this.lines=new Array(12),this._origin=o(),this._direction=o(),this._boundingSphere=new f,this._altitude=null,this._boundingSphereDirty=!0;for(let i=0;i<12;i++)this.lines[i]={origin:null,direction:o(),endpoint:null}}update(i){d(i.viewMatrix,i.projectionMatrix,this.frustum,this._points),t(this._origin,i.eye),t(this._direction,i.viewForward),this._altitude=this.renderCoordsHelper.getAltitude(this._origin),this._updateLines(),this._boundingSphereDirty=!0}get altitude(){return this._altitude}intersectsSphere(t){return p(this.frustum,t)}isConvexHullOutsideViewPyramid(t,i){return c(this.frustum,t,i)}intersectsRay(t){return a(this.frustum,t)}intersectsLineSegment(t,i){return l(this.frustum,t,i)}lineSegmentIntersectsViewPyramid(t,i){return g(this.frustum,t,i)}intersectsPoint(t){return m(this.frustum,t)}_updateLines(){const t=this._points;for(let i=0;i<4;i++){const e=i+4;y(this.lines[i],t[i],t[e]),y(this.lines[i+4],t[i],3===i?t[0]:t[i+1]),y(this.lines[i+8],t[e],3===i?t[4]:t[e+1])}}_updateBoundingSphere(){const{origin:t}=this,n=w;i(n,this.direction);const o=b;e(o,this.points[4],t);const u=.5*r(o,o)/r(n,o),h=this._boundingSphere,d=s(x,t,n,u);h.center=d,h.radius=u}static{this.planePointIndices=_}static{this.nearFarLineIndices=[[0,4],[1,5],[2,6],[3,7]]}}function y(t,i,e){t.origin=i,t.endpoint=e,n(t.direction,i,e)}const b=o(),w=o(),x=o();export{S as Frustum};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as t}from"tslib";import{createScreenPointArray as i,screenPointObjectToArray as e}from"../../../../core/screenUtils.js";import{subclass as r}from"../../../../core/accessorSupport/decorators.js";import{copy as o,distance as s}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{scaleAndAdd as n,dot as a,crossAndNormalize as h,scale as l,add as p}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as c}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as _}from"../../../../geometry/ellipsoidUtils.js";import{create as m,fromPositionAndNormal as d}from"../../../../geometry/support/plane.js";import{Sphere as u}from"../../../../geometry/support/sphere.js";import{pixelDistanceToInteractionFactor as P,applyAll as g}from"../../camera/constraintUtils.js";import{ConstraintOptions as C}from"../../camera/constraintUtils/ConstraintOptions.js";import{InteractiveController as f}from"./InteractiveController.js";import{ropePullMaxElevation as v,findSphereHorizonY as S,computeHorizonPaddingLimits as z,findPlaneHorizonY as w,findGlobalModeRopePullGrabLocation as b,findLocalModeRopePullGrabLocation as j,ropePullYSpeedMultiplier as y,ropePullXSpeedMultiplier as R}from"../utils/ropePullUtils.js";import T from"../../webgl/RenderCamera.js";let H=class extends f{constructor(t){super(t),this._validState=!0,this._adjustedScenePoint=c(),this._referenceSphere=new u,this._referencePlane=m(),this._tmp3d=c(),this._screenPointArray=i(),this._forwardRopeComponent=c(),this._sidewaysRopeComponent=c(),this._ropeTranslation=c(),this._beginScreenPoint=i(),this._screenPickPoint=i(),this._horizonY=null,this._horizonPadding=null,this._ropeBeginScreenPoint=i(),this._ropeScreenHeight=1,this._ropePlane=m(),this._ropePullOverHorizonVelocityAdjustment=1,this._pointerCount=0,this._beginCamera=new T,this._constraintOptions=new C(15,0,0,this._beginCamera)}get isGlobalMode(){return 1===this.view.state.viewingMode}begin(t){this.running&&(this._pointerCount=t.pointers.size,e(t.center,this._screenPickPoint),Math.abs(this._screenPickPoint[0]-this.view.width/2)<.1&&(this._screenPickPoint[0]+=1),o(this._beginScreenPoint,this._screenPickPoint),this.startCamera.relativeElevation>v?this._validState=!1:(this._initClampValues(),this._prepareRopePullMode(),this._beginCamera.copyFrom(this.startCamera)))}update(t){this.running&&this._validState&&(this.currentCamera.copyFrom(this.startCamera),this._panningRopePull(t),this.commitCamera())}end(t){return t.pointers.size===this._pointerCount&&this.update(t),this.finishController(),null}_initClampValues(){this.isGlobalMode?this._globalInitClampValues():this._localInitClampValues()}_globalInitClampValues(){this._referenceSphere.radius=_(this.view.spatialReference).radius,this._horizonY=S(this.startCamera,this._referenceSphere,this._screenPickPoint),this._horizonPadding=null!=this._horizonY?z(this.startCamera,this._horizonY):null}_localInitClampValues(){const t=c();this.view.renderCoordsHelper.worldUpAtPosition(this.startCamera.eye,t);const i=c();n(i,this.startCamera.eye,t,-this.startCamera.relativeElevation),d(i,t,this._referencePlane),this._horizonY=w(this.startCamera,this._referencePlane),this._horizonPadding=z(this.startCamera,this._horizonY)}_prepareRopePullMode(){if(!this._horizonY||!this._horizonPadding)return;this._ropeBeginScreenPoint=this._screenPickPoint,this._ropeScreenHeight=this.startCamera.fullHeight/this.startCamera.pixelRatio;if(!(this.isGlobalMode?b({view:this.view,originalScreenPoint:this._ropeBeginScreenPoint,horizonY:this._horizonY,horizonPadding:this._horizonPadding,outRopeTranslation:this._ropeTranslation,outGrabLocation:this._adjustedScenePoint}):j({view:this.view,originalScreenPoint:this._ropeBeginScreenPoint,horizonY:this._horizonY,horizonPadding:this._horizonPadding,outRopeTranslation:this._ropeTranslation,outGrabLocation:this._adjustedScenePoint})))return void(this._validState=!1);const t=c();this.view.renderCoordsHelper.worldUpAtPosition(this.startCamera.eye,t);const i=this.startCamera.viewRight,e=a(this._ropeTranslation,i),r=h(c(),t,i),o=a(this._ropeTranslation,r);l(this._forwardRopeComponent,r,o),l(this._sidewaysRopeComponent,i,e),d(this._adjustedScenePoint,t,this._ropePlane);const s=this._ropeScreenHeight-this._beginScreenPoint[1],n=this._ropeScreenHeight-this._horizonPadding[0];this._ropePullOverHorizonVelocityAdjustment=Math.max(s/n,1)}_panningRopePull(t){if(!this._horizonY||!this._horizonPadding)return;const i=e(t.center,this._screenPointArray),r=this.startCamera.fullWidth/this.startCamera.pixelRatio*.5,o=(this._ropeScreenHeight-i[1])/(this._ropeScreenHeight-this._beginScreenPoint[1]),a=1-o,h=(i[0]-r)/(this._beginScreenPoint[0]-r),c=a*y*this._ropePullOverHorizonVelocityAdjustment,_=(a*R+o*((1-h)*R))*this._ropePullOverHorizonVelocityAdjustment;l(this._ropeTranslation,this._forwardRopeComponent,c),n(this._ropeTranslation,this._ropeTranslation,this._sidewaysRopeComponent,_),this.currentCamera.eye=p(this._tmp3d,this.startCamera.eye,this._ropeTranslation),this.currentCamera.center=p(this._tmp3d,this.startCamera.center,this._ropeTranslation),this._constraintOptions.interactionType=6,this._constraintOptions.interactionFactor=P(s(this._beginScreenPoint,i)),this._constraintOptions.interactionDirection=this._ropeTranslation,g(this.view,this.currentCamera,this._constraintOptions),this._constraintOptions.interactionDirection=null}};H=t([r("esri.views.3d.state.controllers.RopePullController")],H);export{H as RopePullController};
2
+ import{__decorate as t}from"tslib";import{prefersReducedMotion as i}from"../../../../core/a11yUtils.js";import{createScreenPointArray as e,screenPointObjectToArray as r}from"../../../../core/screenUtils.js";import{subclass as o}from"../../../../core/accessorSupport/decorators.js";import{copy as n,distance as s}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{scaleAndAdd as a,dot as h,crossAndNormalize as l,scale as m,add as p}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as c}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as _}from"../../../../geometry/ellipsoidUtils.js";import{create as u,fromPositionAndNormal as d}from"../../../../geometry/support/plane.js";import{Sphere as P}from"../../../../geometry/support/sphere.js";import{pixelDistanceToInteractionFactor as g,applyAll as C}from"../../camera/constraintUtils.js";import{ConstraintOptions as v}from"../../camera/constraintUtils/ConstraintOptions.js";import{InteractiveController as f}from"./InteractiveController.js";import{RopePullMomentumController as w}from"./momentum/RopePullMomentumController.js";import{ropePullMaxElevation as S,findSphereHorizonY as b,computeHorizonPaddingLimits as z,findPlaneHorizonY as j,findGlobalModeRopePullGrabLocation as y,findLocalModeRopePullGrabLocation as R,ropePullYSpeedMultiplier as M,ropePullXSpeedMultiplier as T}from"../utils/ropePullUtils.js";import H from"../../webgl/RenderCamera.js";import{RopePullMomentumEstimator as E}from"../../../navigation/RopePullMomentumEstimator.js";let Y=class extends f{constructor(t){super(t),this._validState=!0,this._adjustedScenePoint=c(),this._ropePullMomentumEstimator=new E,this._referenceSphere=new P,this._referencePlane=u(),this._tmp3d=c(),this._screenPointArray=e(),this._forwardRopeComponent=c(),this._sidewaysRopeComponent=c(),this._ropeTranslation=c(),this._beginScreenPoint=e(),this._screenPickPoint=e(),this._horizonY=null,this._horizonPadding=null,this._ropeBeginScreenPoint=e(),this._ropeScreenHeight=1,this._ropePlane=u(),this._ropePullOverHorizonVelocityAdjustment=1,this._pointerCount=0,this._beginCamera=new H,this._constraintOptions=new v(15,0,0,this._beginCamera)}get isGlobalMode(){return 1===this.view.state.viewingMode}get momentumEnabled(){return this.view.navigation.momentumEnabled&&this.view.animationsEnabled&&!i()}begin(t){this.running&&(this._pointerCount=t.pointers.size,r(t.center,this._screenPickPoint),Math.abs(this._screenPickPoint[0]-this.view.width/2)<.1&&(this._screenPickPoint[0]+=1),n(this._beginScreenPoint,this._screenPickPoint),this.startCamera.relativeElevation>S?this._validState=!1:(this._initClampValues(),this._prepareRopePullMode(),this._beginCamera.copyFrom(this.startCamera)))}update(t){this.running&&this._validState&&(this.currentCamera.copyFrom(this.startCamera),this._panningRopePull(t),this.commitCamera())}end(t){return t.pointers.size===this._pointerCount&&this.update(t),this.finishController(),this.createMomentum()}_initClampValues(){this.isGlobalMode?this._globalInitClampValues():this._localInitClampValues()}_globalInitClampValues(){this._referenceSphere.radius=_(this.view.spatialReference).radius,this._horizonY=b(this.startCamera,this._referenceSphere,this._screenPickPoint),this._horizonPadding=null!=this._horizonY?z(this.startCamera,this._horizonY):null}_localInitClampValues(){const t=c();this.view.renderCoordsHelper.worldUpAtPosition(this.startCamera.eye,t);const i=c();a(i,this.startCamera.eye,t,-this.startCamera.relativeElevation),d(i,t,this._referencePlane),this._horizonY=j(this.startCamera,this._referencePlane),this._horizonPadding=z(this.startCamera,this._horizonY)}_prepareRopePullMode(){if(!this._horizonY||!this._horizonPadding)return;this._ropePullMomentumEstimator.reset(),this._ropeBeginScreenPoint=this._screenPickPoint,this._ropeScreenHeight=this.startCamera.fullHeight/this.startCamera.pixelRatio;if(!(this.isGlobalMode?y({view:this.view,originalScreenPoint:this._ropeBeginScreenPoint,horizonY:this._horizonY,horizonPadding:this._horizonPadding,outRopeTranslation:this._ropeTranslation,outGrabLocation:this._adjustedScenePoint}):R({view:this.view,originalScreenPoint:this._ropeBeginScreenPoint,horizonY:this._horizonY,horizonPadding:this._horizonPadding,outRopeTranslation:this._ropeTranslation,outGrabLocation:this._adjustedScenePoint})))return void(this._validState=!1);const t=c();this.view.renderCoordsHelper.worldUpAtPosition(this.startCamera.eye,t);const i=this.startCamera.viewRight,e=h(this._ropeTranslation,i),r=l(c(),t,i),o=h(this._ropeTranslation,r);m(this._forwardRopeComponent,r,o),m(this._sidewaysRopeComponent,i,e),d(this._adjustedScenePoint,t,this._ropePlane);const n=this._ropeScreenHeight-this._beginScreenPoint[1],s=this._ropeScreenHeight-this._horizonPadding[0];this._ropePullOverHorizonVelocityAdjustment=Math.max(n/s,1)}_panningRopePull(t){if(!this._horizonY||!this._horizonPadding)return;const i=r(t.center,this._screenPointArray),e=this.startCamera.fullWidth/this.startCamera.pixelRatio*.5,o=(this._ropeScreenHeight-i[1])/(this._ropeScreenHeight-this._beginScreenPoint[1]),n=1-o,h=(i[0]-e)/(this._beginScreenPoint[0]-e),l=n*M*this._ropePullOverHorizonVelocityAdjustment,c=(n*T+o*((1-h)*T))*this._ropePullOverHorizonVelocityAdjustment;m(this._ropeTranslation,this._forwardRopeComponent,l),a(this._ropeTranslation,this._ropeTranslation,this._sidewaysRopeComponent,c),this.currentCamera.eye=p(this._tmp3d,this.startCamera.eye,this._ropeTranslation),this.currentCamera.center=p(this._tmp3d,this.startCamera.center,this._ropeTranslation),this.momentumEnabled&&this._ropePullMomentumEstimator.update(i,this._ropeTranslation,.001*t.timestamp),this._constraintOptions.interactionType=6,this._constraintOptions.interactionFactor=g(s(this._beginScreenPoint,i)),this._constraintOptions.interactionDirection=this._ropeTranslation,C(this.view,this.currentCamera,this._constraintOptions),this._constraintOptions.interactionDirection=null}createMomentum(){const t=this.momentumEnabled&&this._ropePullMomentumEstimator.createMomentum();return t?new w({view:this.view,momentum:t}):null}};Y=t([o("esri.views.3d.state.controllers.RopePullController")],Y);export{Y as RopePullController};
@@ -0,0 +1,2 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
+ import{__decorate as t}from"tslib";import{property as o,subclass as e}from"../../../../../core/accessorSupport/decorators.js";import{scale as r,add as m}from"../../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as s}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{MomentumController as i}from"./MomentumController.js";let n=class extends i{constructor(t){super(t),this.interactionType=6,this._tmpPan=s()}momentumStep(t,o){const e=this.momentum.value(t);r(this._tmpPan,this.momentum.direction,e),o.eye=m(c,o.eye,this._tmpPan),o.center=m(c,o.center,this._tmpPan),this.constraintOptions.interactionDirection=this._tmpPan}};t([o({constructOnly:!0})],n.prototype,"momentum",void 0),n=t([e("esri.views.3d.state.controllers.momentum.RopePullMomentumController")],n);const c=s();export{n as RopePullMomentumController};
@@ -0,0 +1,2 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
+ import{distance as e,length as t,normalize as r,scale as s,dot as i}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{fromValues as a,create as n}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";function h(e,t,r,a,n){const h=i(e,a),c=Math.max(t,Math.min(r,h));return s(n,e,c),n}function c(e,t,r,s,i){const a=Math.max(t,Math.min(r,s[2]));return i[0]=e[0],i[1]=e[1],i[2]=a,i}class o{constructor(e,t){if(this.lowerCenterHeight=e,this.upperCenterHeight=t,!(e<t))throw new Error(`Invalid elevated sphere: ${e}..${t}`)}}class l extends o{constructor(e,i,h){if(super(i,h),this.baseSphere=e,i<=0)throw new Error(`Invalid elevated sphere: ${i}..${h}`);const c=t(e.center);if(this._radialAxis=0===c?a(0,0,1):r(n(),e.center),0===c)return this._surfaceCenter=a(0,0,0),void(this._surfaceRadius=h+e.radius);this._surfaceCenter=s(n(),this._radialAxis,h),this._surfaceRadius=e.radius*h/c}clone(){return new l(this.baseSphere,this.lowerCenterHeight,this.upperCenterHeight)}calculateSurfaceDistanceFromPoint(t){return Math.max(0,e(this._surfaceCenter,t)-this._surfaceRadius)}calculateCenterDistanceFromPoint(t){return this.calculateClosestCenterToPoint(t,C),e(t,C)}calculateClosestCenterToPoint(e,r){return 0===t(this.baseSphere.center)?(r[0]=0,r[1]=0,r[2]=0,r):h(this._radialAxis,this.lowerCenterHeight,this.upperCenterHeight,e,r)}}class u extends o{constructor(e,s,i){if(super(s,i),this.baseSphere=e,s<=0)throw new Error(`Invalid elevated sphere: ${s}..${i}`);const a=t(e.center),h=e.radius;if(a<=h)throw new Error("Invalid sphere cone: base sphere contains the planet center");const c=s-a,o=i-a,l=a+h+Math.max(Math.abs(c),Math.abs(o));this._radialAxis=r(n(),e.center);const u=h/a,p=Math.sqrt(1-u**2),C=a+Math.min(c/(1-u),c/p),d=a+Math.max(o/(1+u),o/p);if(C<=0||C>=d)return this._lowerEnvelopeCenterHeight=s,this._upperEnvelopeCenterHeight=i,void(this._enclosingSphereRadius=l);this._lowerEnvelopeCenterHeight=C,this._upperEnvelopeCenterHeight=d,this._enclosingSphereRadius=null}clone(){return new u(this.baseSphere,this.lowerCenterHeight,this.upperCenterHeight)}calculateSurfaceDistanceFromPoint(r){const a=t(this.baseSphere.center),h=this.baseSphere.radius;if(null!=this._enclosingSphereRadius)return Math.max(0,t(r)-this._enclosingSphereRadius);const c=this._lowerEnvelopeCenterHeight,o=this._upperEnvelopeCenterHeight,l=this._radialAxis,u=h*c/a,p=h*o/a,C=a**2-h**2,d=C/a,f=d*(c/a),S=d*(o/a),g=i(l,r);if(g<=f-u)return this._calculateCapSphereSurfaceDistance(r,c,u);if(g>=S)return this._calculateCapSphereSurfaceDistance(r,o,p);const _=Math.sqrt(C),m=h*_/a,w=s(n(),l,g),x=e(w,r),H=m*g/d;if(x<=H)return 0;const M=_*(o/a),b=_*(g/d);return b<=_*(c/a)?this._calculateCapSphereSurfaceDistance(r,c,u):b>=M?this._calculateCapSphereSurfaceDistance(r,o,p):(x-H)*d/_}calculateCenterDistanceFromPoint(t){return this.calculateClosestCenterToPoint(t,C),e(t,C)}calculateClosestCenterToPoint(e,r){return 0===t(this.baseSphere.center)?(r[0]=0,r[1]=0,r[2]=0,r):h(this._radialAxis,this.lowerCenterHeight,this.upperCenterHeight,e,r)}_calculateCapSphereSurfaceDistance(t,r,i){const a=s(n(),this._radialAxis,r),h=e(a,t);return h<i?0:h-i}}class p extends o{constructor(e,t,r){super(t,r),this.baseSphere=e}clone(){return new p(this.baseSphere,this.lowerCenterHeight,this.upperCenterHeight)}calculateSurfaceDistanceFromPoint(e){const{center:t,radius:r}=this.baseSphere,s=e[2],i=(e[0]-t[0])**2+(e[1]-t[1])**2,{lowerCenterHeight:a,upperCenterHeight:n}=this;return s<=a?Math.max(0,Math.sqrt(i+(s-a)**2)-r):s>=n?Math.max(0,Math.sqrt(i+(s-n)**2)-r):Math.max(0,Math.sqrt(i)-r)}calculateCenterDistanceFromPoint(t){return this.calculateClosestCenterToPoint(t,C),e(t,C)}calculateClosestCenterToPoint(e,t){return c(this.baseSphere.center,this.lowerCenterHeight,this.upperCenterHeight,e,t)}}const C=n();export{l as SphereGlobal,u as SweptSphereConicalVolume,p as SweptSphereCylindricalVolume,o as SweptSphereVolume,h as calculateClosestCenterOnRadialRange,c as calculateClosestCenterOnVerticalRange};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import t from"../../../Camera.js";import e from"../../../Graphic.js";import n from"../../../Viewpoint.js";import{result as r}from"../../../core/asyncUtils.js";import{cyclicalDegrees as o}from"../../../core/Cyclical.js";import a from"../../../core/Error.js";import{throwIfAborted as i}from"../../../core/promiseUtils.js";import{fromMat4 as s,transpose as c}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{create as l}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{create as m}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{scale as u,add as f,distance as p,copy as g,subtract as y,set as h,transformMat3 as d}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{create as w}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import x from"../../../geometry/Extent.js";import j from"../../../geometry/Geometry.js";import v from"../../../geometry/Multipoint.js";import b from"../../../geometry/Point.js";import{projectAsync as R,tryProject as z}from"../../../geometry/projectionUtils.js";import G from"../../../geometry/SpatialReference.js";import{computeTranslationToOriginAndRotation as S}from"../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{projectPointToVectorAsync as B}from"../../../geometry/projection/projectPointToVector.js";import{projectVectorToPoint as M}from"../../../geometry/projection/projectVectorToPoint.js";import{projectVectorToVector as Z}from"../../../geometry/projection/projectVectorToVector.js";import{create as F,center as T,toRect as P,isPoint as V,empty as A,expandWithVec3 as E,expandWithAABB as U,width as O,height as k,depth as N}from"../../../geometry/support/aaBoundingBox.js";import{create as I,isPoint as C}from"../../../geometry/support/aaBoundingRect.js";import{polygonCentroidPoint as W}from"../../../geometry/support/centroid.js";import{intersectsPoint as Y}from"../../../geometry/support/frustum.js";import{getResolutionInMetersForScale as q}from"../../../geometry/support/scaleUtils.js";import{fromRenderCamera as D,toRenderCameraWithScale as J}from"../webgl.js";import{cameraOnContentAlongViewDirection as X}from"../camera/intersectionUtils.js";import{scaleToDistance as _,distanceToScale as H}from"./cameraScaleUtils.js";import{getViewSR as K,fromExtentAsync as L,fromCenterDistanceAsync as Q,fromExtentSync as $,fromCenterDistanceSync as tt,zoomToScale as et,fromCenterScale as nt}from"./cameraUtils.js";import{getElevationAtPoint as rt}from"./ElevationProvider.js";import{directionToHeadingTilt as ot}from"./viewingModeUtils.js";const at=.66;function it(t){return 360-o.normalize(t)}function st(t){return o.normalize(360-t)}function ct(t,e,n){const r=e.camera;if(null!=r)return mt(r,K(t));const{targetGeometry:o}=e;if(null==o)return null;const{camera:a,mode:i}=ft(t,e.rotation,n);if("point"===o.type)return pt(t,e,o,a,i);const s=o.extent;return null==s?null:$(t,s,a.heading,a.tilt,i)}async function lt(t,e,n,r){const o=e.camera;if(null!=o)return ut(o,K(t),r);const{targetGeometry:a}=e;if(null==a)throw new Error("Viewpoint has no targetGeometry!");const{camera:i,mode:s}=ft(t,e.rotation,n);if("point"===a.type)return gt(t,e,a,i,s,r);const c=a.extent;if(null==c)throw new Error("Target geometry has no extent!");return L(t,c,i.heading,i.tilt,s,r)}function mt(t,e){const n=t.position,r=z(n,e);if(!r)return null;const o=t.clone();return o.position=r.clone(),o}async function ut(t,e,n){const r=t.position,o=await R(r,e,{signal:n});i(n);const a=t.clone();return a.position=o.clone(),a}function ft(t,e,n){const r=D(t,t.state.camera);let o=1;return null!=e&&(r.heading=it(e),o=0),null!=n&&(r.tilt=n),{camera:r,mode:o}}function pt(t,e,n,r,o){const a=t.spatialReference,i=z(n.clone(),a);if(!i)return null;const s=null!=e.scale?_(t,e.scale):t.state.camera.distance;return tt(t,i,s,r,o)}async function gt(t,e,n,r,o,a){const s=t.spatialReference,c=await R(n.clone(),s,{signal:a});i(a);const l=null!=e.scale?_(t,e.scale):t.state.camera.distance;return Q(t,c,l,r,o,a)}function yt(t,e,r=null){return null==r&&(r=new n),jt(t,null,e.clone(),r)}async function ht(e,r,o){const i=Vt(e,r);if(!i)throw new a("viewpointutils-create:no-target","Missing target for creating viewpoint");const s=new t({fov:e.camera.fov}),c=new n({camera:s});if(i.target instanceof n){return At(await zt(e,i.target,i,o,c))}if(i.target instanceof t)return At(await Gt(e,i.target,o,c,dt(e,i)));const l=null!=i.scale||null!=i.zoom;if(i.target instanceof x){const t=i.target.xmin===i.target.xmax||i.target.ymin===i.target.ymax;return At(l||t?await Bt(e,i,i.target.center,s,o,c):await Ft(e,i,i.target,s,o,c))}const m=new Ut,u=l?wt(e,i):void 0;if(await Rt(e,i.target,u,m,o),isFinite(m.boundingBox[0])){let t;if(T(m.boundingBox,Ot),Jt.x=Ot[0],Jt.y=Ot[1],Jt.z=Ot[2],Jt.spatialReference=e.spatialReference,isFinite(Jt.z)&&m.hasZ?t=V(m.boundingBox):(Jt.z=void 0,t=C(P(m.boundingBox,Ct))),l||t)return At(await Bt(e,i,Jt,s,o,c));const n=Et(e,m.screenSpaceObjects);return At(await Pt(e,i,Jt,m.boundingBox,n,s,o,c))}return i.position?At(await Mt(e,i,s,c,o)):At(await Zt(e,i,s,o,c))}function dt(t,e){return null==e.scale&&null!=e.zoom?et(t,e.zoom):e.scale}function wt(t,e){const n=dt(t,e);return n?q(n):void 0}function xt(t,e){let n=!1;return null!=e.heading?(t.heading=e.heading,n=!0):null!=e.rotation&&(t.heading=it(e.rotation),n=!0),null!=e.tilt&&(t.tilt=e.tilt,n=!0),null!=e.fov&&(t.fov=e.fov),n}function jt(t,e,n,r,o){const a=t.spatialReference||G.WGS84;if(e??=J(t,n,o),null==e)return r;const i=new b({spatialReference:a});return M(e.center,t.renderSpatialReference,i)?(r.targetGeometry=i,r.scale=o??H(t,e.distance),r.rotation=st(n.heading),r.camera=n,r):r}async function vt(t,e,n,r){const o=()=>new a("viewpointutils:invalid-geometry","The target is missing a valid geometry");if(!e)throw o();"mesh"===e.type&&(e=e.extent);const i=t.groundView.spatialReference;if(!e.hasZ&&t.basemapTerrain){let n;switch(e.type){case"point":n=e;break;case"multipoint":case"polyline":n=e.extent?.center;break;case"extent":n=e.center;break;case"polygon":{const t=W(e);n=t?b.fromJSON(t):null;break}}null!=n&&i&&t.elevationProvider?(n=await R(n,i,{signal:r}),Ot[2]=rt(t.elevationProvider,n)??0):Ot[2]=0}const s=Xt[e.type],c=new Array;if(s(e,e.hasZ?t=>{c.push([t[0],t[1],t[2]])}:t=>{c.push([t[0],t[1]])},Ot),0===c.length)throw o();const l=e.spatialReference,m=t.spatialReference,u=await R(new v({spatialReference:l,hasZ:e.hasZ,hasM:!1,points:c}),m,{signal:r});if(e.hasZ&&(n.hasZ=!0),e.hasZ)for(const[a,f,p]of u.points)Ot[0]=a,Ot[1]=f,Ot[2]=p,E(n.boundingBox,Ot);else for(const[a,f]of u.points)Ot[0]=a,Ot[1]=f,E(n.boundingBox,Ot)}async function bt(t,e,n,o,a){const i=await r(t.whenViewForGraphic(e));if(!1===i.ok||null==i.value||!("whenGraphicBounds"in i.value))return void await vt(t,e.geometry,o,a);const s=i.value,c=await r(s.whenGraphicBounds(e,{minDemResolution:n}));if(!1===c.ok||!c.value)return void await vt(t,e.geometry,o,a);const{screenSpaceObjects:l,boundingBox:m}=c.value;U(o.boundingBox,m),l&&l.forEach(t=>{o.screenSpaceObjects.push(t)}),isFinite(m[2])&&(o.hasZ=!0)}async function Rt(t,n,r,o,a){if(Array.isArray(n)&&2===n.length){const e=n[0],r=n[1];if("number"==typeof e&&"number"==typeof r)return Jt.x=e,Jt.y=r,Jt.z=void 0,Jt.spatialReference=t.spatialReference?.isGeographic?t.spatialReference:G.WGS84,void await vt(t,Jt,o,a)}n&&"map"in n&&"function"==typeof n.map?await Promise.allSettled(n.map(e=>Rt(t,e,r,o,a))):n instanceof j?await vt(t,n,o,a):n instanceof e&&await bt(t,n,r,o,a)}async function zt(t,e,n,r,o){if(e.camera)return Gt(t,e.camera,r,o,dt(t,n)??e.scale);o.scale=e.scale,o.rotation=e.rotation,o.targetGeometry=null!=e.targetGeometry?e.targetGeometry.clone():null,o.camera=null,null!=n.heading?o.rotation=st(n.heading):null!=n.rotation&&(o.rotation=n.rotation);const a=dt(t,n);return null!=a&&(o.scale=a),o.camera=await lt(t,o,n.tilt,r),o}async function Gt(t,e,n,r,o){const a=t.spatialReference,i=await R(e.position,a,{signal:n}),s=e.clone();return s.position=i,jt(t,null,s,r,o)}async function St(t,e,n,r,o,a,i){const s=t.renderSpatialReference;return await B(e,qt,s,{signal:i}),await B(n,Yt,s,{signal:i}),a.targetGeometry=new b(e),o.position=new b(n),y(Wt,qt,Yt),ot(t,Yt,Wt,r.up,o),a.scale=H(t,p(Yt,qt)),a.rotation=st(o.heading),a.camera=o,a}async function Bt(t,e,n,r,o,a){a.targetGeometry=n.clone();const i=X(t);if(e.position)return St(t,a.targetGeometry,e.position,i,r,a,o);if(e.zoomFactor){const n=i.distance/e.zoomFactor,r=u(Ot,i.viewForward,-n);i.eye=f(Ot,i.center,r),a.scale=H(t,n)}D(t,i,r);const s=xt(r,e)?0:1;if(!e.zoomFactor){const n=dt(t,e);if(null==n){await B(a.targetGeometry,Ot,t.renderSpatialReference,{signal:o});const e=Y(i.frustum,Ot)?p(i.eye,Ot):i.distance;a.camera=await Q(t,a.targetGeometry,e,r,s),a.scale=H(t,e)}else a.scale=n,a.camera=await nt(t,a.targetGeometry,a.scale,r,s,o)}return a}async function Mt(t,e,n,r,o){const a=X(t);g(Wt,a.viewForward),ot(t,a.eye,Wt,a.up,Dt);const i=t.spatialReference,{position:s}=e;if(s){const t=await R(s,i,{signal:o});n.position=t}else n.position=new b;return n.heading=null!=e.heading?e.heading:Dt.heading,n.tilt=null!=e.tilt?e.tilt:Dt.tilt,jt(t,null,n,r,dt(t,e))}async function Zt(t,e,n,r,o){if(null!=e.heading||null!=e.rotation||null!=e.scale||null!=e.tilt||null!=e.zoom||null!=e.zoomFactor){const a=X(t),{spatialReference:i,renderSpatialReference:s}=t,c=new b({spatialReference:i});return M(a.center,s,c)?Bt(t,e,c,n,r,o):o}return o.scale=t.scale,o.camera=t.camera.clone(),xt(o.camera,e),o}async function Ft(t,e,n,r,o,a){a.targetGeometry=n.clone();const i=X(t);D(t,i,r);const s=xt(r,e)?0:1;return a.camera=await L(t,n,r.heading,r.tilt,s,o),a}function Tt(t,e,n,r,o){let a=0;null!=n.z?a=n.z:t.basemapTerrain&&t.elevationProvider&&(a=rt(t.elevationProvider,n)),h(Ot,n.x,n.y,a),S(t.spatialReference,Ot,kt,t.renderSpatialReference),s(Nt,kt),c(Nt,Nt),A(It);const i=[[0,1,2],[3,1,2],[0,4,2],[3,4,2],[0,1,5],[3,1,5],[0,4,5],[3,4,5]];for(let s=0;s<i.length;s++){const e=i[s];let n=r[e[2]];isFinite(n)||(n=a),h(Ot,r[e[0]],r[e[1]],n),Z(Ot,t.spatialReference,Ot,t.renderSpatialReference),E(It,d(Ot,Ot,Nt))}const l=O(It),m=k(It),u=N(It),f=1/Math.tan(e.fovX/2),p=1/Math.tan(e.fovY/2),g=.5*Math.sqrt(l*l+u*u)*Math.max(p,f)+.5*m,y=.5*m*p+.5*Math.max(l,u);return Math.max(g,y)/o}async function Pt(t,e,n,r,o,a,i,s){s.targetGeometry=n.clone();const c=X(t),l=Tt(t,c,n,r,o);D(t,c,a);const m=xt(a,e)?0:1;return s.camera=await Q(t,s.targetGeometry,l,a,m,i),s.scale=H(t,l),s}function Vt(t,e){if(!e||!t.spatialReference)return null;const n={target:void 0};return"declaredClass"in e||Array.isArray(e)?n.target=e:(Object.assign(n,e),!n.target&&"center"in e&&e.center&&(n.target=e.center)),n}function At(t){return null!=t?.camera&&(t.rotation=st(t.camera.heading)),t}function Et(t,e){const n=at;if(!e.length)return n;let r=Number.NEGATIVE_INFINITY;for(let o=0;o<e.length;o++){const t=e[o].screenSpaceBoundingRect;r=Math.max(r,Math.abs(t[0]),Math.abs(t[1]),Math.abs(t[2]),Math.abs(t[3]))}return n-r/Math.min(t.width,t.height)*2}class Ut{constructor(){this.hasZ=!1,this.boundingBox=A(),this.screenSpaceObjects=new Array}}const Ot=w(),kt=m(),Nt=l(),It=F(),Ct=I(),Wt=w(),Yt=w(),qt=w(),Dt={heading:0,tilt:0},Jt=new b,Xt={point(t,e,n){n[0]=t.x,n[1]=t.y,null!=t.z&&(n[2]=t.z),e(n)},polygon(t,e,n){const r=t.hasZ;for(let o=0;o<t.rings.length;o++){const a=t.rings[o];for(let t=0;t<a.length;t++)n[0]=a[t][0],n[1]=a[t][1],r&&(n[2]=a[t][2]),e(n)}},polyline(t,e,n){const r=t.hasZ;for(let o=0;o<t.paths.length;o++){const a=t.paths[o];for(let t=0;t<a.length;t++)n[0]=a[t][0],n[1]=a[t][1],r&&(n[2]=a[t][2]),e(n)}},multipoint(t,e,n){const r=t.points,o=t.hasZ;for(let a=0;a<r.length;a++)n[0]=r[a][0],n[1]=r[a][1],o&&(n[2]=r[a][2]),e(n)},extent(t,e,n){null!=t.zmin&&null!=t.zmax?(e(h(n,t.xmin,t.ymin,t.zmin)),e(h(n,t.xmax,t.ymin,t.zmin)),e(h(n,t.xmin,t.ymax,t.zmin)),e(h(n,t.xmax,t.ymax,t.zmin)),e(h(n,t.xmin,t.ymin,t.zmax)),e(h(n,t.xmax,t.ymin,t.zmax)),e(h(n,t.xmin,t.ymax,t.zmax)),e(h(n,t.xmax,t.ymax,t.zmax))):(e(h(n,t.xmin,t.ymin,n[2])),e(h(n,t.xmax,t.ymin,n[2])),e(h(n,t.xmin,t.ymax,n[2])),e(h(n,t.xmax,t.ymax,n[2])))}};export{ht as create,yt as fromCamera,lt as toCameraAsync,ct as toCameraSync};
2
+ import t from"../../../Camera.js";import e from"../../../Graphic.js";import n from"../../../Viewpoint.js";import{result as r}from"../../../core/asyncUtils.js";import{cyclicalDegrees as o}from"../../../core/Cyclical.js";import a from"../../../core/Error.js";import{throwIfAborted as i}from"../../../core/promiseUtils.js";import{fromMat4 as s,transpose as c}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{create as l}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{create as m}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{scale as u,add as f,distance as p,copy as g,subtract as y,set as h,transformMat3 as d}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{create as w}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import x from"../../../geometry/Extent.js";import j from"../../../geometry/Geometry.js";import v from"../../../geometry/Multipoint.js";import b from"../../../geometry/Point.js";import{projectAsync as R,tryProject as z}from"../../../geometry/projectionUtils.js";import G from"../../../geometry/SpatialReference.js";import{computeTranslationToOriginAndRotation as S}from"../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{projectPointToVectorAsync as B}from"../../../geometry/projection/projectPointToVector.js";import{projectVectorToPoint as M}from"../../../geometry/projection/projectVectorToPoint.js";import{projectVectorToVector as Z}from"../../../geometry/projection/projectVectorToVector.js";import{create as F,center as P,toRect as T,isPoint as V,empty as A,expandWithVec3 as E,expandWithAABB as U,width as O,height as k,depth as N}from"../../../geometry/support/aaBoundingBox.js";import{create as I,isPoint as C}from"../../../geometry/support/aaBoundingRect.js";import{polygonCentroidPoint as W}from"../../../geometry/support/centroid.js";import{intersectsPoint as Y}from"../../../geometry/support/frustumPlanes.js";import{getResolutionInMetersForScale as q}from"../../../geometry/support/scaleUtils.js";import{fromRenderCamera as D,toRenderCameraWithScale as J}from"../webgl.js";import{cameraOnContentAlongViewDirection as X}from"../camera/intersectionUtils.js";import{scaleToDistance as _,distanceToScale as H}from"./cameraScaleUtils.js";import{getViewSR as K,fromExtentAsync as L,fromCenterDistanceAsync as Q,fromExtentSync as $,fromCenterDistanceSync as tt,zoomToScale as et,fromCenterScale as nt}from"./cameraUtils.js";import{getElevationAtPoint as rt}from"./ElevationProvider.js";import{directionToHeadingTilt as ot}from"./viewingModeUtils.js";const at=.66;function it(t){return 360-o.normalize(t)}function st(t){return o.normalize(360-t)}function ct(t,e,n){const r=e.camera;if(null!=r)return mt(r,K(t));const{targetGeometry:o}=e;if(null==o)return null;const{camera:a,mode:i}=ft(t,e.rotation,n);if("point"===o.type)return pt(t,e,o,a,i);const s=o.extent;return null==s?null:$(t,s,a.heading,a.tilt,i)}async function lt(t,e,n,r){const o=e.camera;if(null!=o)return ut(o,K(t),r);const{targetGeometry:a}=e;if(null==a)throw new Error("Viewpoint has no targetGeometry!");const{camera:i,mode:s}=ft(t,e.rotation,n);if("point"===a.type)return gt(t,e,a,i,s,r);const c=a.extent;if(null==c)throw new Error("Target geometry has no extent!");return L(t,c,i.heading,i.tilt,s,r)}function mt(t,e){const n=t.position,r=z(n,e);if(!r)return null;const o=t.clone();return o.position=r.clone(),o}async function ut(t,e,n){const r=t.position,o=await R(r,e,{signal:n});i(n);const a=t.clone();return a.position=o.clone(),a}function ft(t,e,n){const r=D(t,t.state.camera);let o=1;return null!=e&&(r.heading=it(e),o=0),null!=n&&(r.tilt=n),{camera:r,mode:o}}function pt(t,e,n,r,o){const a=t.spatialReference,i=z(n.clone(),a);if(!i)return null;const s=null!=e.scale?_(t,e.scale):t.state.camera.distance;return tt(t,i,s,r,o)}async function gt(t,e,n,r,o,a){const s=t.spatialReference,c=await R(n.clone(),s,{signal:a});i(a);const l=null!=e.scale?_(t,e.scale):t.state.camera.distance;return Q(t,c,l,r,o,a)}function yt(t,e,r=null){return null==r&&(r=new n),jt(t,null,e.clone(),r)}async function ht(e,r,o){const i=Vt(e,r);if(!i)throw new a("viewpointutils-create:no-target","Missing target for creating viewpoint");const s=new t({fov:e.camera.fov}),c=new n({camera:s});if(i.target instanceof n){return At(await zt(e,i.target,i,o,c))}if(i.target instanceof t)return At(await Gt(e,i.target,o,c,dt(e,i)));const l=null!=i.scale||null!=i.zoom;if(i.target instanceof x){const t=i.target.xmin===i.target.xmax||i.target.ymin===i.target.ymax;return At(l||t?await Bt(e,i,i.target.center,s,o,c):await Ft(e,i,i.target,s,o,c))}const m=new Ut,u=l?wt(e,i):void 0;if(await Rt(e,i.target,u,m,o),isFinite(m.boundingBox[0])){let t;if(P(m.boundingBox,Ot),Jt.x=Ot[0],Jt.y=Ot[1],Jt.z=Ot[2],Jt.spatialReference=e.spatialReference,isFinite(Jt.z)&&m.hasZ?t=V(m.boundingBox):(Jt.z=void 0,t=C(T(m.boundingBox,Ct))),l||t)return At(await Bt(e,i,Jt,s,o,c));const n=Et(e,m.screenSpaceObjects);return At(await Tt(e,i,Jt,m.boundingBox,n,s,o,c))}return i.position?At(await Mt(e,i,s,c,o)):At(await Zt(e,i,s,o,c))}function dt(t,e){return null==e.scale&&null!=e.zoom?et(t,e.zoom):e.scale}function wt(t,e){const n=dt(t,e);return n?q(n):void 0}function xt(t,e){let n=!1;return null!=e.heading?(t.heading=e.heading,n=!0):null!=e.rotation&&(t.heading=it(e.rotation),n=!0),null!=e.tilt&&(t.tilt=e.tilt,n=!0),null!=e.fov&&(t.fov=e.fov),n}function jt(t,e,n,r,o){const a=t.spatialReference||G.WGS84;if(e??=J(t,n,o),null==e)return r;const i=new b({spatialReference:a});return M(e.center,t.renderSpatialReference,i)?(r.targetGeometry=i,r.scale=o??H(t,e.distance),r.rotation=st(n.heading),r.camera=n,r):r}async function vt(t,e,n,r){const o=()=>new a("viewpointutils:invalid-geometry","The target is missing a valid geometry");if(!e)throw o();"mesh"===e.type&&(e=e.extent);const i=t.groundView.spatialReference;if(!e.hasZ&&t.basemapTerrain){let n;switch(e.type){case"point":n=e;break;case"multipoint":case"polyline":n=e.extent?.center;break;case"extent":n=e.center;break;case"polygon":{const t=W(e);n=t?b.fromJSON(t):null;break}}null!=n&&i&&t.elevationProvider?(n=await R(n,i,{signal:r}),Ot[2]=rt(t.elevationProvider,n)??0):Ot[2]=0}const s=Xt[e.type],c=new Array;if(s(e,e.hasZ?t=>{c.push([t[0],t[1],t[2]])}:t=>{c.push([t[0],t[1]])},Ot),0===c.length)throw o();const l=e.spatialReference,m=t.spatialReference,u=await R(new v({spatialReference:l,hasZ:e.hasZ,hasM:!1,points:c}),m,{signal:r});if(e.hasZ&&(n.hasZ=!0),e.hasZ)for(const[a,f,p]of u.points)Ot[0]=a,Ot[1]=f,Ot[2]=p,E(n.boundingBox,Ot);else for(const[a,f]of u.points)Ot[0]=a,Ot[1]=f,E(n.boundingBox,Ot)}async function bt(t,e,n,o,a){const i=await r(t.whenViewForGraphic(e));if(!1===i.ok||null==i.value||!("whenGraphicBounds"in i.value))return void await vt(t,e.geometry,o,a);const s=i.value,c=await r(s.whenGraphicBounds(e,{minDemResolution:n}));if(!1===c.ok||!c.value)return void await vt(t,e.geometry,o,a);const{screenSpaceObjects:l,boundingBox:m}=c.value;U(o.boundingBox,m),l&&l.forEach(t=>{o.screenSpaceObjects.push(t)}),isFinite(m[2])&&(o.hasZ=!0)}async function Rt(t,n,r,o,a){if(Array.isArray(n)&&2===n.length){const e=n[0],r=n[1];if("number"==typeof e&&"number"==typeof r)return Jt.x=e,Jt.y=r,Jt.z=void 0,Jt.spatialReference=t.spatialReference?.isGeographic?t.spatialReference:G.WGS84,void await vt(t,Jt,o,a)}n&&"map"in n&&"function"==typeof n.map?await Promise.allSettled(n.map(e=>Rt(t,e,r,o,a))):n instanceof j?await vt(t,n,o,a):n instanceof e&&await bt(t,n,r,o,a)}async function zt(t,e,n,r,o){if(e.camera)return Gt(t,e.camera,r,o,dt(t,n)??e.scale);o.scale=e.scale,o.rotation=e.rotation,o.targetGeometry=null!=e.targetGeometry?e.targetGeometry.clone():null,o.camera=null,null!=n.heading?o.rotation=st(n.heading):null!=n.rotation&&(o.rotation=n.rotation);const a=dt(t,n);return null!=a&&(o.scale=a),o.camera=await lt(t,o,n.tilt,r),o}async function Gt(t,e,n,r,o){const a=t.spatialReference,i=await R(e.position,a,{signal:n}),s=e.clone();return s.position=i,jt(t,null,s,r,o)}async function St(t,e,n,r,o,a,i){const s=t.renderSpatialReference;return await B(e,qt,s,{signal:i}),await B(n,Yt,s,{signal:i}),a.targetGeometry=new b(e),o.position=new b(n),y(Wt,qt,Yt),ot(t,Yt,Wt,r.up,o),a.scale=H(t,p(Yt,qt)),a.rotation=st(o.heading),a.camera=o,a}async function Bt(t,e,n,r,o,a){a.targetGeometry=n.clone();const i=X(t);if(e.position)return St(t,a.targetGeometry,e.position,i,r,a,o);if(e.zoomFactor){const n=i.distance/e.zoomFactor,r=u(Ot,i.viewForward,-n);i.eye=f(Ot,i.center,r),a.scale=H(t,n)}D(t,i,r);const s=xt(r,e)?0:1;if(!e.zoomFactor){const n=dt(t,e);if(null==n){await B(a.targetGeometry,Ot,t.renderSpatialReference,{signal:o});const e=Y(i.frustum,Ot)?p(i.eye,Ot):i.distance;a.camera=await Q(t,a.targetGeometry,e,r,s),a.scale=H(t,e)}else a.scale=n,a.camera=await nt(t,a.targetGeometry,a.scale,r,s,o)}return a}async function Mt(t,e,n,r,o){const a=X(t);g(Wt,a.viewForward),ot(t,a.eye,Wt,a.up,Dt);const i=t.spatialReference,{position:s}=e;if(s){const t=await R(s,i,{signal:o});n.position=t}else n.position=new b;return n.heading=null!=e.heading?e.heading:Dt.heading,n.tilt=null!=e.tilt?e.tilt:Dt.tilt,jt(t,null,n,r,dt(t,e))}async function Zt(t,e,n,r,o){if(null!=e.heading||null!=e.rotation||null!=e.scale||null!=e.tilt||null!=e.zoom||null!=e.zoomFactor){const a=X(t),{spatialReference:i,renderSpatialReference:s}=t,c=new b({spatialReference:i});return M(a.center,s,c)?Bt(t,e,c,n,r,o):o}return o.scale=t.scale,o.camera=t.camera.clone(),xt(o.camera,e),o}async function Ft(t,e,n,r,o,a){a.targetGeometry=n.clone();const i=X(t);D(t,i,r);const s=xt(r,e)?0:1;return a.camera=await L(t,n,r.heading,r.tilt,s,o),a}function Pt(t,e,n,r,o){let a=0;null!=n.z?a=n.z:t.basemapTerrain&&t.elevationProvider&&(a=rt(t.elevationProvider,n)),h(Ot,n.x,n.y,a),S(t.spatialReference,Ot,kt,t.renderSpatialReference),s(Nt,kt),c(Nt,Nt),A(It);const i=[[0,1,2],[3,1,2],[0,4,2],[3,4,2],[0,1,5],[3,1,5],[0,4,5],[3,4,5]];for(let s=0;s<i.length;s++){const e=i[s];let n=r[e[2]];isFinite(n)||(n=a),h(Ot,r[e[0]],r[e[1]],n),Z(Ot,t.spatialReference,Ot,t.renderSpatialReference),E(It,d(Ot,Ot,Nt))}const l=O(It),m=k(It),u=N(It),f=1/Math.tan(e.fovX/2),p=1/Math.tan(e.fovY/2),g=.5*Math.sqrt(l*l+u*u)*Math.max(p,f)+.5*m,y=.5*m*p+.5*Math.max(l,u);return Math.max(g,y)/o}async function Tt(t,e,n,r,o,a,i,s){s.targetGeometry=n.clone();const c=X(t),l=Pt(t,c,n,r,o);D(t,c,a);const m=xt(a,e)?0:1;return s.camera=await Q(t,s.targetGeometry,l,a,m,i),s.scale=H(t,l),s}function Vt(t,e){if(!e||!t.spatialReference)return null;const n={target:void 0};return"declaredClass"in e||Array.isArray(e)?n.target=e:(Object.assign(n,e),!n.target&&"center"in e&&e.center&&(n.target=e.center)),n}function At(t){return null!=t?.camera&&(t.rotation=st(t.camera.heading)),t}function Et(t,e){const n=at;if(!e.length)return n;let r=Number.NEGATIVE_INFINITY;for(let o=0;o<e.length;o++){const t=e[o].screenSpaceBoundingRect;r=Math.max(r,Math.abs(t[0]),Math.abs(t[1]),Math.abs(t[2]),Math.abs(t[3]))}return n-r/Math.min(t.width,t.height)*2}class Ut{constructor(){this.hasZ=!1,this.boundingBox=A(),this.screenSpaceObjects=new Array}}const Ot=w(),kt=m(),Nt=l(),It=F(),Ct=I(),Wt=w(),Yt=w(),qt=w(),Dt={heading:0,tilt:0},Jt=new b,Xt={point(t,e,n){n[0]=t.x,n[1]=t.y,null!=t.z&&(n[2]=t.z),e(n)},polygon(t,e,n){const r=t.hasZ;for(let o=0;o<t.rings.length;o++){const a=t.rings[o];for(let t=0;t<a.length;t++)n[0]=a[t][0],n[1]=a[t][1],r&&(n[2]=a[t][2]),e(n)}},polyline(t,e,n){const r=t.hasZ;for(let o=0;o<t.paths.length;o++){const a=t.paths[o];for(let t=0;t<a.length;t++)n[0]=a[t][0],n[1]=a[t][1],r&&(n[2]=a[t][2]),e(n)}},multipoint(t,e,n){const r=t.points,o=t.hasZ;for(let a=0;a<r.length;a++)n[0]=r[a][0],n[1]=r[a][1],o&&(n[2]=r[a][2]),e(n)},extent(t,e,n){null!=t.zmin&&null!=t.zmax?(e(h(n,t.xmin,t.ymin,t.zmin)),e(h(n,t.xmax,t.ymin,t.zmin)),e(h(n,t.xmin,t.ymax,t.zmin)),e(h(n,t.xmax,t.ymax,t.zmin)),e(h(n,t.xmin,t.ymin,t.zmax)),e(h(n,t.xmax,t.ymin,t.zmax)),e(h(n,t.xmin,t.ymax,t.zmax)),e(h(n,t.xmax,t.ymax,t.zmax))):(e(h(n,t.xmin,t.ymin,n[2])),e(h(n,t.xmax,t.ymin,n[2])),e(h(n,t.xmin,t.ymax,n[2])),e(h(n,t.xmax,t.ymax,n[2])))}};export{ht as create,yt as fromCamera,lt as toCameraAsync,ct as toCameraSync};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{equals as e}from"../../../core/arrayUtils.js";import"../../../core/has.js";import{isPowerOfTwo as t}from"../../../core/mathUtils.js";import{disposeMaybe as r,releaseMaybe as i}from"../../../core/maybe.js";import{glLayout as s}from"../support/buffer/glUtil.js";import{GeometryState as a}from"./GeometryState.js";import{PatchGeometry as o}from"./PatchGeometry.js";import{checkPatchGeometryWaterproofness as n}from"./PatchRenderDataWaterproofness.js";import{maxTileNeighborLevelDelta as l}from"./TerrainConst.js";import{internalAssert as h,neighborEdgeIndices as u,oppositeEdge as d,neighborCornerIndices as m,enableTerrainInternalChecks as g}from"./terrainUtils.js";import{TextureFader as c}from"./TextureFader.js";import{TextureReference as f}from"./TextureReference.js";import y from"./TileOverlayData.js";import{fallsWithinLayerView as p}from"./tileUtils.js";import{VertexArrayObject as _}from"../webgl-engine/lib/VertexArrayObject.js";import{BufferObject as x}from"../../webgl/BufferObject.js";import{VertexBuffer as D}from"../../webgl/VertexBuffer.js";class S{constructor(){this.geometry=new o,this.geometryState=null,this._texture=null,this._textureOpacity=1,this._textureFader=new c(()=>this._tile.surface.fadeDuration),this.overlay=new y,this._localOrigin=null,this._geometryStateChangedSinceLastUpdate=!0,this._hasGeometry=!1,this._modifiedFlags=0}get tile(){return this._tile}get localOrigin(){return this._localOrigin}init(e,t){this.clear(),this._tile=e,this.geometry.reset(),this.intersectionData=null,this.geometryState=new a,this._localOrigin=t,this.overlay.clear()}clear(){this.releaseGeometry(),this.releaseTexture(),this._textureFader.clear(),this._tile=null,this.intersectionData=null,this.geometryState=null}updateGeometryIfNeeded(e){if(!this._tile||!this.geometryState)return;if((!this._vao||this._geometryStateChangedSinceLastUpdate||this.wireframeChanged||this.clippingAreaChanged||this.samplerDataChanged||this.numVerticesPerSideChanged||this.dirtyCorners||this.dirtyEdgeResolutions||this.dirtyEdges)&&(this._updateGeometry(e),this._geometryStateChangedSinceLastUpdate=!1),g&&this.tile.intersectsClippingArea)for(let t=0;t<G;++t)h(this.geometry.getEdgeCount(t)===this.geometryState.edgeResolutions[t]+1)}_calculateEdgeResolution(e,t){const r=this.tile,i=this.geometryState.numVerticesPerSide-1;if(!r.surface.isGlobal){const t=r.surface.groundExtent;if(null!=t&&(0===e&&r.extent[3]>t[3]||1===e&&r.extent[2]>t[2]||2===e&&r.extent[1]<t[1]||3===e&&r.extent[0]<t[0]))return i}const s=r.level,a=u[e];if(!t)return h(null==r.surface?.rootTiles||r.surface.updatingRootTiles||!r.shouldHaveNeighbor(a)),i;if(t.loaded){const r=t,a=r.renderData?.geometryState;if(!a)return i;const o=s-r.level;if(h(o>=0),0===o){const e=a.numVerticesPerSide-1;return Math.max(e,i)}const n=2**o,l=a.edgeResolutions[(e+2)%4]/n;return Math.max(1,l)}h(!t.leaf);let o=i;return t.forAllSubtreeOnSide(d(a),e=>e===r||(e.loaded?(o=Math.max(o,2**(e.level-s)),!0):(h(!e.leaf),!1))),o}updateNeighborData(){const e=this.tile;if(!e.intersectsClippingArea)return;const r=e.renderData.geometryState,i=t=>(t.loaded||t.level===e.level)&&t.intersectsClippingArea,s=r.edgePeerNeighbors,a=r.edgePeerNeighborSamplerVersions;for(let o=0;o<G;++o){const n=e.findNeighborTile(u[o],i),d=C(e,n),m=d?.renderData?.geometryState.samplerDataVersion??-1,c=s[o],f=d!==C(e,c),y=a[o]!==m;g&&n&&(h(e.level>=n.level),h(e.level-n.level<=l)),s[o]=n,(f||y)&&(a[o]=m,this._markEdgeDirty(o));const p=r.edgeResolutions[o],_=this._calculateEdgeResolution(o,n);h(t(_)),h(_>=1),r.edgeResolutions[o]=_,p!==_&&this._markEdgeResolutionDirty(o)}for(let t=0;t<G;++t){const a=e.findNeighborTile(m[t],i);r.cornerPeerNeighbors[t]=a;const o=C(e,s[t]),n=C(e,s[(t+1)%G]),l=C(e,a);v[t]=l,v[(t+1)%G]=n,v[(t+2)%G]=e,v[(t+3)%G]=o,h(v.some(t=>t?.loaded||t===e));const u=v.reduce((e,t)=>Math.min(e,t?.level??1/0),1/0);v.forEach((e,t)=>{e&&e.level>u&&(v[t]=null)}),h(v.some(t=>t?.loaded||t===e));const d=r.cornerNeighborCornerTiles,c=r.cornerNeighborCornerTileSamplerVersions;for(let e=0;e<G;++e){const r=v[e],i=r?.renderData?.geometryState?.samplerDataVersion??-1,s=t*G+e,a=d[s]!==r,o=!a&&c[s]!==i;(a||o)&&(d[s]=r,c[s]=i,this._markCornerDirty(t))}g&&h(V.some(r=>{const i=d[t*G+r];return i?.loaded||i===e}))}g&&h(r.edgeResolutions.every(e=>e>0));for(let t=0;t<G;++t)v[t]=null}_updateGeometry(e){if(!this.tile.intersectsClippingArea)return;g&&h(!this.tile.intersectsClippingArea||this.geometryState.edgeResolutions.every(e=>e>0)),this.intersectionData=null;const{tile:t,_vao:r,geometry:i,geometryState:s}=this,{vertexAttributes:a}=i,o=!r||!a||this.wireframeChanged||this.samplerDataChanged||this.clippingAreaChanged,n=0!==this.dirtyEdgeResolutions,l=s.edgeResolutions.reduce((e,t)=>Math.max(e,t),0)+1,u=n&&l>i.maxEdgeVertexCount,d=o||this.numVerticesPerSideChanged||u,m=!d&&n,c=!m&&0!==this.dirtyEdges,f=!c&&0!==this.dirtyCorners;d?(this.releaseGeometry(),this._createGeometry(e)):m?t.updateEdgeElevationsAndResolutions():c||f?t.updateEdgeElevations():console.warn("Update for no reason?"),this._modifiedFlags=0}get hasGeometry(){return this._hasGeometry}releaseGeometry(){return this._hasGeometry=!1,this.intersectionData=null,!!this._vao&&(this._vao=r(this._vao),this.geometry.release(),!0)}ensureTexture(e,t,r,i){const s=t?6408:6407;return null!=this._texture&&(0===r&&this._tile.surface.fadeDuration>0&&this._isTextureVisible(this._texture)||this._texture.descriptor.width!==e||this._texture.descriptor.pixelFormat!==s)&&this.releaseTexture(),null==this._texture&&(this._texture=i(),this.tile.setMemoryDirty()),this._texture}releaseTexture(){this._texture&&(this._texture=i(this._texture),this.tile.setMemoryDirty())}reuseTexture(e,t){return!(!e||!this._texture)&&(e.setTextureReference(new f(this._texture,0,t,this._textureOpacity,0,1)),!0)}get numVerticesPerSideChanged(){return 0!==(this._modifiedFlags&F)}get samplerDataChanged(){return 0!==(this._modifiedFlags&b)}get clippingAreaChanged(){return 0!==(this._modifiedFlags&A)}get wireframeChanged(){return 0!==(this._modifiedFlags&T)}get dirtyEdges(){return this._modifiedFlags>>E&15}get dirtyCorners(){return this._modifiedFlags>>R&15}get dirtyEdgeResolutions(){return this._modifiedFlags>>w&15}_markCornerDirty(e){const t=1<<e<<R;this._modifiedFlags|=t}_markEdgeDirty(e){const t=1<<e<<E;this._modifiedFlags|=t,this._markCornerDirty((e+0)%4),this._markCornerDirty((e+3)%4)}_markEdgeResolutionDirty(e){const t=1<<e<<w;this._modifiedFlags|=t,this._markEdgeDirty(e)}_markAllEdgesAndCornersDirty(){this._modifiedFlags|=15<<R|15<<E|15<<w}updateGeometryState(){const t=this._elevationInfo,r=this.tile,i=t.samplerData?r.getElevationVerticesPerSide(t.maxTileLevel):r.minimumVerticesPerSide,s=Math.max(i,5);let a=r.clippingArea;r.intersectsClippingArea&&!r.withinClippingArea||(a=null);const o=this.geometryState;let n=!1;o.numVerticesPerSide!==s&&(this._modifiedFlags|=F,o.numVerticesPerSide=s,o.samplerDataVersion++,n=!0),t.changed&&(this._modifiedFlags|=b,o.samplerData=t.samplerData,o.samplerDataSourceLevels=t.samplerDataSourceLevels,o.samplerDataVersion++,n=!0),e(o.clippingArea,a)||(this._modifiedFlags|=A,o.clippingArea=a,n=!0);const l=r.surface.wireframe;return o.wireframe!==l&&(this._modifiedFlags|=T,o.wireframe=l,n=!0),this._geometryStateChangedSinceLastUpdate||=n,n&&this._markAllEdgesAndCornersDirty(),this._hasGeometry=!0,this._geometryStateChangedSinceLastUpdate}_createGeometry(e){this.tile.createGeometry();const{vertexAttributes:t,indices:r}=this.geometry,i=e.gl;this._vao=new _(e,new D(e,s(t.layout),t.buffer),x.createIndex(e,i.STATIC_DRAW,r)),this._hasGeometry=!0}get vao(){return this._vao}setTextureReference(e,t=0){e?.texture===this._texture?this._textureOpacity=e.opacities[0]:this.releaseTexture(),this._textureFader.push(e,t)}get textureReference(){return this._textureFader.current}get nextTextureReference(){return this._textureFader.next}get textureFadeFactor(){return this._textureFader.fadeFactor}get textureIsFading(){return this._textureFader.isFading}_isTextureVisible(e){return this._textureFader.current?.texture===e||this._textureFader.next?.texture===e&&this._textureFader.fadeFactor<1}get _elevationInfo(){const t=this.geometryState.samplerData,r=this.geometryState.samplerDataSourceLevels,i=this.tile.layerInfo[0],s=i.length,a=new Array(s),o=new Array(s);let n=0,l=0,h=!1;for(let e=0;e<s;e++){const r=i[e],s=r.upsampleInfo?.tile;if(s){const r=s.layerInfo[0][e].data,i=r&&r.samplerData;t&&t[n]===i||(h=!0),a[n++]=i,o[n-1]=r?.level??s.level,l=Math.max(l,s.lij[0])}else if(r.data){const i=this.tile.surface.layerViewByIndex(e,0);if(p(this.tile,i)){const e=r.data;t&&t[n]===e.samplerData||(h=!0),a[n++]=e.samplerData,o[n-1]=e.level,l=this.tile.level}}}null!=t&&t.length!==n&&(h=!0);const u=n>0,d=u?a:null,m=u?o:null;return u&&(a.length=n,o.length=n),e(r,m)||(h=!0),{changed:h,samplerData:d,samplerDataSourceLevels:m,maxTileLevel:l}}get estimatedGeometryMemoryUsage(){const e=this.intersectionData?.estimatedMemoryUsage??0;return(this.geometry.indices?.byteLength??0)+(this.geometry.vertexAttributes?.byteLength??0)+e}get texture(){return this._texture}get test(){}checkGeometryWaterproofness(){n(this)}}const v=[null,null,null,null];function C(e,t){return t?.loaded||t===e?t:null}const F=1,b=2,A=4,T=8,E=4,R=8,w=12,G=4,V=[0,1,2,3];export{S as PatchRenderData,C as neighborTileIfLoadedOrSelf,V as zeroToFour};
2
+ import{equals as e}from"../../../core/arrayUtils.js";import"../../../core/has.js";import{isPowerOfTwo as t}from"../../../core/mathUtils.js";import{disposeMaybe as r,releaseMaybe as i}from"../../../core/maybe.js";import{glLayout as s}from"../support/buffer/glUtil.js";import{GeometryState as a}from"./GeometryState.js";import{PatchGeometry as o}from"./PatchGeometry.js";import"../../../geometry/Extent.js";import"../../../geometry/support/Ellipsoid.js";import{internalAssert as n,neighborEdgeIndices as l,oppositeEdge as h,neighborCornerIndices as u,enableTerrainInternalChecks as d}from"./terrainUtils.js";import{maxTileNeighborLevelDelta as m}from"./TerrainConst.js";import{TextureFader as g}from"./TextureFader.js";import{TextureReference as c}from"./TextureReference.js";import f from"./TileOverlayData.js";import{fallsWithinLayerView as p}from"./tileUtils.js";import{VertexArrayObject as y}from"../webgl-engine/lib/VertexArrayObject.js";import{BufferObject as _}from"../../webgl/BufferObject.js";import{VertexBuffer as x}from"../../webgl/VertexBuffer.js";class D{constructor(){this.geometry=new o,this.geometryState=null,this._texture=null,this._textureOpacity=1,this._textureFader=new g(()=>this._tile.surface.fadeDuration),this.overlay=new f,this._localOrigin=null,this._geometryStateChangedSinceLastUpdate=!0,this._hasGeometry=!1,this._modifiedFlags=0}get tile(){return this._tile}get localOrigin(){return this._localOrigin}init(e,t){this.clear(),this._tile=e,this.geometry.reset(),this.intersectionData=null,this.geometryState=new a,this._localOrigin=t,this.overlay.clear()}clear(){this.releaseGeometry(),this.releaseTexture(),this._textureFader.clear(),this._tile=null,this.intersectionData=null,this.geometryState=null}updateGeometryIfNeeded(e){if(!this._tile||!this.geometryState)return;if((!this._vao||this._geometryStateChangedSinceLastUpdate||this.wireframeChanged||this.clippingAreaChanged||this.samplerDataChanged||this.numVerticesPerSideChanged||this.dirtyCorners||this.dirtyEdgeResolutions||this.dirtyEdges)&&(this._updateGeometry(e),this._geometryStateChangedSinceLastUpdate=!1),d&&this.tile.intersectsClippingArea)for(let t=0;t<R;++t)n(this.geometry.getEdgeCount(t)===this.geometryState.edgeResolutions[t]+1)}_calculateEdgeResolution(e,t){const r=this.tile,i=this.geometryState.numVerticesPerSide-1;if(!r.surface.isGlobal){const t=r.surface.groundExtent;if(null!=t&&(0===e&&r.extent[3]>t[3]||1===e&&r.extent[2]>t[2]||2===e&&r.extent[1]<t[1]||3===e&&r.extent[0]<t[0]))return i}const s=r.level,a=l[e];if(!t)return n(null==r.surface?.rootTiles||r.surface.updatingRootTiles||!r.shouldHaveNeighbor(a)),i;if(t.loaded){const r=t,a=r.renderData?.geometryState;if(!a)return i;const o=s-r.level;if(n(o>=0),0===o){const e=a.numVerticesPerSide-1;return Math.max(e,i)}const l=2**o,h=a.edgeResolutions[(e+2)%4]/l;return Math.max(1,h)}n(!t.leaf);let o=i;return t.forAllSubtreeOnSide(h(a),e=>e===r||(e.loaded?(o=Math.max(o,2**(e.level-s)),!0):(n(!e.leaf),!1))),o}updateNeighborData(){const e=this.tile;if(!e.intersectsClippingArea)return;const r=e.renderData.geometryState,i=t=>(t.loaded||t.level===e.level)&&t.intersectsClippingArea,s=r.edgePeerNeighbors,a=r.edgePeerNeighborSamplerVersions;for(let o=0;o<R;++o){const h=e.findNeighborTile(l[o],i),u=v(e,h),g=u?.renderData?.geometryState.samplerDataVersion??-1,c=s[o],f=u!==v(e,c),p=a[o]!==g;d&&h&&(n(e.level>=h.level),n(e.level-h.level<=m)),s[o]=h,(f||p)&&(a[o]=g,this._markEdgeDirty(o));const y=r.edgeResolutions[o],_=this._calculateEdgeResolution(o,h);n(t(_)),n(_>=1),r.edgeResolutions[o]=_,y!==_&&this._markEdgeResolutionDirty(o)}for(let t=0;t<R;++t){const a=e.findNeighborTile(u[t],i);r.cornerPeerNeighbors[t]=a;const o=v(e,s[t]),l=v(e,s[(t+1)%R]),h=v(e,a);S[t]=h,S[(t+1)%R]=l,S[(t+2)%R]=e,S[(t+3)%R]=o,n(S.some(t=>t?.loaded||t===e));const m=S.reduce((e,t)=>Math.min(e,t?.level??1/0),1/0);S.forEach((e,t)=>{e&&e.level>m&&(S[t]=null)}),n(S.some(t=>t?.loaded||t===e));const g=r.cornerNeighborCornerTiles,c=r.cornerNeighborCornerTileSamplerVersions;for(let e=0;e<R;++e){const r=S[e],i=r?.renderData?.geometryState?.samplerDataVersion??-1,s=t*R+e,a=g[s]!==r,o=!a&&c[s]!==i;(a||o)&&(g[s]=r,c[s]=i,this._markCornerDirty(t))}d&&n(j.some(r=>{const i=g[t*R+r];return i?.loaded||i===e}))}d&&n(r.edgeResolutions.every(e=>e>0));for(let t=0;t<R;++t)S[t]=null}_updateGeometry(e){if(!this.tile.intersectsClippingArea)return;d&&n(!this.tile.intersectsClippingArea||this.geometryState.edgeResolutions.every(e=>e>0)),this.intersectionData=null;const{tile:t,_vao:r,geometry:i,geometryState:s}=this,{vertexAttributes:a}=i,o=!r||!a||this.wireframeChanged||this.samplerDataChanged||this.clippingAreaChanged,l=0!==this.dirtyEdgeResolutions,h=s.edgeResolutions.reduce((e,t)=>Math.max(e,t),0)+1,u=l&&h>i.maxEdgeVertexCount,m=o||this.numVerticesPerSideChanged||u,g=!m&&l,c=!g&&0!==this.dirtyEdges,f=!c&&0!==this.dirtyCorners;m?(this.releaseGeometry(),this._createGeometry(e)):g?t.updateEdgeElevationsAndResolutions():c||f?t.updateEdgeElevations():console.warn("Update for no reason?"),this._modifiedFlags=0}get hasGeometry(){return this._hasGeometry}releaseGeometry(){return this._hasGeometry=!1,this.intersectionData=null,!!this._vao&&(this._vao=r(this._vao),this.geometry.release(),!0)}ensureTexture(e,t,r,i){const s=t?6408:6407;return null!=this._texture&&(0===r&&this._tile.surface.fadeDuration>0&&this._isTextureVisible(this._texture)||this._texture.descriptor.width!==e||this._texture.descriptor.pixelFormat!==s)&&this.releaseTexture(),null==this._texture&&(this._texture=i(),this.tile.setMemoryDirty()),this._texture}releaseTexture(){this._texture&&(this._texture=i(this._texture),this.tile.setMemoryDirty())}reuseTexture(e,t){return!(!e||!this._texture)&&(e.setTextureReference(new c(this._texture,0,t,this._textureOpacity,0,1)),!0)}get numVerticesPerSideChanged(){return 0!==(this._modifiedFlags&C)}get samplerDataChanged(){return 0!==(this._modifiedFlags&F)}get clippingAreaChanged(){return 0!==(this._modifiedFlags&b)}get wireframeChanged(){return 0!==(this._modifiedFlags&A)}get dirtyEdges(){return this._modifiedFlags>>E&15}get dirtyCorners(){return this._modifiedFlags>>T&15}get dirtyEdgeResolutions(){return this._modifiedFlags>>w&15}_markCornerDirty(e){const t=1<<e<<T;this._modifiedFlags|=t}_markEdgeDirty(e){const t=1<<e<<E;this._modifiedFlags|=t,this._markCornerDirty((e+0)%4),this._markCornerDirty((e+3)%4)}_markEdgeResolutionDirty(e){const t=1<<e<<w;this._modifiedFlags|=t,this._markEdgeDirty(e)}_markAllEdgesAndCornersDirty(){this._modifiedFlags|=15<<T|15<<E|15<<w}updateGeometryState(){const t=this._elevationInfo,r=this.tile,i=t.samplerData?r.getElevationVerticesPerSide(t.maxTileLevel):r.minimumVerticesPerSide,s=Math.max(i,5);let a=r.clippingArea;r.intersectsClippingArea&&!r.withinClippingArea||(a=null);const o=this.geometryState;let n=!1;o.numVerticesPerSide!==s&&(this._modifiedFlags|=C,o.numVerticesPerSide=s,o.samplerDataVersion++,n=!0),t.changed&&(this._modifiedFlags|=F,o.samplerData=t.samplerData,o.samplerDataSourceLevels=t.samplerDataSourceLevels,o.samplerDataVersion++,n=!0),e(o.clippingArea,a)||(this._modifiedFlags|=b,o.clippingArea=a,n=!0);const l=r.surface.wireframe;return o.wireframe!==l&&(this._modifiedFlags|=A,o.wireframe=l,n=!0),this._geometryStateChangedSinceLastUpdate||=n,n&&this._markAllEdgesAndCornersDirty(),this._hasGeometry=!0,this._geometryStateChangedSinceLastUpdate}_createGeometry(e){this.tile.createGeometry();const{vertexAttributes:t,indices:r}=this.geometry,i=e.gl;this._vao=new y(e,new x(e,s(t.layout),t.buffer),_.createIndex(e,i.STATIC_DRAW,r)),this._hasGeometry=!0}get vao(){return this._vao}setTextureReference(e,t=0){e?.texture===this._texture?this._textureOpacity=e.opacities[0]:this.releaseTexture(),this._textureFader.push(e,t)}get textureReference(){return this._textureFader.current}get nextTextureReference(){return this._textureFader.next}get textureFadeFactor(){return this._textureFader.fadeFactor}get textureIsFading(){return this._textureFader.isFading}_isTextureVisible(e){return this._textureFader.current?.texture===e||this._textureFader.next?.texture===e&&this._textureFader.fadeFactor<1}get _elevationInfo(){const t=this.geometryState.samplerData,r=this.geometryState.samplerDataSourceLevels,i=this.tile.layerInfo[0],s=i.length,a=new Array(s),o=new Array(s);let n=0,l=0,h=!1;for(let e=0;e<s;e++){const r=i[e],s=r.upsampleInfo?.tile;if(s){const r=s.layerInfo[0][e].data,i=r&&r.samplerData;t&&t[n]===i||(h=!0),a[n++]=i,o[n-1]=r?.level??s.level,l=Math.max(l,s.lij[0])}else if(r.data){const i=this.tile.surface.layerViewByIndex(e,0);if(p(this.tile,i)){const e=r.data;t&&t[n]===e.samplerData||(h=!0),a[n++]=e.samplerData,o[n-1]=e.level,l=this.tile.level}}}null!=t&&t.length!==n&&(h=!0);const u=n>0,d=u?a:null,m=u?o:null;return u&&(a.length=n,o.length=n),e(r,m)||(h=!0),{changed:h,samplerData:d,samplerDataSourceLevels:m,maxTileLevel:l}}get estimatedGeometryMemoryUsage(){const e=this.intersectionData?.estimatedMemoryUsage??0;return(this.geometry.indices?.byteLength??0)+(this.geometry.vertexAttributes?.byteLength??0)+e}get texture(){return this._texture}get test(){}checkGeometryWaterproofness(){}}const S=[null,null,null,null];function v(e,t){return t?.loaded||t===e?t:null}const C=1,F=2,b=4,A=8,E=4,T=8,w=12,R=4,j=[0,1,2,3];export{D as PatchRenderData,v as neighborTileIfLoadedOrSelf,j as zeroToFour};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{distance as e,dist as r,len as o,subtract as t,normalize as i,dot as l,sub as n,equals as a}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{create as g,clone as s}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{containsXY as d}from"../../../geometry/support/aaBoundingRect.js";import{earth as $}from"../../../geometry/support/Ellipsoid.js";import{enableTerrainInternalChecks as c,internalAssert as p,neighborEdgeIndices as m,neighborCornerIndices as u,v32s as f,lij2s as h}from"./terrainUtils.js";function j(j){if(!c)return;const S=j.tile;if(!S.loaded||!S.intersectsClippingArea||0===S.level)return void p(S.loaded,`waterproof.tile-not-loaded: Tile[${S.lij}] has indexed geometry but is not loaded`);const V=S.surface.groundExtent;if(null!=V&&!S.intersectsExtent(V))return;const N=m.map((e,r)=>null!=V&&(r<2?-1:1)*(S.extent[3-r]-V[3-r])<0),P=S.level;p(0===j.dirtyCorners,`waterproof.dirty-corners: Tile[${S.lij}] dirtyCorners=${j.dirtyCorners}`),p(0===j.dirtyEdges,`waterproof.dirty-edges: Tile[${S.lij}] dirtyEdges=${j.dirtyEdges}`),p(0===j.dirtyEdgeResolutions,`waterproof.dirty-edge-resolutions: Tile[${S.lij}] dirtyEdgeResolutions=${j.dirtyEdgeResolutions}`),p(!j.numVerticesPerSideChanged,`waterproof.vertices-per-side-changed: Tile[${S.lij}] numVerticesPerSideChanged=true`),p(!j.samplerDataChanged,`waterproof.sampler-data-changed: Tile[${S.lij}] samplerDataChanged=true`),p(!j.clippingAreaChanged,`waterproof.clipping-area-changed: Tile[${S.lij}] clippingAreaChanged=true`),p(!j.wireframeChanged,`waterproof.wireframe-changed: Tile[${S.lij}] wireframeChanged=true`);const D=u.map(e=>S.findNeighborCornerTileExact(e,e=>!e.intersectsClippingArea||e.loaded||e.level===S.level)??null).map(e=>e?.intersectsClippingArea?e:null),O=j.geometryState;for(let e=0;e<4;++e){const r=O.cornerPeerNeighbors[e],o=D[e];p(o===r,`waterproof.corner-peer-mismatch: Tile[${S.lij}].corner[${e}] current=[${r?.lij}] expected=[${o?.lij}]`)}m.forEach((c,m)=>{if(N[m])return;const u=S.findNeighborTile(c,e=>(e.level===P||e.loaded)&&e.intersectsClippingArea);if(!u){const e=!S.surface.updatingRootTiles&&null!=S.surface.rootTiles&&S.surface.rootTiles.length>0&&S.shouldHaveNeighbor(c);return void p(!e,`waterproof.required-neighbor-missing: Tile[${S.lij}].edge[${m}]`)}p(u.loaded||u.level===S.level,`waterproof.invalid-neighbor-state: Tile[${S.lij}].edge[${m}] neighbor[${u.lij}] loaded=${u.loaded}`);const C=j.geometryState.edgePeerNeighbors[m];p(u===C,`waterproof.peer-neighbor-mismatch: Tile[${S.lij}].edge[${m}] current=[${C?.lij}] expected=[${u.lij}] dirtyEdges=${j.dirtyEdges} dirtyEdgeResolutions=${j.dirtyEdgeResolutions}`);const V=P-u.level;if(!u.loaded)return p(!u.leaf,`waterproof.unloaded-neighbor-is-leaf: Tile[${S.lij}].edge[${m}] neighbor[${u.lij}]`),void p(0===V,`waterproof.unloaded-neighbor-level-mismatch: Tile[${S.lij}].edge[${m}] neighbor[${u.lij}] levelDelta=${V}`);const D=u.renderData;p(S.isEdgeNeighbor(u,c),`waterproof.invalid-edge-neighbor: Tile[${S.lij}].edge[${m}] neighbor[${u.lij}]`),p(V>=0,`waterproof.higher-level-peer-neighbor: Tile[${S.lij}].edge[${m}] neighbor[${u.lij}] levelDelta=${V}`);const O=2**V;if(V<0)return void p(!1,`waterproof.negative-level-delta: Tile[${S.lij}].edge[${m}] neighbor[${u.lij}] levelDelta=${V}`);const R=S.renderData,A=R.geometry,M=R.localOrigin,X=A.getEdgeCount(m),q=A.numVerticesPerSide-1,B=D.geometry;if(!B)return void p(!1,`waterproof.loaded-neighbor-without-geometry: Tile[${S.lij}].edge[${m}] neighbor[${u.lij}]`);const H=D.localOrigin,I=j.geometryState.edgePeerNeighbors[m];if(I?.loaded){const e=I.renderData;p(R.geometryState.edgePeerNeighborSamplerVersions[m]===e.geometryState.samplerDataVersion,`waterproof.tile-peer-sampler-version-mismatch: Tile[${S.lij}].edge[${m}] stored=${R.geometryState.edgePeerNeighborSamplerVersions[m]} neighbor[${I.lij}]=${e.geometryState.samplerDataVersion}`),p(j.geometryState.edgePeerNeighborSamplerVersions[m]===e.geometryState.samplerDataVersion,`waterproof.render-peer-sampler-version-mismatch: Tile[${S.lij}].edge[${m}] stored=${j.geometryState.edgePeerNeighborSamplerVersions[m]} neighbor[${I.lij}]=${e.geometryState.samplerDataVersion}`)}const U=(m+2)%4,k=B.getEdgeCount(U),z=X-1,F=k-1;p(z*O===F,`waterproof.edge-resolution-mismatch: Tile[${S.lij}].edge[${m}] resolution=${z} neighbor[${u.lij}].edge[${U}] resolution=${F} expected=`+z*O);const G=S.extent,J=0===c||4===c,K=k-1,L=K>>V,Q=X-1;if(L<1)return void p(1===Q,`waterproof.subvertex-neighbor-overlap: Tile[${S.lij}].edge[${m}] tileOverlapCount=${Q} neighborOverlapCount=${L}`);p(L===Q,`waterproof.overlap-count-mismatch: Tile[${S.lij}].edge[${m}] tileOverlapCount=${Q} neighbor[${u.lij}].edge[${U}] neighborOverlapCount=${L}`),p(!(L&L-1),`waterproof.overlap-count-not-power-of-two: Tile[${S.lij}].edge[${m}] neighbor[${u.lij}].edge[${U}] overlapCount=${L}`);const W=B.numVerticesPerSide-1;p(V>0||L===Math.max(W,q),`waterproof.same-level-segment-count-mismatch: Tile[${S.lij}].edge[${m}] tileSegments=${q} neighbor[${u.lij}].edge[${U}] neighborSegments=${W} overlapCount=${L}`);const Y=S.getNeighborEdgeStartVertexIndex(m,u);p(0<=Y&&Y<O,`waterproof.edge-start-offset-out-of-range: Tile[${S.lij}].edge[${m}] neighbor[${u.lij}] offset=${Y} scale=${O}`);const Z=Y*L;p(0<=Z&&Z<=K-L,`waterproof.neighbor-edge-offset-out-of-range: Tile[${S.lij}].edge[${m}] neighbor[${u.lij}].edge[${U}] offset=${Z} validMax=`+(K-L));let _=0,ee=Z;A.getEdgeVertexPosition(m,v,M,0),A.getEdgeVertexPosition(m,b,M,X-1);const re=e(v,b),oe=Math.max(x,1e-4*re);for(let e=0;e<=L;++e){A.getEdgeVertexPosition(m,v,M,_),B.getEdgeVertexPosition(U,b,H,ee);const j=e/L,x=J?G[0]+j*(G[2]-G[0]):6===c?G[0]:G[2],C=J?4===c?G[1]:G[3]:G[1]+j*(G[3]-G[1]),V=S.surface.groundExtent;if(null==V||d(V,x,C)){const e=r(v,b),d=o(v)-$.radius,c=o(b)-$.radius,j=e<oe;if(!j){console.warn(`Tile edge vertex position mismatch: between [${S.lij}].edge${m}[${_}/${X}] and [${u.lij}].edge${U}[${ee}/${k}]`),null!=V&&console.warn(" surface extent= ",V," x,y=",x,",",C);const r=g();t(r,R.localOrigin,D.localOrigin),o(r)>0&&console.warn(` localOrigins: ${R.localOrigin} vs ${D.localOrigin} d=${o(r)} [${r}]`);(()=>{const e=s(v),r=s(b);S.updateEdgeElevations(),u.updateEdgeElevations(),A.getEdgeVertexPosition(m,v,M,_),B.getEdgeVertexPosition(U,b,H,ee);const t=g();n(t,v,e),o(t)>0&&console.warn(` XXX Tile[${S.lij}] edge out of date: ${e} vs ${v} d=${o(t)} [${t}]`),n(t,b,r),o(t)>0&&console.warn(` XXX Neighbor[${u.lij}] edge out of date: ${r} vs ${b} d=${o(t)} [${t}]`)})();const i=A.getEdgeCount(m),l=B.getEdgeCount(U);p(j,`waterproof.edge-position-mismatch: Tile[${S.lij}].edge[${m}][${_}/${i}] neighbor[${u.lij}].edge[${U}][${ee}/${l}] ${f(v)} vs ${f(b)} dist=${e} h(t|n|d)=${d}|${c}|${c-d}`)}A.getEdgeNormal(m,w,_),B.getEdgeNormal(U,E,ee),i(y,w),i(T,E);const N=l(y,T),P=1-N<.01||!1||S===u;if(!P){const e=g();n(e,w,E);const r=()=>`waterproof.edge-normal-mismatch: Tile${h(S.lij)}.edge[${m}][${_}/${X-1}] neighbor${h(u.lij)}.edge[${U}][${ee}/${k-1}]:${f(w)} vs ${f(E)} dot = ${N} : ${f(e)}`;console.warn("Mismatch in tile edge normal: ",r());{S.updateEdgeElevations(),u.updateEdgeElevations();const e=g(),r=g();A.getEdgeNormal(m,e,_),B.getEdgeNormal(U,r,ee),a(w,e)||console.warn("Missing update in tile normal: ",f(w)," => ",f(e)),a(E,r)||console.warn("Missing update in neighbor normal: ",f(E)," => ",f(r))}p(P,r())}}_+=1,ee+=1}}),c&&p(C.every(e=>j.geometryState.edgeResolutions[e]>0),`waterproof.nonpositive-edge-resolution: Tile[${S.lij}] edgeResolutions=${j.geometryState.edgeResolutions.join(",")}`)}const v=g(),b=g(),w=g(),E=g(),y=g(),T=g(),x=1,C=[0,1,2,3];export{j as checkPatchGeometryWaterproofness};
2
+ import"../../../core/has.js";import"../../../core/mathUtils.js";import"../../../geometry/Extent.js";import"../../../geometry/support/Ellipsoid.js";import"../../../core/Collection.js";import"../../../geometry/ellipsoidUtils.js";import"../../../geometry/support/spatialReferenceUtils.js";import"../../../kernel.js";import"../../../request.js";import"../../../core/urlUtils.js";import"../../../core/RandomLCG.js";import"../../../core/Logger.js";import"../../../core/accessorSupport/watch.js";import"../../../core/accessorSupport/tracking/SimpleTrackingTarget.js";import"../../../layers/Layer.js";import"./TerrainConst.js";import"./TilingScheme.js";function r(r){}export{r as checkPatchGeometryWaterproofness};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{fromValues as e,create as t}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import i from"../../../geometry/SpatialReference.js";import{projectVectorToVector as r}from"../../../geometry/projection/projectVectorToVector.js";import{wrap as s}from"../../../geometry/support/aaBoundingBox.js";import{create as o}from"../../../geometry/support/aaBoundingRect.js";import{isPlateCarree as n}from"../../../geometry/support/spatialReferenceUtils.js";import{sphereIntersectsInfiniteVerticalCylinderConservative as a}from"../support/ElevationAgnosticVisibility.js";import{createPlanarGlobePatch as u,updateEdgesAndCornersPlanar as l,updateEdgeElevationsAndResolutionsPlanar as h}from"./PatchGeometryFactory.js";import{Tile as d}from"./Tile.js";import{intersectAabbInvDirBefore as c}from"../webgl-engine/lib/RayIntersections.js";class m extends d{constructor(e,t,i,r,s){super(),this._horizontalScaleFactor=1,this._extentInRenderSR=o(),this._baseRadius=0,this._baseUsedMemory=900,this._subtreeGeometryElevationBoundMin=0,this._subtreeGeometryElevationBoundMax=0,this.init(e,t,i,r,s)}init(t,s,o,a,u){super.init(t,s,o,a,u);const l=u.view.renderSpatialReference,h=u.spatialReference,d=null!=l&&n(l)&&null!=h&&h.isGeographic?this.ellipsoid.radius*Math.PI/180:1;this._horizontalScaleFactor=d;const{isWebMercatorOnPlateCarree:c}=u,m=this._extentInRenderSR,p=this.extent;if(c){const t=e(p[0],p[1],0);r(t,i.WebMercator,t,i.PlateCarree);const s=e(p[2],p[3],0);r(s,i.WebMercator,s,i.PlateCarree),m[0]=t[0],m[1]=t[1],m[2]=s[0],m[3]=s[1]}else for(let e=0;e<4;++e)m[e]=p[e]*d;this.centerAtSeaLevel[0]=.5*(m[0]+m[2]),this.centerAtSeaLevel[1]=.5*(m[1]+m[3]),this.centerAtSeaLevel[2]=0,this._edgeLen=Math.max(m[2]-m[0],m[3]-m[1]),this._edgeLen2=this._edgeLen*this._edgeLen,this.updateRadiusAndCenter()}updateRadiusAndCenter(){this._updateCenter();const e=this._extentInRenderSR,t=.5*(e[2]-e[0]),i=.5*(e[3]-e[1]),r=Math.sqrt(t*t+i*i);this._baseRadius=r;const s=.5*(this.elevationBoundsMax-this.elevationBoundsMin),o=Math.max(r,s);this._center[1].radius=o}_calculateTileFrustumVisibility(e,t){if(null!=t&&!a(this.centerAtSeaLevel,this._baseRadius,t.center,t.radius))return 2;const i=this._aabb(),r=e,s=i[0],o=i[1],n=i[2],u=i[3],l=i[4],h=i[5];let d=!0;for(let a=0;a<6;a++){const e=r[a],t=e[0],i=e[1],c=e[2],m=e[3];if(t*(t>0?s:u)+i*(i>0?o:l)+c*(c>0?n:h)+m>=0)return 2;d=d&&t*(t<0?s:u)+i*(i<0?o:l)+c*(c<0?n:h)+m<=0}return d?0:1}_aabb(){const e=this._extentInRenderSR;return s(e[0],e[1],Math.min(this.elevationBoundsMin,this._subtreeGeometryElevationBoundMin),e[2],e[3],Math.max(this.elevationBoundsMax,this._subtreeGeometryElevationBoundMax))}intersectsRay(e,t,i,r){return p[0]=1/t[0],p[1]=1/t[1],p[2]=1/t[2],c(this._aabb(),e,p,i,r)}createGeometry(){u(this.renderData),this._updateSubtreeGeometryElevationsBounds(),this.setMemoryDirty()}_updateSubtreeGeometryElevationsBounds(){const e=this._subtreeGeometryElevationBoundMin,t=this._subtreeGeometryElevationBoundMax,i=this.renderData;let r=e,s=t;if(i){const e=i.geometry.boundingBox;r=e[2],s=e[5]}else if(!this.leaf){r=1/0,s=-1/0;for(const e of this.children){const t=e;r=Math.min(r,t._subtreeGeometryElevationBoundMin),s=Math.max(s,t._subtreeGeometryElevationBoundMax)}}if(r!==this._subtreeGeometryElevationBoundMin||s!==this._subtreeGeometryElevationBoundMax){this._subtreeGeometryElevationBoundMin=r,this._subtreeGeometryElevationBoundMax=s,this.updateVisibility();const e=this.parent;e?._updateSubtreeGeometryElevationsBounds()}}get minimumVerticesPerSide(){return this.level<9?3:2}updateEdgeElevations(){l(this.renderData),this._updateSubtreeGeometryElevationsBounds()}updateEdgeElevationsAndResolutions(){h(this.renderData),this._updateSubtreeGeometryElevationsBounds()}get horizontalScale(){return this._horizontalScaleFactor}}const p=t();export{m as PlanarPatch};
2
+ import{fromValues as e,create as t}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import i from"../../../geometry/SpatialReference.js";import{projectVectorToVector as r}from"../../../geometry/projection/projectVectorToVector.js";import{wrap as s}from"../../../geometry/support/aaBoundingBox.js";import{create as o}from"../../../geometry/support/aaBoundingRect.js";import{isPlateCarree as n}from"../../../geometry/support/spatialReferenceUtils.js";import{sphereIntersectsInfiniteVerticalCylinderConservative as a}from"../support/ElevationAgnosticVisibility.js";import{createPlanarGlobePatch as u,updateEdgesAndCornersPlanar as l,updateEdgeElevationsAndResolutionsPlanar as h}from"./PatchGeometryFactory.js";import{Tile as d}from"./Tile.js";import{intersectAabbInvDirBefore as c}from"../webgl-engine/lib/RayIntersections.js";class m extends d{constructor(e,t,i,r,s){super(),this._horizontalScaleFactor=1,this._extentInRenderSR=o(),this._baseRadius=0,this._baseUsedMemory=900,this._subtreeGeometryElevationBoundMin=0,this._subtreeGeometryElevationBoundMax=0,this.init(e,t,i,r,s)}init(t,s,o,a,u){super.init(t,s,o,a,u);const l=u.view.renderSpatialReference,h=u.spatialReference,d=null!=l&&n(l)&&null!=h&&h.isGeographic?this.ellipsoid.radius*Math.PI/180:1;this._horizontalScaleFactor=d;const{isWebMercatorOnPlateCarree:c}=u,m=this._extentInRenderSR,p=this.extent;if(c){const t=e(p[0],p[1],0);r(t,i.WebMercator,t,i.PlateCarree);const s=e(p[2],p[3],0);r(s,i.WebMercator,s,i.PlateCarree),m[0]=t[0],m[1]=t[1],m[2]=s[0],m[3]=s[1]}else for(let e=0;e<4;++e)m[e]=p[e]*d;this.centerAtSeaLevel[0]=.5*(m[0]+m[2]),this.centerAtSeaLevel[1]=.5*(m[1]+m[3]),this.centerAtSeaLevel[2]=0,this._edgeLen=Math.max(m[2]-m[0],m[3]-m[1]),this._edgeLen2=this._edgeLen*this._edgeLen,this.updateRadiusAndCenter()}updateRadiusAndCenter(){this._updateCenter();const e=this._extentInRenderSR,t=.5*(e[2]-e[0]),i=.5*(e[3]-e[1]),r=Math.sqrt(t*t+i*i);this._baseRadius=r;const s=.5*(this.elevationBoundsMax-this.elevationBoundsMin),o=Math.max(r,s);this._center[1].radius=o}_calculateFrustumVisibility(e,t){if(null!=t&&!a(this.centerAtSeaLevel,this._baseRadius,t.center,t.radius))return 2;const i=this._aabb(),r=e,s=i[0],o=i[1],n=i[2],u=i[3],l=i[4],h=i[5];let d=!0;for(let a=0;a<6;a++){const e=r[a],t=e[0],i=e[1],c=e[2],m=e[3];if(t*(t>0?s:u)+i*(i>0?o:l)+c*(c>0?n:h)+m>=0)return 2;d=d&&t*(t<0?s:u)+i*(i<0?o:l)+c*(c<0?n:h)+m<=0}return d?0:1}_aabb(){const e=this._extentInRenderSR;return s(e[0],e[1],Math.min(this.elevationBoundsMin,this._subtreeGeometryElevationBoundMin),e[2],e[3],Math.max(this.elevationBoundsMax,this._subtreeGeometryElevationBoundMax))}intersectsRay(e,t,i,r){return p[0]=1/t[0],p[1]=1/t[1],p[2]=1/t[2],c(this._aabb(),e,p,i,r)}createGeometry(){u(this.renderData),this._updateSubtreeGeometryElevationsBounds(),this.setMemoryDirty()}_updateSubtreeGeometryElevationsBounds(){const e=this._subtreeGeometryElevationBoundMin,t=this._subtreeGeometryElevationBoundMax,i=this.renderData;let r=e,s=t;if(i){const e=i.geometry.boundingBox;r=e[2],s=e[5]}else if(!this.leaf){r=1/0,s=-1/0;for(const e of this.children){const t=e;r=Math.min(r,t._subtreeGeometryElevationBoundMin),s=Math.max(s,t._subtreeGeometryElevationBoundMax)}}if(r!==this._subtreeGeometryElevationBoundMin||s!==this._subtreeGeometryElevationBoundMax){this._subtreeGeometryElevationBoundMin=r,this._subtreeGeometryElevationBoundMax=s,this.updateVisibility();const e=this.parent;e?._updateSubtreeGeometryElevationsBounds()}}get minimumVerticesPerSide(){return this.level<9?3:2}updateEdgeElevations(){l(this.renderData),this._updateSubtreeGeometryElevationsBounds()}updateEdgeElevationsAndResolutions(){h(this.renderData),this._updateSubtreeGeometryElevationsBounds()}get horizontalScale(){return this._horizontalScaleFactor}}const p=t();export{m as PlanarPatch};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{lerp as t}from"../../../core/mathUtils.js";import{normalize as e,set as i,add as n,scale as s,len as o,dist as r,dot as l,sub as a,cross as u}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{create as h,ZEROS 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{sphereIntersectsInfiniteRadialConeConservative as x}from"../support/ElevationAgnosticVisibility.js";import{correctSphericalTileCornersForLatitude as $,computeSmallestSphericalTileCone as v,getSphericalTilePole as _}from"../support/sphericalTileUtils.js";import{createSphericalGlobePatch as b,updateEdgesAndCornersSpherical as M,updateEdgeElevationsAndResolutionsSpherical as j}from"./PatchGeometryFactory.js";import{enableTerrainInternalChecks as y,internalAssert as B,almostEquals as S}from"./terrainUtils.js";import{Tile as C}from"./Tile.js";import{compareTilesByLij as T}from"./tileUtils.js";class A extends C{constructor(t,e,i,n,s){super(),this._convexHull=new Array(24),this._boundingConeAxis=h(),this._boundingConeHalfAngleSin=1,this._boundingSphere=new g,this._baseUsedMemory=1816,this.init(t,e,i,n,s)}init(i,n,s,o,r){super.init(i,n,s,o,r);const l=this.ellipsoid.radius,a=this.extentInRadians[0],u=this.extentInRadians[1],h=this.extentInRadians[2],c=this.extentInRadians[3],p=t(u,c,.5),f=t(a,h,.5),m=0===i?0:Math.min(Math.abs(u),Math.abs(c));this._edgeLen=(h-a)*Math.cos(m)*l,this._edgeLen2=this._edgeLen*this._edgeLen,this._curvatureHeight=l-Math.sqrt(l*l-this._edgeLen2/4),d(this.centerAtSeaLevel,f,p,this.ellipsoid.radius),e(this.up,this.centerAtSeaLevel),this.updateRadiusAndCenter()}updateRadiusAndCenter(){this._updateBoundingVolumes();const t=this._center;if(0===this.lij[0])t[1].center=c,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 n=0;const s=e.center;for(let t=0;t<8;++t)n=Math.max(n,V(s,i,3*t));t[1].radius=Math.sqrt(n)}}_calculateTileFrustumVisibility(t,e){if(!f(t,this._boundingSphere))return 2;if(this.lij[0]<10)return 1;if(null!=e&&0===this._getPatchType()&&!x(this._boundingConeAxis,this._boundingConeHalfAngleSin,e.center,e.radius))return 2;const i=this.convexHull,n=this.surface.view.state.camera.near;let s=!0;for(let o=0;o<m;o++){const e=4===o,r=t[o],l=r[0],a=r[1],u=r[2],h=r[3]-(e?n:0);let c=!1;for(let t=0;t<8;++t){const e=3*t;if(l*i[e]+a*i[e+1]+u*i[e+2]+h<0){if(c=!0,!s)break}else s=!1}if(!c)return 2}return s?0:1}computeElevationBounds(){super.computeElevationBounds(),this._updateBoundingVolumes()}createGeometry(){b(this.renderData,this._getPatchType()),this._updateBoundingVolumes(),this.setMemoryDirty()}_updateBoundingVolumes(){this._updateConvexHull(),this._updateBoundingSphere(),y&&this._checkBVs()}_updateBoundingSphere(){const t=this._boundingSphere,e=this.elevationBoundsMin,i=this.elevationBoundsMax,r=this.ellipsoid.radius,l=i;if(0===this.level)t.center=c,t.radius=r+l;else{const l=this.extentInRadians,a=.5*(l[0]+l[2]),u=l[1],h=l[3];I(L,a,u,r),I(F,a,h,r),n(t.center,L,F);const c=r+.5*(e+i);s(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],n=t[1]-d[3*e+1],s=t[2]-d[3*e+2];return Math.sqrt(i*i+n*n+s*s)};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 s=this.elevationBoundsMin,o=this.elevationBoundsMax,r=this._getPatchType(),a=this.surface.isWebMercator,u=a&&1===r,c=a&&2===r,d=c||u,p=Math.PI/2,f=t[0],m=t[2],g=c?-p:t[1],x=u?p:t[3],_=.5*(f+m),b=s,M=i+(d?Math.min(0,b-1):b),j=(t,e,i)=>I(t,e,i,M),y=h(),B=h(),S=h(),C=h();j(y,f,g),j(B,f,x),j(S,m,x),j(C,m,g);const T=(t,e)=>{for(let i=0;i<3;++i)this._convexHull[3*e+i]=t[i]};T(y,0),T(B,1),T(S,2),T(C,3);const A=o,H=i+(d?Math.max(0,A+1):A),V=h(),R=h(),L=h();I(R,_,x,M),I(L,_,g,M),n(V,R,L),e(V,V);const F=P;F[0]=y,F[1]=C,F[2]=S,F[3]=B,F[4]=L,F[5]=R,$(F,M),this._boundingConeHalfAngleSin=v(y,C,S,B,this._boundingConeAxis),T(y,0),T(B,1),T(S,2),T(C,3);const E=(t,e)=>{const i=H/l(e,V);for(let n=0;n<3;++n)this._convexHull[3*t+n]=e[n]*i};E(4,y),E(5,B),E(6,S),E(7,C)}_getPatchType(){const t=_(this.lij,this.spatialReference),e=2===t||3===t;return 1===t||3===t?e?3:1:e?2:0}intersectsRay(t,e,i,n){const s=this._boundingSphere,o=s.radius+i,r=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],l=s.center[0]-t[0],a=s.center[1]-t[1],u=s.center[2]-t[2],h=(l*e[0]+a*e[1]+u*e[2])/r,c=e[0]*h-l,d=e[1]*h-a,p=e[2]*h-u;return c*c+d*d+p*p<o*o}get minimumVerticesPerSide(){return this.level<H.length?H[this.level]+1:2}updateEdgeElevations(){M(this.renderData),this._updateBoundingVolumes()}updateEdgeElevationsAndResolutions(){j(this.renderData),this._updateBoundingVolumes()}_checkBVs(){if(!y)return;if(this.level<=2)return;const t=this._boundingSphere,i=t.radius,s=t.center,c=h(),d=this.ellipsoid.radius,f=this.elevationBoundsMin,m=this.elevationBoundsMax,g=d+f,x=1,$=0,v=this._center[1];v.center;const _=v.radius,b=this.convexHull,M=(t,e)=>{for(let i=0;i<3;++i)t[i]=b[3*e+i]};{const t=h(),i=h(),n=h(),s=h(),o=h(),r=(r,h,c,d)=>{M(i,r),M(n,h),M(s,c),a(i,i,n),a(s,s,n),u(t,i,s),e(t,t);const p=l(t,n);M(o,d);const f=l(t,o),m=Math.abs(f-p);B(S(m,0),`Non coplanar ${r},${h},${c},${d} diff = ${m}`)};r(0,1,2,3),r(4,5,6,7),r(0,1,4,5),r(1,2,5,6),r(2,3,6,7),r(3,0,7,4)}const j=p(24),C=(t,e,i)=>{const n=4*t;for(let s=0;s<3;++s)j[n+s]=e[s];j[n+3]=i},A=h(),H=h(),V=h(),P=h(),L=(t,i,n,s)=>{M(A,i),M(H,n),M(V,s),a(A,A,H),e(A,A),a(V,V,H),e(V,V),u(P,A,V),e(P,P);const o=l(P,H);C(t,P,o)};L(0,0,1,2),L(1,1,0,4),L(2,1,5,2),L(3,3,2,6),L(4,4,0,3),L(5,4,6,5);const F=(t,e,i,n)=>{const s=4*t;return j[s]*e+j[s+1]*i+j[s+2]*n-j[s+3]},E=(t,e,i,n)=>F(t,e,i,n)>=-1,k=(t,e)=>E(t,e[0],e[1],e[2]),w=2**this.lij[0]>2*this.lij[1],D=(t,e,n)=>Math.sqrt(R(t,e,n,s[0],s[1],s[2]))<i,U=t=>D(t[0],t[1],t[2]),q=(t,e)=>D(t[e],t[e+1],t[e+2]),N=this.extentInRadians,G=.5*(N[0]+N[2]),z=N[1],O=N[3],W=h(),J=h();I(W,G,O,g),I(J,G,z,g);const K=w?"Upper":"Lower";let Q=!0;for(let e=0;e<6;++e){for(let t=0;t<8;++t){const i=3*t,n=E(e,b[i],b[i+1],b[i+2]);Q&&=n,B(n,`Tile[${this.lij}] Convex hull point ${t} outside of plane ${e}`)}B(k(e,J),`Tile[${this.lij}] (${K}) bottom mid outside of plane ${e}`),B(k(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(b,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;E(e,b[i],b[i+1],b[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:nt}=tt,st=et.vertexAttributes?.position;if(!st)return;const ot=h(),rt=et.numVerticesPerSide-2,{indices:lt,indexCount:at,edgeVerticesStartIndex:ut,poleVerticesStartIndex:ht}=et;if(!lt)return;const ct=new Set;for(let e=0;e<at;++e){const t=lt[e];if(ct.has(t))continue;ct.add(t);const l=t<ht,a=t>=ut;let u=!1,h=-1;if(a){let e=ut;for(let i=0;i<4;++i){const n=it.edgeResolutions[i];if(t===e||t===e+n-1){u=!0;break}if(e+=n,t<e){h=i;break}}}const p=a?it.edgePeerNeighbors[h]:null,g=a&&p&&T(this,p)>0;st.getVec(t,c),n(ot,c,nt);const v=o(ot)-d;let b=0,M=!1;const j=f-v,y=v-m,B=j>x,S=y>x,C=B||S,A=()=>{const e=l?"internal":a&&!u?"edge":u?"corner":"pole";return`Tile[${this.lij}].vertex[${t}]:${e}`+(B?"(below)":S?"(above)":"")+(g?"(Neighbor)":"")},H=r(ot,s);if(H>=i+$){const t=H-i;C||(console.error(`${A()} 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)})`),M=!0)}for(let e=0;e<6;++e)if(!E(e,ot[0],ot[1],ot[2])){const n=F(e,ot[0],ot[1],ot[2]),s=t%rt,o=(t-s)/rt;0===e&&j||5===e&&y||(console.error(`${A()} (${s},${o})|${rt}] is out of the bounding trapezoid plane ${e} h=${Math.round(v)} / [${Math.round(f)}..${Math.round(m)}] dist=${Math.round(n)} radii = ${Math.round(i)}/${Math.round(_)}} : maxL = ${Z}`),++b)}if(M||b>0)break}}get convexHull(){return this._convexHull}}const H=[128,64,64,32,16,8,8,4];function V(t,e,i){return R(t[0],t[1],t[2],e[i],e[i+1],e[i+2])}function R(t,e,i,n,s,o){const r=n-t,l=s-e,a=o-i;return r*r+l*l+a*a}const I=(t,e,i,n)=>{const s=Math.cos(e),o=Math.sin(e),r=Math.cos(i),l=Math.sin(i);t[0]=n*r*s,t[1]=n*r*o,t[2]=n*l},P=[null,null,null,null,null,null],L=h(),F=h();export{A as SphericalPatch};
2
+ import"../../../core/has.js";import{lerp as t}from"../../../core/mathUtils.js";import{normalize as e,set as s,add as i,scale as n,len as o,dot as r}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{create as a,ZEROS as l}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{lonLatToSphericalPCPF as u}from"../../../geometry/projection/lonLatToSphericalPCPF.js";import{intersectsSphere as h,numPlanes as c}from"../../../geometry/support/frustumPlanes.js";import{Sphere as p}from"../../../geometry/support/sphere.js";import{sphereIntersectsInfiniteRadialConeConservative as d}from"../support/ElevationAgnosticVisibility.js";import{correctSphericalTileCornersForLatitude as m,computeSmallestSphericalTileCone as g,getSphericalTilePole as _}from"../support/sphericalTileUtils.js";import{createSphericalGlobePatch as f,updateEdgesAndCornersSpherical as v,updateEdgeElevationsAndResolutionsSpherical as x}from"./PatchGeometryFactory.js";import"../../../core/Collection.js";import"../../../geometry/ellipsoidUtils.js";import"../../../geometry/support/spatialReferenceUtils.js";import"../../../kernel.js";import"../../../request.js";import"../../../core/urlUtils.js";import"../../../core/RandomLCG.js";import"../../../core/Logger.js";import"../../../core/accessorSupport/watch.js";import"../../../core/accessorSupport/tracking/SimpleTrackingTarget.js";import"../../../layers/Layer.js";import"../../../geometry/Extent.js";import"./TerrainConst.js";import"./TilingScheme.js";import{Tile as j}from"./Tile.js";class M extends j{constructor(t,e,s,i,n){super(),this._convexHull=new Array(24),this._boundingConeAxis=a(),this._boundingConeHalfAngleSin=1,this._boundingSphere=new p,this._baseUsedMemory=1816,this.init(t,e,s,i,n)}init(s,i,n,o,r){super.init(s,i,n,o,r);const a=this.ellipsoid.radius,l=this.extentInRadians[0],h=this.extentInRadians[1],c=this.extentInRadians[2],p=this.extentInRadians[3],d=t(h,p,.5),m=t(l,c,.5),g=0===s?0:Math.min(Math.abs(h),Math.abs(p));this._edgeLen=(c-l)*Math.cos(g)*a,this._edgeLen2=this._edgeLen*this._edgeLen,this._curvatureHeight=a-Math.sqrt(a*a-this._edgeLen2/4),u(this.centerAtSeaLevel,m,d,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=l,s(t[0],0,0,0),s(t[2],0,0,0),t[1].radius=this.ellipsoid.radius+this.elevationBoundsMax;else{this._updateCenter();const e=t[1],s=this.convexHull;let i=0;const n=e.center;for(let t=0;t<8;++t)i=Math.max(i,b(n,s,3*t));t[1].radius=Math.sqrt(i)}}_calculateFrustumVisibility(t,e){if(!h(t,this._boundingSphere))return 2;if(this.lij[0]<10)return 1;if(null!=e&&0===this._getPatchType()&&!d(this._boundingConeAxis,this._boundingConeHalfAngleSin,e.center,e.radius))return 2;const s=this.convexHull,i=this.surface.view.state.camera.near;let n=!0;for(let o=0;o<c;o++){const e=4===o,r=t[o],a=r[0],l=r[1],u=r[2],h=r[3]-(e?i:0);let c=!1;for(let t=0;t<8;++t){const e=3*t;if(a*s[e]+l*s[e+1]+u*s[e+2]+h<0){if(c=!0,!n)break}else n=!1}if(!c)return 2}return n?0:1}computeElevationBounds(){super.computeElevationBounds(),this._updateBoundingVolumes()}createGeometry(){f(this.renderData,this._getPatchType()),this._updateBoundingVolumes(),this.setMemoryDirty()}_updateBoundingVolumes(){this._updateConvexHull(),this._updateBoundingSphere()}_updateBoundingSphere(){const t=this._boundingSphere,e=this.elevationBoundsMin,s=this.elevationBoundsMax,r=this.ellipsoid.radius,a=s;if(0===this.level)t.center=l,t.radius=r+a;else{const a=this.extentInRadians,l=.5*(a[0]+a[2]),u=a[1],h=a[3];B(H,l,u,r),B(A,l,h,r),i(t.center,H,A);const c=r+.5*(e+s);n(t.center,t.center,c/o(t.center));const p=this.convexHull;let d=0;const m=(t,e)=>{const s=t[0]-p[3*e],i=t[1]-p[3*e+1],n=t[2]-p[3*e+2];return Math.sqrt(s*s+i*i+n*n)};for(let e=0;e<8;++e){const s=m(t.center,e);d=Math.max(d,s)}const g=d;t.radius=g+2}}_updateConvexHull(){const t=this.extentInRadians,s=this.ellipsoid.radius;if(0===this.level)return;const n=this.elevationBoundsMin,o=this.elevationBoundsMax,l=this._getPatchType(),u=this.surface.isWebMercator,h=u&&1===l,c=u&&2===l,p=c||h,d=Math.PI/2,_=t[0],f=t[2],v=c?-d:t[1],x=h?d:t[3],j=.5*(_+f),M=n,y=s+(p?Math.min(0,M-1):M),b=(t,e,s)=>B(t,e,s,y),S=a(),H=a(),A=a(),R=a();b(S,_,v),b(H,_,x),b(A,f,x),b(R,f,v);const L=(t,e)=>{for(let s=0;s<3;++s)this._convexHull[3*e+s]=t[s]};L(S,0),L(H,1),L(A,2),L(R,3);const T=o,P=s+(p?Math.max(0,T+1):T),V=a(),E=a(),I=a();B(E,j,x,y),B(I,j,v,y),i(V,E,I),e(V,V);const U=C;U[0]=S,U[1]=R,U[2]=A,U[3]=H,U[4]=I,U[5]=E,m(U,y),this._boundingConeHalfAngleSin=g(S,R,A,H,this._boundingConeAxis),L(S,0),L(H,1),L(A,2),L(R,3);const k=(t,e)=>{const s=P/r(e,V);for(let i=0;i<3;++i)this._convexHull[3*t+i]=e[i]*s};k(4,S),k(5,H),k(6,A),k(7,R)}_getPatchType(){const t=_(this.lij,this.spatialReference),e=2===t||3===t;return 1===t||3===t?e?3:1:e?2:0}intersectsRay(t,e,s,i){const n=this._boundingSphere,o=n.radius+s,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],u=n.center[2]-t[2],h=(a*e[0]+l*e[1]+u*e[2])/r,c=e[0]*h-a,p=e[1]*h-l,d=e[2]*h-u;return c*c+p*p+d*d<o*o}get minimumVerticesPerSide(){return this.level<y.length?y[this.level]+1:2}updateEdgeElevations(){v(this.renderData),this._updateBoundingVolumes()}updateEdgeElevationsAndResolutions(){x(this.renderData),this._updateBoundingVolumes()}_checkBVs(){}get convexHull(){return this._convexHull}}const y=[128,64,64,32,16,8,8,4];function b(t,e,s){return S(t[0],t[1],t[2],e[s],e[s+1],e[s+2])}function S(t,e,s,i,n,o){const r=i-t,a=n-e,l=o-s;return r*r+a*a+l*l}const B=(t,e,s,i)=>{const n=Math.cos(e),o=Math.sin(e),r=Math.cos(s),a=Math.sin(s);t[0]=i*r*n,t[1]=i*r*o,t[2]=i*a},C=[null,null,null,null,null,null],H=a(),A=a();export{M as SphericalPatch};