createCylinderOutlineGeometry.js 2.8 KB

1
  1. define(["./GeometryOffsetAttribute-ed56ff58","./Transforms-98ffa11d","./Matrix2-e3fb4559","./Cartesian3-7e9cc2ff","./Check-741c5f3c","./ComponentDatatype-aaeec80f","./CylinderGeometryLibrary-4083111e","./defaultValue-81eec7ed","./GeometryAttribute-b025f9a8","./GeometryAttributes-32b29525","./IndexDatatype-f1e3f799","./Math-5f585871","./Matrix4-d34187af","./RuntimeError-26acdd3b","./_commonjsHelpers-3aae1032-26891ab7","./combine-3c023bda","./WebGLConstants-508b9636"],(function(t,e,i,n,a,o,r,s,u,f,c,d,l,m,b,p,y){"use strict";const _=new i.Cartesian2;function h(t){const e=(t=s.defaultValue(t,s.defaultValue.EMPTY_OBJECT)).length,i=t.topRadius,n=t.bottomRadius,a=s.defaultValue(t.slices,128),o=Math.max(s.defaultValue(t.numberOfVerticalLines,16),0);this._length=e,this._topRadius=i,this._bottomRadius=n,this._slices=a,this._numberOfVerticalLines=o,this._offsetAttribute=t.offsetAttribute,this._workerName="createCylinderOutlineGeometry"}h.packedLength=6,h.pack=function(t,e,i){return i=s.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]=s.defaultValue(t._offsetAttribute,-1),e};const A={length:void 0,topRadius:void 0,bottomRadius:void 0,slices:void 0,numberOfVerticalLines:void 0,offsetAttribute:void 0};return h.unpack=function(t,e,i){e=s.defaultValue(e,0);const n=t[e++],a=t[e++],o=t[e++],r=t[e++],u=t[e++],f=t[e];return s.defined(i)?(i._length=n,i._topRadius=a,i._bottomRadius=o,i._slices=r,i._numberOfVerticalLines=u,i._offsetAttribute=-1===f?void 0:f,i):(A.length=n,A.topRadius=a,A.bottomRadius=o,A.slices=r,A.numberOfVerticalLines=u,A.offsetAttribute=-1===f?void 0:f,new h(A))},h.createGeometry=function(a){let d=a._length;const l=a._topRadius,m=a._bottomRadius,b=a._slices,p=a._numberOfVerticalLines;if(d<=0||l<0||m<0||0===l&&0===m)return;const y=2*b,h=r.CylinderGeometryLibrary.computePositions(d,l,m,b,!1);let A,R=2*b;if(p>0){const t=Math.min(p,b);A=Math.round(b/t),R+=t}const G=c.IndexDatatype.createTypedArray(y,2*R);let O,V=0;for(O=0;O<b-1;O++)G[V++]=O,G[V++]=O+1,G[V++]=O+b,G[V++]=O+1+b;if(G[V++]=b-1,G[V++]=0,G[V++]=b+b-1,G[V++]=b,p>0)for(O=0;O<b;O+=A)G[V++]=O,G[V++]=O+b;const C=new f.GeometryAttributes;C.position=new u.GeometryAttribute({componentDatatype:o.ComponentDatatype.DOUBLE,componentsPerAttribute:3,values:h}),_.x=.5*d,_.y=Math.max(m,l);const L=new e.BoundingSphere(n.Cartesian3.ZERO,i.Cartesian2.magnitude(_));if(s.defined(a._offsetAttribute)){d=h.length;const e=new Uint8Array(d/3),i=a._offsetAttribute===t.GeometryOffsetAttribute.NONE?0:1;t.arrayFill(e,i),C.applyOffset=new u.GeometryAttribute({componentDatatype:o.ComponentDatatype.UNSIGNED_BYTE,componentsPerAttribute:1,values:e})}return new u.Geometry({attributes:C,indices:G,primitiveType:u.PrimitiveType.LINES,boundingSphere:L,offsetAttribute:a._offsetAttribute})},function(t,e){return s.defined(e)&&(t=h.unpack(t,e)),h.createGeometry(t)}}));