suerprisePlus
2024-12-17 5dfcbd19cd041e1f8a5fb7ed9ab694bf4de00352
1
define(["./AxisAlignedBoundingBox-817cca2a","./Matrix2-69530458","./Matrix3-f420af38","./defaultValue-f6d5e6da","./TerrainEncoding-4be601fb","./IndexDatatype-a9b1bc18","./Math-355606c6","./Transforms-ef48b970","./WebMercatorProjection-32cda14d","./createTaskProcessorWorker","./RuntimeError-9b4ce3fb","./AttributeCompression-913aafb2","./ComponentDatatype-ab629b88","./WebGLConstants-7f557f93","./combine-0c102d93"],(function(t,e,r,n,o,i,a,s,c,h,l,u,d,I,g){"use strict";function m(){s.DeveloperError.throwInstantiationError()}Object.defineProperties(m.prototype,{errorEvent:{get:s.DeveloperError.throwInstantiationError},credit:{get:s.DeveloperError.throwInstantiationError},tilingScheme:{get:s.DeveloperError.throwInstantiationError},ready:{get:s.DeveloperError.throwInstantiationError},readyPromise:{get:s.DeveloperError.throwInstantiationError},hasWaterMask:{get:s.DeveloperError.throwInstantiationError},hasVertexNormals:{get:s.DeveloperError.throwInstantiationError},availability:{get:s.DeveloperError.throwInstantiationError}});const f=[];m.getRegularGridIndices=function(t,e){let r=f[t];n.defined(r)||(f[t]=r=[]);let o=r[e];return n.defined(o)||(o=t*e<a.CesiumMath.SIXTY_FOUR_KILOBYTES?r[e]=new Uint16Array((t-1)*(e-1)*6):r[e]=new Uint32Array((t-1)*(e-1)*6),E(t,e,o,0)),o};const y=[];m.getRegularGridIndicesAndEdgeIndices=function(t,e){let r=y[t];n.defined(r)||(y[t]=r=[]);let o=r[e];if(!n.defined(o)){const n=m.getRegularGridIndices(t,e),i=p(t,e),a=i.westIndicesSouthToNorth,s=i.southIndicesEastToWest,c=i.eastIndicesNorthToSouth,h=i.northIndicesWestToEast;o=r[e]={indices:n,westIndicesSouthToNorth:a,southIndicesEastToWest:s,eastIndicesNorthToSouth:c,northIndicesWestToEast:h}}return o};const T=[];function p(t,e){const r=new Array(e),n=new Array(t),o=new Array(e),i=new Array(t);let a;for(a=0;a<t;++a)i[a]=a,n[a]=t*e-1-a;for(a=0;a<e;++a)o[a]=(a+1)*t-1,r[a]=(e-a-1)*t;return{westIndicesSouthToNorth:r,southIndicesEastToWest:n,eastIndicesNorthToSouth:o,northIndicesWestToEast:i}}function E(t,e,r,n){let o=0;for(let i=0;i<e-1;++i){for(let e=0;e<t-1;++e){const e=o,i=e+t,a=i+1,s=e+1;r[n++]=e,r[n++]=i,r[n++]=s,r[n++]=s,r[n++]=i,r[n++]=a,++o}++o}}function x(t,e,r,n){let o=t[0];const i=t.length;for(let a=1;a<i;++a){const i=t[a];r[n++]=o,r[n++]=i,r[n++]=e,r[n++]=e,r[n++]=i,r[n++]=e+1,o=i,++e}return n}m.getRegularGridAndSkirtIndicesAndEdgeIndices=function(t,e){let r=T[t];n.defined(r)||(T[t]=r=[]);let o=r[e];if(!n.defined(o)){const n=t*e,a=(t-1)*(e-1)*6,s=2*t+2*e,c=n+s,h=a+6*Math.max(0,s-4),l=p(t,e),u=l.westIndicesSouthToNorth,d=l.southIndicesEastToWest,I=l.eastIndicesNorthToSouth,g=l.northIndicesWestToEast,f=i.IndexDatatype.createTypedArray(c,h);E(t,e,f,0),m.addSkirtIndices(u,d,I,g,n,f,a),o=r[e]={indices:f,westIndicesSouthToNorth:u,southIndicesEastToWest:d,eastIndicesNorthToSouth:I,northIndicesWestToEast:g,indexCountWithoutSkirts:a}}return o},m.addSkirtIndices=function(t,e,r,n,o,i,a){let s=o;a=x(t,s,i,a),s+=t.length,a=x(e,s,i,a),s+=e.length,a=x(r,s,i,a),s+=r.length,x(n,s,i,a)},m.heightmapTerrainQuality=.25,m.getEstimatedLevelZeroGeometricErrorForAHeightmap=function(t,e,r){return 2*t.maximumRadius*Math.PI*m.heightmapTerrainQuality/(e*r)},m.prototype.requestTileGeometry=s.DeveloperError.throwInstantiationError,m.prototype.getLevelMaximumGeometricError=s.DeveloperError.throwInstantiationError,m.prototype.getTileDataAvailable=s.DeveloperError.throwInstantiationError,m.prototype.loadTileDataAvailability=s.DeveloperError.throwInstantiationError;const N=32767,w=new r.Cartesian3,M=new r.Cartesian3,S=new r.Cartesian3,b=new r.Cartographic,A=new e.Cartesian2,C=new r.Cartographic,W=[],v=[];function P(t,e){let r,n,o,i,a=0;const s=e.length;for(o=e[0],r=1;r<=s;r++)i=e[r%s],t[0]>Math.min(o[0],i[0])&&t[0]<=Math.max(o[0],i[0])&&t[1]<=Math.max(o[1],i[1])&&o[0]!==i[0]&&(n=(t[0]-o[0])*(i[1]-o[1])/(i[0]-o[0])+o[1],(o[1]===i[1]||t[1]<=n)&&a++),o=i;return a%2!=0}function k(t,e,r,n){const o=(t.x-r.x)*(e.y-r.y)-(t.y-r.y)*(e.x-r.x),i=(t.x-n.x)*(e.y-n.y)-(t.y-n.y)*(e.x-n.x);if(o*i>=0)return!1;const a=(r.x-t.x)*(n.y-t.y)-(r.y-t.y)*(n.x-t.x);if(a*(a+o-i)>=0)return!1;const s=a/(i-o),c=s*(e.x-t.x),h=s*(e.y-t.y);return{x:t.x+c,y:t.y+h}}function D(t,n,o,i,s,c,h,l,u){let d=Number.POSITIVE_INFINITY;const I=s.north,g=s.south;let m=s.east;const f=s.west;m<f&&(m+=a.CesiumMath.TWO_PI);const y=t.length;for(let s=0;s<y;++s){const y=t[s],T=o[y],p=i[y];b.longitude=a.CesiumMath.lerp(f,m,p.x),b.latitude=a.CesiumMath.lerp(g,I,p.y),b.height=T-n;const E=c.cartographicToCartesian(b,w);e.Matrix4.multiplyByPoint(h,E,E),r.Cartesian3.minimumByComponent(E,l,l),r.Cartesian3.maximumByComponent(E,u,u),d=Math.min(d,b.height)}return d}function F(t,e,r,o,i,s,h,l,u,d,I,g,m,f){const y=n.defined(h),T=u.north,p=u.south;let E=u.east;const x=u.west;E<x&&(E+=a.CesiumMath.TWO_PI);const N=r.length;for(let n=0;n<N;++n){const u=r[n],N=i[u],M=s[u];b.longitude=a.CesiumMath.lerp(x,E,M.x)+m,b.latitude=a.CesiumMath.lerp(p,T,M.y)+f,b.height=N-d;const S=l.cartographicToCartesian(b,w);if(y){const t=2*u;A.x=h[t],A.y=h[t+1]}let C,W;o.hasWebMercatorT&&(C=(c.WebMercatorProjection.geodeticLatitudeToMercatorAngle(b.latitude)-I)*g),o.hasGeodeticSurfaceNormals&&(W=l.geodeticSurfaceNormal(S)),e=o.encode(t,e,S,M,b.height,A,C,W,1)}}function H(t,e){let r;return"function"==typeof t.slice&&(r=t.slice(),"function"!=typeof r.sort&&(r=void 0)),n.defined(r)||(r=Array.prototype.slice.call(t)),r.sort(e),r}return h((function(h,l){const u=h.flattenPolygonHeight||[1],d=h.flattenPolygon||[];let I=-65565;const g=h.quantizedVertices,f=g.length/3,y=h.octEncodedNormals,T=h.westIndices.length+h.eastIndices.length+h.southIndices.length+h.northIndices.length,p=h.includeWebMercatorT,E=h.exaggeration,x=h.exaggerationRelativeHeight,_=1!==E,G=e.Rectangle.clone(h.rectangle),V=G.west,Y=G.south,O=G.east,B=G.north;W.length=0,v.length=0;let R=!1;const L=[[V,Y],[O,Y],[O,B],[V,B]];for(let t=0;t<u.length;t++)if(1!==u[t]){R=!1;for(let r=0;r<d[t].length;r++){const n=d[t][r];C.longitude=n[0],C.latitude=n[1],C.height=0;if(e.Rectangle.contains(G,C)){W.push(u[t]),v.push(d[t]),R=!0;break}}if(!R)for(let e=0;e<L.length;e++){if(P(L[e],d[t])){W.push(u[t]),v.push(d[t]),R=!0;break}}if(!R)for(let e=0;e<d[t].length-1;e++){for(let r=0;r<L.length-1;r++){if(k({x:L[r][0],y:L[r][1]},{x:L[r+1][0],y:L[r+1][1]},{x:d[t][e][0],y:d[t][e][1]},{x:d[t][e+1][0],y:d[t][e+1][1]})){W.push(u[t]),v.push(d[t]),R=!0;break}}if(R)break}}const j=r.Ellipsoid.clone(h.ellipsoid),U=h.minimumHeight;let z=h.maximumHeight;const q=h.relativeToCenter,Q=s.Transforms.eastNorthUpToFixedFrame(q,j),K=e.Matrix4.inverseTransformation(Q,new e.Matrix4);let X,Z;p&&(X=c.WebMercatorProjection.geodeticLatitudeToMercatorAngle(Y),Z=1/(c.WebMercatorProjection.geodeticLatitudeToMercatorAngle(B)-X));const J=g.subarray(0,f),$=g.subarray(f,2*f),tt=g.subarray(2*f,3*f),et=n.defined(y),rt=new Array(f),nt=new Array(f),ot=new Array(f),it=p?new Array(f):[],at=_?new Array(f):[],st=M;st.x=Number.POSITIVE_INFINITY,st.y=Number.POSITIVE_INFINITY,st.z=Number.POSITIVE_INFINITY;const ct=S;ct.x=Number.NEGATIVE_INFINITY,ct.y=Number.NEGATIVE_INFINITY,ct.z=Number.NEGATIVE_INFINITY;let ht=Number.POSITIVE_INFINITY,lt=Number.NEGATIVE_INFINITY,ut=Number.POSITIVE_INFINITY,dt=Number.NEGATIVE_INFINITY;for(let t=0;t<f;++t){const n=J[t],o=$[t],i=n/N,s=o/N;let h=a.CesiumMath.lerp(U,z,tt[t]/N);b.longitude=a.CesiumMath.lerp(V,O,i),b.latitude=a.CesiumMath.lerp(Y,B,s),b.height=h;for(let t=0;t<W.length;t++)if(1!==W[t]){P([b.longitude,b.latitude],v[t])&&(b.height=h=u[t],I=Math.max(I,u[t]))}ht=Math.min(b.longitude,ht),lt=Math.max(b.longitude,lt),ut=Math.min(b.latitude,ut),dt=Math.max(b.latitude,dt);const l=j.cartographicToCartesian(b);rt[t]=new e.Cartesian2(i,s),nt[t]=h,ot[t]=l,p&&(it[t]=(c.WebMercatorProjection.geodeticLatitudeToMercatorAngle(b.latitude)-X)*Z),_&&(at[t]=j.geodeticSurfaceNormal(l)),e.Matrix4.multiplyByPoint(K,l,w),r.Cartesian3.minimumByComponent(w,st,st),r.Cartesian3.maximumByComponent(w,ct,ct)}-65565!==I&&(z=1.2*I);const It=H(h.westIndices,(function(t,e){return rt[t].y-rt[e].y})),gt=H(h.eastIndices,(function(t,e){return rt[e].y-rt[t].y})),mt=H(h.southIndices,(function(t,e){return rt[e].x-rt[t].x})),ft=H(h.northIndices,(function(t,e){return rt[t].x-rt[e].x}));let yt;if(U<0){yt=new o.EllipsoidalOccluder(j).computeHorizonCullingPointPossiblyUnderEllipsoid(q,ot,U)}let Tt=U;Tt=Math.min(Tt,D(h.westIndices,h.westSkirtHeight,nt,rt,G,j,K,st,ct)),Tt=Math.min(Tt,D(h.southIndices,h.southSkirtHeight,nt,rt,G,j,K,st,ct)),Tt=Math.min(Tt,D(h.eastIndices,h.eastSkirtHeight,nt,rt,G,j,K,st,ct)),Tt=Math.min(Tt,D(h.northIndices,h.northSkirtHeight,nt,rt,G,j,K,st,ct));const pt=new t.AxisAlignedBoundingBox(st,ct,q),Et=new o.TerrainEncoding(q,pt,Tt,z,Q,et,p,_,E,x),xt=Et.stride,Nt=new Float32Array(f*xt+T*xt);let wt=0;for(let t=0;t<f;++t){if(et){const e=2*t;A.x=y[e],A.y=y[e+1]}wt=Et.encode(Nt,wt,ot[t],rt[t],nt[t],A,it[t],at[t],0)}const Mt=Math.max(0,2*(T-4)),St=h.indices.length+3*Mt,bt=i.IndexDatatype.createTypedArray(f+T,St);bt.set(h.indices,0);const At=1e-4,Ct=(lt-ht)*At,Wt=(dt-ut)*At,vt=-Ct,Pt=Ct,kt=Wt,Dt=-Wt;let Ft=f*xt;return F(Nt,Ft,It,Et,nt,rt,y,j,G,h.westSkirtHeight,X,Z,vt,0),Ft+=h.westIndices.length*xt,F(Nt,Ft,mt,Et,nt,rt,y,j,G,h.southSkirtHeight,X,Z,0,Dt),Ft+=h.southIndices.length*xt,F(Nt,Ft,gt,Et,nt,rt,y,j,G,h.eastSkirtHeight,X,Z,Pt,0),Ft+=h.eastIndices.length*xt,F(Nt,Ft,ft,Et,nt,rt,y,j,G,h.northSkirtHeight,X,Z,0,kt),m.addSkirtIndices(It,mt,gt,ft,f,bt,h.indices.length),l.push(Nt.buffer,bt.buffer),{vertices:Nt.buffer,indices:bt.buffer,westIndicesSouthToNorth:It,southIndicesEastToWest:mt,eastIndicesNorthToSouth:gt,northIndicesWestToEast:ft,vertexStride:xt,center:q,minimumHeight:U,maximumHeight:z,occludeePointInScaledSpace:yt,encoding:Et,indexCountWithoutSkirts:h.indices.length}}))}));