Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 🐛 remove unnecessary transforms from worker #58

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,14 @@
<div class="sat-info-key">Inclination</div>
<div class="sat-info-value" id="sat-inclination">123.45°</div>
</div>
<div class="sat-info-row">
<div class="sat-info-key">Latitude</div>
<div class="sat-info-value" id="sat-latitude">0°</div>
</div>
<div class="sat-info-row">
<div class="sat-info-key">Longitude</div>
<div class="sat-info-value" id="sat-longitude">0°</div>
</div>
<div class="sat-info-row">
<div class="sat-info-key">Altitude</div>
<div class="sat-info-value" id="sat-altitude">100 km</div>
Expand Down
88 changes: 50 additions & 38 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 2 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,17 @@
"dependencies": {
"axios": "^1.6.4",
"gl-matrix": "^3.4.3",
"luxon": "^3.4.4",
"satellite.js": "^5.0.0"
"ootk-core": "^1.0.0-1",
"three": "^0.157.0"
},
"devDependencies": {
"@types/luxon": "^3.3.8",
"@types/three": "^0.157.2",
"@typescript-eslint/eslint-plugin": "^6.17.0",
"@yushijinhun/three-minifier-rollup": "^0.4.0",
"eslint": "^8.56.0",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-plugin-import": "^2.29.1",
"rollup-plugin-visualizer": "^5.12.0",
"three": "^0.157.0",
"typescript": "^5.2.2",
"vite": "^5.0.11"
}
Expand Down
4 changes: 2 additions & 2 deletions public/config.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"tleUrl": "data/attributed-TLE.json",
"propergateInterval": 1000,
"propagateInterval": 1000,
"pushHistory": false,
"logLevel": "info",
"satWorker": {
"runOnce": false,
"propergateIntervalMs": 16
"propagateIntervalMs": 16
},
"satelliteGroups": [
{
Expand Down
2 changes: 1 addition & 1 deletion public/styles/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ ul {
bottom: 0;
margin-top: auto;
margin-bottom: auto;
height: 250px;
height: fit-content;
width: 200px;
display: none;
}
Expand Down
2 changes: 1 addition & 1 deletion src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const baseUrl = import.meta.env.BASE_URL;
const config = {
appName: 'Stuff in Space',
baseUrl,
propergateInterval: 1000, // milliseconds
propagateInterval: 1000, // milliseconds
pushHistory: false,
logLevel: 'debug',
satWorker: {
Expand Down
10 changes: 2 additions & 8 deletions src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
/* eslint-disable import/prefer-default-export */
const R2D = 80 / Math.PI;

const Events = {
export const Events = {
satMovementChange: 'satMovementChange',
selectedSatChange: 'selectedSatChange',
satHover: 'sathoverChange',
Expand All @@ -10,7 +7,4 @@ const Events = {
cruncherReady: 'cruncherReady'
};

export {
R2D,
Events
};
export const pxToRadius = 3185.5;
22 changes: 11 additions & 11 deletions src/hud/SearchBox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,14 @@ function fillResultBox (results: SearchResults[], searchStr: string) {

html += `<div class="search-result" data-sat-id="${satellite.id}">`;
if (result.type !== 'name') {
html += satellite.OBJECT_NAME;
html += satellite.name;
} else {
html += `
${satellite.OBJECT_NAME.substring(0, result.strIndex)}
${satellite.name.substring(0, result.strIndex)}
<span class="search-hilight">
${satellite.OBJECT_NAME.substring(result.strIndex, result.strIndex + searchStr.length)}
${satellite.name.substring(result.strIndex, result.strIndex + searchStr.length)}
</span>
${satellite.OBJECT_NAME.substring(result.strIndex + searchStr.length)}`;
${satellite.name.substring(result.strIndex + searchStr.length)}`;
}

html += '<div class="search-result-intldes">';
Expand All @@ -116,11 +116,11 @@ function fillResultBox (results: SearchResults[], searchStr: string) {
${satellite.intlDes.substring(result.strIndex + searchStr.length)}`;
} else if (result.type === 'noradId') {
html += `
${satellite.NORAD_CAT_ID.substring(0, result.strIndex)}
${satellite.sccNum.substring(0, result.strIndex)}
<span class="search-hilight">
${satellite.NORAD_CAT_ID.substring(result.strIndex, result.strIndex + searchStr.length)}
${satellite.sccNum.substring(result.strIndex, result.strIndex + searchStr.length)}
</span>
${satellite.NORAD_CAT_ID.substring(result.strIndex + searchStr.length)}`;
${satellite.sccNum.substring(result.strIndex + searchStr.length)}`;
} else {
html += satellite.intlDes;
}
Expand Down Expand Up @@ -158,18 +158,18 @@ function doSearch (str: string) {

const results: SearchResults[] = [];
for (let i = 0; i < satData.length; i++) {
if (satData[i]?.NORAD_CAT_ID?.indexOf(str) !== -1) {
if (satData[i]?.sccNum?.indexOf(str) !== -1) {
results.push({
type: 'noradId',
strIndex: satData[i].NORAD_CAT_ID.indexOf(str),
strIndex: satData[i].sccNum.indexOf(str),
satId: i
});
}

if (satData[i]?.OBJECT_NAME.indexOf(str) !== -1) {
if (satData[i]?.name.indexOf(str) !== -1) {
results.push({
type: 'name',
strIndex: satData[i].OBJECT_NAME.indexOf(str),
strIndex: satData[i].name.indexOf(str),
satId: i
});
}
Expand Down
22 changes: 17 additions & 5 deletions src/hud/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
/* eslint-disable no-loop-func */
import { R2D, Events } from '@/constants';
import { Events } from '@/constants';
import SatelliteGroup from '@satellite-viewer/SatelliteGroup';
import { Viewer } from '@satellite-viewer/index';
import HudWindowManager from './HudWindowManager';
import searchBox from './SearchBox';
import { Satellite } from 'ootk-core';

const supporteEvents: string[] = [];
const windowManager = new HudWindowManager();
Expand Down Expand Up @@ -70,16 +71,23 @@ function setHtml (selector: string, html: string) {
}
}

function onSelectedSatChange (satellite: Record<string, any>) {
function onSelectedSatChange (satellite: Satellite) {
if (satellite) {
document.querySelector('#sat-infobox')?.classList.add('visible');
setHtml('#sat-info-title', satellite.OBJECT_NAME);
setHtml('#sat-info-title', satellite.name);
setHtml('#sat-intl-des', satellite.intlDes);
setHtml('#sat-type', satellite.OBJECT_TYPE);
setHtml('#sat-type', satellite.getTypeString());
setHtml('#sat-apogee', `${satellite.apogee?.toFixed(0)} km`);
setHtml('#sat-perigee', `${satellite.perigee?.toFixed(0)} km`);
setHtml('#sat-inclination', `${(satellite.inclination * R2D).toFixed(2)}°`);
setHtml('#sat-inclination', `${(satellite.inclination).toFixed(2)}°`);
setHtml('#sat-period', `${satellite.period?.toFixed(2)} min`);
const lla = satellite.lla();
const latitude = lla.lat > 0 ? `${lla.lat.toFixed(2)}°N` : `${Math.abs(lla.lat).toFixed(2)}°S`;
setHtml('#sat-latitude', latitude);
const longitude = lla.lon > 0 ? `${lla.lon.toFixed(2)}°E` : `${Math.abs(lla.lon).toFixed(2)}°W`;
setHtml('#sat-longitude', longitude);
setHtml('#sat-altitude', `${lla.alt.toFixed(2)} km`);
setHtml('#sat-velocity', `${satellite.totalVelocity.toFixed(2)} km/s`);
} else {
document.querySelector('#sat-infobox')?.classList.remove('visible');
}
Expand Down Expand Up @@ -254,6 +262,10 @@ function initEventListeners () {

function onSatMovementChange (event: any) {
if (event.satId) {
const latitude = event.latitude > 0 ? `${event.latitude.toFixed(2)}°N` : `${Math.abs(event.latitude).toFixed(2)}°S`;
setHtml('#sat-latitude', latitude);
const longitude = event.longitude > 0 ? `${event.longitude.toFixed(2)}°E` : `${Math.abs(event.longitude).toFixed(2)}°W`;
setHtml('#sat-longitude', longitude);
setHtml('#sat-altitude', `${event.altitude.toFixed(2)} km`);
setHtml('#sat-velocity', `${event.velocity.toFixed(2)} km/s`);
}
Expand Down
Loading