1
Surpriseplus
2022-09-16 a7e5110ef3f5fe3c9205f7d1a526b9fbbb55d826
1
define(["./when-77f4e3be","./Check-d71f548f","./Math-b81aa1f1","./Cartesian2-69a87134","./Transforms-03dbcaf7","./RuntimeError-34dd6124","./WebGLConstants-3e40d443","./ComponentDatatype-af4852df","./AttributeCompression-b43e055a","./IntersectionTests-ad3a0195","./Plane-a18bfa39","./WebMercatorProjection-cd5ba614","./createTaskProcessorWorker","./EllipsoidTangentPlane-5dd5582e","./OrientedBoundingBox-3c8fbb69","./TerrainEncoding-c0d02816"],function(Ft,t,Ot,Yt,kt,Ut,e,i,a,n,r,Vt,o,Ht,Lt,Dt){"use strict";var Gt=Uint16Array.BYTES_PER_ELEMENT,jt=Int32Array.BYTES_PER_ELEMENT,zt=Uint32Array.BYTES_PER_ELEMENT,qt=Float32Array.BYTES_PER_ELEMENT,Jt=Float64Array.BYTES_PER_ELEMENT;function Kt(t,e,i){i=Ft.defaultValue(i,Ot.CesiumMath);for(var a=t.length,n=0;n<a;++n)if(i.equalsEpsilon(t[n],e,Ot.CesiumMath.EPSILON12))return n;return-1}var Qt=new Yt.Cartographic,Xt=new Yt.Cartesian3,Zt=new Yt.Cartesian3,$t=new Yt.Cartesian3,te=new kt.Matrix4;function ee(t,e,i,a,n,r,o,s,u,h){for(var d=o.length,c=0;c<d;++c){var g=o[c],l=g.cartographic,m=g.index,p=t.length,v=l.longitude,I=l.latitude;I=Ot.CesiumMath.clamp(I,-Ot.CesiumMath.PI_OVER_TWO,Ot.CesiumMath.PI_OVER_TWO);var f=l.height-r.skirtHeight;r.hMin=Math.min(r.hMin,f),Yt.Cartographic.fromRadians(v,I,f,Qt),u&&(Qt.longitude+=s),u?c===d-1?Qt.latitude+=h:0===c&&(Qt.latitude-=h):Qt.latitude+=s;var E=r.ellipsoid.cartographicToCartesian(Qt);t.push(E),e.push(f),i.push(Yt.Cartesian2.clone(i[m])),0<a.length&&a.push(a[m]),kt.Matrix4.multiplyByPoint(r.toENU,E,Xt);var T=r.minimum,C=r.maximum;Yt.Cartesian3.minimumByComponent(Xt,T,T),Yt.Cartesian3.maximumByComponent(Xt,C,C);var M=r.lastBorderPoint;if(Ft.defined(M)){var N=M.index;n.push(N,p-1,p,p,m,N)}r.lastBorderPoint=g}}return o(function(t,e){t.ellipsoid=Yt.Ellipsoid.clone(t.ellipsoid),t.rectangle=Yt.Rectangle.clone(t.rectangle);var i=function(t,e,i,a,n,r,o,s,u,h){var d,c,g,l,m,p;p=Ft.defined(a)?(d=a.west,c=a.south,g=a.east,l=a.north,m=a.width,a.height):(d=Ot.CesiumMath.toRadians(n.west),c=Ot.CesiumMath.toRadians(n.south),g=Ot.CesiumMath.toRadians(n.east),l=Ot.CesiumMath.toRadians(n.north),m=Ot.CesiumMath.toRadians(a.width),Ot.CesiumMath.toRadians(a.height));var v,I,f=[c,l],E=[d,g],T=kt.Transforms.eastNorthUpToFixedFrame(e,i),C=kt.Matrix4.inverseTransformation(T,te);s&&(v=Vt.WebMercatorProjection.geodeticLatitudeToMercatorAngle(c),I=1/(Vt.WebMercatorProjection.geodeticLatitudeToMercatorAngle(l)-v));var M=new DataView(t),N=Number.POSITIVE_INFINITY,x=Number.NEGATIVE_INFINITY,b=Zt;b.x=Number.POSITIVE_INFINITY,b.y=Number.POSITIVE_INFINITY,b.z=Number.POSITIVE_INFINITY;var S=$t;S.x=Number.NEGATIVE_INFINITY,S.y=Number.NEGATIVE_INFINITY,S.z=Number.NEGATIVE_INFINITY;var w,P,B=0,y=0,A=0;for(P=0;P<4;++P){var R=B;w=M.getUint32(R,!0),R+=zt;var _=Ot.CesiumMath.toRadians(180*M.getFloat64(R,!0));R+=Jt,-1===Kt(E,_)&&E.push(_);var W=Ot.CesiumMath.toRadians(180*M.getFloat64(R,!0));R+=Jt,-1===Kt(f,W)&&f.push(W),R+=2*Jt;var F=M.getInt32(R,!0);R+=jt,y+=F,F=M.getInt32(R,!0),A+=3*F,B+=w+zt}var O=[],Y=[],k=new Array(y),U=new Array(y),V=new Array(y),H=s?new Array(y):[],L=new Array(A),D=[],G=[],j=[],z=[],q=0,J=0;for(P=B=0;P<4;++P){w=M.getUint32(B,!0);var K=B+=zt,Q=Ot.CesiumMath.toRadians(180*M.getFloat64(B,!0));B+=Jt;var X=Ot.CesiumMath.toRadians(180*M.getFloat64(B,!0));B+=Jt;var Z=Ot.CesiumMath.toRadians(180*M.getFloat64(B,!0)),$=.5*Z;B+=Jt;var tt=Ot.CesiumMath.toRadians(180*M.getFloat64(B,!0)),et=.5*tt;B+=Jt;var it=M.getInt32(B,!0);B+=jt;var at=M.getInt32(B,!0);B+=jt,B+=jt;for(var nt=new Array(it),rt=0;rt<it;++rt){var ot=Q+M.getUint8(B++)*Z;Qt.longitude=ot;var st=X+M.getUint8(B++)*tt;Qt.latitude=st;var ut=M.getFloat32(B,!0);if(B+=qt,0!==ut&&ut<h&&(ut*=-Math.pow(2,u)),ut*=6371010*r,Qt.height=ut,-1!==Kt(E,ot)||-1!==Kt(f,st)){var ht=Kt(O,Qt,Yt.Cartographic);if(-1!==ht){nt[rt]=Y[ht];continue}O.push(Yt.Cartographic.clone(Qt)),Y.push(q)}nt[rt]=q,Math.abs(ot-d)<$?D.push({index:q,cartographic:Yt.Cartographic.clone(Qt)}):Math.abs(ot-g)<$?j.push({index:q,cartographic:Yt.Cartographic.clone(Qt)}):Math.abs(st-c)<et?G.push({index:q,cartographic:Yt.Cartographic.clone(Qt)}):Math.abs(st-l)<et&&z.push({index:q,cartographic:Yt.Cartographic.clone(Qt)}),N=Math.min(ut,N),x=Math.max(ut,x),V[q]=ut;var dt=i.cartographicToCartesian(Qt);k[q]=dt,s&&(H[q]=(Vt.WebMercatorProjection.geodeticLatitudeToMercatorAngle(st)-v)*I),kt.Matrix4.multiplyByPoint(C,dt,Xt),Yt.Cartesian3.minimumByComponent(Xt,b,b),Yt.Cartesian3.maximumByComponent(Xt,S,S);var ct=(ot-d)/(g-d);ct=Ot.CesiumMath.clamp(ct,0,1);var gt=(st-c)/(l-c);gt=Ot.CesiumMath.clamp(gt,0,1),U[q]=new Yt.Cartesian2(ct,gt),++q}for(var lt=3*at,mt=0;mt<lt;++mt,++J)L[J]=nt[M.getUint16(B,!0)],B+=Gt;if(w!==B-K)throw new Ut.RuntimeError("Invalid terrain tile.")}k.length=q,U.length=q,V.length=q,s&&(H.length=q);var pt=q,vt=J,It={hMin:N,lastBorderPoint:void 0,skirtHeight:o,toENU:C,ellipsoid:i,minimum:b,maximum:S};D.sort(function(t,e){return e.cartographic.latitude-t.cartographic.latitude}),G.sort(function(t,e){return t.cartographic.longitude-e.cartographic.longitude}),j.sort(function(t,e){return t.cartographic.latitude-e.cartographic.latitude}),z.sort(function(t,e){return e.cartographic.longitude-t.cartographic.longitude});var ft=1e-5;if(ee(k,V,U,H,L,It,D,-ft*m,!0,-ft*p),ee(k,V,U,H,L,It,G,-ft*p,!1),ee(k,V,U,H,L,It,j,ft*m,!0,ft*p),ee(k,V,U,H,L,It,z,ft*p,!1),0<D.length&&0<z.length){var Et=D[0].index,Tt=pt,Ct=z[z.length-1].index,Mt=k.length-1;L.push(Ct,Mt,Tt,Tt,Et,Ct)}y=k.length;var Nt,xt=kt.BoundingSphere.fromPoints(k);Ft.defined(a)&&(Nt=Lt.OrientedBoundingBox.fromRectangle(a,N,x,i));for(var bt=new Dt.EllipsoidalOccluder(i).computeHorizonCullingPointPossiblyUnderEllipsoid(e,k,N),St=new Ht.AxisAlignedBoundingBox(b,S,e),wt=new Dt.TerrainEncoding(St,It.hMin,x,T,!1,s),Pt=new Float32Array(y*wt.getStride()),Bt=0,yt=0;yt<y;++yt)Bt=wt.encode(Pt,Bt,k[yt],U[yt],V[yt],void 0,H[yt]);var At=D.map(function(t){return t.index}).reverse(),Rt=G.map(function(t){return t.index}).reverse(),_t=j.map(function(t){return t.index}).reverse(),Wt=z.map(function(t){return t.index}).reverse();return Rt.unshift(_t[_t.length-1]),Rt.push(At[0]),Wt.unshift(At[At.length-1]),Wt.push(_t[0]),{vertices:Pt,indices:new Uint16Array(L),maximumHeight:x,minimumHeight:N,encoding:wt,boundingSphere3D:xt,orientedBoundingBox:Nt,occludeePointInScaledSpace:bt,vertexCountWithoutSkirts:pt,indexCountWithoutSkirts:vt,westIndicesSouthToNorth:At,southIndicesEastToWest:Rt,eastIndicesNorthToSouth:_t,northIndicesWestToEast:Wt}}(t.buffer,t.relativeToCenter,t.ellipsoid,t.rectangle,t.nativeRectangle,t.exaggeration,t.skirtHeight,t.includeWebMercatorT,t.negativeAltitudeExponentBias,t.negativeElevationThreshold),a=i.vertices;e.push(a.buffer);var n=i.indices;return e.push(n.buffer),{vertices:a.buffer,indices:n.buffer,numberOfAttributes:i.encoding.getStride(),minimumHeight:i.minimumHeight,maximumHeight:i.maximumHeight,boundingSphere3D:i.boundingSphere3D,orientedBoundingBox:i.orientedBoundingBox,occludeePointInScaledSpace:i.occludeePointInScaledSpace,encoding:i.encoding,vertexCountWithoutSkirts:i.vertexCountWithoutSkirts,indexCountWithoutSkirts:i.indexCountWithoutSkirts,westIndicesSouthToNorth:i.westIndicesSouthToNorth,southIndicesEastToWest:i.southIndicesEastToWest,eastIndicesNorthToSouth:i.eastIndicesNorthToSouth,northIndicesWestToEast:i.northIndicesWestToEast}})});