define(["./arrayRemoveDuplicates-398390b2","./BoundingRectangle-735493ea","./Transforms-36e0c57f","./Matrix2-7f5bbd54","./Matrix3-293ae7b3","./ComponentDatatype-985dcc38","./CoplanarPolygonGeometryLibrary-66418079","./defaultValue-865ac579","./GeometryAttribute-df0cc42c","./GeometryAttributes-75794475","./GeometryInstance-0f6ca825","./GeometryPipeline-d395f1f6","./IndexDatatype-16f6b4a1","./Math-76ce6367","./PolygonGeometryLibrary-90e667ef","./PolygonPipeline-8986342f","./VertexFormat-20b5279f","./combine-5e110d09","./RuntimeError-9e0724f9","./WebGLConstants-258cf3a0","./OrientedBoundingBox-df5dc87a","./EllipsoidTangentPlane-7a62129b","./AxisAlignedBoundingBox-6806540a","./IntersectionTests-3a8233fc","./Plane-a7f8aee2","./AttributeCompression-e34a188e","./EncodedCartesian3-d8932345","./ArcType-68098157","./EllipsoidRhumbLine-2feb918c"],(function(e,t,n,o,a,r,i,s,l,c,y,p,u,d,m,g,f,C,h,x,b,P,A,L,w,G,F,v,E){"use strict";const _=new a.Cartesian3,T=new t.BoundingRectangle,k=new o.Cartesian2,D=new o.Cartesian2,V=new a.Cartesian3,R=new a.Cartesian3,H=new a.Cartesian3,I=new a.Cartesian3,M=new a.Cartesian3,B=new a.Cartesian3,O=new n.Quaternion,z=new a.Matrix3,S=new a.Matrix3,N=new a.Cartesian3;function Q(e,t,i,y,p,m,f,C,h){const x=e.positions;let b=g.PolygonPipeline.triangulate(e.positions2D,e.holes);b.length<3&&(b=[0,1,2]);const P=u.IndexDatatype.createTypedArray(x.length,b.length);P.set(b);let A=z;if(0!==y){let e=n.Quaternion.fromAxisAngle(f,y,O);if(A=a.Matrix3.fromQuaternion(e,A),t.tangent||t.bitangent){e=n.Quaternion.fromAxisAngle(f,-y,O);const o=a.Matrix3.fromQuaternion(e,S);C=a.Cartesian3.normalize(a.Matrix3.multiplyByVector(o,C,C),C),t.bitangent&&(h=a.Cartesian3.normalize(a.Cartesian3.cross(f,C,h),h))}}else A=a.Matrix3.clone(a.Matrix3.IDENTITY,A);const L=D;t.st&&(L.x=i.x,L.y=i.y);const w=x.length,G=3*w,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*w):void 0;let R=0,H=0,I=0,M=0,B=0;for(let e=0;e<w;e++){const n=x[e];if(F[R++]=n.x,F[R++]=n.y,F[R++]=n.z,t.st)if(s.defined(p)&&p.positions.length===w)V[B++]=p.positions[e].x,V[B++]=p.positions[e].y;else{const e=m(a.Matrix3.multiplyByVector(A,n,_),k);o.Cartesian2.subtract(e,L,e);const t=d.CesiumMath.clamp(e.x/i.width,0,1),r=d.CesiumMath.clamp(e.y/i.height,0,1);V[B++]=t,V[B++]=r}t.normal&&(v[H++]=f.x,v[H++]=f.y,v[H++]=f.z),t.tangent&&(E[M++]=C.x,E[M++]=C.y,E[M++]=C.z),t.bitangent&&(T[I++]=h.x,T[I++]=h.y,T[I++]=h.z)}const N=new c.GeometryAttributes;return t.position&&(N.position=new l.GeometryAttribute({componentDatatype:r.ComponentDatatype.DOUBLE,componentsPerAttribute:3,values:F})),t.normal&&(N.normal=new l.GeometryAttribute({componentDatatype:r.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:v})),t.tangent&&(N.tangent=new l.GeometryAttribute({componentDatatype:r.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:E})),t.bitangent&&(N.bitangent=new l.GeometryAttribute({componentDatatype:r.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:T})),t.st&&(N.st=new l.GeometryAttribute({componentDatatype:r.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,r=s.defaultValue(e.vertexFormat,f.VertexFormat.DEFAULT);this._vertexFormat=f.VertexFormat.clone(r),this._polygonHierarchy=t,this._stRotation=s.defaultValue(e.stRotation,0),this._ellipsoid=a.Ellipsoid.clone(s.defaultValue(e.ellipsoid,a.Ellipsoid.WGS84)),this._workerName="createCoplanarPolygonGeometry",this._textureCoordinates=n,this.packedLength=m.PolygonGeometryLibrary.computeHierarchyPackedLength(t,a.Cartesian3)+f.VertexFormat.packedLength+a.Ellipsoid.packedLength+(s.defined(n)?m.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.vertexFormat,stRotation:e.stRotation,ellipsoid:e.ellipsoid,textureCoordinates:e.textureCoordinates})},j.pack=function(e,t,n){return n=s.defaultValue(n,0),n=m.PolygonGeometryLibrary.packPolygonHierarchy(e._polygonHierarchy,t,n,a.Cartesian3),a.Ellipsoid.pack(e._ellipsoid,t,n),n+=a.Ellipsoid.packedLength,f.VertexFormat.pack(e._vertexFormat,t,n),n+=f.VertexFormat.packedLength,t[n++]=e._stRotation,s.defined(e._textureCoordinates)?n=m.PolygonGeometryLibrary.packPolygonHierarchy(e._textureCoordinates,t,n,o.Cartesian2):t[n++]=-1,t[n++]=e.packedLength,t};const U=a.Ellipsoid.clone(a.Ellipsoid.UNIT_SPHERE),Y=new f.VertexFormat,q={polygonHierarchy:{}};return j.unpack=function(e,t,n){t=s.defaultValue(t,0);const r=m.PolygonGeometryLibrary.unpackPolygonHierarchy(e,t,a.Cartesian3);t=r.startingIndex,delete r.startingIndex;const i=a.Ellipsoid.unpack(e,t,U);t+=a.Ellipsoid.packedLength;const l=f.VertexFormat.unpack(e,t,Y);t+=f.VertexFormat.packedLength;const c=e[t++],y=-1===e[t]?void 0:m.PolygonGeometryLibrary.unpackPolygonHierarchy(e,t,o.Cartesian2);s.defined(y)?(t=y.startingIndex,delete y.startingIndex):t++;const p=e[t++];return s.defined(n)||(n=new j(q)),n._polygonHierarchy=r,n._ellipsoid=a.Ellipsoid.clone(i,n._ellipsoid),n._vertexFormat=f.VertexFormat.clone(l,n._vertexFormat),n._stRotation=c,n._textureCoordinates=y,n.packedLength=p,n},j.createGeometry=function(t){const o=t._vertexFormat,r=t._polygonHierarchy,c=t._stRotation,g=t._textureCoordinates,f=s.defined(g);let C=r.positions;if(C=e.arrayRemoveDuplicates(C,a.Cartesian3.equalsEpsilon,!0),C.length<3)return;let h=V,x=R,b=H,P=M;const A=B;if(!i.CoplanarPolygonGeometryLibrary.computeProjectTo2DArguments(C,I,P,A))return;if(h=a.Cartesian3.cross(P,A,h),h=a.Cartesian3.normalize(h,h),!a.Cartesian3.equalsEpsilon(I,a.Cartesian3.ZERO,d.CesiumMath.EPSILON6)){const e=t._ellipsoid.geodeticSurfaceNormal(I,N);a.Cartesian3.dot(h,e)<0&&(h=a.Cartesian3.negate(h,h),P=a.Cartesian3.negate(P,P))}const L=i.CoplanarPolygonGeometryLibrary.createProjectPointsTo2DFunction(I,P,A),w=i.CoplanarPolygonGeometryLibrary.createProjectPointTo2DFunction(I,P,A);o.tangent&&(x=a.Cartesian3.clone(P,x)),o.bitangent&&(b=a.Cartesian3.clone(A,b));const G=m.PolygonGeometryLibrary.polygonsFromHierarchy(r,f,L,!1),F=G.hierarchy,v=G.polygons,E=f?m.PolygonGeometryLibrary.polygonsFromHierarchy(g,!0,(function(e){return e}),!1).polygons:void 0;if(0===F.length)return;C=F[0].outerRing;const _=n.BoundingSphere.fromPoints(C),k=m.PolygonGeometryLibrary.computeBoundingRectangle(h,w,C,c,T),D=[];for(let e=0;e<v.length;e++){const t=new y.GeometryInstance({geometry:Q(v[e],o,k,c,f?E[e]:void 0,w,h,x,b)});D.push(t)}const O=p.GeometryPipeline.combineInstances(D)[0];O.attributes.position.values=new Float64Array(O.attributes.position.values),O.indices=u.IndexDatatype.createTypedArray(O.attributes.position.values.length/3,O.indices);const z=O.attributes;return o.position||delete z.position,new l.Geometry({attributes:z,indices:O.indices,primitiveType:O.primitiveType,boundingSphere:_})},function(e,t){return s.defined(t)&&(e=j.unpack(e,t)),j.createGeometry(e)}}));
|