From 0601b46f8c5b9e9e88aa6f1531b2f7d4099a773e Mon Sep 17 00:00:00 2001 From: Victor Giers Date: Sat, 25 Apr 2026 16:29:41 +0200 Subject: [PATCH] Refactor pointer input handling and update target look logic in ThirdPersonNavigationController --- .../third-person-navigation-controller.ts | 37 ++++++++++++++++--- 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/src/runtime-three/third-person-navigation-controller.ts b/src/runtime-three/third-person-navigation-controller.ts index 5bd545db..c2649351 100644 --- a/src/runtime-three/third-person-navigation-controller.ts +++ b/src/runtime-three/third-person-navigation-controller.ts @@ -668,12 +668,34 @@ export class ThirdPersonNavigationController implements NavigationController { this.lastPointerClientX = event.clientX; this.lastPointerClientY = event.clientY; - const targetLookConsumed = - this.context?.handleRuntimeTargetLookInput?.( - deltaX > 0 ? 1 : deltaX < 0 ? -1 : 0 - ) ?? false; + const targetLookResult = + this.context?.handleRuntimeTargetLookInput?.({ + horizontal: deltaX * POINTER_TARGET_LOOK_INPUT_SCALE, + vertical: -deltaY * POINTER_TARGET_LOOK_INPUT_SCALE + }) ?? null; - if (targetLookConsumed) { + if (targetLookResult?.activeTargetLocked === true) { + if ( + targetLookResult.switchedTarget !== true && + targetLookResult.switchInputHeld !== true + ) { + this.targetLookOffsetYawRadians = Math.max( + -TARGET_LOOK_OFFSET_YAW_LIMIT, + Math.min( + TARGET_LOOK_OFFSET_YAW_LIMIT, + this.targetLookOffsetYawRadians - + deltaX * TARGET_LOOK_OFFSET_POINTER_SENSITIVITY + ) + ); + this.targetLookOffsetPitchRadians = Math.max( + -TARGET_LOOK_OFFSET_PITCH_LIMIT, + Math.min( + TARGET_LOOK_OFFSET_PITCH_LIMIT, + this.targetLookOffsetPitchRadians + + deltaY * TARGET_LOOK_OFFSET_POINTER_SENSITIVITY + ) + ); + } return; } @@ -685,7 +707,10 @@ export class ThirdPersonNavigationController implements NavigationController { private handlePointerUp = () => { this.dragging = false; - this.context?.handleRuntimeTargetLookInput?.(0); + this.context?.handleRuntimeTargetLookInput?.({ + horizontal: 0, + vertical: 0 + }); }; private handleWheel = (event: WheelEvent) => {