UNPKG

cong-gis-viewer

Version:

The minimal recommended setup for an app using Cesium with Webpack 5

2 lines 14.2 kB
/*! For license information please see createRectangleGeometry.js.LICENSE.txt */ import{a as J}from"./chunk-BOPLKUOO.js";import{a as Nt}from"./chunk-AYJ4ONX4.js";import{a as zt}from"./chunk-LOUU3TR2.js";import"./chunk-EU6MOGEX.js";import"./chunk-75LITNK5.js";import{a as ut}from"./chunk-P3CVPV5A.js";import{a as X}from"./chunk-IQ5VZFOA.js";import{b as Rt}from"./chunk-NXJBWKCJ.js";import"./chunk-XTD56O4T.js";import"./chunk-MQA5R2TD.js";import"./chunk-BNIMZJFI.js";import{a as yt}from"./chunk-UENNBKKY.js";import{a as Vt}from"./chunk-ZV2BSYVW.js";import{b as Mt,c as Pt,d as q}from"./chunk-3WTHA73F.js";import{d as st}from"./chunk-MEAQKBL7.js";import{f as Lt,i as E,j as At}from"./chunk-RKBLQ2M4.js";import{a as Y}from"./chunk-K3VQHMI6.js";import{a as w,b as _t,c as G,d as H,e as ft}from"./chunk-UTRPTI5S.js";import{a as W}from"./chunk-TFNGIACM.js";import"./chunk-ISVCOS3X.js";import"./chunk-XUAQFAMT.js";import{a as L}from"./chunk-OW23VKVW.js";import{a as St,b as lt}from"./chunk-LKAZ42NI.js";import{e as $}from"./chunk-MYHWD27O.js";var Tt=new w,Bt=new w,Ut=new w,Yt=new w,qt=new E,Zt=new G,Kt=new st,$t=new st;function Xt(t,e){let n=new Pt({attributes:new Vt,primitiveType:Mt.TRIANGLES});return n.attributes.position=new q({componentDatatype:Y.DOUBLE,componentsPerAttribute:3,values:e.positions}),t.normal&&(n.attributes.normal=new q({componentDatatype:Y.FLOAT,componentsPerAttribute:3,values:e.normals})),t.tangent&&(n.attributes.tangent=new q({componentDatatype:Y.FLOAT,componentsPerAttribute:3,values:e.tangents})),t.bitangent&&(n.attributes.bitangent=new q({componentDatatype:Y.FLOAT,componentsPerAttribute:3,values:e.bitangents})),n}function Gt(t,e,n,o){let a=t.length,r=e.normal?new Float32Array(a):void 0,i=e.tangent?new Float32Array(a):void 0,s=e.bitangent?new Float32Array(a):void 0,l=0,u=Yt,c=Ut,m=Bt;if(e.normal||e.tangent||e.bitangent)for(let p=0;p<a;p+=3){let a=w.fromArray(t,p,Tt),h=l+1,f=l+2;m=n.geodeticSurfaceNormal(a,m),(e.tangent||e.bitangent)&&(w.cross(w.UNIT_Z,m,c),ft.multiplyByVector(o,c,c),w.normalize(c,c),e.bitangent&&w.normalize(w.cross(m,c,u),u)),e.normal&&(r[l]=m.x,r[h]=m.y,r[f]=m.z),e.tangent&&(i[l]=c.x,i[h]=c.y,i[f]=c.z),e.bitangent&&(s[l]=u.x,s[h]=u.y,s[f]=u.z),l+=3}return Xt(e,{positions:t,normals:r,tangents:i,bitangents:s})}var Ct=new w,jt=new w;function te(t,e,n){let o=t.length,a=e.normal?new Float32Array(o):void 0,r=e.tangent?new Float32Array(o):void 0,i=e.bitangent?new Float32Array(o):void 0,s=0,l=0,u=0,c=!0,m=Yt,p=Ut,h=Bt;if(e.normal||e.tangent||e.bitangent)for(let f=0;f<o;f+=6){let g=w.fromArray(t,f,Tt),d=w.fromArray(t,(f+6)%o,Ct);if(c){let e=w.fromArray(t,(f+3)%o,jt);w.subtract(d,g,d),w.subtract(e,g,e),h=w.normalize(w.cross(e,d,h),h),c=!1}w.equalsEpsilon(d,g,W.EPSILON10)&&(c=!0),(e.tangent||e.bitangent)&&(m=n.geodeticSurfaceNormal(g,m),e.tangent&&(p=w.normalize(w.cross(m,h,p),p))),e.normal&&(a[s++]=h.x,a[s++]=h.y,a[s++]=h.z,a[s++]=h.x,a[s++]=h.y,a[s++]=h.z),e.tangent&&(r[l++]=p.x,r[l++]=p.y,r[l++]=p.z,r[l++]=p.x,r[l++]=p.y,r[l++]=p.z),e.bitangent&&(i[u++]=m.x,i[u++]=m.y,i[u++]=m.z,i[u++]=m.x,i[u++]=m.y,i[u++]=m.z)}return Xt(e,{positions:t,normals:a,tangents:r,bitangents:i})}function It(t,e){let n=t._vertexFormat,o=t._ellipsoid,a=e.height,r=e.width,i=e.northCap,s=e.southCap,l=0,u=a,c=a,m=0;i&&(l=1,c-=1,m+=1),s&&(u-=1,c-=1,m+=1),m+=r*c;let p=n.position?new Float64Array(3*m):void 0,h=n.st?new Float32Array(2*m):void 0,f=0,g=0,d=Tt,w=Zt,_=Number.MAX_VALUE,y=Number.MAX_VALUE,A=-Number.MAX_VALUE,b=-Number.MAX_VALUE;for(let t=l;t<u;++t)for(let a=0;a<r;++a)J.computePosition(e,o,n.st,t,a,d,w),p[f++]=d.x,p[f++]=d.y,p[f++]=d.z,n.st&&(h[g++]=w.x,h[g++]=w.y,_=Math.min(_,w.x),y=Math.min(y,w.y),A=Math.max(A,w.x),b=Math.max(b,w.y));if(i&&(J.computePosition(e,o,n.st,0,0,d,w),p[f++]=d.x,p[f++]=d.y,p[f++]=d.z,n.st&&(h[g++]=w.x,h[g++]=w.y,_=w.x,y=w.y,A=w.x,b=w.y)),s&&(J.computePosition(e,o,n.st,a-1,0,d,w),p[f++]=d.x,p[f++]=d.y,p[f]=d.z,n.st&&(h[g++]=w.x,h[g]=w.y,_=Math.min(_,w.x),y=Math.min(y,w.y),A=Math.max(A,w.x),b=Math.max(b,w.y))),n.st&&(_<0||y<0||A>1||b>1))for(let t=0;t<h.length;t+=2)h[t]=(h[t]-_)/(A-_),h[t+1]=(h[t+1]-y)/(b-y);let v=Gt(p,n,o,e.tangentRotationMatrix),x=6*(r-1)*(c-1);i&&(x+=3*(r-1)),s&&(x+=3*(r-1));let E,L=yt.createTypedArray(m,x),k=0,F=0;for(E=0;E<c-1;++E){for(let t=0;t<r-1;++t){let t=k,e=t+r,n=e+1,o=t+1;L[F++]=t,L[F++]=e,L[F++]=o,L[F++]=o,L[F++]=e,L[F++]=n,++k}++k}if(i||s){let t,e,n=m-1,o=m-1;if(i&&s&&(n=m-2),k=0,i)for(E=0;E<r-1;E++)t=k,e=t+1,L[F++]=n,L[F++]=t,L[F++]=e,++k;if(s)for(k=(c-1)*r,E=0;E<r-1;E++)t=k,e=t+1,L[F++]=t,L[F++]=o,L[F++]=e,++k}return v.indices=L,n.st&&(v.attributes.st=new q({componentDatatype:Y.FLOAT,componentsPerAttribute:2,values:h})),v}function ht(t,e,n,o,a){return t[e++]=o[n],t[e++]=o[n+1],t[e++]=o[n+2],t[e++]=a[n],t[e++]=a[n+1],t[e]=a[n+2],t}function dt(t,e,n,o){return t[e++]=o[n],t[e++]=o[n+1],t[e++]=o[n],t[e]=o[n+1],t}var Dt=new X;function ee(t,e){let n,o=t._shadowVolume,a=t._offsetAttribute,r=t._vertexFormat,i=t._extrudedHeight,s=t._surfaceHeight,l=t._ellipsoid,u=e.height,c=e.width;if(o){let e=X.clone(r,Dt);e.normal=!0,t._vertexFormat=e}let m=It(t,e);o&&(t._vertexFormat=r);let p=Rt.scaleToGeodeticHeight(m.attributes.position.values,s,l,!1);p=new Float64Array(p);let h=p.length,f=2*h,g=new Float64Array(f);g.set(p);let d=Rt.scaleToGeodeticHeight(m.attributes.position.values,i,l);g.set(d,h),m.attributes.position.values=g;let _,y,A=r.normal?new Float32Array(f):void 0,b=r.tangent?new Float32Array(f):void 0,v=r.bitangent?new Float32Array(f):void 0,x=r.st?new Float32Array(f/3*2):void 0;if(r.normal){for(y=m.attributes.normal.values,A.set(y),n=0;n<h;n++)y[n]=-y[n];A.set(y,h),m.attributes.normal.values=A}if(o){y=m.attributes.normal.values,r.normal||(m.attributes.normal=void 0);let t=new Float32Array(f);for(n=0;n<h;n++)y[n]=-y[n];t.set(y,h),m.attributes.extrudeDirection=new q({componentDatatype:Y.FLOAT,componentsPerAttribute:3,values:t})}let E,L=$(a);if(L){let t=h/3*2,e=new Uint8Array(t);a===ut.TOP?e=e.fill(1,0,t/2):(E=a===ut.NONE?0:1,e=e.fill(E)),m.attributes.applyOffset=new q({componentDatatype:Y.UNSIGNED_BYTE,componentsPerAttribute:1,values:e})}if(r.tangent){let t=m.attributes.tangent.values;for(b.set(t),n=0;n<h;n++)t[n]=-t[n];b.set(t,h),m.attributes.tangent.values=b}if(r.bitangent){let t=m.attributes.bitangent.values;v.set(t),v.set(t,h),m.attributes.bitangent.values=v}r.st&&(_=m.attributes.st.values,x.set(_),x.set(_,h/3*2),m.attributes.st.values=x);let k=m.indices,F=k.length,T=h/3,O=yt.createTypedArray(f/3,2*F);for(O.set(k),n=0;n<F;n+=3)O[n+F]=k[n+2]+T,O[n+1+F]=k[n+1]+T,O[n+2+F]=k[n]+T;m.indices=O;let R=e.northCap,P=e.southCap,N=u,H=2,D=0,j=4,I=4;R&&(H-=1,N-=1,D+=1,j-=2,I-=1),P&&(H-=1,N-=1,D+=1,j-=2,I-=1),D+=H*c+2*N-j;let M=2*(D+I),S=new Float64Array(3*M),V=o?new Float32Array(3*M):void 0,G=L?new Uint8Array(M):void 0,U=r.st?new Float32Array(2*M):void 0,C=a===ut.TOP;L&&!C&&(E=a===ut.ALL?1:0,G=G.fill(E));let Q,J=0,z=0,B=0,K=0,Z=c*N;for(n=0;n<Z;n+=c)Q=3*n,S=ht(S,J,Q,p,d),J+=6,r.st&&(U=dt(U,z,2*n,_),z+=4),o&&(B+=3,V[B++]=y[Q],V[B++]=y[Q+1],V[B++]=y[Q+2]),C&&(G[K++]=1,K+=1);if(P){let t=R?Z+1:Z;for(Q=3*t,n=0;n<2;n++)S=ht(S,J,Q,p,d),J+=6,r.st&&(U=dt(U,z,2*t,_),z+=4),o&&(B+=3,V[B++]=y[Q],V[B++]=y[Q+1],V[B++]=y[Q+2]),C&&(G[K++]=1,K+=1)}else for(n=Z-c;n<Z;n++)Q=3*n,S=ht(S,J,Q,p,d),J+=6,r.st&&(U=dt(U,z,2*n,_),z+=4),o&&(B+=3,V[B++]=y[Q],V[B++]=y[Q+1],V[B++]=y[Q+2]),C&&(G[K++]=1,K+=1);for(n=Z-1;n>0;n-=c)Q=3*n,S=ht(S,J,Q,p,d),J+=6,r.st&&(U=dt(U,z,2*n,_),z+=4),o&&(B+=3,V[B++]=y[Q],V[B++]=y[Q+1],V[B++]=y[Q+2]),C&&(G[K++]=1,K+=1);if(R){let t=Z;for(Q=3*t,n=0;n<2;n++)S=ht(S,J,Q,p,d),J+=6,r.st&&(U=dt(U,z,2*t,_),z+=4),o&&(B+=3,V[B++]=y[Q],V[B++]=y[Q+1],V[B++]=y[Q+2]),C&&(G[K++]=1,K+=1)}else for(n=c-1;n>=0;n--)Q=3*n,S=ht(S,J,Q,p,d),J+=6,r.st&&(U=dt(U,z,2*n,_),z+=4),o&&(B+=3,V[B++]=y[Q],V[B++]=y[Q+1],V[B++]=y[Q+2]),C&&(G[K++]=1,K+=1);let tt=te(S,r,l);r.st&&(tt.attributes.st=new q({componentDatatype:Y.FLOAT,componentsPerAttribute:2,values:U})),o&&(tt.attributes.extrudeDirection=new q({componentDatatype:Y.FLOAT,componentsPerAttribute:3,values:V})),L&&(tt.attributes.applyOffset=new q({componentDatatype:Y.UNSIGNED_BYTE,componentsPerAttribute:1,values:G}));let et,nt,ot,at,rt=yt.createTypedArray(M,6*D);h=S.length/3;let it=0;for(n=0;n<h-1;n+=2){et=n,at=(et+2)%h;let t=w.fromArray(S,3*et,Ct),e=w.fromArray(S,3*at,jt);w.equalsEpsilon(t,e,W.EPSILON10)||(nt=(et+1)%h,ot=(nt+2)%h,rt[it++]=et,rt[it++]=nt,rt[it++]=at,rt[it++]=at,rt[it++]=nt,rt[it++]=ot)}return tt.indices=rt,tt=zt.combineInstances([new Nt({geometry:m}),new Nt({geometry:tt})]),tt[0]}var ne=[new w,new w,new w,new w],Wt=new _t,oe=new _t;function Ht(t,e,n,o,a){if(0===n)return E.clone(t,a);let r=J.computeOptions(t,e,n,0,qt,Wt),i=r.height,s=r.width,l=ne;return J.computePosition(r,o,!1,0,0,l[0]),J.computePosition(r,o,!1,0,s-1,l[1]),J.computePosition(r,o,!1,i-1,0,l[2]),J.computePosition(r,o,!1,i-1,s-1,l[3]),E.fromCartesianArray(l,o,a)}function Q(t){let e=(t=L(t,L.EMPTY_OBJECT)).rectangle;if(lt.typeOf.object("rectangle",e),E._validate(e),e.north<e.south)throw new St("options.rectangle.north must be greater than or equal to options.rectangle.south");let n=L(t.height,0),o=L(t.extrudedHeight,n);this._rectangle=E.clone(e),this._granularity=L(t.granularity,W.RADIANS_PER_DEGREE),this._ellipsoid=H.clone(L(t.ellipsoid,H.default)),this._surfaceHeight=Math.max(n,o),this._rotation=L(t.rotation,0),this._stRotation=L(t.stRotation,0),this._vertexFormat=X.clone(L(t.vertexFormat,X.DEFAULT)),this._extrudedHeight=Math.min(n,o),this._shadowVolume=L(t.shadowVolume,!1),this._workerName="createRectangleGeometry",this._offsetAttribute=t.offsetAttribute,this._rotatedRectangle=void 0,this._textureCoordinateRotationPoints=void 0}Q.packedLength=E.packedLength+H.packedLength+X.packedLength+7,Q.pack=function(t,e,n){return lt.typeOf.object("value",t),lt.defined("array",e),n=L(n,0),E.pack(t._rectangle,e,n),n+=E.packedLength,H.pack(t._ellipsoid,e,n),n+=H.packedLength,X.pack(t._vertexFormat,e,n),n+=X.packedLength,e[n++]=t._granularity,e[n++]=t._surfaceHeight,e[n++]=t._rotation,e[n++]=t._stRotation,e[n++]=t._extrudedHeight,e[n++]=t._shadowVolume?1:0,e[n]=L(t._offsetAttribute,-1),e};var Jt=new E,Qt=H.clone(H.UNIT_SPHERE),tt={rectangle:Jt,ellipsoid:Qt,vertexFormat:Dt,granularity:void 0,height:void 0,rotation:void 0,stRotation:void 0,extrudedHeight:void 0,shadowVolume:void 0,offsetAttribute:void 0};Q.unpack=function(t,e,n){lt.defined("array",t),e=L(e,0);let o=E.unpack(t,e,Jt);e+=E.packedLength;let a=H.unpack(t,e,Qt);e+=H.packedLength;let r=X.unpack(t,e,Dt);e+=X.packedLength;let i=t[e++],s=t[e++],l=t[e++],u=t[e++],c=t[e++],m=1===t[e++],p=t[e];return $(n)?(n._rectangle=E.clone(o,n._rectangle),n._ellipsoid=H.clone(a,n._ellipsoid),n._vertexFormat=X.clone(r,n._vertexFormat),n._granularity=i,n._surfaceHeight=s,n._rotation=l,n._stRotation=u,n._extrudedHeight=c,n._shadowVolume=m,n._offsetAttribute=-1===p?void 0:p,n):(tt.granularity=i,tt.height=s,tt.rotation=l,tt.stRotation=u,tt.extrudedHeight=c,tt.shadowVolume=m,tt.offsetAttribute=-1===p?void 0:p,new Q(tt))},Q.computeRectangle=function(t,e){let n=(t=L(t,L.EMPTY_OBJECT)).rectangle;if(lt.typeOf.object("rectangle",n),E._validate(n),n.north<n.south)throw new St("options.rectangle.north must be greater than or equal to options.rectangle.south");let o=L(t.granularity,W.RADIANS_PER_DEGREE),a=L(t.ellipsoid,H.default);return Ht(n,o,L(t.rotation,0),a,e)};var ie=new ft,Ft=new Lt,ae=new _t;Q.createGeometry=function(t){if(W.equalsEpsilon(t._rectangle.north,t._rectangle.south,W.EPSILON10)||W.equalsEpsilon(t._rectangle.east,t._rectangle.west,W.EPSILON10))return;let e=t._rectangle,n=t._ellipsoid,o=t._rotation,a=t._stRotation,r=t._vertexFormat,i=J.computeOptions(e,t._granularity,o,a,qt,Wt,oe),s=ie;if(0!==a||0!==o){let t=E.center(e,ae),o=n.geodeticSurfaceNormalCartographic(t,Ct);Lt.fromAxisAngle(o,-a,Ft),ft.fromQuaternion(Ft,s)}else ft.clone(ft.IDENTITY,s);let l,u,c=t._surfaceHeight,m=t._extrudedHeight,p=!W.equalsEpsilon(c,m,0,W.EPSILON2);if(i.lonScalar=1/t._rectangle.width,i.latScalar=1/t._rectangle.height,i.tangentRotationMatrix=s,e=t._rectangle,p){l=ee(t,i);let o=st.fromRectangle3D(e,n,c,$t),a=st.fromRectangle3D(e,n,m,Kt);u=st.union(o,a)}else{if(l=It(t,i),l.attributes.position.values=Rt.scaleToGeodeticHeight(l.attributes.position.values,c,n,!1),$(t._offsetAttribute)){let e=l.attributes.position.values.length,n=t._offsetAttribute===ut.NONE?0:1,o=new Uint8Array(e/3).fill(n);l.attributes.applyOffset=new q({componentDatatype:Y.UNSIGNED_BYTE,componentsPerAttribute:1,values:o})}u=st.fromRectangle3D(e,n,c)}return r.position||delete l.attributes.position,new Pt({attributes:l.attributes,indices:l.indices,primitiveType:l.primitiveType,boundingSphere:u,offsetAttribute:t._offsetAttribute})},Q.createShadowVolume=function(t,e,n){let o=t._granularity,a=t._ellipsoid,r=e(o,a),i=n(o,a);return new Q({rectangle:t._rectangle,rotation:t._rotation,ellipsoid:a,stRotation:t._stRotation,granularity:o,extrudedHeight:i,height:r,vertexFormat:X.POSITION_ONLY,shadowVolume:!0})};var vt=new E,se=[new G,new G,new G],re=new At,ce=new _t;function le(t){if(0===t._stRotation)return[0,0,0,1,1,0];let e=E.clone(t._rectangle,vt),n=t._granularity,o=t._ellipsoid,a=Ht(e,n,t._rotation-t._stRotation,o,vt),r=se;r[0].x=a.west,r[0].y=a.south,r[1].x=a.west,r[1].y=a.north,r[2].x=a.east,r[2].y=a.south;let i=t.rectangle,s=At.fromRotation(t._stRotation,re),l=E.center(i,ce);for(let t=0;t<3;++t){let e=r[t];e.x-=l.longitude,e.y-=l.latitude,At.multiplyByVector(s,e,e),e.x+=l.longitude,e.y+=l.latitude,e.x=(e.x-i.west)/i.width,e.y=(e.y-i.south)/i.height}let u=r[0],c=r[1],m=r[2],p=new Array(6);return G.pack(u,p),G.pack(c,p,2),G.pack(m,p,4),p}Object.defineProperties(Q.prototype,{rectangle:{get:function(){return $(this._rotatedRectangle)||(this._rotatedRectangle=Ht(this._rectangle,this._granularity,this._rotation,this._ellipsoid)),this._rotatedRectangle}},textureCoordinateRotationPoints:{get:function(){return $(this._textureCoordinateRotationPoints)||(this._textureCoordinateRotationPoints=le(this)),this._textureCoordinateRotationPoints}}});var Ot=Q;function fe(t,e){return $(e)&&(t=Ot.unpack(t,e)),t._ellipsoid=H.clone(t._ellipsoid),t._rectangle=E.clone(t._rectangle),Ot.createGeometry(t)}var Ye=fe;export{Ye as default};