/**
 * @license
 * Cesium - https://github.com/CesiumGS/cesium
 * Version 1.126
 *
 * 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-WDSHVSF7.js";import{a as k}from"./chunk-HZQ2LRMY.js";import{a as kt}from"./chunk-E25VRLIZ.js";import{a as Ct}from"./chunk-FZEJ65E6.js";import{b as dt,c as _t,d as R}from"./chunk-SPFUTSGC.js";import{d as ht}from"./chunk-E2NX4UJ2.js";import{a as N}from"./chunk-NLPIV6OK.js";import{a as s,c as pt,d as ot}from"./chunk-IIT3SHXK.js";import{a as M}from"./chunk-DLCTHPIV.js";import{a as p}from"./chunk-I2ICH2LD.js";import{a as z}from"./chunk-R6A52HT4.js";import{e as E}from"./chunk-D32DZSEC.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,C=!1,x=!1;A&&(w=2,r>0&&(P=!0,y+=c-1),o<Math.PI&&(C=!0,y+=c-1),(a-n)%M.TWO_PI?(x=!0,y+=2*(u-1)+1):y+=1);let v=d*_*w,b=new Float64Array(3*v),g=new Array(v).fill(!1),O=new Array(v).fill(!1),L=c*u*w,T=6*(L+y+1-(c+u)*w),F=kt.createTypedArray(L,T),I=m.normal?new Float32Array(3*v):void 0,z=m.tangent?new Float32Array(3*v):void 0,D=m.bitangent?new Float32Array(3*v):void 0,j=m.st?new Float32Array(2*v):void 0,S=new Array(_),U=new Array(_);for(l=0;l<_;l++)S[l]=At(k[l]),U[l]=Pt(k[l]);let G=new Array(d),H=new Array(d);for(f=0;f<d;f++)H[f]=Pt(h[f]),G[f]=At(h[f]);for(l=0;l<_;l++)for(f=0;f<d;f++)b[p++]=e.x*S[l]*H[f],b[p++]=e.y*S[l]*G[f],b[p++]=e.z*U[l];let W,Z,K,V,Y=v/2;if(A)for(l=0;l<_;l++)for(f=0;f<d;f++)b[p++]=i.x*S[l]*H[f],b[p++]=i.y*S[l]*G[f],b[p++]=i.z*U[l],g[Y]=!0,l>0&&l!==_-1&&0!==f&&f!==d-1&&(O[Y]=!0),Y++;for(p=0,l=1;l<_-2;l++)for(W=l*d,Z=(l+1)*d,f=1;f<d-2;f++)F[p++]=Z+f,F[p++]=Z+f+1,F[p++]=W+f+1,F[p++]=Z+f,F[p++]=W+f+1,F[p++]=W+f;if(A){let t=_*d;for(l=1;l<_-2;l++)for(W=t+l*d,Z=t+(l+1)*d,f=1;f<d-2;f++)F[p++]=Z+f,F[p++]=W+f,F[p++]=W+f+1,F[p++]=Z+f,F[p++]=W+f+1,F[p++]=Z+f+1}if(A){if(P)for(V=_*d,l=1;l<d-2;l++)F[p++]=l,F[p++]=l+1,F[p++]=V+l+1,F[p++]=l,F[p++]=V+l+1,F[p++]=V+l;if(C)for(K=_*d-d,V=_*d*w-d,l=1;l<d-2;l++)F[p++]=K+l+1,F[p++]=K+l,F[p++]=V+l,F[p++]=K+l+1,F[p++]=V+l,F[p++]=V+l+1}if(x){for(l=1;l<_-2;l++)V=d*_+d*l,K=d*l,F[p++]=V,F[p++]=K+d,F[p++]=K,F[p++]=V,F[p++]=V+d,F[p++]=K+d;for(l=1;l<_-2;l++)V=d*_+d*(l+1)-1,K=d*(l+1)-1,F[p++]=K+d,F[p++]=V,F[p++]=K,F[p++]=K+d,F[p++]=V+d,F[p++]=V}let q=new Ct;m.position&&(q.position=new R({componentDatatype:N.DOUBLE,componentsPerAttribute:3,values:b}));let B,J=0,X=0,Q=0,$=0,tt=v/2,et=ot.fromCartesian3(e),it=ot.fromCartesian3(i);if(m.st||m.normal||m.tangent||m.bitangent){for(l=0;l<v;l++){B=g[l]?it:et;let t=s.fromArray(b,3*l,yt),e=B.geodeticSurfaceNormal(t,vt);if(O[l]&&s.negate(e,e),m.st){let t=pt.negate(e,Nt);j[J++]=Math.atan2(t.y,t.x)/M.TWO_PI+.5,j[J++]=Math.asin(e.z)/Math.PI+.5}if(m.normal&&(I[X++]=e.x,I[X++]=e.y,I[X++]=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&&(z[Q++]=i.x,z[Q++]=i.y,z[Q++]=i.z),m.bitangent){let t=s.cross(e,i,Mt);s.normalize(t,t),D[$++]=t.x,D[$++]=t.y,D[$++]=t.z}}}m.st&&(q.st=new R({componentDatatype:N.FLOAT,componentsPerAttribute:2,values:j})),m.normal&&(q.normal=new R({componentDatatype:N.FLOAT,componentsPerAttribute:3,values:I})),m.tangent&&(q.tangent=new R({componentDatatype:N.FLOAT,componentsPerAttribute:3,values:z})),m.bitangent&&(q.bitangent=new R({componentDatatype:N.FLOAT,componentsPerAttribute:3,values:D}))}if(E(t._offsetAttribute)){let e=b.length,i=t._offsetAttribute===wt.NONE?0:1,n=new Uint8Array(e/3).fill(i);q.applyOffset=new R({componentDatatype:N.UNSIGNED_BYTE,componentsPerAttribute:1,values:n})}return new _t({attributes:q,indices:F,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};