update: add a physic scenne
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
import { useEffect } from "react";
|
||||
import type GUI from "lil-gui";
|
||||
import { Debug } from "@/utils/debug/Debug";
|
||||
|
||||
export function useDebugFolder(
|
||||
name: string,
|
||||
setup: (folder: GUI) => void,
|
||||
): void {
|
||||
useEffect(() => {
|
||||
const debug = Debug.getInstance();
|
||||
if (!debug.active) return;
|
||||
const folder = debug.createFolder(name);
|
||||
if (!folder) return;
|
||||
setup(folder);
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, []);
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import {
|
||||
InteractionManager,
|
||||
type InteractionSnapshot,
|
||||
} from "@/stateManager/InteractionManager";
|
||||
|
||||
export function useInteraction(): InteractionSnapshot {
|
||||
const manager = InteractionManager.getInstance();
|
||||
const [state, setState] = useState<InteractionSnapshot>(manager.getState());
|
||||
|
||||
useEffect(() => {
|
||||
return manager.subscribe(() => {
|
||||
setState({ ...manager.getState() });
|
||||
});
|
||||
}, [manager]);
|
||||
|
||||
return state;
|
||||
}
|
||||
Reference in New Issue
Block a user