Agriculture-front-end/dist/Cesium/Workers/createWallGeometry.js
2023-09-11 21:56:39 +08:00

2 lines
6.9 KiB
JavaScript

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