UNPKG

cesium

Version:

CesiumJS is a JavaScript library for creating 3D globes and 2D maps in a web browser without a plugin.

2 lines (1 loc) 2.74 kB
define(["./GeometryOffsetAttribute-718fa138","./Transforms-79117a7b","./Cartesian2-8646c5a1","./Check-24483042","./ComponentDatatype-1a100acd","./CylinderGeometryLibrary-85e5e690","./when-54335d57","./GeometryAttribute-374f805d","./GeometryAttributes-caa08d6c","./IndexDatatype-82ceea78","./Math-d6182036","./RuntimeError-88a32665","./WebGLConstants-95ceb4e9"],function(b,p,y,t,_,h,A,v,R,G,e,i,a){"use strict";var O=new y.Cartesian2;function s(t){var e=(t=A.defaultValue(t,A.defaultValue.EMPTY_OBJECT)).length,i=t.topRadius,a=t.bottomRadius,r=A.defaultValue(t.slices,128),n=Math.max(A.defaultValue(t.numberOfVerticalLines,16),0);this._length=e,this._topRadius=i,this._bottomRadius=a,this._slices=r,this._numberOfVerticalLines=n,this._offsetAttribute=t.offsetAttribute,this._workerName="createCylinderOutlineGeometry"}s.packedLength=6,s.pack=function(t,e,i){return i=A.defaultValue(i,0),e[i++]=t._length,e[i++]=t._topRadius,e[i++]=t._bottomRadius,e[i++]=t._slices,e[i++]=t._numberOfVerticalLines,e[i]=A.defaultValue(t._offsetAttribute,-1),e};var f={length:void 0,topRadius:void 0,bottomRadius:void 0,slices:void 0,numberOfVerticalLines:void 0,offsetAttribute:void 0};return s.unpack=function(t,e,i){e=A.defaultValue(e,0);var a=t[e++],r=t[e++],n=t[e++],o=t[e++],u=t[e++],e=t[e];return A.defined(i)?(i._length=a,i._topRadius=r,i._bottomRadius=n,i._slices=o,i._numberOfVerticalLines=u,i._offsetAttribute=-1===e?void 0:e,i):(f.length=a,f.topRadius=r,f.bottomRadius=n,f.slices=o,f.numberOfVerticalLines=u,f.offsetAttribute=-1===e?void 0:e,new s(f))},s.createGeometry=function(t){var e=t._length,i=t._topRadius,a=t._bottomRadius,r=t._slices,n=t._numberOfVerticalLines;if(!(e<=0||i<0||a<0||0===i&&0===a)){var o,u,s=2*r,f=h.CylinderGeometryLibrary.computePositions(e,i,a,r,!1),d=2*r;0<n&&(o=Math.min(n,r),u=Math.round(r/o),d+=o);for(var l=G.IndexDatatype.createTypedArray(s,2*d),m=0,c=0;c<r-1;c++)l[m++]=c,l[m++]=c+1,l[m++]=c+r,l[m++]=c+1+r;if(l[m++]=r-1,l[m++]=0,l[m++]=r+r-1,l[m++]=r,0<n)for(c=0;c<r;c+=u)l[m++]=c,l[m++]=c+r;n=new R.GeometryAttributes;n.position=new v.GeometryAttribute({componentDatatype:_.ComponentDatatype.DOUBLE,componentsPerAttribute:3,values:f}),O.x=.5*e,O.y=Math.max(a,i);i=new p.BoundingSphere(y.Cartesian3.ZERO,y.Cartesian2.magnitude(O));return A.defined(t._offsetAttribute)&&(e=f.length,f=new Uint8Array(e/3),e=t._offsetAttribute===b.GeometryOffsetAttribute.NONE?0:1,b.arrayFill(f,e),n.applyOffset=new v.GeometryAttribute({componentDatatype:_.ComponentDatatype.UNSIGNED_BYTE,componentsPerAttribute:1,values:f})),new v.Geometry({attributes:n,indices:l,primitiveType:v.PrimitiveType.LINES,boundingSphere:i,offsetAttribute:t._offsetAttribute})}},function(t,e){return A.defined(e)&&(t=s.unpack(t,e)),s.createGeometry(t)}});