Refactor FirstPersonNavigationController to use local context and improve null safety in mouse movement handling

This commit is contained in:
2026-04-27 17:29:19 +02:00
parent 4c98e2d6a6
commit 7c39fc85f0

View File

@@ -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;