@n3rdw1z4rd/core 0.18.4 → 0.19.0
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/README.md +72 -10
- package/dist/astar.d.ts +44 -0
- package/dist/astar.js +118 -0
- package/dist/canvas-renderer.d.ts +154 -0
- package/dist/canvas-renderer.js +200 -0
- package/dist/clock.d.ts +69 -0
- package/dist/clock.js +108 -0
- package/dist/color-palette.d.ts +25 -0
- package/dist/color-palette.js +112 -0
- package/dist/color.d.ts +90 -0
- package/dist/color.js +224 -0
- package/dist/css/main.css +1 -3
- package/dist/disposable.d.ts +27 -0
- package/dist/disposable.js +32 -0
- package/dist/dungeon-generator.d.ts +142 -0
- package/dist/dungeon-generator.js +288 -0
- package/dist/ecs.d.ts +87 -0
- package/dist/ecs.js +101 -0
- package/dist/emitter.d.ts +40 -0
- package/dist/emitter.js +54 -0
- package/dist/event-queue.d.ts +29 -0
- package/dist/event-queue.js +40 -0
- package/dist/index.cjs +3813 -0
- package/dist/index.d.cts +2655 -0
- package/dist/index.d.ts +35 -873
- package/dist/index.js +34 -3986
- package/dist/input/action-map.d.ts +79 -0
- package/dist/input/action-map.js +131 -0
- package/dist/input/bindings.d.ts +273 -0
- package/dist/input/bindings.js +250 -0
- package/dist/input/gestures.d.ts +108 -0
- package/dist/input/gestures.js +159 -0
- package/dist/input/index.d.ts +5 -0
- package/dist/input/index.js +5 -0
- package/dist/input/input.d.ts +297 -0
- package/dist/input/input.js +695 -0
- package/dist/log.d.ts +8 -0
- package/dist/log.js +9 -0
- package/dist/map2d.d.ts +83 -0
- package/dist/map2d.js +120 -0
- package/dist/map3d-CHDJiq5T.d.cts +236 -0
- package/dist/map3d.d.ts +94 -0
- package/dist/map3d.js +148 -0
- package/dist/math.d.ts +176 -0
- package/dist/math.js +206 -0
- package/dist/misc.d.ts +46 -0
- package/dist/misc.js +71 -0
- package/dist/observable.d.ts +43 -0
- package/dist/observable.js +53 -0
- package/dist/particle-renderer.d.ts +47 -0
- package/dist/particle-renderer.js +82 -0
- package/dist/particle-system-2d.d.ts +60 -0
- package/dist/particle-system-2d.js +147 -0
- package/dist/random.d.ts +46 -0
- package/dist/random.js +74 -0
- package/dist/rectangle.d.ts +44 -0
- package/dist/rectangle.js +69 -0
- package/dist/rng.d.ts +72 -0
- package/dist/rng.js +152 -0
- package/dist/signal.d.ts +34 -0
- package/dist/signal.js +41 -0
- package/dist/spatial-partition-2d.d.ts +42 -0
- package/dist/spatial-partition-2d.js +52 -0
- package/dist/spatial-partition-3d-Ba-VBveM.cjs +1324 -0
- package/dist/spatial-partition-3d.d.ts +44 -0
- package/dist/spatial-partition-3d.js +57 -0
- package/dist/three/asteroid-mesh.d.ts +41 -0
- package/dist/three/asteroid-mesh.js +44 -0
- package/dist/three/camera-rig.d.ts +140 -0
- package/dist/three/camera-rig.js +197 -0
- package/dist/three/cube-sphere-geometry.d.ts +55 -0
- package/dist/three/cube-sphere-geometry.js +239 -0
- package/dist/three/ecs.d.ts +75 -0
- package/dist/three/ecs.js +64 -0
- package/dist/three/index.d.ts +12 -0
- package/dist/three/index.js +12 -0
- package/dist/three/particle-system-3d.d.ts +53 -0
- package/dist/three/particle-system-3d.js +224 -0
- package/dist/three/renderer.d.ts +38 -0
- package/dist/three/renderer.js +57 -0
- package/dist/three/starfield.d.ts +23 -0
- package/dist/three/starfield.js +64 -0
- package/dist/three/texture-atlas.d.ts +76 -0
- package/dist/three/texture-atlas.js +84 -0
- package/dist/three/texture-utils.d.ts +31 -0
- package/dist/three/texture-utils.js +44 -0
- package/dist/three/voxel-geometry.d.ts +72 -0
- package/dist/three/voxel-geometry.js +231 -0
- package/dist/three/voxel-mesh.d.ts +67 -0
- package/dist/three/voxel-mesh.js +71 -0
- package/dist/three.cjs +1307 -0
- package/dist/three.d.cts +655 -0
- package/dist/tilemap.d.ts +17 -0
- package/dist/tilemap.js +26 -0
- package/dist/types.d.ts +34 -0
- package/dist/types.js +0 -0
- package/dist/vector.d.ts +78 -0
- package/dist/vector.js +169 -0
- package/dist/webgl-renderer.d.ts +89 -0
- package/dist/webgl-renderer.js +140 -0
- package/dist/webgl.d.ts +357 -0
- package/dist/webgl.js +628 -0
- package/dist/worker-interface.d.ts +30 -0
- package/dist/worker-interface.js +39 -0
- package/package.json +55 -13
- package/dist/css/index.ts +0 -1
- package/dist/index.css +0 -104
- package/dist/index.d.mts +0 -873
- package/dist/index.mjs +0 -3982
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { Binding } from "./bindings.js";
|
|
2
|
+
//#region src/input/action-map.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* Deadzone given to new actions when none is specified.
|
|
5
|
+
*
|
|
6
|
+
* @category Input
|
|
7
|
+
*/
|
|
8
|
+
export declare const DEFAULT_DEADZONE = 0.2;
|
|
9
|
+
/**
|
|
10
|
+
* A named action in an {@link ActionMap}.
|
|
11
|
+
*
|
|
12
|
+
* @category Input
|
|
13
|
+
*/
|
|
14
|
+
export interface Action {
|
|
15
|
+
/** the action's name */
|
|
16
|
+
readonly name: string;
|
|
17
|
+
/** raw values at or below this don't count (sticks, triggers) */
|
|
18
|
+
deadzone: number;
|
|
19
|
+
/** inputs that trigger the action; the strongest one wins */
|
|
20
|
+
readonly bindings: Binding[];
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* The serialized form of an {@link ActionMap} (from {@link ActionMap.toJSON}), keyed by action name.
|
|
24
|
+
*
|
|
25
|
+
* @category Input
|
|
26
|
+
*/
|
|
27
|
+
export type ActionMapJSON = Record<string, {
|
|
28
|
+
/** see {@link Action.deadzone} */
|
|
29
|
+
deadzone: number;
|
|
30
|
+
/** the action's bindings, in order */
|
|
31
|
+
bindings: Binding[];
|
|
32
|
+
}>;
|
|
33
|
+
/**
|
|
34
|
+
* Named actions and the inputs bound to them, like Godot's InputMap. Every {@link Input} has one as
|
|
35
|
+
* {@link Input.actions}; the methods that change it return `this` for chaining.
|
|
36
|
+
*
|
|
37
|
+
* ```ts
|
|
38
|
+
* input.actions
|
|
39
|
+
* .add('jump', [key('Space'), pad('A')])
|
|
40
|
+
* .bind('jump', gesture('tap'));
|
|
41
|
+
*
|
|
42
|
+
* localStorage.setItem('bindings', JSON.stringify(input.actions));
|
|
43
|
+
* ```
|
|
44
|
+
*
|
|
45
|
+
* @category Input
|
|
46
|
+
*/
|
|
47
|
+
export declare class ActionMap {
|
|
48
|
+
private readonly _actions;
|
|
49
|
+
/** action names, in the order they were added */
|
|
50
|
+
get names(): string[];
|
|
51
|
+
/** Whether an action with this name exists. */
|
|
52
|
+
has(name: string): boolean;
|
|
53
|
+
/** The action with this name, or `undefined`. */
|
|
54
|
+
get(name: string): Action | undefined;
|
|
55
|
+
/** Adds an action, or replaces its bindings (and deadzone, if given) if it exists. */
|
|
56
|
+
add(name: string, bindings?: Binding[], options?: {
|
|
57
|
+
deadzone?: number;
|
|
58
|
+
}): this;
|
|
59
|
+
/** Removes an action, if it exists. */
|
|
60
|
+
remove(name: string): this;
|
|
61
|
+
/** Adds a binding to an action (creating the action if needed); duplicates are ignored. */
|
|
62
|
+
bind(name: string, binding: Binding): this;
|
|
63
|
+
/** Removes a binding (compared with {@link bindingsEqual}) from an action, if present. */
|
|
64
|
+
unbind(name: string, binding: Binding): this;
|
|
65
|
+
/** Actions that already use this binding, e.g. to warn about conflicts when rebinding. */
|
|
66
|
+
findBinding(binding: Binding): string[];
|
|
67
|
+
/** Removes all actions. */
|
|
68
|
+
clear(): this;
|
|
69
|
+
/** A JSON-serializable copy of all actions, for saving rebinds; see {@link ActionMap.load}. */
|
|
70
|
+
toJSON(): ActionMapJSON;
|
|
71
|
+
/** Replaces all actions with the saved ones (e.g. a player's rebinds). */
|
|
72
|
+
load(json: ActionMapJSON): this;
|
|
73
|
+
/**
|
|
74
|
+
* Godot-style `ui_*` actions for menus and dialogs (`ui_accept`, `ui_cancel`, `ui_left`, `ui_right`,
|
|
75
|
+
* `ui_up`, `ui_down`, `ui_page_up`, `ui_page_down`), with a 0.5 deadzone; replaces existing ones.
|
|
76
|
+
*/
|
|
77
|
+
addDefaults(): this;
|
|
78
|
+
}
|
|
79
|
+
//#endregion
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { bindingsEqual, key, pad, padAxis } from "./bindings.js";
|
|
2
|
+
//#region src/input/action-map.ts
|
|
3
|
+
/**
|
|
4
|
+
* Deadzone given to new actions when none is specified.
|
|
5
|
+
*
|
|
6
|
+
* @category Input
|
|
7
|
+
*/
|
|
8
|
+
const DEFAULT_DEADZONE = .2;
|
|
9
|
+
/**
|
|
10
|
+
* Named actions and the inputs bound to them, like Godot's InputMap. Every {@link Input} has one as
|
|
11
|
+
* {@link Input.actions}; the methods that change it return `this` for chaining.
|
|
12
|
+
*
|
|
13
|
+
* ```ts
|
|
14
|
+
* input.actions
|
|
15
|
+
* .add('jump', [key('Space'), pad('A')])
|
|
16
|
+
* .bind('jump', gesture('tap'));
|
|
17
|
+
*
|
|
18
|
+
* localStorage.setItem('bindings', JSON.stringify(input.actions));
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* @category Input
|
|
22
|
+
*/
|
|
23
|
+
var ActionMap = class {
|
|
24
|
+
_actions = /* @__PURE__ */ new Map();
|
|
25
|
+
/** action names, in the order they were added */
|
|
26
|
+
get names() {
|
|
27
|
+
return [...this._actions.keys()];
|
|
28
|
+
}
|
|
29
|
+
/** Whether an action with this name exists. */
|
|
30
|
+
has(name) {
|
|
31
|
+
return this._actions.has(name);
|
|
32
|
+
}
|
|
33
|
+
/** The action with this name, or `undefined`. */
|
|
34
|
+
get(name) {
|
|
35
|
+
return this._actions.get(name);
|
|
36
|
+
}
|
|
37
|
+
/** Adds an action, or replaces its bindings (and deadzone, if given) if it exists. */
|
|
38
|
+
add(name, bindings = [], options = {}) {
|
|
39
|
+
const existing = this._actions.get(name);
|
|
40
|
+
this._actions.set(name, {
|
|
41
|
+
name,
|
|
42
|
+
deadzone: options.deadzone ?? existing?.deadzone ?? .2,
|
|
43
|
+
bindings: [...bindings]
|
|
44
|
+
});
|
|
45
|
+
return this;
|
|
46
|
+
}
|
|
47
|
+
/** Removes an action, if it exists. */
|
|
48
|
+
remove(name) {
|
|
49
|
+
this._actions.delete(name);
|
|
50
|
+
return this;
|
|
51
|
+
}
|
|
52
|
+
/** Adds a binding to an action (creating the action if needed); duplicates are ignored. */
|
|
53
|
+
bind(name, binding) {
|
|
54
|
+
if (!this._actions.has(name)) this.add(name);
|
|
55
|
+
const action = this._actions.get(name);
|
|
56
|
+
if (!action.bindings.some((b) => bindingsEqual(b, binding))) action.bindings.push(binding);
|
|
57
|
+
return this;
|
|
58
|
+
}
|
|
59
|
+
/** Removes a binding (compared with {@link bindingsEqual}) from an action, if present. */
|
|
60
|
+
unbind(name, binding) {
|
|
61
|
+
const action = this._actions.get(name);
|
|
62
|
+
if (action) {
|
|
63
|
+
const i = action.bindings.findIndex((b) => bindingsEqual(b, binding));
|
|
64
|
+
if (i >= 0) action.bindings.splice(i, 1);
|
|
65
|
+
}
|
|
66
|
+
return this;
|
|
67
|
+
}
|
|
68
|
+
/** Actions that already use this binding, e.g. to warn about conflicts when rebinding. */
|
|
69
|
+
findBinding(binding) {
|
|
70
|
+
return this.names.filter((name) => this._actions.get(name).bindings.some((b) => bindingsEqual(b, binding)));
|
|
71
|
+
}
|
|
72
|
+
/** Removes all actions. */
|
|
73
|
+
clear() {
|
|
74
|
+
this._actions.clear();
|
|
75
|
+
return this;
|
|
76
|
+
}
|
|
77
|
+
/** A JSON-serializable copy of all actions, for saving rebinds; see {@link ActionMap.load}. */
|
|
78
|
+
toJSON() {
|
|
79
|
+
const json = {};
|
|
80
|
+
for (const action of this._actions.values()) json[action.name] = {
|
|
81
|
+
deadzone: action.deadzone,
|
|
82
|
+
bindings: action.bindings.map((b) => ({ ...b }))
|
|
83
|
+
};
|
|
84
|
+
return json;
|
|
85
|
+
}
|
|
86
|
+
/** Replaces all actions with the saved ones (e.g. a player's rebinds). */
|
|
87
|
+
load(json) {
|
|
88
|
+
this.clear();
|
|
89
|
+
for (const [name, action] of Object.entries(json)) this.add(name, action.bindings, { deadzone: action.deadzone });
|
|
90
|
+
return this;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Godot-style `ui_*` actions for menus and dialogs (`ui_accept`, `ui_cancel`, `ui_left`, `ui_right`,
|
|
94
|
+
* `ui_up`, `ui_down`, `ui_page_up`, `ui_page_down`), with a 0.5 deadzone; replaces existing ones.
|
|
95
|
+
*/
|
|
96
|
+
addDefaults() {
|
|
97
|
+
const ui = { deadzone: .5 };
|
|
98
|
+
this.add("ui_accept", [
|
|
99
|
+
key("Enter"),
|
|
100
|
+
key("NumpadEnter"),
|
|
101
|
+
key("Space"),
|
|
102
|
+
pad("A")
|
|
103
|
+
], ui);
|
|
104
|
+
this.add("ui_cancel", [key("Escape"), pad("B")], ui);
|
|
105
|
+
this.add("ui_left", [
|
|
106
|
+
key("ArrowLeft"),
|
|
107
|
+
pad("DpadLeft"),
|
|
108
|
+
padAxis("leftX", -1)
|
|
109
|
+
], ui);
|
|
110
|
+
this.add("ui_right", [
|
|
111
|
+
key("ArrowRight"),
|
|
112
|
+
pad("DpadRight"),
|
|
113
|
+
padAxis("leftX", 1)
|
|
114
|
+
], ui);
|
|
115
|
+
this.add("ui_up", [
|
|
116
|
+
key("ArrowUp"),
|
|
117
|
+
pad("DpadUp"),
|
|
118
|
+
padAxis("leftY", -1)
|
|
119
|
+
], ui);
|
|
120
|
+
this.add("ui_down", [
|
|
121
|
+
key("ArrowDown"),
|
|
122
|
+
pad("DpadDown"),
|
|
123
|
+
padAxis("leftY", 1)
|
|
124
|
+
], ui);
|
|
125
|
+
this.add("ui_page_up", [key("PageUp"), pad("LB")], ui);
|
|
126
|
+
this.add("ui_page_down", [key("PageDown"), pad("RB")], ui);
|
|
127
|
+
return this;
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
//#endregion
|
|
131
|
+
export { ActionMap, DEFAULT_DEADZONE };
|
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
//#region src/input/bindings.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Modifier keys that must also be held for a key {@link Binding} to count (left or right side).
|
|
4
|
+
* Modifiers left out are not checked, so a binding without `ctrl` still fires while Ctrl is held.
|
|
5
|
+
*
|
|
6
|
+
* @category Input
|
|
7
|
+
*/
|
|
8
|
+
export interface KeyModifiers {
|
|
9
|
+
/** require Shift */
|
|
10
|
+
shift?: boolean;
|
|
11
|
+
/** require Ctrl */
|
|
12
|
+
ctrl?: boolean;
|
|
13
|
+
/** require Alt */
|
|
14
|
+
alt?: boolean;
|
|
15
|
+
/** require Meta (Windows / Command key) */
|
|
16
|
+
meta?: boolean;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* A mouse or pen button, as numbered by `PointerEvent.button` (0 to 4).
|
|
20
|
+
*
|
|
21
|
+
* @category Input
|
|
22
|
+
*/
|
|
23
|
+
export type MouseButton = 'left' | 'middle' | 'right' | 'back' | 'forward';
|
|
24
|
+
/**
|
|
25
|
+
* A mouse wheel direction.
|
|
26
|
+
*
|
|
27
|
+
* @category Input
|
|
28
|
+
*/
|
|
29
|
+
export type WheelDirection = 'up' | 'down' | 'left' | 'right';
|
|
30
|
+
/**
|
|
31
|
+
* W3C "standard" gamepad mapping, in button-index order (Xbox names; on PlayStation A = Cross,
|
|
32
|
+
* B = Circle, X = Square, Y = Triangle).
|
|
33
|
+
*
|
|
34
|
+
* @category Input
|
|
35
|
+
*/
|
|
36
|
+
export declare const GAMEPAD_BUTTONS: readonly ["A", "B", "X", "Y", "LB", "RB", "LT", "RT", "Select", "Start", "LS", "RS", "DpadUp", "DpadDown", "DpadLeft", "DpadRight", "Home"];
|
|
37
|
+
/**
|
|
38
|
+
* A gamepad button name from {@link GAMEPAD_BUTTONS}.
|
|
39
|
+
*
|
|
40
|
+
* @category Input
|
|
41
|
+
*/
|
|
42
|
+
export type GamepadButton = typeof GAMEPAD_BUTTONS[number];
|
|
43
|
+
/**
|
|
44
|
+
* Standard-mapping gamepad stick axes, in axis-index order; Y is positive downwards.
|
|
45
|
+
*
|
|
46
|
+
* @category Input
|
|
47
|
+
*/
|
|
48
|
+
export declare const GAMEPAD_AXES: readonly ["leftX", "leftY", "rightX", "rightY"];
|
|
49
|
+
/**
|
|
50
|
+
* A gamepad axis name from {@link GAMEPAD_AXES}.
|
|
51
|
+
*
|
|
52
|
+
* @category Input
|
|
53
|
+
*/
|
|
54
|
+
export type GamepadAxis = typeof GAMEPAD_AXES[number];
|
|
55
|
+
/**
|
|
56
|
+
* The touch gestures recognized by {@link GestureRecognizer}.
|
|
57
|
+
*
|
|
58
|
+
* @category Input
|
|
59
|
+
*/
|
|
60
|
+
export declare const GESTURES: readonly ["tap", "doubleTap", "longPress", "swipeLeft", "swipeRight", "swipeUp", "swipeDown", "pinchIn", "pinchOut"];
|
|
61
|
+
/**
|
|
62
|
+
* A gesture name from {@link GESTURES}.
|
|
63
|
+
*
|
|
64
|
+
* @category Input
|
|
65
|
+
*/
|
|
66
|
+
export type Gesture = typeof GESTURES[number];
|
|
67
|
+
/**
|
|
68
|
+
* Which hand a VR controller is held in.
|
|
69
|
+
*
|
|
70
|
+
* @category Input
|
|
71
|
+
*/
|
|
72
|
+
export type XRHand = 'left' | 'right';
|
|
73
|
+
/**
|
|
74
|
+
* WebXR "xr-standard" controller buttons, in button-index order; A/X and B/Y are the
|
|
75
|
+
* primary/secondary face buttons of each hand.
|
|
76
|
+
*
|
|
77
|
+
* @category Input
|
|
78
|
+
*/
|
|
79
|
+
export declare const XR_BUTTONS: readonly ["trigger", "squeeze", "touchpad", "thumbstick", "primary", "secondary"];
|
|
80
|
+
/**
|
|
81
|
+
* A VR controller button name from {@link XR_BUTTONS}.
|
|
82
|
+
*
|
|
83
|
+
* @category Input
|
|
84
|
+
*/
|
|
85
|
+
export type XRButton = typeof XR_BUTTONS[number];
|
|
86
|
+
/**
|
|
87
|
+
* WebXR "xr-standard" controller axes (touchpad, thumbstick), in axis-index order; Y is positive downwards.
|
|
88
|
+
*
|
|
89
|
+
* @category Input
|
|
90
|
+
*/
|
|
91
|
+
export declare const XR_AXES: readonly ["padX", "padY", "thumbX", "thumbY"];
|
|
92
|
+
/**
|
|
93
|
+
* A VR controller axis name from {@link XR_AXES}.
|
|
94
|
+
*
|
|
95
|
+
* @category Input
|
|
96
|
+
*/
|
|
97
|
+
export type XRAxis = typeof XR_AXES[number];
|
|
98
|
+
/**
|
|
99
|
+
* A keyboard key, made with {@link key}.
|
|
100
|
+
*
|
|
101
|
+
* @category Input
|
|
102
|
+
*/
|
|
103
|
+
export interface KeyBinding {
|
|
104
|
+
/** always 'key' */
|
|
105
|
+
type: 'key';
|
|
106
|
+
/** `KeyboardEvent.code`, e.g. 'KeyW' (layout independent) */
|
|
107
|
+
code: string;
|
|
108
|
+
/** modifiers that must also be held, see {@link KeyModifiers} */
|
|
109
|
+
modifiers?: KeyModifiers;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* A mouse (or pen) button, made with {@link mouse}.
|
|
113
|
+
*
|
|
114
|
+
* @category Input
|
|
115
|
+
*/
|
|
116
|
+
export interface MouseBinding {
|
|
117
|
+
/** always 'mouse' */
|
|
118
|
+
type: 'mouse';
|
|
119
|
+
/** which button */
|
|
120
|
+
button: MouseButton;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* A wheel direction, made with {@link wheel}.
|
|
124
|
+
*
|
|
125
|
+
* @category Input
|
|
126
|
+
*/
|
|
127
|
+
export interface WheelBinding {
|
|
128
|
+
/** always 'wheel' */
|
|
129
|
+
type: 'wheel';
|
|
130
|
+
/** which way the wheel moves */
|
|
131
|
+
direction: WheelDirection;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* A gamepad button (standard mapping), made with {@link pad}.
|
|
135
|
+
*
|
|
136
|
+
* @category Input
|
|
137
|
+
*/
|
|
138
|
+
export interface PadBinding {
|
|
139
|
+
/** always 'pad' */
|
|
140
|
+
type: 'pad';
|
|
141
|
+
/** button name from the standard mapping */
|
|
142
|
+
button: GamepadButton;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* One half of a gamepad stick axis, made with {@link padAxis}.
|
|
146
|
+
*
|
|
147
|
+
* @category Input
|
|
148
|
+
*/
|
|
149
|
+
export interface PadAxisBinding {
|
|
150
|
+
/** always 'padAxis' */
|
|
151
|
+
type: 'padAxis';
|
|
152
|
+
/** which stick axis */
|
|
153
|
+
axis: GamepadAxis;
|
|
154
|
+
/** 1 = positive half (right / down), -1 = negative half (left / up) */
|
|
155
|
+
direction: 1 | -1;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* A touch gesture, made with {@link gesture}.
|
|
159
|
+
*
|
|
160
|
+
* @category Input
|
|
161
|
+
*/
|
|
162
|
+
export interface GestureBinding {
|
|
163
|
+
/** always 'gesture' */
|
|
164
|
+
type: 'gesture';
|
|
165
|
+
/** which gesture */
|
|
166
|
+
gesture: Gesture;
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* A VR controller button, made with {@link xr}.
|
|
170
|
+
*
|
|
171
|
+
* @category Input
|
|
172
|
+
*/
|
|
173
|
+
export interface XRBinding {
|
|
174
|
+
/** always 'xr' */
|
|
175
|
+
type: 'xr';
|
|
176
|
+
/** which controller */
|
|
177
|
+
hand: XRHand;
|
|
178
|
+
/** button name from the xr-standard mapping */
|
|
179
|
+
button: XRButton;
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* One half of a VR controller axis, made with {@link xrAxis}.
|
|
183
|
+
*
|
|
184
|
+
* @category Input
|
|
185
|
+
*/
|
|
186
|
+
export interface XRAxisBinding {
|
|
187
|
+
/** always 'xrAxis' */
|
|
188
|
+
type: 'xrAxis';
|
|
189
|
+
/** which controller */
|
|
190
|
+
hand: XRHand;
|
|
191
|
+
/** which touchpad or thumbstick axis */
|
|
192
|
+
axis: XRAxis;
|
|
193
|
+
/** 1 = positive half (right / down), -1 = negative half (left / up) */
|
|
194
|
+
direction: 1 | -1;
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* One physical input that can trigger an action: a plain, JSON-serializable object, usually made
|
|
198
|
+
* with {@link key}, {@link mouse}, {@link wheel}, {@link pad}, {@link padAxis}, {@link gesture},
|
|
199
|
+
* {@link xr} or {@link xrAxis}. `type` selects the variant.
|
|
200
|
+
*
|
|
201
|
+
* @category Input
|
|
202
|
+
*/
|
|
203
|
+
export type Binding = KeyBinding | MouseBinding | WheelBinding | PadBinding | PadAxisBinding | GestureBinding | XRBinding | XRAxisBinding;
|
|
204
|
+
/**
|
|
205
|
+
* A physical key, by `KeyboardEvent.code` (layout independent: 'KeyW' is W on QWERTY, Z on AZERTY).
|
|
206
|
+
*
|
|
207
|
+
* @category Input
|
|
208
|
+
*/
|
|
209
|
+
export declare const key: (code: string, modifiers?: KeyModifiers) => KeyBinding;
|
|
210
|
+
/**
|
|
211
|
+
* A mouse (or pen) button.
|
|
212
|
+
*
|
|
213
|
+
* @category Input
|
|
214
|
+
*/
|
|
215
|
+
export declare const mouse: (button: MouseButton) => MouseBinding;
|
|
216
|
+
/**
|
|
217
|
+
* A wheel direction: pressed for one frame whenever the wheel moves that way.
|
|
218
|
+
*
|
|
219
|
+
* @category Input
|
|
220
|
+
*/
|
|
221
|
+
export declare const wheel: (direction: WheelDirection) => WheelBinding;
|
|
222
|
+
/**
|
|
223
|
+
* A gamepad button (standard mapping).
|
|
224
|
+
*
|
|
225
|
+
* @category Input
|
|
226
|
+
*/
|
|
227
|
+
export declare const pad: (button: GamepadButton) => PadBinding;
|
|
228
|
+
/**
|
|
229
|
+
* One direction of a gamepad stick axis, e.g. padAxis('leftX', -1) for "left stick left".
|
|
230
|
+
*
|
|
231
|
+
* @category Input
|
|
232
|
+
*/
|
|
233
|
+
export declare const padAxis: (axis: GamepadAxis, direction: 1 | -1) => PadAxisBinding;
|
|
234
|
+
/**
|
|
235
|
+
* A touch gesture.
|
|
236
|
+
*
|
|
237
|
+
* @category Input
|
|
238
|
+
*/
|
|
239
|
+
export declare const gesture: (name: Gesture) => GestureBinding;
|
|
240
|
+
/**
|
|
241
|
+
* A VR controller button.
|
|
242
|
+
*
|
|
243
|
+
* @category Input
|
|
244
|
+
*/
|
|
245
|
+
export declare const xr: (hand: XRHand, button: XRButton) => XRBinding;
|
|
246
|
+
/**
|
|
247
|
+
* One direction of a VR controller axis.
|
|
248
|
+
*
|
|
249
|
+
* @category Input
|
|
250
|
+
*/
|
|
251
|
+
export declare const xrAxis: (hand: XRHand, axis: XRAxis, direction: 1 | -1) => XRAxisBinding;
|
|
252
|
+
/**
|
|
253
|
+
* Identifies the physical control behind a binding (modifiers aside), e.g. `'key:KeyW'` or
|
|
254
|
+
* `'padAxis:leftX:-1'`.
|
|
255
|
+
*
|
|
256
|
+
* @category Input
|
|
257
|
+
*/
|
|
258
|
+
export declare function controlId(binding: Binding): string;
|
|
259
|
+
/**
|
|
260
|
+
* Whether two bindings refer to the same control; key bindings must also require the same modifiers
|
|
261
|
+
* (a missing modifier counts as `false`).
|
|
262
|
+
*
|
|
263
|
+
* @category Input
|
|
264
|
+
*/
|
|
265
|
+
export declare function bindingsEqual(a: Binding, b: Binding): boolean;
|
|
266
|
+
/**
|
|
267
|
+
* A readable name for a binding, e.g. for "Press Space to jump" prompts. Pass `keyLabels` (from
|
|
268
|
+
* {@link Input.loadKeyboardLayout}) to name keys as printed on the player's keyboard.
|
|
269
|
+
*
|
|
270
|
+
* @category Input
|
|
271
|
+
*/
|
|
272
|
+
export declare function bindingLabel(binding: Binding, keyLabels?: ReadonlyMap<string, string>): string;
|
|
273
|
+
//#endregion
|