three-gamepad-controls 0.24.0 → 0.24.2
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 +33 -5
- package/dist/core.d.ts +9 -10
- package/dist/gamepad-arcball-controls.d.ts +5 -4
- package/dist/gamepad-arcball-controls.js +28 -13
- package/dist/gamepad-controls.d.ts +18 -11
- package/dist/gamepad-controls.js +13 -6
- package/dist/gamepad-drag-controls.d.ts +4 -6
- package/dist/gamepad-drag-controls.js +24 -15
- package/dist/gamepad-first-person-controls.d.ts +3 -4
- package/dist/gamepad-first-person-controls.js +1 -0
- package/dist/gamepad-fly-controls.d.ts +3 -4
- package/dist/gamepad-fly-controls.js +1 -0
- package/dist/gamepad-input.d.ts +26 -14
- package/dist/gamepad-input.js +15 -6
- package/dist/gamepad-manager.js +4 -2
- package/dist/gamepad-map-controls.d.ts +2 -3
- package/dist/gamepad-orbit-controls.d.ts +3 -4
- package/dist/gamepad-orbit-controls.js +22 -5
- package/dist/gamepad-pointer-lock-controls.d.ts +3 -4
- package/dist/gamepad-pointer-lock-controls.js +1 -0
- package/dist/gamepad-stick-processing.d.ts +16 -17
- package/dist/gamepad-trackball-controls.d.ts +3 -4
- package/dist/gamepad-trackball-controls.js +4 -13
- package/dist/gamepad-transform-controls.d.ts +4 -5
- package/dist/gamepad-transform-controls.js +252 -60
- package/package.json +10 -9
package/dist/gamepad-input.js
CHANGED
|
@@ -52,7 +52,9 @@ const getGamepadButtonValue = (gamepad, button) => {
|
|
|
52
52
|
*/
|
|
53
53
|
var GamepadInput = class extends EventDispatcher {
|
|
54
54
|
/**
|
|
55
|
-
* When `false`,
|
|
55
|
+
* When `false`, polling through `update()` is paused and the last observed
|
|
56
|
+
* state, including button transitions, is retained. Browser listeners remain
|
|
57
|
+
* active and may adopt or disconnect a gamepad; connection events may poll.
|
|
56
58
|
* @default true
|
|
57
59
|
*/
|
|
58
60
|
enabled = true;
|
|
@@ -144,6 +146,9 @@ var GamepadInput = class extends EventDispatcher {
|
|
|
144
146
|
}
|
|
145
147
|
/**
|
|
146
148
|
* Polls the gamepad and refreshes current and previous button state.
|
|
149
|
+
*
|
|
150
|
+
* Resuming compares against the last observed state, without replaying clicks
|
|
151
|
+
* completed during the pause. Adoption seeds held buttons without transitions.
|
|
147
152
|
*/
|
|
148
153
|
update() {
|
|
149
154
|
if (!this.enabled) return;
|
|
@@ -170,7 +175,9 @@ var GamepadInput = class extends EventDispatcher {
|
|
|
170
175
|
this.#syncButtonState({ seedPrevious: false });
|
|
171
176
|
}
|
|
172
177
|
/**
|
|
173
|
-
* Removes
|
|
178
|
+
* Removes this reader's window listeners, clears its state, and disables it.
|
|
179
|
+
* Does not dispatch a synthetic disconnection or affect other input readers.
|
|
180
|
+
* Reusing a disposed reader is unsupported; create a new instance instead.
|
|
174
181
|
*/
|
|
175
182
|
dispose() {
|
|
176
183
|
window.removeEventListener("gamepadconnected", this.#onGamepadConnected);
|
|
@@ -190,19 +197,21 @@ var GamepadInput = class extends EventDispatcher {
|
|
|
190
197
|
return this.#pressedButtons.has(button);
|
|
191
198
|
}
|
|
192
199
|
/**
|
|
193
|
-
* Returns whether a button
|
|
200
|
+
* Returns whether a button changed to pressed in the latest observed state.
|
|
201
|
+
* Paused updates retain this result until the next observation or cleanup.
|
|
194
202
|
*
|
|
195
203
|
* @param button - Button index to inspect.
|
|
196
|
-
* @returns
|
|
204
|
+
* @returns Whether the latest observed button state transitioned to pressed.
|
|
197
205
|
*/
|
|
198
206
|
wasPressed(button) {
|
|
199
207
|
return this.#pressedButtons.has(button) && !this.#previousPressedButtons.has(button);
|
|
200
208
|
}
|
|
201
209
|
/**
|
|
202
|
-
* Returns whether a button
|
|
210
|
+
* Returns whether a button changed to released in the latest observed state.
|
|
211
|
+
* Paused updates retain this result until the next observation or cleanup.
|
|
203
212
|
*
|
|
204
213
|
* @param button - Button index to inspect.
|
|
205
|
-
* @returns
|
|
214
|
+
* @returns Whether the latest observed button state transitioned to released.
|
|
206
215
|
*/
|
|
207
216
|
wasReleased(button) {
|
|
208
217
|
return !this.#pressedButtons.has(button) && this.#previousPressedButtons.has(button);
|
package/dist/gamepad-manager.js
CHANGED
|
@@ -68,8 +68,10 @@ var GamepadManager = class {
|
|
|
68
68
|
/**
|
|
69
69
|
* Polls the Gamepad API and refreshes the active gamepad snapshot.
|
|
70
70
|
*
|
|
71
|
-
* Polling
|
|
72
|
-
*
|
|
71
|
+
* Polling refreshes the active slot without treating changes in object
|
|
72
|
+
* reference, `id`, or `timestamp` as reconnections. A missing or disconnected
|
|
73
|
+
* slot reports only a disconnection; adoption waits until the next update.
|
|
74
|
+
* Physical replacements without an observed loss cannot be distinguished.
|
|
73
75
|
*
|
|
74
76
|
* @returns The active gamepad and any connect/disconnect transition found.
|
|
75
77
|
*/
|
|
@@ -9,7 +9,7 @@ import { MapControls } from "three/addons/controls/MapControls.js";
|
|
|
9
9
|
*
|
|
10
10
|
* Call `update()` inside the render loop **before** `MapControls.update()`.
|
|
11
11
|
*/
|
|
12
|
-
declare class GamepadMapControls extends GamepadOrbitControls {
|
|
12
|
+
export declare class GamepadMapControls extends GamepadOrbitControls {
|
|
13
13
|
/**
|
|
14
14
|
* @param controls - A Three.js `MapControls` instance.
|
|
15
15
|
* @param options - Optional overrides for the default behavior.
|
|
@@ -17,5 +17,4 @@ declare class GamepadMapControls extends GamepadOrbitControls {
|
|
|
17
17
|
*/
|
|
18
18
|
constructor(controls: MapControls, options?: Partial<GamepadOrbitControlsOptions>);
|
|
19
19
|
}
|
|
20
|
-
//#endregion
|
|
21
|
-
export { GamepadMapControls };
|
|
20
|
+
//#endregion
|
|
@@ -7,7 +7,7 @@ import { OrbitControls } from "three/addons/controls/OrbitControls.js";
|
|
|
7
7
|
*
|
|
8
8
|
* Every property has a sensible default, so you only need to pass the properties you want to override.
|
|
9
9
|
*/
|
|
10
|
-
type GamepadOrbitControlsOptions = GamepadControlsOptions & {
|
|
10
|
+
export type GamepadOrbitControlsOptions = GamepadControlsOptions & {
|
|
11
11
|
/**
|
|
12
12
|
* Multiplier on orbit rotation speed.
|
|
13
13
|
* @default 1.0
|
|
@@ -55,7 +55,7 @@ type GamepadOrbitControlsOptions = GamepadControlsOptions & {
|
|
|
55
55
|
* Call `update()` inside the render loop **before** `OrbitControls.update()`.
|
|
56
56
|
* Bindings and speeds are configurable via {@link GamepadOrbitControlsOptions}.
|
|
57
57
|
*/
|
|
58
|
-
declare class GamepadOrbitControls extends GamepadControls {
|
|
58
|
+
export declare class GamepadOrbitControls extends GamepadControls {
|
|
59
59
|
#private;
|
|
60
60
|
/**
|
|
61
61
|
* @param controls - A Three.js `OrbitControls` instance.
|
|
@@ -70,5 +70,4 @@ declare class GamepadOrbitControls extends GamepadControls {
|
|
|
70
70
|
*/
|
|
71
71
|
protected onUpdate(deltaTime: number): void;
|
|
72
72
|
}
|
|
73
|
-
//#endregion
|
|
74
|
-
export { GamepadOrbitControls, GamepadOrbitControlsOptions };
|
|
73
|
+
//#endregion
|
|
@@ -50,17 +50,34 @@ var GamepadOrbitControls = class extends GamepadControls {
|
|
|
50
50
|
* @param deltaTime - Seconds since the last frame.
|
|
51
51
|
*/
|
|
52
52
|
onUpdate(deltaTime) {
|
|
53
|
+
if (!this.#canApplyInput()) return;
|
|
54
|
+
const controls = this.#controls;
|
|
53
55
|
const { rotateSpeed, panSpeed, zoomSpeed, rotateStick, panStick, buttonDeadzone, buttonDollyIn, buttonDollyOut } = this.#options;
|
|
54
56
|
const input = this.gamepadInput;
|
|
55
57
|
const rotate = input.stick(rotateStick.xAxis, rotateStick.yAxis, rotateStick.pipeline);
|
|
56
|
-
if (rotate.x !== 0)
|
|
57
|
-
|
|
58
|
+
if (controls.enableRotate && rotate.x !== 0) {
|
|
59
|
+
controls.rotateLeft(rotate.x * rotateSpeed * deltaTime * Math.PI);
|
|
60
|
+
if (!this.#canApplyInput()) return;
|
|
61
|
+
}
|
|
62
|
+
if (controls.enableRotate && rotate.y !== 0) {
|
|
63
|
+
controls.rotateUp(rotate.y * rotateSpeed * deltaTime * Math.PI);
|
|
64
|
+
if (!this.#canApplyInput()) return;
|
|
65
|
+
}
|
|
58
66
|
const pan = input.stick(panStick.xAxis, panStick.yAxis, panStick.pipeline);
|
|
59
|
-
if (pan.x !== 0 || pan.y !== 0)
|
|
67
|
+
if (controls.enablePan && (pan.x !== 0 || pan.y !== 0)) {
|
|
68
|
+
controls.pan(pan.x * panSpeed * deltaTime * 500, pan.y * panSpeed * deltaTime * 500);
|
|
69
|
+
if (!this.#canApplyInput()) return;
|
|
70
|
+
}
|
|
60
71
|
const triggerIn = input.buttonValue(buttonDollyIn);
|
|
61
72
|
const triggerOut = input.buttonValue(buttonDollyOut);
|
|
62
|
-
if (
|
|
63
|
-
|
|
73
|
+
if (controls.enableZoom && triggerIn > buttonDeadzone) {
|
|
74
|
+
controls.dollyIn(1 / (1 + zoomSpeed * triggerIn * deltaTime));
|
|
75
|
+
if (!this.#canApplyInput()) return;
|
|
76
|
+
}
|
|
77
|
+
if (controls.enableZoom && triggerOut > buttonDeadzone) controls.dollyOut(1 / (1 + zoomSpeed * triggerOut * deltaTime));
|
|
78
|
+
}
|
|
79
|
+
#canApplyInput() {
|
|
80
|
+
return this.enabled && this.#controls.enabled && this.gamepad !== null;
|
|
64
81
|
}
|
|
65
82
|
};
|
|
66
83
|
//#endregion
|
|
@@ -7,7 +7,7 @@ import { PointerLockControls } from "three/addons/controls/PointerLockControls.j
|
|
|
7
7
|
*
|
|
8
8
|
* Every property has a sensible default, so you only need to pass the properties you want to override.
|
|
9
9
|
*/
|
|
10
|
-
type GamepadPointerLockControlsOptions = GamepadControlsOptions & {
|
|
10
|
+
export type GamepadPointerLockControlsOptions = GamepadControlsOptions & {
|
|
11
11
|
/**
|
|
12
12
|
* Camera movement speed in world units per second at full stick deflection.
|
|
13
13
|
* @default 5.0
|
|
@@ -36,7 +36,7 @@ type GamepadPointerLockControlsOptions = GamepadControlsOptions & {
|
|
|
36
36
|
* IS locked, mouse and gamepad look inputs are additive.
|
|
37
37
|
* Bindings and speeds are configurable via {@link GamepadPointerLockControlsOptions}.
|
|
38
38
|
*/
|
|
39
|
-
declare class GamepadPointerLockControls extends GamepadControls {
|
|
39
|
+
export declare class GamepadPointerLockControls extends GamepadControls {
|
|
40
40
|
#private;
|
|
41
41
|
/**
|
|
42
42
|
* @param controls - A Three.js `PointerLockControls` instance.
|
|
@@ -51,5 +51,4 @@ declare class GamepadPointerLockControls extends GamepadControls {
|
|
|
51
51
|
*/
|
|
52
52
|
protected onUpdate(deltaTime: number): void;
|
|
53
53
|
}
|
|
54
|
-
//#endregion
|
|
55
|
-
export { GamepadPointerLockControls, GamepadPointerLockControlsOptions };
|
|
54
|
+
//#endregion
|
|
@@ -50,6 +50,7 @@ var GamepadPointerLockControls = class extends GamepadControls {
|
|
|
50
50
|
* @param deltaTime - Seconds since the last frame.
|
|
51
51
|
*/
|
|
52
52
|
onUpdate(deltaTime) {
|
|
53
|
+
if (!this.#controls.enabled) return;
|
|
53
54
|
const { moveSpeed, lookSpeed, moveStick, lookStick } = this.#options;
|
|
54
55
|
const input = this.gamepadInput;
|
|
55
56
|
const move = input.stick(moveStick.xAxis, moveStick.yAxis, moveStick.pipeline);
|
|
@@ -5,19 +5,19 @@
|
|
|
5
5
|
* Axial processing transforms each component independently. Radial processing
|
|
6
6
|
* transforms vector magnitude while preserving direction.
|
|
7
7
|
*/
|
|
8
|
-
type GamepadStickProcessingMode = "axial" | "radial";
|
|
8
|
+
export type GamepadStickProcessingMode = "axial" | "radial";
|
|
9
9
|
/**
|
|
10
10
|
* Built-in response curve applied to stick components or magnitude.
|
|
11
11
|
*/
|
|
12
|
-
type GamepadResponseCurve = "linear" | "quadratic" | "cubic";
|
|
12
|
+
export type GamepadResponseCurve = "linear" | "quadratic" | "cubic";
|
|
13
13
|
/**
|
|
14
14
|
* Stick component selection used by inversion processing.
|
|
15
15
|
*/
|
|
16
|
-
type GamepadStickInversionAxis = "x" | "y" | "both";
|
|
16
|
+
export type GamepadStickInversionAxis = "x" | "y" | "both";
|
|
17
17
|
/**
|
|
18
18
|
* Two-dimensional gamepad stick value.
|
|
19
19
|
*/
|
|
20
|
-
type GamepadStick = {
|
|
20
|
+
export type GamepadStick = {
|
|
21
21
|
/**
|
|
22
22
|
* Horizontal stick component.
|
|
23
23
|
*/
|
|
@@ -30,14 +30,14 @@ type GamepadStick = {
|
|
|
30
30
|
/**
|
|
31
31
|
* Pure custom transformation applied to a gamepad stick.
|
|
32
32
|
*/
|
|
33
|
-
type GamepadStickTransform = (value: Readonly<GamepadStick>) => GamepadStick;
|
|
33
|
+
export type GamepadStickTransform = (value: Readonly<GamepadStick>) => GamepadStick;
|
|
34
34
|
/**
|
|
35
35
|
* Pure, stateless transformation applied to a gamepad stick.
|
|
36
36
|
*
|
|
37
37
|
* Implementations must not mutate `value`. Stateful processing such as
|
|
38
38
|
* smoothing belongs in a separate lifecycle-aware abstraction.
|
|
39
39
|
*/
|
|
40
|
-
type GamepadStickProcessor = {
|
|
40
|
+
export type GamepadStickProcessor = {
|
|
41
41
|
/**
|
|
42
42
|
* Transforms one stick value.
|
|
43
43
|
*
|
|
@@ -49,7 +49,7 @@ type GamepadStickProcessor = {
|
|
|
49
49
|
/**
|
|
50
50
|
* Options for {@link gamepadStickPipeline}.
|
|
51
51
|
*/
|
|
52
|
-
type GamepadStickPipelineOptions = {
|
|
52
|
+
export type GamepadStickPipelineOptions = {
|
|
53
53
|
/**
|
|
54
54
|
* Default geometry for processing methods that support axial and radial modes.
|
|
55
55
|
* @default "axial"
|
|
@@ -59,7 +59,7 @@ type GamepadStickPipelineOptions = {
|
|
|
59
59
|
/**
|
|
60
60
|
* Options for {@link GamepadStickPipeline.deadzone}.
|
|
61
61
|
*/
|
|
62
|
-
type GamepadDeadzoneOptions = {
|
|
62
|
+
export type GamepadDeadzoneOptions = {
|
|
63
63
|
/**
|
|
64
64
|
* Geometry for this dead zone, overriding the pipeline default.
|
|
65
65
|
*/
|
|
@@ -73,7 +73,7 @@ type GamepadDeadzoneOptions = {
|
|
|
73
73
|
/**
|
|
74
74
|
* Options for {@link GamepadStickPipeline.responseCurve}.
|
|
75
75
|
*/
|
|
76
|
-
type GamepadResponseCurveOptions = {
|
|
76
|
+
export type GamepadResponseCurveOptions = {
|
|
77
77
|
/**
|
|
78
78
|
* Geometry for this response curve, overriding the pipeline default.
|
|
79
79
|
*/
|
|
@@ -85,7 +85,7 @@ type GamepadResponseCurveOptions = {
|
|
|
85
85
|
* Every configuration method returns a new frozen pipeline and leaves the
|
|
86
86
|
* current pipeline unchanged.
|
|
87
87
|
*/
|
|
88
|
-
type GamepadStickPipeline = GamepadStickProcessor & {
|
|
88
|
+
export type GamepadStickPipeline = GamepadStickProcessor & {
|
|
89
89
|
/**
|
|
90
90
|
* Appends an axial or radial dead zone.
|
|
91
91
|
*
|
|
@@ -129,7 +129,7 @@ type GamepadStickPipeline = GamepadStickProcessor & {
|
|
|
129
129
|
*
|
|
130
130
|
* Omitted fields inherit the action-specific defaults.
|
|
131
131
|
*/
|
|
132
|
-
type GamepadStickBindingOptions = {
|
|
132
|
+
export type GamepadStickBindingOptions = {
|
|
133
133
|
/**
|
|
134
134
|
* Axis index used as the horizontal component.
|
|
135
135
|
*/
|
|
@@ -146,7 +146,7 @@ type GamepadStickBindingOptions = {
|
|
|
146
146
|
/**
|
|
147
147
|
* Fully resolved binding used when reading a two-dimensional stick action.
|
|
148
148
|
*/
|
|
149
|
-
type GamepadStickBinding = Required<GamepadStickBindingOptions>;
|
|
149
|
+
export type GamepadStickBinding = Required<GamepadStickBindingOptions>;
|
|
150
150
|
/**
|
|
151
151
|
* Creates an immutable, fluent stick processing pipeline.
|
|
152
152
|
*
|
|
@@ -157,11 +157,11 @@ type GamepadStickBinding = Required<GamepadStickBindingOptions>;
|
|
|
157
157
|
* @param options - Optional pipeline defaults.
|
|
158
158
|
* @returns Frozen stick pipeline.
|
|
159
159
|
*/
|
|
160
|
-
declare const gamepadStickPipeline: (options?: GamepadStickPipelineOptions) => GamepadStickPipeline;
|
|
160
|
+
export declare const gamepadStickPipeline: (options?: GamepadStickPipelineOptions) => GamepadStickPipeline;
|
|
161
161
|
/**
|
|
162
162
|
* Historical stick processing used when no custom pipeline is supplied.
|
|
163
163
|
*/
|
|
164
|
-
declare const DEFAULT_GAMEPAD_STICK_PIPELINE: GamepadStickPipeline;
|
|
164
|
+
export declare const DEFAULT_GAMEPAD_STICK_PIPELINE: GamepadStickPipeline;
|
|
165
165
|
/**
|
|
166
166
|
* Resolves a partial stick binding over an action-specific default.
|
|
167
167
|
*
|
|
@@ -169,6 +169,5 @@ declare const DEFAULT_GAMEPAD_STICK_PIPELINE: GamepadStickPipeline;
|
|
|
169
169
|
* @param options - Optional binding overrides.
|
|
170
170
|
* @returns Complete resolved binding.
|
|
171
171
|
*/
|
|
172
|
-
declare const resolveGamepadStickBinding: (defaults: GamepadStickBinding, options?: GamepadStickBindingOptions) => GamepadStickBinding;
|
|
173
|
-
//#endregion
|
|
174
|
-
export { DEFAULT_GAMEPAD_STICK_PIPELINE, GamepadDeadzoneOptions, GamepadResponseCurve, GamepadResponseCurveOptions, GamepadStick, GamepadStickBinding, GamepadStickBindingOptions, GamepadStickInversionAxis, GamepadStickPipeline, GamepadStickPipelineOptions, GamepadStickProcessingMode, GamepadStickProcessor, GamepadStickTransform, gamepadStickPipeline, resolveGamepadStickBinding };
|
|
172
|
+
export declare const resolveGamepadStickBinding: (defaults: GamepadStickBinding, options?: GamepadStickBindingOptions) => GamepadStickBinding;
|
|
173
|
+
//#endregion
|
|
@@ -7,7 +7,7 @@ import { TrackballControls } from "three/addons/controls/TrackballControls.js";
|
|
|
7
7
|
*
|
|
8
8
|
* Every property has a sensible default, so you only need to pass the properties you want to override.
|
|
9
9
|
*/
|
|
10
|
-
type GamepadTrackballControlsOptions = GamepadControlsOptions & {
|
|
10
|
+
export type GamepadTrackballControlsOptions = GamepadControlsOptions & {
|
|
11
11
|
/**
|
|
12
12
|
* Multiplier on `TrackballControls.rotateSpeed` for rotation.
|
|
13
13
|
* @default 1.0
|
|
@@ -55,7 +55,7 @@ type GamepadTrackballControlsOptions = GamepadControlsOptions & {
|
|
|
55
55
|
* Call `update()` inside the render loop **before** `TrackballControls.update()`.
|
|
56
56
|
* Bindings and speed multipliers are configurable via {@link GamepadTrackballControlsOptions}.
|
|
57
57
|
*/
|
|
58
|
-
declare class GamepadTrackballControls extends GamepadControls {
|
|
58
|
+
export declare class GamepadTrackballControls extends GamepadControls {
|
|
59
59
|
#private;
|
|
60
60
|
/**
|
|
61
61
|
* @param controls - A Three.js `TrackballControls` instance.
|
|
@@ -70,5 +70,4 @@ declare class GamepadTrackballControls extends GamepadControls {
|
|
|
70
70
|
*/
|
|
71
71
|
protected onUpdate(deltaTime: number): void;
|
|
72
72
|
}
|
|
73
|
-
//#endregion
|
|
74
|
-
export { GamepadTrackballControls, GamepadTrackballControlsOptions };
|
|
73
|
+
//#endregion
|
|
@@ -50,6 +50,7 @@ var GamepadTrackballControls = class extends GamepadControls {
|
|
|
50
50
|
* @param deltaTime - Seconds since the last frame.
|
|
51
51
|
*/
|
|
52
52
|
onUpdate(deltaTime) {
|
|
53
|
+
if (!this.#controls.enabled) return;
|
|
53
54
|
const { rotateSpeed, panSpeed, zoomSpeed, rotateStick, panStick, buttonDeadzone, buttonZoomIn, buttonZoomOut } = this.#options;
|
|
54
55
|
this.#queueRotation(deltaTime, rotateSpeed, rotateStick);
|
|
55
56
|
this.#queuePan(deltaTime, panSpeed, panStick);
|
|
@@ -64,11 +65,7 @@ var GamepadTrackballControls = class extends GamepadControls {
|
|
|
64
65
|
*/
|
|
65
66
|
#queueRotation(deltaTime, rotateSpeed, rotateStick) {
|
|
66
67
|
const controls = this.#controls;
|
|
67
|
-
if (controls.noRotate)
|
|
68
|
-
controls._movePrev.copy(controls._moveCurr);
|
|
69
|
-
controls._lastAngle = 0;
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
68
|
+
if (controls.noRotate) return;
|
|
72
69
|
const rotate = this.gamepadInput.stick(rotateStick.xAxis, rotateStick.yAxis, rotateStick.pipeline);
|
|
73
70
|
if (rotate.x === 0 && rotate.y === 0) return;
|
|
74
71
|
const scale = rotateSpeed * deltaTime * Math.PI;
|
|
@@ -84,10 +81,7 @@ var GamepadTrackballControls = class extends GamepadControls {
|
|
|
84
81
|
*/
|
|
85
82
|
#queuePan(deltaTime, panSpeed, panStick) {
|
|
86
83
|
const controls = this.#controls;
|
|
87
|
-
if (controls.noPan)
|
|
88
|
-
controls._panStart.copy(controls._panEnd);
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
84
|
+
if (controls.noPan) return;
|
|
91
85
|
const pan = this.gamepadInput.stick(panStick.xAxis, panStick.yAxis, panStick.pipeline);
|
|
92
86
|
if (pan.x === 0 && pan.y === 0) return;
|
|
93
87
|
const scale = panSpeed * deltaTime * this.#getInputDampingFactor();
|
|
@@ -105,10 +99,7 @@ var GamepadTrackballControls = class extends GamepadControls {
|
|
|
105
99
|
*/
|
|
106
100
|
#queueZoom(deltaTime, zoomSpeed, buttonDeadzone, buttonZoomIn, buttonZoomOut) {
|
|
107
101
|
const controls = this.#controls;
|
|
108
|
-
if (controls.noZoom)
|
|
109
|
-
controls._zoomStart.copy(controls._zoomEnd);
|
|
110
|
-
return;
|
|
111
|
-
}
|
|
102
|
+
if (controls.noZoom) return;
|
|
112
103
|
const input = this.gamepadInput;
|
|
113
104
|
const triggerIn = input.buttonValue(buttonZoomIn);
|
|
114
105
|
const triggerOut = input.buttonValue(buttonZoomOut);
|
|
@@ -7,7 +7,7 @@ import { TransformControls } from "three/addons/controls/TransformControls.js";
|
|
|
7
7
|
*
|
|
8
8
|
* Every property has a sensible default, so you only need to pass the properties you want to override.
|
|
9
9
|
*/
|
|
10
|
-
type GamepadTransformControlsOptions = GamepadControlsOptions & {
|
|
10
|
+
export type GamepadTransformControlsOptions = GamepadControlsOptions & {
|
|
11
11
|
/**
|
|
12
12
|
* Screen-relative translation speed multiplier.
|
|
13
13
|
* @default 1.0
|
|
@@ -91,7 +91,7 @@ type GamepadTransformControlsOptions = GamepadControlsOptions & {
|
|
|
91
91
|
* stick starts a native-style transform interaction, and releasing it ends
|
|
92
92
|
* the interaction while keeping the active axis highlighted.
|
|
93
93
|
*/
|
|
94
|
-
declare class GamepadTransformControls extends GamepadControls {
|
|
94
|
+
export declare class GamepadTransformControls extends GamepadControls {
|
|
95
95
|
#private;
|
|
96
96
|
/**
|
|
97
97
|
* @param controls - A Three.js `TransformControls` instance.
|
|
@@ -107,7 +107,7 @@ declare class GamepadTransformControls extends GamepadControls {
|
|
|
107
107
|
*/
|
|
108
108
|
protected onUpdate(deltaTime: number): void;
|
|
109
109
|
/**
|
|
110
|
-
*
|
|
110
|
+
* Disables gamepad updates and ends only this wrapper's active transform.
|
|
111
111
|
*/
|
|
112
112
|
dispose(): void;
|
|
113
113
|
/**
|
|
@@ -117,5 +117,4 @@ declare class GamepadTransformControls extends GamepadControls {
|
|
|
117
117
|
*/
|
|
118
118
|
protected onGamepadDisconnected(gamepad: Gamepad): void;
|
|
119
119
|
}
|
|
120
|
-
//#endregion
|
|
121
|
-
export { GamepadTransformControls, GamepadTransformControlsOptions };
|
|
120
|
+
//#endregion
|