createPolylineVolumeGeometry.js 5.3 KB

1
  1. define(["./when-92c6cf3c","./Rectangle-bab7abf0","./arrayRemoveDuplicates-f7eaafa2","./BoundingRectangle-418864a2","./buildModuleUrl-3d15f25c","./Cartesian2-6033fa5d","./Cartographic-67e73ef9","./ComponentDatatype-81047f82","./PolylineVolumeGeometryLibrary-9a645937","./Check-52a7d806","./GeometryAttribute-ef657318","./GeometryAttributes-7f66ea53","./GeometryPipeline-f4eddf07","./IndexDatatype-4c0e98b8","./Math-92c3b5f7","./PolygonPipeline-b86e8785","./PrimitiveType-cdfe443e","./VertexFormat-f496a3f1","./WindingOrder-1b9c8a87","./Intersect-b97e930a","./Event-3390cd7d","./RuntimeError-c6a62a80","./WebGLConstants-71f10989","./Cartesian4-ad128b5d","./EllipsoidTangentPlane-53184efd","./IntersectionTests-a42760d9","./Plane-f8d22530","./PolylinePipeline-c0932bf7","./EllipsoidGeodesic-04ac0e77","./EllipsoidRhumbLine-8847d1a1","./FeatureDetection-067cb23c","./AttributeCompression-49f7b62a","./EncodedCartesian3-b86c8d65"],(function(e,t,n,o,a,i,r,s,p,c,l,u,d,h,y,g,f,m,v,b,k,_,P,L,w,C,E,A,D,T,F,R,G){"use strict";function x(n){var o=(n=e.u(n,e.u.EMPTY_OBJECT)).polylinePositions,a=n.shapePositions;if(!e.e(o))throw new c.t("options.polylinePositions is required.");if(!e.e(a))throw new c.t("options.shapePositions is required.");this._positions=o,this._shape=a,this._ellipsoid=t.t.clone(e.u(n.ellipsoid,t.t.WGS84)),this._cornerType=e.u(n.cornerType,p.S.ROUNDED),this._vertexFormat=m.n.clone(e.u(n.vertexFormat,m.n.DEFAULT)),this._granularity=e.u(n.granularity,y.e.RADIANS_PER_DEGREE),this._workerName="createPolylineVolumeGeometry",this.enuCenter=e.u(n.enuCenter,r.t.ZERO);var s=1+o.length*r.t.packedLength;s+=1+a.length*i.o.packedLength+r.t.packedLength,this.packedLength=s+t.t.packedLength+m.n.packedLength+2}x.pack=function(n,o,a){if(!e.e(n))throw new c.t("value is required");if(!e.e(o))throw new c.t("array is required");a=e.u(a,0);var s,p=n._positions,l=p.length;for(o[a++]=l,s=0;s<l;++s,a+=r.t.packedLength)r.t.pack(p[s],o,a);var u=n._shape;for(l=u.length,o[a++]=l,s=0;s<l;++s,a+=i.o.packedLength)i.o.pack(u[s],o,a);return t.t.pack(n._ellipsoid,o,a),a+=t.t.packedLength,m.n.pack(n._vertexFormat,o,a),a+=m.n.packedLength,o[a++]=n._cornerType,o[a++]=n._granularity,r.t.pack(n.enuCenter,o,a),o};var O=t.t.clone(t.t.UNIT_SPHERE),I=new m.n,S={polylinePositions:void 0,shapePositions:void 0,ellipsoid:O,vertexFormat:I,cornerType:void 0,granularity:void 0,enuCenter:void 0};x.unpack=function(n,o,a){if(!e.e(n))throw new c.t("array is required");o=e.u(o,0);var s,p=n[o++],l=new Array(p);for(s=0;s<p;++s,o+=r.t.packedLength)l[s]=r.t.unpack(n,o);p=n[o++];var u=new Array(p);for(s=0;s<p;++s,o+=i.o.packedLength)u[s]=i.o.unpack(n,o);var d=t.t.unpack(n,o,O);o+=t.t.packedLength;var h=m.n.unpack(n,o,I);o+=m.n.packedLength;var y,g=n[o++],f=n[o++];return y=r.t.unpack(n,o),e.e(a)?(a._positions=l,a._shape=u,a._ellipsoid=t.t.clone(d,a._ellipsoid),a._vertexFormat=m.n.clone(h,a._vertexFormat),a._cornerType=g,a._granularity=f,a.enuCenter=y,a):(S.polylinePositions=l,S.shapePositions=u,S.cornerType=g,S.granularity=f,S.enuCenter=y,new x(S))};var q=new o.f;return x.createGeometry=function(t){for(var i=t._positions,c=n.D(i,r.t.equalsEpsilon),y=c.length,m=new Array(y),b=0;b<y;b++)m[b]=r.t.clone(c[b]);var k=t._shape;if(k=p.J.removeDuplicatesFromShape(k),!(c.length<2||k.length<3)){g.A.computeWindingOrder2D(k)===v.W.CLOCKWISE&&k.reverse();var _=o.f.fromPoints(k,q),P={};if(P.combinedPositions=p.J.computePositions(m,k,_,t,!0),!r.t.equals(t.enuCenter,r.t.ZERO)){var L=new Array(y);for(b=0;b<y;b++)L[b]=r.t.clone(c[b]);P.combinedLocalPositions=p.J.computeLocalPositions(L,k,_,t,!0,t.enuCenter)}return function(t,n,o,i){var r=t.combinedPositions,p=t.combinedLocalPositions,c=new u.a;i.position&&(c.position=new l.o({componentDatatype:s.ComponentDatatype.DOUBLE,componentsPerAttribute:3,values:r}));var y,m,v,b,k,_,P=n.length,L=r.length/3,w=(L-2*P)/(2*P),C=g.A.triangulate(n),E=(w-1)*P*6+2*C.length,A=h.IndexDatatype.createTypedArray(L,E),D=2*P,T=0;for(y=0;y<w-1;y++){for(m=0;m<P-1;m++)_=(v=2*m+y*P*2)+D,k=(b=v+1)+D,A[T++]=b,A[T++]=v,A[T++]=k,A[T++]=k,A[T++]=v,A[T++]=_;k=(b=1+(v=2*P-2+y*P*2))+D,_=v+D,A[T++]=b,A[T++]=v,A[T++]=k,A[T++]=k,A[T++]=v,A[T++]=_}if(i.st||i.tangent||i.bitangent){var F,R,G=new Float32Array(2*L),x=1/(w-1),O=1/o.height,I=o.height/2,S=0;for(y=0;y<w;y++){for(F=y*x,R=O*(n[0].y+I),G[S++]=F,G[S++]=R,m=1;m<P;m++)R=O*(n[m].y+I),G[S++]=F,G[S++]=R,G[S++]=F,G[S++]=R;R=O*(n[0].y+I),G[S++]=F,G[S++]=R}for(m=0;m<P;m++)F=0,R=O*(n[m].y+I),G[S++]=F,G[S++]=R;for(m=0;m<P;m++)F=(w-1)*x,R=O*(n[m].y+I),G[S++]=F,G[S++]=R;c.st=new l.o({componentDatatype:s.ComponentDatatype.FLOAT,componentsPerAttribute:2,values:new Float32Array(G)})}var q=L-2*P;for(y=0;y<C.length;y+=3){var N=C[y]+q,U=C[y+1]+q,W=C[y+2]+q;A[T++]=N,A[T++]=U,A[T++]=W,A[T++]=W+P,A[T++]=U+P,A[T++]=N+P}var B=new l.I({attributes:c,indices:A,boundingSphere:a.i.fromVertices(r),primitiveType:f._0x29ba75.TRIANGLES});if(i.normal&&(B=d.k.computeNormal(B)),i.tangent||i.bitangent){try{B=d.k.computeTangentAndBitangent(B)}catch{a.e("polyline-volume-tangent-bitangent","Unable to compute tangents and bitangents for polyline volume geometry")}i.tangent||(B.attributes.tangent=void 0),i.bitangent||(B.attributes.bitangent=void 0),i.st||(B.attributes.st=void 0)}return e.e(p)&&(B.attributes.position.values=p,B.attributes.position.componentDatatype=s.ComponentDatatype.FLOAT),B}(P,k,_,t._vertexFormat)}},function(n,o){return e.e(o)&&(n=x.unpack(n,o)),n._ellipsoid=t.t.clone(n._ellipsoid),x.createGeometry(n)}}));