Refactor FirstPersonNavigationController to use local context and improve null safety in mouse movement handling
This commit is contained in:
@@ -510,23 +510,25 @@ export class FirstPersonNavigationController implements NavigationController {
|
|||||||
};
|
};
|
||||||
|
|
||||||
private handleMouseMove = (event: MouseEvent) => {
|
private handleMouseMove = (event: MouseEvent) => {
|
||||||
|
const context = this.context;
|
||||||
|
|
||||||
if (
|
if (
|
||||||
!this.pointerLocked ||
|
!this.pointerLocked ||
|
||||||
this.context?.isInputSuspended() === true ||
|
context?.isInputSuspended() === true ||
|
||||||
this.context?.isCameraDrivenExternally() === true
|
context?.isCameraDrivenExternally() === true ||
|
||||||
|
context === null
|
||||||
) {
|
) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const horizontalMouseLookSign =
|
const horizontalMouseLookSign =
|
||||||
this.context.getRuntimeScene().playerStart?.invertMouseCameraHorizontal ===
|
context.getRuntimeScene().playerStart?.invertMouseCameraHorizontal === true
|
||||||
true
|
|
||||||
? -1
|
? -1
|
||||||
: 1;
|
: 1;
|
||||||
const horizontalMovement = event.movementX * horizontalMouseLookSign;
|
const horizontalMovement = event.movementX * horizontalMouseLookSign;
|
||||||
|
|
||||||
const targetLookResult =
|
const targetLookResult =
|
||||||
this.context?.handleRuntimeTargetLookInput?.({
|
context.handleRuntimeTargetLookInput?.({
|
||||||
horizontal: horizontalMovement,
|
horizontal: horizontalMovement,
|
||||||
vertical: -event.movementY
|
vertical: -event.movementY
|
||||||
}) ?? null;
|
}) ?? null;
|
||||||
|
|||||||
Reference in New Issue
Block a user