Files
sdk4_demo/sdk/Cesium/Workers/EllipsoidOutlineGeometry-c3b586d4.js
2025-07-03 15:12:58 +08:00

26 lines
5.5 KiB
JavaScript

/**
* @license
* Cesium - https://github.com/CesiumGS/cesium
* Version 1.98
*
* 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-c9e418cb","./Matrix2-cf4c6e69","./ComponentDatatype-9b23164a","./defaultValue-50f7432c","./GeometryAttribute-b84ffce6","./GeometryAttributes-8bab1b25","./GeometryOffsetAttribute-490bc2c9","./IndexDatatype-ceed713e"],(function(t,i,e,n,a,o,r,s,u){"use strict";const m=new e.Cartesian3(1,1,1),f=Math.cos,c=Math.sin;function l(t){t=a.defaultValue(t,a.defaultValue.EMPTY_OBJECT);const i=a.defaultValue(t.radii,m),o=a.defaultValue(t.innerRadii,i),r=a.defaultValue(t.minimumClock,0),s=a.defaultValue(t.maximumClock,n.CesiumMath.TWO_PI),u=a.defaultValue(t.minimumCone,0),f=a.defaultValue(t.maximumCone,n.CesiumMath.PI),c=Math.round(a.defaultValue(t.stackPartitions,10)),l=Math.round(a.defaultValue(t.slicePartitions,8)),d=Math.round(a.defaultValue(t.subdivisions,128));this._radii=e.Cartesian3.clone(i),this._innerRadii=e.Cartesian3.clone(o),this._minimumClock=r,this._maximumClock=s,this._minimumCone=u,this._maximumCone=f,this._stackPartitions=c,this._slicePartitions=l,this._subdivisions=d,this._offsetAttribute=t.offsetAttribute,this._workerName="createEllipsoidOutlineGeometry"}l.packedLength=2*e.Cartesian3.packedLength+8,l.pack=function(t,i,n){return n=a.defaultValue(n,0),e.Cartesian3.pack(t._radii,i,n),n+=e.Cartesian3.packedLength,e.Cartesian3.pack(t._innerRadii,i,n),n+=e.Cartesian3.packedLength,i[n++]=t._minimumClock,i[n++]=t._maximumClock,i[n++]=t._minimumCone,i[n++]=t._maximumCone,i[n++]=t._stackPartitions,i[n++]=t._slicePartitions,i[n++]=t._subdivisions,i[n]=a.defaultValue(t._offsetAttribute,-1),i};const d=new e.Cartesian3,C=new e.Cartesian3,_={radii:d,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};l.unpack=function(t,i,n){i=a.defaultValue(i,0);const o=e.Cartesian3.unpack(t,i,d);i+=e.Cartesian3.packedLength;const r=e.Cartesian3.unpack(t,i,C);i+=e.Cartesian3.packedLength;const s=t[i++],u=t[i++],m=t[i++],f=t[i++],c=t[i++],p=t[i++],h=t[i++],b=t[i];return a.defined(n)?(n._radii=e.Cartesian3.clone(o,n._radii),n._innerRadii=e.Cartesian3.clone(r,n._innerRadii),n._minimumClock=s,n._maximumClock=u,n._minimumCone=m,n._maximumCone=f,n._stackPartitions=c,n._slicePartitions=p,n._subdivisions=h,n._offsetAttribute=-1===b?void 0:b,n):(_.minimumClock=s,_.maximumClock=u,_.minimumCone=m,_.maximumCone=f,_.stackPartitions=c,_.slicePartitions=p,_.subdivisions=h,_.offsetAttribute=-1===b?void 0:b,new l(_))},l.createGeometry=function(t){const m=t._radii;if(m.x<=0||m.y<=0||m.z<=0)return;const l=t._innerRadii;if(l.x<=0||l.y<=0||l.z<=0)return;const d=t._minimumClock,C=t._maximumClock,_=t._minimumCone,p=t._maximumCone,h=t._subdivisions,b=e.Ellipsoid.fromCartesian3(m);let y=t._slicePartitions+1,k=t._stackPartitions+1;y=Math.round(y*Math.abs(C-d)/n.CesiumMath.TWO_PI),k=Math.round(k*Math.abs(p-_)/n.CesiumMath.PI),y<2&&(y=2),k<2&&(k=2);let x=0,A=1;const P=l.x!==m.x||l.y!==m.y||l.z!==m.z;let v=!1,M=!1;P&&(A=2,_>0&&(v=!0,x+=y),p<Math.PI&&(M=!0,x+=y));const w=h*A*(k+y),V=new Float64Array(3*w),g=2*(w+x-(y+k)*A),G=u.IndexDatatype.createTypedArray(w,g);let E,O,D,I,T=0;const z=new Array(k),L=new Array(k);for(E=0;E<k;E++)I=_+E*(p-_)/(k-1),z[E]=c(I),L[E]=f(I);const R=new Array(h),N=new Array(h);for(E=0;E<h;E++)D=d+E*(C-d)/(h-1),R[E]=c(D),N[E]=f(D);for(E=0;E<k;E++)for(O=0;O<h;O++)V[T++]=m.x*z[E]*N[O],V[T++]=m.y*z[E]*R[O],V[T++]=m.z*L[E];if(P)for(E=0;E<k;E++)for(O=0;O<h;O++)V[T++]=l.x*z[E]*N[O],V[T++]=l.y*z[E]*R[O],V[T++]=l.z*L[E];for(z.length=h,L.length=h,E=0;E<h;E++)I=_+E*(p-_)/(h-1),z[E]=c(I),L[E]=f(I);for(R.length=y,N.length=y,E=0;E<y;E++)D=d+E*(C-d)/(y-1),R[E]=c(D),N[E]=f(D);for(E=0;E<h;E++)for(O=0;O<y;O++)V[T++]=m.x*z[E]*N[O],V[T++]=m.y*z[E]*R[O],V[T++]=m.z*L[E];if(P)for(E=0;E<h;E++)for(O=0;O<y;O++)V[T++]=l.x*z[E]*N[O],V[T++]=l.y*z[E]*R[O],V[T++]=l.z*L[E];for(T=0,E=0;E<k*A;E++){const t=E*h;for(O=0;O<h-1;O++)G[T++]=t+O,G[T++]=t+O+1}let B=k*h*A;for(E=0;E<y;E++)for(O=0;O<h-1;O++)G[T++]=B+E+O*y,G[T++]=B+E+(O+1)*y;if(P)for(B=k*h*A+y*h,E=0;E<y;E++)for(O=0;O<h-1;O++)G[T++]=B+E+O*y,G[T++]=B+E+(O+1)*y;if(P){let t=k*h*A,i=t+h*y;if(v)for(E=0;E<y;E++)G[T++]=t+E,G[T++]=i+E;if(M)for(t+=h*y-y,i+=h*y-y,E=0;E<y;E++)G[T++]=t+E,G[T++]=i+E}const S=new r.GeometryAttributes({position:new o.GeometryAttribute({componentDatatype:n.ComponentDatatype.DOUBLE,componentsPerAttribute:3,values:V})});if(a.defined(t._offsetAttribute)){const i=V.length,e=t._offsetAttribute===s.GeometryOffsetAttribute.NONE?0:1,a=new Uint8Array(i/3).fill(e);S.applyOffset=new o.GeometryAttribute({componentDatatype:n.ComponentDatatype.UNSIGNED_BYTE,componentsPerAttribute:1,values:a})}return new o.Geometry({attributes:S,indices:G,primitiveType:o.PrimitiveType.LINES,boundingSphere:i.BoundingSphere.fromEllipsoid(b),offsetAttribute:t._offsetAttribute})},t.EllipsoidOutlineGeometry=l}));