bimland/public/Cesium/Workers/createVectorTilePolygons.js

2 lines
5.1 KiB
JavaScript
Raw Normal View History

2023-07-26 17:04:38 +08:00
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,