@codexo/exojs 0.7.12 → 0.7.13

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.
Files changed (91) hide show
  1. package/CHANGELOG.md +334 -0
  2. package/dist/esm/core/Application.d.ts +3 -1
  3. package/dist/esm/core/Application.js +7 -6
  4. package/dist/esm/core/Application.js.map +1 -1
  5. package/dist/esm/core/Scene.d.ts +30 -0
  6. package/dist/esm/core/Scene.js +56 -0
  7. package/dist/esm/core/Scene.js.map +1 -1
  8. package/dist/esm/core/SceneManager.js +2 -2
  9. package/dist/esm/core/SceneManager.js.map +1 -1
  10. package/dist/esm/debug/DebugOverlay.js +2 -2
  11. package/dist/esm/debug/DebugOverlay.js.map +1 -1
  12. package/dist/esm/debug/PointerStackLayer.js +1 -1
  13. package/dist/esm/debug/PointerStackLayer.js.map +1 -1
  14. package/dist/esm/index.js +4 -3
  15. package/dist/esm/index.js.map +1 -1
  16. package/dist/esm/input/ArcadeStickGamepadMapping.js +18 -19
  17. package/dist/esm/input/ArcadeStickGamepadMapping.js.map +1 -1
  18. package/dist/esm/input/Gamepad.d.ts +164 -62
  19. package/dist/esm/input/Gamepad.js +290 -134
  20. package/dist/esm/input/Gamepad.js.map +1 -1
  21. package/dist/esm/input/GamepadAxis.d.ts +120 -0
  22. package/dist/esm/input/GamepadAxis.js +106 -0
  23. package/dist/esm/input/GamepadAxis.js.map +1 -0
  24. package/dist/esm/input/GamepadButton.d.ts +110 -0
  25. package/dist/esm/input/GamepadButton.js +99 -0
  26. package/dist/esm/input/GamepadButton.js.map +1 -0
  27. package/dist/esm/input/GamepadDefinitions.js +4 -0
  28. package/dist/esm/input/GamepadDefinitions.js.map +1 -1
  29. package/dist/esm/input/GamepadMapping.d.ts +28 -24
  30. package/dist/esm/input/GamepadMapping.js +33 -16
  31. package/dist/esm/input/GamepadMapping.js.map +1 -1
  32. package/dist/esm/input/GamepadPromptLayouts.d.ts +10 -8
  33. package/dist/esm/input/GamepadPromptLayouts.js +21 -20
  34. package/dist/esm/input/GamepadPromptLayouts.js.map +1 -1
  35. package/dist/esm/input/GenericDualAnalogGamepadMapping.d.ts +6 -3
  36. package/dist/esm/input/GenericDualAnalogGamepadMapping.js +55 -46
  37. package/dist/esm/input/GenericDualAnalogGamepadMapping.js.map +1 -1
  38. package/dist/esm/input/InputBinding.d.ts +74 -0
  39. package/dist/esm/input/InputBinding.js +100 -0
  40. package/dist/esm/input/InputBinding.js.map +1 -0
  41. package/dist/esm/input/InputManager.d.ts +79 -33
  42. package/dist/esm/input/InputManager.js +229 -104
  43. package/dist/esm/input/InputManager.js.map +1 -1
  44. package/dist/esm/input/InteractionManager.d.ts +1 -1
  45. package/dist/esm/input/InteractionManager.js +13 -13
  46. package/dist/esm/input/InteractionManager.js.map +1 -1
  47. package/dist/esm/input/JoyConLeftGamepadMapping.d.ts +14 -9
  48. package/dist/esm/input/JoyConLeftGamepadMapping.js +39 -9
  49. package/dist/esm/input/JoyConLeftGamepadMapping.js.map +1 -1
  50. package/dist/esm/input/JoyConRightGamepadMapping.d.ts +14 -9
  51. package/dist/esm/input/JoyConRightGamepadMapping.js +35 -9
  52. package/dist/esm/input/JoyConRightGamepadMapping.js.map +1 -1
  53. package/dist/esm/input/Pointer.d.ts +84 -71
  54. package/dist/esm/input/Pointer.js +71 -71
  55. package/dist/esm/input/Pointer.js.map +1 -1
  56. package/dist/esm/input/SteamDeckGamepadMapping.d.ts +18 -0
  57. package/dist/esm/input/SteamDeckGamepadMapping.js +76 -0
  58. package/dist/esm/input/SteamDeckGamepadMapping.js.map +1 -0
  59. package/dist/esm/input/index.d.ts +7 -4
  60. package/dist/esm/input/types.d.ts +0 -76
  61. package/dist/esm/input/types.js +1 -80
  62. package/dist/esm/input/types.js.map +1 -1
  63. package/dist/esm/resources/CacheFirstStrategy.d.ts +7 -4
  64. package/dist/esm/resources/CacheFirstStrategy.js +11 -8
  65. package/dist/esm/resources/CacheFirstStrategy.js.map +1 -1
  66. package/dist/esm/resources/CacheStrategy.d.ts +14 -6
  67. package/dist/esm/resources/Loader.d.ts +8 -3
  68. package/dist/esm/resources/Loader.js +19 -37
  69. package/dist/esm/resources/Loader.js.map +1 -1
  70. package/dist/esm/resources/NetworkOnlyStrategy.d.ts +3 -0
  71. package/dist/esm/resources/NetworkOnlyStrategy.js +8 -3
  72. package/dist/esm/resources/NetworkOnlyStrategy.js.map +1 -1
  73. package/dist/esm/resources/factories/ImageFactory.d.ts +2 -2
  74. package/dist/esm/resources/factories/ImageFactory.js.map +1 -1
  75. package/dist/esm/resources/factories/TextureFactory.d.ts +2 -2
  76. package/dist/esm/resources/factories/TextureFactory.js.map +1 -1
  77. package/dist/esm/resources/factories/VttFactory.d.ts +3 -3
  78. package/dist/esm/resources/factories/VttFactory.js +83 -6
  79. package/dist/esm/resources/factories/VttFactory.js.map +1 -1
  80. package/dist/exo.esm.js +1390 -795
  81. package/dist/exo.esm.js.map +1 -1
  82. package/package.json +2 -1
  83. package/dist/esm/input/GamepadChannels.d.ts +0 -47
  84. package/dist/esm/input/GamepadChannels.js +0 -53
  85. package/dist/esm/input/GamepadChannels.js.map +0 -1
  86. package/dist/esm/input/GamepadControl.d.ts +0 -33
  87. package/dist/esm/input/GamepadControl.js +0 -42
  88. package/dist/esm/input/GamepadControl.js.map +0 -1
  89. package/dist/esm/input/Input.d.ts +0 -52
  90. package/dist/esm/input/Input.js +0 -90
  91. package/dist/esm/input/Input.js.map +0 -1
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@codexo/exojs",
3
3
  "description": "A TypeScript-first browser 2D runtime for games and interactive apps.",
4
- "version": "0.7.12",
4
+ "version": "0.7.13",
5
5
  "type": "module",
6
6
  "files": [
7
7
  "dist/esm/",
@@ -47,6 +47,7 @@
47
47
  "verify:exports": "tsx ./scripts/verify-exports.ts",
48
48
  "verify:package": "npm run build && npm run verify:exports && npm pack --dry-run --ignore-scripts",
49
49
  "verify:release": "npm run typecheck && npm run lint && npm test && npm run verify:package",
50
+ "release": "node ./scripts/release.mjs",
50
51
  "prepack": "npm run build",
51
52
  "typecheck": "tsc --noEmit",
52
53
  "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"",
@@ -1,47 +0,0 @@
1
- /**
2
- * Canonical channel identifiers for every control a standard gamepad can expose.
3
- *
4
- * Values are absolute offsets into the engine's shared {@link Float32Array} input
5
- * channel buffer — each member equals `ChannelOffset.Gamepads + localIndex`.
6
- * Use {@link Gamepad.resolveChannelOffset} to account for per-slot skew when
7
- * reading a specific gamepad's data.
8
- */
9
- export declare enum GamepadChannel {
10
- ButtonSouth = 512,
11
- ButtonWest = 513,
12
- ButtonEast = 514,
13
- ButtonNorth = 515,
14
- LeftShoulder = 516,
15
- RightShoulder = 517,
16
- LeftTrigger = 518,
17
- RightTrigger = 519,
18
- Select = 520,
19
- Start = 521,
20
- LeftStick = 522,
21
- RightStick = 523,
22
- DPadUp = 524,
23
- DPadDown = 525,
24
- DPadLeft = 526,
25
- DPadRight = 527,
26
- Guide = 528,
27
- Share = 529,
28
- Capture = 530,
29
- Touchpad = 531,
30
- Paddle1 = 532,
31
- LeftStickLeft = 533,
32
- LeftStickRight = 534,
33
- LeftStickUp = 535,
34
- LeftStickDown = 536,
35
- RightStickLeft = 537,
36
- RightStickRight = 538,
37
- RightStickUp = 539,
38
- RightStickDown = 540,
39
- AuxiliaryAxis0Negative = 541,
40
- AuxiliaryAxis0Positive = 542,
41
- AuxiliaryAxis1Negative = 543,
42
- AuxiliaryAxis1Positive = 544,
43
- AuxiliaryAxis2Negative = 545,
44
- AuxiliaryAxis2Positive = 546,
45
- AuxiliaryAxis3Negative = 547,
46
- AuxiliaryAxis3Positive = 548
47
- }
@@ -1,53 +0,0 @@
1
- import './types.js';
2
-
3
- /**
4
- * Canonical channel identifiers for every control a standard gamepad can expose.
5
- *
6
- * Values are absolute offsets into the engine's shared {@link Float32Array} input
7
- * channel buffer — each member equals `ChannelOffset.Gamepads + localIndex`.
8
- * Use {@link Gamepad.resolveChannelOffset} to account for per-slot skew when
9
- * reading a specific gamepad's data.
10
- */
11
- var GamepadChannel;
12
- (function (GamepadChannel) {
13
- GamepadChannel[GamepadChannel["ButtonSouth"] = 512] = "ButtonSouth";
14
- GamepadChannel[GamepadChannel["ButtonWest"] = 513] = "ButtonWest";
15
- GamepadChannel[GamepadChannel["ButtonEast"] = 514] = "ButtonEast";
16
- GamepadChannel[GamepadChannel["ButtonNorth"] = 515] = "ButtonNorth";
17
- GamepadChannel[GamepadChannel["LeftShoulder"] = 516] = "LeftShoulder";
18
- GamepadChannel[GamepadChannel["RightShoulder"] = 517] = "RightShoulder";
19
- GamepadChannel[GamepadChannel["LeftTrigger"] = 518] = "LeftTrigger";
20
- GamepadChannel[GamepadChannel["RightTrigger"] = 519] = "RightTrigger";
21
- GamepadChannel[GamepadChannel["Select"] = 520] = "Select";
22
- GamepadChannel[GamepadChannel["Start"] = 521] = "Start";
23
- GamepadChannel[GamepadChannel["LeftStick"] = 522] = "LeftStick";
24
- GamepadChannel[GamepadChannel["RightStick"] = 523] = "RightStick";
25
- GamepadChannel[GamepadChannel["DPadUp"] = 524] = "DPadUp";
26
- GamepadChannel[GamepadChannel["DPadDown"] = 525] = "DPadDown";
27
- GamepadChannel[GamepadChannel["DPadLeft"] = 526] = "DPadLeft";
28
- GamepadChannel[GamepadChannel["DPadRight"] = 527] = "DPadRight";
29
- GamepadChannel[GamepadChannel["Guide"] = 528] = "Guide";
30
- GamepadChannel[GamepadChannel["Share"] = 529] = "Share";
31
- GamepadChannel[GamepadChannel["Capture"] = 530] = "Capture";
32
- GamepadChannel[GamepadChannel["Touchpad"] = 531] = "Touchpad";
33
- GamepadChannel[GamepadChannel["Paddle1"] = 532] = "Paddle1";
34
- GamepadChannel[GamepadChannel["LeftStickLeft"] = 533] = "LeftStickLeft";
35
- GamepadChannel[GamepadChannel["LeftStickRight"] = 534] = "LeftStickRight";
36
- GamepadChannel[GamepadChannel["LeftStickUp"] = 535] = "LeftStickUp";
37
- GamepadChannel[GamepadChannel["LeftStickDown"] = 536] = "LeftStickDown";
38
- GamepadChannel[GamepadChannel["RightStickLeft"] = 537] = "RightStickLeft";
39
- GamepadChannel[GamepadChannel["RightStickRight"] = 538] = "RightStickRight";
40
- GamepadChannel[GamepadChannel["RightStickUp"] = 539] = "RightStickUp";
41
- GamepadChannel[GamepadChannel["RightStickDown"] = 540] = "RightStickDown";
42
- GamepadChannel[GamepadChannel["AuxiliaryAxis0Negative"] = 541] = "AuxiliaryAxis0Negative";
43
- GamepadChannel[GamepadChannel["AuxiliaryAxis0Positive"] = 542] = "AuxiliaryAxis0Positive";
44
- GamepadChannel[GamepadChannel["AuxiliaryAxis1Negative"] = 543] = "AuxiliaryAxis1Negative";
45
- GamepadChannel[GamepadChannel["AuxiliaryAxis1Positive"] = 544] = "AuxiliaryAxis1Positive";
46
- GamepadChannel[GamepadChannel["AuxiliaryAxis2Negative"] = 545] = "AuxiliaryAxis2Negative";
47
- GamepadChannel[GamepadChannel["AuxiliaryAxis2Positive"] = 546] = "AuxiliaryAxis2Positive";
48
- GamepadChannel[GamepadChannel["AuxiliaryAxis3Negative"] = 547] = "AuxiliaryAxis3Negative";
49
- GamepadChannel[GamepadChannel["AuxiliaryAxis3Positive"] = 548] = "AuxiliaryAxis3Positive";
50
- })(GamepadChannel || (GamepadChannel = {}));
51
-
52
- export { GamepadChannel };
53
- //# sourceMappingURL=GamepadChannels.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"GamepadChannels.js","sources":["../../../../src/input/GamepadChannels.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAEA;;;;;;;AAOG;IACS;AAAZ,CAAA,UAAY,cAAc,EAAA;AACtB,IAAA,cAAA,CAAA,cAAA,CAAA,aAAA,CAAA,GAAA,GAAA,CAAA,GAAA,aAAwC;AACxC,IAAA,cAAA,CAAA,cAAA,CAAA,YAAA,CAAA,GAAA,GAAA,CAAA,GAAA,YAAuC;AACvC,IAAA,cAAA,CAAA,cAAA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pD,IAAA,cAAA,CAAA,cAAA,CAAA,wBAAA,CAAA,GAAA,GAAA,CAAA,GAAA,wBAAoD;AACpD,IAAA,cAAA,CAAA,cAAA,CAAA,wBAAA,CAAA,GAAA,GAAA,CAAA,GAAA,wBAAoD;AACpD,IAAA,cAAA,CAAA,cAAA,CAAA,wBAAA,CAAA,GAAA,GAAA,CAAA,GAAA,wBAAoD;AACpD,IAAA,cAAA,CAAA,cAAA,CAAA,wBAAA,CAAA,GAAA,GAAA,CAAA,GAAA,wBAAoD;AACxD,CAAC,EAtCW,cAAc,KAAd,cAAc,GAAA,EAAA,CAAA,CAAA;;;;"}
@@ -1,33 +0,0 @@
1
- import type { GamepadChannel } from './GamepadChannels';
2
- /**
3
- * Construction options for a single {@link GamepadControl}.
4
- * All fields are optional; defaults produce a plain pass-through control
5
- * with a 0.2 dead-zone.
6
- */
7
- export interface GamepadControlOptions {
8
- invert?: boolean;
9
- normalize?: boolean;
10
- threshold?: number;
11
- }
12
- /**
13
- * Represents a single mappable control — one button or one axis — on a physical gamepad.
14
- *
15
- * Stores the raw Gamepad API `index`, the target {@link GamepadChannel}, and the
16
- * transform parameters (`invert`, `normalize`, `threshold`) applied each frame
17
- * by {@link transformValue} before the value is written to the channel buffer.
18
- */
19
- export declare class GamepadControl {
20
- readonly index: number;
21
- readonly channel: GamepadChannel;
22
- readonly invert: boolean;
23
- readonly normalize: boolean;
24
- readonly threshold: number;
25
- constructor(index: number, channel: GamepadChannel, options?: GamepadControlOptions);
26
- /**
27
- * Applies the control's transform pipeline to a raw browser value.
28
- *
29
- * Pipeline: clamp to [-1, 1] → optional invert → optional normalize to [0, 1]
30
- * → dead-zone (returns 0 when the absolute result is at or below `threshold`).
31
- */
32
- transformValue(value: number): number;
33
- }
@@ -1,42 +0,0 @@
1
- import { clamp } from '../math/utils.js';
2
-
3
- /**
4
- * Represents a single mappable control — one button or one axis — on a physical gamepad.
5
- *
6
- * Stores the raw Gamepad API `index`, the target {@link GamepadChannel}, and the
7
- * transform parameters (`invert`, `normalize`, `threshold`) applied each frame
8
- * by {@link transformValue} before the value is written to the channel buffer.
9
- */
10
- class GamepadControl {
11
- index;
12
- channel;
13
- invert;
14
- normalize;
15
- threshold;
16
- constructor(index, channel, options = {}) {
17
- this.index = index;
18
- this.channel = channel;
19
- this.invert = options.invert ?? false;
20
- this.normalize = options.normalize ?? false;
21
- this.threshold = clamp(options.threshold ?? 0.2, 0, 1);
22
- }
23
- /**
24
- * Applies the control's transform pipeline to a raw browser value.
25
- *
26
- * Pipeline: clamp to [-1, 1] → optional invert → optional normalize to [0, 1]
27
- * → dead-zone (returns 0 when the absolute result is at or below `threshold`).
28
- */
29
- transformValue(value) {
30
- let result = clamp(value, -1, 1);
31
- if (this.invert) {
32
- result *= -1;
33
- }
34
- if (this.normalize) {
35
- result = (result + 1) / 2;
36
- }
37
- return result > this.threshold ? result : 0;
38
- }
39
- }
40
-
41
- export { GamepadControl };
42
- //# sourceMappingURL=GamepadControl.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"GamepadControl.js","sources":["../../../../src/input/GamepadControl.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAeA;;;;;;AAMG;MACU,cAAc,CAAA;AACP,IAAA,KAAK;AACL,IAAA,OAAO;AACP,IAAA,MAAM;AACN,IAAA,SAAS;AACT,IAAA,SAAS;AAEzB,IAAA,WAAA,CAAmB,KAAa,EAAE,OAAuB,EAAE,UAAiC,EAAE,EAAA;AAC1F,QAAA,IAAI,CAAC,KAAK,GAAG,KAAK;AAClB,QAAA,IAAI,CAAC,OAAO,GAAG,OAAO;QACtB,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,KAAK;QACrC,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,KAAK;AAC3C,QAAA,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC,OAAO,CAAC,SAAS,IAAI,GAAG,EAAE,CAAC,EAAE,CAAC,CAAC;IAC1D;AAEA;;;;;AAKG;AACI,IAAA,cAAc,CAAC,KAAa,EAAA;QAC/B,IAAI,MAAM,GAAG,KAAK,CAAC,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC;AAEhC,QAAA,IAAI,IAAI,CAAC,MAAM,EAAE;YACb,MAAM,IAAI,EAAE;QAChB;AAEA,QAAA,IAAI,IAAI,CAAC,SAAS,EAAE;YAChB,MAAM,GAAG,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC;QAC7B;AAEA,QAAA,OAAO,MAAM,GAAG,IAAI,CAAC,SAAS,GAAG,MAAM,GAAG,CAAC;IAC/C;AACH;;;;"}
@@ -1,52 +0,0 @@
1
- import { Signal } from '@/core/Signal';
2
- import type { Keyboard } from '@/input/types';
3
- import type { GamepadChannel } from './GamepadChannels';
4
- /** Convenience options accepted by the {@link Input} constructor. */
5
- interface InputOptions {
6
- onStart?: () => void;
7
- onStop?: () => void;
8
- onActive?: () => void;
9
- onTrigger?: () => void;
10
- context?: object;
11
- threshold?: number;
12
- }
13
- /** Union of channel identifiers an {@link Input} can subscribe to. */
14
- export type InputChannel = GamepadChannel | Keyboard;
15
- /**
16
- * Bind one or more input channels (keyboard keys, gamepad buttons, gamepad
17
- * axes) to a set of high-level events: `onStart` (became active),
18
- * `onStop` (became inactive), `onActive` (per-frame while active), and
19
- * `onTrigger` (released within the threshold window — a "tap"). The current
20
- * raw value is the max across all subscribed channels.
21
- *
22
- * Construct ad-hoc, or via {@link InputManager.add}. Driven by the
23
- * {@link InputManager} update loop which feeds the unified channel buffer.
24
- *
25
- * @example
26
- * ```ts
27
- * const jump = new Input([Keyboard.Space, GamepadChannel.FaceA], {
28
- * onTrigger: () => player.jump(),
29
- * });
30
- * ```
31
- */
32
- export declare class Input {
33
- static triggerThreshold: number;
34
- private readonly channels;
35
- private readonly triggerTimer;
36
- private valueState;
37
- readonly onStart: Signal<[number]>;
38
- readonly onStop: Signal<[number]>;
39
- readonly onActive: Signal<[number]>;
40
- readonly onTrigger: Signal<[number]>;
41
- constructor(channels: Array<InputChannel> | InputChannel, { onStart, onStop, onActive, onTrigger, context, threshold }?: InputOptions);
42
- get activeChannels(): Set<number>;
43
- get value(): number;
44
- /**
45
- * Read the latest values from the unified channel buffer and dispatch
46
- * the appropriate Signals. Called once per frame by {@link InputManager}.
47
- * No-op for inputs not bound to any channel.
48
- */
49
- update(channels: Float32Array): this;
50
- destroy(): void;
51
- }
52
- export {};
@@ -1,90 +0,0 @@
1
- import { Signal } from '../core/Signal.js';
2
- import { Timer } from '../core/Timer.js';
3
- import { milliseconds } from '../core/utils.js';
4
-
5
- /**
6
- * Bind one or more input channels (keyboard keys, gamepad buttons, gamepad
7
- * axes) to a set of high-level events: `onStart` (became active),
8
- * `onStop` (became inactive), `onActive` (per-frame while active), and
9
- * `onTrigger` (released within the threshold window — a "tap"). The current
10
- * raw value is the max across all subscribed channels.
11
- *
12
- * Construct ad-hoc, or via {@link InputManager.add}. Driven by the
13
- * {@link InputManager} update loop which feeds the unified channel buffer.
14
- *
15
- * @example
16
- * ```ts
17
- * const jump = new Input([Keyboard.Space, GamepadChannel.FaceA], {
18
- * onTrigger: () => player.jump(),
19
- * });
20
- * ```
21
- */
22
- class Input {
23
- static triggerThreshold = 300;
24
- channels = new Set();
25
- triggerTimer;
26
- valueState = 0;
27
- onStart = new Signal();
28
- onStop = new Signal();
29
- onActive = new Signal();
30
- onTrigger = new Signal();
31
- constructor(channels, { onStart, onStop, onActive, onTrigger, context, threshold } = {}) {
32
- this.channels = new Set(Array.isArray(channels) ? channels : [channels]);
33
- this.triggerTimer = new Timer(milliseconds(threshold ?? Input.triggerThreshold));
34
- if (onStart) {
35
- this.onStart.add(onStart, context);
36
- }
37
- if (onStop) {
38
- this.onStop.add(onStop, context);
39
- }
40
- if (onActive) {
41
- this.onActive.add(onActive, context);
42
- }
43
- if (onTrigger) {
44
- this.onTrigger.add(onTrigger, context);
45
- }
46
- }
47
- get activeChannels() {
48
- return this.channels;
49
- }
50
- get value() {
51
- return this.valueState;
52
- }
53
- /**
54
- * Read the latest values from the unified channel buffer and dispatch
55
- * the appropriate Signals. Called once per frame by {@link InputManager}.
56
- * No-op for inputs not bound to any channel.
57
- */
58
- update(channels) {
59
- this.valueState = 0;
60
- for (const channel of this.channels) {
61
- this.valueState = Math.max(channels[channel], this.valueState);
62
- }
63
- if (this.valueState) {
64
- if (!this.triggerTimer.running) {
65
- this.triggerTimer.restart();
66
- this.onStart.dispatch(this.valueState);
67
- }
68
- this.onActive.dispatch(this.valueState);
69
- }
70
- else if (this.triggerTimer.running) {
71
- this.onStop.dispatch(this.valueState);
72
- if (!this.triggerTimer.expired) {
73
- this.onTrigger.dispatch(this.valueState);
74
- }
75
- this.triggerTimer.stop();
76
- }
77
- return this;
78
- }
79
- destroy() {
80
- this.channels.clear();
81
- this.triggerTimer.destroy();
82
- this.onStart.destroy();
83
- this.onStop.destroy();
84
- this.onActive.destroy();
85
- this.onTrigger.destroy();
86
- }
87
- }
88
-
89
- export { Input };
90
- //# sourceMappingURL=Input.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Input.js","sources":["../../../../src/input/Input.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;AAoBA;;;;;;;;;;;;;;;;AAgBG;MACU,KAAK,CAAA;AACP,IAAA,OAAO,gBAAgB,GAAG,GAAG;AAEnB,IAAA,QAAQ,GAAG,IAAI,GAAG,EAAU;AAC5B,IAAA,YAAY;IACrB,UAAU,GAAG,CAAC;AAEN,IAAA,OAAO,GAAG,IAAI,MAAM,EAAY;AAChC,IAAA,MAAM,GAAG,IAAI,MAAM,EAAY;AAC/B,IAAA,QAAQ,GAAG,IAAI,MAAM,EAAY;AACjC,IAAA,SAAS,GAAG,IAAI,MAAM,EAAY;AAElD,IAAA,WAAA,CAAmB,QAA4C,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,SAAS,KAAmB,EAAE,EAAA;QAC5I,IAAI,CAAC,QAAQ,GAAG,IAAI,GA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