From 864e075b4289c80beb2a271b9d2bbd4907c7b0f5 Mon Sep 17 00:00:00 2001 From: Tom Boullay Date: Tue, 2 Jun 2026 16:34:05 +0200 Subject: [PATCH] chore(debug): keep hand tracking source controller display in sync Store the lil-gui Source controller so setHandTrackingSource() from the settings menu can refresh its display, and log the transition for traceability. Co-Authored-By: Claude Opus 4.7 (1M context) --- src/utils/debug/Debug.ts | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/src/utils/debug/Debug.ts b/src/utils/debug/Debug.ts index 7c9606b..24df6fe 100644 --- a/src/utils/debug/Debug.ts +++ b/src/utils/debug/Debug.ts @@ -1,9 +1,11 @@ import GUI from "lil-gui"; +import type { Controller } from "lil-gui"; import type { CameraMode, SceneMode } from "@/types/debug/debug"; import type { HandTrackingSource } from "@/types/handTracking/handTracking"; import { FOG_CONFIG } from "@/data/world/fogConfig"; import { EventEmitter } from "@/utils/core/EventEmitter"; import { isDebugEnabled } from "@/utils/debug/isDebugEnabled"; +import { logger } from "@/utils/core/Logger"; const DEBUG_CONTROLS_STORAGE_KEY = "la-fabrik-debug-controls"; @@ -77,6 +79,7 @@ export class Debug { private readonly events = new EventEmitter(); private readonly folders = new Map(); private readonly folderRefCounts = new Map(); + private handTrackingSourceController: Controller | null = null; private readonly controls: { cameraMode: CameraMode; fogEnabled: boolean; @@ -160,16 +163,22 @@ export class Debug { this.emit(); }); - handTrackingFolder - ?.add(this.controls, "handTrackingSource", { - "Browser JS": "browser", - Backend: "backend", - }) - .name("Source") - .onChange((value: HandTrackingSource) => { - this.controls.handTrackingSource = value; - this.saveAndEmit(); - }); + this.handTrackingSourceController = + handTrackingFolder + ?.add(this.controls, "handTrackingSource", { + "Browser JS": "browser", + Backend: "backend", + }) + .name("Source") + .onChange((value: HandTrackingSource) => { + const previousSource = this.controls.handTrackingSource; + this.controls.handTrackingSource = value; + logger.info("HandTracking", "Debug source changed", { + from: previousSource, + to: value, + }); + this.saveAndEmit(); + }) ?? null; } } @@ -254,7 +263,13 @@ export class Debug { } setHandTrackingSource(value: HandTrackingSource): void { + const previousSource = this.controls.handTrackingSource; this.controls.handTrackingSource = value; + this.handTrackingSourceController?.updateDisplay(); + logger.info("HandTracking", "Settings source changed", { + from: previousSource, + to: value, + }); this.saveAndEmit(); }