Browse Source

Track markers only drawn if confirmed. Added debug messages into the console warning.

refactor/modularize
RUSHIL AMBARISH KADU 8 months ago
parent
commit
53a5704c6c
  1. 4
      steps/index.html
  2. 2
      steps/src/dom.js
  3. 13
      steps/src/drawUtils.js
  4. 7
      steps/src/main.js

4
steps/index.html

@ -153,6 +153,10 @@
(P)</label>
<label class="flex items-center gap-2 text-sm cursor-pointer"><input type="checkbox" id="toggle-covariance"
class="form-checkbox h-4 w-4 text-blue-600 rounded focus:ring-blue-500" /> Show Covariance</label>
<label class="flex items-center gap-2 text-sm cursor-pointer"><input type="checkbox" id="toggle-confirmed-only"
class="form-checkbox h-4 w-4 text-blue-600 rounded focus:ring-blue-500" checked />
Confirmed Tracks
</label>
</div>
<!-- SNR Controls -->

2
steps/src/dom.js

@ -80,6 +80,8 @@ export const closeMenuBtn = document.getElementById("close-menu-btn");
export const fullscreenEnterIcon = document.getElementById("fullscreen-enter-icon");
export const fullscreenExitIcon = document.getElementById("fullscreen-exit-icon");
export const menuScrim = document.getElementById("menu-scrim");
export const toggleConfirmedOnly = document.getElementById("toggle-confirmed-only");
//----------------------UPDATE FRAME Function----------------------//
// Updates the UI to reflect the current radar frame and synchronizes video playback.

13
steps/src/drawUtils.js

@ -13,6 +13,7 @@ import {
toggleFrameNorm,
toggleVelocity,
toggleStationaryColor,
toggleConfirmedOnly,
} from "./dom.js";
// Defines a set of SNR (Signal-to-Noise Ratio) colors.
@ -277,8 +278,15 @@ export function drawTrajectories(p, plotScales) {
const localTtcColors = ttcColors(p);
for (const track of appState.vizData.tracks) {
// if (toggleConfirmedOnly.checked && track.isConfirmed === false) {
// continue;
// }
if (!track || !track.historyLog || !Array.isArray(track.historyLog)) {
// Safeguard for malformed data
const trackId = track ? track.id : 'Unknown ID';
console.warn(
`Skipping malformed track in frame ${appState.currentFrame}. Track ID: ${trackId}`,
track // We also log the entire track object for detailed inspection.
); // Safeguard for malformed data
continue;
}
@ -405,6 +413,9 @@ export function drawTrackMarkers(p, plotScales) {
for (const track of appState.vizData.tracks) {
// --- START: Add the Same Safeguard Here ---
// This robust check ensures the track and its historyLog are valid before use.
// if (toggleConfirmedOnly.checked && track.isConfirmed === false) {
// continue;
// }
if (!track || !track.historyLog || !Array.isArray(track.historyLog)) {
// We don't need to log a warning here again, as drawTrajectories already did.
// We can just safely skip this malformed track.

7
steps/src/main.js

@ -93,6 +93,7 @@ import {
fullscreenEnterIcon,
fullscreenExitIcon,
menuScrim,
toggleConfirmedOnly
} from "./dom.js";
import { initializeTheme } from "./theme.js";
@ -364,6 +365,12 @@ function toggleMenu(show) {
}
}
toggleConfirmedOnly.addEventListener("change", () => {
if (appState.p5_instance) {
appState.p5_instance.redraw();
}
});
// Open the menu
toggleMenuBtn.addEventListener("click", () => toggleMenu(true));

Loading…
Cancel
Save