/** * @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 Ct,b as vt}from"./chunk-A4OZ5NVU.js";import{a as Mt}from"./chunk-CXIXPJI2.js";import{a as z}from"./chunk-W4I2V4RC.js";import"./chunk-YRDOGW7W.js";import{a as Wt}from"./chunk-UGOEDKTL.js";import{a as X}from"./chunk-BBX2BII7.js";import{i as At}from"./chunk-FCJU2DRX.js";import"./chunk-JDODZPYM.js";import{b as U,c as bt,d as lt}from"./chunk-Y3I2OBKV.js";import"./chunk-KUWODMWG.js";import{a as P,b as wt,c as pt}from"./chunk-WADCMYQO.js";import{a as f}from"./chunk-2LQD2HPA.js";import"./chunk-YWFM6JRF.js";import"./chunk-P2U2ARL5.js";import"./chunk-3B6S2GOO.js";import{a as m}from"./chunk-EYEHMX6X.js";import{e as w}from"./chunk-BWKFPVR5.js";function T(){m.throwInstantiationError()}Object.defineProperties(T.prototype,{errorEvent:{get:m.throwInstantiationError},credit:{get:m.throwInstantiationError},tilingScheme:{get:m.throwInstantiationError},hasWaterMask:{get:m.throwInstantiationError},hasVertexNormals:{get:m.throwInstantiationError},availability:{get:m.throwInstantiationError}});var Ot=[];T.getRegularGridIndices=function(t,e){if(t*e>=f.FOUR_GIGABYTES)throw new m("The total number of vertices (width * height) must be less than 4,294,967,296.");let r=Ot[t];w(r)||(Ot[t]=r=[]);let n=r[e];return w(n)||(n=t*e<f.SIXTY_FOUR_KILOBYTES?r[e]=new Uint16Array((t-1)*(e-1)*6):r[e]=new Uint32Array((t-1)*(e-1)*6),Pt(t,e,n,0)),n};var Gt=[];T.getRegularGridIndicesAndEdgeIndices=function(t,e){if(t*e>=f.FOUR_GIGABYTES)throw new m("The total number of vertices (width * height) must be less than 4,294,967,296.");let r=Gt[t];w(r)||(Gt[t]=r=[]);let n=r[e];if(!w(n)){let i=T.getRegularGridIndices(t,e),o=Lt(t,e),a=o.westIndicesSouthToNorth,s=o.southIndicesEastToWest,h=o.eastIndicesNorthToSouth,u=o.northIndicesWestToEast;n=r[e]={indices:i,westIndicesSouthToNorth:a,southIndicesEastToWest:s,eastIndicesNorthToSouth:h,northIndicesWestToEast:u}}return n};var kt=[];function Lt(t,e){let r,n=new Array(e),i=new Array(t),o=new Array(e),a=new Array(t);for(r=0;r<t;++r)a[r]=r,i[r]=t*e-1-r;for(r=0;r<e;++r)o[r]=(r+1)*t-1,n[r]=(e-r-1)*t;return{westIndicesSouthToNorth:n,southIndicesEastToWest:i,eastIndicesNorthToSouth:o,northIndicesWestToEast:a}}function Pt(t,e,r,n){let i=0;for(let o=0;o<e-1;++o){for(let e=0;e<t-1;++e){let e=i,o=e+t,a=o+1,s=e+1;r[n++]=e,r[n++]=o,r[n++]=s,r[n++]=s,r[n++]=o,r[n++]=a,++i}++i}}function Z(t,e,r,n){let i=t[0],o=t.length;for(let a=1;a<o;++a){let o=t[a];r[n++]=i,r[n++]=o,r[n++]=e,r[n++]=e,r[n++]=o,r[n++]=e+1,i=o,++e}return n}T.getRegularGridAndSkirtIndicesAndEdgeIndices=function(t,e){if(t*e>=f.FOUR_GIGABYTES)throw new m("The total number of vertices (width * height) must be less than 4,294,967,296.");let r=kt[t];w(r)||(kt[t]=r=[]);let n=r[e];if(!w(n)){let i=t*e,o=(t-1)*(e-1)*6,a=2*t+2*e,s=6*Math.max(0,a-4),h=i+a,u=o+s,c=Lt(t,e),l=c.westIndicesSouthToNorth,I=c.southIndicesEastToWest,d=c.eastIndicesNorthToSouth,m=c.northIndicesWestToEast,g=X.createTypedArray(h,u);Pt(t,e,g,0),T.addSkirtIndices(l,I,d,m,i,g,o),n=r[e]={indices:g,westIndicesSouthToNorth:l,southIndicesEastToWest:I,eastIndicesNorthToSouth:d,northIndicesWestToEast:m,indexCountWithoutSkirts:o}}return n},T.addSkirtIndices=function(t,e,r,n,i,o,a){let s=i;a=Z(t,s,o,a),s+=t.length,a=Z(e,s,o,a),s+=e.length,a=Z(r,s,o,a),s+=r.length,Z(n,s,o,a)},T.heightmapTerrainQuality=.25,T.getEstimatedLevelZeroGeometricErrorForAHeightmap=function(t,e,r){return 2*t.maximumRadius*Math.PI*T.heightmapTerrainQuality/(e*r)},T.prototype.requestTileGeometry=m.throwInstantiationError,T.prototype.getLevelMaximumGeometricError=m.throwInstantiationError,T.prototype.getTileDataAvailable=m.throwInstantiationError,T.prototype.loadTileDataAvailability=m.throwInstantiationError;var Vt=T,ht=32767,D=new P,Xt=new P,Zt=new P,u=new wt,Y=new lt;function Jt(t,e){let r,n,i=t.quantizedVertices,o=i.length/3,a=t.octEncodedNormals,s=t.westIndices.length+t.eastIndices.length+t.southIndices.length+t.northIndices.length,h=t.includeWebMercatorT,c=t.exaggeration,l=t.exaggerationRelativeHeight,I=1!==c,d=bt.clone(t.rectangle),m=d.west,T=d.south,g=d.east,p=d.north,N=pt.clone(t.ellipsoid),E=t.minimumHeight,y=t.maximumHeight,S=t.relativeToCenter,A=At.eastNorthUpToFixedFrame(S,N),b=U.inverseTransformation(A,new U);h&&(r=z.geodeticLatitudeToMercatorAngle(T),n=1/(z.geodeticLatitudeToMercatorAngle(p)-r));let k=i.subarray(0,o),W=i.subarray(o,2*o),x=i.subarray(2*o,3*o),M=w(a),G=new Array(o),O=new Array(o),F=new Array(o),v=h?new Array(o):[],V=I?new Array(o):[],j=Xt;j.x=Number.POSITIVE_INFINITY,j.y=Number.POSITIVE_INFINITY,j.z=Number.POSITIVE_INFINITY;let _=Zt;_.x=Number.NEGATIVE_INFINITY,_.y=Number.NEGATIVE_INFINITY,_.z=Number.NEGATIVE_INFINITY;let C=Number.POSITIVE_INFINITY,H=Number.NEGATIVE_INFINITY,B=Number.POSITIVE_INFINITY,R=Number.NEGATIVE_INFINITY;for(let w=0;w<o;++w){let t=k[w],e=W[w],i=t/ht,o=e/ht,a=f.lerp(E,y,x[w]/ht);u.longitude=f.lerp(m,g,i),u.latitude=f.lerp(T,p,o),u.height=a,C=Math.min(u.longitude,C),H=Math.max(u.longitude,H),B=Math.min(u.latitude,B),R=Math.max(u.latitude,R);let s=N.cartographicToCartesian(u);G[w]=new lt(i,o),O[w]=a,F[w]=s,h&&(v[w]=(z.geodeticLatitudeToMercatorAngle(u.latitude)-r)*n),I&&(V[w]=N.geodeticSurfaceNormal(s)),U.multiplyByPoint(b,s,D),P.minimumByComponent(D,j,j),P.maximumByComponent(D,_,_)}let L,Z=tt(t.westIndices,(function(t,e){return G[t].y-G[e].y})),K=tt(t.eastIndices,(function(t,e){return G[e].y-G[t].y})),Q=tt(t.southIndices,(function(t,e){return G[e].x-G[t].x})),q=tt(t.northIndices,(function(t,e){return G[t].x-G[e].x}));E<0&&(L=new Ct(N).computeHorizonCullingPointPossiblyUnderEllipsoid(S,F,E));let et=E;et=Math.min(et,J(t.westIndices,t.westSkirtHeight,O,G,d,N,b,j,_)),et=Math.min(et,J(t.southIndices,t.southSkirtHeight,O,G,d,N,b,j,_)),et=Math.min(et,J(t.eastIndices,t.eastSkirtHeight,O,G,d,N,b,j,_)),et=Math.min(et,J(t.northIndices,t.northSkirtHeight,O,G,d,N,b,j,_));let rt=new Wt(j,_,S),nt=new vt(S,rt,et,y,A,M,h,I,c,l),it=nt.stride,ot=o*it+s*it,at=new Float32Array(ot),st=0;for(let u=0;u<o;++u){if(M){let t=2*u;Y.x=a[t],Y.y=a[t+1]}st=nt.encode(at,st,F[u],G[u],O[u],Y,v[u],V[u])}let ut=Math.max(0,2*(s-4)),ct=t.indices.length+3*ut,It=X.createTypedArray(o+s,ct);It.set(t.indices,0);let dt=1e-4,mt=(H-C)*dt,Tt=(R-B)*dt,gt=-mt,ft=0,wt=mt,Nt=0,Et=0,yt=Tt,St=0,kt=-Tt,Pt=o*it;return $(at,Pt,Z,nt,O,G,a,N,d,t.westSkirtHeight,r,n,gt,ft),Pt+=t.westIndices.length*it,$(at,Pt,Q,nt,O,G,a,N,d,t.southSkirtHeight,r,n,St,kt),Pt+=t.southIndices.length*it,$(at,Pt,K,nt,O,G,a,N,d,t.eastSkirtHeight,r,n,wt,Nt),Pt+=t.eastIndices.length*it,$(at,Pt,q,nt,O,G,a,N,d,t.northSkirtHeight,r,n,Et,yt),Vt.addSkirtIndices(Z,Q,K,q,o,It,t.indices.length),e.push(at.buffer,It.buffer),{vertices:at.buffer,indices:It.buffer,westIndicesSouthToNorth:Z,southIndicesEastToWest:Q,eastIndicesNorthToSouth:K,northIndicesWestToEast:q,vertexStride:it,center:S,minimumHeight:E,maximumHeight:y,occludeePointInScaledSpace:L,encoding:nt,indexCountWithoutSkirts:t.indices.length}}function J(t,e,r,n,i,o,a,s,h){let c=Number.POSITIVE_INFINITY,l=i.north,I=i.south,d=i.east,m=i.west;d<m&&(d+=f.TWO_PI);let T=t.length;for(let g=0;g<T;++g){let i=t[g],T=r[i],w=n[i];u.longitude=f.lerp(m,d,w.x),u.latitude=f.lerp(I,l,w.y),u.height=T-e;let p=o.cartographicToCartesian(u,D);U.multiplyByPoint(a,p,p),P.minimumByComponent(p,s,s),P.maximumByComponent(p,h,h),c=Math.min(c,u.height)}return c}function $(t,e,r,n,i,o,a,s,h,c,l,I,d,m){let T=w(a),g=h.north,p=h.south,N=h.east,E=h.west;N<E&&(N+=f.TWO_PI);let y=r.length;for(let w=0;w<y;++w){let h=r[w],y=i[h],S=o[h];u.longitude=f.lerp(E,N,S.x)+d,u.latitude=f.lerp(p,g,S.y)+m,u.height=y-c;let A,b,k=s.cartographicToCartesian(u,D);if(T){let t=2*h;Y.x=a[t],Y.y=a[t+1]}n.hasWebMercatorT&&(A=(z.geodeticLatitudeToMercatorAngle(u.latitude)-l)*I),n.hasGeodeticSurfaceNormals&&(b=s.geodeticSurfaceNormal(k)),e=n.encode(t,e,k,S,u.height,Y,A,b)}}function tt(t,e){let r;return"function"==typeof t.slice&&(r=t.slice(),"function"!=typeof r.sort&&(r=void 0)),w(r)||(r=Array.prototype.slice.call(t)),r.sort(e),r}var Se=Mt(Jt);export{Se as default};