/**
 * @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 nt}from"./chunk-HXS2AAIR.js";import"./chunk-S4UG323U.js";import"./chunk-ZYB4DKDQ.js";import{a as _}from"./chunk-6YAFAZVV.js";import"./chunk-ZIUWYBT3.js";import"./chunk-45FCQ3FJ.js";import"./chunk-354SKS6C.js";import"./chunk-H5GL2A6Z.js";import{a as ot}from"./chunk-UGB43LJM.js";import{a as it}from"./chunk-WFZLZ2P5.js";import{b as tt,c as et,d as S}from"./chunk-N72XKOXM.js";import{d as I}from"./chunk-EWTFJ46X.js";import"./chunk-5IUXF6I3.js";import{a as R}from"./chunk-27UWHT4D.js";import{a as s,d as l}from"./chunk-RFPX772U.js";import{a as J}from"./chunk-RAYRECQS.js";import"./chunk-2NAI7YQ3.js";import"./chunk-QE3ZUOZY.js";import{a as w}from"./chunk-6KLVDWWE.js";import{a as P}from"./chunk-6P5KAIBX.js";import{e as r}from"./chunk-4FSVUTPL.js";var Q=new s,Y=new s,lt=new s,st=new s,pt=new s,ut=new s,ft=new s;function k(t){let e=(t=w(t,w.EMPTY_OBJECT)).positions,i=t.maximumHeights,n=t.minimumHeights;if(!r(e))throw new P("options.positions is required.");if(r(i)&&i.length!==e.length)throw new P("options.positions and options.maximumHeights must have the same length.");if(r(n)&&n.length!==e.length)throw new P("options.positions and options.minimumHeights must have the same length.");let o=w(t.vertexFormat,_.DEFAULT),a=w(t.granularity,J.RADIANS_PER_DEGREE),m=w(t.ellipsoid,l.default);this._positions=e,this._minimumHeights=n,this._maximumHeights=i,this._vertexFormat=_.clone(o),this._granularity=a,this._ellipsoid=l.clone(m),this._workerName="createWallGeometry";let p=1+e.length*s.packedLength+2;r(n)&&(p+=n.length),r(i)&&(p+=i.length),this.packedLength=p+l.packedLength+_.packedLength+1}k.pack=function(t,e,i){if(!r(t))throw new P("value is required");if(!r(e))throw new P("array is required");i=w(i,0);let n,o=t._positions,a=o.length;for(e[i++]=a,n=0;n<a;++n,i+=s.packedLength)s.pack(o[n],e,i);let m=t._minimumHeights;if(a=r(m)?m.length:0,e[i++]=a,r(m))for(n=0;n<a;++n)e[i++]=m[n];let p=t._maximumHeights;if(a=r(p)?p.length:0,e[i++]=a,r(p))for(n=0;n<a;++n)e[i++]=p[n];return l.pack(t._ellipsoid,e,i),i+=l.packedLength,_.pack(t._vertexFormat,e,i),e[i+=_.packedLength]=t._granularity,e};var mt=l.clone(l.UNIT_SPHERE),rt=new _,V={positions:void 0,minimumHeights:void 0,maximumHeights:void 0,ellipsoid:mt,vertexFormat:rt,granularity:void 0};k.unpack=function(t,e,i){if(!r(t))throw new P("array is required");e=w(e,0);let n,o,a,m=t[e++],p=new Array(m);for(n=0;n<m;++n,e+=s.packedLength)p[n]=s.unpack(t,e);if(m=t[e++],m>0)for(o=new Array(m),n=0;n<m;++n)o[n]=t[e++];if(m=t[e++],m>0)for(a=new Array(m),n=0;n<m;++n)a[n]=t[e++];let u=l.unpack(t,e,mt);e+=l.packedLength;let h=_.unpack(t,e,rt),c=t[e+=_.packedLength];return r(i)?(i._positions=p,i._minimumHeights=o,i._maximumHeights=a,i._ellipsoid=l.clone(u,i._ellipsoid),i._vertexFormat=_.clone(h,i._vertexFormat),i._granularity=c,i):(V.positions=p,V.minimumHeights=o,V.maximumHeights=a,V.granularity=c,new k(V))},k.fromConstantHeights=function(t){let e=(t=w(t,w.EMPTY_OBJECT)).positions;if(!r(e))throw new P("options.positions is required.");let i,n,o=t.minimumHeight,s=t.maximumHeight,a=r(o),m=r(s);if(a||m){let t=e.length;i=a?new Array(t):void 0,n=m?new Array(t):void 0;for(let e=0;e<t;++e)a&&(i[e]=o),m&&(n[e]=s)}return new k({positions:e,maximumHeights:n,minimumHeights:i,ellipsoid:t.ellipsoid,vertexFormat:t.vertexFormat})},k.createGeometry=function(t){let e=t._positions,i=t._minimumHeights,n=t._maximumHeights,o=t._vertexFormat,a=t._granularity,m=t._ellipsoid,l=nt.computePositions(m,e,n,i,a,!0);if(!r(l))return;let p=l.bottomPositions,u=l.topPositions,h=l.numCorners,c=u.length,g=2*c,f=o.position?new Float64Array(g):void 0,w=o.normal?new Float32Array(g):void 0,k=o.tangent?new Float32Array(g):void 0,d=o.bitangent?new Float32Array(g):void 0,_=o.st?new Float32Array(g/3*2):void 0,y=0,A=0,v=0,x=0,F=0,P=ft,H=ut,L=pt,E=!0;c/=3;let j,b=0,T=1/(c-h-1);for(j=0;j<c;++j){let t=3*j,e=s.fromArray(u,t,Q),i=s.fromArray(p,t,Y);if(o.position&&(f[y++]=i.x,f[y++]=i.y,f[y++]=i.z,f[y++]=e.x,f[y++]=e.y,f[y++]=e.z),o.st&&(_[F++]=b,_[F++]=0,_[F++]=b,_[F++]=1),o.normal||o.tangent||o.bitangent){let i=s.clone(s.ZERO,st),n=s.subtract(e,m.geodeticSurfaceNormal(e,Y),Y);if(j+1<c&&(i=s.fromArray(u,t+3,st)),E){let t=s.subtract(i,e,lt),r=s.subtract(n,e,Q);P=s.normalize(s.cross(r,t,P),P),E=!1}s.equalsEpsilon(e,i,J.EPSILON10)?E=!0:(b+=T,o.tangent&&(H=s.normalize(s.subtract(i,e,H),H)),o.bitangent&&(L=s.normalize(s.cross(P,H,L),L))),o.normal&&(w[A++]=P.x,w[A++]=P.y,w[A++]=P.z,w[A++]=P.x,w[A++]=P.y,w[A++]=P.z),o.tangent&&(k[x++]=H.x,k[x++]=H.y,k[x++]=H.z,k[x++]=H.x,k[x++]=H.y,k[x++]=H.z),o.bitangent&&(d[v++]=L.x,d[v++]=L.y,d[v++]=L.z,d[v++]=L.x,d[v++]=L.y,d[v++]=L.z)}}let O=new it;o.position&&(O.position=new S({componentDatatype:R.DOUBLE,componentsPerAttribute:3,values:f})),o.normal&&(O.normal=new S({componentDatatype:R.FLOAT,componentsPerAttribute:3,values:w})),o.tangent&&(O.tangent=new S({componentDatatype:R.FLOAT,componentsPerAttribute:3,values:k})),o.bitangent&&(O.bitangent=new S({componentDatatype:R.FLOAT,componentsPerAttribute:3,values:d})),o.st&&(O.st=new S({componentDatatype:R.FLOAT,componentsPerAttribute:2,values:_}));let D=g/3;g-=6*(h+1);let U=ot.createTypedArray(D,g),z=0;for(j=0;j<D-2;j+=2){let t=j,e=j+2,i=s.fromArray(f,3*t,Q),n=s.fromArray(f,3*e,Y);if(s.equalsEpsilon(i,n,J.EPSILON10))continue;let r=j+1,o=j+3;U[z++]=r,U[z++]=t,U[z++]=o,U[z++]=o,U[z++]=t,U[z++]=e}return new et({attributes:O,indices:U,primitiveType:tt.TRIANGLES,boundingSphere:new I.fromVertices(f)})};var X=k;function ht(t,e){return r(e)&&(t=X.unpack(t,e)),t._ellipsoid=l.clone(t._ellipsoid),X.createGeometry(t)}var Ot=ht;export{Ot as default};