1 |
- define(["./AttributeCompression-399750a1","./buildModuleUrl-8cce5713","./Cartesian4-b0ddc4ba","./when-b60132fc","./TerrainEncoding-0e08edec","./IndexDatatype-3565e02d","./Check-7b2a090c","./Math-31e539c2","./OrientedBoundingBox-a6c2fb0f","./createTaskProcessorWorker","./WebGLConstants-aba9fc67","./FeatureDetection-ab6f364c","./PolygonPipeline-f2f37e26","./Plane-5716a082","./GeometryAttribute-923c2729","./earcut-2.2.1-20c8012f","./EllipsoidRhumbLine-3ee4574a"],(function(e,t,i,n,r,s,h,u,o,a,p,d,f,l,c,g,x){"use strict";var m={clipTriangleAtAxisAlignedThreshold:function(e,t,i,r,s,h){var u,o,a;n.defined(h)?h.length=0:h=[],t?(u=i<e,o=r<e,a=s<e):(u=i>e,o=r>e,a=s>e);var p,d,f,l,c,g,x=u+o+a;return 1===x?u?(p=(e-i)/(r-i),d=(e-i)/(s-i),h.push(1),h.push(2),1!==d&&(h.push(-1),h.push(0),h.push(2),h.push(d)),1!==p&&(h.push(-1),h.push(0),h.push(1),h.push(p))):o?(f=(e-r)/(s-r),l=(e-r)/(i-r),h.push(2),h.push(0),1!==l&&(h.push(-1),h.push(1),h.push(0),h.push(l)),1!==f&&(h.push(-1),h.push(1),h.push(2),h.push(f))):a&&(c=(e-s)/(i-s),g=(e-s)/(r-s),h.push(0),h.push(1),1!==g&&(h.push(-1),h.push(2),h.push(1),h.push(g)),1!==c&&(h.push(-1),h.push(2),h.push(0),h.push(c))):2===x?u||i===e?o||r===e?a||s===e||(d=(e-i)/(s-i),f=(e-r)/(s-r),h.push(2),h.push(-1),h.push(0),h.push(2),h.push(d),h.push(-1),h.push(1),h.push(2),h.push(f)):(g=(e-s)/(r-s),p=(e-i)/(r-i),h.push(1),h.push(-1),h.push(2),h.push(1),h.push(g),h.push(-1),h.push(0),h.push(1),h.push(p)):(l=(e-r)/(i-r),c=(e-s)/(i-s),h.push(0),h.push(-1),h.push(1),h.push(0),h.push(l),h.push(-1),h.push(2),h.push(0),h.push(c)):3!==x&&(h.push(0),h.push(1),h.push(2)),h},computeBarycentricCoordinates:function(e,t,r,s,h,u,o,a,p){var d=r-o,f=o-h,l=u-a,c=s-a,g=1/(l*d+f*c),x=t-a,m=e-o,v=(l*m+f*x)*g,w=(-c*m+d*x)*g,y=1-v-w;return n.defined(p)?(p.x=v,p.y=w,p.z=y,p):new i.Cartesian3(v,w,y)},computeLineSegmentLineSegmentIntersection:function(e,i,r,s,h,u,o,a,p){var d=(a-u)*(r-e)-(o-h)*(s-i);if(0!==d){var f=((o-h)*(i-u)-(a-u)*(e-h))/d,l=((r-e)*(i-u)-(s-i)*(e-h))/d;return f>=0&&f<=1&&l>=0&&l<=1?(n.defined(p)||(p=new t.Cartesian2),p.x=e+f*(r-e),p.y=i+f*(s-i),p):void 0}}},v=32767,w=16383,y=[],C=[],B=[],b=new i.Cartographic,I=new i.Cartesian3,A=[],z=[],D=[],M=[],T=[],N=new i.Cartesian3,V=new t.BoundingSphere,H=new o.OrientedBoundingBox,E=new t.Cartesian2,R=new i.Cartesian3;function O(){this.vertexBuffer=void 0,this.index=void 0,this.first=void 0,this.second=void 0,this.ratio=void 0}O.prototype.clone=function(e){return n.defined(e)||(e=new O),e.uBuffer=this.uBuffer,e.vBuffer=this.vBuffer,e.heightBuffer=this.heightBuffer,e.normalBuffer=this.normalBuffer,e.index=this.index,e.first=this.first,e.second=this.second,e.ratio=this.ratio,e},O.prototype.initializeIndexed=function(e,t,i,n,r){this.uBuffer=e,this.vBuffer=t,this.heightBuffer=i,this.normalBuffer=n,this.index=r,this.first=void 0,this.second=void 0,this.ratio=void 0},O.prototype.initializeFromClipResult=function(e,t,i){var n=t+1;return-1!==e[t]?i[e[t]].clone(this):(this.vertexBuffer=void 0,this.index=void 0,this.first=i[e[n]],++n,this.second=i[e[n]],++n,this.ratio=e[n],++n),n},O.prototype.getKey=function(){return this.isIndexed()?this.index:JSON.stringify({first:this.first.getKey(),second:this.second.getKey(),ratio:this.ratio})},O.prototype.isIndexed=function(){return n.defined(this.index)},O.prototype.getH=function(e,t){if(n.defined(this.index))return this.heightBuffer[this.index];var i=this.first.getH(e,t),r=this.second.getH(e,t);return 0===t+i/v*e||0===t+r/v*e?0:u.Math3D.lerp(this.first.getH(),this.second.getH(),this.ratio)},O.prototype.getU=function(){return n.defined(this.index)?this.uBuffer[this.index]:u.Math3D.lerp(this.first.getU(),this.second.getU(),this.ratio)},O.prototype.getV=function(){return n.defined(this.index)?this.vBuffer[this.index]:u.Math3D.lerp(this.first.getV(),this.second.getV(),this.ratio)};var U=new t.Cartesian2,F=-1,P=[new i.Cartesian3,new i.Cartesian3],S=[new i.Cartesian3,new i.Cartesian3];function k(t,n){++F;var r=P[F],s=S[F];return r=e.AttributeCompression.octDecode(t.first.getNormalX(),t.first.getNormalY(),r),s=e.AttributeCompression.octDecode(t.second.getNormalX(),t.second.getNormalY(),s),I=i.Cartesian3.lerp(r,s,t.ratio,I),i.Cartesian3.normalize(I,I),e.AttributeCompression.octEncode(I,n),--F,n}O.prototype.getNormalX=function(){return n.defined(this.index)?this.normalBuffer[2*this.index]:(U=k(this,U)).x},O.prototype.getNormalY=function(){return n.defined(this.index)?this.normalBuffer[2*this.index+1]:(U=k(this,U)).y};var L=[];function W(e,t,i,r,s,h,u,o,a,p,d){if(0!==u.length){for(var f=0,l=0;l<u.length;)l=L[f++].initializeFromClipResult(u,l,o);for(var c=0;c<f;++c){var g=L[c];if(g.isIndexed())g.newIndex=h[g.index],g.uBuffer=e,g.vBuffer=t,g.heightBuffer=i,a&&(g.normalBuffer=r);else{var x=g.getKey();if(n.defined(h[x]))g.newIndex=h[x];else{var m=e.length;e.push(g.getU()),t.push(g.getV()),i.push(g.getH(p,d)),a&&(r.push(g.getNormalX()),r.push(g.getNormalY())),g.newIndex=m,h[x]=m}}}3===f?(s.push(L[0].newIndex),s.push(L[1].newIndex),s.push(L[2].newIndex)):4===f&&(s.push(L[0].newIndex),s.push(L[1].newIndex),s.push(L[2].newIndex),s.push(L[0].newIndex),s.push(L[2].newIndex),s.push(L[3].newIndex))}}return L.push(new O),L.push(new O),L.push(new O),L.push(new O),a((function(e,n){var h=e.isEastChild,a=e.isNorthChild,p=h?w:0,d=h?v:w,f=a?w:0,l=a?v:w,c=A,g=z,x=D,U=T;c.length=0,g.length=0,x.length=0,U.length=0;var F=M;F.length=0;var P={},S=e.vertices,k=e.indices;k=k.subarray(0,e.indexCountWithoutSkirts);var L,X,K,Y,G,_=r.TerrainEncoding.clone(e.encoding),J=_.hasVertexNormals,Z=e.exaggeration,j=0,q=e.vertexCountWithoutSkirts,Q=e.minimumHeight,$=e.maximumHeight,ee=new Array(q),te=new Array(q),ie=new Array(q),ne=J?new Array(2*q):void 0;for(X=0,K=0;X<q;++X,K+=2){var re=_.decodeTextureCoordinates(S,X,E);if(L=_.decodeHeight(S,X)/Z,Y=u.Math3D.clamp(re.x*v|0,0,v),G=u.Math3D.clamp(re.y*v|0,0,v),ie[X]=u.Math3D.clamp((L-Q)/($-Q)*v|0,0,v),Y<20&&(Y=0),G<20&&(G=0),v-Y<20&&(Y=v),v-G<20&&(G=v),ee[X]=Y,te[X]=G,J){var se=_.getOctEncodedNormal(S,X,R);ne[K]=se.x,ne[K+1]=se.y}(h&&Y>=w||!h&&Y<=w)&&(a&&G>=w||!a&&G<=w)&&(P[X]=j,c.push(Y),g.push(G),x.push(ie[X]),J&&(U.push(ne[K]),U.push(ne[K+1])),++j)}var he=[];he.push(new O),he.push(new O),he.push(new O);var ue,oe=[];for(oe.push(new O),oe.push(new O),oe.push(new O),X=0;X<k.length;X+=3){var ae=k[X],pe=k[X+1],de=k[X+2],fe=ee[ae],le=ee[pe],ce=ee[de];he[0].initializeIndexed(ee,te,ie,ne,ae),he[1].initializeIndexed(ee,te,ie,ne,pe),he[2].initializeIndexed(ee,te,ie,ne,de);var ge=m.clipTriangleAtAxisAlignedThreshold(w,h,fe,le,ce,y);(ue=0)>=ge.length||((ue=oe[0].initializeFromClipResult(ge,ue,he))>=ge.length||(ue=oe[1].initializeFromClipResult(ge,ue,he))>=ge.length||(ue=oe[2].initializeFromClipResult(ge,ue,he),W(c,g,x,U,F,P,m.clipTriangleAtAxisAlignedThreshold(w,a,oe[0].getV(),oe[1].getV(),oe[2].getV(),C),oe,J,$,Q),ue<ge.length&&(oe[2].clone(oe[1]),oe[2].initializeFromClipResult(ge,ue,he),W(c,g,x,U,F,P,m.clipTriangleAtAxisAlignedThreshold(w,a,oe[0].getV(),oe[1].getV(),oe[2].getV(),C),oe,J,$,Q))))}var xe=h?-32767:0,me=a?-32767:0,ve=[],we=[],ye=[],Ce=[],Be=Number.MAX_VALUE,be=-Be,Ie=B;Ie.length=0;var Ae=t.Ellipsoid.clone(e.ellipsoid),ze=t.Rectangle.clone(e.childRectangle),De=ze.north,Me=ze.south,Te=ze.east,Ne=ze.west;for(Te<Ne&&(Te+=u.Math3D.TWO_PI),X=0;X<c.length;++X)(Y=Math.round(c[X]))<=p?(ve.push(X),Y=0):Y>=d?(ye.push(X),Y=v):Y=2*Y+xe,c[X]=Y,(G=Math.round(g[X]))<=f?(we.push(X),G=0):G>=l?(Ce.push(X),G=v):G=2*G+me,g[X]=G,(L=u.Math3D.lerp(Q,$,x[X]/v))<Be&&(Be=L),L>be&&(be=L),x[X]=L,b.longitude=u.Math3D.lerp(Ne,Te,Y/v),b.latitude=u.Math3D.lerp(Me,De,G/v),b.height=L,Ae.cartographicToCartesian(b,I),Ie.push(I.x),Ie.push(I.y),Ie.push(I.z);var Ve=t.BoundingSphere.fromVertices(Ie,i.Cartesian3.ZERO,3,V),He=o.OrientedBoundingBox.fromRectangle(ze,Be,be,Ae,H),Ee=new r.EllipsoidalOccluder(Ae).computeHorizonCullingPointFromVerticesPossiblyUnderEllipsoid(Ve.center,Ie,3,Ve.center,Be,N),Re=be-Be,Oe=new Uint16Array(c.length+g.length+x.length);for(X=0;X<c.length;++X)Oe[X]=c[X];var Ue=c.length;for(X=0;X<g.length;++X)Oe[Ue+X]=g[X];for(Ue+=g.length,X=0;X<x.length;++X)Oe[Ue+X]=v*(x[X]-Be)/Re;var Fe,Pe=s.IndexDatatype.createTypedArray(c.length,F);if(J){var Se=new Uint8Array(U);n.push(Oe.buffer,Pe.buffer,Se.buffer),Fe=Se.buffer}else n.push(Oe.buffer,Pe.buffer);return{vertices:Oe.buffer,encodedNormals:Fe,indices:Pe.buffer,minimumHeight:Be,maximumHeight:be,westIndices:ve,southIndices:we,eastIndices:ye,northIndices:Ce,boundingSphere:Ve,orientedBoundingBox:He,horizonOcclusionPoint:Ee}}))}));
|