text: define(["exports","./when-54c2dc71","./Check-6c0211bc","./Math-fc8cecf5","./Cartesian3-e5933291","./ComponentDatatype-6d99a1ee","./Cartesian2-062e3760","./Transforms-7e4f9763","./GeometryAttribute-8f568314","./GeometryAttributes-4fcfcf40","./IndexDatatype-53503fee","./GeometryOffsetAttribute-7350d9af","./VertexFormat-7572c785","./CylinderGeometryLibrary-b0214ab1"],function(t,U,e,S,B,Y,Z,J,W,j,q,H,f,K){"use strict";var Q=new Z.Cartesian2,X=new B.Cartesian3,$=new B.Cartesian3,tt=new B.Cartesian3,et=new B.Cartesian3;function d(t){var e,a=(t=U.defaultValue(t,U.defaultValue.EMPTY_OBJECT)).length,r=t.topRadius,n=t.bottomRadius,o=U.defaultValue(t.vertexFormat,f.VertexFormat.DEFAULT),i=U.defaultValue(t.slices,128);this._length=a,this._topRadius=r,this._bottomRadius=n,this._vertexFormat=f.VertexFormat.clone(o),this._slices=i,this._offsetAttribute=t.offsetAttribute,U.defined(t.id)&&(e=t.id._cylinder.RootTransform,this._rootTransform=e),t.rootTransform&&(this._rootTransform=t.rootTransform),U.defined(e)&&(this.rtpackedLength=1+e.length),this._workerName="createCylinderGeometry"}d.packedLength=f.VertexFormat.packedLength+5+17,d.pack=function(t,e,a){a=U.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++]=U.defaultValue(t._offsetAttribute,-1);var r=t._rootTransform;return U.defined(r)&&J.Matrix4.pack(r,e,a++),e};var a,y=new f.VertexFormat,p={vertexFormat:y,length:void 0,topRadius:void 0,bottomRadius:void 0,slices:void 0,offsetAttribute:void 0};d.unpack=function(t,e,a){e=U.defaultValue(e,0);var r=f.VertexFormat.unpack(t,e,y);e+=f.VertexFormat.packedLength;var n=t[e++],o=t[e++],i=t[e++],s=t[e++],m=t[e++],u=new J.Matrix4;return t.length>e&&J.Matrix4.unpack(t,e++,u),U.defined(a)?(a._vertexFormat=f.VertexFormat.clone(r,a._vertexFormat),a._length=n,a._topRadius=o,a._bottomRadius=i,a._slices=s,a._offsetAttribute=-1===m?void 0:m,a._rootTransform=u,a):(p.length=n,p.topRadius=o,p.bottomRadius=i,p.slices=s,p.offsetAttribute=-1===m?void 0:m,p.rootTransform=u,new d(p))},d.createGeometry=function(t){var e=t._length,a=t._topRadius,r=t._bottomRadius,n=t._vertexFormat,o=t._slices;if(!(e<=0||a<0||r<0||0===a&&0===r)){var i=o+o,s=o+i,m=i+i,u=K.CylinderGeometryLibrary.computePositions(e,a,r,o,!0),f=n.st?new Float32Array(2*m):void 0,d=n.normal?new Float32Array(3*m):void 0,y=n.tangent?new Float32Array(3*m):void 0,p=n.bitangent?new Float32Array(3*m):void 0,l=n.normal||n.tangent||n.bitangent;if(l){var c=n.tangent||n.bitangent,b=0,h=0,v=0,x=Math.atan2(r-a,e),A=X;A.z=Math.sin(x);for(var _=Math.cos(x),g=tt,C=$,F=0;F<o;F++){var w=F/o*S.CesiumMath.TWO_PI,T=_*Math.cos(w),M=_*Math.sin(w);l&&(A.x=T,A.y=M,c&&(g=B.Cartesian3.normalize(B.Cartesian3.cross(B.Cartesian3.UNIT_Z,A,g),g)),n.normal&&(d[b++]=A.x,d[b++]=A.y,d[b++]=A.z,d[b++]=A.x,d[b++]=A.y,d[b++]=A.z),n.tangent&&(y[h++]=g.x,y[h++]=g.y,y[h++]=g.z,y[h++]=g.x,y[h++]=g.y,y[h++]=g.z),n.bitangent&&(C=B.Cartesian3.normalize(B.Cartesian3.cross(A,g,C),C),p[v++]=C.x,p[v++]=C.y,p[v++]=C.z,p[v++]=C.x,p[v++]=C.y,p[v++]=C.z))}for(F=0;F<o;F++)n.normal&&(d[b++]=0,d[b++]=0,d[b++]=-1),n.tangent&&(y[h++]=1,y[h++]=0,y[h++]=0),n.bitangent&&(p[v++]=0,p[v++]=-1,p[v++]=0);for(F=0;F<o;F++)n.normal&&(d[b++]=0,d[b++]=0,d[b++]=1),n.tangent&&(y[h++]=1,y[h++]=0,y[h++]=0),n.bitangent&&(p[v++]=0,p[v++]=1,p[v++]=0)}var G=12*o-12,R=q.IndexDatatype.createTypedArray(m,G),D=0,V=0;for(F=0;F<o-1;F++)R[D++]=V,R[D++]=V+2,R[D++]=V+3,R[D++]=V,R[D++]=V+3,R[D++]=V+1,V+=2;for(R[D++]=i-2,R[D++]=0,R[D++]=1,R[D++]=i-2,R[D++]=1,R[D++]=i-1,F=1;F<o-1;F++)R[D++]=i+F+1,R[D++]=i+F,R[D++]=i;for(F=1;F<o-1;F++)R[D++]=s,R[D++]=s+F,R[D++]=s+F+1;var z=0;if(n.st){var L=Math.max(a,r);for(F=0;F<m;F++){var O=B.Cartesian3.fromArray(u,3*F,et);f[z++]=(O.x+L)/(2*L),f[z++]=(O.y+L)/(2*L)}}var k=function(t){for(var e=new B.Cartesian3(-1/0,-1/0,-1/0),a=new B.Cartesian3(1/0,1/0,1/0),r=0;r<t.length/3;r++){var n=new B.Cartesian3(t[3*r],t[3*r+1],t[3*r+2]);e.x=Math.max(e.x,n.x),e.y=Math.max(e.y,n.y),e.z=Math.max(e.z,n.z),a.x=Math.min(a.x,n.x),a.y=Math.min(a.y,n.y),a.z=Math.min(a.z,n.z)}return[e,a]}(u,t.rootTransform),P=new j.GeometryAttributes;n.position&&(P.position=new W.GeometryAttribute({componentDatatype:Y.ComponentDatatype.DOUBLE,componentsPerAttribute:3,values:u})),n.normal&&(P.normal=new W.GeometryAttribute({componentDatatype:Y.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:d})),n.tangent&&(P.tangent=new W.GeometryAttribute({componentDatatype:Y.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:y})),n.bitangent&&(P.bitangent=new W.GeometryAttribute({componentDatatype:Y.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:p})),n.st&&(P.st=new W.GeometryAttribute({componentDatatype:Y.ComponentDatatype.FLOAT,componentsPerAttribute:2,values:f})),Q.x=.5*e,Q.y=Math.max(r,a);var E,N,I=new J.BoundingSphere(B.Cartesian3.ZERO,Z.Cartesian2.magnitude(Q));return U.defined(t._offsetAttribute)&&(e=u.length,E=new Uint8Array(e/3),N=t._offsetAttribute===H.GeometryOffsetAttribute.NONE?0:1,H.arrayFill(E,N),P.applyOffset=new W.GeometryAttribute({componentDatatype:Y.ComponentDatatype.UNSIGNED_BYTE,componentsPerAttribute:1,values:E})),new W.Geometry({attributes:P,indices:R,primitiveType:W.PrimitiveType.TRIANGLES,boundingSphere:I,offsetAttribute:t._offsetAttribute,MaxPoint:k[0],MinPoint:k[1]})}},d.getUnitCylinder=function(){return U.defined(a)||(a=d.createGeometry(new d({topRadius:1,bottomRadius:1,length:1,vertexFormat:f.VertexFormat.POSITION_ONLY}))),a},t.CylinderGeometry=d});
  