using System;
using OmiLAXR.Types;
using UnityEngine;
namespace OmiLAXR.Components.Gaze
{
///
/// Transition between two gaze points / AOIs (a saccade), including timing and amplitude.
/// Modeled after FixationData for a consistent data shape.
///
public sealed class SaccadeData
{
public readonly Vector3 StartGazeCoordinates;
public readonly Vector3 EndGazeCoordinates;
public readonly Duration Duration;
public readonly DateTime? StartTime;
public readonly DateTime? EndTime;
public readonly float SaccadeAmplitudeDegrees;
public readonly float? PupilDiameterMillimeters; // Optional
public readonly GazeHit Hit;
/// Gaze hit at the beginning of the saccade (source AOI).
/// World-space gaze origin at saccade start.
/// World-space gaze point at saccade end.
/// Angular distance of the saccade in degrees.
/// Optional pupil diameter (context for arousal/engagement).
/// Start timestamp of the saccade.
/// End timestamp of the saccade.
public SaccadeData(
GazeHit hit,
Vector3 startGazeCoordinates,
Vector3 endGazeCoordinates,
float saccadeAmplitudeDegrees,
float? pupilDiameterMillimeters,
DateTime? startTime,
DateTime? endTime)
{
Hit = hit;
StartGazeCoordinates = startGazeCoordinates;
EndGazeCoordinates = endGazeCoordinates;
SaccadeAmplitudeDegrees = saccadeAmplitudeDegrees;
PupilDiameterMillimeters = pupilDiameterMillimeters;
StartTime = startTime;
EndTime = endTime;
if (startTime.HasValue && endTime.HasValue)
{
var ms = (int)(endTime.Value - startTime.Value).TotalMilliseconds;
Duration = Duration.FromMilliseconds(ms);
}
}
}
}