define(["./AttributeCompression-af389d04","./Matrix2-9aa31791","./Color-1ab5c5c7","./when-4bbc8319","./IndexDatatype-b7d979a6","./ComponentDatatype-93750d1a","./OrientedBoundingBox-4b932f63","./createTaskProcessorWorker","./RuntimeError-346a3079","./Transforms-d13cc04e","./combine-83860057","./WebGLConstants-1c8239cc","./EllipsoidTangentPlane-eecce7e8","./AxisAlignedBoundingBox-07c6b7f2","./IntersectionTests-96a04219","./Plane-318d6937"],(function(e,a,n,r,t,i,o,s,f,d,c,u,h,l,g,p){"use strict";var b=new a.Cartesian3,m=new a.Ellipsoid,y=new a.Rectangle,C={min:void 0,max:void 0,indexBytesPerElement:void 0},I=new a.Cartesian3,v=new a.Cartesian3,w=new a.Cartesian3,x=new a.Cartesian3,A=new a.Cartesian3,E=new a.Cartographic,N=new a.Rectangle;return s((function(s,f){var d;!function(e){var n=new Float64Array(e),r=0;C.indexBytesPerElement=n[r++],C.min=n[r++],C.max=n[r++],a.Cartesian3.unpack(n,r,b),r+=a.Cartesian3.packedLength,a.Ellipsoid.unpack(n,r,m),r+=a.Ellipsoid.packedLength,a.Rectangle.unpack(n,r,y)}(s.packedBuffer),d=2===C.indexBytesPerElement?new Uint16Array(s.indices):new Uint32Array(s.indices);var c,u,h,l=new Uint16Array(s.positions),g=new Uint32Array(s.counts),p=new Uint32Array(s.indexCounts),T=new Uint32Array(s.batchIds),B=new Uint32Array(s.batchTableColors),k=new Array(g.length),L=b,O=m,U=y,P=C.min,F=C.max,S=s.minimumHeights,D=s.maximumHeights;r.defined(S)&&r.defined(D)&&(S=new Float32Array(S),D=new Float32Array(D));var R=l.length/2,M=l.subarray(0,R),_=l.subarray(R,2*R);e.AttributeCompression.zigZagDeltaDecode(M,_);var G=new Float64Array(3*R);for(c=0;c<R;++c){var Y=M[c],V=_[c],H=i.CesiumMath.lerp(U.west,U.east,Y/32767),W=i.CesiumMath.lerp(U.south,U.north,V/32767),z=a.Cartographic.fromRadians(H,W,0,E),Z=O.cartographicToCartesian(z,I);a.Cartesian3.pack(Z,G,3*c)}var j=g.length,q=new Array(j),J=new Array(j),K=0,Q=0;for(c=0;c<j;++c)q[c]=K,J[c]=Q,K+=g[c],Q+=p[c];var X,$=new Float32Array(3*R*2),ee=new Uint16Array(2*R),ae=new Uint32Array(J.length),ne=new Uint32Array(p.length),re=[],te={};for(c=0;c<j;++c)h=B[c],r.defined(te[h])?(te[h].positionLength+=g[c],te[h].indexLength+=p[c],te[h].batchIds.push(c)):te[h]={positionLength:g[c],indexLength:p[c],offset:0,indexOffset:0,batchIds:[c]};var ie=0,oe=0;for(h in te)if(te.hasOwnProperty(h)){(X=te[h]).offset=ie,X.indexOffset=oe;var se=2*X.positionLength,fe=2*X.indexLength+6*X.positionLength;ie+=se,oe+=fe,X.indexLength=fe}var de=[];for(h in te)te.hasOwnProperty(h)&&(X=te[h],de.push({color:n.Color.fromRgba(parseInt(h)),offset:X.indexOffset,count:X.indexLength,batchIds:X.batchIds}));for(c=0;c<j;++c){var ce=(X=te[h=B[c]]).offset,ue=3*ce,he=ce,le=q[c],ge=g[c],pe=T[c],be=P,me=F;r.defined(S)&&r.defined(D)&&(be=S[c],me=D[c]);var ye=Number.POSITIVE_INFINITY,Ce=Number.NEGATIVE_INFINITY,Ie=Number.POSITIVE_INFINITY,ve=Number.NEGATIVE_INFINITY;for(u=0;u<ge;++u){var we=a.Cartesian3.unpack(G,3*le+3*u,I);O.scaleToGeodeticSurface(we,we);var xe=O.cartesianToCartographic(we,E),Ae=xe.latitude,Ee=xe.longitude;ye=Math.min(Ae,ye),Ce=Math.max(Ae,Ce),Ie=Math.min(Ee,Ie),ve=Math.max(Ee,ve);var Ne=O.geodeticSurfaceNormal(we,v),Te=a.Cartesian3.multiplyByScalar(Ne,be,w),Be=a.Cartesian3.add(we,Te,x);Te=a.Cartesian3.multiplyByScalar(Ne,me,Te);var ke=a.Cartesian3.add(we,Te,A);a.Cartesian3.subtract(ke,L,ke),a.Cartesian3.subtract(Be,L,Be),a.Cartesian3.pack(ke,$,ue),a.Cartesian3.pack(Be,$,ue+3),ee[he]=pe,ee[he+1]=pe,ue+=6,he+=2}(U=N).west=Ie,U.east=ve,U.south=ye,U.north=Ce,k[c]=o.OrientedBoundingBox.fromRectangle(U,P,F,O);var Le=X.indexOffset,Oe=J[c],Ue=p[c];for(ae[c]=Le,u=0;u<Ue;u+=3){var Pe=d[Oe+u]-le,Fe=d[Oe+u+1]-le,Se=d[Oe+u+2]-le;re[Le++]=2*Pe+ce,re[Le++]=2*Fe+ce,re[Le++]=2*Se+ce,re[Le++]=2*Se+1+ce,re[Le++]=2*Fe+1+ce,re[Le++]=2*Pe+1+ce}for(u=0;u<ge;++u){var De=u,Re=(u+1)%ge;re[Le++]=2*De+1+ce,re[Le++]=2*Re+ce,re[Le++]=2*De+ce,re[Le++]=2*De+1+ce,re[Le++]=2*Re+1+ce,re[Le++]=2*Re+ce}X.offset+=2*ge,X.indexOffset=Le,ne[c]=Le-ae[c]}re=t.IndexDatatype.createTypedArray($.length/3,re);for(var Me=de.length,_e=0;_e<Me;++_e){for(var Ge=de[_e].batchIds,Ye=0,Ve=Ge.length,He=0;He<Ve;++He)Ye+=ne[Ge[He]];de[_e].count=Ye}var We=function(e,a,r){var t=a.length,i=2+t*o.OrientedBoundingBox.packedLength+1+function(e){for(var a=e.length,r=0,t=0;t<a;++t)r+=n.Color.packedLength+3+e[t].batchIds.length;return r}(r),s=new Float64Array(i),f=0;s[f++]=e,s[f++]=t;for(var d=0;d<t;++d)o.OrientedBoundingBox.pack(a[d],s,f),f+=o.OrientedBoundingBox.packedLength;var c=r.length;s[f++]=c;for(var u=0;u<c;++u){var h=r[u];n.Color.pack(h.color,s,f),f+=n.Color.packedLength,s[f++]=h.offset,s[f++]=h.count;var l=h.batchIds,g=l.length;s[f++]=g;for(var p=0;p<g;++p)s[f++]=l[p]}return s}(2===re.BYTES_PER_ELEMENT?t.IndexDatatype.UNSIGNED_SHORT:t.IndexDatatype.UNSIGNED_INT,k,de);return f.push($.buffer,re.buffer,ae.buffer,ne.buffer,ee.buffer,We.buffer),{positions:$.buffer,indices:re.buffer,indexOffsets:ae.buffer,indexCounts:ne.buffer,batchIds:ee.buffer,packedBuffer:We.buffer}}))}));