1 line
29 KiB
JavaScript
1 line
29 KiB
JavaScript
define(["exports","./AttributeCompression-af389d04","./Matrix2-9aa31791","./RuntimeError-346a3079","./when-4bbc8319","./ComponentDatatype-93750d1a","./Transforms-d13cc04e","./EncodedCartesian3-f286cedc","./GeometryAttribute-43536dc0","./IndexDatatype-b7d979a6","./IntersectionTests-96a04219","./Plane-318d6937"],(function(e,t,r,a,i,n,s,o,u,p,d,y){"use strict";var l=new r.Cartesian3,v=new r.Cartesian3,f=new r.Cartesian3,m=function(e){var t,r=(e=i.defaultValue(e,i.defaultValue.EMPTY_OBJECT)).indices,a=e.maximumIndex,n=i.defaultValue(e.cacheSize,24);function s(e,r,a,i,n,s,o){for(var u,p=-1,d=-1,y=0;y<a.length;){var l=a[y];i[l].numLiveTriangles&&(u=0,n-i[l].timeStamp+2*i[l].numLiveTriangles<=r&&(u=n-i[l].timeStamp),(u>d||-1===d)&&(d=u,p=l)),++y}return-1===p?function(e,r,a,i){for(;r.length>=1;){var n=r[r.length-1];if(r.splice(r.length-1,1),e[n].numLiveTriangles>0)return n}for(;t<i;){if(e[t].numLiveTriangles>0)return++t-1;++t}return-1}(i,s,0,o):p}var o=r.length,u=0,p=0,d=r[p],y=o;if(i.defined(a))u=a+1;else{for(;p<y;)d>u&&(u=d),d=r[++p];if(-1===u)return 0;++u}var l,v=[];for(l=0;l<u;l++)v[l]={numLiveTriangles:0,timeStamp:0,vertexTriangles:[]};p=0;for(var f=0;p<y;)v[r[p]].vertexTriangles.push(f),++v[r[p]].numLiveTriangles,v[r[p+1]].vertexTriangles.push(f),++v[r[p+1]].numLiveTriangles,v[r[p+2]].vertexTriangles.push(f),++v[r[p+2]].numLiveTriangles,++f,p+=3;var m=0,c=n+1;t=1;var C,h,b,g,A=[],T=[],x=0,P=[],w=o/3,S=[];for(l=0;l<w;l++)S[l]=!1;for(;-1!==m;){A=[],g=(h=v[m]).vertexTriangles.length;for(var I=0;I<g;++I)if(!S[f=h.vertexTriangles[I]]){S[f]=!0,p=f+f+f;for(var O=0;O<3;++O)b=r[p],A.push(b),T.push(b),P[x]=b,++x,--(C=v[b]).numLiveTriangles,c-C.timeStamp>n&&(C.timeStamp=c,++c),++p}m=s(0,n,A,v,c,T,u)}return P},c={};function C(e,t,r,a,i){e[t++]=r,e[t++]=a,e[t++]=a,e[t++]=i,e[t++]=i,e[t]=r}function h(e){var t={};for(var r in e)if(e.hasOwnProperty(r)&&i.defined(e[r])&&i.defined(e[r].values)){var a=e[r];t[r]=new u.GeometryAttribute({componentDatatype:a.componentDatatype,componentsPerAttribute:a.componentsPerAttribute,normalize:a.normalize,values:[]})}return t}function b(e,t,r){for(var a in t)if(t.hasOwnProperty(a)&&i.defined(t[a])&&i.defined(t[a].values))for(var n=t[a],s=0;s<n.componentsPerAttribute;++s)e[a].values.push(n.values[r*n.componentsPerAttribute+s])}c.toWireframe=function(e){var t=e.indices;if(i.defined(t)){switch(e.primitiveType){case u.PrimitiveType.TRIANGLES:e.indices=function(e){for(var t=e.length,r=t/3*6,a=p.IndexDatatype.createTypedArray(t,r),i=0,n=0;n<t;n+=3,i+=6)C(a,i,e[n],e[n+1],e[n+2]);return a}(t);break;case u.PrimitiveType.TRIANGLE_STRIP:e.indices=function(e){var t=e.length;if(t>=3){var r=6*(t-2),a=p.IndexDatatype.createTypedArray(t,r);C(a,0,e[0],e[1],e[2]);for(var i=6,n=3;n<t;++n,i+=6)C(a,i,e[n-1],e[n],e[n-2]);return a}return new Uint16Array}(t);break;case u.PrimitiveType.TRIANGLE_FAN:e.indices=function(e){if(e.length>0){for(var t=e.length-1,r=6*(t-1),a=p.IndexDatatype.createTypedArray(t,r),i=e[0],n=0,s=1;s<t;++s,n+=6)C(a,n,i,e[s],e[s+1]);return a}return new Uint16Array}(t)}e.primitiveType=u.PrimitiveType.LINES}return e},c.createLineSegmentsForVectors=function(e,t,r){t=i.defaultValue(t,"normal"),r=i.defaultValue(r,1e4);for(var a,o=e.attributes.position.values,p=e.attributes[t].values,d=o.length,y=new Float64Array(2*d),l=0,v=0;v<d;v+=3)y[l++]=o[v],y[l++]=o[v+1],y[l++]=o[v+2],y[l++]=o[v]+p[v]*r,y[l++]=o[v+1]+p[v+1]*r,y[l++]=o[v+2]+p[v+2]*r;var f=e.boundingSphere;return i.defined(f)&&(a=new s.BoundingSphere(f.center,f.radius+r)),new u.Geometry({attributes:{position:new u.GeometryAttribute({componentDatatype:n.ComponentDatatype.DOUBLE,componentsPerAttribute:3,values:y})},primitiveType:u.PrimitiveType.LINES,boundingSphere:a})},c.createAttributeLocations=function(e){var t,r=["position","positionHigh","positionLow","position3DHigh","position3DLow","position2DHigh","position2DLow","pickColor","normal","st","tangent","bitangent","extrudeDirection","compressedAttributes"],a=e.attributes,n={},s=0,o=r.length;for(t=0;t<o;++t){var u=r[t];i.defined(a[u])&&(n[u]=s++)}for(var p in a)a.hasOwnProperty(p)&&!i.defined(n[p])&&(n[p]=s++);return n},c.reorderForPreVertexCache=function(e){var t=u.Geometry.computeNumberOfVertices(e),r=e.indices;if(i.defined(r)){for(var a=new Int32Array(t),s=0;s<t;s++)a[s]=-1;for(var o,d=r,y=d.length,l=p.IndexDatatype.createTypedArray(t,y),v=0,f=0,m=0;v<y;)-1!==(o=a[d[v]])?l[f]=o:(a[o=d[v]]=m,l[f]=m,++m),++v,++f;e.indices=l;var c=e.attributes;for(var C in c)if(c.hasOwnProperty(C)&&i.defined(c[C])&&i.defined(c[C].values)){for(var h=c[C],b=h.values,g=0,A=h.componentsPerAttribute,T=n.ComponentDatatype.createTypedArray(h.componentDatatype,m*A);g<t;){var x=a[g];if(-1!==x)for(var P=0;P<A;P++)T[A*x+P]=b[A*g+P];++g}h.values=T}}return e},c.reorderForPostVertexCache=function(e,t){var r=e.indices;if(e.primitiveType===u.PrimitiveType.TRIANGLES&&i.defined(r)){for(var a=r.length,n=0,s=0;s<a;s++)r[s]>n&&(n=r[s]);e.indices=m({indices:r,maximumIndex:n,cacheSize:t})}return e},c.fitToUnsignedShortIndices=function(e){var t=[],r=u.Geometry.computeNumberOfVertices(e);if(i.defined(e.indices)&&r>=n.CesiumMath.SIXTY_FOUR_KILOBYTES){var a,s=[],o=[],p=0,d=h(e.attributes),y=e.indices,l=y.length;e.primitiveType===u.PrimitiveType.TRIANGLES?a=3:e.primitiveType===u.PrimitiveType.LINES?a=2:e.primitiveType===u.PrimitiveType.POINTS&&(a=1);for(var v=0;v<l;v+=a){for(var f=0;f<a;++f){var m=y[v+f],c=s[m];i.defined(c)||(c=p++,s[m]=c,b(d,e.attributes,m)),o.push(c)}p+a>=n.CesiumMath.SIXTY_FOUR_KILOBYTES&&(t.push(new u.Geometry({attributes:d,indices:o,primitiveType:e.primitiveType,boundingSphere:e.boundingSphere,boundingSphereCV:e.boundingSphereCV})),s=[],o=[],p=0,d=h(e.attributes))}0!==o.length&&t.push(new u.Geometry({attributes:d,indices:o,primitiveType:e.primitiveType,boundingSphere:e.boundingSphere,boundingSphereCV:e.boundingSphereCV}))}else t.push(e);return t};var g=new r.Cartesian3,A=new r.Cartographic;c.projectTo2D=function(e,t,a,o,p){for(var d=e.attributes[t],y=(p=i.defined(p)?p:new s.GeographicProjection).ellipsoid,l=d.values,v=new Float64Array(l.length),f=0,m=0;m<l.length;m+=3){var c=r.Cartesian3.fromArray(l,m,g),C=y.cartesianToCartographic(c,A),h=p.project(C,g);v[f++]=h.x,v[f++]=h.y,v[f++]=h.z}return e.attributes[a]=d,e.attributes[o]=new u.GeometryAttribute({componentDatatype:n.ComponentDatatype.DOUBLE,componentsPerAttribute:3,values:v}),delete e.attributes[t],e};var T={high:0,low:0};c.encodeAttribute=function(e,t,r,a){for(var i=e.attributes[t],s=i.values,p=s.length,d=new Float32Array(p),y=new Float32Array(p),l=0;l<p;++l)o.EncodedCartesian3.encode(s[l],T),d[l]=T.high,y[l]=T.low;var v=i.componentsPerAttribute;return e.attributes[r]=new u.GeometryAttribute({componentDatatype:n.ComponentDatatype.FLOAT,componentsPerAttribute:v,values:d}),e.attributes[a]=new u.GeometryAttribute({componentDatatype:n.ComponentDatatype.FLOAT,componentsPerAttribute:v,values:y}),delete e.attributes[t],e};var x=new r.Cartesian3;function P(e,t){if(i.defined(t))for(var a=t.values,n=a.length,s=0;s<n;s+=3)r.Cartesian3.unpack(a,s,x),r.Matrix4.multiplyByPoint(e,x,x),r.Cartesian3.pack(x,a,s)}function w(e,t){if(i.defined(t))for(var a=t.values,n=a.length,s=0;s<n;s+=3)r.Cartesian3.unpack(a,s,x),r.Matrix3.multiplyByVector(e,x,x),x=r.Cartesian3.normalize(x,x),r.Cartesian3.pack(x,a,s)}var S=new r.Matrix4,I=new r.Matrix3;c.transformToWorldCoordinates=function(e){var t=e.modelMatrix;if(r.Matrix4.equals(t,r.Matrix4.IDENTITY))return e;var a=e.geometry.attributes;P(t,a.position),P(t,a.prevPosition),P(t,a.nextPosition),(i.defined(a.normal)||i.defined(a.tangent)||i.defined(a.bitangent))&&(r.Matrix4.inverse(t,S),r.Matrix4.transpose(S,S),r.Matrix4.getMatrix3(S,I),w(I,a.normal),w(I,a.tangent),w(I,a.bitangent));var n=e.geometry.boundingSphere;return i.defined(n)&&(e.geometry.boundingSphere=s.BoundingSphere.transform(n,t,n)),e.modelMatrix=r.Matrix4.clone(r.Matrix4.IDENTITY),e};var O=new r.Cartesian3;function E(e,t){var a,o,d,y,l=e.length;e[0].modelMatrix;var v,f,m,c,C=i.defined(e[0][t].indices),h=e[0][t].primitiveType,b=function(e,t){var r,a=e.length,s={},o=e[0][t].attributes;for(r in o)if(o.hasOwnProperty(r)&&i.defined(o[r])&&i.defined(o[r].values)){for(var p=o[r],d=p.values.length,y=!0,l=1;l<a;++l){var v=e[l][t].attributes[r];if(!i.defined(v)||p.componentDatatype!==v.componentDatatype||p.componentsPerAttribute!==v.componentsPerAttribute||p.normalize!==v.normalize){y=!1;break}d+=v.values.length}y&&(s[r]=new u.GeometryAttribute({componentDatatype:p.componentDatatype,componentsPerAttribute:p.componentsPerAttribute,normalize:p.normalize,values:n.ComponentDatatype.createTypedArray(p.componentDatatype,d)}))}return s}(e,t);for(a in b)if(b.hasOwnProperty(a))for(v=b[a].values,y=0,o=0;o<l;++o)for(m=(f=e[o][t].attributes[a].values).length,d=0;d<m;++d)v[y++]=f[d];if(C){var g=0;for(o=0;o<l;++o)g+=e[o][t].indices.length;var A=u.Geometry.computeNumberOfVertices(new u.Geometry({attributes:b,primitiveType:u.PrimitiveType.POINTS})),T=p.IndexDatatype.createTypedArray(A,g),x=0,P=0;for(o=0;o<l;++o){var w=e[o][t].indices,S=w.length;for(y=0;y<S;++y)T[x++]=P+w[y];P+=u.Geometry.computeNumberOfVertices(e[o][t])}c=T}var I,E=new r.Cartesian3,N=0;for(o=0;o<l;++o){if(I=e[o][t].boundingSphere,!i.defined(I)){E=void 0;break}r.Cartesian3.add(I.center,E,E)}if(i.defined(E))for(r.Cartesian3.divideByScalar(E,l,E),o=0;o<l;++o){I=e[o][t].boundingSphere;var L=r.Cartesian3.magnitude(r.Cartesian3.subtract(I.center,E,O))+I.radius;L>N&&(N=L)}return new u.Geometry({attributes:b,indices:c,primitiveType:h,boundingSphere:i.defined(E)?new s.BoundingSphere(E,N):void 0})}c.combineInstances=function(e){for(var t=[],r=[],a=e.length,n=0;n<a;++n){var s=e[n];i.defined(s.geometry)?t.push(s):i.defined(s.westHemisphereGeometry)&&i.defined(s.eastHemisphereGeometry)&&r.push(s)}var o=[];return t.length>0&&o.push(E(t,"geometry")),r.length>0&&(o.push(E(r,"westHemisphereGeometry")),o.push(E(r,"eastHemisphereGeometry"))),o};var N=new r.Cartesian3,L=new r.Cartesian3,z=new r.Cartesian3,D=new r.Cartesian3;c.computeNormal=function(e){var t,a=e.indices,i=e.attributes,s=i.position.values,o=i.position.values.length/3,p=a.length,d=new Array(o),y=new Array(p/3),l=new Array(p);for(t=0;t<o;t++)d[t]={indexOffset:0,count:0,currentCount:0};var v=0;for(t=0;t<p;t+=3){var f=a[t],m=a[t+1],c=a[t+2],C=3*f,h=3*m,b=3*c;L.x=s[C],L.y=s[C+1],L.z=s[C+2],z.x=s[h],z.y=s[h+1],z.z=s[h+2],D.x=s[b],D.y=s[b+1],D.z=s[b+2],d[f].count++,d[m].count++,d[c].count++,r.Cartesian3.subtract(z,L,z),r.Cartesian3.subtract(D,L,D),y[v]=r.Cartesian3.cross(z,D,new r.Cartesian3),v++}var g,A=0;for(t=0;t<o;t++)d[t].indexOffset+=A,A+=d[t].count;for(v=0,t=0;t<p;t+=3){var T=(g=d[a[t]]).indexOffset+g.currentCount;l[T]=v,g.currentCount++,l[T=(g=d[a[t+1]]).indexOffset+g.currentCount]=v,g.currentCount++,l[T=(g=d[a[t+2]]).indexOffset+g.currentCount]=v,g.currentCount++,v++}var x=new Float32Array(3*o);for(t=0;t<o;t++){var P=3*t;if(g=d[t],r.Cartesian3.clone(r.Cartesian3.ZERO,N),g.count>0){for(v=0;v<g.count;v++)r.Cartesian3.add(N,y[l[g.indexOffset+v]],N);r.Cartesian3.equalsEpsilon(r.Cartesian3.ZERO,N,n.CesiumMath.EPSILON10)&&r.Cartesian3.clone(y[l[g.indexOffset]],N)}r.Cartesian3.equalsEpsilon(r.Cartesian3.ZERO,N,n.CesiumMath.EPSILON10)&&(N.z=1),r.Cartesian3.normalize(N,N),x[P]=N.x,x[P+1]=N.y,x[P+2]=N.z}return e.attributes.normal=new u.GeometryAttribute({componentDatatype:n.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:x}),e};var M=new r.Cartesian3,G=new r.Cartesian3,R=new r.Cartesian3;c.computeTangentAndBitangent=function(e){e.attributes;var t,a,i,s,o=e.indices,p=e.attributes.position.values,d=e.attributes.normal.values,y=e.attributes.st.values,l=e.attributes.position.values.length/3,v=o.length,f=new Array(3*l);for(t=0;t<f.length;t++)f[t]=0;for(t=0;t<v;t+=3){var m=o[t],c=o[t+1],C=o[t+2];i=3*c,s=3*C;var h=2*m,b=2*c,g=2*C,A=p[a=3*m],T=p[a+1],x=p[a+2],P=y[h],w=y[h+1],S=y[b+1]-w,I=y[g+1]-w,O=1/((y[b]-P)*I-(y[g]-P)*S),E=(I*(p[i]-A)-S*(p[s]-A))*O,N=(I*(p[i+1]-T)-S*(p[s+1]-T))*O,L=(I*(p[i+2]-x)-S*(p[s+2]-x))*O;f[a]+=E,f[a+1]+=N,f[a+2]+=L,f[i]+=E,f[i+1]+=N,f[i+2]+=L,f[s]+=E,f[s+1]+=N,f[s+2]+=L}var z=new Float32Array(3*l),D=new Float32Array(3*l);for(t=0;t<l;t++){i=1+(a=3*t),s=a+2;var F=r.Cartesian3.fromArray(d,a,M),V=r.Cartesian3.fromArray(f,a,R),B=r.Cartesian3.dot(F,V);r.Cartesian3.multiplyByScalar(F,B,G),r.Cartesian3.normalize(r.Cartesian3.subtract(V,G,V),V),z[a]=V.x,z[i]=V.y,z[s]=V.z,r.Cartesian3.normalize(r.Cartesian3.cross(F,V,V),V),D[a]=V.x,D[i]=V.y,D[s]=V.z}return e.attributes.tangent=new u.GeometryAttribute({componentDatatype:n.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:z}),e.attributes.bitangent=new u.GeometryAttribute({componentDatatype:n.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:D}),e};var F=new r.Cartesian2,V=new r.Cartesian3,B=new r.Cartesian3,k=new r.Cartesian3,_=new r.Cartesian2;function q(e,t){Math.abs(e.y)<n.CesiumMath.EPSILON6&&(e.y=t?-n.CesiumMath.EPSILON6:n.CesiumMath.EPSILON6)}c.compressVertices=function(e){var a,s,o=e.attributes.extrudeDirection;if(i.defined(o)){var p=o.values;s=p.length/3;var d=new Float32Array(2*s),y=0;for(a=0;a<s;++a)r.Cartesian3.fromArray(p,3*a,V),r.Cartesian3.equals(V,r.Cartesian3.ZERO)?y+=2:(_=t.AttributeCompression.octEncodeInRange(V,65535,_),d[y++]=_.x,d[y++]=_.y);return e.attributes.compressedAttributes=new u.GeometryAttribute({componentDatatype:n.ComponentDatatype.FLOAT,componentsPerAttribute:2,values:d}),delete e.attributes.extrudeDirection,e}var l=e.attributes.normal,v=e.attributes.st,f=i.defined(l),m=i.defined(v);if(!f&&!m)return e;var c,C,h,b,g=e.attributes.tangent,A=e.attributes.bitangent,T=i.defined(g),x=i.defined(A);f&&(c=l.values),m&&(C=v.values),T&&(h=g.values),x&&(b=A.values);var P=s=(f?c.length:C.length)/(f?3:2),w=m&&f?2:1;w+=T||x?1:0;var S=new Float32Array(P*=w),I=0;for(a=0;a<s;++a){m&&(r.Cartesian2.fromArray(C,2*a,F),S[I++]=t.AttributeCompression.compressTextureCoordinates(F));var O=3*a;f&&i.defined(h)&&i.defined(b)?(r.Cartesian3.fromArray(c,O,V),r.Cartesian3.fromArray(h,O,B),r.Cartesian3.fromArray(b,O,k),t.AttributeCompression.octPack(V,B,k,F),S[I++]=F.x,S[I++]=F.y):(f&&(r.Cartesian3.fromArray(c,O,V),S[I++]=t.AttributeCompression.octEncodeFloat(V)),T&&(r.Cartesian3.fromArray(h,O,V),S[I++]=t.AttributeCompression.octEncodeFloat(V)),x&&(r.Cartesian3.fromArray(b,O,V),S[I++]=t.AttributeCompression.octEncodeFloat(V)))}return e.attributes.compressedAttributes=new u.GeometryAttribute({componentDatatype:n.ComponentDatatype.FLOAT,componentsPerAttribute:w,values:S}),f&&delete e.attributes.normal,m&&delete e.attributes.st,x&&delete e.attributes.bitangent,T&&delete e.attributes.tangent,e};var U=new r.Cartesian3;function Y(e,t,a,i){r.Cartesian3.add(e,r.Cartesian3.multiplyByScalar(r.Cartesian3.subtract(t,e,U),e.y/(e.y-t.y),U),a),r.Cartesian3.clone(a,i),q(a,!0),q(i,!1)}var Z=new r.Cartesian3,H=new r.Cartesian3,W=new r.Cartesian3,X=new r.Cartesian3,j={positions:new Array(7),indices:new Array(9)};function K(e,t,r){if(!(e.x>=0||t.x>=0||r.x>=0)){!function(e,t,r){if(0!==e.y&&0!==t.y&&0!==r.y)return q(e,e.y<0),q(t,t.y<0),void q(r,r.y<0);var a=Math.abs(e.y),i=Math.abs(t.y),s=Math.abs(r.y),o=(a>i?a>s?n.CesiumMath.sign(e.y):n.CesiumMath.sign(r.y):i>s?n.CesiumMath.sign(t.y):n.CesiumMath.sign(r.y))<0;q(e,o),q(t,o),q(r,o)}(e,t,r);var a=e.y<0,i=t.y<0,s=r.y<0,o=0;o+=a?1:0,o+=i?1:0;var u=j.indices;1===(o+=s?1:0)?(u[1]=3,u[2]=4,u[5]=6,u[7]=6,u[8]=5,a?(Y(e,t,Z,W),Y(e,r,H,X),u[0]=0,u[3]=1,u[4]=2,u[6]=1):i?(Y(t,r,Z,W),Y(t,e,H,X),u[0]=1,u[3]=2,u[4]=0,u[6]=2):s&&(Y(r,e,Z,W),Y(r,t,H,X),u[0]=2,u[3]=0,u[4]=1,u[6]=0)):2===o&&(u[2]=4,u[4]=4,u[5]=3,u[7]=5,u[8]=6,a?i?s||(Y(r,e,Z,W),Y(r,t,H,X),u[0]=0,u[1]=1,u[3]=0,u[6]=2):(Y(t,r,Z,W),Y(t,e,H,X),u[0]=2,u[1]=0,u[3]=2,u[6]=1):(Y(e,t,Z,W),Y(e,r,H,X),u[0]=1,u[1]=2,u[3]=1,u[6]=0));var p=j.positions;return p[0]=e,p[1]=t,p[2]=r,p.length=3,1!==o&&2!==o||(p[3]=Z,p[4]=H,p[5]=W,p[6]=X,p.length=7),j}}function J(e,t){var r=e.attributes;if(0!==r.position.values.length){for(var a in r)if(r.hasOwnProperty(a)&&i.defined(r[a])&&i.defined(r[a].values)){var o=r[a];o.values=n.ComponentDatatype.createTypedArray(o.componentDatatype,o.values)}var d=u.Geometry.computeNumberOfVertices(e);return e.indices=p.IndexDatatype.createTypedArray(d,e.indices),t&&(e.boundingSphere=s.BoundingSphere.fromVertices(r.position.values)),e}}function Q(e){var t=e.attributes,r={};for(var a in t)if(t.hasOwnProperty(a)&&i.defined(t[a])&&i.defined(t[a].values)){var n=t[a];r[a]=new u.GeometryAttribute({componentDatatype:n.componentDatatype,componentsPerAttribute:n.componentsPerAttribute,normalize:n.normalize,values:[]})}return new u.Geometry({attributes:r,indices:[],primitiveType:e.primitiveType})}function $(e,t,r){var a=i.defined(e.geometry.boundingSphere);t=J(t,a),r=J(r,a),i.defined(r)&&!i.defined(t)?e.geometry=r:!i.defined(r)&&i.defined(t)?e.geometry=t:(e.westHemisphereGeometry=t,e.eastHemisphereGeometry=r,e.geometry=void 0)}function ee(e,t){var r=new e,a=new e,i=new e;return function(n,s,o,u,p,d,y,l){var v=e.fromArray(p,n*t,r),f=e.fromArray(p,s*t,a),m=e.fromArray(p,o*t,i);e.multiplyByScalar(v,u.x,v),e.multiplyByScalar(f,u.y,f),e.multiplyByScalar(m,u.z,m);var c=e.add(v,f,v);e.add(c,m,c),l&&e.normalize(c,c),e.pack(c,d,y*t)}}var te=ee(r.Cartesian4,4),re=ee(r.Cartesian3,3),ae=ee(r.Cartesian2,2),ie=new r.Cartesian3,ne=new r.Cartesian3,se=new r.Cartesian3,oe=new r.Cartesian3;function ue(e,t,a,s,o,u,p,d,y,m,c,C,h,b,g,A){if(i.defined(u)||i.defined(p)||i.defined(d)||i.defined(y)||i.defined(m)||0!==b){var T=function(e,t,a,s,o){var u,p,d,y,m,c,C,h;if(i.defined(o)||(o=new r.Cartesian3),i.defined(t.z)){if(r.Cartesian3.equalsEpsilon(e,t,n.CesiumMath.EPSILON14))return r.Cartesian3.clone(r.Cartesian3.UNIT_X,o);if(r.Cartesian3.equalsEpsilon(e,a,n.CesiumMath.EPSILON14))return r.Cartesian3.clone(r.Cartesian3.UNIT_Y,o);if(r.Cartesian3.equalsEpsilon(e,s,n.CesiumMath.EPSILON14))return r.Cartesian3.clone(r.Cartesian3.UNIT_Z,o);u=r.Cartesian3.subtract(a,t,l),p=r.Cartesian3.subtract(s,t,v),d=r.Cartesian3.subtract(e,t,f),y=r.Cartesian3.dot(u,u),m=r.Cartesian3.dot(u,p),c=r.Cartesian3.dot(u,d),C=r.Cartesian3.dot(p,p),h=r.Cartesian3.dot(p,d)}else{if(r.Cartesian2.equalsEpsilon(e,t,n.CesiumMath.EPSILON14))return r.Cartesian3.clone(r.Cartesian3.UNIT_X,o);if(r.Cartesian2.equalsEpsilon(e,a,n.CesiumMath.EPSILON14))return r.Cartesian3.clone(r.Cartesian3.UNIT_Y,o);if(r.Cartesian2.equalsEpsilon(e,s,n.CesiumMath.EPSILON14))return r.Cartesian3.clone(r.Cartesian3.UNIT_Z,o);u=r.Cartesian2.subtract(a,t,l),p=r.Cartesian2.subtract(s,t,v),d=r.Cartesian2.subtract(e,t,f),y=r.Cartesian2.dot(u,u),m=r.Cartesian2.dot(u,p),c=r.Cartesian2.dot(u,d),C=r.Cartesian2.dot(p,p),h=r.Cartesian2.dot(p,d)}o.y=C*c-m*h,o.z=y*h-m*c;var b=y*C-m*m;return 0!==o.y&&(o.y/=b),0!==o.z&&(o.z/=b),o.x=1-o.y-o.z,o}(s,r.Cartesian3.fromArray(o,3*e,ie),r.Cartesian3.fromArray(o,3*t,ne),r.Cartesian3.fromArray(o,3*a,se),oe);if(i.defined(u)&&re(e,t,a,T,u,C.normal.values,A,!0),i.defined(m)){var x,P=r.Cartesian3.fromArray(m,3*e,ie),w=r.Cartesian3.fromArray(m,3*t,ne),S=r.Cartesian3.fromArray(m,3*a,se);r.Cartesian3.multiplyByScalar(P,T.x,P),r.Cartesian3.multiplyByScalar(w,T.y,w),r.Cartesian3.multiplyByScalar(S,T.z,S),r.Cartesian3.equals(P,r.Cartesian3.ZERO)&&r.Cartesian3.equals(w,r.Cartesian3.ZERO)&&r.Cartesian3.equals(S,r.Cartesian3.ZERO)?((x=ie).x=0,x.y=0,x.z=0):(x=r.Cartesian3.add(P,w,P),r.Cartesian3.add(x,S,x),r.Cartesian3.normalize(x,x)),r.Cartesian3.pack(x,C.extrudeDirection.values,3*A)}if(i.defined(c)&&function(e,t,r,a,i,s,o){var u=i[e]*a.x,p=i[t]*a.y,d=i[r]*a.z;s[o]=u+p+d>n.CesiumMath.EPSILON6?1:0}(e,t,a,T,c,C.applyOffset.values,A),i.defined(p)&&re(e,t,a,T,p,C.tangent.values,A,!0),i.defined(d)&&re(e,t,a,T,d,C.bitangent.values,A,!0),i.defined(y)&&ae(e,t,a,T,y,C.st.values,A),b>0)for(var I=0;I<b;I++){var O=h[I];pe(e,t,a,T,A,g[O],C[O])}}}function pe(e,t,r,a,i,n,s){var o=n.componentsPerAttribute,u=n.values,p=s.values;switch(o){case 4:te(e,t,r,a,u,p,i,!1);break;case 3:re(e,t,r,a,u,p,i,!1);break;case 2:ae(e,t,r,a,u,p,i,!1);break;default:p[i]=u[e]*a.x+u[t]*a.y+u[r]*a.z}}function de(e,t,r,a,i,n){var s=e.position.values.length/3;if(-1!==i){var o=a[i],u=r[o];return-1===u?(r[o]=s,e.position.values.push(n.x,n.y,n.z),t.push(s),s):(t.push(u),u)}return e.position.values.push(n.x,n.y,n.z),t.push(s),s}var ye={position:!0,normal:!0,bitangent:!0,tangent:!0,st:!0,extrudeDirection:!0,applyOffset:!0};function le(e){var t=e.geometry,a=t.attributes,n=a.position.values,s=i.defined(a.normal)?a.normal.values:void 0,o=i.defined(a.bitangent)?a.bitangent.values:void 0,u=i.defined(a.tangent)?a.tangent.values:void 0,p=i.defined(a.st)?a.st.values:void 0,d=i.defined(a.extrudeDirection)?a.extrudeDirection.values:void 0,y=i.defined(a.applyOffset)?a.applyOffset.values:void 0,l=t.indices,v=[];for(var f in a)a.hasOwnProperty(f)&&!ye[f]&&i.defined(a[f])&&v.push(f);var m,c,C,h,b=v.length,g=Q(t),A=Q(t),T=[];T.length=n.length/3;var x=[];for(x.length=n.length/3,h=0;h<T.length;++h)T[h]=-1,x[h]=-1;var P=l.length;for(h=0;h<P;h+=3){var w=l[h],S=l[h+1],I=l[h+2],O=r.Cartesian3.fromArray(n,3*w),E=r.Cartesian3.fromArray(n,3*S),N=r.Cartesian3.fromArray(n,3*I),L=K(O,E,N);if(i.defined(L)&&L.positions.length>3)for(var z=L.positions,D=L.indices,M=D.length,G=0;G<M;++G){var R=D[G],F=z[R];F.y<0?(m=A.attributes,c=A.indices,C=T):(m=g.attributes,c=g.indices,C=x),ue(w,S,I,F,n,s,u,o,p,d,y,m,v,b,a,de(m,c,C,l,R<3?h+R:-1,F))}else i.defined(L)&&(O=L.positions[0],E=L.positions[1],N=L.positions[2]),O.y<0?(m=A.attributes,c=A.indices,C=T):(m=g.attributes,c=g.indices,C=x),ue(w,S,I,O,n,s,u,o,p,d,y,m,v,b,a,de(m,c,C,l,h,O)),ue(w,S,I,E,n,s,u,o,p,d,y,m,v,b,a,de(m,c,C,l,h+1,E)),ue(w,S,I,N,n,s,u,o,p,d,y,m,v,b,a,de(m,c,C,l,h+2,N))}$(e,A,g)}var ve=y.Plane.fromPointNormal(r.Cartesian3.ZERO,r.Cartesian3.UNIT_Y),fe=new r.Cartesian3,me=new r.Cartesian3;function ce(e,t,a,s,o,u,p){if(i.defined(p)){var d=r.Cartesian3.fromArray(s,3*e,ie);r.Cartesian3.equalsEpsilon(d,a,n.CesiumMath.EPSILON10)?u.applyOffset.values[o]=p[e]:u.applyOffset.values[o]=p[t]}}function Ce(e){var t,a=e.geometry,s=a.attributes,o=s.position.values,u=i.defined(s.applyOffset)?s.applyOffset.values:void 0,p=a.indices,y=Q(a),l=Q(a),v=p.length,f=[];f.length=o.length/3;var m=[];for(m.length=o.length/3,t=0;t<f.length;++t)f[t]=-1,m[t]=-1;for(t=0;t<v;t+=2){var c=p[t],C=p[t+1],h=r.Cartesian3.fromArray(o,3*c,ie),b=r.Cartesian3.fromArray(o,3*C,ne);Math.abs(h.y)<n.CesiumMath.EPSILON6&&(h.y<0?h.y=-n.CesiumMath.EPSILON6:h.y=n.CesiumMath.EPSILON6),Math.abs(b.y)<n.CesiumMath.EPSILON6&&(b.y<0?b.y=-n.CesiumMath.EPSILON6:b.y=n.CesiumMath.EPSILON6);var g=y.attributes,A=y.indices,T=m,x=l.attributes,P=l.indices,w=f,S=d.IntersectionTests.lineSegmentPlane(h,b,ve,se);if(i.defined(S)){var I=r.Cartesian3.multiplyByScalar(r.Cartesian3.UNIT_Y,5*n.CesiumMath.EPSILON9,fe);h.y<0&&(r.Cartesian3.negate(I,I),g=l.attributes,A=l.indices,T=f,x=y.attributes,P=y.indices,w=m);var O=r.Cartesian3.add(S,I,me);ce(c,C,h,o,de(g,A,T,p,t,h),g,u),ce(c,C,O,o,de(g,A,T,p,-1,O),g,u),r.Cartesian3.negate(I,I),r.Cartesian3.add(S,I,O),ce(c,C,O,o,de(x,P,w,p,-1,O),x,u),ce(c,C,b,o,de(x,P,w,p,t+1,b),x,u)}else{var E,N,L;h.y<0?(E=l.attributes,N=l.indices,L=f):(E=y.attributes,N=y.indices,L=m),ce(c,C,h,o,de(E,N,L,p,t,h),E,u),ce(c,C,b,o,de(E,N,L,p,t+1,b),E,u)}}$(e,l,y)}var he=new r.Cartesian2,be=new r.Cartesian2,ge=new r.Cartesian3,Ae=new r.Cartesian3,Te=new r.Cartesian3,xe=new r.Cartesian3,Pe=new r.Cartesian3,we=new r.Cartesian3,Se=new r.Cartesian4;function Ie(e){for(var t=e.attributes,a=t.position.values,i=t.prevPosition.values,n=t.nextPosition.values,s=a.length,o=0;o<s;o+=3){var u=r.Cartesian3.unpack(a,o,ge);if(!(u.x>0)){var p=r.Cartesian3.unpack(i,o,Ae);(u.y<0&&p.y>0||u.y>0&&p.y<0)&&(o-3>0?(i[o]=a[o-3],i[o+1]=a[o-2],i[o+2]=a[o-1]):r.Cartesian3.pack(u,i,o));var d=r.Cartesian3.unpack(n,o,Te);(u.y<0&&d.y>0||u.y>0&&d.y<0)&&(o+3<s?(n[o]=a[o+3],n[o+1]=a[o+4],n[o+2]=a[o+5]):r.Cartesian3.pack(u,n,o))}}}var Oe=5*n.CesiumMath.EPSILON9,Ee=n.CesiumMath.EPSILON6;c.splitLongitude=function(e){var t=e.geometry,a=t.boundingSphere;if(i.defined(a)&&(a.center.x-a.radius>0||s.BoundingSphere.intersectPlane(a,y.Plane.ORIGIN_ZX_PLANE)!==s.Intersect.INTERSECTING))return e;if(t.geometryType!==u.GeometryType.NONE)switch(t.geometryType){case u.GeometryType.POLYLINES:!function(e){var t,a,s,o=e.geometry,u=o.attributes,p=u.position.values,y=u.prevPosition.values,l=u.nextPosition.values,v=u.expandAndWidth.values,f=i.defined(u.st)?u.st.values:void 0,m=i.defined(u.color)?u.color.values:void 0,c=Q(o),C=Q(o),h=!1,b=p.length/3;for(t=0;t<b;t+=4){var g=t,A=t+2,T=r.Cartesian3.fromArray(p,3*g,ge),x=r.Cartesian3.fromArray(p,3*A,Ae);if(Math.abs(T.y)<Ee)for(T.y=Ee*(x.y<0?-1:1),p[3*t+1]=T.y,p[3*(t+1)+1]=T.y,a=3*g;a<3*g+12;a+=3)y[a]=p[3*t],y[a+1]=p[3*t+1],y[a+2]=p[3*t+2];if(Math.abs(x.y)<Ee)for(x.y=Ee*(T.y<0?-1:1),p[3*(t+2)+1]=x.y,p[3*(t+3)+1]=x.y,a=3*g;a<3*g+12;a+=3)l[a]=p[3*(t+2)],l[a+1]=p[3*(t+2)+1],l[a+2]=p[3*(t+2)+2];var P=c.attributes,w=c.indices,S=C.attributes,I=C.indices,O=d.IntersectionTests.lineSegmentPlane(T,x,ve,xe);if(i.defined(O)){h=!0;var E=r.Cartesian3.multiplyByScalar(r.Cartesian3.UNIT_Y,Oe,Pe);T.y<0&&(r.Cartesian3.negate(E,E),P=C.attributes,w=C.indices,S=c.attributes,I=c.indices);var N=r.Cartesian3.add(O,E,we);P.position.values.push(T.x,T.y,T.z,T.x,T.y,T.z),P.position.values.push(N.x,N.y,N.z),P.position.values.push(N.x,N.y,N.z),P.prevPosition.values.push(y[3*g],y[3*g+1],y[3*g+2]),P.prevPosition.values.push(y[3*g+3],y[3*g+4],y[3*g+5]),P.prevPosition.values.push(T.x,T.y,T.z,T.x,T.y,T.z),P.nextPosition.values.push(N.x,N.y,N.z),P.nextPosition.values.push(N.x,N.y,N.z),P.nextPosition.values.push(N.x,N.y,N.z),P.nextPosition.values.push(N.x,N.y,N.z),r.Cartesian3.negate(E,E),r.Cartesian3.add(O,E,N),S.position.values.push(N.x,N.y,N.z),S.position.values.push(N.x,N.y,N.z),S.position.values.push(x.x,x.y,x.z,x.x,x.y,x.z),S.prevPosition.values.push(N.x,N.y,N.z),S.prevPosition.values.push(N.x,N.y,N.z),S.prevPosition.values.push(N.x,N.y,N.z),S.prevPosition.values.push(N.x,N.y,N.z),S.nextPosition.values.push(x.x,x.y,x.z,x.x,x.y,x.z),S.nextPosition.values.push(l[3*A],l[3*A+1],l[3*A+2]),S.nextPosition.values.push(l[3*A+3],l[3*A+4],l[3*A+5]);var L=r.Cartesian2.fromArray(v,2*g,he),z=Math.abs(L.y);P.expandAndWidth.values.push(-1,z,1,z),P.expandAndWidth.values.push(-1,-z,1,-z),S.expandAndWidth.values.push(-1,z,1,z),S.expandAndWidth.values.push(-1,-z,1,-z);var D=r.Cartesian3.magnitudeSquared(r.Cartesian3.subtract(O,T,Te));if(D/=r.Cartesian3.magnitudeSquared(r.Cartesian3.subtract(x,T,Te)),i.defined(m)){var M=r.Cartesian4.fromArray(m,4*g,Se),G=r.Cartesian4.fromArray(m,4*A,Se),R=n.CesiumMath.lerp(M.x,G.x,D),F=n.CesiumMath.lerp(M.y,G.y,D),V=n.CesiumMath.lerp(M.z,G.z,D),B=n.CesiumMath.lerp(M.w,G.w,D);for(a=4*g;a<4*g+8;++a)P.color.values.push(m[a]);for(P.color.values.push(R,F,V,B),P.color.values.push(R,F,V,B),S.color.values.push(R,F,V,B),S.color.values.push(R,F,V,B),a=4*A;a<4*A+8;++a)S.color.values.push(m[a])}if(i.defined(f)){var k=r.Cartesian2.fromArray(f,2*g,he),_=r.Cartesian2.fromArray(f,2*(t+3),be),q=n.CesiumMath.lerp(k.x,_.x,D);for(a=2*g;a<2*g+4;++a)P.st.values.push(f[a]);for(P.st.values.push(q,k.y),P.st.values.push(q,_.y),S.st.values.push(q,k.y),S.st.values.push(q,_.y),a=2*A;a<2*A+4;++a)S.st.values.push(f[a])}s=P.position.values.length/3-4,w.push(s,s+2,s+1),w.push(s+1,s+2,s+3),s=S.position.values.length/3-4,I.push(s,s+2,s+1),I.push(s+1,s+2,s+3)}else{var U,Y;for(T.y<0?(U=C.attributes,Y=C.indices):(U=c.attributes,Y=c.indices),U.position.values.push(T.x,T.y,T.z),U.position.values.push(T.x,T.y,T.z),U.position.values.push(x.x,x.y,x.z),U.position.values.push(x.x,x.y,x.z),a=3*t;a<3*t+12;++a)U.prevPosition.values.push(y[a]),U.nextPosition.values.push(l[a]);for(a=2*t;a<2*t+8;++a)U.expandAndWidth.values.push(v[a]),i.defined(f)&&U.st.values.push(f[a]);if(i.defined(m))for(a=4*t;a<4*t+16;++a)U.color.values.push(m[a]);s=U.position.values.length/3-4,Y.push(s,s+2,s+1),Y.push(s+1,s+2,s+3)}}h&&(Ie(C),Ie(c)),$(e,C,c)}(e);break;case u.GeometryType.TRIANGLES:le(e);break;case u.GeometryType.LINES:Ce(e)}else(function(e){switch(e.primitiveType){case u.PrimitiveType.TRIANGLE_FAN:return function(e){var t=u.Geometry.computeNumberOfVertices(e),r=p.IndexDatatype.createTypedArray(t,3*(t-2));r[0]=1,r[1]=0,r[2]=2;for(var a=3,i=3;i<t;++i)r[a++]=i-1,r[a++]=0,r[a++]=i;return e.indices=r,e.primitiveType=u.PrimitiveType.TRIANGLES,e}(e);case u.PrimitiveType.TRIANGLE_STRIP:return function(e){var t=u.Geometry.computeNumberOfVertices(e),r=p.IndexDatatype.createTypedArray(t,3*(t-2));r[0]=0,r[1]=1,r[2]=2,t>3&&(r[3]=0,r[4]=2,r[5]=3);for(var a=6,i=3;i<t-1;i+=2)r[a++]=i,r[a++]=i-1,r[a++]=i+1,i+2<t&&(r[a++]=i,r[a++]=i+1,r[a++]=i+2);return e.indices=r,e.primitiveType=u.PrimitiveType.TRIANGLES,e}(e);case u.PrimitiveType.TRIANGLES:return function(e){if(i.defined(e.indices))return e;for(var t=u.Geometry.computeNumberOfVertices(e),r=p.IndexDatatype.createTypedArray(t,t),a=0;a<t;++a)r[a]=a;return e.indices=r,e}(e);case u.PrimitiveType.LINE_STRIP:return function(e){var t=u.Geometry.computeNumberOfVertices(e),r=p.IndexDatatype.createTypedArray(t,2*(t-1));r[0]=0,r[1]=1;for(var a=2,i=2;i<t;++i)r[a++]=i-1,r[a++]=i;return e.indices=r,e.primitiveType=u.PrimitiveType.LINES,e}(e);case u.PrimitiveType.LINE_LOOP:return function(e){var t=u.Geometry.computeNumberOfVertices(e),r=p.IndexDatatype.createTypedArray(t,2*t);r[0]=0,r[1]=1;for(var a=2,i=2;i<t;++i)r[a++]=i-1,r[a++]=i;return r[a++]=t-1,r[a]=0,e.indices=r,e.primitiveType=u.PrimitiveType.LINES,e}(e);case u.PrimitiveType.LINES:(function(e){if(i.defined(e.indices))return e;for(var t=u.Geometry.computeNumberOfVertices(e),r=p.IndexDatatype.createTypedArray(t,t),a=0;a<t;++a)r[a]=a;e.indices=r})(e)}})(t),t.primitiveType===u.PrimitiveType.TRIANGLES?le(e):t.primitiveType===u.PrimitiveType.LINES&&Ce(e);return e},e.GeometryPipeline=c})); |