diff --git a/src/runtime-three/navigation-controller.ts b/src/runtime-three/navigation-controller.ts index 6aa52334..12aa33e4 100644 --- a/src/runtime-three/navigation-controller.ts +++ b/src/runtime-three/navigation-controller.ts @@ -166,6 +166,7 @@ export interface RuntimeControllerContext { input: RuntimeTargetLookInput ): RuntimeTargetLookInputResult; handleRuntimeTargetLookBoundaryReached?(): boolean; + handleThirdPersonPointerLockReleased?(): boolean; isCameraDrivenExternally(): boolean; getCameraYawRadians(): number; isInputSuspended(): boolean; diff --git a/src/runtime-three/runtime-host.ts b/src/runtime-three/runtime-host.ts index 5cf2291c..87957643 100644 --- a/src/runtime-three/runtime-host.ts +++ b/src/runtime-three/runtime-host.ts @@ -952,6 +952,28 @@ export class RuntimeHost { this.clearActiveRuntimeTarget(); return false; }, + handleThirdPersonPointerLockReleased: () => { + if ( + this.activeController !== this.thirdPersonController || + this.activeRuntimeTargetReference === null + ) { + return false; + } + + const clearTargetKeyboardBinding = + this.resolveRuntimePlayerInputBindings().keyboard.clearTarget; + + if ( + isPlayerStartMouseBindingCode(clearTargetKeyboardBinding) || + clearTargetKeyboardBinding !== "Escape" + ) { + return false; + } + + this.clearActiveRuntimeTarget(); + this.previousClearTargetInputActive = true; + return true; + }, isCameraDrivenExternally: () => this.resolveActiveRuntimeCameraRig() !== null || this.resolveDialogueAttentionNpc() !== null,