update: add a physic scenne

This commit is contained in:
Tom Boullay
2026-04-17 10:48:18 +02:00
parent b26da614f0
commit ed7681a293
23 changed files with 2052 additions and 218 deletions
+22 -14
View File
@@ -9,8 +9,12 @@ export class Debug {
private readonly folders = new Map<string, GUI>();
private readonly registeredFolders = new Set<string>();
private readonly listeners = new Set<() => void>();
private readonly controls: { cameraMode: CameraMode } = {
private readonly controls: {
cameraMode: CameraMode;
showInteractionSpheres: boolean;
} = {
cameraMode: "player",
showInteractionSpheres: false,
};
static getInstance(): Debug {
@@ -28,9 +32,7 @@ export class Debug {
if (this.gui) {
const folder = this.createFolder("Debug");
if (!folder) {
return;
}
if (!folder) return;
folder
.add(this.controls, "cameraMode", { Player: "player", Debug: "debug" })
@@ -39,6 +41,14 @@ export class Debug {
this.controls.cameraMode = value;
this.emit();
});
folder
.add(this.controls, "showInteractionSpheres")
.name("Interaction Spheres")
.onChange((value: boolean) => {
this.controls.showInteractionSpheres = value;
this.emit();
});
}
}
@@ -48,21 +58,15 @@ export class Debug {
* null is returned to avoid duplicating controls under StrictMode double-mount.
*/
createFolder(name: string): GUI | null {
if (!this.gui) {
return null;
}
if (!this.gui) return null;
if (this.registeredFolders.has(name)) {
return null;
}
if (this.registeredFolders.has(name)) return null;
this.registeredFolders.add(name);
const existingFolder = this.folders.get(name);
const existing = this.folders.get(name);
if (existingFolder) {
return existingFolder;
}
if (existing) return existing;
const folder = this.gui.addFolder(name);
this.folders.set(name, folder);
@@ -82,6 +86,10 @@ export class Debug {
return this.controls.cameraMode;
}
getShowInteractionSpheres(): boolean {
return this.controls.showInteractionSpheres;
}
private emit(): void {
this.listeners.forEach((listener) => listener());
}