-
Notifications
You must be signed in to change notification settings - Fork 142
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(core): centralize configuration in component
- Loading branch information
Showing
12 changed files
with
125 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { Component } from "../Types"; | ||
import { Components } from "../Components"; | ||
import { Configurator } from "./src"; | ||
|
||
export * from "./src"; | ||
|
||
/** | ||
* A tool to manage all the configuration from the app centrally. | ||
*/ | ||
export class ConfigManager extends Component { | ||
list = new Set<Configurator<any, any>>(); | ||
|
||
/** {@link Component.enabled} */ | ||
enabled = true; | ||
|
||
/** | ||
* A unique identifier for the component. | ||
* This UUID is used to register the component within the Components system. | ||
*/ | ||
static readonly uuid = "dc86e7e9-a8fd-5473-9ef6-724c67fecb0f" as const; | ||
|
||
constructor(components: Components) { | ||
super(components); | ||
components.add(ConfigManager.uuid, this); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from "./configurator"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import * as THREE from "three"; | ||
|
||
export interface BooleanSettingsControl { | ||
type: "Boolean"; | ||
value: boolean; | ||
} | ||
|
||
export interface ColorSettingsControl { | ||
type: "Color"; | ||
opacity: number; | ||
value: THREE.Color; | ||
} | ||
|
||
export interface TextSettingsControl { | ||
type: "Text"; | ||
value: string; | ||
} | ||
|
||
export interface NumberSettingControl { | ||
type: "Number"; | ||
interpolable: boolean; | ||
min?: number; | ||
max?: number; | ||
value: number; | ||
} | ||
|
||
export interface SelectSettingControl { | ||
type: "Select"; | ||
multiple: boolean; | ||
options: Set<string>; | ||
value: string; | ||
} | ||
|
||
export interface Vector3SettingControl { | ||
type: "Vector3"; | ||
value: THREE.Vector3; | ||
} | ||
|
||
export interface TextSetSettingControl { | ||
type: "TextSet"; | ||
value: Set<string>; | ||
} | ||
|
||
export interface NoControl { | ||
type: "None"; | ||
value: any; | ||
} | ||
|
||
export type ControlEntry = | ||
| BooleanSettingsControl | ||
| ColorSettingsControl | ||
| TextSettingsControl | ||
| NumberSettingControl | ||
| SelectSettingControl | ||
| Vector3SettingControl | ||
| TextSetSettingControl | ||
| NoControl; | ||
|
||
export interface ControlsSchema { | ||
[name: string]: ControlEntry | ControlsSchema; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters