Fix input X sign in RuntimeHost and add test for temporary look-on input in navigation controller

This commit is contained in:
2026-04-25 16:32:35 +02:00
parent e55db834ab
commit 5ce0f1f9cf
2 changed files with 47 additions and 1 deletions

View File

@@ -5733,7 +5733,7 @@ export class RuntimeHost {
let bestCandidate: RuntimeTargetCandidate | null = null;
let bestAlignment = TARGETING_SCREEN_SWITCH_MIN_ALIGNMENT;
let bestScreenDistance = 0;
const inputX = input.horizontal / inputLength;
const inputX = -input.horizontal / inputLength;
const inputY = input.vertical / inputLength;
for (const candidate of this.runtimeTargetCandidates) {

View File

@@ -167,6 +167,52 @@ describe("ThirdPersonNavigationController", () => {
controller.deactivate(context);
});
it("uses lock-on look input as a temporary offset that returns to center", () => {
const { context } = createRuntimeControllerContext();
const controller = new ThirdPersonNavigationController();
let axes = [0, 0, 1, 0];
const getGamepads = vi.fn<() => Gamepad[]>(() => [
createMockGamepad({
axes
})
]);
const handleRuntimeTargetLookInput = vi.fn(() => ({
activeTargetLocked: true,
switchedTarget: false,
switchInputHeld: false
}));
const targetContext = {
...context,
handleRuntimeTargetLookInput
};
Object.defineProperty(navigator, "getGamepads", {
configurable: true,
value: getGamepads
});
controller.activate(targetContext);
const initialCameraX = targetContext.camera.position.x;
controller.update(0.1);
const offsetCameraX = targetContext.camera.position.x;
axes = [0, 0, 0, 0];
controller.update(0.5);
const returnedCameraX = targetContext.camera.position.x;
expect(offsetCameraX).not.toBeCloseTo(initialCameraX);
expect(Math.abs(returnedCameraX - initialCameraX)).toBeLessThan(
Math.abs(offsetCameraX - initialCameraX)
);
expect(handleRuntimeTargetLookInput).toHaveBeenCalledWith({
horizontal: expect.any(Number),
vertical: 0
});
controller.deactivate(targetContext);
});
it("uses the authored movement template speed for third-person motion telemetry", () => {
const playerStart = createPlayerStartEntity({