define(["./arrayRemoveDuplicates-328bac4c","./BoundingRectangle-61e59108","./Transforms-a6362ad2","./Matrix2-ae0e0b05","./RuntimeError-ffc802eb","./ComponentDatatype-64cf6611","./CoplanarPolygonGeometryLibrary-d143dbd1","./when-e3a49219","./GeometryAttribute-50aef525","./GeometryAttributes-3db3f2c9","./GeometryInstance-81c02fd9","./GeometryPipeline-50591033","./IndexDatatype-e12e2493","./PolygonGeometryLibrary-e16e0c71","./PolygonPipeline-2bbe6eb1","./VertexFormat-9bafa8ef","./combine-c7a1ec8a","./PixelFormat-83d70a69","./WebGLConstants-1c8239cc","./OrientedBoundingBox-d2fffacc","./EllipsoidTangentPlane-e3af9e65","./AxisAlignedBoundingBox-699685f5","./IntersectionTests-8be403d7","./Plane-2bf1bb80","./AttributeCompression-8cb78525","./EncodedCartesian3-f1386330","./ArcType-5c308c35","./EllipsoidRhumbLine-b6518e5c"],(function(e,t,a,n,r,o,i,l,s,p,c,y,m,u,d,g,b,v,f,h,x,C,P,A,w,F,G,L){"use strict";var E=new n.Cartesian3,T=new t.BoundingRectangle,D=new n.Cartesian2,_=new n.Cartesian2,V=new n.Cartesian3,k=new n.Cartesian3,R=new n.Cartesian3,I=new n.Cartesian3,M=new n.Cartesian3,B=new n.Cartesian3,H=new a.Quaternion,O=new n.Matrix3,z=new n.Matrix3,S=new n.Cartesian3;function N(e,t,r,i,l,c,y,u){var g=e.positions,b=d.PolygonPipeline.triangulate(e.positions2D,e.holes);b.length<3&&(b=[0,1,2]);var v=m.IndexDatatype.createTypedArray(g.length,b.length);v.set(b);var f=O;if(0!==i){var h=a.Quaternion.fromAxisAngle(c,i,H);if(f=n.Matrix3.fromQuaternion(h,f),t.tangent||t.bitangent){h=a.Quaternion.fromAxisAngle(c,-i,H);var x=n.Matrix3.fromQuaternion(h,z);y=n.Cartesian3.normalize(n.Matrix3.multiplyByVector(x,y,y),y),t.bitangent&&(u=n.Cartesian3.normalize(n.Cartesian3.cross(c,y,u),u))}}else f=n.Matrix3.clone(n.Matrix3.IDENTITY,f);var C=_;t.st&&(C.x=r.x,C.y=r.y);for(var P=g.length,A=3*P,w=new Float64Array(A),F=t.normal?new Float32Array(A):void 0,G=t.tangent?new Float32Array(A):void 0,L=t.bitangent?new Float32Array(A):void 0,T=t.st?new Float32Array(2*P):void 0,V=0,k=0,R=0,I=0,M=0,B=0;B<P;B++){var S=g[B];if(w[V++]=S.x,w[V++]=S.y,w[V++]=S.z,t.st){var N=l(n.Matrix3.multiplyByVector(f,S,E),D);n.Cartesian2.subtract(N,C,N);var Q=o.CesiumMath.clamp(N.x/r.width,0,1),j=o.CesiumMath.clamp(N.y/r.height,0,1);T[M++]=Q,T[M++]=j}t.normal&&(F[k++]=c.x,F[k++]=c.y,F[k++]=c.z),t.tangent&&(G[I++]=y.x,G[I++]=y.y,G[I++]=y.z),t.bitangent&&(L[R++]=u.x,L[R++]=u.y,L[R++]=u.z)}var U=new p.GeometryAttributes;return t.position&&(U.position=new s.GeometryAttribute({componentDatatype:o.ComponentDatatype.DOUBLE,componentsPerAttribute:3,values:w})),t.normal&&(U.normal=new s.GeometryAttribute({componentDatatype:o.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:F})),t.tangent&&(U.tangent=new s.GeometryAttribute({componentDatatype:o.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:G})),t.bitangent&&(U.bitangent=new s.GeometryAttribute({componentDatatype:o.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:L})),t.st&&(U.st=new s.GeometryAttribute({componentDatatype:o.ComponentDatatype.FLOAT,componentsPerAttribute:2,values:T})),new s.Geometry({attributes:U,indices:v,primitiveType:s.PrimitiveType.TRIANGLES})}function Q(e){var t=(e=l.defaultValue(e,l.defaultValue.EMPTY_OBJECT)).polygonHierarchy,a=l.defaultValue(e.vertexFormat,g.VertexFormat.DEFAULT);this._vertexFormat=g.VertexFormat.clone(a),this._polygonHierarchy=t,this._stRotation=l.defaultValue(e.stRotation,0),this._ellipsoid=n.Ellipsoid.clone(l.defaultValue(e.ellipsoid,n.Ellipsoid.WGS84)),this._workerName="createCoplanarPolygonGeometry",this.packedLength=u.PolygonGeometryLibrary.computeHierarchyPackedLength(t)+g.VertexFormat.packedLength+n.Ellipsoid.packedLength+2}Q.fromPositions=function(e){return new Q({polygonHierarchy:{positions:(e=l.defaultValue(e,l.defaultValue.EMPTY_OBJECT)).positions},vertexFormat:e.vertexFormat,stRotation:e.stRotation,ellipsoid:e.ellipsoid})},Q.pack=function(e,t,a){return a=l.defaultValue(a,0),a=u.PolygonGeometryLibrary.packPolygonHierarchy(e._polygonHierarchy,t,a),n.Ellipsoid.pack(e._ellipsoid,t,a),a+=n.Ellipsoid.packedLength,g.VertexFormat.pack(e._vertexFormat,t,a),a+=g.VertexFormat.packedLength,t[a++]=e._stRotation,t[a]=e.packedLength,t};var j=n.Ellipsoid.clone(n.Ellipsoid.UNIT_SPHERE),U=new g.VertexFormat,Y={polygonHierarchy:{}};return Q.unpack=function(e,t,a){t=l.defaultValue(t,0);var r=u.PolygonGeometryLibrary.unpackPolygonHierarchy(e,t);t=r.startingIndex,delete r.startingIndex;var o=n.Ellipsoid.unpack(e,t,j);t+=n.Ellipsoid.packedLength;var i=g.VertexFormat.unpack(e,t,U);t+=g.VertexFormat.packedLength;var s=e[t++],p=e[t];return l.defined(a)||(a=new Q(Y)),a._polygonHierarchy=r,a._ellipsoid=n.Ellipsoid.clone(o,a._ellipsoid),a._vertexFormat=g.VertexFormat.clone(i,a._vertexFormat),a._stRotation=s,a.packedLength=p,a},Q.createGeometry=function(t){var r=t._vertexFormat,l=t._polygonHierarchy,p=t._stRotation,d=l.positions;if(!((d=e.arrayRemoveDuplicates(d,n.Cartesian3.equalsEpsilon,!0)).length<3)){var g=V,b=k,v=R,f=M,h=B;if(i.CoplanarPolygonGeometryLibrary.computeProjectTo2DArguments(d,I,f,h)){if(g=n.Cartesian3.cross(f,h,g),g=n.Cartesian3.normalize(g,g),!n.Cartesian3.equalsEpsilon(I,n.Cartesian3.ZERO,o.CesiumMath.EPSILON6)){var x=t._ellipsoid.geodeticSurfaceNormal(I,S);n.Cartesian3.dot(g,x)<0&&(g=n.Cartesian3.negate(g,g),f=n.Cartesian3.negate(f,f))}var C=i.CoplanarPolygonGeometryLibrary.createProjectPointsTo2DFunction(I,f,h),P=i.CoplanarPolygonGeometryLibrary.createProjectPointTo2DFunction(I,f,h);r.tangent&&(b=n.Cartesian3.clone(f,b)),r.bitangent&&(v=n.Cartesian3.clone(h,v));var A=u.PolygonGeometryLibrary.polygonsFromHierarchy(l,C,!1),w=A.hierarchy,F=A.polygons;if(0!==w.length){d=w[0].outerRing;for(var G=a.BoundingSphere.fromPoints(d),L=u.PolygonGeometryLibrary.computeBoundingRectangle(g,P,d,p,T),E=[],D=0;D<F.length;D++){var _=new c.GeometryInstance({geometry:N(F[D],r,L,p,P,g,b,v)});E.push(_)}var H=y.GeometryPipeline.combineInstances(E)[0];H.attributes.position.values=new Float64Array(H.attributes.position.values),H.indices=m.IndexDatatype.createTypedArray(H.attributes.position.values.length/3,H.indices);var O=H.attributes;return r.position||delete O.position,new s.Geometry({attributes:O,indices:H.indices,primitiveType:H.primitiveType,boundingSphere:G})}}}},function(e,t){return l.defined(t)&&(e=Q.unpack(e,t)),Q.createGeometry(e)}}));
|