2 lines
5.5 KiB
JavaScript
2 lines
5.5 KiB
JavaScript
define(["exports","./GeometryOffsetAttribute-ed56ff58","./BoundingSphere-9a3b5656","./Cartesian3-e0307675","./ComponentDatatype-aaeec80f","./defaultValue-81eec7ed","./Check-741c5f3c","./EllipseGeometryLibrary-6649af71","./Cartesian2-bd414876","./GeometryAttribute-2b42a913","./GeometryAttributes-32b29525","./IndexDatatype-3f3c99e8","./Math-e73894ab"],(function(e,t,i,r,n,a,o,s,l,u,d,c,p){"use strict";const f=new r.Cartesian3;let m=new r.Cartesian3;const h=new i.BoundingSphere,y=new i.BoundingSphere;function b(e){const t=(e=a.defaultValue(e,a.defaultValue.EMPTY_OBJECT)).center,i=a.defaultValue(e.ellipsoid,l.Ellipsoid.WGS84),n=e.semiMajorAxis,o=e.semiMinorAxis,s=a.defaultValue(e.granularity,p.CesiumMath.RADIANS_PER_DEGREE),u=a.defaultValue(e.height,0),d=a.defaultValue(e.extrudedHeight,u);this._center=r.Cartesian3.clone(t),this._semiMajorAxis=n,this._semiMinorAxis=o,this._ellipsoid=l.Ellipsoid.clone(i),this._rotation=a.defaultValue(e.rotation,0),this._height=Math.max(d,u),this._granularity=s,this._extrudedHeight=Math.min(d,u),this._numberOfVerticalLines=Math.max(a.defaultValue(e.numberOfVerticalLines,16),0),this._offsetAttribute=e.offsetAttribute,this._workerName="createEllipseOutlineGeometry"}b.packedLength=r.Cartesian3.packedLength+l.Ellipsoid.packedLength+8,b.pack=function(e,t,i){return i=a.defaultValue(i,0),r.Cartesian3.pack(e._center,t,i),i+=r.Cartesian3.packedLength,l.Ellipsoid.pack(e._ellipsoid,t,i),i+=l.Ellipsoid.packedLength,t[i++]=e._semiMajorAxis,t[i++]=e._semiMinorAxis,t[i++]=e._rotation,t[i++]=e._height,t[i++]=e._granularity,t[i++]=e._extrudedHeight,t[i++]=e._numberOfVerticalLines,t[i]=a.defaultValue(e._offsetAttribute,-1),t};const A=new r.Cartesian3,_=new l.Ellipsoid,g={center:A,ellipsoid:_,semiMajorAxis:void 0,semiMinorAxis:void 0,rotation:void 0,height:void 0,granularity:void 0,extrudedHeight:void 0,numberOfVerticalLines:void 0,offsetAttribute:void 0};b.unpack=function(e,t,i){t=a.defaultValue(t,0);const n=r.Cartesian3.unpack(e,t,A);t+=r.Cartesian3.packedLength;const o=l.Ellipsoid.unpack(e,t,_);t+=l.Ellipsoid.packedLength;const s=e[t++],u=e[t++],d=e[t++],c=e[t++],p=e[t++],f=e[t++],m=e[t++],h=e[t];return a.defined(i)?(i._center=r.Cartesian3.clone(n,i._center),i._ellipsoid=l.Ellipsoid.clone(o,i._ellipsoid),i._semiMajorAxis=s,i._semiMinorAxis=u,i._rotation=d,i._height=c,i._granularity=p,i._extrudedHeight=f,i._numberOfVerticalLines=m,i._offsetAttribute=-1===h?void 0:h,i):(g.height=c,g.extrudedHeight=f,g.granularity=p,g.rotation=d,g.semiMajorAxis=s,g.semiMinorAxis=u,g.numberOfVerticalLines=m,g.offsetAttribute=-1===h?void 0:h,new b(g))},b.createGeometry=function(e){if(e._semiMajorAxis<=0||e._semiMinorAxis<=0)return;const o=e._height,l=e._extrudedHeight,b=!p.CesiumMath.equalsEpsilon(o,l,0,p.CesiumMath.EPSILON2);e._center=e._ellipsoid.scaleToGeodeticSurface(e._center,e._center);const A={center:e._center,semiMajorAxis:e._semiMajorAxis,semiMinorAxis:e._semiMinorAxis,ellipsoid:e._ellipsoid,rotation:e._rotation,height:o,granularity:e._granularity,numberOfVerticalLines:e._numberOfVerticalLines};let _;if(b)A.extrudedHeight=l,A.offsetAttribute=e._offsetAttribute,_=function(e){const o=e.center,l=e.ellipsoid,m=e.semiMajorAxis;let b=r.Cartesian3.multiplyByScalar(l.geodeticSurfaceNormal(o,f),e.height,f);h.center=r.Cartesian3.add(o,b,h.center),h.radius=m,b=r.Cartesian3.multiplyByScalar(l.geodeticSurfaceNormal(o,b),e.extrudedHeight,b),y.center=r.Cartesian3.add(o,b,y.center),y.radius=m;let A=s.EllipseGeometryLibrary.computeEllipsePositions(e,!1,!0).outerPositions;const _=new d.GeometryAttributes({position:new u.GeometryAttribute({componentDatatype:n.ComponentDatatype.DOUBLE,componentsPerAttribute:3,values:s.EllipseGeometryLibrary.raisePositionsToHeight(A,e,!0)})});A=_.position.values;const g=i.BoundingSphere.union(h,y);let x=A.length/3;if(a.defined(e.offsetAttribute)){let i=new Uint8Array(x);if(e.offsetAttribute===t.GeometryOffsetAttribute.TOP)i=t.arrayFill(i,1,0,x/2);else{const r=e.offsetAttribute===t.GeometryOffsetAttribute.NONE?0:1;i=t.arrayFill(i,r)}_.applyOffset=new u.GeometryAttribute({componentDatatype:n.ComponentDatatype.UNSIGNED_BYTE,componentsPerAttribute:1,values:i})}let E=a.defaultValue(e.numberOfVerticalLines,16);E=p.CesiumMath.clamp(E,0,x/2);const M=c.IndexDatatype.createTypedArray(x,2*x+2*E);x/=2;let C,G,L=0;for(C=0;C<x;++C)M[L++]=C,M[L++]=(C+1)%x,M[L++]=C+x,M[L++]=(C+1)%x+x;if(E>0){const e=Math.min(E,x);G=Math.round(x/e);const t=Math.min(G*E,x);for(C=0;C<t;C+=G)M[L++]=C,M[L++]=C+x}return{boundingSphere:g,attributes:_,indices:M}}(A);else if(_=function(e){const t=e.center;m=r.Cartesian3.multiplyByScalar(e.ellipsoid.geodeticSurfaceNormal(t,m),e.height,m),m=r.Cartesian3.add(t,m,m);const a=new i.BoundingSphere(m,e.semiMajorAxis),o=s.EllipseGeometryLibrary.computeEllipsePositions(e,!1,!0).outerPositions,l=new d.GeometryAttributes({position:new u.GeometryAttribute({componentDatatype:n.ComponentDatatype.DOUBLE,componentsPerAttribute:3,values:s.EllipseGeometryLibrary.raisePositionsToHeight(o,e,!1)})}),p=o.length/3,f=c.IndexDatatype.createTypedArray(p,2*p);let h=0;for(let e=0;e<p;++e)f[h++]=e,f[h++]=(e+1)%p;return{boundingSphere:a,attributes:l,indices:f}}(A),a.defined(e._offsetAttribute)){const i=_.attributes.position.values.length,r=new Uint8Array(i/3),a=e._offsetAttribute===t.GeometryOffsetAttribute.NONE?0:1;t.arrayFill(r,a),_.attributes.applyOffset=new u.GeometryAttribute({componentDatatype:n.ComponentDatatype.UNSIGNED_BYTE,componentsPerAttribute:1,values:r})}return new u.Geometry({attributes:_.attributes,indices:_.indices,primitiveType:u.PrimitiveType.LINES,boundingSphere:_.boundingSphere,offsetAttribute:e._offsetAttribute})},e.EllipseOutlineGeometry=b}));
|