createCylinderOutlineGeometry.js 2.7 KB

1
  1. define(["./GeometryOffsetAttribute-1772960d","./Transforms-d5c6ad6e","./Matrix2-ccd5b911","./RuntimeError-346a3079","./ComponentDatatype-93750d1a","./CylinderGeometryLibrary-dc0b434b","./when-4bbc8319","./GeometryAttribute-c30799b8","./GeometryAttributes-7827a6c2","./IndexDatatype-b7d979a6","./combine-83860057","./WebGLConstants-1c8239cc"],function(m,p,y,t,_,h,A,v,R,G,e,i){"use strict";var O=new y.Cartesian2;function s(t){var e=(t=A.defaultValue(t,A.defaultValue.EMPTY_OBJECT)).length,i=t.topRadius,r=t.bottomRadius,a=A.defaultValue(t.slices,128),n=Math.max(A.defaultValue(t.numberOfVerticalLines,16),0);this._length=e,this._topRadius=i,this._bottomRadius=r,this._slices=a,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 d={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 r=t[e++],a=t[e++],n=t[e++],o=t[e++],u=t[e++],e=t[e];return A.defined(i)?(i._length=r,i._topRadius=a,i._bottomRadius=n,i._slices=o,i._numberOfVerticalLines=u,i._offsetAttribute=-1===e?void 0:e,i):(d.length=r,d.topRadius=a,d.bottomRadius=n,d.slices=o,d.numberOfVerticalLines=u,d.offsetAttribute=-1===e?void 0:e,new s(d))},s.createGeometry=function(t){var e=t._length,i=t._topRadius,r=t._bottomRadius,a=t._slices,n=t._numberOfVerticalLines;if(!(e<=0||i<0||r<0||0===i&&0===r)){var o,u,s=2*a,d=h.CylinderGeometryLibrary.computePositions(e,i,r,a,!1),f=2*a;0<n&&(o=Math.min(n,a),u=Math.round(a/o),f+=o);for(var b=G.IndexDatatype.createTypedArray(s,2*f),c=0,l=0;l<a-1;l++)b[c++]=l,b[c++]=l+1,b[c++]=l+a,b[c++]=l+1+a;if(b[c++]=a-1,b[c++]=0,b[c++]=a+a-1,b[c++]=a,0<n)for(l=0;l<a;l+=u)b[c++]=l,b[c++]=l+a;n=new R.GeometryAttributes;n.position=new v.GeometryAttribute({componentDatatype:_.ComponentDatatype.DOUBLE,componentsPerAttribute:3,values:d}),O.x=.5*e,O.y=Math.max(r,i);i=new p.BoundingSphere(y.Cartesian3.ZERO,y.Cartesian2.magnitude(O));return A.defined(t._offsetAttribute)&&(e=d.length,d=new Uint8Array(e/3),e=t._offsetAttribute===m.GeometryOffsetAttribute.NONE?0:1,m.arrayFill(d,e),n.applyOffset=new v.GeometryAttribute({componentDatatype:_.ComponentDatatype.UNSIGNED_BYTE,componentsPerAttribute:1,values:d})),new v.Geometry({attributes:n,indices:b,primitiveType:v.PrimitiveType.LINES,boundingSphere:i,offsetAttribute:t._offsetAttribute})}},function(t,e){return A.defined(e)&&(t=s.unpack(t,e)),s.createGeometry(t)}});