Enhance runtime targeting logic and add unit tests for target switching and loss conditions

This commit is contained in:
2026-04-25 15:33:19 +02:00
parent dd0f6868ac
commit 99dc1871d9
2 changed files with 220 additions and 0 deletions

View File

@@ -329,6 +329,9 @@ const DIALOGUE_PARTICIPANT_RESTORE_EPSILON_DEGREES = 0.5;
const TARGETING_LUX_FOLLOW_RATE = 8;
const TARGETING_LUX_BOB_RATE = 4.2;
const TARGETING_LUX_PULSE_RATE = 6.5;
const TARGETING_SIDE_SWITCH_YAW_THRESHOLD_RADIANS = (12 * Math.PI) / 180;
const TARGETING_CANCEL_YAW_THRESHOLD_RADIANS = (60 * Math.PI) / 180;
const TARGETING_MAX_ACTIVE_TARGET_DISTANCE = 35;
// Proposed-target camera nudging is intentionally disabled for now. Lux alone
// should communicate proposal without moving the gameplay camera.
// const PROPOSED_TARGET_CAMERA_ASSIST_STRENGTH = 0.28;
@@ -369,6 +372,13 @@ function lerpScalar(start: number, end: number, t: number) {
return start + (end - start) * t;
}
function distanceBetweenPoints(
left: { x: number; y: number; z: number },
right: { x: number; y: number; z: number }
) {
return Math.hypot(left.x - right.x, left.y - right.y, left.z - right.z);
}
function smoothStep01(value: number) {
const t = clampScalar(value, 0, 1);