use crate::components::{CodeType, Snippet};
use crate::errors::Result;

use super::Transform;

pub struct Trackball {
    snippet: Snippet,
}

impl Trackball {
    pub fn new() -> Result<Self> {
        let snippets = Snippet::new(
            "trackball",
            CodeType::<&'static str>::Path("transform/trackball.glsl".into()),
            true,
            None,
        )?;

        Ok(Self { snippet: snippets })
    }
}

impl Transform for Trackball {
    fn snippet(&self) -> &Snippet {
        &self.snippet
    }

    fn chain(mut self, other: impl Transform) -> Self {
        let new_snippet = self.snippet.chain(other.snippet().to_owned());
        self.snippet = new_snippet;
        self
    }
}

mod test {
    use super::*;

    #[test]
    fn test_trackball() {
        let trackball = Trackball::new().unwrap();

        println!("{}", trackball.snippet);
    }
}
