2 lines
6.8 KiB
JavaScript
2 lines
6.8 KiB
JavaScript
/* 2020-9-22 15:23:25 | 版权所有 军懋国兴 */
|
|
define(["./when-cbf8cd21","./Check-35e1a91d","./Math-69007a69","./Cartesian2-43e3a3be","./Transforms-2d1ac5ec","./RuntimeError-f4c64df1","./WebGLConstants-95ceb4e9","./ComponentDatatype-607c9a0c","./GeometryAttribute-2303bbfb","./GeometryAttributes-90846c5f","./IndexDatatype-79bb407c","./IntersectionTests-459f6f08","./Plane-46b5436f","./VertexFormat-fe64931e","./arrayRemoveDuplicates-d96adeb6","./ArcType-2b58731c","./EllipsoidRhumbLine-357c11e7","./EllipsoidGeodesic-007422da","./PolylinePipeline-be169602","./Color-3c471f55"],function(J,y,j,K,Q,e,t,X,Z,$,ee,r,o,h,te,re,a,n,oe,ae){"use strict";var ne=[];function f(e){var t=(e=J.defaultValue(e,J.defaultValue.EMPTY_OBJECT)).positions,r=e.colors,o=J.defaultValue(e.width,1),a=J.defaultValue(e.colorsPerVertex,!1);if(!J.defined(t)||t.length<2)throw new y.DeveloperError("At least two positions are required.");if("number"!=typeof o)throw new y.DeveloperError("width must be a number");if(J.defined(r)&&(a&&r.length<t.length||!a&&r.length<t.length-1))throw new y.DeveloperError("colors has an invalid length.");this._positions=t,this._colors=r,this._width=o,this._colorsPerVertex=a,this._vertexFormat=h.VertexFormat.clone(J.defaultValue(e.vertexFormat,h.VertexFormat.DEFAULT)),this._arcType=J.defaultValue(e.arcType,re.ArcType.GEODESIC),this._granularity=J.defaultValue(e.granularity,j.CesiumMath.RADIANS_PER_DEGREE),this._ellipsoid=K.Ellipsoid.clone(J.defaultValue(e.ellipsoid,K.Ellipsoid.WGS84)),this._workerName="createPolylineGeometry";var n=1+t.length*K.Cartesian3.packedLength;n+=J.defined(r)?1+r.length*ae.Color.packedLength:1,this.packedLength=n+K.Ellipsoid.packedLength+h.VertexFormat.packedLength+4}f.pack=function(e,t,r){if(!J.defined(e))throw new y.DeveloperError("value is required");if(!J.defined(t))throw new y.DeveloperError("array is required");var o;r=J.defaultValue(r,0);var a=e._positions,n=a.length;for(t[r++]=n,o=0;o<n;++o,r+=K.Cartesian3.packedLength)K.Cartesian3.pack(a[o],t,r);var i=e._colors,n=J.defined(i)?i.length:0;for(t[r++]=n,o=0;o<n;++o,r+=ae.Color.packedLength)ae.Color.pack(i[o],t,r);return K.Ellipsoid.pack(e._ellipsoid,t,r),r+=K.Ellipsoid.packedLength,h.VertexFormat.pack(e._vertexFormat,t,r),r+=h.VertexFormat.packedLength,t[r++]=e._width,t[r++]=e._colorsPerVertex?1:0,t[r++]=e._arcType,t[r]=e._granularity,t};var m=K.Ellipsoid.clone(K.Ellipsoid.UNIT_SPHERE),v=new h.VertexFormat,C={positions:void 0,colors:void 0,ellipsoid:m,vertexFormat:v,width:void 0,colorsPerVertex:void 0,arcType:void 0,granularity:void 0};f.unpack=function(e,t,r){if(!J.defined(e))throw new y.DeveloperError("array is required");t=J.defaultValue(t,0);for(var o=e[t++],a=new Array(o),n=0;n<o;++n,t+=K.Cartesian3.packedLength)a[n]=K.Cartesian3.unpack(e,t);var i=0<(o=e[t++])?new Array(o):void 0;for(n=0;n<o;++n,t+=ae.Color.packedLength)i[n]=ae.Color.unpack(e,t);var l=K.Ellipsoid.unpack(e,t,m);t+=K.Ellipsoid.packedLength;var s=h.VertexFormat.unpack(e,t,v);t+=h.VertexFormat.packedLength;var p=e[t++],d=1===e[t++],c=e[t++],u=e[t];return J.defined(r)?(r._positions=a,r._colors=i,r._ellipsoid=K.Ellipsoid.clone(l,r._ellipsoid),r._vertexFormat=h.VertexFormat.clone(s,r._vertexFormat),r._width=p,r._colorsPerVertex=d,r._arcType=c,r._granularity=u,r):(C.positions=a,C.colors=i,C.width=p,C.colorsPerVertex=d,C.arcType=c,C.granularity=u,new f(C))};var ie=new K.Cartesian3,le=new K.Cartesian3,se=new K.Cartesian3,pe=new K.Cartesian3;return f.createGeometry=function(e){var t=e._width,r=e._vertexFormat,o=e._colors,a=e._colorsPerVertex,n=e._arcType,i=e._granularity,l=e._ellipsoid,s=te.arrayRemoveDuplicates(e._positions,K.Cartesian3.equalsEpsilon),p=s.length;if(!(p<2||t<=0)){if(n===re.ArcType.GEODESIC||n===re.ArcType.RHUMB){var d,c=n===re.ArcType.GEODESIC?(d=j.CesiumMath.chordLength(i,l.maximumRadius),oe.PolylinePipeline.numberOfPoints):(d=i,oe.PolylinePipeline.numberOfPointsRhumbLine),u=oe.PolylinePipeline.extractHeights(s,l);if(J.defined(o)){for(var y=1,h=0;h<p-1;++h)y+=c(s[h],s[h+1],d);var f=new Array(y),m=0;for(h=0;h<p-1;++h){var v=s[h],C=s[h+1],g=o[h],w=c(v,C,d);if(a&&h<y)for(var E=function(e,t,r){var o=ne;o.length=r;var a=e.red,n=e.green,i=e.blue,l=e.alpha,s=t.red,p=t.green,d=t.blue,c=t.alpha;if(ae.Color.equals(e,t)){for(m=0;m<r;m++)o[m]=ae.Color.clone(e);return o}for(var u=(s-a)/r,y=(p-n)/r,h=(d-i)/r,f=(c-l)/r,m=0;m<r;m++)o[m]=new ae.Color(a+m*u,n+m*y,i+m*h,l+m*f);return o}(g,o[h+1],w),b=E.length,_=0;_<b;++_)f[m++]=E[_];else for(_=0;_<w;++_)f[m++]=ae.Color.clone(g)}f[m]=ae.Color.clone(o[o.length-1]),o=f,ne.length=0}s=n===re.ArcType.GEODESIC?oe.PolylinePipeline.generateCartesianArc({positions:s,minDistance:d,ellipsoid:l,height:u}):oe.PolylinePipeline.generateCartesianRhumbArc({positions:s,granularity:d,ellipsoid:l,height:u})}var A,P,D,T=4*(p=s.length)-4,x=new Float64Array(3*T),k=new Float64Array(3*T),V=new Float64Array(3*T),L=new Float32Array(2*T),F=r.st?new Float32Array(2*T):void 0,G=J.defined(o)?new Uint8Array(4*T):void 0,O=0,R=0,I=0,S=0;for(_=0;_<p;++_){0===_?(A=ie,K.Cartesian3.subtract(s[0],s[1],A),K.Cartesian3.add(s[0],A,A)):A=s[_-1],K.Cartesian3.clone(A,se),K.Cartesian3.clone(s[_],le),_===p-1?(A=ie,K.Cartesian3.subtract(s[p-1],s[p-2],A),K.Cartesian3.add(s[p-1],A,A)):A=s[_+1],K.Cartesian3.clone(A,pe),J.defined(G)&&(P=0===_||a?o[_]:o[_-1],_!==p-1&&(D=o[_]));for(var B=_===p-1?2:4,U=0===_?2:0;U<B;++U){K.Cartesian3.pack(le,x,O),K.Cartesian3.pack(se,k,O),K.Cartesian3.pack(pe,V,O),O+=3;var N,q=U-2<0?-1:1;L[R++]=U%2*2-1,L[R++]=q*t,r.st&&(F[I++]=_/(p-1),F[I++]=Math.max(L[R-2],0)),J.defined(G)&&(N=U<2?P:D,G[S++]=ae.Color.floatToByte(N.red),G[S++]=ae.Color.floatToByte(N.green),G[S++]=ae.Color.floatToByte(N.blue),G[S++]=ae.Color.floatToByte(N.alpha))}}var M=new $.GeometryAttributes;M.position=new Z.GeometryAttribute({componentDatatype:X.ComponentDatatype.DOUBLE,componentsPerAttribute:3,values:x}),M.prevPosition=new Z.GeometryAttribute({componentDatatype:X.ComponentDatatype.DOUBLE,componentsPerAttribute:3,values:k}),M.nextPosition=new Z.GeometryAttribute({componentDatatype:X.ComponentDatatype.DOUBLE,componentsPerAttribute:3,values:V}),M.expandAndWidth=new Z.GeometryAttribute({componentDatatype:X.ComponentDatatype.FLOAT,componentsPerAttribute:2,values:L}),r.st&&(M.st=new Z.GeometryAttribute({componentDatatype:X.ComponentDatatype.FLOAT,componentsPerAttribute:2,values:F})),J.defined(G)&&(M.color=new Z.GeometryAttribute({componentDatatype:X.ComponentDatatype.UNSIGNED_BYTE,componentsPerAttribute:4,values:G,normalize:!0}));var H=ee.IndexDatatype.createTypedArray(T,6*p-6),W=0,Y=0,z=p-1;for(_=0;_<z;++_)H[Y++]=W,H[Y++]=W+2,H[Y++]=W+1,H[Y++]=W+1,H[Y++]=W+2,H[Y++]=W+3,W+=4;return new Z.Geometry({attributes:M,indices:H,primitiveType:Z.PrimitiveType.TRIANGLES,boundingSphere:Q.BoundingSphere.fromPoints(s),geometryType:Z.GeometryType.POLYLINES})}},function(e,t){return J.defined(t)&&(e=f.unpack(e,t)),e._ellipsoid=K.Ellipsoid.clone(e._ellipsoid),f.createGeometry(e)}}); |