#[derive(Default, Clone, Debug)]
pub struct Vector3f {
    pub x: f64,
    pub y: f64,
    pub z: f64,
}

impl Vector3f {
    pub fn from_vec(v: Vec<f64>) -> Self {
        Self {
            x: v.get(0).cloned().unwrap_or_default(),
            y: v.get(1).cloned().unwrap_or_default(),
            z: v.get(2).cloned().unwrap_or_default(),
        }
    }

    pub fn to_vec(&self) -> Vec<f64> {
        vec![self.x, self.y, self.z]
    }

    pub fn is_zero(&self) -> bool {
        self.x == 0.0 && self.y == 0.0 && self.z == 0.0
    }
}

#[derive(Default, Debug, Clone)]
pub struct InteractScale {
    pub x: f64,
    pub y: f64,
    pub z: f64,
    pub w: f64,
    pub r: f64,
}

impl InteractScale {
    pub fn from_str(s: &str) -> Option<Self> {
        let scale = s
            .split(',')
            .map(|c| c.parse::<f64>().unwrap_or_default())
            .collect::<Vec<_>>();

        if scale.len() == 5 {
            Some(Self {
                x: scale[0],
                y: scale[1],
                z: scale[2],
                w: scale[3],
                r: scale[4],
            })
        } else {
            None
        }
    }
}
