Skip to content

Commit

Permalink
Support Orbit visualization for MEO and GEO satellites
Browse files Browse the repository at this point in the history
Related #63
  • Loading branch information
Flowm committed Mar 21, 2023
1 parent 3de7572 commit 667c7c2
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 11 deletions.
13 changes: 7 additions & 6 deletions src/modules/SatelliteEntityWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand All @@ -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) => {
Expand Down
19 changes: 14 additions & 5 deletions src/modules/SatelliteProperties.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
});
}
Expand Down

0 comments on commit 667c7c2

Please sign in to comment.