define(["./arrayRemoveDuplicates-6dfd408b","./BoundingRectangle-9e73068f","./Transforms-b51fdb37","./Rectangle-82621db8","./Check-24483042","./ComponentDatatype-1a100acd","./CoplanarPolygonGeometryLibrary-92e889f6","./when-54335d57","./GeometryAttribute-02fdce7a","./GeometryAttributes-caa08d6c","./GeometryInstance-4247a2b3","./GeometryPipeline-6bfd5efb","./IndexDatatype-edb2f4d6","./Math-7a8129d6","./PolygonGeometryLibrary-340be930","./PolygonPipeline-be37706f","./VertexFormat-81ec7207","./RuntimeError-88a32665","./PixelFormat-d198afce","./WebGLConstants-95ceb4e9","./OrientedBoundingBox-108c8b47","./EllipsoidTangentPlane-3e9e5847","./IntersectionTests-afc06c64","./Plane-fd9e13db","./AttributeCompression-3961575e","./EncodedCartesian3-c7ed7a62","./ArcType-2b58731c","./EllipsoidRhumbLine-2550c0e1"],function(w,e,V,R,t,I,A,s,M,H,F,G,B,O,L,z,p,a,n,r,o,i,l,y,c,m,u,d){"use strict";var S=new R.Cartesian3,E=new e.BoundingRectangle,N=new R.Cartesian2,Q=new R.Cartesian2,T=new R.Cartesian3,D=new R.Cartesian3,_=new R.Cartesian3,k=new R.Cartesian3,j=new R.Cartesian3,U=new R.Cartesian3,Y=new V.Quaternion,q=new V.Matrix3,J=new V.Matrix3,W=new R.Cartesian3;function Z(e,t,a,n,r,o,i,l){var s=e.positions,p=z.PolygonPipeline.triangulate(e.positions2D,e.holes);p.length<3&&(p=[0,1,2]);var y=B.IndexDatatype.createTypedArray(s.length,p.length);y.set(p);var c=q;if(0!==n){var m=V.Quaternion.fromAxisAngle(o,n,Y);if(c=V.Matrix3.fromQuaternion(m,c),t.tangent||t.bitangent){m=V.Quaternion.fromAxisAngle(o,-n,Y);var u=V.Matrix3.fromQuaternion(m,J);i=R.Cartesian3.normalize(V.Matrix3.multiplyByVector(u,i,i),i),t.bitangent&&(l=R.Cartesian3.normalize(R.Cartesian3.cross(o,i,l),l))}}else c=V.Matrix3.clone(V.Matrix3.IDENTITY,c);var d=Q;t.st&&(d.x=a.x,d.y=a.y);for(var g=s.length,b=3*g,v=new Float64Array(b),h=t.normal?new Float32Array(b):void 0,f=t.tangent?new Float32Array(b):void 0,C=t.bitangent?new Float32Array(b):void 0,x=t.st?new Float32Array(2*g):void 0,P=0,w=0,A=0,F=0,G=0,L=0;L<g;L++){var E=s[L];if(v[P++]=E.x,v[P++]=E.y,v[P++]=E.z,t.st){var T=r(V.Matrix3.multiplyByVector(c,E,S),N);R.Cartesian2.subtract(T,d,T);var D=O.CesiumMath.clamp(T.x/a.width,0,1),_=O.CesiumMath.clamp(T.y/a.height,0,1);x[G++]=D,x[G++]=_}t.normal&&(h[w++]=o.x,h[w++]=o.y,h[w++]=o.z),t.tangent&&(f[F++]=i.x,f[F++]=i.y,f[F++]=i.z),t.bitangent&&(C[A++]=l.x,C[A++]=l.y,C[A++]=l.z)}var k=new H.GeometryAttributes;return t.position&&(k.position=new M.GeometryAttribute({componentDatatype:I.ComponentDatatype.DOUBLE,componentsPerAttribute:3,values:v})),t.normal&&(k.normal=new M.GeometryAttribute({componentDatatype:I.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:h})),t.tangent&&(k.tangent=new M.GeometryAttribute({componentDatatype:I.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:f})),t.bitangent&&(k.bitangent=new M.GeometryAttribute({componentDatatype:I.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:C})),t.st&&(k.st=new M.GeometryAttribute({componentDatatype:I.ComponentDatatype.FLOAT,componentsPerAttribute:2,values:x})),new M.Geometry({attributes:k,indices:y,primitiveType:M.PrimitiveType.TRIANGLES})}function g(e){var t=(e=s.defaultValue(e,s.defaultValue.EMPTY_OBJECT)).polygonHierarchy,a=s.defaultValue(e.vertexFormat,p.VertexFormat.DEFAULT);this._vertexFormat=p.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.packedLength=L.PolygonGeometryLibrary.computeHierarchyPackedLength(t)+p.VertexFormat.packedLength+R.Ellipsoid.packedLength+2}g.fromPositions=function(e){return new g({polygonHierarchy:{positions:(e=s.defaultValue(e,s.defaultValue.EMPTY_OBJECT)).positions},vertexFormat:e.vertexFormat,stRotation:e.stRotation,ellipsoid:e.ellipsoid})},g.pack=function(e,t,a){return a=s.defaultValue(a,0),a=L.PolygonGeometryLibrary.packPolygonHierarchy(e._polygonHierarchy,t,a),R.Ellipsoid.pack(e._ellipsoid,t,a),a+=R.Ellipsoid.packedLength,p.VertexFormat.pack(e._vertexFormat,t,a),a+=p.VertexFormat.packedLength,t[a++]=e._stRotation,t[a]=e.packedLength,t};var b=R.Ellipsoid.clone(R.Ellipsoid.UNIT_SPHERE),v=new p.VertexFormat,h={polygonHierarchy:{}};return g.unpack=function(e,t,a){t=s.defaultValue(t,0);var n=L.PolygonGeometryLibrary.unpackPolygonHierarchy(e,t);t=n.startingIndex,delete n.startingIndex;var r=R.Ellipsoid.unpack(e,t,b);t+=R.Ellipsoid.packedLength;var o=p.VertexFormat.unpack(e,t,v);t+=p.VertexFormat.packedLength;var i=e[t++],l=e[t];return s.defined(a)||(a=new g(h)),a._polygonHierarchy=n,a._ellipsoid=R.Ellipsoid.clone(r,a._ellipsoid),a._vertexFormat=p.VertexFormat.clone(o,a._vertexFormat),a._stRotation=i,a.packedLength=l,a},g.createGeometry=function(e){var t=e._vertexFormat,a=e._polygonHierarchy,n=e._stRotation,r=a.positions;if(!((r=w.arrayRemoveDuplicates(r,R.Cartesian3.equalsEpsilon,!0)).length<3)){var o=T,i=D,l=_,s=j,p=U;if(A.CoplanarPolygonGeometryLibrary.computeProjectTo2DArguments(r,k,s,p)){if(o=R.Cartesian3.cross(s,p,o),o=R.Cartesian3.normalize(o,o),!R.Cartesian3.equalsEpsilon(k,R.Cartesian3.ZERO,O.CesiumMath.EPSILON6)){var y=e._ellipsoid.geodeticSurfaceNormal(k,W);R.Cartesian3.dot(o,y)<0&&(o=R.Cartesian3.negate(o,o),s=R.Cartesian3.negate(s,s))}var c=A.CoplanarPolygonGeometryLibrary.createProjectPointsTo2DFunction(k,s,p),m=A.CoplanarPolygonGeometryLibrary.createProjectPointTo2DFunction(k,s,p);t.tangent&&(i=R.Cartesian3.clone(s,i)),t.bitangent&&(l=R.Cartesian3.clone(p,l));var u=L.PolygonGeometryLibrary.polygonsFromHierarchy(a,c,!1),d=u.hierarchy,g=u.polygons;if(0!==d.length){r=d[0].outerRing;for(var b=V.BoundingSphere.fromPoints(r),v=L.PolygonGeometryLibrary.computeBoundingRectangle(o,m,r,n,E),h=[],f=0;f<g.length;f++){var C=new F.GeometryInstance({geometry:Z(g[f],t,v,n,m,o,i,l)});h.push(C)}var x=G.GeometryPipeline.combineInstances(h)[0];x.attributes.position.values=new Float64Array(x.attributes.position.values),x.indices=B.IndexDatatype.createTypedArray(x.attributes.position.values.length/3,x.indices);var P=x.attributes;return t.position||delete P.position,new M.Geometry({attributes:P,indices:x.indices,primitiveType:x.primitiveType,boundingSphere:b})}}}},function(e,t){return s.defined(t)&&(e=g.unpack(e,t)),g.createGeometry(e)}});
|