Improve pointer lock release handling in runtime host and simplify pointer capture logic

This commit is contained in:
2026-04-27 18:20:14 +02:00
parent 6033089ad8
commit 2252a1dc4f
2 changed files with 16 additions and 4 deletions

View File

@@ -4899,9 +4899,7 @@ export function App({ store, initialStatusMessage }: AppProps) {
return;
}
const pointerCaptured =
activeNavigationMode === "firstPerson" &&
firstPersonTelemetry?.pointerLocked === true;
const pointerCaptured = firstPersonTelemetry?.pointerLocked === true;
if (pointerCaptured) {
return;
@@ -4916,7 +4914,7 @@ export function App({ store, initialStatusMessage }: AppProps) {
return () => {
window.removeEventListener("keydown", handleWindowKeyDown);
};
}, [activeNavigationMode, editorState.toolMode, firstPersonTelemetry]);
}, [editorState.toolMode, firstPersonTelemetry]);
const applyProjectName = () => {
const normalizedName = projectNameDraft.trim() || DEFAULT_PROJECT_NAME;

View File

@@ -969,8 +969,22 @@ export class RuntimeHost {
this.runtimeMessageHandler?.(message);
},
setPlayerControllerTelemetry: (telemetry) => {
const pointerLockReleasedFromThirdPerson =
this.currentPlayerControllerTelemetry?.pointerLocked === true &&
telemetry !== null &&
telemetry.pointerLocked === false &&
this.activeController === this.thirdPersonController &&
this.activeRuntimeTargetReference !== null &&
this.resolveRuntimePlayerInputBindings().keyboard.clearTarget ===
"Escape";
this.currentPlayerControllerTelemetry = telemetry;
this.currentPlayerAudioHooks = telemetry?.hooks.audio ?? null;
if (pointerLockReleasedFromThirdPerson) {
this.clearActiveRuntimeTarget();
}
this.playerControllerTelemetryHandler?.(telemetry);
}
};