Add pauseTime input handling and context method for input suspension
This commit is contained in:
@@ -525,7 +525,10 @@ export class FirstPersonNavigationController implements NavigationController {
|
||||
};
|
||||
|
||||
private handleMouseMove = (event: MouseEvent) => {
|
||||
if (!this.pointerLocked) {
|
||||
if (
|
||||
!this.pointerLocked ||
|
||||
this.context?.isInputSuspended() === true
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -554,6 +557,7 @@ export class FirstPersonNavigationController implements NavigationController {
|
||||
private handlePointerDown = () => {
|
||||
if (
|
||||
this.context === null ||
|
||||
this.context.isInputSuspended() ||
|
||||
document.pointerLockElement === this.context.domElement
|
||||
) {
|
||||
return;
|
||||
|
||||
@@ -144,6 +144,7 @@ export interface RuntimeControllerContext {
|
||||
desiredCameraPosition: Vec3,
|
||||
radius: number
|
||||
): Vec3;
|
||||
isInputSuspended(): boolean;
|
||||
setRuntimeMessage(message: string | null): void;
|
||||
setPlayerControllerTelemetry(
|
||||
telemetry: PlayerControllerTelemetry | null
|
||||
|
||||
@@ -19,6 +19,7 @@ export interface PlayerStartActionInputState
|
||||
jump: number;
|
||||
sprint: number;
|
||||
crouch: number;
|
||||
pauseTime: number;
|
||||
}
|
||||
|
||||
export interface PlayerStartLookInputState {
|
||||
@@ -136,6 +137,8 @@ function readSingleGamepadActionBinding(
|
||||
return readGamepadButtonStrength(gamepad.buttons[2]);
|
||||
case "buttonNorth":
|
||||
return readGamepadButtonStrength(gamepad.buttons[3]);
|
||||
case "buttonMenu":
|
||||
return readGamepadButtonStrength(gamepad.buttons[9]);
|
||||
case "leftShoulder":
|
||||
return readGamepadButtonStrength(gamepad.buttons[4]);
|
||||
case "rightShoulder":
|
||||
@@ -288,13 +291,26 @@ export function resolvePlayerStartActionInputs(
|
||||
crouch: Math.max(
|
||||
pressedKeys.has(bindings.keyboard.crouch) ? 1 : 0,
|
||||
readGamepadActionBindingStrength(gamepads, bindings.gamepad.crouch)
|
||||
),
|
||||
pauseTime: Math.max(
|
||||
pressedKeys.has(bindings.keyboard.pauseTime) ? 1 : 0,
|
||||
readGamepadActionBindingStrength(gamepads, bindings.gamepad.pauseTime)
|
||||
)
|
||||
};
|
||||
}
|
||||
|
||||
export function resolvePlayerStartPauseInput(
|
||||
pressedKeys: ReadonlySet<string>,
|
||||
bindings: PlayerStartInputBindings,
|
||||
gamepads: ArrayLike<Gamepad | null> | null | undefined = getAvailableGamepads()
|
||||
): number {
|
||||
return resolvePlayerStartActionInputs(pressedKeys, bindings, gamepads)
|
||||
.pauseTime;
|
||||
}
|
||||
|
||||
export function resolvePlayerStartLookInput(
|
||||
bindings: PlayerStartInputBindings,
|
||||
gamepads: ArrayLike<Gamepad | null> | null | undefined = getAvailableGamepads()
|
||||
): PlayerStartLookInputState {
|
||||
return readGamepadCameraLook(gamepads, bindings.gamepad.cameraLook);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user