define(["exports","./arrayFill-4513d7ad","./BoundingSphere-561b54d0","./Cartographic-3309dd0d","./ComponentDatatype-c140a87d","./when-b60132fc","./Check-7b2a090c","./Cartesian2-47311507","./GeometryAttribute-3a42bbdc","./GeometryAttributes-252e9929","./GeometryOffsetAttribute-fbeb6f1a","./IndexDatatype-8a5eead4","./Math-119be1a3","./PrimitiveType-39acab88"],(function(i,t,e,a,n,r,o,s,m,u,f,d,l,c){"use strict";var C=new a.Cartesian3(1,1,1),_=Math.cos,h=Math.sin;function p(i){i=r.defaultValue(i,r.defaultValue.EMPTY_OBJECT);var t=r.defaultValue(i.radii,C),e=r.defaultValue(i.innerRadii,t),n=r.defaultValue(i.minimumClock,0),o=r.defaultValue(i.maximumClock,l.CesiumMath.TWO_PI),s=r.defaultValue(i.minimumCone,0),m=r.defaultValue(i.maximumCone,l.CesiumMath.PI),u=Math.round(r.defaultValue(i.stackPartitions,10)),f=Math.round(r.defaultValue(i.slicePartitions,8)),d=Math.round(r.defaultValue(i.subdivisions,128));this._radii=a.Cartesian3.clone(t),this._innerRadii=a.Cartesian3.clone(e),this._minimumClock=n,this._maximumClock=o,this._minimumCone=s,this._maximumCone=m,this._stackPartitions=u,this._slicePartitions=f,this._subdivisions=d,this._offsetAttribute=i.offsetAttribute,this._workerName="createEllipsoidOutlineGeometry"}p.packedLength=2*a.Cartesian3.packedLength+8,p.pack=function(i,t,e){return e=r.defaultValue(e,0),a.Cartesian3.pack(i._radii,t,e),e+=a.Cartesian3.packedLength,a.Cartesian3.pack(i._innerRadii,t,e),e+=a.Cartesian3.packedLength,t[e++]=i._minimumClock,t[e++]=i._maximumClock,t[e++]=i._minimumCone,t[e++]=i._maximumCone,t[e++]=i._stackPartitions,t[e++]=i._slicePartitions,t[e++]=i._subdivisions,t[e]=r.defaultValue(i._offsetAttribute,-1),t};var y=new a.Cartesian3,b=new a.Cartesian3,v={radii:y,innerRadii:b,minimumClock:void 0,maximumClock:void 0,minimumCone:void 0,maximumCone:void 0,stackPartitions:void 0,slicePartitions:void 0,subdivisions:void 0,offsetAttribute:void 0};p.unpack=function(i,t,e){t=r.defaultValue(t,0);var n=a.Cartesian3.unpack(i,t,y);t+=a.Cartesian3.packedLength;var o=a.Cartesian3.unpack(i,t,b);t+=a.Cartesian3.packedLength;var s=i[t++],m=i[t++],u=i[t++],f=i[t++],d=i[t++],l=i[t++],c=i[t++],C=i[t];return r.defined(e)?(e._radii=a.Cartesian3.clone(n,e._radii),e._innerRadii=a.Cartesian3.clone(o,e._innerRadii),e._minimumClock=s,e._maximumClock=m,e._minimumCone=u,e._maximumCone=f,e._stackPartitions=d,e._slicePartitions=l,e._subdivisions=c,e._offsetAttribute=-1===C?void 0:C,e):(v.minimumClock=s,v.maximumClock=m,v.minimumCone=u,v.maximumCone=f,v.stackPartitions=d,v.slicePartitions=l,v.subdivisions=c,v.offsetAttribute=-1===C?void 0:C,new p(v))},p.createGeometry=function(i){var a=i._radii;if(!(a.x<=0||a.y<=0||a.z<=0)){var o=i._innerRadii;if(!(o.x<=0||o.y<=0||o.z<=0)){var C=i._minimumClock,p=i._maximumClock,y=i._minimumCone,b=i._maximumCone,v=i._subdivisions,k=s.Ellipsoid.fromCartesian3(a),A=i._slicePartitions+1,x=i._stackPartitions+1;(A=Math.round(A*Math.abs(p-C)/l.CesiumMath.TWO_PI))<2&&(A=2),(x=Math.round(x*Math.abs(b-y)/l.CesiumMath.PI))<2&&(x=2);var P=0,w=1,M=o.x!==a.x||o.y!==a.y||o.z!==a.z,g=!1,V=!1;M&&(w=2,y>0&&(g=!0,P+=A),b<Math.PI&&(V=!0,P+=A));var G,E,O,D,I=v*w*(x+A),T=new Float64Array(3*I),z=2*(I+P-(A+x)*w),L=d.IndexDatatype.createTypedArray(I,z),R=0,N=new Array(x),B=new Array(x);for(G=0;G<x;G++)D=y+G*(b-y)/(x-1),N[G]=h(D),B[G]=_(D);var S=new Array(v),F=new Array(v);for(G=0;G<v;G++)O=C+G*(p-C)/(v-1),S[G]=h(O),F[G]=_(O);for(G=0;G<x;G++)for(E=0;E<v;E++)T[R++]=a.x*N[G]*F[E],T[R++]=a.y*N[G]*S[E],T[R++]=a.z*B[G];if(M)for(G=0;G<x;G++)for(E=0;E<v;E++)T[R++]=o.x*N[G]*F[E],T[R++]=o.y*N[G]*S[E],T[R++]=o.z*B[G];for(N.length=v,B.length=v,G=0;G<v;G++)D=y+G*(b-y)/(v-1),N[G]=h(D),B[G]=_(D);for(S.length=A,F.length=A,G=0;G<A;G++)O=C+G*(p-C)/(A-1),S[G]=h(O),F[G]=_(O);for(G=0;G<v;G++)for(E=0;E<A;E++)T[R++]=a.x*N[G]*F[E],T[R++]=a.y*N[G]*S[E],T[R++]=a.z*B[G];if(M)for(G=0;G<v;G++)for(E=0;E<A;E++)T[R++]=o.x*N[G]*F[E],T[R++]=o.y*N[G]*S[E],T[R++]=o.z*B[G];for(R=0,G=0;G<x*w;G++){var U=G*v;for(E=0;E<v-1;E++)L[R++]=U+E,L[R++]=U+E+1}var W=x*v*w;for(G=0;G<A;G++)for(E=0;E<v-1;E++)L[R++]=W+G+E*A,L[R++]=W+G+(E+1)*A;if(M)for(W=x*v*w+A*v,G=0;G<A;G++)for(E=0;E<v-1;E++)L[R++]=W+G+E*A,L[R++]=W+G+(E+1)*A;if(M){var Y=x*v*w,J=Y+v*A;if(g)for(G=0;G<A;G++)L[R++]=Y+G,L[R++]=J+G;if(V)for(Y+=v*A-A,J+=v*A-A,G=0;G<A;G++)L[R++]=Y+G,L[R++]=J+G}var j=new u.GeometryAttributes({position:new m.GeometryAttribute({componentDatatype:n.ComponentDatatype.DOUBLE,componentsPerAttribute:3,values:T})});if(r.defined(i._offsetAttribute)){var q=T.length,H=new Uint8Array(q/3),K=i._offsetAttribute===f.GeometryOffsetAttribute.NONE?0:1;t.arrayFill(H,K),j.applyOffset=new m.GeometryAttribute({componentDatatype:n.ComponentDatatype.UNSIGNED_BYTE,componentsPerAttribute:1,values:H})}return new m.Geometry({attributes:j,indices:L,primitiveType:c.PrimitiveType.LINES,boundingSphere:e.BoundingSphere.fromEllipsoid(k),offsetAttribute:i._offsetAttribute})}}},i.EllipsoidOutlineGeometry=p}));
