bmh_cesium/public/lib/cesiumjs/Cesium/Workers/createCylinderOutlineGeometry.js

2 lines
2.7 KiB
JavaScript
Raw Normal View History

2025-03-09 23:23:50 +00:00
define(["./when-cbf8cd21","./Check-35e1a91d","./Math-e66fad2a","./Cartesian2-44433f55","./Transforms-d9350502","./RuntimeError-f4c64df1","./WebGLConstants-95ceb4e9","./ComponentDatatype-7ee14e67","./GeometryAttribute-424f2c6a","./GeometryAttributes-90846c5f","./IndexDatatype-66caba23","./GeometryOffsetAttribute-84f7eff3","./CylinderGeometryLibrary-297cfdf0"],function(h,e,t,v,A,i,r,R,G,O,V,C,L){"use strict";var g=new v.Cartesian2;function f(e){var t=(e=h.defaultValue(e,h.defaultValue.EMPTY_OBJECT)).length,i=e.topRadius,r=e.bottomRadius,a=h.defaultValue(e.slices,128),n=Math.max(h.defaultValue(e.numberOfVerticalLines,16),0);this._length=t,this._topRadius=i,this._bottomRadius=r,this._slices=a,this._numberOfVerticalLines=n,this._offsetAttribute=e.offsetAttribute,this._workerName="createCylinderOutlineGeometry"}f.packedLength=6,f.pack=function(e,t,i){return i=h.defaultValue(i,0),t[i++]=e._length,t[i++]=e._topRadius,t[i++]=e._bottomRadius,t[i++]=e._slices,t[i++]=e._numberOfVerticalLines,t[i]=h.defaultValue(e._offsetAttribute,-1),t};var d={length:void 0,topRadius:void 0,bottomRadius:void 0,slices:void 0,numberOfVerticalLines:void 0,offsetAttribute:void 0};return f.unpack=function(e,t,i){t=h.defaultValue(t,0);var r=e[t++],a=e[t++],n=e[t++],o=e[t++],u=e[t++],s=e[t];return h.defined(i)?(i._length=r,i._topRadius=a,i._bottomRadius=n,i._slices=o,i._numberOfVerticalLines=u,i._offsetAttribute=-1===s?void 0:s,i):(d.length=r,d.topRadius=a,d.bottomRadius=n,d.slices=o,d.numberOfVerticalLines=u,d.offsetAttribute=-1===s?void 0:s,new f(d))},f.createGeometry=function(e){var t=e._length,i=e._topRadius,r=e._bottomRadius,a=e._slices,n=e._numberOfVerticalLines;if(!(t<=0||i<0||r<0||0===i&&0===r)){var o,u,s=2*a,f=L.CylinderGeometryLibrary.computePositions(t,i,r,a,!1),d=2*a;0<n&&(o=Math.min(n,a),u=Math.round(a/o),d+=o);for(var l=V.IndexDatatype.createTypedArray(s,2*d),c=0,m=0;m<a-1;m++)l[c++]=m,l[c++]=m+1,l[c++]=m+a,l[c++]=m+1+a;if(l[c++]=a-1,l[c++]=0,l[c++]=a+a-1,l[c++]=a,0<n)for(m=0;m<a;m+=u)l[c++]=m,l[c++]=m+a;var b=new O.GeometryAttributes;b.position=new G.GeometryAttribute({componentDatatype:R.ComponentDatatype.DOUBLE,componentsPerAttribute:3,values:f}),g.x=.5*t,g.y=Math.max(r,i);var p,y,_=new A.BoundingSphere(v.Cartesian3.ZERO,v.Cartesian2.magnitude(g));return h.defined(e._offsetAttribute)&&(t=f.length,p=new Uint8Array(t/3),y=e._offsetAttribute===C.GeometryOffsetAttribute.NONE?0:1,C.arrayFill(p,y),b.applyOffset=new G.GeometryAttribute({componentDatatype:R.ComponentDatatype.UNSIGNED_BYTE,componentsPerAttribute:1,values:p})),new G.Geometry({attributes:b,indices:l,primitiveType:G.PrimitiveType.LINES,boundingSphere:_,offsetAttribute:e._offsetAttribute})}},function(e,t){return h.defined(t)&&(e=f.unpack(e,t)),f.createGeometry(e)}});