From 7c39fc85f0977aac705762b4bd4c947de8ac9209 Mon Sep 17 00:00:00 2001 From: Victor Giers Date: Mon, 27 Apr 2026 17:29:19 +0200 Subject: [PATCH] Refactor FirstPersonNavigationController to use local context and improve null safety in mouse movement handling --- .../first-person-navigation-controller.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/runtime-three/first-person-navigation-controller.ts b/src/runtime-three/first-person-navigation-controller.ts index 274c7ff1..0e3ab539 100644 --- a/src/runtime-three/first-person-navigation-controller.ts +++ b/src/runtime-three/first-person-navigation-controller.ts @@ -510,23 +510,25 @@ export class FirstPersonNavigationController implements NavigationController { }; private handleMouseMove = (event: MouseEvent) => { + const context = this.context; + if ( !this.pointerLocked || - this.context?.isInputSuspended() === true || - this.context?.isCameraDrivenExternally() === true + context?.isInputSuspended() === true || + context?.isCameraDrivenExternally() === true || + context === null ) { return; } const horizontalMouseLookSign = - this.context.getRuntimeScene().playerStart?.invertMouseCameraHorizontal === - true + context.getRuntimeScene().playerStart?.invertMouseCameraHorizontal === true ? -1 : 1; const horizontalMovement = event.movementX * horizontalMouseLookSign; const targetLookResult = - this.context?.handleRuntimeTargetLookInput?.({ + context.handleRuntimeTargetLookInput?.({ horizontal: horizontalMovement, vertical: -event.movementY }) ?? null;