UNPKG

@dp_unity/dpu-gis-viewer

Version:

DPU GIS Viewer version Beta

2 lines 6.44 kB
/*! For license information please see chunk-HQXG4R4L.js.LICENSE.txt */ import{a as wt}from"./chunk-5CC3QRYS.js";import{a as k}from"./chunk-6HIVPZ7K.js";import{a as kt}from"./chunk-34ULWVZF.js";import{a as Ct}from"./chunk-24JYWT5N.js";import{b as dt,c as _t,d as R}from"./chunk-LH3SUUXG.js";import{d as ht}from"./chunk-K2M3OJ7Z.js";import{a as N}from"./chunk-D5HNP2LB.js";import{a as s,c as pt,d as ot}from"./chunk-S4VBGY2U.js";import{a as M}from"./chunk-UCTPWOTZ.js";import{a as p}from"./chunk-N3A5CZ2S.js";import{a as z}from"./chunk-G75U3WZT.js";import{e as E}from"./chunk-3THTQ4QB.js";var yt=new s,vt=new s,Et=new s,Mt=new s,Nt=new s,Rt=new s(1,1,1),Pt=Math.cos,At=Math.sin;function O(t){t=p(t,p.EMPTY_OBJECT);let e=p(t.radii,Rt),i=p(t.innerRadii,e),n=p(t.minimumClock,0),a=p(t.maximumClock,M.TWO_PI),r=p(t.minimumCone,0),o=p(t.maximumCone,M.PI),m=Math.round(p(t.stackPartitions,64)),c=Math.round(p(t.slicePartitions,64)),u=p(t.vertexFormat,k.DEFAULT);if(c<3)throw new z("options.slicePartitions cannot be less than three.");if(m<3)throw new z("options.stackPartitions cannot be less than three.");this._radii=s.clone(e),this._innerRadii=s.clone(i),this._minimumClock=n,this._maximumClock=a,this._minimumCone=r,this._maximumCone=o,this._stackPartitions=m,this._slicePartitions=c,this._vertexFormat=k.clone(u),this._offsetAttribute=t.offsetAttribute,this._workerName="createEllipsoidGeometry"}O.packedLength=2*s.packedLength+k.packedLength+7,O.pack=function(t,e,i){if(!E(t))throw new z("value is required");if(!E(e))throw new z("array is required");return i=p(i,0),s.pack(t._radii,e,i),i+=s.packedLength,s.pack(t._innerRadii,e,i),i+=s.packedLength,k.pack(t._vertexFormat,e,i),i+=k.packedLength,e[i++]=t._minimumClock,e[i++]=t._maximumClock,e[i++]=t._minimumCone,e[i++]=t._maximumCone,e[i++]=t._stackPartitions,e[i++]=t._slicePartitions,e[i]=p(t._offsetAttribute,-1),e};var mt,bt=new s,xt=new s,Ot=new k,y={radii:bt,innerRadii:xt,vertexFormat:Ot,minimumClock:void 0,maximumClock:void 0,minimumCone:void 0,maximumCone:void 0,stackPartitions:void 0,slicePartitions:void 0,offsetAttribute:void 0};O.unpack=function(t,e,i){if(!E(t))throw new z("array is required");e=p(e,0);let n=s.unpack(t,e,bt);e+=s.packedLength;let a=s.unpack(t,e,xt);e+=s.packedLength;let r=k.unpack(t,e,Ot);e+=k.packedLength;let o=t[e++],m=t[e++],c=t[e++],u=t[e++],l=t[e++],f=t[e++],h=t[e];return E(i)?(i._radii=s.clone(n,i._radii),i._innerRadii=s.clone(a,i._innerRadii),i._vertexFormat=k.clone(r,i._vertexFormat),i._minimumClock=o,i._maximumClock=m,i._minimumCone=c,i._maximumCone=u,i._stackPartitions=l,i._slicePartitions=f,i._offsetAttribute=-1===h?void 0:h,i):(y.minimumClock=o,y.maximumClock=m,y.minimumCone=c,y.maximumCone=u,y.stackPartitions=l,y.slicePartitions=f,y.offsetAttribute=-1===h?void 0:h,new O(y))},O.createGeometry=function(t){let e=t._radii;if(e.x<=0||e.y<=0||e.z<=0)return;let i=t._innerRadii;if(i.x<=0||i.y<=0||i.z<=0)return;let n=t._minimumClock,a=t._maximumClock,r=t._minimumCone,o=t._maximumCone,m=t._vertexFormat,c=t._slicePartitions+1,u=t._stackPartitions+1;c=Math.round(c*Math.abs(a-n)/M.TWO_PI),u=Math.round(u*Math.abs(o-r)/M.PI),c<2&&(c=2),u<2&&(u=2);let l,f,p=0,k=[r],h=[n];for(l=0;l<u;l++)k.push(r+l*(o-r)/(u-1));for(k.push(o),f=0;f<c;f++)h.push(n+f*(a-n)/(c-1));h.push(a);let _=k.length,d=h.length,y=0,w=1,A=i.x!==e.x||i.y!==e.y||i.z!==e.z,P=!1,C=!1,x=!1;A&&(w=2,r>0&&(P=!0,y+=c-1),o<Math.PI&&(C=!0,y+=c-1),(a-n)%M.TWO_PI?(x=!0,y+=2*(u-1)+1):y+=1);let v=d*_*w,b=new Float64Array(3*v),O=new Array(v).fill(!1),g=new Array(v).fill(!1),T=c*u*w,L=6*(T+y+1-(c+u)*w),F=kt.createTypedArray(T,L),z=m.normal?new Float32Array(3*v):void 0,I=m.tangent?new Float32Array(3*v):void 0,U=m.bitangent?new Float32Array(3*v):void 0,j=m.st?new Float32Array(2*v):void 0,D=new Array(_),S=new Array(_);for(l=0;l<_;l++)D[l]=At(k[l]),S[l]=Pt(k[l]);let G=new Array(d),W=new Array(d);for(f=0;f<d;f++)W[f]=Pt(h[f]),G[f]=At(h[f]);for(l=0;l<_;l++)for(f=0;f<d;f++)b[p++]=e.x*D[l]*W[f],b[p++]=e.y*D[l]*G[f],b[p++]=e.z*S[l];let Z,B,Y,H,K=v/2;if(A)for(l=0;l<_;l++)for(f=0;f<d;f++)b[p++]=i.x*D[l]*W[f],b[p++]=i.y*D[l]*G[f],b[p++]=i.z*S[l],O[K]=!0,l>0&&l!==_-1&&0!==f&&f!==d-1&&(g[K]=!0),K++;for(p=0,l=1;l<_-2;l++)for(Z=l*d,B=(l+1)*d,f=1;f<d-2;f++)F[p++]=B+f,F[p++]=B+f+1,F[p++]=Z+f+1,F[p++]=B+f,F[p++]=Z+f+1,F[p++]=Z+f;if(A){let t=_*d;for(l=1;l<_-2;l++)for(Z=t+l*d,B=t+(l+1)*d,f=1;f<d-2;f++)F[p++]=B+f,F[p++]=Z+f,F[p++]=Z+f+1,F[p++]=B+f,F[p++]=Z+f+1,F[p++]=B+f+1}if(A){if(P)for(H=_*d,l=1;l<d-2;l++)F[p++]=l,F[p++]=l+1,F[p++]=H+l+1,F[p++]=l,F[p++]=H+l+1,F[p++]=H+l;if(C)for(Y=_*d-d,H=_*d*w-d,l=1;l<d-2;l++)F[p++]=Y+l+1,F[p++]=Y+l,F[p++]=H+l,F[p++]=Y+l+1,F[p++]=H+l,F[p++]=H+l+1}if(x){for(l=1;l<_-2;l++)H=d*_+d*l,Y=d*l,F[p++]=H,F[p++]=Y+d,F[p++]=Y,F[p++]=H,F[p++]=H+d,F[p++]=Y+d;for(l=1;l<_-2;l++)H=d*_+d*(l+1)-1,Y=d*(l+1)-1,F[p++]=Y+d,F[p++]=H,F[p++]=Y,F[p++]=Y+d,F[p++]=H+d,F[p++]=H}let q=new Ct;m.position&&(q.position=new R({componentDatatype:N.DOUBLE,componentsPerAttribute:3,values:b}));let J,Q=0,V=0,X=0,$=0,tt=v/2,et=ot.fromCartesian3(e),it=ot.fromCartesian3(i);if(m.st||m.normal||m.tangent||m.bitangent){for(l=0;l<v;l++){J=O[l]?it:et;let t=s.fromArray(b,3*l,yt),e=J.geodeticSurfaceNormal(t,vt);if(g[l]&&s.negate(e,e),m.st){let t=pt.negate(e,Nt);j[Q++]=Math.atan2(t.y,t.x)/M.TWO_PI+.5,j[Q++]=Math.asin(e.z)/Math.PI+.5}if(m.normal&&(z[V++]=e.x,z[V++]=e.y,z[V++]=e.z),m.tangent||m.bitangent){let t,i=Et,n=0;if(O[l]&&(n=tt),t=!P&&l>=n&&l<n+2*d?s.UNIT_X:s.UNIT_Z,s.cross(t,e,i),s.normalize(i,i),m.tangent&&(I[X++]=i.x,I[X++]=i.y,I[X++]=i.z),m.bitangent){let t=s.cross(e,i,Mt);s.normalize(t,t),U[$++]=t.x,U[$++]=t.y,U[$++]=t.z}}}m.st&&(q.st=new R({componentDatatype:N.FLOAT,componentsPerAttribute:2,values:j})),m.normal&&(q.normal=new R({componentDatatype:N.FLOAT,componentsPerAttribute:3,values:z})),m.tangent&&(q.tangent=new R({componentDatatype:N.FLOAT,componentsPerAttribute:3,values:I})),m.bitangent&&(q.bitangent=new R({componentDatatype:N.FLOAT,componentsPerAttribute:3,values:U}))}if(E(t._offsetAttribute)){let e=b.length,i=t._offsetAttribute===wt.NONE?0:1,n=new Uint8Array(e/3).fill(i);q.applyOffset=new R({componentDatatype:N.UNSIGNED_BYTE,componentsPerAttribute:1,values:n})}return new _t({attributes:q,indices:F,primitiveType:dt.TRIANGLES,boundingSphere:ht.fromEllipsoid(et),offsetAttribute:t._offsetAttribute})},O.getUnitEllipsoid=function(){return E(mt)||(mt=O.createGeometry(new O({radii:new s(1,1,1),vertexFormat:k.POSITION_ONLY}))),mt};var Kt=O;export{Kt as a};