diff --git a/src/modules/SatelliteEntityWrapper.js b/src/modules/SatelliteEntityWrapper.js index 544d005b..2ae7a8fc 100644 --- a/src/modules/SatelliteEntityWrapper.js +++ b/src/modules/SatelliteEntityWrapper.js @@ -29,9 +29,10 @@ export class SatelliteEntityWrapper extends CesiumEntityWrapper { this.createPoint(); // this.createBox(); this.createLabel(); - if (this.props.orbit.orbitalPeriod < 60 * 12) { - this.createOrbit(); - this.createOrbitTrack(); + this.createOrbit(); + this.createOrbitTrack(); + if (this.props.orbit.orbitalPeriod < 60 * 2) { + // Ground track and cone graphic are optimized for LEO satellites this.createGroundTrack(); this.createCone(); } @@ -42,11 +43,11 @@ export class SatelliteEntityWrapper extends CesiumEntityWrapper { this.defaultEntity = this.entities.Point; // Add sampled position to all entities - this.props.createSampledPosition(this.viewer.clock, (sampledPosition) => { + this.props.createSampledPosition(this.viewer.clock, (sampledPosition, sampledPositionInertial) => { Object.entries(this.entities).forEach(([type, entity]) => { if (type === "Orbit") { - entity.position = this.props.sampledPositionInertial; - entity.orientation = new Cesium.VelocityOrientationProperty(this.props.sampledPositionInertial); + entity.position = sampledPositionInertial; + entity.orientation = new Cesium.VelocityOrientationProperty(sampledPositionInertial); } else if (type === "SensorCone") { entity.position = sampledPosition; entity.orientation = new Cesium.CallbackProperty((time) => { diff --git a/src/modules/SatelliteProperties.js b/src/modules/SatelliteProperties.js index 951bfce7..1ec04c4e 100644 --- a/src/modules/SatelliteProperties.js +++ b/src/modules/SatelliteProperties.js @@ -90,14 +90,23 @@ export class SatelliteProperties { } createSampledPosition(clock, callback) { + // Determine sampling interval and number of samples based on orbital period + // For improved performance use 180 sampled positions per orbit + const samplingInterval = (this.orbit.orbitalPeriod * 60) / 180; + const samplingRefreshRate = 60 * 15; + // Propagate a full orbit forward and half an orbit backwards + const samplesFwd = Math.ceil((this.orbit.orbitalPeriod * 60) / samplingInterval); + const samplesBwd = Math.ceil(((this.orbit.orbitalPeriod * 60) / 2 + samplingRefreshRate) / samplingInterval); + // console.log("createSampledPosition", this.name, this.orbit.orbitalPeriod, samplesFwd, samplesBwd, interval); + let lastUpdated; - lastUpdated = this.updateSampledPosition(clock.currentTime); - callback(this.sampledPosition); + lastUpdated = this.updateSampledPosition(clock.currentTime, samplesFwd, samplesBwd, samplingInterval); + callback(this.sampledPosition, this.sampledPositionInertial); clock.onTick.addEventListener((onTickClock) => { const dt = Math.abs(Cesium.JulianDate.secondsDifference(onTickClock.currentTime, lastUpdated)); - if (dt >= 60 * 15) { - lastUpdated = this.updateSampledPosition(onTickClock.currentTime); - callback(this.sampledPosition); + if (dt >= samplingRefreshRate) { + lastUpdated = this.updateSampledPosition(onTickClock.currentTime, samplesFwd, samplesBwd, samplingInterval); + callback(this.sampledPosition, this.sampledPositionInertial); } }); }