1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-14 04:11:48 -05:00
sdrangel/plugins/feature/map/Cesium/Workers/createCoplanarPolygonOutlineGeometry.js

2 lines
2.7 KiB
JavaScript
Raw Normal View History

2022-02-04 15:41:22 -05:00
define(["./arrayRemoveDuplicates-ee080d9d","./Transforms-ab7258fe","./Matrix2-46444433","./RuntimeError-608565a6","./ComponentDatatype-692a36d3","./CoplanarPolygonGeometryLibrary-cb05e471","./when-229515d6","./GeometryAttribute-d3bef603","./GeometryAttributes-b253752a","./GeometryInstance-f781740f","./GeometryPipeline-dfaf2218","./IndexDatatype-7c683b18","./PolygonGeometryLibrary-34c93283","./combine-35b6d9cb","./WebGLConstants-f63312fc","./OrientedBoundingBox-2e56130a","./EllipsoidTangentPlane-4deba134","./AxisAlignedBoundingBox-8f6cec20","./IntersectionTests-4cf437d5","./Plane-1f2a7880","./AttributeCompression-95366034","./EncodedCartesian3-d9d33966","./ArcType-e1641d8d","./EllipsoidRhumbLine-9cd85d72","./PolygonPipeline-259e0bdf"],(function(e,t,n,o,r,i,a,y,c,l,s,p,u,d,m,f,g,b,h,P,G,L,T,E,A){"use strict";function C(e){const t=e.length,n=new Float64Array(3*t),o=p.IndexDatatype.createTypedArray(t,2*t);let i=0,a=0;for(let r=0;r<t;r++){const y=e[r];n[i++]=y.x,n[i++]=y.y,n[i++]=y.z,o[a++]=r,o[a++]=(r+1)%t}const l=new c.GeometryAttributes({position:new y.GeometryAttribute({componentDatatype:r.ComponentDatatype.DOUBLE,componentsPerAttribute:3,values:n})});return new y.Geometry({attributes:l,indices:o,primitiveType:y.PrimitiveType.LINES})}function H(e){const t=(e=a.defaultValue(e,a.defaultValue.EMPTY_OBJECT)).polygonHierarchy;this._polygonHierarchy=t,this._workerName="createCoplanarPolygonOutlineGeometry",this.packedLength=u.PolygonGeometryLibrary.computeHierarchyPackedLength(t)+1}H.fromPositions=function(e){return new H({polygonHierarchy:{positions:(e=a.defaultValue(e,a.defaultValue.EMPTY_OBJECT)).positions}})},H.pack=function(e,t,n){return n=a.defaultValue(n,0),t[n=u.PolygonGeometryLibrary.packPolygonHierarchy(e._polygonHierarchy,t,n)]=e.packedLength,t};const k={polygonHierarchy:{}};return H.unpack=function(e,t,n){t=a.defaultValue(t,0);const o=u.PolygonGeometryLibrary.unpackPolygonHierarchy(e,t);t=o.startingIndex,delete o.startingIndex;const r=e[t];return a.defined(n)||(n=new H(k)),n._polygonHierarchy=o,n.packedLength=r,n},H.createGeometry=function(o){const r=o._polygonHierarchy;let a=r.positions;if(a=e.arrayRemoveDuplicates(a,n.Cartesian3.equalsEpsilon,!0),a.length<3)return;if(!i.CoplanarPolygonGeometryLibrary.validOutline(a))return;const c=u.PolygonGeometryLibrary.polygonOutlinesFromHierarchy(r,!1);if(0===c.length)return;const p=[];for(let e=0;e<c.length;e++){const t=new l.GeometryInstance({geometry:C(c[e])});p.push(t)}const d=s.GeometryPipeline.combineInstances(p)[0],m=t.BoundingSphere.fromPoints(r.positions);return new y.Geometry({attributes:d.attributes,indices:d.indices,primitiveType:d.primitiveType,boundingSphere:m})},function(e,t){return a.defined(t)&&(e=H.unpack(e,t)),e._ellipsoid=n.Ellipsoid.clone(e._ellipsoid),H.createGeometry(e)}}));