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