2 lines
7.6 KiB
JavaScript
2 lines
7.6 KiB
JavaScript
define(["./AxisAlignedBoundingBox-8774439c","./BoundingSphere-9a3b5656","./Cartesian2-bd414876","./Cartesian3-e0307675","./defaultValue-81eec7ed","./TerrainEncoding-0f7ffc20","./Math-e73894ab","./Matrix4-4c545f70","./OrientedBoundingBox-c5d2adb7","./Rectangle-cf3e0e3e","./RuntimeError-26acdd3b","./Transforms-5b829630","./WebMercatorProjection-44373a3d","./createTaskProcessorWorker","./Check-741c5f3c","./GeographicProjection-c931c7fb","./AttributeCompression-8f752c03","./ComponentDatatype-aaeec80f","./WebGLConstants-508b9636","./Matrix2-dc0c61cc","./EllipsoidTangentPlane-4d138901","./IntersectionTests-80510c7b","./Plane-bc8b6777","./when-422ea0ae","./Resource-8ae1a924","./combine-3c023bda"],(function(t,e,n,i,o,a,r,s,c,u,h,d,l,g,m,p,f,I,E,T,C,M,x,N,b,S){"use strict";const w=Uint16Array.BYTES_PER_ELEMENT,B=Int32Array.BYTES_PER_ELEMENT,P=Uint32Array.BYTES_PER_ELEMENT,A=Float32Array.BYTES_PER_ELEMENT,R=Float64Array.BYTES_PER_ELEMENT;function y(t,e,n){n=o.defaultValue(n,r.CesiumMath);const i=t.length;for(let o=0;o<i;++o)if(n.equalsEpsilon(t[o],e,r.CesiumMath.EPSILON12))return o;return-1}const _=new n.Cartographic,W=new i.Cartesian3,v=new i.Cartesian3,F=new i.Cartesian3,O=new s.Matrix4;function V(t,e,a,c,u,h,d,l,g,m,p){const f=l.length;for(let I=0;I<f;++I){const E=l[I],T=E.cartographic,C=E.index,M=t.length,x=T.longitude;let N=T.latitude;N=r.CesiumMath.clamp(N,-r.CesiumMath.PI_OVER_TWO,r.CesiumMath.PI_OVER_TWO);const b=T.height-d.skirtHeight;d.hMin=Math.min(d.hMin,b),n.Cartographic.fromRadians(x,N,b,_),m&&(_.longitude+=g),m?I===f-1?_.latitude+=p:0===I&&(_.latitude-=p):_.latitude+=g;const S=d.ellipsoid.cartographicToCartesian(_);t.push(S),e.push(b),a.push(n.Cartesian2.clone(a[C])),c.length>0&&c.push(c[C]),u.length>0&&u.push(u[C]),s.Matrix4.multiplyByPoint(d.toENU,S,W);const w=d.minimum,B=d.maximum;i.Cartesian3.minimumByComponent(W,w,w),i.Cartesian3.maximumByComponent(W,B,B);const P=d.lastBorderPoint;if(o.defined(P)){const t=P.index;h.push(t,M-1,M,M,C,t)}d.lastBorderPoint=E}}return g((function(g,m){g.ellipsoid=n.Ellipsoid.clone(g.ellipsoid),g.rectangle=u.Rectangle.clone(g.rectangle);const p=function(u,g,m,p,f,I,E,T,C,M,x){let N,b,S,Y,k,U;o.defined(p)?(N=p.west,b=p.south,S=p.east,Y=p.north,k=p.width,U=p.height):(N=r.CesiumMath.toRadians(f.west),b=r.CesiumMath.toRadians(f.south),S=r.CesiumMath.toRadians(f.east),Y=r.CesiumMath.toRadians(f.north),k=r.CesiumMath.toRadians(p.width),U=r.CesiumMath.toRadians(p.height));const H=[b,Y],L=[N,S],G=d.Transforms.eastNorthUpToFixedFrame(g,m),j=s.Matrix4.inverseTransformation(G,O);let D,z;C&&(D=l.WebMercatorProjection.geodeticLatitudeToMercatorAngle(b),z=1/(l.WebMercatorProjection.geodeticLatitudeToMercatorAngle(Y)-D));const q=1!==I,J=new DataView(u);let K=Number.POSITIVE_INFINITY,Q=Number.NEGATIVE_INFINITY;const X=v;X.x=Number.POSITIVE_INFINITY,X.y=Number.POSITIVE_INFINITY,X.z=Number.POSITIVE_INFINITY;const Z=F;Z.x=Number.NEGATIVE_INFINITY,Z.y=Number.NEGATIVE_INFINITY,Z.z=Number.NEGATIVE_INFINITY;let $,tt,et=0,nt=0,it=0;for(tt=0;tt<4;++tt){let t=et;$=J.getUint32(t,!0),t+=P;const e=r.CesiumMath.toRadians(180*J.getFloat64(t,!0));t+=R,-1===y(L,e)&&L.push(e);const n=r.CesiumMath.toRadians(180*J.getFloat64(t,!0));t+=R,-1===y(H,n)&&H.push(n),t+=2*R;let i=J.getInt32(t,!0);t+=B,nt+=i,i=J.getInt32(t,!0),it+=3*i,et+=$+P}const ot=[],at=[],rt=new Array(nt),st=new Array(nt),ct=new Array(nt),ut=C?new Array(nt):[],ht=q?new Array(nt):[],dt=new Array(it),lt=[],gt=[],mt=[],pt=[];let ft=0,It=0;for(et=0,tt=0;tt<4;++tt){$=J.getUint32(et,!0),et+=P;const t=et,e=r.CesiumMath.toRadians(180*J.getFloat64(et,!0));et+=R;const o=r.CesiumMath.toRadians(180*J.getFloat64(et,!0));et+=R;const a=r.CesiumMath.toRadians(180*J.getFloat64(et,!0)),c=.5*a;et+=R;const u=r.CesiumMath.toRadians(180*J.getFloat64(et,!0)),d=.5*u;et+=R;const g=J.getInt32(et,!0);et+=B;const p=J.getInt32(et,!0);et+=B,et+=B;const f=new Array(g);for(let t=0;t<g;++t){const h=e+J.getUint8(et++)*a;_.longitude=h;const g=o+J.getUint8(et++)*u;_.latitude=g;let p=J.getFloat32(et,!0);if(et+=A,0!==p&&p<x&&(p*=-Math.pow(2,M)),p*=6371010,_.height=p,-1!==y(L,h)||-1!==y(H,g)){const e=y(ot,_,n.Cartographic);if(-1!==e){f[t]=at[e];continue}ot.push(n.Cartographic.clone(_)),at.push(ft)}f[t]=ft,Math.abs(h-N)<c?lt.push({index:ft,cartographic:n.Cartographic.clone(_)}):Math.abs(h-S)<c?mt.push({index:ft,cartographic:n.Cartographic.clone(_)}):Math.abs(g-b)<d?gt.push({index:ft,cartographic:n.Cartographic.clone(_)}):Math.abs(g-Y)<d&&pt.push({index:ft,cartographic:n.Cartographic.clone(_)}),K=Math.min(p,K),Q=Math.max(p,Q),ct[ft]=p;const I=m.cartographicToCartesian(_);if(rt[ft]=I,C&&(ut[ft]=(l.WebMercatorProjection.geodeticLatitudeToMercatorAngle(g)-D)*z),q){const t=m.geodeticSurfaceNormal(I);ht[ft]=t}s.Matrix4.multiplyByPoint(j,I,W),i.Cartesian3.minimumByComponent(W,X,X),i.Cartesian3.maximumByComponent(W,Z,Z);let E=(h-N)/(S-N);E=r.CesiumMath.clamp(E,0,1);let T=(g-b)/(Y-b);T=r.CesiumMath.clamp(T,0,1),st[ft]=new n.Cartesian2(E,T),++ft}const I=3*p;for(let t=0;t<I;++t,++It)dt[It]=f[J.getUint16(et,!0)],et+=w;if($!==et-t)throw new h.RuntimeError("Invalid terrain tile.")}rt.length=ft,st.length=ft,ct.length=ft,C&&(ut.length=ft);q&&(ht.length=ft);const Et=ft,Tt=It,Ct={hMin:K,lastBorderPoint:void 0,skirtHeight:T,toENU:j,ellipsoid:m,minimum:X,maximum:Z};lt.sort((function(t,e){return e.cartographic.latitude-t.cartographic.latitude})),gt.sort((function(t,e){return t.cartographic.longitude-e.cartographic.longitude})),mt.sort((function(t,e){return t.cartographic.latitude-e.cartographic.latitude})),pt.sort((function(t,e){return e.cartographic.longitude-t.cartographic.longitude}));const Mt=1e-5;if(V(rt,ct,st,ut,ht,dt,Ct,lt,-Mt*k,!0,-Mt*U),V(rt,ct,st,ut,ht,dt,Ct,gt,-Mt*U,!1),V(rt,ct,st,ut,ht,dt,Ct,mt,Mt*k,!0,Mt*U),V(rt,ct,st,ut,ht,dt,Ct,pt,Mt*U,!1),lt.length>0&&pt.length>0){const t=lt[0].index,e=Et,n=pt[pt.length-1].index,i=rt.length-1;dt.push(n,i,e,e,t,n)}nt=rt.length;const xt=e.BoundingSphere.fromPoints(rt);let Nt;o.defined(p)&&(Nt=c.OrientedBoundingBox.fromRectangle(p,K,Q,m));const bt=new a.EllipsoidalOccluder(m).computeHorizonCullingPointPossiblyUnderEllipsoid(g,rt,K),St=new t.AxisAlignedBoundingBox(X,Z,g),wt=new a.TerrainEncoding(g,St,Ct.hMin,Q,G,!1,C,q,I,E),Bt=new Float32Array(nt*wt.stride);let Pt=0;for(let t=0;t<nt;++t)Pt=wt.encode(Bt,Pt,rt[t],st[t],ct[t],void 0,ut[t],ht[t]);const At=lt.map((function(t){return t.index})).reverse(),Rt=gt.map((function(t){return t.index})).reverse(),yt=mt.map((function(t){return t.index})).reverse(),_t=pt.map((function(t){return t.index})).reverse();return Rt.unshift(yt[yt.length-1]),Rt.push(At[0]),_t.unshift(At[At.length-1]),_t.push(yt[0]),{vertices:Bt,indices:new Uint16Array(dt),maximumHeight:Q,minimumHeight:K,encoding:wt,boundingSphere3D:xt,orientedBoundingBox:Nt,occludeePointInScaledSpace:bt,vertexCountWithoutSkirts:Et,indexCountWithoutSkirts:Tt,westIndicesSouthToNorth:At,southIndicesEastToWest:Rt,eastIndicesNorthToSouth:yt,northIndicesWestToEast:_t}}(g.buffer,g.relativeToCenter,g.ellipsoid,g.rectangle,g.nativeRectangle,g.exaggeration,g.exaggerationRelativeHeight,g.skirtHeight,g.includeWebMercatorT,g.negativeAltitudeExponentBias,g.negativeElevationThreshold),f=p.vertices;m.push(f.buffer);const I=p.indices;return m.push(I.buffer),{vertices:f.buffer,indices:I.buffer,numberOfAttributes:p.encoding.stride,minimumHeight:p.minimumHeight,maximumHeight:p.maximumHeight,boundingSphere3D:p.boundingSphere3D,orientedBoundingBox:p.orientedBoundingBox,occludeePointInScaledSpace:p.occludeePointInScaledSpace,encoding:p.encoding,vertexCountWithoutSkirts:p.vertexCountWithoutSkirts,indexCountWithoutSkirts:p.indexCountWithoutSkirts,westIndicesSouthToNorth:p.westIndicesSouthToNorth,southIndicesEastToWest:p.southIndicesEastToWest,eastIndicesNorthToSouth:p.eastIndicesNorthToSouth,northIndicesWestToEast:p.northIndicesWestToEast}}))}));
|