卫星class的传参修改
This commit is contained in:
parent
af7b6adf5e
commit
d7c196d88d
@ -5,6 +5,10 @@ import chroma from 'chroma-js'
|
||||
|
||||
class SatelliteEntity {
|
||||
constructor(tle = '', options = {}) {
|
||||
const {
|
||||
totalSeconds = 7 * 86400, // 24小时
|
||||
startTime = new Date().toISOString(),
|
||||
} = options
|
||||
const [name, tleLine1, tleLine2] = this._checkTle(tle)
|
||||
let circle = tleLine2.slice(52, 64)
|
||||
|
||||
@ -13,7 +17,10 @@ class SatelliteEntity {
|
||||
this.tleLine2 = tleLine2.trim()
|
||||
this.satrec = twoline2satrec(this.tleLine1, this.tleLine2)
|
||||
|
||||
this.totalSeconds = 7 * 86400 // 24小时
|
||||
this.totalSeconds = totalSeconds
|
||||
|
||||
this.startTime = startTime
|
||||
|
||||
this.stepSeconds = 100
|
||||
this.leadTime = parseInt((24 * 3600) / circle)
|
||||
this.trailTime = 0
|
||||
@ -116,12 +123,13 @@ class SatelliteEntity {
|
||||
|
||||
// 创建PositionProperty
|
||||
_getPositionProperty(height) {
|
||||
const start = Cesium.JulianDate.fromIso8601(new Date().toISOString())
|
||||
const start = Cesium.JulianDate.fromIso8601(this.startTime)
|
||||
const positionProperty = new Cesium.SampledPositionProperty(
|
||||
Cesium.ReferenceFrame.INERTIAL
|
||||
)
|
||||
// const points = []
|
||||
let now = Date.now()
|
||||
// let now = Date.now()
|
||||
let now = new Date(this.startTime).getTime()
|
||||
for (let i = 0; i < this.totalSeconds / this.stepSeconds; i++) {
|
||||
let sateTime = new Date(now + i * this.stepSeconds * 1000)
|
||||
let sateCoord = this.getPositionEci(sateTime)
|
||||
@ -133,6 +141,7 @@ class SatelliteEntity {
|
||||
i * this.stepSeconds,
|
||||
new Cesium.JulianDate()
|
||||
)
|
||||
|
||||
let cesiumPosition = {
|
||||
x: sateCoord.x * 1000,
|
||||
y: sateCoord.y * 1000,
|
||||
@ -158,7 +167,7 @@ class SatelliteEntity {
|
||||
|
||||
// 创建卫星实例
|
||||
createSatelliteEntity() {
|
||||
const start = Cesium.JulianDate.fromIso8601(new Date().toISOString())
|
||||
const start = Cesium.JulianDate.fromIso8601(this.startTime)
|
||||
const stop = Cesium.JulianDate.addSeconds(
|
||||
start,
|
||||
this.totalSeconds,
|
||||
@ -172,9 +181,9 @@ class SatelliteEntity {
|
||||
name: this.name,
|
||||
description: this.name,
|
||||
show: true,
|
||||
availability: new Cesium.TimeIntervalCollection([
|
||||
new Cesium.TimeInterval({ start: start, stop: stop }),
|
||||
]),
|
||||
// availability: new Cesium.TimeIntervalCollection([
|
||||
// new Cesium.TimeInterval({ start: start, stop: stop }),
|
||||
// ]),
|
||||
position: this._getPositionProperty(),
|
||||
|
||||
path: new Cesium.PathGraphics({
|
||||
@ -449,7 +458,7 @@ class SatelliteEntity {
|
||||
}
|
||||
|
||||
_getPositionFromTime() {
|
||||
const start = Cesium.JulianDate.fromIso8601(new Date().toISOString())
|
||||
const start = Cesium.JulianDate.fromIso8601(this.startTime)
|
||||
const pos = this._getPositionProperty(1)
|
||||
|
||||
const points = []
|
||||
@ -468,7 +477,7 @@ class SatelliteEntity {
|
||||
}
|
||||
|
||||
createPointUnderTheSatellite(color) {
|
||||
const start = Cesium.JulianDate.fromIso8601(new Date().toISOString())
|
||||
const start = Cesium.JulianDate.fromIso8601(this.startTime)
|
||||
const stop = Cesium.JulianDate.addSeconds(
|
||||
start,
|
||||
this.totalSeconds,
|
||||
|
Loading…
Reference in New Issue
Block a user