Newer
Older
ganzhou-feidu / static / lib / freedo / Freedo / Workers / createPolylineVolumeGeometry.js
bairujie on 14 Apr 2023 5 KB init
define(["./when-cbf8cd21","./Check-35e1a91d","./Math-e66fad2a","./Cartesian2-44433f55","./Matrix3-146a3f23","./Transforms-fc4c03e8","./RuntimeError-f4c64df1","./WebGLConstants-95ceb4e9","./ComponentDatatype-7ee14e67","./GeometryAttribute-dee5e12d","./GeometryAttributes-90846c5f","./AttributeCompression-170b3be0","./GeometryPipeline-36144dac","./EncodedCartesian3-86f19ac2","./IndexDatatype-66caba23","./IntersectionTests-caa0ba1a","./Plane-e04c899a","./VertexFormat-cc24f342","./arrayRemoveDuplicates-b817241d","./BoundingRectangle-bef3979e","./EllipsoidTangentPlane-d27aa001","./EllipsoidRhumbLine-862a2df4","./PolygonPipeline-b54c9b74","./PolylineVolumeGeometryLibrary-ee2feab7","./EllipsoidGeodesic-7779e55a","./PolylinePipeline-7b01b363"],function(c,e,i,u,t,G,n,r,A,R,D,a,I,o,O,l,s,g,p,d,y,m,S,h,f,v){"use strict";var b={};function B(e,t){c.defined(b[e])||(b[e]=!0,console.warn(c.defaultValue(t,e)))}function E(e){var t=(e=c.defaultValue(e,c.defaultValue.EMPTY_OBJECT)).polylinePositions,n=e.shapePositions;this._positions=t,this._shape=n,this._ellipsoid=u.Ellipsoid.clone(c.defaultValue(e.ellipsoid,u.Ellipsoid.WGS84)),this._cornerType=c.defaultValue(e.cornerType,h.CornerType.ROUNDED),this._vertexFormat=g.VertexFormat.clone(c.defaultValue(e.vertexFormat,g.VertexFormat.DEFAULT)),this._granularity=c.defaultValue(e.granularity,i.CesiumMath.RADIANS_PER_DEGREE),this._workerName="createPolylineVolumeGeometry";var r=1+t.length*u.Cartesian3.packedLength;r+=1+n.length*u.Cartesian2.packedLength,this.packedLength=r+u.Ellipsoid.packedLength+g.VertexFormat.packedLength+2}B.geometryOutlines="Entity geometry outlines are unsupported on terrain. Outlines will be disabled. To enable outlines, disable geometry terrain clamping by explicitly setting height to 0.",B.geometryZIndex="Entity geometry with zIndex are unsupported when height or extrudedHeight are defined.  zIndex will be ignored",B.geometryHeightReference="Entity corridor, ellipse, polygon or rectangle with heightReference must also have a defined height.  heightReference will be ignored",B.geometryExtrudedHeightReference="Entity corridor, ellipse, polygon or rectangle with extrudedHeightReference must also have a defined extrudedHeight.  extrudedHeightReference will be ignored",E.pack=function(e,t,n){var r;n=c.defaultValue(n,0);var i=e._positions,a=i.length;for(t[n++]=a,r=0;r<a;++r,n+=u.Cartesian3.packedLength)u.Cartesian3.pack(i[r],t,n);var o=e._shape,a=o.length;for(t[n++]=a,r=0;r<a;++r,n+=u.Cartesian2.packedLength)u.Cartesian2.pack(o[r],t,n);return u.Ellipsoid.pack(e._ellipsoid,t,n),n+=u.Ellipsoid.packedLength,g.VertexFormat.pack(e._vertexFormat,t,n),n+=g.VertexFormat.packedLength,t[n++]=e._cornerType,t[n]=e._granularity,t};var P=u.Ellipsoid.clone(u.Ellipsoid.UNIT_SPHERE),_=new g.VertexFormat,x={polylinePositions:void 0,shapePositions:void 0,ellipsoid:P,vertexFormat:_,cornerType:void 0,granularity:void 0};E.unpack=function(e,t,n){t=c.defaultValue(t,0);for(var r=e[t++],i=new Array(r),a=0;a<r;++a,t+=u.Cartesian3.packedLength)i[a]=u.Cartesian3.unpack(e,t);r=e[t++];var o=new Array(r);for(a=0;a<r;++a,t+=u.Cartesian2.packedLength)o[a]=u.Cartesian2.unpack(e,t);var l=u.Ellipsoid.unpack(e,t,P);t+=u.Ellipsoid.packedLength;var s=g.VertexFormat.unpack(e,t,_);t+=g.VertexFormat.packedLength;var p=e[t++],d=e[t];return c.defined(n)?(n._positions=i,n._shape=o,n._ellipsoid=u.Ellipsoid.clone(l,n._ellipsoid),n._vertexFormat=g.VertexFormat.clone(s,n._vertexFormat),n._cornerType=p,n._granularity=d,n):(x.polylinePositions=i,x.shapePositions=o,x.cornerType=p,x.granularity=d,new E(x))};var k=new d.BoundingRectangle;return E.createGeometry=function(e){var t=e._positions,n=p.arrayRemoveDuplicates(t,u.Cartesian3.equalsEpsilon),r=e._shape,r=h.PolylineVolumeGeometryLibrary.removeDuplicatesFromShape(r);if(!(n.length<2||r.length<3)){S.PolygonPipeline.computeWindingOrder2D(r)===S.WindingOrder.CLOCKWISE&&r.reverse();var i=d.BoundingRectangle.fromPoints(r,k);return function(e,t,n,r){var i=new D.GeometryAttributes;r.position&&(i.position=new R.GeometryAttribute({componentDatatype:A.ComponentDatatype.DOUBLE,componentsPerAttribute:3,values:e}));var a,o,l,s,p,d=t.length,c=e.length/3,u=(c-2*d)/(2*d),g=S.PolygonPipeline.triangulate(t),y=(u-1)*d*6+2*g.length,m=O.IndexDatatype.createTypedArray(c,y),h=2*d,f=0;for(C=0;C<u-1;C++){for(a=0;a<d-1;a++)p=(o=2*a+C*d*2)+h,s=(l=o+1)+h,m[f++]=l,m[f++]=o,m[f++]=s,m[f++]=s,m[f++]=o,m[f++]=p;s=(l=(o=2*d-2+C*d*2)+1)+h,p=o+h,m[f++]=l,m[f++]=o,m[f++]=s,m[f++]=s,m[f++]=o,m[f++]=p}if(r.st||r.tangent||r.bitangent){for(var v,b,E=new Float32Array(2*c),P=1/(u-1),_=1/n.height,x=n.height/2,k=0,C=0;C<u;C++){for(v=C*P,b=_*(t[0].y+x),E[k++]=v,E[k++]=b,a=1;a<d;a++)b=_*(t[a].y+x),E[k++]=v,E[k++]=b,E[k++]=v,E[k++]=b;b=_*(t[0].y+x),E[k++]=v,E[k++]=b}for(a=0;a<d;a++)v=0,b=_*(t[a].y+x),E[k++]=v,E[k++]=b;for(a=0;a<d;a++)v=(u-1)*P,b=_*(t[a].y+x),E[k++]=v,E[k++]=b;i.st=new R.GeometryAttribute({componentDatatype:A.ComponentDatatype.FLOAT,componentsPerAttribute:2,values:new Float32Array(E)})}var V=c-2*d;for(C=0;C<g.length;C+=3){var L=g[C]+V,w=g[C+1]+V,F=g[C+2]+V;m[f++]=L,m[f++]=w,m[f++]=F,m[f++]=F+d,m[f++]=w+d,m[f++]=L+d}var T=new R.Geometry({attributes:i,indices:m,boundingSphere:G.BoundingSphere.fromVertices(e),primitiveType:R.PrimitiveType.TRIANGLES});if(r.normal&&(T=I.GeometryPipeline.computeNormal(T)),r.tangent||r.bitangent){try{T=I.GeometryPipeline.computeTangentAndBitangent(T)}catch(e){B("polyline-volume-tangent-bitangent","Unable to compute tangents and bitangents for polyline volume geometry")}r.tangent||(T.attributes.tangent=void 0),r.bitangent||(T.attributes.bitangent=void 0),r.st||(T.attributes.st=void 0)}return T}(h.PolylineVolumeGeometryLibrary.computePositions(n,r,i,e,!0),r,i,e._vertexFormat)}},function(e,t){return c.defined(t)&&(e=E.unpack(e,t)),e._ellipsoid=u.Ellipsoid.clone(e._ellipsoid),E.createGeometry(e)}});