three-gamepad-controls 0.10.6 → 0.12.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 +15 -0
- package/dist/gamepad-arcball-controls.d.ts +1 -2
- package/dist/gamepad-arcball-controls.js +75 -16
- package/dist/gamepad-controls.d.ts +25 -12
- package/dist/gamepad-controls.js +58 -51
- package/dist/gamepad-drag-controls.d.ts +1 -2
- package/dist/gamepad-drag-controls.js +86 -13
- package/dist/gamepad-first-person-controls.d.ts +1 -2
- package/dist/gamepad-first-person-controls.js +38 -13
- package/dist/gamepad-fly-controls.d.ts +1 -2
- package/dist/gamepad-fly-controls.js +9 -10
- package/dist/gamepad-input.d.ts +156 -0
- package/dist/gamepad-input.js +310 -0
- package/dist/gamepad-orbit-controls.d.ts +1 -2
- package/dist/gamepad-orbit-controls.js +8 -9
- package/dist/gamepad-pointer-lock-controls.d.ts +1 -2
- package/dist/gamepad-pointer-lock-controls.js +6 -7
- package/dist/gamepad-trackball-controls.d.ts +1 -2
- package/dist/gamepad-trackball-controls.js +45 -15
- package/dist/gamepad-transform-controls.d.ts +1 -2
- package/dist/gamepad-transform-controls.js +317 -21
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/package.json +3 -3
- package/dist/utils.js +0 -41
package/dist/utils.js
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
//#region src/utils.ts
|
|
2
|
-
/**
|
|
3
|
-
* Returns `value` unchanged, or `0` if below the dead zone `threshold`.
|
|
4
|
-
*
|
|
5
|
-
* @param value - Raw axis or trigger value, typically in `[-1, 1]`.
|
|
6
|
-
* @param threshold - Dead zone size; values below this magnitude are zeroed.
|
|
7
|
-
* @returns The original value when outside the dead zone, otherwise `0`.
|
|
8
|
-
*/
|
|
9
|
-
const applyGamepadDeadzone = (value, threshold) => {
|
|
10
|
-
return Math.abs(value) < threshold ? 0 : value;
|
|
11
|
-
};
|
|
12
|
-
/**
|
|
13
|
-
* Returns whether a gamepad button is currently pressed.
|
|
14
|
-
*
|
|
15
|
-
* Missing buttons are treated as not pressed.
|
|
16
|
-
*
|
|
17
|
-
* @param gamepad - Gamepad snapshot to read from.
|
|
18
|
-
* @param button - Button index to inspect.
|
|
19
|
-
* @returns `true` when the button exists and is pressed, otherwise `false`.
|
|
20
|
-
*/
|
|
21
|
-
const getGamepadButtonPressed = (gamepad, button) => {
|
|
22
|
-
return gamepad.buttons[button]?.pressed ?? false;
|
|
23
|
-
};
|
|
24
|
-
/**
|
|
25
|
-
* Returns the analog value for a gamepad button.
|
|
26
|
-
*
|
|
27
|
-
* Some digital buttons may report `pressed` without a meaningful non-zero
|
|
28
|
-
* `value`, so pressed buttons fall back to `1`.
|
|
29
|
-
*
|
|
30
|
-
* @param gamepad - Gamepad snapshot to read from.
|
|
31
|
-
* @param button - Button index to inspect.
|
|
32
|
-
* @returns The button value, `1` for pressed digital buttons, or `0` when unavailable.
|
|
33
|
-
*/
|
|
34
|
-
const getGamepadButtonValue = (gamepad, button) => {
|
|
35
|
-
const gamepadButton = gamepad.buttons[button];
|
|
36
|
-
if (gamepadButton === void 0) return 0;
|
|
37
|
-
if (gamepadButton.value !== 0) return gamepadButton.value;
|
|
38
|
-
return gamepadButton.pressed ? 1 : 0;
|
|
39
|
-
};
|
|
40
|
-
//#endregion
|
|
41
|
-
export { applyGamepadDeadzone, getGamepadButtonPressed, getGamepadButtonValue };
|