@skewedaspect/sage 0.9.6 → 0.10.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/behaviors/sound.d.ts +12 -127
- package/dist/classes/debugConsole.d.ts +1 -0
- package/dist/classes/gameEngine.d.ts +31 -46
- package/dist/classes/gameLevel.d.ts +21 -12
- package/dist/classes/level.d.ts +24 -29
- package/dist/entities/constants.d.ts +1 -0
- package/dist/entities/defineEntity.d.ts +17 -0
- package/dist/entities/entityPicking.d.ts +15 -0
- package/dist/entities/meshConfig.d.ts +14 -0
- package/dist/entities/nodeEntity.d.ts +43 -0
- package/dist/entities/nodePool.d.ts +8 -0
- package/dist/entities/nodeSimulation.d.ts +30 -0
- package/dist/entities/nodeSimulationContext.d.ts +17 -0
- package/dist/entities/standardMeshSource.d.ts +8 -0
- package/dist/events/payloads.d.ts +0 -42
- package/dist/events/types.d.ts +2 -23
- package/dist/input/actionContext.d.ts +13 -0
- package/dist/input/actionRegistry.d.ts +7 -0
- package/dist/input/binding.d.ts +33 -0
- package/dist/input/bindings/delta.d.ts +23 -0
- package/dist/input/bindings/toggle.d.ts +25 -0
- package/dist/input/bindings/trigger.d.ts +23 -0
- package/dist/input/bindings/value.d.ts +26 -0
- package/dist/input/configuration.d.ts +15 -0
- package/dist/input/deliverAction.d.ts +4 -0
- package/dist/input/deviceReader.d.ts +5 -0
- package/dist/input/deviceReaders/gamepad.d.ts +9 -0
- package/dist/input/deviceReaders/keyboard.d.ts +8 -0
- package/dist/input/deviceReaders/mouse.d.ts +9 -0
- package/dist/input/deviceState.d.ts +24 -0
- package/dist/input/inputCapture.d.ts +21 -0
- package/dist/input/resolveBinding.d.ts +4 -0
- package/dist/interfaces/game.d.ts +21 -5
- package/dist/interfaces/level.d.ts +21 -3
- package/dist/managers/asset.d.ts +17 -3
- package/dist/managers/game.d.ts +15 -5
- package/dist/managers/input.d.ts +31 -51
- package/dist/managers/level.d.ts +20 -4
- package/dist/managers/outline.d.ts +4 -4
- package/dist/managers/simulationSave.d.ts +38 -0
- package/dist/{postProcessingFrameGraph-CaMgQzR-.js → postProcessingFrameGraph-C3Og4kaS.js} +34 -26
- package/dist/postProcessingFrameGraph-C3Og4kaS.js.map +1 -0
- package/dist/sage.d.ts +54 -16
- package/dist/sage.es.js +1868 -2424
- package/dist/sage.es.js.map +1 -1
- package/dist/sage.umd.js +1 -1
- package/dist/sage.umd.js.map +1 -1
- package/dist/utils/bounds.d.ts +11 -0
- package/dist/utils/physics.d.ts +4 -1
- package/package.json +29 -66
- package/LICENSE +0 -21
- package/Readme.md +0 -73
- package/dist/behaviors/index.d.ts +0 -2
- package/dist/behaviors/stateMachine.d.ts +0 -76
- package/dist/classes/bindings/toggle.d.ts +0 -116
- package/dist/classes/bindings/trigger.d.ts +0 -81
- package/dist/classes/bindings/value.d.ts +0 -104
- package/dist/classes/entity.d.ts +0 -332
- package/dist/classes/input/gamepad.d.ts +0 -94
- package/dist/classes/input/keyboard.d.ts +0 -66
- package/dist/classes/input/mouse.d.ts +0 -91
- package/dist/classes/input/readers/gamepad.d.ts +0 -73
- package/dist/classes/input/readers/keyboard.d.ts +0 -56
- package/dist/classes/input/readers/mouse.d.ts +0 -41
- package/dist/interfaces/action.d.ts +0 -22
- package/dist/interfaces/binding.d.ts +0 -123
- package/dist/interfaces/entity.d.ts +0 -97
- package/dist/interfaces/input.d.ts +0 -180
- package/dist/managers/binding.d.ts +0 -233
- package/dist/managers/entity.d.ts +0 -264
- package/dist/managers/save.d.ts +0 -75
- package/dist/postProcessingFrameGraph-CaMgQzR-.js.map +0 -1
- package/dist/utils/entityProxy.d.ts +0 -2
- package/dist/utils/raycast.d.ts +0 -26
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { DeviceValueReader, InputState, KeyboardValueReaderDefinition } from "../../../interfaces/input.d.ts";
|
|
2
|
-
/**
|
|
3
|
-
* Types of keyboard input sources
|
|
4
|
-
*/
|
|
5
|
-
export type KeyboardSourceType = 'key';
|
|
6
|
-
/**
|
|
7
|
-
* Options for configuring a keyboard value reader
|
|
8
|
-
*/
|
|
9
|
-
export interface KeyboardReaderOptions {
|
|
10
|
-
/**
|
|
11
|
-
* Whether to use delta state instead of current state
|
|
12
|
-
* When true, the source will only return true on the initial key press
|
|
13
|
-
*/
|
|
14
|
-
useDelta?: boolean;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Reads values from keyboard input states
|
|
18
|
-
*/
|
|
19
|
-
export declare class KeyboardValueReader implements DeviceValueReader {
|
|
20
|
-
/**
|
|
21
|
-
* Always 'key' for keyboard readers.
|
|
22
|
-
*/
|
|
23
|
-
readonly sourceType: KeyboardSourceType;
|
|
24
|
-
/**
|
|
25
|
-
* The key code to monitor (e.g. "KeyA", "Space", "ArrowUp")
|
|
26
|
-
*/
|
|
27
|
-
readonly sourceKey: string;
|
|
28
|
-
/**
|
|
29
|
-
* When true, reads from delta (only true on the frame the key was first pressed/released)
|
|
30
|
-
*/
|
|
31
|
-
private readonly useDelta;
|
|
32
|
-
/**
|
|
33
|
-
* Creates a new KeyboardValueReader
|
|
34
|
-
*
|
|
35
|
-
* @param keyCode - KeyboardEvent.code value (e.g. "KeyA", "Space", "ArrowUp")
|
|
36
|
-
* @param options
|
|
37
|
-
*/
|
|
38
|
-
constructor(keyCode: string, options?: KeyboardReaderOptions);
|
|
39
|
-
/**
|
|
40
|
-
* Gets the value of the key state. Returns undefined for non-keyboard input states.
|
|
41
|
-
*
|
|
42
|
-
* @param state
|
|
43
|
-
*/
|
|
44
|
-
getValue(state: InputState): boolean | undefined;
|
|
45
|
-
/**
|
|
46
|
-
* Creates a KeyboardValueReader from a string representation
|
|
47
|
-
*
|
|
48
|
-
* @param sourceKey - KeyboardEvent.code value (e.g. "KeyA", "Space")
|
|
49
|
-
* @param options
|
|
50
|
-
*/
|
|
51
|
-
static fromString(sourceKey: string, options?: KeyboardReaderOptions): KeyboardValueReader;
|
|
52
|
-
/**
|
|
53
|
-
* Returns a JSON-serializable representation of this keyboard value reader.
|
|
54
|
-
*/
|
|
55
|
-
toJSON(): KeyboardValueReaderDefinition;
|
|
56
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { DeviceValueReader, InputState, MouseValueReaderDefinition } from "../../../interfaces/input.d.ts";
|
|
2
|
-
/**
|
|
3
|
-
* Types of mouse input sources
|
|
4
|
-
*/
|
|
5
|
-
export type MouseSourceType = 'button' | 'position' | 'wheel';
|
|
6
|
-
/**
|
|
7
|
-
* Reads values from mouse input states
|
|
8
|
-
*/
|
|
9
|
-
export declare class MouseValueReader implements DeviceValueReader {
|
|
10
|
-
/**
|
|
11
|
-
* Which category of mouse input: button press, cursor position, or scroll wheel.
|
|
12
|
-
*/
|
|
13
|
-
readonly sourceType: MouseSourceType;
|
|
14
|
-
/**
|
|
15
|
-
* Identifies the input within the source type (e.g. "button-0", "absolute:x", "deltaY")
|
|
16
|
-
*/
|
|
17
|
-
readonly sourceKey: string;
|
|
18
|
-
/**
|
|
19
|
-
* Creates a new MouseValueReader
|
|
20
|
-
*
|
|
21
|
-
* @param sourceType
|
|
22
|
-
* @param sourceKey - e.g. "button-0", "absolute:x", "deltaY"
|
|
23
|
-
*/
|
|
24
|
-
constructor(sourceType: MouseSourceType, sourceKey: string);
|
|
25
|
-
/**
|
|
26
|
-
* Gets the value of the mouse input source. Returns undefined for non-mouse input states.
|
|
27
|
-
*
|
|
28
|
-
* @param state
|
|
29
|
-
*/
|
|
30
|
-
getValue(state: InputState): boolean | number | undefined;
|
|
31
|
-
/**
|
|
32
|
-
* Creates a MouseValueReader from a colon-delimited string (e.g. "button:0", "position:absolute:x")
|
|
33
|
-
*
|
|
34
|
-
* @param sourceTypeString
|
|
35
|
-
*/
|
|
36
|
-
static fromString(sourceTypeString: string): MouseValueReader;
|
|
37
|
-
/**
|
|
38
|
-
* Returns a JSON-serializable representation of this mouse value reader.
|
|
39
|
-
*/
|
|
40
|
-
toJSON(): MouseValueReaderDefinition;
|
|
41
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Digital action (boolean)
|
|
3
|
-
*/
|
|
4
|
-
export interface DigitalAction {
|
|
5
|
-
type: 'digital';
|
|
6
|
-
name: string;
|
|
7
|
-
label?: string;
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* Analog action (numeric)
|
|
11
|
-
*/
|
|
12
|
-
export interface AnalogAction {
|
|
13
|
-
type: 'analog';
|
|
14
|
-
name: string;
|
|
15
|
-
label?: string;
|
|
16
|
-
minValue?: number;
|
|
17
|
-
maxValue?: number;
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Action types
|
|
21
|
-
*/
|
|
22
|
-
export type Action = DigitalAction | AnalogAction;
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
import { GameEventBus } from "../classes/eventBus.d.ts";
|
|
2
|
-
import { DeviceType, DeviceValueReader, DeviceValueReaderDefinition, InputState } from "./input.d.ts";
|
|
3
|
-
import { Action } from "./action.d.ts";
|
|
4
|
-
/**
|
|
5
|
-
* Types of bindings supported by the system
|
|
6
|
-
*/
|
|
7
|
-
export type BindingType = 'trigger' | 'toggle' | 'value';
|
|
8
|
-
/**
|
|
9
|
-
* Array of all supported binding types for validation
|
|
10
|
-
*/
|
|
11
|
-
export declare const bindingTypes: BindingType[];
|
|
12
|
-
/**
|
|
13
|
-
* Context for organizing bindings into groups that can be activated/deactivated together
|
|
14
|
-
*/
|
|
15
|
-
export interface Context {
|
|
16
|
-
name: string;
|
|
17
|
-
/**
|
|
18
|
-
* Whether this context is exclusive (only one exclusive context can be active at a time)
|
|
19
|
-
*/
|
|
20
|
-
exclusive: boolean;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Input definition that combines device ID and reader configuration into a single object
|
|
24
|
-
*/
|
|
25
|
-
export type InputDefinition = DeviceValueReaderDefinition & {
|
|
26
|
-
deviceID: string;
|
|
27
|
-
};
|
|
28
|
-
/**
|
|
29
|
-
* Options for captureInput() — waits for the next intentional input and returns its descriptor.
|
|
30
|
-
*/
|
|
31
|
-
export interface CaptureInputOptions {
|
|
32
|
-
/** Device types to listen for */
|
|
33
|
-
deviceTypes: DeviceType[];
|
|
34
|
-
/** Optional filter for source types (e.g. ['key', 'button', 'axis']) */
|
|
35
|
-
sourceTypes?: ('key' | 'button' | 'axis' | 'position' | 'wheel')[];
|
|
36
|
-
/** Optional AbortSignal for cancellation or timeout */
|
|
37
|
-
signal?: AbortSignal;
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Base interface for binding definitions with object-based sources
|
|
41
|
-
*/
|
|
42
|
-
export interface BindingDefinitionBase {
|
|
43
|
-
type: BindingType;
|
|
44
|
-
/** Name of an already-registered action */
|
|
45
|
-
action: string;
|
|
46
|
-
input: InputDefinition;
|
|
47
|
-
context?: string;
|
|
48
|
-
options?: Record<string, unknown>;
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Trigger binding definition
|
|
52
|
-
*/
|
|
53
|
-
export interface TriggerBindingDefinition extends BindingDefinitionBase {
|
|
54
|
-
type: 'trigger';
|
|
55
|
-
options?: {
|
|
56
|
-
edgeMode?: 'rising' | 'falling' | 'both';
|
|
57
|
-
threshold?: number;
|
|
58
|
-
passthrough?: boolean;
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Toggle binding definition
|
|
63
|
-
*/
|
|
64
|
-
export interface ToggleBindingDefinition extends BindingDefinitionBase {
|
|
65
|
-
type: 'toggle';
|
|
66
|
-
state?: boolean;
|
|
67
|
-
options?: {
|
|
68
|
-
invert?: boolean;
|
|
69
|
-
initialState?: boolean;
|
|
70
|
-
threshold?: number;
|
|
71
|
-
onValue?: boolean | number;
|
|
72
|
-
offValue?: boolean | number;
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Value binding definition
|
|
77
|
-
*/
|
|
78
|
-
export interface ValueBindingDefinition extends BindingDefinitionBase {
|
|
79
|
-
type: 'value';
|
|
80
|
-
options?: {
|
|
81
|
-
scale?: number;
|
|
82
|
-
offset?: number;
|
|
83
|
-
min?: number;
|
|
84
|
-
max?: number;
|
|
85
|
-
invert?: boolean;
|
|
86
|
-
emitOnChange?: boolean;
|
|
87
|
-
deadzone?: number;
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* Union type of all binding definitions
|
|
92
|
-
*/
|
|
93
|
-
export type BindingDefinition = TriggerBindingDefinition | ToggleBindingDefinition | ValueBindingDefinition;
|
|
94
|
-
/**
|
|
95
|
-
* Base interface for all input bindings
|
|
96
|
-
*/
|
|
97
|
-
export interface Binding {
|
|
98
|
-
readonly type: BindingType;
|
|
99
|
-
readonly action: Action;
|
|
100
|
-
readonly context?: string;
|
|
101
|
-
readonly deviceID: string;
|
|
102
|
-
readonly deviceType: DeviceType;
|
|
103
|
-
readonly reader: DeviceValueReader;
|
|
104
|
-
/**
|
|
105
|
-
* Process input state and potentially emit an action event
|
|
106
|
-
*
|
|
107
|
-
* @param state
|
|
108
|
-
* @param eventBus
|
|
109
|
-
*/
|
|
110
|
-
process(state: InputState, eventBus: GameEventBus): void;
|
|
111
|
-
/**
|
|
112
|
-
* Reset edge-detection state for a context activation. When an input state is provided, the binding primes its
|
|
113
|
-
* internal state from the current physical input so that already-held inputs don't produce phantom edges. Without
|
|
114
|
-
* a state, resets to a clean baseline (false).
|
|
115
|
-
*
|
|
116
|
-
* @param state - Last known input state for this binding's device, if available
|
|
117
|
-
*/
|
|
118
|
-
resetEdgeState(state?: InputState): void;
|
|
119
|
-
/**
|
|
120
|
-
* Convert the binding to a JSON-serializable object.
|
|
121
|
-
*/
|
|
122
|
-
toJSON(): BindingDefinition;
|
|
123
|
-
}
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import { GameEntityBehavior } from "../classes/entity.d.ts";
|
|
2
|
-
import { Action } from "./action.d.ts";
|
|
3
|
-
import { ColliderDebugConfig } from "../managers/colliderDebug.d.ts";
|
|
4
|
-
export type GameEntityBehaviorConstructor<RequiredState extends object = object> = new () => GameEntityBehavior<RequiredState>;
|
|
5
|
-
export interface GameEntityDefinition<State extends object = object> {
|
|
6
|
-
/** Unique type identifier for this entity definition. */
|
|
7
|
-
type: string;
|
|
8
|
-
/** Type string of a base definition to inherit from. Resolved at registration time. */
|
|
9
|
-
extends?: string;
|
|
10
|
-
/** Optional human-readable name for entities of this type. Can be overridden per-instance. */
|
|
11
|
-
name?: string;
|
|
12
|
-
/** Initial tags to apply to entities of this type. */
|
|
13
|
-
tags?: string[];
|
|
14
|
-
/** Actions that this entity type responds to. */
|
|
15
|
-
actions?: Action[];
|
|
16
|
-
/** Default state for entities of this type. */
|
|
17
|
-
defaultState: State;
|
|
18
|
-
/** Behaviors to attach to entities of this type. */
|
|
19
|
-
behaviors: GameEntityBehaviorConstructor[];
|
|
20
|
-
/**
|
|
21
|
-
* Visual representation configuration.
|
|
22
|
-
* If specified, a mesh will be automatically created when the entity spawns.
|
|
23
|
-
*/
|
|
24
|
-
mesh?: {
|
|
25
|
-
/**
|
|
26
|
-
* Mesh source: primitive type or path to GLB file.
|
|
27
|
-
* Primitives: 'box', 'sphere', 'capsule', 'cylinder'
|
|
28
|
-
* GLB: '/assets/models/player.glb'
|
|
29
|
-
*/
|
|
30
|
-
source: 'box' | 'sphere' | 'capsule' | 'cylinder' | string;
|
|
31
|
-
/** Scale multiplier for the mesh (default: 1) */
|
|
32
|
-
scale?: number | {
|
|
33
|
-
x: number;
|
|
34
|
-
y: number;
|
|
35
|
-
z: number;
|
|
36
|
-
};
|
|
37
|
-
/** If false, meshes spawn hidden (isVisible = false); they still collide and block raycasts. Default: true */
|
|
38
|
-
visible?: boolean;
|
|
39
|
-
/** Material configuration */
|
|
40
|
-
material?: {
|
|
41
|
-
/** Material type: 'standard' (default) or 'pbr' */
|
|
42
|
-
type?: 'standard' | 'pbr';
|
|
43
|
-
/** Diffuse/albedo color (RGB 0-1) */
|
|
44
|
-
color?: {
|
|
45
|
-
r: number;
|
|
46
|
-
g: number;
|
|
47
|
-
b: number;
|
|
48
|
-
};
|
|
49
|
-
/** Emissive color for glow effects (RGB 0-1) */
|
|
50
|
-
emissive?: {
|
|
51
|
-
r: number;
|
|
52
|
-
g: number;
|
|
53
|
-
b: number;
|
|
54
|
-
};
|
|
55
|
-
/** PBR: Metallic factor (0-1, default 0) */
|
|
56
|
-
metallic?: number;
|
|
57
|
-
/** PBR: Roughness factor (0-1, default 1) */
|
|
58
|
-
roughness?: number;
|
|
59
|
-
};
|
|
60
|
-
/** Primitive-specific parameters */
|
|
61
|
-
params?: {
|
|
62
|
-
size?: number;
|
|
63
|
-
width?: number;
|
|
64
|
-
height?: number;
|
|
65
|
-
depth?: number;
|
|
66
|
-
diameter?: number;
|
|
67
|
-
segments?: number;
|
|
68
|
-
radius?: number;
|
|
69
|
-
};
|
|
70
|
-
};
|
|
71
|
-
/** If true, entities of this type are recycled via an object pool instead of being destroyed. */
|
|
72
|
-
poolable?: boolean;
|
|
73
|
-
/** Number of entities to prewarm in the pool at registration time. Implies poolable. */
|
|
74
|
-
poolSize?: number;
|
|
75
|
-
/** Child entities to create and attach when this entity is created. */
|
|
76
|
-
children?: {
|
|
77
|
-
type: string;
|
|
78
|
-
name?: string;
|
|
79
|
-
initialState?: Record<string, unknown>;
|
|
80
|
-
position?: {
|
|
81
|
-
x: number;
|
|
82
|
-
y: number;
|
|
83
|
-
z: number;
|
|
84
|
-
};
|
|
85
|
-
rotation?: {
|
|
86
|
-
x: number;
|
|
87
|
-
y: number;
|
|
88
|
-
z: number;
|
|
89
|
-
};
|
|
90
|
-
}[];
|
|
91
|
-
/** Debug collider visualization config. Applied automatically during level loading. */
|
|
92
|
-
debugCollider?: ColliderDebugConfig;
|
|
93
|
-
onBeforeCreate?: (state: State) => Promise<State | undefined> | State | undefined;
|
|
94
|
-
onCreate?: (state: State) => Promise<State | undefined> | State | undefined;
|
|
95
|
-
onBeforeDestroy?: (state: State) => Promise<State | undefined> | State | undefined;
|
|
96
|
-
onDestroy?: (state: State) => Promise<void> | void;
|
|
97
|
-
}
|
|
@@ -1,180 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Valid input device types
|
|
3
|
-
*/
|
|
4
|
-
export declare const validDeviceTypes: readonly ["keyboard", "mouse", "gamepad"];
|
|
5
|
-
export type DeviceType = typeof validDeviceTypes[number];
|
|
6
|
-
/**
|
|
7
|
-
* Base input device interface
|
|
8
|
-
*/
|
|
9
|
-
export interface InputDevice {
|
|
10
|
-
id: string;
|
|
11
|
-
name: string;
|
|
12
|
-
type: DeviceType;
|
|
13
|
-
connected: boolean;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Keyboard device information
|
|
17
|
-
*/
|
|
18
|
-
export interface KeyboardDevice extends InputDevice {
|
|
19
|
-
type: 'keyboard';
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Mouse device information
|
|
23
|
-
*/
|
|
24
|
-
export interface MouseDevice extends InputDevice {
|
|
25
|
-
type: 'mouse';
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Gamepad device information
|
|
29
|
-
*/
|
|
30
|
-
export interface GamepadDevice extends InputDevice {
|
|
31
|
-
type: 'gamepad';
|
|
32
|
-
index: number;
|
|
33
|
-
mapping: string;
|
|
34
|
-
axes: number[];
|
|
35
|
-
buttons: GamepadButton[];
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Base interface for all input device states
|
|
39
|
-
*/
|
|
40
|
-
export interface BaseInputState {
|
|
41
|
-
event?: Event;
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Button state interface (for both mouse and gamepad)
|
|
45
|
-
*/
|
|
46
|
-
export interface ButtonState {
|
|
47
|
-
pressed: boolean;
|
|
48
|
-
touched?: boolean;
|
|
49
|
-
value?: number;
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* Mouse position interface
|
|
53
|
-
*/
|
|
54
|
-
export interface Position {
|
|
55
|
-
absolute: {
|
|
56
|
-
x: number;
|
|
57
|
-
y: number;
|
|
58
|
-
};
|
|
59
|
-
relative: {
|
|
60
|
-
x: number;
|
|
61
|
-
y: number;
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Unified keyboard input state with object literals instead of Maps
|
|
66
|
-
*/
|
|
67
|
-
export interface KeyboardInputState extends BaseInputState {
|
|
68
|
-
type: 'keyboard';
|
|
69
|
-
keys: Record<string, boolean>;
|
|
70
|
-
delta: Record<string, boolean>;
|
|
71
|
-
event?: KeyboardEvent;
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* Unified mouse input state with object literals instead of Maps
|
|
75
|
-
*/
|
|
76
|
-
export interface MouseInputState extends BaseInputState {
|
|
77
|
-
type: 'mouse';
|
|
78
|
-
buttons: Record<string, ButtonState>;
|
|
79
|
-
axes: Record<string, number>;
|
|
80
|
-
position: Position;
|
|
81
|
-
wheel?: {
|
|
82
|
-
deltaX: number;
|
|
83
|
-
deltaY: number;
|
|
84
|
-
deltaZ: number;
|
|
85
|
-
deltaMode: number;
|
|
86
|
-
};
|
|
87
|
-
event?: MouseEvent | WheelEvent;
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Unified gamepad input state with object literals instead of Maps
|
|
91
|
-
*/
|
|
92
|
-
export interface GamepadInputState extends BaseInputState {
|
|
93
|
-
type: 'gamepad';
|
|
94
|
-
buttons: Record<string, ButtonState>;
|
|
95
|
-
axes: Record<string, number>;
|
|
96
|
-
event?: GamepadEvent;
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* Unified input state interface that can represent any input device
|
|
100
|
-
*/
|
|
101
|
-
export type InputState = KeyboardInputState | MouseInputState | GamepadInputState;
|
|
102
|
-
/**
|
|
103
|
-
* Type guard to check if an input state is from a keyboard
|
|
104
|
-
*/
|
|
105
|
-
export declare function isKeyboardState(state: InputState): state is KeyboardInputState;
|
|
106
|
-
/**
|
|
107
|
-
* Type guard to check if an input state is from a mouse
|
|
108
|
-
*/
|
|
109
|
-
export declare function isMouseState(state: InputState): state is MouseInputState;
|
|
110
|
-
/**
|
|
111
|
-
* Type guard to check if an input state is from a gamepad
|
|
112
|
-
*/
|
|
113
|
-
export declare function isGamepadState(state: InputState): state is GamepadInputState;
|
|
114
|
-
/**
|
|
115
|
-
* Base interface for serialized device value readers
|
|
116
|
-
*/
|
|
117
|
-
export interface DeviceValueReaderDefinitionBase {
|
|
118
|
-
/** The device type: 'keyboard', 'mouse', or 'gamepad' */
|
|
119
|
-
type: DeviceType;
|
|
120
|
-
/** The input source category (e.g. 'key', 'button', 'axis', 'position', 'wheel') */
|
|
121
|
-
sourceType: string;
|
|
122
|
-
/** The specific input identifier (e.g. 'KeyA', 'button-0', 'axis-1', 'absolute:x') */
|
|
123
|
-
sourceKey: string;
|
|
124
|
-
}
|
|
125
|
-
/**
|
|
126
|
-
* Keyboard value reader definition
|
|
127
|
-
*/
|
|
128
|
-
export interface KeyboardValueReaderDefinition extends DeviceValueReaderDefinitionBase {
|
|
129
|
-
type: 'keyboard';
|
|
130
|
-
sourceType: 'key';
|
|
131
|
-
sourceKey: string;
|
|
132
|
-
options?: {
|
|
133
|
-
useDelta?: boolean;
|
|
134
|
-
};
|
|
135
|
-
}
|
|
136
|
-
/**
|
|
137
|
-
* Mouse value reader definition
|
|
138
|
-
*/
|
|
139
|
-
export interface MouseValueReaderDefinition extends DeviceValueReaderDefinitionBase {
|
|
140
|
-
type: 'mouse';
|
|
141
|
-
sourceType: string;
|
|
142
|
-
sourceKey: string;
|
|
143
|
-
}
|
|
144
|
-
/**
|
|
145
|
-
* Gamepad value reader definition
|
|
146
|
-
*/
|
|
147
|
-
export interface GamepadValueReaderDefinition extends DeviceValueReaderDefinitionBase {
|
|
148
|
-
type: 'gamepad';
|
|
149
|
-
sourceType: string;
|
|
150
|
-
sourceKey: string;
|
|
151
|
-
options?: {
|
|
152
|
-
useAnalogValue?: boolean;
|
|
153
|
-
deadzone?: number;
|
|
154
|
-
invert?: boolean;
|
|
155
|
-
};
|
|
156
|
-
}
|
|
157
|
-
/**
|
|
158
|
-
* Union type of all device value reader definitions
|
|
159
|
-
*/
|
|
160
|
-
export type DeviceValueReaderDefinition = KeyboardValueReaderDefinition | MouseValueReaderDefinition | GamepadValueReaderDefinition;
|
|
161
|
-
/**
|
|
162
|
-
* Interface for all device value readers
|
|
163
|
-
* Unified interface for all types of input sources that can extract values from device states
|
|
164
|
-
*/
|
|
165
|
-
export interface DeviceValueReader {
|
|
166
|
-
/** The input source category (e.g. 'key', 'button', 'axis', 'position', 'wheel') */
|
|
167
|
-
readonly sourceType: string;
|
|
168
|
-
/** The specific input identifier (e.g. 'KeyA', 'button-0', 'axis-1', 'absolute:x') */
|
|
169
|
-
readonly sourceKey: string;
|
|
170
|
-
/**
|
|
171
|
-
* Gets the value from an input state, or undefined if this reader doesn't apply to the given state type.
|
|
172
|
-
*
|
|
173
|
-
* @param state
|
|
174
|
-
*/
|
|
175
|
-
getValue(state: InputState): boolean | number | undefined;
|
|
176
|
-
/**
|
|
177
|
-
* Convert the reader to a JSON-serializable object.
|
|
178
|
-
*/
|
|
179
|
-
toJSON(): DeviceValueReaderDefinition;
|
|
180
|
-
}
|