CylinderGeometry-6f090f14.js 4.8 KB

1
  1. define(["exports","./arrayFill-0358accf","./buildModuleUrl-3d15f25c","./Cartesian2-6033fa5d","./Cartographic-67e73ef9","./ComponentDatatype-81047f82","./CylinderGeometryLibrary-6601cb33","./when-92c6cf3c","./Check-52a7d806","./GeometryAttribute-ef657318","./GeometryAttributes-7f66ea53","./GeometryOffsetAttribute-b4d599f5","./IndexDatatype-4c0e98b8","./Math-92c3b5f7","./PrimitiveType-cdfe443e","./VertexFormat-f496a3f1"],(function(t,e,n,o,a,r,i,s,u,f,p,m,d,c,b,l){"use strict";var y=new o.o,v=new a.t,h=new a.t,w=new a.t,g=new a.t;function A(t){var e=(t=s.u(t,s.u.EMPTY_OBJECT)).length,n=t.topRadius,o=t.bottomRadius,a=s.u(t.vertexFormat,l.n.DEFAULT),r=s.u(t.slices,128);if(!s.e(e))throw new u.t("options.length must be defined.");if(!s.e(n))throw new u.t("options.topRadius must be defined.");if(!s.e(o))throw new u.t("options.bottomRadius must be defined.");if(r<3)throw new u.t("options.slices must be greater than or equal to 3.");if(s.e(t.offsetAttribute)&&t.offsetAttribute===m.z.TOP)throw new u.t("GeometryOffsetAttribute.TOP is not a supported options.offsetAttribute for this geometry.");this._length=e,this._topRadius=n,this._bottomRadius=o,this._vertexFormat=l.n.clone(a),this._slices=r,this._offsetAttribute=t.offsetAttribute,this._workerName="createCylinderGeometry"}A.packedLength=l.n.packedLength+5,A.pack=function(t,e,n){if(!s.e(t))throw new u.t("value is required");if(!s.e(e))throw new u.t("array is required");return n=s.u(n,0),l.n.pack(t._vertexFormat,e,n),n+=l.n.packedLength,e[n++]=t._length,e[n++]=t._topRadius,e[n++]=t._bottomRadius,e[n++]=t._slices,e[n]=s.u(t._offsetAttribute,-1),e};var _,x=new l.n,R={vertexFormat:x,length:void 0,topRadius:void 0,bottomRadius:void 0,slices:void 0,offsetAttribute:void 0};A.unpack=function(t,e,n){if(!s.e(t))throw new u.t("array is required");e=s.u(e,0);var o=l.n.unpack(t,e,x);e+=l.n.packedLength;var a=t[e++],r=t[e++],i=t[e++],f=t[e++],p=t[e];return s.e(n)?(n._vertexFormat=l.n.clone(o,n._vertexFormat),n._length=a,n._topRadius=r,n._bottomRadius=i,n._slices=f,n._offsetAttribute=-1===p?void 0:p,n):(R.length=a,R.topRadius=r,R.bottomRadius=i,R.slices=f,R.offsetAttribute=-1===p?void 0:p,new A(R))},A.createGeometry=function(t){var u=t._length,l=t._topRadius,A=t._bottomRadius,_=t._vertexFormat,x=t._slices;if(!(u<=0||l<0||A<0||0===l&&0===A)){var R,F=x+x,D=x+F,O=F+F,T=i.I.computePositions(u,l,A,x,!0),C=_.st?new Float32Array(2*O):void 0,L=_.normal?new Float32Array(3*O):void 0,P=_.tangent?new Float32Array(3*O):void 0,z=_.bitangent?new Float32Array(3*O):void 0,k=_.normal||_.tangent||_.bitangent;if(k){var G=_.tangent||_.bitangent,I=0,M=0,E=0,N=Math.atan2(A-l,u),U=v;U.z=Math.sin(N);var q=Math.cos(N),S=w,B=h;for(R=0;R<x;R++){var Y=R/x*c.e.TWO_PI,Z=q*Math.cos(Y),J=q*Math.sin(Y);k&&(U.x=Z,U.y=J,G&&(S=a.t.normalize(a.t.cross(a.t.UNIT_Z,U,S),S)),_.normal&&(L[I++]=U.x,L[I++]=U.y,L[I++]=U.z,L[I++]=U.x,L[I++]=U.y,L[I++]=U.z),_.tangent&&(P[M++]=S.x,P[M++]=S.y,P[M++]=S.z,P[M++]=S.x,P[M++]=S.y,P[M++]=S.z),_.bitangent&&(B=a.t.normalize(a.t.cross(U,S,B),B),z[E++]=B.x,z[E++]=B.y,z[E++]=B.z,z[E++]=B.x,z[E++]=B.y,z[E++]=B.z))}for(R=0;R<x;R++)_.normal&&(L[I++]=0,L[I++]=0,L[I++]=-1),_.tangent&&(P[M++]=1,P[M++]=0,P[M++]=0),_.bitangent&&(z[E++]=0,z[E++]=-1,z[E++]=0);for(R=0;R<x;R++)_.normal&&(L[I++]=0,L[I++]=0,L[I++]=1),_.tangent&&(P[M++]=1,P[M++]=0,P[M++]=0),_.bitangent&&(z[E++]=0,z[E++]=1,z[E++]=0)}var V=12*x-12,W=d.IndexDatatype.createTypedArray(O,V),j=0,H=0;for(R=0;R<x-1;R++)W[j++]=H,W[j++]=H+2,W[j++]=H+3,W[j++]=H,W[j++]=H+3,W[j++]=H+1,H+=2;for(W[j++]=F-2,W[j++]=0,W[j++]=1,W[j++]=F-2,W[j++]=1,W[j++]=F-1,R=1;R<x-1;R++)W[j++]=F+R+1,W[j++]=F+R,W[j++]=F;for(R=1;R<x-1;R++)W[j++]=D,W[j++]=D+R,W[j++]=D+R+1;var K=0;if(_.st){var Q=Math.max(l,A);for(R=0;R<O;R++){var X=a.t.fromArray(T,3*R,g);C[K++]=(X.x+Q)/(2*Q),C[K++]=(X.y+Q)/(2*Q)}}var $=new p.a;_.position&&($.position=new f.o({componentDatatype:r.ComponentDatatype.DOUBLE,componentsPerAttribute:3,values:T})),_.normal&&($.normal=new f.o({componentDatatype:r.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:L})),_.tangent&&($.tangent=new f.o({componentDatatype:r.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:P})),_.bitangent&&($.bitangent=new f.o({componentDatatype:r.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:z})),_.st&&($.st=new f.o({componentDatatype:r.ComponentDatatype.FLOAT,componentsPerAttribute:2,values:C})),y.x=.5*u,y.y=Math.max(A,l);var tt=new n.i(a.t.ZERO,o.o.magnitude(y));if(s.e(t._offsetAttribute)){u=T.length;var et=new Uint8Array(u/3),nt=t._offsetAttribute===m.z.NONE?0:1;e.d(et,nt),$.applyOffset=new f.o({componentDatatype:r.ComponentDatatype.UNSIGNED_BYTE,componentsPerAttribute:1,values:et})}return new f.I({attributes:$,indices:W,primitiveType:b._0x29ba75.TRIANGLES,boundingSphere:tt,offsetAttribute:t._offsetAttribute})}},A.getUnitCylinder=function(){return s.e(_)||(_=A.createGeometry(new A({topRadius:1,bottomRadius:1,length:1,vertexFormat:l.n.POSITION_ONLY}))),_},t.l=A}));