@arcgis/core 4.31.0-next.20240606 → 4.31.0-next.20240607

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 (34) hide show
  1. package/assets/esri/core/workers/RemoteClient.js +1 -1
  2. package/assets/esri/core/workers/chunks/{24a02d266749a77c8ae1.js → 7866b86ebe02adf5e874.js} +17 -17
  3. package/chunks/ColorMaterial.glsl.js +1 -1
  4. package/chunks/ComponentShader.glsl.js +1 -1
  5. package/chunks/DefaultMaterial.glsl.js +1 -1
  6. package/chunks/HUDMaterial.glsl.js +32 -32
  7. package/chunks/ImageMaterial.glsl.js +1 -1
  8. package/chunks/LineMarker.glsl.js +1 -1
  9. package/chunks/NativeLine.glsl.js +1 -1
  10. package/chunks/OITCompositing.glsl.js +12 -9
  11. package/chunks/Pattern.glsl.js +1 -1
  12. package/chunks/RealisticTree.glsl.js +1 -1
  13. package/chunks/RibbonLine.glsl.js +1 -1
  14. package/chunks/ShadedColorMaterial.glsl.js +1 -1
  15. package/chunks/WaterSurface.glsl.js +1 -1
  16. package/package.json +1 -1
  17. package/support/revision.js +1 -1
  18. package/views/3d/layers/i3s/I3SClientMaterialUtil.js +1 -1
  19. package/views/3d/layers/i3s/I3SMaterialUtil.js +1 -1
  20. package/views/3d/terrain/PatchRenderData.js +1 -1
  21. package/views/3d/terrain/Tile.js +1 -1
  22. package/views/3d/terrain/TileAgent.js +1 -1
  23. package/views/3d/terrain/TileRenderer.js +1 -1
  24. package/views/3d/terrain/terrainUtils.js +1 -1
  25. package/views/3d/terrain/tileUtils.js +1 -1
  26. package/views/3d/webgl-engine/collections/Component/ElevationAgnosticBVH.js +1 -1
  27. package/views/3d/webgl-engine/collections/Component/Material/ComponentMaterial.js +1 -1
  28. package/views/3d/webgl-engine/core/shaderLibrary/util/AlphaCutoff.js +1 -1
  29. package/views/3d/webgl-engine/core/shaderLibrary/util/DiscardOrAdjustAlphaBlend.glsl.js +1 -1
  30. package/views/3d/webgl-engine/effects/debug/RenderNodeVisualizerNode.js +1 -1
  31. package/views/3d/webgl-engine/lib/OffscreenRendering.js +1 -1
  32. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  33. package/views/3d/webgl-engine/shaders/DefaultMaterialTechnique.js +1 -1
  34. package/views/3d/webgl-engine/shaders/OITCompositing.glsl.js +1 -1
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.31/esri/copyright.txt for details.
4
4
  */
5
- import{equals as e}from"../../../core/arrayUtils.js";import"../../../core/has.js";import{isPowerOfTwo as t}from"../../../core/mathUtils.js";import{disposeMaybe as r}from"../../../core/maybe.js";import{p as i,F as s,H as o,f as a,n,m as l,z as g,G as d}from"../../../chunks/vec32.js";import{create as h,clone as m}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{containsXY as u}from"../../../geometry/support/aaBoundingRect.js";import{earth as c}from"../../../geometry/support/Ellipsoid.js";import{glLayout as f}from"../support/buffer/glUtil.js";import{GeometryState as p}from"./GeometryState.js";import{LayerClass as y}from"./LayerClass.js";import{NeighborIndex as _}from"./NeighborIndex.js";import{PatchGeometry as x}from"./PatchGeometry.js";import{maxTileNeighborLevelDelta as v}from"./TerrainConst.js";import{enableTerrainInternalChecks as E,internalAssert as $,neighborEdgeIndices as S,oppositeEdge as C,neighborCornerIndices as D,v32s as b,lij2s as T}from"./terrainUtils.js";import{TextureFader as j,ActivationTime as A}from"./TextureFader.js";import{isEdgeNeighbor as V}from"./Tile.js";import R from"./TileOverlayData.js";import{fallsWithinLayer as w}from"./tileUtils.js";import{VertexArrayObject as L}from"../webgl-engine/lib/VertexArrayObject.js";import{terrainVertexAttributeLocations as N}from"../webgl-engine/shaders/TerrainTechnique.js";import{BufferObject as P}from"../../webgl/BufferObject.js";import{PixelFormat as F}from"../../webgl/enums.js";class G{constructor(){this.geometry=new x,this.intersectionData=null,this.geometryState=null,this._vao=null,this._texture=null,this._textureRef=new j((()=>this.tile.surface.fadeDuration)),this.overlay=new R,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 p,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),E&&this.tile.intersectsClippingArea)for(let t=0;t<4;++t)$(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.extent;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=S[e];if(!t)return $(null==r.surface?.rootTiles||r.surface.updatingRootTiles||!r.shouldHaveNeighbor(o)),i;if(t.isLoaded){const r=t,o=r.renderData.geometryState,a=s-r.level;if($(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)}$(!t.isLeaf);let a=i;return t.forAllSubtreeOnSide(C(o),(e=>e===r||(e.isLoaded?(a=Math.max(a,2**(e.level-s)),!0):($(!e.isLeaf),!1)))),a}updateNeighborData(){const e=this.tile;if(!e.intersectsClippingArea)return;const r=e.renderData.geometryState,i=t=>(t.isLoaded||t.level===e.level)&&t?.intersectsClippingArea,s=r.edgePeerNeighbors,o=r.edgePeerNeighborSamplerVersions;for(let a=0;a<4;++a){const n=e.findNeighborTile(S[a],i),l=W(e,n),g=l?.renderData?.geometryState.samplerDataVersion??-1,d=s[a],h=l!==W(e,d),m=o[a]!==g;E&&n&&($(e.level>=n.level),$(e.level-n.level<=v)),s[a]=n,(h||m)&&(o[a]=g,this._markEdgeDirty(a));const u=r.edgeResolutions[a],c=this._calculateEdgeResolution(a,n);$(t(c)),$(c>=1),r.edgeResolutions[a]=c,u!==c&&this._markEdgeResolutionDirty(a)}for(let t=0;t<4;++t){const o=e.findNeighborTile(D[t],i);r.cornerPeerNeighbors[t]=o;const a=W(e,s[t]),n=W(e,s[(t+1)%4]),l=W(e,o);B[t]=l,B[(t+1)%4]=n,B[(t+2)%4]=e,B[(t+3)%4]=a,$(B.some((t=>t?.isLoaded||t===e)));const g=B.reduce(((e,t)=>Math.min(e,t?.level??1/0)),1/0);B.forEach(((e,t)=>{e&&e?.level>g&&(B[t]=null)})),$(B.some((t=>t?.isLoaded||t===e)));const d=r.cornerNeighborCornerTiles,h=r.cornerNeighborCornerTileSamplerVersions;for(let e=0;e<4;++e){const r=B[e],i=r?.renderData.geometryState.samplerDataVersion??-1,s=4*t+e,o=d[s]!==r,a=!o&&h[s]!==i;(o||a)&&(d[s]=r,h[s]=i,this._markCornerDirty(t))}E&&$(ee.some((r=>d[4*t+r]?.isLoaded||d[4*t+r]===e)))}E&&$(this.geometryState.edgeResolutions.every((e=>e>0)));for(let t=0;t<4;++t)B[t]=null}_updateGeometry(e){if(!this.tile.intersectsClippingArea)return;E&&$(!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||!{geometry:i}||this.wireframeChanged||this.samplerDataChanged||this.clippingAreaChanged||this.numVerticesPerSideChanged,a=0!==this.dirtyEdgeResolutions,n=s.edgeResolutions.reduce(((e,t)=>e+t+1),0),l=o||a&&n>(i?.maxEdgeVertexCount??0),g=!l&&a,d=!g&&(0!==this.dirtyEdges||a),h=!d&&0!==this.dirtyCorners;l?(this.releaseGeometry(),this._createGeometry(e)):g?t.updateEdgeElevationsAndResolutions():d||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){const i=t?F.RGBA:F.RGB;return null==this._texture||this._texture.descriptor.width===e&&this._texture.descriptor.pixelFormat===i||this.releaseTexture(),null==this._texture&&(this._texture=r(),this.tile.setMemoryDirty()),this._texture}releaseTexture(){null!=this._texture&&(this._texture.release(),this._texture=null,this.tile.setMemoryDirty())}get numVerticesPerSideChanged(){return!!(this._modifiedFlags&q)}get samplerDataChanged(){return!!(this._modifiedFlags&z)}get clippingAreaChanged(){return!!(this._modifiedFlags&J)}get wireframeChanged(){return!!(this._modifiedFlags&K)}get dirtyEdges(){return this._modifiedFlags>>Q&15}get dirtyCorners(){return this._modifiedFlags>>Y&15}get dirtyEdgeResolutions(){return this._modifiedFlags>>Z&15}_markCornerDirty(e){const t=1<<e<<Y;this._modifiedFlags|=t}_markEdgeDirty(e){const t=1<<e<<Q;this._modifiedFlags|=t,this._markCornerDirty((e+0)%4),this._markCornerDirty((e+3)%4)}_markEdgeResolutionDirty(e){const t=1<<e<<Z;this._modifiedFlags|=t,this._markEdgeDirty(e)}_markAllEdgesAndCornersDirty(){this._modifiedFlags|=15<<Y|15<<Q|15<<Z}updateGeometryState(){const t=this._getElevationInfo(),r=this.tile,i=t.samplerData?r.getElevationVerticesPerSide(t.maxTileLevel):r.getDefaultVerticesPerSide(),s=Math.max(i,5);let o=r.clippingArea;r.intersectsClippingArea&&!r.isWithinClippingArea||(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 t=this.geometry.vertexAttributes,r=this.geometry.indices,i=e.gl;this._vao=new L(e,N,{geometry:f(t.layout)},{geometry:P.createVertex(e,i.STATIC_DRAW,t.buffer)},P.createIndex(e,i.STATIC_DRAW,r)),this._hasGeometry=!0}get vao(){return this._vao}setTextureReference(e,t=A.Immediate){null!=e&&e.texture!==this._texture&&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}_getElevationInfo(){const e=this.geometryState.samplerData,t=this.tile.layerInfo[y.ELEVATION],r=t.length,i=new Array(r);let s=0,o=0,a=!1;for(let g=0;g<r;g++){const r=t[g],n=r.upsampleInfo?.tile;if(n){const t=n.layerInfo[y.ELEVATION][g].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(g,y.ELEVATION);if(w(this.tile,t.layer,!1)){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(!E)return;const e=this.tile;if(!e.isLoaded||!e.intersectsClippingArea||0===e.level)return void $(e?.isLoaded);const r=e.surface.extent;if(null!=r&&!e.intersectsExtent(r))return;const f=S.map(((t,i)=>null!=r&&(i<2?-1:1)*(e.extent[3-i]-r[3-i])<0)),p=e.level;$(0===this.dirtyCorners),$(0===this.dirtyEdges),$(0===this.dirtyEdgeResolutions),$(!this.numVerticesPerSideChanged),$(!this.samplerDataChanged),$(!this.clippingAreaChanged),$(!this.wireframeChanged);const y=D.map((t=>e.findNeighborCornerTileExact(t,(t=>!t.intersectsClippingArea||t.isLoaded||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];$(i===r,`Tile[${e.lij}].corner[${t}] out of date: cur=[${r?.lij}] exp=[${i?.lij}]`)}S.forEach(((r,y)=>{if(f[y])return;const x=e.findNeighborTile(r,(e=>(e.level===p||e?.isLoaded)&&e?.intersectsClippingArea));if(!x){const t=!e.surface.updatingRootTiles&&null!=e.surface.rootTiles&&e.surface.rootTiles.length>0&&e.shouldHaveNeighbor(r);return void $(!t)}$(x.isLoaded||x.level===e.level),$(x===this.geometryState.edgePeerNeighbors[y]);const v=p-x.level;if(!x.isLoaded)return $(!x.isLeaf),void $(0===v);const E=x.renderData;$(V(e,x,r)),$(v>=0);const S=2**v;if(v<0)return void $(!1);const C=e.renderData,D=C.geometry,j=C.localOrigin,A=D.getEdgeCount(y),R=D.numVerticesPerSide-1,w=E.geometry;if(!w)return void $(!1);const L=E.localOrigin,N=this.geometryState.edgePeerNeighbors[y];if(N?.isLoaded){const e=N.renderData;$(C.geometryState.edgePeerNeighborSamplerVersions[y]===e.geometryState.samplerDataVersion),$(this.geometryState.edgePeerNeighborSamplerVersions[y]===e.geometryState.samplerDataVersion)}const P=(y+2)%4,F=w.getEdgeCount(P),G=A-1,B=F-1;$(G*S===B,`Tile[${e.lij}]:e${y},res=${G} edgeRes mismatch with Neighbor[${x.lij}]:e${P},res=${B} (expected:${G*S})`);const W=e.extent,q=r===_.NORTH||r===_.SOUTH,z=F-1,J=z>>v,K=A-1;if(J<1)return void $(1===K);$(J===K),$(t(J));const Q=w.numVerticesPerSide-1;$(v>0||J===Math.max(Q,R));const Y=e.getNeighborEdgeStartVertexIndex(y,x);$(0<=Y&&Y<S);const Z=Y*J;$(0<=Z&&Z<=z-J);let ee=0,te=Z;D.getEdgeVertexPosition(y,O,j,0),D.getEdgeVertexPosition(y,I,j,A-1);const re=i(O,I),ie=Math.max(X,1e-4*re);for(let t=0;t<=J;++t){D.getEdgeVertexPosition(y,O,j,ee),w.getEdgeVertexPosition(P,I,L,te);const i=t/J,f=q?W[0]+i*(W[2]-W[0]):r===_.WEST?W[0]:W[2],p=q?r===_.SOUTH?W[1]:W[3]:W[1]+i*(W[3]-W[1]),v=e.surface.extent;if(null==v||u(v,f,p)){const t=s(O,I),r=o(O)-c.radius,i=o(I)-c.radius,u=t<ie;if(!u){console.warn(`Tile edge vertex position mismatch: between [${e.lij}].edge${y}[${ee}/${A}] and [${x.lij}].edge${P}[${te}/${F}]`),null!=v&&console.warn(" surface extent= ",v," x,y=",f,",",p);const s=h();a(s,C.localOrigin,E.localOrigin),o(s)>0&&console.warn(` localOrigins: ${C.localOrigin} vs ${E.localOrigin} d=${o(s)} [${s}]`);(()=>{const t=m(O),r=m(I);e.updateEdgeElevations(),x.updateEdgeElevations(),D.getEdgeVertexPosition(y,O,j,ee),w.getEdgeVertexPosition(P,I,L,te);const i=h();g(i,O,t),o(i)>0&&console.warn(` XXX Tile[${e.lij}] edge out of date: ${t} vs ${O} d=${o(i)} [${i}]`),g(i,I,r),o(i)>0&&console.warn(` XXX Neighbor[${x.lij}] edge out of date: ${r} vs ${I} d=${o(i)} [${i}]`)})();const n=D.getEdgeCount(y),l=w.getEdgeCount(F);$(u,`Mismatch in tile [${e.lij}].edge[${y}][${ee}/${n}] vs neighbor [${x.lij}].edge[${P}][${te}/${l}] ${b(O)} vs ${b(I)} dist=${t} h(t|n|d)=${r}|${i}|${i-r}`)}D.getEdgeNormal(y,M,ee),w.getEdgeNormal(P,U,te),n(k,M),n(H,U);const _=l(k,H),S=1-_<.01||!1||e===x;if(!S){const t=h();g(t,M,U);const r=()=>`Mismatch in tile edge normal ${T(e.lij)} (${ee}/${A-1}) edge ${y} vs neighbor ${T(x.lij)} (${te}/${F-1}) nedge ${P} :${b(M)} vs ${b(U)} dot = ${_} : ${b(t)}`;console.warn("Mismatch in tile edge normal: ",r());{e.updateEdgeElevations(),x.updateEdgeElevations();const t=h(),r=h();D.getEdgeNormal(y,t,ee),w.getEdgeNormal(P,r,te),d(M,t)||console.warn("Missing update in tile normal: ",b(M)," => ",b(t)),d(U,r)||console.warn("Missing update in neighbor normal: ",b(U)," => ",b(r))}$(S,r())}}ee+=1,te+=1}}))}}const O=h(),I=h(),M=h(),U=h(),k=h(),H=h(),X=1,B=[null,null,null,null];function W(e,t){return t?.isLoaded||t===e?t:null}const q=1,z=2,J=4,K=8,Q=4,Y=8,Z=12,ee=[0,1,2,3];export{A as ActivationTime,G as PatchRenderData,W as neighborTileIfLoadedOrSelf,ee as zeroToFour};
5
+ import{equals as e}from"../../../core/arrayUtils.js";import"../../../core/has.js";import{isPowerOfTwo as t}from"../../../core/mathUtils.js";import{disposeMaybe as r}from"../../../core/maybe.js";import{p as i,F as s,H as o,f as a,n,m as l,z as g,G as d}from"../../../chunks/vec32.js";import{create as h,clone as m}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{containsXY as u}from"../../../geometry/support/aaBoundingRect.js";import{earth as c}from"../../../geometry/support/Ellipsoid.js";import{glLayout as f}from"../support/buffer/glUtil.js";import{GeometryState as p}from"./GeometryState.js";import{LayerClass as y}from"./LayerClass.js";import{NeighborIndex as _}from"./NeighborIndex.js";import{PatchGeometry as x}from"./PatchGeometry.js";import{maxTileNeighborLevelDelta as v}from"./TerrainConst.js";import{enableTerrainInternalChecks as E,internalAssert as $,neighborEdgeIndices as S,oppositeEdge as C,neighborCornerIndices as D,v32s as b,lij2s as T}from"./terrainUtils.js";import{TextureFader as j,ActivationTime as A}from"./TextureFader.js";import{isEdgeNeighbor as V}from"./Tile.js";import R from"./TileOverlayData.js";import{fallsWithinLayerView as w}from"./tileUtils.js";import{VertexArrayObject as L}from"../webgl-engine/lib/VertexArrayObject.js";import{terrainVertexAttributeLocations as N}from"../webgl-engine/shaders/TerrainTechnique.js";import{BufferObject as P}from"../../webgl/BufferObject.js";import{PixelFormat as F}from"../../webgl/enums.js";class G{constructor(){this.geometry=new x,this.intersectionData=null,this.geometryState=null,this._vao=null,this._texture=null,this._textureRef=new j((()=>this.tile.surface.fadeDuration)),this.overlay=new R,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 p,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),E&&this.tile.intersectsClippingArea)for(let t=0;t<4;++t)$(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.extent;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=S[e];if(!t)return $(null==r.surface?.rootTiles||r.surface.updatingRootTiles||!r.shouldHaveNeighbor(o)),i;if(t.isLoaded){const r=t,o=r.renderData.geometryState,a=s-r.level;if($(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)}$(!t.isLeaf);let a=i;return t.forAllSubtreeOnSide(C(o),(e=>e===r||(e.isLoaded?(a=Math.max(a,2**(e.level-s)),!0):($(!e.isLeaf),!1)))),a}updateNeighborData(){const e=this.tile;if(!e.intersectsClippingArea)return;const r=e.renderData.geometryState,i=t=>(t.isLoaded||t.level===e.level)&&t?.intersectsClippingArea,s=r.edgePeerNeighbors,o=r.edgePeerNeighborSamplerVersions;for(let a=0;a<4;++a){const n=e.findNeighborTile(S[a],i),l=W(e,n),g=l?.renderData?.geometryState.samplerDataVersion??-1,d=s[a],h=l!==W(e,d),m=o[a]!==g;E&&n&&($(e.level>=n.level),$(e.level-n.level<=v)),s[a]=n,(h||m)&&(o[a]=g,this._markEdgeDirty(a));const u=r.edgeResolutions[a],c=this._calculateEdgeResolution(a,n);$(t(c)),$(c>=1),r.edgeResolutions[a]=c,u!==c&&this._markEdgeResolutionDirty(a)}for(let t=0;t<4;++t){const o=e.findNeighborTile(D[t],i);r.cornerPeerNeighbors[t]=o;const a=W(e,s[t]),n=W(e,s[(t+1)%4]),l=W(e,o);B[t]=l,B[(t+1)%4]=n,B[(t+2)%4]=e,B[(t+3)%4]=a,$(B.some((t=>t?.isLoaded||t===e)));const g=B.reduce(((e,t)=>Math.min(e,t?.level??1/0)),1/0);B.forEach(((e,t)=>{e&&e?.level>g&&(B[t]=null)})),$(B.some((t=>t?.isLoaded||t===e)));const d=r.cornerNeighborCornerTiles,h=r.cornerNeighborCornerTileSamplerVersions;for(let e=0;e<4;++e){const r=B[e],i=r?.renderData.geometryState.samplerDataVersion??-1,s=4*t+e,o=d[s]!==r,a=!o&&h[s]!==i;(o||a)&&(d[s]=r,h[s]=i,this._markCornerDirty(t))}E&&$(ee.some((r=>d[4*t+r]?.isLoaded||d[4*t+r]===e)))}E&&$(this.geometryState.edgeResolutions.every((e=>e>0)));for(let t=0;t<4;++t)B[t]=null}_updateGeometry(e){if(!this.tile.intersectsClippingArea)return;E&&$(!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||!{geometry:i}||this.wireframeChanged||this.samplerDataChanged||this.clippingAreaChanged||this.numVerticesPerSideChanged,a=0!==this.dirtyEdgeResolutions,n=s.edgeResolutions.reduce(((e,t)=>e+t+1),0),l=o||a&&n>(i?.maxEdgeVertexCount??0),g=!l&&a,d=!g&&(0!==this.dirtyEdges||a),h=!d&&0!==this.dirtyCorners;l?(this.releaseGeometry(),this._createGeometry(e)):g?t.updateEdgeElevationsAndResolutions():d||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){const i=t?F.RGBA:F.RGB;return null==this._texture||this._texture.descriptor.width===e&&this._texture.descriptor.pixelFormat===i||this.releaseTexture(),null==this._texture&&(this._texture=r(),this.tile.setMemoryDirty()),this._texture}releaseTexture(){null!=this._texture&&(this._texture.release(),this._texture=null,this.tile.setMemoryDirty())}get numVerticesPerSideChanged(){return!!(this._modifiedFlags&q)}get samplerDataChanged(){return!!(this._modifiedFlags&z)}get clippingAreaChanged(){return!!(this._modifiedFlags&J)}get wireframeChanged(){return!!(this._modifiedFlags&K)}get dirtyEdges(){return this._modifiedFlags>>Q&15}get dirtyCorners(){return this._modifiedFlags>>Y&15}get dirtyEdgeResolutions(){return this._modifiedFlags>>Z&15}_markCornerDirty(e){const t=1<<e<<Y;this._modifiedFlags|=t}_markEdgeDirty(e){const t=1<<e<<Q;this._modifiedFlags|=t,this._markCornerDirty((e+0)%4),this._markCornerDirty((e+3)%4)}_markEdgeResolutionDirty(e){const t=1<<e<<Z;this._modifiedFlags|=t,this._markEdgeDirty(e)}_markAllEdgesAndCornersDirty(){this._modifiedFlags|=15<<Y|15<<Q|15<<Z}updateGeometryState(){const t=this._getElevationInfo(),r=this.tile,i=t.samplerData?r.getElevationVerticesPerSide(t.maxTileLevel):r.getDefaultVerticesPerSide(),s=Math.max(i,5);let o=r.clippingArea;r.intersectsClippingArea&&!r.isWithinClippingArea||(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 t=this.geometry.vertexAttributes,r=this.geometry.indices,i=e.gl;this._vao=new L(e,N,{geometry:f(t.layout)},{geometry:P.createVertex(e,i.STATIC_DRAW,t.buffer)},P.createIndex(e,i.STATIC_DRAW,r)),this._hasGeometry=!0}get vao(){return this._vao}setTextureReference(e,t=A.Immediate){null!=e&&e.texture!==this._texture&&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}_getElevationInfo(){const e=this.geometryState.samplerData,t=this.tile.layerInfo[y.ELEVATION],r=t.length,i=new Array(r);let s=0,o=0,a=!1;for(let g=0;g<r;g++){const r=t[g],n=r.upsampleInfo?.tile;if(n){const t=n.layerInfo[y.ELEVATION][g].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(g,y.ELEVATION);if(w(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(!E)return;const e=this.tile;if(!e.isLoaded||!e.intersectsClippingArea||0===e.level)return void $(e?.isLoaded);const r=e.surface.extent;if(null!=r&&!e.intersectsExtent(r))return;const f=S.map(((t,i)=>null!=r&&(i<2?-1:1)*(e.extent[3-i]-r[3-i])<0)),p=e.level;$(0===this.dirtyCorners),$(0===this.dirtyEdges),$(0===this.dirtyEdgeResolutions),$(!this.numVerticesPerSideChanged),$(!this.samplerDataChanged),$(!this.clippingAreaChanged),$(!this.wireframeChanged);const y=D.map((t=>e.findNeighborCornerTileExact(t,(t=>!t.intersectsClippingArea||t.isLoaded||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];$(i===r,`Tile[${e.lij}].corner[${t}] out of date: cur=[${r?.lij}] exp=[${i?.lij}]`)}S.forEach(((r,y)=>{if(f[y])return;const x=e.findNeighborTile(r,(e=>(e.level===p||e?.isLoaded)&&e?.intersectsClippingArea));if(!x){const t=!e.surface.updatingRootTiles&&null!=e.surface.rootTiles&&e.surface.rootTiles.length>0&&e.shouldHaveNeighbor(r);return void $(!t)}$(x.isLoaded||x.level===e.level),$(x===this.geometryState.edgePeerNeighbors[y]);const v=p-x.level;if(!x.isLoaded)return $(!x.isLeaf),void $(0===v);const E=x.renderData;$(V(e,x,r)),$(v>=0);const S=2**v;if(v<0)return void $(!1);const C=e.renderData,D=C.geometry,j=C.localOrigin,A=D.getEdgeCount(y),R=D.numVerticesPerSide-1,w=E.geometry;if(!w)return void $(!1);const L=E.localOrigin,N=this.geometryState.edgePeerNeighbors[y];if(N?.isLoaded){const e=N.renderData;$(C.geometryState.edgePeerNeighborSamplerVersions[y]===e.geometryState.samplerDataVersion),$(this.geometryState.edgePeerNeighborSamplerVersions[y]===e.geometryState.samplerDataVersion)}const P=(y+2)%4,F=w.getEdgeCount(P),G=A-1,B=F-1;$(G*S===B,`Tile[${e.lij}]:e${y},res=${G} edgeRes mismatch with Neighbor[${x.lij}]:e${P},res=${B} (expected:${G*S})`);const W=e.extent,q=r===_.NORTH||r===_.SOUTH,z=F-1,J=z>>v,K=A-1;if(J<1)return void $(1===K);$(J===K),$(t(J));const Q=w.numVerticesPerSide-1;$(v>0||J===Math.max(Q,R));const Y=e.getNeighborEdgeStartVertexIndex(y,x);$(0<=Y&&Y<S);const Z=Y*J;$(0<=Z&&Z<=z-J);let ee=0,te=Z;D.getEdgeVertexPosition(y,O,j,0),D.getEdgeVertexPosition(y,I,j,A-1);const re=i(O,I),ie=Math.max(X,1e-4*re);for(let t=0;t<=J;++t){D.getEdgeVertexPosition(y,O,j,ee),w.getEdgeVertexPosition(P,I,L,te);const i=t/J,f=q?W[0]+i*(W[2]-W[0]):r===_.WEST?W[0]:W[2],p=q?r===_.SOUTH?W[1]:W[3]:W[1]+i*(W[3]-W[1]),v=e.surface.extent;if(null==v||u(v,f,p)){const t=s(O,I),r=o(O)-c.radius,i=o(I)-c.radius,u=t<ie;if(!u){console.warn(`Tile edge vertex position mismatch: between [${e.lij}].edge${y}[${ee}/${A}] and [${x.lij}].edge${P}[${te}/${F}]`),null!=v&&console.warn(" surface extent= ",v," x,y=",f,",",p);const s=h();a(s,C.localOrigin,E.localOrigin),o(s)>0&&console.warn(` localOrigins: ${C.localOrigin} vs ${E.localOrigin} d=${o(s)} [${s}]`);(()=>{const t=m(O),r=m(I);e.updateEdgeElevations(),x.updateEdgeElevations(),D.getEdgeVertexPosition(y,O,j,ee),w.getEdgeVertexPosition(P,I,L,te);const i=h();g(i,O,t),o(i)>0&&console.warn(` XXX Tile[${e.lij}] edge out of date: ${t} vs ${O} d=${o(i)} [${i}]`),g(i,I,r),o(i)>0&&console.warn(` XXX Neighbor[${x.lij}] edge out of date: ${r} vs ${I} d=${o(i)} [${i}]`)})();const n=D.getEdgeCount(y),l=w.getEdgeCount(F);$(u,`Mismatch in tile [${e.lij}].edge[${y}][${ee}/${n}] vs neighbor [${x.lij}].edge[${P}][${te}/${l}] ${b(O)} vs ${b(I)} dist=${t} h(t|n|d)=${r}|${i}|${i-r}`)}D.getEdgeNormal(y,M,ee),w.getEdgeNormal(P,U,te),n(k,M),n(H,U);const _=l(k,H),S=1-_<.01||!1||e===x;if(!S){const t=h();g(t,M,U);const r=()=>`Mismatch in tile edge normal ${T(e.lij)} (${ee}/${A-1}) edge ${y} vs neighbor ${T(x.lij)} (${te}/${F-1}) nedge ${P} :${b(M)} vs ${b(U)} dot = ${_} : ${b(t)}`;console.warn("Mismatch in tile edge normal: ",r());{e.updateEdgeElevations(),x.updateEdgeElevations();const t=h(),r=h();D.getEdgeNormal(y,t,ee),w.getEdgeNormal(P,r,te),d(M,t)||console.warn("Missing update in tile normal: ",b(M)," => ",b(t)),d(U,r)||console.warn("Missing update in neighbor normal: ",b(U)," => ",b(r))}$(S,r())}}ee+=1,te+=1}}))}}const O=h(),I=h(),M=h(),U=h(),k=h(),H=h(),X=1,B=[null,null,null,null];function W(e,t){return t?.isLoaded||t===e?t:null}const q=1,z=2,J=4,K=8,Q=4,Y=8,Z=12,ee=[0,1,2,3];export{A as ActivationTime,G as PatchRenderData,W as neighborTileIfLoadedOrSelf,ee as zeroToFour};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.31/esri/copyright.txt for details.
4
4
  */
5
- import{clamp as e}from"../../../core/mathUtils.js";import{abortMaybe as t}from"../../../core/maybe.js";import i from"../../../core/ObjectPool.js";import{f as s,q as n,m as r,j as a,g as o,l,c as h}from"../../../chunks/vec32.js";import{create as u,unitZ as d}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getEpsilon as c}from"../../../core/libs/gl-matrix-2/math/common.js";import{getReferenceEllipsoid as g}from"../../../geometry/ellipsoidUtils.js";import{create as p,equals as f}from"../../../geometry/support/aaBoundingRect.js";import{c as _,g as m}from"../../../chunks/sphere.js";import{isGroupLayer as y}from"../../../layers/support/layerUtils.js";import{ElevationBounds as M}from"./ElevationBounds.js";import{ElevationTileAgent as T,isElevationTileAgent as v}from"./ElevationTileAgent.js";import{TextureUpdate as A}from"./interfaces.js";import{LayerClasses as E,LayerClass as D}from"./LayerClass.js";import{MapTileAgent as I,isMapTileAgent as L}from"./MapTileAgent.js";import{NeighborIndex as x}from"./NeighborIndex.js";import{maxPatchTesselation as S}from"./TerrainConst.js";import{isVectorTile as O,isTileTexture as N,isRasterTile as b,isImageWithType as j}from"./TerrainData.js";import{weakAssert as U,getLayerWithExtentRange as C,isBlendableLayerView as B,oppositeCorner as P,internalAssert as R,enableTerrainInternalChecks as V,neighborEdgeIndices as w,oppositeEdge as G,neighborCornerIndices as W,isNorth as q,isSouth as F,isWest as H,isEast as k,enableWaterproofTests as X,almostEquals as Y,isWestCorner as z,isNorthCorner as J}from"./terrainUtils.js";import{tileAgentDone as $}from"./TileAgent.js";import{TileFrustumVisibility as Q}from"./TileFrustumVisibility.js";import{TilePerLayerInfo as K}from"./TilePerLayerInfo.js";import{TileUpdate as Z}from"./TileUpdate.js";import{fallsWithinLayer as ee}from"./tileUtils.js";const te=.1;class ie{constructor(){this._lij=[0,0,0],this._children=[null,null,null,null],this._pendingUpdates=0,this.renderData=null,this._dirty=!0,this._previouslyRendered=!1,this.extent=p(),this._elevationBoundsMin=NaN,this._elevationBoundsMax=0,this.layerInfo=[[],[]],this.extentInRadians=p(),this.centerAtSeaLevel=u(),this._center=[u(),_(),u()],this.up=d(),this._isWithinClippingArea=!0,this._intersectsClippingArea=!0,this._maxTesselation=0,this._usedMemory=0,this._rasterTileMemory=0,this._vectorTileMemory=0,this._mapDataRefCount=0,this.screenDepth=0,this.renderOrder=0,this._edgeLen=0,this._edgeLen2=0,this._curvatureHeight=0,this.extentMidX=0,this.extentMidY=0,this.distanceToPOI=-1,this._lastPOI=u(),this.maxLevelDeltaNeighborCount=0,this.unmergableChildCount=0}get lij(){return this._lij}get elevationLevelDelta(){return this._surface.getElevationLevelDelta(this.level)}static prune(){re.prune(0),ae.prune(0),K.prune()}get _isCached(){return!this.isLeaf&&this._mapDataRefCount<=0}get maxTesselation(){return this._maxTesselation}get isWithinClippingArea(){return this._isWithinClippingArea}get intersectsClippingArea(){return this._intersectsClippingArea}get clippingArea(){return this._clippingArea}get parent(){return this._parent}get children(){return this._children}get surface(){return this._surface}get elevationBoundsMin(){return this._elevationBoundsMin}get elevationBoundsMax(){return this._elevationBoundsMax}get level(){return this._lij[0]}get key(){return`${this._lij[0]}/${this._lij[1]}/${this._lij[2]}`}get edgeLen(){return this._edgeLen}get radius(){return this._center[le.MIDDLE][3]}get visible(){return this._dirty&&this.computeVisibility(),this._visible}get frustumVisibility(){return this._dirty&&this.computeVisibility(),this._frustumVisibility}computeVisibility(){this._dirty=!1;const e=this.parent,t=e?.frustumVisibility??Q.INTERSECTS;this._frustumVisibility=t===Q.INSIDE?Q.INSIDE:t===Q.OUTSIDE?Q.OUTSIDE:this._calculateFrustumVisibilityStatus(this.surface.frustum);const i=this._frustumVisibility!==Q.OUTSIDE&&this._intersectsClippingArea;i!==this._visible&&(this._visible=i,this._surface.emit("tiles-visibility-changed"),this._surface.renderer.setDirty(),this.updateAgentSuspension())}get loadable(){return this.visible||this._surface.view.state.fixedContentCamera}get rendered(){const e=!!this.renderData;return e!==this._previouslyRendered&&(this._surface.emit("tiles-visibility-changed"),this._previouslyRendered=e,this._surface.renderer.setDirty()),e}init(e,t,i,s,n){this._lij[0]=e,this._lij[1]=t,this._lij[2]=i,this.ellipsoid=g(n.tilingScheme.spatialReference),n.tilingScheme.getExtent(e,t,i,this.extent),n.tilingScheme.convertExtentToRadians(this.extent,this.extentInRadians),this.extentMidX=.5*(this.extent[0]+this.extent[2]),this.extentMidY=.5*(this.extent[1]+this.extent[3]),this._isWithinClippingArea=!0,this._intersectsClippingArea=!0,this._clippingArea=null,this._mapDataRefCount=0,n.upsampleMapCache.pop(this.key),this._edgeLen=0,this._edgeLen2=0,this._center[le.MIDDLE][3]=0,this.elevationLevel=e,s&&!Number.isNaN(s.elevationBoundsMin)?(this._elevationBoundsMin=s.elevationBoundsMin,this._elevationBoundsMax=s.elevationBoundsMax):(this._elevationBoundsMin=0,this._elevationBoundsMax=0),this._pendingUpdates=0,this.renderData=null,this.screenDepth=0,this._visible=!1,this._previouslyRendered=!1,this._parent=s,this.clearChildren(),this._surface=n,this.updateVisibility(),this.maxLevelDeltaNeighborCount=0,this.unmergableChildCount=0;for(const r of E){const e=n.numLayers(r),t=this.layerInfo[r];for(const i of t)i.release();t.length=e;for(let i=0;i<e;i++)t[i]=K.acquire(this._surface.upsampleInfoPool),r===D.ELEVATION&&this.findElevationBoundsForLayer(i,-1)}this.computeElevationBounds(),this._maxTesselation=Math.min(n.tilingScheme.pixelSize,S)}dispose(){U(!this.renderData,"tile.renderData was not unloaded"),this._surface.upsampleMapCache.pop(this.key),this.layerInfo.forEach((e=>{e.forEach((e=>e.release())),e.length=0})),this._parent=null,this.clearChildren(),this.setMemoryDirty()}refMapData(){++this._mapDataRefCount,this._isCached||this._surface.upsampleMapCache.pop(this.key)}unrefMapData(){if(--this._mapDataRefCount,this._isCached){const e=this._cachedMemory;e>0&&this._surface.upsampleMapCache.put(this.key,this,e)}}setMemoryDirty(){this._usedMemory=0}get usedMemory(){return this._ensureUsedMemory()+(this._isCached?0:this._mapTileMemory)}get _cachedMemory(){return this._ensureUsedMemory(),this._isCached?this._mapTileMemory:0}get _mapTileMemory(){return this._rasterTileMemory+this._vectorTileMemory}get _cpuImageMemorySize(){const e=4,t=this._surface.tilingScheme.pixelSize;return t*t*e}_ensureUsedMemory(){if(this._usedMemory>0)return this._vectorTileMemory=this.layerInfo[D.MAP].reduce(((e,{data:t})=>e+(O(t)?t.usedMemoryPerReference:0)),0),this._usedMemory;this._usedMemory=this._baseUsedMemory,this._rasterTileMemory=0,this._vectorTileMemory=0;for(const{data:t}of this.layerInfo[D.MAP])O(t)?this._vectorTileMemory+=t.usedMemoryPerReference:this._rasterTileMemory+=this._getTerrainDataMemory(t);const e=this._cpuImageMemorySize;for(const t of this.layerInfo[D.ELEVATION])this._usedMemory+=t.data?e:0;return this.renderData&&(this._usedMemory+=this.renderData.estimatedGeometryMemoryUsage,this._rasterTileMemory+=this.renderData.texture?.usedMemory??0),this._isCached&&this._surface.upsampleMapCache.updateSize(this.key,this,this._mapTileMemory),this._usedMemory}getUsedMemoryForLayer(e,t){const i=this.layerInfo[e][t];return i?.data?e===D.MAP?this._isCached?0:this._getTerrainDataMemory(i.data):e===D.ELEVATION?this._cpuImageMemorySize:0:0}_getTerrainDataMemory(e){return N(e)?e.texture.usedMemory:b(e)?e.memoryUsage:O(e)?e.usedMemoryPerReference:j(e)||e instanceof HTMLImageElement?this._cpuImageMemorySize:0}updateScreenDepth(e){const t=this._center[le.MIDDLE],i=e,s=t[0],n=t[1],r=t[2],a=i[2]*s+i[6]*n+i[10]*r+i[14];this.screenDepth=a<0?0:a/(i[3]*s+i[7]*n+i[11]*r+i[15])}shouldSplit(e,t,i){if(!this.visible)return Z.NONE;if(e.frustum&&(!this._intersectsClippingArea||this._calculateFrustumVisibilityStatus(e.frustum)===Q.OUTSIDE))return Z.NONE;const h=this.level;s(fe,m(this._center[le.MIDDLE]),t);let u=n(fe),d=fe,c=m(this._center[le.MIDDLE]);s(_e,this._center[le.TOP],t);const g=n(_e);g<u&&(u=g,d=_e,c=this._center[le.TOP]),s(me,this._center[le.BOTTOM],t);const p=n(me);if(p<u&&(u=p,d=me,c=this._center[le.BOTTOM]),this._edgeLen2>u&&h<e.maxLod)return Z.SPLIT;const f=Math.sqrt(u),_=e.fovX*f*2,y=this._edgeLen/_,M=()=>{if(h<e.maxLod)return this.elevationLevel=h,Z.NONE;const t=h+Math.ceil(-Math.log2(e.relativeWidthLimit/y));return t!==this.elevationLevel?(this.elevationLevel=t,Z.ELEVATION):Z.NONE},T=null!=i?i-h:1/0;if(T<=.5)return M();const v=r(this.up,fe),A=this._elevationBoundsMax-this._elevationBoundsMin,E=A/this.edgeLen;if(e.aboveGround&&v>0&&E<.001){if(v/f-Math.sin(this._curvatureHeight/(this.edgeLen*Math.SQRT1_2)*Math.PI)-E>0)return Z.NONE}const D=null!=i?3-Math.min(T,2):1;if(y*D<e.relativeWidthLimit||h>=e.maxLod)return M();if(h<7)return Z.SPLIT;a(ye,this.up,v),s(ye,ye,d);const I=n(ye);if(I<=this.radius*this.radius)return Z.SPLIT;a(ye,ye,this.radius/Math.sqrt(I)),o(ye,ye,c),s(ye,t,ye);const L=Math.min(1,(Math.abs(r(ye,this.up))+.5*A+this._curvatureHeight)/l(ye)),x=te/e.angledSplitBias,S=e.fovY*f*2;return L*(this._edgeLen/S*D)<x*e.relativeHeightLimit?Z.NONE:Z.SPLIT}createChildren(){const e=this._children,t=this.lij[0]+1,i=2*this.lij[1],s=2*this.lij[2];return e[0]=this.surface.createTile(t,i,s,this),e[1]=this.surface.createTile(t,i,s+1,this),e[2]=this.surface.createTile(t,i+1,s,this),e[3]=this.surface.createTile(t,i+1,s+1,this),e}clearChildren(){this._children[0]=this._children[1]=this._children[2]=this._children[3]=null}get isLoaded(){return this.renderData?.hasGeometry??!1}load(){this.refMapData();for(const e of E)this._createOrUpdateAgents(0,e);this.surface.renderer.loadTile(this)}unload(e){this.renderData&&this.unrefMapData(),e.unloadTile(this);for(const t of E){const e=this.layerInfo[t];for(const t of e)t.loadingAgent&&t.loadingAgent!==$&&(ne(t.loadingAgent),t.loadingAgent=null),t.pendingUpdates=0}this.resetPendingUpdate(Z.GEOMETRY),this.resetPendingUpdate(Z.TEXTURE_NOFADING),this.resetPendingUpdate(Z.TEXTURE_FADING)}unloadMapData(){const e=this.layerInfo[D.MAP];for(const t of e)t.loadingAgent&&t.loadingAgent!==$&&(ne(t.loadingAgent),t.loadingAgent=null),t.pendingUpdates=0,t.invalidateSourceData();this.renderData&&this.renderData.releaseTexture(),this.setMemoryDirty()}updateClippingStatus(e){if(f(e,this._clippingArea))return!1;const t=this._intersectsClippingArea,i=this._isWithinClippingArea;null!=e?(this._intersectsClippingArea=this.intersectsExtent(e),this._isWithinClippingArea=this._isWithinExtent(e)):(this._intersectsClippingArea=!0,this._isWithinClippingArea=!0),this._clippingArea=e,this.updateVisibility();const s=i&&this._isWithinClippingArea,n=!(i||t||this._isWithinClippingArea||this._intersectsClippingArea);return!this.renderData||s||n||this.setPendingUpdate(Z.GEOMETRY),!0}updateVisibility(){this._dirty=!0,this._surface.setTileTreeDirty()}getLayerInfo(e,t){return this.layerInfo[t][e]}hasLayerData(e,t){const i=this.layerInfo[t][e];return!(!i?.data||i.dataInvalidated)}get updating(){if(this.hasPendingUpdates)return!0;for(const e of E){const t=this.layerInfo[e];for(const e of t)if(e.loadingAgent&&e.loadingAgent!==$&&e.loadingAgent.updating)return!0}return!1}_isSuspended(e){return!!this.hasPendingUpdate(Z.SPLIT)||e!==D.ELEVATION&&!this.loadable}get hasPendingUpdates(){return 0!==this._pendingUpdates}hasPendingUpdate(e){return(this._pendingUpdates&e)===e}setPendingUpdate(e){const t=this._pendingUpdates;return this._pendingUpdates|=e,e===Z.SPLIT||e===Z.MERGE?this._surface.setTileTreeDirty():this._surface.requestUpdate(),t!==this._pendingUpdates}resetPendingUpdate(e){return!!this.hasPendingUpdate(e)&&(this._pendingUpdates&=~e,!0)}requestLayerData(e,i,s){const n=this.layerInfo[i][e];if(n.waitingAgents.has(s))return console.warn("agent already requested this piece of map data (tile %s, agent tile %s, layer: %d/%d)",this._lij.toString(),s.tile.lij.toString(),i,e),!0;if(n.waitingAgents.push(s),n.data&&!n.dataInvalidated){console.warn("agent requested existing data (tile %s, agent tile %s, layer: %d/%d)",this._lij.toString(),s.tile.lij.toString(),i,e);const t=O(n.data);return s.dataArrived(this,t),!0}if(n.requestPromise)return!0;t(n.requestAbort),n.requestAbort=new AbortController;const r=this._surface.requestTileData(this,e,i,n.requestAbort);if(!r)return n.requestAbort=null,!1;const a=()=>{n.requestPromise===r&&(n.requestPromise=null,n.requestAbort=null)};return n.requestPromise=r,r.then(a,a),!0}get isLeaf(){return null==this._children[0]}hasLij(e){return this._lij[0]===e[0]&&this._lij[1]===e[1]&&this._lij[2]===e[2]}findByLij(e){if(this.hasLij(e))return this;const t=this._children;if(!t[0])return null;return t[0].findByLij(e)||t[1].findByLij(e)||t[2].findByLij(e)||t[3].findByLij(e)}distanceToSquared(e){return n(s(ye,m(this._center[le.MIDDLE]),e))}containsPoint(e){const t=this.extent;return e[0]>=t[0]&&e[1]>=t[1]&&e[0]<=t[2]&&e[1]<=t[3]}containsPointXY(e,t){const i=this.extent;return e>=i[0]&&t>=i[1]&&e<=i[2]&&t<=i[3]}unrequestLayerData(e,t,i){const s=this.layerInfo[t][e],n=s.waitingAgents,r=null!=n.removeUnordered(i);U(r,"agent has not requested this piece of map data"),n.length<1&&(s.abortRequest(),this.setMemoryDirty())}dataArrived(e,t,i){const s=O(i),n=this.layerInfo[t][e];n.data=i,n.dataInvalidated=!1,n.waitingAgents.forAll((e=>e.dataArrived(this,s))),n.waitingAgents.clear(),this.setMemoryDirty()}dataMissing(e,t){const i=this.layerInfo[t][e];i.dataMissing=!0,i.waitingAgents.forAll((e=>e.dataMissing())),i.waitingAgents.clear(),this.setMemoryDirty()}updateRenderData(e,t,i){switch(i&&this.forEachLoadedNeighbor((i=>i.updateRenderData(e,t))),e){case D.MAP:return this._updateTexture(t);case D.ELEVATION:return this._updateGeometry()}}_updateTexture(e){this.renderData&&(this.resetPendingUpdate(e===A.FADING?Z.TEXTURE_NOFADING:Z.TEXTURE_FADING),this.setPendingUpdate(e===A.FADING?Z.TEXTURE_FADING:Z.TEXTURE_NOFADING))}_updateGeometry(){this.setPendingUpdate(Z.GEOMETRY);for(const e of this.layerInfo[D.ELEVATION])e.pendingUpdates|=Z.GEOMETRY}invalidateLayerData(e,t){this.layerInfo[t][e].invalidateSourceData(),this.restartAgents(t)}computeElevationBounds(){const e=this._elevationBoundsMin,t=this._elevationBoundsMax;let i=1/0,s=-1/0;const n=this.layerInfo[D.ELEVATION];let r=!0;for(const a of n)null!=a.elevationBounds&&(i=Math.min(i,a.elevationBounds.min),s=Math.max(s,a.elevationBounds.max),a.elevationBounds.hasNoDataValues||(r=!1));r&&(i=Math.min(i,0),s=Math.max(s,0)),e===i&&t===s||(this._elevationBoundsMin=i,this._elevationBoundsMax=s,this.updateRadiusAndCenter(),this._surface.setTileTreeDirty())}_updateCenter(){const e=this._elevationBoundsMin,t=this._elevationBoundsMax,i=.5*(e+t),s=this._center;a(ye,this.up,i),o(m(s[le.MIDDLE]),this.centerAtSeaLevel,ye),a(ye,this.up,e),o(s[le.TOP],this.centerAtSeaLevel,ye),a(ye,this.up,t),o(s[le.BOTTOM],this.centerAtSeaLevel,ye)}findElevationBoundsForLayer(e,t){const i=this.layerInfo[D.ELEVATION][e],s=this.elevationLevelDelta,n=Math.max(this.elevationLevel-s,0),r=i.elevationBounds;if(null!=r&&r.level>=t&&r.level<=n)return;const a=this._surface.layerViewByIndex(e,D.ELEVATION),o=C(a);if(!ee(this,o,!1))return;const l=oe;let h=!1;const u=i.data;if(u&&u.level<=n){const e=i.data;l.min=e.samplerData.data.minValue,l.max=e.samplerData.data.maxValue,l.hasNoDataValues=e.samplerData.data.hasNoDataValues,l.level=this.level,h=!0}else{let t,i,r=0;for(let a=this._parent;a&&(!i||r<s)&&(r=this.elevationLevel-a.level,t=i||t,i=a.layerInfo[D.ELEVATION][e].data,!(!i&&t&&a.level<=n));a=a.parent);i=i||t,i&&(i.computeMinMaxValue(this._lij[0],this._lij[1],this._lij[2],l),l.min!==1/0&&(l.level=i.level,h=!0))}h&&(null==i.elevationBounds&&(i.elevationBounds=new M),i.elevationBounds.copyFrom(l))}modifyLayers(e,t,i){const s=this.layerInfo[i];for(const a of s)a.loadingAgent&&a.loadingAgent!==$&&(ne(a.loadingAgent),a.loadingAgent=null),a.waitingAgents.clear();for(let a=0;a<s.length;++a)void 0===e[a]&&s[a].release();const n=new Array(...s),r=t.length;s.length=r;for(let a=0;a<r;a++){const e=t[a];s[a]=e>-1?n[e]:K.acquire(this._surface.upsampleInfoPool)}this.setMemoryDirty()}restartAgents(e){this.renderData&&(this._createOrUpdateAgents(0,e),this.updateRenderData(e,A.FADING))}updateAgents(e){if(this.renderData){const t=this.layerInfo[e];for(const e of t)e.loadingAgent===$&&(e.loadingAgent=null);this._createOrUpdateAgents(0,e)}}updateAgentSuspension(){for(const e of E){const t=this._isSuspended(e);for(const i of this.layerInfo[e])i.loadingAgent&&i.loadingAgent!==$&&(i.loadingAgent.setSuspension(t),i.loadingAgent===$&&this.updateRenderData(e,A.FADING))}}removeLayerAgent(e,t){const i=this.layerInfo[t][e];i.loadingAgent&&i.loadingAgent!==$&&i.loadingAgent.dispose(),i.loadingAgent=null}agentDone(e,t){const i=this.layerInfo[t][e];i.loadingAgent=$,i.data||null!=i.upsampleInfo||this._createOrUpdateAgents(e+1,t)}_hasBlendableAncestor(e){return"normal"!==e.blendMode||y(e.parent)&&this._hasBlendableAncestor(e.parent)}_hasBlendModes(e,t,i){for(let s=e;s<t;++s){const e=this._surface.layerViewByIndex(s,i);if(B(e)&&"normal"!==e?.layer?.blendMode||y(e?.layer?.parent)&&this._hasBlendableAncestor(e?.layer?.parent))return!0}return!1}_createOrUpdateAgents(e,t){const i=this.layerInfo[t];if(0===i.length)return;const s=this._isSuspended(t);for(let n=e;n<i.length;++n){const r=i[n];let a=!1;const o=this._surface.layerViewByIndex(n,t),l=C(o);if(r.loadingAgent?ee(this,l,!1)?(r.loadingAgent!==$&&r.loadingAgent.setSuspension(s),r.loadingAgent!==$&&(a=r.loadingAgent.update())):r.dispose():ee(this,l,!1)&&(r.loadingAgent=se(this,n,t,s),a=r.loadingAgent.startLoading(),a?r.loadingAgent===$&&this.setPendingUpdate(Z.GEOMETRY):(ne(r.loadingAgent),r.loadingAgent=$)),r.loadingAgent===$&&this.updateRenderData(t,A.FADING),!this._hasBlendModes(e,i.length,t)&&a&&o.isOpaque)return}}_isWithinExtent(e){const t=this.extent;return t[0]>=e[0]&&e[2]>=t[2]&&t[1]>=e[1]&&e[3]>=t[3]}intersectsExtent(e){const t=this.extent;return t[2]>=e[0]&&e[2]>=t[0]&&t[3]>=e[1]&&e[3]>=t[1]}getElevationVerticesPerSide(t){const i=this.elevationLevel-this.level,s=Math.max(this.level-t,this.elevationLevelDelta-i),n=e(1+(this.maxTesselation>>s),2,this.maxTesselation+1),r=this.getDefaultVerticesPerSide();return Math.max(n,r)}_findLIJ(e,t){if(!e)return null;const i=this.surface.rootTiles;if(null!=i)for(const s of i)if(he(s,e)){let i=s,n=e[0]-i.level-1;for(;n>=0&&!i.isLeaf&&!t(i);){const t=e[1]>>n&1,s=e[2]>>n&1;i=i.children[2*t+s],n--}return t(i)?i:null}return null}findNeighborTile(e,t){const i=this._lij,s=this.getNeighborLIJ(i,e);return s?ue(i,s)?t(this)?this:null:this._findLIJ(s,t):null}findCorner(e,t){const i=e===x.NORTH_EAST?1:e===x.NORTH_WEST?0:e===x.SOUTH_WEST?2:3;let s=this;for(;s.children[0]&&(!t||!t(s));)s=s.children[i];return s}findNeighborCornerTileExact(e,t){return this.findNeighborTile(e,(e=>t(e)||e.level===this.level))?.findCorner(P(e),t)||null}forAllSubtreeOnSide(e,t){const i=e===x.NORTH?[0,1]:e===x.NORTH_EAST?[1]:e===x.EAST?[1,3]:e===x.SOUTH_EAST?[3]:e===x.SOUTH?[2,3]:e===x.SOUTH_WEST?[2]:e===x.WEST?[0,2]:[0],s=e=>{const n=e.children;!t(e)&&n[0]&&i.forEach((e=>s(n[e])))};s(this)}getNeighborEdgeStartVertexIndex(e,t){if(!t)return 0;const i=this.level-t.level;if(R(!V||i>=0),0===i)return 0;const s=2**i,n=!(1&~e),r=n?0:1,a=t.lij[r+1]*s,o=this._lij[r+1],l=o-a,h=n?s-1-l:l;return V&&(R(a<=o&&o<a+s),R(0<=h&&h<s)),h}forEachLoadedNeighbor(e){const t=this.level,i=e=>e.level===t||e.isLoaded;w.forEach((t=>{const s=this.findNeighborTile(t,i);null!=s&&s!==this&&s.forAllSubtreeOnSide(G(t),(i=>!!i.isLoaded&&(e(i,t),!0)))})),W.forEach((t=>{const s=this.findNeighborTile(t,i)?.findCorner(P(t),(e=>e.isLoaded));R(!s||ce(this,s,t)),s?.isLoaded&&e(s,t)}))}getNeighborLIJ(e,t){const i=q(t)?-1:F(t)?1:0,s=H(t)?-1:k(t)?1:0,n=[e[0],e[1]+i,e[2]+s];return n[1]<0?null:this.surface.isGlobal?this.wrapLIJ(n):n[2]<0?null:n}wrapLIJ(e){return!e||e[1]<0||e[1]>=2**e[0]?null:this.surface.wrapEastWest(e)}get westNeighborWestExtent(){return this.extent[0]*(this.isWestEnd?-1:1)}get eastNeighborEastExtent(){return this.extent[2]*(this.isEastEnd?-1:1)}get isEastEnd(){return this._lij[2]===this.surface.lijEastEnd(this.level)-1}get isWestEnd(){return 0===this._lij[2]}get isNorthEnd(){return 0===this._lij[1]}get isSouthEnd(){const e=this.surface.extent,t=e?.[1]??null;return null!=t&&this.extent[1]+c()>=t}checkGeometryWaterproofness(){X&&(R(this.isLoaded),this.renderData?.checkGeometryWaterproofness())}shouldHaveNeighbor(e){const t=this.extent,i=this.surface.rootTilesExtent,s=.25*(t[2]-t[0]);if(q(e)&&t[3]+s>=i[3])return!1;if(F(e)&&t[1]-s<=i[1])return!1;const n=this.surface.isGlobal;return!(!n&&H(e)&&t[0]-s<=i[0])&&!(!n&&k(e)&&t[2]+s>=i[2])}updateDistanceToPOI(e){const t=this._lastPOI;if(this.distanceToPOI>=0&&t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2])return;h(this._lastPOI,e);const i=this._center[le.MIDDLE],s=e[0]-i[0],n=e[1]-i[1],r=e[2]-i[2];this.distanceToPOI=s*s+n*n+r*r}}function se(e,t,i,s){const n=i===D.ELEVATION?ae.acquire():re.acquire();return n.init(e,t,i,s),n}function ne(e){e.dispose(),v(e)?ae.release(e):L(e)&&re.release(e)}const re=new i(I),ae=new i(T),oe=new M;var le;function he(e,t){const i=e.lij,s=t[0]-i[0];return!(s<0)&&(t[1]>>s===i[1]&&t[2]>>s===i[2])}function ue(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]}function de(e,t,i){if(null==e||null==t)return!1;if(0===e.level&&0===t.level){if(e.isEastEnd&&t.isWestEnd&&i===x.EAST)return!0;if(e.isWestEnd&&t.isEastEnd&&i===x.WEST)return!0}const s=Math.max(1e-6*(e.extent[2]-e.extent[0]),1);switch(i){case x.NORTH:return Y(e.extent[3],t.extent[1],s);case x.SOUTH:return Y(e.extent[1],t.extent[3],s);case x.EAST:return Y(e.extent[2],t.extent[0],s)||Y(e.extent[2],-t.extent[0],s);case x.WEST:return Y(e.extent[0],t.extent[2],s)||Y(e.extent[0],-t.extent[2],s)}}function ce(e,t,i){return null!=e&&null!=t&&t!==e&&(e.level>=t.level?ge(e,t,i):ge(t,e,P(i)))}function ge(e,t,i){R(e.level>=t.level);const s=z(i),n=J(i),r=e.extent,a=t.extent,o=[s?r[0]:r[2],n?r[3]:r[1]],l=[s?a[2]:a[0],n?a[1]:a[3]],h=1e-5*(r[2]-r[0]),u=Y(o[0],l[0],h)||e.surface.isGlobal&&Y(o[0],-l[0],h),d=Y(o[1],l[1],h);if(u&&d)return!0;if(e.level===t.level)return R(!1),!1;if(!u&&!d)return R(!1),!1;const c=u?pe(a[1],a[3],r[1],r[3],h):pe(a[0],a[2],r[0],r[2],h);return R(c),c}function pe(e,t,i,s,n){return e-n<=i&&i<=s&&s<=t+n}!function(e){e[e.TOP=0]="TOP",e[e.MIDDLE=1]="MIDDLE",e[e.BOTTOM=2]="BOTTOM"}(le||(le={}));const fe=u(),_e=u(),me=u(),ye=u();export{le as CenterPosition,ie as Tile,ce as isCornerNeighbor,de as isEdgeNeighbor,ue as lijEquals};
5
+ import{clamp as e}from"../../../core/mathUtils.js";import{abortMaybe as t}from"../../../core/maybe.js";import i from"../../../core/ObjectPool.js";import{f as s,q as n,m as r,j as a,g as o,l,c as h}from"../../../chunks/vec32.js";import{create as u,unitZ as d}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getEpsilon as c}from"../../../core/libs/gl-matrix-2/math/common.js";import{getReferenceEllipsoid as g}from"../../../geometry/ellipsoidUtils.js";import{create as p,equals as f}from"../../../geometry/support/aaBoundingRect.js";import{c as _,g as m}from"../../../chunks/sphere.js";import{isGroupLayer as y}from"../../../layers/support/layerUtils.js";import{ElevationBounds as M}from"./ElevationBounds.js";import{ElevationTileAgent as T,isElevationTileAgent as v}from"./ElevationTileAgent.js";import{TextureUpdate as A}from"./interfaces.js";import{LayerClasses as E,LayerClass as D}from"./LayerClass.js";import{MapTileAgent as I,isMapTileAgent as L}from"./MapTileAgent.js";import{NeighborIndex as x}from"./NeighborIndex.js";import{maxPatchTesselation as S}from"./TerrainConst.js";import{isVectorTile as O,isTileTexture as N,isRasterTile as b,isImageWithType as j}from"./TerrainData.js";import{weakAssert as U,isBlendableLayerView as C,oppositeCorner as B,internalAssert as P,enableTerrainInternalChecks as R,neighborEdgeIndices as V,oppositeEdge as w,neighborCornerIndices as G,isNorth as W,isSouth as q,isWest as F,isEast as H,enableWaterproofTests as k,almostEquals as X,isWestCorner as Y,isNorthCorner as z}from"./terrainUtils.js";import{tileAgentDone as J}from"./TileAgent.js";import{TileFrustumVisibility as $}from"./TileFrustumVisibility.js";import{TilePerLayerInfo as Q}from"./TilePerLayerInfo.js";import{TileUpdate as K}from"./TileUpdate.js";import{fallsWithinLayerView as Z}from"./tileUtils.js";const ee=.1;class te{constructor(){this._lij=[0,0,0],this._children=[null,null,null,null],this._pendingUpdates=0,this.renderData=null,this._dirty=!0,this._previouslyRendered=!1,this.extent=p(),this._elevationBoundsMin=NaN,this._elevationBoundsMax=0,this.layerInfo=[[],[]],this.extentInRadians=p(),this.centerAtSeaLevel=u(),this._center=[u(),_(),u()],this.up=d(),this._isWithinClippingArea=!0,this._intersectsClippingArea=!0,this._maxTesselation=0,this._usedMemory=0,this._rasterTileMemory=0,this._vectorTileMemory=0,this._mapDataRefCount=0,this.screenDepth=0,this.renderOrder=0,this._edgeLen=0,this._edgeLen2=0,this._curvatureHeight=0,this.extentMidX=0,this.extentMidY=0,this.distanceToPOI=-1,this._lastPOI=u(),this.maxLevelDeltaNeighborCount=0,this.unmergableChildCount=0}get lij(){return this._lij}get elevationLevelDelta(){return this._surface.getElevationLevelDelta(this.level)}static prune(){ne.prune(0),re.prune(0),Q.prune()}get _isCached(){return!this.isLeaf&&this._mapDataRefCount<=0}get maxTesselation(){return this._maxTesselation}get isWithinClippingArea(){return this._isWithinClippingArea}get intersectsClippingArea(){return this._intersectsClippingArea}get clippingArea(){return this._clippingArea}get parent(){return this._parent}get children(){return this._children}get surface(){return this._surface}get elevationBoundsMin(){return this._elevationBoundsMin}get elevationBoundsMax(){return this._elevationBoundsMax}get level(){return this._lij[0]}get key(){return`${this._lij[0]}/${this._lij[1]}/${this._lij[2]}`}get edgeLen(){return this._edgeLen}get radius(){return this._center[oe.MIDDLE][3]}get visible(){return this._dirty&&this.computeVisibility(),this._visible}get frustumVisibility(){return this._dirty&&this.computeVisibility(),this._frustumVisibility}computeVisibility(){this._dirty=!1;const e=this.parent,t=e?.frustumVisibility??$.INTERSECTS;this._frustumVisibility=t===$.INSIDE?$.INSIDE:t===$.OUTSIDE?$.OUTSIDE:this._calculateFrustumVisibilityStatus(this.surface.frustum);const i=this._frustumVisibility!==$.OUTSIDE&&this._intersectsClippingArea;i!==this._visible&&(this._visible=i,this._surface.emit("tiles-visibility-changed"),this._surface.renderer.setDirty(),this.updateAgentSuspension())}get loadable(){return this.visible||this._surface.view.state.fixedContentCamera}get rendered(){const e=!!this.renderData;return e!==this._previouslyRendered&&(this._surface.emit("tiles-visibility-changed"),this._previouslyRendered=e,this._surface.renderer.setDirty()),e}init(e,t,i,s,n){this._lij[0]=e,this._lij[1]=t,this._lij[2]=i,this.ellipsoid=g(n.tilingScheme.spatialReference),n.tilingScheme.getExtent(e,t,i,this.extent),n.tilingScheme.convertExtentToRadians(this.extent,this.extentInRadians),this.extentMidX=.5*(this.extent[0]+this.extent[2]),this.extentMidY=.5*(this.extent[1]+this.extent[3]),this._isWithinClippingArea=!0,this._intersectsClippingArea=!0,this._clippingArea=null,this._mapDataRefCount=0,n.upsampleMapCache.pop(this.key),this._edgeLen=0,this._edgeLen2=0,this._center[oe.MIDDLE][3]=0,this.elevationLevel=e,s&&!Number.isNaN(s.elevationBoundsMin)?(this._elevationBoundsMin=s.elevationBoundsMin,this._elevationBoundsMax=s.elevationBoundsMax):(this._elevationBoundsMin=0,this._elevationBoundsMax=0),this._pendingUpdates=0,this.renderData=null,this.screenDepth=0,this._visible=!1,this._previouslyRendered=!1,this._parent=s,this.clearChildren(),this._surface=n,this.updateVisibility(),this.maxLevelDeltaNeighborCount=0,this.unmergableChildCount=0;for(const r of E){const e=n.numLayers(r),t=this.layerInfo[r];for(const i of t)i.release();t.length=e;for(let i=0;i<e;i++)t[i]=Q.acquire(this._surface.upsampleInfoPool),r===D.ELEVATION&&this.findElevationBoundsForLayer(i,-1)}this.computeElevationBounds(),this._maxTesselation=Math.min(n.tilingScheme.pixelSize,S)}dispose(){U(!this.renderData,"tile.renderData was not unloaded"),this._surface.upsampleMapCache.pop(this.key),this.layerInfo.forEach((e=>{e.forEach((e=>e.release())),e.length=0})),this._parent=null,this.clearChildren(),this.setMemoryDirty()}refMapData(){++this._mapDataRefCount,this._isCached||this._surface.upsampleMapCache.pop(this.key)}unrefMapData(){if(--this._mapDataRefCount,this._isCached){const e=this._cachedMemory;e>0&&this._surface.upsampleMapCache.put(this.key,this,e)}}setMemoryDirty(){this._usedMemory=0}get usedMemory(){return this._ensureUsedMemory()+(this._isCached?0:this._mapTileMemory)}get _cachedMemory(){return this._ensureUsedMemory(),this._isCached?this._mapTileMemory:0}get _mapTileMemory(){return this._rasterTileMemory+this._vectorTileMemory}get _cpuImageMemorySize(){const e=4,t=this._surface.tilingScheme.pixelSize;return t*t*e}_ensureUsedMemory(){if(this._usedMemory>0)return this._vectorTileMemory=this.layerInfo[D.MAP].reduce(((e,{data:t})=>e+(O(t)?t.usedMemoryPerReference:0)),0),this._usedMemory;this._usedMemory=this._baseUsedMemory,this._rasterTileMemory=0,this._vectorTileMemory=0;for(const{data:t}of this.layerInfo[D.MAP])O(t)?this._vectorTileMemory+=t.usedMemoryPerReference:this._rasterTileMemory+=this._getTerrainDataMemory(t);const e=this._cpuImageMemorySize;for(const t of this.layerInfo[D.ELEVATION])this._usedMemory+=t.data?e:0;return this.renderData&&(this._usedMemory+=this.renderData.estimatedGeometryMemoryUsage,this._rasterTileMemory+=this.renderData.texture?.usedMemory??0),this._isCached&&this._surface.upsampleMapCache.updateSize(this.key,this,this._mapTileMemory),this._usedMemory}getUsedMemoryForLayer(e,t){const i=this.layerInfo[e][t];return i?.data?e===D.MAP?this._isCached?0:this._getTerrainDataMemory(i.data):e===D.ELEVATION?this._cpuImageMemorySize:0:0}_getTerrainDataMemory(e){return N(e)?e.texture.usedMemory:b(e)?e.memoryUsage:O(e)?e.usedMemoryPerReference:j(e)||e instanceof HTMLImageElement?this._cpuImageMemorySize:0}updateScreenDepth(e){const t=this._center[oe.MIDDLE],i=e,s=t[0],n=t[1],r=t[2],a=i[2]*s+i[6]*n+i[10]*r+i[14];this.screenDepth=a<0?0:a/(i[3]*s+i[7]*n+i[11]*r+i[15])}shouldSplit(e,t,i){if(!this.visible)return K.NONE;if(e.frustum&&(!this._intersectsClippingArea||this._calculateFrustumVisibilityStatus(e.frustum)===$.OUTSIDE))return K.NONE;const h=this.level;s(pe,m(this._center[oe.MIDDLE]),t);let u=n(pe),d=pe,c=m(this._center[oe.MIDDLE]);s(fe,this._center[oe.TOP],t);const g=n(fe);g<u&&(u=g,d=fe,c=this._center[oe.TOP]),s(_e,this._center[oe.BOTTOM],t);const p=n(_e);if(p<u&&(u=p,d=_e,c=this._center[oe.BOTTOM]),this._edgeLen2>u&&h<e.maxLod)return K.SPLIT;const f=Math.sqrt(u),_=e.fovX*f*2,y=this._edgeLen/_,M=()=>{if(h<e.maxLod)return this.elevationLevel=h,K.NONE;const t=h+Math.ceil(-Math.log2(e.relativeWidthLimit/y));return t!==this.elevationLevel?(this.elevationLevel=t,K.ELEVATION):K.NONE},T=null!=i?i-h:1/0;if(T<=.5)return M();const v=r(this.up,pe),A=this._elevationBoundsMax-this._elevationBoundsMin,E=A/this.edgeLen;if(e.aboveGround&&v>0&&E<.001){if(v/f-Math.sin(this._curvatureHeight/(this.edgeLen*Math.SQRT1_2)*Math.PI)-E>0)return K.NONE}const D=null!=i?3-Math.min(T,2):1;if(y*D<e.relativeWidthLimit||h>=e.maxLod)return M();if(h<7)return K.SPLIT;a(me,this.up,v),s(me,me,d);const I=n(me);if(I<=this.radius*this.radius)return K.SPLIT;a(me,me,this.radius/Math.sqrt(I)),o(me,me,c),s(me,t,me);const L=Math.min(1,(Math.abs(r(me,this.up))+.5*A+this._curvatureHeight)/l(me)),x=ee/e.angledSplitBias,S=e.fovY*f*2;return L*(this._edgeLen/S*D)<x*e.relativeHeightLimit?K.NONE:K.SPLIT}createChildren(){const e=this._children,t=this.lij[0]+1,i=2*this.lij[1],s=2*this.lij[2];return e[0]=this.surface.createTile(t,i,s,this),e[1]=this.surface.createTile(t,i,s+1,this),e[2]=this.surface.createTile(t,i+1,s,this),e[3]=this.surface.createTile(t,i+1,s+1,this),e}clearChildren(){this._children[0]=this._children[1]=this._children[2]=this._children[3]=null}get isLoaded(){return this.renderData?.hasGeometry??!1}load(){this.refMapData();for(const e of E)this._createOrUpdateAgents(0,e);this.surface.renderer.loadTile(this)}unload(e){this.renderData&&this.unrefMapData(),e.unloadTile(this);for(const t of E){const e=this.layerInfo[t];for(const t of e)t.loadingAgent&&t.loadingAgent!==J&&(se(t.loadingAgent),t.loadingAgent=null),t.pendingUpdates=0}this.resetPendingUpdate(K.GEOMETRY),this.resetPendingUpdate(K.TEXTURE_NOFADING),this.resetPendingUpdate(K.TEXTURE_FADING)}unloadMapData(){const e=this.layerInfo[D.MAP];for(const t of e)t.loadingAgent&&t.loadingAgent!==J&&(se(t.loadingAgent),t.loadingAgent=null),t.pendingUpdates=0,t.invalidateSourceData();this.renderData&&this.renderData.releaseTexture(),this.setMemoryDirty()}updateClippingStatus(e){if(f(e,this._clippingArea))return!1;const t=this._intersectsClippingArea,i=this._isWithinClippingArea;null!=e?(this._intersectsClippingArea=this.intersectsExtent(e),this._isWithinClippingArea=this._isWithinExtent(e)):(this._intersectsClippingArea=!0,this._isWithinClippingArea=!0),this._clippingArea=e,this.updateVisibility();const s=i&&this._isWithinClippingArea,n=!(i||t||this._isWithinClippingArea||this._intersectsClippingArea);return!this.renderData||s||n||this.setPendingUpdate(K.GEOMETRY),!0}updateVisibility(){this._dirty=!0,this._surface.setTileTreeDirty()}getLayerInfo(e,t){return this.layerInfo[t][e]}hasLayerData(e,t){const i=this.layerInfo[t][e];return!(!i?.data||i.dataInvalidated)}get updating(){if(this.hasPendingUpdates)return!0;for(const e of E){const t=this.layerInfo[e];for(const e of t)if(e.loadingAgent&&e.loadingAgent!==J&&e.loadingAgent.updating)return!0}return!1}_isSuspended(e){return!!this.hasPendingUpdate(K.SPLIT)||e!==D.ELEVATION&&!this.loadable}get hasPendingUpdates(){return 0!==this._pendingUpdates}hasPendingUpdate(e){return(this._pendingUpdates&e)===e}setPendingUpdate(e){const t=this._pendingUpdates;return this._pendingUpdates|=e,e===K.SPLIT||e===K.MERGE?this._surface.setTileTreeDirty():this._surface.requestUpdate(),t!==this._pendingUpdates}resetPendingUpdate(e){return!!this.hasPendingUpdate(e)&&(this._pendingUpdates&=~e,!0)}requestLayerData(e,i,s){const n=this.layerInfo[i][e];if(n.waitingAgents.has(s))return console.warn("agent already requested this piece of map data (tile %s, agent tile %s, layer: %d/%d)",this._lij.toString(),s.tile.lij.toString(),i,e),!0;if(n.waitingAgents.push(s),n.data&&!n.dataInvalidated){console.warn("agent requested existing data (tile %s, agent tile %s, layer: %d/%d)",this._lij.toString(),s.tile.lij.toString(),i,e);const t=O(n.data);return s.dataArrived(this,t),!0}if(n.requestPromise)return!0;t(n.requestAbort),n.requestAbort=new AbortController;const r=this._surface.requestTileData(this,e,i,n.requestAbort);if(!r)return n.requestAbort=null,!1;const a=()=>{n.requestPromise===r&&(n.requestPromise=null,n.requestAbort=null)};return n.requestPromise=r,r.then(a,a),!0}get isLeaf(){return null==this._children[0]}hasLij(e){return this._lij[0]===e[0]&&this._lij[1]===e[1]&&this._lij[2]===e[2]}findByLij(e){if(this.hasLij(e))return this;const t=this._children;if(!t[0])return null;return t[0].findByLij(e)||t[1].findByLij(e)||t[2].findByLij(e)||t[3].findByLij(e)}distanceToSquared(e){return n(s(me,m(this._center[oe.MIDDLE]),e))}containsPoint(e){const t=this.extent;return e[0]>=t[0]&&e[1]>=t[1]&&e[0]<=t[2]&&e[1]<=t[3]}containsPointXY(e,t){const i=this.extent;return e>=i[0]&&t>=i[1]&&e<=i[2]&&t<=i[3]}unrequestLayerData(e,t,i){const s=this.layerInfo[t][e],n=s.waitingAgents,r=null!=n.removeUnordered(i);U(r,"agent has not requested this piece of map data"),n.length<1&&(s.abortRequest(),this.setMemoryDirty())}dataArrived(e,t,i){const s=O(i),n=this.layerInfo[t][e];n.data=i,n.dataInvalidated=!1,n.waitingAgents.forAll((e=>e.dataArrived(this,s))),n.waitingAgents.clear(),this.setMemoryDirty()}dataMissing(e,t){const i=this.layerInfo[t][e];i.dataMissing=!0,i.waitingAgents.forAll((e=>e.dataMissing())),i.waitingAgents.clear(),this.setMemoryDirty()}updateRenderData(e,t,i){switch(i&&this.forEachLoadedNeighbor((i=>i.updateRenderData(e,t))),e){case D.MAP:return this._updateTexture(t);case D.ELEVATION:return this._updateGeometry()}}_updateTexture(e){this.renderData&&(this.resetPendingUpdate(e===A.FADING?K.TEXTURE_NOFADING:K.TEXTURE_FADING),this.setPendingUpdate(e===A.FADING?K.TEXTURE_FADING:K.TEXTURE_NOFADING))}_updateGeometry(){this.setPendingUpdate(K.GEOMETRY);for(const e of this.layerInfo[D.ELEVATION])e.pendingUpdates|=K.GEOMETRY}invalidateLayerData(e,t){this.layerInfo[t][e].invalidateSourceData(),this.restartAgents(t)}computeElevationBounds(){const e=this._elevationBoundsMin,t=this._elevationBoundsMax;let i=1/0,s=-1/0;const n=this.layerInfo[D.ELEVATION];let r=!0;for(const a of n)null!=a.elevationBounds&&(i=Math.min(i,a.elevationBounds.min),s=Math.max(s,a.elevationBounds.max),a.elevationBounds.hasNoDataValues||(r=!1));r&&(i=Math.min(i,0),s=Math.max(s,0)),e===i&&t===s||(this._elevationBoundsMin=i,this._elevationBoundsMax=s,this.updateRadiusAndCenter(),this._surface.setTileTreeDirty())}_updateCenter(){const e=this._elevationBoundsMin,t=this._elevationBoundsMax,i=.5*(e+t),s=this._center;a(me,this.up,i),o(m(s[oe.MIDDLE]),this.centerAtSeaLevel,me),a(me,this.up,e),o(s[oe.TOP],this.centerAtSeaLevel,me),a(me,this.up,t),o(s[oe.BOTTOM],this.centerAtSeaLevel,me)}findElevationBoundsForLayer(e,t){const i=this.layerInfo[D.ELEVATION][e],s=this.elevationLevelDelta,n=Math.max(this.elevationLevel-s,0),r=i.elevationBounds;if(null!=r&&r.level>=t&&r.level<=n)return;const a=this._surface.layerViewByIndex(e,D.ELEVATION);if(!Z(this,a))return;const o=ae;let l=!1;const h=i.data;if(h&&h.level<=n){const e=i.data;o.min=e.samplerData.data.minValue,o.max=e.samplerData.data.maxValue,o.hasNoDataValues=e.samplerData.data.hasNoDataValues,o.level=this.level,l=!0}else{let t,i,r=0;for(let a=this._parent;a&&(!i||r<s)&&(r=this.elevationLevel-a.level,t=i||t,i=a.layerInfo[D.ELEVATION][e].data,!(!i&&t&&a.level<=n));a=a.parent);i=i||t,i&&(i.computeMinMaxValue(this._lij[0],this._lij[1],this._lij[2],o),o.min!==1/0&&(o.level=i.level,l=!0))}l&&(null==i.elevationBounds&&(i.elevationBounds=new M),i.elevationBounds.copyFrom(o))}modifyLayers(e,t,i){const s=this.layerInfo[i];for(const a of s)a.loadingAgent&&a.loadingAgent!==J&&(se(a.loadingAgent),a.loadingAgent=null),a.waitingAgents.clear();for(let a=0;a<s.length;++a)void 0===e[a]&&s[a].release();const n=new Array(...s),r=t.length;s.length=r;for(let a=0;a<r;a++){const e=t[a];s[a]=e>-1?n[e]:Q.acquire(this._surface.upsampleInfoPool)}this.setMemoryDirty()}restartAgents(e){this.renderData&&(this._createOrUpdateAgents(0,e),this.updateRenderData(e,A.FADING))}updateAgents(e){if(this.renderData){const t=this.layerInfo[e];for(const e of t)e.loadingAgent===J&&(e.loadingAgent=null);this._createOrUpdateAgents(0,e)}}updateAgentSuspension(){for(const e of E){const t=this._isSuspended(e);for(const i of this.layerInfo[e])i.loadingAgent&&i.loadingAgent!==J&&(i.loadingAgent.setSuspension(t),i.loadingAgent===J&&this.updateRenderData(e,A.FADING))}}removeLayerAgent(e,t){const i=this.layerInfo[t][e];i.loadingAgent&&i.loadingAgent!==J&&i.loadingAgent.dispose(),i.loadingAgent=null}agentDone(e,t){const i=this.layerInfo[t][e];i.loadingAgent=J,i.data||null!=i.upsampleInfo||this._createOrUpdateAgents(e+1,t)}_hasBlendableAncestor(e){return"normal"!==e.blendMode||y(e.parent)&&this._hasBlendableAncestor(e.parent)}_hasBlendModes(e,t,i){for(let s=e;s<t;++s){const e=this._surface.layerViewByIndex(s,i);if(C(e)&&"normal"!==e?.layer?.blendMode||y(e?.layer?.parent)&&this._hasBlendableAncestor(e?.layer?.parent))return!0}return!1}_createOrUpdateAgents(e,t){const i=this.layerInfo[t];if(0===i.length)return;const s=this._isSuspended(t);for(let n=e;n<i.length;++n){const r=i[n],a=this._surface.layerViewByIndex(n,t);let o=!1;if(r.loadingAgent?Z(this,a)?(r.loadingAgent!==J&&r.loadingAgent.setSuspension(s),r.loadingAgent!==J&&(o=r.loadingAgent.update())):r.dispose():Z(this,a)&&(r.loadingAgent=ie(this,n,t,s),o=r.loadingAgent.startLoading(),o?r.loadingAgent===J&&this.setPendingUpdate(K.GEOMETRY):(se(r.loadingAgent),r.loadingAgent=J)),r.loadingAgent===J&&this.updateRenderData(t,A.FADING),!this._hasBlendModes(e,i.length,t)&&o&&a.isOpaque)return}}_isWithinExtent(e){const t=this.extent;return t[0]>=e[0]&&e[2]>=t[2]&&t[1]>=e[1]&&e[3]>=t[3]}intersectsExtent(e){const t=this.extent;return t[2]>=e[0]&&e[2]>=t[0]&&t[3]>=e[1]&&e[3]>=t[1]}getElevationVerticesPerSide(t){const i=this.elevationLevel-this.level,s=Math.max(this.level-t,this.elevationLevelDelta-i),n=e(1+(this.maxTesselation>>s),2,this.maxTesselation+1),r=this.getDefaultVerticesPerSide();return Math.max(n,r)}_findLIJ(e,t){if(!e)return null;const i=this.surface.rootTiles;if(null!=i)for(const s of i)if(le(s,e)){let i=s,n=e[0]-i.level-1;for(;n>=0&&!i.isLeaf&&!t(i);){const t=e[1]>>n&1,s=e[2]>>n&1;i=i.children[2*t+s],n--}return t(i)?i:null}return null}findNeighborTile(e,t){const i=this._lij,s=this.getNeighborLIJ(i,e);return s?he(i,s)?t(this)?this:null:this._findLIJ(s,t):null}findCorner(e,t){const i=e===x.NORTH_EAST?1:e===x.NORTH_WEST?0:e===x.SOUTH_WEST?2:3;let s=this;for(;s.children[0]&&(!t||!t(s));)s=s.children[i];return s}findNeighborCornerTileExact(e,t){return this.findNeighborTile(e,(e=>t(e)||e.level===this.level))?.findCorner(B(e),t)||null}forAllSubtreeOnSide(e,t){const i=e===x.NORTH?[0,1]:e===x.NORTH_EAST?[1]:e===x.EAST?[1,3]:e===x.SOUTH_EAST?[3]:e===x.SOUTH?[2,3]:e===x.SOUTH_WEST?[2]:e===x.WEST?[0,2]:[0],s=e=>{const n=e.children;!t(e)&&n[0]&&i.forEach((e=>s(n[e])))};s(this)}getNeighborEdgeStartVertexIndex(e,t){if(!t)return 0;const i=this.level-t.level;if(P(!R||i>=0),0===i)return 0;const s=2**i,n=!(1&~e),r=n?0:1,a=t.lij[r+1]*s,o=this._lij[r+1],l=o-a,h=n?s-1-l:l;return R&&(P(a<=o&&o<a+s),P(0<=h&&h<s)),h}forEachLoadedNeighbor(e){const t=this.level,i=e=>e.level===t||e.isLoaded;V.forEach((t=>{const s=this.findNeighborTile(t,i);null!=s&&s!==this&&s.forAllSubtreeOnSide(w(t),(i=>!!i.isLoaded&&(e(i,t),!0)))})),G.forEach((t=>{const s=this.findNeighborTile(t,i)?.findCorner(B(t),(e=>e.isLoaded));P(!s||de(this,s,t)),s?.isLoaded&&e(s,t)}))}getNeighborLIJ(e,t){const i=W(t)?-1:q(t)?1:0,s=F(t)?-1:H(t)?1:0,n=[e[0],e[1]+i,e[2]+s];return n[1]<0?null:this.surface.isGlobal?this.wrapLIJ(n):n[2]<0?null:n}wrapLIJ(e){return!e||e[1]<0||e[1]>=2**e[0]?null:this.surface.wrapEastWest(e)}get westNeighborWestExtent(){return this.extent[0]*(this.isWestEnd?-1:1)}get eastNeighborEastExtent(){return this.extent[2]*(this.isEastEnd?-1:1)}get isEastEnd(){return this._lij[2]===this.surface.lijEastEnd(this.level)-1}get isWestEnd(){return 0===this._lij[2]}get isNorthEnd(){return 0===this._lij[1]}get isSouthEnd(){const e=this.surface.extent,t=e?.[1]??null;return null!=t&&this.extent[1]+c()>=t}checkGeometryWaterproofness(){k&&(P(this.isLoaded),this.renderData?.checkGeometryWaterproofness())}shouldHaveNeighbor(e){const t=this.extent,i=this.surface.rootTilesExtent,s=.25*(t[2]-t[0]);if(W(e)&&t[3]+s>=i[3])return!1;if(q(e)&&t[1]-s<=i[1])return!1;const n=this.surface.isGlobal;return!(!n&&F(e)&&t[0]-s<=i[0])&&!(!n&&H(e)&&t[2]+s>=i[2])}updateDistanceToPOI(e){const t=this._lastPOI;if(this.distanceToPOI>=0&&t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2])return;h(this._lastPOI,e);const i=this._center[oe.MIDDLE],s=e[0]-i[0],n=e[1]-i[1],r=e[2]-i[2];this.distanceToPOI=s*s+n*n+r*r}}function ie(e,t,i,s){const n=i===D.ELEVATION?re.acquire():ne.acquire();return n.init(e,t,i,s),n}function se(e){e.dispose(),v(e)?re.release(e):L(e)&&ne.release(e)}const ne=new i(I),re=new i(T),ae=new M;var oe;function le(e,t){const i=e.lij,s=t[0]-i[0];return!(s<0)&&(t[1]>>s===i[1]&&t[2]>>s===i[2])}function he(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]}function ue(e,t,i){if(null==e||null==t)return!1;if(0===e.level&&0===t.level){if(e.isEastEnd&&t.isWestEnd&&i===x.EAST)return!0;if(e.isWestEnd&&t.isEastEnd&&i===x.WEST)return!0}const s=Math.max(1e-6*(e.extent[2]-e.extent[0]),1);switch(i){case x.NORTH:return X(e.extent[3],t.extent[1],s);case x.SOUTH:return X(e.extent[1],t.extent[3],s);case x.EAST:return X(e.extent[2],t.extent[0],s)||X(e.extent[2],-t.extent[0],s);case x.WEST:return X(e.extent[0],t.extent[2],s)||X(e.extent[0],-t.extent[2],s)}}function de(e,t,i){return null!=e&&null!=t&&t!==e&&(e.level>=t.level?ce(e,t,i):ce(t,e,B(i)))}function ce(e,t,i){P(e.level>=t.level);const s=Y(i),n=z(i),r=e.extent,a=t.extent,o=[s?r[0]:r[2],n?r[3]:r[1]],l=[s?a[2]:a[0],n?a[1]:a[3]],h=1e-5*(r[2]-r[0]),u=X(o[0],l[0],h)||e.surface.isGlobal&&X(o[0],-l[0],h),d=X(o[1],l[1],h);if(u&&d)return!0;if(e.level===t.level)return P(!1),!1;if(!u&&!d)return P(!1),!1;const c=u?ge(a[1],a[3],r[1],r[3],h):ge(a[0],a[2],r[0],r[2],h);return P(c),c}function ge(e,t,i,s,n){return e-n<=i&&i<=s&&s<=t+n}!function(e){e[e.TOP=0]="TOP",e[e.MIDDLE=1]="MIDDLE",e[e.BOTTOM=2]="BOTTOM"}(oe||(oe={}));const pe=u(),fe=u(),_e=u(),me=u();export{oe as CenterPosition,te as Tile,de as isCornerNeighbor,ue as isEdgeNeighbor,he as lijEquals};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.31/esri/copyright.txt for details.
4
4
  */
5
- import"../../../core/has.js";import{TextureUpdate as e}from"./interfaces.js";import{progressiveLoadingModulo as t}from"./TerrainConst.js";import{getLayerWithExtentRange as s}from"./terrainUtils.js";import{fallsWithinLayer as i}from"./tileUtils.js";class l{get updating(){return!!this._tileRequested}init(e,t,s,i){this.tile=e,this._layerIdx=t,this._layerClass=s,this._suspended=i,this._tileLayerInfo=e.getLayerInfo(t,s),this._tileRequested=null;const l=this._findAncestorWithData();this._setUpsampleTile(l)}startLoading(){return this._requestNext()}dispose(){this._tileRequested&&(this._tileRequested.unrequestLayerData(this._layerIdx,this._layerClass,this),this._tileRequested=null),this.tile=null,this._tileLayerInfo=null}setSuspension(e){e!==this._suspended&&(this._suspended=e,e?this._tileRequested&&(this._tileRequested.unrequestLayerData(this._layerIdx,this._layerClass,this),this._tileRequested=null):this._tileLayerInfo.data||this.update())}update(){const e=this._findAncestorWithData();return this._setUpsampleTile(e),this._requestNext()}dataArrived(t,s){this._setUpsampleTile(t,s),this._tileRequested=null,t===this.tile?this.tile.updateRenderData(this._layerClass,e.FADING,s):this._requestNext()}dataMissing(){this._tileRequested=null,this._tileLayerInfo.data=null,this._requestNext()}_agentDone(){this.tile.agentDone(this._layerIdx,this._layerClass),this.dispose()}_requestNext(){if(this._suspended)return!0;const e=this._findNextDownload();if(this._tileRequested){if(e===this._tileRequested)return!0;this._tileRequested.unrequestLayerData(this._layerIdx,this._layerClass,this),this._tileRequested=null}return null!=e?e.requestLayerData(this._layerIdx,this._layerClass,this)&&(this._tileRequested=e):this._agentDone(),!!this._tileRequested}_findNextDownload(){const e=this._layerIdx,l=this._layerClass,a=this.tile.surface.layerViewByIndex(e,l),r=s(a),{minLevel:n,maxLevel:h}=a.dataLevelRange,d=this._desiredMinLevelDelta,u=this._progressiveLevelModulo+d,o=this._scaleRangeEnabled?i:()=>!0;let _=this.tile;const p=_.level;let y;const f=this._tileLayerInfo.upsampleInfo,c=f?.tile?.level??-1,v=null!=f&&c-p>=d,q=r?.tilemapCache,I="vector-tile-3d"===a.type?a.schemaHelper:null;for(;_&&o(_,r,!1)&&_.level>=n;){const s=_.level,i=p-s,a=_.layerInfo[l][e];if(a.data&&i>=d){(!v||s>c)&&this._setUpsampleTile(_),a.dataInvalidated&&(y=_);break}const r=I?.getLevelRowColumn(_.lij)??_.lij;if("unavailable"!==q?.getAvailability(r[0],r[1],r[2])&&s<=h&&!a.data&&!a.dataMissing&&((!y||_.level===n||s%t==0||p-y.level<d)&&(y=_),i>=u))break;_=_.parent}if(null!=y&&p-y.level<d)if(f)y=null;else{const t=this._findAncestorWithData();if(null!=t){this._setUpsampleTile(t);y=t.layerInfo[l][e].dataInvalidated?t:null}}return y}_findAncestorWithData(){const e=this.tile.elevationLevel,t=this._desiredMinLevelDelta;let s;for(let i=this.tile;i;i=i.parent)if(i.hasLayerData(this._layerIdx,this._layerClass)){if(e-i.level>=t)return i;s=i}return s}_setUpsampleTile(t,s){this._tileLayerInfo.setUpsampleInfo(this.tile,t),this.tile.updateRenderData(this._layerClass,e.FADING,s)}get test(){}}class a extends l{constructor(){super(...arguments),this.type="none"}get _desiredMinLevelDelta(){throw r}get _progressiveLevelModulo(){throw r}dispose(){}}const r=new Error("Abstract method called on TileAgent"),n=new a;export{l as TileAgent,n as tileAgentDone};
5
+ import"../../../core/has.js";import{TextureUpdate as e}from"./interfaces.js";import{progressiveLoadingModulo as t}from"./TerrainConst.js";import{fallsWithinLayerView as s,getTileMapCache as i}from"./tileUtils.js";class l{get updating(){return!!this._tileRequested}init(e,t,s,i){this.tile=e,this._layerIdx=t,this._layerClass=s,this._suspended=i,this._tileLayerInfo=e.getLayerInfo(t,s),this._tileRequested=null;const l=this._findAncestorWithData();this._setUpsampleTile(l)}startLoading(){return this._requestNext()}dispose(){this._tileRequested&&(this._tileRequested.unrequestLayerData(this._layerIdx,this._layerClass,this),this._tileRequested=null),this.tile=null,this._tileLayerInfo=null}setSuspension(e){e!==this._suspended&&(this._suspended=e,e?this._tileRequested&&(this._tileRequested.unrequestLayerData(this._layerIdx,this._layerClass,this),this._tileRequested=null):this._tileLayerInfo.data||this.update())}update(){const e=this._findAncestorWithData();return this._setUpsampleTile(e),this._requestNext()}dataArrived(t,s){this._setUpsampleTile(t,s),this._tileRequested=null,t===this.tile?this.tile.updateRenderData(this._layerClass,e.FADING,s):this._requestNext()}dataMissing(){this._tileRequested=null,this._tileLayerInfo.data=null,this._requestNext()}_agentDone(){this.tile.agentDone(this._layerIdx,this._layerClass),this.dispose()}_requestNext(){if(this._suspended)return!0;const e=this._findNextDownload();if(this._tileRequested){if(e===this._tileRequested)return!0;this._tileRequested.unrequestLayerData(this._layerIdx,this._layerClass,this),this._tileRequested=null}return null!=e?e.requestLayerData(this._layerIdx,this._layerClass,this)&&(this._tileRequested=e):this._agentDone(),!!this._tileRequested}_findNextDownload(){const e=this._layerIdx,l=this._layerClass,a=this.tile.surface.layerViewByIndex(e,l),{minLevel:n,maxLevel:r}=a.dataLevelRange,h=this._desiredMinLevelDelta,d=this._progressiveLevelModulo+h,u=this._scaleRangeEnabled?s:()=>!0;let _=this.tile;const o=_.level;let p;const y=this._tileLayerInfo.upsampleInfo,f=y?.tile?.level??-1,c=null!=y&&f-o>=h,v=i(a),q="vector-tile-3d"===a.type?a.schemaHelper:null;for(;_&&u(_,a)&&_.level>=n;){const s=_.level,i=o-s,a=_.layerInfo[l][e];if(a.data&&i>=h){(!c||s>f)&&this._setUpsampleTile(_),a.dataInvalidated&&(p=_);break}const u=q?.getLevelRowColumn(_.lij)??_.lij;if("unavailable"!==v?.getAvailability(u[0],u[1],u[2])&&s<=r&&!a.data&&!a.dataMissing&&((!p||_.level===n||s%t==0||o-p.level<h)&&(p=_),i>=d))break;_=_.parent}if(null!=p&&o-p.level<h)if(y)p=null;else{const t=this._findAncestorWithData();if(null!=t){this._setUpsampleTile(t);p=t.layerInfo[l][e].dataInvalidated?t:null}}return p}_findAncestorWithData(){const e=this.tile.elevationLevel,t=this._desiredMinLevelDelta;let s;for(let i=this.tile;i;i=i.parent)if(i.hasLayerData(this._layerIdx,this._layerClass)){if(e-i.level>=t)return i;s=i}return s}_setUpsampleTile(t,s){this._tileLayerInfo.setUpsampleInfo(this.tile,t),this.tile.updateRenderData(this._layerClass,e.FADING,s)}get test(){}}class a extends l{constructor(){super(...arguments),this.type="none"}get _desiredMinLevelDelta(){throw n}get _progressiveLevelModulo(){throw n}dispose(){}}const n=new Error("Abstract method called on TileAgent"),r=new a;export{l as TileAgent,r as tileAgentDone};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.31/esri/copyright.txt for details.
4
4
  */
5
- 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{isBaseLayer as i,isGroupLayer as a}from"../../../layers/support/layerUtils.js";import{BlendLayersPassParameters as n}from"./BlendLayersTechnique.js";import{TextureUpdate as u}from"./interfaces.js";import{LayerClass as c}from"./LayerClass.js";import{NeighborIndex as l}from"./NeighborIndex.js";import{isImageWithType as p}from"./TerrainData.js";import{isBlendableLayerView as d,isVectorTileLayerView as h,isVectorTileRenderInfo as m,isImageryTileRenderInfo as f,isImageSourceRenderInfo as _,isTextureTileRenderInfo as T,isVectorTilePerLayerInfo as y}from"./terrainUtils.js";import{ActivationTime as b}from"./TextureFader.js";import{TextureReference as g}from"./TextureReference.js";import{TileCompositor as x}from"./TileCompositor.js";import{TileRenderInfo as I}from"./TileRenderInfo.js";import w from"./TileTexture.js";import{TileUpdate as A}from"./TileUpdate.js";import{blendModeFromString as P}from"../webgl-engine/core/shaderLibrary/output/BlendOptions.js";import{BlendLayersOutput as k}from"../webgl-engine/core/shaderLibrary/terrain/BlendLayersOutput.js";import{createEmptyTexture as O}from"../webgl-engine/lib/glUtil3D.js";import{TextureSamplingMode as E,TextureWrapMode as D,PixelFormat as M}from"../../webgl/enums.js";import{Texture as L}from"../../webgl/Texture.js";import{TextureDescriptor as R}from"../../webgl/TextureDescriptor.js";class j{constructor(e,t,r,s,o,i){this.start=e,this.end=t,this.blendMode=r,this.opacity=s,this.output=o,this.baseOpacity=i}}class C{constructor(e,t,r,s){this._rctx=e,this.tileSize=t,this._techniques=r,this._cache=s,this._passParameters=new n,this._backgroundTexture=null,this._backgroundColor=null,this._backgroundDirty=!1,this._maxAnisotropy=this._rctx.parameters.maxMaxAnisotropy,this._compositor=new x(this._rctx,this._techniques),this._ensureBackgroundTexture(this.tileSize)}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,n=0,l=this.tileSize,p=!1,m=!1;const f=r.view.state.contentPixelRatio;let _=!1;F.clear(),q.length=0;const T=e.layerInfo[c.MAP];let y=0,b=null;for(;y<T.length;y++){const t=r.layerViewByIndex(y,c.MAP),u=t.layer.opacity,g=t.fullOpacity;if(m=m||i(t.layer),d(t)){let e="normal"!==t.layer.blendMode;if(a(t.layer.parent)){const r=t.layer.parent.uid;null!=r&&""!==r&&(e=U(t.layer.parent)||e)}e&&(_=e,p=!1)}if(0===u&&!_){T[y].pendingUpdates&=~(A.TEXTURE_NOFADING&A.TEXTURE_FADING);continue}++n;const x=h(t),I=N(e,y,x);if(I){if(T[y].pendingUpdates&=~(A.TEXTURE_NOFADING&A.TEXTURE_FADING),a(t.layer.parent)){const e=t.layer.parent.uid;null!=e&&""!==e&&B(t.layer.parent,y)}x?l=Math.max(l,this.tileSize*f):1===s&&1===g&&(t.isOpaque||this._dataToTexture(I)&&I.sourceLayerInfo.data.descriptor.isOpaque)&&(p=!0),++o,null===b&&(b=y)}}const g=l/this.tileSize,x=this._ensureBackgroundTexture(this.tileSize);0!==o&&null!==b?1===o&&!_&&this._useLayerTexture(e,b)||this._composeLayers(e,t,y-1,m,l,g,!p||_,F,_):G(e,n,x,t!==u.FADING)}_ensureBackgroundTexture(e){return null==this._backgroundTexture&&(this._backgroundTexture=this._buildTexture(e,!1),this._backgroundDirty=!0),this._backgroundDirty&&(this._compositor.bind(e),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(this._backgroundTexture),this._compositor.unbind(),this._backgroundDirty=!1),this._backgroundTexture}_useLayerTexture(e,t){const r=e.surface.layerViewByIndex(t,c.MAP),s=i(r.layer),o=s?e.surface.baseOpacity:1,a=s?1:e.surface.baseOpacity,n=r.fullOpacity,l=N(e,t,!1);return!!this._dataToTexture(l)&&(e.renderData.setTextureReference(new g(l.sourceLayerInfo.data,u.FADING,l,o,a,n)),!0)}_composeLayers(e,t,r,s,a,n,u,l,p){this._compositor.ensureBuffer(a);const _=e.surface.baseOpacity;let T=!1,y=E.LINEAR_MIPMAP_LINEAR,b=!1,x=0;for(let g=r;g>=0;g--){const t=e.surface.layerViewByIndex(g,c.MAP),r=h(t),I=N(e,g,r),w=t.layer.opacity;if(!I||0===w&&!p)continue;const A=!i(t.layer)&&!T;A&&(T=!0);let O=!1;l.forEach((e=>{e.start===g&&(e.output=s?k.Composite:u&&A?this.backgroundIsGrid?k.GridComposite:k.ColorComposite:k.Composite,e.baseOpacity=A?_:1,q.push(e),this._compositor.openGroup(a),O=!0)}));const D=0===x,M=O?k.GroupBackgroundComposite:u&&D?this.backgroundIsGrid?k.GridComposite:k.ColorComposite:k.Composite,L=P[d(t)?t.layer.blendMode:"normal"];for(this._passParameters.baseOpacity=A&&!O&&_<1?_:1,this._passParameters.opacity=w,m(I)?b=this._compositor.drawVectorData(this._passParameters,M,a,L,I,n,this.tileSize,b):f(I)?(this._compositor.drawRasterData(this._passParameters,M,a,L,I),S(I)&&(y=E.NEAREST)):this._dataToTexture(I)&&(this._passParameters.texture=I.sourceLayerInfo.data.texture,this._passParameters.offset=I.offset,this._passParameters.scale=I.scale,this._compositor.drawImageData(this._passParameters,M,a,L));q.length>0&&q[q.length-1].end===g;){const e=q.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,P[e.blendMode])}x++}const I=e.renderData,w=p||T&&_<1,A=I.ensureTexture(a,w,(()=>this._buildTexture(a,w,y)));this._compositor.copyFBOToTexture(A),this._compositor.unbind(),I.setTextureReference(new g(A,t,H,T?1:_,0,1))}_dataToTexture(e){if(_(e)){const t=e.sourceLayerInfo;t.data=this._buildTexture(t.data,!0),e.tile.setMemoryDirty()}return T(e)}setBackground(e){this._backgroundColor!==e&&(this._backgroundColor=e,this._backgroundDirty=!0)}_buildTexture(e,t,r=E.LINEAR_MIPMAP_LINEAR){if(null==e)return null;const s=new R;s.wrapMode=D.CLAMP_TO_EDGE,s.samplingMode=r,s.maxAnisotropy=this._maxAnisotropy,s.preMultiplyAlpha=!0,s.flipped=!0,s.hasMipmap=!0,t||(s.pixelFormat=M.RGB);const o=this._rctx;let i;if("number"==typeof e)s.width=s.height=e,i=this._buildTileTexture(s,e);else if(p(e))s.isOpaque=e.isOpaque,s.isOpaque&&(s.pixelFormat=M.RGB),i=this._buildTileTexture(s,e.element.width,e.element);else try{s.width=e.width,s.height=e.height,i=this._buildTileTexture(s,e.width,e)}catch(n){i=new w(O(o)),console.warn("TileRenderer: failed to execute 'texImage2D', cross-origin image may not be loaded.")}const a=o.bindTexture(i.texture,L.TEXTURE_UNIT_FOR_UPDATES);return i.generateMipmap(),o.bindTexture(a,L.TEXTURE_UNIT_FOR_UPDATES),i}_buildTileTexture(e,t,r){const s=`${t} ${e.pixelFormat}`,o=this._cache.pop(s);return o?(o.retain(),o.texture.setData(r),o):new w(new L(this._rctx,e,r),this._cache)}get test(){}}function N(e,t,o){v.layerIndex=t,v.vtlNeighborInfos.clear();const i=e.layerInfo[c.MAP][t];if(r(v.offset,0,0),v.tile=e,v.scale=1,v.sourceLod=e.lij,v.sourceLayerInfo=i,v.isVTLBackground=o,i.data)return o&&e.forEachLoadedNeighbor(((r,s)=>{if(r.level!==e.level)return;const o=r.layerInfo[c.MAP][t];if(!y(o)||i.data===o.data)return;const a=v.vtlNeighborInfos.pushNew();a.offset=z[s],a.sourceLod=r.lij,a.sourceLayerInfo=o})),v;const a=i.upsampleInfo,n=a?.tile?.layerInfo[c.MAP][t];return n?(v.tile=a.tile,s(v.offset,a.offset),v.scale=a.scale,v.sourceLod=a.tile.lij,v.sourceLayerInfo=n,v):o?v:null}function S(e){const t=e.sourceLayerInfo.data;return!!t.source&&"nearest"===t.interpolation}function U(e){let t="normal"!==e.blendMode;return a(e.parent)&&(t=U(e.parent)||t),t}function B(e,t){a(e.parent)&&B(e.parent,t);const r=e.uid;if(null!=r&&""!==r){const s=F.get(r);s?s.start=t:F.set(r,new j(t,t,e.blendMode,e.opacity,k.Composite,1))}}function G(e,t,r,s){const o=e.renderData,i=!s&&null!=o.textureReference&&(e.surface.view.layerViewManager.updating||t>0)?b.Delayed:b.Immediate;o.setTextureReference(new g(r,u.FADING,H,e.surface.baseOpacity,0,1),i)}const F=new Map,q=new Array,v=new I,H={offset:[0,0],scale:1},z=new Array;z[l.NORTH]=[0,-1],z[l.NORTH_EAST]=[-1,-1],z[l.EAST]=[-1,0],z[l.SOUTH_EAST]=[-1,1],z[l.SOUTH]=[0,1],z[l.SOUTH_WEST]=[1,1],z[l.WEST]=[1,0],z[l.NORTH_WEST]=[1,-1];export{j as GroupInfo,C as TileRenderer};
5
+ 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{isBaseLayer as i,isGroupLayer as a}from"../../../layers/support/layerUtils.js";import{BlendLayersPassParameters as n}from"./BlendLayersTechnique.js";import{TextureUpdate as u}from"./interfaces.js";import{LayerClass as c}from"./LayerClass.js";import{NeighborIndex as l}from"./NeighborIndex.js";import{isImageWithType as p}from"./TerrainData.js";import{isBlendableLayerView as d,isVectorTileLayerView as h,isVectorTileRenderInfo as m,isImageryTileRenderInfo as f,isImageSourceRenderInfo as _,isTextureTileRenderInfo as T,isVectorTilePerLayerInfo as y}from"./terrainUtils.js";import{ActivationTime as b}from"./TextureFader.js";import{TextureReference as g}from"./TextureReference.js";import{TileCompositor as x}from"./TileCompositor.js";import{TileRenderInfo as I}from"./TileRenderInfo.js";import w from"./TileTexture.js";import{TileUpdate as A}from"./TileUpdate.js";import{fallsWithinLayerView as P}from"./tileUtils.js";import{blendModeFromString as k}from"../webgl-engine/core/shaderLibrary/output/BlendOptions.js";import{BlendLayersOutput as O}from"../webgl-engine/core/shaderLibrary/terrain/BlendLayersOutput.js";import{createEmptyTexture as E}from"../webgl-engine/lib/glUtil3D.js";import{TextureSamplingMode as D,TextureWrapMode as M,PixelFormat as j}from"../../webgl/enums.js";import{Texture as L}from"../../webgl/Texture.js";import{TextureDescriptor as R}from"../../webgl/TextureDescriptor.js";class C{constructor(e,t,r,s,o,i){this.start=e,this.end=t,this.blendMode=r,this.opacity=s,this.output=o,this.baseOpacity=i}}class N{constructor(e,t,r,s){this._rctx=e,this.tileSize=t,this._techniques=r,this._cache=s,this._passParameters=new n,this._backgroundTexture=null,this._backgroundColor=null,this._backgroundDirty=!1,this._maxAnisotropy=this._rctx.parameters.maxMaxAnisotropy,this._compositor=new x(this._rctx,this._techniques),this._ensureBackgroundTexture(this.tileSize)}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,n=0,l=this.tileSize,p=!1,m=!1;const f=r.view.state.contentPixelRatio;let _=!1;q.clear(),v.length=0;const T=e.layerInfo[c.MAP];let y=0,b=null;for(;y<T.length;y++){const t=r.layerViewByIndex(y,c.MAP),u=t.layer,g=!P(e,t),x=u.opacity,I=t.fullOpacity;if(m=m||i(u),d(t)){let e="normal"!==t.layer.blendMode;if(a(u.parent)){const t=u.parent.uid;null!=t&&""!==t&&(e=B(u.parent)||e)}e&&(_=e,p=!1)}if((g||0===x)&&!_){T[y].pendingUpdates&=~(A.TEXTURE_NOFADING&A.TEXTURE_FADING);continue}++n;const w=h(t),k=U(e,y,w);if(k){if(T[y].pendingUpdates&=~(A.TEXTURE_NOFADING&A.TEXTURE_FADING),a(u.parent)){const e=u.parent.uid;null!=e&&""!==e&&G(u.parent,y)}w?l=Math.max(l,this.tileSize*f):1===s&&1===I&&(t.isOpaque||this._dataToTexture(k)&&k.sourceLayerInfo.data.descriptor.isOpaque)&&(p=!0),++o,null===b&&(b=y)}}const g=l/this.tileSize,x=this._ensureBackgroundTexture(this.tileSize);0!==o&&null!==b?1===o&&!_&&this._useLayerTexture(e,b)||this._composeLayers(e,t,y-1,m,l,g,!p||_,q,_):F(e,n,x,t!==u.FADING)}_ensureBackgroundTexture(e){return null==this._backgroundTexture&&(this._backgroundTexture=this._buildTexture(e,!1),this._backgroundDirty=!0),this._backgroundDirty&&(this._compositor.bind(e),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(this._backgroundTexture),this._compositor.unbind(),this._backgroundDirty=!1),this._backgroundTexture}_useLayerTexture(e,t){const r=e.surface.layerViewByIndex(t,c.MAP),s=i(r.layer),o=s?e.surface.baseOpacity:1,a=s?1:e.surface.baseOpacity,n=r.fullOpacity,l=U(e,t,!1);return!!this._dataToTexture(l)&&(e.renderData.setTextureReference(new g(l.sourceLayerInfo.data,u.FADING,l,o,a,n)),!0)}_composeLayers(e,t,r,s,a,n,u,l,p){this._compositor.ensureBuffer(a);const _=e.surface.baseOpacity;let T=!1,y=D.LINEAR_MIPMAP_LINEAR,b=!1,x=0;for(let g=r;g>=0;g--){const t=e.surface.layerViewByIndex(g,c.MAP),r=t.layer,I=h(t),w=U(e,g,I),A=r.opacity,E=!P(e,t);if(!w||(0===A||E)&&!p)continue;const M=!i(r)&&!T;M&&(T=!0);let j=!1;l.forEach((e=>{e.start===g&&(e.output=s?O.Composite:u&&M?this.backgroundIsGrid?O.GridComposite:O.ColorComposite:O.Composite,e.baseOpacity=M?_:1,v.push(e),this._compositor.openGroup(a),j=!0)}));const L=0===x,R=j?O.GroupBackgroundComposite:u&&L?this.backgroundIsGrid?O.GridComposite:O.ColorComposite:O.Composite,C=k[d(t)?t.layer.blendMode:"normal"];for(this._passParameters.baseOpacity=M&&!j&&_<1?_:1,this._passParameters.opacity=A,m(w)?b=this._compositor.drawVectorData(this._passParameters,R,a,C,w,n,this.tileSize,b):f(w)?(this._compositor.drawRasterData(this._passParameters,R,a,C,w),S(w)&&(y=D.NEAREST)):this._dataToTexture(w)&&(this._passParameters.texture=w.sourceLayerInfo.data.texture,this._passParameters.offset=w.offset,this._passParameters.scale=w.scale,this._compositor.drawImageData(this._passParameters,R,a,C));v.length>0&&v[v.length-1].end===g;){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,k[e.blendMode])}x++}const I=e.renderData,w=p||T&&_<1,A=I.ensureTexture(a,w,(()=>this._buildTexture(a,w,y)));this._compositor.copyFBOToTexture(A),this._compositor.unbind(),I.setTextureReference(new g(A,t,z,T?1:_,0,1))}_dataToTexture(e){if(_(e)){const t=e.sourceLayerInfo;t.data=this._buildTexture(t.data,!0),e.tile.setMemoryDirty()}return T(e)}setBackground(e){this._backgroundColor!==e&&(this._backgroundColor=e,this._backgroundDirty=!0)}_buildTexture(e,t,r=D.LINEAR_MIPMAP_LINEAR){if(null==e)return null;const s=new R;s.wrapMode=M.CLAMP_TO_EDGE,s.samplingMode=r,s.maxAnisotropy=this._maxAnisotropy,s.preMultiplyAlpha=!0,s.flipped=!0,s.hasMipmap=!0,t||(s.pixelFormat=j.RGB);const o=this._rctx;let i;if("number"==typeof e)s.width=s.height=e,i=this._buildTileTexture(s,e);else if(p(e))s.isOpaque=e.isOpaque,s.isOpaque&&(s.pixelFormat=j.RGB),i=this._buildTileTexture(s,e.element.width,e.element);else try{s.width=e.width,s.height=e.height,i=this._buildTileTexture(s,e.width,e)}catch(n){i=new w(E(o)),console.warn("TileRenderer: failed to execute 'texImage2D', cross-origin image may not be loaded.")}const a=o.bindTexture(i.texture,L.TEXTURE_UNIT_FOR_UPDATES);return i.generateMipmap(),o.bindTexture(a,L.TEXTURE_UNIT_FOR_UPDATES),i}_buildTileTexture(e,t,r){const s=`${t} ${e.pixelFormat}`,o=this._cache.pop(s);return o?(o.retain(),o.texture.setData(r),o):new w(new L(this._rctx,e,r),this._cache)}get test(){}}function U(e,t,o){H.layerIndex=t,H.vtlNeighborInfos.clear();const i=e.layerInfo[c.MAP][t];if(r(H.offset,0,0),H.tile=e,H.scale=1,H.sourceLod=e.lij,H.sourceLayerInfo=i,H.isVTLBackground=o,i.data)return o&&e.forEachLoadedNeighbor(((r,s)=>{if(r.level!==e.level)return;const o=r.layerInfo[c.MAP][t];if(!y(o)||i.data===o.data)return;const a=H.vtlNeighborInfos.pushNew();a.offset=V[s],a.sourceLod=r.lij,a.sourceLayerInfo=o})),H;const a=i.upsampleInfo,n=a?.tile?.layerInfo[c.MAP][t];return n?(H.tile=a.tile,s(H.offset,a.offset),H.scale=a.scale,H.sourceLod=a.tile.lij,H.sourceLayerInfo=n,H):o?H:null}function S(e){const t=e.sourceLayerInfo.data;return!!t.source&&"nearest"===t.interpolation}function B(e){let t="normal"!==e.blendMode;return a(e.parent)&&(t=B(e.parent)||t),t}function G(e,t){a(e.parent)&&G(e.parent,t);const r=e.uid;if(null!=r&&""!==r){const s=q.get(r);s?s.start=t:q.set(r,new C(t,t,e.blendMode,e.opacity,O.Composite,1))}}function F(e,t,r,s){const o=e.renderData,i=!s&&null!=o.textureReference&&(e.surface.view.layerViewManager.updating||t>0)?b.Delayed:b.Immediate;o.setTextureReference(new g(r,u.FADING,z,e.surface.baseOpacity,0,1),i)}const q=new Map,v=new Array,H=new I,z={offset:[0,0],scale:1},V=new Array;V[l.NORTH]=[0,-1],V[l.NORTH_EAST]=[-1,-1],V[l.EAST]=[-1,0],V[l.SOUTH_EAST]=[-1,1],V[l.SOUTH]=[0,1],V[l.SOUTH_WEST]=[1,1],V[l.WEST]=[1,0],V[l.NORTH_WEST]=[1,-1];export{C as GroupInfo,N as TileRenderer};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.31/esri/copyright.txt for details.
4
4
  */
5
- import n from"../../../core/Collection.js";import{isCGCS2000 as t,isEarth as e}from"../../../geometry/support/spatialReferenceUtils.js";import{getTileMaxtrixSetFromActiveLayer as r}from"../../../layers/support/layerUtils.js";import{ViewingMode as o}from"../../ViewingMode.js";import{NeighborIndex as i}from"./NeighborIndex.js";import{isRasterTile as l,isTileTexture as u,isImageWithType as f,isVectorTile as c}from"./TerrainData.js";import{t as a}from"../../../chunks/terrainUtilsPlanar.js";import{t as T}from"../../../chunks/terrainUtilsSpherical.js";const s={[o.Global]:T,[o.Local]:a};function S(n,t){n||console.warn("Terrain: "+t)}let E=!1,m=!1;function p(n){m=n,E=E||n}function H(n){E=n}function O(n,t){if(E&&!n){const n=(new Error).stack?.slice(5);throw console.warn("Terrain internal: "+(t??"")+" at "+n),new Error("Assertion failed"+(t?": "+t:""))}}function y(n){return I(n)?{fullExtent:n.fullExtent,minScale:n.layer.minScale,maxScale:n.layer.maxScale,tilemapCache:null}:n.layer}function _(n){return"imagery-tile"===n?.type||"wcs"===n?.type}function I(n){return"imagery-tile-3d"===n?.type}function R(n){return"tile-3d"===n?.type}function d(n){return"vector-tile-3d"===n?.type}function N(n){return"wmts-3d"===n?.type}function U(n){return"elevation-3d"===n?.type}function W(n){return"elevation"===n?.type}function x(n){return"group"===n?.type}function A(n){return n&&(R(n)||N(n)||I(n)||d(n))}function h(n){return n&&(R(n)||I(n)||d(n)||N(n))}function L(n){return h(n)||U(n)}function g(n){return l(n?.sourceLayerInfo?.data)}function w(n){return v(n?.sourceLayerInfo)||!!n?.isVTLBackground}function C(n){return u(n?.sourceLayerInfo?.data)}function j(n){const t=n?.sourceLayerInfo?.data;return f(t)||t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof ImageData}function v(n){return c(n?.data)}function b(n){return null!=n&&"release"in n&&n.release(),null}function M(n){return n.fetchTile&&!1!==n.hasOverriddenFetchTile}function V(n,t,e,r,o){return s[r].checkIfTileInfoSupportedForViewSR(n,e,t,o)}function k(n,t,e){let r=null,i=null;if("wmts"===n?.type){const o=F(n,t,e);r=o.tileInfo,i=o.fullExtent}else{i=_(n)?n.getCompatibleFullExtent(t):n.fullExtent;const l=e===o.Local;if(_(n))r=n.getCompatibleTileInfo(t,i,l);else if("vector-tile"===n?.type){r=l&&!D(t)||G.force512VTL?n.tileInfo:n.tileInfo.getCompatibleForVTL(256)}else r=n.tileInfo}const l="tilemapCache"in n?n.tilemapCache?.effectiveMaxLOD:void 0;return null!=r&&null!=i&&null==V(r,i,t,e,l)?{tileInfo:r,fullExtent:i}:null}function F(t,e,o){const i=r(t);if(null!=i){if(!n.isCollection(i))return{tileInfo:i.tileInfo,fullExtent:i.fullExtent};{const n=i.find((n=>null==V(n.tileInfo,n.fullExtent,e,o)));if(n)return{tileInfo:n.tileInfo,fullExtent:n.fullExtent}}}return{tileInfo:null,fullExtent:null}}function D(n){return n.isWGS84||n.isWebMercator||t(n)||!e(n)}const G={force512VTL:!1};function B(n){return"["+n[0]+","+n[1]+","+n[2]+"]"}function P(n){return"("+n[0]+","+n[1]+","+n[2]+")"}function q(n,t,e=en){return Math.abs(n-t)<e}function z(n){return n===i.NORTH_EAST?i.SOUTH_WEST:n===i.NORTH_WEST?i.SOUTH_EAST:n===i.SOUTH_WEST?i.NORTH_EAST:i.NORTH_WEST}function J(n){return n===i.NORTH?i.SOUTH:n===i.EAST?i.WEST:n===i.SOUTH?i.NORTH:i.EAST}function K(n){return n===i.NORTH_WEST||n===i.SOUTH_WEST}function Q(n){return n===i.NORTH_WEST||n===i.NORTH_EAST}function X(n){return n===i.NORTH_WEST||n===i.WEST||n===i.SOUTH_WEST}function Y(n){return n===i.NORTH_EAST||n===i.EAST||n===i.SOUTH_EAST}function Z(n){return n===i.SOUTH_EAST||n===i.SOUTH||n===i.SOUTH_WEST}function $(n){return n===i.NORTH_EAST||n===i.NORTH||n===i.NORTH_WEST}const nn=[i.NORTH,i.EAST,i.SOUTH,i.WEST],tn=[i.NORTH_EAST,i.SOUTH_EAST,i.SOUTH_WEST,i.NORTH_WEST],en=1e-5;export{q as almostEquals,V as checkIfTileInfoSupportedForView,H as enableInternalTerrainChecks,E as enableTerrainInternalChecks,p as enableTerrainWaterproofChecks,m as enableWaterproofTests,en as eps,y as getLayerWithExtentRange,F as getTileInfoAndExtentFromWMTSLayer,k as getTiledLayerInfo,O as internalAssert,A as isBlendableLayerView,Y as isEast,W as isElevationLayer,U as isElevationLayerView,x as isGroupLayerView,j as isImageSourceRenderInfo,I as isImageryTileLayerView,g as isImageryTileRenderInfo,h as isMapTileLayerView,$ as isNorth,Q as isNorthCorner,_ as isProjectableRasterLayer,Z as isSouth,L as isSurfaceLayerView,C as isTextureTileRenderInfo,R as isTileLayerView,d as isVectorTileLayerView,v as isVectorTilePerLayerInfo,w as isVectorTileRenderInfo,N as isWMTSLayerView,X as isWest,K as isWestCorner,B as lij2s,tn as neighborCornerIndices,nn as neighborEdgeIndices,z as oppositeCorner,J as oppositeEdge,b as releaseTerrainData,G as test,M as useFetchTileForLayer,P as v32s,D as vtlAssumes256PixelSizeAsDefault,S as weakAssert};
5
+ import n from"../../../core/Collection.js";import{isCGCS2000 as t,isEarth as e}from"../../../geometry/support/spatialReferenceUtils.js";import{getTileMaxtrixSetFromActiveLayer as r}from"../../../layers/support/layerUtils.js";import{ViewingMode as o}from"../../ViewingMode.js";import{NeighborIndex as i}from"./NeighborIndex.js";import{isRasterTile as u,isTileTexture as l,isImageWithType as f,isVectorTile as c}from"./TerrainData.js";import{t as T}from"../../../chunks/terrainUtilsPlanar.js";import{t as a}from"../../../chunks/terrainUtilsSpherical.js";const s={[o.Global]:a,[o.Local]:T};function S(n,t){n||console.warn("Terrain: "+t)}let E=!1,p=!1;function H(n){p=n,E=E||n}function O(n){E=n}function m(n,t){if(E&&!n){const n=(new Error).stack?.slice(5);throw console.warn("Terrain internal: "+(t??"")+" at "+n),new Error("Assertion failed"+(t?": "+t:""))}}function _(n){return"imagery-tile"===n?.type||"wcs"===n?.type}function I(n){return"imagery-tile-3d"===n?.type}function y(n){return"tile-3d"===n?.type}function R(n){return"vector-tile-3d"===n?.type}function d(n){return"wmts-3d"===n?.type}function N(n){return"elevation-3d"===n?.type}function U(n){return"elevation"===n?.type}function W(n){return"group"===n?.type}function A(n){return n&&(y(n)||d(n)||I(n)||R(n))}function x(n){return n&&(y(n)||I(n)||R(n)||d(n))}function L(n){return x(n)||N(n)}function g(n){return u(n?.sourceLayerInfo?.data)}function h(n){return v(n?.sourceLayerInfo)||!!n?.isVTLBackground}function w(n){return l(n?.sourceLayerInfo?.data)}function j(n){const t=n?.sourceLayerInfo?.data;return f(t)||t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof ImageData}function v(n){return c(n?.data)}function C(n){return null!=n&&"release"in n&&n.release(),null}function b(n){return n.fetchTile&&!1!==n.hasOverriddenFetchTile}function M(n,t,e,r,o){return s[r].checkIfTileInfoSupportedForViewSR(n,e,t,o)}function V(n,t,e){let r=null,i=null;if("wmts"===n?.type){const o=k(n,t,e);r=o.tileInfo,i=o.fullExtent}else{i=_(n)?n.getCompatibleFullExtent(t):n.fullExtent;const u=e===o.Local;if(_(n))r=n.getCompatibleTileInfo(t,i,u);else if("vector-tile"===n?.type){r=u&&!F(t)||D.force512VTL?n.tileInfo:n.tileInfo.getCompatibleForVTL(256)}else r=n.tileInfo}const u="tilemapCache"in n?n.tilemapCache?.effectiveMaxLOD:void 0;return null!=r&&null!=i&&null==M(r,i,t,e,u)?{tileInfo:r,fullExtent:i}:null}function k(t,e,o){const i=r(t);if(null!=i){if(!n.isCollection(i))return{tileInfo:i.tileInfo,fullExtent:i.fullExtent};{const n=i.find((n=>null==M(n.tileInfo,n.fullExtent,e,o)));if(n)return{tileInfo:n.tileInfo,fullExtent:n.fullExtent}}}return{tileInfo:null,fullExtent:null}}function F(n){return n.isWGS84||n.isWebMercator||t(n)||!e(n)}const D={force512VTL:!1};function G(n){return"["+n[0]+","+n[1]+","+n[2]+"]"}function B(n){return"("+n[0]+","+n[1]+","+n[2]+")"}function P(n,t,e=tn){return Math.abs(n-t)<e}function q(n){return n===i.NORTH_EAST?i.SOUTH_WEST:n===i.NORTH_WEST?i.SOUTH_EAST:n===i.SOUTH_WEST?i.NORTH_EAST:i.NORTH_WEST}function z(n){return n===i.NORTH?i.SOUTH:n===i.EAST?i.WEST:n===i.SOUTH?i.NORTH:i.EAST}function J(n){return n===i.NORTH_WEST||n===i.SOUTH_WEST}function K(n){return n===i.NORTH_WEST||n===i.NORTH_EAST}function Q(n){return n===i.NORTH_WEST||n===i.WEST||n===i.SOUTH_WEST}function X(n){return n===i.NORTH_EAST||n===i.EAST||n===i.SOUTH_EAST}function Y(n){return n===i.SOUTH_EAST||n===i.SOUTH||n===i.SOUTH_WEST}function Z(n){return n===i.NORTH_EAST||n===i.NORTH||n===i.NORTH_WEST}const $=[i.NORTH,i.EAST,i.SOUTH,i.WEST],nn=[i.NORTH_EAST,i.SOUTH_EAST,i.SOUTH_WEST,i.NORTH_WEST],tn=1e-5;export{P as almostEquals,M as checkIfTileInfoSupportedForView,O as enableInternalTerrainChecks,E as enableTerrainInternalChecks,H as enableTerrainWaterproofChecks,p as enableWaterproofTests,tn as eps,k as getTileInfoAndExtentFromWMTSLayer,V as getTiledLayerInfo,m as internalAssert,A as isBlendableLayerView,X as isEast,U as isElevationLayer,N as isElevationLayerView,W as isGroupLayerView,j as isImageSourceRenderInfo,I as isImageryTileLayerView,g as isImageryTileRenderInfo,x as isMapTileLayerView,Z as isNorth,K as isNorthCorner,_ as isProjectableRasterLayer,Y as isSouth,L as isSurfaceLayerView,w as isTextureTileRenderInfo,y as isTileLayerView,R as isVectorTileLayerView,v as isVectorTilePerLayerInfo,h as isVectorTileRenderInfo,d as isWMTSLayerView,Q as isWest,J as isWestCorner,G as lij2s,nn as neighborCornerIndices,$ as neighborEdgeIndices,q as oppositeCorner,z as oppositeEdge,C as releaseTerrainData,D as test,b as useFetchTileForLayer,B as v32s,F as vtlAssumes256PixelSizeAsDefault,S as weakAssert};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.31/esri/copyright.txt for details.
4
4
  */
5
- import t from"../../../core/PooledArray.js";import{RenderOrder as e}from"./RenderOrder.js";class n{constructor(){this._queue=new t,this.remove=()=>{}}get done(){return 0===this._queue.length&&(!this._last||this._last.isLeaf)}resetOne(t){this._queue.clear(),this._queue.push(t),this._last=void 0}reset(t=null){this._queue.clear(),null!=t&&this._queue.pushArray(t),this._last=void 0}skipSubtree(){this._last=void 0}next(){const t=this._last?.children;return t?.[0]&&this._queue.pushArray(t),this._last=this._queue.pop(),this._last}}class r{constructor(){this._q=new t}get done(){return 0===this._q.length}reset(t){if(this._q.clear(),null!=t){this._q.pushArray(t);for(let t=0;t<this._q.length;++t){const e=this._q.data[t];e.isLeaf||this._q.pushArray(e.children)}}}next(){return this._q.pop()}}function s(t,e){if(Array.isArray(t))for(let n=0;n<t.length;n++)i(t[n],e);else i(t,e)}function i(t,e){if(e(t),!t.isLeaf)for(const n of t.children)i(n,e)}function o(t,e,n){if(null==e?.fullExtent)return!1;const r=e.fullExtent,s=t.extent;if(n){if(s[0]<r.xmin||s[1]<r.ymin||s[2]>r.xmax||s[3]>r.ymax)return!1}else if(r.xmin>s[2]||r.ymin>s[3]||r.xmax<s[0]||r.ymax<s[1])return!1;const i=t.surface.tilingScheme.levels[t.level].scale,o=e.minScale;if(o>0&&i>1.00000001*o)return!1;const u=e.maxScale;return!(u>0&&i<.99999999*u)}function u(t,e){const n=t.lij,r=e.lij;return n[0]-r[0]||n[1]-r[1]||n[2]-r[2]}function l(t,n,r=null){null==r||0===r.length?t===e.BACK_TO_FRONT?n.sort(c):n.sort(f):n.sort(((e,n)=>a(e,n,t,r)))}function c(t,e){const n=e.screenDepth-t.screenDepth;if(0!==n)return n;const r=t.lij,s=e.lij;return r[0]-s[0]||r[1]-s[1]||r[2]-s[2]}function f(t,e){const n=t.screenDepth-e.screenDepth;if(0!==n)return n;const r=t.lij,s=e.lij;return r[0]-s[0]||r[1]-s[1]||r[2]-s[2]}function h(t,e,n){const r=t.screenDepth,s=e.screenDepth;return r<s?-n:r>s?n:u(t,e)}function a(t,e,n,r){return _(t,r)===_(e,r)?h(t,e,n):t?n:-n}function _(t,e){for(const n of e)if(t.intersectsExtent(n))return!0;return!1}function p(t,e){const n=t.distanceToPOI-e.distanceToPOI;if(0!==n)return n;const r=t.lij,s=e.lij;return r[0]-s[0]||r[1]-s[1]||r[2]-s[2]}function d(t,e){const n=t.length;for(let r=0;r<n;++r){t.at(r).updateDistanceToPOI(e)}t.sort(p)}function m(t,e,n){let r=1,s=0,i=0;for(;t!==e;)if(r*=.5,s*=.5,i*=.5,1&t.lij[2]&&(s+=.5),1&t.lij[1]||(i+=.5),null==(t=t.parent))throw new Error("tile was not a descendant of upsampleTile");n.init(e,s,i,r)}function q(t){for(let e=0;e<t.length;e++){const n=t[e],r=n.parent;if(r)for(let t=0;t<4;t++){const e=r.children[t];if(e&&e!==n)return!0}}return!1}function x(t,e){if(!t||!e||t[0]===e[0])return!1;const n=t[0]<e[0],r=n?t:e,s=n?e:t,i=1<<s[0]-r[0];return Math.floor(s[1]/i)===r[1]&&Math.floor(s[2]/i)===r[2]}export{r as IteratorPostorder,n as IteratorPreorder,h as compareTiles,u as compareTilesByLij,a as compareTilesWithStencil,m as computeUpsampleInfo,o as fallsWithinLayer,q as hasLoadableSiblings,l as sortTiles,d as sortTilesByPOI,x as tilesAreRelated,s as traverseTilesPreorder};
5
+ import t from"../../../core/PooledArray.js";import{RenderOrder as e}from"./RenderOrder.js";import{isImageryTileLayerView as n}from"./terrainUtils.js";class r{constructor(){this._queue=new t,this.remove=()=>{}}get done(){return 0===this._queue.length&&(!this._last||this._last.isLeaf)}resetOne(t){this._queue.clear(),this._queue.push(t),this._last=void 0}reset(t=null){this._queue.clear(),null!=t&&this._queue.pushArray(t),this._last=void 0}skipSubtree(){this._last=void 0}next(){const t=this._last?.children;return t?.[0]&&this._queue.pushArray(t),this._last=this._queue.pop(),this._last}}class i{constructor(){this._q=new t}get done(){return 0===this._q.length}reset(t){if(this._q.clear(),null!=t){this._q.pushArray(t);for(let t=0;t<this._q.length;++t){const e=this._q.data[t];e.isLeaf||this._q.pushArray(e.children)}}}next(){return this._q.pop()}}function s(t,e){if(Array.isArray(t))for(let n=0;n<t.length;n++)l(t[n],e);else l(t,e)}function l(t,e){if(e(t),!t.isLeaf)for(const n of t.children)l(n,e)}function o(t,e){if(null==e)return!1;const n=u(e);if(null==n?.fullExtent)return!1;const r=n.fullExtent,i=t.extent;if(r.xmin>i[2]||r.ymin>i[3]||r.xmax<i[0]||r.ymax<i[1])return!1;const s=t.surface.tilingScheme.levels[t.level].scale,l=n.minScale;if(l>0&&s>1.00000001*l)return!1;const o=n.maxScale;return!(o>0&&s<.99999999*o)}function u(t){return n(t)?{fullExtent:t.fullExtent,minScale:t.layer.minScale,maxScale:t.layer.maxScale}:t.layer}function c(t){return n(t)||!("tilemapCache"in t.layer)?null:t.layer.tilemapCache}function a(t,e){const n=t.lij,r=e.lij;return n[0]-r[0]||n[1]-r[1]||n[2]-r[2]}function f(t,n,r=null){null==r||0===r.length?t===e.BACK_TO_FRONT?n.sort(h):n.sort(p):n.sort(((e,n)=>m(e,n,t,r)))}function h(t,e){const n=e.screenDepth-t.screenDepth;if(0!==n)return n;const r=t.lij,i=e.lij;return r[0]-i[0]||r[1]-i[1]||r[2]-i[2]}function p(t,e){const n=t.screenDepth-e.screenDepth;if(0!==n)return n;const r=t.lij,i=e.lij;return r[0]-i[0]||r[1]-i[1]||r[2]-i[2]}function _(t,e,n){const r=t.screenDepth,i=e.screenDepth;return r<i?-n:r>i?n:a(t,e)}function m(t,e,n,r){return d(t,r)===d(e,r)?_(t,e,n):t?n:-n}function d(t,e){for(const n of e)if(t.intersectsExtent(n))return!0;return!1}function q(t,e){const n=t.distanceToPOI-e.distanceToPOI;if(0!==n)return n;const r=t.lij,i=e.lij;return r[0]-i[0]||r[1]-i[1]||r[2]-i[2]}function x(t,e){const n=t.length;for(let r=0;r<n;++r){t.at(r).updateDistanceToPOI(e)}t.sort(q)}function y(t,e,n){let r=1,i=0,s=0;for(;t!==e;)if(r*=.5,i*=.5,s*=.5,1&t.lij[2]&&(i+=.5),1&t.lij[1]||(s+=.5),null==(t=t.parent))throw new Error("tile was not a descendant of upsampleTile");n.init(e,i,s,r)}function j(t){for(let e=0;e<t.length;e++){const n=t[e],r=n.parent;if(r)for(let t=0;t<4;t++){const e=r.children[t];if(e&&e!==n)return!0}}return!1}function g(t,e){if(!t||!e||t[0]===e[0])return!1;const n=t[0]<e[0],r=n?t:e,i=n?e:t,s=1<<i[0]-r[0];return Math.floor(i[1]/s)===r[1]&&Math.floor(i[2]/s)===r[2]}export{i as IteratorPostorder,r as IteratorPreorder,_ as compareTiles,a as compareTilesByLij,m as compareTilesWithStencil,y as computeUpsampleInfo,o as fallsWithinLayerView,c as getTileMapCache,j as hasLoadableSiblings,f as sortTiles,x as sortTilesByPOI,g as tilesAreRelated,s as traverseTilesPreorder};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.31/esri/copyright.txt for details.
4
4
  */
5
- import{clamp as t}from"../../../../../core/mathUtils.js";import{fromValues as e}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{createUintArray as n}from"../../lib/triangleIntersectionUtils.js";class i{constructor(t,n){this.elementCount=t,this.model=n,this._elementIndexMap=null,this._bspNodes=[],this._generatedBVH=!1,this.localMode=n.localMode,this.planetCenterZ=n.planetCenterZ,this.geometryMinZ=n.geometryMinZ,this.planetCenter=e(0,0,this.planetCenterZ),this.maxBspNodeDepth=n.maxBspNodeDepth??8,this.minElementCountForBVH=n.minElementCountForBVH??15,this.minBspNodeElementCount=n.minBspNodeElementCount??5}get elementIndexMap(){return this._ensureBVH(),this._elementIndexMap}get _skipBVH(){return this.elementCount<this.minElementCountForBVH||this.geometryMinZ<.5*this.planetCenterZ}_ensureBVH(){this._generatedBVH||this._skipBVH||0===this._bspNodes.length&&this._generateBsp()}intersectRay(t,e,n){this.elementCount<1||(this._skipBVH?this._intersectRayWithoutBVH(n):this._intersectRayWithBVH(t,e,n))}_intersectRayWithoutBVH(t){this._intersectRange(0,this.elementCount)}_intersectRange(t,e){this.model.intersectRange(t,e)}_intersectRayWithBVH(t,e,n){this._ensureBVH(),n?this._intersectGeometryWithBVHVerticalRay(t):this._intersectGeometryWithBVHGeneralRay(t,e)}_intersectGeometryWithBVHVerticalRay(t){let e=t[0],n=t[1];if(!this.localMode){const{geometryMinZ:i,planetCenterZ:s}=this,h=(i-s)/(t[2]-s);e=t[0]*h,n=t[1]*h}const{_bspNodes:i}=this;let s=0;for(;s>=0;){const t=i[s],{d:h,dim:o,minIndexIndex:a,minMidIndexIndex:r,maxMidIndexIndex:c,maxIndexIndex:d,aabb2D:l}=t;if(e<l[0]||e>l[2]||n<l[1]||n>l[3])break;if(-1===o||-1===t.child0&&-1===t.child1){this._intersectRange(a,d);break}{this._intersectRange(r,c);const i=(0===o?e:n)-h;if(i<0){if(-1===t.child0){this._intersectRange(a,r);break}s=t.child0}else{if(!(i>0))break;if(-1===t.child1){this._intersectRange(c,d);break}s=t.child1}}}}_intersectGeometryWithBVHGeneralRay(e,n){let i=e[0],s=e[1],h=n[0],o=n[1];const{geometryMinZ:a}=this;if(!this.localMode){let t=0,r=1;const c=Math.min(.5*this.planetCenterZ,a),d=e[2],l=n[2];if(d<c&&l<c)return;if(d<c&&(t=(c-d)/(l-d)),l<c&&(r=(c-d)/(l-d)),t>r)return;const m=(1-t)*e[0]+t*n[0],x=(1-t)*e[1]+t*n[1],u=(1-t)*e[2]+t*n[2],M=(1-r)*e[0]+r*n[0],p=(1-r)*e[1]+r*n[1],f=(1-r)*e[2]+r*n[2],{planetCenterZ:_}=this,g=a-_,I=g/(u-_);i=m*I,s=x*I;const B=g/(f-_);h=M*B,o=p*B}const r=h-i,c=o-s,d=this._bspNodes,l=[0,0,1];let m=0;for(;m<l.length;){const e=l[m];let n=l[m+1],h=l[m+2];if(m+=3,n>h)continue;const o=d[e],{minIndexIndex:a,maxIndexIndex:x}=o,{child0:u,child1:M,minMidIndexIndex:p,maxMidIndexIndex:f,aabb2D:_,d:g,dim:I}=o;{const t=i+n*r,e=i+h*r,s=Math.min(t,e),o=Math.max(t,e),a=_[0],c=_[2];if(o<a||c<s)continue;if(s<a){const t=(a-i)/r;r>0?n=Math.max(n,t):h=Math.min(h,t)}if(c<o){const t=(c-i)/r;r>0?h=Math.min(h,t):n=Math.max(n,t)}}{const t=s+n*c,e=s+h*c,i=Math.min(t,e),o=Math.max(t,e),a=_[1],r=_[3];if(o<a||r<i)continue;if(i<a){const t=(a-s)/c;c>0?n=Math.max(n,t):h=Math.min(h,t)}if(r<o){const t=(r-s)/c;c>0?h=Math.min(h,t):n=Math.max(n,t)}}if(-1===u&&-1===M)this._intersectRange(a,x);else{const e=0===I?i:s,o=0===I?r:c,d=e+n*o,m=e+h*o,_=Math.min(d,m),B=Math.max(d,m),V=t((g-e)/o,0,1);a<p&&_<=g&&(-1!==u?(l.push(u),l.push(o>=0?n:Math.max(n,V)),l.push(o>=0?Math.min(h,V):h)):this._intersectRange(a,p)),this._intersectRange(p,f),f<x&&g<=B&&(-1!==M?(l.push(M),l.push(o>=0?Math.max(n,V):n),l.push(o>=0?h:Math.min(h,V))):this._intersectRange(f,x))}}}_generateBsp(){const{elementCount:t}=this;if(t<1)return;const e=n(t,t);this._elementIndexMap=e;for(let n=0;n<t;++n)e[n]=n;const i=this.model.getAabbs2D();let a=0;const d=this._bspNodes;d.length=0;const{localMode:l}=this;let m=!1;if(!l){const{planetCenterZ:t,geometryMinZ:e}=this;m=t>=0||e<.5*t}const x=[],u=(t,e,n,i,s)=>{x.push(t),x.push(e),x.push(n),x.push(i<0?-1:(s?0:1)+2*i)},{maxBspNodeDepth:M,minBspNodeElementCount:p}=this,f=(t,n,a,x,f)=>{const _=d.length;if(_>0&&(m||a>=M||n-t<p))return;const g=[0,0,0,0];r(g,t,n,e,i);const{d:I,dim:B}=l?s(g):h(g),{rangeMidStart:V,rangeMidEnd:b}=o(t,n,B,I,e,i),C=a===M-1,H=!C&&V>=t+p,R=!C&&n>=b+p;if(H||R||0===_){const e=new c(t,V,b,n,B,I,g);if(H&&u(t,V,a+1,_,!0),R&&u(b,n,a+1,_,!1),d.push(e),-1!==x){const t=d[x];f?t.child0=_:t.child1=_}}};for(u(0,t,0,-1,!1);a<x.length;){const t=x[a],e=x[a+1],n=x[a+2],i=x[a+3];a+=4;const s=i>>1;f(t,e,n,s,i-(s<<1)==0)}this._generatedBVH=!0}}function s(t){const e=t[0],n=t[1],i=t[2],s=t[3];let h,o;return i-e>=s-n?(o=.5*(e+i),h=0):(o=.5*(n+s),h=1),{d:o,dim:h}}function h(t){const e=t[0],n=t[1],i=t[2],s=t[3];let h,o;return i-e>=s-n?(h=0,o=.5*(e+i)):(h=1,o=.5*(n+s)),{dim:h,d:o}}function o(t,e,n,i,s,h){let o=t;{let t=e;for(;o<t;){const e=s[o];a(e,n,i,h)<0?++o:(--t,s[o]=s[t],s[t]=e)}}const r=o;let c=o,d=e;for(;c<d;){const t=s[d-1];a(t,n,i,h)>0?--d:(s[d-1]=s[c],s[c]=t,++c)}return{rangeMidStart:r,rangeMidEnd:d}}function a(t,e,n,i){const s=4*t,h=i[s+0+e];return i[s+2+e]<n?-1:h>n?1:0}function r(t,e,n,i,s){let h=1/0,o=1/0,a=-1/0,r=-1/0;for(let c=e;c<n;++c){const t=4*i[c];h=Math.min(h,s[t+0]),o=Math.min(o,s[t+1]),a=Math.max(a,s[t+2]),r=Math.max(r,s[t+3])}t[0]=h,t[1]=o,t[2]=a,t[3]=r}class c{constructor(t,e,n,i,s,h,o){this.minIndexIndex=t,this.minMidIndexIndex=e,this.maxMidIndexIndex=n,this.maxIndexIndex=i,this.dim=s,this.d=h,this.aabb2D=o,this.child0=-1,this.child1=-1}}export{i as ElevationAgnosticBVH};
5
+ import{clamp as t}from"../../../../../core/mathUtils.js";import{fromValues as e}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{createUintArray as n}from"../../lib/triangleIntersectionUtils.js";class i{constructor(t,n){this.elementCount=t,this.model=n,this._elementIndexMap=null,this._bspNodes=[],this._generatedBVH=!1,this.localMode=n.localMode,this.planetCenterZ=n.planetCenterZ,this.geometryMinZ=n.geometryMinZ,this.planetCenter=e(0,0,this.planetCenterZ),this.maxBspNodeDepth=n.maxBspNodeDepth??8,this.minElementCountForBVH=n.minElementCountForBVH??15,this.minBspNodeElementCount=n.minBspNodeElementCount??5}get elementIndexMap(){return this._ensureBVH(),this._elementIndexMap}get _skipBVH(){return this.elementCount<this.minElementCountForBVH||this.geometryMinZ<.5*this.planetCenterZ}_ensureBVH(){this._generatedBVH||this._skipBVH||0===this._bspNodes.length&&this._generateBsp()}intersectRay(t,e,n){this.elementCount<1||(this._skipBVH?this._intersectRayWithoutBVH(n):this._intersectRayWithBVH(t,e,n))}_intersectRayWithoutBVH(t){this._intersectRange(0,this.elementCount)}_intersectRange(t,e){this.model.intersectRange(t,e)}_intersectRayWithBVH(t,e,n){this._ensureBVH(),n?this._intersectGeometryWithBVHVerticalRay(t):this._intersectGeometryWithBVHGeneralRay(t,e)}_intersectGeometryWithBVHVerticalRay(t){let e=t[0],n=t[1];if(!this.localMode){const{geometryMinZ:i,planetCenterZ:s}=this,h=(i-s)/(t[2]-s);e=t[0]*h,n=t[1]*h}const{_bspNodes:i}=this;let s=0;for(;s>=0;){const t=i[s],{d:h,dim:a,minIndexIndex:o,minMidIndexIndex:r,maxMidIndexIndex:c,maxIndexIndex:m,aabb2D:l}=t;if(e<l[0]||e>l[2]||n<l[1]||n>l[3])break;if(-1===a||-1===t.child0&&-1===t.child1){this._intersectRange(o,m);break}{this._intersectRange(r,c);const i=(0===a?e:n)-h;if(i<0){if(-1===t.child0){this._intersectRange(o,r);break}s=t.child0}else{if(!(i>0))break;if(-1===t.child1){this._intersectRange(c,m);break}s=t.child1}}}}_intersectGeometryWithBVHGeneralRay(e,n){let i=e[0],s=e[1],h=n[0],a=n[1];const{geometryMinZ:o}=this;if(!this.localMode){let t=0,r=1;const c=Math.min(.5*this.planetCenterZ,o),m=e[2],l=n[2];if(m<c&&l<c)return;if(m<c&&(t=(c-m)/(l-m)),l<c&&(r=(c-m)/(l-m)),t>r)return;const d=(1-t)*e[0]+t*n[0],M=(1-t)*e[1]+t*n[1],x=(1-t)*e[2]+t*n[2],u=(1-r)*e[0]+r*n[0],p=(1-r)*e[1]+r*n[1],f=(1-r)*e[2]+r*n[2],{planetCenterZ:_}=this,g=o-_,I=g/(x-_);i=d*I,s=M*I;const B=g/(f-_);h=u*B,a=p*B}const r=h-i,c=a-s,m=this._bspNodes;let l=1;{const{aabb2D:t}=m[0],e=(t,e,n,i)=>{if(Math.abs(e)<1e-5*Math.max(i-n,1))return!1;const s=e>0,h=s?i:n,a=t+l*e;return(s?a<h:a>h)&&(l=Math.max((h-t)/e,l),!0)},n=()=>e(i,r,t[0],t[2]),h=()=>e(s,c,t[1],t[3]);Math.abs(r)>=Math.abs(c)?n()||h():h()||n()}const d=[0,0,l];let M=0;for(;M<d.length;){const e=d[M];let n=d[M+1],h=d[M+2];if(M+=3,n>h)continue;const a=m[e],{minIndexIndex:o,maxIndexIndex:x}=a,{child0:u,child1:p,minMidIndexIndex:f,maxMidIndexIndex:_,aabb2D:g,d:I,dim:B}=a;{const t=i+n*r,e=i+h*r,s=Math.min(t,e),a=Math.max(t,e),o=g[0],c=g[2];if(a<o||c<s)continue;if(s<o){const t=(o-i)/r;r>0?n=Math.max(n,t):h=Math.min(h,t)}if(c<a){const t=(c-i)/r;r>0?h=Math.min(h,t):n=Math.max(n,t)}}{const t=s+n*c,e=s+h*c,i=Math.min(t,e),a=Math.max(t,e),o=g[1],r=g[3];if(a<o||r<i)continue;if(i<o){const t=(o-s)/c;c>0?n=Math.max(n,t):h=Math.min(h,t)}if(r<a){const t=(r-s)/c;c>0?h=Math.min(h,t):n=Math.max(n,t)}}if(-1===u&&-1===p)this._intersectRange(o,x);else{const e=0===B?i:s,a=0===B?r:c,m=e+n*a,M=e+h*a,g=Math.min(m,M),b=Math.max(m,M),V=t((I-e)/a,0,l);o<f&&g<=I&&(-1!==u?(d.push(u),d.push(a>=0?n:Math.max(n,V)),d.push(a>=0?Math.min(h,V):h)):this._intersectRange(o,f)),this._intersectRange(f,_),_<x&&I<=b&&(-1!==p?(d.push(p),d.push(a>=0?Math.max(n,V):n),d.push(a>=0?h:Math.min(h,V))):this._intersectRange(_,x))}}}_generateBsp(){const{elementCount:t}=this;if(t<1)return;const e=n(t,t);this._elementIndexMap=e;for(let n=0;n<t;++n)e[n]=n;const i=this.model.getAabbs2D();let o=0;const m=this._bspNodes;m.length=0;const{localMode:l}=this;let d=!1;if(!l){const{planetCenterZ:t,geometryMinZ:e}=this;d=t>=0||e<.5*t}const M=[],x=(t,e,n,i,s)=>{M.push(t),M.push(e),M.push(n),M.push(i<0?-1:(s?0:1)+2*i)},{maxBspNodeDepth:u,minBspNodeElementCount:p}=this,f=(t,n,o,M,f)=>{const _=m.length;if(_>0&&(d||o>=u||n-t<p))return;const g=[0,0,0,0];r(g,t,n,e,i);const{d:I,dim:B}=l?s(g):h(g),{rangeMidStart:b,rangeMidEnd:V}=a(t,n,B,I,e,i),C=o===u-1,H=!C&&b>=t+p,R=!C&&n>=V+p;if(H||R||0===_){const e=new c(t,b,V,n,B,I,g);if(H&&x(t,b,o+1,_,!0),R&&x(V,n,o+1,_,!1),m.push(e),-1!==M){const t=m[M];f?t.child0=_:t.child1=_}}};for(x(0,t,0,-1,!1);o<M.length;){const t=M[o],e=M[o+1],n=M[o+2],i=M[o+3];o+=4;const s=i>>1;f(t,e,n,s,i-(s<<1)==0)}this._generatedBVH=!0}}function s(t){const e=t[0],n=t[1],i=t[2],s=t[3];let h,a;return i-e>=s-n?(a=.5*(e+i),h=0):(a=.5*(n+s),h=1),{d:a,dim:h}}function h(t){const e=t[0],n=t[1],i=t[2],s=t[3];let h,a;return i-e>=s-n?(h=0,a=.5*(e+i)):(h=1,a=.5*(n+s)),{dim:h,d:a}}function a(t,e,n,i,s,h){let a=t;{let t=e;for(;a<t;){const e=s[a];o(e,n,i,h)<0?++a:(--t,s[a]=s[t],s[t]=e)}}const r=a;let c=a,m=e;for(;c<m;){const t=s[m-1];o(t,n,i,h)>0?--m:(s[m-1]=s[c],s[c]=t,++c)}return{rangeMidStart:r,rangeMidEnd:m}}function o(t,e,n,i){const s=4*t,h=i[s+0+e];return i[s+2+e]<n?-1:h>n?1:0}function r(t,e,n,i,s){let h=1/0,a=1/0,o=-1/0,r=-1/0;for(let c=e;c<n;++c){const t=4*i[c];h=Math.min(h,s[t+0]),a=Math.min(a,s[t+1]),o=Math.max(o,s[t+2]),r=Math.max(r,s[t+3])}t[0]=h,t[1]=a,t[2]=o,t[3]=r}class c{constructor(t,e,n,i,s,h,a){this.minIndexIndex=t,this.minMidIndexIndex=e,this.maxMidIndexIndex=n,this.maxIndexIndex=i,this.dim=s,this.d=h,this.aabb2D=a,this.child0=-1,this.child1=-1}}export{i as ElevationAgnosticBVH};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.31/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../../../chunks/tslib.es6.js";import{releaseMaybe as t}from"../../../../../../core/maybe.js";import{invert as r,transpose as o}from"../../../../../../core/libs/gl-matrix-2/math/mat3.js";import{clone as s}from"../../../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{I as a}from"../../../../../../chunks/vec32.js";import{fromArray as i,fromValues as l}from"../../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{v as n}from"../../../../../../chunks/vec42.js";import{fromValues as u}from"../../../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{ColorMixModeEnum as h}from"../../../../layers/support/symbolColorUtils.js";import{OverlayContent as p}from"../../../../terrain/OverlayContent.js";import{ComponentTechnique as d}from"./ComponentTechnique.js";import{ComponentTechniqueConfiguration as c,IntegratedMeshMode as m}from"./ComponentTechniqueConfiguration.js";import{ComponentDataType as g}from"./shader/ComponentData.glsl.js";import{VertexDiscardMode as x}from"./shader/VertexDiscardByOpacity.glsl.js";import{MaterialBase as y,parameter as b,parameterBlock as f,MaterialParameterBlock as v}from"../../../core/material/MaterialBase.js";import{RenderPassIdentifier as T}from"../../../core/renderPasses/AllRenderPasses.js";import{ShaderOutput as M}from"../../../core/shaderLibrary/ShaderOutput.js";import{NormalType as w}from"../../../core/shaderLibrary/attributes/NormalAttribute.glsl.js";import{NormalsDoubleSidedMode as O}from"../../../core/shaderLibrary/shading/Normals.glsl.js";import{PBRMode as C}from"../../../core/shaderLibrary/shading/PhysicallyBasedRenderingParameters.glsl.js";import{defaultMaskAlphaCutoff as S}from"../../../core/shaderLibrary/util/AlphaCutoff.js";import{EllipsoidMode as P}from"../../../core/shaderLibrary/util/EllipsoidMode.js";import{TwoVectorPosition as j}from"../../../core/util/TwoVectorPosition.js";import{AlphaDiscardMode as N,CullFaceOptions as q}from"../../../lib/basicInterfaces.js";import{TransparencyPassType as D}from"../../../lib/TransparencyPassType.js";import{defaultAdvancedMRRFactors as A}from"../../../materials/pbrUtils.js";class R extends y{constructor(e,t){super(),this.toMapSpace=t,this.baseColor=u(1,1,1,1),this.usePBR=!1,this.hasParametersFromSource=!1,this.mrrFactors=i(A),this.emissiveFactor=l(0,0,0),this.baseColorTexture=null,this.metallicRoughnessTexture=null,this.emissionTexture=null,this.occlusionTexture=null,this.normalTexture=null,this.objectOpacity=1,this.commonMaterialParameters=new E,this.componentParameters=new W,this.textureAlphaCutoff=S,this.alphaDiscardMode=N.Opaque,this.isIntegratedMesh=!1,this.polygonOffsetEnabled=!1,this.ellipsoidMode=P.Earth,this.hasOccludees=!1,this._techniqueConfiguration=new c;const a=new j(e.position),n=s(e.rotationScale);r(n,n),o(n,n),this.transformNormalGlobalFromModel=n,this.transformWorldFromModelTL=a.low,this.transformWorldFromModelTH=a.high,this.transformWorldFromModelRS=e.rotationScale}dispose(){this._technique=t(this._technique),this.baseColorTexture=null,this.metallicRoughnessTexture=null,this.emissionTexture=null,this.occlusionTexture=null,this.normalTexture=null}get texture(){return null!=this.baseColorTexture?this.baseColorTexture.glTexture:null}get textureMetallicRoughness(){return null!=this.metallicRoughnessTexture?this.metallicRoughnessTexture.glTexture:null}get textureEmissive(){return null!=this.emissionTexture?this.emissionTexture.glTexture:null}get textureOcclusion(){return null!=this.occlusionTexture?this.occlusionTexture.glTexture:null}get textureNormal(){return null!=this.normalTexture?this.normalTexture.glTexture:null}prepareTechnique(e,t,r,o){const s=this._techniqueConfiguration;s.hasVertexColors=o.colors,s.hasNormals=o.hasNormals,s.textureCoordinateType=o.textureCoordinates,s.hasMetallicRoughnessTexture=null!=this.metallicRoughnessTexture,s.hasEmissionTexture=null!=this.emissionTexture,s.hasOcclusionTexture=null!=this.occlusionTexture,s.hasNormalTexture=null!=this.normalTexture,s.transparencyPassType=t.identifier===T.Material&&null!=r.transparencyPassType?r.transparencyPassType:D.NONE,s.multipassEnabled=t.identifier===T.Material&&r.multipassEnabled,s.cullAboveGround=t.identifier===T.Material&&r.multipassTerrain.cullAboveGround,s.ellipsoidMode=this.ellipsoidMode,s.componentData=this.componentParameters.type,s.cullFace=this.commonMaterialParameters.cullFace,s.doubleSidedMode=this.commonMaterialParameters.doubleSided?O.View:O.None,s.hasColorTexture=null!=this.baseColorTexture;const a=this._computeWhichMaterialPass();if(s.blendingEnabled=a===F.Transparent||a===F.OpaqueAndTransparent,s.alphaDiscardMode=this.alphaDiscardMode,s.integratedMeshMode=this.isIntegratedMesh?L(r)?B(r)?m.ColorOverlayWithWater:m.ColorOverlay:m.NoOverlay:m.None,s.hasPolygonOffset=this.polygonOffsetEnabled,s.pbrMode=s.integratedMeshMode===m.ColorOverlayWithWater?C.WaterOnIntegratedMesh:this.usePBR?this.hasParametersFromSource?o.needsNormals&&this.isIntegratedMesh?C.Disabled:C.Schematic:C.Normal:C.Disabled,s.normalType=o.needsNormals?s.hasNormals?w.Compressed:w.ScreenDerivative:w.Ground,s.hasSlicePlane=null!=r.slicePlane&&this.commonMaterialParameters.hasSlicePlane,t.identifier===T.ShadowMap)s.output=M.Shadow,s.vertexDiscardMode=x.None;else if(t.identifier===T.ViewshedShadowMap)s.output=M.ViewshedShadow,s.vertexDiscardMode=x.None;else if(t.identifier===T.Highlight)s.output=M.Highlight,s.vertexDiscardMode=x.None;else{switch(a===F.OpaqueAndTransparent?s.vertexDiscardMode=t.transparent?x.Opaque:x.Transparent:s.vertexDiscardMode=x.None,s.output=t.output,s.receiveAmbientOcclusion=!1,s.receiveShadows=!1,t.output){case M.Color:s.receiveAmbientOcclusion=null!=r.ssao,s.hasOccludees=r.hasOccludees,s.receiveShadows=r.shadowMap.ready,s.hasScreenSpaceReflections=null!=r.ssr.lastFrameColor,s.hasCloudsReflections=null!=r.cloudsFade.data;break;case M.ObjectAndLayerIdColor:s.objectAndLayerIdColor=!0}s.snowCover=this.hasSnowCover(r)}return this._technique=e.releaseAndAcquire(d,s,this._technique),this._setClean(),this._technique}hasSnowCover(e){return null!=e.weather&&e.weatherVisible&&"snowy"===e.weather.type&&"enabled"===e.weather.snowCover}submit(e,t,r){if(0===this.objectOpacity)return;const o=r.renderable.geometry,s=r.components,a=r.renderable.meta.cameraDepthSquared,i=s.geometryRanges,l=s.highlightRanges,n=s.defaultShadowMapRanges;switch(this._computeWhichMaterialPass()){case F.Opaque:e.materialOpaque.submitDraw(this,o,i,a);break;case F.Transparent:e.materialTransparent.submitDraw(this,o,i,a);break;case F.OpaqueAndTransparent:e.materialOpaque.submitDraw(this,o,i,a),e.materialTransparent.submitDraw(this,o,i,a);break;case F.IntegratedMesh:e.materialIntegratedMesh.submitDraw(this,o,i,a),k(t)&&e.highlightIntegratedMesh.submitDraw(this,o,i,a)}const u=this.componentParameters.castShadows!==I.None;u&&e.shadowMap.submitDraw(this,o,i,a),null!=l&&(e.highlight.submitDraw(this,o,l,a),u&&e.highlightShadowMap.submitDraw(this,o,l,a)),t.viewshedEnabled&&e.viewshedShadowMap.submitDraw(this,o,i,a),u&&null!=n&&e.defaultShadowMap.submitDraw(this,o,n,a)}_computeWhichMaterialPass(){return this.isIntegratedMesh?F.IntegratedMesh:this.objectOpacity<1?F.Transparent:this.componentParameters.opaqueOverride===I.All?F.Opaque:this.baseColor[3]<1||this.alphaDiscardMode===N.Blend||this.alphaDiscardMode===N.MaskBlend?F.Transparent:this.componentParameters.transparent===I.None?F.Opaque:this.componentParameters.transparent===I.All?F.Transparent:F.OpaqueAndTransparent}}var F,I;e([b({vectorOps:n})],R.prototype,"baseColor",void 0),e([b()],R.prototype,"usePBR",void 0),e([b()],R.prototype,"hasParametersFromSource",void 0),e([b({vectorOps:a})],R.prototype,"mrrFactors",void 0),e([b({vectorOps:a})],R.prototype,"emissiveFactor",void 0),e([b({dispose:!0})],R.prototype,"baseColorTexture",void 0),e([b({dispose:!0})],R.prototype,"metallicRoughnessTexture",void 0),e([b({dispose:!0})],R.prototype,"emissionTexture",void 0),e([b({dispose:!0})],R.prototype,"occlusionTexture",void 0),e([b({dispose:!0})],R.prototype,"normalTexture",void 0),e([b()],R.prototype,"objectOpacity",void 0),e([f()],R.prototype,"commonMaterialParameters",void 0),e([f()],R.prototype,"componentParameters",void 0),e([b()],R.prototype,"textureAlphaCutoff",void 0),e([b()],R.prototype,"alphaDiscardMode",void 0),e([b()],R.prototype,"isIntegratedMesh",void 0),e([b()],R.prototype,"polygonOffsetEnabled",void 0),e([b()],R.prototype,"ellipsoidMode",void 0),e([b()],R.prototype,"hasOccludees",void 0),function(e){e[e.Opaque=0]="Opaque",e[e.Transparent=1]="Transparent",e[e.OpaqueAndTransparent=2]="OpaqueAndTransparent",e[e.IntegratedMesh=3]="IntegratedMesh"}(F||(F={}));class E extends v{constructor(){super(...arguments),this.doubleSided=!1,this.cullFace=q.Back,this.hasSlicePlane=!0}}e([b()],E.prototype,"doubleSided",void 0),e([b()],E.prototype,"cullFace",void 0),e([b()],E.prototype,"hasSlicePlane",void 0);class W extends v{constructor(){super(...arguments),this.externalColor=u(1,1,1,1),this.externalColorMixMode=h.Multiply,this.castShadows=I.All}get transparent(){return this.externalColor[3]<1?I.All:I.None}get opaqueOverride(){return this.externalColorMixMode===h.Replace&&1===this.externalColor[3]?I.All:I.None}get visible(){return this.externalColor[3]>0?I.All:I.None}get type(){return g.Uniform}}e([b({vectorOps:n})],W.prototype,"externalColor",void 0),e([b()],W.prototype,"externalColorMixMode",void 0),e([b()],W.prototype,"castShadows",void 0),function(e){e[e.All=0]="All",e[e.Some=1]="Some",e[e.None=2]="None"}(I||(I={}));class _ extends v{constructor(){super(...arguments),this.texture=null,this.transparent=I.None,this.opaqueOverride=I.None,this.castShadows=I.None}get type(){return g.Varying}}function k(e){return null!=e.overlay?.getTexture(p.Highlight)}function B(e){return null!=e.overlay?.getTexture(p.WaterNormal)}function L(e){return null!=e.overlay?.getTexture(p.ColorNoRasterImage)}e([b()],_.prototype,"texture",void 0),e([b()],_.prototype,"transparent",void 0),e([b()],_.prototype,"opaqueOverride",void 0),e([b()],_.prototype,"castShadows",void 0);export{E as CommonMaterialParameters,R as ComponentMaterial,I as ComponentParameterSummary,W as ComponentParametersUniform,_ as ComponentParametersVarying};
5
+ import{_ as e}from"../../../../../../chunks/tslib.es6.js";import{releaseMaybe as t}from"../../../../../../core/maybe.js";import{invert as r,transpose as o}from"../../../../../../core/libs/gl-matrix-2/math/mat3.js";import{clone as s}from"../../../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{I as a}from"../../../../../../chunks/vec32.js";import{fromArray as i,fromValues as l}from"../../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{v as n}from"../../../../../../chunks/vec42.js";import{fromValues as u}from"../../../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{ColorMixModeEnum as h}from"../../../../layers/support/symbolColorUtils.js";import{OverlayContent as p}from"../../../../terrain/OverlayContent.js";import{ComponentTechnique as d}from"./ComponentTechnique.js";import{ComponentTechniqueConfiguration as c,IntegratedMeshMode as m}from"./ComponentTechniqueConfiguration.js";import{ComponentDataType as g}from"./shader/ComponentData.glsl.js";import{VertexDiscardMode as x}from"./shader/VertexDiscardByOpacity.glsl.js";import{MaterialBase as y,parameter as b,parameterBlock as f,MaterialParameterBlock as v}from"../../../core/material/MaterialBase.js";import{RenderPassIdentifier as T}from"../../../core/renderPasses/AllRenderPasses.js";import{ShaderOutput as M}from"../../../core/shaderLibrary/ShaderOutput.js";import{NormalType as w}from"../../../core/shaderLibrary/attributes/NormalAttribute.glsl.js";import{NormalsDoubleSidedMode as O}from"../../../core/shaderLibrary/shading/Normals.glsl.js";import{PBRMode as C}from"../../../core/shaderLibrary/shading/PhysicallyBasedRenderingParameters.glsl.js";import{alphaCutoff as S}from"../../../core/shaderLibrary/util/AlphaCutoff.js";import{EllipsoidMode as P}from"../../../core/shaderLibrary/util/EllipsoidMode.js";import{TwoVectorPosition as j}from"../../../core/util/TwoVectorPosition.js";import{AlphaDiscardMode as N,CullFaceOptions as q}from"../../../lib/basicInterfaces.js";import{TransparencyPassType as D}from"../../../lib/TransparencyPassType.js";import{defaultAdvancedMRRFactors as A}from"../../../materials/pbrUtils.js";class R extends y{constructor(e,t){super(),this.toMapSpace=t,this.baseColor=u(1,1,1,1),this.usePBR=!1,this.hasParametersFromSource=!1,this.mrrFactors=i(A),this.emissiveFactor=l(0,0,0),this.baseColorTexture=null,this.metallicRoughnessTexture=null,this.emissionTexture=null,this.occlusionTexture=null,this.normalTexture=null,this.objectOpacity=1,this.commonMaterialParameters=new E,this.componentParameters=new W,this.textureAlphaCutoff=S,this.alphaDiscardMode=N.Opaque,this.isIntegratedMesh=!1,this.polygonOffsetEnabled=!1,this.ellipsoidMode=P.Earth,this.hasOccludees=!1,this._techniqueConfiguration=new c;const a=new j(e.position),n=s(e.rotationScale);r(n,n),o(n,n),this.transformNormalGlobalFromModel=n,this.transformWorldFromModelTL=a.low,this.transformWorldFromModelTH=a.high,this.transformWorldFromModelRS=e.rotationScale}dispose(){this._technique=t(this._technique),this.baseColorTexture=null,this.metallicRoughnessTexture=null,this.emissionTexture=null,this.occlusionTexture=null,this.normalTexture=null}get texture(){return null!=this.baseColorTexture?this.baseColorTexture.glTexture:null}get textureMetallicRoughness(){return null!=this.metallicRoughnessTexture?this.metallicRoughnessTexture.glTexture:null}get textureEmissive(){return null!=this.emissionTexture?this.emissionTexture.glTexture:null}get textureOcclusion(){return null!=this.occlusionTexture?this.occlusionTexture.glTexture:null}get textureNormal(){return null!=this.normalTexture?this.normalTexture.glTexture:null}prepareTechnique(e,t,r,o){const s=this._techniqueConfiguration;s.hasVertexColors=o.colors,s.hasNormals=o.hasNormals,s.textureCoordinateType=o.textureCoordinates,s.hasMetallicRoughnessTexture=null!=this.metallicRoughnessTexture,s.hasEmissionTexture=null!=this.emissionTexture,s.hasOcclusionTexture=null!=this.occlusionTexture,s.hasNormalTexture=null!=this.normalTexture,s.transparencyPassType=t.identifier===T.Material&&null!=r.transparencyPassType?r.transparencyPassType:D.NONE,s.multipassEnabled=t.identifier===T.Material&&r.multipassEnabled,s.cullAboveGround=t.identifier===T.Material&&r.multipassTerrain.cullAboveGround,s.ellipsoidMode=this.ellipsoidMode,s.componentData=this.componentParameters.type,s.cullFace=this.commonMaterialParameters.cullFace,s.doubleSidedMode=this.commonMaterialParameters.doubleSided?O.View:O.None,s.hasColorTexture=null!=this.baseColorTexture;const a=this._computeWhichMaterialPass();if(s.blendingEnabled=a===F.Transparent||a===F.OpaqueAndTransparent,s.alphaDiscardMode=this.alphaDiscardMode,s.integratedMeshMode=this.isIntegratedMesh?L(r)?B(r)?m.ColorOverlayWithWater:m.ColorOverlay:m.NoOverlay:m.None,s.hasPolygonOffset=this.polygonOffsetEnabled,s.pbrMode=s.integratedMeshMode===m.ColorOverlayWithWater?C.WaterOnIntegratedMesh:this.usePBR?this.hasParametersFromSource?o.needsNormals&&this.isIntegratedMesh?C.Disabled:C.Schematic:C.Normal:C.Disabled,s.normalType=o.needsNormals?s.hasNormals?w.Compressed:w.ScreenDerivative:w.Ground,s.hasSlicePlane=null!=r.slicePlane&&this.commonMaterialParameters.hasSlicePlane,t.identifier===T.ShadowMap)s.output=M.Shadow,s.vertexDiscardMode=x.None;else if(t.identifier===T.ViewshedShadowMap)s.output=M.ViewshedShadow,s.vertexDiscardMode=x.None;else if(t.identifier===T.Highlight)s.output=M.Highlight,s.vertexDiscardMode=x.None;else{switch(a===F.OpaqueAndTransparent?s.vertexDiscardMode=t.transparent?x.Opaque:x.Transparent:s.vertexDiscardMode=x.None,s.output=t.output,s.receiveAmbientOcclusion=!1,s.receiveShadows=!1,t.output){case M.Color:s.receiveAmbientOcclusion=null!=r.ssao,s.hasOccludees=r.hasOccludees,s.receiveShadows=r.shadowMap.ready,s.hasScreenSpaceReflections=null!=r.ssr.lastFrameColor,s.hasCloudsReflections=null!=r.cloudsFade.data;break;case M.ObjectAndLayerIdColor:s.objectAndLayerIdColor=!0}s.snowCover=this.hasSnowCover(r)}return this._technique=e.releaseAndAcquire(d,s,this._technique),this._setClean(),this._technique}hasSnowCover(e){return null!=e.weather&&e.weatherVisible&&"snowy"===e.weather.type&&"enabled"===e.weather.snowCover}submit(e,t,r){if(0===this.objectOpacity)return;const o=r.renderable.geometry,s=r.components,a=r.renderable.meta.cameraDepthSquared,i=s.geometryRanges,l=s.highlightRanges,n=s.defaultShadowMapRanges;switch(this._computeWhichMaterialPass()){case F.Opaque:e.materialOpaque.submitDraw(this,o,i,a);break;case F.Transparent:e.materialTransparent.submitDraw(this,o,i,a);break;case F.OpaqueAndTransparent:e.materialOpaque.submitDraw(this,o,i,a),e.materialTransparent.submitDraw(this,o,i,a);break;case F.IntegratedMesh:e.materialIntegratedMesh.submitDraw(this,o,i,a),k(t)&&e.highlightIntegratedMesh.submitDraw(this,o,i,a)}const u=this.componentParameters.castShadows!==I.None;u&&e.shadowMap.submitDraw(this,o,i,a),null!=l&&(e.highlight.submitDraw(this,o,l,a),u&&e.highlightShadowMap.submitDraw(this,o,l,a)),t.viewshedEnabled&&e.viewshedShadowMap.submitDraw(this,o,i,a),u&&null!=n&&e.defaultShadowMap.submitDraw(this,o,n,a)}_computeWhichMaterialPass(){return this.isIntegratedMesh?F.IntegratedMesh:this.objectOpacity<1?F.Transparent:this.componentParameters.opaqueOverride===I.All?F.Opaque:this.baseColor[3]<1||this.alphaDiscardMode===N.Blend||this.alphaDiscardMode===N.MaskBlend?F.Transparent:this.componentParameters.transparent===I.None?F.Opaque:this.componentParameters.transparent===I.All?F.Transparent:F.OpaqueAndTransparent}}var F,I;e([b({vectorOps:n})],R.prototype,"baseColor",void 0),e([b()],R.prototype,"usePBR",void 0),e([b()],R.prototype,"hasParametersFromSource",void 0),e([b({vectorOps:a})],R.prototype,"mrrFactors",void 0),e([b({vectorOps:a})],R.prototype,"emissiveFactor",void 0),e([b({dispose:!0})],R.prototype,"baseColorTexture",void 0),e([b({dispose:!0})],R.prototype,"metallicRoughnessTexture",void 0),e([b({dispose:!0})],R.prototype,"emissionTexture",void 0),e([b({dispose:!0})],R.prototype,"occlusionTexture",void 0),e([b({dispose:!0})],R.prototype,"normalTexture",void 0),e([b()],R.prototype,"objectOpacity",void 0),e([f()],R.prototype,"commonMaterialParameters",void 0),e([f()],R.prototype,"componentParameters",void 0),e([b()],R.prototype,"textureAlphaCutoff",void 0),e([b()],R.prototype,"alphaDiscardMode",void 0),e([b()],R.prototype,"isIntegratedMesh",void 0),e([b()],R.prototype,"polygonOffsetEnabled",void 0),e([b()],R.prototype,"ellipsoidMode",void 0),e([b()],R.prototype,"hasOccludees",void 0),function(e){e[e.Opaque=0]="Opaque",e[e.Transparent=1]="Transparent",e[e.OpaqueAndTransparent=2]="OpaqueAndTransparent",e[e.IntegratedMesh=3]="IntegratedMesh"}(F||(F={}));class E extends v{constructor(){super(...arguments),this.doubleSided=!1,this.cullFace=q.Back,this.hasSlicePlane=!0}}e([b()],E.prototype,"doubleSided",void 0),e([b()],E.prototype,"cullFace",void 0),e([b()],E.prototype,"hasSlicePlane",void 0);class W extends v{constructor(){super(...arguments),this.externalColor=u(1,1,1,1),this.externalColorMixMode=h.Multiply,this.castShadows=I.All}get transparent(){return this.externalColor[3]<1?I.All:I.None}get opaqueOverride(){return this.externalColorMixMode===h.Replace&&1===this.externalColor[3]?I.All:I.None}get visible(){return this.externalColor[3]>0?I.All:I.None}get type(){return g.Uniform}}e([b({vectorOps:n})],W.prototype,"externalColor",void 0),e([b()],W.prototype,"externalColorMixMode",void 0),e([b()],W.prototype,"castShadows",void 0),function(e){e[e.All=0]="All",e[e.Some=1]="Some",e[e.None=2]="None"}(I||(I={}));class _ extends v{constructor(){super(...arguments),this.texture=null,this.transparent=I.None,this.opaqueOverride=I.None,this.castShadows=I.None}get type(){return g.Varying}}function k(e){return null!=e.overlay?.getTexture(p.Highlight)}function B(e){return null!=e.overlay?.getTexture(p.WaterNormal)}function L(e){return null!=e.overlay?.getTexture(p.ColorNoRasterImage)}e([b()],_.prototype,"texture",void 0),e([b()],_.prototype,"transparent",void 0),e([b()],_.prototype,"opaqueOverride",void 0),e([b()],_.prototype,"castShadows",void 0);export{E as CommonMaterialParameters,R as ComponentMaterial,I as ComponentParameterSummary,W as ComponentParametersUniform,_ as ComponentParametersVarying};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.31/esri/copyright.txt for details.
4
4
  */
5
- const o=.1,t=.001;export{o as defaultMaskAlphaCutoff,t as symbolAlphaCutoff};
5
+ const o=1/256;export{o as alphaCutoff};
@@ -2,6 +2,6 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.31/esri/copyright.txt for details.
4
4
  */
5
- import{symbolAlphaCutoff as o}from"./AlphaCutoff.js";import{glsl as r}from"../../shaderModules/interfaces.js";function d(d){d.fragment.code.add(r`
5
+ import{alphaCutoff as o}from"./AlphaCutoff.js";import{glsl as r}from"../../shaderModules/interfaces.js";function d(d){d.fragment.code.add(r`
6
6
  #define discardOrAdjustAlpha(color) { if (color.a < ${r.float(o)}) { discard; } }
7
7
  `)}export{d as DiscardOrAdjustAlphaBlend};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.31/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../../chunks/tslib.es6.js";import{property as r}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/has.js";import"../../../../../core/Logger.js";import"../../../../../core/RandomLCG.js";import{subclass as o}from"../../../../../core/accessorSupport/decorators/subclass.js";import{ColorFormat as t}from"../../../webgl/formats.js";import n from"../../../webgl/RenderNode.js";import{Default3D as i}from"../../lib/DefaultVertexAttributeLocations.js";import{ClearBufferBit as s,ColorAttachment as a,BlendFactor as c,SizedPixelFormat as l,PixelFormat as u,DataType as p}from"../../../../webgl/enums.js";let d=class extends n{constructor(e){super(e),this.destroyedCB=null,this.produces="composite-color",this.consumes={required:["composite-color"]},this._focusedFBO=null,this._program=new Array}destroy(){this._program.forEach((e=>e.dispose())),this._program.length=0,this.destroyedCB()}render(e){const r=e.find((({name:e})=>"composite-color"===e));if(!this._focusedFBO)return r;const o=this.renderingContext;o.bindFramebuffer(r.fbo),o.setClearColor(0,0,0,0),o.clear(s.COLOR_BUFFER_BIT);const t=this._ensureShader(o,!1);return o.useProgram(t),o.bindTexture(this._focusedFBO.getTexture(),0),t.setUniform1i("colorTex",0),t.setUniform1i("inputType",0),o.screen.draw(),r}getReplacingFBO(e,r,o,n,i){r===f.ON&&(n=e.width,i=e.height);const u=this.renderingContext,p=e.depthStencilTexture,d=this._ensureShader(u,null!=p),h=this.fboCache.acquire(n,i,"fbo visualizer"),m=!e.colorTexture?.descriptor.hasMipmap;m&&e.colorTexture?.generateMipmap(),u.useProgram(d),u.unbindTexture(h.fbo?.colorTexture),u.bindFramebuffer(h.fbo),p&&(u.bindTexture(p,1),d.setUniform1i("depthTex",1),h.acquireColor(a.COLOR_ATTACHMENT1,t.RGBA),u.gl.drawBuffers([a.COLOR_ATTACHMENT0,a.COLOR_ATTACHMENT1]));const T=u.getViewport();u.setViewport(0,0,n,i),u.setClearColor(0,0,0,0),u.clear(s.COLOR_BUFFER_BIT),u.setBlendingEnabled(!0),u.setBlendFunction(c.ONE,c.ONE_MINUS_SRC_ALPHA),u.bindTexture(e.colorTexture,0),d.setUniform1i("colorTex",0);const g="linear-depth"===o||o.includes("shadow"),v=e.colorTexture?.descriptor.internalFormat,F=g?3:v===l.R16F||v===l.R32F||v===l.R8?1:v===l.RG8?2:v===l.RGBA16F?4:0;if(d.setUniform1i("inputType",F),g){const e=this.camera;d.setUniform2fv("nearFar",e.nearFar)}return u.screen.draw(),u.gl.drawBuffers([a.COLOR_ATTACHMENT0]),u.bindFramebuffer(null),u.setViewport(T.x,T.y,T.width,T.height),r===f.ON&&(this._focusedFBO=h),m&&e.colorTexture?.clearMipmap(),h}clearFocusedFBO(){this._focusedFBO=null}getPreviewContent(e,r,o,t){if(!o)return null;const n=this.renderingContext,i=this.fboCache.acquire(e,r,"fbo visualizer");n.bindFramebuffer(i?.fbo),n.setClearColor(0,0,0,0),n.clear(s.COLOR_BUFFER_BIT),n.setBlendingEnabled(!0),n.setBlendFunction(c.ONE,c.ONE_MINUS_SRC_ALPHA),n.setViewport(0,0,e,r);const a=this._ensureShader(n,!1);n.useProgram(a),n.bindTexture(o.getColorTexture(t),0),a.setUniform1i("colorTex",0),a.setUniform1i("inputType",0),n.screen.draw();const l=new ImageData(new Uint8ClampedArray(e*r*4),e,r);return n.gl.readPixels(0,0,e,r,u.RGBA,p.UNSIGNED_BYTE,new Uint8Array(l.data.buffer)),n.bindFramebuffer(null),i?.release(),l}_ensureShader(e,r){const o=r?1:0;if(this._program[o])return this._program[o];const t="#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 }",n=`#version 300 es\n precision highp float;\n\n in vec2 uv;\n uniform sampler2D colorTex;\n layout(location = 0) out vec4 fragColor;\n ${r?"\n layout(location = 1) out vec4 fragDepth;\n uniform sampler2D depthTex;\n ":""}\n uniform int inputType;\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 rgba2float(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(rgba2float(depth));\n }\n\n float linearDepthFromTexture(sampler2D depthTex, vec2 uv) {\n ivec2 iuv = ivec2(uv * vec2(textureSize(depthTex, 0)));\n return linearDepthFromRGBA(texelFetch(depthTex, iuv, 0));\n }\n\n void main() {\n vec4 color;\n if(inputType == 1) {\n color = vec4(vec3(texture(colorTex, uv).r), 1.0);\n } else if(inputType == 2) {\n color = vec4(texture(colorTex, uv).rg, 0.0, 1.0);\n } else if(inputType == 3) {\n float depth = 1.0 - (-linearDepthFromTexture(colorTex, uv) / (nearFar[1] - nearFar[0]));\n color = vec4(vec3(depth), depth >= 0.999 ? 0.0 : 1.0);\n } else if(inputType == 4) {\n color = texture(colorTex, uv);\n color = vec4(color.rgb / color.a, color.a);\n } else {\n color = texture(colorTex, uv);\n }\n\n\n if(color.a < 0.000001)\n discard;\n else {\n fragColor = color;\n ${r?"\n float depth = 1.0 - pow(texture(depthTex, uv).r, 10.0);\n fragDepth = vec4(vec3(depth), depth < 0.000001 ? 0.0 : 1.0);\n ":""}\n }\n }`;return this._program[o]=e.programCache.acquire(t,n,i),this._program[o]}};var f;e([r()],d.prototype,"destroyedCB",void 0),e([r()],d.prototype,"produces",void 0),e([r()],d.prototype,"consumes",void 0),d=e([o("esri.views.3d.webgl-engine.effects.debug.RenderNodeVisualizerNode")],d),function(e){e[e.ON=0]="ON",e[e.OFF=1]="OFF"}(f||(f={}));export{f as FocusState,d as RenderNodeVisualizerNode};
5
+ import{_ as e}from"../../../../../chunks/tslib.es6.js";import{property as r}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/has.js";import"../../../../../core/Logger.js";import"../../../../../core/RandomLCG.js";import{subclass as o}from"../../../../../core/accessorSupport/decorators/subclass.js";import{ColorFormat as t}from"../../../webgl/formats.js";import n from"../../../webgl/RenderNode.js";import{alphaCutoff as i}from"../../core/shaderLibrary/util/AlphaCutoff.js";import{glsl as s}from"../../core/shaderModules/interfaces.js";import{Default3D as a}from"../../lib/DefaultVertexAttributeLocations.js";import{ClearBufferBit as c,ColorAttachment as l,BlendFactor as u,SizedPixelFormat as p,PixelFormat as d,DataType as f}from"../../../../webgl/enums.js";let h=class extends n{constructor(e){super(e),this.destroyedCB=null,this.produces="final-color",this.consumes={required:["final-color"]},this._focusedFBOType=0,this._program=new Array}destroy(){this._program.forEach((e=>e.dispose())),this._program.length=0,this.destroyedCB()}render(e){const r=e.find((({name:e})=>"final-color"===e));if(!this._focusedFBO)return r;const o=this.renderingContext;o.bindFramebuffer(r.fbo),o.setClearColor(0,0,0,0),o.clear(c.COLOR_BUFFER_BIT);const t=this._ensureShader(o,!1);return o.useProgram(t),o.bindTexture(this._focusedFBO.getTexture(),0),t.setUniform1i("colorTex",0),t.setUniform1i("inputType",this._focusedFBOType),3===this._focusedFBOType&&t.setUniform2fv("nearFar",this.camera.nearFar),o.screen.draw(),r}getReplacingFBO(e,r,o,n,i){r===m.ON&&(n=e.width,i=e.height);const s=this.renderingContext,a=e.depthStencilTexture,d=this._ensureShader(s,null!=a),f=this.fboCache.acquire(n,i,"fbo visualizer"),h=!e.colorTexture?.descriptor.hasMipmap;h&&e.colorTexture?.generateMipmap(),s.useProgram(d),s.unbindTexture(f.fbo?.colorTexture),s.bindFramebuffer(f.fbo),a&&(s.bindTexture(a,1),d.setUniform1i("depthTex",1),f.acquireColor(l.COLOR_ATTACHMENT1,t.RGBA),s.gl.drawBuffers([l.COLOR_ATTACHMENT0,l.COLOR_ATTACHMENT1]));const T=s.getViewport();s.setViewport(0,0,n,i),s.setClearColor(0,0,0,0),s.clear(c.COLOR_BUFFER_BIT),s.setBlendingEnabled(!0),s.setBlendFunction(u.ONE,u.ONE_MINUS_SRC_ALPHA),s.bindTexture(e.colorTexture,0),d.setUniform1i("colorTex",0);const F="linear-depth"===o||o.includes("shadow"),v=e.colorTexture?.descriptor.internalFormat,g=F?3:v===p.R16F||v===p.R32F||v===p.R8?1:v===p.RG8?2:v===p.RGBA16F?4:0;return d.setUniform1i("inputType",g),F&&d.setUniform2fv("nearFar",this.camera.nearFar),s.screen.draw(),s.gl.drawBuffers([l.COLOR_ATTACHMENT0]),s.bindFramebuffer(null),s.setViewport(T.x,T.y,T.width,T.height),r===m.ON&&(this._focusedFBO=f,this._focusedFBOType=g),h&&e.colorTexture?.clearMipmap(),f}clearFocusedFBO(){this._focusedFBO=null}getPreviewContent(e,r,o,t){if(!o)return null;const n=this.renderingContext,i=this.fboCache.acquire(e,r,"fbo visualizer");n.bindFramebuffer(i?.fbo),n.setClearColor(0,0,0,0),n.clear(c.COLOR_BUFFER_BIT),n.setBlendingEnabled(!0),n.setBlendFunction(u.ONE,u.ONE_MINUS_SRC_ALPHA),n.setViewport(0,0,e,r);const s=this._ensureShader(n,!1);n.useProgram(s),n.bindTexture(o.getColorTexture(t),0),s.setUniform1i("colorTex",0),s.setUniform1i("inputType",0),n.screen.draw();const a=new ImageData(new Uint8ClampedArray(e*r*4),e,r);return n.gl.readPixels(0,0,e,r,d.RGBA,f.UNSIGNED_BYTE,new Uint8Array(a.data.buffer)),n.bindFramebuffer(null),i?.release(),a}_ensureShader(e,r){const o=r?1:0;if(this._program[o])return this._program[o];const t="#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 }",n=`#version 300 es\n precision highp float;\n\n in vec2 uv;\n uniform sampler2D colorTex;\n layout(location = 0) out vec4 fragColor;\n ${r?"\n layout(location = 1) out vec4 fragDepth;\n uniform sampler2D depthTex;\n ":""}\n uniform int inputType;\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 rgba2float(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(rgba2float(depth));\n }\n\n float linearDepthFromTexture(sampler2D depthTex, vec2 uv) {\n ivec2 iuv = ivec2(uv * vec2(textureSize(depthTex, 0)));\n return linearDepthFromRGBA(texelFetch(depthTex, iuv, 0));\n }\n\n void main() {\n vec4 color;\n if(inputType == 1) {\n color = vec4(vec3(texture(colorTex, uv).r), 1.0);\n } else if(inputType == 2) {\n color = vec4(texture(colorTex, uv).rg, 0.0, 1.0);\n } else if(inputType == 3) {\n float depth = 1.0 - (-linearDepthFromTexture(colorTex, uv) / (nearFar[1] - nearFar[0]));\n color = vec4(vec3(depth), depth >= 0.999 ? 0.0 : 1.0);\n } else if(inputType == 4) {\n color = texture(colorTex, uv);\n color = vec4(color.rgb / color.a, color.a);\n } else {\n color = texture(colorTex, uv);\n }\n\n\n if(color.a < ${s.float(i)})\n discard;\n else {\n fragColor = color;\n ${r?"\n float depth = 1.0 - pow(texture(depthTex, uv).r, 10.0);\n fragDepth = vec4(vec3(depth), depth < 0.000001 ? 0.0 : 1.0);\n ":""}\n }\n }`;return this._program[o]=e.programCache.acquire(t,n,a),this._program[o]}};var m;e([r()],h.prototype,"destroyedCB",void 0),e([r()],h.prototype,"produces",void 0),e([r()],h.prototype,"consumes",void 0),h=e([o("esri.views.3d.webgl-engine.effects.debug.RenderNodeVisualizerNode")],h),function(e){e[e.ON=0]="ON",e[e.OFF=1]="OFF"}(m||(m={}));export{m as FocusState,h as RenderNodeVisualizerNode};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.31/esri/copyright.txt for details.
4
4
  */
5
- import"../../../../core/has.js";import{releaseMaybe as t}from"../../../../core/maybe.js";import{c as e}from"../../../../chunks/vec42.js";import{create as r}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{ColorFormat as i,DepthFormat as h}from"../../webgl/formats.js";import{RendererTarget as s}from"./rendererUtils.js";import{TransparencyPassType as o}from"./TransparencyPassType.js";import{ColorAttachment as c,ClearBufferBit as a}from"../../../webgl/enums.js";import{ensureAttachmentMaxSize as l}from"../../../webgl/FramebufferObject.js";class f{constructor(t,e){this._fbos=t,this.compositingHelper=e,this._width=4,this._height=4,this._clearColor=r()}dispose(){this._color=t(this._color),this.releaseBuffers()}get framebuffer(){return this.color.attachDepth(this.depth),this.color.fbo}get colorTexture(){return this.color.getTexture()}get depthTexture(){return this.depth.attachment}initializeFrame(t,r,i){this._fbos.interactive=i===s.Default;const h=this._fbos.rctx;this._width=t.fullWidth,this._height=t.fullHeight,l(this,h.parameters.maxTextureSize);const o=this._color;return this._color=null,this.releaseBuffers(),e(this._clearColor,r),o}releaseBuffers(){this._color?.detachDepth(),this._depth=t(this._depth)}renderHUDVisibility(t,e,r){return t?.fbo?.width===this._width&&t?.fbo?.height===this._height||(t?.release(),t=this._fbos.acquire(this._width,this._height,"hud visibility",i.RGBA4)),t.attachDepth(r||this.depth),this._fbos.rctx.bindFramebuffer(t.fbo),this._fbos.rctx.clearFramebuffer(_),e(),t.detachDepth(),t}compositeToHUDVisibility(t,e){this._fbos.rctx.bindFramebuffer(t.hudVisibility?.fbo),this.compositingHelper.compositeHUD(t,e)}renderOITPass(t,e,r){let s,a;const{_width:l,_height:f}=this;switch(e){case o.ColorAlpha:s=this._fbos.acquire(l,f,r?"oit hud color alpha":"oit color alpha",i.RGBA16F),s.acquireColor(c.COLOR_ATTACHMENT1,i.R16F),a=[0,0,0,1];break;case o.FrontFace:s=this._fbos.acquire(l,f,r?"oit hud front":"oit front"),a=[0,0,0,0]}return r?s.acquireDepth(h.DEPTH16_BUFFER):s.attachDepth(this.depth),this._fbos.rctx.bindFramebuffer(s.fbo),this._fbos.rctx.clearFramebuffer(a,r,r),t(),s.detachDepth(),s}compositeToFramebuffer(t,e,r,i){this.bindFbo(),this.compositingHelper.composite(t,e,r,i)}compositeOIT(t,e,r,i){i?(this._fbos.rctx.bindFramebuffer(i.fbo),this._fbos.rctx.setClearColor(0,0,0,1e-13),this._fbos.rctx.clear(a.COLOR_BUFFER_BIT)):this.bindFbo(),this.compositingHelper.compositeOIT(t,e.getTexture(),e.getTexture(c.COLOR_ATTACHMENT1),r.getTexture())}renderDepthDetached(t){this._bindTarget(this.color),t(),this._bindTarget(this.color,this.depth)}renderToCachedFBO(e,r,s,o,c=i.RGBA,a=h.DEPTH16_BUFFER,l=this._width,f=this._height,_=null){return e?.fbo?.width===l&&e?.fbo?.height===f||(e=t(e)),e=e??this._fbos.acquire(l,f,r,c),_?.forEach((t=>e.acquireColor(t.attachment,t.format))),null!=a&&e.acquireDepth(a),this._fbos.rctx.bindFramebuffer(e.fbo),this._fbos.rctx.clearFramebuffer(o,!0,!0),s(),e}renderToTargets(t,e,r,i,h=!1,s=!1){this._bindTarget(e,r),this._fbos.rctx.clearFramebuffer(i,h,s),t(),e.detachDepth()}bindFbo(){const t=null==this._color;if(this._bindTarget(this.color,this.depth),t){const t=this._fbos.rctx;t.setClearStencil(0),t.setClearColor(this._clearColor[0],this._clearColor[1],this._clearColor[2],this._clearColor[3]),t.clear(a.COLOR_BUFFER_BIT|a.DEPTH_BUFFER_BIT|a.STENCIL_BUFFER_BIT)}}_bindTarget(t,e){t.attachDepth(e),this._fbos.rctx.bindFramebuffer(t.fbo)}get width(){return this._width}get height(){return this._height}get color(){return this._ensureColor()}_ensureColor(){return this._color||(this._color=this._fbos.acquire(this._width,this._height,"composite-color")),this._color}updateColor(t){const e=this._ensureColor();e.attachDepth(this.depth),this._color=t(e)}get depth(){return this._depth||(this._depth=this._fbos.acquireDepth(h.DEPTH_STENCIL_TEXTURE,this._width,this._height,"depth")),this._depth}}const _=[0,1,0,1];export{f as OffscreenRendering};
5
+ import{releaseMaybe as t}from"../../../../core/maybe.js";import{c as e}from"../../../../chunks/vec42.js";import{create as r}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{ColorFormat as i,DepthFormat as h}from"../../webgl/formats.js";import{RendererTarget as s}from"./rendererUtils.js";import{TransparencyPassType as o}from"./TransparencyPassType.js";import{ColorAttachment as c,ClearBufferBit as a}from"../../../webgl/enums.js";import{ensureAttachmentMaxSize as l}from"../../../webgl/FramebufferObject.js";class f{constructor(t,e){this._fbos=t,this.compositingHelper=e,this._width=4,this._height=4,this._clearColor=r()}dispose(){this._color=t(this._color),this.releaseBuffers()}get framebuffer(){return this.color.attachDepth(this.depth),this.color.fbo}get colorTexture(){return this.color.getTexture()}get depthTexture(){return this.depth.attachment}initializeFrame(t,r,i){this._fbos.interactive=i===s.Default;const h=this._fbos.rctx;this._width=t.fullWidth,this._height=t.fullHeight,l(this,h.parameters.maxTextureSize);const o=this._color;return this._color=null,this.releaseBuffers(),e(this._clearColor,r),o}releaseBuffers(){this._color?.detachDepth(),this._depth=t(this._depth)}renderHUDVisibility(t,e,r){return t?.fbo?.width===this._width&&t?.fbo?.height===this._height||(t?.release(),t=this._fbos.acquire(this._width,this._height,"hud visibility",i.RGBA4)),t.attachDepth(r||this.depth),this._fbos.rctx.bindFramebuffer(t.fbo),this._fbos.rctx.clearFramebuffer(_),e(),t.detachDepth(),t}compositeToHUDVisibility(t,e){this._fbos.rctx.bindFramebuffer(t.hudVisibility?.fbo),this.compositingHelper.compositeHUD(t,e)}renderOIT(t,e,r){const{_width:s,_height:a,_fbos:l}=this,f=l.rctx;t.transparencyPassType=o.ColorAlpha;const _=this._fbos.acquire(s,a,r?"oit hud color alpha":"oit color alpha",i.RGBA16F);_.acquireColor(c.COLOR_ATTACHMENT1,i.R16F),r||_.attachDepth(this.depth),f.bindFramebuffer(_.fbo),f.clearFramebuffer([0,0,0,1]),e(),_.detachDepth(),t.transparencyPassType=o.FrontFace;const b=this._fbos.acquire(s,a,r?"oit hud front":"oit front");r?b.acquireDepth(h.DEPTH16_BUFFER):b.attachDepth(this.depth),f.bindFramebuffer(b.fbo),f.clearFramebuffer([0,0,0,0],!!r),e(),b.detachDepth(),t.transparencyPassType=o.NONE,this._compositeOIT(t,_,b,r),r?.detachDepth(),b.release(),_.release()}compositeToFramebuffer(t,e,r,i){this.bindFbo(),this.compositingHelper.composite(t,e,r,i)}_compositeOIT(t,e,r,i){i?(this._fbos.rctx.bindFramebuffer(i.fbo),this._fbos.rctx.setClearColor(0,0,0,1e-13),this._fbos.rctx.clear(a.COLOR_BUFFER_BIT)):this.bindFbo(),this.compositingHelper.compositeOIT(t,e.getTexture(),e.getTexture(c.COLOR_ATTACHMENT1),r.getTexture())}renderDepthDetached(t){this._bindTarget(this.color),t(),this._bindTarget(this.color,this.depth)}renderToCachedFBO(e,r,s,o,c=i.RGBA,a=h.DEPTH16_BUFFER,l=this._width,f=this._height,_=null){return e?.fbo?.width===l&&e?.fbo?.height===f||(e=t(e)),e=e??this._fbos.acquire(l,f,r,c),_?.forEach((t=>e.acquireColor(t.attachment,t.format))),null!=a&&e.acquireDepth(a),this._fbos.rctx.bindFramebuffer(e.fbo),this._fbos.rctx.clearFramebuffer(o,!0,!0),s(),e}renderToTargets(t,e,r,i,h=!1,s=!1){this._bindTarget(e,r),this._fbos.rctx.clearFramebuffer(i,h,s),t(),e.detachDepth()}bindFbo(){const t=null==this._color;if(this._bindTarget(this.color,this.depth),t){const t=this._fbos.rctx;t.setClearStencil(0),t.setClearColor(this._clearColor[0],this._clearColor[1],this._clearColor[2],this._clearColor[3]),t.clear(a.COLOR_BUFFER_BIT|a.DEPTH_BUFFER_BIT|a.STENCIL_BUFFER_BIT)}}_bindTarget(t,e){t.attachDepth(e),this._fbos.rctx.bindFramebuffer(t.fbo)}get width(){return this._width}get height(){return this._height}get color(){return this._ensureColor()}_ensureColor(){return this._color||(this._color=this._fbos.acquire(this._width,this._height,"composite-color")),this._color}updateColor(t){const e=this._ensureColor();e.attachDepth(this.depth),this._color=t(e)}get depth(){return this._depth||(this._depth=this._fbos.acquireDepth(h.DEPTH_STENCIL_TEXTURE,this._width,this._height,"depth")),this._depth}}const _=[0,1,0,1];export{f as OffscreenRendering};