@arcgis/core 6.0.0-next.55 → 6.0.0-next.56

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 (205) hide show
  1. package/arcgisGlobal.d.ts +1 -0
  2. package/assets/esri/core/workers/RemoteClient.js +1 -1
  3. package/assets/esri/core/workers/chunks/033b9fcd9833db3b6e7d.js +1 -0
  4. package/assets/esri/core/workers/chunks/0978e12dd6a1cbc50b80.js +1 -0
  5. package/assets/esri/core/workers/chunks/{e956845255bce0910944.js → 1507297550c3cd1268e2.js} +1 -1
  6. package/assets/esri/core/workers/chunks/1c0f5c42331fb6fc26cb.js +1 -0
  7. package/assets/esri/core/workers/chunks/2cd2fcf4a37d180d5d5c.js +1 -0
  8. package/assets/esri/core/workers/chunks/2f9adf0b809ce8797ebf.js +1 -0
  9. package/assets/esri/core/workers/chunks/3982409149571a827390.js +1 -0
  10. package/assets/esri/core/workers/chunks/3d851710f7fcc27c5b60.js +2 -0
  11. package/assets/esri/core/workers/chunks/3e8d70039800f2395d66.js +1 -0
  12. package/assets/esri/core/workers/chunks/4d8539674fc2e4fea03c.js +1 -0
  13. package/assets/esri/core/workers/chunks/{e61082f56c08abe54b3a.js → 5954f02c3901b28d8e73.js} +1 -1
  14. package/assets/esri/core/workers/chunks/5ba6007c3c49a8153256.js +1 -0
  15. package/assets/esri/core/workers/chunks/5bdd95eeb8f34dbf26f2.js +2 -0
  16. package/assets/esri/core/workers/chunks/{ced5dfb2bf46fc5eac8c.js → 5e47026c681238038955.js} +2 -2
  17. package/assets/esri/core/workers/chunks/{2baf35b1b19482d603b5.js → 5f7505ada0991cfbdd84.js} +1 -1
  18. package/assets/esri/core/workers/chunks/{976303f47c342b9d1cc0.js → 62ddd3a82864e26f009a.js} +1 -1
  19. package/assets/esri/core/workers/chunks/{542a9c414c99d84d52ab.js → 6a202ef9ba9b89e09153.js} +1 -1
  20. package/assets/esri/core/workers/chunks/{0826feebdca8a31eb630.js → 6ba6fece5c11fe2a6ace.js} +1 -1
  21. package/assets/esri/core/workers/chunks/{5eb69e2895e5aec81051.js → 6fd10891506925560443.js} +1 -1
  22. package/assets/esri/core/workers/chunks/7b6fd287e7043ad50f4e.js +1 -0
  23. package/assets/esri/core/workers/chunks/7baa49055bc31618b56e.js +1 -0
  24. package/assets/esri/core/workers/chunks/8570e3df90fb76a8741a.js +1 -0
  25. package/assets/esri/core/workers/chunks/{c3c0f24a9e0047232ae1.js → 8679dfc0c53355b6feb0.js} +1 -1
  26. package/assets/esri/core/workers/chunks/8a636dc51372e14c98f5.js +1 -0
  27. package/assets/esri/core/workers/chunks/{14259910f44c08fd5bbd.js → 9117c9b720c9ba6e7a6e.js} +1 -1
  28. package/assets/esri/core/workers/chunks/a22458e5272332d86cb9.js +1 -0
  29. package/assets/esri/core/workers/chunks/{3ea480cebf8ee56228a5.js → a7dfca326883384d2751.js} +1 -1
  30. package/assets/esri/core/workers/chunks/{723d8316f5d4b6ce2942.js → a9539393e2f1812a973a.js} +1 -1
  31. package/assets/esri/core/workers/chunks/{be0b8bb4f09aae6ff5de.js → ab784764ddf9d7f693a1.js} +1 -1
  32. package/assets/esri/core/workers/chunks/b38b6fe08a367e9de4f5.js +1 -0
  33. package/assets/esri/core/workers/chunks/{4e651869e9a196494694.js → b6e628b5d2643af4c19b.js} +1 -1
  34. package/assets/esri/core/workers/chunks/{b37ab6b1cb4cfc85cd9d.js → b7828d7e2c5b75644057.js} +1 -1
  35. package/assets/esri/core/workers/chunks/{ec465abb0344ad719e9d.js → bd8e329ec74d921d311a.js} +1 -1
  36. package/assets/esri/core/workers/chunks/{56e6e70aa40e51827290.js → c3f94024c6c9eed9f273.js} +1 -1
  37. package/assets/esri/core/workers/chunks/{6d17b45022dfd2548098.js → c5ddf8b347c31fe772a3.js} +1 -1
  38. package/assets/esri/core/workers/chunks/{ee9af58ae202b803bba7.js → c7a0c4ca37ebd1d98cf1.js} +1 -1
  39. package/assets/esri/core/workers/chunks/d7763c42754152510e13.js +2 -0
  40. package/assets/esri/core/workers/chunks/{9e508f930086d2ef5f22.js → dfa1b0308e5e82d1ddfe.js} +40 -41
  41. package/assets/esri/core/workers/chunks/e566102c7ed7a8ebf89e.js +1 -0
  42. package/assets/esri/core/workers/chunks/e74586b074d0fa6abb4b.js +1 -0
  43. package/assets/esri/core/workers/chunks/e7dff025780726d5feae.js +1 -0
  44. package/assets/esri/core/workers/chunks/e96fa029acba59c04e4e.js +2 -0
  45. package/assets/esri/core/workers/chunks/{4401b3f8ebb658abe789.js → efd6ea0966f60ab19520.js} +1 -1
  46. package/assets/esri/core/workers/chunks/fdfbd201be372d3796bf.js +2 -0
  47. package/assets/esri/core/workers/chunks/ff0a0819bba5e8264c47.js +1 -0
  48. package/chunks/BlendLayers.glsl.js +1 -1
  49. package/chunks/ColorMaterial.glsl.js +14 -14
  50. package/chunks/Component.glsl.js +37 -37
  51. package/chunks/DefaultMaterial.glsl.js +15 -15
  52. package/chunks/HUDMaterial.glsl.js +3 -3
  53. package/chunks/Path.glsl.js +15 -15
  54. package/chunks/Pattern.glsl.js +20 -20
  55. package/chunks/RasterColorizer.glsl.js +1 -1
  56. package/chunks/ShadowHighlight.glsl.js +1 -1
  57. package/chunks/Terrain.glsl.js +24 -24
  58. package/chunks/Water.glsl.js +29 -20
  59. package/chunks/pdf.js +57 -0
  60. package/config.js +1 -1
  61. package/core/accessorSupport/write.js +1 -1
  62. package/core/scheduling.js +1 -1
  63. package/kernel.js +1 -1
  64. package/layers/VoxelWasmPerSceneView.js +1 -1
  65. package/layers/geospatialPDF/GeospatialPDFFrame.js +1 -1
  66. package/layers/geospatialPDF/GeospatialPDFLayerWorker.js +1 -56
  67. package/layers/geospatialPDF/GeospatialPDFWorkerClient.js +1 -1
  68. package/layers/geospatialPDF/parserUtils.js +2 -0
  69. package/layers/support/ControlPoint.js +1 -1
  70. package/layers/support/ControlPointsGeoreference.js +1 -1
  71. package/layers/support/commonProperties.js +1 -1
  72. package/layers/support/geospatialPDFUtils.d.ts +63 -0
  73. package/layers/support/geospatialPDFUtils.js +2 -0
  74. package/package.json +5 -5
  75. package/symbols/CIMSymbol.d.ts +9 -9
  76. package/symbols/PathSymbol3DLayer.d.ts +1 -1
  77. package/symbols/WaterSymbol3DLayer.d.ts +13 -1
  78. package/symbols/WaterSymbol3DLayer.js +1 -1
  79. package/views/3d/analysis/ShadowCastAnalysisView3D.js +1 -1
  80. package/views/3d/analysis/Viewshed/ViewshedObserverManipulatedObject3D.js +1 -1
  81. package/views/3d/camera/constraintUtils/tilt.js +1 -1
  82. package/views/3d/camera/intersectionUtils.js +1 -1
  83. package/views/3d/environment/EnvironmentView.js +1 -1
  84. package/views/3d/input/handlers/ground/GroundNavigation.js +1 -1
  85. package/views/3d/interactive/Manipulator3D.js +1 -1
  86. package/views/3d/interactive/Manipulator3DBase.js +1 -1
  87. package/views/3d/interactive/editingTools/dragEventPipeline3D.js +1 -1
  88. package/views/3d/interactive/measurementTools/directLineMeasurement3D/DirectLineMeasurement3DView.js +1 -1
  89. package/views/3d/interactive/visualElements/Object3DVisualElement.js +1 -1
  90. package/views/3d/interactive/visualElements/RightAngleQuadVisualElement.js +1 -1
  91. package/views/3d/layers/BuildingSceneLayerView3D.js +1 -1
  92. package/views/3d/layers/DrapedSubView3D.js +1 -1
  93. package/views/3d/layers/DynamicLayerView3D.js +1 -1
  94. package/views/3d/layers/FeatureLikeLayerViewBase3D.js +1 -1
  95. package/views/3d/layers/FlowSubView3D.js +1 -1
  96. package/views/3d/layers/GraphicsLayerView3D.js +1 -1
  97. package/views/3d/layers/I3SMeshView3D.js +1 -1
  98. package/views/3d/layers/RouteLayerView3D.js +1 -1
  99. package/views/3d/layers/SceneLayerGraphicsView3D.js +1 -1
  100. package/views/3d/layers/VectorTileLayerView3D.js +1 -1
  101. package/views/3d/layers/VoxelLayerView3D.js +1 -1
  102. package/views/3d/layers/graphics/Deconflictor.js +1 -1
  103. package/views/3d/layers/graphics/Graphics3DFrustumVisibility.js +1 -1
  104. package/views/3d/layers/graphics/Graphics3DLineSymbolLayer.js +1 -1
  105. package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
  106. package/views/3d/layers/graphics/Graphics3DPolygonFillSymbolLayer.js +1 -1
  107. package/views/3d/layers/graphics/Graphics3DWaterSymbolLayer.js +1 -1
  108. package/views/3d/layers/i3s/I3SIndex.js +1 -1
  109. package/views/3d/layers/i3s/I3SUtil.js +1 -1
  110. package/views/3d/layers/support/Tiles3DBVH.js +1 -1
  111. package/views/3d/layers/support/createTileBVHForLayer.js +1 -1
  112. package/views/3d/state/controllers/PinchAndPanControllerGlobal.js +1 -1
  113. package/views/3d/state/controllers/PinchAndPanControllerLocal.js +1 -1
  114. package/views/3d/state/controllers/RotateController.js +1 -1
  115. package/views/3d/state/controllers/ZoomControllerGlobal.js +1 -1
  116. package/views/3d/state/controllers/ZoomStepControllerGlobal.js +1 -1
  117. package/views/3d/state/utils/groundNavigationUtils.js +1 -1
  118. package/views/3d/state/utils/navigationUtils.js +1 -1
  119. package/views/3d/support/QualityProfile.js +1 -1
  120. package/views/3d/support/QualitySettings.js +1 -1
  121. package/views/3d/support/flow/StreamlineResources3DShape.js +1 -1
  122. package/views/3d/terrain/BlendLayersTechniqueConfiguration.js +1 -1
  123. package/views/3d/terrain/OverlayManager.js +1 -1
  124. package/views/3d/terrain/PatchGeometryFactory.js +1 -1
  125. package/views/3d/terrain/RasterColorizerTechniqueConfiguration.js +1 -1
  126. package/views/3d/terrain/TerrainSurface.js +1 -1
  127. package/views/3d/webgl-engine/collections/Component/Material/Component.glsl.js +1 -1
  128. package/views/3d/webgl-engine/core/shaderLibrary/clampShadowPosition.glsl.js +2 -0
  129. package/views/3d/webgl-engine/core/shaderLibrary/default/DefaultMaterialAuxiliaryPasses.glsl.js +14 -14
  130. package/views/3d/webgl-engine/core/shaderLibrary/hud/HUD.glsl.js +1 -1
  131. package/views/3d/webgl-engine/core/shaderLibrary/terrain/TileComposite.glsl.js +2 -3
  132. package/views/3d/webgl-engine/core/shaderLibrary/util/View.glsl.js +1 -1
  133. package/views/3d/webgl-engine/lib/BufferGeometry.js +1 -1
  134. package/views/3d/webgl-engine/lib/BufferObject3D.js +1 -1
  135. package/views/3d/webgl-engine/lib/GridLocalOriginFactory.js +1 -1
  136. package/views/3d/webgl-engine/lib/Object3D.js +1 -1
  137. package/views/3d/webgl-engine/lib/Program.js +1 -1
  138. package/views/3d/webgl-engine/lib/RenderGeometry.js +1 -1
  139. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  140. package/views/3d/webgl-engine/lib/depthRangeUtils.js +1 -1
  141. package/views/3d/webgl-engine/materials/DefaultLayouts.js +1 -1
  142. package/views/3d/webgl-engine/materials/Path.glsl.js +1 -1
  143. package/views/3d/webgl-engine/materials/Water.glsl.js +1 -1
  144. package/views/3d/webgl-engine/materials/WaterMaterial.js +1 -1
  145. package/views/3d/webgl-engine/parts/Model.js +1 -1
  146. package/views/3d/webgl-engine/shaders/ColorMaterial.glsl.js +1 -1
  147. package/views/3d/webgl-engine/shaders/DefaultMaterial.glsl.js +1 -1
  148. package/views/3d/webgl-engine/shaders/Pattern.glsl.js +1 -1
  149. package/views/3d/webgl-engine/shaders/Terrain.glsl.js +1 -1
  150. package/views/Attribution.js +5 -5
  151. package/views/DOMContainer.d.ts +2 -1
  152. package/views/SceneView.js +1 -1
  153. package/views/draw/DrawGraphicTool.js +1 -1
  154. package/views/draw/support/surfaceCoordinateSystems.js +1 -1
  155. package/views/webgl/Program.js +3 -3
  156. package/views/webgl/ShaderBuilder.js +23 -23
  157. package/webscene/Slide.js +1 -1
  158. package/webscene/VirtualLighting.d.ts +2 -4
  159. package/widgets/BatchAttributeForm/inputs/FieldInput.d.ts +17 -1
  160. package/widgets/BatchAttributeForm/inputs/FieldInput.js +1 -1
  161. package/widgets/BatchAttributeForm/inputs/support/inputUtils.d.ts +7 -0
  162. package/widgets/BatchAttributeForm/inputs/support/inputUtils.js +1 -1
  163. package/widgets/BatchAttributeForm.js +1 -1
  164. package/widgets/ShadowCast/ShadowCastViewModel.js +1 -1
  165. package/widgets/Sketch/SketchViewModel.js +1 -1
  166. package/widgets/Weather/WeatherViewModel.js +1 -1
  167. package/widgets/support/ContingentValuesManager.js +1 -1
  168. package/widgets/support/forms/types.d.ts +23 -1
  169. package/assets/esri/core/workers/chunks/144f18a3dd2c8cf07cf7.js +0 -1
  170. package/assets/esri/core/workers/chunks/23fc1c1ed483ed3b2298.js +0 -1
  171. package/assets/esri/core/workers/chunks/249a687ce1b6d0815242.js +0 -1
  172. package/assets/esri/core/workers/chunks/2634927d26cb1139c6d0.js +0 -1
  173. package/assets/esri/core/workers/chunks/2d1b8154ee40afc9d40b.js +0 -1
  174. package/assets/esri/core/workers/chunks/4a41bf3d1e2e9bb79771.js +0 -2
  175. package/assets/esri/core/workers/chunks/5f324d88785ffcb73ae0.js +0 -1
  176. package/assets/esri/core/workers/chunks/70695e0fb53018d48e7b.js +0 -2
  177. package/assets/esri/core/workers/chunks/723c9ad4c25be2b82476.js +0 -1
  178. package/assets/esri/core/workers/chunks/766a1357be2ed7f4e125.js +0 -1
  179. package/assets/esri/core/workers/chunks/844c593754b2692257f4.js +0 -1
  180. package/assets/esri/core/workers/chunks/846248697c398468d8e6.js +0 -1
  181. package/assets/esri/core/workers/chunks/89e55895683369b5277a.js +0 -1
  182. package/assets/esri/core/workers/chunks/8c94e987754b3919181e.js +0 -1
  183. package/assets/esri/core/workers/chunks/919115788da38049aea7.js +0 -2
  184. package/assets/esri/core/workers/chunks/a116dd204921e7464944.js +0 -1
  185. package/assets/esri/core/workers/chunks/b33e7e74cf8fa3926617.js +0 -1
  186. package/assets/esri/core/workers/chunks/bb2af16e55cb39163827.js +0 -1
  187. package/assets/esri/core/workers/chunks/d5bb9f9b7b341c671525.js +0 -1
  188. package/assets/esri/core/workers/chunks/d96e63d66f7b1f4ea54a.js +0 -2
  189. package/assets/esri/core/workers/chunks/e3bcd2e356f75afc316a.js +0 -1
  190. package/assets/esri/core/workers/chunks/e80526571f1a34de3278.js +0 -1
  191. package/assets/esri/core/workers/chunks/ea71850ba87ae6038000.js +0 -1
  192. package/assets/esri/core/workers/chunks/f537a5e808dc546813c7.js +0 -1
  193. package/assets/esri/core/workers/chunks/fe811d651d201f698b8f.js +0 -2
  194. package/chunks/NativeLine.glsl.js +0 -8
  195. package/layers/geospatialPDF/geospatialPDFParserUtils.js +0 -2
  196. package/views/3d/webgl-engine/materials/NativeLineMaterial.js +0 -2
  197. package/views/3d/webgl-engine/shaders/NativeLine.glsl.js +0 -2
  198. package/views/3d/webgl-engine/shaders/NativeLineTechnique.js +0 -2
  199. package/views/3d/webgl-engine/shaders/NativeLineTechniqueConfiguration.js +0 -2
  200. /package/assets/esri/core/workers/chunks/{919115788da38049aea7.js.LICENSE.txt → 3d851710f7fcc27c5b60.js.LICENSE.txt} +0 -0
  201. /package/assets/esri/core/workers/chunks/{fe811d651d201f698b8f.js.LICENSE.txt → 5bdd95eeb8f34dbf26f2.js.LICENSE.txt} +0 -0
  202. /package/assets/esri/core/workers/chunks/{ced5dfb2bf46fc5eac8c.js.LICENSE.txt → 5e47026c681238038955.js.LICENSE.txt} +0 -0
  203. /package/assets/esri/core/workers/chunks/{4a41bf3d1e2e9bb79771.js.LICENSE.txt → d7763c42754152510e13.js.LICENSE.txt} +0 -0
  204. /package/assets/esri/core/workers/chunks/{d96e63d66f7b1f4ea54a.js.LICENSE.txt → e96fa029acba59c04e4e.js.LICENSE.txt} +0 -0
  205. /package/assets/esri/core/workers/chunks/{70695e0fb53018d48e7b.js.LICENSE.txt → fdfbd201be372d3796bf.js.LICENSE.txt} +0 -0
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import{clamp as e,isPowerOfTwo as t}from"../../../core/mathUtils.js";import{maxUint16 as n}from"../../../core/typedArrayUtil.js";import{empty as r}from"../../../geometry/support/aaBoundingBox.js";import{fromValues as i}from"../../../geometry/support/aaBoundingRect.js";import{compressNormal as a}from"../webgl-engine/lib/Normals.js";import{sampleElevation as o,sampleSingleElevation as s}from"./ElevationData.js";import{PatchGeometryLUT as c}from"./PatchGeometryLUT.js";import{zeroToFour as l,neighborTileIfLoadedOrSelf as u}from"./PatchRenderData.js";import{maxPatchTesselation as d,elevationNoDataValue as f}from"./TerrainConst.js";import{internalAssert as p,enableTerrainInternalChecks as m,neighborEdgeIndices as h,almostEquals as g}from"./terrainUtils.js";import{isCornerNeighbor as _}from"./Tile.js";import{compareTilesByLij as v}from"./tileUtils.js";function y(e,t){let{tile:n,geometry:i,geometryState:a}=e,{extentInRadians:o,surface:s}=n,{isWebMercator:c,renderer:l}=s,{numVerticesPerSide:u,wireframe:d}=a,f=u-1,p=(u-2)**2,m=c&&(t===2||t===3),h=c&&(t===1||t===3),g=(+!!m+ +!!h)*De*u,_=Se(a),v=4*_,y=p+g+v,S=l.tileGeometryCache.acquire(y);i.numVerticesPerSide=u,i.vertexAttributes=S,i.maxEdgeVertexCount=_;let{boundingBox:C}=i;r(C);let w=P(e);$.update(f,o,w),x(e),i.poleVerticesStartIndex=p;let T=b(e,m,h);i.edgeVerticesStartIndex=p+g,te(e),O(e,Te,Ee),W(i,T,d),e.intersectionData=null}function b(e,t,r){let{tile:i,localOrigin:o,geometry:s}=e,{extent:c,ellipsoid:l}=i,{boundingBox:u,numVerticesPerSide:d,vertexAttributes:f,poleVerticesStartIndex:p}=s,m=d-1,h=o[0],g=o[1],_=o[2],v=l.radius,y=c[1],b=c[3],x=[],S=p,C=(e,t)=>{let r=t*d;xe(-h,-g,-_+e*v,u),x.push(new oe(e===1,r,e===1?0:2,S,De));let i=j(e===-1?y:b,v),o=e*Math.PI/2-i,s=(e===1?1:-1)*.99,c=v+0,{position:l,uv0:p}=f,{typedBuffer:C,typedBufferStride:w}=f.normalCompressed;for(let e=1;e<=De;++e){let t=i+e/De*o,r=Math.cos(t),d=Math.sin(t);for(let e=0;e<=m;e++){let t=e/m,i=$.sinLonLUT[e],o=$.cosLonLUT[e]*r,f=i*r,v=d,y=o*c-h,b=f*c-g,x=v*c-_;xe(y,b,x,u),l.setValues(S,y,b,x),p.setValues(S,Math.round(t*n),Math.round(s*n)),a(C,S,o,f,v,w),++S}}};return t&&C(-1,0),r&&C(1,m),x}function x(e){let t=e.geometryState.samplerData,n=t?.length===1?t[0]:null;n?S(e,n):C(e)}function S(e,t){let{tile:n}=e;if(!n.intersectsClippingArea)return;let{geometry:r,geometryState:i,localOrigin:o}=e,{numVerticesPerSide:s}=i,c=s-2,l=s-1,{vertexAttributes:u,boundingBox:d}=r,{position:f,uv0:p}=u,{typedBuffer:m,typedBufferStride:h}=u.normalCompressed,{extent:g}=n,_=n.ellipsoid.radius,v=o[0],y=o[1],b=o[2],x=f.typedBuffer,S=f.typedBufferStride,C=p.typedBuffer,E=p.typedBufferStride;w(l,g,t);let D=0,O=t.data.values;if(1<=c){let e=le[1],t=$.sinLatLUT[1],n=$.cosLatLUT[1];for(let r=1;r<=c;r++){let i=$.sinLonLUT[r],a=$.cosLonLUT[r],o=_+T(r,1,O),s=-v+o*a*n,c=-y+o*i*n,l=-b+o*t;xe(s,c,l,d);let u=(r-1)*S;x[u]=s,x[u+1]=c,x[u+2]=l;let f=(r-1)*E;C[f]=le[r],C[f+1]=e}}for(let e=1;e<=c;e++){let t=$.sinLatLUT[e],n=$.cosLatLUT[e],r=e+1,i=le[r],o=$.sinLatLUT[r],s=$.cosLatLUT[r],u=$.sinLonLUT[0],f=$.cosLonLUT[0],p=_+T(0,e,O),g=f*n*p-v,w=u*n*p-y,k=t*p-b,A=D*S,j=x[A],M=x[A+1],N=x[A+2];for(let u=1;u<=c;u++){let f=$.sinLonLUT[u],p=$.cosLonLUT[u],A=0,P=0,F=0;if(u<c){let e=(D+1)*S;A=x[e],P=x[e+1],F=x[e+2]}else{let r=$.sinLonLUT[l],i=$.cosLonLUT[l],a=_+T(l,e,O);A=i*n*a-v,P=r*n*a-y,F=t*a-b}let I=g,L=w,R=k;g=j,w=M,k=N,j=A,M=P,N=F;let z=A-I,B=P-L,V=F-R,H=0,U=0,ee=0;if(e>1){let e=(D-c)*S;H=x[e],U=x[e+1],ee=x[e+2]}else{let e=$.sinLatLUT[0],t=$.cosLatLUT[0],n=_+T(u,0,O);H=p*t*n-v,U=f*t*n-y,ee=e*n-b}let W=_+T(u,r,O),G=p*s*W-v,K=f*s*W-y,q=o*W-b;if(e<c){let e=D+c,t=e*S;x[t]=G,x[t+1]=K,x[t+2]=q,xe(G,K,q,d);let n=e*E;C[n]=le[u],C[n+1]=i}let J=H-G,Y=U-K,X=ee-q,te=p*n,Z=f*n,ne=t;ne*ne<.999&&(te=V*Y-B*X,Z=z*X-V*J,ne=B*J-z*Y),a(m,D,te,Z,ne,h),++D}}}function C(e){let{tile:t}=e;if(!t.intersectsClippingArea)return;let{geometry:r,geometryState:i,localOrigin:s}=e,{numVerticesPerSide:c,samplerData:l}=i,u=c-2,d=c-1,{vertexAttributes:f,boundingBox:p}=r,{position:m,uv0:h}=f,{typedBuffer:g,typedBufferStride:_}=f.normalCompressed,{extent:v}=t,y=v[0],b=v[2],x=v[1],S=v[3],C=t.ellipsoid.radius,w=s[0],T=s[1],E=s[2],D=m.typedBuffer,O=m.typedBufferStride,k=1/d,A=0;if(1<=u){let e=k,t=x*(1-e)+S*e,r=$.sinLatLUT[1],i=$.cosLatLUT[1];for(let a=1;a<=u;a++){let s=a*k,c=y*(1-s)+b*s,u=$.sinLonLUT[a],d=$.cosLonLUT[a],f=C+o(c,t,l),m=-w+f*d*i,g=-T+f*u*i,_=-E+f*r;xe(m,g,_,p);let v=(a-1)*O;D[v]=m,D[v+1]=g,D[v+2]=_,h.setValues(a-1,Math.round(s*n),Math.round(e*n))}}for(let e=1;e<=u;e++){let t=e*k,r=x*(1-t)+S*t,i=$.sinLatLUT[e],s=$.cosLatLUT[e],c=e+1,f=c*k,m=x*(1-f)+S*f,v=$.sinLatLUT[c],j=$.cosLatLUT[c],M=$.sinLonLUT[0],N=$.cosLonLUT[0],P=C+o(y,r,l),F=N*s*P-w,I=M*s*P-T,L=i*P-E,R=A*O,z=D[R],B=D[R+1],V=D[R+2];for(let t=1;t<=u;t++){let c=t*k,S=y*(1-c)+b*c,M=$.sinLonLUT[t],N=$.cosLonLUT[t],P=0,R=0,H=0;if(t<u){let e=(A+1)*O;P=D[e],R=D[e+1],H=D[e+2]}else{let e=$.sinLonLUT[d],t=$.cosLonLUT[d],n=C+o(b,r,l);P=t*s*n-w,R=e*s*n-T,H=i*n-E}let U=F,ee=I,W=L;F=z,I=B,L=V,z=P,B=R,V=H;let G=P-U,K=R-ee,q=H-W,J=0,Y=0,X=0;if(e>1){let e=(A-u)*O;J=D[e],Y=D[e+1],X=D[e+2]}else{let e=$.sinLatLUT[0],t=$.cosLatLUT[0],n=C+o(S,x,l);J=N*t*n-w,Y=M*t*n-T,X=e*n-E}let te=C+o(S,m,l),Z=N*j*te-w,ne=M*j*te-T,re=v*te-E;if(e<u){let e=A+u,t=e*O;D[t]=Z,D[t+1]=ne,D[t+2]=re,xe(Z,ne,re,p),h.setValues(e,Math.round(c*n),Math.round(f*n))}let ie=J-Z,Q=Y-ne,ae=X-re,oe=N*s,se=M*s,ce=i;ce*ce<.999&&(oe=q*Q-K*ae,se=G*ae-q*ie,ce=K*ie-G*Q);let le=1/Math.sqrt(oe*oe+se*se+ce*ce);a(g,A,oe*le,se*le,ce*le,_),++A}}}function w(t,r,i){let a=r[0],o=r[2],s=r[1],c=r[3],l=1/t,{dx:u,dy:d,x0:f,y1:p,safeWidth:m}=i,h=i.data.width;for(let r=0;r<=t;r++){let t=r*l,i=e(u*(a*(1-t)+o*t-f),0,m),g=Math.floor(i);ue[r]=g,pe[r]=i-g;let _=e(d*(p-(s*(1-t)+c*t)),0,m),v=Math.floor(_);de[r]=v*h,fe[r]=(v+1)*h,me[r]=_-v,le[r]=Math.round(t*n)}}function T(e,t,n){let r=ue[e],i=pe[e],a=de[t],o=fe[t],s=me[t],c=a+r,l=n[c],u=n[c+1],d=n[o+r],f=n[o+r+1];if(l+d+u+f>=ce)return 0;let p=l+(u-l)*i;return p+(d+(f-d)*i-p)*s}function E(e,t=!1){e.tile.intersectsClippingArea&&(O(e,t?Te:e.dirtyEdges,t?Ee:e.dirtyCorners),Q(e),e.intersectionData=null)}function D(e){e.tile.intersectsClippingArea&&(Z(e),O(e,Te,Ee),Q(e),ae(e),e.intersectionData=null)}function O(e,t,n){e.tile.intersectsClippingArea&&(n&&A(e,n),t&&k(e,t),(n||t)&&be(e.geometry.boundingBox))}function k(e,r){let{geometry:i,geometryState:c,tile:l,localOrigin:d}=e,{level:f,extent:_,extentInRadians:y,ellipsoid:b}=l,x=b.radius,S=y[0],C=y[2],w=y[1],T=y[3],{samplerData:E}=c,D=_[0],O=_[2],k=_[1],A=_[3],j=P(e),{boundingBox:M,vertexAttributes:N}=i,F=d[0],I=d[1],L=d[2],{position:R,uv0:z}=N,B=R.typedBuffer,V=R.typedBufferStride,H=z.typedBuffer,U=z.typedBufferStride,{typedBuffer:ee,typedBufferStride:W}=N.normalCompressed,G=E?.length===1?E[0]:null,K=(e,t,n)=>G?s(e,t,G)??0:o(e,t,E)??0;for(let d=0;d<4;++d){if(!(r&1<<d))continue;let y=d===1||d===3,b=c.edgeResolutions[d];p(t(b));let N=b+1,P=u(l,c.edgePeerNeighbors[d]);if(_e(l,P,d)&&ne(e,d,P))continue;let R=P!=null;p(!R||P.level===l.level),p(!R||v(l,P)<=0);let z=P?.renderData?.geometryState;if(m){let e=l.surface;if(!P&&e&&!e.updatingRootTiles){let t=h[d],n=l.findNeighborTile(t,e=>e.loaded||e.leaf||e.level===l.level);n?n.intersectsClippingArea&&(p(!n.loaded),p(!n.leaf),p(n.level===f)):p(e?.rootTiles==null||!l.shouldHaveNeighbor(t))}}let q=d===1?_[2]:_[0],J=P?.extent,Y=J&&y?d===1?J[0]:J[2]:q,X=d===0?_[3]:_[1],te=+(d===1),Z=+(d===0),re=d===1?C:S,ie=d===0?T:w,Q=Math.sin(re),ae=Math.cos(re),oe=Math.sin(ie),se=Math.cos(ie),$=z?.samplerData,ce=$?.length===1?$[0]:null,le=(e,t,n)=>ce?s(n,t,ce)??0:o(n,t,$)??0,ue=R?(e,t,n)=>(K(e,t)+le(e,t,n))*.5:K,de=i.outerEdgesOffsetAndLength[d*2+0],fe=G!=null||E!=null&&E.some(e=>e!=null),pe=ce!=null||$!=null&&$.some(e=>e!=null),me=fe||pe,he=1/b,ge=n*he,ve=te*n,ye=Z*n,be=de;p(!J||g(J[2]-J[0],_[2]-_[0])),(()=>{let e=d===1?-1:+(d===3),t=d===0?-1:+(d===2),n=(_[2]-_[0])*he,r=e*n,i=t*n,c=C-S,l=y?c*he*e:0,u=y?0:t*he,f=Z,p=y?re+l:re,m=y?Math.sin(p):Q,h=y?Math.cos(p):ae,g=y?re-l:re,v=y?Math.sin(g):Q,b=y?Math.cos(g):ae,w=f+u,T=y?ie:j(w),P=y?oe:Math.sin(T),z=y?se:Math.cos(T),K=f-u,J=y?ie:j(K),te=y?oe:Math.sin(J),ne=y?se:Math.cos(J),le=0,de=0,fe=0;{let e=0*he,t=y?q:D*(1-e)+O*e,n=y?Y:t,r=y?k*(1-e)+A*e:X,i=y?re:S*(1-e)+C*e,a=y?Q:Math.sin(i),o=y?ae:Math.cos(i),s=y?j(e):ie,c=y?Math.sin(s):oe,l=y?Math.cos(s):se,u=x+ue(t,r,n);le=o*l*u,de=a*l*u,fe=c*u}let pe=0,_e=0,Se=0;{let e=+he,t=y?q:D*(1-e)+O*e,n=y?Y:t,r=y?k*(1-e)+A*e:X,i=y?re:S*(1-e)+C*e,a=y?Q:Math.sin(i),o=y?ae:Math.cos(i),s=y?j(e):ie,c=y?Math.sin(s):oe,l=y?Math.cos(s):se,u=x+ue(t,r,n);pe=o*l*u,_e=a*l*u,Se=c*u}for(let e=1;e<N-1;++e){let t=0,n=0,c=0;{let r=(e+1)*he,i=y?q:D*(1-r)+O*r,a=y?Y:i,o=y?k*(1-r)+A*r:X,s=y?re:S*(1-r)+C*r,l=y?Q:Math.sin(s),u=y?ae:Math.cos(s),d=y?j(r):ie,f=y?Math.sin(d):oe,p=y?Math.cos(d):se,m=x+ue(i,o,a);t=u*p*m,n=l*p*m,c=f*m}let l=t,u=n,f=c,p=pe,g=_e,_=Se;pe=l,_e=u,Se=f;{let t=be+e,n=t*V,r=p-F,i=g-I,a=_-L;B[n]=r,B[n+1]=i,B[n+2]=a,xe(r,i,a,M);let o=Math.round(e*ge),s=t*U;H[s]=y?ve:o,H[s+1]=y?o:ye}let w=le,T=de,N=fe;le=p,de=g,fe=_;let K=p,J=g,Z=_,Ce=1/Math.sqrt(K*K+J*J+Z*Z),we=Z*Ce,Te=0,Ee=0,De=0;if(me&&we*we<.999){let t=0,n=0,a=0;{let e=d===0?-1:1;t=e*(l-w),n=e*(u-T),a=e*(f-N)}{let c=e*he,l=y?q:D*(1-c)+O*c,u=y?Y:l,f=y?k*(1-c)+A*c:X,p=y?re:S*(1-c)+C*c,g=y?Q:Math.sin(p),_=y?ae:Math.cos(p),w=y?j(c):ie,T=y?Math.sin(w):oe,M=y?Math.cos(w):se,N=K,F=J,I=Z;if(R){let e=u-r,t=f-i,n=x+(ce?s(e,t,ce)??0:o(e,t,$)??0),a=y?v:g,c=y?b:_,l=y?T:te,d=y?M:ne;N=c*d*n,F=a*d*n,I=l*n}{let e=l+r,c=f+i,u=x+(G?s(e,c,G)??0:o(e,c,E)??0),p=y?m:g,v=y?h:_,b=y?T:P,S=y?M:z,C=v*S*u,w=p*S*u,D=b*u;R||(N=2*K-C,F=2*J-w,I=2*Z-D);let O=d===3?-1:1,k=O*(N-C),A=O*(F-w),j=O*(I-D);Te=a*A-n*j,Ee=t*j-a*k,De=n*k-t*A;let L=1/Math.sqrt(Te*Te+Ee*Ee+De*De);Te*=L,Ee*=L,De*=L}}}else Te=K*Ce,Ee=J*Ce,De=Z*Ce;a(ee,be+e,Te,Ee,De,W)}})()}}function A(e,t){re(e,t)}function j(e,t){return Math.PI/2-2*Math.atan(Math.exp(-e/t))}function M(e,t,n,r){return j(e*(1-r)+t*r,n)}function N(e,t,n){return e*(1-n)+t*n}function P(e){let{tile:t}=e;if(t.surface.isWebMercator){let e=t.extent,n=t.ellipsoid.radius;return t=>M(e[1],e[3],n,t)}let n=t.extentInRadians;return e=>N(n[1],n[3],e)}function F(e){let{tile:t,geometryState:n,geometry:i}=e,{extent:a,surface:o}=t,{wireframe:s}=n,c=a[0],l=a[1],u=a[2],d=a[3],f=u-c,p=d-l,{numVerticesPerSide:m,clippingArea:h}=n,g=h==null?0:Math.max(0,(h[0]-c)/f),_=h==null?0:Math.max(0,(h[1]-l)/p),v=h==null?1:Math.min(1,(h[2]-c)/f),y=h==null?1:Math.min(1,(h[3]-l)/p),b=(m-2)**2,x=Se(n),S=b+4*x,C=o.renderer.tileGeometryCache.acquire(S),{boundingBox:w}=i;r(w),i.numVerticesPerSide=m,i.vertexAttributes=C,i.maxEdgeVertexCount=x,i.minu=g,i.minv=_,i.maxu=v,i.maxv=y,I(e),i.edgeVerticesStartIndex=b,te(e),z(e,Te,Ee),W(i,[],s),e.intersectionData=null}function I(t){let r=t.tile;if(!r.intersectsClippingArea)return;let{geometry:i,geometryState:c,localOrigin:l}=t,{samplerData:u,clippingArea:d,numVerticesPerSide:f}=c,{surface:p,extent:m,ellipsoid:h}=r,{isWebMercatorOnPlateCarree:g}=p,_=d??he,v=m[0],y=m[1],b=m[2],x=m[3],S=Math.max(v,_[0]),C=Math.min(b,_[2]),w=Math.max(y,_[1]),T=Math.min(x,_[3]),E=h.radius,D=r.horizontalScale,O=f-1,k=f-2,{minu:A,minv:j,maxu:M,maxv:N,boundingBox:P,vertexAttributes:F}=i,{position:I,uv0:L}=F,{typedBuffer:R,typedBufferStride:z}=F.normalCompressed,B=l[0],V=l[1],H=l[2],U=I.typedBuffer,ee=I.typedBufferStride,W=0,G=e(y,w,T),K=g?(Math.PI/2-2*Math.atan(Math.exp(-G/E)))*E:G*D,q=1/O,J=e(y*(1-q)+x*q,w,T),Y=g?(Math.PI/2-2*Math.atan(Math.exp(-J/E)))*E:J*D,X=K,te=Y,Z=u?.length===1?u[0]:null,ne=Z?(e,t)=>s(e,t,Z)??0:(e,t)=>o(e,t,u)??0;for(let t=1;t<=k;t++){let r=t/O,i=e(y*(1-r)+x*r,w,T),o=e(r,j,N),s=te,c=(t-1)/O,l=e(y*(1-c)+x*c,w,T),u=X,d=(t+1)/O,f=e(y*(1-d)+x*d,w,T),p=g?(Math.PI/2-2*Math.atan(Math.exp(-f/E)))*E:f*D,m=e(d,j,N);X=te,te=p;let h=e(v,S,C),_=h*D,F=ne(h,i),I=1/O,G=e(I,A,M),K=e(v*(1-G)+b*G,S,C),q=G,J=K,Y=K*D,Z=ne(K,i);if(t===1){let t=Y-B,r=X-V,i=Z-H,a=0*ee;U[a]=t,U[a+1]=r,U[a+2]=i,xe(t,r,i,P);let s=e(I,A,M);L.setValues(W,Math.round(s*n),Math.round(o*n))}for(let r=1;r<=k;r++){let c=Y,d=Z,h=(r+1)/O,g=e(h,A,M),y=e(v*(1-h)+b*h,S,C),x=J;J=y;{let e=W+1,a=e*ee;if(t===1||r===k){let c=ne(y,i),l=y*D,u=s,d=c;if(t===1&&r<k){let t=l-B,r=u-V,i=d-H;U[a]=t,U[a+1]=r,U[a+2]=i,xe(t,r,i,P),L.setValues(e,Math.round(g*n),Math.round(o*n))}Y=l,Z=d}else Y=U[a]+B,Z=U[a+2]+H}let w=Y,T=Z,E=_,j=F;_=c,F=d;let N=(W-k)*ee,I=t===1?ne(x,l):U[N+2]+H,G=ne(x,f);if(t<k){let e=W+k,t=e*ee,r=c-B,i=p-V,a=G-H;U[t]=r,U[t+1]=i,U[t+2]=a,xe(r,i,a,P);let o=q;q=g,L.setValues(e,Math.round(o*n),Math.round(m*n))}{let e=w-E,t=T-j,n=u-p,r=I-G,i=n*t,o=e*r,s=-n*e,c=i*i+o*o+s*s;if(c===0)a(R,W,0,0,1,z);else{let e=1/Math.sqrt(c);a(R,W,i*e,o*e,s*e,z)}}++W}}}function L(e){e.tile.intersectsClippingArea&&(Z(e),z(e,Te,Ee),Q(e),ae(e),e.intersectionData=null)}function R(e,t=!1){e.tile.intersectsClippingArea&&(z(e,t?Te:e.dirtyEdges,t?Ee:e.dirtyCorners),Q(e),e.intersectionData=null)}function z(e,t,n){e.tile.intersectsClippingArea&&(n&&V(e,n),t&&B(e,t),(n||t)&&be(e.geometry.boundingBox))}function B(n,r){let{geometry:i,geometryState:a,localOrigin:c}=n,l=n.tile,{surface:d,extent:f}=l,{clippingArea:g,samplerData:_}=a,y=g??he,b=f[0],x=f[2],S=f[1],C=f[3],w=[C>y[3],x>y[2],S<y[1],b<y[0]],T=l.horizontalScale,E=ee(d.isWebMercatorOnPlateCarree,l.ellipsoid.radius,T),{minu:D,minv:O,maxu:k,maxv:A,boundingBox:j}=i,M=Math.max(b,y[0]),N=Math.min(x,y[2]),P=Math.max(S,y[1]),F=Math.min(C,y[3]),I=c[0],L=c[1],R=c[2],z=_?.length===1?_[0]:void 0,B=z?(e,t)=>s(e,t,z)??0:(e,t)=>o(e,t,_)??0;for(let c=0;c<4;++c){if(!(r&1<<c))continue;let f=c===1||c===3,g=a.edgeResolutions[c];p(t(g));let y=g+1,z=w[c],V=u(l,a.edgePeerNeighbors[c]);if(!z&&_e(l,V,c)&&ne(n,c,V))continue;let H=V!=null&&!z,U=V?.renderData?.geometryState;if(m&&(p(!H||V.level===l.level),p(!H||v(l,V)<=0),l&&!V&&!d.updatingRootTiles)){let e=h[c],t=l.findNeighborTile(e,e=>e.loaded||e.leaf||e.level===l.level);d.updatingRootTiles||(t?t.intersectsClippingArea&&(p(!t.loaded),p(!t.leaf),p(t.level===l.level)):p(d?.rootTiles==null||!l.shouldHaveNeighbor(e)))}let ee=e(c===1?x:b,M,N),W=e(c===0?C:S,P,F),G=U?.samplerData,K=e(+(c===1),D,k),q=e(+(c===0),O,A),J=G?.length===1?G[0]:null,Y=(e,t)=>J?s(e,t,J)??0:o(e,t,G)??0,X=H?(e,t)=>(Y(e,t)+B(e,t))*.5:B,te=(x-b)/g,Z=f?c===1?te:-te:0,re=f?0:c===0?te:-te,ie=-Z,Q=-re,ae=0,oe=0,se=0;{let t=0/g,n=f?ee:e(b*(1-t)+x*t,M,N),r=f?e(S*(1-t)+C*t,P,F):W,i=X(n,r);ae=n*T,oe=E(r),se=i}let $=0,ce=0,le=0;{let t=1/g,n=f?ee:e(b*(1-t)+x*t,M,N),r=f?e(S*(1-t)+C*t,P,F):W,i=X(n,r),a=n*T,o=E(r),s=i;$=a,ce=o,le=s}for(let t=1;t<y-1;++t){let n=t/g,r=$,a=ce,s=le;{let o=f?K:e(n,D,k),l=f?e(n,O,A):q,u=r-I,d=a-L,p=s-R;xe(u,d,p,j),i.setEdgeVertexFromValuesRawPositionUV(c,t,u,d,p,o,l)}{let n=(t+1)/g,r=f?ee:e(b*(1-n)+x*n,M,N),i=f?e(S*(1-n)+C*n,P,F):W,a=X(r,i);$=r*T,ce=E(i),le=a}let l=$,u=ce,d=le,p=ae,m=oe,h=se;ae=r,oe=a,se=s;let v=0,y=0,w=0;if(f){let t=u-a,i=d-s,l=m-a,f=h-s,p=e(S*(1-n)+C*n,P,F),g=ee+ie,b=p,x=g*T,E=o(g,b,_),D=x-r,O=E-s,k=c===3?-1:1;if(v=k*(-l+t)*O,y=k*D*(-f+i),w=-k*D*(-l+t),H){let e=ee+Z,n=p,a=e*T,c=o(e,n,G),u=a-r,d=c-s;v=(-l+t)*(O-d),y=(D-u)*(-f+i),w=-(D-u)*(-l+t)}}else{let t=l-r,i=d-s,u=p-r,f=h-s,m=e(b*(1-n)+x*n,M,N),g=m,S=W+Q,C=o(g,S,_)-s,T=E(S)-a,D=c===2?-1:1;if(v=D*T*(-f+i),y=D*(-u+t)*C,w=-D*T*(-u+t),H){let e=m,n=W+re,r=E(n),c=o(e,n,G)-s,l=r-a;v=(-T+l)*(-f+i),y=(-u+t)*(-C+c),w=-(-T+l)*(-u+t)}}let z=1/Math.sqrt(v*v+y*y+w*w);i.setEdgeNormalFromValues(c,t,v*z,y*z,w*z)}}}function V(e,t){re(e,t)}function H(e,t){return(Math.PI/2-2*Math.atan(Math.exp(-e/t)))*t}function U(e,t){return e*t}function ee(e,t,n){return e?e=>H(e,t):e=>U(e,n)}function W(e,t,n){let{numVerticesPerSide:r,vertexAttributes:i,maxEdgeVertexCount:a}=e,o=r-1,s=i.count,c=r-3,u=r-3,d=2*c*u,f=4*(o+a-3),p=l.reduce((t,n)=>t+(o+e.getEdgeCount(n)-3),0),m=t.reduce((e,t)=>e+o*((t.latitudeResolution-1)*2+1),0),h=3*(n?2:1),g=(d+f+m)*h;e.indices=s>=65536?new Uint32Array(g):new Uint16Array(g),e.indexCount=(d+p+m)*h,e.poleIndicesStartIndex=d*h,e.edgeIndicesStartIndex=(d+m)*h,n?(J(e),Y(e,t),X(e)):(G(e),K(e,t),q(e))}function G(e){let{numVerticesPerSide:t,indices:n,vertexAttributes:r}=e,{position:i}=r,{typedBuffer:a,typedBufferStride:o}=i,s=t-2,c=t-3,l=t-3,u=0;for(let e=0;e<c;++e){let t=e*s;for(let e=0;e<l;++e){let r=t+e,i=r+1,c=i+s,l=c-1;Ce(r,i,c,l,o,a)?(n[u]=r,n[u+1]=i,n[u+2]=c,n[u+3]=c,n[u+4]=l,n[u+5]=r):(n[u]=r,n[u+1]=i,n[u+2]=l,n[u+3]=l,n[u+4]=i,n[u+5]=c),u+=6}}}function K(e,t){let{numVerticesPerSide:n,indices:r,poleIndicesStartIndex:i}=e,a=n-1,o=i;for(let i of t){let t=i.isNorth?1:2,s=i.isNorth?2:1,c=i.isNorth?3:4,l=i.isNorth?4:3,u=e.getEdgeVertexIndex(i.connectedOuterEdgeOffset,0),d=1;for(let e=0;e<i.latitudeResolution;++e){let f=e===0?i.rowOffset:u+n;for(let n=0;n<a;n++){let a=f+n;r[o]=u,r[o+t]=u+1,r[o+s]=a,e<i.latitudeResolution-1?(r[o+c]=u+1,r[o+l]=a+1,r[o+5]=a,o+=6):o+=3,u+=d}u=f,d=1}}}function q(e){let{indices:t,numVerticesPerSide:n,edgeIndicesStartIndex:r}=e,i=n-1,a=i-2,o=r;for(let n=0;n<4;++n){let r=ye[n],s=0,c=0,l=e.getEdgeCount(n),u=r.count;p(u===i-1);let d=n===1||n===2,f=d?1:2,m=d?2:1,h=e.getEdgeFirstVertexIndex(n),g=r.vertex0Index,_=r.stride;for(;s<l-1||c<u-1;){let e=g+c*_,n=h+s*1,r=s<l-1,d=c<u-1,p=r?0+i*(s+.5)/(l-1):0,v=d?1+a*(c+.5)/(u-1):0,y=r&&(!d||p<=v);y?++s:++c;let b=y?n+1:e+_;t[o]=e,t[o+f]=n,t[o+m]=b,o+=3}}e.indexCount=o}function J(e){let{indices:t,numVerticesPerSide:n,vertexAttributes:r}=e,{position:i}=r,{typedBuffer:a,typedBufferStride:o}=i,s=n-2,c=0;for(let e=0;e<n-3;++e){let r=e*s;for(let i=0;i<n-3;++i){let n=e*s+i,l=n+1,u=l+s,d=u-1,f=r+i,p=f+1,m=p+s;Ce(f,p,m,m-1,o,a)?(we(t,c,n,l,u),c+=6,we(t,c,u,d,n)):(we(t,c,n,l,d),c+=6,we(t,c,d,u,l)),c+=6}}}function Y(e,t){let{indices:n,numVerticesPerSide:r,poleIndicesStartIndex:i}=e,a=r-1,o=i;for(let i of t){let t=i.connectedOuterEdgeOffset,s=e.getEdgeVertexIndex(t,0),c=1;for(let e=0;e<i.latitudeResolution;++e){let t=e===0?i.rowOffset:s+r;for(let r=0;r<a;r++)we(n,o,s,s+1,t+r),o+=6,e<i.latitudeResolution-1&&(we(n,o,s+1,t+r+1,t+r),o+=6),s+=c;s=t,c=1}}}function X(e){let{indices:t,numVerticesPerSide:n,edgeIndicesStartIndex:r}=e,i=n-1,a=i-2,o=r;for(let n=0;n<4;++n){let r=ye[n],s=0,c=0,l=e.getEdgeCount(n),u=r.count;p(u===i-1);let d=n===1||n===2,f=d?1:3,m=d?3:1,h=e.getEdgeFirstVertexIndex(n),g=r.vertex0Index,_=r.stride;for(;s<l-1||c<u-1;){let e=g+c*_,n=h+s*1,r=s<l-1,d=c<u-1,p=r?0+i*(s+.5)/(l-1):0,v=d?1+a*(c+.5)/(u-1):0,y=r&&(!d||p<=v);y?++s:++c;let b=y?n+1:e+_;t[o]=e,t[o+f]=n,t[o+f+1]=n,t[o+m]=b,t[o+m+1]=b,t[o+5]=e,o+=6}}e.indexCount=o}function te(e){let{geometry:t,geometryState:n}=e,{edgeResolutions:r}=n,{numVerticesPerSide:i,edgeVerticesStartIndex:a}=t,o=i-2,s=a;for(let e=0;e<4;++e){{let t=e===1?o-1:0,n=e===0?o-1:0,r=e===0||e===2,i=+!!r,a=+!r,s=n*o+t,c=a*o+i,l=ye[e];l.vertex0Index=s,l.stride=c,l.count=o}{let n=r[e]+1;t.outerEdgesOffsetAndLength[e*2+0]=s,t.outerEdgesOffsetAndLength[e*2+1]=n,s+=n}}}function Z(e){te(e),e.geometryState.wireframe?X(e.geometry):q(e.geometry)}function ne(r,i,a){let{geometryState:o,geometry:s,tile:c,localOrigin:l}=r,u=i===1||i===3,d=o.edgeResolutions[i];p(t(d));let f=d+1,{boundingBox:m,minu:h,minv:g,maxu:_,maxv:v,vertexAttributes:y}=s,b=e(+(i===1),h,_),x=e(+(i===0),g,v),S=a.renderData,C=S.geometryState;if(!C||!S.geometry.vertexAttributes)return!1;let w=S.geometry,T=(i+2)%4,E=w.getEdgeCount(T),D=c.getNeighborEdgeStartVertexIndex(i,a)*d,O=d*2**(c.level-a.level);p(C.edgeResolutions[T]===O),p(E-1===O);let k=S.localOrigin[0]-l[0],A=S.localOrigin[1]-l[1],j=S.localOrigin[2]-l[2],M=s.getEdgeFirstVertexIndex(i),{position:N,uv0:P}=y,F=N.typedBuffer,I=N.typedBufferStride,L=y.normalCompressed,R=L.typedBuffer,z=L.typedBufferStride,B=w.vertexAttributes,V=w.getEdgeFirstVertexIndex(T),H=B.position.typedBuffer,U=B.position.typedBufferStride,ee=B.normalCompressed.typedBuffer,W=B.normalCompressed.typedBufferStride;for(let t=1;t<f-1;++t){let r=D+t,i=M+t,a=V+r,o=i*I,s=a*U,c=H[s]+k,l=H[s+1]+A,f=H[s+2]+j;F[o]=c,F[o+1]=l,F[o+2]=f,xe(c,l,f,m);let p=i*z,y=a*W;R[p]=ee[y],R[p+1]=ee[y+1];let S=t/d,C=u?b:e(S,h,_),w=u?e(S,g,v):x;P.setValues(i,Math.round(C*n),Math.round(w*n))}return!0}function re(t,r){let{geometry:i,geometryState:a,localOrigin:s}=t,{clippingArea:c,samplerData:l}=a,{minu:u,minv:d,maxu:f,maxv:m,boundingBox:h,vertexAttributes:g}=i,_=t.tile,{surface:y,ellipsoid:b,extent:x,extentInRadians:S,horizontalScale:C}=_,w=y.view?.viewingMode===`local`,T=b.radius,E=0,D=0,O=0,k=w?(()=>{let t=c,n=t!=null&&(x[3]>t[3]||x[2]>t[2]||x[1]<t[1]||x[0]<t[0]),r=ee(y.isWebMercatorOnPlateCarree,T,C);return(i,a,o)=>{let s=i===0?x[0]:x[2],c=a===0?x[1]:x[3],l=n?e(s,t[0],t[2]):s,u=n?e(c,t[1],t[3]):c,d=o;E=l*C,D=r(u),O=d}})():(e,t,n)=>{let r=S[t===0?1:3],i=S[e===0?0:2],a=Math.cos(r),o=Math.sin(r),s=Math.sin(i),c=Math.cos(i),l=T+n;E=c*a*l,D=s*a*l,O=o*l},A=0,j=0,M=0,N=0,F=0,I=0,L=0,R=0,z=0,B=w&&y.isWebMercatorOnPlateCarree,V=(e,t,n,r,i)=>{let a=0,o=0,s=0;if(w){let e=t*C,i=B?(Math.PI/2-2*Math.atan(Math.exp(-n/T)))*T:n*C,c=r;a=e-E,o=i-D,s=c-O}else{let i=P(e),c=e.tile,l=c.extent,u=c.extentInRadians,d=(t-l[0])/(l[2]-l[0]),f=(n-l[1])/(l[3]-l[1]),p=u[0]*(1-d)+u[2]*d,m=i(f),h=Math.cos(m),g=Math.sin(m),_=Math.sin(p),v=Math.cos(p),y=T+r,b=v*h*y,x=_*h*y,S=g*y;a=b-E,o=x-D,s=S-O}switch(i){case 0:L+=a,R+=o,z+=s;break;case 1:N-=a,F-=o,I-=s;break;case 2:L-=a,R-=o,z-=s;break;case 3:N+=a,F+=o,I+=s}},H=c??he,U=x[0],W=x[2],G=x[1],K=x[3],q=[K>H[3],W>H[2],G<H[1],U<H[0]],J=Math.max(U,H[0]),Y=Math.min(W,H[2]),X=Math.max(G,H[1]),te=Math.min(K,H[3]),Z=e=>Math.max(H[0],Math.min(H[2],e)),ne=e=>Math.max(H[1],Math.min(H[3],e)),re=e=>{let t=a.cornerNeighborCornerTiles;A=0,j=0,M=1,N=0,F=0,I=0,L=0,R=0,z=0;let n=1/0;for(let r=0;r<4;++r){let i=t[e*4+r];n=Math.min(n,i?.level??1/0)}for(let r=0;r<4;++r){let i=t[e*4+r];ge[r]=i?.level===n?i:null}let r=1,i=0;for(let e=0;e<4;++e){let t=ge[e];t&&(r=Math.max(r,t?.renderData.geometryState.numVerticesPerSide),i=t.extent[2]-t.extent[0])}let s=i,c=r;p(c>1);let l=s/c;for(let e=0;e<4;++e){let t=ge[(e+3)%4],n=ge[e%4];if(!t&&!n)continue;let r=e===0?1:e===1?2:e===2?3:0,i=e===0?2:e===1?3:e===2?0:1;if(t&&n){let a=se[e][0]*l,s=se[e][1]*l,c=t.extent,u=Z(c[r===0||r===1?2:0]+a),d=ne(c[r===0||r===3?3:1]+s),f=n.extent,p=Z(f[i===0||i===1?2:0]+a),m=ne(f[i===0||i===3?3:1]+s),h=t.renderData,g=n.renderData,_=o(u,d,h.geometryState.samplerData),v=o(p,m,g.geometryState.samplerData);V(h,u,d,.5*(_+v),e)}else{let a=t??n,s=t?r:i,c=a.extent,u=se[e],d=Z(c[s===0||s===1?2:0]+u[0]*l),f=ne(c[s===0||s===3?3:1]+u[1]*l),p=a.renderData,m=o(d,f,p.geometryState.samplerData);V(p,d,f,m,e)}}if(!w){let e=Math.sqrt(E*E+D*D+O*O);A=E/e,j=D/e,M=O/e}if(w||M*M<.999){let e=Math.sqrt(N*N+F*F+I*I);N/=e,F/=e,I/=e;let t=Math.sqrt(L*L+R*R+z*z);L/=t,R/=t,z/=t,A=I*R-F*z,j=N*z-I*L,M=F*L-N*R;let n=1/Math.sqrt(A*A+j*j+M*M);A*=n,j*=n,M*=n}},Q=a.cornerNeighborCornerTiles;for(let t=0;t<4;++t){if(!(r&1<<t))continue;let c=t,y=(t+1)%4,b=+(t===0||t===1),x=+(t===0||t===3),S=e(b,u,f),C=e(x,d,m),w=i.getEdgeFirstVertexIndex(c),T=i.getEdgeCount(c),N=t===0||t===3?T-1:0,P=i.getEdgeFirstVertexIndex(y),F=i.getEdgeCount(y),I=t===0||t===1?F-1:0,L=-1;for(let e=0;e<4;++e){let n=Q[t*4+e],r=Q[t*4+L];n&&(L===-1||v(r,n)>0)&&(L=e)}let R=L,z=Q[t*4+R];if(z!==_){let e=_.level-z.level,r=2**e,i=[z.lij[0]+e,z.lij[1]*r,z.lij[2]*r],o=[i[1]+r===_.lij[1],t===0&&(R===1||R===0&&z!==Q[t*4+3])||t===1&&(R===0||R===1&&z!==Q[t*4+2]),i[1]===_.lij[1]+1,t===2&&(R===3||R===2&&z!==Q[t*4+1])||t===3&&(R===2||R===3&&z!==Q[t*4+0])],c=o.reduce((e,t)=>e+ +!!t,0);p(c===1||c===2);let l=-1,u=-1,d=z.renderData;if(c===1){let e=o.findIndex(e=>e);p(0<=e&&e<=3),l=(e+2)%4;let n=a.edgeResolutions[e];u=_.getNeighborEdgeStartVertexIndex(e,z)*n+n*+(e===0&&t===0||e===1&&t===0||e===2&&t===1||e===3&&t===3)}else{p(o[1]||o[3]),l=o[1]?3:1;let e=d.geometryState.edgeResolutions[l];u=t===0||t===3?0:e}let f=d.geometry;{let e=w+N,t=P+I,r=f.getEdgeFirstVertexIndex(l)+u,i=f.vertexAttributes,a=d.localOrigin,o=i.position,c=o.typedBuffer,p=r*o.typedBufferStride,m=c[p]+a[0]-s[0],_=c[p+1]+a[1]-s[1],v=c[p+2]+a[2]-s[2];xe(m,_,v,h);let y=g.position,b=y.typedBuffer,x=e*y.typedBufferStride;b[x]=m,b[x+1]=_,b[x+2]=v;let T=t*y.typedBufferStride;b[T]=m,b[T+1]=_,b[T+2]=v;let E=g.uv0;E.setValues(e,Math.round(S*n),Math.round(C*n)),E.setValues(t,Math.round(S*n),Math.round(C*n));{let n=i.normalCompressed.typedBuffer,a=r*i.normalCompressed.typedBufferStride,o=g.normalCompressed,s=o.typedBuffer;{let t=e*o.typedBufferStride;s[t]=n[a],s[t+1]=n[a+1]}{let e=t*o.typedBufferStride;s[e]=n[a],s[e+1]=n[a+1]}}}}else{let n=q[c],r=q[y],a;if(n||r){let t=e(U*(1-b)+W*b,J,Y),n=e(G*(1-x)+K*x,X,te);a=o(t,n,l)}else a=ie(Q,t);k(b,x,a),re(t);let u=E-s[0],d=D-s[1],f=O-s[2];xe(u,d,f,h),i.setEdgeVertexFromValuesRawPositionUVNormal(c,N,u,d,f,S,C,A,j,M),i.setEdgeVertexFromValuesRawPositionUVNormal(y,I,u,d,f,S,C,A,j,M)}}for(let e=0;e<4;++e)ge[e]=null}function ie(e,t){let n=t*4,r=l.reduce((t,r)=>Math.min(t,e[n+r]?.level??1/0),1/0);m&&(p(!e[n+0]||!e[n+2]||_(e[n+0],e[n+2],5)),p(!e[n+1]||!e[n+3]||_(e[n+1],e[n+3],7)));let i=0,a=0;for(let t=0;t<4;++t){let s=e[n+t];if(s?.level===r){let e=t===0||t===1,n=t===0||t===3,r=s.extent,c=r[e?0:2],l=r[n?1:3],u=s.renderData?.geometryState?.samplerData,d=o(c,l,u);a+=d,i++}}let s=i?a/i:0;return p(s!=null),s}function Q(e){let{vao:t,geometry:n}=e,{vertexAttributes:r,edgeVerticesStartIndex:i}=n,{position:a}=r,o=a.typedBuffer,s=i*a.typedBufferStride,c=(n.getEdgeFirstVertexIndex(3)+n.getEdgeCount(3))*a.typedBufferStride;t.buffer()?.setSubData(o,s,s,c)}function ae(e){let{vao:t,geometry:n}=e,{indices:r,indexCount:i,edgeIndicesStartIndex:a}=n;t.indexBuffer.setSubData(r,a,a,i)}class oe{constructor(e,t,n,r,i){this.isNorth=e,this.connectedRowOffset=t,this.connectedOuterEdgeOffset=n,this.rowOffset=r,this.latitudeResolution=i}}const se=[[0,1],[1,0],[0,-1],[-1,0]],$=new c,ce=.5*f,le=new Uint16Array(d+1),ue=new Int32Array(d+1),de=new Int32Array(d+1),fe=new Int32Array(d+1),pe=new Float64Array(d+1),me=new Float64Array(d+1),he=i(-1/0,-1/0,1/0,1/0),ge=[null,null,null,null];function _e(e,t,n){if(!t)return!1;let r=v(e,t);return r>0||r===0&&n>=2}class ve{constructor(){this.vertex0Index=0,this.stride=1,this.count=0}getVertexIndex(e){return p(0<=e&&e<this.count),this.vertex0Index+this.stride*e}}const ye=[new ve,new ve,new ve,new ve];function be(e){for(let t=0;t<3;t++)e[t]=Math.min(e[t],Math.fround(e[t])),e[t+3]=Math.max(e[t+3],Math.fround(e[t+3]))}function xe(e,t,n,r){r[0]=Math.min(r[0],e),r[3]=Math.max(r[3],e),r[1]=Math.min(r[1],t),r[4]=Math.max(r[4],t),r[2]=Math.min(r[2],n),r[5]=Math.max(r[5],n)}function Se(e){let{edgeResolutions:t,numVerticesPerSide:n}=e,r=1+Math.max(...t);return Math.max(n,r)}function Ce(e,t,n,r,i,a){let o=e*i,s=a[o],c=a[o+1],l=a[o+2],u=t*i,d=a[u],f=a[u+1],p=a[u+2],m=n*i,h=a[m],g=a[m+1],_=a[m+2],v=r*i,y=a[v],b=a[v+1],x=a[v+2],S=(s-h)*(s-h)+(c-g)*(c-g)+(l-_)*(l-_);return(d-y)*(d-y)+(f-b)*(f-b)+(p-x)*(p-x)>S}function we(e,t,n,r,i){e[t]=n,e[t+1]=r,e[t+2]=r,e[t+3]=i,e[t+4]=i,e[t+5]=n}const Te=15,Ee=15,De=6;export{F as createPlanarGlobePatch,y as createSphericalGlobePatch,L as updateEdgeElevationsAndResolutionsPlanar,D as updateEdgeElevationsAndResolutionsSpherical,R as updateEdgesAndCornersPlanar,E as updateEdgesAndCornersSpherical};
2
+ import{clamp as e,isPowerOfTwo as t}from"../../../core/mathUtils.js";import{maxUint16 as n}from"../../../core/typedArrayUtil.js";import{empty as r}from"../../../geometry/support/aaBoundingBox.js";import{fromValues as i}from"../../../geometry/support/aaBoundingRect.js";import{compressNormal as a}from"../webgl-engine/lib/Normals.js";import{sampleElevation as o,sampleSingleElevation as s}from"./ElevationData.js";import{PatchGeometryLUT as c}from"./PatchGeometryLUT.js";import{zeroToFour as l,neighborTileIfLoadedOrSelf as u}from"./PatchRenderData.js";import{maxPatchTesselation as d,elevationNoDataValue as f}from"./TerrainConst.js";import{internalAssert as p,enableTerrainInternalChecks as m,neighborEdgeIndices as h,almostEquals as g}from"./terrainUtils.js";import{isCornerNeighbor as _}from"./Tile.js";import{compareTilesByLij as v}from"./tileUtils.js";function y(e,t){let{tile:n,geometry:i,geometryState:a}=e,{extentInRadians:o,surface:s}=n,{isWebMercator:c,renderer:l}=s,{numVerticesPerSide:u,wireframe:d}=a,f=u-1,p=(u-2)**2,m=c&&(t===2||t===3),h=c&&(t===1||t===3),g=(+!!m+ +!!h)*De*u,_=Se(a),v=4*_,y=p+g+v,S=l.tileGeometryCache.acquire(y);i.numVerticesPerSide=u,i.vertexAttributes=S,i.maxEdgeVertexCount=_;let{boundingBox:C}=i;r(C);let w=P(e);$.update(f,o,w),x(e),i.poleVerticesStartIndex=p;let T=b(e,m,h);i.edgeVerticesStartIndex=p+g,ne(e),O(e,Te,Ee),W(i,T,d),e.intersectionData=null}function b(e,t,r){let{tile:i,localOrigin:o,geometry:s}=e,{extent:c,ellipsoid:l}=i,{boundingBox:u,numVerticesPerSide:d,vertexAttributes:f,poleVerticesStartIndex:p}=s,m=d-1,h=o[0],g=o[1],_=o[2],v=l.radius,y=c[1],b=c[3],x=[],S=p,C=(e,t)=>{let r=t*d;xe(-h,-g,-_+e*v,u),x.push(new Q(e===1,r,e===1?0:2,S,De));let i=j(e===-1?y:b,v),o=e*Math.PI/2-i,s=(e===1?1:-1)*.99,c=v+0,{position:l,uv0:p}=f,{typedBuffer:C,typedBufferStride:w}=f.normalCompressed;for(let e=1;e<=De;++e){let t=i+e/De*o,r=Math.cos(t),d=Math.sin(t);for(let e=0;e<=m;e++){let t=e/m,i=$.sinLonLUT[e],o=$.cosLonLUT[e]*r,f=i*r,v=d,y=o*c-h,b=f*c-g,x=v*c-_;xe(y,b,x,u),l.setValues(S,y,b,x),p.setValues(S,Math.round(t*n),Math.round(s*n)),a(C,S,o,f,v,w),++S}}};return t&&C(-1,0),r&&C(1,m),x}function x(e){let t=e.geometryState.samplerData,n=t?.length===1?t[0]:null;n?S(e,n):C(e)}function S(e,t){let{tile:n}=e;if(!n.intersectsClippingArea)return;let{geometry:r,geometryState:i,localOrigin:o}=e,{numVerticesPerSide:s}=i,c=s-2,l=s-1,{vertexAttributes:u,boundingBox:d}=r,{position:f,uv0:p}=u,{typedBuffer:m,typedBufferStride:h}=u.normalCompressed,{extent:g}=n,_=n.ellipsoid.radius,v=o[0],y=o[1],b=o[2],x=f.typedBuffer,S=f.typedBufferStride,C=p.typedBuffer,E=p.typedBufferStride;w(l,g,t);let D=0,O=t.data.values;if(1<=c){let e=le[1],t=$.sinLatLUT[1],n=$.cosLatLUT[1];for(let r=1;r<=c;r++){let i=$.sinLonLUT[r],a=$.cosLonLUT[r],o=_+T(r,1,O),s=-v+o*a*n,c=-y+o*i*n,l=-b+o*t;xe(s,c,l,d);let u=(r-1)*S;x[u]=s,x[u+1]=c,x[u+2]=l;let f=(r-1)*E;C[f]=le[r],C[f+1]=e}}for(let e=1;e<=c;e++){let t=$.sinLatLUT[e],n=$.cosLatLUT[e],r=e+1,i=le[r],o=$.sinLatLUT[r],s=$.cosLatLUT[r],u=$.sinLonLUT[0],f=$.cosLonLUT[0],p=_+T(0,e,O),g=f*n*p-v,w=u*n*p-y,k=t*p-b,A=D*S,j=x[A],M=x[A+1],N=x[A+2];for(let u=1;u<=c;u++){let f=$.sinLonLUT[u],p=$.cosLonLUT[u],A=0,P=0,F=0;if(u<c){let e=(D+1)*S;A=x[e],P=x[e+1],F=x[e+2]}else{let r=$.sinLonLUT[l],i=$.cosLonLUT[l],a=_+T(l,e,O);A=i*n*a-v,P=r*n*a-y,F=t*a-b}let I=g,L=w,R=k;g=j,w=M,k=N,j=A,M=P,N=F;let z=A-I,B=P-L,V=F-R,H=0,U=0,ee=0;if(e>1){let e=(D-c)*S;H=x[e],U=x[e+1],ee=x[e+2]}else{let e=$.sinLatLUT[0],t=$.cosLatLUT[0],n=_+T(u,0,O);H=p*t*n-v,U=f*t*n-y,ee=e*n-b}let W=_+T(u,r,O),G=p*s*W-v,K=f*s*W-y,q=o*W-b;if(e<c){let e=D+c,t=e*S;x[t]=G,x[t+1]=K,x[t+2]=q,xe(G,K,q,d);let n=e*E;C[n]=le[u],C[n+1]=i}let J=H-G,Y=U-K,te=ee-q,ne=p*n,X=f*n,re=t;re*re<.999&&(ne=V*Y-B*te,X=z*te-V*J,re=B*J-z*Y),a(m,D,ne,X,re,h),++D}}}function C(e){let{tile:t}=e;if(!t.intersectsClippingArea)return;let{geometry:r,geometryState:i,localOrigin:s}=e,{numVerticesPerSide:c,samplerData:l}=i,u=c-2,d=c-1,{vertexAttributes:f,boundingBox:p}=r,{position:m,uv0:h}=f,{typedBuffer:g,typedBufferStride:_}=f.normalCompressed,{extent:v}=t,y=v[0],b=v[2],x=v[1],S=v[3],C=t.ellipsoid.radius,w=s[0],T=s[1],E=s[2],D=m.typedBuffer,O=m.typedBufferStride,k=1/d,A=0;if(1<=u){let e=k,t=x*(1-e)+S*e,r=$.sinLatLUT[1],i=$.cosLatLUT[1];for(let a=1;a<=u;a++){let s=a*k,c=y*(1-s)+b*s,u=$.sinLonLUT[a],d=$.cosLonLUT[a],f=C+o(c,t,l),m=-w+f*d*i,g=-T+f*u*i,_=-E+f*r;xe(m,g,_,p);let v=(a-1)*O;D[v]=m,D[v+1]=g,D[v+2]=_,h.setValues(a-1,Math.round(s*n),Math.round(e*n))}}for(let e=1;e<=u;e++){let t=e*k,r=x*(1-t)+S*t,i=$.sinLatLUT[e],s=$.cosLatLUT[e],c=e+1,f=c*k,m=x*(1-f)+S*f,v=$.sinLatLUT[c],j=$.cosLatLUT[c],M=$.sinLonLUT[0],N=$.cosLonLUT[0],P=C+o(y,r,l),F=N*s*P-w,I=M*s*P-T,L=i*P-E,R=A*O,z=D[R],B=D[R+1],V=D[R+2];for(let t=1;t<=u;t++){let c=t*k,S=y*(1-c)+b*c,M=$.sinLonLUT[t],N=$.cosLonLUT[t],P=0,R=0,H=0;if(t<u){let e=(A+1)*O;P=D[e],R=D[e+1],H=D[e+2]}else{let e=$.sinLonLUT[d],t=$.cosLonLUT[d],n=C+o(b,r,l);P=t*s*n-w,R=e*s*n-T,H=i*n-E}let U=F,ee=I,W=L;F=z,I=B,L=V,z=P,B=R,V=H;let G=P-U,K=R-ee,q=H-W,J=0,Y=0,te=0;if(e>1){let e=(A-u)*O;J=D[e],Y=D[e+1],te=D[e+2]}else{let e=$.sinLatLUT[0],t=$.cosLatLUT[0],n=C+o(S,x,l);J=N*t*n-w,Y=M*t*n-T,te=e*n-E}let ne=C+o(S,m,l),X=N*j*ne-w,re=M*j*ne-T,Z=v*ne-E;if(e<u){let e=A+u,t=e*O;D[t]=X,D[t+1]=re,D[t+2]=Z,xe(X,re,Z,p),h.setValues(e,Math.round(c*n),Math.round(f*n))}let ie=J-X,ae=Y-re,oe=te-Z,Q=N*s,se=M*s,ce=i;ce*ce<.999&&(Q=q*ae-K*oe,se=G*oe-q*ie,ce=K*ie-G*ae);let le=1/Math.sqrt(Q*Q+se*se+ce*ce);a(g,A,Q*le,se*le,ce*le,_),++A}}}function w(t,r,i){let a=r[0],o=r[2],s=r[1],c=r[3],l=1/t,{dx:u,dy:d,x0:f,y1:p,safeWidth:m}=i,h=i.data.width;for(let r=0;r<=t;r++){let t=r*l,i=e(u*(a*(1-t)+o*t-f),0,m),g=Math.floor(i);ue[r]=g,pe[r]=i-g;let _=e(d*(p-(s*(1-t)+c*t)),0,m),v=Math.floor(_);de[r]=v*h,fe[r]=(v+1)*h,me[r]=_-v,le[r]=Math.round(t*n)}}function T(e,t,n){let r=ue[e],i=pe[e],a=de[t],o=fe[t],s=me[t],c=a+r,l=n[c],u=n[c+1],d=n[o+r],f=n[o+r+1];if(l+d+u+f>=ce)return 0;let p=l+(u-l)*i;return p+(d+(f-d)*i-p)*s}function E(e,t=!1){e.tile.intersectsClippingArea&&(O(e,t?Te:e.dirtyEdges,t?Ee:e.dirtyCorners),ae(e),e.intersectionData=null)}function D(e){e.tile.intersectsClippingArea&&(X(e),O(e,Te,Ee),ae(e),oe(e),e.intersectionData=null)}function O(e,t,n){e.tile.intersectsClippingArea&&(n&&A(e,n),t&&k(e,t),(n||t)&&be(e.geometry.boundingBox))}function k(e,r){let{geometry:i,geometryState:c,tile:l,localOrigin:d}=e,{level:f,extent:_,extentInRadians:y,ellipsoid:b}=l,x=b.radius,S=y[0],C=y[2],w=y[1],T=y[3],{samplerData:E}=c,D=_[0],O=_[2],k=_[1],A=_[3],j=P(e),{boundingBox:M,vertexAttributes:N}=i,F=d[0],I=d[1],L=d[2],{position:R,uv0:z}=N,B=R.typedBuffer,V=R.typedBufferStride,H=z.typedBuffer,U=z.typedBufferStride,{typedBuffer:ee,typedBufferStride:W}=N.normalCompressed,G=E?.length===1?E[0]:null,K=(e,t,n)=>G?s(e,t,G)??0:o(e,t,E)??0;for(let d=0;d<4;++d){if(!(r&1<<d))continue;let y=d===1||d===3,b=c.edgeResolutions[d];p(t(b));let N=b+1,P=u(l,c.edgePeerNeighbors[d]);if(_e(l,P,d)&&re(e,d,P))continue;let R=P!=null;p(!R||P.level===l.level),p(!R||v(l,P)<=0);let z=P?.renderData?.geometryState;if(m){let e=l.surface;if(!P&&e&&!e.updatingRootTiles){let t=h[d],n=l.findNeighborTile(t,e=>e.loaded||e.leaf||e.level===l.level);n?n.intersectsClippingArea&&(p(!n.loaded),p(!n.leaf),p(n.level===f)):p(e?.rootTiles==null||!l.shouldHaveNeighbor(t))}}let q=d===1?_[2]:_[0],J=P?.extent,Y=J&&y?d===1?J[0]:J[2]:q,te=d===0?_[3]:_[1],ne=+(d===1),X=+(d===0),Z=d===1?C:S,ie=d===0?T:w,ae=Math.sin(Z),oe=Math.cos(Z),Q=Math.sin(ie),se=Math.cos(ie),$=z?.samplerData,ce=$?.length===1?$[0]:null,le=(e,t,n)=>ce?s(n,t,ce)??0:o(n,t,$)??0,ue=R?(e,t,n)=>(K(e,t)+le(e,t,n))*.5:K,de=i.outerEdgesOffsetAndLength[d*2+0],fe=G!=null||E!=null&&E.some(e=>e!=null),pe=ce!=null||$!=null&&$.some(e=>e!=null),me=fe||pe,he=1/b,ge=n*he,ve=ne*n,ye=X*n,be=de;p(!J||g(J[2]-J[0],_[2]-_[0])),(()=>{let e=d===1?-1:+(d===3),t=d===0?-1:+(d===2),n=(_[2]-_[0])*he,r=e*n,i=t*n,c=C-S,l=y?c*he*e:0,u=y?0:t*he,f=X,p=y?Z+l:Z,m=y?Math.sin(p):ae,h=y?Math.cos(p):oe,g=y?Z-l:Z,v=y?Math.sin(g):ae,b=y?Math.cos(g):oe,w=f+u,T=y?ie:j(w),P=y?Q:Math.sin(T),z=y?se:Math.cos(T),K=f-u,J=y?ie:j(K),ne=y?Q:Math.sin(J),re=y?se:Math.cos(J),le=0,de=0,fe=0;{let e=0*he,t=y?q:D*(1-e)+O*e,n=y?Y:t,r=y?k*(1-e)+A*e:te,i=y?Z:S*(1-e)+C*e,a=y?ae:Math.sin(i),o=y?oe:Math.cos(i),s=y?j(e):ie,c=y?Math.sin(s):Q,l=y?Math.cos(s):se,u=x+ue(t,r,n);le=o*l*u,de=a*l*u,fe=c*u}let pe=0,_e=0,Se=0;{let e=+he,t=y?q:D*(1-e)+O*e,n=y?Y:t,r=y?k*(1-e)+A*e:te,i=y?Z:S*(1-e)+C*e,a=y?ae:Math.sin(i),o=y?oe:Math.cos(i),s=y?j(e):ie,c=y?Math.sin(s):Q,l=y?Math.cos(s):se,u=x+ue(t,r,n);pe=o*l*u,_e=a*l*u,Se=c*u}for(let e=1;e<N-1;++e){let t=0,n=0,c=0;{let r=(e+1)*he,i=y?q:D*(1-r)+O*r,a=y?Y:i,o=y?k*(1-r)+A*r:te,s=y?Z:S*(1-r)+C*r,l=y?ae:Math.sin(s),u=y?oe:Math.cos(s),d=y?j(r):ie,f=y?Math.sin(d):Q,p=y?Math.cos(d):se,m=x+ue(i,o,a);t=u*p*m,n=l*p*m,c=f*m}let l=t,u=n,f=c,p=pe,g=_e,_=Se;pe=l,_e=u,Se=f;{let t=be+e,n=t*V,r=p-F,i=g-I,a=_-L;B[n]=r,B[n+1]=i,B[n+2]=a,xe(r,i,a,M);let o=Math.round(e*ge),s=t*U;H[s]=y?ve:o,H[s+1]=y?o:ye}let w=le,T=de,N=fe;le=p,de=g,fe=_;let K=p,J=g,X=_,Ce=1/Math.sqrt(K*K+J*J+X*X),we=X*Ce,Te=0,Ee=0,De=0;if(me&&we*we<.999){let t=0,n=0,a=0;{let e=d===0?-1:1;t=e*(l-w),n=e*(u-T),a=e*(f-N)}{let c=e*he,l=y?q:D*(1-c)+O*c,u=y?Y:l,f=y?k*(1-c)+A*c:te,p=y?Z:S*(1-c)+C*c,g=y?ae:Math.sin(p),_=y?oe:Math.cos(p),w=y?j(c):ie,T=y?Math.sin(w):Q,M=y?Math.cos(w):se,N=K,F=J,I=X;if(R){let e=u-r,t=f-i,n=x+(ce?s(e,t,ce)??0:o(e,t,$)??0),a=y?v:g,c=y?b:_,l=y?T:ne,d=y?M:re;N=c*d*n,F=a*d*n,I=l*n}{let e=l+r,c=f+i,u=x+(G?s(e,c,G)??0:o(e,c,E)??0),p=y?m:g,v=y?h:_,b=y?T:P,S=y?M:z,C=v*S*u,w=p*S*u,D=b*u;R||(N=2*K-C,F=2*J-w,I=2*X-D);let O=d===3?-1:1,k=O*(N-C),A=O*(F-w),j=O*(I-D);Te=a*A-n*j,Ee=t*j-a*k,De=n*k-t*A;let L=1/Math.sqrt(Te*Te+Ee*Ee+De*De);Te*=L,Ee*=L,De*=L}}}else Te=K*Ce,Ee=J*Ce,De=X*Ce;a(ee,be+e,Te,Ee,De,W)}})()}}function A(e,t){Z(e,t)}function j(e,t){return Math.PI/2-2*Math.atan(Math.exp(-e/t))}function M(e,t,n,r){return j(e*(1-r)+t*r,n)}function N(e,t,n){return e*(1-n)+t*n}function P(e){let{tile:t}=e;if(t.surface.isWebMercator){let e=t.extent,n=t.ellipsoid.radius;return t=>M(e[1],e[3],n,t)}let n=t.extentInRadians;return e=>N(n[1],n[3],e)}function F(e){let{tile:t,geometryState:n,geometry:i}=e,{extent:a,surface:o}=t,{wireframe:s}=n,c=a[0],l=a[1],u=a[2],d=a[3],f=u-c,p=d-l,{numVerticesPerSide:m,clippingArea:h}=n,g=h==null?0:Math.max(0,(h[0]-c)/f),_=h==null?0:Math.max(0,(h[1]-l)/p),v=h==null?1:Math.min(1,(h[2]-c)/f),y=h==null?1:Math.min(1,(h[3]-l)/p),b=(m-2)**2,x=Se(n),S=b+4*x,C=o.renderer.tileGeometryCache.acquire(S),{boundingBox:w}=i;r(w),i.numVerticesPerSide=m,i.vertexAttributes=C,i.maxEdgeVertexCount=x,i.minu=g,i.minv=_,i.maxu=v,i.maxv=y,I(e),i.edgeVerticesStartIndex=b,ne(e),z(e,Te,Ee),W(i,[],s),e.intersectionData=null}function I(t){let r=t.tile;if(!r.intersectsClippingArea)return;let{geometry:i,geometryState:c,localOrigin:l}=t,{samplerData:u,clippingArea:d,numVerticesPerSide:f}=c,{surface:p,extent:m,ellipsoid:h}=r,{isWebMercatorOnPlateCarree:g}=p,_=d??he,v=m[0],y=m[1],b=m[2],x=m[3],S=Math.max(v,_[0]),C=Math.min(b,_[2]),w=Math.max(y,_[1]),T=Math.min(x,_[3]),E=h.radius,D=r.horizontalScale,O=f-1,k=f-2,{minu:A,minv:j,maxu:M,maxv:N,boundingBox:P,vertexAttributes:F}=i,{position:I,uv0:L}=F,{typedBuffer:R,typedBufferStride:z}=F.normalCompressed,B=l[0],V=l[1],H=l[2],U=I.typedBuffer,ee=I.typedBufferStride,W=0,G=e(y,w,T),K=g?(Math.PI/2-2*Math.atan(Math.exp(-G/E)))*E:G*D,q=1/O,J=e(y*(1-q)+x*q,w,T),Y=g?(Math.PI/2-2*Math.atan(Math.exp(-J/E)))*E:J*D,te=K,ne=Y,X=u?.length===1?u[0]:null,re=X?(e,t)=>s(e,t,X)??0:(e,t)=>o(e,t,u)??0;for(let t=1;t<=k;t++){let r=t/O,i=e(y*(1-r)+x*r,w,T),o=e(r,j,N),s=ne,c=(t-1)/O,l=e(y*(1-c)+x*c,w,T),u=te,d=(t+1)/O,f=e(y*(1-d)+x*d,w,T),p=g?(Math.PI/2-2*Math.atan(Math.exp(-f/E)))*E:f*D,m=e(d,j,N);te=ne,ne=p;let h=e(v,S,C),_=h*D,F=re(h,i),I=1/O,G=e(I,A,M),K=e(v*(1-G)+b*G,S,C),q=G,J=K,Y=K*D,X=re(K,i);if(t===1){let t=Y-B,r=te-V,i=X-H,a=0*ee;U[a]=t,U[a+1]=r,U[a+2]=i,xe(t,r,i,P);let s=e(I,A,M);L.setValues(W,Math.round(s*n),Math.round(o*n))}for(let r=1;r<=k;r++){let c=Y,d=X,h=(r+1)/O,g=e(h,A,M),y=e(v*(1-h)+b*h,S,C),x=J;J=y;{let e=W+1,a=e*ee;if(t===1||r===k){let c=re(y,i),l=y*D,u=s,d=c;if(t===1&&r<k){let t=l-B,r=u-V,i=d-H;U[a]=t,U[a+1]=r,U[a+2]=i,xe(t,r,i,P),L.setValues(e,Math.round(g*n),Math.round(o*n))}Y=l,X=d}else Y=U[a]+B,X=U[a+2]+H}let w=Y,T=X,E=_,j=F;_=c,F=d;let N=(W-k)*ee,I=t===1?re(x,l):U[N+2]+H,G=re(x,f);if(t<k){let e=W+k,t=e*ee,r=c-B,i=p-V,a=G-H;U[t]=r,U[t+1]=i,U[t+2]=a,xe(r,i,a,P);let o=q;q=g,L.setValues(e,Math.round(o*n),Math.round(m*n))}{let e=w-E,t=T-j,n=u-p,r=I-G,i=n*t,o=e*r,s=-n*e,c=i*i+o*o+s*s;if(c===0)a(R,W,0,0,1,z);else{let e=1/Math.sqrt(c);a(R,W,i*e,o*e,s*e,z)}}++W}}}function L(e){e.tile.intersectsClippingArea&&(X(e),z(e,Te,Ee),ae(e),oe(e),e.intersectionData=null)}function R(e,t=!1){e.tile.intersectsClippingArea&&(z(e,t?Te:e.dirtyEdges,t?Ee:e.dirtyCorners),ae(e),e.intersectionData=null)}function z(e,t,n){e.tile.intersectsClippingArea&&(n&&V(e,n),t&&B(e,t),(n||t)&&be(e.geometry.boundingBox))}function B(n,r){let{geometry:i,geometryState:a,localOrigin:c}=n,l=n.tile,{surface:d,extent:f}=l,{clippingArea:g,samplerData:_}=a,y=g??he,b=f[0],x=f[2],S=f[1],C=f[3],w=[C>y[3],x>y[2],S<y[1],b<y[0]],T=l.horizontalScale,E=ee(d.isWebMercatorOnPlateCarree,l.ellipsoid.radius,T),{minu:D,minv:O,maxu:k,maxv:A,boundingBox:j}=i,M=Math.max(b,y[0]),N=Math.min(x,y[2]),P=Math.max(S,y[1]),F=Math.min(C,y[3]),I=c[0],L=c[1],R=c[2],z=_?.length===1?_[0]:void 0,B=z?(e,t)=>s(e,t,z)??0:(e,t)=>o(e,t,_)??0;for(let c=0;c<4;++c){if(!(r&1<<c))continue;let f=c===1||c===3,g=a.edgeResolutions[c];p(t(g));let y=g+1,z=w[c],V=u(l,a.edgePeerNeighbors[c]);if(!z&&_e(l,V,c)&&re(n,c,V))continue;let H=V!=null&&!z,U=V?.renderData?.geometryState;if(m&&(p(!H||V.level===l.level),p(!H||v(l,V)<=0),l&&!V&&!d.updatingRootTiles)){let e=h[c],t=l.findNeighborTile(e,e=>e.loaded||e.leaf||e.level===l.level);d.updatingRootTiles||(t?t.intersectsClippingArea&&(p(!t.loaded),p(!t.leaf),p(t.level===l.level)):p(d?.rootTiles==null||!l.shouldHaveNeighbor(e)))}let ee=e(c===1?x:b,M,N),W=e(c===0?C:S,P,F),G=U?.samplerData,K=e(+(c===1),D,k),q=e(+(c===0),O,A),J=G?.length===1?G[0]:null,Y=(e,t)=>J?s(e,t,J)??0:o(e,t,G)??0,te=H?(e,t)=>(Y(e,t)+B(e,t))*.5:B,ne=(x-b)/g,X=f?c===1?ne:-ne:0,Z=f?0:c===0?ne:-ne,ie=-X,ae=-Z,oe=0,Q=0,se=0;{let t=0/g,n=f?ee:e(b*(1-t)+x*t,M,N),r=f?e(S*(1-t)+C*t,P,F):W,i=te(n,r);oe=n*T,Q=E(r),se=i}let $=0,ce=0,le=0;{let t=1/g,n=f?ee:e(b*(1-t)+x*t,M,N),r=f?e(S*(1-t)+C*t,P,F):W,i=te(n,r),a=n*T,o=E(r),s=i;$=a,ce=o,le=s}for(let t=1;t<y-1;++t){let n=t/g,r=$,a=ce,s=le;{let o=f?K:e(n,D,k),l=f?e(n,O,A):q,u=r-I,d=a-L,p=s-R;xe(u,d,p,j),i.setEdgeVertexFromValuesRawPositionUV(c,t,u,d,p,o,l)}{let n=(t+1)/g,r=f?ee:e(b*(1-n)+x*n,M,N),i=f?e(S*(1-n)+C*n,P,F):W,a=te(r,i);$=r*T,ce=E(i),le=a}let l=$,u=ce,d=le,p=oe,m=Q,h=se;oe=r,Q=a,se=s;let v=0,y=0,w=0;if(f){let t=u-a,i=d-s,l=m-a,f=h-s,p=e(S*(1-n)+C*n,P,F),g=ee+ie,b=p,x=g*T,E=o(g,b,_),D=x-r,O=E-s,k=c===3?-1:1;if(v=k*(-l+t)*O,y=k*D*(-f+i),w=-k*D*(-l+t),H){let e=ee+X,n=p,a=e*T,c=o(e,n,G),u=a-r,d=c-s;v=(-l+t)*(O-d),y=(D-u)*(-f+i),w=-(D-u)*(-l+t)}}else{let t=l-r,i=d-s,u=p-r,f=h-s,m=e(b*(1-n)+x*n,M,N),g=m,S=W+ae,C=o(g,S,_)-s,T=E(S)-a,D=c===2?-1:1;if(v=D*T*(-f+i),y=D*(-u+t)*C,w=-D*T*(-u+t),H){let e=m,n=W+Z,r=E(n),c=o(e,n,G)-s,l=r-a;v=(-T+l)*(-f+i),y=(-u+t)*(-C+c),w=-(-T+l)*(-u+t)}}let z=1/Math.sqrt(v*v+y*y+w*w);i.setEdgeNormalFromValues(c,t,v*z,y*z,w*z)}}}function V(e,t){Z(e,t)}function H(e,t){return(Math.PI/2-2*Math.atan(Math.exp(-e/t)))*t}function U(e,t){return e*t}function ee(e,t,n){return e?e=>H(e,t):e=>U(e,n)}function W(e,t,n){let{numVerticesPerSide:r,vertexAttributes:i,maxEdgeVertexCount:a}=e,o=r-1,s=i.count,c=r-3,u=r-3,d=2*c*u,f=4*(o+a-3),p=l.reduce((t,n)=>t+(o+e.getEdgeCount(n)-3),0),m=t.reduce((e,t)=>e+o*((t.latitudeResolution-1)*2+1),0),h=3*(n?2:1),g=(d+f+m)*h;e.indices=s>=65536?new Uint32Array(g):new Uint16Array(g),e.indexCount=(d+p+m)*h,e.poleIndicesStartIndex=d*h,e.edgeIndicesStartIndex=(d+m)*h,n?(J(e),Y(e,t),te(e)):(G(e),K(e,t),q(e))}function G(e){let{numVerticesPerSide:t,indices:n,vertexAttributes:r}=e,{position:i}=r,{typedBuffer:a,typedBufferStride:o}=i,s=t-2,c=t-3,l=t-3,u=0;for(let e=0;e<c;++e){let t=e*s;for(let e=0;e<l;++e){let r=t+e,i=r+1,c=i+s,l=c-1;Ce(r,i,c,l,o,a)?(n[u]=r,n[u+1]=i,n[u+2]=c,n[u+3]=c,n[u+4]=l,n[u+5]=r):(n[u]=r,n[u+1]=i,n[u+2]=l,n[u+3]=l,n[u+4]=i,n[u+5]=c),u+=6}}}function K(e,t){let{numVerticesPerSide:n,indices:r,poleIndicesStartIndex:i}=e,a=n-1,o=i;for(let i of t){let t=i.isNorth?1:2,s=i.isNorth?2:1,c=i.isNorth?3:4,l=i.isNorth?4:3,u=e.getEdgeVertexIndex(i.connectedOuterEdgeOffset,0),d=1;for(let e=0;e<i.latitudeResolution;++e){let f=e===0?i.rowOffset:u+n;for(let n=0;n<a;n++){let a=f+n;r[o]=u,r[o+t]=u+1,r[o+s]=a,e<i.latitudeResolution-1?(r[o+c]=u+1,r[o+l]=a+1,r[o+5]=a,o+=6):o+=3,u+=d}u=f,d=1}}}function q(e){let{indices:t,numVerticesPerSide:n,edgeIndicesStartIndex:r}=e,i=n-1,a=i-2,o=r;for(let n=0;n<4;++n){let r=ye[n],s=0,c=0,l=e.getEdgeCount(n),u=r.count;p(u===i-1);let d=n===1||n===2,f=d?1:2,m=d?2:1,h=e.getEdgeFirstVertexIndex(n),g=r.vertex0Index,_=r.stride;for(;s<l-1||c<u-1;){let e=g+c*_,n=h+s*1,r=s<l-1,d=c<u-1,p=r?0+i*(s+.5)/(l-1):0,v=d?1+a*(c+.5)/(u-1):0,y=r&&(!d||p<=v);y?++s:++c;let b=y?n+1:e+_;t[o]=e,t[o+f]=n,t[o+m]=b,o+=3}}e.indexCount=o}function J(e){let{indices:t,numVerticesPerSide:n,vertexAttributes:r}=e,{position:i}=r,{typedBuffer:a,typedBufferStride:o}=i,s=n-2,c=0;for(let e=0;e<n-3;++e){let r=e*s;for(let i=0;i<n-3;++i){let n=e*s+i,l=n+1,u=l+s,d=u-1,f=r+i,p=f+1,m=p+s;Ce(f,p,m,m-1,o,a)?(we(t,c,n,l,u),c+=6,we(t,c,u,d,n)):(we(t,c,n,l,d),c+=6,we(t,c,d,u,l)),c+=6}}}function Y(e,t){let{indices:n,numVerticesPerSide:r,poleIndicesStartIndex:i}=e,a=r-1,o=i;for(let i of t){let t=i.connectedOuterEdgeOffset,s=e.getEdgeVertexIndex(t,0),c=1;for(let e=0;e<i.latitudeResolution;++e){let t=e===0?i.rowOffset:s+r;for(let r=0;r<a;r++)we(n,o,s,s+1,t+r),o+=6,e<i.latitudeResolution-1&&(we(n,o,s+1,t+r+1,t+r),o+=6),s+=c;s=t,c=1}}}function te(e){let{indices:t,numVerticesPerSide:n,edgeIndicesStartIndex:r}=e,i=n-1,a=i-2,o=r;for(let n=0;n<4;++n){let r=ye[n],s=0,c=0,l=e.getEdgeCount(n),u=r.count;p(u===i-1);let d=n===1||n===2,f=d?1:3,m=d?3:1,h=e.getEdgeFirstVertexIndex(n),g=r.vertex0Index,_=r.stride;for(;s<l-1||c<u-1;){let e=g+c*_,n=h+s*1,r=s<l-1,d=c<u-1,p=r?0+i*(s+.5)/(l-1):0,v=d?1+a*(c+.5)/(u-1):0,y=r&&(!d||p<=v);y?++s:++c;let b=y?n+1:e+_;t[o]=e,t[o+f]=n,t[o+f+1]=n,t[o+m]=b,t[o+m+1]=b,t[o+5]=e,o+=6}}e.indexCount=o}function ne(e){let{geometry:t,geometryState:n}=e,{edgeResolutions:r}=n,{numVerticesPerSide:i,edgeVerticesStartIndex:a}=t,o=i-2,s=a;for(let e=0;e<4;++e){{let t=e===1?o-1:0,n=e===0?o-1:0,r=e===0||e===2,i=+!!r,a=+!r,s=n*o+t,c=a*o+i,l=ye[e];l.vertex0Index=s,l.stride=c,l.count=o}{let n=r[e]+1;t.outerEdgesOffsetAndLength[e*2+0]=s,t.outerEdgesOffsetAndLength[e*2+1]=n,s+=n}}}function X(e){ne(e),e.geometryState.wireframe?te(e.geometry):q(e.geometry)}function re(r,i,a){let{geometryState:o,geometry:s,tile:c,localOrigin:l}=r,u=i===1||i===3,d=o.edgeResolutions[i];p(t(d));let f=d+1,{boundingBox:m,minu:h,minv:g,maxu:_,maxv:v,vertexAttributes:y}=s,b=e(+(i===1),h,_),x=e(+(i===0),g,v),S=a.renderData,C=S.geometryState;if(!C||!S.geometry.vertexAttributes)return!1;let w=S.geometry,T=(i+2)%4,E=w.getEdgeCount(T),D=c.getNeighborEdgeStartVertexIndex(i,a)*d,O=d*2**(c.level-a.level);p(C.edgeResolutions[T]===O),p(E-1===O);let k=S.localOrigin[0]-l[0],A=S.localOrigin[1]-l[1],j=S.localOrigin[2]-l[2],M=s.getEdgeFirstVertexIndex(i),{position:N,uv0:P}=y,F=N.typedBuffer,I=N.typedBufferStride,L=y.normalCompressed,R=L.typedBuffer,z=L.typedBufferStride,B=w.vertexAttributes,V=w.getEdgeFirstVertexIndex(T),H=B.position.typedBuffer,U=B.position.typedBufferStride,ee=B.normalCompressed.typedBuffer,W=B.normalCompressed.typedBufferStride;for(let t=1;t<f-1;++t){let r=D+t,i=M+t,a=V+r,o=i*I,s=a*U,c=H[s]+k,l=H[s+1]+A,f=H[s+2]+j;F[o]=c,F[o+1]=l,F[o+2]=f,xe(c,l,f,m);let p=i*z,y=a*W;R[p]=ee[y],R[p+1]=ee[y+1];let S=t/d,C=u?b:e(S,h,_),w=u?e(S,g,v):x;P.setValues(i,Math.round(C*n),Math.round(w*n))}return!0}function Z(t,r){let{geometry:i,geometryState:a,localOrigin:s}=t,{clippingArea:c,samplerData:l}=a,{minu:u,minv:d,maxu:f,maxv:m,boundingBox:h,vertexAttributes:g}=i,_=t.tile,{surface:y,ellipsoid:b,extent:x,extentInRadians:S,horizontalScale:C}=_,w=b.radius,T=0,E=0,D=0,O=()=>{let t=c,n=t!=null&&(x[3]>t[3]||x[2]>t[2]||x[1]<t[1]||x[0]<t[0]),r=ee(y.isWebMercatorOnPlateCarree,w,C);return(i,a,o)=>{let s=i===0?x[0]:x[2],c=a===0?x[1]:x[3],l=n?e(s,t[0],t[2]):s,u=n?e(c,t[1],t[3]):c,d=o;T=l*C,E=r(u),D=d}},k=(e,t,n)=>{let r=S[t===0?1:3],i=S[e===0?0:2],a=Math.cos(r),o=Math.sin(r),s=Math.sin(i),c=Math.cos(i),l=w+n;T=c*a*l,E=s*a*l,D=o*l},A=y.isGlobal,j=A?k:O(),M=0,N=0,F=0,I=0,L=0,R=0,z=0,B=0,V=0,H=!A&&y.isWebMercatorOnPlateCarree,U=(e,t,n,r,i)=>{let a=0,o=0,s=0;if(A){let i=P(e),c=e.tile,l=c.extent,u=c.extentInRadians,d=(t-l[0])/(l[2]-l[0]),f=(n-l[1])/(l[3]-l[1]),p=u[0]*(1-d)+u[2]*d,m=i(f),h=Math.cos(m),g=Math.sin(m),_=Math.sin(p),v=Math.cos(p),y=w+r,b=v*h*y,x=_*h*y,S=g*y;a=b-T,o=x-E,s=S-D}else{let e=t*C,i=H?(Math.PI/2-2*Math.atan(Math.exp(-n/w)))*w:n*C,c=r;a=e-T,o=i-E,s=c-D}switch(i){case 0:z+=a,B+=o,V+=s;break;case 1:I-=a,L-=o,R-=s;break;case 2:z-=a,B-=o,V-=s;break;case 3:I+=a,L+=o,R+=s}},W=c??he,G=x[0],K=x[2],q=x[1],J=x[3],Y=[J>W[3],K>W[2],q<W[1],G<W[0]],te=Math.max(G,W[0]),ne=Math.min(K,W[2]),X=Math.max(q,W[1]),re=Math.min(J,W[3]),Z=e=>Math.max(W[0],Math.min(W[2],e)),ae=e=>Math.max(W[1],Math.min(W[3],e)),oe=e=>{let t=a.cornerNeighborCornerTiles;M=0,N=0,F=1,I=0,L=0,R=0,z=0,B=0,V=0;let n=1/0;for(let r=0;r<4;++r){let i=t[e*4+r];n=Math.min(n,i?.level??1/0)}for(let r=0;r<4;++r){let i=t[e*4+r];ge[r]=i?.level===n?i:null}let r=1,i=0;for(let e=0;e<4;++e){let t=ge[e];t&&(r=Math.max(r,t?.renderData.geometryState.numVerticesPerSide),i=t.extent[2]-t.extent[0])}let s=i,c=r;p(c>1);let l=s/c;for(let e=0;e<4;++e){let t=ge[(e+3)%4],n=ge[e%4];if(!t&&!n)continue;let r=e===0?1:e===1?2:e===2?3:0,i=e===0?2:e===1?3:e===2?0:1;if(t&&n){let a=se[e][0]*l,s=se[e][1]*l,c=t.extent,u=Z(c[r===0||r===1?2:0]+a),d=ae(c[r===0||r===3?3:1]+s),f=n.extent,p=Z(f[i===0||i===1?2:0]+a),m=ae(f[i===0||i===3?3:1]+s),h=t.renderData,g=n.renderData,_=o(u,d,h.geometryState.samplerData),v=o(p,m,g.geometryState.samplerData);U(h,u,d,.5*(_+v),e)}else{let a=t??n,s=t?r:i,c=a.extent,u=se[e],d=Z(c[s===0||s===1?2:0]+u[0]*l),f=ae(c[s===0||s===3?3:1]+u[1]*l),p=a.renderData,m=o(d,f,p.geometryState.samplerData);U(p,d,f,m,e)}}if(A){let e=Math.sqrt(T*T+E*E+D*D);M=T/e,N=E/e,F=D/e}if(!A||F*F<.999){let e=Math.sqrt(I*I+L*L+R*R);I/=e,L/=e,R/=e;let t=Math.sqrt(z*z+B*B+V*V);z/=t,B/=t,V/=t,M=R*B-L*V,N=I*V-R*z,F=L*z-I*B;let n=1/Math.sqrt(M*M+N*N+F*F);M*=n,N*=n,F*=n}},Q=a.cornerNeighborCornerTiles;for(let t=0;t<4;++t){if(!(r&1<<t))continue;let c=t,y=(t+1)%4,b=+(t===0||t===1),x=+(t===0||t===3),S=e(b,u,f),C=e(x,d,m),w=i.getEdgeFirstVertexIndex(c),O=i.getEdgeCount(c),k=t===0||t===3?O-1:0,A=i.getEdgeFirstVertexIndex(y),P=i.getEdgeCount(y),I=t===0||t===1?P-1:0,L=-1;for(let e=0;e<4;++e){let n=Q[t*4+e],r=Q[t*4+L];n&&(L===-1||v(r,n)>0)&&(L=e)}let R=L,z=Q[t*4+R];if(z!==_){let e=_.level-z.level,r=2**e,i=[z.lij[0]+e,z.lij[1]*r,z.lij[2]*r],o=[i[1]+r===_.lij[1],t===0&&(R===1||R===0&&z!==Q[t*4+3])||t===1&&(R===0||R===1&&z!==Q[t*4+2]),i[1]===_.lij[1]+1,t===2&&(R===3||R===2&&z!==Q[t*4+1])||t===3&&(R===2||R===3&&z!==Q[t*4+0])],c=o.reduce((e,t)=>e+ +!!t,0);p(c===1||c===2);let l=-1,u=-1,d=z.renderData;if(c===1){let e=o.findIndex(e=>e);p(0<=e&&e<=3),l=(e+2)%4;let n=a.edgeResolutions[e];u=_.getNeighborEdgeStartVertexIndex(e,z)*n+n*+(e===0&&t===0||e===1&&t===0||e===2&&t===1||e===3&&t===3)}else{p(o[1]||o[3]),l=o[1]?3:1;let e=d.geometryState.edgeResolutions[l];u=t===0||t===3?0:e}let f=d.geometry;{let e=w+k,t=A+I,r=f.getEdgeFirstVertexIndex(l)+u,i=f.vertexAttributes,a=d.localOrigin,o=i.position,c=o.typedBuffer,p=r*o.typedBufferStride,m=c[p]+a[0]-s[0],_=c[p+1]+a[1]-s[1],v=c[p+2]+a[2]-s[2];xe(m,_,v,h);let y=g.position,b=y.typedBuffer,x=e*y.typedBufferStride;b[x]=m,b[x+1]=_,b[x+2]=v;let T=t*y.typedBufferStride;b[T]=m,b[T+1]=_,b[T+2]=v;let E=g.uv0;E.setValues(e,Math.round(S*n),Math.round(C*n)),E.setValues(t,Math.round(S*n),Math.round(C*n));{let n=i.normalCompressed.typedBuffer,a=r*i.normalCompressed.typedBufferStride,o=g.normalCompressed,s=o.typedBuffer;{let t=e*o.typedBufferStride;s[t]=n[a],s[t+1]=n[a+1]}{let e=t*o.typedBufferStride;s[e]=n[a],s[e+1]=n[a+1]}}}}else{let n=Y[c],r=Y[y],a;if(n||r){let t=e(G*(1-b)+K*b,te,ne),n=e(q*(1-x)+J*x,X,re);a=o(t,n,l)}else a=ie(Q,t);j(b,x,a),oe(t);let u=T-s[0],d=E-s[1],f=D-s[2];xe(u,d,f,h),i.setEdgeVertexFromValuesRawPositionUVNormal(c,k,u,d,f,S,C,M,N,F),i.setEdgeVertexFromValuesRawPositionUVNormal(y,I,u,d,f,S,C,M,N,F)}}for(let e=0;e<4;++e)ge[e]=null}function ie(e,t){let n=t*4,r=l.reduce((t,r)=>Math.min(t,e[n+r]?.level??1/0),1/0);m&&(p(!e[n+0]||!e[n+2]||_(e[n+0],e[n+2],5)),p(!e[n+1]||!e[n+3]||_(e[n+1],e[n+3],7)));let i=0,a=0;for(let t=0;t<4;++t){let s=e[n+t];if(s?.level===r){let e=t===0||t===1,n=t===0||t===3,r=s.extent,c=r[e?0:2],l=r[n?1:3],u=s.renderData?.geometryState?.samplerData,d=o(c,l,u);a+=d,i++}}let s=i?a/i:0;return p(s!=null),s}function ae(e){let{vao:t,geometry:n}=e,{vertexAttributes:r,edgeVerticesStartIndex:i}=n,{position:a}=r,o=a.typedBuffer,s=i*a.typedBufferStride,c=(n.getEdgeFirstVertexIndex(3)+n.getEdgeCount(3))*a.typedBufferStride;t.buffer()?.setSubData(o,s,s,c)}function oe(e){let{vao:t,geometry:n}=e,{indices:r,indexCount:i,edgeIndicesStartIndex:a}=n;t.indexBuffer.setSubData(r,a,a,i)}class Q{constructor(e,t,n,r,i){this.isNorth=e,this.connectedRowOffset=t,this.connectedOuterEdgeOffset=n,this.rowOffset=r,this.latitudeResolution=i}}const se=[[0,1],[1,0],[0,-1],[-1,0]],$=new c,ce=.5*f,le=new Uint16Array(d+1),ue=new Int32Array(d+1),de=new Int32Array(d+1),fe=new Int32Array(d+1),pe=new Float64Array(d+1),me=new Float64Array(d+1),he=i(-1/0,-1/0,1/0,1/0),ge=[null,null,null,null];function _e(e,t,n){if(!t)return!1;let r=v(e,t);return r>0||r===0&&n>=2}class ve{constructor(){this.vertex0Index=0,this.stride=1,this.count=0}getVertexIndex(e){return p(0<=e&&e<this.count),this.vertex0Index+this.stride*e}}const ye=[new ve,new ve,new ve,new ve];function be(e){for(let t=0;t<3;t++)e[t]=Math.min(e[t],Math.fround(e[t])),e[t+3]=Math.max(e[t+3],Math.fround(e[t+3]))}function xe(e,t,n,r){r[0]=Math.min(r[0],e),r[3]=Math.max(r[3],e),r[1]=Math.min(r[1],t),r[4]=Math.max(r[4],t),r[2]=Math.min(r[2],n),r[5]=Math.max(r[5],n)}function Se(e){let{edgeResolutions:t,numVerticesPerSide:n}=e,r=1+Math.max(...t);return Math.max(n,r)}function Ce(e,t,n,r,i,a){let o=e*i,s=a[o],c=a[o+1],l=a[o+2],u=t*i,d=a[u],f=a[u+1],p=a[u+2],m=n*i,h=a[m],g=a[m+1],_=a[m+2],v=r*i,y=a[v],b=a[v+1],x=a[v+2],S=(s-h)*(s-h)+(c-g)*(c-g)+(l-_)*(l-_);return(d-y)*(d-y)+(f-b)*(f-b)+(p-x)*(p-x)>S}function we(e,t,n,r,i){e[t]=n,e[t+1]=r,e[t+2]=r,e[t+3]=i,e[t+4]=i,e[t+5]=n}const Te=15,Ee=15,De=6;export{F as createPlanarGlobePatch,y as createSphericalGlobePatch,L as updateEdgeElevationsAndResolutionsPlanar,D as updateEdgeElevationsAndResolutionsSpherical,R as updateEdgesAndCornersPlanar,E as updateEdgesAndCornersSpherical};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import{parameter as t}from"../webgl-engine/core/shaderTechnique/ShaderTechniqueConfiguration.js";import{TileBlendTechniqueConfiguration as n}from"./TileBlendTechniqueConfiguration.js";class r extends n{constructor(){super(...arguments),this.colorizerType=0,this.stretchType=0,this.applyColormap=!0,this.requireBilinearWithNN=!1}}e([t({count:3})],r.prototype,`colorizerType`,void 0),e([t({count:2})],r.prototype,`stretchType`,void 0),e([t()],r.prototype,`applyColormap`,void 0),e([t()],r.prototype,`requireBilinearWithNN`,void 0);export{r as RasterColorizerTechniqueConfiguration};
2
+ import{__decorate as e}from"tslib";import{parameter as t}from"../webgl-engine/core/shaderTechnique/ShaderTechniqueConfiguration.js";import{TileBlendTechniqueConfiguration as n}from"./TileBlendTechniqueConfiguration.js";class r extends n{constructor(){super(...arguments),this.colorizerType=0,this.stretchType=0,this.applyColormap=!0,this.requireBilinearWithNN=!1,this.needsUV=!0}}e([t({count:3})],r.prototype,`colorizerType`,void 0),e([t({count:2})],r.prototype,`stretchType`,void 0),e([t()],r.prototype,`applyColormap`,void 0),e([t()],r.prototype,`requireBilinearWithNN`,void 0);export{r as RasterColorizerTechniqueConfiguration};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import t from"../../../Color.js";import{property as n,subclass as r}from"../../../core/accessorSupport/decorators.js";import{filterInPlace as i,difference as a}from"../../../core/arrayUtils.js";import o from"../../../core/CollectionFlattener.js";import{toConst as s}from"../../../core/compilerUtils.js";import{EventedAccessor as c}from"../../../core/Evented.js";import"../../../core/has.js";import{set as l,copy as u,exactEquals as ee}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{create as d}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import f from"../../../core/Logger.js";import{clamp as te}from"../../../core/mathUtils.js";import{destroyMaybe as p,removeMaybe as ne}from"../../../core/maybe.js";import{MemCachePool as re}from"../../../core/MemCachePool.js";import m from"../../../core/ObjectPool.js";import ie from"../../../core/PooledArray.js";import{throwIfAborted as ae,isAbortError as h,isAborted as g}from"../../../core/promiseUtils.js";import{watch as _,syncAndInitial as v,initial as y,sync as b}from"../../../core/reactiveUtils.js";import"../../../core/scheduling.js";import{UpdatingHandles as oe}from"../../../core/support/UpdatingHandles.js";import{getMetersPerUnitForSR as se}from"../../../core/units.js";import{getReferenceEllipsoid as x,radiusModifier as ce}from"../../../geometry/ellipsoidUtils.js";import{projectBoundingSphere as le}from"../../../geometry/projection/projectBoundingSphere.js";import{getProjector as ue}from"../../../geometry/projection/projectors.js";import{projectPointToVector as de}from"../../../geometry/projection/projectPointToVector.js";import{projectVectorToVector as fe}from"../../../geometry/projection/projectVectorToVector.js";import{projectWithoutEngine as pe}from"../../../geometry/projectionUtils.js";import me from"../../../geometry/SpatialReference.js";import{create as S,fromExtent as he,equals as C,intersection as ge,intersectsSphere as _e}from"../../../geometry/support/aaBoundingRect.js";import{copy as ve,create as ye}from"../../../geometry/support/frustumPlanes.js";import{createSpatialReferenceCyclical as be}from"../../../geometry/support/normalizeUtils.js";import{isGeographic as w,isPlateCarree as xe}from"../../../geometry/support/spatialReferenceUtils.js";import{Sphere as Se}from"../../../geometry/support/sphere.js";import{ElevationQueryTileCache as Ce}from"../../../layers/support/ElevationQueryTileCache.js";import{IntegratedMeshSemantics as we}from"../../../layers/support/IntegratedMeshSemantics.js";import{isIntegratedMeshLayer as Te,isBaseLayer as Ee}from"../../../layers/support/layerUtils.js";import{queueHighPriority as De}from"../../../request/queue.js";import{hasLayerBasedScaleVisibility as Oe}from"../../support/layerViewUtils.js";import{ImmediateTask as T,TaskPriority as ke,noBudget as Ae}from"../../support/Scheduler.js";import{TextureCompressionTracker as je}from"../../support/TextureCompressionTracker.js";import{Yield as Me}from"../../support/Yield.js";import{debugFlags as E}from"../support/debugFlags.js";import{ElevationRange as D}from"../support/ElevationRange.js";import{ElevationUpdateEvent as Ne}from"../support/ElevationUpdateEvent.js";import{calculateElevationUpdateExtents as Pe}from"../support/elevationUpdateExtentUtils.js";import{toBoundingRect as Fe}from"../support/extentUtils.js";import{geographicMbsToGeographicExtent as Ie,mbsToGeographicExtent as Le,intersectsGeographicExtent as Re}from"../support/sphereExtentUtils.js";import{isSupportedGCSOnGlobe as O}from"../support/supportedSpatialReference.js";import{updatingProgress as ze}from"../support/updatingProperties.js";import{isCompositeBlendMode as Be,blendModeFromString as Ve}from"../webgl-engine/core/shaderLibrary/output/BlendOptions.js";import{ElevationBounds as He}from"./ElevationBounds.js";import{ElevationData as Ue,sampleElevation as We}from"./ElevationData.js";import{create as Ge}from"./ExtentHelper.js";import{LayerClasses as Ke}from"./LayerClass.js";import{OverlayManager as qe}from"./OverlayManager.js";import{PlanarPatch as Je}from"./PlanarPatch.js";import{Queue as Ye}from"./Queue.js";import{ScaleRangeQueries as Xe}from"./ScaleRangeQueries.js";import{SphericalPatch as Ze}from"./SphericalPatch.js";import{SplitLimits as Qe}from"./SplitLimits.js";import{maxRootTiles as k,tooManyRootTilesAfterChangeError as $e,tooManyRootTilesForLayerError as et,maxTileNeighborLevelDelta as A,maxMemoryLodBias as tt}from"./TerrainConst.js";import{TerrainRenderer as nt}from"./TerrainRenderer.js";import rt from"./TerrainSurfacePerformanceInfo.js";import{weakAssert as j,isVectorTileLayerView as M,internalAssert as N,oppositeEdge as it,neighborEdgeIndices as P,isSurfaceLayerView as F,isGroupLayerView as I,isMapTileLayerView as L,isBlendableLayerView as R,isElevationLayerView as z,releaseTerrainData as B,oppositeCorner as at,enableTerrainInternalChecks as V,enableWaterproofTests as ot,enableInternalTerrainChecks as st,enableTerrainWaterproofChecks as ct,neighborCornerIndices as lt}from"./terrainUtils.js";import{Tile as ut,lijEquals as H}from"./Tile.js";import{printAllocations as dt}from"./TilePerLayerInfo.js";import{sortTiles as ft,IteratorPreorder as pt,IteratorPostorder as mt,compareTilesByLij as U,sortTilesByPOI as ht,traverseTilesPreorder as W}from"./tileUtils.js";import{TilingSchemeLogic as gt}from"./TilingSchemeLogic.js";import{getGroundTransparencyModeFromOpacity as _t}from"./TransparencyMode.js";import{UpsampleInfo as vt}from"./UpsampleInfo.js";var G;let K=class extends c{static{G=this}get allTilesCreated(){return this._allTilesCreated}get allTiles(){return s(this._allTiles)}get renderedTiles(){return ft(i(this._allTiles.toArray(),e=>e.visible&&e.rendered))}get _tileConstructor(){return this.view.state.isGlobal?Ze:Je}get _ellipsoid(){return x(this.view.spatialReference)}get demResolution(){let{_allTiles:e,tilingScheme:t}=this;if(e.length===0)return{min:1,max:1};let n=se(t.spatialReference),r=1/0,i=-1/0;for(let a of e){let e=t.resolutionAtLevel(a.level)*n;r=Math.min(r,e),i=Math.max(i,e)}return{min:r,max:i}}constructor(e){super(e),this.terrainTextureCompressionTracker=new je,this._iteratorPool=new m(()=>new pt,e=>e.remove=()=>this._iteratorPool.release(e)),this._postorderIterator=new mt,this._hasPendingUpdates=!1,this._pendingUpdates=0,this._asyncWorkItems=0,this._allTilesDirty=!0,this._allTilesSorted=!0,this._allTilesCreated=!1,this._usedMemory=null,this._performanceInfo=new rt,this._waterproofnessErrorHandle=null,this._viewChanged=!1,this.heading=0,this._inFrameTask=!1,this._viewChangeUpdateDirty=!1,this._eyePosRenderSR=d(),this._eyePosSurfaceSR=d(),this._splitLimits=new Qe,this._layerViews=[[],[]],this._layerIndexByUid=[new Map,new Map],this._basemapLayerViewHandles=new Map,this._updatingHandles=new oe,this._poiWatchHandle=null,this._frameTask=T,this._allTiles=new ie,this._upsampleInfoPool=new m(()=>new vt),this._shouldEmitChangeEvent=!1,this._rootTilesExtent=S(),this.updatingProgress=.5,this._maxNumUpdating=1,this.hasCompositeBlendMode=!1,this.maxTextureScale=1.2,this._elevationProjectorCache=new Map,this._rootTileElevationRange=new D(1/0,-1/0),this._updatingRootTiles=!1,this._pendingTilesForElevationUpdateEvent=new Set,this._pendingTilesToUpdate=new Set,this.totalGeometryUpdates=0,this.totalTileUpdates=0,this._layerViewsDirty=!1,this.unloadedMemory=0,this.ignoresMemoryFactor=!1,this.enabled=!0,this.overlayManager=new qe({...e,terrainSurface:this}),this._renderer=new nt(this,this.overlayManager.renderer,this._allTiles,this.terrainTextureCompressionTracker,e.view),Oe()||(this._scaleRangeQueries=new Xe)}initialize(){let{view:e}=this,{resourceController:t}=e,{memoryController:n}=t;e.stage.addRenderPlugin(this._renderer),this._tileCache=new re((e,t)=>n.newCache(e,t),`terrain-tile`),this._upsampleMapCache=n.newCache(`terrain-upsample`,({tile:e})=>e.unloadMapData()),this._elevationQueryCache=new Ce(n.newCache(`elevation-query`));let r=this.overlayManager;this.addHandles([_(()=>r.renderer.isEmpty,()=>this._evaluateTransparency()),_(()=>this.renderer.visible,e=>this.freeze=!e),_(()=>this.heading,e=>{this._renderer.updateHeading(e),this._updateTileTextures(0)},v)],`overlayManager`),this._updatingHandles.add(()=>({heading:e.camera?.heading,state:e.state?.mode}),({heading:e,state:t})=>{if(e==null)return;if(this.isGlobal&&this.isGeographic||this.isWebMercatorOnPlateCarree){this.heading=Math.round(e/90)*90%360;return}let n=Math.round(e)%360,r=Math.abs(n-this.heading);(t===2||Math.min(r,360-r)>=30)&&(this.heading=n)},y),this.addHandles([_(()=>this.baseOpacity,()=>{this._handleLayerViewChanges(),this._updateTileTextures(this._evaluateTransparency()?1:2)},v),_(()=>this.hasCompositeBlendMode,()=>this._updateTileTextures(this._evaluateTransparency()?1:2),v),_(()=>this.backgroundColor,(e,t)=>{e?.equals(t)||(this._handleLayerViewChanges(),this._renderer.updateTileBackground(e))},b),_(()=>this.snapLevel,()=>this._viewChanged=!0,b),_(()=>this.view.pointsOfInterest,e=>{this._renderer.pointsOfInterest=e,this._poiWatchHandle=ne(this._poiWatchHandle),e&&(this._poiWatchHandle=this._updatingHandles.add(()=>e.focus?.renderLocation,()=>this._allTilesSorted=!1,{equals:ee}))}),_(()=>E.TERRAIN_TILE_TREE_SHOW_TILES,t=>{t&&!this._treeDebugger?import(`../layers/support/TerrainTileTree3DDebugger.js`).then(({TerrainTileTree3DDebugger:t})=>{!this._treeDebugger&&E.TERRAIN_TILE_TREE_SHOW_TILES&&(this._treeDebugger=new t({view:e}))}):t||(this._treeDebugger=p(this._treeDebugger))},y),_(()=>this.tilingScheme,e=>this._updateTilingScheme(e),b)]);let{spatialReference:i}=e;this._extentHelper=Ge(this.isGlobal,{layers:e.map.allLayers,layerViews:e.allLayerViews,viewSpatialReference:i});let a=new o({getCollections:()=>e.defaultsFromMap?.mapCollections?.map(({layers:e})=>e),getChildrenFunction:e=>e&&`layers`in e?e.layers:null}),s=new gt({layers:a,extentHelper:this._extentHelper,isGlobal:this.isGlobal,viewSpatialReference:i});this._set(`tilingSchemeLogic`,s);let c=t.scheduler;this._frameTask=c.registerTask(ke.TERRAIN_SURFACE,this),this.addHandles([_(()=>this._stencilEnabledExtents,e=>this._renderer.setStencilEnabledLayerExtents(e),y),_(()=>this.groundExtent,()=>this._updateRootTiles(),y),e.on(`resize`,()=>this._viewChangeUpdate()),_(()=>{let t=e.state;return[this._lodBias,this.lodSnappingEnabled,e.quality,t.camera,t.contentCamera,t.fixedContentCamera]},()=>this._viewChangeUpdate(),v),_(()=>e.qualitySettings?.fadeDuration,e=>this._renderer.textureFadingEnabled=e>0,y),_(()=>e.qualitySettings?.physicallyBasedRenderingEnabled,e=>this._renderer.pbrMode=e?5:0,y),_(()=>e.qualitySettings?.tiledSurface.elevationLevelDelta,()=>{this._allTiles.forAll(e=>this.updateElevationSources(e)),this._updateAllTileGeometries()}),e.allLayerViews.on(`after-changes`,()=>this._layerViewsDirty=!0)]),this._updatingHandles.add(()=>this.userClippingExtent,()=>this._updateClippingExtent()),this._layerViewsDirty=!0,this._handleLayerViewChanges(),this._renderer.updateTileBackground(this.backgroundColor)}clearHandles(){this._updatingHandles?.removeAll(),this.removeAllHandles(),this._basemapLayerViewHandles.forEach((e,t)=>this._unregisterTiledLayerView(t)),this._basemapLayerViewHandles.clear()}destroy(){this._waterproofnessErrorHandle?.remove(),this._waterproofnessErrorHandle=null,this._frameTask.remove(),this._frameTask=T,this._updatingHandles?.destroy(),this._removeAllTiles(),this._set(`tilingSchemeLogic`,p(this.tilingSchemeLogic)),this._basemapLayerViewHandles.forEach((e,t)=>this._unregisterTiledLayerView(t)),this._basemapLayerViewHandles.clear(),this._set(`overlayManager`,p(this.overlayManager)),this._tileCache=p(this._tileCache),this._allTiles.prune(),ut.prune(),this._treeDebugger=p(this._treeDebugger),this._renderer.destroyed||(this.view.stage.removeRenderPlugin(this._renderer),this._renderer.destroy()),this._renderer=null,this._iteratorPool=p(this._iteratorPool),this._upsampleMapCache=p(this._upsampleMapCache),this._elevationQueryCache=p(this._elevationQueryCache),this._set(`view`,null),this._extentHelper=p(this._extentHelper),this._upsampleInfoPool=p(this._upsampleInfoPool),dt(),this._layerViews.forEach(e=>e.length=0),this._performanceInfo=null}get renderer(){return this._renderer}get frustum(){return this.view.state.camera.frustum}get snapLevel(){return this.lodSnappingEnabled?this.view.terrainLevel:null}get lodSnappingEnabled(){return this.view.qualitySettings.tiledSurface.reduceTileLevelDifferences}get upsampleInfoPool(){return this._upsampleInfoPool}get upsampleMapCache(){return this._upsampleMapCache}get elevationQueryCache(){return this._elevationQueryCache}get hasStencilEnabledExtents(){return!!this._stencilEnabledExtents?.length}get _stencilEnabledExtents(){let e=this.spatialReference;return e==null?null:Iterator.from(this.view.allLayerViews).map(t=>{let{layer:n}=t;if(!Te(n)||!we.shouldStencilTerrain(n))return null;let{fullExtent:r}=n,i=r==null||r.spatialReference.equals(e)?r:pe(r,r.spatialReference,e);return i?he(i):null}).filter(e=>e!=null).toArray()}get userClippingExtent(){let{spatialReference:e}=this,t=this.view?.clippingArea;if(t==null||e==null)return null;let n=S(),r=Fe(t,n,e)?n:null,i=this._get(`userClippingExtent`);return C(r,i)?i:r}get rootTilesExtent(){return this._rootTilesExtent}get groundExtent(){let e=ge(this.fullGroundExtent,this.userClippingExtent,S()),t=this._get(`groundExtent`);return C(e,t)?t:e}get fullGroundExtent(){return this._tilingSchemeExtent==null?this._rootTilesExtent:this._tilingSchemeExtent}get _tilingSchemeExtent(){return this.tilingSchemeLogic?.extent}get updating(){return this._hasPendingUpdates||(this._maxNumUpdating=1),this.enabled&&!!((this.readyToRun||this._updatingHandles?.updating||this._asyncWorkItems>0)&&this.ready&&!this.freeze||this.overlayManager?.updating||this.terrainTextureCompressionTracker.compressing)}get readyToRun(){return this.enabled&&(this._hasPendingUpdates||this._viewChanged||this._allTilesDirty||!this._allTilesSorted||this._layerViewsDirty||this._scaleRangeQueries?.updating||this._frameTask.updating)&&this.ready&&!this.freeze}get updatingProgressValue(){return this._maxNumUpdating=Math.max(this._pendingUpdates,this._maxNumUpdating),1-this._pendingUpdates/this._maxNumUpdating}get baseOpacity(){return this.view?.map?.ground?.opacity??1}set baseOpacity(e){this.view.map.ground.opacity=e}get isGlobal(){return this.view.state.isGlobal}get ready(){return!this.enabled||this._rootTiles!=null}get rootTiles(){return this._rootTiles}get spatialReference(){return this.tilingScheme?.spatialReference??me.WebMercator}get backgroundColor(){return this.view?.map?.ground?.surfaceColor}set backgroundColor(e){this.view.map.ground.surfaceColor=e}set slicePlaneEnabled(e){this._renderer.slicePlaneEnabled=e,this._set(`slicePlaneEnabled`,e),this._evaluateTransparency()}get tilingScheme(){return this.tilingSchemeLogic?.tilingScheme}get tilingSchemeLocked(){return this.tilingSchemeLogic?.tilingSchemeLocked??!1}get wireframe(){return this._renderer?.wireframe}set wireframe(e){e!==this._renderer.wireframe&&(this._renderer.wireframe=e,this._updateAllTileGeometries())}get opaque(){return this._renderer.transparency===0}get invisible(){return this._renderer.transparency===3}set freeze(e){this._set(`freeze`,e),this._viewChangeUpdate()}get fadeDuration(){return this.view.qualitySettings.fadeDuration??0}intersect(e,t,n,r){this._renderer.intersectRay(e,t,n,r)}intersectBudgeted(e,t,n,r,i){return this._renderer.intersectRayBudgeted(e,t,n,r,i)}getElevationLevelDelta(e){return e<4?3:this.view.qualitySettings.tiledSurface.elevationLevelDelta}get _xNormalizer(){return be(this.spatialReference)}getElevation(e,t,n,r){let i=this._rootTiles;if(!i?.length||!this.enabled||i[0].layerInfo[0].length===0)return null;let a=this._elevationProjectorCache.get(r);if(a===void 0&&(a=ue(r,this.spatialReference)??null,this._elevationProjectorCache.set(r,a)),a==null)return f.getLogger(this).error(`TerrainSurface.getElevation(): could not project given point to tiling scheme coordinate system`),null;let o=l(q,e,t,n);return a(o,0,o,0),Ct(i,this._xNormalizer?.normalize(o[0])??o[0],o[1])}getElevations(e,t,n){let r=this._rootTiles,i=r?r[0].layerInfo[0].length:0;if(!r?.length||i===0||!this.enabled)for(let e=0;e<t;++e)n(e,null);else for(let i=0;i<t;++i){let t=i*3,a=Ct(r,e[t],e[t+1]);n(i,a)}}getLayerIndexByUID(e,t){return this._layerIndexByUid[e].get(t)}get visibleElevationRange(){let e=1/0,t=-1/0;for(let n of this._allTiles)n.renderData&&(e=Math.min(e,n.elevationBoundsMin),t=Math.max(t,n.elevationBoundsMax));let n=this._get(`visibleElevationRange`);return n?.minElevation===e&&n.maxElevation===t?n:new D(e,t)}invalidateElevationRange(){this.notifyChange(`visibleElevationRange`)}tileElevationRangeChanged(e,t=1/0,n=-1/0){let r=this._get(`visibleElevationRange`);(!r||t===r.minElevation||n===r.maxElevation||e.renderData&&(e.elevationBoundsMin<r.minElevation||e.elevationBoundsMax>r.maxElevation))&&this.invalidateElevationRange()}getScale(e){if(!this.tilingScheme)return null;if(!de(e,q,this.spatialReference))return f.getLogger(this).error(`TerrainSurface.getScale(): could not project given point to tiling scheme coordinate system`),null;let t=this._rootTiles;if(t!=null){for(let e of t)if(e?.containsPoint(q)){let t=e;for(;t.children[0]&&!t.rendered;){let e=t.children[0].extent,n=0;q[0]>e[2]&&(n+=1),q[1]<e[1]&&(n+=2),t=t.children[n]}return this._getLodBiasCorrectedScale(t.level)}}return 1/0}getSphereElevationRange(e,t){if(!this.enabled)return null;let n=this._rootTiles,r=this.spatialReference;if(n==null||r==null||n.length===0)return null;let i=w(r);if(i){let n=w(t)&&O(t),i=x(t);if(n&&O(r)&&i===x(r))Ie(e,J,i.radius);else if(!Le(e,t,J,r))return f.getLogger(this).error(`TerrainSurface.getSphereElevationRange(): could not project the query sphere`),null}else if(!le(e,t,bt,r))return f.getLogger(this).error(`TerrainSurface.getSphereElevationRange(): could not project the query sphere`),null;let a=new D,o=[];for(let e of n)o.push(e);let s=0;for(;s<o.length;){let e=o[s];if(++s,!(i?Re(e.extent,J,r):_e(e.extent,bt)))continue;let t=e.children;if(t[0]==null||e.rendered)a.expandElevationRangeValues(e.elevationBoundsMin,e.elevationBoundsMax);else for(let e of t)o.push(e)}return a}getRootElevationRange(){return this.enabled&&this._rootTiles?new D(this._rootTileElevationRange.minElevation,this._rootTileElevationRange.maxElevation):null}getLowerBoundRadius(){let e=this.visibleElevationRange,t=(this._ellipsoid.radius+(e.isEmpty?0:e.minElevation))*ce;return Math.min(t,this._ellipsoid.radius)}queryVisibleScaleRange(e,t,n,r){if(!this._scaleRangeQueries)return;let i=t?this.tilingScheme.levelAtScale(t):0,a=n?this.tilingScheme.levelAtScale(n):1/0,o=this._lodBias;this._scaleRangeQueries.queryVisibleLevelRange(e,i+o,a+o,r)}_evaluateTransparency(){let e=this.baseOpacity,t=this.overlayManager.renderer.isEmpty,n=this._renderer.transparency,r=this._isFullyTransparent?_t(0,t):e>=1&&!this.hasCompositeBlendMode&&!this._renderer.slicePlaneEnabled?0:1;return this._renderer.transparency=r,n!==r&&(this.notifyChange(`opaque`),this.notifyChange(`invisible`),!0)}_updateTilingScheme(e){j(!!e,`tiling scheme cannot be reset to undefined`),e&&this._removeAllTiles(),this._updateClippingExtent(),e&&(this._updateTiledLayers(),this._renderer.tileSize=e.pixelSize,this.overlayManager.spatialReference=e.spatialReference,this._updateRootTiles())}static{this._tileMemcacheKey=`TerrainTileMemcache`}_acquireTile(e,t,n,r){let i=this._tileCache.pop(G._tileMemcacheKey);return i?(i.init(e,t,n,r,this),i):new this._tileConstructor(e,t,n,r,this)}get updatingRootTiles(){return this._updatingRootTiles}_updateRootTiles(){let{groundExtent:e,tilingScheme:t}=this;if(!t)return;if(!this.enabled){this._setRootTiles(null);return}let n=xt,r=t.rootTilesInExtent(e,n,k*5);if(this._rootTiles!=null){if(r.length>k){f.getLogger(this).warn($e);return}let e=this._rootTiles.map(e=>e.lij),t=a(e,r,H);if(this._updatingRootTiles=!0,t.removed.length>0||t.added.length>0){let e=this._rootTiles.filter(e=>t.removed.findIndex(t=>H(t,e.lij))>-1?(this._purgeTile(e),!1):!0);t.added.forEach(t=>e.push(this._newRootTile(t))),this._setRootTiles(e)}}else this._updatingRootTiles=!0,r.length>k&&(f.getLogger(this).warn(et),r=t.rootTilesInExtent(e,n,k)),this._setRootTiles(r.map(e=>this._newRootTile(e)));C(n,this._rootTilesExtent)||(this._rootTilesExtent=S(n)),this.renderer.visible=!0,this.overlayManager.setPlacementDirty(),this.notifyChange(`ready`),this._updateAllTileGeometries(),this._updatingRootTiles=!1,this._viewChangeUpdate(),this.checkAllTilesWaterproofness(`root-tiles-updated`)}_updateAllTileGeometries(){let e=this._allTiles.filter(e=>this._canUpdateTileGeometry(e));e.length===0||(e.sort(U),e.forEach(e=>this._renderer.updateTileGeometryState(e)),e.forEach(e=>e.renderData.updateNeighborData()),this._updateTilesGeometries(e)),this._pendingTilesToUpdate.clear()}_updateTilesGeometries(e){let t=e.filter(e=>this._canUpdateTileGeometry(e));if(t.length===0)return;let n=this.renderer;for(let e of t)n.updateGeometryIfNeeded(e);for(let e of t)this._pendingTilesForElevationUpdateEvent.add(e)}_canUpdateTileGeometry(e){return e.loaded&&e.intersectsClippingArea&&e.hasGeometryState}_shouldSplit(e){return e.shouldSplit(this._splitLimits,this._eyePosRenderSR,this.snapLevel)===1}_newRootTile(e){let t=this._acquireTile(0,e[1],e[2],null);return this._shouldSplit(t)&&t.setPendingUpdate(1),this._loadTile(t),this._markTileToUpdate(t),this._updateRootTileElevationRange(),t}_setRootTiles(e){if(this._rootTiles=e,this._allTiles.clear(),e!=null){let t=this._iteratorPool.acquire();for(t.reset(e);!t.done;)this._allTiles.push(t.next());t.remove()}this.invalidateElevationRange(),this._renderer.setRootTiles(this._rootTiles),this._updateTilesVisibility(e),this.notifyChange(`demResolution`),this.emit(`tiles-changed`,{allTiles:this.allTiles})}_runViewChangeUpdateIfDirty(){this._viewChangeUpdateDirty&&(this._viewChangeUpdateDirty=!1,this._viewChangeUpdate())}_viewChangeUpdate(){this.view&&!this.freeze&&this.tilingScheme&&this.renderer.visible&&(this._inFrameTask||this._updatingRootTiles?this._viewChangeUpdateDirty=!0:(this._viewChangeUpdateDirty=!1,this._updateViewDependentParameters(),this._updateTilesVisibility(this._rootTiles)))}_updateClippingStatus(e){e.updateClippingStatus(this.groundExtent)&&e.resetPendingUpdate(8)&&this._updateTileGeometryState(e)}_updateTilesVisibility(e){if(e==null)return;let t=this.groundExtent,n=this.view.state.contentCamera.viewProjectionMatrix;this.setTileTreeDirty(!1);let r=this._iteratorPool.acquire();for(r.reset(e);!r.done;){let e=r.next();e.updateClippingStatus(t)&&e.resetPendingUpdate(8)&&this._updateTileGeometryState(e),e.computeVisibility(),e.updateScreenDepth(n)}r.remove(),this._viewChanged=!0,this._allTilesDirty=!0,this._updatePendingTileGeometries()}_updateRootTileElevationRange(){let e=1/0,t=-1/0;this._rootTiles?.forEach(({elevationBoundsMin:n,elevationBoundsMax:r})=>{e=Math.min(e,n),t=Math.max(t,r)});let n=this._rootTileElevationRange;(n.minElevation!==e||n.maxElevation!==t)&&(this._rootTileElevationRange=new He(e,t))}_updateViewDependentParameters(){let{camera:e,contentCamera:t}=this.view.state,n=Math.tan(t.fovX*.5),r=Math.tan(t.fovY*.5),i=this.tilingScheme.pixelSize,a=2**-this._lodBias*e.pixelRatio;this._splitLimits.aboveGround=e.aboveGround,this._splitLimits.fovX=n,this._splitLimits.fovY=r,this._splitLimits.relativeWidthLimit=i/e.width*this.maxTextureScale*a,this._splitLimits.relativeHeightLimit=i/e.height*this.maxTextureScale*a,this._splitLimits.maxLod=this.tilingScheme.getMaxLod(),this._splitLimits.angledSplitBias=this.view.qualitySettings.tiledSurface.angledSplitBias,this.view.state.fixedContentCamera?this._splitLimits.frustum=ve(this._splitLimits.frustum??ye(),t.frustum):this._splitLimits.frustum=null,u(this._eyePosRenderSR,t.eye),fe(e.eye,this.view.renderSpatialReference,this._eyePosSurfaceSR,this.spatialReference)}_updateTileGeometryState(e){e.updateVisibility(),this._renderer.updateTileGeometryState(e)&&this._markTileToUpdate(e),this.setMemoryDirty()}_markAllTileNeighborsForUpdate(e){let t;e.forEachLoadedNeighbor(e=>{t??=this._layerViews[1].some(M),t&&e.setPendingUpdate(32),this._pendingTilesToUpdate.add(e)})}_updateTileTexture(e,t){let n=e.hasPendingUpdate(32)?32:e.hasPendingUpdate(16)?16:!1;if(n){let r=this._renderer.updateTileTexture(e,n);return this._usedMemory=null,r&&e.resetPendingUpdate(n),t.madeProgress(),r}return!0}_emitElevationUpdateEventForTiles(){if(!this._shouldEmitChangeEvent)return;let e=this._pendingTilesForElevationUpdateEvent;if(e.size>0){let t=new Float64Array(4*e.size),n=0;for(let r of e)t.set(r.extent,4*n),++n;e.clear();for(let e of Pe(t,this.spatialReference)){let t=new Ne(this.spatialReference,e,`ground`);this.emit(`elevation-change`,t)}}this._shouldEmitChangeEvent=!1}runTask(e){this._handleLayerViewChanges(e),this._frameTask.processQueue(e),this.renderer.processScaleRangeQueries(this._scaleRangeQueries,e),this._inFrameTask=!0,this._pendingUpdates=0,this._hasPendingUpdates=!1,this._updateAllTilesStatus(e),this._sortTiles(e);let t=!this.view.state.fixedContentCamera;this._mergeAndSplit(e,t),this._updateElevation(e);let n=this._updateTextures(e);t||this._mergeAndSplit(e,!0),this._inFrameTask=!1,this._runViewChangeUpdateIfDirty();let r=this._pendingTilesToUpdate.size>0,i=r&&this._hasPendingGeometryWithoutIndices();if((!e.done||i)&&this._updatePendingTileGeometries(),this._emitElevationUpdateEventForTiles(),e.done&&(e.hasProgressed||r&&!i)&&this.requestUpdate(),this.notifyChange(`updatingProgressValue`),!n||!e.hasProgressed)return Me}_checkTileInvariant(){}_updateAllTilesStatus(e){if(!this._viewChanged||!this._rootTiles||e.done)return;this._viewChanged=!1;let t=!1,n=new Ye(this._allTiles.length);n.pushAll(this._rootTiles);let r=this.snapLevel,i=this._splitLimits,a=this._eyePosRenderSR;this._allTiles.forAll(e=>{e.maxLevelDeltaNeighborCount=0,e.unmergableChildCount=0});let o=this.view.state.contentCamera.viewProjectionMatrix;for(;!n.empty;){let e=n.pop(),s=e.parent?.hasPendingUpdate(4),c=e.elevationLevel,l=s?4:e.shouldSplit(i,a,r),u=l===1;e.leaf?X(e,u):n.pushAll(e.children),s?(e.resetPendingUpdate(1),e.leaf||(e.setPendingUpdate(4),t=!0),this._updateClippingStatus(e),e.updateVisibility(),e.updateScreenDepth(o)):(u?(e.resetPendingUpdate(4),e.leaf&&(e.setPendingUpdate(1),t=!0)):(e.resetPendingUpdate(1)&&e.updateAgentSuspension(),l===2&&e.updateAgents(0),e.leaf||(e.setPendingUpdate(4),e.resetPendingUpdate(1),t=!0)),e.elevationLevel!==c&&this.updateElevationSources(e))}this._allTilesDirty=t,this.requestUpdate(),this._shortBatches&&this._updatePendingTileGeometries(),e.madeProgress()}_sortTiles(e){!e.done&&!this._allTilesSorted&&this.view.pointsOfInterest?.focus&&(ht(this._allTiles,this.view.pointsOfInterest.focus.renderLocation),this._allTilesSorted=!0,this._treeDebugger?.update(),e.madeProgress())}_markTileToUpdate(e){N(e.loaded),e.intersectsClippingArea&&(this._pendingTilesToUpdate.add(e),this._markAllTileNeighborsForUpdate(e))}_hasPendingGeometryWithoutIndices(){for(let e of this._pendingTilesToUpdate)if(e.loaded&&e.intersectsClippingArea&&e.renderData?.vao?.indexBuffer==null)return!0;return!1}_updatePendingTileGeometries(){let e=this._pendingTilesToUpdate,t=[];if(e.forEach(e=>{this._canUpdateTileGeometry(e)&&t.push(e)}),t.length===0){e.clear();return}let n=(n,r)=>{!r||!this._canUpdateTileGeometry(r)||r.level<n.level||e.has(r)||(e.add(r),t.push(r),r.renderData.updateNeighborData())};t.sort(U);let r=t.length;for(let i=0;i<r;++i){let r=t[i];N(r.loaded),N(r.intersectsClippingArea);let a=r.renderData;if(!a?.geometryState)continue;a.updateNeighborData();let o=a.dirtyEdgeResolutions,s=a.geometryState,c=e=>{let t=lt[e];n(r,s.cornerPeerNeighbors[e]?.findCorner(at(t),e=>e.loaded))};for(let t=0;t<4;++t)if(o&1<<t){let i=a.geometryState.edgePeerNeighbors[t];i&&i?.level>=r.level&&i.forAllSubtreeOnSide(it(P[t]),t=>this._canUpdateTileGeometry(t)?(N(e.has(t)||U(r,t)<0),n(r,t),!0):!1),c((t+1)%4),c(t)}}e.clear(),t.sort(U),this._updateTilesGeometries(t),this._shouldEmitChangeEvent=!0,V&&ot&&this.checkAllTilesWaterproofness(`pending-geometries-updated`)}_mergeAndSplit(e,t){if(this.freeze||e.done||!this._allTilesDirty)return;this._allTilesDirty=!1,this.requestUpdate();let n=!1,r=this.view.state.fixedContentCamera,i=!1;for(;!e.done;){i=!0;let a=!1,o=!this._allTiles.some(i=>{if(!n&&!r&&!i.visible)return e.done;let o=i;if(i.hasPendingUpdate(4)){if(!t||i.unmergableChildCount>0)return e.done;for(i.resetPendingUpdate(4);o.parent!=null&&o.parent.unmergableChildCount===0&&o.parent.resetPendingUpdate(4);)o=o.parent;this._mergeTile(o),a=!0,e.madeProgress()}else if(i.resetPendingUpdate(1)){let t=!0,n=i.level;if(n>=A){let e=e=>e.leaf||n-e.level<A;for(let r=0;r<4;++r){let a=i.findNeighborTile(P[r],e);a!=null&&n-a.level===A&&(t=!1,V&&(N(a.leaf),N(a.hasPendingUpdate(1))))}}t?(this._splitTile(i),e.madeProgress(),a=!0):i.setPendingUpdate(1)}return e.done});if(a&&(this._allTilesSorted=!1,this._allTilesDirty=!0),o){if(!n){n=!0;continue}if(!a)break}else this._allTilesDirty=!0}i?e.madeProgress():this._allTilesDirty=!0,this._allTilesCreated=!this.allTiles.some(e=>e.hasPendingUpdate(1)||e.hasPendingUpdate(4)&&e.unmergableChildCount===0),this._sortTiles(e)}_updateElevation(e){e.done||this._allTiles.some(t=>(t.resetPendingUpdate(8)&&(this._updateTileGeometryState(t),e.madeProgress()),e.done))}updateElevationSources(e){e.needsElevationSourceUpdate()&&(e.updateAgents(0),e.markElevationSourceUpdateRequested(),this.requestUpdate())}_updateTextures(e){if(e.done)return!0;let t=!0;return this._allTiles.some(n=>(this._updateTileTexture(n,e)||(t=!1),e.done)),t}_updateClippingExtent(){this.spatialReference&&(this.updateOverlayParameters(),this.requestRender(1),this.overlayManager.setPlacementDirty(),this._updateRootTiles())}get _lodBias(){return this.view.qualitySettings.tiledSurface.lodBias-(1-this.view.quality)*tt}_getLodBiasCorrectedScale(e){let t=this.tilingScheme.levels,n=te(e-this._lodBias,0,t.length-1),r=n-Math.floor(n),i=t[Math.floor(n)].scale,a=t[Math.ceil(n)].scale;return i*(1-r)+a*r}_removeAllTiles(){this.renderer.visible=!1,this._pendingTilesToUpdate.clear(),this._pendingTilesForElevationUpdateEvent.clear(),this._rootTiles!=null&&(this._rootTiles.forEach(e=>this._purgeTile(e)),this._setRootTiles(null),this.notifyChange(`ready`)),this._allTiles.clear(),this.notifyChange(`demResolution`),this.emit(`tiles-changed`,{allTiles:this.allTiles})}_purgeSubtree(e){let t=e.children;t[0]&&(this._purgeTile(t[0]),this._purgeTile(t[1]),this._purgeTile(t[2]),this._purgeTile(t[3]),e.clearChildren())}_purgeTile(e){e.leaf?Z(e):this._purgeSubtree(e),this._allTiles.removeUnordered(e),this._unloadTile(e),e.dispose(),this._tileCache.put(G._tileMemcacheKey,e),this.notifyChange(`demResolution`),this.emit(`tiles-changed`,{allTiles:this.allTiles})}_unloadTile(e){this._pendingTilesToUpdate.delete(e),this._pendingTilesForElevationUpdateEvent.delete(e),e.unload()}_splitTile(e){j(e.leaf,`Tile that is already split should not be split again!`),j(e.rendered,`Tile marked to split is not rendered`),Z(e);let t=e.createChildren();this._allTiles.pushArray(t),this.notifyChange(`demResolution`),this.emit(`tiles-changed`,{allTiles:this.allTiles}),e.updateAgentSuspension(),j(e.rendered,`parent should be rendered`),t.forEach(e=>this._loadTile(e)),t.forEach(e=>this._pendingTilesToUpdate.add(e)),this._unloadTile(e),this._markAllTileNeighborsForUpdate(e),this._emitTileScaleChange(e,e.level+1),this._allTilesDirty=!0,this._shortBatches&&this._updatePendingTileGeometries(),t.forEach(e=>X(e,e.hasPendingUpdate(1))),++this._performanceInfo.numSplit}_emitTileScaleChange(e,t=e.level){Y.spatialReference=this.spatialReference,Y.extent=e.extent,Y.scale=this._getLodBiasCorrectedScale(t),this.emit(`scale-change`,Y)}createTile(e,t,n,r){j(!!r,`createTile sanity check`);let i=this._acquireTile(e,t,n,r);return i.updateClippingStatus(this.groundExtent),i.updateScreenDepth(this.view.state.contentCamera.viewProjectionMatrix),this._shouldSplit(i)&&i.setPendingUpdate(1),i}get _shortBatches(){return this.view.state.mode!==2}_mergeTile(e){j(!e.hasPendingUpdate(1),`_mergeTile sanity check`),j(!e.leaf,`Cannot merge a leaf`),e.leaf||(this._purgeSubtree(e),j(!e.renderData,`Merging tile with existing render data?`),this._loadTile(e),this._markTileToUpdate(e),this._emitTileScaleChange(e),this._shortBatches&&this._updatePendingTileGeometries(),X(e,!1),this._allTilesDirty=!0,++this._performanceInfo.numMerged)}_loadTile(e){e.load(),this.requestUpdate(),this._allTilesDirty=!0,this.overlayManager?.hasOverlays&&e.updateOverlayParameters(this.overlayManager)}_handleLayerViewChanges(e=Ae){if(!this._layerViewsDirty)return;this._layerViewsDirty=!1;let t=!1,n=new Set,r=-1;for(let e=this.view.allLayerViews.length-1;e>=0;e--){let i=this.view.allLayerViews.items[e];if(n.add(i.uid),F(i)||I(i)){if(this._basemapLayerViewHandles.has(i.uid)&&!I(i)){let e=this._layerClassFromLayerView(i),n=this.getLayerIndexByUID(e,i.uid);n!=null&&((n<r||r==null)&&(t=!0),r=n)}else this._registerTiledLayerView(i),i.layer.loaded&&(t=!0)}}this._basemapLayerViewHandles.forEach((e,r)=>{n.has(r)||(this._unregisterTiledLayerView(r),t=!0)}),t&&this._updateTiledLayers(),this.hasCompositeBlendMode=this._hasCompositeBlendMode(),this._evaluateTransparency(),e.madeProgress()}get _isFullyTransparent(){if(this.view.map?.ground?.opacity>0)return!1;for(let e of this.view.allLayerViews.items)if(L(e)&&!Ee(e.layer)&&e.fullOpacity!==0)return!1;return!0}_hasCompositeBlendMode(){for(let e of this.view.allLayerViews.items)if((R(e)||I(e))&&Be(Ve[e.layer.blendMode]))return!0;return!1}_layerClassFromLayerView(e){return+!z(e)}_registerTiledLayerView(e){let t=[];if((R(e)||I(e))&&t.push(_(()=>e.layer.blendMode,()=>{this.hasCompositeBlendMode=this._hasCompositeBlendMode(),this._updateTileTextures(2)})),!I(e)){let n=this._layerClassFromLayerView(e);t.push(_(()=>!e.destroyed&&e.suspended,()=>this._updateTiledLayers())),t.push(_(()=>!e.destroyed&&e.fullOpacity,()=>this._updateTileTextures(2)));let{layer:r}=e;`effectiveScaleRange`in r&&t.push(_(()=>!e.destroyed&&r.effectiveScaleRange,()=>this._restartAllAgents(n))),t.push(e.on(`data-changed`,()=>{let t=this.getLayerIndexByUID(n,e.uid);t!=null&&this._invalidateLayerData(t,n)}))}this._unregisterTiledLayerView(e.uid),this._basemapLayerViewHandles.set(e.uid,t)}_unregisterTiledLayerView(e){let t=this._basemapLayerViewHandles.get(e);if(t){for(let e of t)e.remove();this._basemapLayerViewHandles.delete(e)}}_updateTiledLayers(){if(!this.tilingScheme||this.view.suspended)return;let e=this.view.allLayerViews,t=[[],[]],n=null;e.forEach(e=>{if(!e.layer||e.suspended||!F(e)||!e.fullExtent)return;let r=this._layerClassFromLayerView(e);if(r===1){let t=e.displayLevelRange.maxLevel;t!==1/0&&(n===null||t>n)&&(n=t)}t[r].push(e)});for(let e of Ke){let n=this._layerViews[e],r=t[e];r.reverse();let i=r.length,a=n.length!==i,o=Array(i),s=Array(n.length);this._layerIndexByUid[e].clear();for(let t=0;t<i;t++){let i=r[t].uid;this._layerIndexByUid[e].set(i,t);let c=n.indexOf(r[t]);o[t]=c,t!==c&&(a=!0),c>-1&&(s[c]=t)}if(a){let t=this._postorderIterator;for(t.reset(this._rootTiles);!t.done;)t.next().modifyLayers(s,o,e);this._layerViews[e]=r,this._restartAllAgents(e),this._updateTilesVisibility(this._rootTiles)}}this.tilingScheme.ensureMaxLod(n)&&(this._viewChangeUpdate(),this.notifyChange(`tilingScheme`))}_restartAllAgents(e){let t=this._postorderIterator;for(t.reset(this._rootTiles);!t.done;){let n=t.next();n.restartAgents(e),e===0&&n.computeElevationBounds()}this._updateRootTileElevationRange()}layerViewByIndex(e,t){return this._layerViews[t][e]}numLayers(e){return this._layerViews[e].length}_updateTileTextures(e){this._allTiles.forAll(t=>{t.updateAgents(1),e===1?this.renderer.updateTileTexture(t,16):t.updateRenderData(1,e)}),this._evaluateTransparency()}_invalidateLayerData(e,t){this._rootTiles!=null&&(W(this._rootTiles,n=>n.removeLayerAgent(e,t)),W(this._rootTiles,n=>{n.invalidateLayerData(e,t),n.restartAgents(t)}))}setTileTreeDirty(e){this._allTilesDirty=!0,e&&(this._allTilesCreated=!1)}requestRender(e=1){this.renderer.requestRender(e)}requestUpdate(){++this._pendingUpdates===1&&(this._hasPendingUpdates=!0)}requestTileData(e,t,n,r){let i=this.layerViewByIndex(t,n),{tilemapCache:a}=i;return!a||M(i)?this._requestTileData(e,n,i,r):(++this._asyncWorkItems,a.fetchAvailability(e.level,e.lij[1],e.lij[2],{...r,timeout:6e3}).catch(t=>{throw ae(r),h(t)||this._dataMissing(e,n,i),t}).then(()=>this._frameTask.schedule(()=>this._requestTileData(e,n,i,r),r.signal)).finally(()=>--this._asyncWorkItems))}_requestTileData(e,t,n,r){return this.destroying?Promise.resolve():t===0?z(n)?this._requestElevationTileData(e,n,r):Promise.reject():L(n)?this._requestMapTileData(e,n,r):Promise.reject()}_requestElevationTileData(e,t,n){++this._asyncWorkItems;let r=r=>{!g(n)&&r&&(this.setMemoryDirty(),this.requestUpdate(),this._elevationDataArrived(e,t,r))},i=n=>{h(n)||(f.getLogger(this).error(`Tile ${e.lij.toString()} layer 0/${t.uid} error ${n}`),this._dataMissing(e,0,t),this.requestUpdate())};return t.fetchElevationTile(e,{...De,...n}).then(e=>this._frameTask.schedule(()=>r(e)),i).finally(()=>--this._asyncWorkItems)}_elevationDataArrived(e,t,n){let r=this._layerIndexByUid[0].get(t.uid);if(r==null){f.getLogger(this).warn(`TerrainSurface: received data from unknown layer %d %s`,0,e.lij.toString());return}let i=new Ue(e.lij,e.extent,n);e.dataArrived(r,0,i),this.emit(`tile-data-changed`,{tile:e,layerIndex:r,layerClass:0});let a=[e],o=e.level,s=this._iteratorPool.acquire();for(s.reset(a);!s.done;){let e=s.next();e.findElevationBoundsForLayer(r,o),e.computeElevationBounds()}o===0&&this._updateRootTileElevationRange(),s.remove(),this._updateTilesVisibility(a)}_requestMapTileData(e,t,n){++this._asyncWorkItems;let r=(r,i)=>{B(i),g(n)||(console.error(`Tile ${e.lij.toString()} layer 1/${t.uid} error ${r}`),this._dataMissing(e,1,t),this.requestUpdate())},i=e=>t=>r(t,e);return t.fetchTile(e.lij,n).then(r=>this._frameTask.schedule(()=>{this.requestUpdate(),g(n)?B(r):this._mapTileDataArrived(e,t,r)},n.signal,i(r)).catch(i(r)),(e,t=null)=>this._frameTask.schedule(()=>r(e,t))).finally(()=>--this._asyncWorkItems)}_mapTileDataArrived(e,t,n){let r=this.getLayerIndexByUID(1,t.uid);r==null?(B(n),f.getLogger(this).warn(`TerrainSurface: received data from unknown layer`)):(e.dataArrived(r,1,n),this.emit(`tile-data-changed`,{tile:e,layerIndex:r,layerClass:1}))}_dataMissing(e,t,n){let r=this.getLayerIndexByUID(t,n.uid);r==null?f.getLogger(this).warn(`TerrainSurface: received data from unknown layer`):(e.dataMissing(r,t),this.emit(`tile-data-changed`,{tile:e,layerIndex:r,layerClass:t}))}get performanceInfo(){let e=this._performanceInfo;return e.numNodes=this._allTiles.length,e.numLeaves=e.numVisible=e.numRendered=e.numLoadedPerLevel.length=e.numRenderedPerLevel.length=0,this._allTiles.forAll(t=>{t.leaf&&e.numLeaves++;let n=t.level;t.renderData&&(e.numLoadedPerLevel[n]=(e.numLoadedPerLevel[n]||0)+1),t.visible&&(e.numVisible++,t.rendered&&(e.numRenderedPerLevel[n]=(e.numRenderedPerLevel[n]||0)+1,e.numRendered++))}),e}setMemoryDirty(){this._usedMemory=null}get usedMemory(){return this.tilingScheme?(this._usedMemory??=this._recalculateUsedMemory(),this._usedMemory??0):0}_recalculateUsedMemory(){return this.tilingScheme?Math.round(this._allTiles.reduce((e,t)=>e+t.usedMemory,0)):null}getUsedMemoryForLayerView(e){let t=0,n=this._layerClassFromLayerView(e),r=this.getLayerIndexByUID(n,e.uid);return r!=null&&this._allTiles.forAll(e=>t+=e.getUsedMemoryForLayer(n,r)),t}get renderPatchBorders(){return this._renderer.renderPatchBorders}set renderPatchBorders(e){this._renderer.renderPatchBorders=e}get renderingDisabled(){return this._renderer.renderingDisabled}set renderingDisabled(e){this._renderer.renderingDisabled=e}get test(){}checkAllTilesWaterproofness(e=`render-patch-groups`){}get isGeographic(){return this.spatialReference?.isGeographic??!1}get isWebMercator(){return this.spatialReference?.isWebMercator??!1}get isWebMercatorOnPlateCarree(){return this.isWebMercator&&xe(this.view?.renderSpatialReference)}isEastEndWrap(e){return this.isGlobal&&e[2]===this.lijEastEnd(e[0])-1}isWestEndWrap(e){return this.isGlobal&&e[2]===0}lijEastEnd(e){return 1<<e+ +!!this.isGeographic}wrapEastWest(e){let t=this.lijEastEnd(e[0]),n=e[2];if(0<=n&&n<t)return e;if(!this.isGlobal)return null;let r=(n+(n<0?t:0))%t;return[e[0],e[1],r]}enableInternalChecks(e){st(e)}enableWaterproofnessChecks(e){ct(e)}static cleanupTerrainSurface(){St.prune()}enable(e){e!==this.enabled&&(this._set(`enabled`,e),e?(this._updateRootTiles(),this.freeze=!1,this.view.elevationProvider.register(0,this)):(this.view.elevationProvider.unregister(this),this.freeze=!0,this._removeAllTiles(),this._setRootTiles(null)),this.notifyChange(`ready`))}updateOverlayParameters(){let{overlayManager:e}=this;this.allTiles.forAll(t=>t.updateOverlayParameters(e))}};e([n()],K.prototype,`_renderer`,void 0),e([n({constructOnly:!0})],K.prototype,`_scaleRangeQueries`,void 0),e([n({constructOnly:!0})],K.prototype,`view`,void 0),e([n({constructOnly:!0})],K.prototype,`overlayManager`,void 0),e([n()],K.prototype,`_hasPendingUpdates`,void 0),e([n()],K.prototype,`_asyncWorkItems`,void 0),e([n()],K.prototype,`_allTilesDirty`,void 0),e([n()],K.prototype,`_allTilesSorted`,void 0),e([n()],K.prototype,`allTilesCreated`,null),e([n()],K.prototype,`_allTilesCreated`,void 0),e([n()],K.prototype,`_viewChanged`,void 0),e([n({type:Number})],K.prototype,`heading`,void 0),e([n()],K.prototype,`_splitLimits`,void 0),e([n()],K.prototype,`_frameTask`,void 0),e([n()],K.prototype,`_tileConstructor`,null),e([n()],K.prototype,`_ellipsoid`,null),e([n()],K.prototype,`demResolution`,null),e([n({readOnly:!0})],K.prototype,`snapLevel`,null),e([n({readOnly:!0})],K.prototype,`lodSnappingEnabled`,null),e([n()],K.prototype,`_stencilEnabledExtents`,null),e([n({readOnly:!0})],K.prototype,`userClippingExtent`,null),e([n()],K.prototype,`_rootTilesExtent`,void 0),e([n({readOnly:!0})],K.prototype,`groundExtent`,null),e([n({readOnly:!0})],K.prototype,`fullGroundExtent`,null),e([n({readOnly:!0})],K.prototype,`_tilingSchemeExtent`,null),e([n({readOnly:!0})],K.prototype,`updating`,null),e([n({readOnly:!0})],K.prototype,`readyToRun`,null),e([n(ze)],K.prototype,`updatingProgress`,void 0),e([n({readOnly:!0})],K.prototype,`updatingProgressValue`,null),e([n()],K.prototype,`_maxNumUpdating`,void 0),e([n()],K.prototype,`baseOpacity`,null),e([n()],K.prototype,`hasCompositeBlendMode`,void 0),e([n()],K.prototype,`maxTextureScale`,void 0),e([n({readOnly:!0})],K.prototype,`ready`,null),e([n({readOnly:!0})],K.prototype,`rootTiles`,null),e([n()],K.prototype,`_rootTiles`,void 0),e([n()],K.prototype,`spatialReference`,null),e([n({type:t})],K.prototype,`backgroundColor`,null),e([n({value:!1})],K.prototype,`slicePlaneEnabled`,null),e([n()],K.prototype,`tilingScheme`,null),e([n({readOnly:!0})],K.prototype,`tilingSchemeLocked`,null),e([n({readOnly:!0})],K.prototype,`tilingSchemeLogic`,void 0),e([n()],K.prototype,`wireframe`,null),e([n()],K.prototype,`opaque`,null),e([n()],K.prototype,`invisible`,null),e([n({value:!1})],K.prototype,`freeze`,null),e([n()],K.prototype,`fadeDuration`,null),e([n()],K.prototype,`_xNormalizer`,null),e([n()],K.prototype,`visibleElevationRange`,null),e([n()],K.prototype,`_rootTileElevationRange`,void 0),e([n()],K.prototype,`_layerViewsDirty`,void 0),e([n()],K.prototype,`renderPatchBorders`,null),e([n()],K.prototype,`renderingDisabled`,null),e([n()],K.prototype,`isGeographic`,null),e([n()],K.prototype,`isWebMercator`,null),e([n()],K.prototype,`isWebMercatorOnPlateCarree`,null),e([n({readOnly:!0})],K.prototype,`enabled`,void 0),K=G=e([r(`esri.views.3d.terrain.TerrainSurface`)],K);const yt=K,q=d(),bt=new Se,J=S(),xt=S(),St=new ie,Y={spatialReference:null,extent:null,scale:0};function Ct(e,t,n){for(let r of e){if(!r.containsPointXY(t,n))continue;let e=r;for(;e&&!e.renderData;){let r=+(t>e.extentMidX)+(n<e.extentMidY?2:0);e=e.children[r]}let i=e?.renderData?.geometryState.samplerData??null;return We(t,n,i)}return null}function X(e,t){!e.leaf||e.level<A||$(e,e=>{t&&wt(e);let n=Q(e);if(e.maxLevelDeltaNeighborCount++,n){let t=e.parent;for(;t;){let e=Q(t);if(t.unmergableChildCount++,e)t=t.parent;else break}}})}function wt(e){if(e.hasPendingUpdate(1))return;let t=e.parent;for(;t?.resetPendingUpdate(4);)t=t.parent;e.resetPendingUpdate(4),e.leaf&&e.setPendingUpdate(1),e.level<A||$(e,e=>{wt(e)})}function Z(e){e.level<A||$(e,e=>{if(e.maxLevelDeltaNeighborCount--,e.maxLevelDeltaNeighborCount===0&&e.unmergableChildCount===0){let t=e.parent;for(;t&&(t.unmergableChildCount--,Q(t));)t=t.parent}})}function Q(e){return e.maxLevelDeltaNeighborCount===0&&e.unmergableChildCount===0}function $(e,t){if(e.level<A)return;let n=e.level-A,r=e.lij[1]>>A,i=e.lij[2]>>A,a=e=>e.leaf||e.level===n;for(let o=0;o<4;++o){let s=e.findNeighborTile(P[o],a);if(!s||s.level!==n)continue;let c=s.lij;(c[1]!==r||c[2]!==i)&&t(s)}}export{yt as default};
2
+ import{__decorate as e}from"tslib";import t from"../../../Color.js";import{property as n,subclass as r}from"../../../core/accessorSupport/decorators.js";import{filterInPlace as i,difference as a}from"../../../core/arrayUtils.js";import o from"../../../core/CollectionFlattener.js";import{toConst as s}from"../../../core/compilerUtils.js";import{EventedAccessor as c}from"../../../core/Evented.js";import"../../../core/has.js";import{set as l,copy as u,exactEquals as ee}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{create as d}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import f from"../../../core/Logger.js";import{clamp as te}from"../../../core/mathUtils.js";import{destroyMaybe as p,removeMaybe as ne}from"../../../core/maybe.js";import{MemCachePool as re}from"../../../core/MemCachePool.js";import m from"../../../core/ObjectPool.js";import ie from"../../../core/PooledArray.js";import{throwIfAborted as ae,isAbortError as h,isAborted as g}from"../../../core/promiseUtils.js";import{watch as _,syncAndInitial as v,initial as y,sync as b}from"../../../core/reactiveUtils.js";import"../../../core/scheduling.js";import{UpdatingHandles as oe}from"../../../core/support/UpdatingHandles.js";import{getMetersPerUnitForSR as se}from"../../../core/units.js";import{getReferenceEllipsoid as x,radiusModifier as ce}from"../../../geometry/ellipsoidUtils.js";import{projectBoundingSphere as le}from"../../../geometry/projection/projectBoundingSphere.js";import{getProjector as ue}from"../../../geometry/projection/projectors.js";import{projectPointToVector as de}from"../../../geometry/projection/projectPointToVector.js";import{projectVectorToVector as fe}from"../../../geometry/projection/projectVectorToVector.js";import{projectWithoutEngine as pe}from"../../../geometry/projectionUtils.js";import me from"../../../geometry/SpatialReference.js";import{create as S,fromExtent as he,equals as C,intersection as ge,intersectsSphere as _e}from"../../../geometry/support/aaBoundingRect.js";import{copy as ve,create as ye}from"../../../geometry/support/frustumPlanes.js";import{createSpatialReferenceCyclical as be}from"../../../geometry/support/normalizeUtils.js";import{isGeographic as w,isPlateCarree as xe}from"../../../geometry/support/spatialReferenceUtils.js";import{Sphere as Se}from"../../../geometry/support/sphere.js";import{ElevationQueryTileCache as Ce}from"../../../layers/support/ElevationQueryTileCache.js";import{IntegratedMeshSemantics as we}from"../../../layers/support/IntegratedMeshSemantics.js";import{isIntegratedMeshLayer as Te,isBaseLayer as Ee}from"../../../layers/support/layerUtils.js";import{queueHighPriority as De}from"../../../request/queue.js";import{hasLayerBasedScaleVisibility as Oe}from"../../support/layerViewUtils.js";import{ImmediateTask as T,TaskPriority as ke,noBudget as Ae}from"../../support/Scheduler.js";import{TextureCompressionTracker as je}from"../../support/TextureCompressionTracker.js";import{Yield as Me}from"../../support/Yield.js";import{debugFlags as E}from"../support/debugFlags.js";import{ElevationRange as D}from"../support/ElevationRange.js";import{ElevationUpdateEvent as Ne}from"../support/ElevationUpdateEvent.js";import{calculateElevationUpdateExtents as Pe}from"../support/elevationUpdateExtentUtils.js";import{toBoundingRect as Fe}from"../support/extentUtils.js";import{geographicMbsToGeographicExtent as Ie,mbsToGeographicExtent as Le,intersectsGeographicExtent as Re}from"../support/sphereExtentUtils.js";import{isSupportedGCSOnGlobe as O}from"../support/supportedSpatialReference.js";import{updatingProgress as ze}from"../support/updatingProperties.js";import{isCompositeBlendMode as Be,blendModeFromString as Ve}from"../webgl-engine/core/shaderLibrary/output/BlendOptions.js";import{ElevationBounds as He}from"./ElevationBounds.js";import{ElevationData as Ue,sampleElevation as We}from"./ElevationData.js";import{create as Ge}from"./ExtentHelper.js";import{LayerClasses as Ke}from"./LayerClass.js";import{OverlayManager as qe}from"./OverlayManager.js";import{PlanarPatch as Je}from"./PlanarPatch.js";import{Queue as Ye}from"./Queue.js";import{ScaleRangeQueries as Xe}from"./ScaleRangeQueries.js";import{SphericalPatch as Ze}from"./SphericalPatch.js";import{SplitLimits as Qe}from"./SplitLimits.js";import{maxRootTiles as k,tooManyRootTilesAfterChangeError as $e,tooManyRootTilesForLayerError as et,maxTileNeighborLevelDelta as A,maxMemoryLodBias as tt}from"./TerrainConst.js";import{TerrainRenderer as nt}from"./TerrainRenderer.js";import rt from"./TerrainSurfacePerformanceInfo.js";import{weakAssert as j,isVectorTileLayerView as M,internalAssert as N,oppositeEdge as it,neighborEdgeIndices as P,isSurfaceLayerView as F,isGroupLayerView as I,isMapTileLayerView as L,isBlendableLayerView as R,isElevationLayerView as z,releaseTerrainData as B,oppositeCorner as at,enableTerrainInternalChecks as V,enableWaterproofTests as ot,enableInternalTerrainChecks as st,enableTerrainWaterproofChecks as ct,neighborCornerIndices as lt}from"./terrainUtils.js";import{Tile as ut,lijEquals as H}from"./Tile.js";import{printAllocations as dt}from"./TilePerLayerInfo.js";import{sortTiles as ft,IteratorPreorder as pt,IteratorPostorder as mt,compareTilesByLij as U,sortTilesByPOI as ht,traverseTilesPreorder as W}from"./tileUtils.js";import{TilingSchemeLogic as gt}from"./TilingSchemeLogic.js";import{getGroundTransparencyModeFromOpacity as _t}from"./TransparencyMode.js";import{UpsampleInfo as vt}from"./UpsampleInfo.js";var G;let K=class extends c{static{G=this}get allTilesCreated(){return this._allTilesCreated}get allTiles(){return s(this._allTiles)}get renderedTiles(){return ft(i(this._allTiles.toArray(),e=>e.visible&&e.rendered))}get _tileConstructor(){return this.view.state.isGlobal?Ze:Je}get _ellipsoid(){return x(this.view.spatialReference)}get demResolution(){let{_allTiles:e,tilingScheme:t}=this;if(e.length===0)return{min:1,max:1};let n=se(t.spatialReference),r=1/0,i=-1/0;for(let a of e){let e=t.resolutionAtLevel(a.level)*n;r=Math.min(r,e),i=Math.max(i,e)}return{min:r,max:i}}constructor(e){super(e),this.terrainTextureCompressionTracker=new je,this._iteratorPool=new m(()=>new pt,e=>e.remove=()=>this._iteratorPool.release(e)),this._postorderIterator=new mt,this._hasPendingUpdates=!1,this._pendingUpdates=0,this._asyncWorkItems=0,this._allTilesDirty=!0,this._allTilesSorted=!0,this._allTilesCreated=!1,this._usedMemory=null,this._performanceInfo=new rt,this._waterproofnessErrorHandle=null,this._viewChanged=!1,this.heading=0,this._inFrameTask=!1,this._viewChangeUpdateDirty=!1,this._eyePosRenderSR=d(),this._eyePosSurfaceSR=d(),this._splitLimits=new Qe,this._layerViews=[[],[]],this._layerIndexByUid=[new Map,new Map],this._basemapLayerViewHandles=new Map,this._updatingHandles=new oe,this._poiWatchHandle=null,this._frameTask=T,this._allTiles=new ie,this._upsampleInfoPool=new m(()=>new vt),this._shouldEmitChangeEvent=!1,this._lodSnappingEnabled=!0,this._rootTilesExtent=S(),this.updatingProgress=.5,this._maxNumUpdating=1,this.hasCompositeBlendMode=!1,this.maxTextureScale=1.2,this._elevationProjectorCache=new Map,this._rootTileElevationRange=new D(1/0,-1/0),this._updatingRootTiles=!1,this._pendingTilesForElevationUpdateEvent=new Set,this._pendingTilesToUpdate=new Set,this.totalGeometryUpdates=0,this.totalTileUpdates=0,this._layerViewsDirty=!1,this.unloadedMemory=0,this.ignoresMemoryFactor=!1,this.enabled=!0,this.overlayManager=new qe({...e,terrainSurface:this}),this._renderer=new nt(this,this.overlayManager.renderer,this._allTiles,this.terrainTextureCompressionTracker,e.view),Oe()||(this._scaleRangeQueries=new Xe)}initialize(){let{view:e}=this,{resourceController:t}=e,{memoryController:n}=t;e.stage.addRenderPlugin(this._renderer),this._tileCache=new re((e,t)=>n.newCache(e,t),`terrain-tile`),this._upsampleMapCache=n.newCache(`terrain-upsample`,({tile:e})=>e.unloadMapData()),this._elevationQueryCache=new Ce(n.newCache(`elevation-query`));let r=this.overlayManager;this.addHandles([_(()=>r.renderer.isEmpty,()=>this._evaluateTransparency()),_(()=>this.renderer.visible,e=>this.freeze=!e),_(()=>this.heading,e=>{this._renderer.updateHeading(e),this._updateTileTextures(0)},v)],`overlayManager`),this._updatingHandles.add(()=>({heading:e.camera?.heading,state:e.state?.mode}),({heading:e,state:t})=>{if(e==null)return;if(this.isGlobal&&this.isGeographic||this.isWebMercatorOnPlateCarree){this.heading=Math.round(e/90)*90%360;return}let n=Math.round(e)%360,r=Math.abs(n-this.heading);(t===2||Math.min(r,360-r)>=30)&&(this.heading=n)},y),this.addHandles([_(()=>this.baseOpacity,()=>{this._handleLayerViewChanges(),this._updateTileTextures(this._evaluateTransparency()?1:2)},v),_(()=>this.hasCompositeBlendMode,()=>this._updateTileTextures(this._evaluateTransparency()?1:2),v),_(()=>this.backgroundColor,(e,t)=>{e?.equals(t)||(this._handleLayerViewChanges(),this._renderer.updateTileBackground(e))},b),_(()=>this.snapLevel,()=>this._viewChanged=!0,b),_(()=>this.view.pointsOfInterest,e=>{this._renderer.pointsOfInterest=e,this._poiWatchHandle=ne(this._poiWatchHandle),e&&(this._poiWatchHandle=this._updatingHandles.add(()=>e.focus?.renderLocation,()=>this._allTilesSorted=!1,{equals:ee}))}),_(()=>E.TERRAIN_TILE_TREE_SHOW_TILES,t=>{t&&!this._treeDebugger?import(`../layers/support/TerrainTileTree3DDebugger.js`).then(({TerrainTileTree3DDebugger:t})=>{!this._treeDebugger&&E.TERRAIN_TILE_TREE_SHOW_TILES&&(this._treeDebugger=new t({view:e}))}):t||(this._treeDebugger=p(this._treeDebugger))},y),_(()=>this.tilingScheme,e=>this._updateTilingScheme(e),b)]);let{spatialReference:i}=e;this._extentHelper=Ge(this.isGlobal,{layers:e.map.allLayers,layerViews:e.allLayerViews,viewSpatialReference:i});let a=new o({getCollections:()=>e.defaultsFromMap?.mapCollections?.map(({layers:e})=>e),getChildrenFunction:e=>e&&`layers`in e?e.layers:null}),s=new gt({layers:a,extentHelper:this._extentHelper,isGlobal:this.isGlobal,viewSpatialReference:i});this._set(`tilingSchemeLogic`,s);let c=t.scheduler;this._frameTask=c.registerTask(ke.TERRAIN_SURFACE,this),this.addHandles([_(()=>this._stencilEnabledExtents,e=>this._renderer.setStencilEnabledLayerExtents(e),y),_(()=>this.groundExtent,()=>this._updateRootTiles(),y),e.on(`resize`,()=>this._viewChangeUpdate()),_(()=>{let t=e.state;return[this._lodBias,this._lodSnappingEnabled,e.quality,t.camera,t.contentCamera,t.fixedContentCamera]},()=>this._viewChangeUpdate(),v),_(()=>e.qualitySettings?.fadeDuration,e=>this._renderer.textureFadingEnabled=e>0,y),_(()=>e.qualitySettings?.physicallyBasedRenderingEnabled,e=>this._renderer.pbrMode=e?5:0,y),_(()=>e.qualitySettings?.tiledSurface.elevationLevelDelta,()=>{this._allTiles.forAll(e=>this.updateElevationSources(e)),this._updateAllTileGeometries()}),e.allLayerViews.on(`after-changes`,()=>this._layerViewsDirty=!0)]),this._updatingHandles.add(()=>this.userClippingExtent,()=>this._updateClippingExtent()),this._layerViewsDirty=!0,this._handleLayerViewChanges(),this._renderer.updateTileBackground(this.backgroundColor)}clearHandles(){this._updatingHandles?.removeAll(),this.removeAllHandles(),this._basemapLayerViewHandles.forEach((e,t)=>this._unregisterTiledLayerView(t)),this._basemapLayerViewHandles.clear()}destroy(){this._waterproofnessErrorHandle?.remove(),this._waterproofnessErrorHandle=null,this._frameTask.remove(),this._frameTask=T,this._updatingHandles?.destroy(),this._removeAllTiles(),this._set(`tilingSchemeLogic`,p(this.tilingSchemeLogic)),this._basemapLayerViewHandles.forEach((e,t)=>this._unregisterTiledLayerView(t)),this._basemapLayerViewHandles.clear(),this._set(`overlayManager`,p(this.overlayManager)),this._tileCache=p(this._tileCache),this._allTiles.prune(),ut.prune(),this._treeDebugger=p(this._treeDebugger),this._renderer.destroyed||(this.view.stage.removeRenderPlugin(this._renderer),this._renderer.destroy()),this._renderer=null,this._iteratorPool=p(this._iteratorPool),this._upsampleMapCache=p(this._upsampleMapCache),this._elevationQueryCache=p(this._elevationQueryCache),this._set(`view`,null),this._extentHelper=p(this._extentHelper),this._upsampleInfoPool=p(this._upsampleInfoPool),dt(),this._layerViews.forEach(e=>e.length=0),this._performanceInfo=null}get renderer(){return this._renderer}get frustum(){return this.view.state.camera.frustum}get snapLevel(){return this._lodSnappingEnabled?this.view.terrainLevel:null}get upsampleInfoPool(){return this._upsampleInfoPool}get upsampleMapCache(){return this._upsampleMapCache}get elevationQueryCache(){return this._elevationQueryCache}get hasStencilEnabledExtents(){return!!this._stencilEnabledExtents?.length}get _stencilEnabledExtents(){let e=this.spatialReference;return e==null?null:Iterator.from(this.view.allLayerViews).map(t=>{let{layer:n}=t;if(!Te(n)||!we.shouldStencilTerrain(n))return null;let{fullExtent:r}=n,i=r==null||r.spatialReference.equals(e)?r:pe(r,r.spatialReference,e);return i?he(i):null}).filter(e=>e!=null).toArray()}get userClippingExtent(){let{spatialReference:e}=this,t=this.view?.clippingArea;if(t==null||e==null)return null;let n=S(),r=Fe(t,n,e)?n:null,i=this._get(`userClippingExtent`);return C(r,i)?i:r}get rootTilesExtent(){return this._rootTilesExtent}get groundExtent(){let e=ge(this.fullGroundExtent,this.userClippingExtent,S()),t=this._get(`groundExtent`);return C(e,t)?t:e}get fullGroundExtent(){return this._tilingSchemeExtent==null?this._rootTilesExtent:this._tilingSchemeExtent}get _tilingSchemeExtent(){return this.tilingSchemeLogic?.extent}get updating(){return this._hasPendingUpdates||(this._maxNumUpdating=1),this.enabled&&!!((this.readyToRun||this._updatingHandles?.updating||this._asyncWorkItems>0)&&this.ready&&!this.freeze||this.overlayManager?.updating||this.terrainTextureCompressionTracker.compressing)}get readyToRun(){return this.enabled&&(this._hasPendingUpdates||this._viewChanged||this._allTilesDirty||!this._allTilesSorted||this._layerViewsDirty||this._scaleRangeQueries?.updating||this._frameTask.updating)&&this.ready&&!this.freeze}get updatingProgressValue(){return this._maxNumUpdating=Math.max(this._pendingUpdates,this._maxNumUpdating),1-this._pendingUpdates/this._maxNumUpdating}get baseOpacity(){return this.view?.map?.ground?.opacity??1}set baseOpacity(e){this.view.map.ground.opacity=e}get isGlobal(){return this.view.state.isGlobal}get ready(){return!this.enabled||this._rootTiles!=null}get rootTiles(){return this._rootTiles}get spatialReference(){return this.tilingScheme?.spatialReference??me.WebMercator}get backgroundColor(){return this.view?.map?.ground?.surfaceColor}set backgroundColor(e){this.view.map.ground.surfaceColor=e}set slicePlaneEnabled(e){this._renderer.slicePlaneEnabled=e,this._set(`slicePlaneEnabled`,e),this._evaluateTransparency()}get tilingScheme(){return this.tilingSchemeLogic?.tilingScheme}get tilingSchemeLocked(){return this.tilingSchemeLogic?.tilingSchemeLocked??!1}get wireframe(){return this._renderer?.wireframe}set wireframe(e){e!==this._renderer.wireframe&&(this._renderer.wireframe=e,this._updateAllTileGeometries())}get opaque(){return this._renderer.transparency===0}get invisible(){return this._renderer.transparency===3}set freeze(e){this._set(`freeze`,e),this._viewChangeUpdate()}get fadeDuration(){return this.view.qualitySettings.fadeDuration??0}intersect(e,t,n,r){this._renderer.intersectRay(e,t,n,r)}intersectBudgeted(e,t,n,r,i){return this._renderer.intersectRayBudgeted(e,t,n,r,i)}getElevationLevelDelta(e){return e<4?3:this.view.qualitySettings.tiledSurface.elevationLevelDelta}get _xNormalizer(){return be(this.spatialReference)}getElevation(e,t,n,r){let i=this._rootTiles;if(!i?.length||!this.enabled||i[0].layerInfo[0].length===0)return null;let a=this._elevationProjectorCache.get(r);if(a===void 0&&(a=ue(r,this.spatialReference)??null,this._elevationProjectorCache.set(r,a)),a==null)return f.getLogger(this).error(`TerrainSurface.getElevation(): could not project given point to tiling scheme coordinate system`),null;let o=l(q,e,t,n);return a(o,0,o,0),Ct(i,this._xNormalizer?.normalize(o[0])??o[0],o[1])}getElevations(e,t,n){let r=this._rootTiles,i=r?r[0].layerInfo[0].length:0;if(!r?.length||i===0||!this.enabled)for(let e=0;e<t;++e)n(e,null);else for(let i=0;i<t;++i){let t=i*3,a=Ct(r,e[t],e[t+1]);n(i,a)}}getLayerIndexByUID(e,t){return this._layerIndexByUid[e].get(t)}get visibleElevationRange(){let e=1/0,t=-1/0;for(let n of this._allTiles)n.renderData&&(e=Math.min(e,n.elevationBoundsMin),t=Math.max(t,n.elevationBoundsMax));let n=this._get(`visibleElevationRange`);return n?.minElevation===e&&n.maxElevation===t?n:new D(e,t)}invalidateElevationRange(){this.notifyChange(`visibleElevationRange`)}tileElevationRangeChanged(e,t=1/0,n=-1/0){let r=this._get(`visibleElevationRange`);(!r||t===r.minElevation||n===r.maxElevation||e.renderData&&(e.elevationBoundsMin<r.minElevation||e.elevationBoundsMax>r.maxElevation))&&this.invalidateElevationRange()}getScale(e){if(!this.tilingScheme)return null;if(!de(e,q,this.spatialReference))return f.getLogger(this).error(`TerrainSurface.getScale(): could not project given point to tiling scheme coordinate system`),null;let t=this._rootTiles;if(t!=null){for(let e of t)if(e?.containsPoint(q)){let t=e;for(;t.children[0]&&!t.rendered;){let e=t.children[0].extent,n=0;q[0]>e[2]&&(n+=1),q[1]<e[1]&&(n+=2),t=t.children[n]}return this._getLodBiasCorrectedScale(t.level)}}return 1/0}getSphereElevationRange(e,t){if(!this.enabled)return null;let n=this._rootTiles,r=this.spatialReference;if(n==null||r==null||n.length===0)return null;let i=w(r);if(i){let n=w(t)&&O(t),i=x(t);if(n&&O(r)&&i===x(r))Ie(e,J,i.radius);else if(!Le(e,t,J,r))return f.getLogger(this).error(`TerrainSurface.getSphereElevationRange(): could not project the query sphere`),null}else if(!le(e,t,bt,r))return f.getLogger(this).error(`TerrainSurface.getSphereElevationRange(): could not project the query sphere`),null;let a=new D,o=[];for(let e of n)o.push(e);let s=0;for(;s<o.length;){let e=o[s];if(++s,!(i?Re(e.extent,J,r):_e(e.extent,bt)))continue;let t=e.children;if(t[0]==null||e.rendered)a.expandElevationRangeValues(e.elevationBoundsMin,e.elevationBoundsMax);else for(let e of t)o.push(e)}return a}getRootElevationRange(){return this.enabled&&this._rootTiles?new D(this._rootTileElevationRange.minElevation,this._rootTileElevationRange.maxElevation):null}getLowerBoundRadius(){let e=this.visibleElevationRange,t=(this._ellipsoid.radius+(e.isEmpty?0:e.minElevation))*ce;return Math.min(t,this._ellipsoid.radius)}queryVisibleScaleRange(e,t,n,r){if(!this._scaleRangeQueries)return;let i=t?this.tilingScheme.levelAtScale(t):0,a=n?this.tilingScheme.levelAtScale(n):1/0,o=this._lodBias;this._scaleRangeQueries.queryVisibleLevelRange(e,i+o,a+o,r)}_evaluateTransparency(){let e=this.baseOpacity,t=this.overlayManager.renderer.isEmpty,n=this._renderer.transparency,r=this._isFullyTransparent?_t(0,t):e>=1&&!this.hasCompositeBlendMode&&!this._renderer.slicePlaneEnabled?0:1;return this._renderer.transparency=r,n!==r&&(this.notifyChange(`opaque`),this.notifyChange(`invisible`),!0)}_updateTilingScheme(e){j(!!e,`tiling scheme cannot be reset to undefined`),e&&this._removeAllTiles(),this._updateClippingExtent(),e&&(this._updateTiledLayers(),this._renderer.tileSize=e.pixelSize,this.overlayManager.spatialReference=e.spatialReference,this._updateRootTiles())}static{this._tileMemcacheKey=`TerrainTileMemcache`}_acquireTile(e,t,n,r){let i=this._tileCache.pop(G._tileMemcacheKey);return i?(i.init(e,t,n,r,this),i):new this._tileConstructor(e,t,n,r,this)}get updatingRootTiles(){return this._updatingRootTiles}_updateRootTiles(){let{groundExtent:e,tilingScheme:t}=this;if(!t)return;if(!this.enabled){this._setRootTiles(null);return}let n=xt,r=t.rootTilesInExtent(e,n,k*5);if(this._rootTiles!=null){if(r.length>k){f.getLogger(this).warn($e);return}let e=this._rootTiles.map(e=>e.lij),t=a(e,r,H);if(this._updatingRootTiles=!0,t.removed.length>0||t.added.length>0){let e=this._rootTiles.filter(e=>t.removed.findIndex(t=>H(t,e.lij))>-1?(this._purgeTile(e),!1):!0);t.added.forEach(t=>e.push(this._newRootTile(t))),this._setRootTiles(e)}}else this._updatingRootTiles=!0,r.length>k&&(f.getLogger(this).warn(et),r=t.rootTilesInExtent(e,n,k)),this._setRootTiles(r.map(e=>this._newRootTile(e)));C(n,this._rootTilesExtent)||(this._rootTilesExtent=S(n)),this.renderer.visible=!0,this.overlayManager.setPlacementDirty(),this.notifyChange(`ready`),this._updateAllTileGeometries(),this._updatingRootTiles=!1,this._viewChangeUpdate(),this.checkAllTilesWaterproofness(`root-tiles-updated`)}_updateAllTileGeometries(){let e=this._allTiles.filter(e=>this._canUpdateTileGeometry(e));e.length===0||(e.sort(U),e.forEach(e=>this._renderer.updateTileGeometryState(e)),e.forEach(e=>e.renderData.updateNeighborData()),this._updateTilesGeometries(e)),this._pendingTilesToUpdate.clear()}_updateTilesGeometries(e){let t=e.filter(e=>this._canUpdateTileGeometry(e));if(t.length===0)return;let n=this.renderer;for(let e of t)n.updateGeometryIfNeeded(e);for(let e of t)this._pendingTilesForElevationUpdateEvent.add(e)}_canUpdateTileGeometry(e){return e.loaded&&e.intersectsClippingArea&&e.hasGeometryState}_shouldSplit(e){return e.shouldSplit(this._splitLimits,this._eyePosRenderSR,this.snapLevel)===1}_newRootTile(e){let t=this._acquireTile(0,e[1],e[2],null);return this._shouldSplit(t)&&t.setPendingUpdate(1),this._loadTile(t),this._markTileToUpdate(t),this._updateRootTileElevationRange(),t}_setRootTiles(e){if(this._rootTiles=e,this._allTiles.clear(),e!=null){let t=this._iteratorPool.acquire();for(t.reset(e);!t.done;)this._allTiles.push(t.next());t.remove()}this.invalidateElevationRange(),this._renderer.setRootTiles(this._rootTiles),this._updateTilesVisibility(e),this.notifyChange(`demResolution`),this.emit(`tiles-changed`,{allTiles:this.allTiles})}_runViewChangeUpdateIfDirty(){this._viewChangeUpdateDirty&&(this._viewChangeUpdateDirty=!1,this._viewChangeUpdate())}_viewChangeUpdate(){this.view&&!this.freeze&&this.tilingScheme&&this.renderer.visible&&(this._inFrameTask||this._updatingRootTiles?this._viewChangeUpdateDirty=!0:(this._viewChangeUpdateDirty=!1,this._updateViewDependentParameters(),this._updateTilesVisibility(this._rootTiles)))}_updateClippingStatus(e){e.updateClippingStatus(this.groundExtent)&&e.resetPendingUpdate(8)&&this._updateTileGeometryState(e)}_updateTilesVisibility(e){if(e==null)return;let t=this.groundExtent,n=this.view.state.contentCamera.viewProjectionMatrix;this.setTileTreeDirty(!1);let r=this._iteratorPool.acquire();for(r.reset(e);!r.done;){let e=r.next();e.updateClippingStatus(t)&&e.resetPendingUpdate(8)&&this._updateTileGeometryState(e),e.computeVisibility(),e.updateScreenDepth(n)}r.remove(),this._viewChanged=!0,this._allTilesDirty=!0,this._updatePendingTileGeometries()}_updateRootTileElevationRange(){let e=1/0,t=-1/0;this._rootTiles?.forEach(({elevationBoundsMin:n,elevationBoundsMax:r})=>{e=Math.min(e,n),t=Math.max(t,r)});let n=this._rootTileElevationRange;(n.minElevation!==e||n.maxElevation!==t)&&(this._rootTileElevationRange=new He(e,t))}_updateViewDependentParameters(){let{camera:e,contentCamera:t}=this.view.state,n=Math.tan(t.fovX*.5),r=Math.tan(t.fovY*.5),i=this.tilingScheme.pixelSize,a=2**-this._lodBias*e.pixelRatio;this._splitLimits.aboveGround=e.aboveGround,this._splitLimits.fovX=n,this._splitLimits.fovY=r,this._splitLimits.relativeWidthLimit=i/e.width*this.maxTextureScale*a,this._splitLimits.relativeHeightLimit=i/e.height*this.maxTextureScale*a,this._splitLimits.maxLod=this.tilingScheme.getMaxLod(),this._splitLimits.angledSplitBias=this.view.qualitySettings.tiledSurface.angledSplitBias,this.view.state.fixedContentCamera?this._splitLimits.frustum=ve(this._splitLimits.frustum??ye(),t.frustum):this._splitLimits.frustum=null,u(this._eyePosRenderSR,t.eye),fe(e.eye,this.view.renderSpatialReference,this._eyePosSurfaceSR,this.spatialReference)}_updateTileGeometryState(e){e.updateVisibility(),this._renderer.updateTileGeometryState(e)&&this._markTileToUpdate(e),this.setMemoryDirty()}_markAllTileNeighborsForUpdate(e){let t;e.forEachLoadedNeighbor(e=>{t??=this._layerViews[1].some(M),t&&e.setPendingUpdate(32),this._pendingTilesToUpdate.add(e)})}_updateTileTexture(e,t){let n=e.hasPendingUpdate(32)?32:e.hasPendingUpdate(16)?16:!1;if(n){let r=this._renderer.updateTileTexture(e,n);return this._usedMemory=null,r&&e.resetPendingUpdate(n),t.madeProgress(),r}return!0}_emitElevationUpdateEventForTiles(){if(!this._shouldEmitChangeEvent)return;let e=this._pendingTilesForElevationUpdateEvent;if(e.size>0){let t=new Float64Array(4*e.size),n=0;for(let r of e)t.set(r.extent,4*n),++n;e.clear();for(let e of Pe(t,this.spatialReference)){let t=new Ne(this.spatialReference,e,`ground`);this.emit(`elevation-change`,t)}}this._shouldEmitChangeEvent=!1}runTask(e){this._handleLayerViewChanges(e),this._frameTask.processQueue(e),this.renderer.processScaleRangeQueries(this._scaleRangeQueries,e),this._inFrameTask=!0,this._pendingUpdates=0,this._hasPendingUpdates=!1,this._updateAllTilesStatus(e),this._sortTiles(e);let t=!this.view.state.fixedContentCamera;this._mergeAndSplit(e,t),this._updateElevation(e);let n=this._updateTextures(e);t||this._mergeAndSplit(e,!0),this._inFrameTask=!1,this._runViewChangeUpdateIfDirty();let r=this._pendingTilesToUpdate.size>0,i=r&&this._hasPendingGeometryWithoutIndices();if((!e.done||i)&&this._updatePendingTileGeometries(),this._emitElevationUpdateEventForTiles(),e.done&&(e.hasProgressed||r&&!i)&&this.requestUpdate(),this.notifyChange(`updatingProgressValue`),!n||!e.hasProgressed)return Me}_checkTileInvariant(){}_updateAllTilesStatus(e){if(!this._viewChanged||!this._rootTiles||e.done)return;this._viewChanged=!1;let t=!1,n=new Ye(this._allTiles.length);n.pushAll(this._rootTiles);let r=this.snapLevel,i=this._splitLimits,a=this._eyePosRenderSR;this._allTiles.forAll(e=>{e.maxLevelDeltaNeighborCount=0,e.unmergableChildCount=0});let o=this.view.state.contentCamera.viewProjectionMatrix;for(;!n.empty;){let e=n.pop(),s=e.parent?.hasPendingUpdate(4),c=e.elevationLevel,l=s?4:e.shouldSplit(i,a,r),u=l===1;e.leaf?X(e,u):n.pushAll(e.children),s?(e.resetPendingUpdate(1),e.leaf||(e.setPendingUpdate(4),t=!0),this._updateClippingStatus(e),e.updateVisibility(),e.updateScreenDepth(o)):(u?(e.resetPendingUpdate(4),e.leaf&&(e.setPendingUpdate(1),t=!0)):(e.resetPendingUpdate(1)&&e.updateAgentSuspension(),l===2&&e.updateAgents(0),e.leaf||(e.setPendingUpdate(4),e.resetPendingUpdate(1),t=!0)),e.elevationLevel!==c&&this.updateElevationSources(e))}this._allTilesDirty=t,this.requestUpdate(),this._shortBatches&&this._updatePendingTileGeometries(),e.madeProgress()}_sortTiles(e){!e.done&&!this._allTilesSorted&&this.view.pointsOfInterest?.focus&&(ht(this._allTiles,this.view.pointsOfInterest.focus.renderLocation),this._allTilesSorted=!0,this._treeDebugger?.update(),e.madeProgress())}_markTileToUpdate(e){N(e.loaded),e.intersectsClippingArea&&(this._pendingTilesToUpdate.add(e),this._markAllTileNeighborsForUpdate(e))}_hasPendingGeometryWithoutIndices(){for(let e of this._pendingTilesToUpdate)if(e.loaded&&e.intersectsClippingArea&&e.renderData?.vao?.indexBuffer==null)return!0;return!1}_updatePendingTileGeometries(){let e=this._pendingTilesToUpdate,t=[];if(e.forEach(e=>{this._canUpdateTileGeometry(e)&&t.push(e)}),t.length===0){e.clear();return}let n=(n,r)=>{!r||!this._canUpdateTileGeometry(r)||r.level<n.level||e.has(r)||(e.add(r),t.push(r),r.renderData.updateNeighborData())};t.sort(U);let r=t.length;for(let i=0;i<r;++i){let r=t[i];N(r.loaded),N(r.intersectsClippingArea);let a=r.renderData;if(!a?.geometryState)continue;a.updateNeighborData();let o=a.dirtyEdgeResolutions,s=a.geometryState,c=e=>{let t=lt[e];n(r,s.cornerPeerNeighbors[e]?.findCorner(at(t),e=>e.loaded))};for(let t=0;t<4;++t)if(o&1<<t){let i=a.geometryState.edgePeerNeighbors[t];i&&i?.level>=r.level&&i.forAllSubtreeOnSide(it(P[t]),t=>this._canUpdateTileGeometry(t)?(N(e.has(t)||U(r,t)<0),n(r,t),!0):!1),c((t+1)%4),c(t)}}e.clear(),t.sort(U),this._updateTilesGeometries(t),this._shouldEmitChangeEvent=!0,V&&ot&&this.checkAllTilesWaterproofness(`pending-geometries-updated`)}_mergeAndSplit(e,t){if(this.freeze||e.done||!this._allTilesDirty)return;this._allTilesDirty=!1,this.requestUpdate();let n=!1,r=this.view.state.fixedContentCamera,i=!1;for(;!e.done;){i=!0;let a=!1,o=!this._allTiles.some(i=>{if(!n&&!r&&!i.visible)return e.done;let o=i;if(i.hasPendingUpdate(4)){if(!t||i.unmergableChildCount>0)return e.done;for(i.resetPendingUpdate(4);o.parent!=null&&o.parent.unmergableChildCount===0&&o.parent.resetPendingUpdate(4);)o=o.parent;this._mergeTile(o),a=!0,e.madeProgress()}else if(i.resetPendingUpdate(1)){let t=!0,n=i.level;if(n>=A){let e=e=>e.leaf||n-e.level<A;for(let r=0;r<4;++r){let a=i.findNeighborTile(P[r],e);a!=null&&n-a.level===A&&(t=!1,V&&(N(a.leaf),N(a.hasPendingUpdate(1))))}}t?(this._splitTile(i),e.madeProgress(),a=!0):i.setPendingUpdate(1)}return e.done});if(a&&(this._allTilesSorted=!1,this._allTilesDirty=!0),o){if(!n){n=!0;continue}if(!a)break}else this._allTilesDirty=!0}i?e.madeProgress():this._allTilesDirty=!0,this._allTilesCreated=!this.allTiles.some(e=>e.hasPendingUpdate(1)||e.hasPendingUpdate(4)&&e.unmergableChildCount===0),this._sortTiles(e)}_updateElevation(e){e.done||this._allTiles.some(t=>(t.resetPendingUpdate(8)&&(this._updateTileGeometryState(t),e.madeProgress()),e.done))}updateElevationSources(e){e.needsElevationSourceUpdate()&&(e.updateAgents(0),e.markElevationSourceUpdateRequested(),this.requestUpdate())}_updateTextures(e){if(e.done)return!0;let t=!0;return this._allTiles.some(n=>(this._updateTileTexture(n,e)||(t=!1),e.done)),t}_updateClippingExtent(){this.spatialReference&&(this.updateOverlayParameters(),this.requestRender(1),this.overlayManager.setPlacementDirty(),this._updateRootTiles())}get _lodBias(){return this.view.qualitySettings.tiledSurface.lodBias-(1-this.view.quality)*tt}_getLodBiasCorrectedScale(e){let t=this.tilingScheme.levels,n=te(e-this._lodBias,0,t.length-1),r=n-Math.floor(n),i=t[Math.floor(n)].scale,a=t[Math.ceil(n)].scale;return i*(1-r)+a*r}_removeAllTiles(){this.renderer.visible=!1,this._pendingTilesToUpdate.clear(),this._pendingTilesForElevationUpdateEvent.clear(),this._rootTiles!=null&&(this._rootTiles.forEach(e=>this._purgeTile(e)),this._setRootTiles(null),this.notifyChange(`ready`)),this._allTiles.clear(),this.notifyChange(`demResolution`),this.emit(`tiles-changed`,{allTiles:this.allTiles})}_purgeSubtree(e){let t=e.children;t[0]&&(this._purgeTile(t[0]),this._purgeTile(t[1]),this._purgeTile(t[2]),this._purgeTile(t[3]),e.clearChildren())}_purgeTile(e){e.leaf?Z(e):this._purgeSubtree(e),this._allTiles.removeUnordered(e),this._unloadTile(e),e.dispose(),this._tileCache.put(G._tileMemcacheKey,e),this.notifyChange(`demResolution`),this.emit(`tiles-changed`,{allTiles:this.allTiles})}_unloadTile(e){this._pendingTilesToUpdate.delete(e),this._pendingTilesForElevationUpdateEvent.delete(e),e.unload()}_splitTile(e){j(e.leaf,`Tile that is already split should not be split again!`),j(e.rendered,`Tile marked to split is not rendered`),Z(e);let t=e.createChildren();this._allTiles.pushArray(t),this.notifyChange(`demResolution`),this.emit(`tiles-changed`,{allTiles:this.allTiles}),e.updateAgentSuspension(),j(e.rendered,`parent should be rendered`),t.forEach(e=>this._loadTile(e)),t.forEach(e=>this._pendingTilesToUpdate.add(e)),this._unloadTile(e),this._markAllTileNeighborsForUpdate(e),this._emitTileScaleChange(e,e.level+1),this._allTilesDirty=!0,this._shortBatches&&this._updatePendingTileGeometries(),t.forEach(e=>X(e,e.hasPendingUpdate(1))),++this._performanceInfo.numSplit}_emitTileScaleChange(e,t=e.level){Y.spatialReference=this.spatialReference,Y.extent=e.extent,Y.scale=this._getLodBiasCorrectedScale(t),this.emit(`scale-change`,Y)}createTile(e,t,n,r){j(!!r,`createTile sanity check`);let i=this._acquireTile(e,t,n,r);return i.updateClippingStatus(this.groundExtent),i.updateScreenDepth(this.view.state.contentCamera.viewProjectionMatrix),this._shouldSplit(i)&&i.setPendingUpdate(1),i}get _shortBatches(){return this.view.state.mode!==2}_mergeTile(e){j(!e.hasPendingUpdate(1),`_mergeTile sanity check`),j(!e.leaf,`Cannot merge a leaf`),e.leaf||(this._purgeSubtree(e),j(!e.renderData,`Merging tile with existing render data?`),this._loadTile(e),this._markTileToUpdate(e),this._emitTileScaleChange(e),this._shortBatches&&this._updatePendingTileGeometries(),X(e,!1),this._allTilesDirty=!0,++this._performanceInfo.numMerged)}_loadTile(e){e.load(),this.requestUpdate(),this._allTilesDirty=!0,this.overlayManager?.hasOverlays&&e.updateOverlayParameters(this.overlayManager)}_handleLayerViewChanges(e=Ae){if(!this._layerViewsDirty)return;this._layerViewsDirty=!1;let t=!1,n=new Set,r=-1;for(let e=this.view.allLayerViews.length-1;e>=0;e--){let i=this.view.allLayerViews.items[e];if(n.add(i.uid),F(i)||I(i)){if(this._basemapLayerViewHandles.has(i.uid)&&!I(i)){let e=this._layerClassFromLayerView(i),n=this.getLayerIndexByUID(e,i.uid);n!=null&&((n<r||r==null)&&(t=!0),r=n)}else this._registerTiledLayerView(i),i.layer.loaded&&(t=!0)}}this._basemapLayerViewHandles.forEach((e,r)=>{n.has(r)||(this._unregisterTiledLayerView(r),t=!0)}),t&&this._updateTiledLayers(),this.hasCompositeBlendMode=this._hasCompositeBlendMode(),this._evaluateTransparency(),e.madeProgress()}get _isFullyTransparent(){if(this.view.map?.ground?.opacity>0)return!1;for(let e of this.view.allLayerViews.items)if(L(e)&&!Ee(e.layer)&&e.fullOpacity!==0)return!1;return!0}_hasCompositeBlendMode(){for(let e of this.view.allLayerViews.items)if((R(e)||I(e))&&Be(Ve[e.layer.blendMode]))return!0;return!1}_layerClassFromLayerView(e){return+!z(e)}_registerTiledLayerView(e){let t=[];if((R(e)||I(e))&&t.push(_(()=>e.layer.blendMode,()=>{this.hasCompositeBlendMode=this._hasCompositeBlendMode(),this._updateTileTextures(2)})),!I(e)){let n=this._layerClassFromLayerView(e);t.push(_(()=>!e.destroyed&&e.suspended,()=>this._updateTiledLayers())),t.push(_(()=>!e.destroyed&&e.fullOpacity,()=>this._updateTileTextures(2)));let{layer:r}=e;`effectiveScaleRange`in r&&t.push(_(()=>!e.destroyed&&r.effectiveScaleRange,()=>this._restartAllAgents(n))),t.push(e.on(`data-changed`,()=>{let t=this.getLayerIndexByUID(n,e.uid);t!=null&&this._invalidateLayerData(t,n)}))}this._unregisterTiledLayerView(e.uid),this._basemapLayerViewHandles.set(e.uid,t)}_unregisterTiledLayerView(e){let t=this._basemapLayerViewHandles.get(e);if(t){for(let e of t)e.remove();this._basemapLayerViewHandles.delete(e)}}_updateTiledLayers(){if(!this.tilingScheme||this.view.suspended)return;let e=this.view.allLayerViews,t=[[],[]],n=null;e.forEach(e=>{if(!e.layer||e.suspended||!F(e)||!e.fullExtent)return;let r=this._layerClassFromLayerView(e);if(r===1){let t=e.displayLevelRange.maxLevel;t!==1/0&&(n===null||t>n)&&(n=t)}t[r].push(e)});for(let e of Ke){let n=this._layerViews[e],r=t[e];r.reverse();let i=r.length,a=n.length!==i,o=Array(i),s=Array(n.length);this._layerIndexByUid[e].clear();for(let t=0;t<i;t++){let i=r[t].uid;this._layerIndexByUid[e].set(i,t);let c=n.indexOf(r[t]);o[t]=c,t!==c&&(a=!0),c>-1&&(s[c]=t)}if(a){let t=this._postorderIterator;for(t.reset(this._rootTiles);!t.done;)t.next().modifyLayers(s,o,e);this._layerViews[e]=r,this._restartAllAgents(e),this._updateTilesVisibility(this._rootTiles)}}this.tilingScheme.ensureMaxLod(n)&&(this._viewChangeUpdate(),this.notifyChange(`tilingScheme`))}_restartAllAgents(e){let t=this._postorderIterator;for(t.reset(this._rootTiles);!t.done;){let n=t.next();n.restartAgents(e),e===0&&n.computeElevationBounds()}this._updateRootTileElevationRange()}layerViewByIndex(e,t){return this._layerViews[t][e]}numLayers(e){return this._layerViews[e].length}_updateTileTextures(e){this._allTiles.forAll(t=>{t.updateAgents(1),e===1?this.renderer.updateTileTexture(t,16):t.updateRenderData(1,e)}),this._evaluateTransparency()}_invalidateLayerData(e,t){this._rootTiles!=null&&(W(this._rootTiles,n=>n.removeLayerAgent(e,t)),W(this._rootTiles,n=>{n.invalidateLayerData(e,t),n.restartAgents(t)}))}setTileTreeDirty(e){this._allTilesDirty=!0,e&&(this._allTilesCreated=!1)}requestRender(e=1){this.renderer.requestRender(e)}requestUpdate(){++this._pendingUpdates===1&&(this._hasPendingUpdates=!0)}requestTileData(e,t,n,r){let i=this.layerViewByIndex(t,n),{tilemapCache:a}=i;return!a||M(i)?this._requestTileData(e,n,i,r):(++this._asyncWorkItems,a.fetchAvailability(e.level,e.lij[1],e.lij[2],{...r,timeout:6e3}).catch(t=>{throw ae(r),h(t)||this._dataMissing(e,n,i),t}).then(()=>this._frameTask.schedule(()=>this._requestTileData(e,n,i,r),r.signal)).finally(()=>--this._asyncWorkItems))}_requestTileData(e,t,n,r){return this.destroying?Promise.resolve():t===0?z(n)?this._requestElevationTileData(e,n,r):Promise.reject():L(n)?this._requestMapTileData(e,n,r):Promise.reject()}_requestElevationTileData(e,t,n){++this._asyncWorkItems;let r=r=>{!g(n)&&r&&(this.setMemoryDirty(),this.requestUpdate(),this._elevationDataArrived(e,t,r))},i=n=>{h(n)||(f.getLogger(this).error(`Tile ${e.lij.toString()} layer 0/${t.uid} error ${n}`),this._dataMissing(e,0,t),this.requestUpdate())};return t.fetchElevationTile(e,{...De,...n}).then(e=>this._frameTask.schedule(()=>r(e)),i).finally(()=>--this._asyncWorkItems)}_elevationDataArrived(e,t,n){let r=this._layerIndexByUid[0].get(t.uid);if(r==null){f.getLogger(this).warn(`TerrainSurface: received data from unknown layer %d %s`,0,e.lij.toString());return}let i=new Ue(e.lij,e.extent,n);e.dataArrived(r,0,i),this.emit(`tile-data-changed`,{tile:e,layerIndex:r,layerClass:0});let a=[e],o=e.level,s=this._iteratorPool.acquire();for(s.reset(a);!s.done;){let e=s.next();e.findElevationBoundsForLayer(r,o),e.computeElevationBounds()}o===0&&this._updateRootTileElevationRange(),s.remove(),this._updateTilesVisibility(a)}_requestMapTileData(e,t,n){++this._asyncWorkItems;let r=(r,i)=>{B(i),g(n)||(console.error(`Tile ${e.lij.toString()} layer 1/${t.uid} error ${r}`),this._dataMissing(e,1,t),this.requestUpdate())},i=e=>t=>r(t,e);return t.fetchTile(e.lij,n).then(r=>this._frameTask.schedule(()=>{this.requestUpdate(),g(n)?B(r):this._mapTileDataArrived(e,t,r)},n.signal,i(r)).catch(i(r)),(e,t=null)=>this._frameTask.schedule(()=>r(e,t))).finally(()=>--this._asyncWorkItems)}_mapTileDataArrived(e,t,n){let r=this.getLayerIndexByUID(1,t.uid);r==null?(B(n),f.getLogger(this).warn(`TerrainSurface: received data from unknown layer`)):(e.dataArrived(r,1,n),this.emit(`tile-data-changed`,{tile:e,layerIndex:r,layerClass:1}))}_dataMissing(e,t,n){let r=this.getLayerIndexByUID(t,n.uid);r==null?f.getLogger(this).warn(`TerrainSurface: received data from unknown layer`):(e.dataMissing(r,t),this.emit(`tile-data-changed`,{tile:e,layerIndex:r,layerClass:t}))}get performanceInfo(){let e=this._performanceInfo;return e.numNodes=this._allTiles.length,e.numLeaves=e.numVisible=e.numRendered=e.numLoadedPerLevel.length=e.numRenderedPerLevel.length=0,this._allTiles.forAll(t=>{t.leaf&&e.numLeaves++;let n=t.level;t.renderData&&(e.numLoadedPerLevel[n]=(e.numLoadedPerLevel[n]||0)+1),t.visible&&(e.numVisible++,t.rendered&&(e.numRenderedPerLevel[n]=(e.numRenderedPerLevel[n]||0)+1,e.numRendered++))}),e}setMemoryDirty(){this._usedMemory=null}get usedMemory(){return this.tilingScheme?(this._usedMemory??=this._recalculateUsedMemory(),this._usedMemory??0):0}_recalculateUsedMemory(){return this.tilingScheme?Math.round(this._allTiles.reduce((e,t)=>e+t.usedMemory,0)):null}getUsedMemoryForLayerView(e){let t=0,n=this._layerClassFromLayerView(e),r=this.getLayerIndexByUID(n,e.uid);return r!=null&&this._allTiles.forAll(e=>t+=e.getUsedMemoryForLayer(n,r)),t}get renderPatchBorders(){return this._renderer.renderPatchBorders}set renderPatchBorders(e){this._renderer.renderPatchBorders=e}get renderingDisabled(){return this._renderer.renderingDisabled}set renderingDisabled(e){this._renderer.renderingDisabled=e}get test(){}checkAllTilesWaterproofness(e=`render-patch-groups`){}get isGeographic(){return this.spatialReference?.isGeographic??!1}get isWebMercator(){return this.spatialReference?.isWebMercator??!1}get isWebMercatorOnPlateCarree(){return this.isWebMercator&&xe(this.view?.renderSpatialReference)}isEastEndWrap(e){return this.isGlobal&&e[2]===this.lijEastEnd(e[0])-1}isWestEndWrap(e){return this.isGlobal&&e[2]===0}lijEastEnd(e){return 1<<e+ +!!this.isGeographic}wrapEastWest(e){let t=this.lijEastEnd(e[0]),n=e[2];if(0<=n&&n<t)return e;if(!this.isGlobal)return null;let r=(n+(n<0?t:0))%t;return[e[0],e[1],r]}enableInternalChecks(e){st(e)}enableWaterproofnessChecks(e){ct(e)}static cleanupTerrainSurface(){St.prune()}enable(e){e!==this.enabled&&(this._set(`enabled`,e),e?(this._updateRootTiles(),this.freeze=!1,this.view.elevationProvider.register(0,this)):(this.view.elevationProvider.unregister(this),this.freeze=!0,this._removeAllTiles(),this._setRootTiles(null)),this.notifyChange(`ready`))}updateOverlayParameters(){let{overlayManager:e}=this;this.allTiles.forAll(t=>t.updateOverlayParameters(e))}};e([n()],K.prototype,`_renderer`,void 0),e([n({constructOnly:!0})],K.prototype,`_scaleRangeQueries`,void 0),e([n({constructOnly:!0})],K.prototype,`view`,void 0),e([n({constructOnly:!0})],K.prototype,`overlayManager`,void 0),e([n()],K.prototype,`_hasPendingUpdates`,void 0),e([n()],K.prototype,`_asyncWorkItems`,void 0),e([n()],K.prototype,`_allTilesDirty`,void 0),e([n()],K.prototype,`_allTilesSorted`,void 0),e([n()],K.prototype,`allTilesCreated`,null),e([n()],K.prototype,`_allTilesCreated`,void 0),e([n()],K.prototype,`_viewChanged`,void 0),e([n({type:Number})],K.prototype,`heading`,void 0),e([n()],K.prototype,`_splitLimits`,void 0),e([n()],K.prototype,`_frameTask`,void 0),e([n()],K.prototype,`_tileConstructor`,null),e([n()],K.prototype,`_ellipsoid`,null),e([n()],K.prototype,`demResolution`,null),e([n({readOnly:!0})],K.prototype,`snapLevel`,null),e([n()],K.prototype,`_lodSnappingEnabled`,void 0),e([n()],K.prototype,`_stencilEnabledExtents`,null),e([n({readOnly:!0})],K.prototype,`userClippingExtent`,null),e([n()],K.prototype,`_rootTilesExtent`,void 0),e([n({readOnly:!0})],K.prototype,`groundExtent`,null),e([n({readOnly:!0})],K.prototype,`fullGroundExtent`,null),e([n({readOnly:!0})],K.prototype,`_tilingSchemeExtent`,null),e([n({readOnly:!0})],K.prototype,`updating`,null),e([n({readOnly:!0})],K.prototype,`readyToRun`,null),e([n(ze)],K.prototype,`updatingProgress`,void 0),e([n({readOnly:!0})],K.prototype,`updatingProgressValue`,null),e([n()],K.prototype,`_maxNumUpdating`,void 0),e([n()],K.prototype,`baseOpacity`,null),e([n()],K.prototype,`hasCompositeBlendMode`,void 0),e([n()],K.prototype,`maxTextureScale`,void 0),e([n({readOnly:!0})],K.prototype,`ready`,null),e([n({readOnly:!0})],K.prototype,`rootTiles`,null),e([n()],K.prototype,`_rootTiles`,void 0),e([n()],K.prototype,`spatialReference`,null),e([n({type:t})],K.prototype,`backgroundColor`,null),e([n({value:!1})],K.prototype,`slicePlaneEnabled`,null),e([n()],K.prototype,`tilingScheme`,null),e([n({readOnly:!0})],K.prototype,`tilingSchemeLocked`,null),e([n({readOnly:!0})],K.prototype,`tilingSchemeLogic`,void 0),e([n()],K.prototype,`wireframe`,null),e([n()],K.prototype,`opaque`,null),e([n()],K.prototype,`invisible`,null),e([n({value:!1})],K.prototype,`freeze`,null),e([n()],K.prototype,`fadeDuration`,null),e([n()],K.prototype,`_xNormalizer`,null),e([n()],K.prototype,`visibleElevationRange`,null),e([n()],K.prototype,`_rootTileElevationRange`,void 0),e([n()],K.prototype,`_layerViewsDirty`,void 0),e([n()],K.prototype,`renderPatchBorders`,null),e([n()],K.prototype,`renderingDisabled`,null),e([n()],K.prototype,`isGeographic`,null),e([n()],K.prototype,`isWebMercator`,null),e([n()],K.prototype,`isWebMercatorOnPlateCarree`,null),e([n({readOnly:!0})],K.prototype,`enabled`,void 0),K=G=e([r(`esri.views.3d.terrain.TerrainSurface`)],K);const yt=K,q=d(),bt=new Se,J=S(),xt=S(),St=new ie,Y={spatialReference:null,extent:null,scale:0};function Ct(e,t,n){for(let r of e){if(!r.containsPointXY(t,n))continue;let e=r;for(;e&&!e.renderData;){let r=+(t>e.extentMidX)+(n<e.extentMidY?2:0);e=e.children[r]}let i=e?.renderData?.geometryState.samplerData??null;return We(t,n,i)}return null}function X(e,t){!e.leaf||e.level<A||$(e,e=>{t&&wt(e);let n=Q(e);if(e.maxLevelDeltaNeighborCount++,n){let t=e.parent;for(;t;){let e=Q(t);if(t.unmergableChildCount++,e)t=t.parent;else break}}})}function wt(e){if(e.hasPendingUpdate(1))return;let t=e.parent;for(;t?.resetPendingUpdate(4);)t=t.parent;e.resetPendingUpdate(4),e.leaf&&e.setPendingUpdate(1),e.level<A||$(e,e=>{wt(e)})}function Z(e){e.level<A||$(e,e=>{if(e.maxLevelDeltaNeighborCount--,e.maxLevelDeltaNeighborCount===0&&e.unmergableChildCount===0){let t=e.parent;for(;t&&(t.unmergableChildCount--,Q(t));)t=t.parent}})}function Q(e){return e.maxLevelDeltaNeighborCount===0&&e.unmergableChildCount===0}function $(e,t){if(e.level<A)return;let n=e.level-A,r=e.lij[1]>>A,i=e.lij[2]>>A,a=e=>e.leaf||e.level===n;for(let o=0;o<4;++o){let s=e.findNeighborTile(P[o],a);if(!s||s.level!==n)continue;let c=s.lij;(c[1]!==r||c[2]!==i)&&t(s)}}export{yt as default};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import"../../../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import"../../../../../webgl/ShaderBuilder.js";import"../../../core/shaderLibrary/attributes/TextureCoordinateAttribute.glsl.js";import"../../../core/shaderLibrary/attributes/VertexColor.glsl.js";import"../../../core/shaderLibrary/attributes/VertexNormal.glsl.js";import"../../../core/shaderLibrary/attributes/VertexPosition.glsl.js";import"../../../core/shaderLibrary/bindUniforms.js";import"../../../core/shaderLibrary/forwardLinearDepthToWriteShadow.glsl.js";import"../../../core/shaderLibrary/output/DepthConversion.glsl.js";import"../../../core/shaderLibrary/output/OutputDepth.glsl.js";import"../../../core/shaderLibrary/output/OutputHighlight.glsl.js";import"../../../core/shaderLibrary/output/OutputHighlightOverlay.js";import"../../../core/shaderLibrary/ShaderOutput.js";import"../../../core/shaderLibrary/shading/ComputeFragmentNormals.glsl.js";import"../../../core/shaderLibrary/shading/ComputeMaterialColor.glsl.js";import"../../../core/shaderLibrary/shading/ComputeNormalTexture.glsl.js";import"../../../core/shaderLibrary/shading/EvaluateSceneLighting.glsl.js";import"../../../core/shaderLibrary/shading/getLocalUp.glsl.js";import"../../../core/shaderLibrary/shading/lightingUniforms.js";import"../../../core/shaderLibrary/shading/NormalUtils.glsl.js";import"../../../core/shaderLibrary/shading/pbrGlobals.glsl.js";import"../../../core/shaderLibrary/shading/PhysicallyBasedRenderingParameters.glsl.js";import"../../../core/shaderLibrary/shading/ReadBaseColorTexture.glsl.js";import"../../../core/shaderLibrary/shading/readShadow.glsl.js";import"../../../core/shaderLibrary/Slice.glsl.js";import"../../../core/shaderLibrary/terrain/Overlay.glsl.js";import"../../../core/shaderLibrary/util/DiscardOrAdjustAlpha.glsl.js";import"../../../core/shaderModules/BooleanDrawUniform.js";import"../../../core/shaderModules/FloatDrawUniform.js";import"../../../core/shaderModules/glsl.js";import"../../../core/shaderModules/Matrix3DrawUniform.js";import"../../../effects/snowcover/applySnow.glsl.js";import"../../../shaders/alphaCutoff.glsl.js";import"../../../shaders/OutputColorHighlightOLID.glsl.js";import"../../../shaders/SphereDepthInterpolate.glsl.js";import"./ComponentData.glsl.js";export{b as build}from"../../../../../../chunks/Component.glsl.js";
2
+ import"../../../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import"../../../../../webgl/ShaderBuilder.js";import"../../../core/shaderLibrary/attributes/TextureCoordinateAttribute.glsl.js";import"../../../core/shaderLibrary/attributes/VertexColor.glsl.js";import"../../../core/shaderLibrary/attributes/VertexNormal.glsl.js";import"../../../core/shaderLibrary/attributes/VertexPosition.glsl.js";import"../../../core/shaderLibrary/bindUniforms.js";import"../../../core/shaderLibrary/clampShadowPosition.glsl.js";import"../../../core/shaderLibrary/forwardLinearDepthToWriteShadow.glsl.js";import"../../../core/shaderLibrary/output/DepthConversion.glsl.js";import"../../../core/shaderLibrary/output/OutputDepth.glsl.js";import"../../../core/shaderLibrary/output/OutputHighlight.glsl.js";import"../../../core/shaderLibrary/output/OutputHighlightOverlay.js";import"../../../core/shaderLibrary/ShaderOutput.js";import"../../../core/shaderLibrary/shading/ComputeFragmentNormals.glsl.js";import"../../../core/shaderLibrary/shading/ComputeMaterialColor.glsl.js";import"../../../core/shaderLibrary/shading/ComputeNormalTexture.glsl.js";import"../../../core/shaderLibrary/shading/EvaluateSceneLighting.glsl.js";import"../../../core/shaderLibrary/shading/getLocalUp.glsl.js";import"../../../core/shaderLibrary/shading/lightingUniforms.js";import"../../../core/shaderLibrary/shading/NormalUtils.glsl.js";import"../../../core/shaderLibrary/shading/pbrGlobals.glsl.js";import"../../../core/shaderLibrary/shading/PhysicallyBasedRenderingParameters.glsl.js";import"../../../core/shaderLibrary/shading/ReadBaseColorTexture.glsl.js";import"../../../core/shaderLibrary/shading/readShadow.glsl.js";import"../../../core/shaderLibrary/Slice.glsl.js";import"../../../core/shaderLibrary/terrain/Overlay.glsl.js";import"../../../core/shaderLibrary/util/DiscardOrAdjustAlpha.glsl.js";import"../../../core/shaderModules/BooleanDrawUniform.js";import"../../../core/shaderModules/FloatDrawUniform.js";import"../../../core/shaderModules/glsl.js";import"../../../core/shaderModules/Matrix3DrawUniform.js";import"../../../effects/snowcover/applySnow.glsl.js";import"../../../shaders/alphaCutoff.glsl.js";import"../../../shaders/OutputColorHighlightOLID.glsl.js";import"../../../shaders/SphereDepthInterpolate.glsl.js";import"./ComponentData.glsl.js";export{b as build}from"../../../../../../chunks/Component.glsl.js";
@@ -0,0 +1,2 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
+ import{isShadow as e}from"./ShaderOutput.js";function t(t,n){e(n.output)&&t.vertex.main.add(`gl_Position.z = 0.0;`)}export{t as clampShadowPosition};
@@ -1,21 +1,21 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import{glsl as e,If as t}from"../../shaderModules/glsl.js";import{Texture2DPassUniform as n}from"../../shaderModules/Texture2DPassUniform.js";import{NormalAttribute as r}from"../attributes/NormalAttribute.glsl.js";import{ObjectAndLayerIdColor as i}from"../attributes/ObjectAndLayerIdColor.glsl.js";import{TextureCoordinateAttribute as a}from"../attributes/TextureCoordinateAttribute.glsl.js";import{outputDepth as o}from"../output/OutputDepth.glsl.js";import{OutputHighlight as s}from"../output/OutputHighlight.glsl.js";import{VisualVariables as c}from"../shading/VisualVariables.glsl.js";import{sliceDraw as l}from"../Slice.glsl.js";import{Transform as u}from"../Transform.glsl.js";import{nearFar as d}from"../util/cameraUniforms.js";import{DiscardOrAdjustAlphaPass as f}from"../util/DiscardOrAdjustAlpha.glsl.js";import{addProjViewLocalOrigin as p}from"../util/View.glsl.js";import{DefaultMaterialExternalColor as m}from"./DefaultMaterialExternalColor.glsl.js";function h(h,g){let{vertex:_,fragment:v,varyings:y}=h,{hasColorTexture:b,alphaDiscardMode:x}=g,S=b&&x!==1,{output:C,normalType:w,hasColorTextureTransform:T}=g;switch(C){case 3:p(_,g),h.include(u),v.include(l,g),h.include(a,g),S&&v.uniforms.add(new n(`tex`,e=>e.texture)),_.main.add(e`vpos = getVertexInLocalOriginSpace();
2
+ import{glsl as e,If as t}from"../../shaderModules/glsl.js";import{Texture2DPassUniform as n}from"../../shaderModules/Texture2DPassUniform.js";import{NormalAttribute as r}from"../attributes/NormalAttribute.glsl.js";import{ObjectAndLayerIdColor as i}from"../attributes/ObjectAndLayerIdColor.glsl.js";import{TextureCoordinateAttribute as a}from"../attributes/TextureCoordinateAttribute.glsl.js";import{clampShadowPosition as o}from"../clampShadowPosition.glsl.js";import{outputDepth as s}from"../output/OutputDepth.glsl.js";import{OutputHighlight as c}from"../output/OutputHighlight.glsl.js";import{VisualVariables as l}from"../shading/VisualVariables.glsl.js";import{sliceDraw as u}from"../Slice.glsl.js";import{Transform as d}from"../Transform.glsl.js";import{nearFar as f}from"../util/cameraUniforms.js";import{DiscardOrAdjustAlphaPass as p}from"../util/DiscardOrAdjustAlpha.glsl.js";import{addProjViewLocalOrigin as m}from"../util/View.glsl.js";import{DefaultMaterialExternalColor as h}from"./DefaultMaterialExternalColor.glsl.js";function g(g,_){let{vertex:v,fragment:y,varyings:b}=g,{hasColorTexture:x,alphaDiscardMode:S}=_,C=x&&S!==1,{output:w,normalType:T,hasColorTextureTransform:E}=_;switch(w){case 3:m(v,_),g.include(d),y.include(u,_),g.include(a,_),C&&y.uniforms.add(new n(`tex`,e=>e.texture)),v.main.add(e`vpos = getVertexInLocalOriginSpace();
3
3
  vpos = subtractOrigin(vpos);
4
4
  vpos = addVerticalOffset(vpos, localOrigin);
5
5
  gl_Position = transformPosition(proj, view, vpos);
6
- forwardTextureCoordinates();`),h.include(f,g),v.main.add(e`
6
+ forwardTextureCoordinates();`),g.include(p,_),y.main.add(e`
7
7
  discardBySlice(vpos);
8
- ${t(S,e`vec4 texColor = texture(tex, ${T?`colorUV`:`vuv0`});
9
- discardOrAdjustAlpha(texColor);`)}`);break;case 5:case 6:case 7:case 8:case 11:p(_,g),h.include(u),h.include(a,g),h.include(c,g),h.include(o,g),v.include(l,g),h.include(i,g),y.add(`depth`,`float`,{invariant:!0}),S&&v.uniforms.add(new n(`tex`,e=>e.texture)),_.uniforms.add(d).main.add(e`vpos = getVertexInLocalOriginSpace();
8
+ ${t(C,e`vec4 texColor = texture(tex, ${E?`colorUV`:`vuv0`});
9
+ discardOrAdjustAlpha(texColor);`)}`);break;case 5:case 6:case 7:case 8:case 11:m(v,_),g.include(d),g.include(a,_),g.include(l,_),g.include(s,_),y.include(u,_),g.include(i,_),b.add(`depth`,`float`,{invariant:!0}),C&&y.uniforms.add(new n(`tex`,e=>e.texture)),v.uniforms.add(f).main.add(e`vpos = getVertexInLocalOriginSpace();
10
10
  vpos = subtractOrigin(vpos);
11
11
  vpos = addVerticalOffset(vpos, localOrigin);
12
12
  gl_Position = transformPositionWithDepth(proj, view, vpos, nearFar, depth);
13
13
  forwardTextureCoordinates();
14
- forwardObjectAndLayerIdColor();`),h.include(f,g),v.main.add(e`
14
+ forwardObjectAndLayerIdColor();`),g.include(o,_),g.include(p,_),y.main.add(e`
15
15
  discardBySlice(vpos);
16
- ${t(S,e`vec4 texColor = texture(tex, ${T?`colorUV`:`vuv0`});
16
+ ${t(C,e`vec4 texColor = texture(tex, ${E?`colorUV`:`vuv0`});
17
17
  discardOrAdjustAlpha(texColor);`)}
18
- ${C===11?e`outputObjectAndLayerIdColor();`:e`outputDepth(depth);`}`);break;case 4:{p(_,g),h.include(u),h.include(r,g),h.include(a,g),h.include(c,g),h.include(m,g),S&&v.uniforms.add(new n(`tex`,e=>e.texture)),w===2&&y.add(`vPositionView`,`vec3`,{invariant:!0});let i=w===0||w===1;i&&y.add(`vNormalWorld`,`vec3`),_.main.add(e`
18
+ ${w===11?e`outputObjectAndLayerIdColor();`:e`outputDepth(depth);`}`);break;case 4:{m(v,_),g.include(d),g.include(r,_),g.include(a,_),g.include(l,_),g.include(h,_),C&&y.uniforms.add(new n(`tex`,e=>e.texture)),T===2&&b.add(`vPositionView`,`vec3`,{invariant:!0});let i=T===0||T===1;i&&b.add(`vNormalWorld`,`vec3`),v.main.add(e`
19
19
  forwardDefaultMaterialExternalColor();
20
20
 
21
21
  if (shouldCullByOpacity()) {
@@ -28,22 +28,22 @@ forwardObjectAndLayerIdColor();`),h.include(f,g),v.main.add(e`
28
28
  vpos = subtractOrigin(vpos);
29
29
  vpos = addVerticalOffset(vpos, localOrigin);
30
30
  gl_Position = transformPosition(proj, view, vpos);
31
- forwardTextureCoordinates();`),v.include(l,g),h.include(f,g),v.main.add(e`
31
+ forwardTextureCoordinates();`),y.include(u,_),g.include(p,_),y.main.add(e`
32
32
  discardBySlice(vpos);
33
- ${t(S,e`vec4 texColor = texture(tex, ${T?`colorUV`:`vuv0`});
33
+ ${t(C,e`vec4 texColor = texture(tex, ${E?`colorUV`:`vuv0`});
34
34
  discardOrAdjustAlpha(texColor);`,e`vec4 texColor = vec4(1.0);`)}
35
35
  float opacity = getDefaultMaterialOpacity(texColor.a);
36
36
 
37
- ${w===2?e`vec3 normal = screenDerivativeNormal(vPositionView);`:e`vec3 normal = normalize(vNormalWorld);
37
+ ${T===2?e`vec3 normal = screenDerivativeNormal(vPositionView);`:e`vec3 normal = normalize(vNormalWorld);
38
38
  if (gl_FrontFacing == false){
39
39
  normal = -normal;
40
40
  }`}
41
- fragColor = vec4(0.5 + 0.5 * normal, opacity);`);break}case 10:p(_,g),h.include(u),h.include(a,g),h.include(c,g),S&&v.uniforms.add(new n(`tex`,e=>e.texture)),_.main.add(e`vpos = getVertexInLocalOriginSpace();
41
+ fragColor = vec4(0.5 + 0.5 * normal, opacity);`);break}case 10:m(v,_),g.include(d),g.include(a,_),g.include(l,_),C&&y.uniforms.add(new n(`tex`,e=>e.texture)),v.main.add(e`vpos = getVertexInLocalOriginSpace();
42
42
  vpos = subtractOrigin(vpos);
43
43
  vpos = addVerticalOffset(vpos, localOrigin);
44
44
  gl_Position = transformPosition(proj, view, vpos);
45
- forwardTextureCoordinates();`),v.include(l,g),h.include(f,g),h.include(s,g),v.main.add(e`
45
+ forwardTextureCoordinates();`),y.include(u,_),g.include(p,_),g.include(c,_),y.main.add(e`
46
46
  discardBySlice(vpos);
47
- ${t(S,e`vec4 texColor = texture(tex, ${T?`colorUV`:`vuv0`});
47
+ ${t(C,e`vec4 texColor = texture(tex, ${E?`colorUV`:`vuv0`});
48
48
  discardOrAdjustAlpha(texColor);`)}
49
- calculateOcclusionAndOutputHighlight();`)}}export{h as DefaultMaterialAuxiliaryPasses};
49
+ calculateOcclusionAndOutputHighlight();`)}}export{g as DefaultMaterialAuxiliaryPasses};
@@ -1,5 +1,5 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import{FloatBindUniform as e}from"../../shaderModules/FloatBindUniform.js";import{FloatPassUniform as t}from"../../shaderModules/FloatPassUniform.js";import{glsl as n}from"../../shaderModules/glsl.js";import{addVerticalOffset as r}from"../attributes/VerticalOffset.glsl.js";import{viewport as i,viewNormal as a,pixelRatio as o}from"../util/cameraUniforms.js";import{ScreenSizePerspective as s,addScreenSizePerspectiveAlignment as c}from"../util/ScreenSizePerspective.glsl.js";import{addProjViewLocalOrigin as l,addCameraPosition as u}from"../util/View.glsl.js";const d=.5;function f(f,p){let m=f.vertex;f.include(s),f.attributes.add(`position`,`vec3`),f.vertex.inputs.add(`position`,()=>`position`),f.attributes.add(`normal`,`vec3`),p.hasVertexCenterOffset?f.attributes.add(`centerOffset`,`vec3`):m.constants.add(`centerOffset`,`vec3`,[0,0,0]),f.attributes.add(`groundDistance`,`float`),l(m,p),u(m,p),m.uniforms.add(i,new t(`polygonOffset`,e=>e.shaderPolygonOffset),new e(`aboveGround`,e=>e.camera.aboveGround?1:-1)),p.hasVerticalOffset&&r(m),m.code.add(n`struct ProjectHUDAux {
2
+ import{FloatBindUniform as e}from"../../shaderModules/FloatBindUniform.js";import{FloatPassUniform as t}from"../../shaderModules/FloatPassUniform.js";import{glsl as n}from"../../shaderModules/glsl.js";import{addVerticalOffset as r}from"../attributes/VerticalOffset.glsl.js";import{viewport as i,viewNormal as a,pixelRatio as o}from"../util/cameraUniforms.js";import{ScreenSizePerspective as s,addScreenSizePerspectiveAlignment as c}from"../util/ScreenSizePerspective.glsl.js";import{addProjView as l,addCameraPosition as u}from"../util/View.glsl.js";const d=.5;function f(f,p){let m=f.vertex;f.include(s),f.attributes.add(`position`,`vec3`),f.vertex.inputs.add(`position`,()=>`position`),f.attributes.add(`normal`,`vec3`),p.hasVertexCenterOffset?f.attributes.add(`centerOffset`,`vec3`):m.constants.add(`centerOffset`,`vec3`,[0,0,0]),f.attributes.add(`groundDistance`,`float`),l(m,p),u(m,p),m.uniforms.add(i,new t(`polygonOffset`,e=>e.shaderPolygonOffset),new e(`aboveGround`,e=>e.camera.aboveGround?1:-1)),p.hasVerticalOffset&&r(m),m.code.add(n`struct ProjectHUDAux {
3
3
  vec3 posModel;
4
4
  vec3 posView;
5
5
  vec3 vnormal;
@@ -1,4 +1,3 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import{ZEROS as e}from"../../../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{NoParameters as t}from"../../../../../webgl/NoParameters.js";import{Float2PassUniform as n}from"../../shaderModules/Float2PassUniform.js";import{FloatPassUniform as r}from"../../shaderModules/FloatPassUniform.js";import{glsl as i}from"../../shaderModules/glsl.js";class a extends t{constructor(){super(...arguments),this.scale=1,this.offset=e}}function o(e){e.attributes.add(`position`,`vec2`),e.attributes.add(`uv0`,`vec2`),e.varyings.add(`uv`,`vec2`),e.varyings.add(`vuv`,`vec2`),e.vertex.uniforms.add(new r(`scale`,e=>e.scale),new n(`offset`,e=>e.offset)).main.add(i`gl_Position = vec4(position, 0.0, 1.0);
3
- uv = uv0 * scale + offset;
4
- vuv = uv0;`)}export{o as TileComposite,a as TileCompositePassParameters};
2
+ import{ZEROS as e}from"../../../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{NoParameters as t}from"../../../../../webgl/NoParameters.js";import{Float2PassUniform as n}from"../../shaderModules/Float2PassUniform.js";import{FloatPassUniform as r}from"../../shaderModules/FloatPassUniform.js";import{glsl as i}from"../../shaderModules/glsl.js";class a extends t{constructor(){super(...arguments),this.scale=1,this.offset=e}}function o(e,t){e.attributes.add(`position`,`vec2`),e.vertex.main.add(`gl_Position = vec4(position, 0.0, 1.0);`),t.needsUV&&(e.attributes.add(`uv0`,`vec2`),e.varyings.add(`uv`,`vec2`),e.varyings.add(`vuv`,`vec2`),e.vertex.uniforms.add(new r(`scale`,e=>e.scale),new n(`offset`,e=>e.offset)).main.add(i`uv = uv0 * scale + offset;
3
+ vuv = uv0;`))}export{o as TileComposite,a as TileCompositePassParameters};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import{translate as e}from"../../../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as t}from"../../../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{set as n}from"../../../../../../core/libs/gl-matrix-2/math/vec3.js";import{ZEROS as r,create as i}from"../../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{Float3BindUniform as a}from"../../shaderModules/Float3BindUniform.js";import{Float3DrawUniform as o}from"../../shaderModules/Float3DrawUniform.js";import{Matrix4BindUniform as s}from"../../shaderModules/Matrix4BindUniform.js";import{Matrix4DrawUniform as c}from"../../shaderModules/Matrix4DrawUniform.js";import{projMatrix as l}from"./cameraUniforms.js";function u(e,t){t.instancedDoublePrecision?e.constants.add(`cameraPosition`,`vec3`,r):e.uniforms.add(new o(`cameraPosition`,({origin:e},{camera:t})=>n(m,t.viewInverseTransposeMatrix[3]-e[0],t.viewInverseTransposeMatrix[7]-e[1],t.viewInverseTransposeMatrix[11]-e[2])))}function d(t,n){n.instancedDoublePrecision?t.uniforms.add(l,new s(`view`,t=>e(p,t.camera.viewMatrix,f(t))),new a(`localOrigin`,e=>f(e))):t.uniforms.add(l,new c(`view`,(t,n)=>e(p,n.camera.viewMatrix,t.origin)),new o(`localOrigin`,e=>e.origin))}function f({camera:e}){return n(m,e.viewInverseTransposeMatrix[3],e.viewInverseTransposeMatrix[7],e.viewInverseTransposeMatrix[11])}const p=t(),m=i();export{u as addCameraPosition,d as addProjViewLocalOrigin};
2
+ import{translate as e}from"../../../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as t}from"../../../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{set as n}from"../../../../../../core/libs/gl-matrix-2/math/vec3.js";import{ZEROS as r,create as i}from"../../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{Float3BindUniform as a}from"../../shaderModules/Float3BindUniform.js";import{Float3DrawUniform as o}from"../../shaderModules/Float3DrawUniform.js";import{Matrix4BindUniform as s}from"../../shaderModules/Matrix4BindUniform.js";import{Matrix4DrawUniform as c}from"../../shaderModules/Matrix4DrawUniform.js";import{projMatrix as l}from"./cameraUniforms.js";function u(e,t){t.instancedDoublePrecision?e.constants.add(`cameraPosition`,`vec3`,r):e.uniforms.add(new o(`cameraPosition`,({origin:e},{camera:t})=>n(h,t.viewInverseTransposeMatrix[3]-e[0],t.viewInverseTransposeMatrix[7]-e[1],t.viewInverseTransposeMatrix[11]-e[2])))}function d(e,t){f(e,t),e.uniforms.add(t.instancedDoublePrecision?new a(`localOrigin`,e=>p(e)):new o(`localOrigin`,e=>e.origin))}function f(t,n){t.uniforms.add(l,n.instancedDoublePrecision?new s(`view`,t=>e(m,t.camera.viewMatrix,p(t))):new c(`view`,(t,n)=>e(m,n.camera.viewMatrix,t.origin)))}function p({camera:e}){return n(h,e.viewInverseTransposeMatrix[3],e.viewInverseTransposeMatrix[7],e.viewInverseTransposeMatrix[11])}const m=t(),h=i();export{u as addCameraPosition,f as addProjView,d as addProjViewLocalOrigin};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import{add as e}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{integerArrayElementBytes as t}from"../../../../core/memoryEstimations.js";import{getContinuousIndexArray as n}from"../../../../geometry/support/Indices.js";import{NullSphere as r,Sphere as i}from"../../../../geometry/support/sphere.js";import{affectsGeometry as a}from"./affectsGeometry.js";import{BoundingInfo as o}from"./BoundingInfo.js";import{BufferGeometryBaseInstance as s}from"./BufferGeometryBaseInstance.js";import{Object3DHighlightStateID as c}from"./Object3DStateID.js";import{assert as l}from"./Util.js";class u extends s{constructor(e,t,n,r=null,i=null){super(t),this.material=e,this.localOrigin=n,this.mapPositions=r,this.baseGeometry=i,this.layerViewUid=null,this.graphicUid=null,this.castShadow=!1,this._readPrimitivePosition=null,this._boundingInfo=null,this._boundingSphere=null,this._highlights=null,this._highlightOptionsCounts=null,this.occludees=void 0,this.visible=!0;let a=e?.useIndexing??!1,o=t.index!=null,s=i!=null;l(!s||!a&&i.buffers.index==null&&!o,`Instancing for index materials is not supported`),l(!s||t.vertex.count===1,`Instanced BufferGeometry requires exactly one instance`),l(a===o,`Material index requirement and BufferGeometry.buffers.index must match`)}instantiate(e){return new u(e,this._buffers,this.localOrigin,this.mapPositions,this.baseGeometry)}get usedMemoryExcludingBuffers(){return this._boundingInfo?.usedMemory??0}computeBufferMemory(e){return e.arrayMemory(this._buffers.index,t,!0)+e.arrayMemory(this._buffers.storage?.texelElementBuffer)+e.arrayMemory(this.mapPositions)+e.bufferMemory(this._buffers.vertex.buffer)}get indexCount(){return this.baseGeometry?.buffers.indexCount??this._buffers.indexCount??0}get faceCount(){return this.indexCount/3}get readPrimitivePosition(){return this._readPrimitivePosition??=this.material.createPrimitivePositionReader(this.buffers,this.baseGeometry?.buffers),this._readPrimitivePosition}get boundingInfo(){return this._boundingInfo||(this._boundingInfo=this._calculateBoundingInfo(),this._boundingInfo&&this.notifyMemoryChange?.(this._boundingInfo.usedMemory)),this._boundingInfo}get boundingSphere(){let t=this.boundingInfo?.sphere;if(t==null)return r;if(this._boundingSphere==null){let n=new i;n.copyFrom(t),e(n.center,n.center,this.localOrigin.vec3),this._boundingSphere=n}return this._boundingSphere}_calculateBoundingInfo(){let e=this.material.getPrimitivePositionCount(this.buffers,this.baseGeometry?.buffers);if(e===0)return null;let t=this.material.primitiveVertexCount;l(e%t===0,`Indexing error: `+e+` not divisible by `+t);let r=n(e/t);return new o(r,t,this.readPrimitivePosition,e=>this.notifyMemoryChange?.(e))}invalidateBoundingInfo(){let e=this._boundingInfo?.usedMemory??0;this._boundingInfo=null,this._boundingSphere=null,e&&this.notifyMemoryChange?.(-e)}getMutableBuffers(){return this._invalidatePositionCaches(),this._buffers}getMutableVertexField(e,t){let n=this._buffers.vertex.getField(e,t);return n!=null&&a(e)&&this._invalidatePositionCaches(),n}getMutableStorageField(e,t){let n=this._buffers.storage?.getField(e,t);return n!=null&&a(e)&&this._invalidatePositionCaches(),n}_invalidatePositionCaches(){this._readPrimitivePosition=null,this.invalidateBoundingInfo()}computeAttachmentOrigin(t){let n=this.material.getPrimitivePositionCount(this.buffers,this.baseGeometry?.buffers);return this.material.computeAttachmentOrigin(t,this.readPrimitivePosition,n)?(e(t,t,this.localOrigin.vec3),!0):!1}get highlights(){return this._highlights||d}get hasHighlights(){return(this._highlightOptionsCounts?.size??0)>0}forEachHighlightOption(e){this._highlightOptionsCounts?.forEach((t,n)=>e(n))}allocateIdAndHighlight(e){let t=new c(e);return this.addHighlight(t)}addHighlight(e){this._ensureHighlights().add(e);let{highlightName:t}=e,n=(this._highlightOptionsCounts?.get(t)??0)+1;return this._ensureHighlightOptionsCounts().set(t,n),e}_ensureHighlights(){let e=this._highlights;return e||(e=new Set,this._highlights=e),e}_ensureHighlightOptionsCounts(){let e=this._highlightOptionsCounts;return e||(e=new Map,this._highlightOptionsCounts=e),e}removeHighlight(e){if(this._highlights?.delete(e)){let{highlightName:t}=e,n=this._highlightOptionsCounts?.get(t)??0;n<=1?this._highlightOptionsCounts?.delete(t):this._ensureHighlightOptionsCounts().set(t,n-1)}}}const d=new Set;export{u as BufferGeometry};
2
+ import{add as e}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{integerArrayElementBytes as t}from"../../../../core/memoryEstimations.js";import{getContinuousIndexArray as n}from"../../../../geometry/support/Indices.js";import{NullSphere as r,Sphere as i}from"../../../../geometry/support/sphere.js";import{affectsGeometry as a}from"./affectsGeometry.js";import{BoundingInfo as o}from"./BoundingInfo.js";import{BufferGeometryBaseInstance as s}from"./BufferGeometryBaseInstance.js";import{Object3DHighlightStateID as c}from"./Object3DStateID.js";import{assert as l}from"./Util.js";class u extends s{constructor(e,t,n,r=null,i=null){super(t),this.material=e,this.localOrigin=n,this.mapPositions=r,this.baseGeometry=i,this.layerViewUid=null,this.graphicUid=null,this.castShadows=!1,this._readPrimitivePosition=null,this._boundingInfo=null,this._boundingSphere=null,this._highlights=null,this._highlightOptionsCounts=null,this.occludees=void 0,this.visible=!0;let a=e?.useIndexing??!1,o=t.index!=null,s=i!=null;l(!s||!a&&i.buffers.index==null&&!o,`Instancing for index materials is not supported`),l(!s||t.vertex.count===1,`Instanced BufferGeometry requires exactly one instance`),l(a===o,`Material index requirement and BufferGeometry.buffers.index must match`)}instantiate(e){return new u(e,this._buffers,this.localOrigin,this.mapPositions,this.baseGeometry)}get usedMemoryExcludingBuffers(){return this._boundingInfo?.usedMemory??0}computeBufferMemory(e){return e.arrayMemory(this._buffers.index,t,!0)+e.arrayMemory(this._buffers.storage?.texelElementBuffer)+e.arrayMemory(this.mapPositions)+e.bufferMemory(this._buffers.vertex.buffer)}get indexCount(){return this.baseGeometry?.buffers.indexCount??this._buffers.indexCount??0}get faceCount(){return this.indexCount/3}get readPrimitivePosition(){return this._readPrimitivePosition??=this.material.createPrimitivePositionReader(this.buffers,this.baseGeometry?.buffers),this._readPrimitivePosition}get boundingInfo(){return this._boundingInfo||(this._boundingInfo=this._calculateBoundingInfo(),this._boundingInfo&&this.notifyMemoryChange?.(this._boundingInfo.usedMemory)),this._boundingInfo}get boundingSphere(){let t=this.boundingInfo?.sphere;if(t==null)return r;if(this._boundingSphere==null){let n=new i;n.copyFrom(t),e(n.center,n.center,this.localOrigin.vec3),this._boundingSphere=n}return this._boundingSphere}_calculateBoundingInfo(){let e=this.material.getPrimitivePositionCount(this.buffers,this.baseGeometry?.buffers);if(e===0)return null;let t=this.material.primitiveVertexCount;l(e%t===0,`Indexing error: `+e+` not divisible by `+t);let r=n(e/t);return new o(r,t,this.readPrimitivePosition,e=>this.notifyMemoryChange?.(e))}invalidateBoundingInfo(){let e=this._boundingInfo?.usedMemory??0;this._boundingInfo=null,this._boundingSphere=null,e&&this.notifyMemoryChange?.(-e)}getMutableBuffers(){return this._invalidatePositionCaches(),this._buffers}getMutableVertexField(e,t){let n=this._buffers.vertex.getField(e,t);return n!=null&&a(e)&&this._invalidatePositionCaches(),n}getMutableStorageField(e,t){let n=this._buffers.storage?.getField(e,t);return n!=null&&a(e)&&this._invalidatePositionCaches(),n}_invalidatePositionCaches(){this._readPrimitivePosition=null,this.invalidateBoundingInfo()}computeAttachmentOrigin(t){let n=this.material.getPrimitivePositionCount(this.buffers,this.baseGeometry?.buffers);return this.material.computeAttachmentOrigin(t,this.readPrimitivePosition,n)?(e(t,t,this.localOrigin.vec3),!0):!1}get highlights(){return this._highlights||d}get hasHighlights(){return(this._highlightOptionsCounts?.size??0)>0}forEachHighlightOption(e){this._highlightOptionsCounts?.forEach((t,n)=>e(n))}allocateIdAndHighlight(e){let t=new c(e);return this.addHighlight(t)}addHighlight(e){this._ensureHighlights().add(e);let{highlightName:t}=e,n=(this._highlightOptionsCounts?.get(t)??0)+1;return this._ensureHighlightOptionsCounts().set(t,n),e}_ensureHighlights(){let e=this._highlights;return e||(e=new Set,this._highlights=e),e}_ensureHighlightOptionsCounts(){let e=this._highlightOptionsCounts;return e||(e=new Map,this._highlightOptionsCounts=e),e}removeHighlight(e){if(this._highlights?.delete(e)){let{highlightName:t}=e,n=this._highlightOptionsCounts?.get(t)??0;n<=1?this._highlightOptionsCounts?.delete(t):this._ensureHighlightOptionsCounts().set(t,n-1)}}}const d=new Set;export{u as BufferGeometry};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import{identity as e}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as t,IDENTITY as n}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{distance as r}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{generateUID as i}from"../../../../core/uid.js";import{empty as a,copy as o,offset as s,expandWithAABB as c,center as l,create as u}from"../../../../geometry/support/aaBoundingBox.js";import{addObject3DStateID as d,removeObject3DStateID as f}from"../materials/renderers/utils.js";import{affectsGeometry as p}from"./affectsGeometry.js";import{BoundingVolume as m}from"./BoundingVolume.js";import{Object3DOccludeeStateID as h,Object3DHighlightStateID as g}from"./Object3DStateID.js";import{assert as _}from"./Util.js";class v{constructor(e){this.id=i(),this.type=1,this.lastValidElevationBB=void 0,this._layer=null,this._visible=!0,this._highlightIds=new Set,this._boundingVolume=null,this._geometries=Array.from(e.geometries),this.castShadow=e.castShadow??!1,this.graphicUid=e.graphicUid,this.layerViewUid=e.layerViewUid;for(let e of this._geometries)this._applyObjectProperties(e);e.isElevationSource&&(this.lastValidElevationBB=a())}dispose(){this._geometries.length=0}get geometries(){return this._geometries}addGeometry(e){this._applyObjectProperties(e),this._geometries.push(e);for(let t of this._highlightIds)e.highlights.has(t)||e.addHighlight(t);this._emit(`geometriesChanged`,{object:this,removed:[],added:[e]}),this._highlightIds.size&&this._emit(`highlightChanged`,this),this._invalidateBoundingVolume()}removeGeometry(e){let t=this._geometries.splice(e,1)[0];if(t){for(let e of this._highlightIds)t.removeHighlight(e);this._emit(`geometriesChanged`,{object:this,removed:[t],added:[]}),this._highlightIds.size&&this._emit(`highlightChanged`,this),this._invalidateBoundingVolume()}}removeAllGeometries(){for(;this._geometries.length>0;)this.removeGeometry(0)}_applyObjectProperties(e){e.castShadow=this.castShadow,e.graphicUid=this.graphicUid,e.layerViewUid=this.layerViewUid,e.visible=this._visible}get layer(){return this._layer}set layer(e){_(this._layer==null||e==null,`BufferObject3D can only be added to a single Layer`),this._layer=e}get visible(){return this._visible}set visible(e){if(this._visible!==e){this._visible=e;for(let e of this._geometries)e.visible=this._visible;this._emit(`visibilityChanged`,this)}}_emit(e,t){this.layer?.events.emit(e,t)}maskOccludee(){let e=new h;for(let t of this._geometries)t.occludees=d(t.occludees,e);return this._emit(`occlusionChanged`,this),e}removeOcclude(e){for(let t of this._geometries)t.occludees=f(t.occludees,e);this._emit(`occlusionChanged`,this)}highlight(e){let t=new g(e);for(let e of this._geometries)e.addHighlight(t);return this._highlightIds.add(t),this._emit(`highlightChanged`,this),t}removeHighlight(e){if(this._highlightIds.delete(e)){for(let t of this._geometries)t.removeHighlight(e);this._emit(`highlightChanged`,this)}}removeStateID(e){e.channel===0?this.removeHighlight(e):this.removeOcclude(e)}getCombinedStaticTransformation(t,n){return e(n)}getCombinedShaderTransformation(n,r=t()){return e(r)}get boundingVolumeWorldSpace(){return this._boundingVolume||(this._boundingVolume=new m,this._validateBoundingVolume(this._boundingVolume)),this._boundingVolume}get boundingVolumeObjectSpace(){return this.boundingVolumeWorldSpace}_validateBoundingVolume(e){for(let t of this._geometries){let{boundingInfo:n,localOrigin:r}=t;if(n==null)continue;let[i,a,l]=r.vec3;o(y,n.box),s(y,i,a,l),c(e.box,y)}l(e.box,e.sphere.center);for(let t of this._geometries){let{boundingInfo:n,boundingSphere:i}=t;if(n==null)continue;let a=r(i.center,e.sphere.center);e.sphere.radius=Math.max(e.sphere.radius,a+n.sphere.radius)}}get transformation(){return n}get shaderTransformation(){return null}get effectiveTransformation(){return n}geometryVertexAttributeUpdated(e,t,n=!1){p(t)&&this._invalidateBoundingVolume(),this._emit(`attributesChanged`,{object:this,geometry:e,attribute:t,sync:n})}_invalidateBoundingVolume(){let e=this._boundingVolume?.sphere;this._boundingVolume=void 0,this.layer&&e&&this.layer.notifyObjectBBChanged(this,e)}}const y=u();export{v as BufferObject3D};
2
+ import{identity as e}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as t,IDENTITY as n}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{distance as r}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{generateUID as i}from"../../../../core/uid.js";import{empty as a,copy as o,offset as s,expandWithAABB as c,center as l,create as u}from"../../../../geometry/support/aaBoundingBox.js";import{addObject3DStateID as d,removeObject3DStateID as f}from"../materials/renderers/utils.js";import{affectsGeometry as p}from"./affectsGeometry.js";import{BoundingVolume as m}from"./BoundingVolume.js";import{Object3DOccludeeStateID as h,Object3DHighlightStateID as g}from"./Object3DStateID.js";import{assert as _}from"./Util.js";class v{constructor(e){this.id=i(),this.type=1,this.lastValidElevationBB=void 0,this._layer=null,this._visible=!0,this._highlightIds=new Set,this._boundingVolume=null,this._geometries=Array.from(e.geometries),this.castShadows=e.castShadows??!1,this.graphicUid=e.graphicUid,this.layerViewUid=e.layerViewUid;for(let e of this._geometries)this._applyObjectProperties(e);e.isElevationSource&&(this.lastValidElevationBB=a())}dispose(){this._geometries.length=0}get geometries(){return this._geometries}addGeometry(e){this._applyObjectProperties(e),this._geometries.push(e);for(let t of this._highlightIds)e.highlights.has(t)||e.addHighlight(t);this._emit(`geometriesChanged`,{object:this,removed:[],added:[e]}),this._highlightIds.size&&this._emit(`highlightChanged`,this),this._invalidateBoundingVolume()}removeGeometry(e){let t=this._geometries.splice(e,1)[0];if(t){for(let e of this._highlightIds)t.removeHighlight(e);this._emit(`geometriesChanged`,{object:this,removed:[t],added:[]}),this._highlightIds.size&&this._emit(`highlightChanged`,this),this._invalidateBoundingVolume()}}removeAllGeometries(){for(;this._geometries.length>0;)this.removeGeometry(0)}_applyObjectProperties(e){e.castShadows=this.castShadows,e.graphicUid=this.graphicUid,e.layerViewUid=this.layerViewUid,e.visible=this._visible}get layer(){return this._layer}set layer(e){_(this._layer==null||e==null,`BufferObject3D can only be added to a single Layer`),this._layer=e}get visible(){return this._visible}set visible(e){if(this._visible!==e){this._visible=e;for(let e of this._geometries)e.visible=this._visible;this._emit(`visibilityChanged`,this)}}_emit(e,t){this.layer?.events.emit(e,t)}maskOccludee(){let e=new h;for(let t of this._geometries)t.occludees=d(t.occludees,e);return this._emit(`occlusionChanged`,this),e}removeOcclude(e){for(let t of this._geometries)t.occludees=f(t.occludees,e);this._emit(`occlusionChanged`,this)}highlight(e){let t=new g(e);for(let e of this._geometries)e.addHighlight(t);return this._highlightIds.add(t),this._emit(`highlightChanged`,this),t}removeHighlight(e){if(this._highlightIds.delete(e)){for(let t of this._geometries)t.removeHighlight(e);this._emit(`highlightChanged`,this)}}removeStateID(e){e.channel===0?this.removeHighlight(e):this.removeOcclude(e)}getCombinedStaticTransformation(t,n){return e(n)}getCombinedShaderTransformation(n,r=t()){return e(r)}get boundingVolumeWorldSpace(){return this._boundingVolume||(this._boundingVolume=new m,this._validateBoundingVolume(this._boundingVolume)),this._boundingVolume}get boundingVolumeObjectSpace(){return this.boundingVolumeWorldSpace}_validateBoundingVolume(e){for(let t of this._geometries){let{boundingInfo:n,localOrigin:r}=t;if(n==null)continue;let[i,a,l]=r.vec3;o(y,n.box),s(y,i,a,l),c(e.box,y)}l(e.box,e.sphere.center);for(let t of this._geometries){let{boundingInfo:n,boundingSphere:i}=t;if(n==null)continue;let a=r(i.center,e.sphere.center);e.sphere.radius=Math.max(e.sphere.radius,a+n.sphere.radius)}}get transformation(){return n}get shaderTransformation(){return null}get effectiveTransformation(){return n}geometryVertexAttributeUpdated(e,t,n=!1){p(t)&&this._invalidateBoundingVolume(),this._emit(`attributesChanged`,{object:this,geometry:e,attribute:t,sync:n})}_invalidateBoundingVolume(){let e=this._boundingVolume?.sphere;this._boundingVolume=void 0,this.layer&&e&&this.layer.notifyObjectBBChanged(this,e)}}const y=u();export{v as BufferObject3D};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import"../../../../core/has.js";import{subtract as e,distance as t}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as n}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as r}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{generateUID as i}from"../../../../core/uid.js";import{getMetersPerUnitForSR as a}from"../../../../core/units.js";import{projectBuffer as o}from"../../../../geometry/projection/projectBuffer.js";import{RibbonLineMaterial as s}from"../materials/RibbonLineMaterial.js";import{Attribute as c}from"./Attribute.js";import{Geometry as l}from"./Geometry.js";import{fromValues as u}from"./LocalOriginFactory.js";import{Object3D as d}from"./Object3D.js";import{gridLocalOriginFactory as f}from"./testUtils.js";import{WebGLLayer as p}from"./WebGLLayer.js";class m{constructor(e){this._originSR=e,this._rootOriginId=`root/`+i(),this._origins=new Map,this._objects=new Map,this._gridSize=5e5,this._originSR?.isGeographic&&(this._gridSize/=a(this._originSR)),this._baselineDistance=this._gridSize*.5;let t=this._baselineDistance*g;this._baselineObjectSize=t/_}getOrigin(t){let n=this._origins.get(this._rootOriginId);if(n==null){let e=f.rootOrigin;if(e!=null)return this._origins.set(this._rootOriginId,u(e[0],e[1],e[2],this._rootOriginId)),this.getOrigin(t);let n=u(t[0],t[1],t[2],this._rootOriginId);return this._origins.set(this._rootOriginId,n),n}let r=this._gridSize,i=Math.round(t[0]/r),a=Math.round(t[1]/r),o=Math.round(t[2]/r),s=`${i}/${a}/${o}`,c=this._origins.get(s),l=r*.5;if(e(h,t,n.vec3),h[0]=Math.abs(h[0]),h[1]=Math.abs(h[1]),h[2]=Math.abs(h[2]),h[0]<l&&h[1]<l&&h[2]<l){if(c){let n=Math.max(...h);if(e(h,t,c.vec3),h[0]=Math.abs(h[0]),h[1]=Math.abs(h[1]),h[2]=Math.abs(h[2]),Math.max(...h)<n)return c}return n}return c||(c=u(i*r,a*r,o*r,s),this._origins.set(s,c)),c}needsOriginUpdate(e,n,r){let i=t(e.vec3,n),a=Math.max(1,r/this._baselineObjectSize);return i>this._baselineDistance*a}_drawOriginBox(e,t=r(1,1,0,1)){let n=window.view,i=n.stage,a=t.toString();if(!this._objects.has(a)){this._material=new s({width:2,color:t},n);let e=new p(i,{pickable:!1}),r=new d({castShadow:!1});e.add(r),this._objects.set(a,r)}let u=this._objects.get(a),f=[0,1,5,4,0,2,1,7,6,2,0,1,3,7,5,4,6,2,0],m=f.length,h=Array(m*3),g=[],_=this._gridSize*.5;for(let t=0;t<m;t++)h[t*3]=e[0]+(f[t]&1?_:-_),h[t*3+1]=e[1]+(f[t]&2?_:-_),h[t*3+2]=e[2]+(f[t]&4?_:-_),t>0&&g.push(t-1,t);o(h,this._originSR,0,h,n.renderSpatialReference,0,m);let v=new l(this._material,[[`position`,new c(h,g,3,!0)]],null);u.addGeometry(v)}get test(){}}const h=n(),g=2**-23,_=.05;export{m as GridLocalOriginFactory};
2
+ import"../../../../core/has.js";import{subtract as e,distance as t}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as n}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as r}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{generateUID as i}from"../../../../core/uid.js";import{getMetersPerUnitForSR as a}from"../../../../core/units.js";import{projectBuffer as o}from"../../../../geometry/projection/projectBuffer.js";import{RibbonLineMaterial as s}from"../materials/RibbonLineMaterial.js";import{Attribute as c}from"./Attribute.js";import{Geometry as l}from"./Geometry.js";import{fromValues as u}from"./LocalOriginFactory.js";import{Object3D as d}from"./Object3D.js";import{gridLocalOriginFactory as f}from"./testUtils.js";import{WebGLLayer as p}from"./WebGLLayer.js";class m{constructor(e){this._originSR=e,this._rootOriginId=`root/`+i(),this._origins=new Map,this._objects=new Map,this._gridSize=5e5,this._originSR?.isGeographic&&(this._gridSize/=a(this._originSR)),this._baselineDistance=this._gridSize*.5;let t=this._baselineDistance*g;this._baselineObjectSize=t/_}getOrigin(t){let n=this._origins.get(this._rootOriginId);if(n==null){let e=f.rootOrigin;if(e!=null)return this._origins.set(this._rootOriginId,u(e[0],e[1],e[2],this._rootOriginId)),this.getOrigin(t);let n=u(t[0],t[1],t[2],this._rootOriginId);return this._origins.set(this._rootOriginId,n),n}let r=this._gridSize,i=Math.round(t[0]/r),a=Math.round(t[1]/r),o=Math.round(t[2]/r),s=`${i}/${a}/${o}`,c=this._origins.get(s),l=r*.5;if(e(h,t,n.vec3),h[0]=Math.abs(h[0]),h[1]=Math.abs(h[1]),h[2]=Math.abs(h[2]),h[0]<l&&h[1]<l&&h[2]<l){if(c){let n=Math.max(...h);if(e(h,t,c.vec3),h[0]=Math.abs(h[0]),h[1]=Math.abs(h[1]),h[2]=Math.abs(h[2]),Math.max(...h)<n)return c}return n}return c||(c=u(i*r,a*r,o*r,s),this._origins.set(s,c)),c}needsOriginUpdate(e,n,r){let i=t(e.vec3,n),a=Math.max(1,r/this._baselineObjectSize);return i>this._baselineDistance*a}_drawOriginBox(e,t=r(1,1,0,1)){let n=window.view,i=n.stage,a=t.toString();if(!this._objects.has(a)){this._material=new s({width:2,color:t},n);let e=new p(i,{pickable:!1}),r=new d({castShadows:!1});e.add(r),this._objects.set(a,r)}let u=this._objects.get(a),f=[0,1,5,4,0,2,1,7,6,2,0,1,3,7,5,4,6,2,0],m=f.length,h=Array(m*3),g=[],_=this._gridSize*.5;for(let t=0;t<m;t++)h[t*3]=e[0]+(f[t]&1?_:-_),h[t*3+1]=e[1]+(f[t]&2?_:-_),h[t*3+2]=e[2]+(f[t]&4?_:-_),t>0&&g.push(t-1,t);o(h,this._originSR,0,h,n.renderSpatialReference,0,m);let v=new l(this._material,[[`position`,new c(h,g,3,!0)]],null);u.addGeometry(v)}get test(){}}const h=n(),g=2**-23,_=.05;export{m as GridLocalOriginFactory};