createPolylineGeometry.js 6.9 KB

1
  1. define(["./when-92c6cf3c","./Rectangle-bab7abf0","./ArcType-31298545","./arrayRemoveDuplicates-f7eaafa2","./buildModuleUrl-3d15f25c","./Cartographic-67e73ef9","./Color-45274500","./ComponentDatatype-81047f82","./Check-52a7d806","./GeometryAttribute-ef657318","./GeometryAttributes-7f66ea53","./IndexDatatype-4c0e98b8","./Math-92c3b5f7","./PolylinePipeline-c0932bf7","./PrimitiveType-cdfe443e","./VertexFormat-f496a3f1","./Intersect-b97e930a","./Event-3390cd7d","./RuntimeError-c6a62a80","./FeatureDetection-067cb23c","./WebGLConstants-71f10989","./Cartesian2-6033fa5d","./Cartesian4-ad128b5d","./EllipsoidGeodesic-04ac0e77","./EllipsoidRhumbLine-8847d1a1","./IntersectionTests-a42760d9","./Plane-f8d22530"],(function(e,t,r,o,a,n,i,l,s,c,p,d,u,h,f,y,m,v,w,_,g,b,L,D,E,A,P){"use strict";var x=[];function k(e,t,r,o,a){var n=x;n.length=a;var l,s=r.red,c=r.green,p=r.blue,d=r.alpha,u=o.red,h=o.green,f=o.blue,y=o.alpha;if(i.e.equals(r,o)){for(l=0;l<a;l++)n[l]=i.e.clone(r);return n}var m=(u-s)/a,v=(h-c)/a,w=(f-p)/a,_=(y-d)/a;for(l=0;l<a;l++)n[l]=new i.e(s+l*m,c+l*v,p+l*w,d+l*_);return n}function T(o){var l=(o=e.u(o,e.u.EMPTY_OBJECT)).positions,c=o.colors,p=e.u(o.width,1),d=e.u(o.hMax,-1),h=e.u(o.colorsPerVertex,!1);if(!e.e(l)||l.length<2)throw new s.t("At least two positions are required.");if("number"!=typeof p)throw new s.t("width must be a number");if(e.e(c)&&(h&&c.length<l.length||!h&&c.length<l.length-1))throw new s.t("colors has an invalid length.");this._positions=l,this._colors=c,this._width=p,this._hMax=d,this._colorsPerVertex=h,this._dist=o.dist,this._period=o.period,this._vertexFormat=y.n.clone(e.u(o.vertexFormat,y.n.DEFAULT)),this._followSurface=e.u(o.followSurface,!0),e.e(o.followSurface)&&(function(t,r){if(!e.e(t)||!e.e(r))throw new s.t("identifier and message are required.");a.e(t,r)}("PolylineGeometry.followSurface","PolylineGeometry.followSurface is deprecated and will be removed in Cesium 1.55. Use PolylineGeometry.arcType instead."),o.arcType=o.followSurface?r.L.GEODESIC:r.L.NONE),this._arcType=e.u(o.arcType,r.L.GEODESIC),this._followSurface=this._arcType!==r.L.NONE,this._granularity=e.u(o.granularity,u.e.RADIANS_PER_DEGREE),this._ellipsoid=t.t.clone(e.u(o.ellipsoid,t.t.WGS84)),this._workerName="createPolylineGeometry";var f=1+l.length*n.t.packedLength;f+=e.e(c)?1+c.length*i.e.packedLength:1,this.packedLength=f+t.t.packedLength+y.n.packedLength+4+2}T.pack=function(r,o,a){if(!e.e(r))throw new s.t("value is required");if(!e.e(o))throw new s.t("array is required");a=e.u(a,0);var l,c=r._positions,p=c.length;for(o[a++]=p,l=0;l<p;++l,a+=n.t.packedLength)n.t.pack(c[l],o,a);var d=r._colors;for(p=e.e(d)?d.length:0,o[a++]=p,l=0;l<p;++l,a+=i.e.packedLength)i.e.pack(d[l],o,a);return t.t.pack(r._ellipsoid,o,a),a+=t.t.packedLength,y.n.pack(r._vertexFormat,o,a),a+=y.n.packedLength,o[a++]=r._width,o[a++]=r._colorsPerVertex?1:0,o[a++]=r._arcType,o[a++]=r._granularity,o[a++]=r._hMax,o[a++]=r._dist,o[a]=r._period,o};var C=t.t.clone(t.t.UNIT_SPHERE),F=new y.n,G={positions:void 0,colors:void 0,ellipsoid:C,vertexFormat:F,width:void 0,colorsPerVertex:void 0,arcType:void 0,granularity:void 0};T.unpack=function(r,o,a){if(!e.e(r))throw new s.t("array is required");o=e.u(o,0);var l,c=r[o++],p=new Array(c);for(l=0;l<c;++l,o+=n.t.packedLength)p[l]=n.t.unpack(r,o);var d=(c=r[o++])>0?new Array(c):void 0;for(l=0;l<c;++l,o+=i.e.packedLength)d[l]=i.e.unpack(r,o);var u=t.t.unpack(r,o,C);o+=t.t.packedLength;var h=y.n.unpack(r,o,F);o+=y.n.packedLength;var f=r[o++],m=1===r[o++],v=r[o++],w=r[o++],_=r[o++],g=1==r[o++],b=r[o];return e.e(a)?(a._positions=p,a._colors=d,a._ellipsoid=t.t.clone(u,a._ellipsoid),a._vertexFormat=y.n.clone(h,a._vertexFormat),a._width=f,a._colorsPerVertex=m,a._arcType=v,a._granularity=w,a._hMax=_,a._dist=g,a._period=b,a):(G.positions=p,G.colors=d,G.width=f,G.colorsPerVertex=m,G.arcType=v,G.granularity=w,G.hMax=_,G.dist=g,G.period=b,new T(G))};var S=new n.t,O=new n.t,I=new n.t,M=new n.t;return T.createGeometry=function(t){var s,y,m,v=t._width,w=t._hMax,_=t._vertexFormat,g=t._colors,b=t._colorsPerVertex,L=t._arcType,D=t._granularity,E=t._ellipsoid,A=t._dist,P=t._period,T=o.D(t._positions,n.t.equalsEpsilon),C=T.length;if(!(C<2||v<=0)){if(L===r.L.GEODESIC||L===r.L.RHUMB){var F,G;L===r.L.GEODESIC?(F=u.e.chordLength(D,E.maximumRadius),G=h.m.numberOfPoints):(F=D,G=h.m.numberOfPointsRhumbLine);var R=h.m.extractHeights(T,E);if(e.e(g)){var N=1;for(s=0;s<C-1;++s)N+=G(T[s],T[s+1],F);var B=new Array(N),U=0;for(s=0;s<C-1;++s){var V=T[s],q=T[s+1],H=g[s],W=G(V,q,F);if(b&&s<N){var Y=k(0,0,H,g[s+1],W),z=Y.length;for(y=0;y<z;++y)B[U++]=Y[y]}else for(y=0;y<W;++y)B[U++]=i.e.clone(H)}B[U]=i.e.clone(g[g.length-1]),g=B,x.length=0}T=L===r.L.GEODESIC?h.m.generateCartesianArc({positions:T,minDistance:F,ellipsoid:E,height:R,hMax:w}):h.m.generateCartesianRhumbArc({positions:T,granularity:F,ellipsoid:E,height:R})}var J,j=4*(C=T.length)-4,K=new Float64Array(3*j),Q=new Float64Array(3*j),X=new Float64Array(3*j),Z=new Float32Array(2*j),$=_.st?new Float32Array(2*j):void 0,ee=e.e(g)?new Uint8Array(4*j):void 0,te=A?new Float32Array(3*j):void 0,re=0,oe=0,ae=0,ne=0,ie=0,le=0;for(y=0;y<C;++y){var se,ce;0===y?(J=S,n.t.subtract(T[0],T[1],J),n.t.add(T[0],J,J)):J=T[y-1],n.t.clone(J,I),n.t.clone(T[y],O),y===C-1?(J=S,n.t.subtract(T[C-1],T[C-2],J),n.t.add(T[C-1],J,J)):J=T[y+1],n.t.clone(J,M),e.e(ee)&&(se=0===y||b?g[y]:g[y-1],y!==C-1&&(ce=g[y]));var pe=y===C-1?2:4;for(m=0===y?2:0;m<pe;++m){n.t.pack(O,K,re),n.t.pack(I,Q,re),n.t.pack(M,X,re),re+=3;var de=m-2<0?-1:1,ue=m%2*2-1,he=ue*y/C;if(Z[oe++]=w>0?he:ue,Z[oe++]=de*v,_.st&&($[ae++]=y/(C-1),$[ae++]=Math.max(Z[oe-2],0)),e.e(ee)){var fe=m<2?se:ce;ee[ne++]=i.e.floatToByte(fe.red),ee[ne++]=i.e.floatToByte(fe.green),ee[ne++]=i.e.floatToByte(fe.blue),ee[ne++]=i.e.floatToByte(fe.alpha)}A&&(te[3*ie]=le,ie++)}le+=n.t.distance(J,T[y])}if(A){var ye=le,me=Math.random()*(P>0?P:ye);for(y=0;y<j;y++)te[3*y+1]=ye,te[3*y+2]=me}var ve=new p.a;ve.position=new c.o({componentDatatype:l.ComponentDatatype.DOUBLE,componentsPerAttribute:3,values:K}),ve.prevPosition=new c.o({componentDatatype:l.ComponentDatatype.DOUBLE,componentsPerAttribute:3,values:Q}),ve.nextPosition=new c.o({componentDatatype:l.ComponentDatatype.DOUBLE,componentsPerAttribute:3,values:X}),ve.expandAndWidth=new c.o({componentDatatype:l.ComponentDatatype.FLOAT,componentsPerAttribute:2,values:Z}),_.st&&(ve.st=new c.o({componentDatatype:l.ComponentDatatype.FLOAT,componentsPerAttribute:2,values:$})),e.e(ee)&&(ve.color=new c.o({componentDatatype:l.ComponentDatatype.UNSIGNED_BYTE,componentsPerAttribute:4,values:ee,normalize:!0})),A&&(ve.dist=new c.o({componentDatatype:l.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:te}));var we=d.IndexDatatype.createTypedArray(j,6*C-6),_e=0,ge=0,be=C-1;for(y=0;y<be;++y)we[ge++]=_e,we[ge++]=_e+2,we[ge++]=_e+1,we[ge++]=_e+1,we[ge++]=_e+2,we[ge++]=_e+3,_e+=4;return new c.I({attributes:ve,indices:we,primitiveType:f._0x29ba75.TRIANGLES,boundingSphere:a.i.fromPoints(T),geometryType:c.Me.POLYLINES})}},function(r,o){return e.e(o)&&(r=T.unpack(r,o)),r._ellipsoid=t.t.clone(r._ellipsoid),T.createGeometry(r)}}));