/** * @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 R}from"./chunk-OYBVIZ5Q.js";import{a as It}from"./chunk-7CHYY4MB.js";import{a as M}from"./chunk-JA4HQIWI.js";import{a as bt}from"./chunk-AWTNTFWT.js";import"./chunk-HVRCTCKZ.js";import"./chunk-PCAQWIAU.js";import"./chunk-ZZPAAKFL.js";import"./chunk-A2J5OJ74.js";import{a as W}from"./chunk-VRSMIU2E.js";import"./chunk-JYT7LKWQ.js";import{h as z}from"./chunk-DPXXHKCX.js";import"./chunk-UTQP35IH.js";import{a as o,b as nt,d as j}from"./chunk-S74IVKSO.js";import{a as et}from"./chunk-XQPFZTAL.js";import"./chunk-CYX2VK56.js";import"./chunk-A5LGJSYE.js";import"./chunk-CDFKIAC5.js";import"./chunk-DRUYFASX.js";import{e as A}from"./chunk-A4U73JJE.js";var kt=new o,Bt=new j,Nt=new z,E={min:void 0,max:void 0,indexBytesPerElement:void 0};function Pt(t){let e=new Float64Array(t),n=0;E.indexBytesPerElement=e[n++],E.min=e[n++],E.max=e[n++],o.unpack(e,n,kt),n+=o.packedLength,j.unpack(e,n,Bt),n+=j.packedLength,z.unpack(e,n,Nt)}function Tt(t){let e=t.length,n=0;for(let r=0;r<e;++r)n+=R.packedLength+3+t[r].batchIds.length;return n}function Ct(t,e,n){let r=e.length,o=2+r*M.packedLength+1+Tt(n),a=new Float64Array(o),i=0;a[i++]=t,a[i++]=r;for(let f=0;f<r;++f)M.pack(e[f],a,i),i+=M.packedLength;let s=n.length;a[i++]=s;for(let f=0;f<s;++f){let t=n[f];R.pack(t.color,a,i),i+=R.packedLength,a[i++]=t.offset,a[i++]=t.count;let e=t.batchIds,r=e.length;a[i++]=r;for(let n=0;n<r;++n)a[i++]=e[n]}return a}var yt=32767,wt=new o,Ht=new o,St=new o,Ut=new o,Ft=new o,Lt=new nt,Mt=new z;function Rt(t,e){let n;Pt(t.packedBuffer),n=2===E.indexBytesPerElement?new Uint16Array(t.indices):new Uint32Array(t.indices);let r=new Uint16Array(t.positions),a=new Uint32Array(t.counts),i=new Uint32Array(t.indexCounts),s=new Uint32Array(t.batchIds),f=new Uint32Array(t.batchTableColors),c=new Array(a.length),h=kt,l=Bt,u=Nt,m=E.min,p=E.max,d=t.minimumHeights,I=t.maximumHeights;A(d)&&A(I)&&(d=new Float32Array(d),I=new Float32Array(I));let k,g,w,b=r.length/2,y=r.subarray(0,b),T=r.subarray(b,2*b);bt.zigZagDeltaDecode(y,T);let N=new Float64Array(3*b);for(k=0;k<b;++k){let t=y[k],e=T[k],n=et.lerp(u.west,u.east,t/yt),r=et.lerp(u.south,u.north,e/yt),a=nt.fromRadians(n,r,0,Lt),i=l.cartographicToCartesian(a,wt);o.pack(i,N,3*k)}let j=a.length,x=new Array(j),L=new Array(j),U=0,F=0;for(k=0;k<j;++k)x[k]=U,L[k]=F,U+=a[k],F+=i[k];let S=new Float32Array(3*b*2),C=new Uint16Array(2*b),P=new Uint32Array(L.length),O=new Uint32Array(i.length),B=[],Y={};for(k=0;k<j;++k)w=f[k],A(Y[w])?(Y[w].positionLength+=a[k],Y[w].indexLength+=i[k],Y[w].batchIds.push(k)):Y[w]={positionLength:a[k],indexLength:i[k],offset:0,indexOffset:0,batchIds:[k]};let H,J=0,V=0;for(w in Y)if(Y.hasOwnProperty(w)){H=Y[w],H.offset=J,H.indexOffset=V;let t=2*H.positionLength,e=2*H.indexLength+6*H.positionLength;J+=t,V+=e,H.indexLength=e}let _=[];for(w in Y)Y.hasOwnProperty(w)&&(H=Y[w],_.push({color:R.fromRgba(parseInt(w)),offset:H.indexOffset,count:H.indexLength,batchIds:H.batchIds}));for(k=0;k<j;++k){w=f[k],H=Y[w];let t=H.offset,e=3*t,r=t,b=x[k],y=a[k],E=s[k],T=m,j=p;A(d)&&A(I)&&(T=d[k],j=I[k]);let U=Number.POSITIVE_INFINITY,F=Number.NEGATIVE_INFINITY,R=Number.POSITIVE_INFINITY,J=Number.NEGATIVE_INFINITY;for(g=0;g<y;++g){let t=o.unpack(N,3*b+3*g,wt);l.scaleToGeodeticSurface(t,t);let n=l.cartesianToCartographic(t,Lt),a=n.latitude,i=n.longitude;U=Math.min(a,U),F=Math.max(a,F),R=Math.min(i,R),J=Math.max(i,J);let s=l.geodeticSurfaceNormal(t,Ht),f=o.multiplyByScalar(s,T,St),c=o.add(t,f,Ut);f=o.multiplyByScalar(s,j,f);let u=o.add(t,f,Ft);o.subtract(u,h,u),o.subtract(c,h,c),o.pack(u,S,e),o.pack(c,S,e+3),C[r]=E,C[r+1]=E,e+=6,r+=2}u=Mt,u.west=R,u.east=J,u.south=U,u.north=F,c[k]=M.fromRectangle(u,m,p,l);let V=H.indexOffset,W=L[k],_=i[k];for(P[k]=V,g=0;g<_;g+=3){let e=n[W+g]-b,r=n[W+g+1]-b,o=n[W+g+2]-b;B[V++]=2*e+t,B[V++]=2*r+t,B[V++]=2*o+t,B[V++]=2*o+1+t,B[V++]=2*r+1+t,B[V++]=2*e+1+t}for(g=0;g<y;++g){let e=g,n=(g+1)%y;B[V++]=2*e+1+t,B[V++]=2*n+t,B[V++]=2*e+t,B[V++]=2*e+1+t,B[V++]=2*n+1+t,B[V++]=2*n+t}H.offset+=2*y,H.indexOffset=V,O[k]=V-P[k]}B=W.createTypedArray(S.length/3,B);let D=_.length;for(let o=0;o<D;++o){let t=_[o].batchIds,e=0,n=t.length;for(let r=0;r<n;++r)e+=O[t[r]];_[o].count=e}let K=2===B.BYTES_PER_ELEMENT?W.UNSIGNED_SHORT:W.UNSIGNED_INT,v=Ct(K,c,_);return e.push(S.buffer,B.buffer,P.buffer,O.buffer,C.buffer,v.buffer),{positions:S.buffer,indices:B.buffer,indexOffsets:P.buffer,indexCounts:O.buffer,batchIds:C.buffer,packedBuffer:v.buffer}}var Jt=It(Rt);export{Jt as default};