three-gamepad-controls 0.4.0 → 0.5.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 +1 -0
- package/dist/gamepad-map-controls.d.ts +22 -0
- package/dist/gamepad-map-controls.js +35 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -39,5 +39,6 @@ bun add three-gamepad-controls
|
|
|
39
39
|
- [Core](./docs/core.md) — The fundamental building blocks.
|
|
40
40
|
- [GamepadControls](./docs/gamepad-controls.md) — Abstract base class for custom gamepad controls.
|
|
41
41
|
- [GamepadFlyControls](./docs/gamepad-fly-controls.md) — Gamepad support for `FlyControls`.
|
|
42
|
+
- [GamepadMapControls](./docs/gamepad-map-controls.md) — Gamepad support for `MapControls`.
|
|
42
43
|
- [GamepadOrbitControls](./docs/gamepad-orbit-controls.md) — Gamepad support for `OrbitControls`.
|
|
43
44
|
- [GamepadPointerLockControls](./docs/gamepad-pointer-lock-controls.md) — Gamepad support for `PointerLockControls`.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { GamepadOrbitControls, GamepadOrbitControlsOptions } from "./gamepad-orbit-controls.js";
|
|
2
|
+
import { MapControls } from "three/addons/controls/MapControls.js";
|
|
3
|
+
|
|
4
|
+
//#region src/gamepad-map-controls.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Adds gamepad support to Three.js `MapControls`.
|
|
7
|
+
*
|
|
8
|
+
* Pan is the primary action (left stick by default), matching `MapControls`'
|
|
9
|
+
* mouse conventions. All options from {@link GamepadOrbitControlsOptions} are available.
|
|
10
|
+
*
|
|
11
|
+
* Call `update()` inside the render loop **before** `MapControls.update()`.
|
|
12
|
+
*/
|
|
13
|
+
declare class GamepadMapControls extends GamepadOrbitControls {
|
|
14
|
+
/**
|
|
15
|
+
* @param controls - A Three.js `MapControls` instance.
|
|
16
|
+
* @param options - Optional overrides for the default behavior.
|
|
17
|
+
* Any property not provided falls back to its default value.
|
|
18
|
+
*/
|
|
19
|
+
constructor(controls: MapControls, options?: Partial<GamepadOrbitControlsOptions>);
|
|
20
|
+
}
|
|
21
|
+
//#endregion
|
|
22
|
+
export { GamepadMapControls };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { GAMEPAD_AXIS } from "./core.js";
|
|
2
|
+
import { GamepadOrbitControls } from "./gamepad-orbit-controls.js";
|
|
3
|
+
//#region src/gamepad-map-controls.ts
|
|
4
|
+
/**
|
|
5
|
+
* Axis overrides for {@link GamepadMapControls}: left stick pans, right stick orbits.
|
|
6
|
+
*/
|
|
7
|
+
const DEFAULT_MAP_OPTIONS = {
|
|
8
|
+
axisPanX: GAMEPAD_AXIS.LeftX,
|
|
9
|
+
axisPanY: GAMEPAD_AXIS.LeftY,
|
|
10
|
+
axisRotateX: GAMEPAD_AXIS.RightX,
|
|
11
|
+
axisRotateY: GAMEPAD_AXIS.RightY
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Adds gamepad support to Three.js `MapControls`.
|
|
15
|
+
*
|
|
16
|
+
* Pan is the primary action (left stick by default), matching `MapControls`'
|
|
17
|
+
* mouse conventions. All options from {@link GamepadOrbitControlsOptions} are available.
|
|
18
|
+
*
|
|
19
|
+
* Call `update()` inside the render loop **before** `MapControls.update()`.
|
|
20
|
+
*/
|
|
21
|
+
var GamepadMapControls = class extends GamepadOrbitControls {
|
|
22
|
+
/**
|
|
23
|
+
* @param controls - A Three.js `MapControls` instance.
|
|
24
|
+
* @param options - Optional overrides for the default behavior.
|
|
25
|
+
* Any property not provided falls back to its default value.
|
|
26
|
+
*/
|
|
27
|
+
constructor(controls, options) {
|
|
28
|
+
super(controls, {
|
|
29
|
+
...DEFAULT_MAP_OPTIONS,
|
|
30
|
+
...options
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
//#endregion
|
|
35
|
+
export { GamepadMapControls };
|
package/dist/index.d.ts
CHANGED
|
@@ -2,5 +2,6 @@ import { GAMEPAD_AXIS, GAMEPAD_BUTTON, GamepadAxisKey, GamepadAxisValue, Gamepad
|
|
|
2
2
|
import { GamepadControls, GamepadControlsEventMap } from "./gamepad-controls.js";
|
|
3
3
|
import { GamepadFlyControls, GamepadFlyControlsOptions } from "./gamepad-fly-controls.js";
|
|
4
4
|
import { GamepadOrbitControls, GamepadOrbitControlsOptions } from "./gamepad-orbit-controls.js";
|
|
5
|
+
import { GamepadMapControls } from "./gamepad-map-controls.js";
|
|
5
6
|
import { GamepadPointerLockControls, GamepadPointerLockControlsOptions } from "./gamepad-pointer-lock-controls.js";
|
|
6
|
-
export { GAMEPAD_AXIS, GAMEPAD_BUTTON, GamepadAxisKey, GamepadAxisValue, GamepadButtonKey, GamepadButtonValue, GamepadControls, GamepadControlsEventMap, GamepadFlyControls, GamepadFlyControlsOptions, GamepadOrbitControls, GamepadOrbitControlsOptions, GamepadPointerLockControls, GamepadPointerLockControlsOptions };
|
|
7
|
+
export { GAMEPAD_AXIS, GAMEPAD_BUTTON, GamepadAxisKey, GamepadAxisValue, GamepadButtonKey, GamepadButtonValue, GamepadControls, GamepadControlsEventMap, GamepadFlyControls, GamepadFlyControlsOptions, GamepadMapControls, GamepadOrbitControls, GamepadOrbitControlsOptions, GamepadPointerLockControls, GamepadPointerLockControlsOptions };
|
package/dist/index.js
CHANGED
|
@@ -2,5 +2,6 @@ import { GAMEPAD_AXIS, GAMEPAD_BUTTON } from "./core.js";
|
|
|
2
2
|
import { GamepadControls } from "./gamepad-controls.js";
|
|
3
3
|
import { GamepadFlyControls } from "./gamepad-fly-controls.js";
|
|
4
4
|
import { GamepadOrbitControls } from "./gamepad-orbit-controls.js";
|
|
5
|
+
import { GamepadMapControls } from "./gamepad-map-controls.js";
|
|
5
6
|
import { GamepadPointerLockControls } from "./gamepad-pointer-lock-controls.js";
|
|
6
|
-
export { GAMEPAD_AXIS, GAMEPAD_BUTTON, GamepadControls, GamepadFlyControls, GamepadOrbitControls, GamepadPointerLockControls };
|
|
7
|
+
export { GAMEPAD_AXIS, GAMEPAD_BUTTON, GamepadControls, GamepadFlyControls, GamepadMapControls, GamepadOrbitControls, GamepadPointerLockControls };
|
package/package.json
CHANGED