UNPKG

@dp_unity/dpu-gis-viewer

Version:

DPU GIS Viewer version Beta

2 lines 7.97 kB
/*! For license information please see createVerticesFromQuantizedTerrainMesh.js.LICENSE.txt */ import{a as Ct,b as vt}from"./chunk-PJQ53UQY.js";import{a as Mt}from"./chunk-4BYMTYMT.js";import{a as z}from"./chunk-UJMUN4NO.js";import"./chunk-Q5MYX5A2.js";import{a as Wt}from"./chunk-Z7BLUZ7R.js";import{a as X}from"./chunk-34ULWVZF.js";import"./chunk-K2M3OJ7Z.js";import{b as U,g as bt,h as At}from"./chunk-M3A6SPGI.js";import"./chunk-D5HNP2LB.js";import{a as P,b as wt,c as lt,d as pt}from"./chunk-S4VBGY2U.js";import{a as f}from"./chunk-UCTPWOTZ.js";import"./chunk-54PMPXZ4.js";import"./chunk-R62IKKEC.js";import"./chunk-N3A5CZ2S.js";import{a as m}from"./chunk-G75U3WZT.js";import{e as w}from"./chunk-3THTQ4QB.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=i+a,h=o+6*Math.max(0,a-4),u=Lt(t,e),c=u.westIndicesSouthToNorth,l=u.southIndicesEastToWest,d=u.eastIndicesNorthToSouth,m=u.northIndicesWestToEast,I=X.createTypedArray(s,h);Pt(t,e,I,0),T.addSkirtIndices(c,l,d,m,i,I,o),n=r[e]={indices:I,westIndicesSouthToNorth:c,southIndicesEastToWest:l,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,d=1!==c,m=At.clone(t.rectangle),I=m.west,T=m.south,g=m.east,p=m.north,N=pt.clone(t.ellipsoid),y=t.minimumHeight,E=t.maximumHeight,S=t.relativeToCenter,A=bt.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),M=i.subarray(o,2*o),x=i.subarray(2*o,3*o),G=w(a),W=new Array(o),v=new Array(o),F=new Array(o),O=h?new Array(o):[],_=d?new Array(o):[],j=Xt;j.x=Number.POSITIVE_INFINITY,j.y=Number.POSITIVE_INFINITY,j.z=Number.POSITIVE_INFINITY;let H=Zt;H.x=Number.NEGATIVE_INFINITY,H.y=Number.NEGATIVE_INFINITY,H.z=Number.NEGATIVE_INFINITY;let V=Number.POSITIVE_INFINITY,C=Number.NEGATIVE_INFINITY,Z=Number.POSITIVE_INFINITY,B=Number.NEGATIVE_INFINITY;for(let t=0;t<o;++t){let e=k[t],i=M[t],o=e/ht,a=i/ht,s=f.lerp(y,E,x[t]/ht);u.longitude=f.lerp(I,g,o),u.latitude=f.lerp(T,p,a),u.height=s,V=Math.min(u.longitude,V),C=Math.max(u.longitude,C),Z=Math.min(u.latitude,Z),B=Math.max(u.latitude,B);let c=N.cartographicToCartesian(u);W[t]=new lt(o,a),v[t]=s,F[t]=c,h&&(O[t]=(z.geodeticLatitudeToMercatorAngle(u.latitude)-r)*n),d&&(_[t]=N.geodeticSurfaceNormal(c)),U.multiplyByPoint(b,c,D),P.minimumByComponent(D,j,j),P.maximumByComponent(D,H,H)}let L,R=tt(t.westIndices,(function(t,e){return W[t].y-W[e].y})),Q=tt(t.eastIndices,(function(t,e){return W[e].y-W[t].y})),K=tt(t.southIndices,(function(t,e){return W[e].x-W[t].x})),q=tt(t.northIndices,(function(t,e){return W[t].x-W[e].x}));y<0&&(L=new Ct(N).computeHorizonCullingPointPossiblyUnderEllipsoid(S,F,y));let et=y;et=Math.min(et,J(t.westIndices,t.westSkirtHeight,v,W,m,N,b,j,H)),et=Math.min(et,J(t.southIndices,t.southSkirtHeight,v,W,m,N,b,j,H)),et=Math.min(et,J(t.eastIndices,t.eastSkirtHeight,v,W,m,N,b,j,H)),et=Math.min(et,J(t.northIndices,t.northSkirtHeight,v,W,m,N,b,j,H));let rt=new Wt(j,H,S),nt=new vt(S,rt,et,E,A,G,h,d,c,l),it=nt.stride,ot=new Float32Array(o*it+s*it),at=0;for(let t=0;t<o;++t){if(G){let e=2*t;Y.x=a[e],Y.y=a[e+1]}at=nt.encode(ot,at,F[t],W[t],v[t],Y,O[t],_[t])}let st=Math.max(0,2*(s-4)),ut=t.indices.length+3*st,ct=X.createTypedArray(o+s,ut);ct.set(t.indices,0);let dt=1e-4,mt=(C-V)*dt,It=(B-Z)*dt,Tt=-mt,gt=mt,ft=It,wt=-It,Nt=o*it;return $(ot,Nt,R,nt,v,W,a,N,m,t.westSkirtHeight,r,n,Tt,0),Nt+=t.westIndices.length*it,$(ot,Nt,K,nt,v,W,a,N,m,t.southSkirtHeight,r,n,0,wt),Nt+=t.southIndices.length*it,$(ot,Nt,Q,nt,v,W,a,N,m,t.eastSkirtHeight,r,n,gt,0),Nt+=t.eastIndices.length*it,$(ot,Nt,q,nt,v,W,a,N,m,t.northSkirtHeight,r,n,0,ft),Vt.addSkirtIndices(R,K,Q,q,o,ct,t.indices.length),e.push(ot.buffer,ct.buffer),{vertices:ot.buffer,indices:ct.buffer,westIndicesSouthToNorth:R,southIndicesEastToWest:K,eastIndicesNorthToSouth:Q,northIndicesWestToEast:q,vertexStride:it,center:S,minimumHeight:y,maximumHeight:E,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,d=i.south,m=i.east,I=i.west;m<I&&(m+=f.TWO_PI);let T=t.length;for(let i=0;i<T;++i){let T=t[i],g=r[T],w=n[T];u.longitude=f.lerp(I,m,w.x),u.latitude=f.lerp(d,l,w.y),u.height=g-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,d,m,I){let T=w(a),g=h.north,p=h.south,N=h.east,y=h.west;N<y&&(N+=f.TWO_PI);let E=r.length;for(let h=0;h<E;++h){let w=r[h],E=i[w],S=o[w];u.longitude=f.lerp(y,N,S.x)+m,u.latitude=f.lerp(p,g,S.y)+I,u.height=E-c;let A,b,k=s.cartographicToCartesian(u,D);if(T){let t=2*w;Y.x=a[t],Y.y=a[t+1]}n.hasWebMercatorT&&(A=(z.geodeticLatitudeToMercatorAngle(u.latitude)-l)*d),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};