/**
 * @license
 * Cesium - https://github.com/CesiumGS/cesium
 * Version 1.122
 *
 * 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.
 */
import{a as wt}from"./chunk-IFAARW2T.js";import{a as k}from"./chunk-6YAFAZVV.js";import{a as kt}from"./chunk-UGB43LJM.js";import{a as Ct}from"./chunk-WFZLZ2P5.js";import{b as dt,c as _t,d as R}from"./chunk-N72XKOXM.js";import{d as ht}from"./chunk-EWTFJ46X.js";import{a as N}from"./chunk-27UWHT4D.js";import{a as s,c as pt,d as ot}from"./chunk-RFPX772U.js";import{a as M}from"./chunk-RAYRECQS.js";import{a as p}from"./chunk-6KLVDWWE.js";import{a as z}from"./chunk-6P5KAIBX.js";import{e as E}from"./chunk-4FSVUTPL.js";var yt=new s,vt=new s,Et=new s,Mt=new s,Nt=new s,Rt=new s(1,1,1),Pt=Math.cos,At=Math.sin;function O(t){t=p(t,p.EMPTY_OBJECT);let e=p(t.radii,Rt),i=p(t.innerRadii,e),n=p(t.minimumClock,0),a=p(t.maximumClock,M.TWO_PI),r=p(t.minimumCone,0),o=p(t.maximumCone,M.PI),m=Math.round(p(t.stackPartitions,64)),c=Math.round(p(t.slicePartitions,64)),u=p(t.vertexFormat,k.DEFAULT);if(c<3)throw new z("options.slicePartitions cannot be less than three.");if(m<3)throw new z("options.stackPartitions cannot be less than three.");this._radii=s.clone(e),this._innerRadii=s.clone(i),this._minimumClock=n,this._maximumClock=a,this._minimumCone=r,this._maximumCone=o,this._stackPartitions=m,this._slicePartitions=c,this._vertexFormat=k.clone(u),this._offsetAttribute=t.offsetAttribute,this._workerName="createEllipsoidGeometry"}O.packedLength=2*s.packedLength+k.packedLength+7,O.pack=function(t,e,i){if(!E(t))throw new z("value is required");if(!E(e))throw new z("array is required");return i=p(i,0),s.pack(t._radii,e,i),i+=s.packedLength,s.pack(t._innerRadii,e,i),i+=s.packedLength,k.pack(t._vertexFormat,e,i),i+=k.packedLength,e[i++]=t._minimumClock,e[i++]=t._maximumClock,e[i++]=t._minimumCone,e[i++]=t._maximumCone,e[i++]=t._stackPartitions,e[i++]=t._slicePartitions,e[i]=p(t._offsetAttribute,-1),e};var mt,bt=new s,xt=new s,Ot=new k,y={radii:bt,innerRadii:xt,vertexFormat:Ot,minimumClock:void 0,maximumClock:void 0,minimumCone:void 0,maximumCone:void 0,stackPartitions:void 0,slicePartitions:void 0,offsetAttribute:void 0};O.unpack=function(t,e,i){if(!E(t))throw new z("array is required");e=p(e,0);let n=s.unpack(t,e,bt);e+=s.packedLength;let a=s.unpack(t,e,xt);e+=s.packedLength;let r=k.unpack(t,e,Ot);e+=k.packedLength;let o=t[e++],m=t[e++],c=t[e++],u=t[e++],l=t[e++],f=t[e++],h=t[e];return E(i)?(i._radii=s.clone(n,i._radii),i._innerRadii=s.clone(a,i._innerRadii),i._vertexFormat=k.clone(r,i._vertexFormat),i._minimumClock=o,i._maximumClock=m,i._minimumCone=c,i._maximumCone=u,i._stackPartitions=l,i._slicePartitions=f,i._offsetAttribute=-1===h?void 0:h,i):(y.minimumClock=o,y.maximumClock=m,y.minimumCone=c,y.maximumCone=u,y.stackPartitions=l,y.slicePartitions=f,y.offsetAttribute=-1===h?void 0:h,new O(y))},O.createGeometry=function(t){let e=t._radii;if(e.x<=0||e.y<=0||e.z<=0)return;let i=t._innerRadii;if(i.x<=0||i.y<=0||i.z<=0)return;let n=t._minimumClock,a=t._maximumClock,r=t._minimumCone,o=t._maximumCone,m=t._vertexFormat,c=t._slicePartitions+1,u=t._stackPartitions+1;c=Math.round(c*Math.abs(a-n)/M.TWO_PI),u=Math.round(u*Math.abs(o-r)/M.PI),c<2&&(c=2),u<2&&(u=2);let l,f,p=0,k=[r],h=[n];for(l=0;l<u;l++)k.push(r+l*(o-r)/(u-1));for(k.push(o),f=0;f<c;f++)h.push(n+f*(a-n)/(c-1));h.push(a);let _=k.length,d=h.length,y=0,w=1,A=i.x!==e.x||i.y!==e.y||i.z!==e.z,P=!1,x=!1,v=!1;A&&(w=2,r>0&&(P=!0,y+=c-1),o<Math.PI&&(x=!0,y+=c-1),(a-n)%M.TWO_PI?(v=!0,y+=2*(u-1)+1):y+=1);let C=d*_*w,b=new Float64Array(3*C),g=new Array(C).fill(!1),O=new Array(C).fill(!1),F=c*u*w,T=6*(F+y+1-(c+u)*w),L=kt.createTypedArray(F,T),z=m.normal?new Float32Array(3*C):void 0,I=m.tangent?new Float32Array(3*C):void 0,j=m.bitangent?new Float32Array(3*C):void 0,D=m.st?new Float32Array(2*C):void 0,U=new Array(_),W=new Array(_);for(l=0;l<_;l++)U[l]=At(k[l]),W[l]=Pt(k[l]);let S=new Array(d),G=new Array(d);for(f=0;f<d;f++)G[f]=Pt(h[f]),S[f]=At(h[f]);for(l=0;l<_;l++)for(f=0;f<d;f++)b[p++]=e.x*U[l]*G[f],b[p++]=e.y*U[l]*S[f],b[p++]=e.z*W[l];let X,B,K,Y,V=C/2;if(A)for(l=0;l<_;l++)for(f=0;f<d;f++)b[p++]=i.x*U[l]*G[f],b[p++]=i.y*U[l]*S[f],b[p++]=i.z*W[l],g[V]=!0,l>0&&l!==_-1&&0!==f&&f!==d-1&&(O[V]=!0),V++;for(p=0,l=1;l<_-2;l++)for(X=l*d,B=(l+1)*d,f=1;f<d-2;f++)L[p++]=B+f,L[p++]=B+f+1,L[p++]=X+f+1,L[p++]=B+f,L[p++]=X+f+1,L[p++]=X+f;if(A){let t=_*d;for(l=1;l<_-2;l++)for(X=t+l*d,B=t+(l+1)*d,f=1;f<d-2;f++)L[p++]=B+f,L[p++]=X+f,L[p++]=X+f+1,L[p++]=B+f,L[p++]=X+f+1,L[p++]=B+f+1}if(A){if(P)for(Y=_*d,l=1;l<d-2;l++)L[p++]=l,L[p++]=l+1,L[p++]=Y+l+1,L[p++]=l,L[p++]=Y+l+1,L[p++]=Y+l;if(x)for(K=_*d-d,Y=_*d*w-d,l=1;l<d-2;l++)L[p++]=K+l+1,L[p++]=K+l,L[p++]=Y+l,L[p++]=K+l+1,L[p++]=Y+l,L[p++]=Y+l+1}if(v){for(l=1;l<_-2;l++)Y=d*_+d*l,K=d*l,L[p++]=Y,L[p++]=K+d,L[p++]=K,L[p++]=Y,L[p++]=Y+d,L[p++]=K+d;for(l=1;l<_-2;l++)Y=d*_+d*(l+1)-1,K=d*(l+1)-1,L[p++]=K+d,L[p++]=Y,L[p++]=K,L[p++]=K+d,L[p++]=Y+d,L[p++]=Y}let Z=new Ct;m.position&&(Z.position=new R({componentDatatype:N.DOUBLE,componentsPerAttribute:3,values:b}));let q,J=0,H=0,Q=0,$=0,tt=C/2,et=ot.fromCartesian3(e),it=ot.fromCartesian3(i);if(m.st||m.normal||m.tangent||m.bitangent){for(l=0;l<C;l++){q=g[l]?it:et;let t=s.fromArray(b,3*l,yt),e=q.geodeticSurfaceNormal(t,vt);if(O[l]&&s.negate(e,e),m.st){let t=pt.negate(e,Nt);D[J++]=Math.atan2(t.y,t.x)/M.TWO_PI+.5,D[J++]=Math.asin(e.z)/Math.PI+.5}if(m.normal&&(z[H++]=e.x,z[H++]=e.y,z[H++]=e.z),m.tangent||m.bitangent){let t,i=Et,n=0;if(g[l]&&(n=tt),t=!P&&l>=n&&l<n+2*d?s.UNIT_X:s.UNIT_Z,s.cross(t,e,i),s.normalize(i,i),m.tangent&&(I[Q++]=i.x,I[Q++]=i.y,I[Q++]=i.z),m.bitangent){let t=s.cross(e,i,Mt);s.normalize(t,t),j[$++]=t.x,j[$++]=t.y,j[$++]=t.z}}}m.st&&(Z.st=new R({componentDatatype:N.FLOAT,componentsPerAttribute:2,values:D})),m.normal&&(Z.normal=new R({componentDatatype:N.FLOAT,componentsPerAttribute:3,values:z})),m.tangent&&(Z.tangent=new R({componentDatatype:N.FLOAT,componentsPerAttribute:3,values:I})),m.bitangent&&(Z.bitangent=new R({componentDatatype:N.FLOAT,componentsPerAttribute:3,values:j}))}if(E(t._offsetAttribute)){let e=b.length,i=t._offsetAttribute===wt.NONE?0:1,n=new Uint8Array(e/3).fill(i);Z.applyOffset=new R({componentDatatype:N.UNSIGNED_BYTE,componentsPerAttribute:1,values:n})}return new _t({attributes:Z,indices:L,primitiveType:dt.TRIANGLES,boundingSphere:ht.fromEllipsoid(et),offsetAttribute:t._offsetAttribute})},O.getUnitEllipsoid=function(){return E(mt)||(mt=O.createGeometry(new O({radii:new s(1,1,1),vertexFormat:k.POSITION_ONLY}))),mt};var Kt=O;export{Kt as a};