tengri/Content/Camera/Tests/FT_CameraRotation.ts

135 lines
5.8 KiB
TypeScript

// Camera/Tests/FT_CameraRotation.ts
import { AC_Camera } from '#root/Camera/Components/AC_Camera.ts';
import { AC_DebugHUD } from '#root/Debug/Components/AC_DebugHUD.ts';
import { AC_InputDevice } from '#root/Input/Components/AC_InputDevice.ts';
import { AC_ToastSystem } from '#root/Toasts/Components/AC_ToastSystem.ts';
import { EFunctionalTestResult } from '#root/UE/EFunctionalTestResult.ts';
import { FunctionalTest } from '#root/UE/FunctionalTest.ts';
import { MathLibrary } from '#root/UE/MathLibrary.ts';
import { Vector } from '#root/UE/Vector.ts';
/**
* Functional Test: Camera Rotation Calculations
* Tests pitch/yaw calculations and rotation accumulation
* Validates Mario Odyssey-style camera behavior
*/
export class FT_CameraRotation extends FunctionalTest {
// ════════════════════════════════════════════════════════════════════════════════════════
// GRAPHS
// ════════════════════════════════════════════════════════════════════════════════════════
// ────────────────────────────────────────────────────────────────────────────────────────
// EventGraph
// ────────────────────────────────────────────────────────────────────────────────────────
/**
* Test execution - validates rotation calculations
* Tests positive/negative input, accumulation, and axis behavior
*/
EventStartTest(): void {
// Initialize system
this.ToastSystemComponent.InitializeToastSystem();
this.InputDeviceComponent.InitializeDeviceDetection(
this.ToastSystemComponent,
this.DebugHUDComponent
);
this.CameraComponent.InitializeCameraSystem(
this.InputDeviceComponent,
this.DebugHUDComponent
);
// Test positive X input (should increase Yaw)
this.CameraComponent.ProcessLookInput(new Vector(1.0, 0.0, 0.0), 0.016);
this.CameraComponent.UpdateCameraRotation(0.016);
const { Pitch: rotation1Pitch, Yaw: rotation1Yaw } =
this.CameraComponent.GetCameraRotation();
if (rotation1Yaw > 0) {
// Test positive Y input (should decrease Pitch due to inversion)
this.CameraComponent.ProcessLookInput(new Vector(0.0, 1.0, 0.0), 0.016);
this.CameraComponent.UpdateCameraRotation(0.016);
const { Pitch: rotation2Pitch, Yaw: rotation2Yaw } =
this.CameraComponent.GetCameraRotation();
if (rotation2Pitch < rotation1Pitch) {
// Test accumulation - second positive X should increase Yaw further
this.CameraComponent.ProcessLookInput(new Vector(1.0, 0.0, 0.0), 0.016);
this.CameraComponent.UpdateCameraRotation(0.016);
const { Pitch: rotation3Pitch, Yaw: rotation3Yaw } =
this.CameraComponent.GetCameraRotation();
if (rotation3Yaw > rotation2Yaw) {
// Test zero input maintains rotation
this.CameraComponent.ProcessLookInput(
new Vector(0.0, 0.0, 0.0),
0.016
);
this.CameraComponent.UpdateCameraRotation(0.016);
const { Pitch: rotation4Pitch, Yaw: rotation4Yaw } =
this.CameraComponent.GetCameraRotation();
if (
MathLibrary.abs(rotation4Yaw - rotation3Yaw) <= 0.01 &&
MathLibrary.abs(rotation4Pitch - rotation3Pitch) <= 0.01
) {
this.FinishTest(EFunctionalTestResult.Succeeded);
} else {
this.FinishTest(
EFunctionalTestResult.Failed,
'Zero input should maintain current rotation'
);
}
} else {
this.FinishTest(
EFunctionalTestResult.Failed,
'Multiple inputs should accumulate rotation'
);
}
} else {
this.FinishTest(
EFunctionalTestResult.Failed,
'Positive Y input should decrease Pitch (inverted)'
);
}
} else {
this.FinishTest(
EFunctionalTestResult.Failed,
'Positive X input should increase Yaw'
);
}
}
// ════════════════════════════════════════════════════════════════════════════════════════
// VARIABLES
// ════════════════════════════════════════════════════════════════════════════════════════
/**
* Camera system component - component under test
* @category Components
*/
private CameraComponent = new AC_Camera();
/**
* Input device detection system - required for camera initialization
* @category Components
*/
private InputDeviceComponent = new AC_InputDevice();
/**
* Toast notification system - required for input device initialization
* @category Components
*/
private ToastSystemComponent = new AC_ToastSystem();
/**
* Debug HUD system - displays test status and parameters
* @category Components
*/
private DebugHUDComponent = new AC_DebugHUD();
}