bmh_cesium/public/lib/cesiumjs/CesiumUnminified/Workers/EllipseOutlineGeometry-5b61f98e.js
2025-03-10 07:23:50 +08:00

2 lines
6.0 KiB
JavaScript

/* 2020-9-22 15:23:25 | 版权所有 军懋国兴 */
define(["exports","./when-cbf8cd21","./Check-35e1a91d","./Math-69007a69","./Cartesian2-43e3a3be","./Transforms-2d1ac5ec","./ComponentDatatype-607c9a0c","./GeometryAttribute-2303bbfb","./GeometryAttributes-90846c5f","./IndexDatatype-79bb407c","./GeometryOffsetAttribute-9c676324","./EllipseGeometryLibrary-304b788d"],function(e,A,c,_,g,v,E,x,M,w,C,D){"use strict";var G=new g.Cartesian3,l=new g.Cartesian3;var L=new v.BoundingSphere,O=new v.BoundingSphere;function m(e){var t=(e=A.defaultValue(e,A.defaultValue.EMPTY_OBJECT)).center,i=A.defaultValue(e.ellipsoid,g.Ellipsoid.WGS84),r=e.semiMajorAxis,a=e.semiMinorAxis,n=A.defaultValue(e.granularity,_.CesiumMath.RADIANS_PER_DEGREE);if(!A.defined(t))throw new c.DeveloperError("center is required.");if(!A.defined(r))throw new c.DeveloperError("semiMajorAxis is required.");if(!A.defined(a))throw new c.DeveloperError("semiMinorAxis is required.");if(r<a)throw new c.DeveloperError("semiMajorAxis must be greater than or equal to the semiMinorAxis.");if(n<=0)throw new c.DeveloperError("granularity must be greater than zero.");var o=A.defaultValue(e.height,0),s=A.defaultValue(e.extrudedHeight,o);this._center=g.Cartesian3.clone(t),this._semiMajorAxis=r,this._semiMinorAxis=a,this._ellipsoid=g.Ellipsoid.clone(i),this._rotation=A.defaultValue(e.rotation,0),this._height=Math.max(s,o),this._granularity=n,this._extrudedHeight=Math.min(s,o),this._numberOfVerticalLines=Math.max(A.defaultValue(e.numberOfVerticalLines,16),0),this._offsetAttribute=e.offsetAttribute,this._workerName="createEllipseOutlineGeometry"}m.packedLength=g.Cartesian3.packedLength+g.Ellipsoid.packedLength+8,m.pack=function(e,t,i){if(!A.defined(e))throw new c.DeveloperError("value is required");if(!A.defined(t))throw new c.DeveloperError("array is required");return i=A.defaultValue(i,0),g.Cartesian3.pack(e._center,t,i),i+=g.Cartesian3.packedLength,g.Ellipsoid.pack(e._ellipsoid,t,i),i+=g.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};var h=new g.Cartesian3,y=new g.Ellipsoid,b={center:h,ellipsoid:y,semiMajorAxis:void 0,semiMinorAxis:void 0,rotation:void 0,height:void 0,granularity:void 0,extrudedHeight:void 0,numberOfVerticalLines:void 0,offsetAttribute:void 0};m.unpack=function(e,t,i){if(!A.defined(e))throw new c.DeveloperError("array is required");t=A.defaultValue(t,0);var r=g.Cartesian3.unpack(e,t,h);t+=g.Cartesian3.packedLength;var a=g.Ellipsoid.unpack(e,t,y);t+=g.Ellipsoid.packedLength;var n=e[t++],o=e[t++],s=e[t++],u=e[t++],l=e[t++],d=e[t++],p=e[t++],f=e[t];return A.defined(i)?(i._center=g.Cartesian3.clone(r,i._center),i._ellipsoid=g.Ellipsoid.clone(a,i._ellipsoid),i._semiMajorAxis=n,i._semiMinorAxis=o,i._rotation=s,i._height=u,i._granularity=l,i._extrudedHeight=d,i._numberOfVerticalLines=p,i._offsetAttribute=-1===f?void 0:f,i):(b.height=u,b.extrudedHeight=d,b.granularity=l,b.rotation=s,b.semiMajorAxis=n,b.semiMinorAxis=o,b.numberOfVerticalLines=p,b.offsetAttribute=-1===f?void 0:f,new m(b))},m.createGeometry=function(e){if(!(e._semiMajorAxis<=0||e._semiMinorAxis<=0)){var t=e._height,i=e._extrudedHeight,r=!_.CesiumMath.equalsEpsilon(t,i,0,_.CesiumMath.EPSILON2);e._center=e._ellipsoid.scaleToGeodeticSurface(e._center,e._center);var a,n,o,s,u={center:e._center,semiMajorAxis:e._semiMajorAxis,semiMinorAxis:e._semiMinorAxis,ellipsoid:e._ellipsoid,rotation:e._rotation,height:t,granularity:e._granularity,numberOfVerticalLines:e._numberOfVerticalLines};return r?(u.extrudedHeight=i,u.offsetAttribute=e._offsetAttribute,s=function(e){var t=e.center,i=e.ellipsoid,r=e.semiMajorAxis,a=g.Cartesian3.multiplyByScalar(i.geodeticSurfaceNormal(t,G),e.height,G);L.center=g.Cartesian3.add(t,a,L.center),L.radius=r,a=g.Cartesian3.multiplyByScalar(i.geodeticSurfaceNormal(t,a),e.extrudedHeight,a),O.center=g.Cartesian3.add(t,a,O.center),O.radius=r;var n,o,s=D.EllipseGeometryLibrary.computeEllipsePositions(e,!1,!0).outerPositions,u=new M.GeometryAttributes({position:new x.GeometryAttribute({componentDatatype:E.ComponentDatatype.DOUBLE,componentsPerAttribute:3,values:D.EllipseGeometryLibrary.raisePositionsToHeight(s,e,!0)})}),s=u.position.values,l=v.BoundingSphere.union(L,O),d=s.length/3;A.defined(e.offsetAttribute)&&(o=new Uint8Array(d),o=e.offsetAttribute===C.GeometryOffsetAttribute.TOP?C.arrayFill(o,1,0,d/2):(n=e.offsetAttribute===C.GeometryOffsetAttribute.NONE?0:1,C.arrayFill(o,n)),u.applyOffset=new x.GeometryAttribute({componentDatatype:E.ComponentDatatype.UNSIGNED_BYTE,componentsPerAttribute:1,values:o}));var p=A.defaultValue(e.numberOfVerticalLines,16),p=_.CesiumMath.clamp(p,0,d/2),f=w.IndexDatatype.createTypedArray(d,2*d+2*p);d/=2;var c=0;for(b=0;b<d;++b)f[c++]=b,f[c++]=(b+1)%d,f[c++]=b+d,f[c++]=(b+1)%d+d;if(0<p)for(var m=Math.min(p,d),h=Math.round(d/m),y=Math.min(h*p,d),b=0;b<y;b+=h)f[c++]=b,f[c++]=b+d;return{boundingSphere:l,attributes:u,indices:f}}(u)):(s=function(e){var t=e.center;l=g.Cartesian3.multiplyByScalar(e.ellipsoid.geodeticSurfaceNormal(t,l),e.height,l),l=g.Cartesian3.add(t,l,l);for(var i=new v.BoundingSphere(l,e.semiMajorAxis),r=D.EllipseGeometryLibrary.computeEllipsePositions(e,!1,!0).outerPositions,a=new M.GeometryAttributes({position:new x.GeometryAttribute({componentDatatype:E.ComponentDatatype.DOUBLE,componentsPerAttribute:3,values:D.EllipseGeometryLibrary.raisePositionsToHeight(r,e,!1)})}),n=r.length/3,o=w.IndexDatatype.createTypedArray(n,2*n),s=0,u=0;u<n;++u)o[s++]=u,o[s++]=(u+1)%n;return{boundingSphere:i,attributes:a,indices:o}}(u),A.defined(e._offsetAttribute)&&(a=s.attributes.position.values.length,n=new Uint8Array(a/3),o=e._offsetAttribute===C.GeometryOffsetAttribute.NONE?0:1,C.arrayFill(n,o),s.attributes.applyOffset=new x.GeometryAttribute({componentDatatype:E.ComponentDatatype.UNSIGNED_BYTE,componentsPerAttribute:1,values:n}))),new x.Geometry({attributes:s.attributes,indices:s.indices,primitiveType:x.PrimitiveType.LINES,boundingSphere:s.boundingSphere,offsetAttribute:e._offsetAttribute})}},e.EllipseOutlineGeometry=m});