@n3rdw1z4rd/core 0.19.0 → 0.20.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 +27 -10
- package/dist/canvas-renderer.d.ts +3 -0
- package/dist/canvas-renderer.js +7 -0
- package/dist/index.cjs +449 -155
- package/dist/index.d.cts +233 -49
- package/dist/index.d.ts +5 -4
- package/dist/index.js +4 -3
- package/dist/input/_input.d.ts +25 -0
- package/dist/input/_input.js +97 -0
- package/dist/input/action-map.d.ts +42 -7
- package/dist/input/action-map.js +44 -18
- package/dist/input/bindings.d.ts +1 -1
- package/dist/input/bindings.js +1 -1
- package/dist/input/gestures.d.ts +20 -2
- package/dist/input/gestures.js +34 -8
- package/dist/input/index.d.ts +5 -4
- package/dist/input/index.js +3 -2
- package/dist/input/input-action-map.d.ts +327 -0
- package/dist/input/input-action-map.js +689 -0
- package/dist/input/input.d.ts +77 -272
- package/dist/input/input.js +201 -653
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -154,6 +154,8 @@ export declare class CanvasRenderer {
|
|
|
154
154
|
get width(): number;
|
|
155
155
|
/** canvas height in pixels */
|
|
156
156
|
get height(): number;
|
|
157
|
+
/** canvas center in pixels */
|
|
158
|
+
get center(): XY;
|
|
157
159
|
/**
|
|
158
160
|
* @param canvas defaults to a new canvas element, not attached to the page (append {@link CanvasRenderer.canvas} yourself)
|
|
159
161
|
*/
|
|
@@ -1064,7 +1066,7 @@ export declare function controlId(binding: Binding): string;
|
|
|
1064
1066
|
export declare function bindingsEqual(a: Binding, b: Binding): boolean;
|
|
1065
1067
|
/**
|
|
1066
1068
|
* A readable name for a binding, e.g. for "Press Space to jump" prompts. Pass `keyLabels` (from
|
|
1067
|
-
* {@link
|
|
1069
|
+
* {@link InputActionMap.loadKeyboardLayout}) to name keys as printed on the player's keyboard.
|
|
1068
1070
|
*
|
|
1069
1071
|
* @category Input
|
|
1070
1072
|
*/
|
|
@@ -1077,6 +1079,38 @@ export declare function bindingLabel(binding: Binding, keyLabels?: ReadonlyMap<s
|
|
|
1077
1079
|
* @category Input
|
|
1078
1080
|
*/
|
|
1079
1081
|
export declare const DEFAULT_DEADZONE = 0.2;
|
|
1082
|
+
/**
|
|
1083
|
+
* Auto-repeat timing for a held action, in ms: like a held key in a text field, the action
|
|
1084
|
+
* presses again after `delay`, then every `interval`.
|
|
1085
|
+
*
|
|
1086
|
+
* @category Input
|
|
1087
|
+
*/
|
|
1088
|
+
export interface ActionRepeat {
|
|
1089
|
+
/** ms held before the first repeat */
|
|
1090
|
+
delay: number;
|
|
1091
|
+
/** ms between repeats after that */
|
|
1092
|
+
interval: number;
|
|
1093
|
+
}
|
|
1094
|
+
/**
|
|
1095
|
+
* Repeat timing used by `repeat: true`: first repeat after 400 ms, then every 100 ms.
|
|
1096
|
+
*
|
|
1097
|
+
* @category Input
|
|
1098
|
+
*/
|
|
1099
|
+
export declare const DEFAULT_REPEAT: Readonly<ActionRepeat>;
|
|
1100
|
+
/**
|
|
1101
|
+
* Options for {@link ActionMap.add}.
|
|
1102
|
+
*
|
|
1103
|
+
* @category Input
|
|
1104
|
+
*/
|
|
1105
|
+
export interface ActionOptions {
|
|
1106
|
+
/** default {@link DEFAULT_DEADZONE} */
|
|
1107
|
+
deadzone?: number;
|
|
1108
|
+
/**
|
|
1109
|
+
* auto-repeat while held: `true` for {@link DEFAULT_REPEAT}, timings to override it, or `false`
|
|
1110
|
+
* for none (the default)
|
|
1111
|
+
*/
|
|
1112
|
+
repeat?: boolean | Partial<ActionRepeat>;
|
|
1113
|
+
}
|
|
1080
1114
|
/**
|
|
1081
1115
|
* A named action in an {@link ActionMap}.
|
|
1082
1116
|
*
|
|
@@ -1089,6 +1123,8 @@ export interface Action {
|
|
|
1089
1123
|
deadzone: number;
|
|
1090
1124
|
/** inputs that trigger the action; the strongest one wins */
|
|
1091
1125
|
readonly bindings: Binding[];
|
|
1126
|
+
/** auto-repeat while held, see {@link InputActionMap.isActionJustPressed}; none if unset */
|
|
1127
|
+
repeat?: ActionRepeat;
|
|
1092
1128
|
}
|
|
1093
1129
|
/**
|
|
1094
1130
|
* The serialized form of an {@link ActionMap} (from {@link ActionMap.toJSON}), keyed by action name.
|
|
@@ -1100,10 +1136,12 @@ export type ActionMapJSON = Record<string, {
|
|
|
1100
1136
|
deadzone: number;
|
|
1101
1137
|
/** the action's bindings, in order */
|
|
1102
1138
|
bindings: Binding[];
|
|
1139
|
+
/** see {@link Action.repeat} */
|
|
1140
|
+
repeat?: ActionRepeat;
|
|
1103
1141
|
}>;
|
|
1104
1142
|
/**
|
|
1105
|
-
* Named actions and the inputs bound to them, like Godot's InputMap. Every {@link
|
|
1106
|
-
* {@link
|
|
1143
|
+
* Named actions and the inputs bound to them, like Godot's InputMap. Every {@link InputActionMap} has one as
|
|
1144
|
+
* {@link InputActionMap.actions}; the methods that change it return `this` for chaining.
|
|
1107
1145
|
*
|
|
1108
1146
|
* ```ts
|
|
1109
1147
|
* input.actions
|
|
@@ -1123,10 +1161,8 @@ export declare class ActionMap {
|
|
|
1123
1161
|
has(name: string): boolean;
|
|
1124
1162
|
/** The action with this name, or `undefined`. */
|
|
1125
1163
|
get(name: string): Action | undefined;
|
|
1126
|
-
/** Adds an action, or replaces its bindings (and deadzone, if given) if it exists. */
|
|
1127
|
-
add(name: string, bindings?: Binding[], options?:
|
|
1128
|
-
deadzone?: number;
|
|
1129
|
-
}): this;
|
|
1164
|
+
/** Adds an action, or replaces its bindings (and deadzone / repeat, if given) if it exists. */
|
|
1165
|
+
add(name: string, bindings?: Binding[], options?: ActionOptions): this;
|
|
1130
1166
|
/** Removes an action, if it exists. */
|
|
1131
1167
|
remove(name: string): this;
|
|
1132
1168
|
/** Adds a binding to an action (creating the action if needed); duplicates are ignored. */
|
|
@@ -1143,7 +1179,8 @@ export declare class ActionMap {
|
|
|
1143
1179
|
load(json: ActionMapJSON): this;
|
|
1144
1180
|
/**
|
|
1145
1181
|
* Godot-style `ui_*` actions for menus and dialogs (`ui_accept`, `ui_cancel`, `ui_left`, `ui_right`,
|
|
1146
|
-
* `ui_up`, `ui_down`, `ui_page_up`, `ui_page_down`), with a 0.5 deadzone;
|
|
1182
|
+
* `ui_up`, `ui_down`, `ui_page_up`, `ui_page_down`), with a 0.5 deadzone; the directions and
|
|
1183
|
+
* page actions auto-repeat ({@link DEFAULT_REPEAT}). Replaces existing ones.
|
|
1147
1184
|
*/
|
|
1148
1185
|
addDefaults(): this;
|
|
1149
1186
|
}
|
|
@@ -1191,6 +1228,21 @@ export interface GestureThresholds {
|
|
|
1191
1228
|
/** relative scale change per frame that counts as pinching (0.005 = 0.5%, the default) */
|
|
1192
1229
|
pinchMinChange: number;
|
|
1193
1230
|
}
|
|
1231
|
+
/**
|
|
1232
|
+
* A recognized gesture and where it happened, in pixels: where the finger lifted for a tap or
|
|
1233
|
+
* double tap, where it is held for a long press, where it started for a swipe, and the midpoint
|
|
1234
|
+
* of the two fingers for a pinch.
|
|
1235
|
+
*
|
|
1236
|
+
* @category Input
|
|
1237
|
+
*/
|
|
1238
|
+
export interface GestureEvent {
|
|
1239
|
+
/** which gesture */
|
|
1240
|
+
gesture: Gesture;
|
|
1241
|
+
/** px */
|
|
1242
|
+
x: number;
|
|
1243
|
+
/** px */
|
|
1244
|
+
y: number;
|
|
1245
|
+
}
|
|
1194
1246
|
/**
|
|
1195
1247
|
* What {@link GestureRecognizer.update} recognized since the previous update.
|
|
1196
1248
|
*
|
|
@@ -1199,6 +1251,8 @@ export interface GestureThresholds {
|
|
|
1199
1251
|
export interface GestureFrame {
|
|
1200
1252
|
/** recognized since the last update */
|
|
1201
1253
|
gestures: Gesture[];
|
|
1254
|
+
/** the same gestures, with positions */
|
|
1255
|
+
events: GestureEvent[];
|
|
1202
1256
|
/** two-finger scale change this frame (1 = none, > 1 = fingers apart) */
|
|
1203
1257
|
pinch: number;
|
|
1204
1258
|
/** two-finger movement this frame, px */
|
|
@@ -1214,7 +1268,7 @@ export interface GestureFrame {
|
|
|
1214
1268
|
/**
|
|
1215
1269
|
* Turns touch points into gestures: tap, double tap, long press, swipes (one finger) and
|
|
1216
1270
|
* pinch / pan / rotate (two fingers). Feed it with down / move / up, call update() once per frame.
|
|
1217
|
-
* Times are in ms and positions in pixels, from any consistent clock and origin. {@link
|
|
1271
|
+
* Times are in ms and positions in pixels, from any consistent clock and origin. {@link InputActionMap} drives
|
|
1218
1272
|
* one for you; use this class directly only for custom touch handling.
|
|
1219
1273
|
*
|
|
1220
1274
|
* Tap, double tap and swipe are reported when the finger lifts, long press while it is still held;
|
|
@@ -1225,7 +1279,8 @@ export interface GestureFrame {
|
|
|
1225
1279
|
* el.addEventListener('pointerdown', e => recognizer.down(e.pointerId, e.offsetX, e.offsetY, performance.now()));
|
|
1226
1280
|
* // ... move / up / cancel likewise
|
|
1227
1281
|
*
|
|
1228
|
-
* const { gestures, pinch } = recognizer.update(performance.now());
|
|
1282
|
+
* const { gestures, events, pinch } = recognizer.update(performance.now());
|
|
1283
|
+
* const tap = events.find(e => e.gesture === 'tap'); // { gesture, x, y }
|
|
1229
1284
|
* ```
|
|
1230
1285
|
*
|
|
1231
1286
|
* @category Input
|
|
@@ -1255,6 +1310,106 @@ export declare class GestureRecognizer {
|
|
|
1255
1310
|
update(time: number): GestureFrame;
|
|
1256
1311
|
}
|
|
1257
1312
|
//#endregion
|
|
1313
|
+
//#region src/input/input.d.ts
|
|
1314
|
+
/**
|
|
1315
|
+
* Whether a key or button is down (`state` 1) or up (0), and when that last changed.
|
|
1316
|
+
*
|
|
1317
|
+
* @category Input
|
|
1318
|
+
*/
|
|
1319
|
+
export interface InputState {
|
|
1320
|
+
/** 1 = down, 0 = up */
|
|
1321
|
+
state: number;
|
|
1322
|
+
/** `Event.timeStamp` of the last change, ms */
|
|
1323
|
+
timeStamp: number;
|
|
1324
|
+
}
|
|
1325
|
+
/**
|
|
1326
|
+
* Event-based input for keyboard, mouse, pen and touch: subscribe with `on()` and query state
|
|
1327
|
+
* at any time; no frame loop needed. One shared instance, {@link Input.instance}.
|
|
1328
|
+
*
|
|
1329
|
+
* Events (listeners get the DOM event):
|
|
1330
|
+
* - keys, by lowercased `KeyboardEvent.code`: `key_down`, `key_up`, `key_repeat`, `key_pressed`
|
|
1331
|
+
* (released within `inputThreshold` ms), and per key `keyw_down`, `keyw_up`, `keyw_pressed`, ...
|
|
1332
|
+
* - buttons (mouse buttons; the primary finger or pen is button 0): `button_down`, `button_up`,
|
|
1333
|
+
* `button_clicked`, and per button `button0_down`, `button0_up`, `button0_clicked`, ...
|
|
1334
|
+
* No click after a drag.
|
|
1335
|
+
* - pointer: `pointer_move`; `drag_start`, `drag`, `drag_end` (moved `dragThreshold` px with a
|
|
1336
|
+
* button down); `mouse_wheel`; `contextmenu` (see `disableContextMenu()`)
|
|
1337
|
+
* - every finger: `touch_down`, `touch_move`, `touch_up`, `touch_cancel`
|
|
1338
|
+
* - `blur`: the window lost focus or the tab was hidden; every key and button is released
|
|
1339
|
+
*
|
|
1340
|
+
* ```ts
|
|
1341
|
+
* const input = Input.instance;
|
|
1342
|
+
* input.target = canvas;
|
|
1343
|
+
*
|
|
1344
|
+
* input.on('keyw_down', 'arrowup_down', () => move(0, -1));
|
|
1345
|
+
* input.on('button0_clicked', () => select(input.pointerPosition));
|
|
1346
|
+
* input.on('pointer_move', () => {
|
|
1347
|
+
* if (input.isButtonDown(0)) pan(input.pointerDelta.x, input.pointerDelta.y);
|
|
1348
|
+
* });
|
|
1349
|
+
* ```
|
|
1350
|
+
*
|
|
1351
|
+
* @category Input
|
|
1352
|
+
*/
|
|
1353
|
+
export declare class Input extends Emitter {
|
|
1354
|
+
private static _instance?;
|
|
1355
|
+
/** the shared instance, created on first use */
|
|
1356
|
+
static get instance(): Input;
|
|
1357
|
+
private _state;
|
|
1358
|
+
private _windowListeners;
|
|
1359
|
+
private _targetListeners;
|
|
1360
|
+
private _target;
|
|
1361
|
+
private _contextMenuDisabled;
|
|
1362
|
+
private _dragStart?;
|
|
1363
|
+
private _dragging;
|
|
1364
|
+
/** pixels from the target's top-left */
|
|
1365
|
+
readonly pointerPosition: Vector;
|
|
1366
|
+
/** -1..1 across the target, y up */
|
|
1367
|
+
readonly pointerPositionNdc: Vector;
|
|
1368
|
+
/** pixels moved by the last pointer event (mouse, pen and touch alike) */
|
|
1369
|
+
readonly pointerDelta: Vector;
|
|
1370
|
+
/** ms; a key or button released within this is also `_pressed` / `_clicked` */
|
|
1371
|
+
inputThreshold: number;
|
|
1372
|
+
/** px; moving further than this with a button down starts a drag */
|
|
1373
|
+
dragThreshold: number;
|
|
1374
|
+
/**
|
|
1375
|
+
* Where pointer, wheel and context-menu events are read and positions are measured, default
|
|
1376
|
+
* `window`; usually the canvas. Keys are always read from `window`.
|
|
1377
|
+
*/
|
|
1378
|
+
get target(): EventTarget;
|
|
1379
|
+
/** moves the pointer, wheel and context-menu listeners to `target` */
|
|
1380
|
+
set target(target: EventTarget);
|
|
1381
|
+
/** a drag is in progress */
|
|
1382
|
+
get isDragging(): boolean;
|
|
1383
|
+
private constructor();
|
|
1384
|
+
/** Stops the right-click menu on the target; `contextmenu` is still emitted. */
|
|
1385
|
+
disableContextMenu(): void;
|
|
1386
|
+
/** Removes every DOM listener; the next {@link Input.instance} is a new one. */
|
|
1387
|
+
dispose(): void;
|
|
1388
|
+
private _listenToTarget;
|
|
1389
|
+
private _listen;
|
|
1390
|
+
private _down;
|
|
1391
|
+
private _up;
|
|
1392
|
+
private _anyButtonDown;
|
|
1393
|
+
private _updatePointer;
|
|
1394
|
+
private _onContextMenu;
|
|
1395
|
+
private _onKeyDown;
|
|
1396
|
+
private _onKeyUp;
|
|
1397
|
+
private _onPointerDown;
|
|
1398
|
+
private _onPointerUp;
|
|
1399
|
+
private _onPointerMove;
|
|
1400
|
+
private _endDrag;
|
|
1401
|
+
private _onWheel;
|
|
1402
|
+
private _onBlur;
|
|
1403
|
+
/** Whether a key (by `KeyboardEvent.code`, e.g. 'KeyW') is down. */
|
|
1404
|
+
isKeyDown(keyCode: string): boolean;
|
|
1405
|
+
/** 1 if the key is down, else 0. */
|
|
1406
|
+
getKeyState(keyCode: string): number;
|
|
1407
|
+
/** Whether a button (`PointerEvent.button`: 0 left / primary finger, 1 middle, 2 right, ...) is down. */
|
|
1408
|
+
isButtonDown(buttonNumber: number): boolean;
|
|
1409
|
+
/** 1 if the button is down, else 0. */
|
|
1410
|
+
getButtonState(buttonNumber: number): number;
|
|
1411
|
+
}
|
|
1412
|
+
//#endregion
|
|
1258
1413
|
//#region src/observable.d.ts
|
|
1259
1414
|
/**
|
|
1260
1415
|
* An {@link Observable} observer: called with the notified value (and any extra arguments).
|
|
@@ -1298,7 +1453,7 @@ export declare class Observable<T> {
|
|
|
1298
1453
|
get size(): number;
|
|
1299
1454
|
}
|
|
1300
1455
|
//#endregion
|
|
1301
|
-
//#region src/input/input.d.ts
|
|
1456
|
+
//#region src/input/input-action-map.d.ts
|
|
1302
1457
|
/**
|
|
1303
1458
|
* 0 = keyboard, mouse, pen, touch and VR; 1, 2, ... = gamepads.
|
|
1304
1459
|
*
|
|
@@ -1306,25 +1461,36 @@ export declare class Observable<T> {
|
|
|
1306
1461
|
*/
|
|
1307
1462
|
export type InputDevice = number;
|
|
1308
1463
|
/**
|
|
1309
|
-
* The kind of device the player last used, see {@link
|
|
1464
|
+
* The kind of device the player last used, see {@link InputActionMap.lastDevice}.
|
|
1310
1465
|
*
|
|
1311
1466
|
* @category Input
|
|
1312
1467
|
*/
|
|
1313
1468
|
export type InputDeviceType = 'keyboard' | 'mouse' | 'pen' | 'touch' | 'gamepad' | 'xr';
|
|
1314
1469
|
/**
|
|
1315
|
-
* When an {@link
|
|
1470
|
+
* When an {@link InputActionMap.onAction} callback fires: as the action becomes pressed, or released.
|
|
1316
1471
|
*
|
|
1317
1472
|
* @category Input
|
|
1318
1473
|
*/
|
|
1319
1474
|
export type ActionPhase = 'pressed' | 'released';
|
|
1320
1475
|
/**
|
|
1321
|
-
*
|
|
1476
|
+
* Passed to {@link InputActionMap.onAction} callbacks.
|
|
1477
|
+
*
|
|
1478
|
+
* @category Input
|
|
1479
|
+
*/
|
|
1480
|
+
export interface ActionEvent {
|
|
1481
|
+
/** the action's name */
|
|
1482
|
+
action: string;
|
|
1483
|
+
/** an auto-repeat of a held action (see {@link ActionRepeat}), not a new press */
|
|
1484
|
+
repeat: boolean;
|
|
1485
|
+
}
|
|
1486
|
+
/**
|
|
1487
|
+
* Options for the {@link InputActionMap} constructor.
|
|
1322
1488
|
*
|
|
1323
1489
|
* @category Input
|
|
1324
1490
|
*/
|
|
1325
|
-
export interface
|
|
1326
|
-
/** where
|
|
1327
|
-
|
|
1491
|
+
export interface InputActionMapOptions {
|
|
1492
|
+
/** where events come from, default {@link Input.instance}; set `input.target` to the canvas */
|
|
1493
|
+
input?: Input;
|
|
1328
1494
|
/** add the ui_* actions. Default true. */
|
|
1329
1495
|
defaults?: boolean;
|
|
1330
1496
|
/** stop bound keys / the wheel from scrolling the page. Default true. */
|
|
@@ -1342,7 +1508,7 @@ export interface DeviceQuery {
|
|
|
1342
1508
|
device?: InputDevice;
|
|
1343
1509
|
}
|
|
1344
1510
|
/**
|
|
1345
|
-
* A connected gamepad, see {@link
|
|
1511
|
+
* A connected gamepad, see {@link InputActionMap.gamepads}.
|
|
1346
1512
|
*
|
|
1347
1513
|
* @category Input
|
|
1348
1514
|
*/
|
|
@@ -1355,7 +1521,7 @@ export interface GamepadInfo {
|
|
|
1355
1521
|
standard: boolean;
|
|
1356
1522
|
}
|
|
1357
1523
|
/**
|
|
1358
|
-
* The parts of a WebXR XRSession that
|
|
1524
|
+
* The parts of a WebXR XRSession that InputActionMap reads (structural, so no WebXR typings are required).
|
|
1359
1525
|
*
|
|
1360
1526
|
* @category Input
|
|
1361
1527
|
*/
|
|
@@ -1379,8 +1545,8 @@ export interface XRSessionLike extends EventTarget {
|
|
|
1379
1545
|
}>;
|
|
1380
1546
|
}
|
|
1381
1547
|
/**
|
|
1382
|
-
* Mouse or pen state, see {@link
|
|
1383
|
-
* wheel totals on each {@link
|
|
1548
|
+
* Mouse or pen state, see {@link InputActionMap.pointer}. Positions update on pointer events; deltas and
|
|
1549
|
+
* wheel totals on each {@link InputActionMap.update}.
|
|
1384
1550
|
*
|
|
1385
1551
|
* @property y pixels, relative to the target's top-left, y down
|
|
1386
1552
|
* @property ndcY -1..1, y up
|
|
@@ -1412,7 +1578,7 @@ export interface PointerState {
|
|
|
1412
1578
|
tiltY: number;
|
|
1413
1579
|
}
|
|
1414
1580
|
/**
|
|
1415
|
-
* Options for {@link
|
|
1581
|
+
* Options for {@link InputActionMap.captureBinding}.
|
|
1416
1582
|
*
|
|
1417
1583
|
* @category Input
|
|
1418
1584
|
*/
|
|
@@ -1423,32 +1589,41 @@ export interface CaptureOptions {
|
|
|
1423
1589
|
types?: Binding['type'][];
|
|
1424
1590
|
}
|
|
1425
1591
|
/**
|
|
1426
|
-
* Game input with a Godot-style action map: bind keys, buttons,
|
|
1427
|
-
* to named actions, then query actions instead of devices
|
|
1592
|
+
* Game input with a Godot-style action map, built on {@link Input}'s events: bind keys, buttons,
|
|
1593
|
+
* sticks, gestures and VR controls to named actions, then query actions instead of devices once
|
|
1594
|
+
* per frame. Gamepads and VR controllers are polled by `update()`.
|
|
1595
|
+
*
|
|
1596
|
+
* Input.instance.target = canvas;
|
|
1428
1597
|
*
|
|
1429
|
-
* const
|
|
1430
|
-
*
|
|
1598
|
+
* const controls = new InputActionMap();
|
|
1599
|
+
* controls.actions.add('jump', [key('Space'), pad('A')]);
|
|
1431
1600
|
*
|
|
1432
1601
|
* // every frame, before game logic:
|
|
1433
|
-
*
|
|
1434
|
-
* if (
|
|
1602
|
+
* controls.update();
|
|
1603
|
+
* if (controls.isActionJustPressed('jump')) player.jump();
|
|
1435
1604
|
*
|
|
1436
|
-
* Call `dispose()` to
|
|
1605
|
+
* Call `dispose()` to stop listening.
|
|
1437
1606
|
*
|
|
1438
1607
|
* @category Input
|
|
1439
1608
|
*/
|
|
1440
|
-
export declare class
|
|
1441
|
-
/** the actions to query; holds the `ui_*` defaults unless {@link
|
|
1609
|
+
export declare class InputActionMap {
|
|
1610
|
+
/** the actions to query; holds the `ui_*` defaults unless {@link InputActionMapOptions.defaults} is false */
|
|
1442
1611
|
readonly actions: ActionMap;
|
|
1443
1612
|
/** Thresholds for taps, swipes etc. can be tuned via `gestureRecognizer.thresholds`. */
|
|
1444
1613
|
readonly gestureRecognizer: GestureRecognizer;
|
|
1445
|
-
/**
|
|
1614
|
+
/**
|
|
1615
|
+
* Touch gestures from the last frame: `events` (each recognized gesture and where it happened,
|
|
1616
|
+
* e.g. the tap that triggered an action) and the two-finger values (pinch 1 / pan 0 / rotate 0
|
|
1617
|
+
* when not gesturing).
|
|
1618
|
+
*/
|
|
1446
1619
|
readonly gestures: Omit<GestureFrame, 'gestures'>;
|
|
1620
|
+
/** the {@link Input} events are read from */
|
|
1621
|
+
readonly input: Input;
|
|
1447
1622
|
/** Fingers currently on the target. */
|
|
1448
1623
|
get touches(): TouchPoint[];
|
|
1449
1624
|
/** the mouse or pen; not updated by touch */
|
|
1450
1625
|
readonly pointer: PointerState;
|
|
1451
|
-
/** notified when {@link
|
|
1626
|
+
/** notified when {@link InputActionMap.lastDevice} changes, e.g. to switch on-screen button prompts */
|
|
1452
1627
|
readonly onDeviceChange: Observable<InputDeviceType>;
|
|
1453
1628
|
/** notified from update() when a gamepad is first seen */
|
|
1454
1629
|
readonly onGamepadConnected: Observable<GamepadInfo>;
|
|
@@ -1459,7 +1634,6 @@ export declare class Input {
|
|
|
1459
1634
|
get gamepads(): GamepadInfo[];
|
|
1460
1635
|
private _lastDevice;
|
|
1461
1636
|
private _keyLabels?;
|
|
1462
|
-
private readonly _target?;
|
|
1463
1637
|
private readonly _options;
|
|
1464
1638
|
private readonly _listeners;
|
|
1465
1639
|
private readonly _controls;
|
|
@@ -1470,21 +1644,26 @@ export declare class Input {
|
|
|
1470
1644
|
private _capture?;
|
|
1471
1645
|
/** The kind of device that produced the most recent input (initially `'keyboard'`). */
|
|
1472
1646
|
get lastDevice(): InputDeviceType;
|
|
1473
|
-
/** Whether the pointer is locked to the target, see {@link
|
|
1647
|
+
/** Whether the pointer is locked to the target, see {@link InputActionMap.lockPointer}. */
|
|
1474
1648
|
get isPointerLocked(): boolean;
|
|
1475
|
-
|
|
1476
|
-
* @param target element that receives pointer, wheel and touch input (usually the canvas)
|
|
1477
|
-
*/
|
|
1478
|
-
constructor(target?: EventTarget, options?: InputOptions);
|
|
1649
|
+
constructor(options?: InputActionMapOptions);
|
|
1479
1650
|
/**
|
|
1480
1651
|
* Call once per frame, before reading input: polls devices and advances "just pressed" /
|
|
1481
1652
|
* "just released" by one frame. Action callbacks fire from here.
|
|
1653
|
+
*
|
|
1654
|
+
* @param time current time in ms (e.g. the `requestAnimationFrame` timestamp), used for
|
|
1655
|
+
* gesture timing and auto-repeat; default `performance.now()`
|
|
1482
1656
|
*/
|
|
1483
|
-
update(): void;
|
|
1657
|
+
update(time?: number): void;
|
|
1484
1658
|
/** Whether the action is held past its deadzone. Unknown actions return false (and warn once). */
|
|
1485
1659
|
isActionPressed(action: string, query?: DeviceQuery): boolean;
|
|
1486
|
-
/**
|
|
1660
|
+
/**
|
|
1661
|
+
* Whether the action became pressed in the last update(), or auto-repeated while held if the
|
|
1662
|
+
* action has {@link Action.repeat} (e.g. to keep walking while a direction is held).
|
|
1663
|
+
*/
|
|
1487
1664
|
isActionJustPressed(action: string, query?: DeviceQuery): boolean;
|
|
1665
|
+
/** Whether the last update()'s press of the action was an auto-repeat rather than a new press. */
|
|
1666
|
+
isActionRepeated(action: string, query?: DeviceQuery): boolean;
|
|
1488
1667
|
/** Whether the action was released in the last update(). */
|
|
1489
1668
|
isActionJustReleased(action: string, query?: DeviceQuery): boolean;
|
|
1490
1669
|
/** 0..1, rescaled past the action's deadzone (analog triggers and sticks give values in between). */
|
|
@@ -1508,8 +1687,12 @@ export declare class Input {
|
|
|
1508
1687
|
/** -1..1, positive towards `positiveY` */
|
|
1509
1688
|
y: number;
|
|
1510
1689
|
};
|
|
1511
|
-
/**
|
|
1512
|
-
|
|
1690
|
+
/**
|
|
1691
|
+
* Calls `callback` when the action is pressed or released (during update()). With
|
|
1692
|
+
* {@link Action.repeat}, `'pressed'` also fires on each auto-repeat, with `event.repeat` set.
|
|
1693
|
+
* Returns an unsubscribe function.
|
|
1694
|
+
*/
|
|
1695
|
+
onAction(action: string, phase: ActionPhase, callback: (event: ActionEvent) => void, query?: DeviceQuery): () => void;
|
|
1513
1696
|
/** Whether a key (by `KeyboardEvent.code`) is held right now, regardless of actions. */
|
|
1514
1697
|
isKeyPressed(code: string): boolean;
|
|
1515
1698
|
/** Whether a mouse or pen button is held right now, regardless of actions. */
|
|
@@ -1529,14 +1712,14 @@ export declare class Input {
|
|
|
1529
1712
|
* doesn't trigger any actions.
|
|
1530
1713
|
*/
|
|
1531
1714
|
captureBinding(options?: CaptureOptions): Promise<Binding | null>;
|
|
1532
|
-
/** Ends a pending {@link
|
|
1715
|
+
/** Ends a pending {@link InputActionMap.captureBinding}, resolving it with `null`. */
|
|
1533
1716
|
cancelCapture(): void;
|
|
1534
1717
|
/**
|
|
1535
1718
|
* Loads the keyboard layout (where supported, e.g. Chromium) so {@link bindingLabel} names keys
|
|
1536
1719
|
* as printed on the player's keyboard: KeyW is "Z" on AZERTY.
|
|
1537
1720
|
*/
|
|
1538
1721
|
loadKeyboardLayout(): Promise<ReadonlyMap<string, string> | undefined>;
|
|
1539
|
-
/** The layout loaded by {@link
|
|
1722
|
+
/** The layout loaded by {@link InputActionMap.loadKeyboardLayout}, if any: `KeyboardEvent.code` to printed key. */
|
|
1540
1723
|
get keyLabels(): ReadonlyMap<string, string> | undefined;
|
|
1541
1724
|
/** Removes all event listeners and action callbacks, cancels any capture and detaches XR. */
|
|
1542
1725
|
dispose(): void;
|
|
@@ -1566,7 +1749,7 @@ export declare class Input {
|
|
|
1566
1749
|
private _xrSession?;
|
|
1567
1750
|
private _xrEnd?;
|
|
1568
1751
|
private readonly _xrHeld;
|
|
1569
|
-
/** The session set by {@link
|
|
1752
|
+
/** The session set by {@link InputActionMap.attachXR}, until detached or ended. */
|
|
1570
1753
|
get xrSession(): XRSessionLike | undefined;
|
|
1571
1754
|
/**
|
|
1572
1755
|
* Reads VR controller buttons and sticks from a WebXR session (e.g. `renderer.xr.getSession()`)
|
|
@@ -1584,10 +1767,11 @@ export declare class Input {
|
|
|
1584
1767
|
private _onKeyUp;
|
|
1585
1768
|
private _updatePointer;
|
|
1586
1769
|
private _local;
|
|
1587
|
-
private
|
|
1588
|
-
private _onPointerUp;
|
|
1589
|
-
private _onPointerCancel;
|
|
1770
|
+
private _onButton;
|
|
1590
1771
|
private _onPointerMove;
|
|
1772
|
+
private _onTouchDown;
|
|
1773
|
+
private _onTouchMove;
|
|
1774
|
+
private _onTouchUp;
|
|
1591
1775
|
private _onWheel;
|
|
1592
1776
|
}
|
|
1593
1777
|
//#endregion
|
package/dist/index.d.ts
CHANGED
|
@@ -13,10 +13,11 @@ import { Component, ComponentInstances, ComponentType, ECS, Entity, System, ecs
|
|
|
13
13
|
import { Emitter, Listener } from "./emitter.js";
|
|
14
14
|
import { EventQueue } from "./event-queue.js";
|
|
15
15
|
import { Binding, GAMEPAD_AXES, GAMEPAD_BUTTONS, GESTURES, GamepadAxis, GamepadButton, Gesture, GestureBinding, KeyBinding, KeyModifiers, MouseBinding, MouseButton, PadAxisBinding, PadBinding, WheelBinding, WheelDirection, XRAxis, XRAxisBinding, XRBinding, XRButton, XRHand, XR_AXES, XR_BUTTONS, bindingLabel, bindingsEqual, controlId, gesture, key, mouse, pad, padAxis, wheel, xr, xrAxis } from "./input/bindings.js";
|
|
16
|
-
import { Action, ActionMap, ActionMapJSON, DEFAULT_DEADZONE } from "./input/action-map.js";
|
|
17
|
-
import { GestureFrame, GestureRecognizer, GestureThresholds, TouchPoint } from "./input/gestures.js";
|
|
16
|
+
import { Action, ActionMap, ActionMapJSON, ActionOptions, ActionRepeat, DEFAULT_DEADZONE, DEFAULT_REPEAT } from "./input/action-map.js";
|
|
17
|
+
import { GestureEvent, GestureFrame, GestureRecognizer, GestureThresholds, TouchPoint } from "./input/gestures.js";
|
|
18
|
+
import { Input, InputState } from "./input/input.js";
|
|
18
19
|
import { Observable, Observer } from "./observable.js";
|
|
19
|
-
import { ActionPhase, CaptureOptions, DeviceQuery, GamepadInfo,
|
|
20
|
+
import { ActionEvent, ActionPhase, CaptureOptions, DeviceQuery, GamepadInfo, InputActionMap, InputActionMapOptions, InputDevice, InputDeviceType, PointerState, XRSessionLike } from "./input/input-action-map.js";
|
|
20
21
|
import { log } from "./log.js";
|
|
21
22
|
import { DEFAULT_MAP_3D_VALUE, MAP_3D_MAX_COORD, MAP_3D_MIN_COORD, Map3D, Map3DCell } from "./map3d.js";
|
|
22
23
|
import { DEG2RAD, E, EPSILON, HALF_PI, LN10, LN2, LOG10E, LOG2E, PI, QUARTER_PI, RAD2DEG, SQRT1_2, SQRT2, TAU, clamp, degrees, distance2d, distance3d, fract, hash32, hash32mix, inverseLerp, lerp, manhattanDistance, mod, nearlyEqual, normalizeRadians, radians, roundTo, saturate, smoothstep, squaredDistance, wrap } from "./math.js";
|
|
@@ -32,4 +33,4 @@ import { Tilemap } from "./tilemap.js";
|
|
|
32
33
|
import { AttributeInfo, AttributeSource, BindRenderTarget, BufferOptions, CompileShader, CreateBuffer, CreateProgram, CreateProgramInfo, CreateRenderTarget, CreateTexture, CreateVertexArray, CreateWebGlContext, DeleteProgramInfo, DeleteRenderTarget, DeleteTexture, DeleteVertexArray, Draw, DrawOptions, GetProgramLocations, LoadWebGlTexture, ProgramInfo, ProgramLocations, RenderTarget, RenderTargetOptions, ResizeRenderTarget, ResizeWebGlContext, SetUniforms, ShaderType, TextureData, TextureInfo, TextureOptions, UniformInfo, UniformValue, UpdateBuffer, UpdateTexture, VertexArrayInfo } from "./webgl.js";
|
|
33
34
|
import { RendererParams, WebGlRenderer } from "./webgl-renderer.js";
|
|
34
35
|
import { WorkerInterface } from "./worker-interface.js";
|
|
35
|
-
export { Action, ActionMap, ActionMapJSON, ActionPhase, AttributeInfo, AttributeSource, BindRenderTarget, Binding, BufferOptions, CanvasColor, CanvasRenderer, CaptureOptions, Clock, ClockCallback, Color, ColorPalette, CompileShader, Component, ComponentInstances, ComponentType, CreateBuffer, CreateProgram, CreateProgramInfo, CreateRenderTarget, CreateTexture, CreateVertexArray, CreateWebGlContext, DEFAULT_COLOR, DEFAULT_DEADZONE, DEFAULT_FONT, DEFAULT_FONT_NAME, DEFAULT_FONT_SIZE, DEFAULT_MAP_2D_VALUE, DEFAULT_MAP_3D_VALUE, DEFAULT_PIXEL_SIZE, DEFAULT_TEXTALIGN, DEFAULT_TEXTBASELINE, DEG2RAD, DeleteProgramInfo, DeleteRenderTarget, DeleteTexture, DeleteVertexArray, DeviceQuery, Disposable, DoorsParams, Draw, DrawOptions, DrawParams, E, ECS, EPSILON, Emitter, Entity, EventQueue, GAMEPAD_AXES, GAMEPAD_BUTTONS, GESTURES, GamepadAxis, GamepadButton, GamepadInfo, GenerateDoors, GenerateRooms, GenerateRoomsParams, GenerateWalls, Gesture, GestureBinding, GestureFrame, GestureRecognizer, GestureThresholds, GetProgramLocations, GetUrlParams, HALF_PI, Input, InputDevice, InputDeviceType,
|
|
36
|
+
export { Action, ActionEvent, ActionMap, ActionMapJSON, ActionOptions, ActionPhase, ActionRepeat, AttributeInfo, AttributeSource, BindRenderTarget, Binding, BufferOptions, CanvasColor, CanvasRenderer, CaptureOptions, Clock, ClockCallback, Color, ColorPalette, CompileShader, Component, ComponentInstances, ComponentType, CreateBuffer, CreateProgram, CreateProgramInfo, CreateRenderTarget, CreateTexture, CreateVertexArray, CreateWebGlContext, DEFAULT_COLOR, DEFAULT_DEADZONE, DEFAULT_FONT, DEFAULT_FONT_NAME, DEFAULT_FONT_SIZE, DEFAULT_MAP_2D_VALUE, DEFAULT_MAP_3D_VALUE, DEFAULT_PIXEL_SIZE, DEFAULT_REPEAT, DEFAULT_TEXTALIGN, DEFAULT_TEXTBASELINE, DEG2RAD, DeleteProgramInfo, DeleteRenderTarget, DeleteTexture, DeleteVertexArray, DeviceQuery, Disposable, DoorsParams, Draw, DrawOptions, DrawParams, E, ECS, EPSILON, Emitter, Entity, EventQueue, GAMEPAD_AXES, GAMEPAD_BUTTONS, GESTURES, GamepadAxis, GamepadButton, GamepadInfo, GenerateDoors, GenerateRooms, GenerateRoomsParams, GenerateWalls, Gesture, GestureBinding, GestureEvent, GestureFrame, GestureRecognizer, GestureThresholds, GetProgramLocations, GetUrlParams, HALF_PI, Input, InputActionMap, InputActionMapOptions, InputDevice, InputDeviceType, InputState, KeyBinding, KeyModifiers, KeyValue, LN10, LN2, LOG10E, LOG2E, Listener, LoadWebGlTexture, MAP_2D_MAX_COORD, MAP_2D_MIN_COORD, MAP_3D_MAX_COORD, MAP_3D_MIN_COORD, Map2D, Map2DData, Map3D, Map3DCell, MouseBinding, MouseButton, NoiseFunction3D, ONE_SECOND, Observable, Observer, PI, PadAxisBinding, PadBinding, ParticleRenderer, ParticleSystem2d, PathOptions, PathsParams, PointPair, PointerState, ProgramInfo, ProgramLocations, QUARTER_PI, RAD2DEG, RGB, Random, RectPair, Rectangle, RenderTarget, RenderTargetOptions, RendererParams, ResizeRenderTarget, ResizeWebGlContext, Rng, RoomsParams, SQRT1_2, SQRT2, SetUniforms, ShaderType, Signal, SpatialPartition2d, SpatialPartition3d, SpatialPartitionEntity2d, SpatialPartitionEntity3d, SpriteParams, StepCost, Subscriber, System, TAU, TILE_EMPTY, TILE_FLOOR, TILE_PATH, TextureData, TextureInfo, TextureOptions, Tilemap, TouchPoint, UniformInfo, UniformValue, UpdateBuffer, UpdateTexture, Vector, VertexArrayInfo, WebGlRenderer, WheelBinding, WheelDirection, WorkerInterface, XRAxis, XRAxisBinding, XRBinding, XRButton, XRHand, XRSessionLike, XR_AXES, XR_BUTTONS, XY, XYZ, bindingLabel, bindingsEqual, buildColorPalette, clamp, controlId, degrees, distance2d, distance3d, ecs, findPath, fract, gesture, getRedYellowGreenGradientHex, hash32, hash32mix, inverseLerp, isNullOrUndefined, isPositiveString, k2xy, k2xyz, key, lerp, log, manhattanDistance, mod, mouse, nearlyEqual, normalizeRadians, pad, padAxis, radians, randomMatrix, rng, roundTo, saturate, smoothstep, squaredDistance, wheel, wrap, xr, xrAxis, xy2k, xyz2k };
|
package/dist/index.js
CHANGED
|
@@ -16,10 +16,11 @@ import { ECS, ecs } from "./ecs.js";
|
|
|
16
16
|
import { Emitter } from "./emitter.js";
|
|
17
17
|
import { EventQueue } from "./event-queue.js";
|
|
18
18
|
import { GAMEPAD_AXES, GAMEPAD_BUTTONS, GESTURES, XR_AXES, XR_BUTTONS, bindingLabel, bindingsEqual, controlId, gesture, key, mouse, pad, padAxis, wheel, xr, xrAxis } from "./input/bindings.js";
|
|
19
|
-
import { ActionMap, DEFAULT_DEADZONE } from "./input/action-map.js";
|
|
19
|
+
import { ActionMap, DEFAULT_DEADZONE, DEFAULT_REPEAT } from "./input/action-map.js";
|
|
20
20
|
import { GestureRecognizer } from "./input/gestures.js";
|
|
21
|
-
import { Observable } from "./observable.js";
|
|
22
21
|
import { Input } from "./input/input.js";
|
|
22
|
+
import { Observable } from "./observable.js";
|
|
23
|
+
import { InputActionMap } from "./input/input-action-map.js";
|
|
23
24
|
import { DEFAULT_MAP_3D_VALUE, MAP_3D_MAX_COORD, MAP_3D_MIN_COORD, Map3D } from "./map3d.js";
|
|
24
25
|
import { GetUrlParams, getRedYellowGreenGradientHex, isNullOrUndefined, isPositiveString, k2xy, k2xyz, xy2k, xyz2k } from "./misc.js";
|
|
25
26
|
import { ParticleRenderer } from "./particle-renderer.js";
|
|
@@ -31,4 +32,4 @@ import { Tilemap } from "./tilemap.js";
|
|
|
31
32
|
import { BindRenderTarget, CompileShader, CreateBuffer, CreateProgram, CreateProgramInfo, CreateRenderTarget, CreateTexture, CreateVertexArray, CreateWebGlContext, DeleteProgramInfo, DeleteRenderTarget, DeleteTexture, DeleteVertexArray, Draw, GetProgramLocations, LoadWebGlTexture, ResizeRenderTarget, ResizeWebGlContext, SetUniforms, ShaderType, UpdateBuffer, UpdateTexture } from "./webgl.js";
|
|
32
33
|
import { WebGlRenderer } from "./webgl-renderer.js";
|
|
33
34
|
import { WorkerInterface } from "./worker-interface.js";
|
|
34
|
-
export { ActionMap, BindRenderTarget, CanvasRenderer, Clock, Color, CompileShader, CreateBuffer, CreateProgram, CreateProgramInfo, CreateRenderTarget, CreateTexture, CreateVertexArray, CreateWebGlContext, DEFAULT_COLOR, DEFAULT_DEADZONE, DEFAULT_FONT, DEFAULT_FONT_NAME, DEFAULT_FONT_SIZE, DEFAULT_MAP_2D_VALUE, DEFAULT_MAP_3D_VALUE, DEFAULT_PIXEL_SIZE, DEFAULT_TEXTALIGN, DEFAULT_TEXTBASELINE, DEG2RAD, DeleteProgramInfo, DeleteRenderTarget, DeleteTexture, DeleteVertexArray, Disposable, Draw, E, ECS, EPSILON, Emitter, EventQueue, GAMEPAD_AXES, GAMEPAD_BUTTONS, GESTURES, GenerateDoors, GenerateRooms, GenerateWalls, GestureRecognizer, GetProgramLocations, GetUrlParams, HALF_PI, Input, LN10, LN2, LOG10E, LOG2E, LoadWebGlTexture, MAP_2D_MAX_COORD, MAP_2D_MIN_COORD, MAP_3D_MAX_COORD, MAP_3D_MIN_COORD, Map2D, Map3D, ONE_SECOND, Observable, PI, ParticleRenderer, ParticleSystem2d, QUARTER_PI, RAD2DEG, Random, Rectangle, ResizeRenderTarget, ResizeWebGlContext, Rng, SQRT1_2, SQRT2, SetUniforms, ShaderType, Signal, SpatialPartition2d, SpatialPartition3d, TAU, TILE_EMPTY, TILE_FLOOR, TILE_PATH, Tilemap, UpdateBuffer, UpdateTexture, Vector, WebGlRenderer, WorkerInterface, XR_AXES, XR_BUTTONS, bindingLabel, bindingsEqual, buildColorPalette, clamp, controlId, degrees, distance2d, distance3d, ecs, findPath, fract, gesture, getRedYellowGreenGradientHex, hash32, hash32mix, inverseLerp, isNullOrUndefined, isPositiveString, k2xy, k2xyz, key, lerp, log, manhattanDistance, mod, mouse, nearlyEqual, normalizeRadians, pad, padAxis, radians, randomMatrix, rng, roundTo, saturate, smoothstep, squaredDistance, wheel, wrap, xr, xrAxis, xy2k, xyz2k };
|
|
35
|
+
export { ActionMap, BindRenderTarget, CanvasRenderer, Clock, Color, CompileShader, CreateBuffer, CreateProgram, CreateProgramInfo, CreateRenderTarget, CreateTexture, CreateVertexArray, CreateWebGlContext, DEFAULT_COLOR, DEFAULT_DEADZONE, DEFAULT_FONT, DEFAULT_FONT_NAME, DEFAULT_FONT_SIZE, DEFAULT_MAP_2D_VALUE, DEFAULT_MAP_3D_VALUE, DEFAULT_PIXEL_SIZE, DEFAULT_REPEAT, DEFAULT_TEXTALIGN, DEFAULT_TEXTBASELINE, DEG2RAD, DeleteProgramInfo, DeleteRenderTarget, DeleteTexture, DeleteVertexArray, Disposable, Draw, E, ECS, EPSILON, Emitter, EventQueue, GAMEPAD_AXES, GAMEPAD_BUTTONS, GESTURES, GenerateDoors, GenerateRooms, GenerateWalls, GestureRecognizer, GetProgramLocations, GetUrlParams, HALF_PI, Input, InputActionMap, LN10, LN2, LOG10E, LOG2E, LoadWebGlTexture, MAP_2D_MAX_COORD, MAP_2D_MIN_COORD, MAP_3D_MAX_COORD, MAP_3D_MIN_COORD, Map2D, Map3D, ONE_SECOND, Observable, PI, ParticleRenderer, ParticleSystem2d, QUARTER_PI, RAD2DEG, Random, Rectangle, ResizeRenderTarget, ResizeWebGlContext, Rng, SQRT1_2, SQRT2, SetUniforms, ShaderType, Signal, SpatialPartition2d, SpatialPartition3d, TAU, TILE_EMPTY, TILE_FLOOR, TILE_PATH, Tilemap, UpdateBuffer, UpdateTexture, Vector, WebGlRenderer, WorkerInterface, XR_AXES, XR_BUTTONS, bindingLabel, bindingsEqual, buildColorPalette, clamp, controlId, degrees, distance2d, distance3d, ecs, findPath, fract, gesture, getRedYellowGreenGradientHex, hash32, hash32mix, inverseLerp, isNullOrUndefined, isPositiveString, k2xy, k2xyz, key, lerp, log, manhattanDistance, mod, mouse, nearlyEqual, normalizeRadians, pad, padAxis, radians, randomMatrix, rng, roundTo, saturate, smoothstep, squaredDistance, wheel, wrap, xr, xrAxis, xy2k, xyz2k };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Emitter } from "../emitter.js";
|
|
2
|
+
//#region src/input/_input.d.ts
|
|
3
|
+
export interface InputState {
|
|
4
|
+
state: number;
|
|
5
|
+
timeStamp: number;
|
|
6
|
+
}
|
|
7
|
+
export declare class Input extends Emitter {
|
|
8
|
+
private static _instance;
|
|
9
|
+
static get instance(): Input;
|
|
10
|
+
private _state;
|
|
11
|
+
inputThreshold: number;
|
|
12
|
+
private constructor();
|
|
13
|
+
disableContextMenu(): void;
|
|
14
|
+
private _onKeyDown;
|
|
15
|
+
private _onKeyUp;
|
|
16
|
+
private _onPointerDown;
|
|
17
|
+
private _onPointerUp;
|
|
18
|
+
private _onPointerMove;
|
|
19
|
+
private _onWheel;
|
|
20
|
+
isKeyDown(keyCode: string): boolean;
|
|
21
|
+
getKeyState(keyCode: string): number;
|
|
22
|
+
isButtonDown(buttonNumber: number): boolean;
|
|
23
|
+
getButtonState(buttonNumber: number): number;
|
|
24
|
+
}
|
|
25
|
+
//#endregion
|