createCoplanarPolygonOutlineGeometry.js 2.6 KB

1
  1. define(["./when-54c2dc71","./Check-6c0211bc","./Math-fc8cecf5","./Cartesian2-bddc1162","./Transforms-ec27f304","./RuntimeError-2109023a","./WebGLConstants-76bb35d1","./ComponentDatatype-6d99a1ee","./GeometryAttribute-44fb48f1","./GeometryAttributes-4fcfcf40","./AttributeCompression-9fc99391","./GeometryPipeline-b49b2e59","./EncodedCartesian3-e9c71cf0","./IndexDatatype-53503fee","./IntersectionTests-2626c9e9","./Plane-231f1723","./GeometryInstance-11f9a3bd","./arrayRemoveDuplicates-ebc732b0","./EllipsoidTangentPlane-ed172748","./OrientedBoundingBox-c9ad91c4","./CoplanarPolygonGeometryLibrary-dc8e954f","./ArcType-dc1c5aee","./EllipsoidRhumbLine-c704bf4c","./PolygonPipeline-ff364b47","./PolygonGeometryLibrary-29b9a52e"],function(i,e,t,l,p,r,n,s,u,d,o,f,a,m,y,c,g,b,h,P,G,v,L,C,T){"use strict";function E(e){var t=(e=i.defaultValue(e,i.defaultValue.EMPTY_OBJECT)).polygonHierarchy;this._polygonHierarchy=t,this._workerName="createCoplanarPolygonOutlineGeometry",this.packedLength=T.PolygonGeometryLibrary.computeHierarchyPackedLength(t)+1}E.fromPositions=function(e){return new E({polygonHierarchy:{positions:(e=i.defaultValue(e,i.defaultValue.EMPTY_OBJECT)).positions}})},E.pack=function(e,t,r){return r=i.defaultValue(r,0),t[r=T.PolygonGeometryLibrary.packPolygonHierarchy(e._polygonHierarchy,t,r)]=e.packedLength,t};var k={polygonHierarchy:{}};return E.unpack=function(e,t,r){t=i.defaultValue(t,0);var n=T.PolygonGeometryLibrary.unpackPolygonHierarchy(e,t);t=n.startingIndex,delete n.startingIndex;var o=e[t];return i.defined(r)||(r=new E(k)),r._polygonHierarchy=n,r.packedLength=o,r},E.createGeometry=function(e){var t=e._polygonHierarchy,r=t.positions;if(!((r=b.arrayRemoveDuplicates(r,l.Cartesian3.equalsEpsilon,!0)).length<3)&&G.CoplanarPolygonGeometryLibrary.validOutline(r)){var n=T.PolygonGeometryLibrary.polygonOutlinesFromHierarchy(t,!1);if(0!==n.length){for(var o=[],i=0;i<n.length;i++){var a=new g.GeometryInstance({geometry:function(e){for(var t=e.length,r=new Float64Array(3*t),n=m.IndexDatatype.createTypedArray(t,2*t),o=0,i=0,a=0;a<t;a++){var y=e[a];r[o++]=y.x,r[o++]=y.y,r[o++]=y.z,n[i++]=a,n[i++]=(a+1)%t}var c=new d.GeometryAttributes({position:new u.GeometryAttribute({componentDatatype:s.ComponentDatatype.DOUBLE,componentsPerAttribute:3,values:r})});return new u.Geometry({attributes:c,indices:n,primitiveType:u.PrimitiveType.LINES})}(n[i])});o.push(a)}var y=f.GeometryPipeline.combineInstances(o)[0],c=p.BoundingSphere.fromPoints(t.positions);return new u.Geometry({attributes:y.attributes,indices:y.indices,primitiveType:y.primitiveType,boundingSphere:c})}}},function(e,t){return i.defined(t)&&(e=E.unpack(e,t)),e._ellipsoid=l.Ellipsoid.clone(e._ellipsoid),E.createGeometry(e)}});