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=te,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=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=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))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