Refactor pointer capture logic and remove third-person pointer lock target clearing
This commit is contained in:
@@ -4899,7 +4899,9 @@ export function App({ store, initialStatusMessage }: AppProps) {
|
||||
return;
|
||||
}
|
||||
|
||||
const pointerCaptured = firstPersonTelemetry?.pointerLocked === true;
|
||||
const pointerCaptured =
|
||||
activeNavigationMode === "firstPerson" &&
|
||||
firstPersonTelemetry?.pointerLocked === true;
|
||||
|
||||
if (pointerCaptured) {
|
||||
return;
|
||||
@@ -4914,7 +4916,7 @@ export function App({ store, initialStatusMessage }: AppProps) {
|
||||
return () => {
|
||||
window.removeEventListener("keydown", handleWindowKeyDown);
|
||||
};
|
||||
}, [editorState.toolMode, firstPersonTelemetry]);
|
||||
}, [activeNavigationMode, editorState.toolMode, firstPersonTelemetry]);
|
||||
|
||||
const applyProjectName = () => {
|
||||
const normalizedName = projectNameDraft.trim() || DEFAULT_PROJECT_NAME;
|
||||
|
||||
@@ -969,22 +969,8 @@ 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);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -3889,58 +3889,6 @@ describe("RuntimeHost", () => {
|
||||
host.dispose();
|
||||
});
|
||||
|
||||
it("clears the active target when third-person pointer lock drops on Escape", () => {
|
||||
const host = new RuntimeHost({
|
||||
enableRendering: false
|
||||
});
|
||||
const hostInternals = host as unknown as {
|
||||
runtimeScene: unknown;
|
||||
activeController: unknown;
|
||||
thirdPersonController: unknown;
|
||||
activeRuntimeTargetReference: {
|
||||
kind: "npc" | "interactable";
|
||||
entityId: string;
|
||||
} | null;
|
||||
controllerContext: {
|
||||
setPlayerControllerTelemetry(telemetry: unknown): void;
|
||||
};
|
||||
};
|
||||
|
||||
hostInternals.runtimeScene = {
|
||||
playerInputBindings: {
|
||||
keyboard: {
|
||||
clearTarget: "Escape"
|
||||
}
|
||||
},
|
||||
entities: {
|
||||
cameraRigs: [],
|
||||
interactables: [],
|
||||
npcs: []
|
||||
}
|
||||
} as never;
|
||||
hostInternals.activeController = hostInternals.thirdPersonController;
|
||||
hostInternals.activeRuntimeTargetReference = {
|
||||
kind: "npc",
|
||||
entityId: "npc-active"
|
||||
};
|
||||
|
||||
hostInternals.controllerContext.setPlayerControllerTelemetry({
|
||||
pointerLocked: true,
|
||||
hooks: {
|
||||
audio: null
|
||||
}
|
||||
});
|
||||
hostInternals.controllerContext.setPlayerControllerTelemetry({
|
||||
pointerLocked: false,
|
||||
hooks: {
|
||||
audio: null
|
||||
}
|
||||
});
|
||||
|
||||
expect(hostInternals.activeRuntimeTargetReference).toBeNull();
|
||||
host.dispose();
|
||||
});
|
||||
|
||||
it("switches an active target once from directional screen-space look input", () => {
|
||||
const host = new RuntimeHost({
|
||||
enableRendering: false
|
||||
|
||||
Reference in New Issue
Block a user