Newer
Older
smartwell_front_dz / XLJCYJ / mars3d-cesium / Workers / createVectorTilePolygons.js
wangxitong on 8 Jul 2024 5 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 R}from"./chunk-CRE7E3ZQ.js";import{a as It}from"./chunk-CXIXPJI2.js";import{a as M}from"./chunk-HKOQYCKL.js";import{a as bt}from"./chunk-YRDOGW7W.js";import"./chunk-GTVOTRDF.js";import"./chunk-UGOEDKTL.js";import"./chunk-XZQSRYDQ.js";import"./chunk-MPWN7KNI.js";import{a as W}from"./chunk-BBX2BII7.js";import"./chunk-FCJU2DRX.js";import"./chunk-JDODZPYM.js";import{c as z}from"./chunk-Y3I2OBKV.js";import"./chunk-KUWODMWG.js";import{a as o,b as nt,c as j}from"./chunk-WADCMYQO.js";import{a as et}from"./chunk-2LQD2HPA.js";import"./chunk-YWFM6JRF.js";import"./chunk-P2U2ARL5.js";import"./chunk-3B6S2GOO.js";import"./chunk-EYEHMX6X.js";import{e as A}from"./chunk-BWKFPVR5.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,k=t.maximumHeights;A(d)&&A(k)&&(d=new Float32Array(d),k=new Float32Array(k));let I,g,w,b=r.length/2,y=r.subarray(0,b),N=r.subarray(b,2*b);bt.zigZagDeltaDecode(y,N);let j=new Float64Array(3*b);for(I=0;I<b;++I){let t=y[I],e=N[I],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,j,3*I)}let x=a.length,L=new Array(x),T=new Array(x),O=0,U=0;for(I=0;I<x;++I)L[I]=O,T[I]=U,O+=a[I],U+=i[I];let B=new Float32Array(3*b*2),F=new Uint16Array(2*b),P=new Uint32Array(T.length),D=new Uint32Array(i.length),S=[],Y={};for(I=0;I<x;++I)w=f[I],A(Y[w])?(Y[w].positionLength+=a[I],Y[w].indexLength+=i[I],Y[w].batchIds.push(I)):Y[w]={positionLength:a[I],indexLength:i[I],offset:0,indexOffset:0,batchIds:[I]};let C,G=0,H=0;for(w in Y)if(Y.hasOwnProperty(w)){C=Y[w],C.offset=G,C.indexOffset=H;let t=2*C.positionLength,e=2*C.indexLength+6*C.positionLength;G+=t,H+=e,C.indexLength=e}let _=[];for(w in Y)Y.hasOwnProperty(w)&&(C=Y[w],_.push({color:R.fromRgba(parseInt(w)),offset:C.indexOffset,count:C.indexLength,batchIds:C.batchIds}));for(I=0;I<x;++I){w=f[I],C=Y[w];let t=C.offset,e=3*t,r=t,b=L[I],y=a[I],E=s[I],N=m,x=p;A(d)&&A(k)&&(N=d[I],x=k[I]);let O=Number.POSITIVE_INFINITY,R=Number.NEGATIVE_INFINITY,U=Number.POSITIVE_INFINITY,W=Number.NEGATIVE_INFINITY;for(g=0;g<y;++g){let t=o.unpack(j,3*b+3*g,wt);l.scaleToGeodeticSurface(t,t);let n=l.cartesianToCartographic(t,Lt),a=n.latitude,i=n.longitude;O=Math.min(a,O),R=Math.max(a,R),U=Math.min(i,U),W=Math.max(i,W);let s=l.geodeticSurfaceNormal(t,Ht),f=o.multiplyByScalar(s,N,St),c=o.add(t,f,Ut);f=o.multiplyByScalar(s,x,f);let u=o.add(t,f,Ft);o.subtract(u,h,u),o.subtract(c,h,c),o.pack(u,B,e),o.pack(c,B,e+3),F[r]=E,F[r+1]=E,e+=6,r+=2}u=Mt,u.west=U,u.east=W,u.south=O,u.north=R,c[I]=M.fromRectangle(u,m,p,l);let G=C.indexOffset,H=T[I],_=i[I];for(P[I]=G,g=0;g<_;g+=3){let e=n[H+g]-b,r=n[H+g+1]-b,o=n[H+g+2]-b;S[G++]=2*e+t,S[G++]=2*r+t,S[G++]=2*o+t,S[G++]=2*o+1+t,S[G++]=2*r+1+t,S[G++]=2*e+1+t}for(g=0;g<y;++g){let e=g,n=(g+1)%y;S[G++]=2*e+1+t,S[G++]=2*n+t,S[G++]=2*e+t,S[G++]=2*e+1+t,S[G++]=2*n+1+t,S[G++]=2*n+t}C.offset+=2*y,C.indexOffset=G,D[I]=G-P[I]}S=W.createTypedArray(B.length/3,S);let K=_.length;for(let o=0;o<K;++o){let t=_[o].batchIds,e=0,n=t.length;for(let r=0;r<n;++r)e+=D[t[r]];_[o].count=e}let V=2===S.BYTES_PER_ELEMENT?W.UNSIGNED_SHORT:W.UNSIGNED_INT,X=Ct(V,c,_);return e.push(B.buffer,S.buffer,P.buffer,D.buffer,F.buffer,X.buffer),{positions:B.buffer,indices:S.buffer,indexOffsets:P.buffer,indexCounts:D.buffer,batchIds:F.buffer,packedBuffer:X.buffer}}var Jt=It(Rt);export{Jt as default};