@dp_unity/dpu-gis-viewer
Version:
DPU GIS Viewer version Beta
2 lines • 6.05 kB
JavaScript
/*! For license information please see createPolylineGeometry.js.LICENSE.txt */
import{a as m}from"./chunk-JXLT7VPX.js";import{a as N}from"./chunk-HQ4YU6WD.js";import{a as U}from"./chunk-RNF7TLFF.js";import"./chunk-E7HC3VTG.js";import{a as k}from"./chunk-6HIVPZ7K.js";import{a as le}from"./chunk-GJI4ZBKE.js";import"./chunk-RDAVO5OM.js";import"./chunk-PY4CW263.js";import"./chunk-RRZIPF5C.js";import{a as se}from"./chunk-34ULWVZF.js";import{a as ce}from"./chunk-24JYWT5N.js";import{a as ne,b as re,c as ie,d as O}from"./chunk-LH3SUUXG.js";import{d as oe}from"./chunk-K2M3OJ7Z.js";import"./chunk-M3A6SPGI.js";import{a as x}from"./chunk-D5HNP2LB.js";import{a as p,d as u}from"./chunk-S4VBGY2U.js";import{a as J}from"./chunk-UCTPWOTZ.js";import"./chunk-54PMPXZ4.js";import"./chunk-R62IKKEC.js";import{a as A}from"./chunk-N3A5CZ2S.js";import{a as V}from"./chunk-G75U3WZT.js";import{e as h}from"./chunk-3THTQ4QB.js";var me=[];function Ae(e,t,r,o,n){let a=me;a.length=n;let i,s=r.red,l=r.green,p=r.blue,c=r.alpha,h=o.red,u=o.green,d=o.blue,f=o.alpha;if(m.equals(r,o)){for(i=0;i<n;i++)a[i]=m.clone(r);return a}let k=(h-s)/n,g=(u-l)/n,w=(d-p)/n,y=(f-c)/n;for(i=0;i<n;i++)a[i]=new m(s+i*k,l+i*g,p+i*w,c+i*y);return a}function G(e){let t=(e=A(e,A.EMPTY_OBJECT)).positions,r=e.colors,o=A(e.width,1),n=A(e.colorsPerVertex,!1);if(!h(t)||t.length<2)throw new V("At least two positions are required.");if("number"!=typeof o)throw new V("width must be a number");if(h(r)&&(n&&r.length<t.length||!n&&r.length<t.length-1))throw new V("colors has an invalid length.");this._positions=t,this._colors=r,this._width=o,this._colorsPerVertex=n,this._vertexFormat=k.clone(A(e.vertexFormat,k.DEFAULT)),this._arcType=A(e.arcType,N.GEODESIC),this._granularity=A(e.granularity,J.RADIANS_PER_DEGREE),this._ellipsoid=u.clone(A(e.ellipsoid,u.default)),this._workerName="createPolylineGeometry";let a=1+t.length*p.packedLength;a+=h(r)?1+r.length*m.packedLength:1,this.packedLength=a+u.packedLength+k.packedLength+4}G.pack=function(e,t,r){if(!h(e))throw new V("value is required");if(!h(t))throw new V("array is required");r=A(r,0);let o,n=e._positions,a=n.length;for(t[r++]=a,o=0;o<a;++o,r+=p.packedLength)p.pack(n[o],t,r);let i=e._colors;for(a=h(i)?i.length:0,t[r++]=a,o=0;o<a;++o,r+=m.packedLength)m.pack(i[o],t,r);return u.pack(e._ellipsoid,t,r),r+=u.packedLength,k.pack(e._vertexFormat,t,r),r+=k.packedLength,t[r++]=e._width,t[r++]=e._colorsPerVertex?1:0,t[r++]=e._arcType,t[r]=e._granularity,t};var de=u.clone(u.UNIT_SPHERE),ue=new k,S={positions:void 0,colors:void 0,ellipsoid:de,vertexFormat:ue,width:void 0,colorsPerVertex:void 0,arcType:void 0,granularity:void 0};G.unpack=function(e,t,r){if(!h(e))throw new V("array is required");t=A(t,0);let o,n=e[t++],a=new Array(n);for(o=0;o<n;++o,t+=p.packedLength)a[o]=p.unpack(e,t);n=e[t++];let i=n>0?new Array(n):void 0;for(o=0;o<n;++o,t+=m.packedLength)i[o]=m.unpack(e,t);let s=u.unpack(e,t,de);t+=u.packedLength;let l=k.unpack(e,t,ue);t+=k.packedLength;let c=e[t++],d=1===e[t++],f=e[t++],g=e[t];return h(r)?(r._positions=a,r._colors=i,r._ellipsoid=u.clone(s,r._ellipsoid),r._vertexFormat=k.clone(l,r._vertexFormat),r._width=c,r._colorsPerVertex=d,r._arcType=f,r._granularity=g,r):(S.positions=a,S.colors=i,S.width=c,S.colorsPerVertex=d,S.arcType=f,S.granularity=g,new G(S))};var pe=new p,ae=new p,fe=new p,he=new p;G.createGeometry=function(e){let t,r,o,n=e._width,a=e._vertexFormat,i=e._colors,s=e._colorsPerVertex,l=e._arcType,c=e._granularity,u=e._ellipsoid,d=[],f=le(e._positions,p.equalsEpsilon,!1,d);if(h(i)&&d.length>0){let e=0,t=d[0];i=i.filter((function(r,o){let n=!1;return n=s?o===t||0===o&&1===t:o+1===t,!n||(e++,t=d[e],!1)}))}let k=f.length;if(k<2||n<=0)return;if(l===N.GEODESIC||l===N.RHUMB){let e,o;l===N.GEODESIC?(e=J.chordLength(c,u.maximumRadius),o=U.numberOfPoints):(e=c,o=U.numberOfPointsRhumbLine);let n=U.extractHeights(f,u);if(h(i)){let n=1;for(t=0;t<k-1;++t)n+=o(f[t],f[t+1],e);let a=new Array(n),l=0;for(t=0;t<k-1;++t){let p=f[t],c=f[t+1],h=i[t],u=o(p,c,e);if(s&&t<n){let e=Ae(p,c,h,i[t+1],u),o=e.length;for(r=0;r<o;++r)a[l++]=e[r]}else for(r=0;r<u;++r)a[l++]=m.clone(h)}a[l]=m.clone(i[i.length-1]),i=a,me.length=0}f=l===N.GEODESIC?U.generateCartesianArc({positions:f,minDistance:e,ellipsoid:u,height:n}):U.generateCartesianRhumbArc({positions:f,granularity:e,ellipsoid:u,height:n})}k=f.length;let g,w=4*k-4,y=new Float64Array(3*w),A=new Float64Array(3*w),_=new Float64Array(3*w),P=new Float32Array(2*w),v=a.st?new Float32Array(2*w):void 0,T=h(i)?new Uint8Array(4*w):void 0,L=0,E=0,j=0,G=0;for(r=0;r<k;++r){let e,t;0===r?(g=pe,p.subtract(f[0],f[1],g),p.add(f[0],g,g)):g=f[r-1],p.clone(g,fe),p.clone(f[r],ae),r===k-1?(g=pe,p.subtract(f[k-1],f[k-2],g),p.add(f[k-1],g,g)):g=f[r+1],p.clone(g,he),h(T)&&(e=0===r||s?i[r]:i[r-1],r!==k-1&&(t=i[r]));let l=r===k-1?2:4;for(o=0===r?2:0;o<l;++o){p.pack(ae,y,L),p.pack(fe,A,L),p.pack(he,_,L),L+=3;let i=o-2<0?-1:1;if(P[E++]=o%2*2-1,P[E++]=i*n,a.st&&(v[j++]=r/(k-1),v[j++]=Math.max(P[E-2],0)),h(T)){let r=o<2?e:t;T[G++]=m.floatToByte(r.red),T[G++]=m.floatToByte(r.green),T[G++]=m.floatToByte(r.blue),T[G++]=m.floatToByte(r.alpha)}}}let S=new ce;S.position=new O({componentDatatype:x.DOUBLE,componentsPerAttribute:3,values:y}),S.prevPosition=new O({componentDatatype:x.DOUBLE,componentsPerAttribute:3,values:A}),S.nextPosition=new O({componentDatatype:x.DOUBLE,componentsPerAttribute:3,values:_}),S.expandAndWidth=new O({componentDatatype:x.FLOAT,componentsPerAttribute:2,values:P}),a.st&&(S.st=new O({componentDatatype:x.FLOAT,componentsPerAttribute:2,values:v})),h(T)&&(S.color=new O({componentDatatype:x.UNSIGNED_BYTE,componentsPerAttribute:4,values:T,normalize:!0}));let b=se.createTypedArray(w,6*k-6),D=0,F=0,V=k-1;for(r=0;r<V;++r)b[F++]=D,b[F++]=D+2,b[F++]=D+1,b[F++]=D+1,b[F++]=D+2,b[F++]=D+3,D+=4;return new ie({attributes:S,indices:b,primitiveType:re.TRIANGLES,boundingSphere:oe.fromPoints(f),geometryType:ne.POLYLINES})};var Q=G;function ge(e,t){return h(t)&&(e=Q.unpack(e,t)),e._ellipsoid=u.clone(e._ellipsoid),Q.createGeometry(e)}var We=ge;export{We as default};