Newer
Older
smartwell_front_dz / smartwell / mars3d-cesium / Workers / EllipsoidOutlineGeometry-17b3e928.js
wangxitong on 11 Sep 2023 6 KB first commit
/**
 * @license
 * Cesium - https://github.com/CesiumGS/cesium
 * Version 1.96.6
 *
 * Copyright 2011-2022 Cesium Contributors
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * Columbus View (Pat. Pend.)
 *
 * Portions licensed separately.
 * See https://github.com/CesiumGS/cesium/blob/main/LICENSE.md for full licensing details.
 */
define(["exports","./Transforms-66eda18c","./Matrix2-4706dd70","./ComponentDatatype-438cad2a","./defaultValue-028a8a27","./RuntimeError-a977b8e0","./GeometryAttribute-2cdece80","./GeometryAttributes-98e858da","./GeometryOffsetAttribute-116f8293","./IndexDatatype-dfa09980"],(function(t,e,i,r,o,n,a,s,u,m){"use strict";const f=new i.Cartesian3(1,1,1),l=Math.cos,d=Math.sin;function c(t){t=o.defaultValue(t,o.defaultValue.EMPTY_OBJECT);const e=o.defaultValue(t.radii,f),a=o.defaultValue(t.innerRadii,e),s=o.defaultValue(t.minimumClock,0),m=o.defaultValue(t.maximumClock,r.CesiumMath.TWO_PI),l=o.defaultValue(t.minimumCone,0),d=o.defaultValue(t.maximumCone,r.CesiumMath.PI),c=Math.round(o.defaultValue(t.stackPartitions,10)),p=Math.round(o.defaultValue(t.slicePartitions,8)),C=Math.round(o.defaultValue(t.subdivisions,128));if(c<1)throw new n.DeveloperError("options.stackPartitions cannot be less than 1");if(p<0)throw new n.DeveloperError("options.slicePartitions cannot be less than 0");if(C<0)throw new n.DeveloperError("options.subdivisions must be greater than or equal to zero.");if(o.defined(t.offsetAttribute)&&t.offsetAttribute===u.GeometryOffsetAttribute.TOP)throw new n.DeveloperError("GeometryOffsetAttribute.TOP is not a supported options.offsetAttribute for this geometry.");this._radii=i.Cartesian3.clone(e),this._innerRadii=i.Cartesian3.clone(a),this._minimumClock=s,this._maximumClock=m,this._minimumCone=l,this._maximumCone=d,this._stackPartitions=c,this._slicePartitions=p,this._subdivisions=C,this._offsetAttribute=t.offsetAttribute,this._workerName="createEllipsoidOutlineGeometry"}c.packedLength=2*i.Cartesian3.packedLength+8,c.pack=function(t,e,r){if(!o.defined(t))throw new n.DeveloperError("value is required");if(!o.defined(e))throw new n.DeveloperError("array is required");return r=o.defaultValue(r,0),i.Cartesian3.pack(t._radii,e,r),r+=i.Cartesian3.packedLength,i.Cartesian3.pack(t._innerRadii,e,r),r+=i.Cartesian3.packedLength,e[r++]=t._minimumClock,e[r++]=t._maximumClock,e[r++]=t._minimumCone,e[r++]=t._maximumCone,e[r++]=t._stackPartitions,e[r++]=t._slicePartitions,e[r++]=t._subdivisions,e[r]=o.defaultValue(t._offsetAttribute,-1),e};const p=new i.Cartesian3,C=new i.Cartesian3,h={radii:p,innerRadii:C,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(t,e,r){if(!o.defined(t))throw new n.DeveloperError("array is required");e=o.defaultValue(e,0);const a=i.Cartesian3.unpack(t,e,p);e+=i.Cartesian3.packedLength;const s=i.Cartesian3.unpack(t,e,C);e+=i.Cartesian3.packedLength;const u=t[e++],m=t[e++],f=t[e++],l=t[e++],d=t[e++],_=t[e++],y=t[e++],b=t[e];return o.defined(r)?(r._radii=i.Cartesian3.clone(a,r._radii),r._innerRadii=i.Cartesian3.clone(s,r._innerRadii),r._minimumClock=u,r._maximumClock=m,r._minimumCone=f,r._maximumCone=l,r._stackPartitions=d,r._slicePartitions=_,r._subdivisions=y,r._offsetAttribute=-1===b?void 0:b,r):(h.minimumClock=u,h.maximumClock=m,h.minimumCone=f,h.maximumCone=l,h.stackPartitions=d,h.slicePartitions=_,h.subdivisions=y,h.offsetAttribute=-1===b?void 0:b,new c(h))},c.createGeometry=function(t){const n=t._radii;if(n.x<=0||n.y<=0||n.z<=0)return;const f=t._innerRadii;if(f.x<=0||f.y<=0||f.z<=0)return;const c=t._minimumClock,p=t._maximumClock,C=t._minimumCone,h=t._maximumCone,_=t._subdivisions,y=i.Ellipsoid.fromCartesian3(n);let b=t._slicePartitions+1,k=t._stackPartitions+1;b=Math.round(b*Math.abs(p-c)/r.CesiumMath.TWO_PI),k=Math.round(k*Math.abs(h-C)/r.CesiumMath.PI),b<2&&(b=2),k<2&&(k=2);let A=0,v=1;const w=f.x!==n.x||f.y!==n.y||f.z!==n.z;let P=!1,x=!1;w&&(v=2,C>0&&(P=!0,A+=b),h<Math.PI&&(x=!0,A+=b));const E=_*v*(k+b),D=new Float64Array(3*E),M=2*(E+A-(b+k)*v),g=m.IndexDatatype.createTypedArray(E,M);let V,G,O,T,z=0;const I=new Array(k),L=new Array(k);for(V=0;V<k;V++)T=C+V*(h-C)/(k-1),I[V]=d(T),L[V]=l(T);const R=new Array(_),N=new Array(_);for(V=0;V<_;V++)O=c+V*(p-c)/(_-1),R[V]=d(O),N[V]=l(O);for(V=0;V<k;V++)for(G=0;G<_;G++)D[z++]=n.x*I[V]*N[G],D[z++]=n.y*I[V]*R[G],D[z++]=n.z*L[V];if(w)for(V=0;V<k;V++)for(G=0;G<_;G++)D[z++]=f.x*I[V]*N[G],D[z++]=f.y*I[V]*R[G],D[z++]=f.z*L[V];for(I.length=_,L.length=_,V=0;V<_;V++)T=C+V*(h-C)/(_-1),I[V]=d(T),L[V]=l(T);for(R.length=b,N.length=b,V=0;V<b;V++)O=c+V*(p-c)/(b-1),R[V]=d(O),N[V]=l(O);for(V=0;V<_;V++)for(G=0;G<b;G++)D[z++]=n.x*I[V]*N[G],D[z++]=n.y*I[V]*R[G],D[z++]=n.z*L[V];if(w)for(V=0;V<_;V++)for(G=0;G<b;G++)D[z++]=f.x*I[V]*N[G],D[z++]=f.y*I[V]*R[G],D[z++]=f.z*L[V];for(z=0,V=0;V<k*v;V++){const t=V*_;for(G=0;G<_-1;G++)g[z++]=t+G,g[z++]=t+G+1}let q=k*_*v;for(V=0;V<b;V++)for(G=0;G<_-1;G++)g[z++]=q+V+G*b,g[z++]=q+V+(G+1)*b;if(w)for(q=k*_*v+b*_,V=0;V<b;V++)for(G=0;G<_-1;G++)g[z++]=q+V+G*b,g[z++]=q+V+(G+1)*b;if(w){let t=k*_*v,e=t+_*b;if(P)for(V=0;V<b;V++)g[z++]=t+V,g[z++]=e+V;if(x)for(t+=_*b-b,e+=_*b-b,V=0;V<b;V++)g[z++]=t+V,g[z++]=e+V}const B=new s.GeometryAttributes({position:new a.GeometryAttribute({componentDatatype:r.ComponentDatatype.DOUBLE,componentsPerAttribute:3,values:D})});if(o.defined(t._offsetAttribute)){const e=D.length,i=t._offsetAttribute===u.GeometryOffsetAttribute.NONE?0:1,o=new Uint8Array(e/3).fill(i);B.applyOffset=new a.GeometryAttribute({componentDatatype:r.ComponentDatatype.UNSIGNED_BYTE,componentsPerAttribute:1,values:o})}return new a.Geometry({attributes:B,indices:g,primitiveType:a.PrimitiveType.LINES,boundingSphere:e.BoundingSphere.fromEllipsoid(y),offsetAttribute:t._offsetAttribute})},t.EllipsoidOutlineGeometry=c}));