createSimplePolylineGeometry.js 5.1 KB

1
  1. define(["./when-92c6cf3c","./Rectangle-bab7abf0","./ArcType-31298545","./buildModuleUrl-3d15f25c","./Cartographic-67e73ef9","./Color-45274500","./ComponentDatatype-81047f82","./Check-52a7d806","./GeometryAttribute-ef657318","./GeometryAttributes-7f66ea53","./IndexDatatype-4c0e98b8","./Math-92c3b5f7","./PolylinePipeline-c0932bf7","./PrimitiveType-cdfe443e","./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,a,o,n,i,l,s,c,p,f,u,y,h,d,g,m,T,v,_,b,w,B,k){"use strict";function E(e,t,r,a,o,i,l){var s,c=u.m.numberOfPoints(e,t,o),p=r.red,f=r.green,y=r.blue,h=r.alpha,d=a.red,g=a.green,m=a.blue,T=a.alpha;if(n.e.equals(r,a)){for(s=0;s<c;s++)i[l++]=n.e.floatToByte(p),i[l++]=n.e.floatToByte(f),i[l++]=n.e.floatToByte(y),i[l++]=n.e.floatToByte(h);return l}var v=(d-p)/c,_=(g-f)/c,b=(m-y)/c,w=(T-h)/c,B=l;for(s=0;s<c;s++)i[B++]=n.e.floatToByte(p+s*v),i[B++]=n.e.floatToByte(f+s*_),i[B++]=n.e.floatToByte(y+s*b),i[B++]=n.e.floatToByte(h+s*w);return B}function L(a){var i=(a=e.u(a,e.u.EMPTY_OBJECT)).positions,s=a.colors,c=e.u(a.colorsPerVertex,!1);if(!e.e(i)||i.length<2)throw new l.t("At least two positions are required.");if(e.e(s)&&(c&&s.length<i.length||!c&&s.length<i.length-1))throw new l.t("colors has an invalid length.");this._positions=i,this._colors=s,this._colorsPerVertex=c,this._arcType=e.u(a.arcType,r.L.GEODESIC),this._granularity=e.u(a.granularity,f.e.RADIANS_PER_DEGREE),this._ellipsoid=e.u(a.ellipsoid,t.t.WGS84),this._workerName="createSimplePolylineGeometry";var p=1+i.length*o.t.packedLength;p+=e.e(s)?1+s.length*n.e.packedLength:1,this.packedLength=p+t.t.packedLength+3}L.pack=function(r,a,i){if(!e.e(r))throw new l.t("value is required");if(!e.e(a))throw new l.t("array is required");i=e.u(i,0);var s,c=r._positions,p=c.length;for(a[i++]=p,s=0;s<p;++s,i+=o.t.packedLength)o.t.pack(c[s],a,i);var f=r._colors;for(p=e.e(f)?f.length:0,a[i++]=p,s=0;s<p;++s,i+=n.e.packedLength)n.e.pack(f[s],a,i);return t.t.pack(r._ellipsoid,a,i),i+=t.t.packedLength,a[i++]=r._colorsPerVertex?1:0,a[i++]=r._arcType,a[i]=r._granularity,a},L.unpack=function(r,a,i){if(!e.e(r))throw new l.t("array is required");a=e.u(a,0);var s,c=r[a++],p=new Array(c);for(s=0;s<c;++s,a+=o.t.packedLength)p[s]=o.t.unpack(r,a);var f=(c=r[a++])>0?new Array(c):void 0;for(s=0;s<c;++s,a+=n.e.packedLength)f[s]=n.e.unpack(r,a);var u=t.t.unpack(r,a);a+=t.t.packedLength;var y=1===r[a++],h=r[a++],d=r[a];return e.e(i)?(i._positions=p,i._colors=f,i._ellipsoid=u,i._colorsPerVertex=y,i._arcType=h,i._granularity=d,i):new L({positions:p,colors:f,ellipsoid:u,colorsPerVertex:y,arcType:h,granularity:d})};var A=new Array(2),P=new Array(2),D={positions:A,height:P,ellipsoid:void 0,minDistance:void 0,granularity:void 0};return L.createGeometry=function(t){var l,h,d,g,m,T=t._positions,v=t._colors,_=t._colorsPerVertex,b=t._arcType,w=t._granularity,B=t._ellipsoid,k=f.e.chordLength(w,B.maximumRadius),L=e.e(v)&&!_,C=T.length,G=0;if(b===r.L.GEODESIC||b===r.L.RHUMB){var x,I,R;b===r.L.GEODESIC?(x=f.e.chordLength(w,B.maximumRadius),I=u.m.numberOfPoints,R=u.m.generateArc):(x=w,I=u.m.numberOfPointsRhumbLine,R=u.m.generateRhumbArc);var S=u.m.extractHeights(T,B),O=D;if(b===r.L.GEODESIC?O.minDistance=k:O.granularity=w,O.ellipsoid=B,L){var U=0;for(l=0;l<C-1;l++)U+=I(T[l],T[l+1],x)+1;h=new Float64Array(3*U),g=new Uint8Array(4*U),O.positions=A,O.height=P;var V=0;for(l=0;l<C-1;++l){A[0]=T[l],A[1]=T[l+1],P[0]=S[l],P[1]=S[l+1];var q=R(O);if(e.e(v)){var N=q.length/3;m=v[l];for(var F=0;F<N;++F)g[V++]=n.e.floatToByte(m.red),g[V++]=n.e.floatToByte(m.green),g[V++]=n.e.floatToByte(m.blue),g[V++]=n.e.floatToByte(m.alpha)}h.set(q,G),G+=q.length}}else if(O.positions=T,O.height=S,h=new Float64Array(R(O)),e.e(v)){for(g=new Uint8Array(h.length/3*4),l=0;l<C-1;++l){G=E(T[l],T[l+1],v[l],v[l+1],k,g,G)}var M=v[C-1];g[G++]=n.e.floatToByte(M.red),g[G++]=n.e.floatToByte(M.green),g[G++]=n.e.floatToByte(M.blue),g[G++]=n.e.floatToByte(M.alpha)}}else{d=L?2*C-2:C,h=new Float64Array(3*d),g=e.e(v)?new Uint8Array(4*d):void 0;var H=0,W=0;for(l=0;l<C;++l){var Y=T[l];if(L&&l>0&&(o.t.pack(Y,h,H),H+=3,m=v[l-1],g[W++]=n.e.floatToByte(m.red),g[W++]=n.e.floatToByte(m.green),g[W++]=n.e.floatToByte(m.blue),g[W++]=n.e.floatToByte(m.alpha)),L&&l===C-1)break;o.t.pack(Y,h,H),H+=3,e.e(v)&&(m=v[l],g[W++]=n.e.floatToByte(m.red),g[W++]=n.e.floatToByte(m.green),g[W++]=n.e.floatToByte(m.blue),g[W++]=n.e.floatToByte(m.alpha))}}var z=new c.a;z.position=new s.o({componentDatatype:i.ComponentDatatype.DOUBLE,componentsPerAttribute:3,values:h}),e.e(v)&&(z.color=new s.o({componentDatatype:i.ComponentDatatype.UNSIGNED_BYTE,componentsPerAttribute:4,values:g,normalize:!0}));var J=2*((d=h.length/3)-1),j=p.IndexDatatype.createTypedArray(d,J),K=0;for(l=0;l<d-1;++l)j[K++]=l,j[K++]=l+1;return new s.I({attributes:z,indices:j,primitiveType:y._0x29ba75.LINES,boundingSphere:a.i.fromPoints(T)})},function(r,a){return e.e(a)&&(r=L.unpack(r,a)),r._ellipsoid=t.t.clone(r._ellipsoid),L.createGeometry(r)}}));