Agriculture-front-end/public/Cesium/Workers/createWallGeometry.js
2023-04-16 22:33:44 +08:00

2 lines
6.8 KiB
JavaScript

define(["./when-b60132fc","./Cartesian2-47311507","./buildModuleUrl-4e1b81e7","./Cartographic-3309dd0d","./ComponentDatatype-c140a87d","./Check-7b2a090c","./GeometryAttribute-3a88ba31","./GeometryAttributes-252e9929","./IndexDatatype-8a5eead4","./Math-119be1a3","./PrimitiveType-a54dc62f","./VertexFormat-6446fca0","./WallGeometryLibrary-81096bc7","./Event-16a2dfbf","./RuntimeError-4a5c8994","./WebGLConstants-4ae0db90","./FeatureDetection-c3b71206","./Cartesian4-3ca25aab","./arrayRemoveDuplicates-d2f048c5","./PolylinePipeline-2fe9092e","./EllipsoidGeodesic-0f19ac62","./EllipsoidRhumbLine-ed1a6bf4","./IntersectionTests-7386ffbf","./Plane-7ae8294c"],(function(e,t,a,i,n,r,o,s,m,l,u,p,d,c,f,y,C,g,v,h,b,x,A,_){"use strict";var E=new i.Cartesian3,F=new i.Cartesian3,w=new i.Cartesian3,k=new i.Cartesian3,L=new i.Cartesian3,P=new i.Cartesian3,D=new i.Cartesian3,G=new i.Cartesian3;function T(a){var n=(a=e.defaultValue(a,e.defaultValue.EMPTY_OBJECT)).positions,r=a.maximumHeights,o=a.minimumHeights,s=e.defaultValue(a.vertexFormat,p.VertexFormat.DEFAULT),m=e.defaultValue(a.granularity,l.CesiumMath.RADIANS_PER_DEGREE),u=e.defaultValue(a.ellipsoid,t.Ellipsoid.WGS84);this._positions=n,this._minimumHeights=o,this._maximumHeights=r,this._vertexFormat=p.VertexFormat.clone(s),this._granularity=m,this._ellipsoid=t.Ellipsoid.clone(u),this._enuCenter=a.enuCenter,this._workerName="createWallGeometry";var d=1+n.length*i.Cartesian3.packedLength+2;e.defined(o)&&(d+=o.length),e.defined(r)&&(d+=r.length),this.packedLength=d+t.Ellipsoid.packedLength+p.VertexFormat.packedLength+1,this.packedLength+=i.Cartesian3.packedLength}T.pack=function(a,n,r){var o;r=e.defaultValue(r,0);var s=a._positions,m=s.length;for(n[r++]=m,o=0;o<m;++o,r+=i.Cartesian3.packedLength)i.Cartesian3.pack(s[o],n,r);var l=a._minimumHeights;if(m=e.defined(l)?l.length:0,n[r++]=m,e.defined(l))for(o=0;o<m;++o)n[r++]=l[o];var u=a._maximumHeights;if(m=e.defined(u)?u.length:0,n[r++]=m,e.defined(u))for(o=0;o<m;++o)n[r++]=u[o];return t.Ellipsoid.pack(a._ellipsoid,n,r),r+=t.Ellipsoid.packedLength,p.VertexFormat.pack(a._vertexFormat,n,r),r+=p.VertexFormat.packedLength,n[r++]=a._granularity,e.defined(a._enuCenter)?i.Cartesian3.pack(a._enuCenter,n,r):i.Cartesian3.pack(i.Cartesian3.ZERO,n,r),n};var H=t.Ellipsoid.clone(t.Ellipsoid.UNIT_SPHERE),V=new p.VertexFormat,O={positions:void 0,minimumHeights:void 0,maximumHeights:void 0,ellipsoid:H,vertexFormat:V,granularity:void 0,enuCenter:void 0};return T.unpack=function(a,n,r){var o;n=e.defaultValue(n,0);var s,m,l=a[n++],u=new Array(l);for(o=0;o<l;++o,n+=i.Cartesian3.packedLength)u[o]=i.Cartesian3.unpack(a,n);if((l=a[n++])>0)for(s=new Array(l),o=0;o<l;++o)s[o]=a[n++];if((l=a[n++])>0)for(m=new Array(l),o=0;o<l;++o)m[o]=a[n++];var d=t.Ellipsoid.unpack(a,n,H);n+=t.Ellipsoid.packedLength;var c=p.VertexFormat.unpack(a,n,V);n+=p.VertexFormat.packedLength;var f=a[n++],y=i.Cartesian3.unpack(a,n);return i.Cartesian3.equals(y,i.Cartesian3.ZERO)&&(y=void 0),e.defined(r)?(r._positions=u,r._minimumHeights=s,r._maximumHeights=m,r._ellipsoid=t.Ellipsoid.clone(d,r._ellipsoid),r._vertexFormat=p.VertexFormat.clone(c,r._vertexFormat),r._granularity=f,r._enuCenter=y,r):(O.positions=u,O.minimumHeights=s,O.maximumHeights=m,O.granularity=f,O.enuCenter=y,new T(O))},T.fromConstantHeights=function(t){var a,i,n=(t=e.defaultValue(t,e.defaultValue.EMPTY_OBJECT)).positions,r=t.minimumHeight,o=t.maximumHeight,s=e.defined(r),m=e.defined(o);if(s||m){var l=n.length;a=s?new Array(l):void 0,i=m?new Array(l):void 0;for(var u=0;u<l;++u)s&&(a[u]=r),m&&(i[u]=o)}return new T({positions:n,maximumHeights:i,minimumHeights:a,ellipsoid:t.ellipsoid,vertexFormat:t.vertexFormat})},T.createGeometry=function(t){var r=t._positions,p=t._minimumHeights,c=t._maximumHeights,f=t._vertexFormat,y=t._granularity,C=t._ellipsoid,g=t._enuCenter,v=d.WallGeometryLibrary.computePositions(C,r,c,p,y,!0,g);if(e.defined(v.pos)){var h;e.defined(g)&&(h=o.Transforms.eastNorthUpToFixedFrame(g));var b,x=v.pos.bottomPositions,A=v.pos.topPositions,_=v.pos.numCorners,T=A.length,H=2*T,V=f.position?new Float64Array(H):void 0,O=f.normal?new Float32Array(H):void 0,z=f.tangent?new Float32Array(H):void 0,R=f.bitangent?new Float32Array(H):void 0,S=f.st?new Float32Array(H/3*2):void 0,I=0,M=0,N=0,B=0,U=0,W=G,q=D,Z=P,J=!0,Y=0,j=1/((T/=3)-r.length+1);for(b=0;b<T;++b){var K=3*b,Q=i.Cartesian3.fromArray(A,K,E),X=i.Cartesian3.fromArray(x,K,F);if(f.position&&(V[I++]=X.x,V[I++]=X.y,V[I++]=X.z,V[I++]=Q.x,V[I++]=Q.y,V[I++]=Q.z),f.st&&(S[U++]=Y,S[U++]=0,S[U++]=Y,S[U++]=1),f.normal||f.tangent||f.bitangent){var $,ee=i.Cartesian3.clone(i.Cartesian3.ZERO,L),te=C.scaleToGeodeticSurface(i.Cartesian3.fromArray(A,K,F),F);if(b+1<T&&($=C.scaleToGeodeticSurface(i.Cartesian3.fromArray(A,K+3,w),w),ee=i.Cartesian3.fromArray(A,K+3,L)),J){var ae=i.Cartesian3.subtract(ee,Q,k),ie=i.Cartesian3.subtract(te,Q,E);W=i.Cartesian3.normalize(i.Cartesian3.cross(ie,ae,W),W),J=!1}i.Cartesian3.equalsEpsilon($,te,l.CesiumMath.EPSILON10)?J=!0:(Y+=j,f.tangent&&(q=i.Cartesian3.normalize(i.Cartesian3.subtract($,te,q),q)),f.bitangent&&(Z=i.Cartesian3.normalize(i.Cartesian3.cross(W,q,Z),Z))),f.normal&&(e.defined(g)&&(u.Matrix4.multiplyByPoint(h,W,W),i.Cartesian3.normalize(W,W)),O[M++]=W.x,O[M++]=W.y,O[M++]=W.z,O[M++]=W.x,O[M++]=W.y,O[M++]=W.z),f.tangent&&(z[B++]=q.x,z[B++]=q.y,z[B++]=q.z,z[B++]=q.x,z[B++]=q.y,z[B++]=q.z),f.bitangent&&(R[N++]=Z.x,R[N++]=Z.y,R[N++]=Z.z,R[N++]=Z.x,R[N++]=Z.y,R[N++]=Z.z)}}var ne=new s.GeometryAttributes;f.position&&(ne.position=new o.GeometryAttribute({componentDatatype:n.ComponentDatatype.DOUBLE,componentsPerAttribute:3,values:V})),f.normal&&(ne.normal=new o.GeometryAttribute({componentDatatype:n.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:O})),f.tangent&&(ne.tangent=new o.GeometryAttribute({componentDatatype:n.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:z})),f.bitangent&&(ne.bitangent=new o.GeometryAttribute({componentDatatype:n.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:R})),f.st&&(ne.st=new o.GeometryAttribute({componentDatatype:n.ComponentDatatype.FLOAT,componentsPerAttribute:2,values:S}));var re=H/3;H-=6*(_+1);var oe=m.IndexDatatype.createTypedArray(re,H),se=0;for(b=0;b<re-2;b+=2){var me=b,le=b+2,ue=i.Cartesian3.fromArray(V,3*me,E),pe=i.Cartesian3.fromArray(V,3*le,F);if(!i.Cartesian3.equalsEpsilon(ue,pe,l.CesiumMath.EPSILON10)){var de=b+1,ce=b+3;oe[se++]=de,oe[se++]=me,oe[se++]=ce,oe[se++]=ce,oe[se++]=me,oe[se++]=le}}var fe=new o.Geometry({attributes:ne,indices:oe,primitiveType:u.PrimitiveType.TRIANGLES,boundingSphere:new a.BoundingSphere.fromVertices(V)});return e.defined(t._enuCenter)&&(fe.attributes.position.values.set(v.localPos.topPositions,0),fe.attributes.position.values.set(v.localPos.bottomPositions,fe.attributes.position.values.length/2),fe.attributes.position.componentDatatype=n.ComponentDatatype.FLOAT),fe}},function(a,i){return e.defined(i)&&(a=T.unpack(a,i)),a._ellipsoid=t.Ellipsoid.clone(a._ellipsoid),T.createGeometry(a)}}));