Agriculture-front-end/public/Cesium/Workers/createCoplanarPolygonGeometry.js

2 lines
7.0 KiB
JavaScript
Raw Normal View History

2023-04-23 09:41:12 +08:00
define(["./arrayRemoveDuplicates-9b636830","./BoundingRectangle-1d581417","./Transforms-20461479","./Matrix2-413c4048","./Matrix3-81054f0f","./ComponentDatatype-ab629b88","./CoplanarPolygonGeometryLibrary-281d77bd","./defaultValue-f6d5e6da","./GeometryAttribute-b8117bde","./GeometryAttributes-1e4ddcd2","./GeometryInstance-0318e0cd","./GeometryPipeline-fcaf4d4d","./IndexDatatype-d3db4e7d","./Math-2ce22ee9","./PolygonGeometryLibrary-d7e504f0","./PolygonPipeline-621b1cb0","./VertexFormat-fbdec922","./combine-0c102d93","./RuntimeError-9b4ce3fb","./WebGLConstants-7f557f93","./OrientedBoundingBox-fc7f7ca4","./EllipsoidTangentPlane-d430e7d5","./AxisAlignedBoundingBox-2c0751ca","./IntersectionTests-a57eed59","./Plane-6add0ae1","./AttributeCompression-48e336db","./EncodedCartesian3-5e2017ab","./ArcType-26a3f38d","./EllipsoidRhumbLine-77eff028"],(function(e,t,n,o,r,a,i,s,l,y,c,p,u,m,d,g,h,x,C,b,f,P,A,w,L,G,F,v,E){"use strict";const _=new r.Cartesian3,T=new t.BoundingRectangle,k=new o.Cartesian2,D=new o.Cartesian2,V=new r.Cartesian3,R=new r.Cartesian3,H=new r.Cartesian3,I=new r.Cartesian3,M=new r.Cartesian3,B=new r.Cartesian3,O=new n.Quaternion,z=new r.Matrix3,S=new r.Matrix3,N=new r.Cartesian3;function Q(e,t,i,c,p,d,h,x,C){const b=e.positions;let f=g.PolygonPipeline.triangulate(e.positions2D,e.holes);f.length<3&&(f=[0,1,2]);const P=u.IndexDatatype.createTypedArray(b.length,f.length);P.set(f);let A=z;if(0!==c){let e=n.Quaternion.fromAxisAngle(h,c,O);if(A=r.Matrix3.fromQuaternion(e,A),t.tangent||t.bitangent){e=n.Quaternion.fromAxisAngle(h,-c,O);const o=r.Matrix3.fromQuaternion(e,S);x=r.Cartesian3.normalize(r.Matrix3.multiplyByVector(o,x,x),x),t.bitangent&&(C=r.Cartesian3.normalize(r.Cartesian3.cross(h,x,C),C))}}else A=r.Matrix3.clone(r.Matrix3.IDENTITY,A);const w=D;t.st&&(w.x=i.x,w.y=i.y);const L=b.length,G=3*L,F=new Float64Array(G),v=t.normal?new Float32Array(G):void 0,E=t.tangent?new Float32Array(G):void 0,T=t.bitangent?new Float32Array(G):void 0,V=t.st?new Float32Array(2*L):void 0;let R=0,H=0,I=0,M=0,B=0;for(let e=0;e<L;e++){const n=b[e];if(F[R++]=n.x,F[R++]=n.y,F[R++]=n.z,t.st)if(s.defined(p)&&p.positions.length===L)V[B++]=p.positions[e].x,V[B++]=p.positions[e].y;else{const e=d(r.Matrix3.multiplyByVector(A,n,_),k);o.Cartesian2.subtract(e,w,e);const t=m.CesiumMath.clamp(e.x/i.width,0,1),a=m.CesiumMath.clamp(e.y/i.height,0,1);V[B++]=t,V[B++]=a}t.normal&&(v[H++]=h.x,v[H++]=h.y,v[H++]=h.z),t.tangent&&(E[M++]=x.x,E[M++]=x.y,E[M++]=x.z),t.bitangent&&(T[I++]=C.x,T[I++]=C.y,T[I++]=C.z)}const N=new y.GeometryAttributes;return t.position&&(N.position=new l.GeometryAttribute({componentDatatype:a.ComponentDatatype.DOUBLE,componentsPerAttribute:3,values:F})),t.normal&&(N.normal=new l.GeometryAttribute({componentDatatype:a.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:v})),t.tangent&&(N.tangent=new l.GeometryAttribute({componentDatatype:a.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:E})),t.bitangent&&(N.bitangent=new l.GeometryAttribute({componentDatatype:a.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:T})),t.st&&(N.st=new l.GeometryAttribute({componentDatatype:a.ComponentDatatype.FLOAT,componentsPerAttribute:2,values:V})),new l.Geometry({attributes:N,indices:P,primitiveType:l.PrimitiveType.TRIANGLES})}function j(e){const t=(e=s.defaultValue(e,s.defaultValue.EMPTY_OBJECT)).polygonHierarchy,n=e.textureCoordinates,a=s.defaultValue(e.vertexFormat,h.VertexFormat.DEFAULT);this._vertexFormat=h.VertexFormat.clone(a),this._polygonHierarchy=t,this._stRotation=s.defaultValue(e.stRotation,0),this._ellipsoid=r.Ellipsoid.clone(s.defaultValue(e.ellipsoid,r.Ellipsoid.WGS84)),this._workerName="createCoplanarPolygonGeometry",this._textureCoordinates=n,this.packedLength=d.PolygonGeometryLibrary.computeHierarchyPackedLength(t,r.Cartesian3)+h.VertexFormat.packedLength+r.Ellipsoid.packedLength+(s.defined(n)?d.PolygonGeometryLibrary.computeHierarchyPackedLength(n,o.Cartesian2):1)+2}j.fromPositions=function(e){return new j({polygonHierarchy:{positions:(e=s.defaultValue(e,s.defaultValue.EMPTY_OBJECT)).positions},vertexFormat:e.vertexF