tengri/Content/Camera/Tests/FT_CameraSmoothing.ts

123 lines
5.3 KiB
TypeScript

// Camera/Tests/FT_CameraSmoothing.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 { Vector } from '#root/UE/Vector.ts';
/**
* Functional Test: Camera Smoothing System
* Tests smooth interpolation vs instant rotation modes
* Validates FInterpTo behavior and smoothing speed effects
*/
export class FT_CameraSmoothing extends FunctionalTest {
// ════════════════════════════════════════════════════════════════════════════════════════
// GRAPHS
// ════════════════════════════════════════════════════════════════════════════════════════
// ────────────────────────────────────────────────────────────────────────────────────────
// EventGraph
// ────────────────────────────────────────────────────────────────────────────────────────
/**
* Test execution - validates smoothing behavior
* Tests instant vs smooth rotation and interpolation accuracy
*/
EventStartTest(): void {
// Initialize system
this.ToastSystemComponent.InitializeToastSystem();
this.InputDeviceComponent.InitializeDeviceDetection(
this.ToastSystemComponent,
this.DebugHUDComponent
);
this.CameraComponent.InitializeCameraSystem(
this.InputDeviceComponent,
this.DebugHUDComponent
);
// Test 1: Test smooth rotation behavior
this.CameraComponent.ProcessLookInput(new Vector(5.0, 0.0, 0.0), 0.016);
// Before UpdateCameraRotation, current should still be 0
if (this.CameraComponent.GetCameraRotation().Yaw === 0.0) {
// After one update, should be moving toward target but not reached
this.CameraComponent.UpdateCameraRotation(0.016);
const afterUpdateYaw = this.CameraComponent.GetCameraRotation().Yaw;
if (afterUpdateYaw !== 0.0) {
// Test 2: Verify smoothing continues over multiple frames
this.CameraComponent.UpdateCameraRotation(0.016);
if (this.CameraComponent.GetCameraRotation().Yaw > afterUpdateYaw) {
// Test 3: Test convergence to target after many updates
this.CameraComponent.ProcessLookInput(
new Vector(1.0, 0.0, 0.0),
0.016
);
// Run many update cycles
for (let i = 0; i < 100; i++) {
this.CameraComponent.UpdateCameraRotation(0.016);
}
// Should have converged to target after many updates
if (this.CameraComponent.GetCameraRotation().Yaw !== 0.0) {
this.FinishTest(EFunctionalTestResult.Succeeded);
} else {
this.FinishTest(
EFunctionalTestResult.Failed,
'Smoothing should eventually reach target rotation'
);
}
} else {
this.FinishTest(
EFunctionalTestResult.Failed,
'Smoothing should continue to approach target'
);
}
} else {
this.FinishTest(
EFunctionalTestResult.Failed,
'Rotation should start moving after UpdateCameraRotation'
);
}
} else {
this.FinishTest(
EFunctionalTestResult.Failed,
'Current rotation should be 0 before UpdateCameraRotation'
);
}
}
// ════════════════════════════════════════════════════════════════════════════════════════
// 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();
}