define(["./AttributeCompression-af7f4dda","./Transforms-75891ac8","./Matrix2-2fec35ad","./when-229515d6","./TerrainEncoding-c8019d31","./IndexDatatype-b10faa0b","./RuntimeError-ffe03243","./ComponentDatatype-17b06483","./OrientedBoundingBox-be6343b4","./createTaskProcessorWorker","./combine-8ce3f24b","./PixelFormat-daf99ebc","./WebGLConstants-4e26b85a","./EllipsoidTangentPlane-52a8d8f6","./AxisAlignedBoundingBox-9cc0d3fd","./IntersectionTests-c2481e4c","./Plane-c66ae040"],(function(e,i,t,n,s,r,h,u,o,a,d,p,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=te,o=s>e,a=r>e);var d,p,f,l,c,g,m=u+o+a;return 1===m?u?(d=(e-t)/(s-t),p=(e-t)/(r-t),h.push(1),h.push(2),1!==p&&(h.push(-1),h.push(0),h.push(2),h.push(p)),1!==d&&(h.push(-1),h.push(0),h.push(1),h.push(d))):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||(p=(e-t)/(r-t),f=(e-s)/(r-s),h.push(2),h.push(-1),h.push(0),h.push(2),h.push(p),h.push(-1),h.push(1),h.push(2),h.push(f)):(g=(e-r)/(s-r),d=(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(d)):(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,d){var p=s-o,f=o-h,l=u-a,c=r-a,g=1/(l*p+f*c),m=i-a,x=e-o,v=(l*x+f*m)*g,w=(-c*x+p*m)*g,C=1-v-w;return n.defined(d)?(d.x=v,d.y=w,d.z=C,d):new t.Cartesian3(v,w,C)},computeLineSegmentLineSegmentIntersection:function(e,i,s,r,h,u,o,a,d){var p=(a-u)*(s-e)-(o-h)*(r-i);if(0!==p){var f=((o-h)*(i-u)-(a-u)*(e-h))/p,l=((s-e)*(i-u)-(r-i)*(e-h))/p;return f>=0&&f<=1&&l>=0&&l<=1?(n.defined(d)||(d=new t.Cartesian2),d.x=e+f*(s-e),d.y=i+f*(r-i),d):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 d=0,p=0;p=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=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=p?(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))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