qa-prevention-gwj-vue/static/map/cesium91/CesiumUnminified/Workers/createCoplanarPolygonGeomet...

2 lines
6.5 KiB
JavaScript

define(["./arrayRemoveDuplicates-cea3b206","./BoundingRectangle-0e36efc3","./BoundingSphere-9a3b5656","./Cartesian2-bd414876","./Cartesian3-e0307675","./Check-741c5f3c","./ComponentDatatype-aaeec80f","./CoplanarPolygonGeometryLibrary-08d616f3","./defaultValue-81eec7ed","./GeometryAttribute-2b42a913","./GeometryAttributes-32b29525","./GeometryInstance-1b39c9e8","./GeometryPipeline-e7083fea","./IndexDatatype-3f3c99e8","./Math-e73894ab","./Matrix4-4c545f70","./PolygonGeometryLibrary-231711c2","./PolygonPipeline-04baeb41","./Transforms-5b829630","./VertexFormat-d50a69ba","./GeographicProjection-c931c7fb","./Rectangle-cf3e0e3e","./WebGLConstants-508b9636","./OrientedBoundingBox-c5d2adb7","./EllipsoidTangentPlane-4d138901","./AxisAlignedBoundingBox-8774439c","./IntersectionTests-80510c7b","./Plane-bc8b6777","./Matrix2-dc0c61cc","./AttributeCompression-8f752c03","./EncodedCartesian3-aafcc30f","./RuntimeError-26acdd3b","./ArcType-fc72c06c","./EllipsoidRhumbLine-592e8885","./when-422ea0ae","./Resource-8ae1a924","./combine-3c023bda"],(function(e,t,n,o,a,r,i,s,l,c,p,y,u,m,d,g,b,h,f,C,x,P,A,w,F,G,L,E,v,T,D,V,_,k,R,M,B){"use strict";const I=new a.Cartesian3,H=new t.BoundingRectangle,O=new o.Cartesian2,S=new o.Cartesian2,z=new a.Cartesian3,N=new a.Cartesian3,Q=new a.Cartesian3,j=new a.Cartesian3,U=new a.Cartesian3,Y=new a.Cartesian3,q=new f.Quaternion,J=new g.Matrix3,W=new g.Matrix3,Z=new a.Cartesian3;function K(e,t,n,r,s,l,y,u){const b=e.positions;let C=h.PolygonPipeline.triangulate(e.positions2D,e.holes);C.length<3&&(C=[0,1,2]);const x=m.IndexDatatype.createTypedArray(b.length,C.length);x.set(C);let P=J;if(0!==r){let e=f.Quaternion.fromAxisAngle(l,r,q);if(P=g.Matrix3.fromQuaternion(e,P),t.tangent||t.bitangent){e=f.Quaternion.fromAxisAngle(l,-r,q);const n=g.Matrix3.fromQuaternion(e,W);y=a.Cartesian3.normalize(g.Matrix3.multiplyByVector(n,y,y),y),t.bitangent&&(u=a.Cartesian3.normalize(a.Cartesian3.cross(l,y,u),u))}}else P=g.Matrix3.clone(g.Matrix3.IDENTITY,P);const A=S;t.st&&(A.x=n.x,A.y=n.y);const w=b.length,F=3*w,G=new Float64Array(F),L=t.normal?new Float32Array(F):void 0,E=t.tangent?new Float32Array(F):void 0,v=t.bitangent?new Float32Array(F):void 0,T=t.st?new Float32Array(2*w):void 0;let D=0,V=0,_=0,k=0,R=0;for(let e=0;e<w;e++){const a=b[e];if(G[D++]=a.x,G[D++]=a.y,G[D++]=a.z,t.st){const e=s(g.Matrix3.multiplyByVector(P,a,I),O);o.Cartesian2.subtract(e,A,e);const t=d.CesiumMath.clamp(e.x/n.width,0,1),r=d.CesiumMath.clamp(e.y/n.height,0,1);T[R++]=t,T[R++]=r}t.normal&&(L[V++]=l.x,L[V++]=l.y,L[V++]=l.z),t.tangent&&(E[k++]=y.x,E[k++]=y.y,E[k++]=y.z),t.bitangent&&(v[_++]=u.x,v[_++]=u.y,v[_++]=u.z)}const M=new p.GeometryAttributes;return t.position&&(M.position=new c.GeometryAttribute({componentDatatype:i.ComponentDatatype.DOUBLE,componentsPerAttribute:3,values:G})),t.normal&&(M.normal=new c.GeometryAttribute({componentDatatype:i.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:L})),t.tangent&&(M.tangent=new c.GeometryAttribute({componentDatatype:i.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:E})),t.bitangent&&(M.bitangent=new c.GeometryAttribute({componentDatatype:i.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:v})),t.st&&(M.st=new c.GeometryAttribute({componentDatatype:i.ComponentDatatype.FLOAT,componentsPerAttribute:2,values:T})),new c.Geometry({attributes:M,indices:x,primitiveType:c.PrimitiveType.TRIANGLES})}function X(e){const t=(e=l.defaultValue(e,l.defaultValue.EMPTY_OBJECT)).polygonHierarchy,n=l.defaultValue(e.vertexFormat,C.VertexFormat.DEFAULT);this._vertexFormat=C.VertexFormat.clone(n),this._polygonHierarchy=t,this._stRotation=l.defaultValue(e.stRotation,0),this._ellipsoid=o.Ellipsoid.clone(l.defaultValue(e.ellipsoid,o.Ellipsoid.WGS84)),this._workerName="createCoplanarPolygonGeometry",this.packedLength=b.PolygonGeometryLibrary.computeHierarchyPackedLength(t)+C.VertexFormat.packedLength+o.Ellipsoid.packedLength+2}X.fromPositions=function(e){return new X({polygonHierarchy:{positions:(e=l.defaultValue(e,l.defaultValue.EMPTY_OBJECT)).positions},vertexFormat:e.vertexFormat,stRotation:e.stRotation,ellipsoid:e.ellipsoid})},X.pack=function(e,t,n){return n=l.defaultValue(n,0),n=b.PolygonGeometryLibrary.packPolygonHierarchy(e._polygonHierarchy,t,n),o.Ellipsoid.pack(e._ellipsoid,t,n),n+=o.Ellipsoid.packedLength,C.VertexFormat.pack(e._vertexFormat,t,n),n+=C.VertexFormat.packedLength,t[n++]=e._stRotation,t[n]=e.packedLength,t};const $=o.Ellipsoid.clone(o.Ellipsoid.UNIT_SPHERE),ee=new C.VertexFormat,te={polygonHierarchy:{}};return X.unpack=function(e,t,n){t=l.defaultValue(t,0);const a=b.PolygonGeometryLibrary.unpackPolygonHierarchy(e,t);t=a.startingIndex,delete a.startingIndex;const r=o.Ellipsoid.unpack(e,t,$);t+=o.Ellipsoid.packedLength;const i=C.VertexFormat.unpack(e,t,ee);t+=C.VertexFormat.packedLength;const s=e[t++],c=e[t];return l.defined(n)||(n=new X(te)),n._polygonHierarchy=a,n._ellipsoid=o.Ellipsoid.clone(r,n._ellipsoid),n._vertexFormat=C.VertexFormat.clone(i,n._vertexFormat),n._stRotation=s,n.packedLength=c,n},X.createGeometry=function(t){const o=t._vertexFormat,r=t._polygonHierarchy,i=t._stRotation;let l=r.positions;if(l=e.arrayRemoveDuplicates(l,a.Cartesian3.equalsEpsilon,!0),l.length<3)return;let p=z,g=N,h=Q,f=U;const C=Y;if(!s.CoplanarPolygonGeometryLibrary.computeProjectTo2DArguments(l,j,f,C))return;if(p=a.Cartesian3.cross(f,C,p),p=a.Cartesian3.normalize(p,p),!a.Cartesian3.equalsEpsilon(j,a.Cartesian3.ZERO,d.CesiumMath.EPSILON6)){const e=t._ellipsoid.geodeticSurfaceNormal(j,Z);a.Cartesian3.dot(p,e)<0&&(p=a.Cartesian3.negate(p,p),f=a.Cartesian3.negate(f,f))}const x=s.CoplanarPolygonGeometryLibrary.createProjectPointsTo2DFunction(j,f,C),P=s.CoplanarPolygonGeometryLibrary.createProjectPointTo2DFunction(j,f,C);o.tangent&&(g=a.Cartesian3.clone(f,g)),o.bitangent&&(h=a.Cartesian3.clone(C,h));const A=b.PolygonGeometryLibrary.polygonsFromHierarchy(r,x,!1),w=A.hierarchy,F=A.polygons;if(0===w.length)return;l=w[0].outerRing;const G=n.BoundingSphere.fromPoints(l),L=b.PolygonGeometryLibrary.computeBoundingRectangle(p,P,l,i,H),E=[];for(let e=0;e<F.length;e++){const t=new y.GeometryInstance({geometry:K(F[e],o,L,i,P,p,g,h)});E.push(t)}const v=u.GeometryPipeline.combineInstances(E)[0];v.attributes.position.values=new Float64Array(v.attributes.position.values),v.indices=m.IndexDatatype.createTypedArray(v.attributes.position.values.length/3,v.indices);const T=v.attributes;return o.position||delete T.position,new c.Geometry({attributes:T,indices:v.indices,primitiveType:v.primitiveType,boundingSphere:G})},function(e,t){return l.defined(t)&&(e=X.unpack(e,t)),X.createGeometry(e)}}));