Newer
Older
smartwell_front_dz / XLJCYJ / mars3d-cesium / Workers / createVectorTileGeometries.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 P}from"./chunk-CRE7E3ZQ.js";import{a as z}from"./chunk-KNKMZEBT.js";import"./chunk-BSMDNUXT.js";import{a as H}from"./chunk-5OXA6X6I.js";import{a as Y}from"./chunk-CXIXPJI2.js";import{a as j}from"./chunk-VWRUIIRD.js";import"./chunk-DFHMTLCD.js";import"./chunk-JEAHRXD5.js";import{a as W}from"./chunk-BBX2BII7.js";import"./chunk-BZJ4WRF6.js";import"./chunk-ESC6A27A.js";import{d as E}from"./chunk-FCJU2DRX.js";import"./chunk-JDODZPYM.js";import{b as d}from"./chunk-Y3I2OBKV.js";import"./chunk-KUWODMWG.js";import{a as o}from"./chunk-WADCMYQO.js";import"./chunk-2LQD2HPA.js";import"./chunk-YWFM6JRF.js";import"./chunk-P2U2ARL5.js";import"./chunk-3B6S2GOO.js";import"./chunk-EYEHMX6X.js";import{e as l}from"./chunk-BWKFPVR5.js";function X(e){this.offset=e.offset,this.count=e.count,this.color=e.color,this.batchIds=e.batchIds}var J=X,S=new o,$=d.packedLength+o.packedLength,ee=d.packedLength+2,ne=d.packedLength+o.packedLength,te=o.packedLength+1,u={modelMatrix:new d,boundingVolume:new E};function oe(e,t){let n=t*$,r=o.unpack(e,n,S);n+=o.packedLength;let i=d.unpack(e,n,u.modelMatrix);d.multiplyByScale(i,r,i);let s=u.boundingVolume;return o.clone(o.ZERO,s.center),s.radius=Math.sqrt(3),u}function ce(e,t){let n=t*ee,r=e[n++],i=e[n++],s=o.fromElements(r,r,i,S),a=d.unpack(e,n,u.modelMatrix);d.multiplyByScale(a,s,a);let l=u.boundingVolume;return o.clone(o.ZERO,l.center),l.radius=Math.sqrt(2),u}function se(e,t){let n=t*ne,r=o.unpack(e,n,S);n+=o.packedLength;let i=d.unpack(e,n,u.modelMatrix);d.multiplyByScale(i,r,i);let s=u.boundingVolume;return o.clone(o.ZERO,s.center),s.radius=1,u}function ie(e,t){let n=t*te,r=e[n++],i=o.unpack(e,n,S),s=d.fromTranslation(i,u.modelMatrix);d.multiplyByUniformScale(s,r,s);let a=u.boundingVolume;return o.clone(o.ZERO,a.center),a.radius=1,u}var de=new o;function R(e,t,n,r,i){if(!l(t))return;let s=n.length,a=r.attributes.position.values,c=r.indices,u=e.positions,f=e.vertexBatchIds,h=e.indices,p=e.batchIds,m=e.batchTableColors,b=e.batchedIndices,k=e.indexOffsets,g=e.indexCounts,I=e.boundingVolumes,y=e.modelMatrix,x=e.center,B=e.positionOffset,A=e.batchIdIndex,w=e.indexOffset,O=e.batchedIndicesOffset;for(let l=0;l<s;++l){let e=i(t,l),r=e.modelMatrix;d.multiply(y,r,r);let s=n[l],j=a.length;for(let t=0;t<j;t+=3){let e=o.unpack(a,t,de);d.multiplyByPoint(r,e,e),o.subtract(e,x,e),o.pack(e,u,3*B+t),f[A++]=s}let R=c.length;for(let t=0;t<R;++t)h[w+t]=c[t]+B;let v=l+O;b[v]=new J({offset:w,count:R,color:P.fromRgba(m[s]),batchIds:[s]}),p[v]=s,k[v]=w,g[v]=R,I[v]=E.transform(e.boundingVolume,r),B+=j/3,w+=R}e.positionOffset=B,e.batchIdIndex=A,e.indexOffset=w,e.batchedIndicesOffset+=s}var K=new o,Q=new d;function re(e){let t=new Float64Array(e),n=0;o.unpack(t,n,K),n+=o.packedLength,d.unpack(t,n,Q)}function le(e){let t=e.length,n=0;for(let o=0;o<t;++o)n+=P.packedLength+3+e[o].batchIds.length;return n}function ae(e,t,n){let o=n.length,r=2+o*E.packedLength+1+le(t),i=new Float64Array(r),s=0;i[s++]=e,i[s++]=o;for(let l=0;l<o;++l)E.pack(n[l],i,s),s+=E.packedLength;let a=t.length;i[s++]=a;for(let l=0;l<a;++l){let e=t[l];P.pack(e.color,i,s),s+=P.packedLength,i[s++]=e.offset,i[s++]=e.count;let n=e.batchIds,o=n.length;i[s++]=o;for(let t=0;t<o;++t)i[s++]=n[t]}return i}function fe(e,t){let n=l(e.boxes)?new Float32Array(e.boxes):void 0,o=l(e.boxBatchIds)?new Uint16Array(e.boxBatchIds):void 0,r=l(e.cylinders)?new Float32Array(e.cylinders):void 0,i=l(e.cylinderBatchIds)?new Uint16Array(e.cylinderBatchIds):void 0,s=l(e.ellipsoids)?new Float32Array(e.ellipsoids):void 0,a=l(e.ellipsoidBatchIds)?new Uint16Array(e.ellipsoidBatchIds):void 0,c=l(e.spheres)?new Float32Array(e.spheres):void 0,d=l(e.sphereBatchIds)?new Uint16Array(e.sphereBatchIds):void 0,u=l(n)?o.length:0,f=l(r)?i.length:0,h=l(s)?a.length:0,p=l(c)?d.length:0,m=j.getUnitBox(),b=z.getUnitCylinder(),k=H.getUnitEllipsoid(),g=m.attributes.position.values,I=b.attributes.position.values,y=k.attributes.position.values,x=g.length*u;x+=I.length*f,x+=y.length*(h+p);let B=m.indices,A=b.indices,w=k.indices,O=B.length*u;O+=A.length*f,O+=w.length*(h+p);let E=new Float32Array(x),v=new Uint16Array(x/3),M=W.createTypedArray(x/3,O),U=u+f+h+p,L=new Uint16Array(U),C=new Array(U),F=new Uint32Array(U),S=new Uint32Array(U),P=new Array(U);re(e.packedBuffer);let X={batchTableColors:new Uint32Array(e.batchTableColors),positions:E,vertexBatchIds:v,indices:M,batchIds:L,batchedIndices:C,indexOffsets:F,indexCounts:S,boundingVolumes:P,positionOffset:0,batchIdIndex:0,indexOffset:0,batchedIndicesOffset:0,modelMatrix:Q,center:K};R(X,n,o,m,oe),R(X,r,i,b,ce),R(X,s,a,k,se),R(X,c,d,k,ie);let D=ae(M.BYTES_PER_ELEMENT,C,P);return t.push(E.buffer,v.buffer,M.buffer),t.push(L.buffer,F.buffer,S.buffer),t.push(D.buffer),{positions:E.buffer,vertexBatchIds:v.buffer,indices:M.buffer,indexOffsets:F.buffer,indexCounts:S.buffer,batchIds:L.buffer,packedBuffer:D.buffer}}var Oe=Y(fe);export{Oe as default};