Agriculture-front-end/public/Cesium/Workers/createVectorTilePolygons.js
2023-04-16 22:33:44 +08:00

2 lines
5.1 KiB
JavaScript

define(["./AttributeCompression-90851096","./Cartographic-3309dd0d","./Color-5008547b","./when-b60132fc","./Cartesian2-47311507","./IndexDatatype-8a5eead4","./Math-119be1a3","./OrientedBoundingBox-87d59c2a","./createTaskProcessorWorker","./Check-7b2a090c","./FeatureDetection-c3b71206","./WebGLConstants-4ae0db90","./buildModuleUrl-4e1b81e7","./PrimitiveType-a54dc62f","./Cartesian4-3ca25aab","./RuntimeError-4a5c8994","./Event-16a2dfbf","./EllipsoidTangentPlane-edb321d3","./IntersectionTests-7386ffbf","./Plane-7ae8294c","./GeometryAttribute-3a88ba31","./PolygonPipeline-660e1625","./earcut-2.2.1-20c8012f","./ComponentDatatype-c140a87d","./EllipsoidRhumbLine-ed1a6bf4"],(function(e,a,r,n,t,i,o,s,d,f,c,u,l,h,p,b,g,y,C,m,v,I,w,x,A){"use strict";var E=new a.Cartesian3,N=new t.Ellipsoid,T=new t.Rectangle,k={min:void 0,max:void 0,indexBytesPerElement:void 0};function B(e,a,n){var t=a.length,i=2+t*s.OrientedBoundingBox.packedLength+1+function(e){for(var a=e.length,n=0,t=0;t<a;++t)n+=r.Color.packedLength+3+e[t].batchIds.length;return n}(n),o=new Float64Array(i),d=0;o[d++]=e,o[d++]=t;for(var f=0;f<t;++f)s.OrientedBoundingBox.pack(a[f],o,d),d+=s.OrientedBoundingBox.packedLength;var c=n.length;o[d++]=c;for(var u=0;u<c;++u){var l=n[u];r.Color.pack(l.color,o,d),d+=r.Color.packedLength,o[d++]=l.offset,o[d++]=l.count;var h=l.batchIds,p=h.length;o[d++]=p;for(var b=0;b<p;++b)o[d++]=h[b]}return o}var L=new a.Cartesian3,O=new a.Cartesian3,P=new a.Cartesian3,U=new a.Cartesian3,F=new a.Cartesian3,D=new a.Cartographic,R=new t.Rectangle;return d((function(d,f){var c;!function(e){var r=new Float64Array(e),n=0;k.indexBytesPerElement=r[n++],k.min=r[n++],k.max=r[n++],a.Cartesian3.unpack(r,n,E),n+=a.Cartesian3.packedLength,t.Ellipsoid.unpack(r,n,N),n+=t.Ellipsoid.packedLength,t.Rectangle.unpack(r,n,T)}(d.packedBuffer),c=2===k.indexBytesPerElement?new Uint16Array(d.indices):new Uint32Array(d.indices);var u,l,h,p=new Uint16Array(d.positions),b=new Uint32Array(d.counts),g=new Uint32Array(d.indexCounts),y=new Uint32Array(d.batchIds),C=new Uint32Array(d.batchTableColors),m=new Array(b.length),v=E,I=N,w=T,x=k.min,A=k.max,S=d.minimumHeights,M=d.maximumHeights;n.defined(S)&&n.defined(M)&&(S=new Float32Array(S),M=new Float32Array(M));var _=p.length/2,G=p.subarray(0,_),Y=p.subarray(_,2*_);e.AttributeCompression.zigZagDeltaDecode(G,Y);var V=new Float32Array(3*_);for(u=0;u<_;++u){var H=G[u],W=Y[u],z=o.CesiumMath.lerp(w.west,w.east,H/32767),Z=o.CesiumMath.lerp(w.south,w.north,W/32767),j=a.Cartographic.fromRadians(z,Z,0,D),q=I.cartographicToCartesian(j,L);a.Cartesian3.pack(q,V,3*u)}var J=b.length,K=new Array(J),Q=new Array(J),X=0,$=0;for(u=0;u<J;++u)K[u]=X,Q[u]=$,X+=b[u],$+=g[u];var ee,ae=new Float32Array(3*_*2),re=new Uint16Array(2*_),ne=new Uint32Array(Q.length),te=new Uint32Array(g.length),ie=[],oe={};for(u=0;u<J;++u)h=C[u],n.defined(oe[h])?(oe[h].positionLength+=b[u],oe[h].indexLength+=g[u],oe[h].batchIds.push(u)):oe[h]={positionLength:b[u],indexLength:g[u],offset:0,indexOffset:0,batchIds:[u]};var se=0,de=0;for(h in oe)if(oe.hasOwnProperty(h)){(ee=oe[h]).offset=se,ee.indexOffset=de;var fe=2*ee.positionLength,ce=2*ee.indexLength+6*ee.positionLength;se+=fe,de+=ce,ee.indexLength=ce}var ue=[];for(h in oe)oe.hasOwnProperty(h)&&(ee=oe[h],ue.push({color:r.Color.fromRgba(parseInt(h)),offset:ee.indexOffset,count:ee.indexLength,batchIds:ee.batchIds}));for(u=0;u<J;++u){var le=(ee=oe[h=C[u]]).offset,he=3*le,pe=le,be=K[u],ge=b[u],ye=y[u],Ce=x,me=A;n.defined(S)&&n.defined(M)&&(Ce=S[u],me=M[u]);var ve=Number.POSITIVE_INFINITY,Ie=Number.NEGATIVE_INFINITY,we=Number.POSITIVE_INFINITY,xe=Number.NEGATIVE_INFINITY;for(l=0;l<ge;++l){var Ae=a.Cartesian3.unpack(V,3*be+3*l,L);I.scaleToGeodeticSurface(Ae,Ae);var Ee=I.cartesianToCartographic(Ae,D),Ne=Ee.latitude,Te=Ee.longitude;ve=Math.min(Ne,ve),Ie=Math.max(Ne,Ie),we=Math.min(Te,we),xe=Math.max(Te,xe);var ke=I.geodeticSurfaceNormal(Ae,O),Be=a.Cartesian3.multiplyByScalar(ke,Ce,P),Le=a.Cartesian3.add(Ae,Be,U);Be=a.Cartesian3.multiplyByScalar(ke,me,Be);var Oe=a.Cartesian3.add(Ae,Be,F);a.Cartesian3.subtract(Oe,v,Oe),a.Cartesian3.subtract(Le,v,Le),a.Cartesian3.pack(Oe,ae,he),a.Cartesian3.pack(Le,ae,he+3),re[pe]=ye,re[pe+1]=ye,he+=6,pe+=2}(w=R).west=we,w.east=xe,w.south=ve,w.north=Ie,m[u]=s.OrientedBoundingBox.fromRectangle(w,x,A,I);var Pe=ee.indexOffset,Ue=Q[u],Fe=g[u];for(ne[u]=Pe,l=0;l<Fe;l+=3){var De=c[Ue+l]-be,Re=c[Ue+l+1]-be,Se=c[Ue+l+2]-be;ie[Pe++]=2*De+le,ie[Pe++]=2*Re+le,ie[Pe++]=2*Se+le,ie[Pe++]=2*Se+1+le,ie[Pe++]=2*Re+1+le,ie[Pe++]=2*De+1+le}for(l=0;l<ge;++l){var Me=l,_e=(l+1)%ge;ie[Pe++]=2*Me+1+le,ie[Pe++]=2*_e+le,ie[Pe++]=2*Me+le,ie[Pe++]=2*Me+1+le,ie[Pe++]=2*_e+1+le,ie[Pe++]=2*_e+le}ee.offset+=2*ge,ee.indexOffset=Pe,te[u]=Pe-ne[u]}ie=i.IndexDatatype.createTypedArray(ae.length/3,ie);for(var Ge=ue.length,Ye=0;Ye<Ge;++Ye){for(var Ve=ue[Ye].batchIds,He=0,We=Ve.length,ze=0;ze<We;++ze)He+=te[Ve[ze]];ue[Ye].count=He}var Ze=B(2===ie.BYTES_PER_ELEMENT?i.IndexDatatype.UNSIGNED_SHORT:i.IndexDatatype.UNSIGNED_INT,m,ue);return f.push(ae.buffer,ie.buffer,ne.buffer,te.buffer,re.buffer,Ze.buffer),{positions:ae.buffer,indices:ie.buffer,indexOffsets:ne.buffer,indexCounts:te.buffer,batchIds:re.buffer,packedBuffer:Ze.buffer}}))}));