bmh_cesium/public/lib/cesiumjs/CesiumUnminified/Workers/EllipsoidOutlineGeometry-03485d1a.js
2025-03-10 07:23:50 +08:00

2 lines
5.4 KiB
JavaScript

/* 2020-9-22 15:23:26 | 版权所有 军懋国兴 */
define(["exports","./when-cbf8cd21","./Check-35e1a91d","./Math-69007a69","./Cartesian2-43e3a3be","./Transforms-2d1ac5ec","./ComponentDatatype-607c9a0c","./GeometryAttribute-2303bbfb","./GeometryAttributes-90846c5f","./IndexDatatype-79bb407c","./GeometryOffsetAttribute-9c676324"],function(e,R,c,N,q,B,S,U,F,W,Y){"use strict";var f=new q.Cartesian3(1,1,1),J=Math.cos,j=Math.sin;function C(e){e=R.defaultValue(e,R.defaultValue.EMPTY_OBJECT);var t=R.defaultValue(e.radii,f),i=R.defaultValue(e.innerRadii,t),r=R.defaultValue(e.minimumClock,0),a=R.defaultValue(e.maximumClock,N.CesiumMath.TWO_PI),o=R.defaultValue(e.minimumCone,0),n=R.defaultValue(e.maximumCone,N.CesiumMath.PI),s=Math.round(R.defaultValue(e.stackPartitions,10)),u=Math.round(R.defaultValue(e.slicePartitions,8)),m=Math.round(R.defaultValue(e.subdivisions,128));if(s<1)throw new c.DeveloperError("options.stackPartitions cannot be less than 1");if(u<0)throw new c.DeveloperError("options.slicePartitions cannot be less than 0");if(m<0)throw new c.DeveloperError("options.subdivisions must be greater than or equal to zero.");if(R.defined(e.offsetAttribute)&&e.offsetAttribute===Y.GeometryOffsetAttribute.TOP)throw new c.DeveloperError("GeometryOffsetAttribute.TOP is not a supported options.offsetAttribute for this geometry.");this._radii=q.Cartesian3.clone(t),this._innerRadii=q.Cartesian3.clone(i),this._minimumClock=r,this._maximumClock=a,this._minimumCone=o,this._maximumCone=n,this._stackPartitions=s,this._slicePartitions=u,this._subdivisions=m,this._offsetAttribute=e.offsetAttribute,this._workerName="createEllipsoidOutlineGeometry"}C.packedLength=2*q.Cartesian3.packedLength+8,C.pack=function(e,t,i){if(!R.defined(e))throw new c.DeveloperError("value is required");if(!R.defined(t))throw new c.DeveloperError("array is required");return i=R.defaultValue(i,0),q.Cartesian3.pack(e._radii,t,i),i+=q.Cartesian3.packedLength,q.Cartesian3.pack(e._innerRadii,t,i),i+=q.Cartesian3.packedLength,t[i++]=e._minimumClock,t[i++]=e._maximumClock,t[i++]=e._minimumCone,t[i++]=e._maximumCone,t[i++]=e._stackPartitions,t[i++]=e._slicePartitions,t[i++]=e._subdivisions,t[i]=R.defaultValue(e._offsetAttribute,-1),t};var p=new q.Cartesian3,h=new q.Cartesian3,_={radii:p,innerRadii:h,minimumClock:void 0,maximumClock:void 0,minimumCone:void 0,maximumCone:void 0,stackPartitions:void 0,slicePartitions:void 0,subdivisions:void 0,offsetAttribute:void 0};C.unpack=function(e,t,i){if(!R.defined(e))throw new c.DeveloperError("array is required");t=R.defaultValue(t,0);var r=q.Cartesian3.unpack(e,t,p);t+=q.Cartesian3.packedLength;var a=q.Cartesian3.unpack(e,t,h);t+=q.Cartesian3.packedLength;var o=e[t++],n=e[t++],s=e[t++],u=e[t++],m=e[t++],f=e[t++],d=e[t++],l=e[t];return R.defined(i)?(i._radii=q.Cartesian3.clone(r,i._radii),i._innerRadii=q.Cartesian3.clone(a,i._innerRadii),i._minimumClock=o,i._maximumClock=n,i._minimumCone=s,i._maximumCone=u,i._stackPartitions=m,i._slicePartitions=f,i._subdivisions=d,i._offsetAttribute=-1===l?void 0:l,i):(_.minimumClock=o,_.maximumClock=n,_.minimumCone=s,_.maximumCone=u,_.stackPartitions=m,_.slicePartitions=f,_.subdivisions=d,_.offsetAttribute=-1===l?void 0:l,new C(_))},C.createGeometry=function(e){var t=e._radii;if(!(t.x<=0||t.y<=0||t.z<=0)){var i=e._innerRadii;if(!(i.x<=0||i.y<=0||i.z<=0)){var r=e._minimumClock,a=e._maximumClock,o=e._minimumCone,n=e._maximumCone,s=e._subdivisions,u=q.Ellipsoid.fromCartesian3(t),m=e._slicePartitions+1,f=e._stackPartitions+1;(m=Math.round(m*Math.abs(a-r)/N.CesiumMath.TWO_PI))<2&&(m=2),(f=Math.round(f*Math.abs(n-o)/N.CesiumMath.PI))<2&&(f=2);var d=0,l=1,c=i.x!==t.x||i.y!==t.y||i.z!==t.z,C=!1,p=!1;c&&(l=2,0<o&&(C=!0,d+=m),n<Math.PI&&(p=!0,d+=m));for(var h,_,b=s*l*(f+m),v=new Float64Array(3*b),y=2*(b+d-(m+f)*l),k=W.IndexDatatype.createTypedArray(b,y),A=0,w=new Array(f),P=new Array(f),x=0;x<f;x++)_=o+x*(n-o)/(f-1),w[x]=j(_),P[x]=J(_);var E=new Array(s),D=new Array(s);for(x=0;x<s;x++)h=r+x*(a-r)/(s-1),E[x]=j(h),D[x]=J(h);for(x=0;x<f;x++)for(g=0;g<s;g++)v[A++]=t.x*w[x]*D[g],v[A++]=t.y*w[x]*E[g],v[A++]=t.z*P[x];if(c)for(x=0;x<f;x++)for(g=0;g<s;g++)v[A++]=i.x*w[x]*D[g],v[A++]=i.y*w[x]*E[g],v[A++]=i.z*P[x];for(w.length=s,P.length=s,x=0;x<s;x++)_=o+x*(n-o)/(s-1),w[x]=j(_),P[x]=J(_);for(E.length=m,D.length=m,x=0;x<m;x++)h=r+x*(a-r)/(m-1),E[x]=j(h),D[x]=J(h);for(x=0;x<s;x++)for(g=0;g<m;g++)v[A++]=t.x*w[x]*D[g],v[A++]=t.y*w[x]*E[g],v[A++]=t.z*P[x];if(c)for(x=0;x<s;x++)for(g=0;g<m;g++)v[A++]=i.x*w[x]*D[g],v[A++]=i.y*w[x]*E[g],v[A++]=i.z*P[x];for(x=A=0;x<f*l;x++)for(var M=x*s,g=0;g<s-1;g++)k[A++]=M+g,k[A++]=M+g+1;var G=f*s*l;for(x=0;x<m;x++)for(g=0;g<s-1;g++)k[A++]=G+x+g*m,k[A++]=G+x+(g+1)*m;if(c)for(G=f*s*l+m*s,x=0;x<m;x++)for(g=0;g<s-1;g++)k[A++]=G+x+g*m,k[A++]=G+x+(g+1)*m;if(c){var O=f*s*l,V=O+s*m;if(C)for(x=0;x<m;x++)k[A++]=O+x,k[A++]=V+x;if(p)for(O+=s*m-m,V+=s*m-m,x=0;x<m;x++)k[A++]=O+x,k[A++]=V+x}var T,z,I,L=new F.GeometryAttributes({position:new U.GeometryAttribute({componentDatatype:S.ComponentDatatype.DOUBLE,componentsPerAttribute:3,values:v})});return R.defined(e._offsetAttribute)&&(T=v.length,z=new Uint8Array(T/3),I=e._offsetAttribute===Y.GeometryOffsetAttribute.NONE?0:1,Y.arrayFill(z,I),L.applyOffset=new U.GeometryAttribute({componentDatatype:S.ComponentDatatype.UNSIGNED_BYTE,componentsPerAttribute:1,values:z})),new U.Geometry({attributes:L,indices:k,primitiveType:U.PrimitiveType.LINES,boundingSphere:B.BoundingSphere.fromEllipsoid(u),offsetAttribute:e._offsetAttribute})}}},e.EllipsoidOutlineGeometry=C});