@arcgis/core 4.34.0-next.41 → 4.34.0-next.42
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.
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/016d421114118307d4dd.js +1 -0
- package/assets/esri/core/workers/chunks/250b1629becca0410f2a.js +1 -0
- package/assets/esri/core/workers/chunks/3245d20ea4bb779f87ef.js +1 -0
- package/assets/esri/core/workers/chunks/6b73926feb5c5d957062.js +1 -0
- package/assets/esri/core/workers/chunks/{6269c4bbf0f224a954e9.js → 6f4079b7a2b45f304ee6.js} +1 -1
- package/assets/esri/core/workers/chunks/82955562805ad5514ed8.js +346 -0
- package/assets/esri/core/workers/chunks/{94850c094e076d81a016.js → dca2b487152cde45fb65.js} +1 -1
- package/assets/esri/core/workers/chunks/{31ad9949b08a5b07218c.js → eea3e0bd17479a767160.js} +2 -2
- package/assets/esri/core/workers/chunks/fe6fa1f2c2d54d41645e.js +1 -0
- package/config.js +1 -1
- package/core/workers/registry.js +1 -1
- package/kernel.js +1 -1
- package/layers/Lyr3DWasmPerSceneView.js +1 -1
- package/package.json +1 -1
- package/support/revision.js +1 -1
- package/views/2d/engine/flow/styles/Imagery.js +1 -1
- package/views/2d/engine/flow/styles/Particles.js +1 -1
- package/views/2d/engine/flow/styles/Streamlines.js +1 -1
- package/views/2d/engine/imagery/RasterVFDisplayObject.js +1 -1
- package/views/2d/engine/vectorTiles/RenderBucket.js +1 -1
- package/views/2d/engine/webgl/BitBlitRenderer.js +1 -1
- package/views/2d/engine/webgl/Mesh2D.js +1 -1
- package/views/2d/engine/webgl/VertexStream.js +1 -1
- package/views/2d/engine/webgl/brushes/WGLBrushStencil.js +1 -1
- package/views/2d/engine/webgl/brushes/WGLBrushTileDebugInfo.js +1 -1
- package/views/2d/engine/webgl/brushes/WGLBrushVTLBackground.js +1 -1
- package/views/2d/engine/webgl/cpuMapped/Buffer.js +1 -1
- package/views/2d/engine/webgl/cpuMapped/MappedMesh.js +1 -1
- package/views/2d/engine/webgl/effects/highlight/HighlightRenderer.js +1 -1
- package/views/2d/engine/webgl/meshing/Mesh.js +1 -1
- package/views/2d/engine/webgl/meshing/SimpleMesh.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/overlay/OverlayTechnique.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/videoScreenRenderer/VideoScreenTechnique.js +1 -1
- package/views/2d/layers/BaseDynamicLayerView2D.js +1 -1
- package/views/2d/layers/FeatureLayerView2D.js +1 -1
- package/views/2d/layers/KMLLayerView2D.js +1 -1
- package/views/2d/layers/MapImageLayerView2D.js +1 -1
- package/views/2d/layers/MediaLayerView2D.js +1 -1
- package/views/2d/layers/TileLayerView2D.js +1 -1
- package/views/2d/layers/WMSLayerView2D.js +1 -1
- package/views/2d/layers/graphics/GraphicBoundsRenderer.js +1 -1
- package/views/2d/layers/support/DebugOverlay.js +1 -1
- package/views/3d/environment/LocalAtmosphere.js +1 -1
- package/views/3d/environment/MarsAtmosphere.js +1 -1
- package/views/3d/environment/Precipitation.js +1 -1
- package/views/3d/layers/FlowSubView3D.js +1 -1
- package/views/3d/layers/GaussianSplatLayerView3D.js +1 -1
- package/views/3d/layers/I3SMeshView3D.js +1 -1
- package/views/3d/layers/SceneLayerGraphicsView3D.js +1 -1
- package/views/3d/layers/graphics/pipeline/rendering/DirectRenderer.js +1 -1
- package/views/3d/layers/i3s/PointCloudRenderer.js +1 -1
- package/views/3d/layers/support/FlowTileTree3DDebugger.js +1 -1
- package/views/3d/support/GaussianSplatSortWorker.js +5 -0
- package/views/3d/support/GaussianSplatWorkerHandle.js +5 -0
- package/views/3d/support/flow/FlowSubViewTiles3D.js +1 -1
- package/views/3d/support/flow/geometryUtils.js +1 -1
- package/views/3d/support/flow/loadUtils.js +1 -1
- package/views/3d/terrain/PatchGeometryFactory.js +1 -1
- package/views/3d/terrain/PatchRenderData.js +1 -1
- package/views/3d/webgl-engine/collections/Component/ComponentObjectCollection.js +1 -1
- package/views/3d/webgl-engine/collections/Component/Material/ComponentTechnique.js +1 -1
- package/views/3d/webgl-engine/effects/ScreenSpaceGeometry.js +1 -1
- package/views/3d/webgl-engine/effects/focusArea/FocusAreaMaskNode.js +1 -1
- package/views/3d/webgl-engine/effects/highlight/Highlight.js +1 -1
- package/views/3d/webgl-engine/effects/laserlines/LaserlinePathData.js +1 -1
- package/views/3d/webgl-engine/effects/stars/Stars.js +1 -1
- package/views/3d/webgl-engine/lib/edgeRendering/EdgeView.js +1 -1
- package/views/3d/webgl-engine/lib/edgeRendering/bufferLayouts.js +1 -1
- package/views/3d/webgl-engine/lib/edgeRendering/edgeBufferWriters.js +1 -1
- package/views/3d/webgl-engine/lib/glUtil3D.js +1 -1
- package/views/3d/webgl-engine/lib/lodRendering/BackedBufferObject.js +1 -1
- package/views/3d/webgl-engine/lib/lodRendering/LodComponentData.js +1 -1
- package/views/3d/webgl-engine/lib/lodRendering/LodRenderer.js +1 -1
- package/views/3d/webgl-engine/lib/lodRendering/RenderInstanceData.js +1 -1
- package/views/3d/webgl-engine/materials/renderers/MergedBuffer.js +1 -1
- package/views/3d/webgl-engine/materials/renderers/VaoCache.js +1 -1
- package/views/VideoView.js +1 -1
- package/views/support/TileTreeDebugger.js +1 -1
- package/views/webgl/BufferObject.js +1 -1
- package/views/webgl/Util.js +1 -1
- package/views/webgl/VertexArrayObject.js +1 -1
- package/views/webgl/VertexBuffer.js +1 -1
- package/views/webgl/testFloatBufferBlend.js +1 -1
- package/views/webgl/testSVGPremultipliedAlpha.js +1 -1
- package/assets/esri/core/workers/chunks/01bd8f90e55081e65b38.js +0 -1
- package/assets/esri/core/workers/chunks/0a27f9b11d03874809ee.js +0 -346
- package/assets/esri/core/workers/chunks/34f677e8c1691c10e4e9.js +0 -1
- package/assets/esri/core/workers/chunks/e95a8c988ef822723503.js +0 -1
- package/assets/esri/core/workers/chunks/fd3009164d5e38fda85f.js +0 -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.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import t from"../../../../Color.js";import{fromValues as o}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{newHalfFloatArray as e}from"../../../../geometry/support/HalfFloatArray.js";import{zValueInAbsoluteHeightMode as n}from"../../../../support/elevationInfoUtils.js";import{lineStripsToParameters as r,createGeometry as i}from"../engineContent/line.js";function l(t,l,s,c,h,m){const{spatialReference:p}=
|
|
5
|
+
import t from"../../../../Color.js";import{fromValues as o}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{newHalfFloatArray as e}from"../../../../geometry/support/HalfFloatArray.js";import{zValueInAbsoluteHeightMode as n}from"../../../../support/elevationInfoUtils.js";import{lineStripsToParameters as r,createGeometry as i}from"../engineContent/line.js";function l(t,l,s,c,h,m){const{spatialReference:p}=l.extent,g=[];for(let e=0;e<s.length;e+=3){const r=[s[e],s[e+1]],[i,a]=f(r,l),{absoluteZ:h}=n(i,a,0,p,t,c),m=o(i,a,h);t.renderCoordsHelper.toRenderCoords(m,p,m),g.push(m)}const u=Math.floor(s.length/3),d=e(u);for(let o=0;o<u;o++)d[o]=s[3*o+2];a(d,Math.floor(m.getIntRange(0,d.length)));const j=r([g],void 0,[d]);return i(h,j[0])}function s(o,e,n){if(null==o)return{};const r=t.toUnitRGBA(o.color);return r[3]*=e,{color:r,width:o.trailWidth,cap:2,animationSpeed:o.flowSpeed,trailLength:o.trailLength,animation:3,emissiveStrength:n}}function f([t,o],e){const{extent:n,size:[r,i]}=e;return[t/r*n.width+n.xmin,(i-o)/i*n.height+n.ymin]}function a(t,o){if(0===t.length||o<0||o>=t.length)return;const e=t[o];for(let n=0;n<t.length;n++)t[n]-=e}export{l as createStreamlineGeometry,s as materialParametersFromRenderer};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{width as t,height as n,containsXY as l,
|
|
5
|
+
import{width as t,height as n,containsXY as l,create as r}from"../../../../geometry/support/aaBoundingRect.js";import{createFlowFieldFromData as o}from"../../../2d/engine/flow/dataUtils.js";import{getFeatureTileId as u}from"../../layers/support/FeatureTileDescriptor.js";class e{constructor(t,n,l,r,o,u){this.data=t,this.mask=n,this.width=l,this.height=r,this.lij=o,this.extent=u}}function i(t){return u(t.lij[0],t.lij[1],t.lij[2])}function s(t){let[n,l,o,u]=[null,null,null,null];for(const r of t){const t=r.extent;n=a(t[0],n),l=a(t[1],l),o=c(t[2],o),u=c(t[3],u)}return null==n||null==l||null==o||null==u?null:r([n,l,o,u])}function c(t,n){return null==n?t:Math.max(t,n)}function a(t,n){return null==n?t:Math.min(t,n)}function f(r,u,e,i,s){const[c,a]=e;let f=null;const h=new Map;u.forEach(t=>{h.set(t.lij,o(r,t))});const m=(t,n,r)=>l(t.extent,n,r);return(l,r)=>{const o=Math.round(l),e=Math.round(r);if(o<0||o>=c||e<0||e>=a)return[0,0];const p=l/c*t(i)+i[0],j=(a-r)/a*n(i)+i[1];if(null==f||!m(f,p,j)){f=null;for(const[t,n]of u)if(m(n,p,j)){f=n;break}}if(null==f?.data)return[0,0];const d=h.get(f.lij);if(null==d)return[0,0];const x=f.extent;return d((p-x[0])/t(x)*s,s-(j-x[1])/n(x)*s)}}export{e as FlowDataTile,s as boundingRectOfTiles,f as createFlowFieldFromDataTiled,i as tileToKey};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{clamp as t,isPowerOfTwo as e}from"../../../core/mathUtils.js";import{maxUint16 as n}from"../../../core/typedArrayUtil.js";import{empty as o}from"../../../geometry/support/aaBoundingBox.js";import{fromValues as s}from"../../../geometry/support/aaBoundingRect.js";import{sampleElevation as r}from"./ElevationData.js";import{PatchGeometryLUT as i}from"./PatchGeometryLUT.js";import{zeroToFour as a,neighborTileIfLoadedOrSelf as c}from"./PatchRenderData.js";import{internalAssert as l,enableTerrainInternalChecks as u,neighborEdgeIndices as d,almostEquals as f}from"./terrainUtils.js";import{isCornerNeighbor as m}from"./Tile.js";import{compareTilesByLij as g}from"./tileUtils.js";import{compressNormal as h}from"../webgl-engine/lib/Normals.js";const p=65536;function x(t,e){const{tile:n,geometry:s,geometryState:r}=t,{extentInRadians:i,surface:a}=n,{isWebMercator:c,renderer:l}=a,{numVerticesPerSide:u,wireframe:d}=r,f=u-1,m=(u-2)**2,g=c&&(2===e||3===e),h=c&&(1===e||3===e),p=((g?1:0)+(h?1:0))*mt*u,x=ut(r),S=m+p+4*x,v=l.tileGeometryCache.acquire(S);s.numVerticesPerSide=u,s.vertexAttributes=v,s.maxEdgeVertexCount=x;const{boundingBox:V}=s;o(V);const b=P(t);ot.update(f,i,b),y(t),s.poleVerticesStartIndex=m;const B=M(t,g,h);s.edgeVerticesStartIndex=m+p,Q(t),I(t),W(s,B,d),t.intersectionData=null}function M(t,e,o){const{tile:s,localOrigin:r,geometry:i}=t,{extent:a,ellipsoid:c}=s,{boundingBox:l,numVerticesPerSide:u,vertexAttributes:d,poleVerticesStartIndex:f}=i,m=u-1,g=r[0],p=r[1],x=r[2],M=c.radius,y=a[1],S=a[3],v=[];let V=f;const I=(t,e)=>{const o=e*u;lt(-g,-p,t*M-x,l),v.push(new et(1===t,o,1===t?0:2,V,mt));const s=C(-1===t?y:S,M),r=t*Math.PI/2-s,i=.99*(1===t?1:-1),a=M+0,{position:c,uv0:f}=d,{typedBuffer:I,typedBufferStride:b}=d.normalCompressed;for(let u=1;u<=mt;++u){const t=s+r*(u/mt),e=Math.cos(t),o=Math.sin(t);for(let s=0;s<=m;s++){const t=s/m,r=ot.sinLonLUT[s],u=ot.cosLonLUT[s]*e,d=r*e,M=o,y=u*a-g,S=d*a-p,v=M*a-x;lt(y,S,v,l),c.setValues(V,y,S,v),f.setValues(V,Math.round(t*n),Math.round(i*n)),h(I,V,u,d,M,b),++V}}};return e&&I(-1,0),o&&I(1,m),v}function y(t){const{tile:e}=t;if(!e.intersectsClippingArea)return;const{geometry:o,geometryState:s,localOrigin:i}=t,{numVerticesPerSide:a,samplerData:c}=s,l=a-2,u=a-1,{vertexAttributes:d,boundingBox:f}=o,{position:m,uv0:g}=d,{typedBuffer:p,typedBufferStride:x}=d.normalCompressed,{extent:M}=e,y=M[0],S=M[2],v=M[1],V=M[3],I=e.ellipsoid.radius,b=i[0],B=i[1],C=i[2],L=m.typedBuffer,A=m.typedBufferStride,P=1/u;let D=0;if(1<=l){const t=P,e=v*(1-t)+V*t,o=ot.sinLatLUT[1],s=ot.cosLatLUT[1];for(let i=1;i<=l;i++){const a=i*P,l=y*(1-a)+S*a,u=ot.sinLonLUT[i],d=ot.cosLonLUT[i],m=I+r(l,e,c),h=m*d*s-b,p=m*u*s-B,x=m*o-C;lt(h,p,x,f);const M=(i-1)*A;L[M]=h,L[M+1]=p,L[M+2]=x,g.setValues(i-1,Math.round(a*n),Math.round(t*n))}}for(let E=1;E<=l;E++){const t=E*P,e=v*(1-t)+V*t,o=ot.sinLatLUT[E],s=ot.cosLatLUT[E],i=E+1,a=i*P,d=v*(1-a)+V*a,m=ot.sinLatLUT[i],M=ot.cosLatLUT[i],T=ot.sinLonLUT[0],O=ot.cosLonLUT[0],R=I+r(y,e,c);let U=O*s*R-b,w=T*s*R-B,N=o*R-C;const j=D*A;let F=L[j],q=L[j+1],W=L[j+2];for(let V=1;V<=l;V++){const t=V*P,i=y*(1-t)+S*t,T=ot.sinLonLUT[V],O=ot.cosLonLUT[V];let R=0,j=0,k=0;if(V<l){const t=(D+1)*A;R=L[t],j=L[t+1],k=L[t+2]}else{const t=ot.sinLonLUT[u],n=ot.cosLonLUT[u],i=I+r(S,e,c);R=n*s*i-b,j=t*s*i-B,k=o*i-C}const z=U,G=w,H=N;U=F,w=q,N=W,F=R,q=j,W=k;const J=R-z,K=j-G,Q=k-H;let X=0,Y=0,Z=0;if(E>1){const t=(D-l)*A;X=L[t],Y=L[t+1],Z=L[t+2]}else{const t=ot.sinLatLUT[0],e=ot.cosLatLUT[0],n=I+r(i,v,c);X=O*e*n-b,Y=T*e*n-B,Z=t*n-C}const $=I+r(i,d,c),_=O*M*$-b,tt=T*M*$-B,et=m*$-C;if(E<l){const e=D+l,o=e*A;L[o]=_,L[o+1]=tt,L[o+2]=et,lt(_,tt,et,f),g.setValues(e,Math.round(t*n),Math.round(a*n))}const nt=X-_,st=Y-tt,rt=Z-et;let it=O*s,at=T*s,ct=o;ct*ct<.999&&(it=Q*st-K*rt,at=J*rt-Q*nt,ct=K*nt-J*st);const ut=1/Math.sqrt(it*it+at*at+ct*ct);h(p,D,it*ut,at*ut,ct*ut,x),++D}}}function S(t){t.tile.intersectsClippingArea&&(I(t),_(t),t.intersectionData=null)}function v(t){t.tile.intersectsClippingArea&&(X(t),I(t),_(t),tt(t),t.intersectionData=null)}function V(t){t.tile.intersectsClippingArea&&(B(t),b(t,!0),_(t),t.intersectionData=null)}function I(t){t.tile.intersectsClippingArea&&(B(t),b(t))}function b(t,o=!1){const{geometry:s,geometryState:i,tile:a,localOrigin:m}=t,{level:h,extent:p,extentInRadians:x,ellipsoid:M}=a,y=M.radius,S=x[0],v=x[2],V=x[1],I=x[3],{samplerData:b}=i,B=p[0],C=p[2],L=p[1],A=p[3],D=P(t),{boundingBox:E,vertexAttributes:T}=s,O=m[0],R=m[1],U=m[2],{position:w,uv0:N}=T,j=w.typedBuffer,F=w.typedBufferStride;for(let P=0;P<4;++P){const m=1===P||3===P,x=i.edgeResolutions[P];l(e(x));const M=x+1,T=c(a,i.edgePeerNeighbors[P]);if(it(a,T,P)){Y(t,P,T);continue}const w=null!=T;l(!w||T.level===a.level),l(!w||g(a,T)<=0);const q=T?.renderData,W=q?.geometryState;if(u){const t=a.surface;if(!T&&t&&!t.updatingRootTiles){const e=d[P],n=a.findNeighborTile(e,t=>t.loaded||t.leaf||t.level===a.level);n?n.intersectsClippingArea&&(l(!n.loaded),l(!n.leaf),l(n.level===h)):l(null==t?.rootTiles||!a.shouldHaveNeighbor(e))}}const k=1===P?p[2]:p[0],z=T?.extent,G=z&&m?1===P?z[0]:z[2]:k,H=0===P?p[3]:p[1],J=1===P?1:0,K=0===P?1:0,Q=1===P?v:S,X=0===P?I:V,Z=Math.sin(Q),$=Math.cos(Q),_=Math.sin(X),tt=Math.cos(X),et=W?.samplerData,nt=w?(t,e,n)=>.5*(r(t,e,b)+r(n,e,et)):(t,e,n)=>r(t,e,b),ot=s.outerEdgesOffsetAndLength[2*P+0],st=o&&M>3?M-3:1,rt=null!=b&&b.some(t=>null!=t),at=null!=et&&et.some(t=>null!=t),ct=rt||at,ut=1/x,dt=ot;l(!z||f(z[2]-z[0],p[2]-p[0]));(()=>{const t=1===P?-1:3===P?1:0,e=0===P?-1:2===P?1:0,o=(p[2]-p[0])*ut,i=t*o,a=e*o,c=m?t*((v-S)*ut):0,l=m?0:e*ut,u=K,d=m?Q+c:Q,f=m?Math.sin(d):Z,g=m?Math.cos(d):$,h=m?Q-c:Q,x=m?Math.sin(h):Z,V=m?Math.cos(h):$,I=m?X:D(u+l),T=m?_:Math.sin(I),q=m?tt:Math.cos(I),W=m?X:D(u-l),z=m?_:Math.sin(W),Y=m?tt:Math.cos(W);let ot=0,rt=0,it=0;{const t=0*ut,e=m?k:B*(1-t)+C*t,n=m?G:e,o=m?L*(1-t)+A*t:H,s=m?Q:S*(1-t)+v*t,r=m?Z:Math.sin(s),i=m?$:Math.cos(s),a=m?D(t):X,c=m?Math.sin(a):_,l=m?Math.cos(a):tt,u=y+nt(e,o,n);ot=i*l*u,rt=r*l*u,it=c*u}let at=0,ft=0,mt=0;{const t=1*ut,e=m?k:B*(1-t)+C*t,n=m?G:e,o=m?L*(1-t)+A*t:H,s=m?Q:S*(1-t)+v*t,r=m?Z:Math.sin(s),i=m?$:Math.cos(s),a=m?D(t):X,c=m?Math.sin(a):_,l=m?Math.cos(a):tt,u=y+nt(e,o,n);at=i*l*u,ft=r*l*u,mt=c*u}for(let p=1;p<M-1;p+=st){let t=0,e=0,o=0;{const n=(p+1)*ut,s=m?k:B*(1-n)+C*n,r=m?G:s,i=m?L*(1-n)+A*n:H,a=m?Q:S*(1-n)+v*n,c=m?Z:Math.sin(a),l=m?$:Math.cos(a),u=m?D(n):X,d=m?Math.sin(u):_,f=m?Math.cos(u):tt,g=y+nt(s,i,r);t=l*f*g,e=c*f*g,o=d*g}const c=t,l=e,u=o,d=at,h=ft,M=mt;at=c,ft=l,mt=u;{const t=dt+p,e=t*F,o=d-O,s=h-R,r=M-U;j[e]=o,j[e+1]=s,j[e+2]=r,lt(o,s,r,E);const i=p*ut,a=m?J:i,c=m?i:K;N.setValues(t,Math.round(a*n),Math.round(c*n))}const I=ot,W=rt,st=it;ot=d,rt=h,it=M;const gt=d,ht=h,pt=M,xt=1/Math.sqrt(gt*gt+ht*ht+pt*pt),Mt=pt*xt;let yt=0,St=0,vt=0;if(ct&&Mt*Mt<.999){let t=0,e=0,n=0;{const o=0===P?-1:1;t=o*(c-I),e=o*(l-W),n=o*(u-st)}{const o=p*ut,s=m?k:B*(1-o)+C*o,c=m?G:s,l=m?L*(1-o)+A*o:H,u=m?Q:S*(1-o)+v*o,d=m?Z:Math.sin(u),h=m?$:Math.cos(u),M=m?D(o):X,I=m?Math.sin(M):_,E=m?Math.cos(M):tt;let O=gt,R=ht,U=pt;if(w){const t=y+r(c-i,l-a,et),e=m?E:Y;O=(m?V:h)*e*t,R=(m?x:d)*e*t,U=(m?I:z)*t}{const o=y+r(s+i,l+a,b),c=m?E:q,u=(m?g:h)*c*o,p=(m?f:d)*c*o,x=(m?I:T)*o;w||(O=2*gt-u,R=2*ht-p,U=2*pt-x);const M=3===P?-1:1,S=M*(O-u),v=M*(R-p),V=M*(U-x);yt=n*v-e*V,St=t*V-n*S,vt=e*S-t*v;const B=1/Math.sqrt(yt*yt+St*St+vt*vt);yt*=B,St*=B,vt*=B}}}else yt=gt*xt,St=ht*xt,vt=pt*xt;s.setEdgeNormalFromValues(P,p,yt,St,vt)}})()}}function B(t){Z(t)}function C(t,e){return Math.PI/2-2*Math.atan(Math.exp(-t/e))}function L(t,e,n,o){return C(t*(1-o)+e*o,n)}function A(t,e,n){return t*(1-n)+e*n}function P(t){const{tile:e}=t;if(e.surface.isWebMercator){const t=e.extent,n=e.ellipsoid.radius;return e=>L(t[1],t[3],n,e)}const n=e.extentInRadians;return t=>A(n[1],n[3],t)}function D(t,e){const{tile:n,geometryState:s,geometry:r}=t,{extent:i,surface:a}=n,{wireframe:c}=s,l=i[0],u=i[1],d=i[2]-l,f=i[3]-u,{numVerticesPerSide:m,clippingArea:g}=s,h=null!=g?Math.max(0,(g[0]-l)/d):0,p=null!=g?Math.max(0,(g[1]-u)/f):0,x=null!=g?Math.min(1,(g[2]-l)/d):1,M=null!=g?Math.min(1,(g[3]-u)/f):1,y=(m-2)**2,S=ut(s),v=y+4*S,V=a.renderer.tileGeometryCache.acquire(v),{boundingBox:I}=r;o(I),r.numVerticesPerSide=m,r.vertexAttributes=V,r.maxEdgeVertexCount=S,r.minu=h,r.minv=p,r.maxu=x,r.maxv=M,E(t),r.edgeVerticesStartIndex=y,Q(t),U(t),W(r,[],c),t.intersectionData=null}function E(e){const o=e.tile;if(!o.intersectsClippingArea)return;const{geometry:s,geometryState:i,localOrigin:a}=e,{samplerData:c,clippingArea:l,numVerticesPerSide:u}=i,{surface:d,extent:f,ellipsoid:m}=o,{isWebMercatorOnPlateCarree:g}=d,p=null!=l?l:st,x=f[0],M=f[1],y=f[2],S=f[3],v=Math.max(x,p[0]),V=Math.min(y,p[2]),I=Math.max(M,p[1]),b=Math.min(S,p[3]),B=m.radius,C=o.horizontalScale,L=u-1,A=u-2,{minu:P,minv:D,maxu:E,maxv:T,boundingBox:O,vertexAttributes:R}=s,{position:U,uv0:w}=R,{typedBuffer:N,typedBufferStride:j}=R.normalCompressed,F=a[0],q=a[1],W=a[2],k=U.typedBuffer,z=U.typedBufferStride;let G=0;const H=t(M,I,b),J=g?(Math.PI/2-2*Math.atan(Math.exp(-H/B)))*B:H*C,K=1/L,Q=t(M*(1-K)+S*K,I,b);let X=J,Y=g?(Math.PI/2-2*Math.atan(Math.exp(-Q/B)))*B:Q*C;for(let Z=1;Z<=A;Z++){const e=Z/L,o=t(M*(1-e)+S*e,I,b),s=t(e,D,T),i=Y,a=(Z-1)/L,l=t(M*(1-a)+S*a,I,b),u=X,d=(Z+1)/L,f=t(M*(1-d)+S*d,I,b),m=g?(Math.PI/2-2*Math.atan(Math.exp(-f/B)))*B:f*C,p=t(d,D,T);X=Y,Y=m;const R=t(x,v,V);let U=R*C,H=r(R,o,c);const J=1/L,K=t(J,P,E),Q=t(x*(1-K)+y*K,v,V);let $=K,_=Q,tt=Q*C,et=r(Q,o,c);if(1===Z){const e=tt-F,o=X-q,r=et-W,i=0*z;k[i]=e,k[i+1]=o,k[i+2]=r,lt(e,o,r,O);const a=t(J,P,E);w.setValues(G,Math.round(a*n),Math.round(s*n))}for(let g=1;g<=A;g++){const e=tt,a=et,d=(g+1)/L,M=t(d,P,E),S=t(x*(1-d)+y*d,v,V),I=_;_=S;{const t=G+1,e=t*z;if(1===Z||g===A){const a=S*C,l=r(S,o,c);if(1===Z&&g<A){const o=a-F,r=i-q,c=l-W;k[e]=o,k[e+1]=r,k[e+2]=c,lt(o,r,c,O),w.setValues(t,Math.round(M*n),Math.round(s*n))}tt=a,et=l}else tt=k[e]+F,et=k[e+2]+W}const b=tt,B=et,D=U,T=H;U=e,H=a;const R=(G-A)*z,J=1===Z?r(I,l,c):k[R+2]+W,K=r(I,f,c);if(Z<A){const t=G+A,o=t*z,s=e-F,r=m-q,i=K-W;k[o]=s,k[o+1]=r,k[o+2]=i,lt(s,r,i,O);const a=$;$=M,w.setValues(t,Math.round(a*n),Math.round(p*n))}{const t=b-D,e=u-m,n=e*(B-T),o=t*(J-K),s=-e*t,r=n*n+o*o+s*s;if(0===r)h(N,G,0,0,1,j);else{const t=1/Math.sqrt(r);h(N,G,n*t,o*t,s*t,j)}}++G}}}function T(t,e){t.tile.intersectsClippingArea&&(N(t),w(t,!0),_(t),t.intersectionData=null)}function O(t,e){t.tile.intersectsClippingArea&&(X(t),U(t),_(t),tt(t),t.intersectionData=null)}function R(t,e){t.tile.intersectsClippingArea&&(U(t),_(t),t.intersectionData=null)}function U(t,e){t.tile.intersectsClippingArea&&(N(t),w(t,!1))}function w(n,o){const{geometry:s,geometryState:i,localOrigin:a}=n,f=n.tile,{surface:m,extent:h}=f,{clippingArea:p,samplerData:x}=i,M=null!=p?p:st,y=h[0],S=h[2],v=h[1],V=h[3],I=[V>M[3],S>M[2],v<M[1],y<M[0]],b=f.horizontalScale,B=q(m.isWebMercatorOnPlateCarree,f.ellipsoid.radius,b),{minu:C,minv:L,maxu:A,maxv:P,boundingBox:D}=s,E=Math.max(y,M[0]),T=Math.min(S,M[2]),O=Math.max(v,M[1]),R=Math.min(V,M[3]),U=a[0],w=a[1],N=a[2];for(let j=0;j<4;++j){const a=1===j||3===j,h=i.edgeResolutions[j];l(e(h));const p=h+1,M=I[j],F=c(f,i.edgePeerNeighbors[j]);if(!M&&it(f,F,j)){Y(n,j,F);continue}const q=null!=F&&!M,W=F?.renderData,k=W?.geometryState;if(u&&(l(!q||F.level===f.level),l(!q||g(f,F)<=0),f&&!F&&!m.updatingRootTiles)){const t=d[j],e=f.findNeighborTile(t,t=>t.loaded||t.leaf||t.level===f.level);m.updatingRootTiles||(e?e.intersectsClippingArea&&(l(!e.loaded),l(!e.leaf),l(e.level===f.level)):l(null==m?.rootTiles||!f.shouldHaveNeighbor(t)))}const z=t(1===j?S:y,E,T),G=t(0===j?V:v,O,R),H=k?.samplerData,J=o&&p>3?p-3:1,K=t(1===j?1:0,C,A),Q=t(0===j?1:0,L,P),X=q?(t,e)=>.5*(r(t,e,H)+r(t,e,x)):(t,e)=>r(t,e,x),Z=(S-y)/h,$=a?1===j?Z:-Z:0,_=a?0:0===j?Z:-Z,tt=-$,et=-_;let nt=0,ot=0,st=0;{const e=0/h,n=a?z:t(y*(1-e)+S*e,E,T),o=a?t(v*(1-e)+V*e,O,R):G,s=X(n,o);nt=n*b,ot=B(o),st=s}let rt=0,at=0,ct=0;{const e=1/h,n=a?z:t(y*(1-e)+S*e,E,T),o=a?t(v*(1-e)+V*e,O,R):G,s=X(n,o);rt=n*b,at=B(o),ct=s}for(let e=1;e<p-1;e+=J){const n=e/h,o=rt,i=at,c=ct;{const r=a?K:t(n,C,A),l=a?t(n,L,P):Q,u=o-U,d=i-w,f=c-N;lt(o,d,f,D),s.setEdgeVertexFromValuesRawPositionUV(j,e,u,d,f,r,l)}{const n=(e+1)/h,o=a?z:t(y*(1-n)+S*n,E,T),s=a?t(v*(1-n)+V*n,O,R):G,r=X(o,s);rt=o*b,at=B(s),ct=r}const l=rt,u=ct,d=nt,f=ot,m=st;nt=o,ot=i,st=c;let g=0,p=0,M=0;if(a){const e=at-i,s=u-c,a=f-i,l=m-c,d=t(v*(1-n)+V*n,O,R),h=z+tt,y=h*b-o,S=r(h,d,x)-c,I=3===j?-1:1;if(g=I*(-a+e)*S,p=I*y*(-l+s),M=-I*y*(-a+e),q){const t=z+$,n=t*b-o;g=(-a+e)*(S-(r(t,d,H)-c)),p=(y-n)*(-l+s),M=-(y-n)*(-a+e)}}else{const e=l-o,s=u-c,a=d-o,f=m-c,h=t(y*(1-n)+S*n,E,T),v=G+et,V=r(h,v,x)-c,I=B(v)-i,b=2===j?-1:1;if(g=b*I*(-f+s),p=b*(-a+e)*V,M=-b*I*(-a+e),q){const t=h,n=G+_,o=B(n)-i;g=(-I+o)*(-f+s),p=(-a+e)*(-V+(r(t,n,H)-c)),M=-(-I+o)*(-a+e)}}const I=1/Math.sqrt(g*g+p*p+M*M);s.setEdgeNormalFromValues(j,e,g*I,p*I,M*I)}}}function N(t,e){Z(t)}function j(t,e){return(Math.PI/2-2*Math.atan(Math.exp(-t/e)))*e}function F(t,e){return t*e}function q(t,e,n){return t?t=>j(t,e):t=>F(t,n)}function W(t,e,n){const{numVerticesPerSide:o,vertexAttributes:s,maxEdgeVertexCount:r}=t,i=o-1,c=s.count,l=2*(o-3)*(o-3),u=4*(i+r-3),d=a.reduce((e,n)=>e+(i+t.getEdgeCount(n)-3),0),f=e.reduce((t,e)=>t+i*(2*(e.latitudeResolution-1)+1),0),m=3*(n?2:1),g=(l+u+f)*m,h=c>=p?new Uint32Array(g):new Uint16Array(g);for(let a=0;a<g;++a)h[a]=0;t.indices=h,t.indexCount=(l+d+f)*m,t.poleIndicesStartIndex=l*m,t.edgeIndicesStartIndex=(l+f)*m,n?(H(t),J(t,e),K(t)):(k(t),z(t,e),G(t))}function k(t){const{numVerticesPerSide:e,indices:n,vertexAttributes:o}=t,{position:s}=o,{typedBuffer:r,typedBufferStride:i}=s,a=e-2,c=e-3,l=0,u=e-3;let d=0;for(let f=0;f<c;++f){const t=f*a;for(let e=l;e<u;++e){const o=t+e,s=o+1,c=s+a,l=c-1;dt(o,s,c,l,i,r)?(n[d]=o,n[d+1]=s,n[d+2]=c,n[d+3]=c,n[d+4]=l,n[d+5]=o):(n[d]=o,n[d+1]=s,n[d+2]=l,n[d+3]=l,n[d+4]=s,n[d+5]=c),d+=6}}}function z(t,e){const{numVerticesPerSide:n,indices:o,poleIndicesStartIndex:s}=t,r=n-1;let i=s;for(const a of e){const e=a.isNorth?1:2,s=a.isNorth?2:1,c=a.isNorth?3:4,l=a.isNorth?4:3;let u=t.getEdgeVertexIndex(a.connectedOuterEdgeOffset,0),d=1;for(let t=0;t<a.latitudeResolution;++t){const f=0===t?a.rowOffset:u+n;for(let n=0;n<r;n++){const r=f+n;o[i]=u,o[i+e]=u+1,o[i+s]=r,t<a.latitudeResolution-1?(o[i+c]=u+1,o[i+l]=r+1,o[i+5]=r,i+=6):i+=3,u+=d}u=f,d=1}}}function G(t){const{indices:e,numVerticesPerSide:n,edgeIndicesStartIndex:o}=t,s=n-1,r=s-2;let i=o;for(let a=0;a<4;++a){const n=ct[a];let o=0,c=0;const u=t.getEdgeCount(a),d=n.count;l(d===s-1);const f=1===a||2===a,m=f?1:2,g=f?2:1,h=t.getEdgeFirstVertexIndex(a),p=1,x=n.vertex0Index,M=n.stride;for(;o<u-1||c<d-1;){const t=x+c*M,n=h+o*p,a=o<u-1,l=c<d-1,f=a&&(!l||(a?0+s*(o+.5)/(u-1):0)<=(l?1+r*(c+.5)/(d-1):0));f?++o:++c;const y=f?n+p:t+M;e[i]=t,e[i+m]=n,e[i+g]=y,i+=3}}t.indexCount=i}function H(t){const{indices:e,numVerticesPerSide:n,vertexAttributes:o}=t,{position:s}=o,{typedBuffer:r,typedBufferStride:i}=s,a=n-2;let c=0;for(let l=0;l<n-3;++l){const t=l*a;for(let o=0;o<n-3;++o){const n=l*a+o,s=n+1,u=s+a,d=u-1,f=t+o,m=f+1,g=m+a;dt(f,m,g,g-1,i,r)?(ft(e,c,n,s,u),c+=6,ft(e,c,u,d,n)):(ft(e,c,n,s,d),c+=6,ft(e,c,d,u,s)),c+=6}}}function J(t,e){const{indices:n,numVerticesPerSide:o,poleIndicesStartIndex:s}=t,r=o-1;let i=s;for(const a of e){const e=a.connectedOuterEdgeOffset;let s=t.getEdgeVertexIndex(e,0),c=1;for(let t=0;t<a.latitudeResolution;++t){const e=0===t?a.rowOffset:s+o;for(let o=0;o<r;o++)ft(n,i,s,s+1,e+o),i+=6,t<a.latitudeResolution-1&&(ft(n,i,s+1,e+o+1,e+o),i+=6),s+=c;s=e,c=1}}}function K(t){const{indices:e,numVerticesPerSide:n,edgeIndicesStartIndex:o}=t,s=n-1,r=s-2;let i=o;for(let a=0;a<4;++a){const n=ct[a];let o=0,c=0;const u=t.getEdgeCount(a),d=n.count;l(d===s-1);const f=1===a||2===a,m=f?1:3,g=f?3:1,h=t.getEdgeFirstVertexIndex(a),p=1,x=n.vertex0Index,M=n.stride;for(;o<u-1||c<d-1;){const t=x+c*M,n=h+o*p,a=o<u-1,l=c<d-1,f=a&&(!l||(a?0+s*(o+.5)/(u-1):0)<=(l?1+r*(c+.5)/(d-1):0));f?++o:++c;const y=f?n+p:t+M;e[i]=t,e[i+m]=n,e[i+m+1]=n,e[i+g]=y,e[i+g+1]=y,e[i+5]=t,i+=6}}t.indexCount=i}function Q(t){const{geometry:e,geometryState:n}=t,{edgeResolutions:o}=n,{numVerticesPerSide:s,edgeVerticesStartIndex:r}=e,i=s-2;let a=r;for(let c=0;c<4;++c){{const t=0===c||2===c,e=(0===c?i-1:0)*i+(1===c?i-1:0),n=(t?0:1)*i+(t?1:0),o=ct[c];o.vertex0Index=e,o.stride=n,o.count=i}{const t=o[c]+1;e.outerEdgesOffsetAndLength[2*c+0]=a,e.outerEdgesOffsetAndLength[2*c+1]=t,a+=t}}}function X(t){Q(t),t.geometryState.wireframe?K(t.geometry):G(t.geometry)}function Y(o,s,r){const{geometryState:i,geometry:a,tile:c,localOrigin:u}=o,d=1===s||3===s,f=i.edgeResolutions[s];l(e(f));const m=f+1,{boundingBox:g,minu:h,minv:p,maxu:x,maxv:M,vertexAttributes:y}=a,S=t(1===s?1:0,h,x),v=t(0===s?1:0,p,M),V=r.renderData,I=V.geometryState,b=V.geometry,B=(s+2)%4,C=b.getEdgeCount(B),L=c.getNeighborEdgeStartVertexIndex(s,r)*f,A=f*2**(c.level-r.level);l(I.edgeResolutions[B]===A),l(C-1===A);const P=V.localOrigin[0]-u[0],D=V.localOrigin[1]-u[1],E=V.localOrigin[2]-u[2],T=a.getEdgeFirstVertexIndex(s),{position:O,uv0:R}=y,U=O.typedBuffer,w=O.typedBufferStride,N=y.normalCompressed,j=N.typedBuffer,F=N.typedBufferStride,q=b.vertexAttributes,W=b.getEdgeFirstVertexIndex(B),k=q.position.typedBuffer,z=q.position.typedBufferStride,G=q.normalCompressed.typedBuffer,H=q.normalCompressed.typedBufferStride;for(let e=1;e<m-1;++e){const o=T+e,s=W+(L+e),r=o*w,i=s*z,a=k[i]+P,c=k[i+1]+D,l=k[i+2]+E;U[r]=a,U[r+1]=c,U[r+2]=l,lt(a,c,l,g);const u=o*F,m=s*H;j[u]=G[m],j[u+1]=G[m+1];const y=e/f,V=d?S:t(y,h,x),I=d?t(y,p,M):v;R.setValues(o,Math.round(V*n),Math.round(I*n))}}function Z(e){const{geometry:o,geometryState:s,localOrigin:i}=e,{clippingArea:a,samplerData:c}=s,{minu:u,minv:d,maxu:f,maxv:m,boundingBox:h,vertexAttributes:p}=o,x=e.tile,{surface:M,ellipsoid:y,extent:S,extentInRadians:v,horizontalScale:V}=x,I="local"===M.view?.viewingMode,b=y.radius;let B=0,C=0,L=0;const A=(t,e,n)=>{const o=v[0===e?1:3],s=v[0===t?0:2],r=Math.cos(o),i=Math.sin(o),a=Math.sin(s),c=Math.cos(s),l=b+n;B=c*r*l,C=a*r*l,L=i*l},D=I?(()=>{const e=a,n=null!=e&&(S[3]>e[3]||S[2]>e[2]||S[1]<e[1]||S[0]<e[0]),o=q(M.isWebMercatorOnPlateCarree,b,V);return(s,r,i)=>{const a=0===s?S[0]:S[2],c=0===r?S[1]:S[3],l=n?t(a,e[0],e[2]):a,u=n?t(c,e[1],e[3]):c,d=i;B=l*V,C=o(u),L=d}})():A;let E=0,T=0,O=0,R=0,U=0,w=0,N=0,j=0,F=0;const W=I&&M.isWebMercatorOnPlateCarree,k=(t,e,n,o,s)=>{let r=0,i=0,a=0;if(I){const t=e*V,s=W?(Math.PI/2-2*Math.atan(Math.exp(-n/b)))*b:n*V;r=t-B,i=s-C,a=o-L}else{const s=P(t),c=t.tile,l=c.extent,u=c.extentInRadians,d=(e-l[0])/(l[2]-l[0]),f=(n-l[1])/(l[3]-l[1]),m=u[0]*(1-d)+u[2]*d,g=s(f),h=Math.cos(g),p=Math.sin(g),x=Math.sin(m),M=Math.cos(m),y=b+o;r=M*h*y-B,i=x*h*y-C,a=p*y-L}switch(s){case 0:N+=r,j+=i,F+=a;break;case 1:R-=r,U-=i,w-=a;break;case 2:N-=r,j-=i,F-=a;break;case 3:R+=r,U+=i,w+=a}},z=a??st,G=S[0],H=S[2],J=S[1],K=S[3],Q=[K>z[3],H>z[2],J<z[1],G<z[0]],X=Math.max(G,z[0]),Y=Math.min(H,z[2]),Z=Math.max(J,z[1]),_=Math.min(K,z[3]),tt=t=>Math.max(z[0],Math.min(z[2],t)),et=t=>Math.max(z[1],Math.min(z[3],t)),ot=t=>{const e=s.cornerNeighborCornerTiles;E=0,T=0,O=1,R=0,U=0,w=0,N=0,j=0,F=0;let n=1/0;for(let s=0;s<4;++s){const o=e[4*t+s];n=Math.min(n,o?.level??1/0)}for(let s=0;s<4;++s){const o=e[4*t+s];rt[s]=o?.level===n?o:null}let o=1,i=0;for(let s=0;s<4;++s){const t=rt[s];t&&(o=Math.max(o,t?.renderData.geometryState.numVerticesPerSide),i=t.extent[2]-t.extent[0])}const a=i,c=o;l(c>1);const u=a/c;for(let s=0;s<4;++s){const t=rt[(s+3)%4],e=rt[s%4];if(!t&&!e)continue;const n=0===s?1:1===s?2:2===s?3:0,o=0===s?2:1===s?3:2===s?0:1;if(t&&e){const i=nt[s][0]*u,a=nt[s][1]*u,c=t.extent,l=tt(c[0===n||1===n?2:0]+i),d=et(c[0===n||3===n?3:1]+a),f=e.extent,m=tt(f[0===o||1===o?2:0]+i),g=et(f[0===o||3===o?3:1]+a),h=t.renderData,p=e.renderData,x=r(l,d,h.geometryState.samplerData),M=r(m,g,p.geometryState.samplerData);k(h,l,d,.5*(x+M),s)}else{const i=t??e,a=t?n:o,c=i.extent,l=nt[s],d=tt(c[0===a||1===a?2:0]+l[0]*u),f=et(c[0===a||3===a?3:1]+l[1]*u),m=i.renderData,g=r(d,f,m.geometryState.samplerData);k(m,d,f,g,s)}}if(!I){const t=Math.sqrt(B*B+C*C+L*L);E=B/t,T=C/t,O=L/t}if(I||O*O<.999){const t=Math.sqrt(R*R+U*U+w*w);R/=t,U/=t,w/=t;const e=Math.sqrt(N*N+j*j+F*F);N/=e,j/=e,F/=e,E=w*j-U*F,T=R*F-w*N,O=U*N-R*j;const n=1/Math.sqrt(E*E+T*T+O*O);E*=n,T*=n,O*=n}},it=s.cornerNeighborCornerTiles;for(let P=0;P<4;++P){const e=P,a=(P+1)%4,M=0===P||1===P?1:0,y=0===P||3===P?1:0,S=t(M,u,f),v=t(y,d,m),V=o.getEdgeFirstVertexIndex(e),I=o.getEdgeCount(e),b=0===P||3===P?I-1:0,A=o.getEdgeFirstVertexIndex(a),R=o.getEdgeCount(a),U=0===P||1===P?R-1:0;let w=-1;for(let t=0;t<4;++t){const e=it[4*P+t],n=it[4*P+w];e&&(-1===w||g(n,e)>0)&&(w=t)}const N=w,j=it[4*P+N];if(j!==x){const t=x.level-j.level,e=2**t,o=[j.lij[0]+t,j.lij[1]*e,j.lij[2]*e],r=[o[1]+e===x.lij[1],0===P&&(1===N||0===N&&j!==it[4*P+3])||1===P&&(0===N||1===N&&j!==it[4*P+2]),o[1]===x.lij[1]+1,2===P&&(3===N||2===N&&j!==it[4*P+1])||3===P&&(2===N||3===N&&j!==it[4*P+0])],a=r.reduce((t,e)=>t+(e?1:0),0);l(1===a||2===a);let c=-1,u=-1;const d=j.renderData;if(1===a){const t=r.findIndex(t=>t);l(0<=t&&t<=3),c=(t+2)%4;const e=s.edgeResolutions[t];u=x.getNeighborEdgeStartVertexIndex(t,j)*e+e*(0===t&&0===P||1===t&&0===P||2===t&&1===P||3===t&&3===P?1:0)}else{l(r[1]||r[3]),c=r[1]?3:1;const t=d.geometryState.edgeResolutions[c];u=0===P||3===P?0:t}const f=d.geometry;{const t=V+b,e=A+U,o=f.getEdgeFirstVertexIndex(c)+u,s=f.vertexAttributes,r=d.localOrigin,a=s.position,l=a.typedBuffer,m=o*a.typedBufferStride,g=l[m]+r[0]-i[0],x=l[m+1]+r[1]-i[1],M=l[m+2]+r[2]-i[2];lt(g,x,M,h);const y=p.position,I=y.typedBuffer,B=t*y.typedBufferStride;I[B]=g,I[B+1]=x,I[B+2]=M;const C=e*y.typedBufferStride;I[C]=g,I[C+1]=x,I[C+2]=M;const L=p.uv0;L.setValues(t,Math.round(S*n),Math.round(v*n)),L.setValues(e,Math.round(S*n),Math.round(v*n));{const n=s.normalCompressed.typedBuffer,r=o*s.normalCompressed.typedBufferStride,i=p.normalCompressed,a=i.typedBuffer;{const e=t*i.typedBufferStride;a[e]=n[r],a[e+1]=n[r+1]}{const t=e*i.typedBufferStride;a[t]=n[r],a[t+1]=n[r+1]}}}}else{const n=Q[e],s=Q[a];let l;if(n||s){const e=t(G*(1-M)+H*M,X,Y),n=t(J*(1-y)+K*y,Z,_);l=r(e,n,c)}else l=$(it,P);D(M,y,l),ot(P);const u=B-i[0],d=C-i[1],f=L-i[2];lt(u,d,f,h),o.setEdgeVertexFromValuesRawPositionUVNormal(e,b,u,d,f,S,v,E,T,O),o.setEdgeVertexFromValuesRawPositionUVNormal(a,U,u,d,f,S,v,E,T,O)}}for(let t=0;t<4;++t)rt[t]=null}function $(t,e){const n=4*e,o=a.reduce((e,o)=>Math.min(e,t[n+o]?.level??1/0),1/0);u&&(l(!t[n+0]||!t[n+2]||m(t[n+0],t[n+2],5)),l(!t[n+1]||!t[n+3]||m(t[n+1],t[n+3],7)));let s=0,i=0;for(let a=0;a<4;++a){const e=t[n+a];if(e&&e.level===o){const t=0===a||1===a,n=0===a||3===a,o=e.extent,c=o[t?0:2],l=o[n?1:3],u=e.renderData?.geometryState?.samplerData;i+=r(c,l,u),s++}}const c=s?i/s:0;return l(null!=c),c}function _(t){const{vao:e,geometry:n}=t,{vertexAttributes:o,edgeVerticesStartIndex:s}=n,r=o.position.typedBuffer;e.buffer()?.buffer.setSubData(r,s,s,r.length)}function tt(t){const{vao:e,geometry:n}=t,{indices:o,indexCount:s,edgeIndicesStartIndex:r}=n;e.indexBuffer.setSubData(o,r,r,s)}class et{constructor(t,e,n,o,s){this.isNorth=t,this.connectedRowOffset=e,this.connectedOuterEdgeOffset=n,this.rowOffset=o,this.latitudeResolution=s}}const nt=[[0,1],[1,0],[0,-1],[-1,0]],ot=new i,st=s(-1/0,-1/0,1/0,1/0),rt=[null,null,null,null];function it(t,e,n){if(!e)return!1;const o=g(t,e);return o>0||0===o&&n>=2}class at{constructor(){this.vertex0Index=0,this.stride=1,this.count=0}getVertexIndex(t){return l(0<=t&&t<this.count),this.vertex0Index+this.stride*t}}const ct=[new at,new at,new at,new at];function lt(t,e,n,o){t<o[0]?o[0]=t:t>o[3]&&(o[3]=t),e<o[1]?o[1]=e:e>o[4]&&(o[4]=e),n<o[2]?o[2]=n:n>o[5]&&(o[5]=n)}function ut(t){const{edgeResolutions:e,numVerticesPerSide:n}=t,o=1+Math.max(...e);return Math.max(n,o)}function dt(t,e,n,o,s,r){const i=t*s,a=r[i],c=r[i+1],l=r[i+2],u=e*s,d=r[u],f=r[u+1],m=r[u+2],g=n*s,h=r[g],p=r[g+1],x=r[g+2],M=o*s,y=r[M],S=r[M+1],v=r[M+2];return(d-y)*(d-y)+(f-S)*(f-S)+(m-v)*(m-v)>(a-h)*(a-h)+(c-p)*(c-p)+(l-x)*(l-x)}function ft(t,e,n,o,s){t[e]=n,t[e+1]=o,t[e+2]=o,t[e+3]=s,t[e+4]=s,t[e+5]=n}const mt=6;export{D as createPlanarGlobePatch,x as createSphericalGlobePatch,V as updateCornerSpherical,T as updateCornersPlanar,O as updateEdgeElevationsAndResolutionsPlanar,v as updateEdgeElevationsAndResolutionsSpherical,R as updateEdgesAndCornersPlanar,S as updateEdgesAndCornersSpherical};
|
|
5
|
+
import{clamp as t,isPowerOfTwo as e}from"../../../core/mathUtils.js";import{maxUint16 as n}from"../../../core/typedArrayUtil.js";import{empty as o}from"../../../geometry/support/aaBoundingBox.js";import{fromValues as s}from"../../../geometry/support/aaBoundingRect.js";import{sampleElevation as r}from"./ElevationData.js";import{PatchGeometryLUT as i}from"./PatchGeometryLUT.js";import{zeroToFour as a,neighborTileIfLoadedOrSelf as c}from"./PatchRenderData.js";import{internalAssert as l,enableTerrainInternalChecks as u,neighborEdgeIndices as d,almostEquals as f}from"./terrainUtils.js";import{isCornerNeighbor as m}from"./Tile.js";import{compareTilesByLij as g}from"./tileUtils.js";import{compressNormal as h}from"../webgl-engine/lib/Normals.js";const p=65536;function x(t,e){const{tile:n,geometry:s,geometryState:r}=t,{extentInRadians:i,surface:a}=n,{isWebMercator:c,renderer:l}=a,{numVerticesPerSide:u,wireframe:d}=r,f=u-1,m=(u-2)**2,g=c&&(2===e||3===e),h=c&&(1===e||3===e),p=((g?1:0)+(h?1:0))*mt*u,x=ut(r),S=m+p+4*x,v=l.tileGeometryCache.acquire(S);s.numVerticesPerSide=u,s.vertexAttributes=v,s.maxEdgeVertexCount=x;const{boundingBox:V}=s;o(V);const B=P(t);ot.update(f,i,B),y(t),s.poleVerticesStartIndex=m;const b=M(t,g,h);s.edgeVerticesStartIndex=m+p,Q(t),I(t),W(s,b,d),t.intersectionData=null}function M(t,e,o){const{tile:s,localOrigin:r,geometry:i}=t,{extent:a,ellipsoid:c}=s,{boundingBox:l,numVerticesPerSide:u,vertexAttributes:d,poleVerticesStartIndex:f}=i,m=u-1,g=r[0],p=r[1],x=r[2],M=c.radius,y=a[1],S=a[3],v=[];let V=f;const I=(t,e)=>{const o=e*u;lt(-g,-p,t*M-x,l),v.push(new et(1===t,o,1===t?0:2,V,mt));const s=C(-1===t?y:S,M),r=t*Math.PI/2-s,i=.99*(1===t?1:-1),a=M+0,{position:c,uv0:f}=d,{typedBuffer:I,typedBufferStride:B}=d.normalCompressed;for(let u=1;u<=mt;++u){const t=s+r*(u/mt),e=Math.cos(t),o=Math.sin(t);for(let s=0;s<=m;s++){const t=s/m,r=ot.sinLonLUT[s],u=ot.cosLonLUT[s]*e,d=r*e,M=o,y=u*a-g,S=d*a-p,v=M*a-x;lt(y,S,v,l),c.setValues(V,y,S,v),f.setValues(V,Math.round(t*n),Math.round(i*n)),h(I,V,u,d,M,B),++V}}};return e&&I(-1,0),o&&I(1,m),v}function y(t){const{tile:e}=t;if(!e.intersectsClippingArea)return;const{geometry:o,geometryState:s,localOrigin:i}=t,{numVerticesPerSide:a,samplerData:c}=s,l=a-2,u=a-1,{vertexAttributes:d,boundingBox:f}=o,{position:m,uv0:g}=d,{typedBuffer:p,typedBufferStride:x}=d.normalCompressed,{extent:M}=e,y=M[0],S=M[2],v=M[1],V=M[3],I=e.ellipsoid.radius,B=i[0],b=i[1],C=i[2],L=m.typedBuffer,A=m.typedBufferStride,P=1/u;let D=0;if(1<=l){const t=P,e=v*(1-t)+V*t,o=ot.sinLatLUT[1],s=ot.cosLatLUT[1];for(let i=1;i<=l;i++){const a=i*P,l=y*(1-a)+S*a,u=ot.sinLonLUT[i],d=ot.cosLonLUT[i],m=I+r(l,e,c),h=m*d*s-B,p=m*u*s-b,x=m*o-C;lt(h,p,x,f);const M=(i-1)*A;L[M]=h,L[M+1]=p,L[M+2]=x,g.setValues(i-1,Math.round(a*n),Math.round(t*n))}}for(let E=1;E<=l;E++){const t=E*P,e=v*(1-t)+V*t,o=ot.sinLatLUT[E],s=ot.cosLatLUT[E],i=E+1,a=i*P,d=v*(1-a)+V*a,m=ot.sinLatLUT[i],M=ot.cosLatLUT[i],T=ot.sinLonLUT[0],O=ot.cosLonLUT[0],R=I+r(y,e,c);let U=O*s*R-B,w=T*s*R-b,N=o*R-C;const j=D*A;let F=L[j],q=L[j+1],W=L[j+2];for(let V=1;V<=l;V++){const t=V*P,i=y*(1-t)+S*t,T=ot.sinLonLUT[V],O=ot.cosLonLUT[V];let R=0,j=0,k=0;if(V<l){const t=(D+1)*A;R=L[t],j=L[t+1],k=L[t+2]}else{const t=ot.sinLonLUT[u],n=ot.cosLonLUT[u],i=I+r(S,e,c);R=n*s*i-B,j=t*s*i-b,k=o*i-C}const z=U,G=w,H=N;U=F,w=q,N=W,F=R,q=j,W=k;const J=R-z,K=j-G,Q=k-H;let X=0,Y=0,Z=0;if(E>1){const t=(D-l)*A;X=L[t],Y=L[t+1],Z=L[t+2]}else{const t=ot.sinLatLUT[0],e=ot.cosLatLUT[0],n=I+r(i,v,c);X=O*e*n-B,Y=T*e*n-b,Z=t*n-C}const $=I+r(i,d,c),_=O*M*$-B,tt=T*M*$-b,et=m*$-C;if(E<l){const e=D+l,o=e*A;L[o]=_,L[o+1]=tt,L[o+2]=et,lt(_,tt,et,f),g.setValues(e,Math.round(t*n),Math.round(a*n))}const nt=X-_,st=Y-tt,rt=Z-et;let it=O*s,at=T*s,ct=o;ct*ct<.999&&(it=Q*st-K*rt,at=J*rt-Q*nt,ct=K*nt-J*st);const ut=1/Math.sqrt(it*it+at*at+ct*ct);h(p,D,it*ut,at*ut,ct*ut,x),++D}}}function S(t){t.tile.intersectsClippingArea&&(I(t),_(t),t.intersectionData=null)}function v(t){t.tile.intersectsClippingArea&&(X(t),I(t),_(t),tt(t),t.intersectionData=null)}function V(t){t.tile.intersectsClippingArea&&(b(t),B(t,!0),_(t),t.intersectionData=null)}function I(t){t.tile.intersectsClippingArea&&(b(t),B(t))}function B(t,o=!1){const{geometry:s,geometryState:i,tile:a,localOrigin:m}=t,{level:h,extent:p,extentInRadians:x,ellipsoid:M}=a,y=M.radius,S=x[0],v=x[2],V=x[1],I=x[3],{samplerData:B}=i,b=p[0],C=p[2],L=p[1],A=p[3],D=P(t),{boundingBox:E,vertexAttributes:T}=s,O=m[0],R=m[1],U=m[2],{position:w,uv0:N}=T,j=w.typedBuffer,F=w.typedBufferStride;for(let P=0;P<4;++P){const m=1===P||3===P,x=i.edgeResolutions[P];l(e(x));const M=x+1,T=c(a,i.edgePeerNeighbors[P]);if(it(a,T,P)){Y(t,P,T);continue}const w=null!=T;l(!w||T.level===a.level),l(!w||g(a,T)<=0);const q=T?.renderData,W=q?.geometryState;if(u){const t=a.surface;if(!T&&t&&!t.updatingRootTiles){const e=d[P],n=a.findNeighborTile(e,t=>t.loaded||t.leaf||t.level===a.level);n?n.intersectsClippingArea&&(l(!n.loaded),l(!n.leaf),l(n.level===h)):l(null==t?.rootTiles||!a.shouldHaveNeighbor(e))}}const k=1===P?p[2]:p[0],z=T?.extent,G=z&&m?1===P?z[0]:z[2]:k,H=0===P?p[3]:p[1],J=1===P?1:0,K=0===P?1:0,Q=1===P?v:S,X=0===P?I:V,Z=Math.sin(Q),$=Math.cos(Q),_=Math.sin(X),tt=Math.cos(X),et=W?.samplerData,nt=w?(t,e,n)=>.5*(r(t,e,B)+r(n,e,et)):(t,e,n)=>r(t,e,B),ot=s.outerEdgesOffsetAndLength[2*P+0],st=o&&M>3?M-3:1,rt=null!=B&&B.some(t=>null!=t),at=null!=et&&et.some(t=>null!=t),ct=rt||at,ut=1/x,dt=ot;l(!z||f(z[2]-z[0],p[2]-p[0]));(()=>{const t=1===P?-1:3===P?1:0,e=0===P?-1:2===P?1:0,o=(p[2]-p[0])*ut,i=t*o,a=e*o,c=m?t*((v-S)*ut):0,l=m?0:e*ut,u=K,d=m?Q+c:Q,f=m?Math.sin(d):Z,g=m?Math.cos(d):$,h=m?Q-c:Q,x=m?Math.sin(h):Z,V=m?Math.cos(h):$,I=m?X:D(u+l),T=m?_:Math.sin(I),q=m?tt:Math.cos(I),W=m?X:D(u-l),z=m?_:Math.sin(W),Y=m?tt:Math.cos(W);let ot=0,rt=0,it=0;{const t=0*ut,e=m?k:b*(1-t)+C*t,n=m?G:e,o=m?L*(1-t)+A*t:H,s=m?Q:S*(1-t)+v*t,r=m?Z:Math.sin(s),i=m?$:Math.cos(s),a=m?D(t):X,c=m?Math.sin(a):_,l=m?Math.cos(a):tt,u=y+nt(e,o,n);ot=i*l*u,rt=r*l*u,it=c*u}let at=0,ft=0,mt=0;{const t=1*ut,e=m?k:b*(1-t)+C*t,n=m?G:e,o=m?L*(1-t)+A*t:H,s=m?Q:S*(1-t)+v*t,r=m?Z:Math.sin(s),i=m?$:Math.cos(s),a=m?D(t):X,c=m?Math.sin(a):_,l=m?Math.cos(a):tt,u=y+nt(e,o,n);at=i*l*u,ft=r*l*u,mt=c*u}for(let p=1;p<M-1;p+=st){let t=0,e=0,o=0;{const n=(p+1)*ut,s=m?k:b*(1-n)+C*n,r=m?G:s,i=m?L*(1-n)+A*n:H,a=m?Q:S*(1-n)+v*n,c=m?Z:Math.sin(a),l=m?$:Math.cos(a),u=m?D(n):X,d=m?Math.sin(u):_,f=m?Math.cos(u):tt,g=y+nt(s,i,r);t=l*f*g,e=c*f*g,o=d*g}const c=t,l=e,u=o,d=at,h=ft,M=mt;at=c,ft=l,mt=u;{const t=dt+p,e=t*F,o=d-O,s=h-R,r=M-U;j[e]=o,j[e+1]=s,j[e+2]=r,lt(o,s,r,E);const i=p*ut,a=m?J:i,c=m?i:K;N.setValues(t,Math.round(a*n),Math.round(c*n))}const I=ot,W=rt,st=it;ot=d,rt=h,it=M;const gt=d,ht=h,pt=M,xt=1/Math.sqrt(gt*gt+ht*ht+pt*pt),Mt=pt*xt;let yt=0,St=0,vt=0;if(ct&&Mt*Mt<.999){let t=0,e=0,n=0;{const o=0===P?-1:1;t=o*(c-I),e=o*(l-W),n=o*(u-st)}{const o=p*ut,s=m?k:b*(1-o)+C*o,c=m?G:s,l=m?L*(1-o)+A*o:H,u=m?Q:S*(1-o)+v*o,d=m?Z:Math.sin(u),h=m?$:Math.cos(u),M=m?D(o):X,I=m?Math.sin(M):_,E=m?Math.cos(M):tt;let O=gt,R=ht,U=pt;if(w){const t=y+r(c-i,l-a,et),e=m?E:Y;O=(m?V:h)*e*t,R=(m?x:d)*e*t,U=(m?I:z)*t}{const o=y+r(s+i,l+a,B),c=m?E:q,u=(m?g:h)*c*o,p=(m?f:d)*c*o,x=(m?I:T)*o;w||(O=2*gt-u,R=2*ht-p,U=2*pt-x);const M=3===P?-1:1,S=M*(O-u),v=M*(R-p),V=M*(U-x);yt=n*v-e*V,St=t*V-n*S,vt=e*S-t*v;const b=1/Math.sqrt(yt*yt+St*St+vt*vt);yt*=b,St*=b,vt*=b}}}else yt=gt*xt,St=ht*xt,vt=pt*xt;s.setEdgeNormalFromValues(P,p,yt,St,vt)}})()}}function b(t){Z(t)}function C(t,e){return Math.PI/2-2*Math.atan(Math.exp(-t/e))}function L(t,e,n,o){return C(t*(1-o)+e*o,n)}function A(t,e,n){return t*(1-n)+e*n}function P(t){const{tile:e}=t;if(e.surface.isWebMercator){const t=e.extent,n=e.ellipsoid.radius;return e=>L(t[1],t[3],n,e)}const n=e.extentInRadians;return t=>A(n[1],n[3],t)}function D(t,e){const{tile:n,geometryState:s,geometry:r}=t,{extent:i,surface:a}=n,{wireframe:c}=s,l=i[0],u=i[1],d=i[2]-l,f=i[3]-u,{numVerticesPerSide:m,clippingArea:g}=s,h=null!=g?Math.max(0,(g[0]-l)/d):0,p=null!=g?Math.max(0,(g[1]-u)/f):0,x=null!=g?Math.min(1,(g[2]-l)/d):1,M=null!=g?Math.min(1,(g[3]-u)/f):1,y=(m-2)**2,S=ut(s),v=y+4*S,V=a.renderer.tileGeometryCache.acquire(v),{boundingBox:I}=r;o(I),r.numVerticesPerSide=m,r.vertexAttributes=V,r.maxEdgeVertexCount=S,r.minu=h,r.minv=p,r.maxu=x,r.maxv=M,E(t),r.edgeVerticesStartIndex=y,Q(t),U(t),W(r,[],c),t.intersectionData=null}function E(e){const o=e.tile;if(!o.intersectsClippingArea)return;const{geometry:s,geometryState:i,localOrigin:a}=e,{samplerData:c,clippingArea:l,numVerticesPerSide:u}=i,{surface:d,extent:f,ellipsoid:m}=o,{isWebMercatorOnPlateCarree:g}=d,p=null!=l?l:st,x=f[0],M=f[1],y=f[2],S=f[3],v=Math.max(x,p[0]),V=Math.min(y,p[2]),I=Math.max(M,p[1]),B=Math.min(S,p[3]),b=m.radius,C=o.horizontalScale,L=u-1,A=u-2,{minu:P,minv:D,maxu:E,maxv:T,boundingBox:O,vertexAttributes:R}=s,{position:U,uv0:w}=R,{typedBuffer:N,typedBufferStride:j}=R.normalCompressed,F=a[0],q=a[1],W=a[2],k=U.typedBuffer,z=U.typedBufferStride;let G=0;const H=t(M,I,B),J=g?(Math.PI/2-2*Math.atan(Math.exp(-H/b)))*b:H*C,K=1/L,Q=t(M*(1-K)+S*K,I,B);let X=J,Y=g?(Math.PI/2-2*Math.atan(Math.exp(-Q/b)))*b:Q*C;for(let Z=1;Z<=A;Z++){const e=Z/L,o=t(M*(1-e)+S*e,I,B),s=t(e,D,T),i=Y,a=(Z-1)/L,l=t(M*(1-a)+S*a,I,B),u=X,d=(Z+1)/L,f=t(M*(1-d)+S*d,I,B),m=g?(Math.PI/2-2*Math.atan(Math.exp(-f/b)))*b:f*C,p=t(d,D,T);X=Y,Y=m;const R=t(x,v,V);let U=R*C,H=r(R,o,c);const J=1/L,K=t(J,P,E),Q=t(x*(1-K)+y*K,v,V);let $=K,_=Q,tt=Q*C,et=r(Q,o,c);if(1===Z){const e=tt-F,o=X-q,r=et-W,i=0*z;k[i]=e,k[i+1]=o,k[i+2]=r,lt(e,o,r,O);const a=t(J,P,E);w.setValues(G,Math.round(a*n),Math.round(s*n))}for(let g=1;g<=A;g++){const e=tt,a=et,d=(g+1)/L,M=t(d,P,E),S=t(x*(1-d)+y*d,v,V),I=_;_=S;{const t=G+1,e=t*z;if(1===Z||g===A){const a=S*C,l=r(S,o,c);if(1===Z&&g<A){const o=a-F,r=i-q,c=l-W;k[e]=o,k[e+1]=r,k[e+2]=c,lt(o,r,c,O),w.setValues(t,Math.round(M*n),Math.round(s*n))}tt=a,et=l}else tt=k[e]+F,et=k[e+2]+W}const B=tt,b=et,D=U,T=H;U=e,H=a;const R=(G-A)*z,J=1===Z?r(I,l,c):k[R+2]+W,K=r(I,f,c);if(Z<A){const t=G+A,o=t*z,s=e-F,r=m-q,i=K-W;k[o]=s,k[o+1]=r,k[o+2]=i,lt(s,r,i,O);const a=$;$=M,w.setValues(t,Math.round(a*n),Math.round(p*n))}{const t=B-D,e=u-m,n=e*(b-T),o=t*(J-K),s=-e*t,r=n*n+o*o+s*s;if(0===r)h(N,G,0,0,1,j);else{const t=1/Math.sqrt(r);h(N,G,n*t,o*t,s*t,j)}}++G}}}function T(t,e){t.tile.intersectsClippingArea&&(N(t),w(t,!0),_(t),t.intersectionData=null)}function O(t,e){t.tile.intersectsClippingArea&&(X(t),U(t),_(t),tt(t),t.intersectionData=null)}function R(t,e){t.tile.intersectsClippingArea&&(U(t),_(t),t.intersectionData=null)}function U(t,e){t.tile.intersectsClippingArea&&(N(t),w(t,!1))}function w(n,o){const{geometry:s,geometryState:i,localOrigin:a}=n,f=n.tile,{surface:m,extent:h}=f,{clippingArea:p,samplerData:x}=i,M=null!=p?p:st,y=h[0],S=h[2],v=h[1],V=h[3],I=[V>M[3],S>M[2],v<M[1],y<M[0]],B=f.horizontalScale,b=q(m.isWebMercatorOnPlateCarree,f.ellipsoid.radius,B),{minu:C,minv:L,maxu:A,maxv:P,boundingBox:D}=s,E=Math.max(y,M[0]),T=Math.min(S,M[2]),O=Math.max(v,M[1]),R=Math.min(V,M[3]),U=a[0],w=a[1],N=a[2];for(let j=0;j<4;++j){const a=1===j||3===j,h=i.edgeResolutions[j];l(e(h));const p=h+1,M=I[j],F=c(f,i.edgePeerNeighbors[j]);if(!M&&it(f,F,j)){Y(n,j,F);continue}const q=null!=F&&!M,W=F?.renderData,k=W?.geometryState;if(u&&(l(!q||F.level===f.level),l(!q||g(f,F)<=0),f&&!F&&!m.updatingRootTiles)){const t=d[j],e=f.findNeighborTile(t,t=>t.loaded||t.leaf||t.level===f.level);m.updatingRootTiles||(e?e.intersectsClippingArea&&(l(!e.loaded),l(!e.leaf),l(e.level===f.level)):l(null==m?.rootTiles||!f.shouldHaveNeighbor(t)))}const z=t(1===j?S:y,E,T),G=t(0===j?V:v,O,R),H=k?.samplerData,J=o&&p>3?p-3:1,K=t(1===j?1:0,C,A),Q=t(0===j?1:0,L,P),X=q?(t,e)=>.5*(r(t,e,H)+r(t,e,x)):(t,e)=>r(t,e,x),Z=(S-y)/h,$=a?1===j?Z:-Z:0,_=a?0:0===j?Z:-Z,tt=-$,et=-_;let nt=0,ot=0,st=0;{const e=0/h,n=a?z:t(y*(1-e)+S*e,E,T),o=a?t(v*(1-e)+V*e,O,R):G,s=X(n,o);nt=n*B,ot=b(o),st=s}let rt=0,at=0,ct=0;{const e=1/h,n=a?z:t(y*(1-e)+S*e,E,T),o=a?t(v*(1-e)+V*e,O,R):G,s=X(n,o);rt=n*B,at=b(o),ct=s}for(let e=1;e<p-1;e+=J){const n=e/h,o=rt,i=at,c=ct;{const r=a?K:t(n,C,A),l=a?t(n,L,P):Q,u=o-U,d=i-w,f=c-N;lt(o,d,f,D),s.setEdgeVertexFromValuesRawPositionUV(j,e,u,d,f,r,l)}{const n=(e+1)/h,o=a?z:t(y*(1-n)+S*n,E,T),s=a?t(v*(1-n)+V*n,O,R):G,r=X(o,s);rt=o*B,at=b(s),ct=r}const l=rt,u=ct,d=nt,f=ot,m=st;nt=o,ot=i,st=c;let g=0,p=0,M=0;if(a){const e=at-i,s=u-c,a=f-i,l=m-c,d=t(v*(1-n)+V*n,O,R),h=z+tt,y=h*B-o,S=r(h,d,x)-c,I=3===j?-1:1;if(g=I*(-a+e)*S,p=I*y*(-l+s),M=-I*y*(-a+e),q){const t=z+$,n=t*B-o;g=(-a+e)*(S-(r(t,d,H)-c)),p=(y-n)*(-l+s),M=-(y-n)*(-a+e)}}else{const e=l-o,s=u-c,a=d-o,f=m-c,h=t(y*(1-n)+S*n,E,T),v=G+et,V=r(h,v,x)-c,I=b(v)-i,B=2===j?-1:1;if(g=B*I*(-f+s),p=B*(-a+e)*V,M=-B*I*(-a+e),q){const t=h,n=G+_,o=b(n)-i;g=(-I+o)*(-f+s),p=(-a+e)*(-V+(r(t,n,H)-c)),M=-(-I+o)*(-a+e)}}const I=1/Math.sqrt(g*g+p*p+M*M);s.setEdgeNormalFromValues(j,e,g*I,p*I,M*I)}}}function N(t,e){Z(t)}function j(t,e){return(Math.PI/2-2*Math.atan(Math.exp(-t/e)))*e}function F(t,e){return t*e}function q(t,e,n){return t?t=>j(t,e):t=>F(t,n)}function W(t,e,n){const{numVerticesPerSide:o,vertexAttributes:s,maxEdgeVertexCount:r}=t,i=o-1,c=s.count,l=2*(o-3)*(o-3),u=4*(i+r-3),d=a.reduce((e,n)=>e+(i+t.getEdgeCount(n)-3),0),f=e.reduce((t,e)=>t+i*(2*(e.latitudeResolution-1)+1),0),m=3*(n?2:1),g=(l+u+f)*m,h=c>=p?new Uint32Array(g):new Uint16Array(g);for(let a=0;a<g;++a)h[a]=0;t.indices=h,t.indexCount=(l+d+f)*m,t.poleIndicesStartIndex=l*m,t.edgeIndicesStartIndex=(l+f)*m,n?(H(t),J(t,e),K(t)):(k(t),z(t,e),G(t))}function k(t){const{numVerticesPerSide:e,indices:n,vertexAttributes:o}=t,{position:s}=o,{typedBuffer:r,typedBufferStride:i}=s,a=e-2,c=e-3,l=0,u=e-3;let d=0;for(let f=0;f<c;++f){const t=f*a;for(let e=l;e<u;++e){const o=t+e,s=o+1,c=s+a,l=c-1;dt(o,s,c,l,i,r)?(n[d]=o,n[d+1]=s,n[d+2]=c,n[d+3]=c,n[d+4]=l,n[d+5]=o):(n[d]=o,n[d+1]=s,n[d+2]=l,n[d+3]=l,n[d+4]=s,n[d+5]=c),d+=6}}}function z(t,e){const{numVerticesPerSide:n,indices:o,poleIndicesStartIndex:s}=t,r=n-1;let i=s;for(const a of e){const e=a.isNorth?1:2,s=a.isNorth?2:1,c=a.isNorth?3:4,l=a.isNorth?4:3;let u=t.getEdgeVertexIndex(a.connectedOuterEdgeOffset,0),d=1;for(let t=0;t<a.latitudeResolution;++t){const f=0===t?a.rowOffset:u+n;for(let n=0;n<r;n++){const r=f+n;o[i]=u,o[i+e]=u+1,o[i+s]=r,t<a.latitudeResolution-1?(o[i+c]=u+1,o[i+l]=r+1,o[i+5]=r,i+=6):i+=3,u+=d}u=f,d=1}}}function G(t){const{indices:e,numVerticesPerSide:n,edgeIndicesStartIndex:o}=t,s=n-1,r=s-2;let i=o;for(let a=0;a<4;++a){const n=ct[a];let o=0,c=0;const u=t.getEdgeCount(a),d=n.count;l(d===s-1);const f=1===a||2===a,m=f?1:2,g=f?2:1,h=t.getEdgeFirstVertexIndex(a),p=1,x=n.vertex0Index,M=n.stride;for(;o<u-1||c<d-1;){const t=x+c*M,n=h+o*p,a=o<u-1,l=c<d-1,f=a&&(!l||(a?0+s*(o+.5)/(u-1):0)<=(l?1+r*(c+.5)/(d-1):0));f?++o:++c;const y=f?n+p:t+M;e[i]=t,e[i+m]=n,e[i+g]=y,i+=3}}t.indexCount=i}function H(t){const{indices:e,numVerticesPerSide:n,vertexAttributes:o}=t,{position:s}=o,{typedBuffer:r,typedBufferStride:i}=s,a=n-2;let c=0;for(let l=0;l<n-3;++l){const t=l*a;for(let o=0;o<n-3;++o){const n=l*a+o,s=n+1,u=s+a,d=u-1,f=t+o,m=f+1,g=m+a;dt(f,m,g,g-1,i,r)?(ft(e,c,n,s,u),c+=6,ft(e,c,u,d,n)):(ft(e,c,n,s,d),c+=6,ft(e,c,d,u,s)),c+=6}}}function J(t,e){const{indices:n,numVerticesPerSide:o,poleIndicesStartIndex:s}=t,r=o-1;let i=s;for(const a of e){const e=a.connectedOuterEdgeOffset;let s=t.getEdgeVertexIndex(e,0),c=1;for(let t=0;t<a.latitudeResolution;++t){const e=0===t?a.rowOffset:s+o;for(let o=0;o<r;o++)ft(n,i,s,s+1,e+o),i+=6,t<a.latitudeResolution-1&&(ft(n,i,s+1,e+o+1,e+o),i+=6),s+=c;s=e,c=1}}}function K(t){const{indices:e,numVerticesPerSide:n,edgeIndicesStartIndex:o}=t,s=n-1,r=s-2;let i=o;for(let a=0;a<4;++a){const n=ct[a];let o=0,c=0;const u=t.getEdgeCount(a),d=n.count;l(d===s-1);const f=1===a||2===a,m=f?1:3,g=f?3:1,h=t.getEdgeFirstVertexIndex(a),p=1,x=n.vertex0Index,M=n.stride;for(;o<u-1||c<d-1;){const t=x+c*M,n=h+o*p,a=o<u-1,l=c<d-1,f=a&&(!l||(a?0+s*(o+.5)/(u-1):0)<=(l?1+r*(c+.5)/(d-1):0));f?++o:++c;const y=f?n+p:t+M;e[i]=t,e[i+m]=n,e[i+m+1]=n,e[i+g]=y,e[i+g+1]=y,e[i+5]=t,i+=6}}t.indexCount=i}function Q(t){const{geometry:e,geometryState:n}=t,{edgeResolutions:o}=n,{numVerticesPerSide:s,edgeVerticesStartIndex:r}=e,i=s-2;let a=r;for(let c=0;c<4;++c){{const t=0===c||2===c,e=(0===c?i-1:0)*i+(1===c?i-1:0),n=(t?0:1)*i+(t?1:0),o=ct[c];o.vertex0Index=e,o.stride=n,o.count=i}{const t=o[c]+1;e.outerEdgesOffsetAndLength[2*c+0]=a,e.outerEdgesOffsetAndLength[2*c+1]=t,a+=t}}}function X(t){Q(t),t.geometryState.wireframe?K(t.geometry):G(t.geometry)}function Y(o,s,r){const{geometryState:i,geometry:a,tile:c,localOrigin:u}=o,d=1===s||3===s,f=i.edgeResolutions[s];l(e(f));const m=f+1,{boundingBox:g,minu:h,minv:p,maxu:x,maxv:M,vertexAttributes:y}=a,S=t(1===s?1:0,h,x),v=t(0===s?1:0,p,M),V=r.renderData,I=V.geometryState,B=V.geometry,b=(s+2)%4,C=B.getEdgeCount(b),L=c.getNeighborEdgeStartVertexIndex(s,r)*f,A=f*2**(c.level-r.level);l(I.edgeResolutions[b]===A),l(C-1===A);const P=V.localOrigin[0]-u[0],D=V.localOrigin[1]-u[1],E=V.localOrigin[2]-u[2],T=a.getEdgeFirstVertexIndex(s),{position:O,uv0:R}=y,U=O.typedBuffer,w=O.typedBufferStride,N=y.normalCompressed,j=N.typedBuffer,F=N.typedBufferStride,q=B.vertexAttributes,W=B.getEdgeFirstVertexIndex(b),k=q.position.typedBuffer,z=q.position.typedBufferStride,G=q.normalCompressed.typedBuffer,H=q.normalCompressed.typedBufferStride;for(let e=1;e<m-1;++e){const o=T+e,s=W+(L+e),r=o*w,i=s*z,a=k[i]+P,c=k[i+1]+D,l=k[i+2]+E;U[r]=a,U[r+1]=c,U[r+2]=l,lt(a,c,l,g);const u=o*F,m=s*H;j[u]=G[m],j[u+1]=G[m+1];const y=e/f,V=d?S:t(y,h,x),I=d?t(y,p,M):v;R.setValues(o,Math.round(V*n),Math.round(I*n))}}function Z(e){const{geometry:o,geometryState:s,localOrigin:i}=e,{clippingArea:a,samplerData:c}=s,{minu:u,minv:d,maxu:f,maxv:m,boundingBox:h,vertexAttributes:p}=o,x=e.tile,{surface:M,ellipsoid:y,extent:S,extentInRadians:v,horizontalScale:V}=x,I="local"===M.view?.viewingMode,B=y.radius;let b=0,C=0,L=0;const A=(t,e,n)=>{const o=v[0===e?1:3],s=v[0===t?0:2],r=Math.cos(o),i=Math.sin(o),a=Math.sin(s),c=Math.cos(s),l=B+n;b=c*r*l,C=a*r*l,L=i*l},D=I?(()=>{const e=a,n=null!=e&&(S[3]>e[3]||S[2]>e[2]||S[1]<e[1]||S[0]<e[0]),o=q(M.isWebMercatorOnPlateCarree,B,V);return(s,r,i)=>{const a=0===s?S[0]:S[2],c=0===r?S[1]:S[3],l=n?t(a,e[0],e[2]):a,u=n?t(c,e[1],e[3]):c,d=i;b=l*V,C=o(u),L=d}})():A;let E=0,T=0,O=0,R=0,U=0,w=0,N=0,j=0,F=0;const W=I&&M.isWebMercatorOnPlateCarree,k=(t,e,n,o,s)=>{let r=0,i=0,a=0;if(I){const t=e*V,s=W?(Math.PI/2-2*Math.atan(Math.exp(-n/B)))*B:n*V;r=t-b,i=s-C,a=o-L}else{const s=P(t),c=t.tile,l=c.extent,u=c.extentInRadians,d=(e-l[0])/(l[2]-l[0]),f=(n-l[1])/(l[3]-l[1]),m=u[0]*(1-d)+u[2]*d,g=s(f),h=Math.cos(g),p=Math.sin(g),x=Math.sin(m),M=Math.cos(m),y=B+o;r=M*h*y-b,i=x*h*y-C,a=p*y-L}switch(s){case 0:N+=r,j+=i,F+=a;break;case 1:R-=r,U-=i,w-=a;break;case 2:N-=r,j-=i,F-=a;break;case 3:R+=r,U+=i,w+=a}},z=a??st,G=S[0],H=S[2],J=S[1],K=S[3],Q=[K>z[3],H>z[2],J<z[1],G<z[0]],X=Math.max(G,z[0]),Y=Math.min(H,z[2]),Z=Math.max(J,z[1]),_=Math.min(K,z[3]),tt=t=>Math.max(z[0],Math.min(z[2],t)),et=t=>Math.max(z[1],Math.min(z[3],t)),ot=t=>{const e=s.cornerNeighborCornerTiles;E=0,T=0,O=1,R=0,U=0,w=0,N=0,j=0,F=0;let n=1/0;for(let s=0;s<4;++s){const o=e[4*t+s];n=Math.min(n,o?.level??1/0)}for(let s=0;s<4;++s){const o=e[4*t+s];rt[s]=o?.level===n?o:null}let o=1,i=0;for(let s=0;s<4;++s){const t=rt[s];t&&(o=Math.max(o,t?.renderData.geometryState.numVerticesPerSide),i=t.extent[2]-t.extent[0])}const a=i,c=o;l(c>1);const u=a/c;for(let s=0;s<4;++s){const t=rt[(s+3)%4],e=rt[s%4];if(!t&&!e)continue;const n=0===s?1:1===s?2:2===s?3:0,o=0===s?2:1===s?3:2===s?0:1;if(t&&e){const i=nt[s][0]*u,a=nt[s][1]*u,c=t.extent,l=tt(c[0===n||1===n?2:0]+i),d=et(c[0===n||3===n?3:1]+a),f=e.extent,m=tt(f[0===o||1===o?2:0]+i),g=et(f[0===o||3===o?3:1]+a),h=t.renderData,p=e.renderData,x=r(l,d,h.geometryState.samplerData),M=r(m,g,p.geometryState.samplerData);k(h,l,d,.5*(x+M),s)}else{const i=t??e,a=t?n:o,c=i.extent,l=nt[s],d=tt(c[0===a||1===a?2:0]+l[0]*u),f=et(c[0===a||3===a?3:1]+l[1]*u),m=i.renderData,g=r(d,f,m.geometryState.samplerData);k(m,d,f,g,s)}}if(!I){const t=Math.sqrt(b*b+C*C+L*L);E=b/t,T=C/t,O=L/t}if(I||O*O<.999){const t=Math.sqrt(R*R+U*U+w*w);R/=t,U/=t,w/=t;const e=Math.sqrt(N*N+j*j+F*F);N/=e,j/=e,F/=e,E=w*j-U*F,T=R*F-w*N,O=U*N-R*j;const n=1/Math.sqrt(E*E+T*T+O*O);E*=n,T*=n,O*=n}},it=s.cornerNeighborCornerTiles;for(let P=0;P<4;++P){const e=P,a=(P+1)%4,M=0===P||1===P?1:0,y=0===P||3===P?1:0,S=t(M,u,f),v=t(y,d,m),V=o.getEdgeFirstVertexIndex(e),I=o.getEdgeCount(e),B=0===P||3===P?I-1:0,A=o.getEdgeFirstVertexIndex(a),R=o.getEdgeCount(a),U=0===P||1===P?R-1:0;let w=-1;for(let t=0;t<4;++t){const e=it[4*P+t],n=it[4*P+w];e&&(-1===w||g(n,e)>0)&&(w=t)}const N=w,j=it[4*P+N];if(j!==x){const t=x.level-j.level,e=2**t,o=[j.lij[0]+t,j.lij[1]*e,j.lij[2]*e],r=[o[1]+e===x.lij[1],0===P&&(1===N||0===N&&j!==it[4*P+3])||1===P&&(0===N||1===N&&j!==it[4*P+2]),o[1]===x.lij[1]+1,2===P&&(3===N||2===N&&j!==it[4*P+1])||3===P&&(2===N||3===N&&j!==it[4*P+0])],a=r.reduce((t,e)=>t+(e?1:0),0);l(1===a||2===a);let c=-1,u=-1;const d=j.renderData;if(1===a){const t=r.findIndex(t=>t);l(0<=t&&t<=3),c=(t+2)%4;const e=s.edgeResolutions[t];u=x.getNeighborEdgeStartVertexIndex(t,j)*e+e*(0===t&&0===P||1===t&&0===P||2===t&&1===P||3===t&&3===P?1:0)}else{l(r[1]||r[3]),c=r[1]?3:1;const t=d.geometryState.edgeResolutions[c];u=0===P||3===P?0:t}const f=d.geometry;{const t=V+B,e=A+U,o=f.getEdgeFirstVertexIndex(c)+u,s=f.vertexAttributes,r=d.localOrigin,a=s.position,l=a.typedBuffer,m=o*a.typedBufferStride,g=l[m]+r[0]-i[0],x=l[m+1]+r[1]-i[1],M=l[m+2]+r[2]-i[2];lt(g,x,M,h);const y=p.position,I=y.typedBuffer,b=t*y.typedBufferStride;I[b]=g,I[b+1]=x,I[b+2]=M;const C=e*y.typedBufferStride;I[C]=g,I[C+1]=x,I[C+2]=M;const L=p.uv0;L.setValues(t,Math.round(S*n),Math.round(v*n)),L.setValues(e,Math.round(S*n),Math.round(v*n));{const n=s.normalCompressed.typedBuffer,r=o*s.normalCompressed.typedBufferStride,i=p.normalCompressed,a=i.typedBuffer;{const e=t*i.typedBufferStride;a[e]=n[r],a[e+1]=n[r+1]}{const t=e*i.typedBufferStride;a[t]=n[r],a[t+1]=n[r+1]}}}}else{const n=Q[e],s=Q[a];let l;if(n||s){const e=t(G*(1-M)+H*M,X,Y),n=t(J*(1-y)+K*y,Z,_);l=r(e,n,c)}else l=$(it,P);D(M,y,l),ot(P);const u=b-i[0],d=C-i[1],f=L-i[2];lt(u,d,f,h),o.setEdgeVertexFromValuesRawPositionUVNormal(e,B,u,d,f,S,v,E,T,O),o.setEdgeVertexFromValuesRawPositionUVNormal(a,U,u,d,f,S,v,E,T,O)}}for(let t=0;t<4;++t)rt[t]=null}function $(t,e){const n=4*e,o=a.reduce((e,o)=>Math.min(e,t[n+o]?.level??1/0),1/0);u&&(l(!t[n+0]||!t[n+2]||m(t[n+0],t[n+2],5)),l(!t[n+1]||!t[n+3]||m(t[n+1],t[n+3],7)));let s=0,i=0;for(let a=0;a<4;++a){const e=t[n+a];if(e&&e.level===o){const t=0===a||1===a,n=0===a||3===a,o=e.extent,c=o[t?0:2],l=o[n?1:3],u=e.renderData?.geometryState?.samplerData;i+=r(c,l,u),s++}}const c=s?i/s:0;return l(null!=c),c}function _(t){const{vao:e,geometry:n}=t,{vertexAttributes:o,edgeVerticesStartIndex:s}=n,r=o.position.typedBuffer;e.buffer()?.setSubData(r,s,s,r.length)}function tt(t){const{vao:e,geometry:n}=t,{indices:o,indexCount:s,edgeIndicesStartIndex:r}=n;e.indexBuffer.setSubData(o,r,r,s)}class et{constructor(t,e,n,o,s){this.isNorth=t,this.connectedRowOffset=e,this.connectedOuterEdgeOffset=n,this.rowOffset=o,this.latitudeResolution=s}}const nt=[[0,1],[1,0],[0,-1],[-1,0]],ot=new i,st=s(-1/0,-1/0,1/0,1/0),rt=[null,null,null,null];function it(t,e,n){if(!e)return!1;const o=g(t,e);return o>0||0===o&&n>=2}class at{constructor(){this.vertex0Index=0,this.stride=1,this.count=0}getVertexIndex(t){return l(0<=t&&t<this.count),this.vertex0Index+this.stride*t}}const ct=[new at,new at,new at,new at];function lt(t,e,n,o){t<o[0]?o[0]=t:t>o[3]&&(o[3]=t),e<o[1]?o[1]=e:e>o[4]&&(o[4]=e),n<o[2]?o[2]=n:n>o[5]&&(o[5]=n)}function ut(t){const{edgeResolutions:e,numVerticesPerSide:n}=t,o=1+Math.max(...e);return Math.max(n,o)}function dt(t,e,n,o,s,r){const i=t*s,a=r[i],c=r[i+1],l=r[i+2],u=e*s,d=r[u],f=r[u+1],m=r[u+2],g=n*s,h=r[g],p=r[g+1],x=r[g+2],M=o*s,y=r[M],S=r[M+1],v=r[M+2];return(d-y)*(d-y)+(f-S)*(f-S)+(m-v)*(m-v)>(a-h)*(a-h)+(c-p)*(c-p)+(l-x)*(l-x)}function ft(t,e,n,o,s){t[e]=n,t[e+1]=o,t[e+2]=o,t[e+3]=s,t[e+4]=s,t[e+5]=n}const mt=6;export{D as createPlanarGlobePatch,x as createSphericalGlobePatch,V as updateCornerSpherical,T as updateCornersPlanar,O as updateEdgeElevationsAndResolutionsPlanar,v as updateEdgeElevationsAndResolutionsSpherical,R as updateEdgesAndCornersPlanar,S as updateEdgesAndCornersSpherical};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/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,releaseMaybe as i}from"../../../core/maybe.js";import{j as s,F as o,H as a,d as n,n as l,e as d,a as g,G as h}from"../../../chunks/vec32.js";import{create as u,clone as m}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{containsXY as c}from"../../../geometry/support/aaBoundingRect.js";import{earth as f}from"../../../geometry/support/Ellipsoid.js";import{glLayout as p}from"../support/buffer/glUtil.js";import{GeometryState as y}from"./GeometryState.js";import{PatchGeometry as x}from"./PatchGeometry.js";import{maxTileNeighborLevelDelta as _}from"./TerrainConst.js";import{internalAssert as v,neighborEdgeIndices as $,oppositeEdge as C,neighborCornerIndices as E,enableTerrainInternalChecks as S,v32s as D,lij2s as b}from"./terrainUtils.js";import{TextureFader as j}from"./TextureFader.js";import{TextureReference as R}from"./TextureReference.js";import T from"./TileOverlayData.js";import{fallsWithinLayerView as V}from"./tileUtils.js";import{VertexArrayObject as w}from"../webgl-engine/lib/VertexArrayObject.js";import{BufferObject as A}from"../../webgl/BufferObject.js";import{VertexBuffer as P}from"../../webgl/VertexBuffer.js";class F{constructor(){this.geometry=new x,this.geometryState=null,this._texture=null,this._textureOpacity=1,this._textureRef=new j(()=>this._tile.surface.fadeDuration),this.overlay=new T,this._localOrigin=null,this._geometryStateChangedSinceLastUpdate=!0,this._hasGeometry=!1,this._modifiedFlags=0}get tile(){return this._tile}get localOrigin(){return this._localOrigin}init(e,t){this.clear(),this._tile=e,this.geometry.reset(),this.intersectionData=null,this.geometryState=new y,this._localOrigin=t,this.overlay.clear()}clear(){this.releaseGeometry(),this.releaseTexture(),this._textureRef.clear(),this._tile=null,this.intersectionData=null,this.geometryState=null}updateGeometryIfNeeded(e){if((!this._vao||this._geometryStateChangedSinceLastUpdate||this.wireframeChanged||this.clippingAreaChanged||this.samplerDataChanged||this.numVerticesPerSideChanged||this.dirtyCorners||this.dirtyEdgeResolutions||this.dirtyEdges)&&(this._updateGeometry(e),this._geometryStateChangedSinceLastUpdate=!1),S&&this.tile.intersectsClippingArea)for(let t=0;t<4;++t)v(this.geometry.getEdgeCount(t)===this.geometryState.edgeResolutions[t]+1)}_calculateEdgeResolution(e,t){const r=this.tile,i=this.geometryState.numVerticesPerSide-1;if(!r.surface.isGlobal){const t=r.surface.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=$[e];if(!t)return v(null==r.surface?.rootTiles||r.surface.updatingRootTiles||!r.shouldHaveNeighbor(o)),i;if(t.loaded){const r=t,o=r.renderData.geometryState,a=s-r.level;if(v(a>=0),0===a){const e=o.numVerticesPerSide-1;return Math.max(e,i)}const n=2**a,l=o.edgeResolutions[(e+2)%4]/n;return Math.max(1,l)}v(!t.leaf);let a=i;return t.forAllSubtreeOnSide(C(o),e=>e===r||(e.loaded?(a=Math.max(a,2**(e.level-s)),!0):(v(!e.leaf),!1))),a}updateNeighborData(){const e=this.tile;if(!e.intersectsClippingArea)return;const r=e.renderData.geometryState,i=t=>(t.loaded||t.level===e.level)&&t?.intersectsClippingArea,s=r.edgePeerNeighbors,o=r.edgePeerNeighborSamplerVersions;for(let a=0;a<4;++a){const n=e.findNeighborTile($[a],i),l=X(e,n),d=l?.renderData?.geometryState.samplerDataVersion??-1,g=s[a],h=l!==X(e,g),u=o[a]!==d;S&&n&&(v(e.level>=n.level),v(e.level-n.level<=_)),s[a]=n,(h||u)&&(o[a]=d,this._markEdgeDirty(a));const m=r.edgeResolutions[a],c=this._calculateEdgeResolution(a,n);v(t(c)),v(c>=1),r.edgeResolutions[a]=c,m!==c&&this._markEdgeResolutionDirty(a)}for(let t=0;t<4;++t){const o=e.findNeighborTile(E[t],i);r.cornerPeerNeighbors[t]=o;const a=X(e,s[t]),n=X(e,s[(t+1)%4]),l=X(e,o);L[t]=l,L[(t+1)%4]=n,L[(t+2)%4]=e,L[(t+3)%4]=a,v(L.some(t=>t?.loaded||t===e));const d=L.reduce((e,t)=>Math.min(e,t?.level??1/0),1/0);L.forEach((e,t)=>{e&&e?.level>d&&(L[t]=null)}),v(L.some(t=>t?.loaded||t===e));const g=r.cornerNeighborCornerTiles,h=r.cornerNeighborCornerTileSamplerVersions;for(let e=0;e<4;++e){const r=L[e],i=r?.renderData.geometryState.samplerDataVersion??-1,s=4*t+e,o=g[s]!==r,a=!o&&h[s]!==i;(o||a)&&(g[s]=r,h[s]=i,this._markCornerDirty(t))}S&&v(Q.some(r=>g[4*t+r]?.loaded||g[4*t+r]===e))}S&&v(this.geometryState.edgeResolutions.every(e=>e>0));for(let t=0;t<4;++t)L[t]=null}_updateGeometry(e){if(!this.tile.intersectsClippingArea)return;S&&v(!this.tile.intersectsClippingArea||this.geometryState.edgeResolutions.every(e=>e>0)),this.intersectionData=null;const{tile:t,_vao:r,geometry:i,geometryState:s}=this,o=!r||!{}||this.wireframeChanged||this.samplerDataChanged||this.clippingAreaChanged||this.numVerticesPerSideChanged,a=0!==this.dirtyEdgeResolutions,n=s.edgeResolutions.reduce((e,t)=>e+t+1,0),l=o||a&&n>(i?.maxEdgeVertexCount??0),d=!l&&a,g=!d&&(0!==this.dirtyEdges||a),h=!g&&0!==this.dirtyCorners;l?(this.releaseGeometry(),this._createGeometry(e)):d?t.updateEdgeElevationsAndResolutions():g||h?t.updateEdgeElevations():h?t.updateCornerElevations():console.warn("Update for no reason?"),this._modifiedFlags=0}get hasGeometry(){return this._hasGeometry}releaseGeometry(){return this._hasGeometry=!1,this.intersectionData=null,!!this._vao&&(this._vao=r(this._vao),this.geometry.release(),!0)}ensureTexture(e,t,r,i){const s=t?6408:6407;return null!=this._texture&&(0===r&&this._tile.surface.fadeDuration>0&&this._isTextureVisible(this._texture)||this._texture.descriptor.width!==e||this._texture.descriptor.pixelFormat!==s)&&this.releaseTexture(),null==this._texture&&(this._texture=i(),this.tile.setMemoryDirty()),this._texture}releaseTexture(){this._texture&&(this._texture=i(this._texture),this.tile.setMemoryDirty())}reuseTexture(e,t){return!(!e||!this._texture)&&(e.setTextureReference(new R(this._texture,0,t,this._textureOpacity,0,1)),!0)}get numVerticesPerSideChanged(){return 0!==(this._modifiedFlags&B)}get samplerDataChanged(){return 0!==(this._modifiedFlags&H)}get clippingAreaChanged(){return 0!==(this._modifiedFlags&W)}get wireframeChanged(){return 0!==(this._modifiedFlags&q)}get dirtyEdges(){return this._modifiedFlags>>z&15}get dirtyCorners(){return this._modifiedFlags>>J&15}get dirtyEdgeResolutions(){return this._modifiedFlags>>K&15}_markCornerDirty(e){const t=1<<e<<J;this._modifiedFlags|=t}_markEdgeDirty(e){const t=1<<e<<z;this._modifiedFlags|=t,this._markCornerDirty((e+0)%4),this._markCornerDirty((e+3)%4)}_markEdgeResolutionDirty(e){const t=1<<e<<K;this._modifiedFlags|=t,this._markEdgeDirty(e)}_markAllEdgesAndCornersDirty(){this._modifiedFlags|=15<<J|15<<z|15<<K}updateGeometryState(){const t=this._elevationInfo,r=this.tile,i=t.samplerData?r.getElevationVerticesPerSide(t.maxTileLevel):r.minimumVerticesPerSide,s=Math.max(i,5);let o=r.clippingArea;r.intersectsClippingArea&&!r.withinClippingArea||(o=null);const a=this.geometryState;let n=!1;a.numVerticesPerSide!==s&&(this._modifiedFlags|=1,a.numVerticesPerSide=s,a.samplerDataVersion++,n=!0),t.changed&&(this._modifiedFlags|=2,a.samplerData=t.samplerData,a.samplerDataVersion++,n=!0),e(a.clippingArea,o)||(this._modifiedFlags=4,a.clippingArea=o,n=!0);const l=r.surface.wireframe;return a.wireframe!==l&&(this._modifiedFlags=8,a.wireframe=l,n=!0),this._geometryStateChangedSinceLastUpdate||=n,n&&this._markAllEdgesAndCornersDirty(),this._hasGeometry=!0,this._geometryStateChangedSinceLastUpdate}_createGeometry(e){this.tile.createGeometry();const{vertexAttributes:t,indices:r}=this.geometry,i=e.gl;this._vao=new w(e,new P(p(t.layout),A.createVertex(e,i.STATIC_DRAW,t.buffer)),A.createIndex(e,i.STATIC_DRAW,r)),this._hasGeometry=!0}get vao(){return this._vao}setTextureReference(e,t=0){e?.texture===this._texture?this._textureOpacity=e.opacities[0]:this.releaseTexture(),this._textureRef.push(e,t)}get textureReference(){return this._textureRef.current}get nextTextureReference(){return this._textureRef.next}get textureFadeFactor(){return this._textureRef.fadeFactor}get textureIsFading(){return this._textureRef.isFading}_isTextureVisible(e){return this._textureRef.current?.texture===e||this._textureRef.next?.texture===e&&this._textureRef.fadeFactor<1}get _elevationInfo(){const e=this.geometryState.samplerData,t=this.tile.layerInfo[0],r=t.length,i=new Array(r);let s=0,o=0,a=!1;for(let d=0;d<r;d++){const r=t[d],n=r.upsampleInfo?.tile;if(n){const t=n.layerInfo[0][d].data,r=t&&t.samplerData;e&&e[s]===r||(a=!0),i[s++]=r,o=Math.max(o,n.lij[0])}else if(r.data){const t=this.tile.surface.layerViewByIndex(d,0);if(V(this.tile,t)){const t=r.data;e&&e[s]===t.samplerData||(a=!0),i[s++]=t.samplerData,o=this.tile.level}}}null!=e&&e.length!==s&&(a=!0);const n=s>0,l=n?i:null;return n&&(i.length=s),{changed:a,samplerData:l,maxTileLevel:o}}get estimatedGeometryMemoryUsage(){const e=this.intersectionData?.estimatedMemoryUsage??0;return(this.geometry.indices?.byteLength??0)+(this.geometry.vertexAttributes?.byteLength??0)+e}get texture(){return this._texture}get test(){}checkGeometryWaterproofness(){if(!S)return;const e=this.tile;if(!e.loaded||!e.intersectsClippingArea||0===e.level)return void v(e?.loaded);const r=e.surface.extent;if(null!=r&&!e.intersectsExtent(r))return;const i=$.map((t,i)=>null!=r&&(i<2?-1:1)*(e.extent[3-i]-r[3-i])<0),p=e.level;v(0===this.dirtyCorners),v(0===this.dirtyEdges),v(0===this.dirtyEdgeResolutions),v(!this.numVerticesPerSideChanged),v(!this.samplerDataChanged),v(!this.clippingAreaChanged),v(!this.wireframeChanged);const y=E.map(t=>e.findNeighborCornerTileExact(t,t=>!t.intersectsClippingArea||t.loaded||t.level===e.level)??null).map(e=>e?.intersectsClippingArea?e:null),x=this.geometryState;for(let t=0;t<4;++t){const r=x.cornerPeerNeighbors[t],i=y[t];v(i===r,`Tile[${e.lij}].corner[${t}] out of date: cur=[${r?.lij}] exp=[${i?.lij}]`)}$.forEach((r,y)=>{if(i[y])return;const x=e.findNeighborTile(r,e=>(e.level===p||e?.loaded)&&e?.intersectsClippingArea);if(!x){const t=!e.surface.updatingRootTiles&&null!=e.surface.rootTiles&&e.surface.rootTiles.length>0&&e.shouldHaveNeighbor(r);return void v(!t)}v(x.loaded||x.level===e.level),v(x===this.geometryState.edgePeerNeighbors[y]);const _=p-x.level;if(!x.loaded)return v(!x.leaf),void v(0===_);const $=x.renderData;v(e.isEdgeNeighbor(x,r)),v(_>=0);const C=2**_;if(_<0)return void v(!1);const E=e.renderData,S=E.geometry,j=E.localOrigin,R=S.getEdgeCount(y),T=S.numVerticesPerSide-1,V=$.geometry;if(!V)return void v(!1);const w=$.localOrigin,A=this.geometryState.edgePeerNeighbors[y];if(A?.loaded){const e=A.renderData;v(E.geometryState.edgePeerNeighborSamplerVersions[y]===e.geometryState.samplerDataVersion),v(this.geometryState.edgePeerNeighborSamplerVersions[y]===e.geometryState.samplerDataVersion)}const P=(y+2)%4,F=V.getEdgeCount(P),L=R-1,X=F-1;v(L*C===X,`Tile[${e.lij}]:e${y},res=${L} edgeRes mismatch with Neighbor[${x.lij}]:e${P},res=${X} (expected:${L*C})`);const B=e.extent,H=0===r||4===r,W=F-1,q=W>>_,z=R-1;if(q<1)return void v(1===z);v(q===z),v(t(q));const J=V.numVerticesPerSide-1;v(_>0||q===Math.max(J,T));const K=e.getNeighborEdgeStartVertexIndex(y,x);v(0<=K&&K<C);const Q=K*q;v(0<=Q&&Q<=W-q);let Y=0,Z=Q;S.getEdgeVertexPosition(y,N,j,0),S.getEdgeVertexPosition(y,G,j,R-1);const ee=s(N,G),te=Math.max(I,1e-4*ee);for(let t=0;t<=q;++t){S.getEdgeVertexPosition(y,N,j,Y),V.getEdgeVertexPosition(P,G,w,Z);const i=t/q,s=H?B[0]+i*(B[2]-B[0]):6===r?B[0]:B[2],p=H?4===r?B[1]:B[3]:B[1]+i*(B[3]-B[1]),_=e.surface.extent;if(null==_||c(_,s,p)){const t=o(N,G),r=a(N)-f.radius,i=a(G)-f.radius,c=t<te;if(!c){console.warn(`Tile edge vertex position mismatch: between [${e.lij}].edge${y}[${Y}/${R}] and [${x.lij}].edge${P}[${Z}/${F}]`),null!=_&&console.warn(" surface extent= ",_," x,y=",s,",",p);const o=u();n(o,E.localOrigin,$.localOrigin),a(o)>0&&console.warn(` localOrigins: ${E.localOrigin} vs ${$.localOrigin} d=${a(o)} [${o}]`);(()=>{const t=m(N),r=m(G);e.updateEdgeElevations(),x.updateEdgeElevations(),S.getEdgeVertexPosition(y,N,j,Y),V.getEdgeVertexPosition(P,G,w,Z);const i=u();g(i,N,t),a(i)>0&&console.warn(` XXX Tile[${e.lij}] edge out of date: ${t} vs ${N} d=${a(i)} [${i}]`),g(i,G,r),a(i)>0&&console.warn(` XXX Neighbor[${x.lij}] edge out of date: ${r} vs ${G} d=${a(i)} [${i}]`)})();const l=S.getEdgeCount(y),d=V.getEdgeCount(F);v(c,`Mismatch in tile [${e.lij}].edge[${y}][${Y}/${l}] vs neighbor [${x.lij}].edge[${P}][${Z}/${d}] ${D(N)} vs ${D(G)} dist=${t} h(t|n|d)=${r}|${i}|${i-r}`)}S.getEdgeNormal(y,O,Y),V.getEdgeNormal(P,M,Z),l(k,O),l(U,M);const C=d(k,U),T=1-C<.01||!1||e===x;if(!T){const t=u();g(t,O,M);const r=()=>`Mismatch in tile edge normal ${b(e.lij)} (${Y}/${R-1}) edge ${y} vs neighbor ${b(x.lij)} (${Z}/${F-1}) nedge ${P} :${D(O)} vs ${D(M)} dot = ${C} : ${D(t)}`;console.warn("Mismatch in tile edge normal: ",r());{e.updateEdgeElevations(),x.updateEdgeElevations();const t=u(),r=u();S.getEdgeNormal(y,t,Y),V.getEdgeNormal(P,r,Z),h(O,t)||console.warn("Missing update in tile normal: ",D(O)," => ",D(t)),h(M,r)||console.warn("Missing update in neighbor normal: ",D(M)," => ",D(r))}v(T,r())}}Y+=1,Z+=1}})}}const N=u(),G=u(),O=u(),M=u(),k=u(),U=u(),I=1,L=[null,null,null,null];function X(e,t){return t?.loaded||t===e?t:null}const B=1,H=2,W=4,q=8,z=4,J=8,K=12,Q=[0,1,2,3];export{F as PatchRenderData,X as neighborTileIfLoadedOrSelf,Q 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,releaseMaybe as i}from"../../../core/maybe.js";import{j as s,F as o,H as a,d as n,n as l,e as d,a as g,G as h}from"../../../chunks/vec32.js";import{create as u,clone as m}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{containsXY as c}from"../../../geometry/support/aaBoundingRect.js";import{earth as f}from"../../../geometry/support/Ellipsoid.js";import{glLayout as p}from"../support/buffer/glUtil.js";import{GeometryState as y}from"./GeometryState.js";import{PatchGeometry as x}from"./PatchGeometry.js";import{maxTileNeighborLevelDelta as _}from"./TerrainConst.js";import{internalAssert as v,neighborEdgeIndices as $,oppositeEdge as C,neighborCornerIndices as E,enableTerrainInternalChecks as S,v32s as D,lij2s as b}from"./terrainUtils.js";import{TextureFader as j}from"./TextureFader.js";import{TextureReference as R}from"./TextureReference.js";import V from"./TileOverlayData.js";import{fallsWithinLayerView as T}from"./tileUtils.js";import{VertexArrayObject as w}from"../webgl-engine/lib/VertexArrayObject.js";import{BufferObject as A}from"../../webgl/BufferObject.js";import{VertexBuffer as P}from"../../webgl/VertexBuffer.js";class F{constructor(){this.geometry=new x,this.geometryState=null,this._texture=null,this._textureOpacity=1,this._textureRef=new j(()=>this._tile.surface.fadeDuration),this.overlay=new V,this._localOrigin=null,this._geometryStateChangedSinceLastUpdate=!0,this._hasGeometry=!1,this._modifiedFlags=0}get tile(){return this._tile}get localOrigin(){return this._localOrigin}init(e,t){this.clear(),this._tile=e,this.geometry.reset(),this.intersectionData=null,this.geometryState=new y,this._localOrigin=t,this.overlay.clear()}clear(){this.releaseGeometry(),this.releaseTexture(),this._textureRef.clear(),this._tile=null,this.intersectionData=null,this.geometryState=null}updateGeometryIfNeeded(e){if((!this._vao||this._geometryStateChangedSinceLastUpdate||this.wireframeChanged||this.clippingAreaChanged||this.samplerDataChanged||this.numVerticesPerSideChanged||this.dirtyCorners||this.dirtyEdgeResolutions||this.dirtyEdges)&&(this._updateGeometry(e),this._geometryStateChangedSinceLastUpdate=!1),S&&this.tile.intersectsClippingArea)for(let t=0;t<4;++t)v(this.geometry.getEdgeCount(t)===this.geometryState.edgeResolutions[t]+1)}_calculateEdgeResolution(e,t){const r=this.tile,i=this.geometryState.numVerticesPerSide-1;if(!r.surface.isGlobal){const t=r.surface.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=$[e];if(!t)return v(null==r.surface?.rootTiles||r.surface.updatingRootTiles||!r.shouldHaveNeighbor(o)),i;if(t.loaded){const r=t,o=r.renderData.geometryState,a=s-r.level;if(v(a>=0),0===a){const e=o.numVerticesPerSide-1;return Math.max(e,i)}const n=2**a,l=o.edgeResolutions[(e+2)%4]/n;return Math.max(1,l)}v(!t.leaf);let a=i;return t.forAllSubtreeOnSide(C(o),e=>e===r||(e.loaded?(a=Math.max(a,2**(e.level-s)),!0):(v(!e.leaf),!1))),a}updateNeighborData(){const e=this.tile;if(!e.intersectsClippingArea)return;const r=e.renderData.geometryState,i=t=>(t.loaded||t.level===e.level)&&t?.intersectsClippingArea,s=r.edgePeerNeighbors,o=r.edgePeerNeighborSamplerVersions;for(let a=0;a<4;++a){const n=e.findNeighborTile($[a],i),l=X(e,n),d=l?.renderData?.geometryState.samplerDataVersion??-1,g=s[a],h=l!==X(e,g),u=o[a]!==d;S&&n&&(v(e.level>=n.level),v(e.level-n.level<=_)),s[a]=n,(h||u)&&(o[a]=d,this._markEdgeDirty(a));const m=r.edgeResolutions[a],c=this._calculateEdgeResolution(a,n);v(t(c)),v(c>=1),r.edgeResolutions[a]=c,m!==c&&this._markEdgeResolutionDirty(a)}for(let t=0;t<4;++t){const o=e.findNeighborTile(E[t],i);r.cornerPeerNeighbors[t]=o;const a=X(e,s[t]),n=X(e,s[(t+1)%4]),l=X(e,o);L[t]=l,L[(t+1)%4]=n,L[(t+2)%4]=e,L[(t+3)%4]=a,v(L.some(t=>t?.loaded||t===e));const d=L.reduce((e,t)=>Math.min(e,t?.level??1/0),1/0);L.forEach((e,t)=>{e&&e?.level>d&&(L[t]=null)}),v(L.some(t=>t?.loaded||t===e));const g=r.cornerNeighborCornerTiles,h=r.cornerNeighborCornerTileSamplerVersions;for(let e=0;e<4;++e){const r=L[e],i=r?.renderData.geometryState.samplerDataVersion??-1,s=4*t+e,o=g[s]!==r,a=!o&&h[s]!==i;(o||a)&&(g[s]=r,h[s]=i,this._markCornerDirty(t))}S&&v(Q.some(r=>g[4*t+r]?.loaded||g[4*t+r]===e))}S&&v(this.geometryState.edgeResolutions.every(e=>e>0));for(let t=0;t<4;++t)L[t]=null}_updateGeometry(e){if(!this.tile.intersectsClippingArea)return;S&&v(!this.tile.intersectsClippingArea||this.geometryState.edgeResolutions.every(e=>e>0)),this.intersectionData=null;const{tile:t,_vao:r,geometry:i,geometryState:s}=this,o=!r||!{}||this.wireframeChanged||this.samplerDataChanged||this.clippingAreaChanged||this.numVerticesPerSideChanged,a=0!==this.dirtyEdgeResolutions,n=s.edgeResolutions.reduce((e,t)=>e+t+1,0),l=o||a&&n>(i?.maxEdgeVertexCount??0),d=!l&&a,g=!d&&(0!==this.dirtyEdges||a),h=!g&&0!==this.dirtyCorners;l?(this.releaseGeometry(),this._createGeometry(e)):d?t.updateEdgeElevationsAndResolutions():g||h?t.updateEdgeElevations():h?t.updateCornerElevations():console.warn("Update for no reason?"),this._modifiedFlags=0}get hasGeometry(){return this._hasGeometry}releaseGeometry(){return this._hasGeometry=!1,this.intersectionData=null,!!this._vao&&(this._vao=r(this._vao),this.geometry.release(),!0)}ensureTexture(e,t,r,i){const s=t?6408:6407;return null!=this._texture&&(0===r&&this._tile.surface.fadeDuration>0&&this._isTextureVisible(this._texture)||this._texture.descriptor.width!==e||this._texture.descriptor.pixelFormat!==s)&&this.releaseTexture(),null==this._texture&&(this._texture=i(),this.tile.setMemoryDirty()),this._texture}releaseTexture(){this._texture&&(this._texture=i(this._texture),this.tile.setMemoryDirty())}reuseTexture(e,t){return!(!e||!this._texture)&&(e.setTextureReference(new R(this._texture,0,t,this._textureOpacity,0,1)),!0)}get numVerticesPerSideChanged(){return 0!==(this._modifiedFlags&B)}get samplerDataChanged(){return 0!==(this._modifiedFlags&H)}get clippingAreaChanged(){return 0!==(this._modifiedFlags&W)}get wireframeChanged(){return 0!==(this._modifiedFlags&q)}get dirtyEdges(){return this._modifiedFlags>>z&15}get dirtyCorners(){return this._modifiedFlags>>J&15}get dirtyEdgeResolutions(){return this._modifiedFlags>>K&15}_markCornerDirty(e){const t=1<<e<<J;this._modifiedFlags|=t}_markEdgeDirty(e){const t=1<<e<<z;this._modifiedFlags|=t,this._markCornerDirty((e+0)%4),this._markCornerDirty((e+3)%4)}_markEdgeResolutionDirty(e){const t=1<<e<<K;this._modifiedFlags|=t,this._markEdgeDirty(e)}_markAllEdgesAndCornersDirty(){this._modifiedFlags|=15<<J|15<<z|15<<K}updateGeometryState(){const t=this._elevationInfo,r=this.tile,i=t.samplerData?r.getElevationVerticesPerSide(t.maxTileLevel):r.minimumVerticesPerSide,s=Math.max(i,5);let o=r.clippingArea;r.intersectsClippingArea&&!r.withinClippingArea||(o=null);const a=this.geometryState;let n=!1;a.numVerticesPerSide!==s&&(this._modifiedFlags|=1,a.numVerticesPerSide=s,a.samplerDataVersion++,n=!0),t.changed&&(this._modifiedFlags|=2,a.samplerData=t.samplerData,a.samplerDataVersion++,n=!0),e(a.clippingArea,o)||(this._modifiedFlags=4,a.clippingArea=o,n=!0);const l=r.surface.wireframe;return a.wireframe!==l&&(this._modifiedFlags=8,a.wireframe=l,n=!0),this._geometryStateChangedSinceLastUpdate||=n,n&&this._markAllEdgesAndCornersDirty(),this._hasGeometry=!0,this._geometryStateChangedSinceLastUpdate}_createGeometry(e){this.tile.createGeometry();const{vertexAttributes:t,indices:r}=this.geometry,i=e.gl;this._vao=new w(e,new P(e,p(t.layout),t.buffer),A.createIndex(e,i.STATIC_DRAW,r)),this._hasGeometry=!0}get vao(){return this._vao}setTextureReference(e,t=0){e?.texture===this._texture?this._textureOpacity=e.opacities[0]:this.releaseTexture(),this._textureRef.push(e,t)}get textureReference(){return this._textureRef.current}get nextTextureReference(){return this._textureRef.next}get textureFadeFactor(){return this._textureRef.fadeFactor}get textureIsFading(){return this._textureRef.isFading}_isTextureVisible(e){return this._textureRef.current?.texture===e||this._textureRef.next?.texture===e&&this._textureRef.fadeFactor<1}get _elevationInfo(){const e=this.geometryState.samplerData,t=this.tile.layerInfo[0],r=t.length,i=new Array(r);let s=0,o=0,a=!1;for(let d=0;d<r;d++){const r=t[d],n=r.upsampleInfo?.tile;if(n){const t=n.layerInfo[0][d].data,r=t&&t.samplerData;e&&e[s]===r||(a=!0),i[s++]=r,o=Math.max(o,n.lij[0])}else if(r.data){const t=this.tile.surface.layerViewByIndex(d,0);if(T(this.tile,t)){const t=r.data;e&&e[s]===t.samplerData||(a=!0),i[s++]=t.samplerData,o=this.tile.level}}}null!=e&&e.length!==s&&(a=!0);const n=s>0,l=n?i:null;return n&&(i.length=s),{changed:a,samplerData:l,maxTileLevel:o}}get estimatedGeometryMemoryUsage(){const e=this.intersectionData?.estimatedMemoryUsage??0;return(this.geometry.indices?.byteLength??0)+(this.geometry.vertexAttributes?.byteLength??0)+e}get texture(){return this._texture}get test(){}checkGeometryWaterproofness(){if(!S)return;const e=this.tile;if(!e.loaded||!e.intersectsClippingArea||0===e.level)return void v(e?.loaded);const r=e.surface.extent;if(null!=r&&!e.intersectsExtent(r))return;const i=$.map((t,i)=>null!=r&&(i<2?-1:1)*(e.extent[3-i]-r[3-i])<0),p=e.level;v(0===this.dirtyCorners),v(0===this.dirtyEdges),v(0===this.dirtyEdgeResolutions),v(!this.numVerticesPerSideChanged),v(!this.samplerDataChanged),v(!this.clippingAreaChanged),v(!this.wireframeChanged);const y=E.map(t=>e.findNeighborCornerTileExact(t,t=>!t.intersectsClippingArea||t.loaded||t.level===e.level)??null).map(e=>e?.intersectsClippingArea?e:null),x=this.geometryState;for(let t=0;t<4;++t){const r=x.cornerPeerNeighbors[t],i=y[t];v(i===r,`Tile[${e.lij}].corner[${t}] out of date: cur=[${r?.lij}] exp=[${i?.lij}]`)}$.forEach((r,y)=>{if(i[y])return;const x=e.findNeighborTile(r,e=>(e.level===p||e?.loaded)&&e?.intersectsClippingArea);if(!x){const t=!e.surface.updatingRootTiles&&null!=e.surface.rootTiles&&e.surface.rootTiles.length>0&&e.shouldHaveNeighbor(r);return void v(!t)}v(x.loaded||x.level===e.level),v(x===this.geometryState.edgePeerNeighbors[y]);const _=p-x.level;if(!x.loaded)return v(!x.leaf),void v(0===_);const $=x.renderData;v(e.isEdgeNeighbor(x,r)),v(_>=0);const C=2**_;if(_<0)return void v(!1);const E=e.renderData,S=E.geometry,j=E.localOrigin,R=S.getEdgeCount(y),V=S.numVerticesPerSide-1,T=$.geometry;if(!T)return void v(!1);const w=$.localOrigin,A=this.geometryState.edgePeerNeighbors[y];if(A?.loaded){const e=A.renderData;v(E.geometryState.edgePeerNeighborSamplerVersions[y]===e.geometryState.samplerDataVersion),v(this.geometryState.edgePeerNeighborSamplerVersions[y]===e.geometryState.samplerDataVersion)}const P=(y+2)%4,F=T.getEdgeCount(P),L=R-1,X=F-1;v(L*C===X,`Tile[${e.lij}]:e${y},res=${L} edgeRes mismatch with Neighbor[${x.lij}]:e${P},res=${X} (expected:${L*C})`);const B=e.extent,H=0===r||4===r,W=F-1,q=W>>_,z=R-1;if(q<1)return void v(1===z);v(q===z),v(t(q));const J=T.numVerticesPerSide-1;v(_>0||q===Math.max(J,V));const K=e.getNeighborEdgeStartVertexIndex(y,x);v(0<=K&&K<C);const Q=K*q;v(0<=Q&&Q<=W-q);let Y=0,Z=Q;S.getEdgeVertexPosition(y,N,j,0),S.getEdgeVertexPosition(y,G,j,R-1);const ee=s(N,G),te=Math.max(I,1e-4*ee);for(let t=0;t<=q;++t){S.getEdgeVertexPosition(y,N,j,Y),T.getEdgeVertexPosition(P,G,w,Z);const i=t/q,s=H?B[0]+i*(B[2]-B[0]):6===r?B[0]:B[2],p=H?4===r?B[1]:B[3]:B[1]+i*(B[3]-B[1]),_=e.surface.extent;if(null==_||c(_,s,p)){const t=o(N,G),r=a(N)-f.radius,i=a(G)-f.radius,c=t<te;if(!c){console.warn(`Tile edge vertex position mismatch: between [${e.lij}].edge${y}[${Y}/${R}] and [${x.lij}].edge${P}[${Z}/${F}]`),null!=_&&console.warn(" surface extent= ",_," x,y=",s,",",p);const o=u();n(o,E.localOrigin,$.localOrigin),a(o)>0&&console.warn(` localOrigins: ${E.localOrigin} vs ${$.localOrigin} d=${a(o)} [${o}]`);(()=>{const t=m(N),r=m(G);e.updateEdgeElevations(),x.updateEdgeElevations(),S.getEdgeVertexPosition(y,N,j,Y),T.getEdgeVertexPosition(P,G,w,Z);const i=u();g(i,N,t),a(i)>0&&console.warn(` XXX Tile[${e.lij}] edge out of date: ${t} vs ${N} d=${a(i)} [${i}]`),g(i,G,r),a(i)>0&&console.warn(` XXX Neighbor[${x.lij}] edge out of date: ${r} vs ${G} d=${a(i)} [${i}]`)})();const l=S.getEdgeCount(y),d=T.getEdgeCount(F);v(c,`Mismatch in tile [${e.lij}].edge[${y}][${Y}/${l}] vs neighbor [${x.lij}].edge[${P}][${Z}/${d}] ${D(N)} vs ${D(G)} dist=${t} h(t|n|d)=${r}|${i}|${i-r}`)}S.getEdgeNormal(y,O,Y),T.getEdgeNormal(P,M,Z),l(k,O),l(U,M);const C=d(k,U),V=1-C<.01||!1||e===x;if(!V){const t=u();g(t,O,M);const r=()=>`Mismatch in tile edge normal ${b(e.lij)} (${Y}/${R-1}) edge ${y} vs neighbor ${b(x.lij)} (${Z}/${F-1}) nedge ${P} :${D(O)} vs ${D(M)} dot = ${C} : ${D(t)}`;console.warn("Mismatch in tile edge normal: ",r());{e.updateEdgeElevations(),x.updateEdgeElevations();const t=u(),r=u();S.getEdgeNormal(y,t,Y),T.getEdgeNormal(P,r,Z),h(O,t)||console.warn("Missing update in tile normal: ",D(O)," => ",D(t)),h(M,r)||console.warn("Missing update in neighbor normal: ",D(M)," => ",D(r))}v(V,r())}}Y+=1,Z+=1}})}}const N=u(),G=u(),O=u(),M=u(),k=u(),U=u(),I=1,L=[null,null,null,null];function X(e,t){return t?.loaded||t===e?t:null}const B=1,H=2,W=4,q=8,z=4,J=8,K=12,Q=[0,1,2,3];export{F as PatchRenderData,X as neighborTileIfLoadedOrSelf,Q 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.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../../../../core/Logger.js";import{getOrCreateMapValue as t}from"../../../../../core/MapUtils.js";import i from"../../../../../core/PooledArray.js";import{isTypedArray as o}from"../../../../../core/typedArrayUtil.js";import{s as n}from"../../../../../chunks/vec32.js";import{clone as r}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as s}from"../../../../../geometry/support/aaBoundingBox.js";import{compactIndices as a}from"../../../../../geometry/support/Indices.js";import{c as l}from"../../../../../chunks/vec3.js";import{c}from"../../../../../chunks/vec33.js";import{encodeSymbolColor as m}from"../../../layers/support/symbolColorUtils.js";import{computeOffsetObb as h}from"../../../support/orientedBoundingBox.js";import{glLayout as f}from"../../../support/buffer/glUtil.js";import{ComponentData as p}from"./ComponentData.js";import{ComponentObject as g}from"./ComponentObject.js";import{IntersectionGeometry as d}from"./IntersectionGeometry.js";import{Renderable as u}from"./Renderable.js";import{RenderGeometry as b}from"./RenderGeometry.js";import{RenderSubmitSystem as v}from"./RenderSubmitSystem.js";import{createVertexBufferLayout as y}from"./SourceGeometry.js";import{UniformComponentParameters as _}from"./UniformComponentParameters.js";import{ComponentParametersVarying as M,ComponentParametersUniform as C,ComponentMaterial as j}from"./Material/ComponentMaterial.js";import{componentIndexGlLayout as w}from"./Material/ComponentTechnique.js";import{encodeElevationOffset as x}from"./Material/shader/ComponentData.glsl.js";import{olidEnabled as O}from"../../effects/geometry/olidUtils.js";import{getVisibility as D,updatePickabilityWithCount as R}from"../../lib/ComponentUtils.js";import{assert as A}from"../../lib/Util.js";import{VertexArrayObject as B}from"../../lib/VertexArrayObject.js";import{getVerticalOffsetI3S as E}from"../../lib/verticalOffsetUtils.js";import{BufferManager as H}from"../../lib/TextureBackedBuffer/BufferManager.js";import{BufferObject as S}from"../../../../webgl/BufferObject.js";import{PrimitiveType as U}from"../../../../webgl/enums.js";import{VertexBuffer as V}from"../../../../webgl/VertexBuffer.js";const P=()=>e.getLogger("esri.views.3d.webgl-engine.collections.Component.ComponentObjectCollection");class I{constructor(e,t){this._renderManager=e,this._viewingMode=t,this._elevationRangeCacheVerticalOffset=NaN,this._elevationRangeCacheMin=NaN,this._elevationRangeCacheMax=NaN,this._activeHighlightOptions=new Map,this._visible=new i,this._hidden=new i,this._renderSubmit=new v(this),this._renderManager.register(this._renderSubmit),this._componentBufferManager=new H(e.rctx,2+(O()?1:0))}destroy(){A(0===this._hidden.length&&0===this._visible.length,"ObjectCollection should be empty upon disposal"),this._componentBufferManager.destroy(),this._componentBufferManager=null,this._visible.forAll(e=>e.destroy()),this._visible.prune(),this._hidden.forAll(e=>e.destroy()),this._hidden.prune(),this._renderSubmit.destroy()}createObject(e){const t=e.geometry,i=new p(this._componentBufferManager,a(t.componentOffsets)),o=this._createRenderable(e,i),n=new d(this._viewingMode,t.positionData,i),r=new g(e.transform,e.toMapSpace,e.obb.clone(),i,o,n);return(r.visible?this._visible:this._hidden).push(r),r}destroyObject(e){const t=e;(t.visible?this._visible:this._hidden).removeUnordered(t),t.destroy(),this._notifyDirty()}setObjectVisibility(e,t){const i=e;t!==i.visible&&(t?(this._hidden.removeUnordered(i),this._visible.push(i)):(this._visible.removeUnordered(i),this._hidden.push(i)),i.visible=t,this._notifyDirty())}preSubmit(e){const t=e.camera.eye;this.visibleObjects.forAll(e=>e.renderable.meta.cameraDepthSquared=n(t,e.obb.center))}getMaterial(e){return e.renderable.material}updateMaterial(e,t){const i=e.renderable.material;t(i),i.dirty&&this._notifyDirty()}setAllComponentVisibilities(e,t){const i=e;i.componentData.visibility.reset(t),i.componentData.markVisibilityDirty(),this._notifyDirty()}forEachVisibleComponent(e,t){return e.componentData.visibility.forEachComponent(t)}getComponentCount(e){const t=e,i=t.componentData.visibility.componentCount;return{visible:i,invisible:t.componentData.count-i}}setComponentData(e,t){const i=e,{renderable:o,componentData:n}=i,r=o.material,s=n.materialDataBuffer,a=n.materialDataIndices,l=new _,c=s.textureBuffer,f=new Uint8Array(4),p=new Uint32Array(f.buffer);let g=0,d=0,u=0,b=n.verticalOffsets,v=1/0,y=-1/0,j=!1,w=!1,A=0;for(let h=0;h<n.count;h++){t(h,l),g+=+(l.externalColor[3]<1),d+=+(3===l.externalColorMixMode&&1===l.externalColor[3]),u+=+l.castShadows,m(l.externalColor,l.externalColorMixMode,f),f[2]=254&f[2]|+l.castShadows,c.setData(a[h],0,f[0],f[1],f[2],f[3]),j||=h>0&&A!==p[0],A=p[0],w||=0!==l.elevationOffset,w&&null==b&&(b=new Array(h).fill(0)),null!=b&&(b[h]=l.elevationOffset),v=Math.min(v,l.elevationOffset),y=Math.max(y,l.elevationOffset),x(l.elevationOffset,f),c.setData(a[h],1,f[0],f[1],f[2],f[3]);const e=l.olidColor;null!=e&&c.setData(a[h],2,e[0],e[1],e[2],e[3]),l.pickable!==D(n.pickability,h)&&R(n,h,l.pickable)}n.verticalOffsets=w?b:null,i.offsetObb=w?h(i.obb,v,y,this._viewingMode,i.offsetObb??i.obb.clone()):null,j||w||O()?(r.componentParameters=new M,r.componentParameters.castShadows=N(u,n.count),r.componentParameters.transparent=N(g,n.count),r.componentParameters.opaqueOverride=N(d,n.count),r.componentParameters.texture=c,c.updateTexture()):(r.componentParameters=new C,r.componentParameters.castShadows=l.castShadows?0:2,r.componentParameters.externalColor=l.externalColor,r.componentParameters.externalColorMixMode=l.externalColorMixMode),this._elevationRangeCacheVerticalOffset=NaN,this._notifyDirty()}getComponentAabb(e,t,i,o=!1){e.intersectionGeometry.getComponentAabb(t,i);const n=e,r=n.componentData.verticalOffsets;if(o||null==r)return i;const s=r[t];if(2===this._viewingMode||0===s)return i[2]+=s,i[5]+=s,i;const a=E(s);return a.localOrigin=n.transform.position,a.applyToAabb(i)}getComponentObb(e){return e.obb}getObjectTransform(e){return e.transform}getComponentPositions(e,t,i){return e.intersectionGeometry.getComponentPositions(t,i)}expandRangeWithComponentObjectElevationRange(e,t,i,o){Number.isNaN(this._elevationRangeCacheVerticalOffset)||this._elevationRangeCacheVerticalOffset!==t||o.expandElevationRangeValues(this._elevationRangeCacheMin,this._elevationRangeCacheMax);const n=e,r=n.componentData,s=r.count,a=r.verticalOffsets,l=n.intersectionGeometry,c=2===this._viewingMode,m=l.getComponentAabbs(),h=k;let f=1/0,p=-1/0;for(let g=0;g<s;g++){const e=6*g,r=a?.[g]??0;let s=1/0,l=-1/0;if(c)s=m[e+2]+r+t,l=m[e+5]+r+t;else{if(h[0]=m[e],h[1]=m[e+1],h[2]=m[e+2],h[3]=m[e+3],h[4]=m[e+4],h[5]=m[e+5],0!==r){const e=E(r);e.localOrigin=n.transform.position,e.applyToAabb(h)}const s=Math.max(Math.abs(h[3]),Math.abs(h[0])),a=Math.max(Math.abs(h[4]),Math.abs(h[1])),l=t+h[5]+i;o.expandElevationRangeValues(t+h[2],Math.sqrt(s*s+a*a+l*l)-i)}o.expandElevationRangeValues(s,l),f=Math.min(f,s),p=Math.max(p,l)}this._elevationRangeCacheVerticalOffset=t,this._elevationRangeCacheMin=f,this._elevationRangeCacheMax=p}intersect(e,t,i,o,n,r,s){const a=e,{transform:l,componentData:c,intersectionGeometry:m}=a;return null!=n&&(n.localOrigin=l.position),m.intersect(t,i,o,n,c.verticalOffsets,l,r,s)}addEdges(e,t,i,o,n){const r=e,{indices:s,positions:a}=r.intersectionGeometry,l=r.componentData.offsets;return t.addComponentObject(r,a,s,l,i,o,n)}async extractEdgeInformation(e,t,i){const o=e,n=o.componentData.visibility;if(n.allInvisible()){const{extractComponentsEdgeLocationsLayout:e}=await import("../../lib/edgeRendering/edgeProcessing.js");return{buffer:e.createBuffer(0),origin:[0,0,0]}}const{indices:s,positions:a}=o.intersectionGeometry,m=o.componentData.offsets,{EdgeInputBufferLayout:h}=await import("../../lib/edgeRendering/bufferLayouts.js"),f=h.createBuffer(a.length/3);c(f.position.typedBuffer,a,f.position.typedBufferStride,3),l(f.position,f.position,o.transform.rotationScale),this._setComponentIndices(f.componentIndex,s,m);const p=f.count,g=this._computeVisibilityIndices(s,n,m,p);return{origin:r(o.transform.position),buffer:await t.extractComponentsEdgeLocations({indices:g,indicesLength:g.length,skipDeduplicate:!0,data:f,writerSettings:{reducedPrecision:!1,variants:0}},i)}}_setComponentIndices(e,t,i){let o=0;for(let n=0;n<i.length-1;n++){const r=i[n],s=i[n+1];for(let i=r;i<s;i++){const n=t?t[i]:i;e.set(n,o)}o++}}_computeVisibilityIndices(e,t,i,n){if(e&&t.allVisible())return e;let r=0;t.forEachComponentRange((e,t)=>(r+=i[t]-i[e],!0));const s=o(e)?2===e?.BYTES_PER_ELEMENT||n<=65536?new Uint16Array(r):new Uint32Array(r):new Array(r);let a=0;return t.forEachComponentRange((t,o)=>{const n=i[t],r=i[o];for(let i=n;i<r;i++)s[a++]=e?e[i]:i;return!0}),s}addComponentHighlight(e,i,o){const n=e.componentData,r=t(n.componentHighlights,o,()=>new Uint32Array(n.count+1));{const e=this._activeHighlightOptions.get(o)??0;this._activeHighlightOptions.set(o,e+1)}0===r[i]++&&(n.markHighlightsDirty(),this._notifyDirty()),r[n.count]++}removeComponentHighlight(e,t,i){const{componentData:o}=e,n=o.componentHighlights.get(i);if(void 0===n)return void P().warn("Removing non-existing highlight.");const r=n[t];if(0===r)return void P().warn("Removing non-existing highlight.");this._removeActiveHighlight(i);const s=n[o.count];if(r>1)return n[t]=r-1,void(n[o.count]=s-1);n[t]=0,1===s?o.componentHighlights.delete(i):n[o.count]=s-1,o.markHighlightsDirty(),this._notifyDirty()}_removeActiveHighlight(e,t=1){const i=this._activeHighlightOptions.get(e);if(void 0===i)P().warn("Removing non-existing highlight.");else{const o=i-t;o<0&&P().warn("Removing non-existing highlight."),o<=0?this._activeHighlightOptions.delete(e):this._activeHighlightOptions.set(e,o)}}clearHighlights(e){const{componentData:t}=e,{componentHighlights:i}=t;if(i.size>0){for(const e of i)this._removeActiveHighlight(e[0],e[1][t.count]);i.clear(),t.markHighlightsDirty(),this._notifyDirty()}}hasHighlight(e){return this._activeHighlightOptions.has(e)}getObjectGPUMemoryUsage(e){return e.renderable.meta.gpuMemoryEstimate}get visibleObjects(){return this._visible}_createRenderable(e,t){const i=this._renderManager.rctx,o=e.geometry,n=o.vertices.layoutParameters,r=S.createVertex(i,35044,o.vertices.data),s=o.indices?S.createIndex(i,35044,o.indices):null,a=f(y(n)),l=new Uint16Array(o.vertices.count);for(let f=0;f<t.count;f++){const e=t.offsets[f],i=t.offsets[f+1],n=t.materialDataIndices[f];if(null!=o.indices)for(let t=e;t<i;t++){l[o.indices[t]]=n}else for(let t=e;t<i;t++)l[t]=n}const c=S.createVertex(i,35044,l.buffer),m=new j(e.transform,e.toMapSpace),h=new B(i,new Map([["geometry",new V(a,r)],["componentIndices",new V(w,c)]]),s),p=new b(h,U.TRIANGLES,n,null!=s),g={cameraDepthSquared:.5,gpuMemoryEstimate:r.usedMemory+c.usedMemory+(null!=s?s.usedMemory:0)};return new u(m,p,g)}_notifyDirty(){this._renderManager.notifyDirty()}}function N(e,t){return e===t?0:0===e?2:1}const k=s();export{I as ComponentObjectCollection};
|
|
5
|
+
import e from"../../../../../core/Logger.js";import{getOrCreateMapValue as t}from"../../../../../core/MapUtils.js";import i from"../../../../../core/PooledArray.js";import{isTypedArray as o}from"../../../../../core/typedArrayUtil.js";import{s as n}from"../../../../../chunks/vec32.js";import{clone as r}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as s}from"../../../../../geometry/support/aaBoundingBox.js";import{compactIndices as a}from"../../../../../geometry/support/Indices.js";import{c as l}from"../../../../../chunks/vec3.js";import{c}from"../../../../../chunks/vec33.js";import{encodeSymbolColor as m}from"../../../layers/support/symbolColorUtils.js";import{computeOffsetObb as h}from"../../../support/orientedBoundingBox.js";import{glLayout as f}from"../../../support/buffer/glUtil.js";import{ComponentData as p}from"./ComponentData.js";import{ComponentObject as g}from"./ComponentObject.js";import{IntersectionGeometry as d}from"./IntersectionGeometry.js";import{Renderable as u}from"./Renderable.js";import{RenderGeometry as b}from"./RenderGeometry.js";import{RenderSubmitSystem as v}from"./RenderSubmitSystem.js";import{createVertexBufferLayout as y}from"./SourceGeometry.js";import{UniformComponentParameters as _}from"./UniformComponentParameters.js";import{ComponentParametersVarying as M,ComponentParametersUniform as C,ComponentMaterial as j}from"./Material/ComponentMaterial.js";import{indexGlLayout as w}from"./Material/ComponentTechnique.js";import{encodeElevationOffset as x}from"./Material/shader/ComponentData.glsl.js";import{olidEnabled as O}from"../../effects/geometry/olidUtils.js";import{getVisibility as D,updatePickabilityWithCount as R}from"../../lib/ComponentUtils.js";import{assert as A}from"../../lib/Util.js";import{VertexArrayObject as B}from"../../lib/VertexArrayObject.js";import{getVerticalOffsetI3S as E}from"../../lib/verticalOffsetUtils.js";import{BufferManager as H}from"../../lib/TextureBackedBuffer/BufferManager.js";import{BufferObject as S}from"../../../../webgl/BufferObject.js";import{PrimitiveType as U}from"../../../../webgl/enums.js";import{VertexBuffer as P}from"../../../../webgl/VertexBuffer.js";const V=()=>e.getLogger("esri.views.3d.webgl-engine.collections.Component.ComponentObjectCollection");class I{constructor(e,t){this._renderManager=e,this._viewingMode=t,this._elevationRangeCacheVerticalOffset=NaN,this._elevationRangeCacheMin=NaN,this._elevationRangeCacheMax=NaN,this._activeHighlightOptions=new Map,this._visible=new i,this._hidden=new i,this._renderSubmit=new v(this),this._renderManager.register(this._renderSubmit),this._componentBufferManager=new H(e.rctx,2+(O()?1:0))}destroy(){A(0===this._hidden.length&&0===this._visible.length,"ObjectCollection should be empty upon disposal"),this._componentBufferManager.destroy(),this._componentBufferManager=null,this._visible.forAll(e=>e.destroy()),this._visible.prune(),this._hidden.forAll(e=>e.destroy()),this._hidden.prune(),this._renderSubmit.destroy()}createObject(e){const t=e.geometry,i=new p(this._componentBufferManager,a(t.componentOffsets)),o=this._createRenderable(e,i),n=new d(this._viewingMode,t.positionData,i),r=new g(e.transform,e.toMapSpace,e.obb.clone(),i,o,n);return(r.visible?this._visible:this._hidden).push(r),r}destroyObject(e){const t=e;(t.visible?this._visible:this._hidden).removeUnordered(t),t.destroy(),this._notifyDirty()}setObjectVisibility(e,t){const i=e;t!==i.visible&&(t?(this._hidden.removeUnordered(i),this._visible.push(i)):(this._visible.removeUnordered(i),this._hidden.push(i)),i.visible=t,this._notifyDirty())}preSubmit(e){const t=e.camera.eye;this.visibleObjects.forAll(e=>e.renderable.meta.cameraDepthSquared=n(t,e.obb.center))}getMaterial(e){return e.renderable.material}updateMaterial(e,t){const i=e.renderable.material;t(i),i.dirty&&this._notifyDirty()}setAllComponentVisibilities(e,t){const i=e;i.componentData.visibility.reset(t),i.componentData.markVisibilityDirty(),this._notifyDirty()}forEachVisibleComponent(e,t){return e.componentData.visibility.forEachComponent(t)}getComponentCount(e){const t=e,i=t.componentData.visibility.componentCount;return{visible:i,invisible:t.componentData.count-i}}setComponentData(e,t){const i=e,{renderable:o,componentData:n}=i,r=o.material,s=n.materialDataBuffer,a=n.materialDataIndices,l=new _,c=s.textureBuffer,f=new Uint8Array(4),p=new Uint32Array(f.buffer);let g=0,d=0,u=0,b=n.verticalOffsets,v=1/0,y=-1/0,j=!1,w=!1,A=0;for(let h=0;h<n.count;h++){t(h,l),g+=+(l.externalColor[3]<1),d+=+(3===l.externalColorMixMode&&1===l.externalColor[3]),u+=+l.castShadows,m(l.externalColor,l.externalColorMixMode,f),f[2]=254&f[2]|+l.castShadows,c.setData(a[h],0,f[0],f[1],f[2],f[3]),j||=h>0&&A!==p[0],A=p[0],w||=0!==l.elevationOffset,w&&null==b&&(b=new Array(h).fill(0)),null!=b&&(b[h]=l.elevationOffset),v=Math.min(v,l.elevationOffset),y=Math.max(y,l.elevationOffset),x(l.elevationOffset,f),c.setData(a[h],1,f[0],f[1],f[2],f[3]);const e=l.olidColor;null!=e&&c.setData(a[h],2,e[0],e[1],e[2],e[3]),l.pickable!==D(n.pickability,h)&&R(n,h,l.pickable)}n.verticalOffsets=w?b:null,i.offsetObb=w?h(i.obb,v,y,this._viewingMode,i.offsetObb??i.obb.clone()):null,j||w||O()?(r.componentParameters=new M,r.componentParameters.castShadows=N(u,n.count),r.componentParameters.transparent=N(g,n.count),r.componentParameters.opaqueOverride=N(d,n.count),r.componentParameters.texture=c,c.updateTexture()):(r.componentParameters=new C,r.componentParameters.castShadows=l.castShadows?0:2,r.componentParameters.externalColor=l.externalColor,r.componentParameters.externalColorMixMode=l.externalColorMixMode),this._elevationRangeCacheVerticalOffset=NaN,this._notifyDirty()}getComponentAabb(e,t,i,o=!1){e.intersectionGeometry.getComponentAabb(t,i);const n=e,r=n.componentData.verticalOffsets;if(o||null==r)return i;const s=r[t];if(2===this._viewingMode||0===s)return i[2]+=s,i[5]+=s,i;const a=E(s);return a.localOrigin=n.transform.position,a.applyToAabb(i)}getComponentObb(e){return e.obb}getObjectTransform(e){return e.transform}getComponentPositions(e,t,i){return e.intersectionGeometry.getComponentPositions(t,i)}expandRangeWithComponentObjectElevationRange(e,t,i,o){Number.isNaN(this._elevationRangeCacheVerticalOffset)||this._elevationRangeCacheVerticalOffset!==t||o.expandElevationRangeValues(this._elevationRangeCacheMin,this._elevationRangeCacheMax);const n=e,r=n.componentData,s=r.count,a=r.verticalOffsets,l=n.intersectionGeometry,c=2===this._viewingMode,m=l.getComponentAabbs(),h=k;let f=1/0,p=-1/0;for(let g=0;g<s;g++){const e=6*g,r=a?.[g]??0;let s=1/0,l=-1/0;if(c)s=m[e+2]+r+t,l=m[e+5]+r+t;else{if(h[0]=m[e],h[1]=m[e+1],h[2]=m[e+2],h[3]=m[e+3],h[4]=m[e+4],h[5]=m[e+5],0!==r){const e=E(r);e.localOrigin=n.transform.position,e.applyToAabb(h)}const s=Math.max(Math.abs(h[3]),Math.abs(h[0])),a=Math.max(Math.abs(h[4]),Math.abs(h[1])),l=t+h[5]+i;o.expandElevationRangeValues(t+h[2],Math.sqrt(s*s+a*a+l*l)-i)}o.expandElevationRangeValues(s,l),f=Math.min(f,s),p=Math.max(p,l)}this._elevationRangeCacheVerticalOffset=t,this._elevationRangeCacheMin=f,this._elevationRangeCacheMax=p}intersect(e,t,i,o,n,r,s){const a=e,{transform:l,componentData:c,intersectionGeometry:m}=a;return null!=n&&(n.localOrigin=l.position),m.intersect(t,i,o,n,c.verticalOffsets,l,r,s)}addEdges(e,t,i,o,n){const r=e,{indices:s,positions:a}=r.intersectionGeometry,l=r.componentData.offsets;return t.addComponentObject(r,a,s,l,i,o,n)}async extractEdgeInformation(e,t,i){const o=e,n=o.componentData.visibility;if(n.allInvisible()){const{extractComponentsEdgeLocationsLayout:e}=await import("../../lib/edgeRendering/edgeProcessing.js");return{buffer:e.createBuffer(0),origin:[0,0,0]}}const{indices:s,positions:a}=o.intersectionGeometry,m=o.componentData.offsets,{EdgeInputBufferLayout:h}=await import("../../lib/edgeRendering/bufferLayouts.js"),f=h.createBuffer(a.length/3);c(f.position.typedBuffer,a,f.position.typedBufferStride,3),l(f.position,f.position,o.transform.rotationScale),this._setComponentIndices(f.componentIndex,s,m);const p=f.count,g=this._computeVisibilityIndices(s,n,m,p);return{origin:r(o.transform.position),buffer:await t.extractComponentsEdgeLocations({indices:g,indicesLength:g.length,skipDeduplicate:!0,data:f,writerSettings:{reducedPrecision:!1,variants:0}},i)}}_setComponentIndices(e,t,i){let o=0;for(let n=0;n<i.length-1;n++){const r=i[n],s=i[n+1];for(let i=r;i<s;i++){const n=t?t[i]:i;e.set(n,o)}o++}}_computeVisibilityIndices(e,t,i,n){if(e&&t.allVisible())return e;let r=0;t.forEachComponentRange((e,t)=>(r+=i[t]-i[e],!0));const s=o(e)?2===e?.BYTES_PER_ELEMENT||n<=65536?new Uint16Array(r):new Uint32Array(r):new Array(r);let a=0;return t.forEachComponentRange((t,o)=>{const n=i[t],r=i[o];for(let i=n;i<r;i++)s[a++]=e?e[i]:i;return!0}),s}addComponentHighlight(e,i,o){const n=e.componentData,r=t(n.componentHighlights,o,()=>new Uint32Array(n.count+1));{const e=this._activeHighlightOptions.get(o)??0;this._activeHighlightOptions.set(o,e+1)}0===r[i]++&&(n.markHighlightsDirty(),this._notifyDirty()),r[n.count]++}removeComponentHighlight(e,t,i){const{componentData:o}=e,n=o.componentHighlights.get(i);if(void 0===n)return void V().warn("Removing non-existing highlight.");const r=n[t];if(0===r)return void V().warn("Removing non-existing highlight.");this._removeActiveHighlight(i);const s=n[o.count];if(r>1)return n[t]=r-1,void(n[o.count]=s-1);n[t]=0,1===s?o.componentHighlights.delete(i):n[o.count]=s-1,o.markHighlightsDirty(),this._notifyDirty()}_removeActiveHighlight(e,t=1){const i=this._activeHighlightOptions.get(e);if(void 0===i)V().warn("Removing non-existing highlight.");else{const o=i-t;o<0&&V().warn("Removing non-existing highlight."),o<=0?this._activeHighlightOptions.delete(e):this._activeHighlightOptions.set(e,o)}}clearHighlights(e){const{componentData:t}=e,{componentHighlights:i}=t;if(i.size>0){for(const e of i)this._removeActiveHighlight(e[0],e[1][t.count]);i.clear(),t.markHighlightsDirty(),this._notifyDirty()}}hasHighlight(e){return this._activeHighlightOptions.has(e)}getObjectGPUMemoryUsage(e){return e.renderable.meta.gpuMemoryEstimate}get visibleObjects(){return this._visible}_createRenderable(e,t){const i=this._renderManager.rctx,o=e.geometry,n=o.vertices.layoutParameters,r=f(y(n)),s=new P(i,r,o.vertices.data),a=o.indices?S.createIndex(i,35044,o.indices):null,l=new Uint16Array(o.vertices.count);for(let f=0;f<t.count;f++){const e=t.offsets[f],i=t.offsets[f+1],n=t.materialDataIndices[f];if(null!=o.indices)for(let t=e;t<i;t++){l[o.indices[t]]=n}else for(let t=e;t<i;t++)l[t]=n}const c=new P(i,w,l.buffer),m=new j(e.transform,e.toMapSpace),h=new B(i,new Map([["geometry",s],["componentIndices",c]]),a),p=new b(h,U.TRIANGLES,n,null!=a),g={cameraDepthSquared:.5,gpuMemoryEstimate:s.usedMemory+c.usedMemory+(null!=a?a.usedMemory:0)};return new u(m,p,g)}_notifyDirty(){this._renderManager.notifyDirty()}}function N(e,t){return e===t?0:0===e?2:1}const k=s();export{I as ComponentObjectCollection};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{glLayout as e}from"../../../../support/buffer/glUtil.js";import{newLayout as r}from"../../../../support/buffer/InterleavedLayout.js";import{createVertexBufferLayout as t}from"../SourceGeometry.js";import{C as o}from"../../../../../../chunks/ComponentShader.glsl.js";import{isColorOrColorEmission as n}from"../../../core/shaderLibrary/ShaderOutput.js";import{ReloadableShaderModule as s}from"../../../core/shaderTechnique/ReloadableShaderModule.js";import{ShaderTechnique as l,depthOnlyOutputBuffersOr as i}from"../../../core/shaderTechnique/ShaderTechnique.js";import{OITPolygonOffset as u,oitDepthTest as d,blending as a,getDrawBuffers as c}from"../../../lib/OrderIndependentTransparency.js";import{replaceBitWhenDepthTestPasses as p,stencilBaseAllZerosParams as m,stencilWriteMaskOn as f}from"../../../lib/StencilUtils.js";import{makePipelineState as h,defaultColorWrite as b,defaultDepthWrite as j,cullingParams as g,premultipliedAlpha as S}from"../../../../../webgl/renderState.js";import{fromLayouts as y}from"../../../../../webgl/VertexAttributeLocations.js";class O extends l{constructor(r,n){super(r,n,new s(o,()=>import("./shader/ComponentShader.glsl.js")),y([e(t(n)),T]))}initializePipeline(e){const{integratedMeshMode:r,output:t,blendingEnabled:o,cullFace:s,hasOccludees:l,hasPolygonOffset:y,oitPass:O,renderOccluded:T}=e,w=0!==r,x=0===O,q=2===O;return h({blending:T?S:n(t)&&o?a(O):null,culling:g(s),depthTest:T?null:{func:d(O)},depthWrite:T||!x&&!q?null:j,drawBuffers:i(t,c(O,t)),colorWrite:b,stencilWrite:!T&&w||l?f:null,stencilTest:w?p(1):l?m:null,polygonOffset:x||q?y?{factor:2,units:2}:null:u})}}const T=e(r().u16("componentIndex"));export{O as ComponentTechnique,T as
|
|
5
|
+
import{glLayout as e}from"../../../../support/buffer/glUtil.js";import{newLayout as r}from"../../../../support/buffer/InterleavedLayout.js";import{createVertexBufferLayout as t}from"../SourceGeometry.js";import{C as o}from"../../../../../../chunks/ComponentShader.glsl.js";import{isColorOrColorEmission as n}from"../../../core/shaderLibrary/ShaderOutput.js";import{ReloadableShaderModule as s}from"../../../core/shaderTechnique/ReloadableShaderModule.js";import{ShaderTechnique as l,depthOnlyOutputBuffersOr as i}from"../../../core/shaderTechnique/ShaderTechnique.js";import{OITPolygonOffset as u,oitDepthTest as d,blending as a,getDrawBuffers as c}from"../../../lib/OrderIndependentTransparency.js";import{replaceBitWhenDepthTestPasses as p,stencilBaseAllZerosParams as m,stencilWriteMaskOn as f}from"../../../lib/StencilUtils.js";import{makePipelineState as h,defaultColorWrite as b,defaultDepthWrite as j,cullingParams as g,premultipliedAlpha as S}from"../../../../../webgl/renderState.js";import{fromLayouts as y}from"../../../../../webgl/VertexAttributeLocations.js";class O extends l{constructor(r,n){super(r,n,new s(o,()=>import("./shader/ComponentShader.glsl.js")),y([e(t(n)),T]))}initializePipeline(e){const{integratedMeshMode:r,output:t,blendingEnabled:o,cullFace:s,hasOccludees:l,hasPolygonOffset:y,oitPass:O,renderOccluded:T}=e,w=0!==r,x=0===O,q=2===O;return h({blending:T?S:n(t)&&o?a(O):null,culling:g(s),depthTest:T?null:{func:d(O)},depthWrite:T||!x&&!q?null:j,drawBuffers:i(t,c(O,t)),colorWrite:b,stencilWrite:!T&&w||l?f:null,stencilTest:w?p(1):l?m:null,polygonOffset:x||q?y?{factor:2,units:2}:null:u})}}const T=e(r().u16("componentIndex"));export{O as ComponentTechnique,T as indexGlLayout};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import"../../../../core/has.js";import{disposeMaybe as r}from"../../../../core/maybe.js";import{Pos2 as t}from"../lib/DefaultVertexBufferLayouts.js";import{VertexArrayObject as
|
|
5
|
+
import"../../../../core/has.js";import{disposeMaybe as r}from"../../../../core/maybe.js";import{Pos2 as t}from"../lib/DefaultVertexBufferLayouts.js";import{VertexArrayObject as o}from"../lib/VertexArrayObject.js";import{PrimitiveType as e}from"../../../webgl/enums.js";import{VertexBuffer as s}from"../../../webgl/VertexBuffer.js";class i{constructor(r){this._rctx=r,this._vao=a(r)}destroy(){this._vao=r(this._vao)}draw(){null!=this._vao&&(this._rctx.bindVAO(this._vao),this._rctx.drawArrays(e.TRIANGLES,0,3))}get test(){}}function a(r){const e=new Float32Array([-1,-1,3,-1,-1,3]);return new o(r,new s(r,t,e))}export{i as ScreenSpaceGeometry};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import{property as
|
|
5
|
+
import{__decorate as e}from"tslib";import{property as s}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/has.js";import"../../../../../core/Logger.js";import"../../../../../core/RandomLCG.js";import{subclass as t}from"../../../../../core/accessorSupport/decorators/subclass.js";import{RenderCategory as r,InternalRenderCategory as o}from"../../../webgl.js";import i from"../../../webgl/RenderNode.js";import{FocusAreaMaskTechnique as n}from"./FocusAreaMaskTechnique.js";import{Pos3 as a}from"../../lib/DefaultVertexBufferLayouts.js";import{VertexArrayObject as c}from"../../lib/VertexArrayObject.js";import{F as h}from"../../../../../chunks/FocusAreaMask.glsl.js";import{DepthStencilAttachment as p,PrimitiveType as l}from"../../../../webgl/enums.js";import{noParameters as u}from"../../../../webgl/NoParameters.js";import{VertexBuffer as m}from"../../../../webgl/VertexBuffer.js";let d=class extends i{constructor(e){super({...e,view:e.focusAreasView.view}),this.consumes={required:[r.TRANSPARENT]},this.produces=o.FOCUSAREA,this._vaos=new Array,this._counts=new Array,this._origins=new Array,this._maskParameters=new h}initialize(){this.updateGeometries()}destroy(){this._vaos.forEach(e=>e.dispose()),this._vaos.length=this._counts.length=this._origins.length=0}precompile(){this.techniques.precompile(n)}render(e){const s=this.techniques.get(n),t=this.bindParameters,i=t.camera,a=i.fullViewport[2],c=i.fullViewport[3];if(!s.compiled||!this._vaos)return void this.requestRender();const h=e.find(({name:e})=>e===r.TRANSPARENT),m=this.renderingContext,d=this.fboCache.acquire(a,c,o.FOCUSAREA,2);this.view.stage.renderer.occludedRequiresStencil?(d.acquireDepth(11),m.blitFramebuffer(h.fbo,d.fbo,256)):d.attachDepth(h.getAttachment(p)),m.bindFramebuffer(d.fbo),m.setClearColor(0,0,0,1),m.clear(17408),m.setViewport(0,0,a,c);const f=m.bindTechnique(s,t);m.setFaceCullingEnabled(!1),m.setStencilTestEnabled(!0),m.setStencilOpSeparate(1028,7680,34055,7680),m.setStencilOpSeparate(1029,7680,34056,7680),m.setDepthWriteEnabled(!1);for(let r=0;r<this._vaos.length;r++){const e=this._vaos[r],s=this._counts[r];this._maskParameters.origin=this._origins[r],f.bindDraw(t,u,this._maskParameters),m.bindVAO(e),m.setDepthTestEnabled(!0),m.setStencilWriteMask(255),m.setStencilFunction(519,0,255),m.setColorMask(!1,!1,!1,!1),m.drawArrays(l.TRIANGLES,0,s),m.setDepthTestEnabled(!1),m.setStencilWriteMask(0),m.setStencilFunction(517,0,255),m.setColorMask(!0,!0,!0,!0),m.drawArrays(l.TRIANGLES,0,s)}return d}updateGeometries(){if(!this.view.stage)return;this._vaos.forEach(e=>e.dispose()),this._vaos.length=this._counts.length=this._origins.length=0;this.focusAreasView.volumes.forEach(e=>{const s=new Array;let t=0,r=0;e.geometryVolumes.forEach(e=>{const o=e.indicesBottom;t+=o.length;for(let t=0;t<o.length;t++)s.push(e.positions[3*(o[t]-1)]),s.push(e.positions[3*(o[t]-1)+1]),s.push(e.positions[3*(o[t]-1)+2]);const i=e.indicesExtruded;r+=i.length;for(let t=0;t<i.length;t++)s.push(e.positions[3*i[t]]),s.push(e.positions[3*i[t]+1]),s.push(e.positions[3*i[t]+2])});const o=new c(this.renderingContext,new m(this.renderingContext,a,new Float32Array(s)));this._vaos.push(o),this._counts.push(t+r),this._origins.push(e.origin)}),this.requestRender()}};e([s()],d.prototype,"consumes",void 0),e([s()],d.prototype,"produces",void 0),e([s({constructOnly:!0})],d.prototype,"focusAreasView",void 0),d=e([t("esri.views.3d.webgl-engine.effects.focusArea.FocusAreaMaskNode")],d);export{d as FocusAreaMaskNode};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import"../../../../../core/has.js";import{releaseMaybe as t,disposeMaybe as r}from"../../../../../core/maybe.js";import{watch as i,initial as s}from"../../../../../core/reactiveUtils.js";import{property as o}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/Logger.js";import"../../../../../core/RandomLCG.js";import{subclass as h}from"../../../../../core/accessorSupport/decorators/subclass.js";import{set as n}from"../../../../../core/libs/gl-matrix-2/math/vec2.js";import{InternalRenderCategory as l}from"../../../webgl.js";import a from"../../../webgl/RenderNode.js";import{HighlightApplyTechnique as g}from"./HighlightApplyTechnique.js";import{HighlightBlurTechnique as c}from"./HighlightBlurTechnique.js";import{HighlightDownsampleTechnique as u}from"./HighlightDownsampleTechnique.js";import{HighlightPassParameters as p}from"./HighlightPassParameters.js";import{HighlightToSingleTechnique as m}from"./HighlightToSingleTechnique.js";import{NoVertex as d}from"../../lib/DefaultVertexBufferLayouts.js";import{VertexArrayObject as f}from"../../lib/VertexArrayObject.js";import{H as b}from"../../../../../chunks/HighlightBlur.glsl.js";import{H as w,g as x}from"../../../../../chunks/HighlightDownsample.glsl.js";import{BufferObject as T}from"../../../../webgl/BufferObject.js";import{PrimitiveType as C,DataType as _}from"../../../../webgl/enums.js";import{Texture as v}from"../../../../webgl/Texture.js";import{TextureDescriptor as j}from"../../../../webgl/TextureDescriptor.js";import{VertexBuffer as H}from"../../../../webgl/VertexBuffer.js";let q=class extends a{constructor(){super(...arguments),this.produces=l.HIGHLIGHTS,this.consumes={required:[l.HIGHLIGHTS,"highlights"]},this._downsampleDrawParameters=new w,this._passParameters=new p,this._highlightBlurDrawParameters=new b,this._grid=new P}initialize(){this.addHandles([i(()=>this._updateOptionsTexture(),()=>{},s)])}destroy(){this._grid.coverage=t(this._grid.coverage),this._grid.vao=r(this._grid.vao),this._passParameters.highlightOptionsTexture=t(this._passParameters.highlightOptionsTexture)}_updateOptionsTexture(){if(null==this._passParameters.highlightOptionsTexture){const e=new j(16,2);e.internalFormat=6408,e.samplingMode=9728,this._passParameters.highlightOptionsTexture=new v(this.renderingContext,e,null)}this._passParameters.highlightOptionsTexture.setData(O(this.view.state.highlights)),this.requestRender(1)}precompile(){this.techniques.precompile(u),this.techniques.precompile(m),this.techniques.precompile(c),this.techniques.precompile(g)}render(e){const t=e.find(({name:e})=>e===l.HIGHLIGHTS),{techniques:r,bindParameters:i}=this;if(!i.decorations)return t;if(!r.get(u).compiled)return this.requestRender(1),t;const s=e.find(({name:e})=>"highlights"===e).getTexture();return this._renderHighlightPostprocess(s,t),t}_prepareAndDownSample(e){this._gridUpdateResources(e);const t=this.techniques.get(u),r=this._gridComputeCoverage(t,e),{horizontalCellCount:i,verticalCellCount:s}=r,o=this._passParameters;return o.horizontalCellCount=i,o.verticalCellCount=s,o.coverageTexture=r.coverage?.getTexture(),r}_renderGrid(e){const t=e.verticalCellCount*e.horizontalCellCount;this.renderingContext.bindVAO(e.vao),this.renderingContext.drawElementsInstanced(C.TRIANGLES,6,_.UNSIGNED_BYTE,0,t)}_renderHighlightPostprocess(e,t){const{fboCache:r,techniques:i,bindParameters:s,_passParameters:o,renderingContext:h}=this,l=i.get(m),a=i.get(c),u=i.get(g);if(!u.compiled||!a.compiled||!l.compiled)return void this.requestRender(1);o.highlightTexture=e;const p=this._prepareAndDownSample(e),{width:d,height:f}=e.descriptor;o.highlightTexture=e;const{camera:b}=s,{fullWidth:w,fullHeight:x,pixelRatio:T,fullViewport:C}=b,_=Math.ceil(w/T),v=Math.ceil(x/T),{_highlightBlurDrawParameters:j}=this,H=this.view.stage.renderView.renderer,{highlights:q}=s;for(let g=0;g<q.length;++g){const{name:e}=q[g];if(!H.hasHighlight(e))continue;o.highlightLevel=g,h.setClearColor(0,0,0,0);const i=r.acquire(d,f,"single highlight",2);h.bindFramebuffer(i.fbo),h.setViewport(0,0,d,f),h.clear(16384),h.bindTechnique(l,s,o),this._renderGrid(p),j.blurInput=i.getTexture(),n(j.blurSize,1/_,0);const c=r.acquire(_,v,"single highlight blur h",2);h.unbindTexture(c.fbo?.colorTexture),h.bindFramebuffer(c.fbo),h.setViewport(0,0,_,v),h.clear(16384),h.bindTechnique(a,s,o,j),this._renderGrid(p),i.release(),n(j.blurSize,0,1/v),o.highlightBlurTexture=c.getTexture(),h.bindFramebuffer(t.fbo),h.setViewport4fv(C),h.bindTechnique(u,s,o,j),this._renderGrid(p),c.release()}o.coverageTexture=o.highlightTexture=null}_gridUpdateResources(e){const t=this._grid,{width:r,height:i}=e.descriptor;if(t.horizontalCellCount=Math.ceil(r/x),t.verticalCellCount=Math.ceil(i/x),t.vao)return;const s=this.renderingContext,o=T.createIndex(s,35044,S);t.vao=new f(s,new H(
|
|
5
|
+
import{__decorate as e}from"tslib";import"../../../../../core/has.js";import{releaseMaybe as t,disposeMaybe as r}from"../../../../../core/maybe.js";import{watch as i,initial as s}from"../../../../../core/reactiveUtils.js";import{property as o}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/Logger.js";import"../../../../../core/RandomLCG.js";import{subclass as h}from"../../../../../core/accessorSupport/decorators/subclass.js";import{set as n}from"../../../../../core/libs/gl-matrix-2/math/vec2.js";import{InternalRenderCategory as l}from"../../../webgl.js";import a from"../../../webgl/RenderNode.js";import{HighlightApplyTechnique as g}from"./HighlightApplyTechnique.js";import{HighlightBlurTechnique as c}from"./HighlightBlurTechnique.js";import{HighlightDownsampleTechnique as u}from"./HighlightDownsampleTechnique.js";import{HighlightPassParameters as p}from"./HighlightPassParameters.js";import{HighlightToSingleTechnique as m}from"./HighlightToSingleTechnique.js";import{NoVertex as d}from"../../lib/DefaultVertexBufferLayouts.js";import{VertexArrayObject as f}from"../../lib/VertexArrayObject.js";import{H as b}from"../../../../../chunks/HighlightBlur.glsl.js";import{H as w,g as x}from"../../../../../chunks/HighlightDownsample.glsl.js";import{BufferObject as T}from"../../../../webgl/BufferObject.js";import{PrimitiveType as C,DataType as _}from"../../../../webgl/enums.js";import{Texture as v}from"../../../../webgl/Texture.js";import{TextureDescriptor as j}from"../../../../webgl/TextureDescriptor.js";import{VertexBuffer as H}from"../../../../webgl/VertexBuffer.js";let q=class extends a{constructor(){super(...arguments),this.produces=l.HIGHLIGHTS,this.consumes={required:[l.HIGHLIGHTS,"highlights"]},this._downsampleDrawParameters=new w,this._passParameters=new p,this._highlightBlurDrawParameters=new b,this._grid=new P}initialize(){this.addHandles([i(()=>this._updateOptionsTexture(),()=>{},s)])}destroy(){this._grid.coverage=t(this._grid.coverage),this._grid.vao=r(this._grid.vao),this._passParameters.highlightOptionsTexture=t(this._passParameters.highlightOptionsTexture)}_updateOptionsTexture(){if(null==this._passParameters.highlightOptionsTexture){const e=new j(16,2);e.internalFormat=6408,e.samplingMode=9728,this._passParameters.highlightOptionsTexture=new v(this.renderingContext,e,null)}this._passParameters.highlightOptionsTexture.setData(O(this.view.state.highlights)),this.requestRender(1)}precompile(){this.techniques.precompile(u),this.techniques.precompile(m),this.techniques.precompile(c),this.techniques.precompile(g)}render(e){const t=e.find(({name:e})=>e===l.HIGHLIGHTS),{techniques:r,bindParameters:i}=this;if(!i.decorations)return t;if(!r.get(u).compiled)return this.requestRender(1),t;const s=e.find(({name:e})=>"highlights"===e).getTexture();return this._renderHighlightPostprocess(s,t),t}_prepareAndDownSample(e){this._gridUpdateResources(e);const t=this.techniques.get(u),r=this._gridComputeCoverage(t,e),{horizontalCellCount:i,verticalCellCount:s}=r,o=this._passParameters;return o.horizontalCellCount=i,o.verticalCellCount=s,o.coverageTexture=r.coverage?.getTexture(),r}_renderGrid(e){const t=e.verticalCellCount*e.horizontalCellCount;this.renderingContext.bindVAO(e.vao),this.renderingContext.drawElementsInstanced(C.TRIANGLES,6,_.UNSIGNED_BYTE,0,t)}_renderHighlightPostprocess(e,t){const{fboCache:r,techniques:i,bindParameters:s,_passParameters:o,renderingContext:h}=this,l=i.get(m),a=i.get(c),u=i.get(g);if(!u.compiled||!a.compiled||!l.compiled)return void this.requestRender(1);o.highlightTexture=e;const p=this._prepareAndDownSample(e),{width:d,height:f}=e.descriptor;o.highlightTexture=e;const{camera:b}=s,{fullWidth:w,fullHeight:x,pixelRatio:T,fullViewport:C}=b,_=Math.ceil(w/T),v=Math.ceil(x/T),{_highlightBlurDrawParameters:j}=this,H=this.view.stage.renderView.renderer,{highlights:q}=s;for(let g=0;g<q.length;++g){const{name:e}=q[g];if(!H.hasHighlight(e))continue;o.highlightLevel=g,h.setClearColor(0,0,0,0);const i=r.acquire(d,f,"single highlight",2);h.bindFramebuffer(i.fbo),h.setViewport(0,0,d,f),h.clear(16384),h.bindTechnique(l,s,o),this._renderGrid(p),j.blurInput=i.getTexture(),n(j.blurSize,1/_,0);const c=r.acquire(_,v,"single highlight blur h",2);h.unbindTexture(c.fbo?.colorTexture),h.bindFramebuffer(c.fbo),h.setViewport(0,0,_,v),h.clear(16384),h.bindTechnique(a,s,o,j),this._renderGrid(p),i.release(),n(j.blurSize,0,1/v),o.highlightBlurTexture=c.getTexture(),h.bindFramebuffer(t.fbo),h.setViewport4fv(C),h.bindTechnique(u,s,o,j),this._renderGrid(p),c.release()}o.coverageTexture=o.highlightTexture=null}_gridUpdateResources(e){const t=this._grid,{width:r,height:i}=e.descriptor;if(t.horizontalCellCount=Math.ceil(r/x),t.verticalCellCount=Math.ceil(i/x),t.vao)return;const s=this.renderingContext,o=T.createIndex(s,35044,S);t.vao=new f(s,new H(s,d),o)}_gridComputeCoverage(e,t){const r=this.renderingContext,i=this._grid,s=t.descriptor,o=Math.ceil(s.width/x),h=Math.ceil(s.height/x);this._downsampleDrawParameters.input=t;const{highlights:n}=this.bindParameters;i.coverage?.release();const l=this.fboCache.acquire(o,h,"highlight coverage",n.length>I?3:1);return i.coverage=l,r.bindFramebuffer(l.fbo),r.bindTechnique(e,this.bindParameters,this._passParameters,this._downsampleDrawParameters),r.setViewport(0,0,o,h),r.screen.draw(),i}get test(){}};e([o()],q.prototype,"produces",void 0),e([o()],q.prototype,"consumes",void 0),q=e([h("esri.views.3d.webgl-engine.effects.highlight.Highlight")],q);class P{constructor(){this.coverage=null,this.vao=null,this.verticalCellCount=0,this.horizontalCellCount=0,this.viewportWidth=0,this.viewportHeight=0}}function O(e){const t=new Uint8Array(128);let r=0;for(const i of e){const e=4*r,s=4*r+64;++r;const{color:o}=i,h=i.haloColor??o;t[e+0]=o.r,t[e+1]=o.g,t[e+2]=o.b,t[e+3]=i.fillOpacity*o.a*255,t[s+0]=h.r,t[s+1]=h.g,t[s+2]=h.b,t[s+3]=i.haloOpacity*h.a*255}return t}let y=0;function D(e){let t=0;for(const i of e){const{name:e}=i;t+=e.length;const{color:r,fillOpacity:s,haloColor:o,haloOpacity:h}=i;t+=r.r+r.g+r.b+r.a+s,t+=o?o.r+o.g+o.b+o.a+h:0}const r=e.at(0);if(r){const{shadowOpacity:e,shadowDifference:i,shadowColor:s}=r;t+=e+i+s.r+s.g+s.b+s.a}return y+++(t>=0?0:1)}const S=new Uint8Array([0,1,2,2,1,3]);function G(e,t,r,i,s,o=0){const{highlights:h}=i,l=h.length>1?t.acquire(r.width,r.height,"highlight mix",h.length>I?3:1):null,{gl:a}=e;if(l){const t=e.getBoundFramebufferObject();e.bindFramebuffer(l.fbo),a.clearBufferuiv(a.COLOR,0,[0,0,0,0]),e.bindFramebuffer(t)}const g=l?.getTexture();i.highlightMixTexture=g,n(i.highlightMixOrigin,o,0),h.forEach((t,h)=>{if(h>0){const t=v.TEXTURE_UNIT_FOR_UPDATES;e.bindTexture(g,t),e.setActiveTexture(t),a.copyTexSubImage2D(3553,0,0,0,o,0,r.width,r.height),e.bindTexture(null,t)}e.clear(256),i.highlightLevel=h,s()}),i.highlightLevel=null,i.highlightMixTexture=null,l?.release()}const I=4;export{q as Highlight,I as maxHighlightsPerChannel,G as renderHighlightBuffer,D as trackHighlightOptions};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{i as e,d as t}from"../../../../../chunks/vec32.js";import{create as r}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{newDoubleArray as s}from"../../../../../geometry/support/DoubleArray.js";import{glLayout as
|
|
5
|
+
import{i as e,d as t}from"../../../../../chunks/vec32.js";import{create as r}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{newDoubleArray as s}from"../../../../../geometry/support/DoubleArray.js";import{glLayout as i}from"../../../support/buffer/glUtil.js";import{newLayout as o}from"../../../support/buffer/InterleavedLayout.js";import{VertexArrayObject as f}from"../../lib/VertexArrayObject.js";import{PrimitiveType as n}from"../../../../webgl/enums.js";import{VertexBuffer as u}from"../../../../webgl/VertexBuffer.js";class a{constructor(e){this._renderCoordsHelper=e,this._origin=r(),this._dirty=!1,this._count=0}set vertices(e){const t=s(3*e.length);let r=0;for(const s of e)t[r++]=s[0],t[r++]=s[1],t[r++]=s[2];this.buffers=[t]}set buffers(t){if(this._buffers=t,this._buffers.length>0){const t=this._buffers[0],r=3*Math.floor(t.length/3/2);e(this._origin,t[r],t[r+1],t[r+2])}else e(this._origin,0,0,0);this._dirty=!0}get origin(){return this._origin}draw(e){const t=this._ensureVAO(e);null!=t&&(e.bindVAO(t),e.drawArrays(n.TRIANGLES,0,this._count))}dispose(){null!=this._vao&&this._vao.dispose()}get _layout(){return 1===this._renderCoordsHelper.viewingMode?_:d}_ensureVAO(e){return null==this._buffers?null:(this._vao??=this._createVAO(e,this._buffers),this._ensureVertexData(this._vao,this._buffers),this._vao)}_createVAO(e,t){const r=this._createDataBuffer(t);return this._dirty=!1,new f(e,new u(e,i(this._layout),r))}_ensureVertexData(e,t){if(!this._dirty)return;const r=this._createDataBuffer(t);e.buffer()?.setData(r),this._dirty=!1}_createDataBuffer(r){const s=r.reduce((e,t)=>e+l(t),0);this._count=s;const i=this._layout.createBuffer(s),o=this._origin;let f=0,n=0;const u="startUp"in i?this._setUpVectors.bind(this,i):void 0;for(const a of r){for(let r=0;r<a.length;r+=3){const s=e(h,a[r],a[r+1],a[r+2]);0===r?n=this._renderCoordsHelper.getAltitude(s):this._renderCoordsHelper.setAltitude(s,n);const l=f+2*r;u?.(r,l,a,s);const c=t(h,s,o);if(r<a.length-3){for(let e=0;e<6;e++)i.start.setVec(l+e,c);i.extrude.setValues(l,0,-1),i.extrude.setValues(l+1,1,-1),i.extrude.setValues(l+2,1,1),i.extrude.setValues(l+3,0,-1),i.extrude.setValues(l+4,1,1),i.extrude.setValues(l+5,0,1)}if(r>0)for(let e=-6;e<0;e++)i.end.setVec(l+e,c)}f+=l(a)}return i.buffer}_setUpVectors(e,t,r,s,i){const o=this._renderCoordsHelper.worldUpAtPosition(i,c);if(t<s.length-3)for(let f=0;f<6;f++)e.startUp.setVec(r+f,o);if(t>0)for(let f=-6;f<0;f++)e.endUp.setVec(r+f,o)}}function l(e){return 3*(2*(e.length/3-1))}const c=r(),h=r(),_=o().vec3f("start").vec3f("end").vec2f("extrude").vec3f("startUp").vec3f("endUp"),d=o().vec3f("start").vec3f("end").vec2f("extrude");export{a as LaserlinePathData};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as t}from"tslib";import{fetchAsset as e}from"../../../../../assets.js";import{createTask as s}from"../../../../../core/asyncUtils.js";import r from"../../../../../core/Error.js";import i from"../../../../../core/Logger.js";import{abortMaybe as a,disposeMaybe as o}from"../../../../../core/maybe.js";import{isAbortError as n}from"../../../../../core/promiseUtils.js";import{watch as f,initial as c,syncAndInitial as m}from"../../../../../core/reactiveUtils.js";import"../../../../../core/has.js";import"../../../../../core/RandomLCG.js";import{subclass as h}from"../../../../../core/accessorSupport/decorators/subclass.js";import{copy as u,rotateZ as l,multiply as d}from"../../../../../core/libs/gl-matrix-2/math/mat4.js";import{fromValues as p}from"../../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{InternalRenderCategory as b}from"../../../webgl.js";import{glLayout as _}from"../../../support/buffer/glUtil.js";import{OpaqueEnvironment as g}from"../OpaqueEnvironment.js";import{StarPassParameters as w,StarsTechnique as j,layout as v}from"./StarsTechnique.js";import{VertexArrayObject as P}from"../../lib/VertexArrayObject.js";import{
|
|
5
|
+
import{__decorate as t}from"tslib";import{fetchAsset as e}from"../../../../../assets.js";import{createTask as s}from"../../../../../core/asyncUtils.js";import r from"../../../../../core/Error.js";import i from"../../../../../core/Logger.js";import{abortMaybe as a,disposeMaybe as o}from"../../../../../core/maybe.js";import{isAbortError as n}from"../../../../../core/promiseUtils.js";import{watch as f,initial as c,syncAndInitial as m}from"../../../../../core/reactiveUtils.js";import"../../../../../core/has.js";import"../../../../../core/RandomLCG.js";import{subclass as h}from"../../../../../core/accessorSupport/decorators/subclass.js";import{copy as u,rotateZ as l,multiply as d}from"../../../../../core/libs/gl-matrix-2/math/mat4.js";import{fromValues as p}from"../../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{InternalRenderCategory as b}from"../../../webgl.js";import{glLayout as _}from"../../../support/buffer/glUtil.js";import{OpaqueEnvironment as g}from"../OpaqueEnvironment.js";import{StarPassParameters as w,StarsTechnique as j,layout as v}from"./StarsTechnique.js";import{VertexArrayObject as P}from"../../lib/VertexArrayObject.js";import{PrimitiveType as y}from"../../../../webgl/enums.js";import{VertexBuffer as D}from"../../../../webgl/VertexBuffer.js";let T=class extends g{constructor(){super(...arguments),this._numPoints=0,this._passParameters=new w}initialize(){this.addHandles([f(()=>this.view.environment.starsEnabled,t=>t?this._enable():this._disable(),c),f(()=>"virtual"===this.view.environment.lighting.type?null:this.view.environment.lighting.date,t=>this._update(t),m)])}_enable(){super._enable(),this._loadDataTask=this._createLoadDataTask()}get loading(){return!!this._loadDataTask&&!this._loadDataTask.finished}destroy(){this._loadDataTask=a(this._loadDataTask),this._numPoints=0,this._vao=o(this._vao),this._starData=null}precompile(){this.techniques.precompile(j)}render(t){const e=t.find(({name:t})=>t===b.OPAQUE_ENVIRONMENT),s=this.renderingContext;if(this.loading)return this.requestRender(1),e;if(!this._starData)return e;this._vao??=this._ensureResources(this._starData,s);const r=this.techniques.get(j);return r.compiled?(s.bindTechnique(r,this.bindParameters,this._passParameters),s.bindVAO(this._vao),s.drawArrays(y.POINTS,0,this._numPoints),e):(this.requestRender(1),e)}_ensureResources(t,e){this._numPoints=t.byteLength/E;return M(e,new Float32Array(t,0,2*this._numPoints),new Uint8Array(t,2*this._numPoints*4,this._numPoints),this._numPoints)}_update(t){if(!t)return;const e=(t.getHours()/12+t.getMinutes()/60*(2/24)+t.getSeconds()/60*(2/1440)-.9972222)%2,s=2*q(t),r=u(this._passParameters.modelMatrix,A);l(r,r,-s*Math.PI),d(r,L,r),l(r,r,-e*Math.PI),this.requestRender(1)}_createLoadDataTask(){if(this._starData)return null;const t=s(async t=>{const{data:s}=await e("esri/views/3d/environment/resources/stars.wsv",{responseType:"array-buffer",signal:t});x(s),this._starData=s});return t.promise.catch(t=>{n(t)||i.getLogger(this).error(t)}).then(()=>{this.destroyed||this.requestRender(1)}),t}};function M(t,e,s,r){const i=v.createBuffer(r),a=i.position,o=i.color,n=i.size;for(let f=0;f<r;f++){const t=e[2*f],r=e[2*f+1];a.set(f,0,-Math.cos(t)*Math.sin(r)),a.set(f,1,-Math.sin(t)*Math.sin(r)),a.set(f,2,-Math.cos(r));const i=k(s[f]),c=R(I[i[1]]);o.set(f,0,255*c[0]),o.set(f,1,255*c[1]),o.set(f,2,255*c[2]),o.set(f,3,255),n.set(f,i[0])}return new P(t,new D(t,_(v),i.buffer))}function q(t){const e=t,s=new Date(t.getFullYear(),0,1,11,58,56);return(+e-+s)/(+new Date(t.getFullYear()+1,0,1,11,58,55)-+s)}function x(t){if(!t)throw new r("stars:no-data-received","Failed to create stars because star catalogue is missing");const e=t.byteLength/E;if(e%1!=0||e>5e4||e<5e3)throw new r("stars:invalid-data","Failed to create stars because star catalogue data is invalid")}function R(t){return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}function k(t){return t>=192?[2.9,t-192]:t>=160?[2.5,t-160]:t>=128?[2,t-128]:t>=96?[1.5,t-96]:t>=64?[1,t-64]:t>=32?[.7,t-32]:[.4,t]}T=t([h("esri.views.3d.webgl-engine.effects.stars.Stars")],T);const I=["9bb2ff","9eb5ff","aabfff","bbccff","ccd8ff ","dae2ff","e4e9ff","eeefff","f8f6ff","fff9fb","fff5ef","fff1e5","ffeddb","ffe9d2","ffe6ca","ffe3c3","ffe0bb","ffddb4","ffdaad","ffd6a5","ffd29c","ffcc8f","ffc178","ffa94b","ff7b00"],L=p(1,0,0,0,0,.9174771405229186,.39778850739794974,0,0,-.39778850739794974,.9174771405229186,0,0,0,0,1),A=p(1,0,0,0,0,.9174771405229186,-.39778850739794974,0,0,.39778850739794974,.9174771405229186,0,0,0,0,1),E=9;export{T as Stars};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import t from"../../../../../core/Accessor.js";import{equals as r,binaryIndexOf as s}from"../../../../../core/arrayUtils.js";import"../../../../../core/has.js";import n from"../../../../../core/Logger.js";import{clamp as i}from"../../../../../core/mathUtils.js";import{disposeMaybe as o,destroyMaybe as a}from"../../../../../core/maybe.js";import{isAbortError as c,onAbortOrThrow as l}from"../../../../../core/promiseUtils.js";import{property as d}from"../../../../../core/accessorSupport/decorators/property.js";import{subclass as h}from"../../../../../core/accessorSupport/decorators/subclass.js";import{fromMat4 as u,transpose as m,invert as g}from"../../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as f}from"../../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{create as p}from"../../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{i as _,c as b,a as y,e as j}from"../../../../../chunks/vec32.js";import{create as w,clone as O}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{UpdatingHandles as E}from"../../../../../core/support/UpdatingHandles.js";import{a as x,g as v}from"../../../../../chunks/sphere.js";import{c as M}from"../../../../../chunks/vec33.js";import{encodeElevationOffset as R}from"../../collections/Component/Material/shader/ComponentData.glsl.js";import{TwoVectorPosition as T}from"../../core/util/TwoVectorPosition.js";import{Attribute as C}from"../Attribute.js";import{GridLocalOriginFactory as D}from"../GridLocalOriginFactory.js";import{applyToModelMatrix as P}from"../localOriginHelper.js";import{LocalOriginManager as A}from"../LocalOriginManager.js";import{Object3D as k}from"../Object3D.js";import{VertexArrayObject as B}from"../VertexArrayObject.js";import{VertexLayout as L,EdgeInputBufferLayout as U,glVertexLayout as q}from"./bufferLayouts.js";import{RegularEdgeBufferWriter as V,SilhouetteEdgeBufferWriter as H}from"./edgeBufferWriters.js";import{EdgeRenderer as S,lineWidthFractionFactor as I,extensionLengthOffset as N}from"./EdgeRenderer.js";import{EdgePassParameters as z}from"./EdgeShaderParameters.js";import{EdgeWorkerHandle as W}from"./EdgeWorkerHandle.js";import{generateStrokesTexture as F}from"./strokes.js";import{determineRendererType as G,determineEdgeTransparency as K,determineObjectTransparency as J,fillComponentBufferIndices as Q}from"./util.js";import{BufferManager as X}from"../TextureBackedBuffer/BufferManager.js";import{BufferObject as Y}from"../../../../webgl/BufferObject.js";import{VertexBuffer as Z}from"../../../../webgl/VertexBuffer.js";const $=128;let ee=class extends t{constructor(e){super(e),this._updatingHandles=new E,this._objectEntries=new Map,this._pendingDeletions=new Map,this._renderers=new Map,this._gpuMemoryUsage=0,this._workerAbort=new AbortController,this._tmpModelPosition=w(),this._localOrigins=new A(new D(e.renderSR));const t=L.createBuffer(4);for(let r=0;r<4;r++)t.sideness.set(r,0,0===r||3===r?0:1),t.sideness.set(r,1,0===r||1===r?0:1);this._verticesBufferObject=Y.createVertex(e.rctx,35044,t.buffer)}initialize(){this._worker=new W(this.schedule),this._componentColorManager=new X(this.rctx,3)}destroy(){this.destroyed||(this._objectEntries.forEach(e=>this._discardObjectEntry(e)),this._objectEntries.clear(),this._pendingDeletions.forEach(e=>this._discardObjectEntry(e)),this._pendingDeletions.clear(),this._strokesTexture=o(this._strokesTexture),this._componentColorManager=a(this._componentColorManager),this._workerAbort.abort(),this._worker.destroy(),this._verticesBufferObject.dispose(),this._renderers.clear(),this._updatingHandles.destroy(),this._set("schedule",be))}get updating(){return this._updatingHandles.updating}get usedMemory(){return this._gpuMemoryUsage}shouldRender(){return this._renderers.size>0}async addComponentObject(e,t,r,s,n,i,o){if(this.hasObject(e))return this._getObjectMemoryUsage(e);let a;const c=new se(null,new Promise(e=>a=e),e.obb.center,e.obb.radius);this._objectEntries.set(e,c);const l=await this._updatingHandles.addPromise(this._addComponentGeometry(e.transform,c,t,r,s,n,i,o));return this.setNeedsRender(),a(),l}async addOrUpdateObject3D(e,t,r,s){if(this.destroyed)return void n.getLogger(this).warn("Attempt to add an object to a destroyed instance");const i=new AbortController;let o;const a=e.boundingVolumeWorldSpace.bounds,l=new se(i,new Promise(e=>o=e),x(a),v(a)),d=this._objectEntries.get(e);d&&(this._pendingDeletions.has(e)?this._discardObjectEntry(d):this._pendingDeletions.set(e,d)),this._objectEntries.set(e,l);try{const n=new Array;if(e.geometries.length>1&&re(e))n.push(this._addObjectMergedGeometries(e,l,t,r,s));else for(const i of e.geometries)i.material.supportsEdges&&n.push(this._addGeometry(e,l,i,t,r,s));await this._updatingHandles.addPromise(Promise.all(n)),this._removePendingDeletion(e)}catch(h){c(h)?this._discardObjectEntry(l):this._removePendingDeletion(e)}finally{this.setNeedsRender(),o()}}removeObject(e){const t=this._objectEntries.get(e);this._objectEntries.delete(e),this._discardObjectEntry(t),this._removePendingDeletion(e)}_removePendingDeletion(e){const t=this._pendingDeletions.get(e);this._pendingDeletions.delete(e),this._discardObjectEntry(t)}async _getObjectEntry(e){const t=this._objectEntries.get(e);if(!t)throw new Error("no object");return await t.loaded,null==t.loaded?null:t}fastUpdateObject3DEdgesTransform(e){if(this.destroyed)return!1;const t=this._objectEntries.get(e);if(!t)return!1;const{geometries:r}=e,{renderables:s}=t;if(0===r.length||0===s.length)return!0;if(s.length>1)return!1;const[n]=s,i=n.transform;if(!(i instanceof oe))return!1;const[o]=r;if(o.localOrigin!==i.origin.origin)return!1;const a=p(),c=this._computeModelTransformWithLocalOrigin(e,o,a);return n.transform=new oe(a,c),this.setNeedsRender(),!0}_discardObjectEntry(e){e&&(e.abort?.abort(),e.renderables.length&&(e.renderables.forEach(e=>this._removeRenderable(e)),this.setNeedsRender()),e.loaded=null)}hasObject(e){return this._objectEntries.has(e)}async updateAllComponentOpacities(e,t){const r=await this._updatingHandles.addPromise(this._getObjectEntry(e));if(null==r)return;const s=Array.isArray(t)?e=>t[e]:()=>t;r.renderables.forEach(e=>{const t=e.components.meta.length;for(let r=0;r<t;r++){const t=s(r),n=e.components.meta[r],i=n.index;n.material.opacity=t,e.components.buffer.textureBuffer.setDataElement(i,1,3,255*t)}this._updateTransparency(e)}),this.setNeedsRender()}async _getObjectMemoryUsage(e){const t=await this._getObjectEntry(e);return t?t.renderables.reduce((e,t)=>e+t.statistics.gpuMemoryUsage,0):0}async updateAllComponentMaterials(e,t,r,s){const n=e instanceof k,i=G(t),o=S.getKey(i,r,n),a=await this._updatingHandles.addPromise(this._getObjectEntry(e));null!=a&&(a.renderables.forEach(e=>{if(o!==e.rendererKey){const t=this._renderers.get(e.rendererKey),s=this._acquireRenderer(i,r,n);t.removeRenderable(e),--t.refCount,e.rendererKey=o,s.addRenderable(e)}if(Array.isArray(t))for(let r=0;r<t.length;r++)e.components.meta[r].material=t[r];else e.components.meta[0].material=t;s&&le(e.components),this._updateTransparency(e)}),this.setNeedsRender())}async updateAllVerticalOffsets(e,t){const r=await this._updatingHandles.addPromise(this._getObjectEntry(e));null!=r&&this._updateAllVerticalOffsets(r,t)}_updateAllVerticalOffsets(e,t){e.renderables.forEach(e=>{const r=e.components.meta;for(let s=0;s<r.length;s++)e.components.meta[s].verticalOffset=t?.[s]??0;le(e.components)}),this.setNeedsRender()}async updateObjectVisibility(e,t){const r=await this._updatingHandles.addPromise(this._getObjectEntry(e));r&&(r.renderables.forEach(e=>e.visible=t),this.setNeedsRender())}render(e,t){if(null==this._componentColorManager)return;this._localOrigins.updateViewMatrices(e.camera.viewMatrix);const r=e.camera.viewInverseTransposeMatrix,s=w(),n=new T;let i=0,o=0;if(this._renderers.forEach(r=>{0!==r.refCount?(++this.techniques.precompiling,r.forEachRenderable(t=>{t.visible&&(i+=t.statistics.averageEdgeLength,o++,t.regular&&r.acquireTechnique(e,!1),t.silhouette&&r.acquireTechnique(e,!0))},t),--this.techniques.precompiling):this._renderers.delete(r.key)}),this._componentColorManager.garbageCollect(),this._componentColorManager.updateTextures(),0===o)return;const a=new z(40*i/o,t);_(s,r[3],r[7],r[11]),n.set(s),b(a.transformWorldFromViewTH,n.high),b(a.transformWorldFromViewTL,n.low),u(a.transformViewFromCameraRelativeRS,e.camera.viewMatrix),m(_e,a.transformViewFromCameraRelativeRS),g(a.transformNormalViewFromGlobal,_e),a.transformProjFromView=e.camera.projectionMatrix,this._updateObjectCameraDistances(e),this._renderers.forEach(t=>{de(t,e,a),he(t,e,a)})}_updateTransparency(e){const t=K(e.components.meta),r=J(e.components.meta);t===e.edgeTransparency&&r===e.objectTransparency||(e.edgeTransparency=t,e.objectTransparency=r,this._renderers.get(e.rendererKey).setRenderablesDirty())}_computeModelTransformWithLocalOrigin(e,t,r){e.getCombinedShaderTransformation(t,r);const s=null!=t.localOrigin?this._localOrigins.register(t.localOrigin):this._localOrigins.acquire(_(this._tmpModelPosition,r[12],r[13],r[14]));return t.localOrigin=s.origin,P(s.origin.vec3,r),s}_createComponentBuffers(e){if(null==this._componentColorManager)return null;const t=new Array,r=this._componentColorManager.getBuffer(e.length);for(let n=0;n<e.length;n++){const s=e[n],i=r.acquireIndex();t.push({index:i,verticalOffset:0,material:s})}const s=new ne(r,t);return le(s),s}_extractEdges(e,t,r,s,n,i,o=i.length){return o<$&&(n=!0),this._worker.process({data:r,indices:i,indicesLength:o,writerSettings:t,skipDeduplicate:s},e,n)}_createRenderable(e,t,r,s,n){const i=t=>new ie(new B(this.rctx,new Map([["vertices",new Z(q,this._verticesBufferObject)],["instances",new Z(0===t?V.glLayout:H.glLayout,Y.createVertex(this.rctx,35044,0===t?e.regular.instancesData.buffer:e.silhouette.instancesData.buffer))]])),0===t?e.regular.lodInfo:e.silhouette.lodInfo),o=e.regular.lodInfo.lengths.length>0?i(0):null,a=e.silhouette.lodInfo.lengths.length>0?i(1):null,c=(o?.vao.cachedMemory??0)+(a?.vao.cachedMemory??0);return new ae(o,a,{gpuMemoryUsage:c,externalMemoryUsage:n,averageEdgeLength:e.averageEdgeLength},r,K(t.meta),J(t.meta),t,s)}async _addGeometry(e,t,r,s,n,i){if(r.edgeIndicesLength<=0)return;const o=r.attributes.get("position"),a=p(),c=this._computeModelTransformWithLocalOrigin(e,r,a),l=new pe(o,a,c);return this._addPositionData(t,l,r.edgeIndicesLength,s,n,i)}async _addPositionData(e,t,r,s,n,i=!1){if(null==e.loaded)return;const o=this._createComponentBuffers([s]);if(null==o)return;const a=this._acquireRenderer(s.type,n,!0),{modelTransform:c,origin:l}=t,d=t.position.indices,h=t.position,u=h.data.length/h.size,m=U.createBuffer(u);for(let p=0;p<u;p++)m.position.set(p,0,h.data[p*h.size]),m.position.set(p,1,h.data[p*h.size+1]),m.position.set(p,2,h.data[p*h.size+2]);Q(o.meta,[0,m.componentIndex.count],m.componentIndex);const g=await this._updatingHandles.addPromise(this._extractEdges(e.abort?.signal||this._workerAbort.signal,a.writerSettings,m,!1,i,d,r));if(null==e.loaded)return;const f=this._createRenderable(g,o,new oe(c,l),a.key,!1);e.renderables.push(f),a.addRenderable(f),this._gpuMemoryUsage+=f.statistics.gpuMemoryUsage}async _addComponentGeometry(e,t,r,s,n,i,o,a){if(null==t.loaded)return 0;const c=this._createComponentBuffers(i);if(null==c)return 0;const l=G(i),d=this._acquireRenderer(l,o||!1,!1),h=U.createBuffer(r.length/3);M(h.position.typedBuffer,r,h.position.typedBufferStride,3),Q(c.meta,n,h.componentIndex,s);const u=!0,m=d.writerSettings,g=await this._updatingHandles.addPromise(this._extractEdges(this._workerAbort.signal,m,h,u,!1,s));if(null==t.loaded)return 0;const f=this._createRenderable(g,c,e,d.key,!0);return t.renderables.push(f),d.addRenderable(f),this._updateAllVerticalOffsets(t,a),f.statistics.gpuMemoryUsage}async _addObjectMergedGeometries(e,t,r,s,n){const i=new Map;let o=0,a=0,c=null;const l=e.geometries.filter(e=>{if(e.edgeIndicesLength<=0||!e.material.supportsEdges)return!1;!c&&e.localOrigin&&(c=e);const t=e.attributes.get("position");return a+=t.data.length/t.size,o+=e.edgeIndicesLength,!0});if(0===l.length)return;const d=a>=65536?Uint32Array:Uint16Array,h=o?new d(o):null,u=[];let m=0;l.forEach(e=>{const t=e.attributes.get("position"),r=t.indices;let s=i.get(t.data);if(null==s){s=u.length/3;for(let e=0;e<t.data.length;e+=t.size)u.push(t.data[e]),u.push(t.data[e+1]),u.push(t.data[e+2]);i.set(t.data,s)}for(let n=0;n<e.edgeIndicesLength;n++)h[m++]=s+r[n]});const g=c||e.geometries[0],f=p(),_=this._computeModelTransformWithLocalOrigin(e,g,f);for(let p=0;p<e.geometries.length;p++)e.geometries[p].localOrigin=_.origin;const b=new pe(new C(u,h,3),f,_);await this._updatingHandles.addPromise(this._addPositionData(t,b,h.length,r,s,n))}_acquireRenderer(e,t,r){const s=S.getKey(e,t,r);let n=this._renderers.get(s);return null==this._strokesTexture&&(this._strokesTexture=F(this.rctx)),n||(n=new S(this.rctx,this.techniques,{type:e,hasSlicePlane:t,strokesTexture:this._strokesTexture,legacy:r,spherical:1===this.viewingMode}),this._renderers.set(s,n)),++n.refCount,n}_removeRenderable(e){te(e.regular),te(e.silhouette);const t=this._renderers.get(e.rendererKey);if(t){t.removeRenderable(e),--t.refCount,this._localOrigins.release(e.transform.origin),this._gpuMemoryUsage-=e.statistics.externalMemoryUsage?0:e.statistics.gpuMemoryUsage;for(const t of e.components.meta)e.components.buffer.releaseIndex(t.index)}}_updateObjectCameraDistances(e){const t=e.camera.eye,r=e.camera.viewForward,s=w(),n=e=>{y(s,e.center,t);const n=j(s,r),i=e.radius,o=n<-i?1/0:n<i?0:n-i;e.renderables.forEach(e=>e.distanceToCamera=o)};this._objectEntries.forEach(n),this._pendingDeletions.forEach(n)}get test(){}};function te(e){e?.vao&&(e.vao.buffer("instances")?.buffer.dispose(),e.vao.disposeVAOOnly(),e.vao=null)}function re(e){let t=null,s=null;for(const n of e.geometries){if(n.material.supportsEdges){if(t){if(!r(t,n.transformation))return!1}else t=n.transformation;if(s||null==n.localOrigin){if(null!=s?.localOrigin&&null!=n.localOrigin&&s.localOrigin.id!==n.localOrigin.id)return!1}else s=n}}return!0}e([d({constructOnly:!0})],ee.prototype,"rctx",void 0),e([d({constructOnly:!0})],ee.prototype,"renderSR",void 0),e([d({constructOnly:!0})],ee.prototype,"viewingMode",void 0),e([d({constructOnly:!0})],ee.prototype,"techniques",void 0),e([d({constructOnly:!0})],ee.prototype,"setNeedsRender",void 0),e([d({constructOnly:!0})],ee.prototype,"schedule",void 0),e([d({readOnly:!0})],ee.prototype,"_updatingHandles",void 0),e([d({readOnly:!0})],ee.prototype,"updating",null),ee=e([h("esri.views.3d.webgl-engine.lib.edgeRendering.EdgeView")],ee);class se{constructor(e,t,r,s){this.abort=e,this.radius=s,this.renderables=new Array;const n=e?l(e.signal,()=>e.abort()):null;this.loaded=t,this.loaded.then(()=>{null!=this.loaded&&(this.loaded=!0),this.abort=null,n?.remove()}),this.center=O(r)}}class ne{constructor(e,t){this.buffer=e,this.meta=t}}class ie{constructor(e,t){this.vao=e,this.lod=t}}class oe{constructor(e,t){this.modelMatrix=e,this.origin=t}}class ae{constructor(e,t,r,s,n,i,o,a){this.regular=e,this.silhouette=t,this.statistics=r,this.transform=s,this.edgeTransparency=n,this.objectTransparency=i,this.components=o,this.rendererKey=a,this.distanceToCamera=0,this.visible=!0}}class ce extends ae{}function le(e){const{meta:t,buffer:r}=e,s=new Uint8Array(4);for(let n=0;n<t.length;n++){const e=t[n].material,o=t[n].index,a=i(Math.round(e.size*I),0,255),c=i(e.extensionLength,-N,255-N)+N,l=255*e.opacity,d=e.color,h=255*d[0],u=255*d[1],m=255*d[2],g=255*d[3];r.textureBuffer.setData(o,0,h,u,m,g),r.textureBuffer.setData(o,1,a,c,e.type,l),R(t[n].verticalOffset,s),r.textureBuffer.setData(o,2,s[0],s[1],s[2],s[3])}}function de(e,t,r){let s,n;const i=r.transparency,o=t.camera.perScreenPixelRatio;e.forEachRenderable(i=>{if(!ue(i)||!i.visible)return;s??=e.acquireTechnique(t,!1),n??=e.rctx.bindTechnique(s,t,r);const a=fe(i.regular.lod.lengths,i.distanceToCamera,o);e.renderRegularEdges(n,i,r,t,a)},i)}function he(e,t,r){let s,n;const i=r.transparency,o=t.camera.perScreenPixelRatio;e.forEachRenderable(i=>{if(!ge(i)||!i.visible)return;s??=e.acquireTechnique(t,!0),n??=e.rctx.bindTechnique(s,t,r);const a=fe(i.silhouette.lod.lengths,i.distanceToCamera,o);e.renderSilhouetteEdges(n,i,r,t,a)},i)}function ue(e){return null!=e.regular}class me extends ae{}function ge(e){return null!=e.silhouette}function fe(e,t,r){const n=t*r,i=s(e,n,!0);return-1===i?n<e[0]?e.length:0:e.length-i}class pe{constructor(e,t,r){this.position=e,this.modelTransform=t,this.origin=r}}const _e=f(),be=()=>Promise.reject();export{ee as EdgeView,oe as LegacyTransform,ce as RegularRenderable,ae as Renderable,me as SilhouetteRenderable};
|
|
5
|
+
import{__decorate as e}from"tslib";import t from"../../../../../core/Accessor.js";import{equals as r,binaryIndexOf as s}from"../../../../../core/arrayUtils.js";import"../../../../../core/has.js";import n from"../../../../../core/Logger.js";import{clamp as i}from"../../../../../core/mathUtils.js";import{disposeMaybe as o,destroyMaybe as a}from"../../../../../core/maybe.js";import{isAbortError as c,onAbortOrThrow as l}from"../../../../../core/promiseUtils.js";import{property as d}from"../../../../../core/accessorSupport/decorators/property.js";import{subclass as h}from"../../../../../core/accessorSupport/decorators/subclass.js";import{fromMat4 as u,transpose as m,invert as g}from"../../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as p}from"../../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{create as f}from"../../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{i as _,c as b,a as y,e as j}from"../../../../../chunks/vec32.js";import{create as w,clone as O}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{UpdatingHandles as E}from"../../../../../core/support/UpdatingHandles.js";import{a as x,g as v}from"../../../../../chunks/sphere.js";import{c as M}from"../../../../../chunks/vec33.js";import{encodeElevationOffset as R}from"../../collections/Component/Material/shader/ComponentData.glsl.js";import{TwoVectorPosition as T}from"../../core/util/TwoVectorPosition.js";import{Attribute as C}from"../Attribute.js";import{GridLocalOriginFactory as D}from"../GridLocalOriginFactory.js";import{applyToModelMatrix as P}from"../localOriginHelper.js";import{LocalOriginManager as A}from"../LocalOriginManager.js";import{Object3D as k}from"../Object3D.js";import{VertexArrayObject as U}from"../VertexArrayObject.js";import{VertexLayout as q,glVertexLayout as B,EdgeInputBufferLayout as H,RegularEdgeInstancesGLLayout as L,SilhouetteEdgeInstancesGLLayout as V}from"./bufferLayouts.js";import{EdgeRenderer as S,lineWidthFractionFactor as I,extensionLengthOffset as N}from"./EdgeRenderer.js";import{EdgePassParameters as z}from"./EdgeShaderParameters.js";import{EdgeWorkerHandle as F}from"./EdgeWorkerHandle.js";import{generateStrokesTexture as G}from"./strokes.js";import{determineRendererType as K,determineEdgeTransparency as W,determineObjectTransparency as J,fillComponentBufferIndices as Q}from"./util.js";import{BufferManager as X}from"../TextureBackedBuffer/BufferManager.js";import{VertexBuffer as Y}from"../../../../webgl/VertexBuffer.js";const Z=128;let $=class extends t{constructor(e){super(e),this._updatingHandles=new E,this._objectEntries=new Map,this._pendingDeletions=new Map,this._renderers=new Map,this._gpuMemoryUsage=0,this._workerAbort=new AbortController,this._tmpModelPosition=w(),this._localOrigins=new A(new D(e.renderSR));const t=q.createBuffer(4);for(let r=0;r<4;r++)t.sideness.set(r,0,0===r||3===r?0:1),t.sideness.set(r,1,0===r||1===r?0:1);this._vertexBuffer=new Y(e.rctx,B,t.buffer)}initialize(){this._workerHandle=new F(this.schedule),this._componentColorManager=new X(this.rctx,3)}destroy(){this.destroyed||(this._objectEntries.forEach(e=>this._discardObjectEntry(e)),this._objectEntries.clear(),this._pendingDeletions.forEach(e=>this._discardObjectEntry(e)),this._pendingDeletions.clear(),this._strokesTexture=o(this._strokesTexture),this._componentColorManager=a(this._componentColorManager),this._workerAbort.abort(),this._workerHandle.destroy(),this._vertexBuffer.dispose(),this._renderers.clear(),this._updatingHandles.destroy(),this._set("schedule",_e))}get updating(){return this._updatingHandles.updating}get usedMemory(){return this._gpuMemoryUsage}shouldRender(){return this._renderers.size>0}async addComponentObject(e,t,r,s,n,i,o){if(this.hasObject(e))return this._getObjectMemoryUsage(e);let a;const c=new re(null,new Promise(e=>a=e),e.obb.center,e.obb.radius);this._objectEntries.set(e,c);const l=await this._updatingHandles.addPromise(this._addComponentGeometry(e.transform,c,t,r,s,n,i,o));return this.setNeedsRender(),a(),l}async addOrUpdateObject3D(e,t,r,s){if(this.destroyed)return void n.getLogger(this).warn("Attempt to add an object to a destroyed instance");const i=new AbortController;let o;const a=e.boundingVolumeWorldSpace.bounds,l=new re(i,new Promise(e=>o=e),x(a),v(a)),d=this._objectEntries.get(e);d&&(this._pendingDeletions.has(e)?this._discardObjectEntry(d):this._pendingDeletions.set(e,d)),this._objectEntries.set(e,l);try{const n=new Array;if(e.geometries.length>1&&te(e))n.push(this._addObjectMergedGeometries(e,l,t,r,s));else for(const i of e.geometries)i.material.supportsEdges&&n.push(this._addGeometry(e,l,i,t,r,s));await this._updatingHandles.addPromise(Promise.all(n)),this._removePendingDeletion(e)}catch(h){c(h)?this._discardObjectEntry(l):this._removePendingDeletion(e)}finally{this.setNeedsRender(),o()}}removeObject(e){const t=this._objectEntries.get(e);this._objectEntries.delete(e),this._discardObjectEntry(t),this._removePendingDeletion(e)}_removePendingDeletion(e){const t=this._pendingDeletions.get(e);this._pendingDeletions.delete(e),this._discardObjectEntry(t)}async _getObjectEntry(e){const t=this._objectEntries.get(e);if(!t)throw new Error("no object");return await t.loaded,null==t.loaded?null:t}fastUpdateObject3DEdgesTransform(e){if(this.destroyed)return!1;const t=this._objectEntries.get(e);if(!t)return!1;const{geometries:r}=e,{renderables:s}=t;if(0===r.length||0===s.length)return!0;if(s.length>1)return!1;const[n]=s,i=n.transform;if(!(i instanceof ie))return!1;const[o]=r;if(o.localOrigin!==i.origin.origin)return!1;const a=f(),c=this._computeModelTransformWithLocalOrigin(e,o,a);return n.transform=new ie(a,c),this.setNeedsRender(),!0}_discardObjectEntry(e){e&&(e.abort?.abort(),e.renderables.length&&(e.renderables.forEach(e=>this._removeRenderable(e)),this.setNeedsRender()),e.loaded=null)}hasObject(e){return this._objectEntries.has(e)}async updateAllComponentOpacities(e,t){const r=await this._updatingHandles.addPromise(this._getObjectEntry(e));if(null==r)return;const s=Array.isArray(t)?e=>t[e]:()=>t;r.renderables.forEach(e=>{const t=e.components.meta.length;for(let r=0;r<t;r++){const t=s(r),n=e.components.meta[r],i=n.index;n.material.opacity=t,e.components.buffer.textureBuffer.setDataElement(i,1,3,255*t)}this._updateTransparency(e)}),this.setNeedsRender()}async _getObjectMemoryUsage(e){const t=await this._getObjectEntry(e);return t?t.renderables.reduce((e,t)=>e+t.statistics.gpuMemoryUsage,0):0}async updateAllComponentMaterials(e,t,r,s){const n=e instanceof k,i=K(t),o=S.getKey(i,r,n),a=await this._updatingHandles.addPromise(this._getObjectEntry(e));null!=a&&(a.renderables.forEach(e=>{if(o!==e.rendererKey){const t=this._renderers.get(e.rendererKey),s=this._acquireRenderer(i,r,n);t.removeRenderable(e),--t.refCount,e.rendererKey=o,s.addRenderable(e)}if(Array.isArray(t))for(let r=0;r<t.length;r++)e.components.meta[r].material=t[r];else e.components.meta[0].material=t;s&&ce(e.components),this._updateTransparency(e)}),this.setNeedsRender())}async updateAllVerticalOffsets(e,t){const r=await this._updatingHandles.addPromise(this._getObjectEntry(e));null!=r&&this._updateAllVerticalOffsets(r,t)}_updateAllVerticalOffsets(e,t){e.renderables.forEach(e=>{const r=e.components.meta;for(let s=0;s<r.length;s++)e.components.meta[s].verticalOffset=t?.[s]??0;ce(e.components)}),this.setNeedsRender()}async updateObjectVisibility(e,t){const r=await this._updatingHandles.addPromise(this._getObjectEntry(e));r&&(r.renderables.forEach(e=>e.visible=t),this.setNeedsRender())}render(e,t){if(null==this._componentColorManager)return;this._localOrigins.updateViewMatrices(e.camera.viewMatrix);const r=e.camera.viewInverseTransposeMatrix,s=w(),n=new T;let i=0,o=0;if(this._renderers.forEach(r=>{0!==r.refCount?(++this.techniques.precompiling,r.forEachRenderable(t=>{t.visible&&(i+=t.statistics.averageEdgeLength,o++,t.regular&&r.acquireTechnique(e,!1),t.silhouette&&r.acquireTechnique(e,!0))},t),--this.techniques.precompiling):this._renderers.delete(r.key)}),this._componentColorManager.garbageCollect(),this._componentColorManager.updateTextures(),0===o)return;const a=new z(40*i/o,t);_(s,r[3],r[7],r[11]),n.set(s),b(a.transformWorldFromViewTH,n.high),b(a.transformWorldFromViewTL,n.low),u(a.transformViewFromCameraRelativeRS,e.camera.viewMatrix),m(fe,a.transformViewFromCameraRelativeRS),g(a.transformNormalViewFromGlobal,fe),a.transformProjFromView=e.camera.projectionMatrix,this._updateObjectCameraDistances(e),this._renderers.forEach(t=>{le(t,e,a),de(t,e,a)})}_updateTransparency(e){const t=W(e.components.meta),r=J(e.components.meta);t===e.edgeTransparency&&r===e.objectTransparency||(e.edgeTransparency=t,e.objectTransparency=r,this._renderers.get(e.rendererKey).setRenderablesDirty())}_computeModelTransformWithLocalOrigin(e,t,r){e.getCombinedShaderTransformation(t,r);const s=null!=t.localOrigin?this._localOrigins.register(t.localOrigin):this._localOrigins.acquire(_(this._tmpModelPosition,r[12],r[13],r[14]));return t.localOrigin=s.origin,P(s.origin.vec3,r),s}_createComponentBuffers(e){if(null==this._componentColorManager)return null;const t=new Array,r=this._componentColorManager.getBuffer(e.length);for(let n=0;n<e.length;n++){const s=e[n],i=r.acquireIndex();t.push({index:i,verticalOffset:0,material:s})}const s=new se(r,t);return ce(s),s}_extractEdges(e,t,r,s,n,i,o=i.length){return o<Z&&(n=!0),this._workerHandle.process({data:r,indices:i,indicesLength:o,writerSettings:t,skipDeduplicate:s},e,n)}_createRenderable(e,t,r,s,n){const i=t=>new ne(new U(this.rctx,new Map([["vertices",this._vertexBuffer],["instances",0===t?new Y(this.rctx,L,e.regular.instancesData.buffer):new Y(this.rctx,V,e.silhouette.instancesData.buffer)]])),0===t?e.regular.lodInfo:e.silhouette.lodInfo),o=e.regular.lodInfo.lengths.length>0?i(0):null,a=e.silhouette.lodInfo.lengths.length>0?i(1):null,c=(o?.vao.cachedMemory??0)+(a?.vao.cachedMemory??0);return new oe(o,a,{gpuMemoryUsage:c,externalMemoryUsage:n,averageEdgeLength:e.averageEdgeLength},r,W(t.meta),J(t.meta),t,s)}async _addGeometry(e,t,r,s,n,i){if(r.edgeIndicesLength<=0)return;const o=r.attributes.get("position"),a=f(),c=this._computeModelTransformWithLocalOrigin(e,r,a),l=new pe(o,a,c);return this._addPositionData(t,l,r.edgeIndicesLength,s,n,i)}async _addPositionData(e,t,r,s,n,i=!1){if(null==e.loaded)return;const o=this._createComponentBuffers([s]);if(null==o)return;const a=this._acquireRenderer(s.type,n,!0),{modelTransform:c,origin:l}=t,d=t.position.indices,h=t.position,u=h.data.length/h.size,m=H.createBuffer(u);for(let f=0;f<u;f++)m.position.set(f,0,h.data[f*h.size]),m.position.set(f,1,h.data[f*h.size+1]),m.position.set(f,2,h.data[f*h.size+2]);Q(o.meta,[0,m.componentIndex.count],m.componentIndex);const g=await this._updatingHandles.addPromise(this._extractEdges(e.abort?.signal||this._workerAbort.signal,a.writerSettings,m,!1,i,d,r));if(null==e.loaded)return;const p=this._createRenderable(g,o,new ie(c,l),a.key,!1);e.renderables.push(p),a.addRenderable(p),this._gpuMemoryUsage+=p.statistics.gpuMemoryUsage}async _addComponentGeometry(e,t,r,s,n,i,o,a){if(null==t.loaded)return 0;const c=this._createComponentBuffers(i);if(null==c)return 0;const l=K(i),d=this._acquireRenderer(l,o||!1,!1),h=H.createBuffer(r.length/3);M(h.position.typedBuffer,r,h.position.typedBufferStride,3),Q(c.meta,n,h.componentIndex,s);const u=!0,m=d.writerSettings,g=await this._updatingHandles.addPromise(this._extractEdges(this._workerAbort.signal,m,h,u,!1,s));if(null==t.loaded)return 0;const p=this._createRenderable(g,c,e,d.key,!0);return t.renderables.push(p),d.addRenderable(p),this._updateAllVerticalOffsets(t,a),p.statistics.gpuMemoryUsage}async _addObjectMergedGeometries(e,t,r,s,n){const i=new Map;let o=0,a=0,c=null;const l=e.geometries.filter(e=>{if(e.edgeIndicesLength<=0||!e.material.supportsEdges)return!1;!c&&e.localOrigin&&(c=e);const t=e.attributes.get("position");return a+=t.data.length/t.size,o+=e.edgeIndicesLength,!0});if(0===l.length)return;const d=a>=65536?Uint32Array:Uint16Array,h=o?new d(o):null,u=[];let m=0;l.forEach(e=>{const t=e.attributes.get("position"),r=t.indices;let s=i.get(t.data);if(null==s){s=u.length/3;for(let e=0;e<t.data.length;e+=t.size)u.push(t.data[e]),u.push(t.data[e+1]),u.push(t.data[e+2]);i.set(t.data,s)}for(let n=0;n<e.edgeIndicesLength;n++)h[m++]=s+r[n]});const g=c||e.geometries[0],p=f(),_=this._computeModelTransformWithLocalOrigin(e,g,p);for(let f=0;f<e.geometries.length;f++)e.geometries[f].localOrigin=_.origin;const b=new pe(new C(u,h,3),p,_);await this._updatingHandles.addPromise(this._addPositionData(t,b,h.length,r,s,n))}_acquireRenderer(e,t,r){const s=S.getKey(e,t,r);let n=this._renderers.get(s);return null==this._strokesTexture&&(this._strokesTexture=G(this.rctx)),n||(n=new S(this.rctx,this.techniques,{type:e,hasSlicePlane:t,strokesTexture:this._strokesTexture,legacy:r,spherical:1===this.viewingMode}),this._renderers.set(s,n)),++n.refCount,n}_removeRenderable(e){ee(e.regular),ee(e.silhouette);const t=this._renderers.get(e.rendererKey);if(t){t.removeRenderable(e),--t.refCount,this._localOrigins.release(e.transform.origin),this._gpuMemoryUsage-=e.statistics.externalMemoryUsage?0:e.statistics.gpuMemoryUsage;for(const t of e.components.meta)e.components.buffer.releaseIndex(t.index)}}_updateObjectCameraDistances(e){const t=e.camera.eye,r=e.camera.viewForward,s=w(),n=e=>{y(s,e.center,t);const n=j(s,r),i=e.radius,o=n<-i?1/0:n<i?0:n-i;e.renderables.forEach(e=>e.distanceToCamera=o)};this._objectEntries.forEach(n),this._pendingDeletions.forEach(n)}get test(){}};function ee(e){e?.vao&&(e.vao.buffer("instances")?.dispose(),e.vao.disposeVAOOnly(),e.vao=null)}function te(e){let t=null,s=null;for(const n of e.geometries){if(n.material.supportsEdges){if(t){if(!r(t,n.transformation))return!1}else t=n.transformation;if(s||null==n.localOrigin){if(null!=s?.localOrigin&&null!=n.localOrigin&&s.localOrigin.id!==n.localOrigin.id)return!1}else s=n}}return!0}e([d({constructOnly:!0})],$.prototype,"rctx",void 0),e([d({constructOnly:!0})],$.prototype,"renderSR",void 0),e([d({constructOnly:!0})],$.prototype,"viewingMode",void 0),e([d({constructOnly:!0})],$.prototype,"techniques",void 0),e([d({constructOnly:!0})],$.prototype,"setNeedsRender",void 0),e([d({constructOnly:!0})],$.prototype,"schedule",void 0),e([d({readOnly:!0})],$.prototype,"_updatingHandles",void 0),e([d({readOnly:!0})],$.prototype,"updating",null),$=e([h("esri.views.3d.webgl-engine.lib.edgeRendering.EdgeView")],$);class re{constructor(e,t,r,s){this.abort=e,this.radius=s,this.renderables=new Array;const n=e?l(e.signal,()=>e.abort()):null;this.loaded=t,this.loaded.then(()=>{null!=this.loaded&&(this.loaded=!0),this.abort=null,n?.remove()}),this.center=O(r)}}class se{constructor(e,t){this.buffer=e,this.meta=t}}class ne{constructor(e,t){this.vao=e,this.lod=t}}class ie{constructor(e,t){this.modelMatrix=e,this.origin=t}}class oe{constructor(e,t,r,s,n,i,o,a){this.regular=e,this.silhouette=t,this.statistics=r,this.transform=s,this.edgeTransparency=n,this.objectTransparency=i,this.components=o,this.rendererKey=a,this.distanceToCamera=0,this.visible=!0}}class ae extends oe{}function ce(e){const{meta:t,buffer:r}=e,s=new Uint8Array(4);for(let n=0;n<t.length;n++){const e=t[n].material,o=t[n].index,a=i(Math.round(e.size*I),0,255),c=i(e.extensionLength,-N,255-N)+N,l=255*e.opacity,d=e.color,h=255*d[0],u=255*d[1],m=255*d[2],g=255*d[3];r.textureBuffer.setData(o,0,h,u,m,g),r.textureBuffer.setData(o,1,a,c,e.type,l),R(t[n].verticalOffset,s),r.textureBuffer.setData(o,2,s[0],s[1],s[2],s[3])}}function le(e,t,r){let s,n;const i=r.transparency,o=t.camera.perScreenPixelRatio;e.forEachRenderable(i=>{if(!he(i)||!i.visible)return;s??=e.acquireTechnique(t,!1),n??=e.rctx.bindTechnique(s,t,r);const a=ge(i.regular.lod.lengths,i.distanceToCamera,o);e.renderRegularEdges(n,i,r,t,a)},i)}function de(e,t,r){let s,n;const i=r.transparency,o=t.camera.perScreenPixelRatio;e.forEachRenderable(i=>{if(!me(i)||!i.visible)return;s??=e.acquireTechnique(t,!0),n??=e.rctx.bindTechnique(s,t,r);const a=ge(i.silhouette.lod.lengths,i.distanceToCamera,o);e.renderSilhouetteEdges(n,i,r,t,a)},i)}function he(e){return null!=e.regular}class ue extends oe{}function me(e){return null!=e.silhouette}function ge(e,t,r){const n=t*r,i=s(e,n,!0);return-1===i?n<e[0]?e.length:0:e.length-i}class pe{constructor(e,t,r){this.position=e,this.modelTransform=t,this.origin=r}}const fe=p(),_e=()=>Promise.reject();export{$ as EdgeView,ie as LegacyTransform,ae as RegularRenderable,oe as Renderable,ue as SilhouetteRenderable};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{glLayout as e}from"../../../support/buffer/glUtil.js";import{newLayout as o}from"../../../support/buffer/InterleavedLayout.js";import{fromLayouts as r}from"../../../../webgl/VertexAttributeLocations.js";const t=o().vec3f("position").u16("componentIndex").freeze(),i=o().vec2u8("sideness").freeze(),n=e(i),s=o().vec3f("position0").vec3f("position1").vec2i16("normalCompressed").u16("componentIndex").u8("variantOffset",{glNormalized:!0}).u8("variantStroke").u8("variantExtension",{glNormalized:!0}).freeze(),a=o().vec3f("position0").vec3f("position1").vec2i16("normalCompressed").vec2i16("normal2Compressed").u16("componentIndex").u8("variantOffset",{glNormalized:!0}).u8("variantStroke").u8("variantExtension",{glNormalized:!0}).freeze(),f=r([n,
|
|
5
|
+
import{glLayout as e}from"../../../support/buffer/glUtil.js";import{newLayout as o}from"../../../support/buffer/InterleavedLayout.js";import{fromLayouts as r}from"../../../../webgl/VertexAttributeLocations.js";const t=o().vec3f("position").u16("componentIndex").freeze(),i=o().vec2u8("sideness").freeze(),n=e(i),s=o().vec3f("position0").vec3f("position1").vec2i16("normalCompressed").u16("componentIndex").u8("variantOffset",{glNormalized:!0}).u8("variantStroke").u8("variantExtension",{glNormalized:!0}).freeze(),a=o().vec3f("position0").vec3f("position1").vec2i16("normalCompressed").vec2i16("normal2Compressed").u16("componentIndex").u8("variantOffset",{glNormalized:!0}).u8("variantStroke").u8("variantExtension",{glNormalized:!0}).freeze(),f=e(s,1),m=e(a,1),p=r([n,f]),u=r([n,m]);export{t as EdgeInputBufferLayout,f as RegularEdgeInstancesGLLayout,s as RegularEdgeInstancesLayout,p as RegularEdgeLocations,m as SilhouetteEdgeInstancesGLLayout,a as SilhouetteEdgeInstancesLayout,u as SilhouetteEdgeLocations,i as VertexLayout,n as glVertexLayout};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import t from"../../../../../core/RandomLCG.js";import{f as
|
|
5
|
+
import t from"../../../../../core/RandomLCG.js";import{f as e,n as o}from"../../../../../chunks/vec32.js";import{create as n}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{compressNormal as r}from"../Normals.js";import{RegularEdgeInstancesLayout as i,SilhouetteEdgeInstancesLayout as s}from"./bufferLayouts.js";const a=.7;class c{updateSettings(t){this.settings=t,this._edgeHashFunction=t.reducedPrecision?d:u}write(t,e,o){S.seed=this._edgeHashFunction(o);const n=S.getIntRange(0,255),r=S.getIntRange(0,this.settings.variants-1),i=S.getFloat(),s=255*(.5*g(-(1-Math.min(i/a,1))+Math.max(0,i-a)/(1-a),1.2)+.5);t.position0.setVec(e,o.position0),t.position1.setVec(e,o.position1),t.componentIndex.set(e,o.componentIndex),t.variantOffset.set(e,n),t.variantStroke.set(e,r),t.variantExtension.set(e,s)}}const f=new Float32Array(6),m=new Uint32Array(f.buffer),p=new Uint32Array(1);function u(t){return f[0]=t.position0[0],f[1]=t.position0[1],f[2]=t.position0[2],f[3]=t.position1[0],f[4]=t.position1[1],f[5]=t.position1[2],p[0]=31*(31*(31*(31*(31*(166811+m[0])+m[1])+m[2])+m[3])+m[4])+m[5],p[0]}function d(t){const e=f;e[0]=h(t.position0[0]),e[1]=h(t.position0[1]),e[2]=h(t.position0[2]),e[3]=h(t.position1[0]),e[4]=h(t.position1[1]),e[5]=h(t.position1[2]),p[0]=5381;for(let o=0;o<m.length;o++)p[0]=31*p[0]+m[o];return p[0]}const l=1e4;function h(t){return Math.round(t*l)/l}function g(t,e){return Math.abs(t)**e*Math.sign(t)}class w{constructor(){this._commonWriter=new c}updateSettings(t){this._commonWriter.updateSettings(t)}allocate(t){return i.createBuffer(t)}write(t,n,i){this._commonWriter.write(t,n,i),e(N,i.faceNormal0,i.faceNormal1),o(N,N);const{typedBuffer:s,typedBufferStride:a}=t.normalCompressed;r(s,n,N[0],N[1],N[2],a)}}class y{constructor(){this._commonWriter=new c}updateSettings(t){this._commonWriter.updateSettings(t)}allocate(t){return s.createBuffer(t)}write(t,e,o){this._commonWriter.write(t,e,o);{const{typedBuffer:n,typedBufferStride:i}=t.normalCompressed;r(n,e,o.faceNormal0[0],o.faceNormal0[1],o.faceNormal0[2],i)}{const{typedBuffer:n,typedBufferStride:i}=t.normal2Compressed;r(n,e,o.faceNormal1[0],o.faceNormal1[1],o.faceNormal1[2],i)}}}const N=n(),S=new t;export{w as RegularEdgeBufferWriter,y as SilhouetteEdgeBufferWriter};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{hasNativeFloat16Array as r,makeFloat16Array as e}from"../../../../geometry/support/float16.js";import{Pos2TexF16 as t,Pos2TexF32 as o,Pos2 as
|
|
5
|
+
import{hasNativeFloat16Array as r,makeFloat16Array as e}from"../../../../geometry/support/float16.js";import{Pos2TexF16 as t,Pos2TexF32 as o,Pos2 as n}from"./DefaultVertexBufferLayouts.js";import{VertexArrayObject as f}from"./VertexArrayObject.js";import{Texture as s}from"../../../webgl/Texture.js";import{TextureDescriptor as m}from"../../../webgl/TextureDescriptor.js";import{VertexBuffer as u}from"../../../webgl/VertexBuffer.js";function a(s,m=0,a=-1,i=1){const p=1===m,w=p?r?new Float32Array([a,a,0,i,a,0,a,i,0,i,i,0]):new Float32Array([a,a,0,0,i,a,1,0,a,i,0,1,i,i,1,1]):new Float32Array([a,a,i,a,a,i,i,i]);if(p&&r){const r=e(w.buffer);r[10]=r[17]=r[22]=r[23]=1}return new f(s,new u(s,p?r?t:o:n,w))}const i=4;function p(r){const e=new m(i);return e.samplingMode=9728,new s(r,e)}export{p as createEmptyTexture,a as createQuadVAO};
|