/** * @license * Cesium - https://github.com/CesiumGS/cesium * Version 1.109.1 * * 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-DFHMTLCD.js";import{a as k}from"./chunk-JEAHRXD5.js";import{a as kt}from"./chunk-BBX2BII7.js";import{a as Ct}from"./chunk-BZJ4WRF6.js";import{b as dt,c as _t,d as R}from"./chunk-ESC6A27A.js";import{d as pt}from"./chunk-FCJU2DRX.js";import{d as ht}from"./chunk-Y3I2OBKV.js";import{a as N}from"./chunk-KUWODMWG.js";import{a as s,c as ot}from"./chunk-WADCMYQO.js";import{a as M}from"./chunk-2LQD2HPA.js";import{a as p}from"./chunk-3B6S2GOO.js";import{a as z}from"./chunk-EYEHMX6X.js";import{e as E}from"./chunk-BWKFPVR5.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),r=p(t.maximumClock,M.TWO_PI),a=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=r,this._minimumCone=a,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 r=s.unpack(t,e,xt);e+=s.packedLength;let a=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(r,i._innerRadii),i._vertexFormat=k.clone(a,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,r=t._maximumClock,a=t._minimumCone,o=t._maximumCone,m=t._vertexFormat,c=t._slicePartitions+1,u=t._stackPartitions+1;c=Math.round(c*Math.abs(r-n)/M.TWO_PI),u=Math.round(u*Math.abs(o-a)/M.PI),c<2&&(c=2),u<2&&(u=2);let l,f,p=0,k=[a],h=[n];for(l=0;l<u;l++)k.push(a+l*(o-a)/(u-1));for(k.push(o),f=0;f<c;f++)h.push(n+f*(r-n)/(c-1));h.push(r);let _=k.length,d=h.length,y=0,w=1,A=i.x!==e.x||i.y!==e.y||i.z!==e.z,C=!1,P=!1,x=!1;A&&(w=2,a>0&&(C=!0,y+=c-1),o<Math.PI&&(P=!0,y+=c-1),(r-n)%M.TWO_PI?(x=!0,y+=2*(u-1)+1):y+=1);let v=d*_*w,O=new Float64Array(3*v),b=new Array(v).fill(!1),g=new Array(v).fill(!1),F=c*u*w,L=6*(F+y+1-(c+u)*w),T=kt.createTypedArray(F,L),z=m.normal?new Float32Array(3*v):void 0,I=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,B=new Array(_),U=new Array(_);for(l=0;l<_;l++)B[l]=At(k[l]),U[l]=Pt(k[l]);let W=new Array(d),G=new Array(d);for(f=0;f<d;f++)G[f]=Pt(h[f]),W[f]=At(h[f]);for(l=0;l<_;l++)for(f=0;f<d;f++)O[p++]=e.x*B[l]*G[f],O[p++]=e.y*B[l]*W[f],O[p++]=e.z*U[l];let S,X,Y,K,H=v/2;if(A)for(l=0;l<_;l++)for(f=0;f<d;f++)O[p++]=i.x*B[l]*G[f],O[p++]=i.y*B[l]*W[f],O[p++]=i.z*U[l],b[H]=!0,l>0&&l!==_-1&&0!==f&&f!==d-1&&(g[H]=!0),H++;for(p=0,l=1;l<_-2;l++)for(S=l*d,X=(l+1)*d,f=1;f<d-2;f++)T[p++]=X+f,T[p++]=X+f+1,T[p++]=S+f+1,T[p++]=X+f,T[p++]=S+f+1,T[p++]=S+f;if(A){let t=_*d;for(l=1;l<_-2;l++)for(S=t+l*d,X=t+(l+1)*d,f=1;f<d-2;f++)T[p++]=X+f,T[p++]=S+f,T[p++]=S+f+1,T[p++]=X+f,T[p++]=S+f+1,T[p++]=X+f+1}if(A){if(C)for(K=_*d,l=1;l<d-2;l++)T[p++]=l,T[p++]=l+1,T[p++]=K+l+1,T[p++]=l,T[p++]=K+l+1,T[p++]=K+l;if(P)for(Y=_*d-d,K=_*d*w-d,l=1;l<d-2;l++)T[p++]=Y+l+1,T[p++]=Y+l,T[p++]=K+l,T[p++]=Y+l+1,T[p++]=K+l,T[p++]=K+l+1}if(x){for(l=1;l<_-2;l++)K=d*_+d*l,Y=d*l,T[p++]=K,T[p++]=Y+d,T[p++]=Y,T[p++]=K,T[p++]=K+d,T[p++]=Y+d;for(l=1;l<_-2;l++)K=d*_+d*(l+1)-1,Y=d*(l+1)-1,T[p++]=Y+d,T[p++]=K,T[p++]=Y,T[p++]=Y+d,T[p++]=K+d,T[p++]=K}let J=new Ct;m.position&&(J.position=new R({componentDatatype:N.DOUBLE,componentsPerAttribute:3,values:O}));let q,Q=0,V=0,Z=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++){q=b[l]?it:et;let t=s.fromArray(O,3*l,yt),e=q.geodeticSurfaceNormal(t,vt);if(g[l]&&s.negate(e,e),m.st){let t=ht.negate(e,Nt);j[Q++]=Math.atan2(t.y,t.x)/M.TWO_PI+.5,j[Q++]=Math.asin(e.z)/Math.PI+.5}if(m.normal&&(z[V++]=e.x,z[V++]=e.y,z[V++]=e.z),m.tangent||m.bitangent){let t,i=Et,n=0;if(b[l]&&(n=tt),t=!C&&l>=n&&l<n+2*d?s.UNIT_X:s.UNIT_Z,s.cross(t,e,i),s.normalize(i,i),m.tangent&&(I[Z++]=i.x,I[Z++]=i.y,I[Z++]=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&&(J.st=new R({componentDatatype:N.FLOAT,componentsPerAttribute:2,values:j})),m.normal&&(J.normal=new R({componentDatatype:N.FLOAT,componentsPerAttribute:3,values:z})),m.tangent&&(J.tangent=new R({componentDatatype:N.FLOAT,componentsPerAttribute:3,values:I})),m.bitangent&&(J.bitangent=new R({componentDatatype:N.FLOAT,componentsPerAttribute:3,values:D}))}if(E(t._offsetAttribute)){let e=O.length,i=t._offsetAttribute===wt.NONE?0:1,n=new Uint8Array(e/3).fill(i);J.applyOffset=new R({componentDatatype:N.UNSIGNED_BYTE,componentsPerAttribute:1,values:n})}return new _t({attributes:J,indices:T,primitiveType:dt.TRIANGLES,boundingSphere:pt.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};