Agriculture-front-end/public/Cesium/Workers/createSimplePolylineGeometry.js
2023-09-11 21:56:39 +08:00

2 lines
5.3 KiB
JavaScript

define(["./when-b60132fc","./Cartesian2-47311507","./ArcType-29cf2197","./BoundingSphere-561b54d0","./Cartographic-3309dd0d","./Color-5008547b","./ComponentDatatype-c140a87d","./Check-7b2a090c","./GeometryAttribute-3a42bbdc","./GeometryAttributes-252e9929","./IndexDatatype-8a5eead4","./Math-119be1a3","./PolylinePipeline-971d8853","./PrimitiveType-39acab88","./Cartesian4-3ca25aab","./RuntimeError-4a5c8994","./FeatureDetection-c3b71206","./WebGLConstants-4ae0db90","./Transforms-cb0006b0","./buildModuleUrl-3addfe33","./EllipsoidGeodesic-0f19ac62","./EllipsoidRhumbLine-ed1a6bf4","./IntersectionTests-0c6d0a14","./Plane-097b3a8f"],(function(e,o,r,t,a,i,l,n,s,p,d,c,y,u,f,h,C,g,T,m,b,v,P,_){"use strict";function B(e,o,r,t,a,l,n){var s,p=y.PolylinePipeline.numberOfPoints(e,o,a),d=r.red,c=r.green,u=r.blue,f=r.alpha,h=t.red,C=t.green,g=t.blue,T=t.alpha;if(i.Color.equals(r,t)){for(s=0;s<p;s++)l[n++]=i.Color.floatToByte(d),l[n++]=i.Color.floatToByte(c),l[n++]=i.Color.floatToByte(u),l[n++]=i.Color.floatToByte(f);return n}var m=(h-d)/p,b=(C-c)/p,v=(g-u)/p,P=(T-f)/p,_=n;for(s=0;s<p;s++)l[_++]=i.Color.floatToByte(d+s*m),l[_++]=i.Color.floatToByte(c+s*b),l[_++]=i.Color.floatToByte(u+s*v),l[_++]=i.Color.floatToByte(f+s*P);return _}function A(t){var l=(t=e.defaultValue(t,e.defaultValue.EMPTY_OBJECT)).positions,n=t.colors,s=e.defaultValue(t.colorsPerVertex,!1);this._positions=l,this._colors=n,this._colorsPerVertex=s,this._arcType=e.defaultValue(t.arcType,r.ArcType.GEODESIC),this._granularity=e.defaultValue(t.granularity,c.CesiumMath.RADIANS_PER_DEGREE),this._ellipsoid=e.defaultValue(t.ellipsoid,o.Ellipsoid.WGS84),this._workerName="createSimplePolylineGeometry";var p=1+l.length*a.Cartesian3.packedLength;p+=e.defined(n)?1+n.length*i.Color.packedLength:1,this.packedLength=p+o.Ellipsoid.packedLength+3}A.pack=function(r,t,l){var n;l=e.defaultValue(l,0);var s=r._positions,p=s.length;for(t[l++]=p,n=0;n<p;++n,l+=a.Cartesian3.packedLength)a.Cartesian3.pack(s[n],t,l);var d=r._colors;for(p=e.defined(d)?d.length:0,t[l++]=p,n=0;n<p;++n,l+=i.Color.packedLength)i.Color.pack(d[n],t,l);return o.Ellipsoid.pack(r._ellipsoid,t,l),l+=o.Ellipsoid.packedLength,t[l++]=r._colorsPerVertex?1:0,t[l++]=r._arcType,t[l]=r._granularity,t},A.unpack=function(r,t,l){var n;t=e.defaultValue(t,0);var s=r[t++],p=new Array(s);for(n=0;n<s;++n,t+=a.Cartesian3.packedLength)p[n]=a.Cartesian3.unpack(r,t);var d=(s=r[t++])>0?new Array(s):void 0;for(n=0;n<s;++n,t+=i.Color.packedLength)d[n]=i.Color.unpack(r,t);var c=o.Ellipsoid.unpack(r,t);t+=o.Ellipsoid.packedLength;var y=1===r[t++],u=r[t++],f=r[t];return e.defined(l)?(l._positions=p,l._colors=d,l._ellipsoid=c,l._colorsPerVertex=y,l._arcType=u,l._granularity=f,l):new A({positions:p,colors:d,ellipsoid:c,colorsPerVertex:y,arcType:u,granularity:f})};var E=new Array(2),k=new Array(2),D={positions:E,height:k,ellipsoid:void 0,minDistance:void 0,granularity:void 0};return A.createGeometry=function(o){var n,f,h,C,g,T=o._positions,m=o._colors,b=o._colorsPerVertex,v=o._arcType,P=o._granularity,_=o._ellipsoid,A=c.CesiumMath.chordLength(P,_.maximumRadius),G=e.defined(m)&&!b,w=T.length,L=0;if(v===r.ArcType.GEODESIC||v===r.ArcType.RHUMB){var V,S,x;v===r.ArcType.GEODESIC?(V=c.CesiumMath.chordLength(P,_.maximumRadius),S=y.PolylinePipeline.numberOfPoints,x=y.PolylinePipeline.generateArc):(V=P,S=y.PolylinePipeline.numberOfPointsRhumbLine,x=y.PolylinePipeline.generateRhumbArc);var I=y.PolylinePipeline.extractHeights(T,_),R=D;if(v===r.ArcType.GEODESIC?R.minDistance=A:R.granularity=P,R.ellipsoid=_,G){var O=0;for(n=0;n<w-1;n++)O+=S(T[n],T[n+1],V)+1;f=new Float64Array(3*O),C=new Uint8Array(4*O),R.positions=E,R.height=k;var M=0;for(n=0;n<w-1;++n){E[0]=T[n],E[1]=T[n+1],k[0]=I[n],k[1]=I[n+1];var U=x(R);if(e.defined(m)){var N=U.length/3;g=m[n];for(var F=0;F<N;++F)C[M++]=i.Color.floatToByte(g.red),C[M++]=i.Color.floatToByte(g.green),C[M++]=i.Color.floatToByte(g.blue),C[M++]=i.Color.floatToByte(g.alpha)}f.set(U,L),L+=U.length}}else if(R.positions=T,R.height=I,f=new Float64Array(x(R)),e.defined(m)){for(C=new Uint8Array(f.length/3*4),n=0;n<w-1;++n){L=B(T[n],T[n+1],m[n],m[n+1],A,C,L)}var H=m[w-1];C[L++]=i.Color.floatToByte(H.red),C[L++]=i.Color.floatToByte(H.green),C[L++]=i.Color.floatToByte(H.blue),C[L++]=i.Color.floatToByte(H.alpha)}}else{h=G?2*w-2:w,f=new Float64Array(3*h),C=e.defined(m)?new Uint8Array(4*h):void 0;var W=0,Y=0;for(n=0;n<w;++n){var q=T[n];if(G&&n>0&&(a.Cartesian3.pack(q,f,W),W+=3,g=m[n-1],C[Y++]=i.Color.floatToByte(g.red),C[Y++]=i.Color.floatToByte(g.green),C[Y++]=i.Color.floatToByte(g.blue),C[Y++]=i.Color.floatToByte(g.alpha)),G&&n===w-1)break;a.Cartesian3.pack(q,f,W),W+=3,e.defined(m)&&(g=m[n],C[Y++]=i.Color.floatToByte(g.red),C[Y++]=i.Color.floatToByte(g.green),C[Y++]=i.Color.floatToByte(g.blue),C[Y++]=i.Color.floatToByte(g.alpha))}}var z=new p.GeometryAttributes;z.position=new s.GeometryAttribute({componentDatatype:l.ComponentDatatype.DOUBLE,componentsPerAttribute:3,values:f}),e.defined(m)&&(z.color=new s.GeometryAttribute({componentDatatype:l.ComponentDatatype.UNSIGNED_BYTE,componentsPerAttribute:4,values:C,normalize:!0}));var J=2*((h=f.length/3)-1),j=d.IndexDatatype.createTypedArray(h,J),K=0;for(n=0;n<h-1;++n)j[K++]=n,j[K++]=n+1;return new s.Geometry({attributes:z,indices:j,primitiveType:u.PrimitiveType.LINES,boundingSphere:t.BoundingSphere.fromPoints(T)})},function(r,t){return e.defined(t)&&(r=A.unpack(r,t)),r._ellipsoid=o.Ellipsoid.clone(r._ellipsoid),A.createGeometry(r)}}));