!function(t,e){"object"===typeof exports&&"object"===typeof module?module.exports=e(require("cesium/Cesium")):"function"===typeof define&&define.amd?define(["cesium/Cesium"],e):"object"===typeof exports?exports.space=e(require("cesium/Cesium")):t.space=e(t.Cesium)}("undefined"!==typeof self?self:this,function(t){return function(t){function e(n){if(i[n])return i[n].exports;var o=i[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,e),o.l=!0,o.exports}var i={};return e.m=t,e.c=i,e.d=function(t,i,n){e.o(t,i)||Object.defineProperty(t,i,{configurable:!1,enumerable:!0,get:n})},e.n=function(t){var i=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(i,"a",i),i},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=5)}([function(e,i){e.exports=t},function(t,e,i){"use strict";function n(t){var e=t.indices,i=t.attributes,n=e.length;if(i.position){var r=i.position.values;if(void 0===i.normal)i.normal=new l.GeometryAttribute({componentDatatype:l.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:new Float32Array(r.length)});else for(var a=i.normal.values,s=0;s=0&&k>=0&&f.push(0,T,k);p=new Float32Array(p),f=new Int32Array(f),d=new Float32Array(d);var L={position:new r.GeometryAttribute({componentDatatype:r.ComponentDatatype.DOUBLE,componentsPerAttribute:3,values:p}),st:new r.GeometryAttribute({componentDatatype:r.ComponentDatatype.FLOAT,componentsPerAttribute:2,values:d})},V=r.BoundingSphere.fromVertices(p),D=new r.Geometry({attributes:L,indices:f,primitiveType:r.PrimitiveType.TRIANGLES,boundingSphere:V});return(0,a.computeVertexNormals)(D),p=[],f=[],D},n.createOutlineGeometry=function(t){var e=t.length,i=t.topRadius,n=t.bottomRadius,o=t.slices,a=2*Math.PI/(o-1),h=t.zReverse,l=[],u=[],m=[],c=[],p=[n,i],d=[0,h?-e:e],f=0,y=Math.atan2(n-i,e),_=s;_.z=Math.sin(y);for(var v=Math.cos(y),g=0;g=0&&T>=0&&d.push(0,S,T);for(var R=(x[0].length,0);R=0&&T>=0&&d.push(0,S,T);p=new Float32Array(p),d=new Int32Array(d),f=new Float32Array(f);var L={position:new r.GeometryAttribute({componentDatatype:r.ComponentDatatype.DOUBLE,componentsPerAttribute:3,values:p}),st:new r.GeometryAttribute({componentDatatype:r.ComponentDatatype.FLOAT,componentsPerAttribute:2,values:f})},V=r.BoundingSphere.fromVertices(p),D=new r.Geometry({attributes:L,indices:d,primitiveType:r.PrimitiveType.TRIANGLES,boundingSphere:V});return D.myindexs=d,(0,a.computeVertexNormals)(D),p=[],d=[],D},n.createOutlineGeometry=function(t){for(var e=t._bottomWidth,i=t._bottomHeight,n=t._topWidth,o=t._topHeight,a=t._zReverse,s=(a?-1:1)*t._length,h=new Float32Array(24),l=[],u=[],m=[0,s],c=[e,n],p=[i,o],d=0,f=0;f<2;f++)h[3*d]=-c[f]/2,h[3*d+1]=-p[f]/2,h[3*d+2]=m[f],u[2*d]=f,u[2*d+1]=0,d++,h[3*d]=-c[f]/2,h[3*d+1]=p[f]/2,h[3*d+2]=m[f],u[2*d]=f,u[2*d+1]=0,d++,h[3*d]=c[f]/2,h[3*d+1]=p[f]/2,h[3*d+2]=m[f],u[2*d]=f,u[2*d+1]=0,d++,h[3*d]=c[f]/2,h[3*d+1]=-p[f]/2,h[3*d+2]=m[f],u[2*d]=f,u[2*d+1]=0,d++;l.push(0,1,1,2),l.push(2,3,3,0),l.push(0,4),l.push(1,5),l.push(2,6),l.push(3,7),l.push(4,5,5,6),l.push(6,7,7,4),l=new Int16Array(l),u=new Float32Array(u);var y={position:new r.GeometryAttribute({componentDatatype:r.ComponentDatatype.DOUBLE,componentsPerAttribute:3,values:h}),st:new r.GeometryAttribute({componentDatatype:r.ComponentDatatype.FLOAT,componentsPerAttribute:2,values:u})},_=r.BoundingSphere.fromVertices(h),v=new r.Geometry({attributes:y,indices:l,primitiveType:r.PrimitiveType.LINES,boundingSphere:_});return h=[],l=[],v},n.createOutlineGeometry2=function(t){var e=(t._bottomWidth,t._bottomHeight,t._topWidth),i=t._topHeight,n=t._zReverse,o=(n?-1:1)*t._length,s=[],h=[],l=[],u=e/2,m=i/2,c=0;s.push(0,0,0),l.push(1,1),c++;for(var p=[],d=-16;d<16;d++){for(var f=[],y=-16;y<16;y++){f.push(c);var _=m*d/16,v=u*y/16;s.push(v,_,o),l.push(1,1),c++}p.push(f)}for(var g,C,w=[0,p.length-1],x=0;x0){if(a!=t[s].primitiveType){o=!0;break}var h=i[s-1];if(!(n=h.length!=i[s].length))for(var l=0;l0){n=turf.featureCollection(n);var u=turf.convex(n);if(u){var c=turf.getCoords(u);c&&c.length>0&&(l=c[0])}}return l}},{key:"updateImagingAreaGeometry2",value:function(t){for(var e=[],i=[],n=0,o=0;o0){i=turf.featureCollection(i);var u=turf.convex(i);if(u){var m=turf.getCoords(u);m&&m.length>0&&(h=m[0])}}return h}}},{key:"computeMatrix",value:function(t,e){if(this._positionCartesian||(this._positionCartesian=new l.Cartesian3()),this._position instanceof l.Cartesian3?this._positionCartesian=this._position:"function"===typeof this._position.getValue?this._positionCartesian=this._position.getValue(t):this._position._value&&this._position._value instanceof l.Cartesian3&&(this._positionCartesian=this._position._value),!this._positionCartesian)return this._matrix;if(this._modelMatrix=this._fixedFrameTransform(this._positionCartesian,s,this._modelMatrix),this._positionCartographic=l.Cartographic.fromCartesian(this._positionCartesian,s,this._positionCartographic),this._fixedFrameTransform(this._positionCartesian,s,this._modelMatrix),this.autoAngle&&this._orientation){var i=l.Property.getValueOrUndefined(this._orientation,t,_);if(i){var n=wutu3d.matrix.getHeadingPitchRollByOrientation(i,s,this._fixedFrameTransform);this._rotation.heading=n.heading}}return l.Quaternion.fromHeadingPitchRoll(this._rotation,this._quaternion),this._matrix=l.Matrix4.fromTranslationQuaternionRotationScale(this._translation,this._quaternion,this._scale,this._matrix),l.Matrix4.multiplyTransformation(this._modelMatrix,this._matrix,this._matrix),l.Matrix4.inverseTransformation(this._matrix,this._inverseMatrix),this._matrix}},{key:"updateGeometry",value:function(){this._areaType==v.Cone?(this._geometry=u.CylinderGeometry.createGeometry(u.CylinderGeometry.fromAngleAndLength(this._angle1,this._length,!0),this._matrix),this._outlineGeometry=u.CylinderGeometry.createOutlineGeometry(u.CylinderGeometry.fromAngleAndLength(this._angle1,this._length,!0))):(this._geometry=m.FourPrismGeometry.createGeometry(m.FourPrismGeometry.fromAnglesLength(this._angle1,this._angle2,this._length,!0),this._matrix),this._outlineGeometry=m.FourPrismGeometry.createOutlineGeometry(m.FourPrismGeometry.fromAnglesLength(this._angle1,this._angle2,this._length,!0))),this._positions=new Float32Array(this._geometry.attributes.position.values.length);for(var t=0;te&&t1e3&&(e=3e5);for(var i=this.time_tick_local-this.period_m/2,n=this.time_tick_local+this.period_m/2,o=i;o<=n;){var r=satellite.calculate_sat_pos_ex("ECI",this.options.tle1,this.options.tle2,o-this.time_zone);if(isNaN(r.x)||isNaN(r.longitude))return null;var a=h.JulianDate.fromDate(new Date(o)),s=new h.Cartesian3(1e3*r.x,1e3*r.y,1e3*r.z),l=h.Cartesian3.fromRadians(r.longitude,r.latitude);this.property.addSample(a,s),t.push({position:l,positionWX:s,time:a,millis:o}),o+=e}this._points=t,this.property.setInterpolationOptions({interpolationDegree:2,interpolationAlgorithm:h.LagrangePolynomialApproximation}),this.orbit_bt=this.time_tick_local-this.period_m/2,this.orbit_et=this.time_tick_local+this.period_m/2+e}},{key:"createEntity",value:function(){var t,e=this;this.options.label.text=this.name;var i=wutu3d.draw.attr.model.style2Entity(this.options.model),o=wutu3d.draw.attr.label.style2Entity(this.options.label),r=wutu3d.draw.attr.polyline.style2Entity(this.options.path,{}),a=new h.VelocityOrientationProperty(this.property);this.velocityOrientation=a;var s=this.viewer.entities.add((t={name:this.name,availability:new h.TimeIntervalCollection([new h.TimeInterval({start:h.JulianDate.fromDate(new Date(this.orbit_bt)),stop:h.JulianDate.fromDate(new Date(this.orbit_et))})]),position:this.property,orientation:new h.CallbackProperty(function(t){return e.orientation},!1),model:i,label:o,path:r,popup:this.options.popup},n(t,"popup",this.options.tooltip),n(t,"click",this.options.click),t));this.entity=s,this.options.shadingLine&&this.showShadingLine(),this.options.cone&&this.showCone(),this.updateOrientation()}},{key:"updateEntity",value:function(){this.entity.availability=new h.TimeIntervalCollection([new h.TimeInterval({start:h.JulianDate.fromDate(new Date(this.orbit_bt)),stop:h.JulianDate.fromDate(new Date(this.orbit_et))})]),this.entity.position=this.property,this.velocityOrientation.position=this.property;var t=this;this.coneEntityList&&this.coneEntityList.forEach(function(e,i,n){e.position=t.property}),this.coneEntity&&(this.coneEntity.position=this.property)}},{key:"update",value:function(){if(this._visible)return this.time_tick_local=h.JulianDate.toDate(this.viewer.clock.currentTime).getTime(),this.updateOrientation(),this.updateShadingPositions(),!this.isNeedRecalculate()||(this.calculateOrbitPoints(),null!=this.property&&(null==this.entity?this.createEntity():this.updateEntity(),!0))}},{key:"updateStyle",value:function(t){for(var e in t)if("object"===r(t[e])&&this.options[e])for(var i in t[e])this.options[e][i]=t[e][i];else this.options[e]=t[e];if(this.options.label.text=this.name,this.options.tle2){if(this.options.period=satellite.get_period(this.options.tle2),isNaN(this.options.period))return!1;this.period_m=60*this.options.period*1e3}wutu3d.draw.attr.model.style2Entity(this.options.model,this.entity.model),wutu3d.draw.attr.label.style2Entity(this.options.label,this.entity.label),wutu3d.draw.attr.polyline.style2Entity(this.options.path,this.entity.path),this.options.cone&&this.showCone(),this.options.shadingLine&&this.showShadingLine(),this.updateOrientation()}},{key:"getPointTime",value:function(t,e){e=e||this._points;for(var i=wutu3d.point.setPositionsHeight(t,0),n=0,o=0,r=[],a=0,s=e.length;a0?this._showListCone(t):this._showOneCone(t):(this.coneEntityList&&(this.coneEntityList.forEach(function(t,e,i){t.remove(),t.destroy(!0)}),this.coneEntityList.clear()),this.coneEntity&&(this.coneEntity.remove(),this.coneEntity.destroy(!0),delete this.coneEntity))}},{key:"_showOneCone",value:function(t){if(this.coneEntity)this.coneEntity.angle1=t.angle1||20,this.coneEntity.angle2=t.angle2||20,this.coneEntity.areaType=t.areaType?wutu3d.SatelliteCoverageSimulation.AreaType.FourPrism:wutu3d.SatelliteCoverageSimulation.AreaType.Cone,this.coneEntity.heading=h.Math.toRadians(this.options.model.heading||0),this.coneEntity.pitch=h.Math.toRadians(this.options.model.pitch||0),this.coneEntity.roll=h.Math.toRadians(this.options.model.roll||0),this.coneEntity.color=new h.Color.fromCssColorString(t.color||"#6ef500").withAlpha(Number(t.opacity||.5)),this.coneEntity.outline=t.outline;else{var e=new wutu3d.SatelliteCoverageSimulation(this.viewer,{position:this.entity.position,angle1:t.angle1||20,angle2:t.angle2||20,areaType:t.areaType?wutu3d.SatelliteCoverageSimulation.AreaType.FourPrism:wutu3d.SatelliteCoverageSimulation.AreaType.Cone,autoAngle:!1,//!this.options.model.angleType, rotation:{heading:h.Math.toRadians(this.options.model.heading||0),pitch:h.Math.toRadians(this.options.model.pitch||0),roll:h.Math.toRadians(this.options.model.roll||0)},color:new h.Color.fromCssColorString(t.color||"#6ef500").withAlpha(Number(t.opacity||.5)),outline:t.outline,reverse:t.reverse});e.trackedEntity=this.entity,this.coneEntity=e}}},{key:"_showListCone",value:function(t){this.coneEntityList||(this.coneEntityList=new Map());for(var e=0;ee._radius?[]:[i,e._trackedEntityPosition]:[]},!1),followSurface:!1,material:new s.PolylineDashMaterialProperty({color:s.Color.CYAN}),width:1}})}}},{key:"computeHintPots",value:function(t){var e=[],i=this.getNowPosition(t);if(!i)return e;for(var n=this._radius*Math.sin(s.Math.toRadians(90-this._angle)),o=s.Matrix4.multiplyByPoint(this._matrix,this.lbcenter,new s.Cartesian3()),r=s.Cartesian3.subtract(o,i,new s.Cartesian3()),a=s.Cartesian3.cross(r,o,new s.Cartesian3()),h=s.Cartesian3.cross(o,r,new s.Cartesian3()),l=0;l<=this.hintPotsNum;l++){var u=new s.Ray(o,a),m=n*l/this.hintPotsNum,c=s.Ray.getPoint(u,m,new s.Cartesian3()),p=s.Cartesian3.subtract(c,i,new s.Cartesian3());u=new s.Ray(i,p);var d=s.Ray.getPoint(u,this._radius,new s.Cartesian3());e.push(d)}e.push(i);for(var l=this.hintPotsNum;l>=0;l--){var u=new s.Ray(o,h),m=n*l/this.hintPotsNum,c=s.Ray.getPoint(u,m,new s.Cartesian3()),p=s.Cartesian3.subtract(c,i,new s.Cartesian3());u=new s.Ray(i,p);var d=s.Ray.getPoint(u,this._radius,new s.Cartesian3());e.push(d)}return e}},{key:"addHintLines",value:function(){if(!this.hintLines){var t=this;this.hintLines=viewer.entities.add({polygon:{hierarchy:new s.CallbackProperty(function(e,i){return new s.PolygonHierarchy(t.computeHintPots(e))},!1),outline:!0,outlineColor:s.Color.WHITE.withAlpha(1),outlineWidth:1,material:s.Color.RED.withAlpha(.5)},show:this.viewer.scene._mode==s.SceneMode.SCENE2D})}}},{key:"getNowPosition",value:function(t){var e;return this.position instanceof s.Cartesian3?e=this.position:"function"===typeof this.position.getValue?e=this.position.getValue(t):this.position._value&&this.position._value instanceof s.Cartesian3&&(e=this.position._value),e}},{key:"computeMatrix",value:function(t,e){if(this._positionCartesian=this.getNowPosition(t),!this._positionCartesian)return this._matrix=new s.Matrix4(),this._matrix;if(this._trackedEntity&&this._trackedEntity.position){var i=this._positionCartesian,n=s.Property.getValueOrUndefined(this._trackedEntity.position,t,u);if(s.defined(n)){this._trackedEntityPosition=n;var r=wutu3d.matrix.getHeadingPitchRollForLine(i,n,o,this._fixedFrameTransform);this._rotation.heading=r.heading,this._rotation.pitch=r.pitch,this._rotation.roll=r.roll}}return this._modelMatrix=this._fixedFrameTransform(this._positionCartesian,o,this._modelMatrix),this._positionCartographic=s.Cartographic.fromCartesian(this._positionCartesian,o,this._positionCartographic),this._fixedFrameTransform(this._positionCartesian,o,this._modelMatrix),s.Quaternion.fromHeadingPitchRoll(this._rotation,this._quaternion),this._matrix=s.Matrix4.fromTranslationQuaternionRotationScale(this._translation,this._quaternion,this._scale,this._matrix),s.Matrix4.multiplyTransformation(this._modelMatrix,this._matrix,this._matrix),s.Matrix4.inverseTransformation(this._matrix,this._inverseMatrix),this._matrix}},{key:"getTopGeometry",value:function(){var t=this.radius,e=[],i=[],n=[],o=[],r=90-parseInt(this.angle),a=r<1?r/8:1,h=2*Math.PI/127;this.lbcenter=new s.Cartesian3(0,0,t);for(var u=0,m=this.angle;m<91;m+=a){var c=s.Math.toRadians(m<90?m:90);c=Math.cos(c)*t;for(var p=[],d=0;d<128;d++){var f=h*d,y=c*Math.cos(f),_=c*Math.sin(f),v=Math.sqrt(t*t-y*y-_*_);e.push(y,_,v),i.push(1,1),p.push(u++)}o.push(p)}for(var m=1;mt});if(i>0){var n=e[i-1],o=e[i],r=(t-n.fov)/(o.fov-n.fov);return n.radius*(1-r)+o.radius*r}}function h(t,e,i,n,o,h,l){for(var u=new Float32Array((o+1)*(h+1)*3),m=0;m