createVerticesFromGoogleEarthEnterpriseBuffer.js 7.0 KB

1
  1. define(["./EllipsoidTangentPlane-53184efd","./buildModuleUrl-3d15f25c","./Cartesian2-6033fa5d","./Cartographic-67e73ef9","./when-92c6cf3c","./Rectangle-bab7abf0","./TerrainEncoding-5d55ad09","./Math-92c3b5f7","./PrimitiveType-cdfe443e","./OrientedBoundingBox-513cf61d","./RuntimeError-c6a62a80","./GeometryAttribute-ef657318","./WebMercatorProjection-39906b85","./createTaskProcessorWorker","./Check-52a7d806","./Intersect-b97e930a","./Cartesian4-ad128b5d","./IntersectionTests-a42760d9","./Plane-f8d22530","./Event-3390cd7d","./AttributeCompression-49f7b62a","./ComponentDatatype-81047f82","./WebGLConstants-71f10989","./PolygonPipeline-b86e8785","./WindingOrder-1b9c8a87","./EllipsoidRhumbLine-8847d1a1","./Buffer-1d0f8963","./IndexDatatype-4c0e98b8","./RenderState-94064c70","./BoundingRectangle-418864a2","./Color-45274500","./FeatureDetection-067cb23c"],(function(e,t,n,i,r,a,o,u,s,d,c,h,l,g,m,p,v,I,f,E,T,N,b,x,S,y,w,P,R,B,A,M){"use strict";var C=Uint16Array.BYTES_PER_ELEMENT,_=Int32Array.BYTES_PER_ELEMENT,F=Uint32Array.BYTES_PER_ELEMENT,W=Float32Array.BYTES_PER_ELEMENT,U=Float64Array.BYTES_PER_ELEMENT;function Y(e,t,n){n=r.u(n,u.e);for(var i=e.length,a=0;a<i;++a)if(n.equalsEpsilon(e[a],t,u.e.EPSILON12))return a;return-1}var k=new i.t$1,O=new i.t,L=new i.t,V=new i.t,H=new s.y;function $(e,t,a,o,d,c,h,l,g,m){for(var p=h.length,v=0;v<p;++v){var I=h[v],f=I.cartographic,E=I.index,T=e.length,N=f.longitude,b=f.latitude;b=u.e.clamp(b,-u.e.PI_OVER_TWO,u.e.PI_OVER_TWO);var x=f.height-c.skirtHeight;c.hMin=Math.min(c.hMin,x),i.t$1.fromRadians(N,b,x,k),g&&(k.longitude+=l),g?v===p-1?k.latitude+=m:0===v&&(k.latitude-=m):k.latitude+=l;var S=c.ellipsoid.cartographicToCartesian(k);e.push(S),t.push(x),a.push(n.o.clone(a[E])),o.length>0&&o.push(o[E]),s.y.multiplyByPoint(c.toENU,S,O);var y=c.minimum,w=c.maximum;i.t.minimumByComponent(O,y,y),i.t.maximumByComponent(O,w,w);var P=c.lastBorderPoint;if(r.e(P)){var R=P.index;d.push(R,T-1,T,T,E,R)}c.lastBorderPoint=I}}return g((function(g,m){g.ellipsoid=a.t.clone(g.ellipsoid),g.rectangle=a.h.clone(g.rectangle);var p=function(a,g,m,p,v,I,f,E,T,N){var b,x,S,y,w,P;r.e(p)?(b=p.west,x=p.south,S=p.east,y=p.north,w=p.width,P=p.height):(b=u.e.toRadians(v.west),x=u.e.toRadians(v.south),S=u.e.toRadians(v.east),y=u.e.toRadians(v.north),w=u.e.toRadians(p.width),P=u.e.toRadians(p.height));var R,B,A=[x,y],M=[b,S],D=h.m.eastNorthUpToFixedFrame(g,m),G=s.y.inverseTransformation(D,H);E&&(R=l.t.geodeticLatitudeToMercatorAngle(x),B=1/(l.t.geodeticLatitudeToMercatorAngle(y)-R));var z=new DataView(a),j=Number.POSITIVE_INFINITY,q=Number.NEGATIVE_INFINITY,J=L;J.x=Number.POSITIVE_INFINITY,J.y=Number.POSITIVE_INFINITY,J.z=Number.POSITIVE_INFINITY;var K=V;K.x=Number.NEGATIVE_INFINITY,K.y=Number.NEGATIVE_INFINITY,K.z=Number.NEGATIVE_INFINITY;var Q,X,Z=0,ee=0,te=0;for(X=0;X<4;++X){var ne=Z;Q=z.getUint32(ne,!0),ne+=F;var ie=u.e.toRadians(180*z.getFloat64(ne,!0));ne+=U,-1===Y(M,ie)&&M.push(ie);var re=u.e.toRadians(180*z.getFloat64(ne,!0));ne+=U,-1===Y(A,re)&&A.push(re),ne+=2*U;var ae=z.getInt32(ne,!0);ne+=_,ee+=ae,te+=3*(ae=z.getInt32(ne,!0)),Z+=Q+F}var oe=[],ue=[],se=new Array(ee),de=new Array(ee),ce=new Array(ee),he=E?new Array(ee):[],le=new Array(te),ge=[],me=[],pe=[],ve=[],Ie=0,fe=0;for(Z=0,X=0;X<4;++X){Q=z.getUint32(Z,!0);var Ee=Z+=F,Te=u.e.toRadians(180*z.getFloat64(Z,!0));Z+=U;var Ne=u.e.toRadians(180*z.getFloat64(Z,!0));Z+=U;var be=u.e.toRadians(180*z.getFloat64(Z,!0)),xe=.5*be;Z+=U;var Se=u.e.toRadians(180*z.getFloat64(Z,!0)),ye=.5*Se;Z+=U;var we=z.getInt32(Z,!0);Z+=_;var Pe=z.getInt32(Z,!0);Z+=_,Z+=_;for(var Re=new Array(we),Be=0;Be<we;++Be){var Ae=Te+z.getUint8(Z++)*be;k.longitude=Ae;var Me=Ne+z.getUint8(Z++)*Se;k.latitude=Me;var Ce=z.getFloat32(Z,!0);if(Z+=W,0!==Ce&&Ce<N&&(Ce*=-Math.pow(2,T)),Ce*=6371010*I,k.height=Ce,-1!==Y(M,Ae)||-1!==Y(A,Me)){var _e=Y(oe,k,i.t$1);if(-1!==_e){Re[Be]=ue[_e];continue}oe.push(i.t$1.clone(k)),ue.push(Ie)}Re[Be]=Ie,Math.abs(Ae-b)<xe?ge.push({index:Ie,cartographic:i.t$1.clone(k)}):Math.abs(Ae-S)<xe?pe.push({index:Ie,cartographic:i.t$1.clone(k)}):Math.abs(Me-x)<ye?me.push({index:Ie,cartographic:i.t$1.clone(k)}):Math.abs(Me-y)<ye&&ve.push({index:Ie,cartographic:i.t$1.clone(k)}),j=Math.min(Ce,j),q=Math.max(Ce,q),ce[Ie]=Ce;var Fe=m.cartographicToCartesian(k);se[Ie]=Fe,E&&(he[Ie]=(l.t.geodeticLatitudeToMercatorAngle(Me)-R)*B),s.y.multiplyByPoint(G,Fe,O),i.t.minimumByComponent(O,J,J),i.t.maximumByComponent(O,K,K);var We=(Ae-b)/(S-b);We=u.e.clamp(We,0,1);var Ue=(Me-x)/(y-x);Ue=u.e.clamp(Ue,0,1),de[Ie]=new n.o(We,Ue),++Ie}for(var Ye=3*Pe,ke=0;ke<Ye;++ke,++fe)le[fe]=Re[z.getUint16(Z,!0)],Z+=C;if(Q!==Z-Ee)throw new c.t("Invalid terrain tile.")}se.length=Ie,de.length=Ie,ce.length=Ie,E&&(he.length=Ie);var Oe=Ie,Le=fe,Ve={hMin:j,lastBorderPoint:void 0,skirtHeight:f,toENU:G,ellipsoid:m,minimum:J,maximum:K};ge.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 He=1e-5;if($(se,ce,de,he,le,Ve,ge,-He*w,!0,-He*P),$(se,ce,de,he,le,Ve,me,-He*P,!1),$(se,ce,de,he,le,Ve,pe,He*w,!0,He*P),$(se,ce,de,he,le,Ve,ve,He*P,!1),ge.length>0&&ve.length>0){var $e=ge[0].index,De=Oe,Ge=ve[ve.length-1].index,ze=se.length-1;le.push(Ge,ze,De,De,$e,Ge)}ee=se.length;var je,qe=t.i.fromPoints(se);r.e(p)&&(je=d.x.fromRectangle(p,j,q,m));for(var Je=new o.s(m).computeHorizonCullingPointPossiblyUnderEllipsoid(g,se,j),Ke=new e.e(J,K,g),Qe=new o.h(Ke,Ve.hMin,q,D,!1,E),Xe=new Float32Array(ee*Qe.getStride()),Ze=0,et=0;et<ee;++et)Ze=Qe.encode(Xe,Ze,se[et],de[et],ce[et],void 0,he[et]);var tt=ge.map((function(e){return e.index})).reverse(),nt=me.map((function(e){return e.index})).reverse(),it=pe.map((function(e){return e.index})).reverse(),rt=ve.map((function(e){return e.index})).reverse();return nt.unshift(it[it.length-1]),nt.push(tt[0]),rt.unshift(tt[tt.length-1]),rt.push(it[0]),{vertices:Xe,indices:new Uint16Array(le),maximumHeight:q,minimumHeight:j,encoding:Qe,boundingSphere3D:qe,orientedBoundingBox:je,occludeePointInScaledSpace:Je,vertexCountWithoutSkirts:Oe,indexCountWithoutSkirts:Le,westIndicesSouthToNorth:tt,southIndicesEastToWest:nt,eastIndicesNorthToSouth:it,northIndicesWestToEast:rt}}(g.buffer,g.relativeToCenter,g.ellipsoid,g.rectangle,g.nativeRectangle,g.exaggeration,g.skirtHeight,g.includeWebMercatorT,g.negativeAltitudeExponentBias,g.negativeElevationThreshold),v=p.vertices;m.push(v.buffer);var I=p.indices;return m.push(I.buffer),{vertices:v.buffer,indices:I.buffer,numberOfAttributes:p.encoding.getStride(),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}}))}));