Fix input X sign in RuntimeHost and add test for temporary look-on input in navigation controller
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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({
|
||||
|
||||
Reference in New Issue
Block a user