Spaces:
Running
Running
Download editor/src/ModeManager.ts from dylanebert/gsplat-editor: direct link, hf CLI and curl.
- Browser
- Download file 1.01 kB
-
https://huggingface.co/spaces/dylanebert/gsplat-editor/resolve/main/editor/src/ModeManager.ts
- Command line
-
hf download hf://spaces/dylanebert/gsplat-editor/editor/src/ModeManager.ts
-
curl -L -o ModeManager.ts https://huggingface.co/spaces/dylanebert/gsplat-editor/resolve/main/editor/src/ModeManager.ts
1.01 kB
| import { InputMode } from "./InputMode"; | |
| class ModeManager { | |
| private static _instance: ModeManager; | |
| private static _modeFactories: Map<string, () => InputMode> = new Map(); | |
| private static _currentMode: InputMode | null = null; | |
| public static get instance(): ModeManager { | |
| if (!ModeManager._instance) { | |
| ModeManager._instance = new ModeManager(); | |
| } | |
| return ModeManager._instance; | |
| } | |
| public static registerMode(name: string, factory: () => InputMode) { | |
| this._modeFactories.set(name, factory); | |
| } | |
| public static enterMode(name: string) { | |
| const factory = this._modeFactories.get(name); | |
| if (factory) { | |
| this._currentMode?.exit(); | |
| this._currentMode = factory(); | |
| } else { | |
| console.error(`No mode registered with name ${name}.`); | |
| } | |
| } | |
| public static exitCurrentMode() { | |
| this._currentMode?.exit(); | |
| this._currentMode = null; | |
| } | |
| } | |
| export { ModeManager }; | |