Newer
Older
smartwell_front_dz / XLJCYJ / mars3d-cesium / Workers / createVerticesFromGoogleEarthEnterpriseBuffer.js
wangxitong on 8 Jul 2024 7 KB 达州变更
/**
 * @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 Gt,b as Xt}from"./chunk-A4OZ5NVU.js";import{a as kt}from"./chunk-CXIXPJI2.js";import{a as lt}from"./chunk-W4I2V4RC.js";import{a as Dt}from"./chunk-HKOQYCKL.js";import"./chunk-YRDOGW7W.js";import"./chunk-GTVOTRDF.js";import{a as qt}from"./chunk-UGOEDKTL.js";import"./chunk-XZQSRYDQ.js";import"./chunk-MPWN7KNI.js";import{d as zt,i as Lt}from"./chunk-FCJU2DRX.js";import"./chunk-JDODZPYM.js";import{b as $,c as Ot,d as wt}from"./chunk-Y3I2OBKV.js";import"./chunk-KUWODMWG.js";import{a as P,b as N,c as Ht}from"./chunk-WADCMYQO.js";import{a as r}from"./chunk-2LQD2HPA.js";import"./chunk-YWFM6JRF.js";import{a as Vt}from"./chunk-P2U2ARL5.js";import{a as Ut}from"./chunk-3B6S2GOO.js";import"./chunk-EYEHMX6X.js";import{e as ht}from"./chunk-BWKFPVR5.js";var te=Uint16Array.BYTES_PER_ELEMENT,mt=Int32Array.BYTES_PER_ELEMENT,Pt=Uint32Array.BYTES_PER_ELEMENT,ee=Float32Array.BYTES_PER_ELEMENT,H=Float64Array.BYTES_PER_ELEMENT;function tt(t,e,n){n=Ut(n,r);let i=t.length;for(let o=0;o<i;++o)if(n.equalsEpsilon(t[o],e,r.EPSILON12))return o;return-1}function oe(t,e){t.ellipsoid=Ht.clone(t.ellipsoid),t.rectangle=Ot.clone(t.rectangle);let n=se(t.buffer,t.relativeToCenter,t.ellipsoid,t.rectangle,t.nativeRectangle,t.exaggeration,t.exaggerationRelativeHeight,t.skirtHeight,t.includeWebMercatorT,t.negativeAltitudeExponentBias,t.negativeElevationThreshold),i=n.vertices;e.push(i.buffer);let r=n.indices;return e.push(r.buffer),{vertices:i.buffer,indices:r.buffer,numberOfAttributes:n.encoding.stride,minimumHeight:n.minimumHeight,maximumHeight:n.maximumHeight,boundingSphere3D:n.boundingSphere3D,orientedBoundingBox:n.orientedBoundingBox,occludeePointInScaledSpace:n.occludeePointInScaledSpace,encoding:n.encoding,vertexCountWithoutSkirts:n.vertexCountWithoutSkirts,indexCountWithoutSkirts:n.indexCountWithoutSkirts,westIndicesSouthToNorth:n.westIndicesSouthToNorth,southIndicesEastToWest:n.southIndicesEastToWest,eastIndicesNorthToSouth:n.eastIndicesNorthToSouth,northIndicesWestToEast:n.northIndicesWestToEast}}var u=new N,G=new P,ne=new P,ie=new P,re=new $;function se(t,e,n,i,o,a,s,l,h,c,m){let d,g,p,I,f,E;ht(i)?(d=i.west,g=i.south,p=i.east,I=i.north,f=i.width,E=i.height):(d=r.toRadians(o.west),g=r.toRadians(o.south),p=r.toRadians(o.east),I=r.toRadians(o.north),f=r.toRadians(i.width),E=r.toRadians(i.height));let T,x,S=[g,I],w=[d,p],k=Lt.eastNorthUpToFixedFrame(e,n),R=$.inverseTransformation(k,re);h&&(T=lt.geodeticLatitudeToMercatorAngle(g),x=1/(lt.geodeticLatitudeToMercatorAngle(I)-T));let A=1!==a,b=new DataView(t),M=Number.POSITIVE_INFINITY,y=Number.NEGATIVE_INFINITY,F=ne;F.x=Number.POSITIVE_INFINITY,F.y=Number.POSITIVE_INFINITY,F.z=Number.POSITIVE_INFINITY;let B=ie;B.x=Number.NEGATIVE_INFINITY,B.y=Number.NEGATIVE_INFINITY,B.z=Number.NEGATIVE_INFINITY;let W,v,O=0,_=0,Y=0;for(v=0;v<4;++v){let t=O;W=b.getUint32(t,!0),t+=Pt;let e=r.toRadians(180*b.getFloat64(t,!0));t+=H,-1===tt(w,e)&&w.push(e);let n=r.toRadians(180*b.getFloat64(t,!0));t+=H,-1===tt(S,n)&&S.push(n),t+=2*H;let i=b.getInt32(t,!0);t+=mt,_+=i,i=b.getInt32(t,!0),Y+=3*i,O+=W+Pt}let j=[],C=[],U=new Array(_),V=new Array(_),D=new Array(_),L=h?new Array(_):[],X=A?new Array(_):[],K=new Array(Y),z=[],Q=[],J=[],q=[],Z=0,et=0;for(O=0,v=0;v<4;++v){W=b.getUint32(O,!0),O+=Pt;let t=O,e=r.toRadians(180*b.getFloat64(O,!0));O+=H;let i=r.toRadians(180*b.getFloat64(O,!0));O+=H;let o=r.toRadians(180*b.getFloat64(O,!0)),a=.5*o;O+=H;let s=r.toRadians(180*b.getFloat64(O,!0)),l=.5*s;O+=H;let f=b.getInt32(O,!0);O+=mt;let E=b.getInt32(O,!0);O+=mt,O+=mt;let k=new Array(f);for(let H=0;H<f;++H){let t=e+b.getUint8(O++)*o;u.longitude=t;let f=i+b.getUint8(O++)*s;u.latitude=f;let E=b.getFloat32(O,!0);if(O+=ee,0!==E&&E<m&&(E*=-Math.pow(2,c)),E*=6371010,u.height=E,-1!==tt(w,t)||-1!==tt(S,f)){let t=tt(j,u,N);if(-1!==t){k[H]=C[t];continue}j.push(N.clone(u)),C.push(Z)}k[H]=Z,Math.abs(t-d)<a?z.push({index:Z,cartographic:N.clone(u)}):Math.abs(t-p)<a?J.push({index:Z,cartographic:N.clone(u)}):Math.abs(f-g)<l?Q.push({index:Z,cartographic:N.clone(u)}):Math.abs(f-I)<l&&q.push({index:Z,cartographic:N.clone(u)}),M=Math.min(E,M),y=Math.max(E,y),D[Z]=E;let W=n.cartographicToCartesian(u);if(U[Z]=W,h&&(L[Z]=(lt.geodeticLatitudeToMercatorAngle(f)-T)*x),A){let t=n.geodeticSurfaceNormal(W);X[Z]=t}$.multiplyByPoint(R,W,G),P.minimumByComponent(G,F,F),P.maximumByComponent(G,B,B);let v=(t-d)/(p-d);v=r.clamp(v,0,1);let _=(f-g)/(I-g);_=r.clamp(_,0,1),V[Z]=new wt(v,_),++Z}let v=3*E;for(let n=0;n<v;++n,++et)K[et]=k[b.getUint16(O,!0)],O+=te;if(W!==O-t)throw new Vt("Invalid terrain tile.")}U.length=Z,V.length=Z,D.length=Z,h&&(L.length=Z),A&&(X.length=Z);let nt=Z,it=et,rt={hMin:M,lastBorderPoint:void 0,skirtHeight:l,toENU:R,ellipsoid:n,minimum:F,maximum:B};z.sort((function(t,e){return e.cartographic.latitude-t.cartographic.latitude})),Q.sort((function(t,e){return t.cartographic.longitude-e.cartographic.longitude})),J.sort((function(t,e){return t.cartographic.latitude-e.cartographic.latitude})),q.sort((function(t,e){return e.cartographic.longitude-t.cartographic.longitude}));let ot=1e-5;if(gt(U,D,V,L,X,K,rt,z,-ot*f,!0,-ot*E),gt(U,D,V,L,X,K,rt,Q,-ot*E,!1),gt(U,D,V,L,X,K,rt,J,ot*f,!0,ot*E),gt(U,D,V,L,X,K,rt,q,ot*E,!1),z.length>0&&q.length>0){let t=z[0].index,e=nt,n=q[q.length-1].index,i=U.length-1;K.push(n,i,e,e,t,n)}_=U.length;let at,ut=zt.fromPoints(U);ht(i)&&(at=Dt.fromRectangle(i,M,y,n));let st=new Gt(n).computeHorizonCullingPointPossiblyUnderEllipsoid(e,U,M),ct=new qt(F,B,e),dt=new Xt(e,ct,rt.hMin,y,k,!1,h,A,a,s),pt=new Float32Array(_*dt.stride),It=0;for(let r=0;r<_;++r)It=dt.encode(pt,It,U[r],V[r],D[r],void 0,L[r],X[r]);let ft=z.map((function(t){return t.index})).reverse(),Nt=Q.map((function(t){return t.index})).reverse(),Et=J.map((function(t){return t.index})).reverse(),Tt=q.map((function(t){return t.index})).reverse();return Nt.unshift(Et[Et.length-1]),Nt.push(ft[0]),Tt.unshift(ft[ft.length-1]),Tt.push(Et[0]),{vertices:pt,indices:new Uint16Array(K),maximumHeight:y,minimumHeight:M,encoding:dt,boundingSphere3D:ut,orientedBoundingBox:at,occludeePointInScaledSpace:st,vertexCountWithoutSkirts:nt,indexCountWithoutSkirts:it,westIndicesSouthToNorth:ft,southIndicesEastToWest:Nt,eastIndicesNorthToSouth:Et,northIndicesWestToEast:Tt}}function gt(t,e,n,i,o,a,s,l,h,c,m){let d=l.length;for(let g=0;g<d;++g){let p=l[g],I=p.cartographic,f=p.index,E=t.length,T=I.longitude,x=I.latitude;x=r.clamp(x,-r.PI_OVER_TWO,r.PI_OVER_TWO);let S=I.height-s.skirtHeight;s.hMin=Math.min(s.hMin,S),N.fromRadians(T,x,S,u),c&&(u.longitude+=h),c?g===d-1?u.latitude+=m:0===g&&(u.latitude-=m):u.latitude+=h;let w=s.ellipsoid.cartographicToCartesian(u);t.push(w),e.push(S),n.push(wt.clone(n[f])),i.length>0&&i.push(i[f]),o.length>0&&o.push(o[f]),$.multiplyByPoint(s.toENU,w,G);let k=s.minimum,R=s.maximum;P.minimumByComponent(G,k,k),P.maximumByComponent(G,R,R);let A=s.lastBorderPoint;if(ht(A)){let t=A.index;a.push(t,E-1,E,E,f,t)}s.lastBorderPoint=p}}var Ae=kt(oe);export{Ae as default};