define(["exports","./arrayFill-4513d7ad","./buildModuleUrl-57a32107","./Cartesian2-47311507","./Cartographic-3309dd0d","./ComponentDatatype-c140a87d","./CylinderGeometryLibrary-aa453214","./when-b60132fc","./Check-7b2a090c","./GeometryAttribute-c42d25b7","./GeometryAttributes-252e9929","./GeometryOffsetAttribute-fbeb6f1a","./IndexDatatype-8a5eead4","./Math-119be1a3","./VertexFormat-6446fca0"],(function(t,e,a,r,n,o,i,s,u,m,d,l,p,y,f){"use strict";var b=new r.Cartesian2,c=new n.Cartesian3,v=new n.Cartesian3,A=new n.Cartesian3,g=new n.Cartesian3;function h(t){var e=(t=s.defaultValue(t,s.defaultValue.EMPTY_OBJECT)).length,a=t.topRadius,r=t.bottomRadius,n=s.defaultValue(t.vertexFormat,f.VertexFormat.DEFAULT),o=s.defaultValue(t.slices,128);this._length=e,this._topRadius=a,this._bottomRadius=r,this._vertexFormat=f.VertexFormat.clone(n),this._slices=o,this._offsetAttribute=t.offsetAttribute,this._workerName="createCylinderGeometry"}h.packedLength=f.VertexFormat.packedLength+5,h.pack=function(t,e,a){return a=s.defaultValue(a,0),f.VertexFormat.pack(t._vertexFormat,e,a),a+=f.VertexFormat.packedLength,e[a++]=t._length,e[a++]=t._topRadius,e[a++]=t._bottomRadius,e[a++]=t._slices,e[a]=s.defaultValue(t._offsetAttribute,-1),e};var x,_=new f.VertexFormat,C={vertexFormat:_,length:void 0,topRadius:void 0,bottomRadius:void 0,slices:void 0,offsetAttribute:void 0};h.unpack=function(t,e,a){e=s.defaultValue(e,0);var r=f.VertexFormat.unpack(t,e,_);e+=f.VertexFormat.packedLength;var n=t[e++],o=t[e++],i=t[e++],u=t[e++],m=t[e];return s.defined(a)?(a._vertexFormat=f.VertexFormat.clone(r,a._vertexFormat),a._length=n,a._topRadius=o,a._bottomRadius=i,a._slices=u,a._offsetAttribute=-1===m?void 0:m,a):(C.length=n,C.topRadius=o,C.bottomRadius=i,C.slices=u,C.offsetAttribute=-1===m?void 0:m,new h(C))},h.createGeometry=function(t){var u=t._length,f=t._topRadius,h=t._bottomRadius,x=t._vertexFormat,_=t._slices;if(!(u<=0||f<0||h<0||0===f&&0===h)){var C,F=_+_,w=_+F,G=F+F,D=i.CylinderGeometryLibrary.computePositions(u,f,h,_,!0),R=x.st?new Float32Array(2*G):void 0,V=x.normal?new Float32Array(3*G):void 0,O=x.tangent?new Float32Array(3*G):void 0,T=x.bitangent?new Float32Array(3*G):void 0,L=x.normal||x.tangent||x.bitangent;if(L){var M=x.tangent||x.bitangent,P=0,k=0,z=0,E=Math.atan2(h-f,u),N=c;N.z=Math.sin(E);var I=Math.cos(E),U=A,S=v;for(C=0;C<_;C++){var B=C/_*y.CesiumMath.TWO_PI,Y=I*Math.cos(B),Z=I*Math.sin(B);L&&(N.x=Y,N.y=Z,M&&(U=n.Cartesian3.normalize(n.Cartesian3.cross(n.Cartesian3.UNIT_Z,N,U),U)),x.normal&&(V[P++]=N.x,V[P++]=N.y,V[P++]=N.z,V[P++]=N.x,V[P++]=N.y,V[P++]=N.z),x.tangent&&(O[k++]=U.x,O[k++]=U.y,O[k++]=U.z,O[k++]=U.x,O[k++]=U.y,O[k++]=U.z),x.bitangent&&(S=n.Cartesian3.normalize(n.Cartesian3.cross(N,U,S),S),T[z++]=S.x,T[z++]=S.y,T[z++]=S.z,T[z++]=S.x,T[z++]=S.y,T[z++]=S.z))}for(C=0;C<_;C++)x.normal&&(V[P++]=0,V[P++]=0,V[P++]=-1),x.tangent&&(O[k++]=1,O[k++]=0,O[k++]=0),x.bitangent&&(T[z++]=0,T[z++]=-1,T[z++]=0);for(C=0;C<_;C++)x.normal&&(V[P++]=0,V[P++]=0,V[P++]=1),x.tangent&&(O[k++]=1,O[k++]=0,O[k++]=0),x.bitangent&&(T[z++]=0,T[z++]=1,T[z++]=0)}var J=12*_-12,W=p.IndexDatatype.createTypedArray(G,J),j=0,q=0;for(C=0;C<_-1;C++)W[j++]=q,W[j++]=q+2,W[j++]=q+3,W[j++]=q,W[j++]=q+3,W[j++]=q+1,q+=2;for(W[j++]=F-2,W[j++]=0,W[j++]=1,W[j++]=F-2,W[j++]=1,W[j++]=F-1,C=1;C<_-1;C++)W[j++]=F+C+1,W[j++]=F+C,W[j++]=F;for(C=1;C<_-1;C++)W[j++]=w,W[j++]=w+C,W[j++]=w+C+1;var H=0;if(x.st){var K=Math.max(f,h);for(C=0;C<G;C++){var Q=n.Cartesian3.fromArray(D,3*C,g);R[H++]=(Q.x+K)/(2*K),R[H++]=(Q.y+K)/(2*K)}}var X=new d.GeometryAttributes;x.position&&(X.position=new m.GeometryAttribute({componentDatatype:o.ComponentDatatype.DOUBLE,componentsPerAttribute:3,values:D})),x.normal&&(X.normal=new m.GeometryAttribute({componentDatatype:o.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:V})),x.tangent&&(X.tangent=new m.GeometryAttribute({componentDatatype:o.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:O})),x.bitangent&&(X.bitangent=new m.GeometryAttribute({componentDatatype:o.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:T})),x.st&&(X.st=new m.GeometryAttribute({componentDatatype:o.ComponentDatatype.FLOAT,componentsPerAttribute:2,values:R})),b.x=.5*u,b.y=Math.max(h,f);var $=new a.BoundingSphere(n.Cartesian3.ZERO,r.Cartesian2.magnitude(b));if(s.defined(t._offsetAttribute)){u=D.length;var tt=new Uint8Array(u/3),et=t._offsetAttribute===l.GeometryOffsetAttribute.NONE?0:1;e.arrayFill(tt,et),X.applyOffset=new m.GeometryAttribute({componentDatatype:o.ComponentDatatype.UNSIGNED_BYTE,componentsPerAttribute:1,values:tt})}return new m.Geometry({attributes:X,indices:W,primitiveType:a.PrimitiveType.TRIANGLES,boundingSphere:$,offsetAttribute:t._offsetAttribute})}},h.getUnitCylinder=function(){return s.defined(x)||(x=h.createGeometry(new h({topRadius:1,bottomRadius:1,length:1,vertexFormat:f.VertexFormat.POSITION_ONLY}))),x},t.CylinderGeometry=h}));
