Newer
Older
ganzhou-feidu / static / lib / freedo / Freedo / Workers / createCoplanarPolygonGeometry.js
bairujie on 14 Apr 2023 6 KB init
define(["./when-cbf8cd21","./Check-35e1a91d","./Math-e66fad2a","./Cartesian2-44433f55","./Matrix3-146a3f23","./Transforms-fc4c03e8","./RuntimeError-f4c64df1","./WebGLConstants-95ceb4e9","./ComponentDatatype-7ee14e67","./GeometryAttribute-dee5e12d","./GeometryAttributes-90846c5f","./AttributeCompression-170b3be0","./GeometryPipeline-36144dac","./EncodedCartesian3-86f19ac2","./IndexDatatype-66caba23","./IntersectionTests-caa0ba1a","./Plane-e04c899a","./VertexFormat-cc24f342","./GeometryInstance-398c27d3","./arrayRemoveDuplicates-b817241d","./BoundingRectangle-bef3979e","./EllipsoidTangentPlane-d27aa001","./OrientedBoundingBox-6e047f5d","./CoplanarPolygonGeometryLibrary-3781c48e","./ArcType-2b58731c","./EllipsoidRhumbLine-862a2df4","./PolygonPipeline-b54c9b74","./PolygonGeometryLibrary-6b267a69"],function(s,e,V,R,M,I,t,a,H,B,O,n,w,r,z,o,i,p,A,F,l,c,y,G,m,u,S,L){"use strict";var N=new R.Cartesian3,E=new l.BoundingRectangle,Q=new R.Cartesian2,j=new R.Cartesian2,T=new R.Cartesian3,D=new R.Cartesian3,_=new R.Cartesian3,k=new R.Cartesian3,U=new R.Cartesian3,Y=new R.Cartesian3,q=new I.Quaternion,J=new M.Matrix3,W=new M.Matrix3,Z=new R.Cartesian3;function d(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}d.fromPositions=function(e){return new d({polygonHierarchy:{positions:(e=s.defaultValue(e,s.defaultValue.EMPTY_OBJECT)).positions},vertexFormat:e.vertexFormat,stRotation:e.stRotation,ellipsoid:e.ellipsoid})},d.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 g=R.Ellipsoid.clone(R.Ellipsoid.UNIT_SPHERE),b=new p.VertexFormat,h={polygonHierarchy:{}};return d.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,g);t+=R.Ellipsoid.packedLength;var o=p.VertexFormat.unpack(e,t,b);t+=p.VertexFormat.packedLength;var i=e[t++],l=e[t];return s.defined(a)||(a=new d(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},d.createGeometry=function(e){var t=e._vertexFormat,a=e._polygonHierarchy,n=e._stRotation,r=a.positions;if(!((r=F.arrayRemoveDuplicates(r,R.Cartesian3.equalsEpsilon,!0)).length<3)){var o=T,i=D,l=_,s=U,p=Y;if(G.CoplanarPolygonGeometryLibrary.computeProjectTo2DArguments(r,k,s,p)){var c,o=R.Cartesian3.cross(s,p,o);o=R.Cartesian3.normalize(o,o),R.Cartesian3.equalsEpsilon(k,R.Cartesian3.ZERO,V.CesiumMath.EPSILON6)||(c=e._ellipsoid.geodeticSurfaceNormal(k,Z),R.Cartesian3.dot(o,c)<0&&(o=R.Cartesian3.negate(o,o),s=R.Cartesian3.negate(s,s)));var y=G.CoplanarPolygonGeometryLibrary.createProjectPointsTo2DFunction(k,s,p),m=G.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,y,!1),d=u.hierarchy,g=u.polygons;if(0!==d.length){r=d[0].outerRing;for(var b=I.BoundingSphere.fromPoints(r),h=L.PolygonGeometryLibrary.computeBoundingRectangle(o,m,r,n,E),v=[],f=0;f<g.length;f++){var C=new A.GeometryInstance({geometry:function(e,t,a,n,r,o,i,l){var s=e.positions,p=S.PolygonPipeline.triangulate(e.positions2D,e.holes);p.length<3&&(p=[0,1,2]);var c=z.IndexDatatype.createTypedArray(s.length,p.length);c.set(p);var y,m,u=J;0!==n?(y=I.Quaternion.fromAxisAngle(o,n,q),u=M.Matrix3.fromQuaternion(y,u),(t.tangent||t.bitangent)&&(y=I.Quaternion.fromAxisAngle(o,-n,q),m=M.Matrix3.fromQuaternion(y,W),i=R.Cartesian3.normalize(M.Matrix3.multiplyByVector(m,i,i),i),t.bitangent&&(l=R.Cartesian3.normalize(R.Cartesian3.cross(o,i,l),l)))):u=M.Matrix3.clone(M.Matrix3.IDENTITY,u);var d=j;t.st&&(d.x=a.x,d.y=a.y);for(var g=s.length,b=3*g,h=new Float64Array(b),v=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,T,D,_=s[L];h[P++]=_.x,h[P++]=_.y,h[P++]=_.z,t.st&&(E=r(M.Matrix3.multiplyByVector(u,_,N),Q),R.Cartesian2.subtract(E,d,E),T=V.CesiumMath.clamp(E.x/a.width,0,1),D=V.CesiumMath.clamp(E.y/a.height,0,1),x[G++]=T,x[G++]=D),t.normal&&(v[w++]=o.x,v[w++]=o.y,v[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 O.GeometryAttributes;return t.position&&(k.position=new B.GeometryAttribute({componentDatatype:H.ComponentDatatype.DOUBLE,componentsPerAttribute:3,values:h})),t.normal&&(k.normal=new B.GeometryAttribute({componentDatatype:H.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:v})),t.tangent&&(k.tangent=new B.GeometryAttribute({componentDatatype:H.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:f})),t.bitangent&&(k.bitangent=new B.GeometryAttribute({componentDatatype:H.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:C})),t.st&&(k.st=new B.GeometryAttribute({componentDatatype:H.ComponentDatatype.FLOAT,componentsPerAttribute:2,values:x})),new B.Geometry({attributes:k,indices:c,primitiveType:B.PrimitiveType.TRIANGLES})}(g[f],t,h,n,m,o,i,l)});v.push(C)}var x=w.GeometryPipeline.combineInstances(v)[0];x.attributes.position.values=new Float64Array(x.attributes.position.values),x.indices=z.IndexDatatype.createTypedArray(x.attributes.position.values.length/3,x.indices);var P=x.attributes;return t.position||delete P.position,new B.Geometry({attributes:P,indices:x.indices,primitiveType:x.primitiveType,boundingSphere:b})}}}},function(e,t){return s.defined(t)&&(e=d.unpack(e,t)),d.createGeometry(e)}});