define(["./AttributeCompression-747df01a","./Transforms-b2d190a4","./Matrix2-671a840a","./defaultValue-69ee94f4","./TerrainEncoding-8b4ef476","./IndexDatatype-1cbc8622","./RuntimeError-ac440aa5","./ComponentDatatype-a9820060","./OrientedBoundingBox-20c61072","./createTaskProcessorWorker","./_commonjsHelpers-3aae1032-15991586","./combine-0259f56f","./PixelFormat-9ceadbf3","./WebGLConstants-f63312fc","./EllipsoidTangentPlane-8dba80f8","./AxisAlignedBoundingBox-41c092aa","./IntersectionTests-3c5a408d","./Plane-2cd3a9dd"],(function(e,t,n,i,s,r,h,o,u,d,p,a,l,f,c,g,m,x){"use strict";const w={clipTriangleAtAxisAlignedThreshold:function(e,t,n,s,r,h){let o,u,d;i.defined(h)?h.length=0:h=[],t?(o=ne,u=s>e,d=r>e);const p=o+u+d;let a,l,f,c,g,m;return 1===p?o?(a=(e-n)/(s-n),l=(e-n)/(r-n),h.push(1),h.push(2),1!==l&&(h.push(-1),h.push(0),h.push(2),h.push(l)),1!==a&&(h.push(-1),h.push(0),h.push(1),h.push(a))):u?(f=(e-s)/(r-s),c=(e-s)/(n-s),h.push(2),h.push(0),1!==c&&(h.push(-1),h.push(1),h.push(0),h.push(c)),1!==f&&(h.push(-1),h.push(1),h.push(2),h.push(f))):d&&(g=(e-r)/(n-r),m=(e-r)/(s-r),h.push(0),h.push(1),1!==m&&(h.push(-1),h.push(2),h.push(1),h.push(m)),1!==g&&(h.push(-1),h.push(2),h.push(0),h.push(g))):2===p?o||n===e?u||s===e?d||r===e||(l=(e-n)/(r-n),f=(e-s)/(r-s),h.push(2),h.push(-1),h.push(0),h.push(2),h.push(l),h.push(-1),h.push(1),h.push(2),h.push(f)):(m=(e-r)/(s-r),a=(e-n)/(s-n),h.push(1),h.push(-1),h.push(2),h.push(1),h.push(m),h.push(-1),h.push(0),h.push(1),h.push(a)):(c=(e-s)/(n-s),g=(e-r)/(n-r),h.push(0),h.push(-1),h.push(1),h.push(0),h.push(c),h.push(-1),h.push(2),h.push(0),h.push(g)):3!==p&&(h.push(0),h.push(1),h.push(2)),h},computeBarycentricCoordinates:function(e,t,s,r,h,o,u,d,p){const a=s-u,l=u-h,f=o-d,c=r-d,g=1/(f*a+l*c),m=t-d,x=e-u,w=(f*x+l*m)*g,C=(-c*x+a*m)*g,B=1-w-C;return i.defined(p)?(p.x=w,p.y=C,p.z=B,p):new n.Cartesian3(w,C,B)},computeLineSegmentLineSegmentIntersection:function(e,t,s,r,h,o,u,d,p){const a=(d-o)*(s-e)-(u-h)*(r-t);if(0===a)return;const l=((u-h)*(t-o)-(d-o)*(e-h))/a,f=((s-e)*(t-o)-(r-t)*(e-h))/a;return l>=0&&l<=1&&f>=0&&f<=1?(i.defined(p)||(p=new n.Cartesian2),p.x=e+l*(s-e),p.y=t+l*(r-t),p):void 0}},C=32767,B=16383,y=[],I=[],A=[],b=new n.Cartographic;let v=new n.Cartesian3;const T=[],z=[],V=[],M=[],N=[],E=new n.Cartesian3,H=new t.BoundingSphere,R=new u.OrientedBoundingBox,O=new n.Cartesian2,F=new n.Cartesian3;function P(){this.vertexBuffer=void 0,this.index=void 0,this.first=void 0,this.second=void 0,this.ratio=void 0}P.prototype.clone=function(e){return i.defined(e)||(e=new P),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},P.prototype.initializeIndexed=function(e,t,n,i,s){this.uBuffer=e,this.vBuffer=t,this.heightBuffer=n,this.normalBuffer=i,this.index=s,this.first=void 0,this.second=void 0,this.ratio=void 0},P.prototype.initializeFromClipResult=function(e,t,n){let i=t+1;return-1!==e[t]?n[e[t]].clone(this):(this.vertexBuffer=void 0,this.index=void 0,this.first=n[e[i]],++i,this.second=n[e[i]],++i,this.ratio=e[i],++i),i},P.prototype.getKey=function(){return this.isIndexed()?this.index:JSON.stringify({first:this.first.getKey(),second:this.second.getKey(),ratio:this.ratio})},P.prototype.isIndexed=function(){return i.defined(this.index)},P.prototype.getH=function(){return i.defined(this.index)?this.heightBuffer[this.index]:o.CesiumMath.lerp(this.first.getH(),this.second.getH(),this.ratio)},P.prototype.getU=function(){return i.defined(this.index)?this.uBuffer[this.index]:o.CesiumMath.lerp(this.first.getU(),this.second.getU(),this.ratio)},P.prototype.getV=function(){return i.defined(this.index)?this.vBuffer[this.index]:o.CesiumMath.lerp(this.first.getV(),this.second.getV(),this.ratio)};let S=new n.Cartesian2,U=-1;const D=[new n.Cartesian3,new n.Cartesian3],W=[new n.Cartesian3,new n.Cartesian3];function X(t,i){++U;let s=D[U],r=W[U];return s=e.AttributeCompression.octDecode(t.first.getNormalX(),t.first.getNormalY(),s),r=e.AttributeCompression.octDecode(t.second.getNormalX(),t.second.getNormalY(),r),v=n.Cartesian3.lerp(s,r,t.ratio,v),n.Cartesian3.normalize(v,v),e.AttributeCompression.octEncode(v,i),--U,i}P.prototype.getNormalX=function(){return i.defined(this.index)?this.normalBuffer[2*this.index]:(S=X(this,S),S.x)},P.prototype.getNormalY=function(){return i.defined(this.index)?this.normalBuffer[2*this.index+1]:(S=X(this,S),S.y)};const k=[];function K(e,t,n,s,r,h,o,u,d){if(0===o.length)return;let p=0,a=0;for(;a=B||!h&&te<=B)&&(d&&ne>=B||!d&&ne<=B)&&(U[$]=L,c.push(te),g.push(ne),m.push(Z[$]),k&&(x.push(q[ee]),x.push(q[ee+1])),++L)}const ie=[];ie.push(new P),ie.push(new P),ie.push(new P);const se=[];let re,he;for(se.push(new P),se.push(new P),se.push(new P),$=0;$=o.length||(re=se[0].initializeFromClipResult(o,re,ie),re>=o.length||(re=se[1].initializeFromClipResult(o,re,ie),re>=o.length||(re=se[2].initializeFromClipResult(o,re,ie),he=w.clipTriangleAtAxisAlignedThreshold(B,d,se[0].getV(),se[1].getV(),se[2].getV(),I),K(c,g,m,x,S,U,he,se,k),re=a?(ae.push($),te=C):te=2*te+oe,c[$]=te,ne=Math.round(g[$]),ne<=l?(pe.push($),ne=0):ne>=f?(le.push($),ne=C):ne=2*ne+ue,g[$]=ne,Q=o.CesiumMath.lerp(_,j,m[$]/C),Qce&&(ce=Q),m[$]=Q,b.longitude=o.CesiumMath.lerp(ye,Be,te/C),b.latitude=o.CesiumMath.lerp(Ce,we,ne/C),b.height=Q,me.cartographicToCartesian(b,v),ge.push(v.x),ge.push(v.y),ge.push(v.z);const Ie=t.BoundingSphere.fromVertices(ge,n.Cartesian3.ZERO,3,H),Ae=u.OrientedBoundingBox.fromRectangle(xe,fe,ce,me,R),be=new s.EllipsoidalOccluder(me).computeHorizonCullingPointFromVerticesPossiblyUnderEllipsoid(Ie.center,ge,3,Ie.center,fe,E),ve=ce-fe,Te=new Uint16Array(c.length+g.length+m.length);for($=0;$