@arcgis/core 5.2.0-next.30 → 5.2.0-next.32

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 (156) hide show
  1. package/WebDocument2D.js +1 -1
  2. package/WebScene.js +1 -1
  3. package/arcade/ArcadePortal.js +1 -1
  4. package/arcade/Attachment.js +1 -1
  5. package/arcade/Dictionary.js +1 -1
  6. package/arcade/Feature.js +1 -1
  7. package/arcade/arcadeAsyncRuntime.js +1 -1
  8. package/arcade/arcadeCompiler.js +1 -1
  9. package/arcade/arcadeRuntime.js +1 -1
  10. package/arcade/containerUtils.js +1 -1
  11. package/arcade/debug.js +1 -1
  12. package/arcade/deepClone.js +1 -1
  13. package/arcade/featureSetUtils.js +1 -1
  14. package/arcade/featureset/sources/FeatureLayerDynamic.js +1 -1
  15. package/arcade/featureset/support/shared.js +1 -1
  16. package/arcade/functions/convertdirection.js +1 -1
  17. package/arcade/functions/date.js +1 -1
  18. package/arcade/functions/feature.js +1 -1
  19. package/arcade/functions/featuresetbase.js +1 -1
  20. package/arcade/functions/featuresetgeom.js +1 -1
  21. package/arcade/functions/featuresetstats.js +1 -1
  22. package/arcade/functions/featuresetstring.js +1 -1
  23. package/arcade/functions/geomasync.js +1 -1
  24. package/arcade/functions/geometry.js +1 -1
  25. package/arcade/functions/geomsync.js +1 -1
  26. package/arcade/functions/knowledgegraph.js +1 -1
  27. package/arcade/functions/maths.js +1 -1
  28. package/arcade/functions/stats.js +1 -1
  29. package/arcade/functions/string.js +1 -1
  30. package/arcade/geometry/constructors.js +1 -1
  31. package/arcade/geometry/functions.js +1 -1
  32. package/arcade/languageUtils.js +1 -1
  33. package/assets/esri/core/workers/RemoteClient.js +1 -1
  34. package/assets/esri/core/workers/chunks/{e5d2fab228d54b18a8a8.js → 08405116b5feb2d00101.js} +1 -1
  35. package/assets/esri/core/workers/chunks/{774615303c1cc9a77e20.js → 11af659688cf963ea6cd.js} +1 -1
  36. package/assets/esri/core/workers/chunks/{2665337e1b665e7e2b70.js → 15081b361fc42f40b865.js} +1 -1
  37. package/assets/esri/core/workers/chunks/{bcb2092c87d8d21c6458.js → 197b9f8483fad2258650.js} +1 -1
  38. package/assets/esri/core/workers/chunks/1cd8dff4373494b01ad4.js +1 -0
  39. package/assets/esri/core/workers/chunks/1d92da90fbbc3f98b201.js +1 -0
  40. package/assets/esri/core/workers/chunks/210ffc448c73a7bf63aa.js +1 -0
  41. package/assets/esri/core/workers/chunks/{a14e5607c5c091c77e3d.js → 2540beb53f1443a070d7.js} +1 -1
  42. package/assets/esri/core/workers/chunks/{689673173ca1c0e098fe.js → 25932fa010f9a32475c1.js} +1 -1
  43. package/assets/esri/core/workers/chunks/{e2d500ac1a264d09c857.js → 32b5d2537feefe6e94a3.js} +1 -1
  44. package/assets/esri/core/workers/chunks/34a024eda22d228e1fbe.js +1 -0
  45. package/assets/esri/core/workers/chunks/3f63b14b53b5ca716e3a.js +1 -0
  46. package/assets/esri/core/workers/chunks/{6df54132299b9e8f6dad.js → 456b77b8f13933a75b68.js} +1 -1
  47. package/assets/esri/core/workers/chunks/{3c342e662c13a05f4caf.js → 49713dfa4c8b788079d1.js} +1 -1
  48. package/assets/esri/core/workers/chunks/{45e4b9069263adeae394.js → 49a45083a9a155614c1c.js} +1 -1
  49. package/assets/esri/core/workers/chunks/4be31fcc5482a2526d2b.js +1 -0
  50. package/assets/esri/core/workers/chunks/{31d92ba9089617aa59ab.js → 57c003c6745d450558a7.js} +1 -1
  51. package/assets/esri/core/workers/chunks/{8104ac2eee69d79ada86.js → 6048c89fc4dcd2e9988d.js} +1 -1
  52. package/assets/esri/core/workers/chunks/{1b9c68e8431bb4608209.js → 6162f6735ea4622e54d8.js} +1 -1
  53. package/assets/esri/core/workers/chunks/684c9b4bd9590d2db12f.js +1 -0
  54. package/assets/esri/core/workers/chunks/684d3cb4fb233180b2d0.js +1 -0
  55. package/assets/esri/core/workers/chunks/{fe6385115d76e16e8da0.js → 75baf6dff6e7658b17b3.js} +1 -1
  56. package/assets/esri/core/workers/chunks/{166a0df6e37627e18976.js → 7a2dfa42610fe8414ed7.js} +1 -1
  57. package/assets/esri/core/workers/chunks/{43847d66726fd0bcbbb7.js → 83ae56c7fa8d84865605.js} +1 -1
  58. package/assets/esri/core/workers/chunks/8722e2790272e90a1897.js +1 -0
  59. package/assets/esri/core/workers/chunks/{1282598516cd0e3056b7.js → 977e6f589bd266d6067d.js} +2 -2
  60. package/assets/esri/core/workers/chunks/9f3d37e5f42bf1529673.js +1 -0
  61. package/assets/esri/core/workers/chunks/a833fc9250635eb4152f.js +1 -0
  62. package/assets/esri/core/workers/chunks/{47290f27375c76bcc9c7.js → b0253fe7b3529bc22270.js} +1 -1
  63. package/assets/esri/core/workers/chunks/b324bdb9c74fc3f956db.js +1 -0
  64. package/assets/esri/core/workers/chunks/{1bd7b7f4ee7ea6cb7ef9.js → b60f24a6c777301803f4.js} +1 -1
  65. package/assets/esri/core/workers/chunks/bd155794e9bc16dd0474.js +1 -0
  66. package/assets/esri/core/workers/chunks/{906f4c0fa8135e6c2f03.js → c660a5a1086870a3a6b9.js} +1 -1
  67. package/assets/esri/core/workers/chunks/cb58aff1ff186fa18345.js +1 -0
  68. package/assets/esri/core/workers/chunks/{17b98787a0698f584882.js → e7cb1b72f0b54e845741.js} +1 -1
  69. package/assets/esri/core/workers/chunks/{21122f3f3e19a7fd7d33.js → f69d3ff8a69c1985bca3.js} +1 -1
  70. package/assets/esri/libs/lyr3d/lyr3DMain.wasm +0 -0
  71. package/assets/esri/libs/parquet/pkg/bundle_bg.wasm +0 -0
  72. package/chunks/ShadowCastVisualize.glsl.js +4 -10
  73. package/chunks/aiServices.js +1 -1
  74. package/chunks/array.js +1 -1
  75. package/chunks/languageUtils.js +1 -1
  76. package/chunks/lyr3DMain.js +1 -1
  77. package/config.js +1 -1
  78. package/core/has.js +1 -1
  79. package/graphic/AnnotationFeatureGraphicOrigin.d.ts +3 -3
  80. package/graphic/AnnotationFeatureGraphicOrigin.js +1 -1
  81. package/intl/messages.d.ts +12 -2
  82. package/intl/t9n.d.ts +8 -1
  83. package/intl.d.ts +4 -0
  84. package/kernel.js +1 -1
  85. package/layers/AnnotationFeatureLayer.d.ts +1 -4
  86. package/layers/AnnotationFeatureLayer.js +1 -1
  87. package/layers/DimensionFeatureLayer.js +1 -1
  88. package/layers/VoxelWasmPerSceneView.js +1 -1
  89. package/layers/mixins/DataElementMixin.js +2 -0
  90. package/layers/support/AnnotationFeatureSublayer.js +1 -1
  91. package/layers/support/parquetUtils.js +1 -1
  92. package/package.json +1 -1
  93. package/support/ArcadeExpression.js +1 -1
  94. package/support/arcadeUtils.js +1 -1
  95. package/support/revision.js +1 -1
  96. package/symbols/cim/supportUtils.js +2 -0
  97. package/views/2d/engine/webgl/util/DimensionMatcher.js +1 -1
  98. package/views/2d/layers/features/layerAdapters/AnnotationLayerAdapter.js +1 -1
  99. package/views/2d/layers/features/layerAdapters/DimensionLayerAdapter.js +1 -1
  100. package/views/2d/layers/features/support/FeatureSetReaderParquet.js +1 -1
  101. package/views/2d/layers/support/annodime/annotationSchema.js +1 -1
  102. package/views/2d/layers/support/annodime/dimensionSchema.js +1 -1
  103. package/views/2d/layers/support/annodime/utils.js +1 -1
  104. package/views/2d/layers/support/annodime/virtualFields.js +1 -1
  105. package/views/3d/camera/constraintUtils.js +1 -1
  106. package/views/3d/state/ConstraintsManager.js +1 -1
  107. package/views/3d/terrain/PatchGeometryFactory.js +1 -1
  108. package/views/3d/terrain/PatchRenderData.js +1 -1
  109. package/views/3d/terrain/PatchRenderDataWaterproofness.js +2 -0
  110. package/views/3d/terrain/PlanarPatch.js +1 -1
  111. package/views/3d/terrain/SphericalPatch.js +1 -1
  112. package/views/3d/terrain/TileRenderer.js +1 -1
  113. package/views/3d/webgl-engine/effects/OpaqueEnvironment.js +1 -1
  114. package/views/3d/webgl-engine/effects/RenderNodes.js +1 -1
  115. package/views/3d/webgl-engine/effects/debug/RenderNodeVisualizerNode.js +1 -1
  116. package/views/3d/webgl-engine/effects/focusArea/FocusAreaMask.js +1 -1
  117. package/views/3d/webgl-engine/effects/geometry/ObjectAndLayerID.js +1 -1
  118. package/views/3d/webgl-engine/effects/highlight/Highlight.js +1 -1
  119. package/views/3d/webgl-engine/effects/highlight/ShadowHighlight.js +1 -1
  120. package/views/3d/webgl-engine/effects/highlight/ShadowHighlightBuffer.js +1 -1
  121. package/views/3d/webgl-engine/effects/laserlines/LaserLineRenderer.js +1 -1
  122. package/views/3d/webgl-engine/effects/magnifier/Magnifier.js +1 -1
  123. package/views/3d/webgl-engine/effects/smaa/SMAA.js +1 -1
  124. package/views/3d/webgl-engine/effects/stars/Stars.js +1 -1
  125. package/views/3d/webgl-engine/effects/stars/StarsTechnique.js +1 -1
  126. package/views/3d/webgl-engine/lib/CutFillComputation.js +1 -1
  127. package/views/3d/webgl-engine/lib/GaussianSplatRenderer.js +1 -1
  128. package/views/3d/webgl-engine/lib/GaussianSplatShadows.js +1 -1
  129. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  130. package/views/3d/webgl-engine/lib/ShadowAccumulator.js +1 -1
  131. package/views/3d/webgl-engine/lib/ShadowCastRenderer.js +1 -1
  132. package/views/3d/webgl-engine/lib/ShadowMap.js +1 -1
  133. package/views/3d/webgl-engine/statistics/RendererPerformanceInfo.js +1 -1
  134. package/views/3d/webgl.js +1 -1
  135. package/views/PopupView.js +1 -1
  136. package/views/layers/FeatureLikeLayerView.js +1 -1
  137. package/views/popupAdapter.js +1 -1
  138. package/webdoc/support/thumbnailUtils.js +1 -1
  139. package/webdoc/support/webdocSaveUtils.js +1 -1
  140. package/widgets/support/widget.d.ts +1 -0
  141. package/assets/esri/core/workers/chunks/125edba5c618c6257cb8.js +0 -1
  142. package/assets/esri/core/workers/chunks/168be2eac0fa3c67ae27.js +0 -1
  143. package/assets/esri/core/workers/chunks/32740b075d7a890d7888.js +0 -1
  144. package/assets/esri/core/workers/chunks/5189413a83faf3480e29.js +0 -1
  145. package/assets/esri/core/workers/chunks/a2be8784f2cfdbb42681.js +0 -1
  146. package/assets/esri/core/workers/chunks/a9db775210ebeee41738.js +0 -1
  147. package/assets/esri/core/workers/chunks/bca6abc185dedec0f41b.js +0 -1
  148. package/assets/esri/core/workers/chunks/bee56a6ac99312f03109.js +0 -1
  149. package/assets/esri/core/workers/chunks/d1d135a54233092ad637.js +0 -1
  150. package/assets/esri/core/workers/chunks/d750e4abeb777caa8c36.js +0 -1
  151. package/assets/esri/core/workers/chunks/daf539e9f88fc9e101e4.js +0 -1
  152. package/assets/esri/core/workers/chunks/e774303efefee31952d0.js +0 -1
  153. package/assets/esri/core/workers/chunks/e8546ab510fc9515bd23.js +0 -1
  154. package/assets/esri/core/workers/chunks/fc9664d3282b052ef40f.js +0 -1
  155. package/views/2d/layers/support/annodime/DimensionMatcherSchema.js +0 -2
  156. package/views/2d/layers/support/annodime/unsupported.js +0 -2
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{clamp as t,isPowerOfTwo as e}from"../../../core/mathUtils.js";import{maxUint16 as n}from"../../../core/typedArrayUtil.js";import{empty as o}from"../../../geometry/support/aaBoundingBox.js";import{fromValues as s}from"../../../geometry/support/aaBoundingRect.js";import{sampleElevation as r,sampleSingleElevation as i}from"./ElevationData.js";import{PatchGeometryLUT as a}from"./PatchGeometryLUT.js";import{zeroToFour as c,neighborTileIfLoadedOrSelf as l}from"./PatchRenderData.js";import{maxPatchTesselation as u,elevationNoDataValue as d}from"./TerrainConst.js";import{internalAssert as f,enableTerrainInternalChecks as m,neighborEdgeIndices as g,almostEquals as h}from"./terrainUtils.js";import{isCornerNeighbor as p}from"./Tile.js";import{compareTilesByLij as x}from"./tileUtils.js";import{compressNormal as M}from"../webgl-engine/lib/Normals.js";const y=65536;function S(t,e){const{tile:n,geometry:s,geometryState:r}=t,{extentInRadians:i,surface:a}=n,{isWebMercator:c,renderer:l}=a,{numVerticesPerSide:u,wireframe:d}=r,f=u-1,m=(u-2)**2,g=c&&(2===e||3===e),h=c&&(1===e||3===e),p=((g?1:0)+(h?1:0))*Ct*u,x=Vt(r),M=m+p+4*x,y=l.tileGeometryCache.acquire(M);s.numVerticesPerSide=u,s.vertexAttributes=y,s.maxEdgeVertexCount=x;const{boundingBox:S}=s;o(S);const B=R(t);ut.update(f,i,B),v(t),s.poleVerticesStartIndex=m;const V=L(t,g,h);s.edgeVerticesStartIndex=m+p,et(t),A(t),Q(s,V,d),t.intersectionData=null}function L(t,e,o){const{tile:s,localOrigin:r,geometry:i}=t,{extent:a,ellipsoid:c}=s,{boundingBox:l,numVerticesPerSide:u,vertexAttributes:d,poleVerticesStartIndex:f}=i,m=u-1,g=r[0],h=r[1],p=r[2],x=c.radius,y=a[1],S=a[3],L=[];let v=f;const B=(t,e)=>{const o=e*u;Bt(-g,-h,t*x-p,l),L.push(new ct(1===t,o,1===t?0:2,v,Ct));const s=E(-1===t?y:S,x),r=t*Math.PI/2-s,i=.99*(1===t?1:-1),a=x+0,{position:c,uv0:f}=d,{typedBuffer:B,typedBufferStride:V}=d.normalCompressed;for(let u=1;u<=Ct;++u){const t=s+r*(u/Ct),e=Math.cos(t),o=Math.sin(t);for(let s=0;s<=m;s++){const t=s/m,r=ut.sinLonLUT[s],u=ut.cosLonLUT[s]*e,d=r*e,x=o,y=u*a-g,S=d*a-h,L=x*a-p;Bt(y,S,L,l),c.setValues(v,y,S,L),f.setValues(v,Math.round(t*n),Math.round(i*n)),M(B,v,u,d,x,V),++v}}};return e&&B(-1,0),o&&B(1,m),L}function v(t){const e=t.geometryState.samplerData,n=1===e?.length?e[0]:null;n?B(t,n):V(t)}function B(t,e){const{tile:n}=t;if(!n.intersectsClippingArea)return;const{geometry:o,geometryState:s,localOrigin:r}=t,{numVerticesPerSide:i}=s,a=i-2,c=i-1,{vertexAttributes:l,boundingBox:u}=o,{position:d,uv0:f}=l,{typedBuffer:m,typedBufferStride:g}=l.normalCompressed,{extent:h}=n,p=n.ellipsoid.radius,x=r[0],y=r[1],S=r[2],L=d.typedBuffer,v=d.typedBufferStride,B=f.typedBuffer,V=f.typedBufferStride;I(c,h,e);let C=0;const T=e.data.values;if(1<=a){const t=ft[1],e=ut.sinLatLUT[1],n=ut.cosLatLUT[1];for(let o=1;o<=a;o++){const s=ut.sinLonLUT[o],r=ut.cosLonLUT[o],i=p+b(o,1,T),a=i*r*n-x,c=i*s*n-y,l=i*e-S;Bt(a,c,l,u);const d=(o-1)*v;L[d]=a,L[d+1]=c,L[d+2]=l;const f=(o-1)*V;B[f]=ft[o],B[f+1]=t}}for(let I=1;I<=a;I++){const t=ut.sinLatLUT[I],e=ut.cosLatLUT[I],n=I+1,o=ft[n],s=ut.sinLatLUT[n],r=ut.cosLatLUT[n],i=ut.sinLonLUT[0],l=ut.cosLonLUT[0],d=p+b(0,I,T);let f=l*e*d-x,h=i*e*d-y,U=t*d-S;const A=C*v;let P=L[A],D=L[A+1],E=L[A+2];for(let w=1;w<=a;w++){const i=ut.sinLonLUT[w],l=ut.cosLonLUT[w];let d=0,A=0,O=0;if(w<a){const t=(C+1)*v;d=L[t],A=L[t+1],O=L[t+2]}else{const n=ut.sinLonLUT[c],o=ut.cosLonLUT[c],s=p+b(c,I,T);d=o*e*s-x,A=n*e*s-y,O=t*s-S}const R=f,N=h,j=U;f=P,h=D,U=E,P=d,D=A,E=O;const F=d-R,q=A-N,W=O-j;let k=0,z=0,G=0;if(I>1){const t=(C-a)*v;k=L[t],z=L[t+1],G=L[t+2]}else{const t=ut.sinLatLUT[0],e=ut.cosLatLUT[0],n=p+b(w,0,T);k=l*e*n-x,z=i*e*n-y,G=t*n-S}const H=p+b(w,n,T),J=l*r*H-x,K=i*r*H-y,Q=s*H-S;if(I<a){const t=C+a,e=t*v;L[e]=J,L[e+1]=K,L[e+2]=Q,Bt(J,K,Q,u);const n=t*V;B[n]=ft[w],B[n+1]=o}const X=k-J,Y=z-K,Z=G-Q;let $=l*e,_=i*e,tt=t;tt*tt<.999&&($=W*Y-q*Z,_=F*Z-W*X,tt=q*X-F*Y);const et=1/Math.sqrt($*$+_*_+tt*tt);M(m,C,$*et,_*et,tt*et,g),++C}}}function V(t){const{tile:e}=t;if(!e.intersectsClippingArea)return;const{geometry:o,geometryState:s,localOrigin:i}=t,{numVerticesPerSide:a,samplerData:c}=s,l=a-2,u=a-1,{vertexAttributes:d,boundingBox:f}=o,{position:m,uv0:g}=d,{typedBuffer:h,typedBufferStride:p}=d.normalCompressed,{extent:x}=e,y=x[0],S=x[2],L=x[1],v=x[3],B=e.ellipsoid.radius,V=i[0],I=i[1],b=i[2],C=m.typedBuffer,T=m.typedBufferStride,U=1/u;let A=0;if(1<=l){const t=U,e=L*(1-t)+v*t,o=ut.sinLatLUT[1],s=ut.cosLatLUT[1];for(let i=1;i<=l;i++){const a=i*U,l=y*(1-a)+S*a,u=ut.sinLonLUT[i],d=ut.cosLonLUT[i],m=B+r(l,e,c),h=m*d*s-V,p=m*u*s-I,x=m*o-b;Bt(h,p,x,f);const M=(i-1)*T;C[M]=h,C[M+1]=p,C[M+2]=x,g.setValues(i-1,Math.round(a*n),Math.round(t*n))}}for(let P=1;P<=l;P++){const t=P*U,e=L*(1-t)+v*t,o=ut.sinLatLUT[P],s=ut.cosLatLUT[P],i=P+1,a=i*U,d=L*(1-a)+v*a,m=ut.sinLatLUT[i],x=ut.cosLatLUT[i],D=ut.sinLonLUT[0],E=ut.cosLonLUT[0],w=B+r(y,e,c);let O=E*s*w-V,R=D*s*w-I,N=o*w-b;const j=A*T;let F=C[j],q=C[j+1],W=C[j+2];for(let v=1;v<=l;v++){const t=v*U,i=y*(1-t)+S*t,D=ut.sinLonLUT[v],E=ut.cosLonLUT[v];let w=0,j=0,k=0;if(v<l){const t=(A+1)*T;w=C[t],j=C[t+1],k=C[t+2]}else{const t=ut.sinLonLUT[u],n=ut.cosLonLUT[u],i=B+r(S,e,c);w=n*s*i-V,j=t*s*i-I,k=o*i-b}const z=O,G=R,H=N;O=F,R=q,N=W,F=w,q=j,W=k;const J=w-z,K=j-G,Q=k-H;let X=0,Y=0,Z=0;if(P>1){const t=(A-l)*T;X=C[t],Y=C[t+1],Z=C[t+2]}else{const t=ut.sinLatLUT[0],e=ut.cosLatLUT[0],n=B+r(i,L,c);X=E*e*n-V,Y=D*e*n-I,Z=t*n-b}const $=B+r(i,d,c),_=E*x*$-V,tt=D*x*$-I,et=m*$-b;if(P<l){const e=A+l,o=e*T;C[o]=_,C[o+1]=tt,C[o+2]=et,Bt(_,tt,et,f),g.setValues(e,Math.round(t*n),Math.round(a*n))}const nt=X-_,ot=Y-tt,st=Z-et;let rt=E*s,it=D*s,at=o;at*at<.999&&(rt=Q*ot-K*st,it=J*st-Q*nt,at=K*nt-J*ot);const ct=1/Math.sqrt(rt*rt+it*it+at*at);M(h,A,rt*ct,it*ct,at*ct,p),++A}}}function I(e,o,s){const r=o[0],i=o[2],a=o[1],c=o[3],l=1/e,{dx:u,dy:d,x0:f,y1:m,safeWidth:g}=s,h=s.data.width;for(let p=0;p<=e;p++){const e=p*l,o=t(u*(r*(1-e)+i*e-f),0,g),s=Math.floor(o);mt[p]=s,pt[p]=o-s;const x=t(d*(m-(a*(1-e)+c*e)),0,g),M=Math.floor(x);gt[p]=M*h,ht[p]=(M+1)*h,xt[p]=x-M,ft[p]=Math.round(e*n)}}function b(t,e,n){const o=mt[t],s=pt[t],r=gt[e],i=ht[e],a=xt[e],c=r+o,l=n[c],u=n[c+1],d=n[i+o],f=n[i+o+1];if(l+d+u+f>=dt)return 0;const m=l+(u-l)*s;return m+(d+(f-d)*s-m)*a}function C(t){t.tile.intersectsClippingArea&&(A(t),it(t),t.intersectionData=null)}function T(t){t.tile.intersectsClippingArea&&(nt(t),A(t),it(t),at(t),t.intersectionData=null)}function U(t){t.tile.intersectsClippingArea&&(D(t),P(t,!0),it(t),t.intersectionData=null)}function A(t){t.tile.intersectsClippingArea&&(D(t),P(t))}function P(t,o=!1){const{geometry:s,geometryState:a,tile:c,localOrigin:u}=t,{level:d,extent:p,extentInRadians:y,ellipsoid:S}=c,L=S.radius,v=y[0],B=y[2],V=y[1],I=y[3],{samplerData:b}=a,C=p[0],T=p[2],U=p[1],A=p[3],P=R(t),{boundingBox:D,vertexAttributes:E}=s,w=u[0],O=u[1],N=u[2],{position:j,uv0:F}=E,q=j.typedBuffer,W=j.typedBufferStride,k=F.typedBuffer,z=F.typedBufferStride,{typedBuffer:G,typedBufferStride:H}=E.normalCompressed,J=1===b?.length?b[0]:null,K=(t,e,n)=>J?i(t,e,J)??0:r(t,e,b)??0;for(let R=0;R<4;++R){const u=1===R||3===R,y=a.edgeResolutions[R];f(e(y));const S=y+1,E=l(c,a.edgePeerNeighbors[R]);if(St(c,E,R)){ot(t,R,E);continue}const j=null!=E;f(!j||E.level===c.level),f(!j||x(c,E)<=0);const F=E?.renderData,Q=F?.geometryState;if(m){const t=c.surface;if(!E&&t&&!t.updatingRootTiles){const e=g[R],n=c.findNeighborTile(e,t=>t.loaded||t.leaf||t.level===c.level);n?n.intersectsClippingArea&&(f(!n.loaded),f(!n.leaf),f(n.level===d)):f(null==t?.rootTiles||!c.shouldHaveNeighbor(e))}}const X=1===R?p[2]:p[0],Y=E?.extent,Z=Y&&u?1===R?Y[0]:Y[2]:X,$=0===R?p[3]:p[1],_=1===R?1:0,tt=0===R?1:0,et=1===R?B:v,nt=0===R?I:V,st=Math.sin(et),rt=Math.cos(et),it=Math.sin(nt),at=Math.cos(nt),ct=Q?.samplerData,lt=1===ct?.length?ct[0]:null,ut=(t,e,n)=>lt?i(n,e,lt)??0:r(n,e,ct)??0,dt=j?(t,e,n)=>.5*(K(t,e)+ut(t,e,n)):K,ft=s.outerEdgesOffsetAndLength[2*R+0],mt=o&&S>3?S-3:1,gt=null!=J||null!=b&&b.some(t=>null!=t),ht=null!=lt||null!=ct&&ct.some(t=>null!=t),pt=gt||ht,xt=1/y,Mt=n*xt,yt=_*n,Lt=tt*n,vt=ft;f(!Y||h(Y[2]-Y[0],p[2]-p[0]));(()=>{const t=1===R?-1:3===R?1:0,e=0===R?-1:2===R?1:0,n=(p[2]-p[0])*xt,o=t*n,s=e*n,a=u?t*((B-v)*xt):0,c=u?0:e*xt,l=tt,d=u?et+a:et,f=u?Math.sin(d):st,m=u?Math.cos(d):rt,g=u?et-a:et,h=u?Math.sin(g):st,x=u?Math.cos(g):rt,y=u?nt:P(l+c),V=u?it:Math.sin(y),I=u?at:Math.cos(y),E=u?nt:P(l-c),F=u?it:Math.sin(E),K=u?at:Math.cos(E);let Q=0,Y=0,_=0;{const t=0*xt,e=u?X:C*(1-t)+T*t,n=u?Z:e,o=u?U*(1-t)+A*t:$,s=u?et:v*(1-t)+B*t,r=u?st:Math.sin(s),i=u?rt:Math.cos(s),a=u?P(t):nt,c=u?Math.sin(a):it,l=u?Math.cos(a):at,d=L+dt(e,o,n);Q=i*l*d,Y=r*l*d,_=c*d}let ot=0,ut=0,ft=0;{const t=1*xt,e=u?X:C*(1-t)+T*t,n=u?Z:e,o=u?U*(1-t)+A*t:$,s=u?et:v*(1-t)+B*t,r=u?st:Math.sin(s),i=u?rt:Math.cos(s),a=u?P(t):nt,c=u?Math.sin(a):it,l=u?Math.cos(a):at,d=L+dt(e,o,n);ot=i*l*d,ut=r*l*d,ft=c*d}for(let p=1;p<S-1;p+=mt){let t=0,e=0,n=0;{const o=(p+1)*xt,s=u?X:C*(1-o)+T*o,r=u?Z:s,i=u?U*(1-o)+A*o:$,a=u?et:v*(1-o)+B*o,c=u?st:Math.sin(a),l=u?rt:Math.cos(a),d=u?P(o):nt,f=u?Math.sin(d):it,m=u?Math.cos(d):at,g=L+dt(s,i,r);t=l*m*g,e=c*m*g,n=f*g}const a=t,c=e,l=n,d=ot,g=ut,y=ft;ot=a,ut=c,ft=l;{const t=vt+p,e=t*W,n=d-w,o=g-O,s=y-N;q[e]=n,q[e+1]=o,q[e+2]=s,Bt(n,o,s,D);const r=Math.round(p*Mt),i=t*z;k[i]=u?yt:r,k[i+1]=u?r:Lt}const S=Q,E=Y,tt=_;Q=d,Y=g,_=y;const mt=d,gt=g,ht=y,St=1/Math.sqrt(mt*mt+gt*gt+ht*ht),Vt=ht*St;let It=0,bt=0,Ct=0;if(pt&&Vt*Vt<.999){let t=0,e=0,n=0;{const o=0===R?-1:1;t=o*(a-S),e=o*(c-E),n=o*(l-tt)}{const a=p*xt,c=u?X:C*(1-a)+T*a,l=u?Z:c,d=u?U*(1-a)+A*a:$,g=u?et:v*(1-a)+B*a,M=u?st:Math.sin(g),y=u?rt:Math.cos(g),S=u?P(a):nt,D=u?Math.sin(S):it,E=u?Math.cos(S):at;let w=mt,O=gt,N=ht;if(j){const t=l-o,e=d-s,n=L+(lt?i(t,e,lt)??0:r(t,e,ct)??0),a=u?E:K;w=(u?x:y)*a*n,O=(u?h:M)*a*n,N=(u?D:F)*n}{const a=c+o,l=d+s,g=L+(J?i(a,l,J)??0:r(a,l,b)??0),h=u?E:I,p=(u?m:y)*h*g,x=(u?f:M)*h*g,S=(u?D:V)*g;j||(w=2*mt-p,O=2*gt-x,N=2*ht-S);const v=3===R?-1:1,B=v*(w-p),C=v*(O-x),T=v*(N-S);It=n*C-e*T,bt=t*T-n*B,Ct=e*B-t*C;const U=1/Math.sqrt(It*It+bt*bt+Ct*Ct);It*=U,bt*=U,Ct*=U}}}else It=mt*St,bt=gt*St,Ct=ht*St;M(G,vt+p,It,bt,Ct,H)}})()}}function D(t){st(t)}function E(t,e){return Math.PI/2-2*Math.atan(Math.exp(-t/e))}function w(t,e,n,o){return E(t*(1-o)+e*o,n)}function O(t,e,n){return t*(1-n)+e*n}function R(t){const{tile:e}=t;if(e.surface.isWebMercator){const t=e.extent,n=e.ellipsoid.radius;return e=>w(t[1],t[3],n,e)}const n=e.extentInRadians;return t=>O(n[1],n[3],t)}function N(t,e){const{tile:n,geometryState:s,geometry:r}=t,{extent:i,surface:a}=n,{wireframe:c}=s,l=i[0],u=i[1],d=i[2]-l,f=i[3]-u,{numVerticesPerSide:m,clippingArea:g}=s,h=null!=g?Math.max(0,(g[0]-l)/d):0,p=null!=g?Math.max(0,(g[1]-u)/f):0,x=null!=g?Math.min(1,(g[2]-l)/d):1,M=null!=g?Math.min(1,(g[3]-u)/f):1,y=(m-2)**2,S=Vt(s),L=y+4*S,v=a.renderer.tileGeometryCache.acquire(L),{boundingBox:B}=r;o(B),r.numVerticesPerSide=m,r.vertexAttributes=v,r.maxEdgeVertexCount=S,r.minu=h,r.minv=p,r.maxu=x,r.maxv=M,j(t),r.edgeVerticesStartIndex=y,et(t),k(t),Q(r,[],c),t.intersectionData=null}function j(e){const o=e.tile;if(!o.intersectsClippingArea)return;const{geometry:s,geometryState:a,localOrigin:c}=e,{samplerData:l,clippingArea:u,numVerticesPerSide:d}=a,{surface:f,extent:m,ellipsoid:g}=o,{isWebMercatorOnPlateCarree:h}=f,p=null!=u?u:Mt,x=m[0],y=m[1],S=m[2],L=m[3],v=Math.max(x,p[0]),B=Math.min(S,p[2]),V=Math.max(y,p[1]),I=Math.min(L,p[3]),b=g.radius,C=o.horizontalScale,T=d-1,U=d-2,{minu:A,minv:P,maxu:D,maxv:E,boundingBox:w,vertexAttributes:O}=s,{position:R,uv0:N}=O,{typedBuffer:j,typedBufferStride:F}=O.normalCompressed,q=c[0],W=c[1],k=c[2],z=R.typedBuffer,G=R.typedBufferStride;let H=0;const J=t(y,V,I),K=h?(Math.PI/2-2*Math.atan(Math.exp(-J/b)))*b:J*C,Q=1/T,X=t(y*(1-Q)+L*Q,V,I);let Y=K,Z=h?(Math.PI/2-2*Math.atan(Math.exp(-X/b)))*b:X*C;const $=1===l?.length?l[0]:null,_=$?(t,e)=>i(t,e,$)??0:(t,e)=>r(t,e,l)??0;for(let r=1;r<=U;r++){const e=r/T,o=t(y*(1-e)+L*e,V,I),s=t(e,P,E),i=Z,a=(r-1)/T,c=t(y*(1-a)+L*a,V,I),l=Y,u=(r+1)/T,d=t(y*(1-u)+L*u,V,I),f=h?(Math.PI/2-2*Math.atan(Math.exp(-d/b)))*b:d*C,m=t(u,P,E);Y=Z,Z=f;const g=t(x,v,B);let p=g*C,O=_(g,o);const R=1/T,J=t(R,A,D),K=t(x*(1-J)+S*J,v,B);let Q=J,X=K,$=K*C,tt=_(K,o);if(1===r){const e=$-q,o=Y-W,r=tt-k,i=0*G;z[i]=e,z[i+1]=o,z[i+2]=r,Bt(e,o,r,w);const a=t(R,A,D);N.setValues(H,Math.round(a*n),Math.round(s*n))}for(let h=1;h<=U;h++){const e=$,a=tt,u=(h+1)/T,g=t(u,A,D),y=t(x*(1-u)+S*u,v,B),L=X;X=y;{const t=H+1,e=t*G;if(1===r||h===U){const a=y*C,c=_(y,o);if(1===r&&h<U){const o=a-q,r=i-W,l=c-k;z[e]=o,z[e+1]=r,z[e+2]=l,Bt(o,r,l,w),N.setValues(t,Math.round(g*n),Math.round(s*n))}$=a,tt=c}else $=z[e]+q,tt=z[e+2]+k}const V=$,I=tt,b=p,P=O;p=e,O=a;const E=(H-U)*G,R=1===r?_(L,c):z[E+2]+k,J=_(L,d);if(r<U){const t=H+U,o=t*G,s=e-q,r=f-W,i=J-k;z[o]=s,z[o+1]=r,z[o+2]=i,Bt(s,r,i,w);const a=Q;Q=g,N.setValues(t,Math.round(a*n),Math.round(m*n))}{const t=V-b,e=l-f,n=e*(I-P),o=t*(R-J),s=-e*t,r=n*n+o*o+s*s;if(0===r)M(j,H,0,0,1,F);else{const t=1/Math.sqrt(r);M(j,H,n*t,o*t,s*t,F)}}++H}}}function F(t,e){t.tile.intersectsClippingArea&&(G(t),z(t,!0),it(t),t.intersectionData=null)}function q(t,e){t.tile.intersectsClippingArea&&(nt(t),k(t),it(t),at(t),t.intersectionData=null)}function W(t,e){t.tile.intersectsClippingArea&&(k(t),it(t),t.intersectionData=null)}function k(t,e){t.tile.intersectsClippingArea&&(G(t),z(t,!1))}function z(n,o){const{geometry:s,geometryState:a,localOrigin:c}=n,u=n.tile,{surface:d,extent:h}=u,{clippingArea:p,samplerData:M}=a,y=null!=p?p:Mt,S=h[0],L=h[2],v=h[1],B=h[3],V=[B>y[3],L>y[2],v<y[1],S<y[0]],I=u.horizontalScale,b=K(d.isWebMercatorOnPlateCarree,u.ellipsoid.radius,I),{minu:C,minv:T,maxu:U,maxv:A,boundingBox:P}=s,D=Math.max(S,y[0]),E=Math.min(L,y[2]),w=Math.max(v,y[1]),O=Math.min(B,y[3]),R=c[0],N=c[1],j=c[2],F=1===M?.length?M[0]:void 0,q=F?(t,e)=>i(t,e,F)??0:(t,e)=>r(t,e,M)??0;for(let W=0;W<4;++W){const c=1===W||3===W,h=a.edgeResolutions[W];f(e(h));const p=h+1,y=V[W],F=l(u,a.edgePeerNeighbors[W]);if(!y&&St(u,F,W)){ot(n,W,F);continue}const k=null!=F&&!y,z=F?.renderData,G=z?.geometryState;if(m&&(f(!k||F.level===u.level),f(!k||x(u,F)<=0),u&&!F&&!d.updatingRootTiles)){const t=g[W],e=u.findNeighborTile(t,t=>t.loaded||t.leaf||t.level===u.level);d.updatingRootTiles||(e?e.intersectsClippingArea&&(f(!e.loaded),f(!e.leaf),f(e.level===u.level)):f(null==d?.rootTiles||!u.shouldHaveNeighbor(t)))}const H=t(1===W?L:S,D,E),J=t(0===W?B:v,w,O),K=G?.samplerData,Q=o&&p>3?p-3:1,X=t(1===W?1:0,C,U),Y=t(0===W?1:0,T,A),Z=1===K?.length?K[0]:null,$=(t,e)=>Z?i(t,e,Z)??0:r(t,e,K)??0,_=k?(t,e)=>.5*($(t,e)+q(t,e)):q,tt=(L-S)/h,et=c?1===W?tt:-tt:0,nt=c?0:0===W?tt:-tt,st=-et,rt=-nt;let it=0,at=0,ct=0;{const e=0/h,n=c?H:t(S*(1-e)+L*e,D,E),o=c?t(v*(1-e)+B*e,w,O):J,s=_(n,o);it=n*I,at=b(o),ct=s}let lt=0,ut=0,dt=0;{const e=1/h,n=c?H:t(S*(1-e)+L*e,D,E),o=c?t(v*(1-e)+B*e,w,O):J,s=_(n,o);lt=n*I,ut=b(o),dt=s}for(let e=1;e<p-1;e+=Q){const n=e/h,o=lt,i=ut,a=dt;{const r=c?X:t(n,C,U),l=c?t(n,T,A):Y,u=o-R,d=i-N,f=a-j;Bt(o,d,f,P),s.setEdgeVertexFromValuesRawPositionUV(W,e,u,d,f,r,l)}{const n=(e+1)/h,o=c?H:t(S*(1-n)+L*n,D,E),s=c?t(v*(1-n)+B*n,w,O):J,r=_(o,s);lt=o*I,ut=b(s),dt=r}const l=lt,u=dt,d=it,f=at,m=ct;it=o,at=i,ct=a;let g=0,p=0,x=0;if(c){const e=ut-i,s=u-a,c=f-i,l=m-a,d=t(v*(1-n)+B*n,w,O),h=H+st,y=h*I-o,S=r(h,d,M)-a,L=3===W?-1:1;if(g=L*(-c+e)*S,p=L*y*(-l+s),x=-L*y*(-c+e),k){const t=H+et,n=t*I-o;g=(-c+e)*(S-(r(t,d,K)-a)),p=(y-n)*(-l+s),x=-(y-n)*(-c+e)}}else{const e=l-o,s=u-a,c=d-o,f=m-a,h=t(S*(1-n)+L*n,D,E),y=J+rt,v=r(h,y,M)-a,B=b(y)-i,V=2===W?-1:1;if(g=V*B*(-f+s),p=V*(-c+e)*v,x=-V*B*(-c+e),k){const t=h,n=J+nt,o=b(n)-i;g=(-B+o)*(-f+s),p=(-c+e)*(-v+(r(t,n,K)-a)),x=-(-B+o)*(-c+e)}}const y=1/Math.sqrt(g*g+p*p+x*x);s.setEdgeNormalFromValues(W,e,g*y,p*y,x*y)}}}function G(t,e){st(t)}function H(t,e){return(Math.PI/2-2*Math.atan(Math.exp(-t/e)))*e}function J(t,e){return t*e}function K(t,e,n){return t?t=>H(t,e):t=>J(t,n)}function Q(t,e,n){const{numVerticesPerSide:o,vertexAttributes:s,maxEdgeVertexCount:r}=t,i=o-1,a=s.count,l=2*(o-3)*(o-3),u=4*(i+r-3),d=c.reduce((e,n)=>e+(i+t.getEdgeCount(n)-3),0),f=e.reduce((t,e)=>t+i*(2*(e.latitudeResolution-1)+1),0),m=3*(n?2:1),g=(l+u+f)*m,h=a>=y?new Uint32Array(g):new Uint16Array(g);for(let c=0;c<g;++c)h[c]=0;t.indices=h,t.indexCount=(l+d+f)*m,t.poleIndicesStartIndex=l*m,t.edgeIndicesStartIndex=(l+f)*m,n?($(t),_(t,e),tt(t)):(X(t),Y(t,e),Z(t))}function X(t){const{numVerticesPerSide:e,indices:n,vertexAttributes:o}=t,{position:s}=o,{typedBuffer:r,typedBufferStride:i}=s,a=e-2,c=e-3,l=0,u=e-3;let d=0;for(let f=0;f<c;++f){const t=f*a;for(let e=l;e<u;++e){const o=t+e,s=o+1,c=s+a,l=c-1;It(o,s,c,l,i,r)?(n[d]=o,n[d+1]=s,n[d+2]=c,n[d+3]=c,n[d+4]=l,n[d+5]=o):(n[d]=o,n[d+1]=s,n[d+2]=l,n[d+3]=l,n[d+4]=s,n[d+5]=c),d+=6}}}function Y(t,e){const{numVerticesPerSide:n,indices:o,poleIndicesStartIndex:s}=t,r=n-1;let i=s;for(const a of e){const e=a.isNorth?1:2,s=a.isNorth?2:1,c=a.isNorth?3:4,l=a.isNorth?4:3;let u=t.getEdgeVertexIndex(a.connectedOuterEdgeOffset,0),d=1;for(let t=0;t<a.latitudeResolution;++t){const f=0===t?a.rowOffset:u+n;for(let n=0;n<r;n++){const r=f+n;o[i]=u,o[i+e]=u+1,o[i+s]=r,t<a.latitudeResolution-1?(o[i+c]=u+1,o[i+l]=r+1,o[i+5]=r,i+=6):i+=3,u+=d}u=f,d=1}}}function Z(t){const{indices:e,numVerticesPerSide:n,edgeIndicesStartIndex:o}=t,s=n-1,r=s-2;let i=o;for(let a=0;a<4;++a){const n=vt[a];let o=0,c=0;const l=t.getEdgeCount(a),u=n.count;f(u===s-1);const d=1===a||2===a,m=d?1:2,g=d?2:1,h=t.getEdgeFirstVertexIndex(a),p=1,x=n.vertex0Index,M=n.stride;for(;o<l-1||c<u-1;){const t=x+c*M,n=h+o*p,a=o<l-1,d=c<u-1,f=a&&(!d||(a?0+s*(o+.5)/(l-1):0)<=(d?1+r*(c+.5)/(u-1):0));f?++o:++c;const y=f?n+p:t+M;e[i]=t,e[i+m]=n,e[i+g]=y,i+=3}}t.indexCount=i}function $(t){const{indices:e,numVerticesPerSide:n,vertexAttributes:o}=t,{position:s}=o,{typedBuffer:r,typedBufferStride:i}=s,a=n-2;let c=0;for(let l=0;l<n-3;++l){const t=l*a;for(let o=0;o<n-3;++o){const n=l*a+o,s=n+1,u=s+a,d=u-1,f=t+o,m=f+1,g=m+a;It(f,m,g,g-1,i,r)?(bt(e,c,n,s,u),c+=6,bt(e,c,u,d,n)):(bt(e,c,n,s,d),c+=6,bt(e,c,d,u,s)),c+=6}}}function _(t,e){const{indices:n,numVerticesPerSide:o,poleIndicesStartIndex:s}=t,r=o-1;let i=s;for(const a of e){const e=a.connectedOuterEdgeOffset;let s=t.getEdgeVertexIndex(e,0),c=1;for(let t=0;t<a.latitudeResolution;++t){const e=0===t?a.rowOffset:s+o;for(let o=0;o<r;o++)bt(n,i,s,s+1,e+o),i+=6,t<a.latitudeResolution-1&&(bt(n,i,s+1,e+o+1,e+o),i+=6),s+=c;s=e,c=1}}}function tt(t){const{indices:e,numVerticesPerSide:n,edgeIndicesStartIndex:o}=t,s=n-1,r=s-2;let i=o;for(let a=0;a<4;++a){const n=vt[a];let o=0,c=0;const l=t.getEdgeCount(a),u=n.count;f(u===s-1);const d=1===a||2===a,m=d?1:3,g=d?3:1,h=t.getEdgeFirstVertexIndex(a),p=1,x=n.vertex0Index,M=n.stride;for(;o<l-1||c<u-1;){const t=x+c*M,n=h+o*p,a=o<l-1,d=c<u-1,f=a&&(!d||(a?0+s*(o+.5)/(l-1):0)<=(d?1+r*(c+.5)/(u-1):0));f?++o:++c;const y=f?n+p:t+M;e[i]=t,e[i+m]=n,e[i+m+1]=n,e[i+g]=y,e[i+g+1]=y,e[i+5]=t,i+=6}}t.indexCount=i}function et(t){const{geometry:e,geometryState:n}=t,{edgeResolutions:o}=n,{numVerticesPerSide:s,edgeVerticesStartIndex:r}=e,i=s-2;let a=r;for(let c=0;c<4;++c){{const t=0===c||2===c,e=(0===c?i-1:0)*i+(1===c?i-1:0),n=(t?0:1)*i+(t?1:0),o=vt[c];o.vertex0Index=e,o.stride=n,o.count=i}{const t=o[c]+1;e.outerEdgesOffsetAndLength[2*c+0]=a,e.outerEdgesOffsetAndLength[2*c+1]=t,a+=t}}}function nt(t){et(t),t.geometryState.wireframe?tt(t.geometry):Z(t.geometry)}function ot(o,s,r){const{geometryState:i,geometry:a,tile:c,localOrigin:l}=o,u=1===s||3===s,d=i.edgeResolutions[s];f(e(d));const m=d+1,{boundingBox:g,minu:h,minv:p,maxu:x,maxv:M,vertexAttributes:y}=a,S=t(1===s?1:0,h,x),L=t(0===s?1:0,p,M),v=r.renderData,B=v.geometryState,V=v.geometry,I=(s+2)%4,b=V.getEdgeCount(I),C=c.getNeighborEdgeStartVertexIndex(s,r)*d,T=d*2**(c.level-r.level);f(B.edgeResolutions[I]===T),f(b-1===T);const U=v.localOrigin[0]-l[0],A=v.localOrigin[1]-l[1],P=v.localOrigin[2]-l[2],D=a.getEdgeFirstVertexIndex(s),{position:E,uv0:w}=y,O=E.typedBuffer,R=E.typedBufferStride,N=y.normalCompressed,j=N.typedBuffer,F=N.typedBufferStride,q=V.vertexAttributes,W=V.getEdgeFirstVertexIndex(I),k=q.position.typedBuffer,z=q.position.typedBufferStride,G=q.normalCompressed.typedBuffer,H=q.normalCompressed.typedBufferStride;for(let e=1;e<m-1;++e){const o=D+e,s=W+(C+e),r=o*R,i=s*z,a=k[i]+U,c=k[i+1]+A,l=k[i+2]+P;O[r]=a,O[r+1]=c,O[r+2]=l,Bt(a,c,l,g);const f=o*F,m=s*H;j[f]=G[m],j[f+1]=G[m+1];const y=e/d,v=u?S:t(y,h,x),B=u?t(y,p,M):L;w.setValues(o,Math.round(v*n),Math.round(B*n))}}function st(e){const{geometry:o,geometryState:s,localOrigin:i}=e,{clippingArea:a,samplerData:c}=s,{minu:l,minv:u,maxu:d,maxv:m,boundingBox:g,vertexAttributes:h}=o,p=e.tile,{surface:M,ellipsoid:y,extent:S,extentInRadians:L,horizontalScale:v}=p,B="local"===M.view?.viewingMode,V=y.radius;let I=0,b=0,C=0;const T=(t,e,n)=>{const o=L[0===e?1:3],s=L[0===t?0:2],r=Math.cos(o),i=Math.sin(o),a=Math.sin(s),c=Math.cos(s),l=V+n;I=c*r*l,b=a*r*l,C=i*l},U=B?(()=>{const e=a,n=null!=e&&(S[3]>e[3]||S[2]>e[2]||S[1]<e[1]||S[0]<e[0]),o=K(M.isWebMercatorOnPlateCarree,V,v);return(s,r,i)=>{const a=0===s?S[0]:S[2],c=0===r?S[1]:S[3],l=n?t(a,e[0],e[2]):a,u=n?t(c,e[1],e[3]):c,d=i;I=l*v,b=o(u),C=d}})():T;let A=0,P=0,D=0,E=0,w=0,O=0,N=0,j=0,F=0;const q=B&&M.isWebMercatorOnPlateCarree,W=(t,e,n,o,s)=>{let r=0,i=0,a=0;if(B){const t=e*v,s=q?(Math.PI/2-2*Math.atan(Math.exp(-n/V)))*V:n*v;r=t-I,i=s-b,a=o-C}else{const s=R(t),c=t.tile,l=c.extent,u=c.extentInRadians,d=(e-l[0])/(l[2]-l[0]),f=(n-l[1])/(l[3]-l[1]),m=u[0]*(1-d)+u[2]*d,g=s(f),h=Math.cos(g),p=Math.sin(g),x=Math.sin(m),M=Math.cos(m),y=V+o;r=M*h*y-I,i=x*h*y-b,a=p*y-C}switch(s){case 0:N+=r,j+=i,F+=a;break;case 1:E-=r,w-=i,O-=a;break;case 2:N-=r,j-=i,F-=a;break;case 3:E+=r,w+=i,O+=a}},k=a??Mt,z=S[0],G=S[2],H=S[1],J=S[3],Q=[J>k[3],G>k[2],H<k[1],z<k[0]],X=Math.max(z,k[0]),Y=Math.min(G,k[2]),Z=Math.max(H,k[1]),$=Math.min(J,k[3]),_=t=>Math.max(k[0],Math.min(k[2],t)),tt=t=>Math.max(k[1],Math.min(k[3],t)),et=t=>{const e=s.cornerNeighborCornerTiles;A=0,P=0,D=1,E=0,w=0,O=0,N=0,j=0,F=0;let n=1/0;for(let s=0;s<4;++s){const o=e[4*t+s];n=Math.min(n,o?.level??1/0)}for(let s=0;s<4;++s){const o=e[4*t+s];yt[s]=o?.level===n?o:null}let o=1,i=0;for(let s=0;s<4;++s){const t=yt[s];t&&(o=Math.max(o,t?.renderData.geometryState.numVerticesPerSide),i=t.extent[2]-t.extent[0])}const a=i,c=o;f(c>1);const l=a/c;for(let s=0;s<4;++s){const t=yt[(s+3)%4],e=yt[s%4];if(!t&&!e)continue;const n=0===s?1:1===s?2:2===s?3:0,o=0===s?2:1===s?3:2===s?0:1;if(t&&e){const i=lt[s][0]*l,a=lt[s][1]*l,c=t.extent,u=_(c[0===n||1===n?2:0]+i),d=tt(c[0===n||3===n?3:1]+a),f=e.extent,m=_(f[0===o||1===o?2:0]+i),g=tt(f[0===o||3===o?3:1]+a),h=t.renderData,p=e.renderData,x=r(u,d,h.geometryState.samplerData),M=r(m,g,p.geometryState.samplerData);W(h,u,d,.5*(x+M),s)}else{const i=t??e,a=t?n:o,c=i.extent,u=lt[s],d=_(c[0===a||1===a?2:0]+u[0]*l),f=tt(c[0===a||3===a?3:1]+u[1]*l),m=i.renderData,g=r(d,f,m.geometryState.samplerData);W(m,d,f,g,s)}}if(!B){const t=Math.sqrt(I*I+b*b+C*C);A=I/t,P=b/t,D=C/t}if(B||D*D<.999){const t=Math.sqrt(E*E+w*w+O*O);E/=t,w/=t,O/=t;const e=Math.sqrt(N*N+j*j+F*F);N/=e,j/=e,F/=e,A=O*j-w*F,P=E*F-O*N,D=w*N-E*j;const n=1/Math.sqrt(A*A+P*P+D*D);A*=n,P*=n,D*=n}},nt=s.cornerNeighborCornerTiles;for(let R=0;R<4;++R){const e=R,a=(R+1)%4,M=0===R||1===R?1:0,y=0===R||3===R?1:0,S=t(M,l,d),L=t(y,u,m),v=o.getEdgeFirstVertexIndex(e),B=o.getEdgeCount(e),V=0===R||3===R?B-1:0,T=o.getEdgeFirstVertexIndex(a),E=o.getEdgeCount(a),w=0===R||1===R?E-1:0;let O=-1;for(let t=0;t<4;++t){const e=nt[4*R+t],n=nt[4*R+O];e&&(-1===O||x(n,e)>0)&&(O=t)}const N=O,j=nt[4*R+N];if(j!==p){const t=p.level-j.level,e=2**t,o=[j.lij[0]+t,j.lij[1]*e,j.lij[2]*e],r=[o[1]+e===p.lij[1],0===R&&(1===N||0===N&&j!==nt[4*R+3])||1===R&&(0===N||1===N&&j!==nt[4*R+2]),o[1]===p.lij[1]+1,2===R&&(3===N||2===N&&j!==nt[4*R+1])||3===R&&(2===N||3===N&&j!==nt[4*R+0])],a=r.reduce((t,e)=>t+(e?1:0),0);f(1===a||2===a);let c=-1,l=-1;const u=j.renderData;if(1===a){const t=r.findIndex(t=>t);f(0<=t&&t<=3),c=(t+2)%4;const e=s.edgeResolutions[t];l=p.getNeighborEdgeStartVertexIndex(t,j)*e+e*(0===t&&0===R||1===t&&0===R||2===t&&1===R||3===t&&3===R?1:0)}else{f(r[1]||r[3]),c=r[1]?3:1;const t=u.geometryState.edgeResolutions[c];l=0===R||3===R?0:t}const d=u.geometry;{const t=v+V,e=T+w,o=d.getEdgeFirstVertexIndex(c)+l,s=d.vertexAttributes,r=u.localOrigin,a=s.position,f=a.typedBuffer,m=o*a.typedBufferStride,p=f[m]+r[0]-i[0],x=f[m+1]+r[1]-i[1],M=f[m+2]+r[2]-i[2];Bt(p,x,M,g);const y=h.position,B=y.typedBuffer,I=t*y.typedBufferStride;B[I]=p,B[I+1]=x,B[I+2]=M;const b=e*y.typedBufferStride;B[b]=p,B[b+1]=x,B[b+2]=M;const C=h.uv0;C.setValues(t,Math.round(S*n),Math.round(L*n)),C.setValues(e,Math.round(S*n),Math.round(L*n));{const n=s.normalCompressed.typedBuffer,r=o*s.normalCompressed.typedBufferStride,i=h.normalCompressed,a=i.typedBuffer;{const e=t*i.typedBufferStride;a[e]=n[r],a[e+1]=n[r+1]}{const t=e*i.typedBufferStride;a[t]=n[r],a[t+1]=n[r+1]}}}}else{const n=Q[e],s=Q[a];let l;if(n||s){const e=t(z*(1-M)+G*M,X,Y),n=t(H*(1-y)+J*y,Z,$);l=r(e,n,c)}else l=rt(nt,R);U(M,y,l),et(R);const u=I-i[0],d=b-i[1],f=C-i[2];Bt(u,d,f,g),o.setEdgeVertexFromValuesRawPositionUVNormal(e,V,u,d,f,S,L,A,P,D),o.setEdgeVertexFromValuesRawPositionUVNormal(a,w,u,d,f,S,L,A,P,D)}}for(let t=0;t<4;++t)yt[t]=null}function rt(t,e){const n=4*e,o=c.reduce((e,o)=>Math.min(e,t[n+o]?.level??1/0),1/0);m&&(f(!t[n+0]||!t[n+2]||p(t[n+0],t[n+2],5)),f(!t[n+1]||!t[n+3]||p(t[n+1],t[n+3],7)));let s=0,i=0;for(let c=0;c<4;++c){const e=t[n+c];if(e?.level===o){const t=0===c||1===c,n=0===c||3===c,o=e.extent,a=o[t?0:2],l=o[n?1:3],u=e.renderData?.geometryState?.samplerData;i+=r(a,l,u),s++}}const a=s?i/s:0;return f(null!=a),a}function it(t){const{vao:e,geometry:n}=t,{vertexAttributes:o,edgeVerticesStartIndex:s}=n,r=o.position.typedBuffer;e.buffer()?.setSubData(r,s,s,r.length)}function at(t){const{vao:e,geometry:n}=t,{indices:o,indexCount:s,edgeIndicesStartIndex:r}=n;e.indexBuffer.setSubData(o,r,r,s)}class ct{constructor(t,e,n,o,s){this.isNorth=t,this.connectedRowOffset=e,this.connectedOuterEdgeOffset=n,this.rowOffset=o,this.latitudeResolution=s}}const lt=[[0,1],[1,0],[0,-1],[-1,0]],ut=new a,dt=.5*d,ft=new Uint16Array(u+1),mt=new Int32Array(u+1),gt=new Int32Array(u+1),ht=new Int32Array(u+1),pt=new Float64Array(u+1),xt=new Float64Array(u+1),Mt=s(-1/0,-1/0,1/0,1/0),yt=[null,null,null,null];function St(t,e,n){if(!e)return!1;const o=x(t,e);return o>0||0===o&&n>=2}class Lt{constructor(){this.vertex0Index=0,this.stride=1,this.count=0}getVertexIndex(t){return f(0<=t&&t<this.count),this.vertex0Index+this.stride*t}}const vt=[new Lt,new Lt,new Lt,new Lt];function Bt(t,e,n,o){t<o[0]?o[0]=t:t>o[3]&&(o[3]=t),e<o[1]?o[1]=e:e>o[4]&&(o[4]=e),n<o[2]?o[2]=n:n>o[5]&&(o[5]=n)}function Vt(t){const{edgeResolutions:e,numVerticesPerSide:n}=t,o=1+Math.max(...e);return Math.max(n,o)}function It(t,e,n,o,s,r){const i=t*s,a=r[i],c=r[i+1],l=r[i+2],u=e*s,d=r[u],f=r[u+1],m=r[u+2],g=n*s,h=r[g],p=r[g+1],x=r[g+2],M=o*s,y=r[M],S=r[M+1],L=r[M+2];return(d-y)*(d-y)+(f-S)*(f-S)+(m-L)*(m-L)>(a-h)*(a-h)+(c-p)*(c-p)+(l-x)*(l-x)}function bt(t,e,n,o,s){t[e]=n,t[e+1]=o,t[e+2]=o,t[e+3]=s,t[e+4]=s,t[e+5]=n}const Ct=6;export{N as createPlanarGlobePatch,S as createSphericalGlobePatch,U as updateCornerSpherical,F as updateCornersPlanar,q as updateEdgeElevationsAndResolutionsPlanar,T as updateEdgeElevationsAndResolutionsSpherical,W as updateEdgesAndCornersPlanar,C as updateEdgesAndCornersSpherical};
2
+ import{clamp as t,isPowerOfTwo as e}from"../../../core/mathUtils.js";import{maxUint16 as n}from"../../../core/typedArrayUtil.js";import{empty as o}from"../../../geometry/support/aaBoundingBox.js";import{fromValues as s}from"../../../geometry/support/aaBoundingRect.js";import{sampleElevation as r,sampleSingleElevation as i}from"./ElevationData.js";import{PatchGeometryLUT as a}from"./PatchGeometryLUT.js";import{zeroToFour as c,neighborTileIfLoadedOrSelf as l}from"./PatchRenderData.js";import{maxPatchTesselation as u,elevationNoDataValue as d}from"./TerrainConst.js";import{internalAssert as f,enableTerrainInternalChecks as m,neighborEdgeIndices as g,almostEquals as h}from"./terrainUtils.js";import{isCornerNeighbor as p}from"./Tile.js";import{compareTilesByLij as x}from"./tileUtils.js";import{compressNormal as M}from"../webgl-engine/lib/Normals.js";const y=65536;function S(t,e){const{tile:n,geometry:s,geometryState:r}=t,{extentInRadians:i,surface:a}=n,{isWebMercator:c,renderer:l}=a,{numVerticesPerSide:u,wireframe:d}=r,f=u-1,m=(u-2)**2,g=c&&(2===e||3===e),h=c&&(1===e||3===e),p=((g?1:0)+(h?1:0))*It*u,x=vt(r),M=m+p+4*x,y=l.tileGeometryCache.acquire(M);s.numVerticesPerSide=u,s.vertexAttributes=y,s.maxEdgeVertexCount=x;const{boundingBox:S}=s;o(S);const B=O(t);ct.update(f,i,B),v(t),s.poleVerticesStartIndex=m;const V=L(t,g,h);s.edgeVerticesStartIndex=m+p,_(t),C(t),J(s,V,d),t.intersectionData=null}function L(t,e,o){const{tile:s,localOrigin:r,geometry:i}=t,{extent:a,ellipsoid:c}=s,{boundingBox:l,numVerticesPerSide:u,vertexAttributes:d,poleVerticesStartIndex:f}=i,m=u-1,g=r[0],h=r[1],p=r[2],x=c.radius,y=a[1],S=a[3],L=[];let v=f;const B=(t,e)=>{const o=e*u;Lt(-g,-h,t*x-p,l),L.push(new it(1===t,o,1===t?0:2,v,It));const s=D(-1===t?y:S,x),r=t*Math.PI/2-s,i=.99*(1===t?1:-1),a=x+0,{position:c,uv0:f}=d,{typedBuffer:B,typedBufferStride:V}=d.normalCompressed;for(let u=1;u<=It;++u){const t=s+r*(u/It),e=Math.cos(t),o=Math.sin(t);for(let s=0;s<=m;s++){const t=s/m,r=ct.sinLonLUT[s],u=ct.cosLonLUT[s]*e,d=r*e,x=o,y=u*a-g,S=d*a-h,L=x*a-p;Lt(y,S,L,l),c.setValues(v,y,S,L),f.setValues(v,Math.round(t*n),Math.round(i*n)),M(B,v,u,d,x,V),++v}}};return e&&B(-1,0),o&&B(1,m),L}function v(t){const e=t.geometryState.samplerData,n=1===e?.length?e[0]:null;n?B(t,n):V(t)}function B(t,e){const{tile:n}=t;if(!n.intersectsClippingArea)return;const{geometry:o,geometryState:s,localOrigin:r}=t,{numVerticesPerSide:i}=s,a=i-2,c=i-1,{vertexAttributes:l,boundingBox:u}=o,{position:d,uv0:f}=l,{typedBuffer:m,typedBufferStride:g}=l.normalCompressed,{extent:h}=n,p=n.ellipsoid.radius,x=r[0],y=r[1],S=r[2],L=d.typedBuffer,v=d.typedBufferStride,B=f.typedBuffer,V=f.typedBufferStride;I(c,h,e);let T=0;const U=e.data.values;if(1<=a){const t=ut[1],e=ct.sinLatLUT[1],n=ct.cosLatLUT[1];for(let o=1;o<=a;o++){const s=ct.sinLonLUT[o],r=ct.cosLonLUT[o],i=p+b(o,1,U),a=i*r*n-x,c=i*s*n-y,l=i*e-S;Lt(a,c,l,u);const d=(o-1)*v;L[d]=a,L[d+1]=c,L[d+2]=l;const f=(o-1)*V;B[f]=ut[o],B[f+1]=t}}for(let I=1;I<=a;I++){const t=ct.sinLatLUT[I],e=ct.cosLatLUT[I],n=I+1,o=ut[n],s=ct.sinLatLUT[n],r=ct.cosLatLUT[n],i=ct.sinLonLUT[0],l=ct.cosLonLUT[0],d=p+b(0,I,U);let f=l*e*d-x,h=i*e*d-y,C=t*d-S;const A=T*v;let P=L[A],D=L[A+1],E=L[A+2];for(let w=1;w<=a;w++){const i=ct.sinLonLUT[w],l=ct.cosLonLUT[w];let d=0,A=0,O=0;if(w<a){const t=(T+1)*v;d=L[t],A=L[t+1],O=L[t+2]}else{const n=ct.sinLonLUT[c],o=ct.cosLonLUT[c],s=p+b(c,I,U);d=o*e*s-x,A=n*e*s-y,O=t*s-S}const R=f,N=h,j=C;f=P,h=D,C=E,P=d,D=A,E=O;const F=d-R,q=A-N,W=O-j;let k=0,z=0,G=0;if(I>1){const t=(T-a)*v;k=L[t],z=L[t+1],G=L[t+2]}else{const t=ct.sinLatLUT[0],e=ct.cosLatLUT[0],n=p+b(w,0,U);k=l*e*n-x,z=i*e*n-y,G=t*n-S}const H=p+b(w,n,U),J=l*r*H-x,K=i*r*H-y,Q=s*H-S;if(I<a){const t=T+a,e=t*v;L[e]=J,L[e+1]=K,L[e+2]=Q,Lt(J,K,Q,u);const n=t*V;B[n]=ut[w],B[n+1]=o}const X=k-J,Y=z-K,Z=G-Q;let $=l*e,_=i*e,tt=t;tt*tt<.999&&($=W*Y-q*Z,_=F*Z-W*X,tt=q*X-F*Y);const et=1/Math.sqrt($*$+_*_+tt*tt);M(m,T,$*et,_*et,tt*et,g),++T}}}function V(t){const{tile:e}=t;if(!e.intersectsClippingArea)return;const{geometry:o,geometryState:s,localOrigin:i}=t,{numVerticesPerSide:a,samplerData:c}=s,l=a-2,u=a-1,{vertexAttributes:d,boundingBox:f}=o,{position:m,uv0:g}=d,{typedBuffer:h,typedBufferStride:p}=d.normalCompressed,{extent:x}=e,y=x[0],S=x[2],L=x[1],v=x[3],B=e.ellipsoid.radius,V=i[0],I=i[1],b=i[2],T=m.typedBuffer,U=m.typedBufferStride,C=1/u;let A=0;if(1<=l){const t=C,e=L*(1-t)+v*t,o=ct.sinLatLUT[1],s=ct.cosLatLUT[1];for(let i=1;i<=l;i++){const a=i*C,l=y*(1-a)+S*a,u=ct.sinLonLUT[i],d=ct.cosLonLUT[i],m=B+r(l,e,c),h=m*d*s-V,p=m*u*s-I,x=m*o-b;Lt(h,p,x,f);const M=(i-1)*U;T[M]=h,T[M+1]=p,T[M+2]=x,g.setValues(i-1,Math.round(a*n),Math.round(t*n))}}for(let P=1;P<=l;P++){const t=P*C,e=L*(1-t)+v*t,o=ct.sinLatLUT[P],s=ct.cosLatLUT[P],i=P+1,a=i*C,d=L*(1-a)+v*a,m=ct.sinLatLUT[i],x=ct.cosLatLUT[i],D=ct.sinLonLUT[0],E=ct.cosLonLUT[0],w=B+r(y,e,c);let O=E*s*w-V,R=D*s*w-I,N=o*w-b;const j=A*U;let F=T[j],q=T[j+1],W=T[j+2];for(let v=1;v<=l;v++){const t=v*C,i=y*(1-t)+S*t,D=ct.sinLonLUT[v],E=ct.cosLonLUT[v];let w=0,j=0,k=0;if(v<l){const t=(A+1)*U;w=T[t],j=T[t+1],k=T[t+2]}else{const t=ct.sinLonLUT[u],n=ct.cosLonLUT[u],i=B+r(S,e,c);w=n*s*i-V,j=t*s*i-I,k=o*i-b}const z=O,G=R,H=N;O=F,R=q,N=W,F=w,q=j,W=k;const J=w-z,K=j-G,Q=k-H;let X=0,Y=0,Z=0;if(P>1){const t=(A-l)*U;X=T[t],Y=T[t+1],Z=T[t+2]}else{const t=ct.sinLatLUT[0],e=ct.cosLatLUT[0],n=B+r(i,L,c);X=E*e*n-V,Y=D*e*n-I,Z=t*n-b}const $=B+r(i,d,c),_=E*x*$-V,tt=D*x*$-I,et=m*$-b;if(P<l){const e=A+l,o=e*U;T[o]=_,T[o+1]=tt,T[o+2]=et,Lt(_,tt,et,f),g.setValues(e,Math.round(t*n),Math.round(a*n))}const nt=X-_,ot=Y-tt,st=Z-et;let rt=E*s,it=D*s,at=o;at*at<.999&&(rt=Q*ot-K*st,it=J*st-Q*nt,at=K*nt-J*ot);const lt=1/Math.sqrt(rt*rt+it*it+at*at);M(h,A,rt*lt,it*lt,at*lt,p),++A}}}function I(e,o,s){const r=o[0],i=o[2],a=o[1],c=o[3],l=1/e,{dx:u,dy:d,x0:f,y1:m,safeWidth:g}=s,h=s.data.width;for(let p=0;p<=e;p++){const e=p*l,o=t(u*(r*(1-e)+i*e-f),0,g),s=Math.floor(o);dt[p]=s,gt[p]=o-s;const x=t(d*(m-(a*(1-e)+c*e)),0,g),M=Math.floor(x);ft[p]=M*h,mt[p]=(M+1)*h,ht[p]=x-M,ut[p]=Math.round(e*n)}}function b(t,e,n){const o=dt[t],s=gt[t],r=ft[e],i=mt[e],a=ht[e],c=r+o,l=n[c],u=n[c+1],d=n[i+o],f=n[i+o+1];if(l+d+u+f>=lt)return 0;const m=l+(u-l)*s;return m+(d+(f-d)*s-m)*a}function T(t){t.tile.intersectsClippingArea&&(C(t),st(t),t.intersectionData=null)}function U(t){t.tile.intersectsClippingArea&&(tt(t),C(t),st(t),rt(t),t.intersectionData=null)}function C(t){t.tile.intersectsClippingArea&&(P(t),A(t))}function A(t){const{geometry:o,geometryState:s,tile:a,localOrigin:c}=t,{level:u,extent:d,extentInRadians:p,ellipsoid:y}=a,S=y.radius,L=p[0],v=p[2],B=p[1],V=p[3],{samplerData:I}=s,b=d[0],T=d[2],U=d[1],C=d[3],A=O(t),{boundingBox:P,vertexAttributes:D}=o,E=c[0],w=c[1],R=c[2],{position:N,uv0:j}=D,F=N.typedBuffer,q=N.typedBufferStride,W=j.typedBuffer,k=j.typedBufferStride,{typedBuffer:z,typedBufferStride:G}=D.normalCompressed,H=1===I?.length?I[0]:null,J=(t,e,n)=>H?i(t,e,H)??0:r(t,e,I)??0;for(let O=0;O<4;++O){const c=1===O||3===O,p=s.edgeResolutions[O];f(e(p));const y=p+1,D=l(a,s.edgePeerNeighbors[O]);if(Mt(a,D,O)){et(t,O,D);continue}const N=null!=D;f(!N||D.level===a.level),f(!N||x(a,D)<=0);const j=D?.renderData,K=j?.geometryState;if(m){const t=a.surface;if(!D&&t&&!t.updatingRootTiles){const e=g[O],n=a.findNeighborTile(e,t=>t.loaded||t.leaf||t.level===a.level);n?n.intersectsClippingArea&&(f(!n.loaded),f(!n.leaf),f(n.level===u)):f(null==t?.rootTiles||!a.shouldHaveNeighbor(e))}}const Q=1===O?d[2]:d[0],X=D?.extent,Y=X&&c?1===O?X[0]:X[2]:Q,Z=0===O?d[3]:d[1],$=1===O?1:0,_=0===O?1:0,tt=1===O?v:L,nt=0===O?V:B,ot=Math.sin(tt),st=Math.cos(tt),rt=Math.sin(nt),it=Math.cos(nt),at=K?.samplerData,ct=1===at?.length?at[0]:null,lt=(t,e,n)=>ct?i(n,e,ct)??0:r(n,e,at)??0,ut=N?(t,e,n)=>.5*(J(t,e)+lt(t,e,n)):J,dt=o.outerEdgesOffsetAndLength[2*O+0],ft=null!=H||null!=I&&I.some(t=>null!=t),mt=null!=ct||null!=at&&at.some(t=>null!=t),gt=ft||mt,ht=1/p,pt=n*ht,xt=$*n,yt=_*n,St=dt;f(!X||h(X[2]-X[0],d[2]-d[0]));(()=>{const t=1===O?-1:3===O?1:0,e=0===O?-1:2===O?1:0,n=(d[2]-d[0])*ht,o=t*n,s=e*n,a=c?t*((v-L)*ht):0,l=c?0:e*ht,u=_,f=c?tt+a:tt,m=c?Math.sin(f):ot,g=c?Math.cos(f):st,h=c?tt-a:tt,p=c?Math.sin(h):ot,x=c?Math.cos(h):st,B=c?nt:A(u+l),V=c?rt:Math.sin(B),D=c?it:Math.cos(B),j=c?nt:A(u-l),J=c?rt:Math.sin(j),K=c?it:Math.cos(j);let X=0,$=0,et=0;{const t=0*ht,e=c?Q:b*(1-t)+T*t,n=c?Y:e,o=c?U*(1-t)+C*t:Z,s=c?tt:L*(1-t)+v*t,r=c?ot:Math.sin(s),i=c?st:Math.cos(s),a=c?A(t):nt,l=c?Math.sin(a):rt,u=c?Math.cos(a):it,d=S+ut(e,o,n);X=i*u*d,$=r*u*d,et=l*d}let lt=0,dt=0,ft=0;{const t=1*ht,e=c?Q:b*(1-t)+T*t,n=c?Y:e,o=c?U*(1-t)+C*t:Z,s=c?tt:L*(1-t)+v*t,r=c?ot:Math.sin(s),i=c?st:Math.cos(s),a=c?A(t):nt,l=c?Math.sin(a):rt,u=c?Math.cos(a):it,d=S+ut(e,o,n);lt=i*u*d,dt=r*u*d,ft=l*d}for(let d=1;d<y-1;++d){let t=0,e=0,n=0;{const o=(d+1)*ht,s=c?Q:b*(1-o)+T*o,r=c?Y:s,i=c?U*(1-o)+C*o:Z,a=c?tt:L*(1-o)+v*o,l=c?ot:Math.sin(a),u=c?st:Math.cos(a),f=c?A(o):nt,m=c?Math.sin(f):rt,g=c?Math.cos(f):it,h=S+ut(s,i,r);t=u*g*h,e=l*g*h,n=m*h}const a=t,l=e,u=n,f=lt,h=dt,y=ft;lt=a,dt=l,ft=u;{const t=St+d,e=t*q,n=f-E,o=h-w,s=y-R;F[e]=n,F[e+1]=o,F[e+2]=s,Lt(n,o,s,P);const r=Math.round(d*pt),i=t*k;W[i]=c?xt:r,W[i+1]=c?r:yt}const B=X,j=$,_=et;X=f,$=h,et=y;const mt=f,Mt=h,vt=y,Bt=1/Math.sqrt(mt*mt+Mt*Mt+vt*vt),Vt=vt*Bt;let It=0,bt=0,Tt=0;if(gt&&Vt*Vt<.999){let t=0,e=0,n=0;{const o=0===O?-1:1;t=o*(a-B),e=o*(l-j),n=o*(u-_)}{const a=d*ht,l=c?Q:b*(1-a)+T*a,u=c?Y:l,f=c?U*(1-a)+C*a:Z,h=c?tt:L*(1-a)+v*a,M=c?ot:Math.sin(h),y=c?st:Math.cos(h),B=c?A(a):nt,P=c?Math.sin(B):rt,E=c?Math.cos(B):it;let w=mt,R=Mt,j=vt;if(N){const t=u-o,e=f-s,n=S+(ct?i(t,e,ct)??0:r(t,e,at)??0),a=c?E:K;w=(c?x:y)*a*n,R=(c?p:M)*a*n,j=(c?P:J)*n}{const a=l+o,u=f+s,d=S+(H?i(a,u,H)??0:r(a,u,I)??0),h=c?E:D,p=(c?g:y)*h*d,x=(c?m:M)*h*d,L=(c?P:V)*d;N||(w=2*mt-p,R=2*Mt-x,j=2*vt-L);const v=3===O?-1:1,B=v*(w-p),b=v*(R-x),T=v*(j-L);It=n*b-e*T,bt=t*T-n*B,Tt=e*B-t*b;const U=1/Math.sqrt(It*It+bt*bt+Tt*Tt);It*=U,bt*=U,Tt*=U}}}else It=mt*Bt,bt=Mt*Bt,Tt=vt*Bt;M(z,St+d,It,bt,Tt,G)}})()}}function P(t){nt(t)}function D(t,e){return Math.PI/2-2*Math.atan(Math.exp(-t/e))}function E(t,e,n,o){return D(t*(1-o)+e*o,n)}function w(t,e,n){return t*(1-n)+e*n}function O(t){const{tile:e}=t;if(e.surface.isWebMercator){const t=e.extent,n=e.ellipsoid.radius;return e=>E(t[1],t[3],n,e)}const n=e.extentInRadians;return t=>w(n[1],n[3],t)}function R(t){const{tile:e,geometryState:n,geometry:s}=t,{extent:r,surface:i}=e,{wireframe:a}=n,c=r[0],l=r[1],u=r[2]-c,d=r[3]-l,{numVerticesPerSide:f,clippingArea:m}=n,g=null!=m?Math.max(0,(m[0]-c)/u):0,h=null!=m?Math.max(0,(m[1]-l)/d):0,p=null!=m?Math.min(1,(m[2]-c)/u):1,x=null!=m?Math.min(1,(m[3]-l)/d):1,M=(f-2)**2,y=vt(n),S=M+4*y,L=i.renderer.tileGeometryCache.acquire(S),{boundingBox:v}=s;o(v),s.numVerticesPerSide=f,s.vertexAttributes=L,s.maxEdgeVertexCount=y,s.minu=g,s.minv=h,s.maxu=p,s.maxv=x,N(t),s.edgeVerticesStartIndex=M,_(t),q(t),J(s,[],a),t.intersectionData=null}function N(e){const o=e.tile;if(!o.intersectsClippingArea)return;const{geometry:s,geometryState:a,localOrigin:c}=e,{samplerData:l,clippingArea:u,numVerticesPerSide:d}=a,{surface:f,extent:m,ellipsoid:g}=o,{isWebMercatorOnPlateCarree:h}=f,p=null!=u?u:pt,x=m[0],y=m[1],S=m[2],L=m[3],v=Math.max(x,p[0]),B=Math.min(S,p[2]),V=Math.max(y,p[1]),I=Math.min(L,p[3]),b=g.radius,T=o.horizontalScale,U=d-1,C=d-2,{minu:A,minv:P,maxu:D,maxv:E,boundingBox:w,vertexAttributes:O}=s,{position:R,uv0:N}=O,{typedBuffer:j,typedBufferStride:F}=O.normalCompressed,q=c[0],W=c[1],k=c[2],z=R.typedBuffer,G=R.typedBufferStride;let H=0;const J=t(y,V,I),K=h?(Math.PI/2-2*Math.atan(Math.exp(-J/b)))*b:J*T,Q=1/U,X=t(y*(1-Q)+L*Q,V,I);let Y=K,Z=h?(Math.PI/2-2*Math.atan(Math.exp(-X/b)))*b:X*T;const $=1===l?.length?l[0]:null,_=$?(t,e)=>i(t,e,$)??0:(t,e)=>r(t,e,l)??0;for(let r=1;r<=C;r++){const e=r/U,o=t(y*(1-e)+L*e,V,I),s=t(e,P,E),i=Z,a=(r-1)/U,c=t(y*(1-a)+L*a,V,I),l=Y,u=(r+1)/U,d=t(y*(1-u)+L*u,V,I),f=h?(Math.PI/2-2*Math.atan(Math.exp(-d/b)))*b:d*T,m=t(u,P,E);Y=Z,Z=f;const g=t(x,v,B);let p=g*T,O=_(g,o);const R=1/U,J=t(R,A,D),K=t(x*(1-J)+S*J,v,B);let Q=J,X=K,$=K*T,tt=_(K,o);if(1===r){const e=$-q,o=Y-W,r=tt-k,i=0*G;z[i]=e,z[i+1]=o,z[i+2]=r,Lt(e,o,r,w);const a=t(R,A,D);N.setValues(H,Math.round(a*n),Math.round(s*n))}for(let h=1;h<=C;h++){const e=$,a=tt,u=(h+1)/U,g=t(u,A,D),y=t(x*(1-u)+S*u,v,B),L=X;X=y;{const t=H+1,e=t*G;if(1===r||h===C){const a=y*T,c=_(y,o);if(1===r&&h<C){const o=a-q,r=i-W,l=c-k;z[e]=o,z[e+1]=r,z[e+2]=l,Lt(o,r,l,w),N.setValues(t,Math.round(g*n),Math.round(s*n))}$=a,tt=c}else $=z[e]+q,tt=z[e+2]+k}const V=$,I=tt,b=p,P=O;p=e,O=a;const E=(H-C)*G,R=1===r?_(L,c):z[E+2]+k,J=_(L,d);if(r<C){const t=H+C,o=t*G,s=e-q,r=f-W,i=J-k;z[o]=s,z[o+1]=r,z[o+2]=i,Lt(s,r,i,w);const a=Q;Q=g,N.setValues(t,Math.round(a*n),Math.round(m*n))}{const t=V-b,e=l-f,n=e*(I-P),o=t*(R-J),s=-e*t,r=n*n+o*o+s*s;if(0===r)M(j,H,0,0,1,F);else{const t=1/Math.sqrt(r);M(j,H,n*t,o*t,s*t,F)}}++H}}}function j(t){t.tile.intersectsClippingArea&&(tt(t),q(t),st(t),rt(t),t.intersectionData=null)}function F(t){t.tile.intersectsClippingArea&&(q(t),st(t),t.intersectionData=null)}function q(t){t.tile.intersectsClippingArea&&(k(t),W(t))}function W(n){const{geometry:o,geometryState:s,localOrigin:a}=n,c=n.tile,{surface:u,extent:d}=c,{clippingArea:h,samplerData:p}=s,M=null!=h?h:pt,y=d[0],S=d[2],L=d[1],v=d[3],B=[v>M[3],S>M[2],L<M[1],y<M[0]],V=c.horizontalScale,I=H(u.isWebMercatorOnPlateCarree,c.ellipsoid.radius,V),{minu:b,minv:T,maxu:U,maxv:C,boundingBox:A}=o,P=Math.max(y,M[0]),D=Math.min(S,M[2]),E=Math.max(L,M[1]),w=Math.min(v,M[3]),O=a[0],R=a[1],N=a[2],j=1===p?.length?p[0]:void 0,F=j?(t,e)=>i(t,e,j)??0:(t,e)=>r(t,e,p)??0;for(let q=0;q<4;++q){const a=1===q||3===q,d=s.edgeResolutions[q];f(e(d));const h=d+1,M=B[q],j=l(c,s.edgePeerNeighbors[q]);if(!M&&Mt(c,j,q)){et(n,q,j);continue}const W=null!=j&&!M,k=j?.renderData,z=k?.geometryState;if(m&&(f(!W||j.level===c.level),f(!W||x(c,j)<=0),c&&!j&&!u.updatingRootTiles)){const t=g[q],e=c.findNeighborTile(t,t=>t.loaded||t.leaf||t.level===c.level);u.updatingRootTiles||(e?e.intersectsClippingArea&&(f(!e.loaded),f(!e.leaf),f(e.level===c.level)):f(null==u?.rootTiles||!c.shouldHaveNeighbor(t)))}const G=t(1===q?S:y,P,D),H=t(0===q?v:L,E,w),J=z?.samplerData,K=t(1===q?1:0,b,U),Q=t(0===q?1:0,T,C),X=1===J?.length?J[0]:null,Y=(t,e)=>X?i(t,e,X)??0:r(t,e,J)??0,Z=W?(t,e)=>.5*(Y(t,e)+F(t,e)):F,$=(S-y)/d,_=a?1===q?$:-$:0,tt=a?0:0===q?$:-$,nt=-_,ot=-tt;let st=0,rt=0,it=0;{const e=0/d,n=a?G:t(y*(1-e)+S*e,P,D),o=a?t(L*(1-e)+v*e,E,w):H,s=Z(n,o);st=n*V,rt=I(o),it=s}let at=0,ct=0,lt=0;{const e=1/d,n=a?G:t(y*(1-e)+S*e,P,D),o=a?t(L*(1-e)+v*e,E,w):H,s=Z(n,o);at=n*V,ct=I(o),lt=s}for(let e=1;e<h-1;++e){const n=e/d,s=at,i=ct,c=lt;{const r=a?K:t(n,b,U),l=a?t(n,T,C):Q,u=s-O,d=i-R,f=c-N;Lt(s,d,f,A),o.setEdgeVertexFromValuesRawPositionUV(q,e,u,d,f,r,l)}{const n=(e+1)/d,o=a?G:t(y*(1-n)+S*n,P,D),s=a?t(L*(1-n)+v*n,E,w):H,r=Z(o,s);at=o*V,ct=I(s),lt=r}const l=at,u=lt,f=st,m=rt,g=it;st=s,rt=i,it=c;let h=0,x=0,M=0;if(a){const e=ct-i,o=u-c,a=m-i,l=g-c,d=t(L*(1-n)+v*n,E,w),f=G+nt,y=f*V-s,S=r(f,d,p)-c,B=3===q?-1:1;if(h=B*(-a+e)*S,x=B*y*(-l+o),M=-B*y*(-a+e),W){const t=G+_,n=t*V-s;h=(-a+e)*(S-(r(t,d,J)-c)),x=(y-n)*(-l+o),M=-(y-n)*(-a+e)}}else{const e=l-s,o=u-c,a=f-s,d=g-c,m=t(y*(1-n)+S*n,P,D),L=H+ot,v=r(m,L,p)-c,B=I(L)-i,V=2===q?-1:1;if(h=V*B*(-d+o),x=V*(-a+e)*v,M=-V*B*(-a+e),W){const t=m,n=H+tt,s=I(n)-i;h=(-B+s)*(-d+o),x=(-a+e)*(-v+(r(t,n,J)-c)),M=-(-B+s)*(-a+e)}}const B=1/Math.sqrt(h*h+x*x+M*M);o.setEdgeNormalFromValues(q,e,h*B,x*B,M*B)}}}function k(t){nt(t)}function z(t,e){return(Math.PI/2-2*Math.atan(Math.exp(-t/e)))*e}function G(t,e){return t*e}function H(t,e,n){return t?t=>z(t,e):t=>G(t,n)}function J(t,e,n){const{numVerticesPerSide:o,vertexAttributes:s,maxEdgeVertexCount:r}=t,i=o-1,a=s.count,l=2*(o-3)*(o-3),u=4*(i+r-3),d=c.reduce((e,n)=>e+(i+t.getEdgeCount(n)-3),0),f=e.reduce((t,e)=>t+i*(2*(e.latitudeResolution-1)+1),0),m=3*(n?2:1),g=(l+u+f)*m,h=a>=y?new Uint32Array(g):new Uint16Array(g);for(let c=0;c<g;++c)h[c]=0;t.indices=h,t.indexCount=(l+d+f)*m,t.poleIndicesStartIndex=l*m,t.edgeIndicesStartIndex=(l+f)*m,n?(Y(t),Z(t,e),$(t)):(K(t),Q(t,e),X(t))}function K(t){const{numVerticesPerSide:e,indices:n,vertexAttributes:o}=t,{position:s}=o,{typedBuffer:r,typedBufferStride:i}=s,a=e-2,c=e-3,l=0,u=e-3;let d=0;for(let f=0;f<c;++f){const t=f*a;for(let e=l;e<u;++e){const o=t+e,s=o+1,c=s+a,l=c-1;Bt(o,s,c,l,i,r)?(n[d]=o,n[d+1]=s,n[d+2]=c,n[d+3]=c,n[d+4]=l,n[d+5]=o):(n[d]=o,n[d+1]=s,n[d+2]=l,n[d+3]=l,n[d+4]=s,n[d+5]=c),d+=6}}}function Q(t,e){const{numVerticesPerSide:n,indices:o,poleIndicesStartIndex:s}=t,r=n-1;let i=s;for(const a of e){const e=a.isNorth?1:2,s=a.isNorth?2:1,c=a.isNorth?3:4,l=a.isNorth?4:3;let u=t.getEdgeVertexIndex(a.connectedOuterEdgeOffset,0),d=1;for(let t=0;t<a.latitudeResolution;++t){const f=0===t?a.rowOffset:u+n;for(let n=0;n<r;n++){const r=f+n;o[i]=u,o[i+e]=u+1,o[i+s]=r,t<a.latitudeResolution-1?(o[i+c]=u+1,o[i+l]=r+1,o[i+5]=r,i+=6):i+=3,u+=d}u=f,d=1}}}function X(t){const{indices:e,numVerticesPerSide:n,edgeIndicesStartIndex:o}=t,s=n-1,r=s-2;let i=o;for(let a=0;a<4;++a){const n=St[a];let o=0,c=0;const l=t.getEdgeCount(a),u=n.count;f(u===s-1);const d=1===a||2===a,m=d?1:2,g=d?2:1,h=t.getEdgeFirstVertexIndex(a),p=1,x=n.vertex0Index,M=n.stride;for(;o<l-1||c<u-1;){const t=x+c*M,n=h+o*p,a=o<l-1,d=c<u-1,f=a&&(!d||(a?0+s*(o+.5)/(l-1):0)<=(d?1+r*(c+.5)/(u-1):0));f?++o:++c;const y=f?n+p:t+M;e[i]=t,e[i+m]=n,e[i+g]=y,i+=3}}t.indexCount=i}function Y(t){const{indices:e,numVerticesPerSide:n,vertexAttributes:o}=t,{position:s}=o,{typedBuffer:r,typedBufferStride:i}=s,a=n-2;let c=0;for(let l=0;l<n-3;++l){const t=l*a;for(let o=0;o<n-3;++o){const n=l*a+o,s=n+1,u=s+a,d=u-1,f=t+o,m=f+1,g=m+a;Bt(f,m,g,g-1,i,r)?(Vt(e,c,n,s,u),c+=6,Vt(e,c,u,d,n)):(Vt(e,c,n,s,d),c+=6,Vt(e,c,d,u,s)),c+=6}}}function Z(t,e){const{indices:n,numVerticesPerSide:o,poleIndicesStartIndex:s}=t,r=o-1;let i=s;for(const a of e){const e=a.connectedOuterEdgeOffset;let s=t.getEdgeVertexIndex(e,0),c=1;for(let t=0;t<a.latitudeResolution;++t){const e=0===t?a.rowOffset:s+o;for(let o=0;o<r;o++)Vt(n,i,s,s+1,e+o),i+=6,t<a.latitudeResolution-1&&(Vt(n,i,s+1,e+o+1,e+o),i+=6),s+=c;s=e,c=1}}}function $(t){const{indices:e,numVerticesPerSide:n,edgeIndicesStartIndex:o}=t,s=n-1,r=s-2;let i=o;for(let a=0;a<4;++a){const n=St[a];let o=0,c=0;const l=t.getEdgeCount(a),u=n.count;f(u===s-1);const d=1===a||2===a,m=d?1:3,g=d?3:1,h=t.getEdgeFirstVertexIndex(a),p=1,x=n.vertex0Index,M=n.stride;for(;o<l-1||c<u-1;){const t=x+c*M,n=h+o*p,a=o<l-1,d=c<u-1,f=a&&(!d||(a?0+s*(o+.5)/(l-1):0)<=(d?1+r*(c+.5)/(u-1):0));f?++o:++c;const y=f?n+p:t+M;e[i]=t,e[i+m]=n,e[i+m+1]=n,e[i+g]=y,e[i+g+1]=y,e[i+5]=t,i+=6}}t.indexCount=i}function _(t){const{geometry:e,geometryState:n}=t,{edgeResolutions:o}=n,{numVerticesPerSide:s,edgeVerticesStartIndex:r}=e,i=s-2;let a=r;for(let c=0;c<4;++c){{const t=0===c||2===c,e=(0===c?i-1:0)*i+(1===c?i-1:0),n=(t?0:1)*i+(t?1:0),o=St[c];o.vertex0Index=e,o.stride=n,o.count=i}{const t=o[c]+1;e.outerEdgesOffsetAndLength[2*c+0]=a,e.outerEdgesOffsetAndLength[2*c+1]=t,a+=t}}}function tt(t){_(t),t.geometryState.wireframe?$(t.geometry):X(t.geometry)}function et(o,s,r){const{geometryState:i,geometry:a,tile:c,localOrigin:l}=o,u=1===s||3===s,d=i.edgeResolutions[s];f(e(d));const m=d+1,{boundingBox:g,minu:h,minv:p,maxu:x,maxv:M,vertexAttributes:y}=a,S=t(1===s?1:0,h,x),L=t(0===s?1:0,p,M),v=r.renderData,B=v.geometryState,V=v.geometry,I=(s+2)%4,b=V.getEdgeCount(I),T=c.getNeighborEdgeStartVertexIndex(s,r)*d,U=d*2**(c.level-r.level);f(B.edgeResolutions[I]===U),f(b-1===U);const C=v.localOrigin[0]-l[0],A=v.localOrigin[1]-l[1],P=v.localOrigin[2]-l[2],D=a.getEdgeFirstVertexIndex(s),{position:E,uv0:w}=y,O=E.typedBuffer,R=E.typedBufferStride,N=y.normalCompressed,j=N.typedBuffer,F=N.typedBufferStride,q=V.vertexAttributes,W=V.getEdgeFirstVertexIndex(I),k=q.position.typedBuffer,z=q.position.typedBufferStride,G=q.normalCompressed.typedBuffer,H=q.normalCompressed.typedBufferStride;for(let e=1;e<m-1;++e){const o=D+e,s=W+(T+e),r=o*R,i=s*z,a=k[i]+C,c=k[i+1]+A,l=k[i+2]+P;O[r]=a,O[r+1]=c,O[r+2]=l,Lt(a,c,l,g);const f=o*F,m=s*H;j[f]=G[m],j[f+1]=G[m+1];const y=e/d,v=u?S:t(y,h,x),B=u?t(y,p,M):L;w.setValues(o,Math.round(v*n),Math.round(B*n))}}function nt(e){const{geometry:o,geometryState:s,localOrigin:i}=e,{clippingArea:a,samplerData:c}=s,{minu:l,minv:u,maxu:d,maxv:m,boundingBox:g,vertexAttributes:h}=o,p=e.tile,{surface:M,ellipsoid:y,extent:S,extentInRadians:L,horizontalScale:v}=p,B="local"===M.view?.viewingMode,V=y.radius;let I=0,b=0,T=0;const U=(t,e,n)=>{const o=L[0===e?1:3],s=L[0===t?0:2],r=Math.cos(o),i=Math.sin(o),a=Math.sin(s),c=Math.cos(s),l=V+n;I=c*r*l,b=a*r*l,T=i*l},C=B?(()=>{const e=a,n=null!=e&&(S[3]>e[3]||S[2]>e[2]||S[1]<e[1]||S[0]<e[0]),o=H(M.isWebMercatorOnPlateCarree,V,v);return(s,r,i)=>{const a=0===s?S[0]:S[2],c=0===r?S[1]:S[3],l=n?t(a,e[0],e[2]):a,u=n?t(c,e[1],e[3]):c,d=i;I=l*v,b=o(u),T=d}})():U;let A=0,P=0,D=0,E=0,w=0,R=0,N=0,j=0,F=0;const q=B&&M.isWebMercatorOnPlateCarree,W=(t,e,n,o,s)=>{let r=0,i=0,a=0;if(B){const t=e*v,s=q?(Math.PI/2-2*Math.atan(Math.exp(-n/V)))*V:n*v;r=t-I,i=s-b,a=o-T}else{const s=O(t),c=t.tile,l=c.extent,u=c.extentInRadians,d=(e-l[0])/(l[2]-l[0]),f=(n-l[1])/(l[3]-l[1]),m=u[0]*(1-d)+u[2]*d,g=s(f),h=Math.cos(g),p=Math.sin(g),x=Math.sin(m),M=Math.cos(m),y=V+o;r=M*h*y-I,i=x*h*y-b,a=p*y-T}switch(s){case 0:N+=r,j+=i,F+=a;break;case 1:E-=r,w-=i,R-=a;break;case 2:N-=r,j-=i,F-=a;break;case 3:E+=r,w+=i,R+=a}},k=a??pt,z=S[0],G=S[2],J=S[1],K=S[3],Q=[K>k[3],G>k[2],J<k[1],z<k[0]],X=Math.max(z,k[0]),Y=Math.min(G,k[2]),Z=Math.max(J,k[1]),$=Math.min(K,k[3]),_=t=>Math.max(k[0],Math.min(k[2],t)),tt=t=>Math.max(k[1],Math.min(k[3],t)),et=t=>{const e=s.cornerNeighborCornerTiles;A=0,P=0,D=1,E=0,w=0,R=0,N=0,j=0,F=0;let n=1/0;for(let s=0;s<4;++s){const o=e[4*t+s];n=Math.min(n,o?.level??1/0)}for(let s=0;s<4;++s){const o=e[4*t+s];xt[s]=o?.level===n?o:null}let o=1,i=0;for(let s=0;s<4;++s){const t=xt[s];t&&(o=Math.max(o,t?.renderData.geometryState.numVerticesPerSide),i=t.extent[2]-t.extent[0])}const a=i,c=o;f(c>1);const l=a/c;for(let s=0;s<4;++s){const t=xt[(s+3)%4],e=xt[s%4];if(!t&&!e)continue;const n=0===s?1:1===s?2:2===s?3:0,o=0===s?2:1===s?3:2===s?0:1;if(t&&e){const i=at[s][0]*l,a=at[s][1]*l,c=t.extent,u=_(c[0===n||1===n?2:0]+i),d=tt(c[0===n||3===n?3:1]+a),f=e.extent,m=_(f[0===o||1===o?2:0]+i),g=tt(f[0===o||3===o?3:1]+a),h=t.renderData,p=e.renderData,x=r(u,d,h.geometryState.samplerData),M=r(m,g,p.geometryState.samplerData);W(h,u,d,.5*(x+M),s)}else{const i=t??e,a=t?n:o,c=i.extent,u=at[s],d=_(c[0===a||1===a?2:0]+u[0]*l),f=tt(c[0===a||3===a?3:1]+u[1]*l),m=i.renderData,g=r(d,f,m.geometryState.samplerData);W(m,d,f,g,s)}}if(!B){const t=Math.sqrt(I*I+b*b+T*T);A=I/t,P=b/t,D=T/t}if(B||D*D<.999){const t=Math.sqrt(E*E+w*w+R*R);E/=t,w/=t,R/=t;const e=Math.sqrt(N*N+j*j+F*F);N/=e,j/=e,F/=e,A=R*j-w*F,P=E*F-R*N,D=w*N-E*j;const n=1/Math.sqrt(A*A+P*P+D*D);A*=n,P*=n,D*=n}},nt=s.cornerNeighborCornerTiles;for(let O=0;O<4;++O){const e=O,a=(O+1)%4,M=0===O||1===O?1:0,y=0===O||3===O?1:0,S=t(M,l,d),L=t(y,u,m),v=o.getEdgeFirstVertexIndex(e),B=o.getEdgeCount(e),V=0===O||3===O?B-1:0,U=o.getEdgeFirstVertexIndex(a),E=o.getEdgeCount(a),w=0===O||1===O?E-1:0;let R=-1;for(let t=0;t<4;++t){const e=nt[4*O+t],n=nt[4*O+R];e&&(-1===R||x(n,e)>0)&&(R=t)}const N=R,j=nt[4*O+N];if(j!==p){const t=p.level-j.level,e=2**t,o=[j.lij[0]+t,j.lij[1]*e,j.lij[2]*e],r=[o[1]+e===p.lij[1],0===O&&(1===N||0===N&&j!==nt[4*O+3])||1===O&&(0===N||1===N&&j!==nt[4*O+2]),o[1]===p.lij[1]+1,2===O&&(3===N||2===N&&j!==nt[4*O+1])||3===O&&(2===N||3===N&&j!==nt[4*O+0])],a=r.reduce((t,e)=>t+(e?1:0),0);f(1===a||2===a);let c=-1,l=-1;const u=j.renderData;if(1===a){const t=r.findIndex(t=>t);f(0<=t&&t<=3),c=(t+2)%4;const e=s.edgeResolutions[t];l=p.getNeighborEdgeStartVertexIndex(t,j)*e+e*(0===t&&0===O||1===t&&0===O||2===t&&1===O||3===t&&3===O?1:0)}else{f(r[1]||r[3]),c=r[1]?3:1;const t=u.geometryState.edgeResolutions[c];l=0===O||3===O?0:t}const d=u.geometry;{const t=v+V,e=U+w,o=d.getEdgeFirstVertexIndex(c)+l,s=d.vertexAttributes,r=u.localOrigin,a=s.position,f=a.typedBuffer,m=o*a.typedBufferStride,p=f[m]+r[0]-i[0],x=f[m+1]+r[1]-i[1],M=f[m+2]+r[2]-i[2];Lt(p,x,M,g);const y=h.position,B=y.typedBuffer,I=t*y.typedBufferStride;B[I]=p,B[I+1]=x,B[I+2]=M;const b=e*y.typedBufferStride;B[b]=p,B[b+1]=x,B[b+2]=M;const T=h.uv0;T.setValues(t,Math.round(S*n),Math.round(L*n)),T.setValues(e,Math.round(S*n),Math.round(L*n));{const n=s.normalCompressed.typedBuffer,r=o*s.normalCompressed.typedBufferStride,i=h.normalCompressed,a=i.typedBuffer;{const e=t*i.typedBufferStride;a[e]=n[r],a[e+1]=n[r+1]}{const t=e*i.typedBufferStride;a[t]=n[r],a[t+1]=n[r+1]}}}}else{const n=Q[e],s=Q[a];let l;if(n||s){const e=t(z*(1-M)+G*M,X,Y),n=t(J*(1-y)+K*y,Z,$);l=r(e,n,c)}else l=ot(nt,O);C(M,y,l),et(O);const u=I-i[0],d=b-i[1],f=T-i[2];Lt(u,d,f,g),o.setEdgeVertexFromValuesRawPositionUVNormal(e,V,u,d,f,S,L,A,P,D),o.setEdgeVertexFromValuesRawPositionUVNormal(a,w,u,d,f,S,L,A,P,D)}}for(let t=0;t<4;++t)xt[t]=null}function ot(t,e){const n=4*e,o=c.reduce((e,o)=>Math.min(e,t[n+o]?.level??1/0),1/0);m&&(f(!t[n+0]||!t[n+2]||p(t[n+0],t[n+2],5)),f(!t[n+1]||!t[n+3]||p(t[n+1],t[n+3],7)));let s=0,i=0;for(let c=0;c<4;++c){const e=t[n+c];if(e?.level===o){const t=0===c||1===c,n=0===c||3===c,o=e.extent,a=o[t?0:2],l=o[n?1:3],u=e.renderData?.geometryState?.samplerData;i+=r(a,l,u),s++}}const a=s?i/s:0;return f(null!=a),a}function st(t){const{vao:e,geometry:n}=t,{vertexAttributes:o,edgeVerticesStartIndex:s}=n,r=o.position.typedBuffer;e.buffer()?.setSubData(r,s,s,r.length)}function rt(t){const{vao:e,geometry:n}=t,{indices:o,indexCount:s,edgeIndicesStartIndex:r}=n;e.indexBuffer.setSubData(o,r,r,s)}class it{constructor(t,e,n,o,s){this.isNorth=t,this.connectedRowOffset=e,this.connectedOuterEdgeOffset=n,this.rowOffset=o,this.latitudeResolution=s}}const at=[[0,1],[1,0],[0,-1],[-1,0]],ct=new a,lt=.5*d,ut=new Uint16Array(u+1),dt=new Int32Array(u+1),ft=new Int32Array(u+1),mt=new Int32Array(u+1),gt=new Float64Array(u+1),ht=new Float64Array(u+1),pt=s(-1/0,-1/0,1/0,1/0),xt=[null,null,null,null];function Mt(t,e,n){if(!e)return!1;const o=x(t,e);return o>0||0===o&&n>=2}class yt{constructor(){this.vertex0Index=0,this.stride=1,this.count=0}getVertexIndex(t){return f(0<=t&&t<this.count),this.vertex0Index+this.stride*t}}const St=[new yt,new yt,new yt,new yt];function Lt(t,e,n,o){t<o[0]?o[0]=t:t>o[3]&&(o[3]=t),e<o[1]?o[1]=e:e>o[4]&&(o[4]=e),n<o[2]?o[2]=n:n>o[5]&&(o[5]=n)}function vt(t){const{edgeResolutions:e,numVerticesPerSide:n}=t,o=1+Math.max(...e);return Math.max(n,o)}function Bt(t,e,n,o,s,r){const i=t*s,a=r[i],c=r[i+1],l=r[i+2],u=e*s,d=r[u],f=r[u+1],m=r[u+2],g=n*s,h=r[g],p=r[g+1],x=r[g+2],M=o*s,y=r[M],S=r[M+1],L=r[M+2];return(d-y)*(d-y)+(f-S)*(f-S)+(m-L)*(m-L)>(a-h)*(a-h)+(c-p)*(c-p)+(l-x)*(l-x)}function Vt(t,e,n,o,s){t[e]=n,t[e+1]=o,t[e+2]=o,t[e+3]=s,t[e+4]=s,t[e+5]=n}const It=6;export{R as createPlanarGlobePatch,S as createSphericalGlobePatch,j as updateEdgeElevationsAndResolutionsPlanar,U as updateEdgeElevationsAndResolutionsSpherical,F as updateEdgesAndCornersPlanar,T as updateEdgesAndCornersSpherical};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{equals as e}from"../../../core/arrayUtils.js";import"../../../core/has.js";import{isPowerOfTwo as t}from"../../../core/mathUtils.js";import{disposeMaybe as r,releaseMaybe as i}from"../../../core/maybe.js";import{distance as s,dist as o,len as a,subtract as n,normalize as l,dot as d,sub as g,equals as h}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{create as u,clone as m}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{containsXY as c}from"../../../geometry/support/aaBoundingRect.js";import{earth as f}from"../../../geometry/support/Ellipsoid.js";import{glLayout as p}from"../support/buffer/glUtil.js";import{GeometryState as y}from"./GeometryState.js";import{PatchGeometry as x}from"./PatchGeometry.js";import{maxTileNeighborLevelDelta as _}from"./TerrainConst.js";import{internalAssert as v,neighborEdgeIndices as $,oppositeEdge as E,neighborCornerIndices as C,enableTerrainInternalChecks as S,v32s as D,lij2s as b}from"./terrainUtils.js";import{TextureFader as j}from"./TextureFader.js";import{TextureReference as R}from"./TextureReference.js";import V from"./TileOverlayData.js";import{fallsWithinLayerView as T}from"./tileUtils.js";import{VertexArrayObject as w}from"../webgl-engine/lib/VertexArrayObject.js";import{BufferObject as A}from"../../webgl/BufferObject.js";import{VertexBuffer as P}from"../../webgl/VertexBuffer.js";class N{constructor(){this.geometry=new x,this.geometryState=null,this._texture=null,this._textureOpacity=1,this._textureRef=new j(()=>this._tile.surface.fadeDuration),this.overlay=new V,this._localOrigin=null,this._geometryStateChangedSinceLastUpdate=!0,this._hasGeometry=!1,this._modifiedFlags=0}get tile(){return this._tile}get localOrigin(){return this._localOrigin}init(e,t){this.clear(),this._tile=e,this.geometry.reset(),this.intersectionData=null,this.geometryState=new y,this._localOrigin=t,this.overlay.clear()}clear(){this.releaseGeometry(),this.releaseTexture(),this._textureRef.clear(),this._tile=null,this.intersectionData=null,this.geometryState=null}updateGeometryIfNeeded(e){if((!this._vao||this._geometryStateChangedSinceLastUpdate||this.wireframeChanged||this.clippingAreaChanged||this.samplerDataChanged||this.numVerticesPerSideChanged||this.dirtyCorners||this.dirtyEdgeResolutions||this.dirtyEdges)&&(this._updateGeometry(e),this._geometryStateChangedSinceLastUpdate=!1),S&&this.tile.intersectsClippingArea)for(let t=0;t<4;++t)v(this.geometry.getEdgeCount(t)===this.geometryState.edgeResolutions[t]+1)}_calculateEdgeResolution(e,t){const r=this.tile,i=this.geometryState.numVerticesPerSide-1;if(!r.surface.isGlobal){const t=r.surface.groundExtent;if(null!=t&&(0===e&&r.extent[3]>t[3]||1===e&&r.extent[2]>t[2]||2===e&&r.extent[1]<t[1]||3===e&&r.extent[0]<t[0]))return i}const s=r.level,o=$[e];if(!t)return v(null==r.surface?.rootTiles||r.surface.updatingRootTiles||!r.shouldHaveNeighbor(o)),i;if(t.loaded){const r=t,o=r.renderData.geometryState,a=s-r.level;if(v(a>=0),0===a){const e=o.numVerticesPerSide-1;return Math.max(e,i)}const n=2**a,l=o.edgeResolutions[(e+2)%4]/n;return Math.max(1,l)}v(!t.leaf);let a=i;return t.forAllSubtreeOnSide(E(o),e=>e===r||(e.loaded?(a=Math.max(a,2**(e.level-s)),!0):(v(!e.leaf),!1))),a}updateNeighborData(){const e=this.tile;if(!e.intersectsClippingArea)return;const r=e.renderData.geometryState,i=t=>(t.loaded||t.level===e.level)&&t?.intersectsClippingArea,s=r.edgePeerNeighbors,o=r.edgePeerNeighborSamplerVersions;for(let a=0;a<4;++a){const n=e.findNeighborTile($[a],i),l=X(e,n),d=l?.renderData?.geometryState.samplerDataVersion??-1,g=s[a],h=l!==X(e,g),u=o[a]!==d;S&&n&&(v(e.level>=n.level),v(e.level-n.level<=_)),s[a]=n,(h||u)&&(o[a]=d,this._markEdgeDirty(a));const m=r.edgeResolutions[a],c=this._calculateEdgeResolution(a,n);v(t(c)),v(c>=1),r.edgeResolutions[a]=c,m!==c&&this._markEdgeResolutionDirty(a)}for(let t=0;t<4;++t){const o=e.findNeighborTile(C[t],i);r.cornerPeerNeighbors[t]=o;const a=X(e,s[t]),n=X(e,s[(t+1)%4]),l=X(e,o);L[t]=l,L[(t+1)%4]=n,L[(t+2)%4]=e,L[(t+3)%4]=a,v(L.some(t=>t?.loaded||t===e));const d=L.reduce((e,t)=>Math.min(e,t?.level??1/0),1/0);L.forEach((e,t)=>{e&&e?.level>d&&(L[t]=null)}),v(L.some(t=>t?.loaded||t===e));const g=r.cornerNeighborCornerTiles,h=r.cornerNeighborCornerTileSamplerVersions;for(let e=0;e<4;++e){const r=L[e],i=r?.renderData.geometryState.samplerDataVersion??-1,s=4*t+e,o=g[s]!==r,a=!o&&h[s]!==i;(o||a)&&(g[s]=r,h[s]=i,this._markCornerDirty(t))}S&&v(Q.some(r=>g[4*t+r]?.loaded||g[4*t+r]===e))}S&&v(this.geometryState.edgeResolutions.every(e=>e>0));for(let t=0;t<4;++t)L[t]=null}_updateGeometry(e){if(!this.tile.intersectsClippingArea)return;S&&v(!this.tile.intersectsClippingArea||this.geometryState.edgeResolutions.every(e=>e>0)),this.intersectionData=null;const{tile:t,_vao:r,geometry:i,geometryState:s}=this,o=!r||!{}||this.wireframeChanged||this.samplerDataChanged||this.clippingAreaChanged||this.numVerticesPerSideChanged,a=0!==this.dirtyEdgeResolutions,n=s.edgeResolutions.reduce((e,t)=>Math.max(e,t),0)+1,l=o||a&&n>(i?.maxEdgeVertexCount??0),d=!l&&a,g=!d&&(0!==this.dirtyEdges||a),h=!g&&0!==this.dirtyCorners;l?(this.releaseGeometry(),this._createGeometry(e)):d?t.updateEdgeElevationsAndResolutions():g||h?t.updateEdgeElevations():h?t.updateCornerElevations():console.warn("Update for no reason?"),this._modifiedFlags=0}get hasGeometry(){return this._hasGeometry}releaseGeometry(){return this._hasGeometry=!1,this.intersectionData=null,!!this._vao&&(this._vao=r(this._vao),this.geometry.release(),!0)}ensureTexture(e,t,r,i){const s=t?6408:6407;return null!=this._texture&&(0===r&&this._tile.surface.fadeDuration>0&&this._isTextureVisible(this._texture)||this._texture.descriptor.width!==e||this._texture.descriptor.pixelFormat!==s)&&this.releaseTexture(),null==this._texture&&(this._texture=i(),this.tile.setMemoryDirty()),this._texture}releaseTexture(){this._texture&&(this._texture=i(this._texture),this.tile.setMemoryDirty())}reuseTexture(e,t){return!(!e||!this._texture)&&(e.setTextureReference(new R(this._texture,0,t,this._textureOpacity,0,1)),!0)}get numVerticesPerSideChanged(){return 0!==(this._modifiedFlags&B)}get samplerDataChanged(){return 0!==(this._modifiedFlags&H)}get clippingAreaChanged(){return 0!==(this._modifiedFlags&W)}get wireframeChanged(){return 0!==(this._modifiedFlags&q)}get dirtyEdges(){return this._modifiedFlags>>z&15}get dirtyCorners(){return this._modifiedFlags>>J&15}get dirtyEdgeResolutions(){return this._modifiedFlags>>K&15}_markCornerDirty(e){const t=1<<e<<J;this._modifiedFlags|=t}_markEdgeDirty(e){const t=1<<e<<z;this._modifiedFlags|=t,this._markCornerDirty((e+0)%4),this._markCornerDirty((e+3)%4)}_markEdgeResolutionDirty(e){const t=1<<e<<K;this._modifiedFlags|=t,this._markEdgeDirty(e)}_markAllEdgesAndCornersDirty(){this._modifiedFlags|=15<<J|15<<z|15<<K}updateGeometryState(){const t=this._elevationInfo,r=this.tile,i=t.samplerData?r.getElevationVerticesPerSide(t.maxTileLevel):r.minimumVerticesPerSide,s=Math.max(i,5);let o=r.clippingArea;r.intersectsClippingArea&&!r.withinClippingArea||(o=null);const a=this.geometryState;let n=!1;a.numVerticesPerSide!==s&&(this._modifiedFlags|=1,a.numVerticesPerSide=s,a.samplerDataVersion++,n=!0),t.changed&&(this._modifiedFlags|=2,a.samplerData=t.samplerData,a.samplerDataVersion++,n=!0),e(a.clippingArea,o)||(this._modifiedFlags=4,a.clippingArea=o,n=!0);const l=r.surface.wireframe;return a.wireframe!==l&&(this._modifiedFlags=8,a.wireframe=l,n=!0),this._geometryStateChangedSinceLastUpdate||=n,n&&this._markAllEdgesAndCornersDirty(),this._hasGeometry=!0,this._geometryStateChangedSinceLastUpdate}_createGeometry(e){this.tile.createGeometry();const{vertexAttributes:t,indices:r}=this.geometry,i=e.gl;this._vao=new w(e,new P(e,p(t.layout),t.buffer),A.createIndex(e,i.STATIC_DRAW,r)),this._hasGeometry=!0}get vao(){return this._vao}setTextureReference(e,t=0){e?.texture===this._texture?this._textureOpacity=e.opacities[0]:this.releaseTexture(),this._textureRef.push(e,t)}get textureReference(){return this._textureRef.current}get nextTextureReference(){return this._textureRef.next}get textureFadeFactor(){return this._textureRef.fadeFactor}get textureIsFading(){return this._textureRef.isFading}_isTextureVisible(e){return this._textureRef.current?.texture===e||this._textureRef.next?.texture===e&&this._textureRef.fadeFactor<1}get _elevationInfo(){const e=this.geometryState.samplerData,t=this.tile.layerInfo[0],r=t.length,i=new Array(r);let s=0,o=0,a=!1;for(let d=0;d<r;d++){const r=t[d],n=r.upsampleInfo?.tile;if(n){const t=n.layerInfo[0][d].data,r=t&&t.samplerData;e&&e[s]===r||(a=!0),i[s++]=r,o=Math.max(o,n.lij[0])}else if(r.data){const t=this.tile.surface.layerViewByIndex(d,0);if(T(this.tile,t)){const t=r.data;e&&e[s]===t.samplerData||(a=!0),i[s++]=t.samplerData,o=this.tile.level}}}null!=e&&e.length!==s&&(a=!0);const n=s>0,l=n?i:null;return n&&(i.length=s),{changed:a,samplerData:l,maxTileLevel:o}}get estimatedGeometryMemoryUsage(){const e=this.intersectionData?.estimatedMemoryUsage??0;return(this.geometry.indices?.byteLength??0)+(this.geometry.vertexAttributes?.byteLength??0)+e}get texture(){return this._texture}get test(){}checkGeometryWaterproofness(){if(!S)return;const e=this.tile;if(!e.loaded||!e.intersectsClippingArea||0===e.level)return void v(e?.loaded);const r=e.surface.groundExtent;if(null!=r&&!e.intersectsExtent(r))return;const i=$.map((t,i)=>null!=r&&(i<2?-1:1)*(e.extent[3-i]-r[3-i])<0),p=e.level;v(0===this.dirtyCorners),v(0===this.dirtyEdges),v(0===this.dirtyEdgeResolutions),v(!this.numVerticesPerSideChanged),v(!this.samplerDataChanged),v(!this.clippingAreaChanged),v(!this.wireframeChanged);const y=C.map(t=>e.findNeighborCornerTileExact(t,t=>!t.intersectsClippingArea||t.loaded||t.level===e.level)??null).map(e=>e?.intersectsClippingArea?e:null),x=this.geometryState;for(let t=0;t<4;++t){const r=x.cornerPeerNeighbors[t],i=y[t];v(i===r,`Tile[${e.lij}].corner[${t}] out of date: cur=[${r?.lij}] exp=[${i?.lij}]`)}$.forEach((r,y)=>{if(i[y])return;const x=e.findNeighborTile(r,e=>(e.level===p||e?.loaded)&&e?.intersectsClippingArea);if(!x){const t=!e.surface.updatingRootTiles&&null!=e.surface.rootTiles&&e.surface.rootTiles.length>0&&e.shouldHaveNeighbor(r);return void v(!t)}v(x.loaded||x.level===e.level),v(x===this.geometryState.edgePeerNeighbors[y]);const _=p-x.level;if(!x.loaded)return v(!x.leaf),void v(0===_);const $=x.renderData;v(e.isEdgeNeighbor(x,r)),v(_>=0);const E=2**_;if(_<0)return void v(!1);const C=e.renderData,S=C.geometry,j=C.localOrigin,R=S.getEdgeCount(y),V=S.numVerticesPerSide-1,T=$.geometry;if(!T)return void v(!1);const w=$.localOrigin,A=this.geometryState.edgePeerNeighbors[y];if(A?.loaded){const e=A.renderData;v(C.geometryState.edgePeerNeighborSamplerVersions[y]===e.geometryState.samplerDataVersion),v(this.geometryState.edgePeerNeighborSamplerVersions[y]===e.geometryState.samplerDataVersion)}const P=(y+2)%4,N=T.getEdgeCount(P),L=R-1,X=N-1;v(L*E===X,`Tile[${e.lij}]:e${y},res=${L} edgeRes mismatch with Neighbor[${x.lij}]:e${P},res=${X} (expected:${L*E})`);const B=e.extent,H=0===r||4===r,W=N-1,q=W>>_,z=R-1;if(q<1)return void v(1===z);v(q===z),v(t(q));const J=T.numVerticesPerSide-1;v(_>0||q===Math.max(J,V));const K=e.getNeighborEdgeStartVertexIndex(y,x);v(0<=K&&K<E);const Q=K*q;v(0<=Q&&Q<=W-q);let Y=0,Z=Q;S.getEdgeVertexPosition(y,F,j,0),S.getEdgeVertexPosition(y,G,j,R-1);const ee=s(F,G),te=Math.max(I,1e-4*ee);for(let t=0;t<=q;++t){S.getEdgeVertexPosition(y,F,j,Y),T.getEdgeVertexPosition(P,G,w,Z);const i=t/q,s=H?B[0]+i*(B[2]-B[0]):6===r?B[0]:B[2],p=H?4===r?B[1]:B[3]:B[1]+i*(B[3]-B[1]),_=e.surface.groundExtent;if(null==_||c(_,s,p)){const t=o(F,G),r=a(F)-f.radius,i=a(G)-f.radius,c=t<te;if(!c){console.warn(`Tile edge vertex position mismatch: between [${e.lij}].edge${y}[${Y}/${R}] and [${x.lij}].edge${P}[${Z}/${N}]`),null!=_&&console.warn(" surface extent= ",_," x,y=",s,",",p);const o=u();n(o,C.localOrigin,$.localOrigin),a(o)>0&&console.warn(` localOrigins: ${C.localOrigin} vs ${$.localOrigin} d=${a(o)} [${o}]`);(()=>{const t=m(F),r=m(G);e.updateEdgeElevations(),x.updateEdgeElevations(),S.getEdgeVertexPosition(y,F,j,Y),T.getEdgeVertexPosition(P,G,w,Z);const i=u();g(i,F,t),a(i)>0&&console.warn(` XXX Tile[${e.lij}] edge out of date: ${t} vs ${F} d=${a(i)} [${i}]`),g(i,G,r),a(i)>0&&console.warn(` XXX Neighbor[${x.lij}] edge out of date: ${r} vs ${G} d=${a(i)} [${i}]`)})();const l=S.getEdgeCount(y),d=T.getEdgeCount(N);v(c,`Mismatch in tile [${e.lij}].edge[${y}][${Y}/${l}] vs neighbor [${x.lij}].edge[${P}][${Z}/${d}] ${D(F)} vs ${D(G)} dist=${t} h(t|n|d)=${r}|${i}|${i-r}`)}S.getEdgeNormal(y,M,Y),T.getEdgeNormal(P,O,Z),l(U,M),l(k,O);const E=d(U,k),V=1-E<.01||!1||e===x;if(!V){const t=u();g(t,M,O);const r=()=>`Mismatch in tile edge normal ${b(e.lij)} (${Y}/${R-1}) edge ${y} vs neighbor ${b(x.lij)} (${Z}/${N-1}) nedge ${P} :${D(M)} vs ${D(O)} dot = ${E} : ${D(t)}`;console.warn("Mismatch in tile edge normal: ",r());{e.updateEdgeElevations(),x.updateEdgeElevations();const t=u(),r=u();S.getEdgeNormal(y,t,Y),T.getEdgeNormal(P,r,Z),h(M,t)||console.warn("Missing update in tile normal: ",D(M)," => ",D(t)),h(O,r)||console.warn("Missing update in neighbor normal: ",D(O)," => ",D(r))}v(V,r())}}Y+=1,Z+=1}})}}const F=u(),G=u(),M=u(),O=u(),U=u(),k=u(),I=1,L=[null,null,null,null];function X(e,t){return t?.loaded||t===e?t:null}const B=1,H=2,W=4,q=8,z=4,J=8,K=12,Q=[0,1,2,3];export{N as PatchRenderData,X as neighborTileIfLoadedOrSelf,Q as zeroToFour};
2
+ import{equals as e}from"../../../core/arrayUtils.js";import"../../../core/has.js";import{isPowerOfTwo as t}from"../../../core/mathUtils.js";import{disposeMaybe as r,releaseMaybe as i}from"../../../core/maybe.js";import{glLayout as s}from"../support/buffer/glUtil.js";import{GeometryState as a}from"./GeometryState.js";import{PatchGeometry as o}from"./PatchGeometry.js";import{checkPatchGeometryWaterproofness as n}from"./PatchRenderDataWaterproofness.js";import{maxTileNeighborLevelDelta as l}from"./TerrainConst.js";import{internalAssert as h,neighborEdgeIndices as d,oppositeEdge as u,neighborCornerIndices as m,enableTerrainInternalChecks as g}from"./terrainUtils.js";import{TextureFader as c}from"./TextureFader.js";import{TextureReference as f}from"./TextureReference.js";import y from"./TileOverlayData.js";import{fallsWithinLayerView as _}from"./tileUtils.js";import{VertexArrayObject as p}from"../webgl-engine/lib/VertexArrayObject.js";import{BufferObject as x}from"../../webgl/BufferObject.js";import{VertexBuffer as D}from"../../webgl/VertexBuffer.js";class S{constructor(){this.geometry=new o,this.geometryState=null,this._texture=null,this._textureOpacity=1,this._textureFader=new c(()=>this._tile.surface.fadeDuration),this.overlay=new y,this._localOrigin=null,this._geometryStateChangedSinceLastUpdate=!0,this._hasGeometry=!1,this._modifiedFlags=0}get tile(){return this._tile}get localOrigin(){return this._localOrigin}init(e,t){this.clear(),this._tile=e,this.geometry.reset(),this.intersectionData=null,this.geometryState=new a,this._localOrigin=t,this.overlay.clear()}clear(){this.releaseGeometry(),this.releaseTexture(),this._textureFader.clear(),this._tile=null,this.intersectionData=null,this.geometryState=null}updateGeometryIfNeeded(e){if((!this._vao||this._geometryStateChangedSinceLastUpdate||this.wireframeChanged||this.clippingAreaChanged||this.samplerDataChanged||this.numVerticesPerSideChanged||this.dirtyCorners||this.dirtyEdgeResolutions||this.dirtyEdges)&&(this._updateGeometry(e),this._geometryStateChangedSinceLastUpdate=!1),g&&this.tile.intersectsClippingArea)for(let t=0;t<4;++t)h(this.geometry.getEdgeCount(t)===this.geometryState.edgeResolutions[t]+1)}_calculateEdgeResolution(e,t){const r=this.tile,i=this.geometryState.numVerticesPerSide-1;if(!r.surface.isGlobal){const t=r.surface.groundExtent;if(null!=t&&(0===e&&r.extent[3]>t[3]||1===e&&r.extent[2]>t[2]||2===e&&r.extent[1]<t[1]||3===e&&r.extent[0]<t[0]))return i}const s=r.level,a=d[e];if(!t)return h(null==r.surface?.rootTiles||r.surface.updatingRootTiles||!r.shouldHaveNeighbor(a)),i;if(t.loaded){const r=t,a=r.renderData.geometryState,o=s-r.level;if(h(o>=0),0===o){const e=a.numVerticesPerSide-1;return Math.max(e,i)}const n=2**o,l=a.edgeResolutions[(e+2)%4]/n;return Math.max(1,l)}h(!t.leaf);let o=i;return t.forAllSubtreeOnSide(u(a),e=>e===r||(e.loaded?(o=Math.max(o,2**(e.level-s)),!0):(h(!e.leaf),!1))),o}updateNeighborData(){const e=this.tile;if(!e.intersectsClippingArea)return;const r=e.renderData.geometryState,i=t=>(t.loaded||t.level===e.level)&&t.intersectsClippingArea,s=r.edgePeerNeighbors,a=r.edgePeerNeighborSamplerVersions;for(let o=0;o<4;++o){const n=e.findNeighborTile(d[o],i),u=v(e,n),m=u?.renderData?.geometryState.samplerDataVersion??-1,c=s[o],f=u!==v(e,c),y=a[o]!==m;g&&n&&(h(e.level>=n.level),h(e.level-n.level<=l)),s[o]=n,(f||y)&&(a[o]=m,this._markEdgeDirty(o));const _=r.edgeResolutions[o],p=this._calculateEdgeResolution(o,n);h(t(p)),h(p>=1),r.edgeResolutions[o]=p,_!==p&&this._markEdgeResolutionDirty(o)}for(let t=0;t<4;++t){const a=e.findNeighborTile(m[t],i);r.cornerPeerNeighbors[t]=a;const o=v(e,s[t]),n=v(e,s[(t+1)%4]),l=v(e,a);C[t]=l,C[(t+1)%4]=n,C[(t+2)%4]=e,C[(t+3)%4]=o,h(C.some(t=>t?.loaded||t===e));const d=C.reduce((e,t)=>Math.min(e,t?.level??1/0),1/0);C.forEach((e,t)=>{e&&e?.level>d&&(C[t]=null)}),h(C.some(t=>t?.loaded||t===e));const u=r.cornerNeighborCornerTiles,c=r.cornerNeighborCornerTileSamplerVersions;for(let e=0;e<4;++e){const r=C[e],i=r?.renderData.geometryState.samplerDataVersion??-1,s=4*t+e,a=u[s]!==r,o=!a&&c[s]!==i;(a||o)&&(u[s]=r,c[s]=i,this._markCornerDirty(t))}g&&h(G.some(r=>u[4*t+r]?.loaded||u[4*t+r]===e))}g&&h(this.geometryState.edgeResolutions.every(e=>e>0));for(let t=0;t<4;++t)C[t]=null}_updateGeometry(e){if(!this.tile.intersectsClippingArea)return;g&&h(!this.tile.intersectsClippingArea||this.geometryState.edgeResolutions.every(e=>e>0)),this.intersectionData=null;const{tile:t,_vao:r,geometry:i,geometryState:s}=this,{vertexAttributes:a}=i,o=!r||!a||this.wireframeChanged||this.samplerDataChanged||this.clippingAreaChanged||this.numVerticesPerSideChanged,n=0!==this.dirtyEdgeResolutions,l=s.edgeResolutions.reduce((e,t)=>Math.max(e,t),0)+1,d=o||n&&l>(i?.maxEdgeVertexCount??0),u=!d&&n,m=!u&&(0!==this.dirtyEdges||n),c=!m&&0!==this.dirtyCorners;d?(this.releaseGeometry(),this._createGeometry(e)):u?t.updateEdgeElevationsAndResolutions():m||c?t.updateEdgeElevations():console.warn("Update for no reason?"),this._modifiedFlags=0}get hasGeometry(){return this._hasGeometry}releaseGeometry(){return this._hasGeometry=!1,this.intersectionData=null,!!this._vao&&(this._vao=r(this._vao),this.geometry.release(),!0)}ensureTexture(e,t,r,i){const s=t?6408:6407;return null!=this._texture&&(0===r&&this._tile.surface.fadeDuration>0&&this._isTextureVisible(this._texture)||this._texture.descriptor.width!==e||this._texture.descriptor.pixelFormat!==s)&&this.releaseTexture(),null==this._texture&&(this._texture=i(),this.tile.setMemoryDirty()),this._texture}releaseTexture(){this._texture&&(this._texture=i(this._texture),this.tile.setMemoryDirty())}reuseTexture(e,t){return!(!e||!this._texture)&&(e.setTextureReference(new f(this._texture,0,t,this._textureOpacity,0,1)),!0)}get numVerticesPerSideChanged(){return 0!==(this._modifiedFlags&F)}get samplerDataChanged(){return 0!==(this._modifiedFlags&b)}get clippingAreaChanged(){return 0!==(this._modifiedFlags&A)}get wireframeChanged(){return 0!==(this._modifiedFlags&T)}get dirtyEdges(){return this._modifiedFlags>>E&15}get dirtyCorners(){return this._modifiedFlags>>R&15}get dirtyEdgeResolutions(){return this._modifiedFlags>>w&15}_markCornerDirty(e){const t=1<<e<<R;this._modifiedFlags|=t}_markEdgeDirty(e){const t=1<<e<<E;this._modifiedFlags|=t,this._markCornerDirty((e+0)%4),this._markCornerDirty((e+3)%4)}_markEdgeResolutionDirty(e){const t=1<<e<<w;this._modifiedFlags|=t,this._markEdgeDirty(e)}_markAllEdgesAndCornersDirty(){this._modifiedFlags|=15<<R|15<<E|15<<w}updateGeometryState(){const t=this._elevationInfo,r=this.tile,i=t.samplerData?r.getElevationVerticesPerSide(t.maxTileLevel):r.minimumVerticesPerSide,s=Math.max(i,5);let a=r.clippingArea;r.intersectsClippingArea&&!r.withinClippingArea||(a=null);const o=this.geometryState;let n=!1;o.numVerticesPerSide!==s&&(this._modifiedFlags|=F,o.numVerticesPerSide=s,o.samplerDataVersion++,n=!0),t.changed&&(this._modifiedFlags|=b,o.samplerData=t.samplerData,o.samplerDataVersion++,n=!0),e(o.clippingArea,a)||(this._modifiedFlags|=A,o.clippingArea=a,n=!0);const l=r.surface.wireframe;return o.wireframe!==l&&(this._modifiedFlags|=T,o.wireframe=l,n=!0),this._geometryStateChangedSinceLastUpdate||=n,n&&this._markAllEdgesAndCornersDirty(),this._hasGeometry=!0,this._geometryStateChangedSinceLastUpdate}_createGeometry(e){this.tile.createGeometry();const{vertexAttributes:t,indices:r}=this.geometry,i=e.gl;this._vao=new p(e,new D(e,s(t.layout),t.buffer),x.createIndex(e,i.STATIC_DRAW,r)),this._hasGeometry=!0}get vao(){return this._vao}setTextureReference(e,t=0){e?.texture===this._texture?this._textureOpacity=e.opacities[0]:this.releaseTexture(),this._textureFader.push(e,t)}get textureReference(){return this._textureFader.current}get nextTextureReference(){return this._textureFader.next}get textureFadeFactor(){return this._textureFader.fadeFactor}get textureIsFading(){return this._textureFader.isFading}_isTextureVisible(e){return this._textureFader.current?.texture===e||this._textureFader.next?.texture===e&&this._textureFader.fadeFactor<1}get _elevationInfo(){const e=this.geometryState.samplerData,t=this.tile.layerInfo[0],r=t.length,i=new Array(r);let s=0,a=0,o=!1;for(let h=0;h<r;h++){const r=t[h],n=r.upsampleInfo?.tile;if(n){const t=n.layerInfo[0][h].data,r=t&&t.samplerData;e&&e[s]===r||(o=!0),i[s++]=r,a=Math.max(a,n.lij[0])}else if(r.data){const t=this.tile.surface.layerViewByIndex(h,0);if(_(this.tile,t)){const t=r.data;e&&e[s]===t.samplerData||(o=!0),i[s++]=t.samplerData,a=this.tile.level}}}null!=e&&e.length!==s&&(o=!0);const n=s>0,l=n?i:null;return n&&(i.length=s),{changed:o,samplerData:l,maxTileLevel:a}}get estimatedGeometryMemoryUsage(){const e=this.intersectionData?.estimatedMemoryUsage??0;return(this.geometry.indices?.byteLength??0)+(this.geometry.vertexAttributes?.byteLength??0)+e}get texture(){return this._texture}get test(){}checkGeometryWaterproofness(){n(this)}}const C=[null,null,null,null];function v(e,t){return t?.loaded||t===e?t:null}const F=1,b=2,A=4,T=8,E=4,R=8,w=12,G=[0,1,2,3];export{S as PatchRenderData,v as neighborTileIfLoadedOrSelf,G as zeroToFour};
@@ -0,0 +1,2 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
+ import{distance as e,dist as t,len as o,subtract as r,normalize as i,dot as n,sub as s,equals as l}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{create as a,clone as g}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{containsXY as d}from"../../../geometry/support/aaBoundingRect.js";import{earth as c}from"../../../geometry/support/Ellipsoid.js";import{enableTerrainInternalChecks as $,internalAssert as m,neighborEdgeIndices as u,neighborCornerIndices as p,v32s as f,lij2s as h}from"./terrainUtils.js";function E(E){if(!$)return;const S=E.tile;if(!S.loaded||!S.intersectsClippingArea||0===S.level)return void m(S?.loaded);const V=S.surface.groundExtent;if(null!=V&&!S.intersectsExtent(V))return;const w=u.map((e,t)=>null!=V&&(t<2?-1:1)*(S.extent[3-t]-V[3-t])<0),T=S.level;m(0===E.dirtyCorners),m(0===E.dirtyEdges),m(0===E.dirtyEdgeResolutions),m(!E.numVerticesPerSideChanged),m(!E.samplerDataChanged),m(!E.clippingAreaChanged),m(!E.wireframeChanged);const M=p.map(e=>S.findNeighborCornerTileExact(e,e=>!e.intersectsClippingArea||e.loaded||e.level===S.level)??null).map(e=>e?.intersectsClippingArea?e:null),O=E.geometryState;for(let e=0;e<4;++e){const t=O.cornerPeerNeighbors[e],o=M[e];m(o===t,`Tile[${S.lij}].corner[${e}] out of date: cur=[${t?.lij}] exp=[${o?.lij}]`)}u.forEach(($,u)=>{if(w[u])return;const p=S.findNeighborTile($,e=>(e.level===T||e.loaded)&&e.intersectsClippingArea);if(!p){const e=!S.surface.updatingRootTiles&&null!=S.surface.rootTiles&&S.surface.rootTiles.length>0&&S.shouldHaveNeighbor($);return void m(!e)}m(p.loaded||p.level===S.level),m(p===E.geometryState.edgePeerNeighbors[u]);const P=T-p.level;if(!p.loaded)return m(!p.leaf),void m(0===P);const V=p.renderData;m(S.isEdgeNeighbor(p,$)),m(P>=0);const M=2**P;if(P<0)return void m(!1);const O=S.renderData,D=O.geometry,X=O.localOrigin,A=D.getEdgeCount(u),R=D.numVerticesPerSide-1,B=V.geometry;if(!B)return void m(!1);const H=V.localOrigin,I=E.geometryState.edgePeerNeighbors[u];if(I?.loaded){const e=I.renderData;m(O.geometryState.edgePeerNeighborSamplerVersions[u]===e.geometryState.samplerDataVersion),m(E.geometryState.edgePeerNeighborSamplerVersions[u]===e.geometryState.samplerDataVersion)}const U=(u+2)%4,k=B.getEdgeCount(U),q=A-1,z=k-1;m(q*M===z,`Tile[${S.lij}]:e${u},res=${q} edgeRes mismatch with Neighbor[${p.lij}]:e${U},res=${z} (expected:${q*M})`);const F=S.extent,G=0===$||4===$,J=k-1,K=J>>P,L=A-1;if(K<1)return void m(1===L);m(K===L),m(!(K&K-1));const Q=B.numVerticesPerSide-1;m(P>0||K===Math.max(Q,R));const W=S.getNeighborEdgeStartVertexIndex(u,p);m(0<=W&&W<M);const Y=W*K;m(0<=Y&&Y<=J-K);let Z=0,_=Y;D.getEdgeVertexPosition(u,v,X,0),D.getEdgeVertexPosition(u,x,X,A-1);const ee=e(v,x),te=Math.max(C,1e-4*ee);for(let e=0;e<=K;++e){D.getEdgeVertexPosition(u,v,X,Z),B.getEdgeVertexPosition(U,x,H,_);const E=e/K,C=G?F[0]+E*(F[2]-F[0]):6===$?F[0]:F[2],P=G?4===$?F[1]:F[3]:F[1]+E*(F[3]-F[1]),w=S.surface.groundExtent;if(null==w||d(w,C,P)){const e=t(v,x),d=o(v)-c.radius,$=o(x)-c.radius,E=e<te;if(!E){console.warn(`Tile edge vertex position mismatch: between [${S.lij}].edge${u}[${Z}/${A}] and [${p.lij}].edge${U}[${_}/${k}]`),null!=w&&console.warn(" surface extent= ",w," x,y=",C,",",P);const t=a();r(t,O.localOrigin,V.localOrigin),o(t)>0&&console.warn(` localOrigins: ${O.localOrigin} vs ${V.localOrigin} d=${o(t)} [${t}]`);(()=>{const e=g(v),t=g(x);S.updateEdgeElevations(),p.updateEdgeElevations(),D.getEdgeVertexPosition(u,v,X,Z),B.getEdgeVertexPosition(U,x,H,_);const r=a();s(r,v,e),o(r)>0&&console.warn(` XXX Tile[${S.lij}] edge out of date: ${e} vs ${v} d=${o(r)} [${r}]`),s(r,x,t),o(r)>0&&console.warn(` XXX Neighbor[${p.lij}] edge out of date: ${t} vs ${x} d=${o(r)} [${r}]`)})();const i=D.getEdgeCount(u),n=B.getEdgeCount(U);m(E,`Mismatch in tile [${S.lij}].edge[${u}][${Z}/${i}] vs neighbor [${p.lij}].edge[${U}][${_}/${n}] ${f(v)} vs ${f(x)} dist=${e} h(t|n|d)=${d}|${$}|${$-d}`)}D.getEdgeNormal(u,b,Z),B.getEdgeNormal(U,j,_),i(y,b),i(N,j);const T=n(y,N),M=1-T<.01||!1||S===p;if(!M){const e=a();s(e,b,j);const t=()=>`Mismatch in tile edge normal ${h(S.lij)} (${Z}/${A-1}) edge ${u} vs neighbor ${h(p.lij)} (${_}/${k-1}) nedge ${U} :${f(b)} vs ${f(j)} dot = ${T} : ${f(e)}`;console.warn("Mismatch in tile edge normal: ",t());{S.updateEdgeElevations(),p.updateEdgeElevations();const e=a(),t=a();D.getEdgeNormal(u,e,Z),B.getEdgeNormal(U,t,_),l(b,e)||console.warn("Missing update in tile normal: ",f(b)," => ",f(e)),l(j,t)||console.warn("Missing update in neighbor normal: ",f(j)," => ",f(t))}m(M,t())}}Z+=1,_+=1}}),$&&m(P.every(e=>E.geometryState.edgeResolutions[e]>0))}const v=a(),x=a(),b=a(),j=a(),y=a(),N=a(),C=1,P=[0,1,2,3];export{E as checkPatchGeometryWaterproofness};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{fromValues as e,create as t}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import r from"../../../geometry/SpatialReference.js";import{projectVectorToVector as o}from"../../../geometry/projection/projectVectorToVector.js";import{wrap as i}from"../../../geometry/support/aaBoundingBox.js";import{create as n}from"../../../geometry/support/aaBoundingRect.js";import{isPlateCarree as s}from"../../../geometry/support/spatialReferenceUtils.js";import{createPlanarGlobePatch as a,updateCornersPlanar as l,updateEdgesAndCornersPlanar as u,updateEdgeElevationsAndResolutionsPlanar as h}from"./PatchGeometryFactory.js";import{Tile as d}from"./Tile.js";import{intersectAabbInvDirBefore as c}from"../webgl-engine/lib/RayIntersections.js";class m extends d{constructor(e,t,r,o,i){super(),this._horizontalScaleFactor=1,this._extentInRenderSR=n(),this._baseUsedMemory=900,this._subtreeGeometryElevationBoundMin=0,this._subtreeGeometryElevationBoundMax=0,this.init(e,t,r,o,i)}init(t,i,n,a,l){super.init(t,i,n,a,l);const u=l.view.renderSpatialReference,h=l.spatialReference,d=null!=u&&s(u)&&null!=h&&h.isGeographic?this.ellipsoid.radius*Math.PI/180:1;this._horizontalScaleFactor=d;const{isWebMercatorOnPlateCarree:c}=l,m=this._extentInRenderSR,_=this.extent;if(c){const t=e(_[0],_[1],0);o(t,r.WebMercator,t,r.PlateCarree);const i=e(_[2],_[3],0);o(i,r.WebMercator,i,r.PlateCarree),m[0]=t[0],m[1]=t[1],m[2]=i[0],m[3]=i[1]}else for(let e=0;e<4;++e)m[e]=_[e]*d;this.centerAtSeaLevel[0]=.5*(m[0]+m[2]),this.centerAtSeaLevel[1]=.5*(m[1]+m[3]),this.centerAtSeaLevel[2]=0,this._edgeLen=Math.max(m[2]-m[0],m[3]-m[1]),this._edgeLen2=this._edgeLen*this._edgeLen,this.updateRadiusAndCenter()}updateRadiusAndCenter(){this._updateCenter();const e=this._extentInRenderSR,t=.5*(e[2]-e[0]),r=.5*(e[3]-e[1]),o=Math.sqrt(t*t+r*r),i=.5*(this.elevationBoundsMax-this.elevationBoundsMin),n=Math.max(o,i);this._center[1].radius=n}_calculateFrustumVisibility(e){const t=this._aabb(),r=t[0],o=t[1],i=t[2],n=t[3],s=t[4],a=t[5];let l=!0;for(let u=0;u<6;u++){const t=e[u],h=t[0],d=t[1],c=t[2],m=t[3];if(h*(h>0?r:n)+d*(d>0?o:s)+c*(c>0?i:a)+m>=0)return 2;l=l&&h*(h<0?r:n)+d*(d<0?o:s)+c*(c<0?i:a)+m<=0}return l?0:1}_aabb(){const e=this._extentInRenderSR;return i(e[0],e[1],Math.min(this.elevationBoundsMin,this._subtreeGeometryElevationBoundMin),e[2],e[3],Math.max(this.elevationBoundsMax,this._subtreeGeometryElevationBoundMax))}intersectsRay(e,t,r,o){return _[0]=1/t[0],_[1]=1/t[1],_[2]=1/t[2],c(this._aabb(),e,_,r,o)}createGeometry(){a(this.renderData,this._horizontalScaleFactor),this._updateSubtreeGeometryElevationsBounds(),this.setMemoryDirty()}_updateSubtreeGeometryElevationsBounds(){const e=this._subtreeGeometryElevationBoundMin,t=this._subtreeGeometryElevationBoundMax,r=this.renderData;let o=e,i=t;if(r){const e=r.geometry.boundingBox;o=e[2],i=e[5]}else if(!this.leaf){o=1/0,i=-1/0;for(const e of this.children){const t=e;o=Math.min(o,t._subtreeGeometryElevationBoundMin),i=Math.max(i,t._subtreeGeometryElevationBoundMax)}}if(o!==this._subtreeGeometryElevationBoundMin||i!==this._subtreeGeometryElevationBoundMax){this._subtreeGeometryElevationBoundMin=o,this._subtreeGeometryElevationBoundMax=i;const e=this.parent;e?._updateSubtreeGeometryElevationsBounds()}}get minimumVerticesPerSide(){return this.level<9?3:2}updateCornerElevations(){l(this.renderData,this._horizontalScaleFactor),this._updateSubtreeGeometryElevationsBounds()}updateEdgeElevations(){u(this.renderData,this._horizontalScaleFactor),this._updateSubtreeGeometryElevationsBounds()}updateEdgeElevationsAndResolutions(){h(this.renderData,this._horizontalScaleFactor),this._updateSubtreeGeometryElevationsBounds()}get horizontalScale(){return this._horizontalScaleFactor}}const _=t();export{m as PlanarPatch};
2
+ import{fromValues as e,create as t}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import r from"../../../geometry/SpatialReference.js";import{projectVectorToVector as o}from"../../../geometry/projection/projectVectorToVector.js";import{wrap as i}from"../../../geometry/support/aaBoundingBox.js";import{create as n}from"../../../geometry/support/aaBoundingRect.js";import{isPlateCarree as s}from"../../../geometry/support/spatialReferenceUtils.js";import{createPlanarGlobePatch as a,updateEdgesAndCornersPlanar as u,updateEdgeElevationsAndResolutionsPlanar as l}from"./PatchGeometryFactory.js";import{Tile as h}from"./Tile.js";import{intersectAabbInvDirBefore as d}from"../webgl-engine/lib/RayIntersections.js";class m extends h{constructor(e,t,r,o,i){super(),this._horizontalScaleFactor=1,this._extentInRenderSR=n(),this._baseUsedMemory=900,this._subtreeGeometryElevationBoundMin=0,this._subtreeGeometryElevationBoundMax=0,this.init(e,t,r,o,i)}init(t,i,n,a,u){super.init(t,i,n,a,u);const l=u.view.renderSpatialReference,h=u.spatialReference,d=null!=l&&s(l)&&null!=h&&h.isGeographic?this.ellipsoid.radius*Math.PI/180:1;this._horizontalScaleFactor=d;const{isWebMercatorOnPlateCarree:m}=u,c=this._extentInRenderSR,p=this.extent;if(m){const t=e(p[0],p[1],0);o(t,r.WebMercator,t,r.PlateCarree);const i=e(p[2],p[3],0);o(i,r.WebMercator,i,r.PlateCarree),c[0]=t[0],c[1]=t[1],c[2]=i[0],c[3]=i[1]}else for(let e=0;e<4;++e)c[e]=p[e]*d;this.centerAtSeaLevel[0]=.5*(c[0]+c[2]),this.centerAtSeaLevel[1]=.5*(c[1]+c[3]),this.centerAtSeaLevel[2]=0,this._edgeLen=Math.max(c[2]-c[0],c[3]-c[1]),this._edgeLen2=this._edgeLen*this._edgeLen,this.updateRadiusAndCenter()}updateRadiusAndCenter(){this._updateCenter();const e=this._extentInRenderSR,t=.5*(e[2]-e[0]),r=.5*(e[3]-e[1]),o=Math.sqrt(t*t+r*r),i=.5*(this.elevationBoundsMax-this.elevationBoundsMin),n=Math.max(o,i);this._center[1].radius=n}_calculateFrustumVisibility(e){const t=this._aabb(),r=t[0],o=t[1],i=t[2],n=t[3],s=t[4],a=t[5];let u=!0;for(let l=0;l<6;l++){const t=e[l],h=t[0],d=t[1],m=t[2],c=t[3];if(h*(h>0?r:n)+d*(d>0?o:s)+m*(m>0?i:a)+c>=0)return 2;u=u&&h*(h<0?r:n)+d*(d<0?o:s)+m*(m<0?i:a)+c<=0}return u?0:1}_aabb(){const e=this._extentInRenderSR;return i(e[0],e[1],Math.min(this.elevationBoundsMin,this._subtreeGeometryElevationBoundMin),e[2],e[3],Math.max(this.elevationBoundsMax,this._subtreeGeometryElevationBoundMax))}intersectsRay(e,t,r,o){return c[0]=1/t[0],c[1]=1/t[1],c[2]=1/t[2],d(this._aabb(),e,c,r,o)}createGeometry(){a(this.renderData),this._updateSubtreeGeometryElevationsBounds(),this.setMemoryDirty()}_updateSubtreeGeometryElevationsBounds(){const e=this._subtreeGeometryElevationBoundMin,t=this._subtreeGeometryElevationBoundMax,r=this.renderData;let o=e,i=t;if(r){const e=r.geometry.boundingBox;o=e[2],i=e[5]}else if(!this.leaf){o=1/0,i=-1/0;for(const e of this.children){const t=e;o=Math.min(o,t._subtreeGeometryElevationBoundMin),i=Math.max(i,t._subtreeGeometryElevationBoundMax)}}if(o!==this._subtreeGeometryElevationBoundMin||i!==this._subtreeGeometryElevationBoundMax){this._subtreeGeometryElevationBoundMin=o,this._subtreeGeometryElevationBoundMax=i;const e=this.parent;e?._updateSubtreeGeometryElevationsBounds()}}get minimumVerticesPerSide(){return this.level<9?3:2}updateEdgeElevations(){u(this.renderData),this._updateSubtreeGeometryElevationsBounds()}updateEdgeElevationsAndResolutions(){l(this.renderData),this._updateSubtreeGeometryElevationsBounds()}get horizontalScale(){return this._horizontalScaleFactor}}const c=t();export{m as PlanarPatch};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{lerp as t}from"../../../core/mathUtils.js";import{normalize as e,set as i,add as s,scale as n,len as o,cross as r,dot as l,dist as a,sub as h}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{ZEROS as u,create as c}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{lonLatToSphericalPCPF as d}from"../../../geometry/projection/lonLatToSphericalPCPF.js";import{newDoubleArray as p}from"../../../geometry/support/DoubleArray.js";import{intersectsSphere as f,numPlanes as m}from"../../../geometry/support/frustum.js";import{Sphere as g}from"../../../geometry/support/sphere.js";import{createSphericalGlobePatch as x,updateCornerSpherical as $,updateEdgesAndCornersSpherical as v,updateEdgeElevationsAndResolutionsSpherical as M}from"./PatchGeometryFactory.js";import{enableTerrainInternalChecks as _,internalAssert as b,almostEquals as j}from"./terrainUtils.js";import{Tile as y}from"./Tile.js";import{compareTilesByLij as B}from"./tileUtils.js";class S extends y{constructor(t,e,i,s,n){super(),this._convexHull=new Array(24),this._boundingSphere=new g,this._baseUsedMemory=1816,this.init(t,e,i,s,n)}init(i,s,n,o,r){super.init(i,s,n,o,r);const l=this.ellipsoid.radius,a=this.extentInRadians[0],h=this.extentInRadians[1],u=this.extentInRadians[2],c=this.extentInRadians[3],p=t(h,c,.5),f=t(a,u,.5),m=0===i?0:Math.min(Math.abs(h),Math.abs(c));this._edgeLen=(u-a)*Math.cos(m)*l,this._edgeLen2=this._edgeLen*this._edgeLen,this._curvatureHeight=l-Math.sqrt(l*l-this._edgeLen2/4),d(this.centerAtSeaLevel,f,p,this.ellipsoid.radius),e(this.up,this.centerAtSeaLevel),this.updateRadiusAndCenter()}updateRadiusAndCenter(){this._updateBoundingVolumes();const t=this._center;if(0===this.lij[0])t[1].center=u,i(t[0],0,0,0),i(t[2],0,0,0),t[1].radius=this.ellipsoid.radius+this.elevationBoundsMax;else{this._updateCenter();const e=t[1],i=this.convexHull;let s=0;const n=e.center;for(let t=0;t<8;++t)s=Math.max(s,R(n,i,3*t));t[1].radius=Math.sqrt(s)}}_calculateFrustumVisibility(t){if(!f(t,this._boundingSphere))return 2;if(this.lij[0]<10)return 1;const e=this.convexHull,i=this.surface.view.state.camera.near;let s=!0;for(let n=0;n<m;n++){const o=4===n,r=t[n],l=r[0],a=r[1],h=r[2],u=r[3]-(o?i:0);let c=!1;for(let t=0;t<8;++t){const i=3*t;if(l*e[i]+a*e[i+1]+h*e[i+2]+u<0){if(c=!0,!s)break}else s=!1}if(!c)return 2}return s?0:1}computeElevationBounds(){super.computeElevationBounds(),this._updateBoundingVolumes()}createGeometry(){x(this.renderData,this._getPatchType()),this._updateBoundingVolumes(),this.setMemoryDirty()}_updateBoundingVolumes(){this._updateConvexHull(),this._updateBoundingSphere(),_&&this._checkBVs()}_updateBoundingSphere(){const t=this._boundingSphere,e=this.elevationBoundsMin,i=this.elevationBoundsMax,r=this.ellipsoid.radius,l=i;if(0===this.level)t.center=u,t.radius=r+l;else{const l=this.extentInRadians,a=.5*(l[0]+l[2]),h=l[1],u=l[3];H(I,a,h,r),H(L,a,u,r),s(t.center,I,L);const c=r+.5*(e+i);n(t.center,t.center,c/o(t.center));const d=this.convexHull;let p=0;const f=(t,e)=>{const i=t[0]-d[3*e],s=t[1]-d[3*e+1],n=t[2]-d[3*e+2];return Math.sqrt(i*i+s*s+n*n)};for(let e=0;e<8;++e){const i=f(t.center,e);p=Math.max(p,i)}const m=p;t.radius=m+2}}_updateConvexHull(){const t=this.extentInRadians,i=this.ellipsoid.radius;if(0===this.level)return;const a=this.elevationBoundsMin,u=this.elevationBoundsMax,d=this._getPatchType(),p=this.surface.isWebMercator,f=p&&1===d,m=p&&2===d,g=m||f,x=Math.PI/2,$=t[0],v=t[2],M=m?-x:t[1],_=f?x:t[3],y=.5*($+v),B=a,S=i+(g?Math.min(0,B-1):B),V=(t,e,i)=>H(t,e,i,S),R=c(),T=c(),I=c(),L=c();V(R,$,M),V(T,$,_),V(I,v,_),V(L,v,M);const P=(t,e)=>{for(let i=0;i<3;++i)this._convexHull[3*e+i]=t[i]};P(R,0),P(T,1),P(I,2),P(L,3);const F=u,A=i+(g?Math.max(0,F+1):F),D=c(),E=c(),k=c();H(E,y,_,S),H(k,y,M,S),s(D,E,k),e(D,D);const w=c(),U=c(),q=(t,i)=>{h(U,t,i),e(U,U);const o=-l(t,w)/l(U,w);b(o>=0),n(U,U,o),s(t,t,U)};if(2**this.lij[0]>2*this.lij[1]){const t=k,i=c();r(i,C,t),e(i,i),r(w,t,i),e(w,w),b(j(l(w,t)/o(t),0)),q(R,T),q(L,I),P(R,0),P(L,3)}else if(2**this.lij[0]!==2*this.lij[1]){const t=E,i=c();r(i,C,t),e(i,i),r(w,i,t),e(w,w),q(T,R),q(I,L),P(T,1),P(I,2)}const N=(t,e)=>{const i=A/l(e,D);for(let s=0;s<3;++s)this._convexHull[3*t+s]=e[s]*i};N(4,R),N(5,T),N(6,I),N(7,L)}_getPatchType(){const t=this.lij[1],e=0===t,i=t===(1<<this.level)-1;return e?i?3:1:i?2:0}intersectsRay(t,e,i,s){const n=this._boundingSphere,o=n.radius+i,r=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],l=n.center[0]-t[0],a=n.center[1]-t[1],h=n.center[2]-t[2],u=(l*e[0]+a*e[1]+h*e[2])/r,c=e[0]*u-l,d=e[1]*u-a,p=e[2]*u-h;return c*c+d*d+p*p<o*o}get minimumVerticesPerSide(){return this.level<V.length?V[this.level]+1:2}updateCornerElevations(){$(this.renderData),this._updateBoundingVolumes()}updateEdgeElevations(){v(this.renderData),this._updateBoundingVolumes()}updateEdgeElevationsAndResolutions(){M(this.renderData),this._updateBoundingVolumes()}_checkBVs(){if(!_)return;if(this.level<=2)return;const t=this._boundingSphere,i=t.radius,n=t.center,u=c(),d=this.ellipsoid.radius,f=this.elevationBoundsMin,m=this.elevationBoundsMax,g=d+f,x=1,$=0,v=this._center[1];v.center;const M=v.radius,y=this.convexHull,S=(t,e)=>{for(let i=0;i<3;++i)t[i]=y[3*e+i]};{const t=c(),i=c(),s=c(),n=c(),o=c(),a=(a,u,c,d)=>{S(i,a),S(s,u),S(n,c),h(i,i,s),h(n,n,s),r(t,i,n),e(t,t);const p=l(t,s);S(o,d);const f=l(t,o),m=Math.abs(f-p);b(j(m,0),`Non coplanar ${a},${u},${c},${d} diff = ${m}`)};a(0,1,2,3),a(4,5,6,7),a(0,1,4,5),a(1,2,5,6),a(2,3,6,7),a(3,0,7,4)}const V=p(24),R=(t,e,i)=>{const s=4*t;for(let n=0;n<3;++n)V[s+n]=e[n];V[s+3]=i},C=c(),I=c(),L=c(),P=c(),F=(t,i,s,n)=>{S(C,i),S(I,s),S(L,n),h(C,C,I),e(C,C),h(L,L,I),e(L,L),r(P,C,L),e(P,P);const o=l(P,I);R(t,P,o)};F(0,0,1,2),F(1,1,0,4),F(2,1,5,2),F(3,3,2,6),F(4,4,0,3),F(5,4,6,5);const A=(t,e,i,s)=>{const n=4*t;return V[n]*e+V[n+1]*i+V[n+2]*s-V[n+3]},D=(t,e,i,s)=>A(t,e,i,s)>=-1,E=(t,e)=>D(t,e[0],e[1],e[2]),k=2**this.lij[0]>2*this.lij[1],w=(t,e,s)=>Math.sqrt(T(t,e,s,n[0],n[1],n[2]))<i,U=t=>w(t[0],t[1],t[2]),q=(t,e)=>w(t[e],t[e+1],t[e+2]),N=this.extentInRadians,G=.5*(N[0]+N[2]),z=N[1],O=N[3],W=c(),J=c();H(W,G,O,g),H(J,G,z,g);const K=k?"Upper":"Lower";let Q=!0;for(let e=0;e<6;++e){for(let t=0;t<8;++t){const i=3*t,s=D(e,y[i],y[i+1],y[i+2]);Q&&=s,b(s,`Tile[${this.lij}] Convex hull point ${t} outside of plane ${e}`)}b(E(e,J),`Tile[${this.lij}] (${K}) bottom mid outside of plane ${e}`),b(E(e,W),`Tile[${this.lij}] (${K}) top mid outside of plane ${e}`)}b(Q,"Not all convex hull points are inside convex hull polyhedron"),b(U(J),`Tile[${this.lij}] (${K}) bottom mid outside of bounding sphere`),b(U(W),`Tile[${this.lij}] (${K}) top mid outside of bounding sphere`);for(let e=0;e<8;++e){const t=q(y,3*e);b(t,`Tile[${this.lij}] Convex hull point ${e} outside of bounding sphere`)}for(let e=0;e<6;++e)for(let t=0;t<8;++t){const i=3*t;D(e,y[i],y[i+1],y[i+2])||console.error(`Tile[${this.lij}] Convex hull point ${t} outside of plane ${e}`)}const{extentInRadians:X}=this,Y=Math.max(X[2]-X[0],X[3]-X[1]),Z=Math.round(Y*d),{renderData:tt}=this;if(!tt)return;const{geometry:et,geometryState:it,localOrigin:st}=tt,nt=et.vertexAttributes?.position;if(!nt)return;const ot=c(),rt=et.numVerticesPerSide-2,{indices:lt,indexCount:at,edgeVerticesStartIndex:ht,poleVerticesStartIndex:ut}=et;if(!lt)return;const ct=new Set;for(let e=0;e<at;++e){const t=lt[e];if(ct.has(t))continue;ct.add(t);const r=t<ut,l=t>=ht;let h=!1,c=-1;if(l){let e=ht;for(let i=0;i<4;++i){const s=it.edgeResolutions[i];if(t===e||t===e+s-1){h=!0;break}if(e+=s,t<e){c=i;break}}}const p=l?it.edgePeerNeighbors[c]:null,g=l&&p&&B(this,p)>0;nt.getVec(t,u),s(ot,u,st);const v=o(ot)-d;let _=0,b=!1;const j=f-v,y=v-m,S=j>x,V=y>x,R=S||V,T=()=>{const e=r?"internal":l&&!h?"edge":h?"corner":"pole";return`Tile[${this.lij}].vertex[${t}]:${e}`+(S?"(below)":V?"(above)":"")+(g?"(Neighbor)":"")},H=a(ot,n);if(H>=i+$){const t=H-i;R||(console.error(`${T()} is out of the bounding sphere by ${t.toFixed(0)} / ${i.toFixed(0)}[tol=${$}] h=${v.toFixed(0)} / [${f.toFixed(0)}..${m.toFixed(0)}] (${(t/i).toFixed(0)})`),b=!0)}for(let e=0;e<6;++e)if(!D(e,ot[0],ot[1],ot[2])){const s=A(e,ot[0],ot[1],ot[2]),n=t%rt,o=(t-n)/rt;0===e&&j||5===e&&y||(console.error(`${T()} (${n},${o})|${rt}] is out of the bounding trapezoid plane ${e} h=${Math.round(v)} / [${Math.round(f)}..${Math.round(m)}] dist=${Math.round(s)} radii = ${Math.round(i)}/${Math.round(M)}} : maxL = ${Z}`),++_)}if(b||_>0)break}}get convexHull(){return this._convexHull}}const V=[128,64,64,32,16,8,8,4];function R(t,e,i){return T(t[0],t[1],t[2],e[i],e[i+1],e[i+2])}function T(t,e,i,s,n,o){const r=s-t,l=n-e,a=o-i;return r*r+l*l+a*a}const H=(t,e,i,s)=>{const n=Math.cos(e),o=Math.sin(e),r=Math.cos(i),l=Math.sin(i);t[0]=s*r*n,t[1]=s*r*o,t[2]=s*l},C=[0,0,1],I=c(),L=c();export{S as SphericalPatch};
2
+ import{lerp as t}from"../../../core/mathUtils.js";import{normalize as e,set as i,add as s,scale as n,len as o,cross as r,dot as l,dist as a,sub as h}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{ZEROS as u,create as c}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{lonLatToSphericalPCPF as d}from"../../../geometry/projection/lonLatToSphericalPCPF.js";import{newDoubleArray as p}from"../../../geometry/support/DoubleArray.js";import{intersectsSphere as f,numPlanes as m}from"../../../geometry/support/frustum.js";import{Sphere as g}from"../../../geometry/support/sphere.js";import{createSphericalGlobePatch as x,updateEdgesAndCornersSpherical as $,updateEdgeElevationsAndResolutionsSpherical as v}from"./PatchGeometryFactory.js";import{enableTerrainInternalChecks as M,internalAssert as _,almostEquals as b}from"./terrainUtils.js";import{Tile as j}from"./Tile.js";import{compareTilesByLij as y}from"./tileUtils.js";class B extends j{constructor(t,e,i,s,n){super(),this._convexHull=new Array(24),this._boundingSphere=new g,this._baseUsedMemory=1816,this.init(t,e,i,s,n)}init(i,s,n,o,r){super.init(i,s,n,o,r);const l=this.ellipsoid.radius,a=this.extentInRadians[0],h=this.extentInRadians[1],u=this.extentInRadians[2],c=this.extentInRadians[3],p=t(h,c,.5),f=t(a,u,.5),m=0===i?0:Math.min(Math.abs(h),Math.abs(c));this._edgeLen=(u-a)*Math.cos(m)*l,this._edgeLen2=this._edgeLen*this._edgeLen,this._curvatureHeight=l-Math.sqrt(l*l-this._edgeLen2/4),d(this.centerAtSeaLevel,f,p,this.ellipsoid.radius),e(this.up,this.centerAtSeaLevel),this.updateRadiusAndCenter()}updateRadiusAndCenter(){this._updateBoundingVolumes();const t=this._center;if(0===this.lij[0])t[1].center=u,i(t[0],0,0,0),i(t[2],0,0,0),t[1].radius=this.ellipsoid.radius+this.elevationBoundsMax;else{this._updateCenter();const e=t[1],i=this.convexHull;let s=0;const n=e.center;for(let t=0;t<8;++t)s=Math.max(s,V(n,i,3*t));t[1].radius=Math.sqrt(s)}}_calculateFrustumVisibility(t){if(!f(t,this._boundingSphere))return 2;if(this.lij[0]<10)return 1;const e=this.convexHull,i=this.surface.view.state.camera.near;let s=!0;for(let n=0;n<m;n++){const o=4===n,r=t[n],l=r[0],a=r[1],h=r[2],u=r[3]-(o?i:0);let c=!1;for(let t=0;t<8;++t){const i=3*t;if(l*e[i]+a*e[i+1]+h*e[i+2]+u<0){if(c=!0,!s)break}else s=!1}if(!c)return 2}return s?0:1}computeElevationBounds(){super.computeElevationBounds(),this._updateBoundingVolumes()}createGeometry(){x(this.renderData,this._getPatchType()),this._updateBoundingVolumes(),this.setMemoryDirty()}_updateBoundingVolumes(){this._updateConvexHull(),this._updateBoundingSphere(),M&&this._checkBVs()}_updateBoundingSphere(){const t=this._boundingSphere,e=this.elevationBoundsMin,i=this.elevationBoundsMax,r=this.ellipsoid.radius,l=i;if(0===this.level)t.center=u,t.radius=r+l;else{const l=this.extentInRadians,a=.5*(l[0]+l[2]),h=l[1],u=l[3];T(I,a,h,r),T(C,a,u,r),s(t.center,I,C);const c=r+.5*(e+i);n(t.center,t.center,c/o(t.center));const d=this.convexHull;let p=0;const f=(t,e)=>{const i=t[0]-d[3*e],s=t[1]-d[3*e+1],n=t[2]-d[3*e+2];return Math.sqrt(i*i+s*s+n*n)};for(let e=0;e<8;++e){const i=f(t.center,e);p=Math.max(p,i)}const m=p;t.radius=m+2}}_updateConvexHull(){const t=this.extentInRadians,i=this.ellipsoid.radius;if(0===this.level)return;const a=this.elevationBoundsMin,u=this.elevationBoundsMax,d=this._getPatchType(),p=this.surface.isWebMercator,f=p&&1===d,m=p&&2===d,g=m||f,x=Math.PI/2,$=t[0],v=t[2],M=m?-x:t[1],j=f?x:t[3],y=.5*($+v),B=a,S=i+(g?Math.min(0,B-1):B),V=(t,e,i)=>T(t,e,i,S),R=c(),I=c(),C=c(),L=c();V(R,$,M),V(I,$,j),V(C,v,j),V(L,v,M);const P=(t,e)=>{for(let i=0;i<3;++i)this._convexHull[3*e+i]=t[i]};P(R,0),P(I,1),P(C,2),P(L,3);const F=u,A=i+(g?Math.max(0,F+1):F),k=c(),w=c(),D=c();T(w,y,j,S),T(D,y,M,S),s(k,w,D),e(k,k);const E=c(),U=c(),q=(t,i)=>{h(U,t,i),e(U,U);const o=-l(t,E)/l(U,E);_(o>=0),n(U,U,o),s(t,t,U)};if(2**this.lij[0]>2*this.lij[1]){const t=D,i=c();r(i,H,t),e(i,i),r(E,t,i),e(E,E),_(b(l(E,t)/o(t),0)),q(R,I),q(L,C),P(R,0),P(L,3)}else if(2**this.lij[0]!==2*this.lij[1]){const t=w,i=c();r(i,H,t),e(i,i),r(E,i,t),e(E,E),q(I,R),q(C,L),P(I,1),P(C,2)}const N=(t,e)=>{const i=A/l(e,k);for(let s=0;s<3;++s)this._convexHull[3*t+s]=e[s]*i};N(4,R),N(5,I),N(6,C),N(7,L)}_getPatchType(){const t=this.lij[1],e=0===t,i=t===(1<<this.level)-1;return e?i?3:1:i?2:0}intersectsRay(t,e,i,s){const n=this._boundingSphere,o=n.radius+i,r=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],l=n.center[0]-t[0],a=n.center[1]-t[1],h=n.center[2]-t[2],u=(l*e[0]+a*e[1]+h*e[2])/r,c=e[0]*u-l,d=e[1]*u-a,p=e[2]*u-h;return c*c+d*d+p*p<o*o}get minimumVerticesPerSide(){return this.level<S.length?S[this.level]+1:2}updateEdgeElevations(){$(this.renderData),this._updateBoundingVolumes()}updateEdgeElevationsAndResolutions(){v(this.renderData),this._updateBoundingVolumes()}_checkBVs(){if(!M)return;if(this.level<=2)return;const t=this._boundingSphere,i=t.radius,n=t.center,u=c(),d=this.ellipsoid.radius,f=this.elevationBoundsMin,m=this.elevationBoundsMax,g=d+f,x=1,$=0,v=this._center[1];v.center;const j=v.radius,B=this.convexHull,S=(t,e)=>{for(let i=0;i<3;++i)t[i]=B[3*e+i]};{const t=c(),i=c(),s=c(),n=c(),o=c(),a=(a,u,c,d)=>{S(i,a),S(s,u),S(n,c),h(i,i,s),h(n,n,s),r(t,i,n),e(t,t);const p=l(t,s);S(o,d);const f=l(t,o),m=Math.abs(f-p);_(b(m,0),`Non coplanar ${a},${u},${c},${d} diff = ${m}`)};a(0,1,2,3),a(4,5,6,7),a(0,1,4,5),a(1,2,5,6),a(2,3,6,7),a(3,0,7,4)}const V=p(24),H=(t,e,i)=>{const s=4*t;for(let n=0;n<3;++n)V[s+n]=e[n];V[s+3]=i},I=c(),C=c(),L=c(),P=c(),F=(t,i,s,n)=>{S(I,i),S(C,s),S(L,n),h(I,I,C),e(I,I),h(L,L,C),e(L,L),r(P,I,L),e(P,P);const o=l(P,C);H(t,P,o)};F(0,0,1,2),F(1,1,0,4),F(2,1,5,2),F(3,3,2,6),F(4,4,0,3),F(5,4,6,5);const A=(t,e,i,s)=>{const n=4*t;return V[n]*e+V[n+1]*i+V[n+2]*s-V[n+3]},k=(t,e,i,s)=>A(t,e,i,s)>=-1,w=(t,e)=>k(t,e[0],e[1],e[2]),D=2**this.lij[0]>2*this.lij[1],E=(t,e,s)=>Math.sqrt(R(t,e,s,n[0],n[1],n[2]))<i,U=t=>E(t[0],t[1],t[2]),q=(t,e)=>E(t[e],t[e+1],t[e+2]),N=this.extentInRadians,G=.5*(N[0]+N[2]),z=N[1],O=N[3],W=c(),J=c();T(W,G,O,g),T(J,G,z,g);const K=D?"Upper":"Lower";let Q=!0;for(let e=0;e<6;++e){for(let t=0;t<8;++t){const i=3*t,s=k(e,B[i],B[i+1],B[i+2]);Q&&=s,_(s,`Tile[${this.lij}] Convex hull point ${t} outside of plane ${e}`)}_(w(e,J),`Tile[${this.lij}] (${K}) bottom mid outside of plane ${e}`),_(w(e,W),`Tile[${this.lij}] (${K}) top mid outside of plane ${e}`)}_(Q,"Not all convex hull points are inside convex hull polyhedron"),_(U(J),`Tile[${this.lij}] (${K}) bottom mid outside of bounding sphere`),_(U(W),`Tile[${this.lij}] (${K}) top mid outside of bounding sphere`);for(let e=0;e<8;++e){const t=q(B,3*e);_(t,`Tile[${this.lij}] Convex hull point ${e} outside of bounding sphere`)}for(let e=0;e<6;++e)for(let t=0;t<8;++t){const i=3*t;k(e,B[i],B[i+1],B[i+2])||console.error(`Tile[${this.lij}] Convex hull point ${t} outside of plane ${e}`)}const{extentInRadians:X}=this,Y=Math.max(X[2]-X[0],X[3]-X[1]),Z=Math.round(Y*d),{renderData:tt}=this;if(!tt)return;const{geometry:et,geometryState:it,localOrigin:st}=tt,nt=et.vertexAttributes?.position;if(!nt)return;const ot=c(),rt=et.numVerticesPerSide-2,{indices:lt,indexCount:at,edgeVerticesStartIndex:ht,poleVerticesStartIndex:ut}=et;if(!lt)return;const ct=new Set;for(let e=0;e<at;++e){const t=lt[e];if(ct.has(t))continue;ct.add(t);const r=t<ut,l=t>=ht;let h=!1,c=-1;if(l){let e=ht;for(let i=0;i<4;++i){const s=it.edgeResolutions[i];if(t===e||t===e+s-1){h=!0;break}if(e+=s,t<e){c=i;break}}}const p=l?it.edgePeerNeighbors[c]:null,g=l&&p&&y(this,p)>0;nt.getVec(t,u),s(ot,u,st);const v=o(ot)-d;let M=0,_=!1;const b=f-v,B=v-m,S=b>x,V=B>x,R=S||V,T=()=>{const e=r?"internal":l&&!h?"edge":h?"corner":"pole";return`Tile[${this.lij}].vertex[${t}]:${e}`+(S?"(below)":V?"(above)":"")+(g?"(Neighbor)":"")},H=a(ot,n);if(H>=i+$){const t=H-i;R||(console.error(`${T()} is out of the bounding sphere by ${t.toFixed(0)} / ${i.toFixed(0)}[tol=${$}] h=${v.toFixed(0)} / [${f.toFixed(0)}..${m.toFixed(0)}] (${(t/i).toFixed(0)})`),_=!0)}for(let e=0;e<6;++e)if(!k(e,ot[0],ot[1],ot[2])){const s=A(e,ot[0],ot[1],ot[2]),n=t%rt,o=(t-n)/rt;0===e&&b||5===e&&B||(console.error(`${T()} (${n},${o})|${rt}] is out of the bounding trapezoid plane ${e} h=${Math.round(v)} / [${Math.round(f)}..${Math.round(m)}] dist=${Math.round(s)} radii = ${Math.round(i)}/${Math.round(j)}} : maxL = ${Z}`),++M)}if(_||M>0)break}}get convexHull(){return this._convexHull}}const S=[128,64,64,32,16,8,8,4];function V(t,e,i){return R(t[0],t[1],t[2],e[i],e[i+1],e[i+2])}function R(t,e,i,s,n,o){const r=s-t,l=n-e,a=o-i;return r*r+l*l+a*a}const T=(t,e,i,s)=>{const n=Math.cos(e),o=Math.sin(e),r=Math.cos(i),l=Math.sin(i);t[0]=s*r*n,t[1]=s*r*o,t[2]=s*l},H=[0,0,1],I=c(),C=c();export{B as SphericalPatch};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import"../../../core/has.js";import{disposeMaybe as e,releaseMaybe as t}from"../../../core/maybe.js";import{set as r,copy as s}from"../../../core/libs/gl-matrix-2/math/vec2.js";import{ZEROS as o}from"../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{fromValues as a}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{isBaseLayer as i,isGroupLayer as n,isReferenceLayer as c}from"../../../layers/support/layerUtils.js";import{isLayerViewWithFlowRenderer as u}from"../support/flowUtils.js";import{BlendLayersPassParameters as l}from"./BlendLayersTechnique.js";import{isBlendableLayerView as p,isVectorTileLayerView as h,isVectorTileRenderInfo as d,isImageryTileRenderInfo as m,isImageSourceRenderInfo as f,isTextureTileRenderInfo as _,isVectorTilePerLayerInfo as x}from"./terrainUtils.js";import{TextureReference as y}from"./TextureReference.js";import{TileCompositor as T}from"./TileCompositor.js";import{TileRenderInfo as b}from"./TileRenderInfo.js";import{getCacheKey as g,TileTexture as k}from"./TileTexture.js";import{fallsWithinLayerView as w}from"./tileUtils.js";import{blendModeFromString as I}from"../webgl-engine/core/shaderLibrary/output/BlendOptions.js";import{isCompressible as O}from"../../support/TextureCompressionWorkerHandle.js";import P from"../../webgl/Texture.js";import{TextureDescriptor as j}from"../../webgl/TextureDescriptor.js";class L{constructor(e,t,r,s,o,a){this.start=e,this.end=t,this.blendMode=r,this.opacity=s,this.output=o,this.baseOpacity=a}}class B{constructor(e,t,r,s,o){this._rctx=e,this.tileSize=t,this._techniques=r,this._cache=s,this._compressionTracker=o,this._passParameters=new l,this._backgroundColor=null,this._maxAnisotropy=this._rctx.parameters.maxMaxAnisotropy,this._compositor=new T(this._rctx,this._techniques)}dispose(){this._compositor=e(this._compositor),this._backgroundTexture=t(this._backgroundTexture)}get backgroundIsGrid(){return null==this._backgroundColor}get backgroundColor(){return this._backgroundColor}updateHeading(e){this._compositor?.updateHeading(e)}updateTileTexture(e,t){if(!e.renderData)return;const r=e.surface,s=r.baseOpacity;let o=0,a=0,l=this.tileSize,d=!1,m=!1;const f=r.view.state.contentPixelRatio;let _=!1;U.clear(),v.length=0;const x=e.layerInfo[1];let y=0,T=null;for(;y<x.length;y++){const t=r.layerViewByIndex(y,1),b=t.layer,g=!w(e,t),k=b.opacity,I=t.fullOpacity;if(m=m||i(b),u(t))continue;if(p(t)){let e="normal"!==t.layer.blendMode;if(n(b.parent)){const t=b.parent.uid;null!=t&&""!==t&&(e=D(b.parent)||e)}e&&(_=e,d=!1)}if((g||0===k)&&!_){x[y].pendingUpdates&=-1;continue}++a;const O=h(t),P=C(e,y,O);if(P){if(x[y].pendingUpdates&=-1,n(b.parent)){const e=b.parent.uid;null!=e&&""!==e&&R(b.parent,y)}O?l=Math.max(l,this.tileSize*f):1===s&&1===I&&(t.isOpaque||this._dataToTexture(P,c(b))&&P.sourceLayerInfo.data.descriptor.isOpaque)&&(d=!0),++o,null===T&&(T=y)}}const b=l/this.tileSize;0!==o&&null!==T?1===o&&!_&&this._useLayerTexture(e,T)||this._composeLayers(e,t,y-1,m,l,b,!d||_,U,_):this._useBackgroundTexture(e,a,0!==t)}setBackground(e){this._backgroundColor!==e&&(this._backgroundColor=e,this._backgroundTexture&&this._drawBackgroundTexture(this._backgroundTexture))}_ensureBackgroundTexture(){return null==this._backgroundTexture&&(this._backgroundTexture=this._buildTexture(this.tileSize,!1),this._drawBackgroundTexture(this._backgroundTexture)),this._backgroundTexture}_drawBackgroundTexture(e){this._compositor.bind(this.tileSize),this._passParameters.offset=o,this._passParameters.scale=1,this._passParameters.opacity=1,this.backgroundColor&&(this._passParameters.backgroundColor=this.backgroundColor),this._compositor.drawBackground(this._passParameters,null!=this.backgroundColor),this._compositor.copyFBOToTexture(e),this._compositor.unbind()}_useBackgroundTexture(e,t,r){const s=e.renderData,o=!r&&null!=s.textureReference&&(e.surface.view.layerViewManager.updating||t>0)?5e3:0,a=this._ensureBackgroundTexture();s.setTextureReference(new y(a,0,S,e.surface.baseOpacity,0,1),o)}_useLayerTexture(e,t){const r=e.surface.layerViewByIndex(t,1),s=i(r.layer),o=s?e.surface.baseOpacity:1,n=s?1:e.surface.baseOpacity,u=r.fullOpacity,l=C(e,t,!1);return!!this._dataToTexture(l,c(r.layer))&&(e.renderData.setTextureReference(new y(l.sourceLayerInfo.data,0,a(l.offset[0],l.offset[1],l.scale,l.scale),o,n,u)),!0)}_composeLayers(e,t,r,s,a,n,l,f,_){this._compositor.ensureBuffer(a);const x=e.surface.baseOpacity;let T=!1,b=9987,g=!1,k=0;for(let y=r;y>=0;y--){const t=e.surface.layerViewByIndex(y,1),r=t.layer,O=h(t),P=C(e,y,O),j=r.opacity,L=!w(e,t);if(!P||(0===j||L)&&!_)continue;if(u(t))continue;const B=!i(r)&&!T;T||=B;let D=!1;f.forEach(e=>{e.start===y&&(e.output=s?1:l&&B?this.backgroundIsGrid?3:2:1,e.baseOpacity=B?x:1,v.push(e),this._compositor.openGroup(a),D=!0)});const R=D?4:l&&0===k?this.backgroundIsGrid?3:2:1,U=I[p(t)?t.layer.blendMode:"normal"];for(this._passParameters.baseOpacity=B&&!D&&x<1?x:1,this._passParameters.opacity=j,d(P)?g=this._compositor.drawVectorData(this._passParameters,R,a,U,P,n,this.tileSize,g):m(P)?(this._compositor.drawRasterData(this._passParameters,R,a,U,P),M(P)&&(b=9728)):this._dataToTexture(P,c(r))&&(this._passParameters.texture=P.sourceLayerInfo.data.texture,this._passParameters.offset=P.offset,this._passParameters.scale=P.scale,this._compositor.drawImageData(this._passParameters,R,a,U));v.length>0&&v[v.length-1].end===y;){const e=v.pop();this._passParameters.baseOpacity=e.baseOpacity,this._passParameters.opacity=e.opacity,this._passParameters.offset=o,this._passParameters.scale=1,this._compositor.drawGroup(this._passParameters,e.output,a,I[e.blendMode])}k++}const O=e.renderData,P=_||T&&x<1,j=O.ensureTexture(a,P,t,()=>this._buildTexture(a,P,b));this._compositor.copyFBOToTexture(j),this._compositor.unbind(),O.setTextureReference(new y(j,t,S,T?1:x,0,1))}_dataToTexture(e,t){if(f(e)){const r=e.sourceLayerInfo,s=1===e.scale&&!t;r.data=this._buildTexture(r.data,!0,s,e.tile.onCompressionFinished),e.tile.setMemoryDirty()}return _(e)}_buildTexture(e,t,r=9987,s=()=>{}){if(null==e)return null;const o=new j;o.wrapMode=33071,o.samplingMode="boolean"==typeof r?9987:r,o.maxAnisotropy=this._maxAnisotropy,o.preMultiplyAlpha=!0,o.flipped=!0,o.hasMipmap=!0,t||(o.pixelFormat=6407);const a=this._rctx,i="boolean"==typeof r&&r;let n;if("number"==typeof e)o.width=o.height=e,n=this._buildTileTexture(o);else{o.isOpaque=e.isOpaque,o.isOpaque&&(o.pixelFormat=6407);const{bitmap:t}=e;o.width=t.width,o.height=t.height,n=this._buildTileTexture(o,i,s,t)}const c=a.bindTexture(n.texture,P.TEXTURE_UNIT_FOR_UPDATES);return n.generateMipmap(),a.bindTexture(c,P.TEXTURE_UNIT_FOR_UPDATES),n}_buildTileTexture(e,t=!1,r=()=>{},s){const o=this._cache.pop(g(e,!1))??this._cache.pop(g(e,!0));if(t&&=O(s,e),o)return o.retain(),t?o.texture.enableCompression({compressionTracker:this._compressionTracker,compressionCallback:r}):o.texture.disableCompression(),o.texture.setData(s),o;e.compress=t?{compressionTracker:this._compressionTracker,compressionCallback:r}:void 0;const a=new P(this._rctx,e,s);return new k(a,this._cache)}get test(){}}function C(e,t,o){A.layerIndex=t,A.vtlNeighborInfos.clear();const a=e.layerInfo[1][t];if(r(A.offset,0,0),A.tile=e,A.scale=1,A.sourceLod=e.lij,A.sourceLayerInfo=a,A.isVTLBackground=o,a.data)return o&&e.forEachLoadedNeighbor((r,s)=>{if(r.level!==e.level)return;const o=r.layerInfo[1][t];if(!x(o)||a.data===o.data)return;const i=A.vtlNeighborInfos.pushNew();i.offset=q[s],i.sourceLod=r.lij,i.sourceLayerInfo=o}),A;const i=a.upsampleInfo,n=i?.tile?.layerInfo[1][t];return n&&i.tile?(A.tile=i.tile,s(A.offset,i.offset),A.scale=i.scale,A.sourceLod=i.tile.lij,A.sourceLayerInfo=n,A):o?A:null}function M(e){const t=e.sourceLayerInfo.data;return!!t.source&&"nearest"===t.interpolation}function D(e){let t="normal"!==e.blendMode;return n(e.parent)&&(t=D(e.parent)||t),t}function R(e,t){n(e.parent)&&R(e.parent,t);const r=e.uid;if(null!=r&&""!==r){const s=U.get(r);s?s.start=t:U.set(r,new L(t,t,e.blendMode,e.opacity,1,1))}}const U=new Map,v=new Array,A=new b,S=a(0,0,1,1),q=new Array;function E(){A.sourceLayerInfo=null,A.tile=null,A.vtlNeighborInfos.prune()}q[0]=[0,-1],q[1]=[-1,-1],q[2]=[-1,0],q[3]=[-1,1],q[4]=[0,1],q[5]=[1,1],q[6]=[1,0],q[7]=[1,-1];export{L as GroupInfo,B as TileRenderer,E as cleanupTileRenderer};
2
+ import"../../../core/has.js";import{disposeMaybe as e,releaseMaybe as t}from"../../../core/maybe.js";import{set as r,copy as s}from"../../../core/libs/gl-matrix-2/math/vec2.js";import{ZEROS as o}from"../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{fromValues as a}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{isBaseLayer as i,isGroupLayer as n,isReferenceLayer as u}from"../../../layers/support/layerUtils.js";import{isLayerViewWithFlowRenderer as c}from"../support/flowUtils.js";import{BlendLayersPassParameters as p}from"./BlendLayersTechnique.js";import{isBlendableLayerView as l,isVectorTileLayerView as d,isVectorTileRenderInfo as h,isImageryTileRenderInfo as m,isImageSourceRenderInfo as _,isTextureTileRenderInfo as f,isVectorTilePerLayerInfo as x}from"./terrainUtils.js";import{TextureReference as T}from"./TextureReference.js";import{TileCompositor as y}from"./TileCompositor.js";import{TileRenderInfo as g}from"./TileRenderInfo.js";import{getCacheKey as b,TileTexture as k}from"./TileTexture.js";import{fallsWithinLayerView as L}from"./tileUtils.js";import{blendModeFromString as w}from"../webgl-engine/core/shaderLibrary/output/BlendOptions.js";import{isCompressible as I}from"../../support/TextureCompressionWorkerHandle.js";import B from"../../webgl/Texture.js";import{TextureDescriptor as C}from"../../webgl/TextureDescriptor.js";class P{constructor(e,t,r,s,o){this._rctx=e,this.tileSize=t,this._techniques=r,this._cache=s,this._compressionTracker=o,this._passParameters=new p,this._backgroundColor=null,this._maxAnisotropy=this._rctx.parameters.maxMaxAnisotropy,this._compositor=new y(this._rctx,this._techniques)}dispose(){this._compositor=e(this._compositor),this._backgroundTexture=t(this._backgroundTexture)}get backgroundIsGrid(){return null==this._backgroundColor}get backgroundColor(){return this._backgroundColor}updateHeading(e){this._compositor?.updateHeading(e)}updateTileTexture(e,t){if(!e.renderData)return;const r=this._prepareUpdateState(e),s=r.targetTextureSize/this.tileSize;0!==r.numTexturedLayers&&null!==r.firstTexturedLayerIndex?1===r.numTexturedLayers&&!r.foundBlendMode&&this._useLayerTexture(e,r.firstTexturedLayerIndex)||this._composeLayers(e,t,r.lastLayerIndex,r.hasBasemapLayers,r.targetTextureSize,s,!r.backgroundCovered||r.foundBlendMode,v,r.foundBlendMode):this._useBackgroundTexture(e,r.numVisibleLayers,0!==t)}_prepareUpdateState(e){const t=e.surface,r=t.baseOpacity,s=t.view.state.contentPixelRatio,o=e.layerInfo[1];let a=0,p=0,h=this.tileSize,m=!1,_=!1,f=!1,x=null;v.clear(),D.length=0;for(let T=0;T<o.length;T++){const y=t.layerViewByIndex(T,1),g=y.layer,b=!L(e,y),k=g.opacity,w=y.fullOpacity;if(_=_||i(g),c(y))continue;if(l(y)){let e="normal"!==y.layer.blendMode;if(n(g.parent)){const t=g.parent.uid;null!=t&&""!==t&&(e=j(g.parent)||e)}e&&(f=e,m=!1)}if(this._canSkipLayer(k,b,f)){this._clearTexturePendingUpdates(o[T]);continue}++p;const I=d(y),B=M(e,T,I);if(B){if(this._clearTexturePendingUpdates(o[T]),n(g.parent)){const e=g.parent.uid;null!=e&&""!==e&&S(g.parent,T)}if(I)h=Math.max(h,this.tileSize*s);else{const e=this._prepareTextureForBackgroundCoverageCheck(B,u(g));1===r&&1===w&&(y.isOpaque||!0===e?.descriptor.isOpaque)&&(m=!0)}++a,null===x&&(x=T)}}return{numTexturedLayers:a,numVisibleLayers:p,targetTextureSize:h,backgroundCovered:m,hasBasemapLayers:_,foundBlendMode:f,firstTexturedLayerIndex:x,lastLayerIndex:o.length-1}}_canSkipLayer(e,t,r){return this._isLayerNonContributing(e,t)&&!r}_isLayerNonContributing(e,t){return 0===e||t}_clearTexturePendingUpdates(e){e.pendingUpdates&=-1}_prepareTextureForBackgroundCoverageCheck(e,t){return this._dataToTexture(e,t)?e.sourceLayerInfo.data:null}setBackground(e){this._backgroundColor!==e&&(this._backgroundColor=e,this._backgroundTexture&&this._drawBackgroundTexture(this._backgroundTexture))}_ensureBackgroundTexture(){return null==this._backgroundTexture&&(this._backgroundTexture=this._buildTexture(this.tileSize,!1),this._drawBackgroundTexture(this._backgroundTexture)),this._backgroundTexture}_drawBackgroundTexture(e){this._compositor.bind(this.tileSize),this._passParameters.offset=o,this._passParameters.scale=1,this._passParameters.opacity=1,this.backgroundColor&&(this._passParameters.backgroundColor=this.backgroundColor),this._compositor.drawBackground(this._passParameters,null!=this.backgroundColor),this._compositor.copyFBOToTexture(e),this._compositor.unbind()}_useBackgroundTexture(e,t,r){const s=e.renderData,o=!r&&null!=s.textureReference&&(e.surface.view.layerViewManager.updating||t>0)?5e3:0,a=this._ensureBackgroundTexture();s.setTextureReference(new T(a,0,z,e.surface.baseOpacity,0,1),o)}_useLayerTexture(e,t){const r=e.surface.layerViewByIndex(t,1),s=i(r.layer),o=s?e.surface.baseOpacity:1,n=s?1:e.surface.baseOpacity,c=r.fullOpacity,p=M(e,t,!1);return!!this._dataToTexture(p,u(r.layer))&&(e.renderData.setTextureReference(new T(p.sourceLayerInfo.data,0,a(p.offset[0],p.offset[1],p.scale,p.scale),o,n,c)),!0)}_composeLayers(e,t,r,s,a,n,p,_,f){this._compositor.ensureBuffer(a);const x=e.surface.baseOpacity;let y=!1,g=9987,b=!1,k=0;for(let T=r;T>=0;T--){const t=e.surface.layerViewByIndex(T,1);if(c(t))continue;const r=t.layer,I=M(e,T,d(t)),B=r.opacity,C=!L(e,t);if(!I||this._canSkipLayer(B,C,f))continue;const P=!i(r)&&!y;y||=P;const j=this._openGroupsAtLayer(T,a,x,s,p,P,_),S=j?4:p&&0===k?this.backgroundIsGrid?3:2:1,U=w[l(t)?t.layer.blendMode:"normal"];for(this._passParameters.baseOpacity=P&&!j&&x<1?x:1,this._passParameters.opacity=B,h(I)?b=this._compositor.drawVectorData(this._passParameters,S,a,U,I,n,this.tileSize,b):m(I)?(this._compositor.drawRasterData(this._passParameters,S,a,U,I),O(I)&&(g=9728)):this._dataToTexture(I,u(r))&&(this._passParameters.texture=I.sourceLayerInfo.data.texture,this._passParameters.offset=I.offset,this._passParameters.scale=I.scale,this._compositor.drawImageData(this._passParameters,S,a,U));D.length>0&&D[D.length-1].end===T;){const e=D.pop();this._passParameters.baseOpacity=e.baseOpacity,this._passParameters.opacity=e.opacity,this._passParameters.offset=o,this._passParameters.scale=1,this._compositor.drawGroup(this._passParameters,e.output,a,w[e.blendMode])}k++}const I=e.renderData,B=f||y&&x<1,C=I.ensureTexture(a,B,t,()=>this._buildTexture(a,B,g));this._compositor.copyFBOToTexture(C),this._compositor.unbind(),I.setTextureReference(new T(C,t,z,y?1:x,0,1))}_openGroupsAtLayer(e,t,r,s,o,a,i){let n=!1;return i.forEach(i=>{i.start===e&&(i.output=s?1:o&&a?this.backgroundIsGrid?3:2:1,i.baseOpacity=a?r:1,D.push(i),this._compositor.openGroup(t),n=!0)}),n}_dataToTexture(e,t){if(_(e)){const r=e.sourceLayerInfo,s=1===e.scale&&!t;r.data=this._buildTexture(r.data,!0,s,e.tile.onCompressionFinished),e.tile.setMemoryDirty()}return f(e)}_buildTexture(e,t,r=9987,s=()=>{}){return null==e?null:"number"==typeof e?this._buildTextureFromSize(e,t,r):this._buildTextureFromImage(e,t,r,s)}_buildTextureFromSize(e,t,r){const s=this._createTextureDescriptor(t,"boolean"==typeof r?9987:r);s.width=s.height=e;const o=this._buildTileTexture(s);return this._generateTextureMipmap(o),o}_buildTextureFromImage(e,t,r,s){const o=this._createTextureDescriptor(t,"boolean"==typeof r?9987:r);o.isOpaque=e.isOpaque,o.isOpaque&&(o.pixelFormat=6407);const{bitmap:a}=e;o.width=a.width,o.height=a.height;const i="boolean"==typeof r&&r,n=this._buildTileTexture(o,i,s,a);return this._generateTextureMipmap(n),n}_createTextureDescriptor(e,t){const r=new C;return r.wrapMode=33071,r.samplingMode=t,r.maxAnisotropy=this._maxAnisotropy,r.preMultiplyAlpha=!0,r.flipped=!0,r.hasMipmap=!0,e||(r.pixelFormat=6407),r}_generateTextureMipmap(e){const t=this._rctx,r=t.bindTexture(e.texture,B.TEXTURE_UNIT_FOR_UPDATES);e.generateMipmap(),t.bindTexture(r,B.TEXTURE_UNIT_FOR_UPDATES)}_buildTileTexture(e,t=!1,r=()=>{},s){const o=this._cache.pop(b(e,!1))??this._cache.pop(b(e,!0));if(t&&=I(s,e),o)return o.retain(),t?o.texture.enableCompression({compressionTracker:this._compressionTracker,compressionCallback:r}):o.texture.disableCompression(),o.texture.setData(s),o;e.compress=t?{compressionTracker:this._compressionTracker,compressionCallback:r}:void 0;const a=new B(this._rctx,e,s);return new k(a,this._cache)}get test(){}}function M(e,t,o){F.layerIndex=t,F.vtlNeighborInfos.clear();const a=e.layerInfo[1][t];if(r(F.offset,0,0),F.tile=e,F.scale=1,F.sourceLod=e.lij,F.sourceLayerInfo=a,F.isVTLBackground=o,a.data)return o&&e.forEachLoadedNeighbor((r,s)=>{if(r.level!==e.level)return;const o=r.layerInfo[1][t];if(!x(o)||a.data===o.data)return;const i=F.vtlNeighborInfos.pushNew();i.offset=R[s],i.sourceLod=r.lij,i.sourceLayerInfo=o}),F;const i=a.upsampleInfo,n=i?.tile?.layerInfo[1][t];return n&&i.tile?(F.tile=i.tile,s(F.offset,i.offset),F.scale=i.scale,F.sourceLod=i.tile.lij,F.sourceLayerInfo=n,F):o?F:null}function O(e){const t=e.sourceLayerInfo.data;return!!t.source&&"nearest"===t.interpolation}function j(e){let t="normal"!==e.blendMode;return n(e.parent)&&(t=j(e.parent)||t),t}function S(e,t){n(e.parent)&&S(e.parent,t);const r=e.uid;if(null!=r&&""!==r){const s=v.get(r);s?s.start=t:v.set(r,new U(t,t,e.blendMode,e.opacity,1,1))}}class U{constructor(e,t,r,s,o,a){this.start=e,this.end=t,this.blendMode=r,this.opacity=s,this.output=o,this.baseOpacity=a}}const v=new Map,D=new Array,F=new g,z=a(0,0,1,1),R=new Array;function A(){F.sourceLayerInfo=null,F.tile=null,F.vtlNeighborInfos.prune()}R[0]=[0,-1],R[1]=[-1,-1],R[2]=[-1,0],R[3]=[-1,1],R[4]=[0,1],R[5]=[1,1],R[6]=[1,0],R[7]=[1,-1];export{U as GroupInfo,P as TileRenderer,A as cleanupTileRenderer};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import{property as s,subclass as r}from"../../../../core/accessorSupport/decorators.js";import{InternalRenderCategory as o}from"../../webgl.js";import t from"../../webgl/RenderNode.js";let i=class extends t{constructor(){super(...arguments),this.produces="disabled",this.consumes={required:[o.OPAQUE_ENVIRONMENT]}}_enable(){this.produces=o.OPAQUE_ENVIRONMENT,this.requestRender(1)}_disable(){this.produces="disabled",this.requestRender(1)}};e([s()],i.prototype,"produces",void 0),e([s()],i.prototype,"consumes",void 0),i=e([r("esri.views.3d.webgl-engine.effects.OpaqueEnvironment")],i);export{i as OpaqueEnvironment};
2
+ import{__decorate as e}from"tslib";import{property as s,subclass as r}from"../../../../core/accessorSupport/decorators.js";import{InternalRenderCategory as o}from"../../webgl.js";import t from"../../webgl/RenderNode.js";let i=class extends t{constructor(){super(...arguments),this.consumes={required:[o.OPAQUE_ENVIRONMENT]},this.produces="disabled"}_enable(){this.produces=o.OPAQUE_ENVIRONMENT,this.requestRender(1)}_disable(){this.produces="disabled",this.requestRender(1)}};e([s()],i.prototype,"consumes",void 0),e([s()],i.prototype,"produces",void 0),i=e([r("esri.views.3d.webgl-engine.effects.OpaqueEnvironment")],i);export{i as OpaqueEnvironment};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import e from"../../../../core/Error.js";import"../../../../core/has.js";import r from"../../../../core/Logger.js";import t from"../../../../core/PooledArray.js";import{DepthRange as o}from"../lib/DepthRange.js";class n{constructor(e){this._context=e,this._nodes=new t,this._debug=!1}destroy(){this._nodes.forEach(e=>e.destroy()),this._nodes.prune()}add(e){this._nodes.push(e)}remove(e){this._nodes.remove(e)}produces(e){return this._nodes.some(({produces:r})=>r===e)}require(e,...r){const t=this._nodes,o=r=>t.reduce((t,{consumes:o,produces:n})=>t+(!o.required.includes(e)||null!=r&&n!==r?0:1),0);return 0===r.length?o():r.reduce((e,r)=>e+o(r),0)}optional(e,...r){const t=this._nodes,o=r=>t.reduce((t,{consumes:o,produces:n})=>t+(!o.optional?.includes(e)||null!=r&&n!==r?0:1),0);return 0===r.length?o():r.reduce((e,r)=>e+o(r),0)}updateAnimation(e){return this._nodes.reduce((r,t)=>t.updateAnimation(e)||r,!1)}precompile(e,...r){++this._context.techniques.precompiling;for(const t of r)this._nodes.forEach(r=>{const o=e||!r.consumes.required.includes("emissive");r.produces===t&&o&&r.precompile()});--this._context.techniques.precompiling}queryDepthRange(e,t){return this._nodes.reduce((o,n)=>{if(n.produces!==e)return o;try{return o.union(n.queryDepthRange(t))}catch(s){return r.getLogger(n).errorOnce(s),o}},new o)}render(e,r,t=()=>{}){return this._render(e,r,t)??e}produce(e,r,t=()=>{}){return this._render(e,r,t)}_render(t,o,n=()=>{}){const s="string"==typeof t?t:t.name,i=this._nodes.filter(({produces:e})=>e===s);if(0===i.length)return;let u="string"==typeof t?null:t;return i.some(t=>{const i=u?[u]:[],c=null==u;for(const e of t.consumes.required){if(e===s){if(c)return!1;continue}const r=o.get(e);if(r)i.push(r);else if("emissive"!==e||!o.get(s)?.hasAttachment(e))return n?.(i),!1}if(t.consumes.optional)for(const e of t.consumes.optional){if(e===s)continue;const r=o.get(e);r&&i.push(r)}try{const n=t.doRender(i);if(n&&n!==u){if(s!==n.name&&(r.getLogger(t).errorOnce(`RenderNode produced ${n.name}, expected ${s}`),n.setName(s)),this._debug&&u&&n.fbo.usedMemory!==u.usedMemory)throw new e("render-node:invalid-output",`${t.declaredClass} did not return a framebuffer with the same attachments as the input framebuffer`);u?.release(),u=n,o.set(s,u)}}catch(d){if(r.getLogger(t).errorOnce(d),d instanceof e)throw d}return n?.(i),c&&null!=u}),this._context.rctx.enforceState(),u}get requireGeometryDepth(){return this._nodes.some(e=>"disabled"!==e.produces&&e.requireGeometryDepth)}get test(){return{nodes:this._nodes}}}export{n as RenderNodes};
2
+ import e from"../../../../core/Error.js";import"../../../../core/has.js";import r from"../../../../core/Logger.js";import t from"../../../../core/PooledArray.js";import{DepthRange as o}from"../lib/DepthRange.js";class n{constructor(e){this._context=e,this._nodes=new t,this._debug=!1}destroy(){this._nodes.forEach(e=>e.destroy()),this._nodes.prune()}add(e){this._nodes.push(e)}remove(e){this._nodes.remove(e)}produces(e){return this._nodes.some(({produces:r})=>r===e)}require(e,...r){const t=this._nodes,o=r=>t.reduce((t,{consumes:o,produces:n})=>t+(!o.required.includes(e)||null!=r&&n!==r?0:1),0);return 0===r.length?o():r.reduce((e,r)=>e+o(r),0)}optional(e,...r){const t=this._nodes,o=r=>t.reduce((t,{consumes:o,produces:n})=>t+(!o.optional?.includes(e)||null!=r&&n!==r?0:1),0);return 0===r.length?o():r.reduce((e,r)=>e+o(r),0)}updateAnimation(e){return this._nodes.reduce((r,t)=>t.updateAnimation(e)||r,!1)}precompile(e,...r){++this._context.techniques.precompiling;for(const t of r)this._nodes.forEach(r=>{const o=e||!r.consumes.required.includes("emissive");r.produces===t&&o&&r.precompile()});--this._context.techniques.precompiling}queryDepthRange(e,t){return this._nodes.reduce((o,n)=>{if(n.produces!==e)return o;try{return o.union(n.queryDepthRange(t))}catch(s){return r.getLogger(n).errorOnce(s),o}},new o)}render(e,r,t=()=>{}){return this._render(e,r,t)??e}produce(e,r,t=()=>{}){return this._render(e,r,t)}_render(t,o,n=()=>{}){const s="string"==typeof t?t:t.name,i=this._nodes.filter(({produces:e})=>e===s);if(0===i.length)return;let u="string"==typeof t?null:t;return i.some(t=>{const i=new Array,d=null==u;for(const e of t.consumes.required){const r=o.get(e);if(r)i.push(r);else if("emissive"!==e||!o.get(s)?.hasAttachment(e))return n?.(i),!1}if(t.consumes.optional)for(const e of t.consumes.optional){if(e===s)continue;const r=o.get(e);r&&i.push(r)}try{const n=t.doRender(i);if(this._debug&&!n&&!d)throw new e("render-node:invalid-output",`${t.declaredClass} did not produce an output`);if(n&&n!==u){if(s!==n.name&&(r.getLogger(t).errorOnce(`RenderNode produced ${n.name}, expected ${s}`),n.setName(s)),this._debug&&u&&n.fbo.usedMemory!==u.usedMemory)throw new e("render-node:invalid-output",`${t.declaredClass} did not return a framebuffer with the same attachments as the input framebuffer`);u?.release(),u=n,o.set(s,u)}}catch(c){if(r.getLogger(t).errorOnce(c),c instanceof e)throw c}return n?.(i),d&&null!=u}),this._context.rctx.enforceState(),u}get requireGeometryDepth(){return this._nodes.some(e=>"disabled"!==e.produces&&e.requireGeometryDepth)}get test(){return{nodes:this._nodes}}}export{n as RenderNodes};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import{releaseMaybe as r}from"../../../../../core/maybe.js";import{property as t,subclass as o}from"../../../../../core/accessorSupport/decorators.js";import{ZEROS as n}from"../../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{RenderNodeOutput as i}from"../../../webgl.js";import s from"../../../webgl/RenderNode.js";import{If as a,glsl as c}from"../../core/shaderModules/glsl.js";import{Pos2Locations as u}from"../../lib/DefaultVertexBufferLayouts.js";import{floatBlendReductionFactor as l}from"../../shaders/oitResolution.glsl.js";import{checkWebGLError as h}from"../../../../webgl/checkWebGLError.js";import{ColorAttachment0 as p,SizedPixelFormat as f,DataType as d}from"../../../../webgl/enums.js";let m=class extends s{constructor(e){super(e),this.destroyedCB=null,this.produces=i.FINAL,this.consumes={required:[i.FINAL]},this.clearColor=n,this._focusedFBOType=7,this._programs=new Map}destroy(){this._programs.clear(),this.destroyedCB()}render(){const e=this.input;if(!this._focusedTexture)return e;const r=this.renderingContext,t=r.boundFramebuffer;r.bindFramebuffer(e.fbo),r.setClearColor(0,0,0,0),r.clear(16384);const o=this._focusedTexture.attachment,n=[v(o)],i=this._ensureProgram(r,!1,n);return r.useProgram(i),r.bindTexture(o,0),i.setUniform1i("colorTex0",0),i.setUniform1i("inputType",this._focusedFBOType),3===this._focusedFBOType&&i.setUniform2fv("nearFar",this.camera.nearFar),r.setDrawBuffers([p]),r.screen.draw(),r.bindFramebuffer(t),e}getDownscaledFBO(e,r,t,o,n,i){if(n?.startsWith(`${r}\n`)??!1){const r=1/2**e.level;t=e.width*r,o=e.height*r}else i=null;const s="linear depth"===r||r.includes("shadow"),a="overlay highlight"===r||"highlights"===r||"highlight mix"===r,c="highlight coverage"===r,u=e.colorTexture?.descriptor,l=u?.internalFormat,d=[],m=new Array,g=new Array;e.colorAttachments.forEach((r,t)=>{const o=e.getColorTexture(r);if(o){const e=v(o);d.push(e);const{descriptor:r}=o;"float"!==e||r.hasMipmap||r.isImmutable||(o.generateMipmap(),m[t]=!0)}if(t>0){const e=o?.descriptor.internalFormat;return void(e===f.RGBA8&&(o?.debugName?.indexOf("emissive")??-1)>=0?g.push(8):g.push(F(e)))}g.push(s?0:a?1:c?2:i??F(l))});const x=this.renderingContext,{depthStencilTexture:$}=e,b=this._ensureProgram(x,null!=$,d,e.level),C=this.fboCache.acquire(t,o,"fbo visualizer");x.useProgram(b);const R=x.boundFramebuffer;x.bindFramebuffer(C.fbo);const y=new Array;e.colorAttachments.forEach((r,t)=>{const o=`colorTex${t.toFixed()}`;x.bindTexture(e.getColorTexture(r),t),b.setUniform1i(o,t),t>0&&C.acquireColor(p+t,5,"fbo visualizer"),y.push(r)});const w=$?.descriptor.linearFilterDepth??!1;if($){const r=e.colorAttachments.length;$.setShadowFiltering(!1),x.bindTexture($,r),b.setUniform1i("depthTex",r);const t=p+r;t>p&&C.acquireColor(t,5,"fbo visualizer"),y.push(t)}x.gl.drawBuffers(y),h(x.gl);const B=x.getViewport();return x.setViewport(0,0,t,o),x.setClearColor(0,0,0,0),x.clear(16384),x.setBlendingEnabled(!0),x.setBlendFunction(1,771),b.setUniform1iv("inputTypes",g.length>0?g:[7]),b.setUniform2fv("nearFar",this.camera.nearFar),x.screen.draw(),h(x.gl),x.bindFramebuffer(R),x.setViewport(B.x,B.y,B.width,B.height),e.colorAttachments.forEach((t,o)=>{const i=e.getColorTexture(t);m[o]&&i?.clearMipmap(),n===T(r,e,t,!1)&&(this._focusedTexture?.release(),this._focusedTexture=C.getAttachment(t),this._focusedTexture?.retain(),this._focusedFBOType=9===g[o]?F(i?.descriptor.internalFormat):g[o])}),$&&$.setShadowFiltering(w),C}clearFocusedFBO(){this._focusedTexture=r(this._focusedTexture)}getPreviewContent(e,r,t,o){const n=this.renderingContext,i=o.includes("\ndepth"),s=this.fboCache.acquire(e,r,"fbo visualizer"),a=n.boundFramebuffer;n.bindFramebuffer(s?.fbo);const c=n.getViewport();n.setViewport(0,0,e,r),n.setClearColor(this.clearColor[0],this.clearColor[1],this.clearColor[2],this.clearColor[3]),n.clear(16384),n.setBlendingEnabled(!0),n.setBlendFunction(1,771);const u=t.attachment,l=this._ensureProgram(n,!1,[v(u)]);n.useProgram(l),n.bindTexture(u,0),l.setUniform1i("colorTex0",0),l.setUniform1iv("inputTypes",[i||u.descriptor.internalFormat!==f.RGBA16F?7:5]),n.screen.draw();const p=new ImageData(new Uint8ClampedArray(e*r*4),e,r);return n.gl.readPixels(0,0,e,r,6408,d.UNSIGNED_BYTE,new Uint8Array(p.data.buffer)),h(n.gl),n.bindFramebuffer(a),n.setViewport(c.x,c.y,c.width,c.height),s?.release(),p}_ensureProgram(e,r,t,o=0){const n=x({hasDepthAttachment:r,colorSamplerTypes:t}),i=this._programs.get(n);if(i)return i;const s="#version 300 es\n in vec2 position;\n out vec2 uv;\n\n void main() {\n gl_Position = vec4(position, 0.0, 1.0);\n uv = position * 0.5 + vec2(0.5);\n }",h=e=>{let r="";for(let t=0;t<e.length;++t){const o=e[t];r+=`layout(location = ${c.int(t)}) out vec4 fragColor${c.int(t)};\n uniform ${g(o)} colorTex${c.int(t)};`}return r},p=e=>e.reduce((e,r,t)=>e+`{\n int inputType = inputTypes[${t}];\n if (inputType == ${3..toFixed()}) {\n fragColor${t} = vec4(vec3(texture(colorTex${t}, uv, ${o}.0).r), 1.0);\n } else if (inputType == ${4..toFixed()}) {\n fragColor${t} = vec4(texture(colorTex${t}, uv, ${o}.0).rg, 0.0, 1.0);\n } else if (inputType == ${(0).toFixed()}) {\n float depth = 1.0 - ((-linearDepthFromTexture(colorTex${t}, uv) - nearFar[0]) / (nearFar[1] - nearFar[0]));\n fragColor${t} = vec4(vec3(depth), depth >= 0.999 ? 0.0 : 1.0);\n } else if (inputType == ${5..toFixed()}) {\n fragColor${t} = vec4(texture(colorTex${t}, uv, ${o}.0).rgb, 1.0);\n } else if (inputType == ${1..toFixed()}) {\n fragColor${t} = vec4(texture(colorTex${t}, uv, ${o}.0)) * 255.0;\n fragColor${t} = vec4(fragColor${t}.rgb / fragColor${t}.a, fragColor${t}.a);\n } else if(inputType == ${2..toFixed()}) {\n vec2 texDim = vec2(textureSize(colorTex${t}, 0));\n ivec2 iuv = ivec2(uv * texDim);\n uvec2 hh = uvec2(texelFetch(colorTex${t}, iuv, 0).rg);\n fragColor${t} = vec4(\n ((hh & uvec2(0x55u)) != uvec2(0u)) ? 1.0 : 0.0,\n ((hh & uvec2(0xaau)) != uvec2(0u)) ? 1.0 : 0.0,\n 0.0,\n 1.0);\n } else if(inputType == ${8..toFixed()}) {\n fragColor${t} = vec4(texture(colorTex${t}, uv, ${o}.0));\n fragColor${t}.rgb *= ${l.toFixed(1)};\n } else if (inputType == ${9..toFixed()}) {\n fragColor${t} = vec4(vec3(texture(colorTex${t}, uv, ${o}.0).a), 1.0);\n } else {\n fragColor${t} = vec4(texture(colorTex${t}, uv, ${o}.0));\n }\n }`,""),f=t.length,d=`#version 300 es\n precision highp float;\n precision highp usampler2D;\n\n in vec2 uv;\n ${h(t)}\n ${a(r,`layout(location = ${c.int(f)}) out vec4 fragDepth;\n uniform sampler2D depthTex;`)}\n\n uniform int inputTypes[${t.length||1}];\n uniform vec2 nearFar;\n\n // Factors to convert rgba back to float\n const vec4 RGBA_2_FLOAT_FACTORS = vec4(\n 255.0 / (256.0),\n 255.0 / (256.0 * 256.0),\n 255.0 / (256.0 * 256.0 * 256.0),\n 255.0 / (256.0 * 256.0 * 256.0 * 256.0)\n );\n\n\n float rgbaToFloat(vec4 rgba) {\n // Convert components from 0->1 back to 0->255 and then add the components together with their corresponding\n // fixed point factors, i.e. (256^1, 256^2, 256^3, 256^4)\n return dot(rgba, RGBA_2_FLOAT_FACTORS);\n }\n\n float linearDepthFromFloat(float depth) {\n depth = pow(depth, 0.2);\n return -(depth * (nearFar[1] - nearFar[0]) + nearFar[0]);\n }\n\n float linearDepthFromRGBA(vec4 depth) {\n return linearDepthFromFloat(rgbaToFloat(depth));\n }\n\n ${"float"===t[0]?"float linearDepthFromTexture(sampler2D depthTex, vec2 uv) {\n ivec2 iuv = ivec2(uv * vec2(textureSize(depthTex, 0)));\n return linearDepthFromRGBA(texelFetch(depthTex, iuv, 0));\n }":"float linearDepthFromTexture(usampler2D depthTex, vec2 uv) {\n ivec2 iuv = ivec2(uv * vec2(textureSize(depthTex, 0)));\n return linearDepthFromRGBA(vec4(texelFetch(depthTex, iuv, 0)) * 255.0);\n }"}\n\n void main() {\n ${p(t)}\n ${a(r,"float depth = 1.0 - pow(texture(depthTex, uv).r, 10.0);\n fragDepth = vec4(vec3(depth), depth < 0.000001 ? 0.0 : 1.0);")}\n }`,m=e.programCache.get(s,d,u);return this._programs.set(n,m),m}};function g(e){switch(e){case"float":return"sampler2D";case"uint":return"usampler2D";case"int":return"isampler2D"}}function v(e){if(!e)return"float";const{internalFormat:r}=e.descriptor;switch(r){case f.R8I:case f.R16I:case f.R32I:case f.RG8I:case f.RG16I:case f.RG32I:case f.RGB8I:case f.RGB16I:case f.RGB32I:case f.RGBA8I:case f.RGBA16I:case f.RGBA32I:return"int";case f.R8UI:case f.R16UI:case f.R32UI:case f.RG8UI:case f.RG16UI:case f.RG32UI:case f.RGB8UI:case f.RGB16UI:case f.RGB32UI:case f.RGBA8UI:case f.RGBA16UI:case f.RGBA32UI:return"uint";default:return"float"}}function x(e){const{hasDepthAttachment:r,colorSamplerTypes:t}=e;return`${r?"Depth":""}${t.reduceRight((e,r)=>e+`|C${r}`,"")}`}function F(e){switch(e){case f.R16F:case f.R32F:case f.R8:return 3;case f.RG8:return 4;case f.RGBA16F:return 5;case f.RG8UI:return 6;default:return 7}}function T(e,r,t,o){return o?`${e}\ndepth`:`${e}\n${$(r,t)}`}function $(e,r){return`${e.getColorTexture(r)?.debugName??"color"+(r-p)}`}e([t()],m.prototype,"destroyedCB",void 0),e([t()],m.prototype,"produces",void 0),e([t()],m.prototype,"consumes",void 0),e([t()],m.prototype,"clearColor",void 0),m=e([o("esri.views.3d.webgl-engine.effects.debug.RenderNodeVisualizerNode")],m);export{m as RenderNodeVisualizerNode,T as getAttachmentName};
2
+ import{__decorate as e}from"tslib";import{releaseMaybe as r}from"../../../../../core/maybe.js";import{property as t,subclass as o}from"../../../../../core/accessorSupport/decorators.js";import{ZEROS as n}from"../../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{RenderNodeOutput as i}from"../../../webgl.js";import s from"../../../webgl/RenderNode.js";import{If as a,glsl as c}from"../../core/shaderModules/glsl.js";import{Pos2Locations as u}from"../../lib/DefaultVertexBufferLayouts.js";import{floatBlendReductionFactor as l}from"../../shaders/oitResolution.glsl.js";import{checkWebGLError as h}from"../../../../webgl/checkWebGLError.js";import{ColorAttachment0 as p,SizedPixelFormat as f,DataType as d}from"../../../../webgl/enums.js";let m=class extends s{constructor(e){super(e),this.destroyedCB=null,this.consumes={required:[i.FINAL]},this.produces=i.FINAL,this.clearColor=n,this._focusedFBOType=7,this._programs=new Map}destroy(){this._programs.clear(),this.destroyedCB()}render(){const e=this.input;if(!this._focusedTexture)return e;const r=this.renderingContext,t=r.boundFramebuffer;r.bindFramebuffer(e.fbo),r.setClearColor(0,0,0,0),r.clear(16384);const o=this._focusedTexture.attachment,n=[v(o)],i=this._ensureProgram(r,!1,n);return r.useProgram(i),r.bindTexture(o,0),i.setUniform1i("colorTex0",0),i.setUniform1i("inputType",this._focusedFBOType),3===this._focusedFBOType&&i.setUniform2fv("nearFar",this.camera.nearFar),r.setDrawBuffers([p]),r.screen.draw(),r.bindFramebuffer(t),e}getDownscaledFBO(e,r,t,o,n,i){if(n?.startsWith(`${r}\n`)??!1){const r=1/2**e.level;t=e.width*r,o=e.height*r}else i=null;const s="linear depth"===r||r.includes("shadow"),a="overlay highlight"===r||"highlights"===r||"highlight mix"===r,c="highlight coverage"===r,u=e.colorTexture?.descriptor,l=u?.internalFormat,d=[],m=new Array,g=new Array;e.colorAttachments.forEach((r,t)=>{const o=e.getColorTexture(r);if(o){const e=v(o);d.push(e);const{descriptor:r}=o;"float"!==e||r.hasMipmap||r.isImmutable||(o.generateMipmap(),m[t]=!0)}if(t>0){const e=o?.descriptor.internalFormat;return void(e===f.RGBA8&&(o?.debugName?.indexOf("emissive")??-1)>=0?g.push(8):g.push(F(e)))}g.push(s?0:a?1:c?2:i??F(l))});const x=this.renderingContext,{depthStencilTexture:$}=e,b=this._ensureProgram(x,null!=$,d,e.level),C=this.fboCache.acquire(t,o,"fbo visualizer");x.useProgram(b);const R=x.boundFramebuffer;x.bindFramebuffer(C.fbo);const y=new Array;e.colorAttachments.forEach((r,t)=>{const o=`colorTex${t.toFixed()}`;x.bindTexture(e.getColorTexture(r),t),b.setUniform1i(o,t),t>0&&C.acquireColor(p+t,5,"fbo visualizer"),y.push(r)});const w=$?.descriptor.linearFilterDepth??!1;if($){const r=e.colorAttachments.length;$.setShadowFiltering(!1),x.bindTexture($,r),b.setUniform1i("depthTex",r);const t=p+r;t>p&&C.acquireColor(t,5,"fbo visualizer"),y.push(t)}x.gl.drawBuffers(y),h(x.gl);const B=x.getViewport();return x.setViewport(0,0,t,o),x.setClearColor(0,0,0,0),x.clear(16384),x.setBlendingEnabled(!0),x.setBlendFunction(1,771),b.setUniform1iv("inputTypes",g.length>0?g:[7]),b.setUniform2fv("nearFar",this.camera.nearFar),x.screen.draw(),h(x.gl),x.bindFramebuffer(R),x.setViewport(B.x,B.y,B.width,B.height),e.colorAttachments.forEach((t,o)=>{const i=e.getColorTexture(t);m[o]&&i?.clearMipmap(),n===T(r,e,t,!1)&&(this._focusedTexture?.release(),this._focusedTexture=C.getAttachment(t),this._focusedTexture?.retain(),this._focusedFBOType=9===g[o]?F(i?.descriptor.internalFormat):g[o])}),$&&$.setShadowFiltering(w),C}clearFocusedFBO(){this._focusedTexture=r(this._focusedTexture)}getPreviewContent(e,r,t,o){const n=this.renderingContext,i=o.includes("\ndepth"),s=this.fboCache.acquire(e,r,"fbo visualizer"),a=n.boundFramebuffer;n.bindFramebuffer(s?.fbo);const c=n.getViewport();n.setViewport(0,0,e,r),n.setClearColor(this.clearColor[0],this.clearColor[1],this.clearColor[2],this.clearColor[3]),n.clear(16384),n.setBlendingEnabled(!0),n.setBlendFunction(1,771);const u=t.attachment,l=this._ensureProgram(n,!1,[v(u)]);n.useProgram(l),n.bindTexture(u,0),l.setUniform1i("colorTex0",0),l.setUniform1iv("inputTypes",[i||u.descriptor.internalFormat!==f.RGBA16F?7:5]),n.screen.draw();const p=new ImageData(new Uint8ClampedArray(e*r*4),e,r);return n.gl.readPixels(0,0,e,r,6408,d.UNSIGNED_BYTE,new Uint8Array(p.data.buffer)),h(n.gl),n.bindFramebuffer(a),n.setViewport(c.x,c.y,c.width,c.height),s?.release(),p}_ensureProgram(e,r,t,o=0){const n=x({hasDepthAttachment:r,colorSamplerTypes:t}),i=this._programs.get(n);if(i)return i;const s="#version 300 es\n in vec2 position;\n out vec2 uv;\n\n void main() {\n gl_Position = vec4(position, 0.0, 1.0);\n uv = position * 0.5 + vec2(0.5);\n }",h=e=>{let r="";for(let t=0;t<e.length;++t){const o=e[t];r+=`layout(location = ${c.int(t)}) out vec4 fragColor${c.int(t)};\n uniform ${g(o)} colorTex${c.int(t)};`}return r},p=e=>e.reduce((e,r,t)=>e+`{\n int inputType = inputTypes[${t}];\n if (inputType == ${3..toFixed()}) {\n fragColor${t} = vec4(vec3(texture(colorTex${t}, uv, ${o}.0).r), 1.0);\n } else if (inputType == ${4..toFixed()}) {\n fragColor${t} = vec4(texture(colorTex${t}, uv, ${o}.0).rg, 0.0, 1.0);\n } else if (inputType == ${(0).toFixed()}) {\n float depth = 1.0 - ((-linearDepthFromTexture(colorTex${t}, uv) - nearFar[0]) / (nearFar[1] - nearFar[0]));\n fragColor${t} = vec4(vec3(depth), depth >= 0.999 ? 0.0 : 1.0);\n } else if (inputType == ${5..toFixed()}) {\n fragColor${t} = vec4(texture(colorTex${t}, uv, ${o}.0).rgb, 1.0);\n } else if (inputType == ${1..toFixed()}) {\n fragColor${t} = vec4(texture(colorTex${t}, uv, ${o}.0)) * 255.0;\n fragColor${t} = vec4(fragColor${t}.rgb / fragColor${t}.a, fragColor${t}.a);\n } else if(inputType == ${2..toFixed()}) {\n vec2 texDim = vec2(textureSize(colorTex${t}, 0));\n ivec2 iuv = ivec2(uv * texDim);\n uvec2 hh = uvec2(texelFetch(colorTex${t}, iuv, 0).rg);\n fragColor${t} = vec4(\n ((hh & uvec2(0x55u)) != uvec2(0u)) ? 1.0 : 0.0,\n ((hh & uvec2(0xaau)) != uvec2(0u)) ? 1.0 : 0.0,\n 0.0,\n 1.0);\n } else if(inputType == ${8..toFixed()}) {\n fragColor${t} = vec4(texture(colorTex${t}, uv, ${o}.0));\n fragColor${t}.rgb *= ${l.toFixed(1)};\n } else if (inputType == ${9..toFixed()}) {\n fragColor${t} = vec4(vec3(texture(colorTex${t}, uv, ${o}.0).a), 1.0);\n } else {\n fragColor${t} = vec4(texture(colorTex${t}, uv, ${o}.0));\n }\n }`,""),f=t.length,d=`#version 300 es\n precision highp float;\n precision highp usampler2D;\n\n in vec2 uv;\n ${h(t)}\n ${a(r,`layout(location = ${c.int(f)}) out vec4 fragDepth;\n uniform sampler2D depthTex;`)}\n\n uniform int inputTypes[${t.length||1}];\n uniform vec2 nearFar;\n\n // Factors to convert rgba back to float\n const vec4 RGBA_2_FLOAT_FACTORS = vec4(\n 255.0 / (256.0),\n 255.0 / (256.0 * 256.0),\n 255.0 / (256.0 * 256.0 * 256.0),\n 255.0 / (256.0 * 256.0 * 256.0 * 256.0)\n );\n\n\n float rgbaToFloat(vec4 rgba) {\n // Convert components from 0->1 back to 0->255 and then add the components together with their corresponding\n // fixed point factors, i.e. (256^1, 256^2, 256^3, 256^4)\n return dot(rgba, RGBA_2_FLOAT_FACTORS);\n }\n\n float linearDepthFromFloat(float depth) {\n depth = pow(depth, 0.2);\n return -(depth * (nearFar[1] - nearFar[0]) + nearFar[0]);\n }\n\n float linearDepthFromRGBA(vec4 depth) {\n return linearDepthFromFloat(rgbaToFloat(depth));\n }\n\n ${"float"===t[0]?"float linearDepthFromTexture(sampler2D depthTex, vec2 uv) {\n ivec2 iuv = ivec2(uv * vec2(textureSize(depthTex, 0)));\n return linearDepthFromRGBA(texelFetch(depthTex, iuv, 0));\n }":"float linearDepthFromTexture(usampler2D depthTex, vec2 uv) {\n ivec2 iuv = ivec2(uv * vec2(textureSize(depthTex, 0)));\n return linearDepthFromRGBA(vec4(texelFetch(depthTex, iuv, 0)) * 255.0);\n }"}\n\n void main() {\n ${p(t)}\n ${a(r,"float depth = 1.0 - pow(texture(depthTex, uv).r, 10.0);\n fragDepth = vec4(vec3(depth), depth < 0.000001 ? 0.0 : 1.0);")}\n }`,m=e.programCache.get(s,d,u);return this._programs.set(n,m),m}};function g(e){switch(e){case"float":return"sampler2D";case"uint":return"usampler2D";case"int":return"isampler2D"}}function v(e){if(!e)return"float";const{internalFormat:r}=e.descriptor;switch(r){case f.R8I:case f.R16I:case f.R32I:case f.RG8I:case f.RG16I:case f.RG32I:case f.RGB8I:case f.RGB16I:case f.RGB32I:case f.RGBA8I:case f.RGBA16I:case f.RGBA32I:return"int";case f.R8UI:case f.R16UI:case f.R32UI:case f.RG8UI:case f.RG16UI:case f.RG32UI:case f.RGB8UI:case f.RGB16UI:case f.RGB32UI:case f.RGBA8UI:case f.RGBA16UI:case f.RGBA32UI:return"uint";default:return"float"}}function x(e){const{hasDepthAttachment:r,colorSamplerTypes:t}=e;return`${r?"Depth":""}${t.reduceRight((e,r)=>e+`|C${r}`,"")}`}function F(e){switch(e){case f.R16F:case f.R32F:case f.R8:return 3;case f.RG8:return 4;case f.RGBA16F:return 5;case f.RG8UI:return 6;default:return 7}}function T(e,r,t,o){return o?`${e}\ndepth`:`${e}\n${$(r,t)}`}function $(e,r){return`${e.getColorTexture(r)?.debugName??"color"+(r-p)}`}e([t()],m.prototype,"destroyedCB",void 0),e([t()],m.prototype,"consumes",void 0),e([t()],m.prototype,"produces",void 0),e([t()],m.prototype,"clearColor",void 0),m=e([o("esri.views.3d.webgl-engine.effects.debug.RenderNodeVisualizerNode")],m);export{m as RenderNodeVisualizerNode,T as getAttachmentName};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import{property as s,subclass as t}from"../../../../../core/accessorSupport/decorators.js";import{RenderNodeOutput as r,InternalRenderCategory as i}from"../../../webgl.js";import o from"../../../webgl/RenderNode.js";import{F as n}from"../../../../../chunks/FocusAreaMask.glsl.js";import{FocusAreaMaskTechnique as a}from"./FocusAreaMaskTechnique.js";import{volumeToVao as h}from"./focusAreaMaskUtils.js";import{DepthStencilAttachment as c,PrimitiveType as u}from"../../../../webgl/enums.js";import{noParameters as l}from"../../../../webgl/NoParameters.js";let p=class extends o{constructor(e){super({...e,view:e.focusAreasView.view}),this.consumes={required:[r.TRANSPARENT]},this.produces=i.FOCUSAREA,this._vaos=new Array,this._counts=new Array,this._origins=new Array,this._maskParameters=new n}initialize(){this.updateGeometries()}destroy(){this._vaos.forEach(e=>e.dispose()),this._vaos.length=this._counts.length=this._origins.length=0}render(e){const s=this.techniques.getCompiled(a);if(!s||!this._vaos)return void this.requestRender(1);const t=e.find(({name:e})=>e===r.TRANSPARENT),o=this.renderingContext,n=this.bindParameters,h=n.camera,p=h.fullViewport[2],m=h.fullViewport[3],d=this.fboCache.acquire(p,m,i.FOCUSAREA,2);this.view.stage.renderer.occludedRequiresStencil?(d.acquireDepth(14),o.blitFramebuffer(t.fbo,d.fbo,256)):d.attachDepth(t.getAttachment(c)),o.bindFramebuffer(d.fbo),o.setClearColor(0,0,0,1),o.clear(17408),o.setViewport(0,0,p,m);const f=o.bindTechnique(s,n,l);o.setFaceCullingEnabled(!1),o.setStencilTestEnabled(!0),o.setStencilOpSeparate(1028,7680,34055,7680),o.setStencilOpSeparate(1029,7680,34056,7680),o.setDepthWriteEnabled(!1);for(let r=0;r<this._vaos.length;r++){const e=this._vaos[r],s=this._counts[r];this._maskParameters.origin=this._origins[r],f.bindDraw(n,l,this._maskParameters),o.bindVAO(e),o.setDepthTestEnabled(!0),o.setStencilWriteMask(255),o.setStencilFunction(519,0,255),o.setColorMask(!1,!1,!1,!1),o.drawArrays(u.TRIANGLES,0,s),o.setDepthTestEnabled(!1),o.setStencilWriteMask(0),o.setStencilFunction(517,0,255),o.setColorMask(!0,!0,!0,!0),o.drawArrays(u.TRIANGLES,0,s)}return d}updateGeometries(){if(!this.view.stage)return;this._vaos.forEach(e=>e.dispose()),this._vaos.length=this._counts.length=this._origins.length=0;this.focusAreasView.volumes.forEach(e=>{const s=e.geometryVolume,{vao:t,vertexCount:r}=h(this.renderingContext,s);this._vaos.push(t),this._counts.push(r),this._origins.push(e.origin)}),this.requestRender(1)}};e([s()],p.prototype,"consumes",void 0),e([s()],p.prototype,"produces",void 0),e([s({constructOnly:!0})],p.prototype,"focusAreasView",void 0),p=e([t("esri.views.3d.webgl-engine.effects.focusArea.FocusAreaMask")],p);export{p as FocusAreaMask};
2
+ import{__decorate as e}from"tslib";import{property as s,subclass as t}from"../../../../../core/accessorSupport/decorators.js";import{InternalRenderCategory as r}from"../../../webgl.js";import i from"../../../webgl/RenderNode.js";import{F as o}from"../../../../../chunks/FocusAreaMask.glsl.js";import{FocusAreaMaskTechnique as n}from"./FocusAreaMaskTechnique.js";import{volumeToVao as a}from"./focusAreaMaskUtils.js";import{DepthStencilAttachment as h,PrimitiveType as c}from"../../../../webgl/enums.js";import{noParameters as u}from"../../../../webgl/NoParameters.js";let l=class extends i{constructor(e){super({...e,view:e.focusAreasView.view}),this.consumes={required:[r.CUTFILL_COMPUTATION]},this.produces=r.FOCUSAREA,this._vaos=new Array,this._counts=new Array,this._origins=new Array,this._maskParameters=new o}initialize(){this.updateGeometries()}destroy(){this._vaos.forEach(e=>e.dispose()),this._vaos.length=this._counts.length=this._origins.length=0}render(e){const s=this.techniques.getCompiled(n);if(!s||!this._vaos)return void this.requestRender(1);const t=e.find(({name:e})=>e===r.CUTFILL_COMPUTATION),i=this.renderingContext,o=this.bindParameters,a=o.camera,l=a.fullViewport[2],p=a.fullViewport[3],m=this.fboCache.acquire(l,p,r.FOCUSAREA,2);this.view.stage.renderer.occludedRequiresStencil?(m.acquireDepth(14),i.blitFramebuffer(t.fbo,m.fbo,256)):m.attachDepth(t.getAttachment(h)),i.bindFramebuffer(m.fbo),i.setClearColor(0,0,0,1),i.clear(17408),i.setViewport(0,0,l,p);const d=i.bindTechnique(s,o,u);i.setFaceCullingEnabled(!1),i.setStencilTestEnabled(!0),i.setStencilOpSeparate(1028,7680,34055,7680),i.setStencilOpSeparate(1029,7680,34056,7680),i.setDepthWriteEnabled(!1);for(let r=0;r<this._vaos.length;r++){const e=this._vaos[r],s=this._counts[r];this._maskParameters.origin=this._origins[r],d.bindDraw(o,u,this._maskParameters),i.bindVAO(e),i.setDepthTestEnabled(!0),i.setStencilWriteMask(255),i.setStencilFunction(519,0,255),i.setColorMask(!1,!1,!1,!1),i.drawArrays(c.TRIANGLES,0,s),i.setDepthTestEnabled(!1),i.setStencilWriteMask(0),i.setStencilFunction(517,0,255),i.setColorMask(!0,!0,!0,!0),i.drawArrays(c.TRIANGLES,0,s)}return m}updateGeometries(){if(!this.view.stage)return;this._vaos.forEach(e=>e.dispose()),this._vaos.length=this._counts.length=this._origins.length=0;this.focusAreasView.volumes.forEach(e=>{const s=e.geometryVolume,{vao:t,vertexCount:r}=a(this.renderingContext,s);this._vaos.push(t),this._counts.push(r),this._origins.push(e.origin)}),this.requestRender(1)}};e([s()],l.prototype,"consumes",void 0),e([s()],l.prototype,"produces",void 0),e([s({constructOnly:!0})],l.prototype,"focusAreasView",void 0),l=e([t("esri.views.3d.webgl-engine.effects.focusArea.FocusAreaMask")],l);export{l as FocusAreaMask};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import{property as r,subclass as o}from"../../../../../core/accessorSupport/decorators.js";import{ZEROS as t}from"../../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import s from"../../../webgl/RenderNode.js";let i=class extends s{constructor(e){super(e),this.consumes={required:["olid"]},this.produces="olid"}destroy(){}render(e){const r=e.find(({name:e})=>"olid"===e),o=this.renderingContext;return o.bindFramebuffer(r.fbo),o.clearFramebuffer(t,!0,!0),this.view.stage.renderer.renderAllGeometry(11),o.clear(1280),this.view.stage.renderer.renderHUD(1),r}};e([r()],i.prototype,"consumes",void 0),e([r()],i.prototype,"produces",void 0),i=e([o("esri.views.3d.webgl-engine.effects.geometry.ObjectAndLayerID")],i);export{i as ObjectAndLayerID};
2
+ import{__decorate as e}from"tslib";import{property as r,subclass as o}from"../../../../../core/accessorSupport/decorators.js";import{ZEROS as t}from"../../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{InternalRenderCategory as s}from"../../../webgl.js";import i from"../../../webgl/RenderNode.js";let n=class extends i{constructor(e){super(e),this.consumes={required:[s.OBJECT_AND_LAYER_ID_COLOR]},this.produces=s.OBJECT_AND_LAYER_ID_COLOR}destroy(){}render(){const e=this.input,r=this.renderingContext;return r.bindFramebuffer(e.fbo),r.clearFramebuffer(t,!0,!0),this.view.stage.renderer.renderAllGeometry(11),r.clear(1280),this.view.stage.renderer.renderHUD(1),e}};e([r()],n.prototype,"consumes",void 0),e([r()],n.prototype,"produces",void 0),n=e([o("esri.views.3d.webgl-engine.effects.geometry.ObjectAndLayerID")],n);export{n as ObjectAndLayerID};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import"../../../../../core/has.js";import{releaseMaybe as t,disposeMaybe as r}from"../../../../../core/maybe.js";import{watch as i,initial as s}from"../../../../../core/reactiveUtils.js";import{property as o,subclass as h}from"../../../../../core/accessorSupport/decorators.js";import{set as n}from"../../../../../core/libs/gl-matrix-2/math/vec2.js";import{InternalRenderCategory as l}from"../../../webgl.js";import a from"../../../webgl/RenderNode.js";import{HighlightApplyTechnique as g}from"./HighlightApplyTechnique.js";import{H as u}from"../../../../../chunks/HighlightBlur.glsl.js";import{HighlightBlurTechnique as c}from"./HighlightBlurTechnique.js";import{H as m,g as d}from"../../../../../chunks/HighlightDownsample.glsl.js";import{HighlightDownsampleTechnique as p}from"./HighlightDownsampleTechnique.js";import{HighlightPassParameters as f}from"./HighlightPassParameters.js";import{HighlightToSingleTechnique as b}from"./HighlightToSingleTechnique.js";import{NoVertex as w}from"../../lib/DefaultVertexBufferLayouts.js";import{VertexArrayObject as x}from"../../lib/VertexArrayObject.js";import{BufferObject as T}from"../../../../webgl/BufferObject.js";import{ColorAttachment0 as C,PrimitiveType as _,DataType as v}from"../../../../webgl/enums.js";import O from"../../../../webgl/Texture.js";import{TextureDescriptor as j}from"../../../../webgl/TextureDescriptor.js";import{VertexBuffer as H}from"../../../../webgl/VertexBuffer.js";let P=class extends a{constructor(){super(...arguments),this.produces=l.HIGHLIGHT_COLOR,this.consumes={required:[l.HIGHLIGHT_COLOR,"highlights"]},this._downsampleDrawParameters=new m,this._passParameters=new f,this._highlightBlurDrawParameters=new u,this._grid=new q}initialize(){this.addHandles([i(()=>this._updateOptionsTexture(),()=>{},s)])}destroy(){this._grid.coverage=t(this._grid.coverage),this._grid.vao=r(this._grid.vao),this._passParameters.highlightOptionsTexture=t(this._passParameters.highlightOptionsTexture)}_updateOptionsTexture(){if(null==this._passParameters.highlightOptionsTexture){const e=new j(16,2);e.internalFormat=6408,e.samplingMode=9728,this._passParameters.highlightOptionsTexture=new O(this.renderingContext,e,null)}this._passParameters.highlightOptionsTexture.setData(D(this.view.state.highlights)),this.requestRender(1)}render(e){const t=e.find(({name:e})=>e===l.HIGHLIGHT_COLOR),{techniques:r,bindParameters:i,fboCache:s,_passParameters:o,renderingContext:h}=this;if(!i.decorations)return t;const a=r.getCompiled(p),u=r.getCompiled(b),m=r.getCompiled(c),d=r.getCompiled(g);if(!(a&&d&&m&&u))return this.requestRender(1),t;const f=e.find(({name:e})=>"highlights"===e).getTexture();o.highlightTexture=f;const w=this._prepareAndDownSample(f),{width:x,height:T}=f.descriptor;o.highlightTexture=f;const{camera:_}=i,{fullWidth:v,fullHeight:O,pixelRatio:j,fullViewport:H}=_,P=Math.ceil(v/j),q=Math.ceil(O/j),{_highlightBlurDrawParameters:D}=this,y=this.view.stage.renderView.renderer,{highlights:I}=i;for(let l=0;l<I.length;++l){const{name:e}=I[l];if(!y.hasHighlight(e))continue;o.highlightLevel=l,h.setClearColor(0,0,0,0);const r=s.acquire(x,T,"single highlight",2);h.bindFramebuffer(r.fbo),h.setViewport(0,0,x,T),h.clear(16384),h.bindTechnique(u,i,o),this._renderGrid(w),D.blurInput=r.getTexture(),n(D.blurSize,1/P,0);const a=s.acquire(P,q,"single highlight blur",2);h.unbindTexture(a.fbo?.colorTexture),h.bindFramebuffer(a.fbo),h.setViewport(0,0,P,q),h.clear(16384),h.bindTechnique(m,i,o,D),this._renderGrid(w),r.release(),n(D.blurSize,0,1/q),o.highlightBlurTexture=a.getTexture(),h.bindFramebuffer(t.fbo),h.setDrawBuffers([C]),h.setViewport4fv(H),h.bindTechnique(d,i,o,D),this._renderGrid(w),a.release()}return o.coverageTexture=o.highlightTexture=null,t}_prepareAndDownSample(e){this._gridUpdateResources(e);const t=this.techniques.get(p),r=this._gridComputeCoverage(t,e),{horizontalCellCount:i,verticalCellCount:s}=r,o=this._passParameters;return o.horizontalCellCount=i,o.verticalCellCount=s,o.coverageTexture=r.coverage?.getTexture(),r}_renderGrid(e){const t=e.verticalCellCount*e.horizontalCellCount;this.renderingContext.bindVAO(e.vao),this.renderingContext.drawElementsInstanced(_.TRIANGLES,6,v.UNSIGNED_BYTE,0,t)}_gridUpdateResources(e){const t=this._grid,{width:r,height:i}=e.descriptor;if(t.horizontalCellCount=Math.ceil(r/d),t.verticalCellCount=Math.ceil(i/d),t.vao)return;const s=this.renderingContext,o=T.createIndex(s,35044,R);t.vao=new x(s,new H(s,w),o)}_gridComputeCoverage(e,t){const r=this.renderingContext,i=this._grid,s=t.descriptor,o=Math.ceil(s.width/d),h=Math.ceil(s.height/d);this._downsampleDrawParameters.input=t;const{highlights:n}=this.bindParameters;i.coverage?.release();const l=this.fboCache.acquire(o,h,"highlight coverage",n.length>L?3:1);return i.coverage=l,r.bindFramebuffer(l.fbo),r.bindTechnique(e,this.bindParameters,this._passParameters,this._downsampleDrawParameters),r.setViewport(0,0,o,h),r.screen.draw(),i}get test(){}};e([o()],P.prototype,"produces",void 0),e([o()],P.prototype,"consumes",void 0),P=e([h("esri.views.3d.webgl-engine.effects.highlight.Highlight")],P);class q{constructor(){this.coverage=null,this.vao=null,this.verticalCellCount=0,this.horizontalCellCount=0,this.viewportWidth=0,this.viewportHeight=0}}function D(e){const t=new Uint8Array(128);let r=0;for(const i of e){const e=4*r,s=4*r+64;++r;const{color:o}=i,h=i.haloColor??o;t[e+0]=o.r,t[e+1]=o.g,t[e+2]=o.b,t[e+3]=i.fillOpacity*o.a*255,t[s+0]=h.r,t[s+1]=h.g,t[s+2]=h.b,t[s+3]=i.haloOpacity*h.a*255}return t}let y=0;function I(e){let t=0;for(const i of e){const{name:e}=i;t+=e.length;const{color:r,fillOpacity:s,haloColor:o,haloOpacity:h}=i;t+=r.r+r.g+r.b+r.a+s,t+=o?o.r+o.g+o.b+o.a+h:0}const r=e.at(0);if(r){const{shadowOpacity:e,shadowDifference:i,shadowColor:s}=r;t+=e+i+s.r+s.g+s.b+s.a}return y+++(t>=0?0:1)}const R=new Uint8Array([0,1,2,2,1,3]);function G(e,t,r,i,s,o,h=0){const{highlights:l}=s,a=l.length>1?t.acquire(r,i,"highlight mix",l.length>L?3:1):null,{gl:g}=e;if(a){const t=e.boundFramebuffer;e.bindFramebuffer(a.fbo),g.clearBufferuiv(g.COLOR,0,[0,0,0,0]),e.bindFramebuffer(t)}const u=a?.getTexture();s.highlightMixTexture=u,n(s.highlightMixOrigin,h,0),l.forEach((t,n)=>{if(n>0){const t=O.TEXTURE_UNIT_FOR_UPDATES;e.bindTexture(u,t),e.setActiveTexture(t),g.copyTexSubImage2D(3553,0,0,0,h,0,r,i),e.bindTexture(null,t)}e.clear(256),s.highlightLevel=n,o()}),s.highlightLevel=null,s.highlightMixTexture=null,a?.release()}const L=4;export{P as Highlight,L as maxHighlightsPerChannel,G as renderHighlightBuffer,I as trackHighlightOptions};
2
+ import{__decorate as e}from"tslib";import"../../../../../core/has.js";import{releaseMaybe as t,disposeMaybe as r}from"../../../../../core/maybe.js";import{watch as i,initial as s}from"../../../../../core/reactiveUtils.js";import{property as o,subclass as h}from"../../../../../core/accessorSupport/decorators.js";import{set as n}from"../../../../../core/libs/gl-matrix-2/math/vec2.js";import{InternalRenderCategory as l}from"../../../webgl.js";import a from"../../../webgl/RenderNode.js";import{HighlightApplyTechnique as g}from"./HighlightApplyTechnique.js";import{H as u}from"../../../../../chunks/HighlightBlur.glsl.js";import{HighlightBlurTechnique as c}from"./HighlightBlurTechnique.js";import{H as m,g as d}from"../../../../../chunks/HighlightDownsample.glsl.js";import{HighlightDownsampleTechnique as p}from"./HighlightDownsampleTechnique.js";import{HighlightPassParameters as f}from"./HighlightPassParameters.js";import{HighlightToSingleTechnique as b}from"./HighlightToSingleTechnique.js";import{NoVertex as w}from"../../lib/DefaultVertexBufferLayouts.js";import{VertexArrayObject as x}from"../../lib/VertexArrayObject.js";import{BufferObject as T}from"../../../../webgl/BufferObject.js";import{ColorAttachment0 as C,PrimitiveType as _,DataType as v}from"../../../../webgl/enums.js";import O from"../../../../webgl/Texture.js";import{TextureDescriptor as j}from"../../../../webgl/TextureDescriptor.js";import{VertexBuffer as H}from"../../../../webgl/VertexBuffer.js";let P=class extends a{constructor(){super(...arguments),this.consumes={required:[l.HIGHLIGHT_COLOR,"highlights"]},this.produces=l.HIGHLIGHT_COLOR,this._downsampleDrawParameters=new m,this._passParameters=new f,this._highlightBlurDrawParameters=new u,this._grid=new q}initialize(){this.addHandles([i(()=>this._updateOptionsTexture(),()=>{},s)])}destroy(){this._grid.coverage=t(this._grid.coverage),this._grid.vao=r(this._grid.vao),this._passParameters.highlightOptionsTexture=t(this._passParameters.highlightOptionsTexture)}_updateOptionsTexture(){if(null==this._passParameters.highlightOptionsTexture){const e=new j(16,2);e.internalFormat=6408,e.samplingMode=9728,this._passParameters.highlightOptionsTexture=new O(this.renderingContext,e,null)}this._passParameters.highlightOptionsTexture.setData(D(this.view.state.highlights)),this.requestRender(1)}render(e){const t=e.find(({name:e})=>e===l.HIGHLIGHT_COLOR),{techniques:r,bindParameters:i,fboCache:s,_passParameters:o,renderingContext:h}=this;if(!i.decorations)return t;const a=r.getCompiled(p),u=r.getCompiled(b),m=r.getCompiled(c),d=r.getCompiled(g);if(!(a&&d&&m&&u))return this.requestRender(1),t;const f=e.find(({name:e})=>"highlights"===e).getTexture();o.highlightTexture=f;const w=this._prepareAndDownSample(f),{width:x,height:T}=f.descriptor;o.highlightTexture=f;const{camera:_}=i,{fullWidth:v,fullHeight:O,pixelRatio:j,fullViewport:H}=_,P=Math.ceil(v/j),q=Math.ceil(O/j),{_highlightBlurDrawParameters:D}=this,y=this.view.stage.renderView.renderer,{highlights:I}=i;for(let l=0;l<I.length;++l){const{name:e}=I[l];if(!y.hasHighlight(e))continue;o.highlightLevel=l,h.setClearColor(0,0,0,0);const r=s.acquire(x,T,"single highlight",2);h.bindFramebuffer(r.fbo),h.setViewport(0,0,x,T),h.clear(16384),h.bindTechnique(u,i,o),this._renderGrid(w),D.blurInput=r.getTexture(),n(D.blurSize,1/P,0);const a=s.acquire(P,q,"single highlight blur",2);h.unbindTexture(a.fbo?.colorTexture),h.bindFramebuffer(a.fbo),h.setViewport(0,0,P,q),h.clear(16384),h.bindTechnique(m,i,o,D),this._renderGrid(w),r.release(),n(D.blurSize,0,1/q),o.highlightBlurTexture=a.getTexture(),h.bindFramebuffer(t.fbo),h.setDrawBuffers([C]),h.setViewport4fv(H),h.bindTechnique(d,i,o,D),this._renderGrid(w),a.release()}return o.coverageTexture=o.highlightTexture=null,t}_prepareAndDownSample(e){this._gridUpdateResources(e);const t=this.techniques.get(p),r=this._gridComputeCoverage(t,e),{horizontalCellCount:i,verticalCellCount:s}=r,o=this._passParameters;return o.horizontalCellCount=i,o.verticalCellCount=s,o.coverageTexture=r.coverage?.getTexture(),r}_renderGrid(e){const t=e.verticalCellCount*e.horizontalCellCount;this.renderingContext.bindVAO(e.vao),this.renderingContext.drawElementsInstanced(_.TRIANGLES,6,v.UNSIGNED_BYTE,0,t)}_gridUpdateResources(e){const t=this._grid,{width:r,height:i}=e.descriptor;if(t.horizontalCellCount=Math.ceil(r/d),t.verticalCellCount=Math.ceil(i/d),t.vao)return;const s=this.renderingContext,o=T.createIndex(s,35044,R);t.vao=new x(s,new H(s,w),o)}_gridComputeCoverage(e,t){const r=this.renderingContext,i=this._grid,s=t.descriptor,o=Math.ceil(s.width/d),h=Math.ceil(s.height/d);this._downsampleDrawParameters.input=t;const{highlights:n}=this.bindParameters;i.coverage?.release();const l=this.fboCache.acquire(o,h,"highlight coverage",n.length>L?3:1);return i.coverage=l,r.bindFramebuffer(l.fbo),r.bindTechnique(e,this.bindParameters,this._passParameters,this._downsampleDrawParameters),r.setViewport(0,0,o,h),r.screen.draw(),i}get test(){}};e([o()],P.prototype,"consumes",void 0),e([o()],P.prototype,"produces",void 0),P=e([h("esri.views.3d.webgl-engine.effects.highlight.Highlight")],P);class q{constructor(){this.coverage=null,this.vao=null,this.verticalCellCount=0,this.horizontalCellCount=0,this.viewportWidth=0,this.viewportHeight=0}}function D(e){const t=new Uint8Array(128);let r=0;for(const i of e){const e=4*r,s=4*r+64;++r;const{color:o}=i,h=i.haloColor??o;t[e+0]=o.r,t[e+1]=o.g,t[e+2]=o.b,t[e+3]=i.fillOpacity*o.a*255,t[s+0]=h.r,t[s+1]=h.g,t[s+2]=h.b,t[s+3]=i.haloOpacity*h.a*255}return t}let y=0;function I(e){let t=0;for(const i of e){const{name:e}=i;t+=e.length;const{color:r,fillOpacity:s,haloColor:o,haloOpacity:h}=i;t+=r.r+r.g+r.b+r.a+s,t+=o?o.r+o.g+o.b+o.a+h:0}const r=e.at(0);if(r){const{shadowOpacity:e,shadowDifference:i,shadowColor:s}=r;t+=e+i+s.r+s.g+s.b+s.a}return y+++(t>=0?0:1)}const R=new Uint8Array([0,1,2,2,1,3]);function G(e,t,r,i,s,o,h=0){const{highlights:l}=s,a=l.length>1?t.acquire(r,i,"highlight mix",l.length>L?3:1):null,{gl:g}=e;if(a){const t=e.boundFramebuffer;e.bindFramebuffer(a.fbo),g.clearBufferuiv(g.COLOR,0,[0,0,0,0]),e.bindFramebuffer(t)}const u=a?.getTexture();s.highlightMixTexture=u,n(s.highlightMixOrigin,h,0),l.forEach((t,n)=>{if(n>0){const t=O.TEXTURE_UNIT_FOR_UPDATES;e.bindTexture(u,t),e.setActiveTexture(t),g.copyTexSubImage2D(3553,0,0,0,h,0,r,i),e.bindTexture(null,t)}e.clear(256),s.highlightLevel=n,o()}),s.highlightLevel=null,s.highlightMixTexture=null,a?.release()}const L=4;export{P as Highlight,L as maxHighlightsPerChannel,G as renderHighlightBuffer,I as trackHighlightOptions};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import{smoothstep as t,clamp as s}from"../../../../../core/mathUtils.js";import{watch as i,syncAndInitial as a}from"../../../../../core/reactiveUtils.js";import{property as r,subclass as o}from"../../../../../core/accessorSupport/decorators.js";import{normalize as h,set as c,dot as n}from"../../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as d}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{RenderNodeOutput as p}from"../../../webgl.js";import m from"../../../webgl/RenderNode.js";import{ShadowHighlightPassParameters as l,ShadowHighlightTechnique as u}from"./ShadowHighlightTechnique.js";import{defaultShadowOpacity as g,defaultShadowDifference as f,defaultShadowColor as w}from"../../../../support/HighlightDefaults.js";import{ColorAttachment0 as _}from"../../../../webgl/enums.js";const O=1/512,y=4e4,P=5e4;let x=class extends m{constructor(e){super(e),this.produces=p.COMPOSITE,this.consumes={required:[p.COMPOSITE,"highlights"]},this._passParameters=new l,this._maxOpacity=1,this._shadowDifference=.2}initialize(){this.addHandles([i(()=>this.view.defaultHighlight?.shadowOpacity,e=>{this._passParameters.shadowOpacity=e??g,this._updateOccludedShadowOpacity(),this._ensureMaxOpacity()},a),i(()=>this.view.defaultHighlight?.shadowDifference,e=>{this._shadowDifference=e??f,this._updateOccludedShadowOpacity(),this._ensureMaxOpacity()},a),i(()=>this.view.defaultHighlight?.shadowColor,e=>{this._passParameters.shadowColor=(e??w).toUnitRGBA(),this._ensureMaxOpacity()},a)])}_updateOccludedShadowOpacity(){this._passParameters.occludedShadowOpacity=this._passParameters.shadowOpacity*(1-this._shadowDifference)}_ensureMaxOpacity(){const e=Math.max(this._passParameters.shadowOpacity,this._passParameters.occludedShadowOpacity);this._maxOpacity=e*this._passParameters.shadowColor[3],this.requestRender(1)}render(e){const t=e.find(({name:e})=>e===p.COMPOSITE),s=this.bindParameters;if(!this._ensureIfVisible())return t;const i=this.techniques.getCompiled(u);if(!i)return this.requestRender(1),t;this._passParameters.highlightTexture=e.find(({name:e})=>"highlights"===e)?.getTexture(),this._passParameters.origin=s.camera.center;const a=this.renderingContext,r=t.obtainDepthTexture();return a.bindFramebuffer(t.fbo),a.setDrawBuffers([_]),a.bindTechnique(i,s,this._passParameters),a.screen.draw(),t.attachDepth(r),r?.release(),t}_ensureIfVisible(){const e=this.bindParameters;if(!e.hasShadowHighlights||!e.mainDepth||!e.shadowHighlight?.getTexture())return!1;const{camera:i,lighting:a}=e;this._passParameters.opacityElevation=1-t(y,P,i.relativeElevation);const r=1===this.viewingMode?h(b,i.center):c(b,0,0,1),o=n(r,a.mainLight.direction);return this._passParameters.dayNightTerminator=t(0,1,s(30*o,0,1)),this._maxOpacity*this._passParameters.opacityElevation*this._passParameters.dayNightTerminator>=O}};e([r()],x.prototype,"produces",void 0),e([r()],x.prototype,"consumes",void 0),e([r({constructOnly:!0})],x.prototype,"viewingMode",void 0),x=e([o("esri.views.3d.webgl-engine.effects.highlight.ShadowHighlight")],x);const b=d();export{x as ShadowHighlight};
2
+ import{__decorate as e}from"tslib";import{smoothstep as t,clamp as s}from"../../../../../core/mathUtils.js";import{watch as i,syncAndInitial as a}from"../../../../../core/reactiveUtils.js";import{property as r,subclass as o}from"../../../../../core/accessorSupport/decorators.js";import{normalize as h,set as c,dot as n}from"../../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as d}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{RenderNodeOutput as p}from"../../../webgl.js";import m from"../../../webgl/RenderNode.js";import{ShadowHighlightPassParameters as l,ShadowHighlightTechnique as u}from"./ShadowHighlightTechnique.js";import{defaultShadowOpacity as g,defaultShadowDifference as f,defaultShadowColor as w}from"../../../../support/HighlightDefaults.js";import{ColorAttachment0 as _}from"../../../../webgl/enums.js";const O=1/512,y=4e4,P=5e4;let x=class extends m{constructor(e){super(e),this.consumes={required:[p.COMPOSITE,"highlights"]},this.produces=p.COMPOSITE,this._passParameters=new l,this._maxOpacity=1,this._shadowDifference=.2}initialize(){this.addHandles([i(()=>this.view.defaultHighlight?.shadowOpacity,e=>{this._passParameters.shadowOpacity=e??g,this._updateOccludedShadowOpacity(),this._ensureMaxOpacity()},a),i(()=>this.view.defaultHighlight?.shadowDifference,e=>{this._shadowDifference=e??f,this._updateOccludedShadowOpacity(),this._ensureMaxOpacity()},a),i(()=>this.view.defaultHighlight?.shadowColor,e=>{this._passParameters.shadowColor=(e??w).toUnitRGBA(),this._ensureMaxOpacity()},a)])}_updateOccludedShadowOpacity(){this._passParameters.occludedShadowOpacity=this._passParameters.shadowOpacity*(1-this._shadowDifference)}_ensureMaxOpacity(){const e=Math.max(this._passParameters.shadowOpacity,this._passParameters.occludedShadowOpacity);this._maxOpacity=e*this._passParameters.shadowColor[3],this.requestRender(1)}render(e){const t=e.find(({name:e})=>e===p.COMPOSITE),s=this.bindParameters;if(!this._ensureIfVisible())return t;const i=this.techniques.getCompiled(u);if(!i)return this.requestRender(1),t;this._passParameters.highlightTexture=e.find(({name:e})=>"highlights"===e)?.getTexture(),this._passParameters.origin=s.camera.center;const a=this.renderingContext,r=t.obtainDepthTexture();return a.bindFramebuffer(t.fbo),a.setDrawBuffers([_]),a.bindTechnique(i,s,this._passParameters),a.screen.draw(),t.attachDepth(r),r?.release(),t}_ensureIfVisible(){const e=this.bindParameters;if(!e.hasShadowHighlights||!e.mainDepth||!e.shadowHighlight?.getTexture())return!1;const{camera:i,lighting:a}=e;this._passParameters.opacityElevation=1-t(y,P,i.relativeElevation);const r=1===this.viewingMode?h(b,i.center):c(b,0,0,1),o=n(r,a.mainLight.direction);return this._passParameters.dayNightTerminator=t(0,1,s(30*o,0,1)),this._maxOpacity*this._passParameters.opacityElevation*this._passParameters.dayNightTerminator>=O}};e([r()],x.prototype,"consumes",void 0),e([r()],x.prototype,"produces",void 0),e([r({constructOnly:!0})],x.prototype,"viewingMode",void 0),x=e([o("esri.views.3d.webgl-engine.effects.highlight.ShadowHighlight")],x);const b=d();export{x as ShadowHighlight};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import{property as r,subclass as t}from"../../../../../core/accessorSupport/decorators.js";import{ZEROS as s}from"../../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{InternalRenderCategory as i}from"../../../webgl.js";import o from"../../../webgl/RenderNode.js";import{ReadShadowMapOrigin as a}from"../../core/shaderLibrary/shading/calculateUVZShadow.glsl.js";import{ShadowHighlightBufferTechnique as h}from"./ShadowHighlightBufferTechnique.js";let n=class extends o{get requireGeometryDepth(){return this.bindParameters.hasShadowHighlights}constructor(e){super(e),this.produces=i.SHADOW_HIGHLIGHT,this._passParameters=new a}render(){const e=this.bindParameters,r=null!=e.depth,t=null!=e.shadowMap.getOutput(6);if(!e.hasShadowHighlights||!r&&!t)return;const o=this.techniques.getCompiled(h);if(!o)return void this.requestRender(1);const{fullWidth:a,fullHeight:n}=e.camera,c=this.fboCache.acquire(a,n,i.SHADOW_HIGHLIGHT,0);this._passParameters.origin=e.camera.center;const d=this.renderingContext;return d.bindFramebuffer(c.fbo),d.clearFramebuffer(s),d.bindTechnique(o,e,this._passParameters),d.screen.draw(),c}};e([r()],n.prototype,"produces",void 0),n=e([t("esri.views.3d.webgl-engine.effects.highlight.ShadowHighlightBuffer")],n);export{n as ShadowHighlightBuffer};
2
+ import{__decorate as e}from"tslib";import{property as r,subclass as t}from"../../../../../core/accessorSupport/decorators.js";import{ZEROS as s}from"../../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{InternalRenderCategory as i}from"../../../webgl.js";import o from"../../../webgl/RenderNode.js";import{ReadShadowMapOrigin as a}from"../../core/shaderLibrary/shading/calculateUVZShadow.glsl.js";import{ShadowHighlightBufferTechnique as h}from"./ShadowHighlightBufferTechnique.js";let n=class extends o{constructor(e){super(e),this.produces=i.SHADOW_HIGHLIGHT,this._passParameters=new a}get requireGeometryDepth(){return this.bindParameters.hasShadowHighlights}render(){const e=this.bindParameters,r=null!=e.depth,t=null!=e.shadowMap.getOutput(6);if(!e.hasShadowHighlights||!r&&!t)return;const i=this.techniques.getCompiled(h);if(!i)return void this.requestRender(1);const{fullWidth:o,fullHeight:a}=e.camera,n=this.fboCache.acquire(o,a,this.produces,0);this._passParameters.origin=e.camera.center;const c=this.renderingContext;return c.bindFramebuffer(n.fbo),c.clearFramebuffer(s),c.bindTechnique(i,e,this._passParameters),c.screen.draw(),n}};e([r()],n.prototype,"produces",void 0),n=e([t("esri.views.3d.webgl-engine.effects.highlight.ShadowHighlightBuffer")],n);export{n as ShadowHighlightBuffer};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import"../../../../../core/has.js";import{disposeMaybe as t}from"../../../../../core/maybe.js";import{property as i,subclass as r}from"../../../../../core/accessorSupport/decorators.js";import{copy as n,add as s}from"../../../../../core/libs/gl-matrix-2/math/vec3.js";import{fromRay as a,getStart as o,getEnd as l,create as h}from"../../../../../geometry/support/clipRay.js";import{intersectClipRay as c}from"../../../../../geometry/support/frustum.js";import{copy as d}from"../../../../../geometry/support/lineSegment.js";import{wrap as p}from"../../../../../geometry/support/ray.js";import{InternalRenderCategory as u}from"../../../webgl.js";import m from"../../../webgl/RenderNode.js";import{Blit as g}from"../blit/Blit.js";import{LaserlinePathData as f}from"./LaserlinePathData.js";import{LaserlinePathPassParameters as _,LaserlinePathTechnique as b}from"./LaserlinePathTechnique.js";import{LaserlinePathTechniqueConfiguration as P}from"./LaserlinePathTechniqueConfiguration.js";import{LaserlineTechnique as E}from"./LaserlineTechnique.js";import{LaserlineTechniqueConfiguration as L}from"./LaserlineTechniqueConfiguration.js";import{updateParameters as V}from"../../materials/internal/MaterialUtil.js";import{ColorAttachment0 as q}from"../../../../webgl/enums.js";let D=class extends m{get requireGeometryDepth(){return!0}constructor(e){super(e),this.isDecoration=!0,this.produces=u.LASERLINES,this.consumes={required:[u.LASERLINES,"normals"]},this._configuration=new L,this._pathTechniqueConfiguration=new P,this._intersectsLineInfinite=!1,this._pathVerticalPlaneEnabled=!1,this._passParameters=new _,this._blit=new g(e.view.stage.renderView.techniques,2)}initialize(){this._passParameters.renderCoordsHelper=this.view.renderCoordsHelper,this._configuration.spherical=1===this.view.state.viewingMode,this._configuration.contrastControlEnabled=this.contrastControlEnabled,this._pathTechniqueConfiguration.spherical=1===this.view.state.viewingMode,this._pathTechniqueConfiguration.contrastControlEnabled=this.contrastControlEnabled}destroy(){this._pathVerticalPlaneData=t(this._pathVerticalPlaneData)}get heightManifoldEnabled(){return this._configuration.heightManifoldEnabled}set heightManifoldEnabled(e){this._configuration.heightManifoldEnabled!==e&&(this._configuration.heightManifoldEnabled=e,this.requestRender(1))}get heightManifoldTarget(){return this._passParameters.heightManifoldTarget}set heightManifoldTarget(e){n(this._passParameters.heightManifoldTarget,e),this.requestRender(1)}get pointDistanceEnabled(){return this._configuration.pointDistanceEnabled}set pointDistanceEnabled(e){e!==this._configuration.pointDistanceEnabled&&(this._configuration.pointDistanceEnabled=e,this.requestRender(1))}get pointDistanceTarget(){return this._passParameters.pointDistanceTarget}set pointDistanceTarget(e){n(this._passParameters.pointDistanceTarget,e),this.requestRender(1)}get pointDistanceOrigin(){return this._passParameters.pointDistanceOrigin}set pointDistanceOrigin(e){n(this._passParameters.pointDistanceOrigin,e),this.requestRender(1)}get lineVerticalPlaneEnabled(){return this._configuration.lineVerticalPlaneEnabled}set lineVerticalPlaneEnabled(e){e!==this._configuration.lineVerticalPlaneEnabled&&(this._configuration.lineVerticalPlaneEnabled=e,this.requestRender(1))}get lineVerticalPlaneSegment(){return this._passParameters.lineVerticalPlaneSegment}set lineVerticalPlaneSegment(e){d(e,this._passParameters.lineVerticalPlaneSegment),this.requestRender(1)}get intersectsLineEnabled(){return this._configuration.intersectsLineEnabled}set intersectsLineEnabled(e){e!==this._configuration.intersectsLineEnabled&&(this._configuration.intersectsLineEnabled=e,this.requestRender(1))}get intersectsLineSegment(){return this._passParameters.intersectsLineSegment}set intersectsLineSegment(e){d(e,this._passParameters.intersectsLineSegment),this.requestRender(1)}get intersectsLineInfinite(){return this._intersectsLineInfinite}set intersectsLineInfinite(e){e!==this._intersectsLineInfinite&&(this._intersectsLineInfinite=e,this.requestRender(1))}get pathVerticalPlaneEnabled(){return this._pathVerticalPlaneEnabled}set pathVerticalPlaneEnabled(e){e!==this._pathVerticalPlaneEnabled&&(this._pathVerticalPlaneEnabled=e,null!=this._pathVerticalPlaneData&&this.requestRender(1))}set pathVerticalPlaneVertices(e){null==this._pathVerticalPlaneData&&(this._pathVerticalPlaneData=new f(this._passParameters.renderCoordsHelper)),this._pathVerticalPlaneData.vertices=e,this.pathVerticalPlaneEnabled&&this.requestRender(1)}set pathVerticalPlaneBuffers(e){null==this._pathVerticalPlaneData&&(this._pathVerticalPlaneData=new f(this._passParameters.renderCoordsHelper)),this._pathVerticalPlaneData.buffers=e,this.pathVerticalPlaneEnabled&&this.requestRender(1)}setParameters(e){V(this._passParameters,e)&&this.requestRender(1)}precompile(){this.techniques.precompile(E,this._configuration),this.contrastControlEnabled&&this._blit.precompile(),this.pathVerticalPlaneEnabled&&this._pathVerticalPlaneData&&this.techniques.precompile(b,this._pathTechniqueConfiguration)}render(e){const t=this.input;if(this.isDecoration&&!this.bindParameters.decorations)return t;const i=this.renderingContext,r=e.find(({name:e})=>"normals"===e);if(this._passParameters.normals=r?.getTexture(),!this.contrastControlEnabled)return i.bindFramebuffer(t.fbo),this._renderLaserLines(),t;this._passParameters.colors=t.getTexture();const n=this.fboCache.acquire(t.fbo.width,t.fbo.height,"laser lines");return i.bindFramebuffer(n.fbo),i.setClearColor(0,0,0,0),i.clear(16640),this._renderLaserLines(),i.unbindTexture(t.getTexture()),this._blit.blend(n,t,this.bindParameters)||this.requestRender(1),n.release(),t}_renderLaserLines(){(this.heightManifoldEnabled||this.pointDistanceEnabled||this.lineVerticalPlaneSegment||this.intersectsLineEnabled)&&this._renderUnified(),this.pathVerticalPlaneEnabled&&this._renderPath()}_renderUnified(){if(!this._updatePassParameters())return;const e=this.techniques.getCompiled(E,this._configuration);if(e){const t=this.renderingContext;t.setDrawBuffers([q]),t.bindTechnique(e,this.bindParameters,this._passParameters),t.screen.draw()}else this.requestRender(1)}_renderPath(){if(null==this._pathVerticalPlaneData)return;const e=this.techniques.get(b,this._pathTechniqueConfiguration);if(e.compiled){const t=this.renderingContext;this._passParameters.origin=this._pathVerticalPlaneData.origin,t.setDrawBuffers([q]),t.bindTechnique(e,this.bindParameters,this._passParameters),this._pathVerticalPlaneData.draw(t)}else this.requestRender(1)}_updatePassParameters(){if(!this.intersectsLineEnabled)return!0;const e=this.bindParameters.camera,t=this._passParameters;if(this._intersectsLineInfinite){if(a(p(t.intersectsLineSegment.origin,t.intersectsLineSegment.vector),C),C.c0=-Number.MAX_VALUE,!c(e.frustum,C))return!1;o(C,t.lineStartWorld),l(C,t.lineEndWorld)}else n(t.lineStartWorld,t.intersectsLineSegment.origin),s(t.lineEndWorld,t.intersectsLineSegment.origin,t.intersectsLineSegment.vector);return!0}get test(){}};e([i({constructOnly:!0})],D.prototype,"contrastControlEnabled",void 0),e([i()],D.prototype,"isDecoration",void 0),e([i()],D.prototype,"produces",void 0),e([i()],D.prototype,"consumes",void 0),D=e([r("esri.views.3d.webgl-engine.effects.laserlines.LaserLineRenderer")],D);const C=h();export{D as LaserLineRenderer};
2
+ import{__decorate as e}from"tslib";import"../../../../../core/has.js";import{disposeMaybe as t}from"../../../../../core/maybe.js";import{property as i,subclass as r}from"../../../../../core/accessorSupport/decorators.js";import{copy as n,add as s}from"../../../../../core/libs/gl-matrix-2/math/vec3.js";import{fromRay as a,getStart as o,getEnd as l,create as h}from"../../../../../geometry/support/clipRay.js";import{intersectClipRay as c}from"../../../../../geometry/support/frustum.js";import{copy as d}from"../../../../../geometry/support/lineSegment.js";import{wrap as p}from"../../../../../geometry/support/ray.js";import{InternalRenderCategory as u}from"../../../webgl.js";import m from"../../../webgl/RenderNode.js";import{Blit as g}from"../blit/Blit.js";import{LaserlinePathData as f}from"./LaserlinePathData.js";import{LaserlinePathPassParameters as _,LaserlinePathTechnique as b}from"./LaserlinePathTechnique.js";import{LaserlinePathTechniqueConfiguration as P}from"./LaserlinePathTechniqueConfiguration.js";import{LaserlineTechnique as E}from"./LaserlineTechnique.js";import{LaserlineTechniqueConfiguration as L}from"./LaserlineTechniqueConfiguration.js";import{updateParameters as V}from"../../materials/internal/MaterialUtil.js";import{ColorAttachment0 as q}from"../../../../webgl/enums.js";let D=class extends m{get requireGeometryDepth(){return!0}constructor(e){super(e),this.isDecoration=!0,this.consumes={required:[u.LASERLINES,"normals"]},this.produces=u.LASERLINES,this._configuration=new L,this._pathTechniqueConfiguration=new P,this._intersectsLineInfinite=!1,this._pathVerticalPlaneEnabled=!1,this._passParameters=new _,this._blit=new g(e.view.stage.renderView.techniques,2)}initialize(){this._passParameters.renderCoordsHelper=this.view.renderCoordsHelper,this._configuration.spherical=1===this.view.state.viewingMode,this._configuration.contrastControlEnabled=this.contrastControlEnabled,this._pathTechniqueConfiguration.spherical=1===this.view.state.viewingMode,this._pathTechniqueConfiguration.contrastControlEnabled=this.contrastControlEnabled}destroy(){this._pathVerticalPlaneData=t(this._pathVerticalPlaneData)}get heightManifoldEnabled(){return this._configuration.heightManifoldEnabled}set heightManifoldEnabled(e){this._configuration.heightManifoldEnabled!==e&&(this._configuration.heightManifoldEnabled=e,this.requestRender(1))}get heightManifoldTarget(){return this._passParameters.heightManifoldTarget}set heightManifoldTarget(e){n(this._passParameters.heightManifoldTarget,e),this.requestRender(1)}get pointDistanceEnabled(){return this._configuration.pointDistanceEnabled}set pointDistanceEnabled(e){e!==this._configuration.pointDistanceEnabled&&(this._configuration.pointDistanceEnabled=e,this.requestRender(1))}get pointDistanceTarget(){return this._passParameters.pointDistanceTarget}set pointDistanceTarget(e){n(this._passParameters.pointDistanceTarget,e),this.requestRender(1)}get pointDistanceOrigin(){return this._passParameters.pointDistanceOrigin}set pointDistanceOrigin(e){n(this._passParameters.pointDistanceOrigin,e),this.requestRender(1)}get lineVerticalPlaneEnabled(){return this._configuration.lineVerticalPlaneEnabled}set lineVerticalPlaneEnabled(e){e!==this._configuration.lineVerticalPlaneEnabled&&(this._configuration.lineVerticalPlaneEnabled=e,this.requestRender(1))}get lineVerticalPlaneSegment(){return this._passParameters.lineVerticalPlaneSegment}set lineVerticalPlaneSegment(e){d(e,this._passParameters.lineVerticalPlaneSegment),this.requestRender(1)}get intersectsLineEnabled(){return this._configuration.intersectsLineEnabled}set intersectsLineEnabled(e){e!==this._configuration.intersectsLineEnabled&&(this._configuration.intersectsLineEnabled=e,this.requestRender(1))}get intersectsLineSegment(){return this._passParameters.intersectsLineSegment}set intersectsLineSegment(e){d(e,this._passParameters.intersectsLineSegment),this.requestRender(1)}get intersectsLineInfinite(){return this._intersectsLineInfinite}set intersectsLineInfinite(e){e!==this._intersectsLineInfinite&&(this._intersectsLineInfinite=e,this.requestRender(1))}get pathVerticalPlaneEnabled(){return this._pathVerticalPlaneEnabled}set pathVerticalPlaneEnabled(e){e!==this._pathVerticalPlaneEnabled&&(this._pathVerticalPlaneEnabled=e,null!=this._pathVerticalPlaneData&&this.requestRender(1))}set pathVerticalPlaneVertices(e){null==this._pathVerticalPlaneData&&(this._pathVerticalPlaneData=new f(this._passParameters.renderCoordsHelper)),this._pathVerticalPlaneData.vertices=e,this.pathVerticalPlaneEnabled&&this.requestRender(1)}set pathVerticalPlaneBuffers(e){null==this._pathVerticalPlaneData&&(this._pathVerticalPlaneData=new f(this._passParameters.renderCoordsHelper)),this._pathVerticalPlaneData.buffers=e,this.pathVerticalPlaneEnabled&&this.requestRender(1)}setParameters(e){V(this._passParameters,e)&&this.requestRender(1)}precompile(){this.techniques.precompile(E,this._configuration),this.contrastControlEnabled&&this._blit.precompile(),this.pathVerticalPlaneEnabled&&this._pathVerticalPlaneData&&this.techniques.precompile(b,this._pathTechniqueConfiguration)}render(e){const t=this.input;if(this.isDecoration&&!this.bindParameters.decorations)return t;const i=this.renderingContext,r=e.find(({name:e})=>"normals"===e);if(this._passParameters.normals=r?.getTexture(),!this.contrastControlEnabled)return i.bindFramebuffer(t.fbo),this._renderLaserLines(),t;this._passParameters.colors=t.getTexture();const n=this.fboCache.acquire(t.fbo.width,t.fbo.height,"laser lines");return i.bindFramebuffer(n.fbo),i.setClearColor(0,0,0,0),i.clear(16640),this._renderLaserLines(),i.unbindTexture(t.getTexture()),this._blit.blend(n,t,this.bindParameters)||this.requestRender(1),n.release(),t}_renderLaserLines(){(this.heightManifoldEnabled||this.pointDistanceEnabled||this.lineVerticalPlaneSegment||this.intersectsLineEnabled)&&this._renderUnified(),this.pathVerticalPlaneEnabled&&this._renderPath()}_renderUnified(){if(!this._updatePassParameters())return;const e=this.techniques.getCompiled(E,this._configuration);if(e){const t=this.renderingContext;t.setDrawBuffers([q]),t.bindTechnique(e,this.bindParameters,this._passParameters),t.screen.draw()}else this.requestRender(1)}_renderPath(){if(null==this._pathVerticalPlaneData)return;const e=this.techniques.get(b,this._pathTechniqueConfiguration);if(e.compiled){const t=this.renderingContext;this._passParameters.origin=this._pathVerticalPlaneData.origin,t.setDrawBuffers([q]),t.bindTechnique(e,this.bindParameters,this._passParameters),this._pathVerticalPlaneData.draw(t)}else this.requestRender(1)}_updatePassParameters(){if(!this.intersectsLineEnabled)return!0;const e=this.bindParameters.camera,t=this._passParameters;if(this._intersectsLineInfinite){if(a(p(t.intersectsLineSegment.origin,t.intersectsLineSegment.vector),C),C.c0=-Number.MAX_VALUE,!c(e.frustum,C))return!1;o(C,t.lineStartWorld),l(C,t.lineEndWorld)}else n(t.lineStartWorld,t.intersectsLineSegment.origin),s(t.lineEndWorld,t.intersectsLineSegment.origin,t.intersectsLineSegment.vector);return!0}get test(){}};e([i({constructOnly:!0})],D.prototype,"contrastControlEnabled",void 0),e([i()],D.prototype,"isDecoration",void 0),e([i()],D.prototype,"consumes",void 0),e([i()],D.prototype,"produces",void 0),D=e([r("esri.views.3d.webgl-engine.effects.laserlines.LaserLineRenderer")],D);const C=h();export{D as LaserLineRenderer};