/** * @license * Cesium - https://github.com/CesiumGS/cesium * Version 1.120.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 J}from"./chunk-7CHYY4MB.js";import{a as Y}from"./chunk-AWTNTFWT.js";import{a as B}from"./chunk-VRSMIU2E.js";import{c as X,h as W}from"./chunk-DPXXHKCX.js";import"./chunk-UTQP35IH.js";import{a as t,b as k,d as _}from"./chunk-S74IVKSO.js";import{a as v}from"./chunk-XQPFZTAL.js";import"./chunk-CYX2VK56.js";import"./chunk-A5LGJSYE.js";import"./chunk-CDFKIAC5.js";import"./chunk-DRUYFASX.js";import"./chunk-A4U73JJE.js";var V=32767,it=Math.cos(v.toRadians(150)),ct=new k,rt=new t;function at(e,r,s,a,n,i,o){let l=e.length,d=new Float64Array(3*l);for(let f=0;f<l;++f){let l=e[f],h=r[f],c=s[f],u=v.lerp(a.west,a.east,l/V),p=v.lerp(a.south,a.north,h/V),m=v.lerp(n,i,c/V),A=k.fromRadians(u,p,m,ct),w=o.cartographicToCartesian(A,rt);t.pack(w,d,3*f)}return d}function dt(t){let e=t.length,r=new Uint32Array(e+1),s=0;for(let a=0;a<e;++a)r[a]=s,s+=t[a];return r[e]=s,r}var lt=new k,ht=new k;function ft(t,e,r,s){let a=s.length,n=t.length,i=new Uint8Array(n),o=lt,l=ht,d=0;for(let h=0;h<a;h++){let r=s[h],a=r;for(let s=1;s<r;s++){let r=d+s,n=r-1;l.longitude=t[r],l.latitude=e[r],o.longitude=t[n],o.latitude=e[n],k.equals(l,o)&&(a--,i[n]=1)}s[h]=a,d+=r}let f=0;for(let h=0;h<n;h++)1!==i[h]&&(t[f]=t[h],e[f]=e[h],r[f]=r[h],f++)}function ot(t){let e=8*t,r=3*e,s=4*e;this.startEllipsoidNormals=new Float32Array(r),this.endEllipsoidNormals=new Float32Array(r),this.startPositionAndHeights=new Float32Array(s),this.startFaceNormalAndVertexCornerIds=new Float32Array(s),this.endPositionAndHeights=new Float32Array(s),this.endFaceNormalAndHalfWidths=new Float32Array(s),this.vertexBatchIds=new Uint16Array(e),this.indices=B.createTypedArray(e,36*t),this.vec3Offset=0,this.vec4Offset=0,this.batchIdOffset=0,this.indexOffset=0,this.volumeStartIndex=0}var Q=new t,pt=new t;function $(e,r,s,a,n){let i=t.subtract(s,r,pt),o=t.subtract(r,e,Q);return t.normalize(i,i),t.normalize(o,o),t.dot(i,o)<it&&(o=t.multiplyByScalar(o,-1,Q)),t.add(i,o,n),t.equals(n,t.ZERO)&&(n=t.subtract(e,r)),t.cross(n,a,n),t.cross(a,n,n),t.normalize(n,n),n}var st=[0,2,6,0,6,4,0,1,3,0,3,2,0,4,5,0,5,1,5,3,1,5,7,3,7,5,4,7,4,6,7,6,2,7,2,3],j=st.length,tt=new t,ut=new t,mt=new t,At=new t,Nt=new t;ot.prototype.addVolume=function(e,r,s,a,n,i,o,l,d,f){let h=t.add(r,d,tt),c=f.geodeticSurfaceNormal(h,ut);h=t.add(s,d,tt);let u,p=f.geodeticSurfaceNormal(h,At),m=$(e,r,s,c,mt),A=$(a,s,r,p,Nt),k=this.startEllipsoidNormals,w=this.endEllipsoidNormals,b=this.startPositionAndHeights,N=this.startFaceNormalAndVertexCornerIds,g=this.endPositionAndHeights,v=this.endFaceNormalAndHalfWidths,y=this.vertexBatchIds,I=this.batchIdOffset,E=this.vec3Offset,F=this.vec4Offset;for(u=0;u<8;u++)t.pack(c,k,E),t.pack(p,w,E),t.pack(r,b,F),b[F+3]=n,t.pack(s,g,F),g[F+3]=i,t.pack(m,N,F),N[F+3]=u,t.pack(A,v,F),v[F+3]=o,y[I++]=l,E+=3,F+=4;this.batchIdOffset=I,this.vec3Offset=E,this.vec4Offset=F;let x=this.indices,H=this.volumeStartIndex,P=this.indexOffset;for(u=0;u<j;u++)x[P+u]=st[u]+H;this.volumeStartIndex+=8,this.indexOffset+=j};var gt=new W,Et=new _,wt=new t,M=new t,It=new t,xt=new t,T=new t;function Pt(e,r){let s=new Uint16Array(e.positions),a=new Uint16Array(e.widths),n=new Uint32Array(e.counts),i=new Uint16Array(e.batchIds),o=gt,l=Et,d=wt,f=new Float64Array(e.packedBuffer),h=0,c=f[h++],u=f[h++];W.unpack(f,h,o),h+=W.packedLength,_.unpack(f,h,l),h+=_.packedLength,t.unpack(f,h,d);let p,m=s.length/3,A=s.subarray(0,m),k=s.subarray(m,2*m),w=s.subarray(2*m,3*m);Y.zigZagDeltaDecode(A,k,w),ft(A,k,w,n);let b=n.length,N=0;for(p=0;p<b;p++){let t=n[p];N+=t-1}let g=new ot(N),y=at(A,k,w,o,c,u,l,d);m=A.length;let I=new Float32Array(3*m);for(p=0;p<m;++p)I[3*p]=y[3*p]-d.x,I[3*p+1]=y[3*p+1]-d.y,I[3*p+2]=y[3*p+2]-d.z;let E=0,F=0;for(p=0;p<b;p++){let e=n[p]-1,r=.5*a[p],s=i[p],o=E;for(let a=0;a<e;a++){let n=t.unpack(I,E,It),i=t.unpack(I,E+3,xt),f=w[F],h=w[F+1];f=v.lerp(c,u,f/V),h=v.lerp(c,u,h/V),F++;let p=M,m=T;if(0===a){let r=o+3*e,s=t.unpack(I,r,M);if(t.equals(s,n))t.unpack(I,r-3,p);else{let e=t.subtract(n,i,M);p=t.add(e,n,M)}}else t.unpack(I,E-3,p);if(a===e-1){let e=t.unpack(I,o,T);if(t.equals(e,i))t.unpack(I,o+3,m);else{let e=t.subtract(i,n,T);m=t.add(e,i,T)}}else t.unpack(I,E+6,m);g.addVolume(p,n,i,m,f,h,r,s,d,l),E+=3}E+=3,F++}let x=g.indices;r.push(g.startEllipsoidNormals.buffer),r.push(g.endEllipsoidNormals.buffer),r.push(g.startPositionAndHeights.buffer),r.push(g.startFaceNormalAndVertexCornerIds.buffer),r.push(g.endPositionAndHeights.buffer),r.push(g.endFaceNormalAndHalfWidths.buffer),r.push(g.vertexBatchIds.buffer),r.push(x.buffer);let H={indexDatatype:2===x.BYTES_PER_ELEMENT?B.UNSIGNED_SHORT:B.UNSIGNED_INT,startEllipsoidNormals:g.startEllipsoidNormals.buffer,endEllipsoidNormals:g.endEllipsoidNormals.buffer,startPositionAndHeights:g.startPositionAndHeights.buffer,startFaceNormalAndVertexCornerIds:g.startFaceNormalAndVertexCornerIds.buffer,endPositionAndHeights:g.endPositionAndHeights.buffer,endFaceNormalAndHalfWidths:g.endFaceNormalAndHalfWidths.buffer,vertexBatchIds:g.vertexBatchIds.buffer,indices:x.buffer};if(e.keepDecodedPositions){let t=dt(n);r.push(y.buffer,t.buffer),H=X(H,{decodedPositions:y.buffer,decodedPositionOffsets:t.buffer})}return H}var Vt=J(Pt);export{Vt as default};