define(["./AttributeCompression-8cb78525","./Transforms-a6362ad2","./Matrix2-ae0e0b05","./when-e3a49219","./TerrainEncoding-d0dbd995","./IndexDatatype-e12e2493","./RuntimeError-ffc802eb","./ComponentDatatype-64cf6611","./OrientedBoundingBox-d2fffacc","./createTaskProcessorWorker","./combine-c7a1ec8a","./PixelFormat-83d70a69","./WebGLConstants-1c8239cc","./EllipsoidTangentPlane-e3af9e65","./AxisAlignedBoundingBox-699685f5","./IntersectionTests-8be403d7","./Plane-2bf1bb80"],(function(e,i,t,n,s,r,h,u,o,a,p,d,f,l,c,g,m){"use strict";var x={clipTriangleAtAxisAlignedThreshold:function(e,i,t,s,r,h){var u,o,a;n.defined(h)?h.length=0:h=[],i?(u=t<e,o=s<e,a=r<e):(u=t>e,o=s>e,a=r>e);var p,d,f,l,c,g,m=u+o+a;return 1===m?u?(p=(e-t)/(s-t),d=(e-t)/(r-t),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-s)/(r-s),l=(e-s)/(t-s),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-r)/(t-r),g=(e-r)/(s-r),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===m?u||t===e?o||s===e?a||r===e||(d=(e-t)/(r-t),f=(e-s)/(r-s),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-r)/(s-r),p=(e-t)/(s-t),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-s)/(t-s),c=(e-r)/(t-r),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!==m&&(h.push(0),h.push(1),h.push(2)),h},computeBarycentricCoordinates:function(e,i,s,r,h,u,o,a,p){var d=s-o,f=o-h,l=u-a,c=r-a,g=1/(l*d+f*c),m=i-a,x=e-o,v=(l*x+f*m)*g,w=(-c*x+d*m)*g,C=1-v-w;return n.defined(p)?(p.x=v,p.y=w,p.z=C,p):new t.Cartesian3(v,w,C)},computeLineSegmentLineSegmentIntersection:function(e,i,s,r,h,u,o,a,p){var d=(a-u)*(s-e)-(o-h)*(r-i);if(0!==d){var f=((o-h)*(i-u)-(a-u)*(e-h))/d,l=((s-e)*(i-u)-(r-i)*(e-h))/d;return f>=0&&f<=1&&l>=0&&l<=1?(n.defined(p)||(p=new t.Cartesian2),p.x=e+f*(s-e),p.y=i+f*(r-i),p):void 0}}},v=32767,w=16383,C=[],B=[],y=[],I=new t.Cartographic,A=new t.Cartesian3,b=[],T=[],z=[],M=[],N=[],V=new t.Cartesian3,E=new i.BoundingSphere,R=new o.OrientedBoundingBox,H=new t.Cartesian2,O=new t.Cartesian3;function F(){this.vertexBuffer=void 0,this.index=void 0,this.first=void 0,this.second=void 0,this.ratio=void 0}F.prototype.clone=function(e){return n.defined(e)||(e=new F),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},F.prototype.initializeIndexed=function(e,i,t,n,s){this.uBuffer=e,this.vBuffer=i,this.heightBuffer=t,this.normalBuffer=n,this.index=s,this.first=void 0,this.second=void 0,this.ratio=void 0},F.prototype.initializeFromClipResult=function(e,i,t){var n=i+1;return-1!==e[i]?t[e[i]].clone(this):(this.vertexBuffer=void 0,this.index=void 0,this.first=t[e[n]],++n,this.second=t[e[n]],++n,this.ratio=e[n],++n),n},F.prototype.getKey=function(){return this.isIndexed()?this.index:JSON.stringify({first:this.first.getKey(),second:this.second.getKey(),ratio:this.ratio})},F.prototype.isIndexed=function(){return n.defined(this.index)},F.prototype.getH=function(){return n.defined(this.index)?this.heightBuffer[this.index]:u.CesiumMath.lerp(this.first.getH(),this.second.getH(),this.ratio)},F.prototype.getU=function(){return n.defined(this.index)?this.uBuffer[this.index]:u.CesiumMath.lerp(this.first.getU(),this.second.getU(),this.ratio)},F.prototype.getV=function(){return n.defined(this.index)?this.vBuffer[this.index]:u.CesiumMath.lerp(this.first.getV(),this.second.getV(),this.ratio)};var P=new t.Cartesian2,S=-1,U=[new t.Cartesian3,new t.Cartesian3],D=[new t.Cartesian3,new t.Cartesian3];function W(i,n){++S;var s=U[S],r=D[S];return s=e.AttributeCompression.octDecode(i.first.getNormalX(),i.first.getNormalY(),s),r=e.AttributeCompression.octDecode(i.second.getNormalX(),i.second.getNormalY(),r),A=t.Cartesian3.lerp(s,r,i.ratio,A),t.Cartesian3.normalize(A,A),e.AttributeCompression.octEncode(A,n),--S,n}F.prototype.getNormalX=function(){return n.defined(this.index)?this.normalBuffer[2*this.index]:(P=W(this,P)).x},F.prototype.getNormalY=function(){return n.defined(this.index)?this.normalBuffer[2*this.index+1]:(P=W(this,P)).y};var X=[];function k(e,i,t,s,r,h,u,o,a){if(0!==u.length){for(var p=0,d=0;d<u.length;)d=X[p++].initializeFromClipResult(u,d,o);for(var f=0;f<p;++f){var l=X[f];if(l.isIndexed())l.newIndex=h[l.index],l.uBuffer=e,l.vBuffer=i,l.heightBuffer=t,a&&(l.normalBuffer=s);else{var c=l.getKey();if(n.defined(h[c]))l.newIndex=h[c];else{var g=e.length;e.push(l.getU()),i.push(l.getV()),t.push(l.getH()),a&&(s.push(l.getNormalX()),s.push(l.getNormalY())),l.newIndex=g,h[c]=g}}}3===p?(r.push(X[0].newIndex),r.push(X[1].newIndex),r.push(X[2].newIndex)):4===p&&(r.push(X[0].newIndex),r.push(X[1].newIndex),r.push(X[2].newIndex),r.push(X[0].newIndex),r.push(X[2].newIndex),r.push(X[3].newIndex))}}return X.push(new F),X.push(new F),X.push(new F),X.push(new F),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=b,g=T,m=z,P=N;c.length=0,g.length=0,m.length=0,P.length=0;var S=M;S.length=0;var U={},D=e.vertices,W=e.indices;W=W.subarray(0,e.indexCountWithoutSkirts);var X,K,L,Y,_,G=s.TerrainEncoding.clone(e.encoding),J=G.hasVertexNormals,Z=0,j=e.vertexCountWithoutSkirts,q=e.minimumHeight,Q=e.maximumHeight,$=new Array(j),ee=new Array(j),ie=new Array(j),te=J?new Array(2*j):void 0;for(K=0,L=0;K<j;++K,L+=2){var ne=G.decodeTextureCoordinates(D,K,H);if(X=G.decodeHeight(D,K),Y=u.CesiumMath.clamp(ne.x*v|0,0,v),_=u.CesiumMath.clamp(ne.y*v|0,0,v),ie[K]=u.CesiumMath.clamp((X-q)/(Q-q)*v|0,0,v),Y<20&&(Y=0),_<20&&(_=0),v-Y<20&&(Y=v),v-_<20&&(_=v),$[K]=Y,ee[K]=_,J){var se=G.getOctEncodedNormal(D,K,O);te[L]=se.x,te[L+1]=se.y}(h&&Y>=w||!h&&Y<=w)&&(a&&_>=w||!a&&_<=w)&&(U[K]=Z,c.push(Y),g.push(_),m.push(ie[K]),J&&(P.push(te[L]),P.push(te[L+1])),++Z)}var re=[];re.push(new F),re.push(new F),re.push(new F);var he,ue=[];for(ue.push(new F),ue.push(new F),ue.push(new F),K=0;K<W.length;K+=3){var oe=W[K],ae=W[K+1],pe=W[K+2],de=$[oe],fe=$[ae],le=$[pe];re[0].initializeIndexed($,ee,ie,te,oe),re[1].initializeIndexed($,ee,ie,te,ae),re[2].initializeIndexed($,ee,ie,te,pe);var ce=x.clipTriangleAtAxisAlignedThreshold(w,h,de,fe,le,C);(he=0)>=ce.length||((he=ue[0].initializeFromClipResult(ce,he,re))>=ce.length||(he=ue[1].initializeFromClipResult(ce,he,re))>=ce.length||(he=ue[2].initializeFromClipResult(ce,he,re),k(c,g,m,P,S,U,x.clipTriangleAtAxisAlignedThreshold(w,a,ue[0].getV(),ue[1].getV(),ue[2].getV(),B),ue,J),he<ce.length&&(ue[2].clone(ue[1]),ue[2].initializeFromClipResult(ce,he,re),k(c,g,m,P,S,U,x.clipTriangleAtAxisAlignedThreshold(w,a,ue[0].getV(),ue[1].getV(),ue[2].getV(),B),ue,J))))}var ge=h?-32767:0,me=a?-32767:0,xe=[],ve=[],we=[],Ce=[],Be=Number.MAX_VALUE,ye=-Be,Ie=y;Ie.length=0;var Ae=t.Ellipsoid.clone(e.ellipsoid),be=t.Rectangle.clone(e.childRectangle),Te=be.north,ze=be.south,Me=be.east,Ne=be.west;for(Me<Ne&&(Me+=u.CesiumMath.TWO_PI),K=0;K<c.length;++K)(Y=Math.round(c[K]))<=p?(xe.push(K),Y=0):Y>=d?(we.push(K),Y=v):Y=2*Y+ge,c[K]=Y,(_=Math.round(g[K]))<=f?(ve.push(K),_=0):_>=l?(Ce.push(K),_=v):_=2*_+me,g[K]=_,(X=u.CesiumMath.lerp(q,Q,m[K]/v))<Be&&(Be=X),X>ye&&(ye=X),m[K]=X,I.longitude=u.CesiumMath.lerp(Ne,Me,Y/v),I.latitude=u.CesiumMath.lerp(ze,Te,_/v),I.height=X,Ae.cartographicToCartesian(I,A),Ie.push(A.x),Ie.push(A.y),Ie.push(A.z);var Ve=i.BoundingSphere.fromVertices(Ie,t.Cartesian3.ZERO,3,E),Ee=o.OrientedBoundingBox.fromRectangle(be,Be,ye,Ae,R),Re=new s.EllipsoidalOccluder(Ae).computeHorizonCullingPointFromVerticesPossiblyUnderEllipsoid(Ve.center,Ie,3,Ve.center,Be,V),He=ye-Be,Oe=new Uint16Array(c.length+g.length+m.length);for(K=0;K<c.length;++K)Oe[K]=c[K];var Fe=c.length;for(K=0;K<g.length;++K)Oe[Fe+K]=g[K];for(Fe+=g.length,K=0;K<m.length;++K)Oe[Fe+K]=v*(m[K]-Be)/He;var Pe,Se=r.IndexDatatype.createTypedArray(c.length,S);if(J){var Ue=new Uint8Array(P);n.push(Oe.buffer,Se.buffer,Ue.buffer),Pe=Ue.buffer}else n.push(Oe.buffer,Se.buffer);return{vertices:Oe.buffer,encodedNormals:Pe,indices:Se.buffer,minimumHeight:Be,maximumHeight:ye,westIndices:xe,southIndices:ve,eastIndices:we,northIndices:Ce,boundingSphere:Ve,orientedBoundingBox:Ee,horizonOcclusionPoint:Re}}))}));
|