2 lines
5.3 KiB
JavaScript
2 lines
5.3 KiB
JavaScript
define(["./defaultValue-81eec7ed","./Cartesian2-bd414876","./arrayRemoveDuplicates-cea3b206","./BoundingRectangle-0e36efc3","./BoundingSphere-9a3b5656","./Cartesian3-e0307675","./ComponentDatatype-aaeec80f","./PolylineVolumeGeometryLibrary-c618b783","./Check-741c5f3c","./GeometryAttribute-2b42a913","./GeometryAttributes-32b29525","./GeometryPipeline-e7083fea","./IndexDatatype-3f3c99e8","./Math-e73894ab","./PolygonPipeline-04baeb41","./VertexFormat-d50a69ba","./GeographicProjection-c931c7fb","./Rectangle-cf3e0e3e","./Matrix4-4c545f70","./RuntimeError-26acdd3b","./WebGLConstants-508b9636","./EllipsoidTangentPlane-4d138901","./AxisAlignedBoundingBox-8774439c","./IntersectionTests-80510c7b","./Plane-bc8b6777","./Transforms-5b829630","./when-422ea0ae","./Resource-8ae1a924","./combine-3c023bda","./PolylinePipeline-0e56eeb9","./EllipsoidGeodesic-e7a5ca44","./EllipsoidRhumbLine-592e8885","./Matrix2-dc0c61cc","./AttributeCompression-8f752c03","./EncodedCartesian3-aafcc30f"],(function(e,t,n,o,i,a,r,l,s,c,p,u,d,m,y,g,h,f,b,P,E,_,k,C,v,V,x,L,F,A,G,T,D,R,w){"use strict";function B(n){const o=(n=e.defaultValue(n,e.defaultValue.EMPTY_OBJECT)).polylinePositions,i=n.shapePositions;this._positions=o,this._shape=i,this._ellipsoid=t.Ellipsoid.clone(e.defaultValue(n.ellipsoid,t.Ellipsoid.WGS84)),this._cornerType=e.defaultValue(n.cornerType,l.CornerType.ROUNDED),this._vertexFormat=g.VertexFormat.clone(e.defaultValue(n.vertexFormat,g.VertexFormat.DEFAULT)),this._granularity=e.defaultValue(n.granularity,m.CesiumMath.RADIANS_PER_DEGREE),this._workerName="createPolylineVolumeGeometry";let r=1+o.length*a.Cartesian3.packedLength;r+=1+i.length*t.Cartesian2.packedLength,this.packedLength=r+t.Ellipsoid.packedLength+g.VertexFormat.packedLength+2}B.pack=function(n,o,i){let r;i=e.defaultValue(i,0);const l=n._positions;let s=l.length;for(o[i++]=s,r=0;r<s;++r,i+=a.Cartesian3.packedLength)a.Cartesian3.pack(l[r],o,i);const c=n._shape;for(s=c.length,o[i++]=s,r=0;r<s;++r,i+=t.Cartesian2.packedLength)t.Cartesian2.pack(c[r],o,i);return t.Ellipsoid.pack(n._ellipsoid,o,i),i+=t.Ellipsoid.packedLength,g.VertexFormat.pack(n._vertexFormat,o,i),i+=g.VertexFormat.packedLength,o[i++]=n._cornerType,o[i]=n._granularity,o};const S=t.Ellipsoid.clone(t.Ellipsoid.UNIT_SPHERE),I=new g.VertexFormat,O={polylinePositions:void 0,shapePositions:void 0,ellipsoid:S,vertexFormat:I,cornerType:void 0,granularity:void 0};B.unpack=function(n,o,i){let r;o=e.defaultValue(o,0);let l=n[o++];const s=new Array(l);for(r=0;r<l;++r,o+=a.Cartesian3.packedLength)s[r]=a.Cartesian3.unpack(n,o);l=n[o++];const c=new Array(l);for(r=0;r<l;++r,o+=t.Cartesian2.packedLength)c[r]=t.Cartesian2.unpack(n,o);const p=t.Ellipsoid.unpack(n,o,S);o+=t.Ellipsoid.packedLength;const u=g.VertexFormat.unpack(n,o,I);o+=g.VertexFormat.packedLength;const d=n[o++],m=n[o];return e.defined(i)?(i._positions=s,i._shape=c,i._ellipsoid=t.Ellipsoid.clone(p,i._ellipsoid),i._vertexFormat=g.VertexFormat.clone(u,i._vertexFormat),i._cornerType=d,i._granularity=m,i):(O.polylinePositions=s,O.shapePositions=c,O.cornerType=d,O.granularity=m,new B(O))};const N=new o.BoundingRectangle;return B.createGeometry=function(e){const t=e._positions,s=n.arrayRemoveDuplicates(t,a.Cartesian3.equalsEpsilon);let m=e._shape;if(m=l.PolylineVolumeGeometryLibrary.removeDuplicatesFromShape(m),s.length<2||m.length<3)return;y.PolygonPipeline.computeWindingOrder2D(m)===y.WindingOrder.CLOCKWISE&&m.reverse();const g=o.BoundingRectangle.fromPoints(m,N);return function(e,t,n,o){const a=new p.GeometryAttributes;o.position&&(a.position=new c.GeometryAttribute({componentDatatype:r.ComponentDatatype.DOUBLE,componentsPerAttribute:3,values:e}));const s=t.length,m=e.length/3,g=(m-2*s)/(2*s),h=y.PolygonPipeline.triangulate(t),f=(g-1)*s*6+2*h.length,b=d.IndexDatatype.createTypedArray(m,f);let P,E,_,k,C,v;const V=2*s;let x=0;for(P=0;P<g-1;P++){for(E=0;E<s-1;E++)_=2*E+P*s*2,v=_+V,k=_+1,C=k+V,b[x++]=k,b[x++]=_,b[x++]=C,b[x++]=C,b[x++]=_,b[x++]=v;_=2*s-2+P*s*2,k=_+1,C=k+V,v=_+V,b[x++]=k,b[x++]=_,b[x++]=C,b[x++]=C,b[x++]=_,b[x++]=v}if(o.st||o.tangent||o.bitangent){const e=new Float32Array(2*m),o=1/(g-1),i=1/n.height,l=n.height/2;let p,u,d=0;for(P=0;P<g;P++){for(p=P*o,u=i*(t[0].y+l),e[d++]=p,e[d++]=u,E=1;E<s;E++)u=i*(t[E].y+l),e[d++]=p,e[d++]=u,e[d++]=p,e[d++]=u;u=i*(t[0].y+l),e[d++]=p,e[d++]=u}for(E=0;E<s;E++)p=0,u=i*(t[E].y+l),e[d++]=p,e[d++]=u;for(E=0;E<s;E++)p=(g-1)*o,u=i*(t[E].y+l),e[d++]=p,e[d++]=u;a.st=new c.GeometryAttribute({componentDatatype:r.ComponentDatatype.FLOAT,componentsPerAttribute:2,values:new Float32Array(e)})}const L=m-2*s;for(P=0;P<h.length;P+=3){const e=h[P]+L,t=h[P+1]+L,n=h[P+2]+L;b[x++]=e,b[x++]=t,b[x++]=n,b[x++]=n+s,b[x++]=t+s,b[x++]=e+s}let F=new c.Geometry({attributes:a,indices:b,boundingSphere:i.BoundingSphere.fromVertices(e),primitiveType:c.PrimitiveType.TRIANGLES});if(o.normal&&(F=u.GeometryPipeline.computeNormal(F)),o.tangent||o.bitangent){try{F=u.GeometryPipeline.computeTangentAndBitangent(F)}catch(e){l.oneTimeWarning("polyline-volume-tangent-bitangent","Unable to compute tangents and bitangents for polyline volume geometry")}o.tangent||(F.attributes.tangent=void 0),o.bitangent||(F.attributes.bitangent=void 0),o.st||(F.attributes.st=void 0)}return F}(l.PolylineVolumeGeometryLibrary.computePositions(s,m,g,e,!0),m,g,e._vertexFormat)},function(n,o){return e.defined(o)&&(n=B.unpack(n,o)),n._ellipsoid=t.Ellipsoid.clone(n._ellipsoid),B.createGeometry(n)}}));
|