2 lines
5.5 KiB
JavaScript
2 lines
5.5 KiB
JavaScript
define(["./defaultValue-81eec7ed","./Cartesian2-bd414876","./ArcType-fc72c06c","./BoundingSphere-9a3b5656","./Cartesian3-e0307675","./Color-82ef4a75","./ComponentDatatype-aaeec80f","./Check-741c5f3c","./GeometryAttribute-2b42a913","./GeometryAttributes-32b29525","./IndexDatatype-3f3c99e8","./Math-e73894ab","./PolylinePipeline-0e56eeb9","./GeographicProjection-c931c7fb","./Matrix4-4c545f70","./RuntimeError-26acdd3b","./Rectangle-cf3e0e3e","./Transforms-5b829630","./when-422ea0ae","./Resource-8ae1a924","./combine-3c023bda","./WebGLConstants-508b9636","./Matrix2-dc0c61cc","./EllipsoidGeodesic-e7a5ca44","./EllipsoidRhumbLine-592e8885","./IntersectionTests-80510c7b","./Plane-bc8b6777"],(function(e,o,t,r,l,n,a,i,s,c,p,d,f,y,u,h,C,g,T,m,b,P,_,B,A,E,k){"use strict";function G(e,o,t,r,l,a,i){const s=f.PolylinePipeline.numberOfPoints(e,o,l);let c;const p=t.red,d=t.green,y=t.blue,u=t.alpha,h=r.red,C=r.green,g=r.blue,T=r.alpha;if(n.Color.equals(t,r)){for(c=0;c<s;c++)a[i++]=n.Color.floatToByte(p),a[i++]=n.Color.floatToByte(d),a[i++]=n.Color.floatToByte(y),a[i++]=n.Color.floatToByte(u);return i}const m=(h-p)/s,b=(C-d)/s,P=(g-y)/s,_=(T-u)/s;let B=i;for(c=0;c<s;c++)a[B++]=n.Color.floatToByte(p+c*m),a[B++]=n.Color.floatToByte(d+c*b),a[B++]=n.Color.floatToByte(y+c*P),a[B++]=n.Color.floatToByte(u+c*_);return B}function w(r){const a=(r=e.defaultValue(r,e.defaultValue.EMPTY_OBJECT)).positions,i=r.colors,s=e.defaultValue(r.colorsPerVertex,!1);this._positions=a,this._colors=i,this._colorsPerVertex=s,this._arcType=e.defaultValue(r.arcType,t.ArcType.GEODESIC),this._granularity=e.defaultValue(r.granularity,d.CesiumMath.RADIANS_PER_DEGREE),this._ellipsoid=e.defaultValue(r.ellipsoid,o.Ellipsoid.WGS84),this._workerName="createSimplePolylineGeometry";let c=1+a.length*l.Cartesian3.packedLength;c+=e.defined(i)?1+i.length*n.Color.packedLength:1,this.packedLength=c+o.Ellipsoid.packedLength+3}w.pack=function(t,r,a){let i;a=e.defaultValue(a,0);const s=t._positions;let c=s.length;for(r[a++]=c,i=0;i<c;++i,a+=l.Cartesian3.packedLength)l.Cartesian3.pack(s[i],r,a);const p=t._colors;for(c=e.defined(p)?p.length:0,r[a++]=c,i=0;i<c;++i,a+=n.Color.packedLength)n.Color.pack(p[i],r,a);return o.Ellipsoid.pack(t._ellipsoid,r,a),a+=o.Ellipsoid.packedLength,r[a++]=t._colorsPerVertex?1:0,r[a++]=t._arcType,r[a]=t._granularity,r},w.unpack=function(t,r,a){let i;r=e.defaultValue(r,0);let s=t[r++];const c=new Array(s);for(i=0;i<s;++i,r+=l.Cartesian3.packedLength)c[i]=l.Cartesian3.unpack(t,r);s=t[r++];const p=s>0?new Array(s):void 0;for(i=0;i<s;++i,r+=n.Color.packedLength)p[i]=n.Color.unpack(t,r);const d=o.Ellipsoid.unpack(t,r);r+=o.Ellipsoid.packedLength;const f=1===t[r++],y=t[r++],u=t[r];return e.defined(a)?(a._positions=c,a._colors=p,a._ellipsoid=d,a._colorsPerVertex=f,a._arcType=y,a._granularity=u,a):new w({positions:c,colors:p,ellipsoid:d,colorsPerVertex:f,arcType:y,granularity:u})};const D=new Array(2),L=new Array(2),V={positions:D,height:L,ellipsoid:void 0,minDistance:void 0,granularity:void 0};return w.createGeometry=function(o){const i=o._positions,y=o._colors,u=o._colorsPerVertex,h=o._arcType,C=o._granularity,g=o._ellipsoid,T=d.CesiumMath.chordLength(C,g.maximumRadius),m=e.defined(y)&&!u;let b;const P=i.length;let _,B,A,E,k=0;if(h===t.ArcType.GEODESIC||h===t.ArcType.RHUMB){let o,r,l;h===t.ArcType.GEODESIC?(o=d.CesiumMath.chordLength(C,g.maximumRadius),r=f.PolylinePipeline.numberOfPoints,l=f.PolylinePipeline.generateArc):(o=C,r=f.PolylinePipeline.numberOfPointsRhumbLine,l=f.PolylinePipeline.generateRhumbArc);const a=f.PolylinePipeline.extractHeights(i,g),s=V;if(h===t.ArcType.GEODESIC?s.minDistance=T:s.granularity=C,s.ellipsoid=g,m){let t=0;for(b=0;b<P-1;b++)t+=r(i[b],i[b+1],o)+1;_=new Float64Array(3*t),A=new Uint8Array(4*t),s.positions=D,s.height=L;let c=0;for(b=0;b<P-1;++b){D[0]=i[b],D[1]=i[b+1],L[0]=a[b],L[1]=a[b+1];const o=l(s);if(e.defined(y)){const e=o.length/3;E=y[b];for(let o=0;o<e;++o)A[c++]=n.Color.floatToByte(E.red),A[c++]=n.Color.floatToByte(E.green),A[c++]=n.Color.floatToByte(E.blue),A[c++]=n.Color.floatToByte(E.alpha)}_.set(o,k),k+=o.length}}else if(s.positions=i,s.height=a,_=new Float64Array(l(s)),e.defined(y)){for(A=new Uint8Array(_.length/3*4),b=0;b<P-1;++b){k=G(i[b],i[b+1],y[b],y[b+1],T,A,k)}const e=y[P-1];A[k++]=n.Color.floatToByte(e.red),A[k++]=n.Color.floatToByte(e.green),A[k++]=n.Color.floatToByte(e.blue),A[k++]=n.Color.floatToByte(e.alpha)}}else{B=m?2*P-2:P,_=new Float64Array(3*B),A=e.defined(y)?new Uint8Array(4*B):void 0;let o=0,t=0;for(b=0;b<P;++b){const r=i[b];if(m&&b>0&&(l.Cartesian3.pack(r,_,o),o+=3,E=y[b-1],A[t++]=n.Color.floatToByte(E.red),A[t++]=n.Color.floatToByte(E.green),A[t++]=n.Color.floatToByte(E.blue),A[t++]=n.Color.floatToByte(E.alpha)),m&&b===P-1)break;l.Cartesian3.pack(r,_,o),o+=3,e.defined(y)&&(E=y[b],A[t++]=n.Color.floatToByte(E.red),A[t++]=n.Color.floatToByte(E.green),A[t++]=n.Color.floatToByte(E.blue),A[t++]=n.Color.floatToByte(E.alpha))}}const w=new c.GeometryAttributes;w.position=new s.GeometryAttribute({componentDatatype:a.ComponentDatatype.DOUBLE,componentsPerAttribute:3,values:_}),e.defined(y)&&(w.color=new s.GeometryAttribute({componentDatatype:a.ComponentDatatype.UNSIGNED_BYTE,componentsPerAttribute:4,values:A,normalize:!0})),B=_.length/3;const x=2*(B-1),R=p.IndexDatatype.createTypedArray(B,x);let S=0;for(b=0;b<B-1;++b)R[S++]=b,R[S++]=b+1;return new s.Geometry({attributes:w,indices:R,primitiveType:s.PrimitiveType.LINES,boundingSphere:r.BoundingSphere.fromPoints(i)})},function(t,r){return e.defined(r)&&(t=w.unpack(t,r)),t._ellipsoid=o.Ellipsoid.clone(t._ellipsoid),w.createGeometry(t)}}));
|