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;o<n;++o)if(i.equalsEpsilon(e[o],t,r.CesiumMath.EPSILON12))return o;return-1}var x=new i.Cartographic,N=new i.Cartesian3,b=new i.Cartesian3,S=new i.Cartesian3,w=new i.Matrix4;function P(e,t,n,o,s,u,h,c,d,g,l){for(var m=c.length,p=0;p<m;++p){var v=c[p],f=v.cartographic,I=v.index,E=e.length,T=f.longitude,C=f.latitude;C=r.CesiumMath.clamp(C,-r.CesiumMath.PI_OVER_TWO,r.CesiumMath.PI_OVER_TWO);var M=f.height-h.skirtHeight;h.hMin=Math.min(h.hMin,M),i.Cartographic.fromRadians(T,C,M,x),g&&(x.longitude+=d),g?p===m-1?x.latitude+=l:0===p&&(x.latitude-=l):x.latitude+=d;var b=h.ellipsoid.cartographicToCartesian(x);e.push(b),t.push(M),n.push(i.Cartesian2.clone(n[I])),o.length>0&&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;Be<Se;++Be){var Ae=Te+j.getUint8(Z++)*Me;x.longitude=Ae;var ye=Ce+j.getUint8(Z++)*Ne;x.latitude=ye;var Re=j.getFloat32(Z,!0);if(Z+=T,0!==Re&&Re<y&&(Re*=-Math.pow(2,A)),Re*=6371010,x.height=Re,-1!==M(H,Ae)||-1!==M(k,ye)){var _e=M(re,x,i.Cartographic);if(-1!==_e){Pe[Be]=oe[_e];continue}re.push(i.Cartographic.clone(x)),oe.push(fe)}Pe[Be]=fe,Math.abs(Ae-R)<xe?le.push({index:fe,cartographic:i.Cartographic.clone(x)}):Math.abs(Ae-F)<xe?pe.push({index:fe,cartographic:i.Cartographic.clone(x)}):Math.abs(ye-_)<be?me.push({index:fe,cartographic:i.Cartographic.clone(x)}):Math.abs(ye-W)<be&&ve.push({index:fe,cartographic:i.Cartographic.clone(x)}),z=Math.min(Re,z),q=Math.max(Re,q),he[fe]=Re;var Fe=d.cartographicToCartesian(x);if(se[fe]=Fe,B&&(ce[fe]=(u.WebMercatorProjection.geodeticLatitudeToMercatorAngle(ye)-U)*V),G){var We=d.geodeticSurfaceNormal(Fe);de[fe]=We}i.Matrix4.multiplyByPoint(D,Fe,N),i.Cartesian3.minimumByComponent(N,J,J),i.Cartesian3.maximumByComponent(N,K,K);var Oe=(Ae-R)/(F-R);Oe=r.CesiumMath.clamp(Oe,0,1);var Ye=(ye-_)/(W-_);Ye=r.CesiumMath.clamp(Ye,0,1),ue[fe]=new i.Cartesian2(Oe,Ye),++fe}for(var Ue=3*we,Ve=0;Ve<Ue;++Ve,++Ie)ge[Ie]=Pe[j.getUint16(Z,!0)],Z+=f;if(Q!==Z-Ee)throw new s.RuntimeError("Invalid terrain tile.")}se.length=fe,ue.length=fe,he.length=fe,B&&(ce.length=fe);G&&(de.length=fe);var ke=fe,He=Ie,Le={hMin:z,lastBorderPoint:void 0,skirtHeight:v,toENU:D,ellipsoid:d,minimum:J,maximum:K};le.sort((function(e,t){return t.cartographic.latitude-e.cartographic.latitude})),me.sort((function(e,t){return e.cartographic.longitude-t.cartographic.longitude})),pe.sort((function(e,t){return e.cartographic.latitude-t.cartographic.latitude})),ve.sort((function(e,t){return t.cartographic.longitude-e.cartographic.longitude}));var De=1e-5;if(P(se,he,ue,ce,de,ge,Le,le,-De*O,!0,-De*Y),P(se,he,ue,ce,de,ge,Le,me,-De*Y,!1),P(se,he,ue,ce,de,ge,Le,pe,De*O,!0,De*Y),P(se,he,ue,ce,de,ge,Le,ve,De*Y,!1),le.length>0&&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}}))}));
|