refacto: enleve la map

This commit is contained in:
2026-04-16 16:11:20 +02:00
parent 1eed905e8b
commit b26da614f0
10 changed files with 66 additions and 111 deletions
+12 -2
View File
@@ -7,6 +7,7 @@ export class Debug {
public readonly active: boolean;
private readonly gui: GUI | null;
private readonly folders = new Map<string, GUI>();
private readonly registeredFolders = new Set<string>();
private readonly listeners = new Set<() => void>();
private readonly controls: { cameraMode: CameraMode } = {
cameraMode: "player",
@@ -41,13 +42,22 @@ export class Debug {
}
}
createFolder(name: string): GUI;
createFolder(name: string): GUI | null;
/**
* Creates a named GUI folder. Returns the folder on first call, null on
* subsequent calls with the same name — callers should skip `.add()` when
* null is returned to avoid duplicating controls under StrictMode double-mount.
*/
createFolder(name: string): GUI | null {
if (!this.gui) {
return null;
}
if (this.registeredFolders.has(name)) {
return null;
}
this.registeredFolders.add(name);
const existingFolder = this.folders.get(name);
if (existingFolder) {