| 1 |
- import{a as T}from"./chunk-SP6GVFX5.js";import{a as W,b as M}from"./chunk-RELHBJJP.js";import{a as N}from"./chunk-W3WRSDQH.js";import{a as F}from"./chunk-VETUMSV6.js";import{a as J}from"./chunk-AOW426VA.js";import{a as U}from"./chunk-XKBSMKNP.js";import{a as X}from"./chunk-J4ID4JKR.js";import{g as k,h as D,n as z,o as V}from"./chunk-K2IDXOCV.js";import{a as O}from"./chunk-45OWWDV7.js";import{a as H}from"./chunk-JX5O4HI2.js";import{a as R}from"./chunk-FEOWMVRK.js";import{a as K}from"./chunk-CUQT2UK5.js";import{a as p,c as B}from"./chunk-I46SWINN.js";import{a as C}from"./chunk-LNIYJJXS.js";import{a as Q}from"./chunk-4D2ERGZX.js";import{a as g}from"./chunk-NUC3LT2W.js";function I(){this._array=[],this._offset=0,this._length=0}Object.defineProperties(I.prototype,{length:{get:function(){return this._length}}});I.prototype.enqueue=function(a){this._array.push(a),this._length++};I.prototype.dequeue=function(){if(this._length!==0){var a=this._array,n=this._offset,m=a[n];return a[n]=void 0,n++,n>10&&n*2>a.length&&(this._array=a.slice(n),n=0),this._offset=n,this._length--,m}};I.prototype.peek=function(){if(this._length!==0)return this._array[this._offset]};I.prototype.contains=function(a){return this._array.indexOf(a)!==-1};I.prototype.clear=function(){this._array.length=this._offset=this._length=0};I.prototype.sort=function(a){this._offset>0&&(this._array=this._array.slice(this._offset),this._offset=0),this._array.sort(a)};var Y=I;var y={};y.computeHierarchyPackedLength=function(a){for(var n=0,m=[a];m.length>0;){var o=m.pop();if(!!g(o)){n+=2;var f=o.positions,u=o.holes;if(g(f)&&(n+=f.length*p.packedLength),g(u))for(var r=u.length,t=0;t<r;++t)m.push(u[t])}}return n};y.packPolygonHierarchy=function(a,n,m){for(var o=[a];o.length>0;){var f=o.pop();if(!!g(f)){var u=f.positions,r=f.holes;if(n[m++]=g(u)?u.length:0,n[m++]=g(r)?r.length:0,g(u))for(var t=u.length,e=0;e<t;++e,m+=3)p.pack(u[e],n,m);if(g(r))for(var c=r.length,v=0;v<c;++v)o.push(r[v])}}return m};y.unpackPolygonHierarchy=function(a,n){for(var m=a[n++],o=a[n++],f=new Array(m),u=o>0?new Array(o):void 0,r=0;r<m;++r,n+=p.packedLength)f[r]=p.unpack(a,n);for(var t=0;t<o;++t)u[t]=y.unpackPolygonHierarchy(a,n),n=u[t].startingIndex,delete u[t].startingIndex;return{positions:f,holes:u,startingIndex:n}};var G=new p;function j(a,n,m,o){return p.subtract(n,a,G),p.multiplyByScalar(G,m/o,G),p.add(a,G,G),[G.x,G.y,G.z]}y.subdivideLineCount=function(a,n,m){var o=p.distance(a,n),f=o/m,u=Math.max(0,Math.ceil(C.log2(f)));return Math.pow(2,u)};var $=new B,P=new B,rr=new B,er=new p;y.subdivideRhumbLineCount=function(a,n,m,o){var f=a.cartesianToCartographic(n,$),u=a.cartesianToCartographic(m,P),r=new F(f,u,a),t=r.surfaceDistance/o,e=Math.max(0,Math.ceil(C.log2(t)));return Math.pow(2,e)};y.subdivideLine=function(a,n,m,o){var f=y.subdivideLineCount(a,n,m),u=p.distance(a,n),r=u/f;g(o)||(o=[]);var t=o;t.length=f*3;for(var e=0,c=0;c<f;c++){var v=j(a,n,c*r,u);t[e++]=v[0],t[e++]=v[1],t[e++]=v[2]}return t};y.subdivideRhumbLine=function(a,n,m,o,f){var u=a.cartesianToCartographic(n,$),r=a.cartesianToCartographic(m,P),t=new F(u,r,a),e=t.surfaceDistance/o,c=Math.max(0,Math.ceil(C.log2(e))),v=Math.pow(2,c),l=t.surfaceDistance/v;g(f)||(f=[]);var h=f;h.length=v*3;for(var i=0,d=0;d<v;d++){var S=t.interpolateUsingSurfaceDistance(d*l,rr),b=a.cartographicToCartesian(S,er);h[i++]=b.x,h[i++]=b.y,h[i++]=b.z}return h};var ar=new p,tr=new p,nr=new p,vr=new p;y.scaleToGeodeticHeightExtruded=function(a,n,m,o,f){o=Q(o,K.WGS84);var u=ar,r=tr,t=nr,e=vr;if(g(a)&&g(a.attributes)&&g(a.attributes.position))for(var c=a.attributes.position.values,v=c.length/2,l=0;l<v;l+=3)p.fromArray(c,l,t),o.geodeticSurfaceNormal(t,u),e=o.scaleToGeodeticSurface(t,e),r=p.multiplyByScalar(u,m,r),r=p.add(e,r,r),c[l+v]=r.x,c[l+1+v]=r.y,c[l+2+v]=r.z,f&&(e=p.clone(t,e)),r=p.multiplyByScalar(u,n,r),r=p.add(e,r,r),c[l]=r.x,c[l+1]=r.y,c[l+2]=r.z;return a};y.polygonOutlinesFromHierarchy=function(a,n,m){var o=[],f=new Y;f.enqueue(a);for(var u,r,t;f.length!==0;){var e=f.dequeue(),c=e.positions;if(n)for(t=c.length,u=0;u<t;u++)m.scaleToGeodeticSurface(c[u],c[u]);if(c=N(c,p.equalsEpsilon,!0),!(c.length<3)){var v=e.holes?e.holes.length:0;for(u=0;u<v;u++){var l=e.holes[u],h=l.positions;if(n)for(t=h.length,r=0;r<t;++r)m.scaleToGeodeticSurface(h[r],h[r]);if(h=N(h,p.equalsEpsilon,!0),!(h.length<3)){o.push(h);var i=0;for(g(l.holes)&&(i=l.holes.length),r=0;r<i;r++)f.enqueue(l.holes[r])}}o.push(c)}}return o};var cr=new p(6378137,6378137,6378137);y.polygonsFromHierarchy=function(a,n,m,o){var f=[],u=[],r=new Y;for(r.enqueue(a);r.length!==0;){var t=r.dequeue(),e=t.positions,c=t.holes,v,l,h=e.slice();if(m)for(l=e.length,v=0;v<l;v++)o.scaleToGeodeticSurface(e[v],h[v]);var i;if(g(o)&&!p.equals(o._radii,cr)&&(i=C.EPSILON7),e=N(h,p.equalsEpsilon,!0,i),!(e.length<3)){var d=n(e);if(!!g(d)){var S=[],b=M.computeWindingOrder2D(d);b===W.CLOCKWISE&&(d.reverse(),e=e.slice().reverse());var L=e.slice(),A=g(c)?c.length:0,E=[],s;for(v=0;v<A;v++){var _=c[v],w=_.positions;if(m)for(l=w.length,s=0;s<l;++s)o.scaleToGeodeticSurface(w[s],w[s]);if(w=N(w,p.equalsEpsilon,!0,C.EPSILON7),!(w.length<3)){var x=n(w);if(!!g(x)){b=M.computeWindingOrder2D(x),b===W.CLOCKWISE&&(x.reverse(),w=w.slice().reverse()),E.push(w),S.push(L.length),L=L.concat(w),d=d.concat(x);var q=0;for(g(_.holes)&&(q=_.holes.length),s=0;s<q;s++)r.enqueue(_.holes[s])}}}f.push({outerRing:e,holes:E}),u.push({positions:L,positions2D:d,holes:S})}}}return{hierarchy:f,polygons:u}};var ur=new R,ir=new p,fr=new D,or=new O;y.computeBoundingRectangle=function(a,n,m,o,f){for(var u=D.fromAxisAngle(a,o,fr),r=O.fromQuaternion(u,or),t=Number.POSITIVE_INFINITY,e=Number.NEGATIVE_INFINITY,c=Number.POSITIVE_INFINITY,v=Number.NEGATIVE_INFINITY,l=m.length,h=0;h<l;++h){var i=p.clone(m[h],ir);O.multiplyByVector(r,i,i);var d=n(i,ur);g(d)&&(t=Math.min(t,d.x),e=Math.max(e,d.x),c=Math.min(c,d.y),v=Math.max(v,d.y))}return f.x=t,f.y=c,f.width=e-t,f.height=v-c,f};y.createGeometryFromPositions=function(a,n,m,o,f,u){var r=M.triangulate(n.positions2D,n.holes);r.length<3&&(r=[0,1,2]);var t=n.positions;if(o){for(var e=t.length,c=new Array(e*3),v=0,l=0;l<e;l++){var h=t[l];c[v++]=h.x,c[v++]=h.y,c[v++]=h.z}var i=new z({attributes:{position:new V({componentDatatype:H.DOUBLE,componentsPerAttribute:3,values:c})},indices:r,primitiveType:k.TRIANGLES});return f.normal?J.computeNormal(i):i}if(u===T.GEODESIC)return M.computeSubdivision(a,t,r,m);if(u===T.RHUMB)return M.computeRhumbLineSubdivision(a,t,r,m)};var Z=[],hr=new p,mr=new p;y.computeWallGeometry=function(a,n,m,o,f,u){var r,t,e,c,v,l=u?1:0,h=a.length,i=0;if(o)for(t=(h-l)*3*2,r=new Array(t*2),e=0;e<h-l;e++)c=a[e],v=a[(e+1)%h],r[i]=r[i+t]=c.x,++i,r[i]=r[i+t]=c.y,++i,r[i]=r[i+t]=c.z,++i,r[i]=r[i+t]=v.x,++i,r[i]=r[i+t]=v.y,++i,r[i]=r[i+t]=v.z,++i;else{var d=C.chordLength(m,n.maximumRadius),S=0;if(f===T.GEODESIC)for(e=0;e<h;e++)S+=y.subdivideLineCount(a[e],a[(e+1)%h],d);else if(f===T.RHUMB)for(e=0;e<h;e++)S+=y.subdivideRhumbLineCount(n,a[e],a[(e+1)%h],d);for(t=(S+h)*3,r=new Array(t*2),e=0;e<h;e++){c=a[e],v=a[(e+1)%h];var b;f===T.GEODESIC?b=y.subdivideLine(c,v,d,Z):f===T.RHUMB&&(b=y.subdivideRhumbLine(n,c,v,d,Z));for(var L=b.length,A=0;A<L;++A,++i)r[i]=b[A],r[i+t]=b[A];r[i]=v.x,r[i+t]=v.x,++i,r[i]=v.y,r[i+t]=v.y,++i,r[i]=v.z,r[i+t]=v.z,++i}}h=r.length;var E=U.createTypedArray(h/3,h-(a.length-l)*6),s=0;for(h/=6,e=0;e<h;e++){var _=e,w=_+1,x=_+h,q=x+1;c=p.fromArray(r,_*3,hr),v=p.fromArray(r,w*3,mr),!p.equalsEpsilon(c,v,C.EPSILON10,C.EPSILON10)&&(E[s++]=_,E[s++]=x,E[s++]=w,E[s++]=w,E[s++]=x,E[s++]=q)}return new z({attributes:new X({position:new V({componentDatatype:H.DOUBLE,componentsPerAttribute:3,values:r})}),indices:E,primitiveType:k.TRIANGLES})};var Hr=y;export{Hr as a};
|