define(["./AxisAlignedBoundingBox-699685f5","./Transforms-a6362ad2","./Matrix2-ae0e0b05","./when-e3a49219","./TerrainEncoding-d0dbd995","./ComponentDatatype-64cf6611","./OrientedBoundingBox-d2fffacc","./RuntimeError-ffc802eb","./WebMercatorProjection-043b7eb3","./createTaskProcessorWorker","./combine-c7a1ec8a","./PixelFormat-83d70a69","./WebGLConstants-1c8239cc","./AttributeCompression-8cb78525","./EllipsoidTangentPlane-e3af9e65","./IntersectionTests-8be403d7","./Plane-2bf1bb80"],(function(e,t,i,a,n,r,o,s,u,h,c,d,g,l,m,p,v){"use strict";var f=Uint16Array.BYTES_PER_ELEMENT,I=Int32Array.BYTES_PER_ELEMENT,E=Uint32Array.BYTES_PER_ELEMENT,T=Float32Array.BYTES_PER_ELEMENT,C=Float64Array.BYTES_PER_ELEMENT;function M(e,t,i){i=a.defaultValue(i,r.CesiumMath);for(var n=e.length,o=0;o0&&o.push(o[I]),s.length>0&&s.push(s[I]),i.Matrix4.multiplyByPoint(h.toENU,b,N);var S=h.minimum,w=h.maximum;i.Cartesian3.minimumByComponent(N,S,S),i.Cartesian3.maximumByComponent(N,w,w);var P=h.lastBorderPoint;if(a.defined(P)){var B=P.index;u.push(B,E-1,E,E,I,B)}h.lastBorderPoint=v}}return h((function(h,c){h.ellipsoid=i.Ellipsoid.clone(h.ellipsoid),h.rectangle=i.Rectangle.clone(h.rectangle);var d=function(h,c,d,g,l,m,p,v,B,A,y){var R,_,F,W,O,Y;a.defined(g)?(R=g.west,_=g.south,F=g.east,W=g.north,O=g.width,Y=g.height):(R=r.CesiumMath.toRadians(l.west),_=r.CesiumMath.toRadians(l.south),F=r.CesiumMath.toRadians(l.east),W=r.CesiumMath.toRadians(l.north),O=r.CesiumMath.toRadians(g.width),Y=r.CesiumMath.toRadians(g.height));var U,V,k=[_,W],H=[R,F],L=t.Transforms.eastNorthUpToFixedFrame(c,d),D=i.Matrix4.inverseTransformation(L,w);B&&(U=u.WebMercatorProjection.geodeticLatitudeToMercatorAngle(_),V=1/(u.WebMercatorProjection.geodeticLatitudeToMercatorAngle(W)-U));var G=1!==m,j=new DataView(h),z=Number.POSITIVE_INFINITY,q=Number.NEGATIVE_INFINITY,J=b;J.x=Number.POSITIVE_INFINITY,J.y=Number.POSITIVE_INFINITY,J.z=Number.POSITIVE_INFINITY;var K=S;K.x=Number.NEGATIVE_INFINITY,K.y=Number.NEGATIVE_INFINITY,K.z=Number.NEGATIVE_INFINITY;var Q,X,Z=0,$=0,ee=0;for(X=0;X<4;++X){var te=Z;Q=j.getUint32(te,!0),te+=E;var ie=r.CesiumMath.toRadians(180*j.getFloat64(te,!0));te+=C,-1===M(H,ie)&&H.push(ie);var ae=r.CesiumMath.toRadians(180*j.getFloat64(te,!0));te+=C,-1===M(k,ae)&&k.push(ae),te+=2*C;var ne=j.getInt32(te,!0);te+=I,$+=ne,ee+=3*(ne=j.getInt32(te,!0)),Z+=Q+E}var re=[],oe=[],se=new Array($),ue=new Array($),he=new Array($),ce=B?new Array($):[],de=G?new Array($):[],ge=new Array(ee),le=[],me=[],pe=[],ve=[],fe=0,Ie=0;for(Z=0,X=0;X<4;++X){Q=j.getUint32(Z,!0);var Ee=Z+=E,Te=r.CesiumMath.toRadians(180*j.getFloat64(Z,!0));Z+=C;var Ce=r.CesiumMath.toRadians(180*j.getFloat64(Z,!0));Z+=C;var Me=r.CesiumMath.toRadians(180*j.getFloat64(Z,!0)),xe=.5*Me;Z+=C;var Ne=r.CesiumMath.toRadians(180*j.getFloat64(Z,!0)),be=.5*Ne;Z+=C;var Se=j.getInt32(Z,!0);Z+=I;var we=j.getInt32(Z,!0);Z+=I,Z+=I;for(var Pe=new Array(Se),Be=0;Be0&&ve.length>0){var Ge=le[0].index,je=ke,ze=ve[ve.length-1].index,qe=se.length-1;ge.push(ze,qe,je,je,Ge,ze)}$=se.length;var Je,Ke=t.BoundingSphere.fromPoints(se);a.defined(g)&&(Je=o.OrientedBoundingBox.fromRectangle(g,z,q,d));for(var Qe=new n.EllipsoidalOccluder(d).computeHorizonCullingPointPossiblyUnderEllipsoid(c,se,z),Xe=new e.AxisAlignedBoundingBox(J,K,c),Ze=new n.TerrainEncoding(c,Xe,Le.hMin,q,L,!1,B,G,m,p),$e=new Float32Array($*Ze.stride),et=0,tt=0;tt<$;++tt)et=Ze.encode($e,et,se[tt],ue[tt],he[tt],void 0,ce[tt],de[tt]);var it=le.map((function(e){return e.index})).reverse(),at=me.map((function(e){return e.index})).reverse(),nt=pe.map((function(e){return e.index})).reverse(),rt=ve.map((function(e){return e.index})).reverse();return at.unshift(nt[nt.length-1]),at.push(it[0]),rt.unshift(it[it.length-1]),rt.push(nt[0]),{vertices:$e,indices:new Uint16Array(ge),maximumHeight:q,minimumHeight:z,encoding:Ze,boundingSphere3D:Ke,orientedBoundingBox:Je,occludeePointInScaledSpace:Qe,vertexCountWithoutSkirts:ke,indexCountWithoutSkirts:He,westIndicesSouthToNorth:it,southIndicesEastToWest:at,eastIndicesNorthToSouth:nt,northIndicesWestToEast:rt}}(h.buffer,h.relativeToCenter,h.ellipsoid,h.rectangle,h.nativeRectangle,h.exaggeration,h.exaggerationRelativeHeight,h.skirtHeight,h.includeWebMercatorT,h.negativeAltitudeExponentBias,h.negativeElevationThreshold),g=d.vertices;c.push(g.buffer);var l=d.indices;return c.push(l.buffer),{vertices:g.buffer,indices:l.buffer,numberOfAttributes:d.encoding.stride,minimumHeight:d.minimumHeight,maximumHeight:d.maximumHeight,boundingSphere3D:d.boundingSphere3D,orientedBoundingBox:d.orientedBoundingBox,occludeePointInScaledSpace:d.occludeePointInScaledSpace,encoding:d.encoding,vertexCountWithoutSkirts:d.vertexCountWithoutSkirts,indexCountWithoutSkirts:d.indexCountWithoutSkirts,westIndicesSouthToNorth:d.westIndicesSouthToNorth,southIndicesEastToWest:d.southIndicesEastToWest,eastIndicesNorthToSouth:d.eastIndicesNorthToSouth,northIndicesWestToEast:d.northIndicesWestToEast}}))}));