chunk-AOW426VA.js 31 KB

1
  1. import{a as or}from"./chunk-MJVT7BN7.js";import{a as Kr}from"./chunk-WTYKDBBN.js";import{b as Ir}from"./chunk-OGTTQ4KL.js";import{a as Rr}from"./chunk-7AR5UXG3.js";import{a as Z}from"./chunk-XKBSMKNP.js";import{a as Xr,b as Jr,d as hr,e as Sr,g as q,n as C,o as Y}from"./chunk-K2IDXOCV.js";import{a as Vr,b as Q}from"./chunk-45OWWDV7.js";import{a as k}from"./chunk-JX5O4HI2.js";import{a as G}from"./chunk-FEOWMVRK.js";import{a as Tr}from"./chunk-CB3KB2D3.js";import{a as v,c as Wr}from"./chunk-I46SWINN.js";import{a as x}from"./chunk-LNIYJJXS.js";import{a as ar}from"./chunk-4D2ERGZX.js";import{a as yr}from"./chunk-EDZQSM3T.js";import{a as b}from"./chunk-PJGSCWXZ.js";import{a as f}from"./chunk-NUC3LT2W.js";var Qr=new v,$r=new v,jr=new v;function Ta(r,a,e,n,i){yr.defined("point",r),yr.defined("p0",a),yr.defined("p1",e),yr.defined("p2",n),f(i)||(i=new v);var o,t,l,u,s,c,w,m;if(f(a.z)){if(v.equalsEpsilon(r,a,x.EPSILON14))return v.clone(v.UNIT_X,i);if(v.equalsEpsilon(r,e,x.EPSILON14))return v.clone(v.UNIT_Y,i);if(v.equalsEpsilon(r,n,x.EPSILON14))return v.clone(v.UNIT_Z,i);o=v.subtract(e,a,Qr),t=v.subtract(n,a,$r),l=v.subtract(r,a,jr),u=v.dot(o,o),s=v.dot(o,t),c=v.dot(o,l),w=v.dot(t,t),m=v.dot(t,l)}else{if(G.equalsEpsilon(r,a,x.EPSILON14))return v.clone(v.UNIT_X,i);if(G.equalsEpsilon(r,e,x.EPSILON14))return v.clone(v.UNIT_Y,i);if(G.equalsEpsilon(r,n,x.EPSILON14))return v.clone(v.UNIT_Z,i);o=G.subtract(e,a,Qr),t=G.subtract(n,a,$r),l=G.subtract(r,a,jr),u=G.dot(o,o),s=G.dot(o,t),c=G.dot(o,l),w=G.dot(t,t),m=G.dot(t,l)}i.y=w*c-s*m,i.z=u*m-s*c;var h=u*w-s*s;return i.y!==0&&(i.y/=h),i.z!==0&&(i.z/=h),i.x=1-i.y-i.z,i}var ra=Ta;var Gr={};Gr.calculateACMR=function(r){r=ar(r,ar.EMPTY_OBJECT);var a=r.indices,e=r.maximumIndex,n=ar(r.cacheSize,24);if(!f(a))throw new b("indices is required.");var i=a.length;if(i<3||i%3!==0)throw new b("indices length must be a multiple of three.");if(e<=0)throw new b("maximumIndex must be greater than zero.");if(n<3)throw new b("cacheSize must be greater than two.");if(!f(e)){e=0;for(var o=0,t=a[o];o<i;)t>e&&(e=t),++o,t=a[o]}for(var l=[],u=0;u<e+1;u++)l[u]=0;for(var s=n+1,c=0;c<i;++c)s-l[a[c]]>n&&(l[a[c]]=s,++s);return(s-n+1)/(i/3)};Gr.tipsify=function(r){r=ar(r,ar.EMPTY_OBJECT);var a=r.indices,e=r.maximumIndex,n=ar(r.cacheSize,24),i;function o(R,D,_,B){for(;D.length>=1;){var I=D[D.length-1];if(D.splice(D.length-1,1),R[I].numLiveTriangles>0)return I}for(;i<B;){if(R[i].numLiveTriangles>0)return++i,i-1;++i}return-1}function t(R,D,_,B,I,H,rr){for(var W=-1,nr,vr=-1,ir=0;ir<_.length;){var K=_[ir];B[K].numLiveTriangles&&(nr=0,I-B[K].timeStamp+2*B[K].numLiveTriangles<=D&&(nr=I-B[K].timeStamp),(nr>vr||vr===-1)&&(vr=nr,W=K)),++ir}return W===-1?o(B,H,R,rr):W}if(!f(a))throw new b("indices is required.");var l=a.length;if(l<3||l%3!==0)throw new b("indices length must be a multiple of three.");if(e<=0)throw new b("maximumIndex must be greater than zero.");if(n<3)throw new b("cacheSize must be greater than two.");var u=0,s=0,c=a[s],w=l;if(f(e))u=e+1;else{for(;s<w;)c>u&&(u=c),++s,c=a[s];if(u===-1)return 0;++u}var m=[],h;for(h=0;h<u;h++)m[h]={numLiveTriangles:0,timeStamp:0,vertexTriangles:[]};s=0;for(var p=0;s<w;)m[a[s]].vertexTriangles.push(p),++m[a[s]].numLiveTriangles,m[a[s+1]].vertexTriangles.push(p),++m[a[s+1]].numLiveTriangles,m[a[s+2]].vertexTriangles.push(p),++m[a[s+2]].numLiveTriangles,++p,s+=3;var A=0,g=n+1;i=1;var S=[],T=[],y,d,O=0,N=[],E=l/3,P=[];for(h=0;h<E;h++)P[h]=!1;for(var z,V;A!==-1;){S=[],d=m[A],V=d.vertexTriangles.length;for(var L=0;L<V;++L)if(p=d.vertexTriangles[L],!P[p]){P[p]=!0,s=p+p+p;for(var F=0;F<3;++F)z=a[s],S.push(z),T.push(z),N[O]=z,++O,y=m[z],--y.numLiveTriangles,g-y.timeStamp>n&&(y.timeStamp=g,++g),++s}A=t(a,n,S,m,g,T,u)}return N};var aa=Gr;var M={};function qr(r,a,e,n,i){r[a++]=e,r[a++]=n,r[a++]=n,r[a++]=i,r[a++]=i,r[a]=e}function Sa(r){for(var a=r.length,e=a/3*6,n=Z.createTypedArray(a,e),i=0,o=0;o<a;o+=3,i+=6)qr(n,i,r[o],r[o+1],r[o+2]);return n}function ba(r){var a=r.length;if(a>=3){var e=(a-2)*6,n=Z.createTypedArray(a,e);qr(n,0,r[0],r[1],r[2]);for(var i=6,o=3;o<a;++o,i+=6)qr(n,i,r[o-1],r[o],r[o-2]);return n}return new Uint16Array}function ga(r){if(r.length>0){for(var a=r.length-1,e=(a-1)*6,n=Z.createTypedArray(a,e),i=r[0],o=0,t=1;t<a;++t,o+=6)qr(n,o,i,r[t],r[t+1]);return n}return new Uint16Array}M.toWireframe=function(r){if(!f(r))throw new b("geometry is required.");var a=r.indices;if(f(a)){switch(r.primitiveType){case q.TRIANGLES:r.indices=Sa(a);break;case q.TRIANGLE_STRIP:r.indices=ba(a);break;case q.TRIANGLE_FAN:r.indices=ga(a);break;default:throw new b("geometry.primitiveType must be TRIANGLES, TRIANGLE_STRIP, or TRIANGLE_FAN.")}r.primitiveType=q.LINES}return r};M.createLineSegmentsForVectors=function(r,a,e){if(a=ar(a,"normal"),!f(r))throw new b("geometry is required.");if(!f(r.attributes.position))throw new b("geometry.attributes.position is required.");if(!f(r.attributes[a]))throw new b("geometry.attributes must have an attribute with the same name as the attributeName parameter, "+a+".");e=ar(e,1e4);for(var n=r.attributes.position.values,i=r.attributes[a].values,o=n.length,t=new Float64Array(2*o),l=0,u=0;u<o;u+=3)t[l++]=n[u],t[l++]=n[u+1],t[l++]=n[u+2],t[l++]=n[u]+i[u]*e,t[l++]=n[u+1]+i[u+1]*e,t[l++]=n[u+2]+i[u+2]*e;var s,c=r.boundingSphere;return f(c)&&(s=new hr(c.center,c.radius+e)),new C({attributes:{position:new Y({componentDatatype:k.DOUBLE,componentsPerAttribute:3,values:t})},primitiveType:q.LINES,boundingSphere:s})};M.createAttributeLocations=function(r){if(!f(r))throw new b("geometry is required.");var a=["position","positionHigh","positionLow","position3DHigh","position3DLow","position2DHigh","position2DLow","pickColor","normal","st","tangent","bitangent","extrudeDirection","compressedAttributes"],e=r.attributes,n={},i=0,o,t=a.length;for(o=0;o<t;++o){var l=a[o];f(e[l])&&(n[l]=i++)}for(var u in e)e.hasOwnProperty(u)&&!f(n[u])&&(n[u]=i++);return n};M.reorderForPreVertexCache=function(r){if(!f(r))throw new b("geometry is required.");var a=C.computeNumberOfVertices(r),e=r.indices;if(f(e)){for(var n=new Int32Array(a),i=0;i<a;i++)n[i]=-1;for(var o=e,t=o.length,l=Z.createTypedArray(a,t),u=0,s=0,c=0,w;u<t;)w=n[o[u]],w!==-1?l[s]=w:(w=o[u],n[w]=c,l[s]=c,++c),++u,++s;r.indices=l;var m=r.attributes;for(var h in m)if(m.hasOwnProperty(h)&&f(m[h])&&f(m[h].values)){for(var p=m[h],A=p.values,g=0,S=p.componentsPerAttribute,T=k.createTypedArray(p.componentDatatype,c*S);g<a;){var y=n[g];if(y!==-1)for(var d=0;d<S;d++)T[S*y+d]=A[S*g+d];++g}p.values=T}}return r};M.reorderForPostVertexCache=function(r,a){if(!f(r))throw new b("geometry is required.");var e=r.indices;if(r.primitiveType===q.TRIANGLES&&f(e)){for(var n=e.length,i=0,o=0;o<n;o++)e[o]>i&&(i=e[o]);r.indices=aa.tipsify({indices:e,maximumIndex:i,cacheSize:a})}return r};function ea(r){var a={};for(var e in r)if(r.hasOwnProperty(e)&&f(r[e])&&f(r[e].values)){var n=r[e];a[e]=new Y({componentDatatype:n.componentDatatype,componentsPerAttribute:n.componentsPerAttribute,normalize:n.normalize,values:[]})}return a}function Ea(r,a,e){for(var n in a)if(a.hasOwnProperty(n)&&f(a[n])&&f(a[n].values))for(var i=a[n],o=0;o<i.componentsPerAttribute;++o)r[n].values.push(i.values[e*i.componentsPerAttribute+o])}M.fitToUnsignedShortIndices=function(r){if(!f(r))throw new b("geometry is required.");if(f(r.indices)&&r.primitiveType!==q.TRIANGLES&&r.primitiveType!==q.LINES&&r.primitiveType!==q.POINTS)throw new b("geometry.primitiveType must equal to PrimitiveType.TRIANGLES, PrimitiveType.LINES, or PrimitiveType.POINTS.");var a=[],e=C.computeNumberOfVertices(r);if(f(r.indices)&&e>=x.SIXTY_FOUR_KILOBYTES){var n=[],i=[],o=0,t=ea(r.attributes),l=r.indices,u=l.length,s;r.primitiveType===q.TRIANGLES?s=3:r.primitiveType===q.LINES?s=2:r.primitiveType===q.POINTS&&(s=1);for(var c=0;c<u;c+=s){for(var w=0;w<s;++w){var m=l[c+w],h=n[m];f(h)||(h=o++,n[m]=h,Ea(t,r.attributes,m)),i.push(h)}o+s>=x.SIXTY_FOUR_KILOBYTES&&(a.push(new C({attributes:t,indices:i,primitiveType:r.primitiveType,boundingSphere:r.boundingSphere,boundingSphereCV:r.boundingSphereCV})),n=[],i=[],o=0,t=ea(r.attributes))}i.length!==0&&a.push(new C({attributes:t,indices:i,primitiveType:r.primitiveType,boundingSphere:r.boundingSphere,boundingSphereCV:r.boundingSphereCV}))}else a.push(r);return a};var na=new v,La=new Wr;M.projectTo2D=function(r,a,e,n,i){if(!f(r))throw new b("geometry is required.");if(!f(a))throw new b("attributeName is required.");if(!f(e))throw new b("attributeName3D is required.");if(!f(n))throw new b("attributeName2D is required.");if(!f(r.attributes[a]))throw new b("geometry must have attribute matching the attributeName argument: "+a+".");if(r.attributes[a].componentDatatype!==k.DOUBLE)throw new b("The attribute componentDatatype must be ComponentDatatype.DOUBLE.");var o=r.attributes[a];i=f(i)?i:new Xr;for(var t=i.ellipsoid,l=o.values,u=new Float64Array(l.length),s=0,c=0;c<l.length;c+=3){var w=v.fromArray(l,c,na),m=t.cartesianToCartographic(w,La);if(!f(m))throw new b("Could not project point ("+w.x+", "+w.y+", "+w.z+") to 2D.");var h=i.project(m,na);u[s++]=h.x,u[s++]=h.y,u[s++]=h.z}return r.attributes[e]=o,r.attributes[n]=new Y({componentDatatype:k.DOUBLE,componentsPerAttribute:3,values:u}),delete r.attributes[a],r};var Br={high:0,low:0};M.encodeAttribute=function(r,a,e,n){if(!f(r))throw new b("geometry is required.");if(!f(a))throw new b("attributeName is required.");if(!f(e))throw new b("attributeHighName is required.");if(!f(n))throw new b("attributeLowName is required.");if(!f(r.attributes[a]))throw new b("geometry must have attribute matching the attributeName argument: "+a+".");if(r.attributes[a].componentDatatype!==k.DOUBLE)throw new b("The attribute componentDatatype must be ComponentDatatype.DOUBLE.");for(var i=r.attributes[a],o=i.values,t=o.length,l=new Float32Array(t),u=new Float32Array(t),s=0;s<t;++s)Kr.encode(o[s],Br),l[s]=Br.high,u[s]=Br.low;var c=i.componentsPerAttribute;return r.attributes[e]=new Y({componentDatatype:k.FLOAT,componentsPerAttribute:c,values:l}),r.attributes[n]=new Y({componentDatatype:k.FLOAT,componentsPerAttribute:c,values:u}),delete r.attributes[a],r};var j=new v;function Fr(r,a){if(f(a))for(var e=a.values,n=e.length,i=0;i<n;i+=3)v.unpack(e,i,j),Q.multiplyByPoint(r,j,j),v.pack(j,e,i)}function Cr(r,a){if(f(a))for(var e=a.values,n=e.length,i=0;i<n;i+=3)v.unpack(e,i,j),Vr.multiplyByVector(r,j,j),j=v.normalize(j,j),v.pack(j,e,i)}var Ar=new Q,Pr=new Vr;M.transformToWorldCoordinates=function(r){if(!f(r))throw new b("instance is required.");var a=r.modelMatrix;if(Q.equals(a,Q.IDENTITY))return r;var e=r.geometry.attributes;Fr(a,e.position),Fr(a,e.prevPosition),Fr(a,e.nextPosition),(f(e.normal)||f(e.tangent)||f(e.bitangent))&&(Q.inverse(a,Ar),Q.transpose(Ar,Ar),Q.getRotation(Ar,Pr),Cr(Pr,e.normal),Cr(Pr,e.tangent),Cr(Pr,e.bitangent));var n=r.geometry.boundingSphere;return f(n)&&(r.geometry.boundingSphere=hr.transform(n,a,n)),r.modelMatrix=Q.clone(Q.IDENTITY),r};function Oa(r,a){var e=r.length,n={},i=r[0][a].attributes,o;for(o in i)if(i.hasOwnProperty(o)&&f(i[o])&&f(i[o].values)){for(var t=i[o],l=t.values.length,u=!0,s=1;s<e;++s){var c=r[s][a].attributes[o];if(!f(c)||t.componentDatatype!==c.componentDatatype||t.componentsPerAttribute!==c.componentsPerAttribute||t.normalize!==c.normalize){u=!1;break}l+=c.values.length}u&&(n[o]=new Y({componentDatatype:t.componentDatatype,componentsPerAttribute:t.componentsPerAttribute,normalize:t.normalize,values:k.createTypedArray(t.componentDatatype,l)}),t.isInstanceAttribute&&(n[o].isInstanceAttribute=!0))}return n}var Aa=new v;function _r(r,a){var e=r.length,n,i,o,t,l=r[0].modelMatrix,u=f(r[0][a].indices),s=r[0][a].primitiveType;for(i=1;i<e;++i){if(!Q.equals(r[i].modelMatrix,l))throw new b("All instances must have the same modelMatrix.");if(f(r[i][a].indices)!==u)throw new b("All instance geometries must have an indices or not have one.");if(r[i][a].primitiveType!==s)throw new b("All instance geometries must have the same primitiveType.")}var c=Oa(r,a),w,m,h;for(n in c)if(c.hasOwnProperty(n))for(w=c[n].values,t=0,i=0;i<e;++i)for(m=r[i][a].attributes[n].values,h=m.length,o=0;o<h;++o)w[t++]=m[o];var p;if(u){var A=0;for(i=0;i<e;++i)A+=r[i][a].indices.length;var g=C.computeNumberOfVertices(new C({attributes:c,primitiveType:q.POINTS})),S=Z.createTypedArray(g,A),T=0,y=0;for(i=0;i<e;++i){var d=r[i][a].indices,O=d.length;for(t=0;t<O;++t)S[T++]=y+d[t];y+=C.computeNumberOfVertices(r[i][a])}p=S}var N=new v,E=0,P;for(i=0;i<e;++i){if(P=r[i][a].boundingSphere,!f(P)){N=void 0;break}v.add(P.center,N,N)}if(f(N))for(v.divideByScalar(N,e,N),i=0;i<e;++i){P=r[i][a].boundingSphere;var z=v.magnitude(v.subtract(P.center,N,Aa))+P.radius;z>E&&(E=z)}return new C({attributes:c,indices:p,primitiveType:s,boundingSphere:f(N)?new hr(N,E):void 0})}M.combineInstances=function(r){if(!f(r)||r.length<1)throw new b("instances is required and must have length greater than zero.");for(var a=[],e=[],n=r.length,i=0;i<n;++i){var o=r[i];f(o.geometry)?a.push(o):f(o.westHemisphereGeometry)&&f(o.eastHemisphereGeometry)&&e.push(o)}var t=[];return a.length>0&&t.push(_r(a,"geometry")),e.length>0&&(t.push(_r(e,"westHemisphereGeometry")),t.push(_r(e,"eastHemisphereGeometry"))),t};var X=new v,br=new v,cr=new v,mr=new v;M.computeNormal=function(r){if(!f(r))throw new b("geometry is required.");if(!f(r.attributes.position)||!f(r.attributes.position.values))throw new b("geometry.attributes.position.values is required.");if(!f(r.indices))throw new b("geometry.indices is required.");if(r.indices.length<2||r.indices.length%3!==0)throw new b("geometry.indices length must be greater than 0 and be a multiple of 3.");if(r.primitiveType!==q.TRIANGLES)throw new b("geometry.primitiveType must be PrimitiveType.TRIANGLES.");var a=r.indices,e=r.attributes,n=e.position.values,i=e.position.values.length/3,o=a.length,t=new Array(i),l=new Array(o/3),u=new Array(o),s;for(s=0;s<i;s++)t[s]={indexOffset:0,count:0,currentCount:0};var c=0;for(s=0;s<o;s+=3){var w=a[s],m=a[s+1],h=a[s+2],p=w*3,A=m*3,g=h*3;br.x=n[p],br.y=n[p+1],br.z=n[p+2],cr.x=n[A],cr.y=n[A+1],cr.z=n[A+2],mr.x=n[g],mr.y=n[g+1],mr.z=n[g+2],t[w].count++,t[m].count++,t[h].count++,v.subtract(cr,br,cr),v.subtract(mr,br,mr),l[c]=v.cross(cr,mr,new v),c++}var S=0;for(s=0;s<i;s++)t[s].indexOffset+=S,S+=t[s].count;c=0;var T;for(s=0;s<o;s+=3){T=t[a[s]];var y=T.indexOffset+T.currentCount;u[y]=c,T.currentCount++,T=t[a[s+1]],y=T.indexOffset+T.currentCount,u[y]=c,T.currentCount++,T=t[a[s+2]],y=T.indexOffset+T.currentCount,u[y]=c,T.currentCount++,c++}var d=new Float32Array(i*3);for(s=0;s<i;s++){var O=s*3;if(T=t[s],v.clone(v.ZERO,X),T.count>0){for(c=0;c<T.count;c++)v.add(X,l[u[T.indexOffset+c]],X);v.equalsEpsilon(v.ZERO,X,x.EPSILON10)&&v.clone(l[u[T.indexOffset]],X)}v.equalsEpsilon(v.ZERO,X,x.EPSILON10)&&(X.z=1),v.normalize(X,X),d[O]=X.x,d[O+1]=X.y,d[O+2]=X.z}return r.attributes.normal=new Y({componentDatatype:k.FLOAT,componentsPerAttribute:3,values:d}),r};var Pa=new v,ia=new v,za=new v;M.computeTangentAndBitangent=function(r){if(!f(r))throw new b("geometry is required.");var a=r.attributes,e=r.indices;if(!f(a.position)||!f(a.position.values))throw new b("geometry.attributes.position.values is required.");if(!f(a.normal)||!f(a.normal.values))throw new b("geometry.attributes.normal.values is required.");if(!f(a.st)||!f(a.st.values))throw new b("geometry.attributes.st.values is required.");if(!f(e))throw new b("geometry.indices is required.");if(e.length<2||e.length%3!==0)throw new b("geometry.indices length must be greater than 0 and be a multiple of 3.");if(r.primitiveType!==q.TRIANGLES)throw new b("geometry.primitiveType must be PrimitiveType.TRIANGLES.");var n=r.attributes.position.values,i=r.attributes.normal.values,o=r.attributes.st.values,t=r.attributes.position.values.length/3,l=e.length,u=new Array(t*3),s;for(s=0;s<u.length;s++)u[s]=0;var c,w,m;for(s=0;s<l;s+=3){var h=e[s],p=e[s+1],A=e[s+2];c=h*3,w=p*3,m=A*3;var g=h*2,S=p*2,T=A*2,y=n[c],d=n[c+1],O=n[c+2],N=o[g],E=o[g+1],P=o[S+1]-E,z=o[T+1]-E,V=1/((o[S]-N)*z-(o[T]-N)*P),L=(z*(n[w]-y)-P*(n[m]-y))*V,F=(z*(n[w+1]-d)-P*(n[m+1]-d))*V,R=(z*(n[w+2]-O)-P*(n[m+2]-O))*V;u[c]+=L,u[c+1]+=F,u[c+2]+=R,u[w]+=L,u[w+1]+=F,u[w+2]+=R,u[m]+=L,u[m+1]+=F,u[m+2]+=R}var D=new Float32Array(t*3),_=new Float32Array(t*3);for(s=0;s<t;s++){c=s*3,w=c+1,m=c+2;var B=v.fromArray(i,c,Pa),I=v.fromArray(u,c,za),H=v.dot(B,I);v.multiplyByScalar(B,H,ia),v.normalize(v.subtract(I,ia,I),I),D[c]=I.x,D[w]=I.y,D[m]=I.z,v.normalize(v.cross(B,I,I),I),_[c]=I.x,_[w]=I.y,_[m]=I.z}return r.attributes.tangent=new Y({componentDatatype:k.FLOAT,componentsPerAttribute:3,values:D}),r.attributes.bitangent=new Y({componentDatatype:k.FLOAT,componentsPerAttribute:3,values:_}),r};var gr=new G,$=new v,ta=new v,va=new v,zr=new G;M.compressVertices=function(r){if(!f(r))throw new b("geometry is required.");var a=r.attributes.extrudeDirection,e,n;if(f(a)){var i=a.values;n=i.length/3;var o=new Float32Array(n*2),t=0;for(e=0;e<n;++e){if(v.fromArray(i,e*3,$),v.equals($,v.ZERO)){t+=2;continue}zr=or.octEncodeInRange($,65535,zr),o[t++]=zr.x,o[t++]=zr.y}return r.attributes.compressedAttributes=new Y({componentDatatype:k.FLOAT,componentsPerAttribute:2,values:o}),delete r.attributes.extrudeDirection,r}var l=r.attributes.normal,u=r.attributes.st,s=f(l),c=f(u);if(!s&&!c)return r;var w=r.attributes.tangent,m=r.attributes.bitangent,h=f(w),p=f(m),A,g,S,T;s&&(A=l.values),c&&(g=u.values),h&&(S=w.values),p&&(T=m.values);var y=s?A.length:g.length,d=s?3:2;n=y/d;var O=n,N=c&&s?2:1;N+=h||p?1:0,O*=N;var E=new Float32Array(O),P=0;for(e=0;e<n;++e){c&&(G.fromArray(g,e*u.componentsPerAttribute,gr),E[P++]=or.compressTextureCoordinates(gr));var z=e*3;s&&f(S)&&f(T)?(v.fromArray(A,z,$),v.fromArray(S,z,ta),v.fromArray(T,z,va),or.octPack($,ta,va,gr),E[P++]=gr.x,E[P++]=gr.y):(s&&(v.fromArray(A,z,$),E[P++]=or.octEncodeFloat($)),h&&(v.fromArray(S,z,$),E[P++]=or.octEncodeFloat($)),p&&(v.fromArray(T,z,$),E[P++]=or.octEncodeFloat($)))}return r.attributes.compressedAttributes=new Y({componentDatatype:k.FLOAT,componentsPerAttribute:N,values:E}),s&&delete r.attributes.normal,c&&delete r.attributes.st,p&&delete r.attributes.bitangent,h&&delete r.attributes.tangent,r};function Na(r){if(f(r.indices))return r;var a=C.computeNumberOfVertices(r);if(a<3)throw new b("The number of vertices must be at least three.");if(a%3!==0)throw new b("The number of vertices must be a multiple of three.");for(var e=Z.createTypedArray(a,a),n=0;n<a;++n)e[n]=n;return r.indices=e,r}function xa(r){var a=C.computeNumberOfVertices(r);if(a<3)throw new b("The number of vertices must be at least three.");var e=Z.createTypedArray(a,(a-2)*3);e[0]=1,e[1]=0,e[2]=2;for(var n=3,i=3;i<a;++i)e[n++]=i-1,e[n++]=0,e[n++]=i;return r.indices=e,r.primitiveType=q.TRIANGLES,r}function Da(r){var a=C.computeNumberOfVertices(r);if(a<3)throw new b("The number of vertices must be at least 3.");var e=Z.createTypedArray(a,(a-2)*3);e[0]=0,e[1]=1,e[2]=2,a>3&&(e[3]=0,e[4]=2,e[5]=3);for(var n=6,i=3;i<a-1;i+=2)e[n++]=i,e[n++]=i-1,e[n++]=i+1,i+2<a&&(e[n++]=i,e[n++]=i+1,e[n++]=i+2);return r.indices=e,r.primitiveType=q.TRIANGLES,r}function qa(r){if(f(r.indices))return r;var a=C.computeNumberOfVertices(r);if(a<2)throw new b("The number of vertices must be at least two.");if(a%2!==0)throw new b("The number of vertices must be a multiple of 2.");for(var e=Z.createTypedArray(a,a),n=0;n<a;++n)e[n]=n;return r.indices=e,r}function Va(r){var a=C.computeNumberOfVertices(r);if(a<2)throw new b("The number of vertices must be at least two.");var e=Z.createTypedArray(a,(a-1)*2);e[0]=0,e[1]=1;for(var n=2,i=2;i<a;++i)e[n++]=i-1,e[n++]=i;return r.indices=e,r.primitiveType=q.LINES,r}function Ia(r){var a=C.computeNumberOfVertices(r);if(a<2)throw new b("The number of vertices must be at least two.");var e=Z.createTypedArray(a,a*2);e[0]=0,e[1]=1;for(var n=2,i=2;i<a;++i)e[n++]=i-1,e[n++]=i;return e[n++]=a-1,e[n]=0,r.indices=e,r.primitiveType=q.LINES,r}function Ra(r){switch(r.primitiveType){case q.TRIANGLE_FAN:return xa(r);case q.TRIANGLE_STRIP:return Da(r);case q.TRIANGLES:return Na(r);case q.LINE_STRIP:return Va(r);case q.LINE_LOOP:return Ia(r);case q.LINES:return qa(r)}return r}function tr(r,a){Math.abs(r.y)<x.EPSILON6&&(a?r.y=-x.EPSILON6:r.y=x.EPSILON6)}function Ga(r,a,e){if(r.y!==0&&a.y!==0&&e.y!==0){tr(r,r.y<0),tr(a,a.y<0),tr(e,e.y<0);return}var n=Math.abs(r.y),i=Math.abs(a.y),o=Math.abs(e.y),t;n>i?n>o?t=x.sign(r.y):t=x.sign(e.y):i>o?t=x.sign(a.y):t=x.sign(e.y);var l=t<0;tr(r,l),tr(a,l),tr(e,l)}var oa=new v;function J(r,a,e,n){v.add(r,v.multiplyByScalar(v.subtract(a,r,oa),r.y/(r.y-a.y),oa),e),v.clone(e,n),tr(e,!0),tr(n,!1)}var sr=new v,ur=new v,lr=new v,fr=new v,kr={positions:new Array(7),indices:new Array(3*3)};function Ba(r,a,e){if(!(r.x>=0||a.x>=0||e.x>=0)){Ga(r,a,e);var n=r.y<0,i=a.y<0,o=e.y<0,t=0;t+=n?1:0,t+=i?1:0,t+=o?1:0;var l=kr.indices;t===1?(l[1]=3,l[2]=4,l[5]=6,l[7]=6,l[8]=5,n?(J(r,a,sr,lr),J(r,e,ur,fr),l[0]=0,l[3]=1,l[4]=2,l[6]=1):i?(J(a,e,sr,lr),J(a,r,ur,fr),l[0]=1,l[3]=2,l[4]=0,l[6]=2):o&&(J(e,r,sr,lr),J(e,a,ur,fr),l[0]=2,l[3]=0,l[4]=1,l[6]=0)):t===2&&(l[2]=4,l[4]=4,l[5]=3,l[7]=5,l[8]=6,n?i?o||(J(e,r,sr,lr),J(e,a,ur,fr),l[0]=0,l[1]=1,l[3]=0,l[6]=2):(J(a,e,sr,lr),J(a,r,ur,fr),l[0]=2,l[1]=0,l[3]=2,l[6]=1):(J(r,a,sr,lr),J(r,e,ur,fr),l[0]=1,l[1]=2,l[3]=1,l[6]=0));var u=kr.positions;return u[0]=r,u[1]=a,u[2]=e,u.length=3,(t===1||t===2)&&(u[3]=sr,u[4]=ur,u[5]=lr,u[6]=fr,u.length=7),kr}}function sa(r,a){var e=r.attributes;if(e.position.values.length!==0){for(var n in e)if(e.hasOwnProperty(n)&&f(e[n])&&f(e[n].values)){var i=e[n];i.values=k.createTypedArray(i.componentDatatype,i.values)}var o=C.computeNumberOfVertices(r);return r.indices=Z.createTypedArray(o,r.indices),a&&(r.boundingSphere=hr.fromVertices(e.position.values)),r}}function dr(r){var a=r.attributes,e={};for(var n in a)if(a.hasOwnProperty(n)&&f(a[n])&&f(a[n].values)){var i=a[n];e[n]=new Y({componentDatatype:i.componentDatatype,componentsPerAttribute:i.componentsPerAttribute,normalize:i.normalize,values:[]})}return new C({attributes:e,indices:[],primitiveType:r.primitiveType})}function Zr(r,a,e){var n=f(r.geometry.boundingSphere);a=sa(a,n),e=sa(e,n),f(e)&&!f(a)?r.geometry=e:!f(e)&&f(a)?r.geometry=a:(r.westHemisphereGeometry=a,r.eastHemisphereGeometry=e,r.geometry=void 0)}function Hr(r,a){var e=new r,n=new r,i=new r;return function(o,t,l,u,s,c,w,m){var h=r.fromArray(s,o*a,e),p=r.fromArray(s,t*a,n),A=r.fromArray(s,l*a,i);r.multiplyByScalar(h,u.x,h),r.multiplyByScalar(p,u.y,p),r.multiplyByScalar(A,u.z,A);var g=r.add(h,p,h);r.add(g,A,g),m&&r.normalize(g,g),r.pack(g,c,w*a)}}var Fa=Hr(Tr,4),Dr=Hr(v,3),pa=Hr(G,2),Ca=function(r,a,e,n,i,o,t){var l=i[r]*n.x,u=i[a]*n.y,s=i[e]*n.z;o[t]=l+u+s>x.EPSILON6?1:0},Er=new v,Mr=new v,Ur=new v,_a=new v;function Nr(r,a,e,n,i,o,t,l,u,s,c,w,m,h,p,A){if(!(!f(o)&&!f(t)&&!f(l)&&!f(u)&&!f(s)&&h===0)){var g=v.fromArray(i,r*3,Er),S=v.fromArray(i,a*3,Mr),T=v.fromArray(i,e*3,Ur),y=ra(n,g,S,T,_a);if(f(o)&&Dr(r,a,e,y,o,w.normal.values,A,!0),f(s)){var d=v.fromArray(s,r*3,Er),O=v.fromArray(s,a*3,Mr),N=v.fromArray(s,e*3,Ur);v.multiplyByScalar(d,y.x,d),v.multiplyByScalar(O,y.y,O),v.multiplyByScalar(N,y.z,N);var E;!v.equals(d,v.ZERO)||!v.equals(O,v.ZERO)||!v.equals(N,v.ZERO)?(E=v.add(d,O,d),v.add(E,N,E),v.normalize(E,E)):(E=Er,E.x=0,E.y=0,E.z=0),v.pack(E,w.extrudeDirection.values,A*3)}if(f(c)&&Ca(r,a,e,y,c,w.applyOffset.values,A),f(t)&&Dr(r,a,e,y,t,w.tangent.values,A,!0),f(l)&&Dr(r,a,e,y,l,w.bitangent.values,A,!0),f(u)&&pa(r,a,e,y,u,w.st.values,A),h>0)for(var P=0;P<h;P++){var z=m[P];ka(r,a,e,y,A,p[z],w[z])}}}function ka(r,a,e,n,i,o,t){var l=o.componentsPerAttribute,u=o.values,s=t.values;switch(l){case 4:Fa(r,a,e,n,u,s,i,!1);break;case 3:Dr(r,a,e,n,u,s,i,!1);break;case 2:pa(r,a,e,n,u,s,i,!1);break;default:s[i]=u[r]*n.x+u[a]*n.y+u[e]*n.z}}function er(r,a,e,n,i,o){var t=r.position.values.length/3;if(i!==-1){var l=n[i],u=e[l];return u===-1?(e[l]=t,r.position.values.push(o.x,o.y,o.z),a.push(t),t):(a.push(u),u)}return r.position.values.push(o.x,o.y,o.z),a.push(t),t}var Ma={position:!0,normal:!0,bitangent:!0,tangent:!0,st:!0,extrudeDirection:!0,applyOffset:!0};function ua(r){var a=r.geometry,e=a.attributes,n=e.position.values,i=f(e.normal)?e.normal.values:void 0,o=f(e.bitangent)?e.bitangent.values:void 0,t=f(e.tangent)?e.tangent.values:void 0,l=f(e.st)?e.st.values:void 0,u=f(e.extrudeDirection)?e.extrudeDirection.values:void 0,s=f(e.applyOffset)?e.applyOffset.values:void 0,c=a.indices,w=[];for(var m in e)e.hasOwnProperty(m)&&!Ma[m]&&f(e[m])&&w.push(m);var h=w.length,p=dr(a),A=dr(a),g,S,T,y,d,O=[];O.length=n.length/3;var N=[];for(N.length=n.length/3,d=0;d<O.length;++d)O[d]=-1,N[d]=-1;var E=c.length;for(d=0;d<E;d+=3){var P=c[d],z=c[d+1],V=c[d+2],L=v.fromArray(n,P*3),F=v.fromArray(n,z*3),R=v.fromArray(n,V*3),D=Ba(L,F,R);if(f(D)&&D.positions.length>3)for(var _=D.positions,B=D.indices,I=B.length,H=0;H<I;++H){var rr=B[H],W=_[rr];W.y<0?(g=A.attributes,S=A.indices,T=O):(g=p.attributes,S=p.indices,T=N),y=er(g,S,T,c,rr<3?d+rr:-1,W),Nr(P,z,V,W,n,i,t,o,l,u,s,g,w,h,e,y)}else f(D)&&(L=D.positions[0],F=D.positions[1],R=D.positions[2]),L.y<0?(g=A.attributes,S=A.indices,T=O):(g=p.attributes,S=p.indices,T=N),y=er(g,S,T,c,d,L),Nr(P,z,V,L,n,i,t,o,l,u,s,g,w,h,e,y),y=er(g,S,T,c,d+1,F),Nr(P,z,V,F,n,i,t,o,l,u,s,g,w,h,e,y),y=er(g,S,T,c,d+2,R),Nr(P,z,V,R,n,i,t,o,l,u,s,g,w,h,e,y)}Zr(r,A,p)}var da=Rr.fromPointNormal(v.ZERO,v.UNIT_Y),Ua=new v,Ya=new v;function pr(r,a,e,n,i,o,t){if(!!f(t)){var l=v.fromArray(n,r*3,Er);v.equalsEpsilon(l,e,x.EPSILON10)?o.applyOffset.values[i]=t[r]:o.applyOffset.values[i]=t[a]}}function la(r){var a=r.geometry,e=a.attributes,n=e.position.values,i=f(e.applyOffset)?e.applyOffset.values:void 0,o=a.indices,t=dr(a),l=dr(a),u,s=o.length,c=[];c.length=n.length/3;var w=[];for(w.length=n.length/3,u=0;u<c.length;++u)c[u]=-1,w[u]=-1;for(u=0;u<s;u+=2){var m=o[u],h=o[u+1],p=v.fromArray(n,m*3,Er),A=v.fromArray(n,h*3,Mr),g;Math.abs(p.y)<x.EPSILON6&&(p.y<0?p.y=-x.EPSILON6:p.y=x.EPSILON6),Math.abs(A.y)<x.EPSILON6&&(A.y<0?A.y=-x.EPSILON6:A.y=x.EPSILON6);var S=t.attributes,T=t.indices,y=w,d=l.attributes,O=l.indices,N=c,E=Ir.lineSegmentPlane(p,A,da,Ur);if(f(E)){var P=v.multiplyByScalar(v.UNIT_Y,5*x.EPSILON9,Ua);p.y<0&&(v.negate(P,P),S=l.attributes,T=l.indices,y=c,d=t.attributes,O=t.indices,N=w);var z=v.add(E,P,Ya);g=er(S,T,y,o,u,p),pr(m,h,p,n,g,S,i),g=er(S,T,y,o,-1,z),pr(m,h,z,n,g,S,i),v.negate(P,P),v.add(E,P,z),g=er(d,O,N,o,-1,z),pr(m,h,z,n,g,d,i),g=er(d,O,N,o,u+1,A),pr(m,h,A,n,g,d,i)}else{var V,L,F;p.y<0?(V=l.attributes,L=l.indices,F=c):(V=t.attributes,L=t.indices,F=w),g=er(V,L,F,o,u,p),pr(m,h,p,n,g,V,i),g=er(V,L,F,o,u+1,A),pr(m,h,A,n,g,V,i)}}Zr(r,l,t)}var fa=new G,Za=new G,wa=new v,ya=new v,Yr=new v,Ha=new v,Wa=new v,Xa=new v,ha=new v,ca=new Tr;function ma(r){for(var a=r.attributes,e=a.position.values,n=a.prevPosition.values,i=a.nextPosition.values,o=e.length,t=0;t<o;t+=3){var l=v.unpack(e,t,wa);if(!(l.x>0)){var u=v.unpack(n,t,ya);(l.y<0&&u.y>0||l.y>0&&u.y<0)&&(t-3>0?(n[t]=e[t-3],n[t+1]=e[t-2],n[t+2]=e[t-1]):v.pack(l,n,t));var s=v.unpack(i,t,Yr);(l.y<0&&s.y>0||l.y>0&&s.y<0)&&(t+3<o?(i[t]=e[t+3],i[t+1]=e[t+4],i[t+2]=e[t+5]):v.pack(l,i,t))}}}var Ja=5*x.EPSILON9,xr=x.EPSILON6;function Ka(r){var a=r.geometry,e=a.attributes,n=e.position.values,i=e.prevPosition.values,o=e.nextPosition.values,t=e.expandAndWidth.values,l=f(e.st)?e.st.values:void 0,u=f(e.color)?e.color.values:void 0,s=f(e.dist)?e.dist.values:void 0,c=dr(a),w=dr(a),m,h,p,A=!1,g=n.length/3;for(m=0;m<g;m+=4){var S=m,T=m+2,y=v.fromArray(n,S*3,wa),d=v.fromArray(n,T*3,ya);if(Math.abs(y.y)<xr)for(y.y=xr*(d.y<0?-1:1),n[m*3+1]=y.y,n[(m+1)*3+1]=y.y,h=S*3;h<S*3+4*3;h+=3)i[h]=n[m*3],i[h+1]=n[m*3+1],i[h+2]=n[m*3+2];if(Math.abs(d.y)<xr)for(d.y=xr*(y.y<0?-1:1),n[(m+2)*3+1]=d.y,n[(m+3)*3+1]=d.y,h=S*3;h<S*3+4*3;h+=3)o[h]=n[(m+2)*3],o[h+1]=n[(m+2)*3+1],o[h+2]=n[(m+2)*3+2];var O=c.attributes,N=c.indices,E=w.attributes,P=w.indices,z=Ir.lineSegmentPlane(y,d,da,Ha);if(f(z)){A=!0;var V=v.multiplyByScalar(v.UNIT_Y,Ja,Wa);y.y<0&&(v.negate(V,V),O=w.attributes,N=w.indices,E=c.attributes,P=c.indices);var L=v.add(z,V,Xa);O.position.values.push(y.x,y.y,y.z,y.x,y.y,y.z),O.position.values.push(L.x,L.y,L.z),O.position.values.push(L.x,L.y,L.z),O.prevPosition.values.push(i[S*3],i[S*3+1],i[S*3+2]),O.prevPosition.values.push(i[S*3+3],i[S*3+4],i[S*3+5]),O.prevPosition.values.push(y.x,y.y,y.z,y.x,y.y,y.z),O.nextPosition.values.push(L.x,L.y,L.z),O.nextPosition.values.push(L.x,L.y,L.z),O.nextPosition.values.push(L.x,L.y,L.z),O.nextPosition.values.push(L.x,L.y,L.z),v.negate(V,V),v.add(z,V,L),E.position.values.push(L.x,L.y,L.z),E.position.values.push(L.x,L.y,L.z),E.position.values.push(d.x,d.y,d.z,d.x,d.y,d.z),E.prevPosition.values.push(L.x,L.y,L.z),E.prevPosition.values.push(L.x,L.y,L.z),E.prevPosition.values.push(L.x,L.y,L.z),E.prevPosition.values.push(L.x,L.y,L.z),E.nextPosition.values.push(d.x,d.y,d.z,d.x,d.y,d.z),E.nextPosition.values.push(o[T*3],o[T*3+1],o[T*3+2]),E.nextPosition.values.push(o[T*3+3],o[T*3+4],o[T*3+5]);var F=G.fromArray(t,S*2,fa),R=Math.abs(F.y);O.expandAndWidth.values.push(-1,R,1,R),O.expandAndWidth.values.push(-1,-R,1,-R),E.expandAndWidth.values.push(-1,R,1,R),E.expandAndWidth.values.push(-1,-R,1,-R);var D=v.magnitudeSquared(v.subtract(z,y,Yr));if(D/=v.magnitudeSquared(v.subtract(d,y,Yr)),f(u)){var _=Tr.fromArray(u,S*4,ca),B=Tr.fromArray(u,T*4,ca),I=x.lerp(_.x,B.x,D),H=x.lerp(_.y,B.y,D),rr=x.lerp(_.z,B.z,D),W=x.lerp(_.w,B.w,D);for(h=S*4;h<S*4+2*4;++h)O.color.values.push(u[h]);for(O.color.values.push(I,H,rr,W),O.color.values.push(I,H,rr,W),E.color.values.push(I,H,rr,W),E.color.values.push(I,H,rr,W),h=T*4;h<T*4+2*4;++h)E.color.values.push(u[h])}if(f(l)){var nr=G.fromArray(l,S*2,fa),vr=G.fromArray(l,(m+3)*2,Za),ir=x.lerp(nr.x,vr.x,D);for(h=S*2;h<S*2+2*2;++h)O.st.values.push(l[h]);for(O.st.values.push(ir,nr.y),O.st.values.push(ir,vr.y),E.st.values.push(ir,nr.y),E.st.values.push(ir,vr.y),h=T*2;h<T*2+2*2;++h)E.st.values.push(l[h])}if(f(s)){var K=v.fromArray(s,S*3,ha),wr=v.fromArray(s,T*3,ha),Lr=x.lerp(K.x,wr.x,D);for(h=S*3;h<S*3+2*3;++h)O.dist.values.push(s[h]);for(O.dist.values.push(Lr,K.y,K.z),O.dist.values.push(Lr,K.y,K.z),E.dist.values.push(Lr,wr.y,wr.z),E.dist.values.push(Lr,wr.y,wr.z),h=T*3;h<T*3+2*3;++h)E.dist.values.push(s[h])}p=O.position.values.length/3-4,N.push(p,p+2,p+1),N.push(p+1,p+2,p+3),p=E.position.values.length/3-4,P.push(p,p+2,p+1),P.push(p+1,p+2,p+3)}else{var U,Or;for(y.y<0?(U=w.attributes,Or=w.indices):(U=c.attributes,Or=c.indices),U.position.values.push(y.x,y.y,y.z),U.position.values.push(y.x,y.y,y.z),U.position.values.push(d.x,d.y,d.z),U.position.values.push(d.x,d.y,d.z),h=m*3;h<m*3+4*3;++h)U.prevPosition.values.push(i[h]),U.nextPosition.values.push(o[h]);for(h=m*2;h<m*2+4*2;++h)U.expandAndWidth.values.push(t[h]),f(l)&&U.st.values.push(l[h]);if(f(u))for(h=m*4;h<m*4+4*4;++h)U.color.values.push(u[h]);if(f(s))for(h=m*3;h<m*3+4*3;++h)U.dist.values.push(s[h]);p=U.position.values.length/3-4,Or.push(p,p+2,p+1),Or.push(p+1,p+2,p+3)}}A&&(ma(w),ma(c)),Zr(r,w,c)}M.splitLongitude=function(r){if(!f(r))throw new b("instance is required.");var a=r.geometry,e=a.boundingSphere;if(f(e)){var n=e.center.x-e.radius;if(n>0||hr.intersectPlane(e,Rr.ORIGIN_ZX_PLANE)!==Jr.INTERSECTING)return r}if(a.geometryType!==Sr.NONE)switch(a.geometryType){case Sr.POLYLINES:Ka(r);break;case Sr.TRIANGLES:ua(r);break;case Sr.LINES:la(r);break}else Ra(a),a.primitiveType===q.TRIANGLES?ua(r):a.primitiveType===q.LINES&&la(r);return r};var qe=M;export{qe as a};