From fa184670887f3d3e0c791347d76093e0f74c4468 Mon Sep 17 00:00:00 2001 From: Victor Giers Date: Sat, 25 Apr 2026 17:09:26 +0200 Subject: [PATCH] Add unit test for target direction initialization in ThirdPersonNavigationController --- ...third-person-navigation-controller.test.ts | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/tests/unit/third-person-navigation-controller.test.ts b/tests/unit/third-person-navigation-controller.test.ts index 1d71e038..66e04d20 100644 --- a/tests/unit/third-person-navigation-controller.test.ts +++ b/tests/unit/third-person-navigation-controller.test.ts @@ -241,6 +241,33 @@ describe("ThirdPersonNavigationController", () => { controller.deactivate(targetContext); }); + it("uses target direction as the lock-on base yaw immediately", () => { + const { context } = createRuntimeControllerContext(); + const controller = new ThirdPersonNavigationController(); + const targetContext = { + ...context, + resolveThirdPersonTargetAssist: () => ({ + targetPosition: { + x: 5, + y: 1, + z: 0 + }, + strength: 1 + }) + }; + + controller.activate(targetContext); + + expect(Math.abs(targetContext.camera.position.x)).toBeLessThan(0.001); + + controller.update(0); + + expect(targetContext.camera.position.x).toBeLessThan(-3); + expect(Math.abs(targetContext.camera.position.z)).toBeLessThan(1); + + controller.deactivate(targetContext); + }); + it("fades vertical target assist when camera collision pushes the camera close", () => { const { context } = createRuntimeControllerContext(); const controller = new ThirdPersonNavigationController();