fuchengshen
2022-07-04 343ba87e09501be7a63abde000a43e13a5b4f03e
1
define(["./arrayRemoveDuplicates-47b233f1","./BoundingRectangle-df67ecf0","./Transforms-a7d32f6c","./Cartesian2-40b13f31","./Check-3917d765","./ComponentDatatype-6c2e43c1","./CoplanarPolygonGeometryLibrary-c86d51c7","./when-7b580518","./GeometryAttribute-8f00b923","./GeometryAttributes-fbd9a3fb","./GeometryInstance-e5765c46","./GeometryPipeline-06778f23","./IndexDatatype-b42089ce","./Math-87254c13","./PolygonGeometryLibrary-3364a920","./PolygonPipeline-4cefc824","./VertexFormat-8d463a4f","./combine-83aa7971","./RuntimeError-fad4d3c6","./WebGLConstants-4e26b85a","./OrientedBoundingBox-714102d2","./EllipsoidTangentPlane-b7b148bd","./AxisAlignedBoundingBox-14881a9b","./IntersectionTests-2dece3b4","./Plane-69fa3eea","./AttributeCompression-56959beb","./EncodedCartesian3-942c4568","./ArcType-1da7fdca","./EllipsoidRhumbLine-6baec512"],function(h,e,L,E,t,T,f,l,D,_,C,v,k,V,x,R,s,n,a,r,o,i,p,c,y,m,u,d,g){"use strict";var I=new E.Cartesian3,P=new e.BoundingRectangle,M=new E.Cartesian2,B=new E.Cartesian2,A=new E.Cartesian3,w=new E.Cartesian3,F=new E.Cartesian3,G=new E.Cartesian3,H=new E.Cartesian3,O=new E.Cartesian3,z=new L.Quaternion,S=new L.Matrix3,N=new L.Matrix3,Q=new E.Cartesian3;function b(e){var t=(e=l.defaultValue(e,l.defaultValue.EMPTY_OBJECT)).polygonHierarchy,n=l.defaultValue(e.vertexFormat,s.VertexFormat.DEFAULT);this._vertexFormat=s.VertexFormat.clone(n),this._polygonHierarchy=t,this._stRotation=l.defaultValue(e.stRotation,0),this._ellipsoid=E.Ellipsoid.clone(l.defaultValue(e.ellipsoid,E.Ellipsoid.WGS84)),this._workerName="createCoplanarPolygonGeometry",this.packedLength=x.PolygonGeometryLibrary.computeHierarchyPackedLength(t)+s.VertexFormat.packedLength+E.Ellipsoid.packedLength+2}b.fromPositions=function(e){return new b({polygonHierarchy:{positions:(e=l.defaultValue(e,l.defaultValue.EMPTY_OBJECT)).positions},vertexFormat:e.vertexFormat,stRotation:e.stRotation,ellipsoid:e.ellipsoid})},b.pack=function(e,t,n){return n=l.defaultValue(n,0),n=x.PolygonGeometryLibrary.packPolygonHierarchy(e._polygonHierarchy,t,n),E.Ellipsoid.pack(e._ellipsoid,t,n),n+=E.Ellipsoid.packedLength,s.VertexFormat.pack(e._vertexFormat,t,n),n+=s.VertexFormat.packedLength,t[n++]=e._stRotation,t[n]=e.packedLength,t};var j=E.Ellipsoid.clone(E.Ellipsoid.UNIT_SPHERE),U=new s.VertexFormat,Y={polygonHierarchy:{}};return b.unpack=function(e,t,n){t=l.defaultValue(t,0);var a=x.PolygonGeometryLibrary.unpackPolygonHierarchy(e,t);t=a.startingIndex,delete a.startingIndex;var r=E.Ellipsoid.unpack(e,t,j);t+=E.Ellipsoid.packedLength;var o=s.VertexFormat.unpack(e,t,U);t+=s.VertexFormat.packedLength;var i=e[t++],t=e[t];return(n=!l.defined(n)?new b(Y):n)._polygonHierarchy=a,n._ellipsoid=E.Ellipsoid.clone(r,n._ellipsoid),n._vertexFormat=s.VertexFormat.clone(o,n._vertexFormat),n._stRotation=i,n.packedLength=t,n},b.createGeometry=function(e){var t=e._vertexFormat,n=e._polygonHierarchy,a=e._stRotation,r=n.positions;if(!((r=h.arrayRemoveDuplicates(r,E.Cartesian3.equalsEpsilon,!0)).length<3)){var o=A,i=w,l=F,s=H,p=O;if(f.CoplanarPolygonGeometryLibrary.computeProjectTo2DArguments(r,G,s,p)){o=E.Cartesian3.cross(s,p,o);o=E.Cartesian3.normalize(o,o),E.Cartesian3.equalsEpsilon(G,E.Cartesian3.ZERO,V.CesiumMath.EPSILON6)||(c=e._ellipsoid.geodeticSurfaceNormal(G,Q),E.Cartesian3.dot(o,c)<0&&(o=E.Cartesian3.negate(o,o),s=E.Cartesian3.negate(s,s)));var c=f.CoplanarPolygonGeometryLibrary.createProjectPointsTo2DFunction(G,s,p),y=f.CoplanarPolygonGeometryLibrary.createProjectPointTo2DFunction(G,s,p);t.tangent&&(i=E.Cartesian3.clone(s,i)),t.bitangent&&(l=E.Cartesian3.clone(p,l));var n=x.PolygonGeometryLibrary.polygonsFromHierarchy(n,c,!1),c=n.hierarchy,m=n.polygons;if(0!==c.length){for(var r=c[0].outerRing,n=L.BoundingSphere.fromPoints(r),u=x.PolygonGeometryLibrary.computeBoundingRectangle(o,y,r,a,P),d=[],g=0;g<m.length;g++){var b=new C.GeometryInstance({geometry:function(e,t,n,a,r,o,i,l){var s=e.positions,p=R.PolygonPipeline.triangulate(e.positions2D,e.holes);p.length<3&&(p=[0,1,2]),(e=k.IndexDatatype.createTypedArray(s.length,p.length)).set(p);var c=S;0!==a?(p=L.Quaternion.fromAxisAngle(o,a,z),c=L.Matrix3.fromQuaternion(p,c),(t.tangent||t.bitangent)&&(p=L.Quaternion.fromAxisAngle(o,-a,z),u=L.Matrix3.fromQuaternion(p,N),i=E.Cartesian3.normalize(L.Matrix3.multiplyByVector(u,i,i),i),t.bitangent&&(l=E.Cartesian3.normalize(E.Cartesian3.cross(o,i,l),l)))):c=L.Matrix3.clone(L.Matrix3.IDENTITY,c);var y=B;t.st&&(y.x=n.x,y.y=n.y);for(var m=s.length,u=3*m,d=new Float64Array(u),g=t.normal?new Float32Array(u):void 0,b=t.tangent?new Float32Array(u):void 0,h=t.bitangent?new Float32Array(u):void 0,f=t.st?new Float32Array(2*m):void 0,C=0,v=0,x=0,P=0,A=0,w=0;w<m;w++){var F,G=s[w];d[C++]=G.x,d[C++]=G.y,d[C++]=G.z,t.st&&(F=r(L.Matrix3.multiplyByVector(c,G,I),M),E.Cartesian2.subtract(F,y,F),G=V.CesiumMath.clamp(F.x/n.width,0,1),F=V.CesiumMath.clamp(F.y/n.height,0,1),f[A++]=G,f[A++]=F),t.normal&&(g[v++]=o.x,g[v++]=o.y,g[v++]=o.z),t.tangent&&(b[P++]=i.x,b[P++]=i.y,b[P++]=i.z),t.bitangent&&(h[x++]=l.x,h[x++]=l.y,h[x++]=l.z)}return u=new _.GeometryAttributes,t.position&&(u.position=new D.GeometryAttribute({componentDatatype:T.ComponentDatatype.DOUBLE,componentsPerAttribute:3,values:d})),t.normal&&(u.normal=new D.GeometryAttribute({componentDatatype:T.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:g})),t.tangent&&(u.tangent=new D.GeometryAttribute({componentDatatype:T.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:b})),t.bitangent&&(u.bitangent=new D.GeometryAttribute({componentDatatype:T.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:h})),t.st&&(u.st=new D.GeometryAttribute({componentDatatype:T.ComponentDatatype.FLOAT,componentsPerAttribute:2,values:f})),new D.Geometry({attributes:u,indices:e,primitiveType:D.PrimitiveType.TRIANGLES})}(m[g],t,u,a,y,o,i,l)});d.push(b)}c=v.GeometryPipeline.combineInstances(d)[0];c.attributes.position.values=new Float64Array(c.attributes.position.values),c.indices=k.IndexDatatype.createTypedArray(c.attributes.position.values.length/3,c.indices);r=c.attributes;return t.position||delete r.position,new D.Geometry({attributes:r,indices:c.indices,primitiveType:c.primitiveType,boundingSphere:n})}}}},function(e,t){return l.defined(t)&&(e=b.unpack(e,t)),b.createGeometry(e)}});