qa-prevention-gwj-vue/static/map/cesium91/CesiumUnminified/Workers/createPolylineGeometry.js

2 lines
6.7 KiB
JavaScript

define(["./defaultValue-81eec7ed","./Cartesian2-bd414876","./ArcType-fc72c06c","./arrayRemoveDuplicates-cea3b206","./BoundingSphere-9a3b5656","./Cartesian3-e0307675","./Color-82ef4a75","./ComponentDatatype-aaeec80f","./Check-741c5f3c","./GeometryAttribute-2b42a913","./GeometryAttributes-32b29525","./IndexDatatype-3f3c99e8","./Math-e73894ab","./PolylinePipeline-0e56eeb9","./VertexFormat-d50a69ba","./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,t,o,n,r,a,i,l,s,c,p,d,u,y,m,f,h,C,g,b,_,A,E,P,w,x,T,k,D){"use strict";const V=[];function v(e,t,o,n,r){const a=V;let l;a.length=r;const s=o.red,c=o.green,p=o.blue,d=o.alpha,u=n.red,y=n.green,m=n.blue,f=n.alpha;if(i.Color.equals(o,n)){for(l=0;l<r;l++)a[l]=i.Color.clone(o);return a}const h=(u-s)/r,C=(y-c)/r,g=(m-p)/r,b=(f-d)/r;for(l=0;l<r;l++)a[l]=new i.Color(s+l*h,c+l*C,p+l*g,d+l*b);return a}function L(n){const r=(n=e.defaultValue(n,e.defaultValue.EMPTY_OBJECT)).positions,l=n.colors,s=e.defaultValue(n.width,1),c=e.defaultValue(n.colorsPerVertex,!1);this._positions=r,this._colors=l,this._width=s,this._colorsPerVertex=c,this._vertexFormat=m.VertexFormat.clone(e.defaultValue(n.vertexFormat,m.VertexFormat.DEFAULT)),this._arcType=e.defaultValue(n.arcType,o.ArcType.GEODESIC),this._granularity=e.defaultValue(n.granularity,u.CesiumMath.RADIANS_PER_DEGREE),this._ellipsoid=t.Ellipsoid.clone(e.defaultValue(n.ellipsoid,t.Ellipsoid.WGS84)),this._workerName="createPolylineGeometry";let p=1+r.length*a.Cartesian3.packedLength;p+=e.defined(l)?1+l.length*i.Color.packedLength:1,this.packedLength=p+t.Ellipsoid.packedLength+m.VertexFormat.packedLength+4}L.pack=function(o,n,r){let l;r=e.defaultValue(r,0);const s=o._positions;let c=s.length;for(n[r++]=c,l=0;l<c;++l,r+=a.Cartesian3.packedLength)a.Cartesian3.pack(s[l],n,r);const p=o._colors;for(c=e.defined(p)?p.length:0,n[r++]=c,l=0;l<c;++l,r+=i.Color.packedLength)i.Color.pack(p[l],n,r);return t.Ellipsoid.pack(o._ellipsoid,n,r),r+=t.Ellipsoid.packedLength,m.VertexFormat.pack(o._vertexFormat,n,r),r+=m.VertexFormat.packedLength,n[r++]=o._width,n[r++]=o._colorsPerVertex?1:0,n[r++]=o._arcType,n[r]=o._granularity,n};const F=t.Ellipsoid.clone(t.Ellipsoid.UNIT_SPHERE),G=new m.VertexFormat,R={positions:void 0,colors:void 0,ellipsoid:F,vertexFormat:G,width:void 0,colorsPerVertex:void 0,arcType:void 0,granularity:void 0};L.unpack=function(o,n,r){let l;n=e.defaultValue(n,0);let s=o[n++];const c=new Array(s);for(l=0;l<s;++l,n+=a.Cartesian3.packedLength)c[l]=a.Cartesian3.unpack(o,n);s=o[n++];const p=s>0?new Array(s):void 0;for(l=0;l<s;++l,n+=i.Color.packedLength)p[l]=i.Color.unpack(o,n);const d=t.Ellipsoid.unpack(o,n,F);n+=t.Ellipsoid.packedLength;const u=m.VertexFormat.unpack(o,n,G);n+=m.VertexFormat.packedLength;const y=o[n++],f=1===o[n++],h=o[n++],C=o[n];return e.defined(r)?(r._positions=c,r._colors=p,r._ellipsoid=t.Ellipsoid.clone(d,r._ellipsoid),r._vertexFormat=m.VertexFormat.clone(u,r._vertexFormat),r._width=y,r._colorsPerVertex=f,r._arcType=h,r._granularity=C,r):(R.positions=c,R.colors=p,R.width=y,R.colorsPerVertex=f,R.arcType=h,R.granularity=C,new L(R))};const O=new a.Cartesian3,S=new a.Cartesian3,B=new a.Cartesian3,I=new a.Cartesian3;return L.createGeometry=function(t){const s=t._width,m=t._vertexFormat;let f=t._colors;const h=t._colorsPerVertex,C=t._arcType,g=t._granularity,b=t._ellipsoid;let _,A,E;const P=[];let w=n.arrayRemoveDuplicates(t._positions,a.Cartesian3.equalsEpsilon,!1,P);if(e.defined(f)&&P.length>0){let e=0,t=P[0];f=f.filter((function(o,n){let r=!1;return r=h?n===t||0===n&&1===t:n+1===t,!r||(e++,t=P[e],!1)}))}let x=w.length;if(x<2||s<=0)return;if(C===o.ArcType.GEODESIC||C===o.ArcType.RHUMB){let t,n;C===o.ArcType.GEODESIC?(t=u.CesiumMath.chordLength(g,b.maximumRadius),n=y.PolylinePipeline.numberOfPoints):(t=g,n=y.PolylinePipeline.numberOfPointsRhumbLine);const r=y.PolylinePipeline.extractHeights(w,b);if(e.defined(f)){let e=1;for(_=0;_<x-1;++_)e+=n(w[_],w[_+1],t);const o=new Array(e);let r=0;for(_=0;_<x-1;++_){const a=w[_],l=w[_+1],s=f[_],c=n(a,l,t);if(h&&_<e){const e=v(0,0,s,f[_+1],c),t=e.length;for(A=0;A<t;++A)o[r++]=e[A]}else for(A=0;A<c;++A)o[r++]=i.Color.clone(s)}o[r]=i.Color.clone(f[f.length-1]),f=o,V.length=0}w=C===o.ArcType.GEODESIC?y.PolylinePipeline.generateCartesianArc({positions:w,minDistance:t,ellipsoid:b,height:r}):y.PolylinePipeline.generateCartesianRhumbArc({positions:w,granularity:t,ellipsoid:b,height:r})}x=w.length;const T=4*x-4,k=new Float64Array(3*T),D=new Float64Array(3*T),L=new Float64Array(3*T),F=new Float32Array(2*T),G=m.st?new Float32Array(2*T):void 0,R=e.defined(f)?new Uint8Array(4*T):void 0;let M,U=0,N=0,H=0,W=0;for(A=0;A<x;++A){let t,o;0===A?(M=O,a.Cartesian3.subtract(w[0],w[1],M),a.Cartesian3.add(w[0],M,M)):M=w[A-1],a.Cartesian3.clone(M,B),a.Cartesian3.clone(w[A],S),A===x-1?(M=O,a.Cartesian3.subtract(w[x-1],w[x-2],M),a.Cartesian3.add(w[x-1],M,M)):M=w[A+1],a.Cartesian3.clone(M,I),e.defined(R)&&(t=0===A||h?f[A]:f[A-1],A!==x-1&&(o=f[A]));const n=A===x-1?2:4;for(E=0===A?2:0;E<n;++E){a.Cartesian3.pack(S,k,U),a.Cartesian3.pack(B,D,U),a.Cartesian3.pack(I,L,U),U+=3;const n=E-2<0?-1:1;if(F[N++]=E%2*2-1,F[N++]=n*s,m.st&&(G[H++]=A/(x-1),G[H++]=Math.max(F[N-2],0)),e.defined(R)){const e=E<2?t:o;R[W++]=i.Color.floatToByte(e.red),R[W++]=i.Color.floatToByte(e.green),R[W++]=i.Color.floatToByte(e.blue),R[W++]=i.Color.floatToByte(e.alpha)}}}const Y=new p.GeometryAttributes;Y.position=new c.GeometryAttribute({componentDatatype:l.ComponentDatatype.DOUBLE,componentsPerAttribute:3,values:k}),Y.prevPosition=new c.GeometryAttribute({componentDatatype:l.ComponentDatatype.DOUBLE,componentsPerAttribute:3,values:D}),Y.nextPosition=new c.GeometryAttribute({componentDatatype:l.ComponentDatatype.DOUBLE,componentsPerAttribute:3,values:L}),Y.expandAndWidth=new c.GeometryAttribute({componentDatatype:l.ComponentDatatype.FLOAT,componentsPerAttribute:2,values:F}),m.st&&(Y.st=new c.GeometryAttribute({componentDatatype:l.ComponentDatatype.FLOAT,componentsPerAttribute:2,values:G})),e.defined(R)&&(Y.color=new c.GeometryAttribute({componentDatatype:l.ComponentDatatype.UNSIGNED_BYTE,componentsPerAttribute:4,values:R,normalize:!0}));const q=d.IndexDatatype.createTypedArray(T,6*x-6);let j=0,z=0;const J=x-1;for(A=0;A<J;++A)q[z++]=j,q[z++]=j+2,q[z++]=j+1,q[z++]=j+1,q[z++]=j+2,q[z++]=j+3,j+=4;return new c.Geometry({attributes:Y,indices:q,primitiveType:c.PrimitiveType.TRIANGLES,boundingSphere:r.BoundingSphere.fromPoints(w),geometryType:c.GeometryType.POLYLINES})},function(o,n){return e.defined(n)&&(o=L.unpack(o,n)),o._ellipsoid=t.Ellipsoid.clone(o._ellipsoid),L.createGeometry(o)}}));