Skip to main content

gled_model/asset/animation/
mod.rs

1pub mod argument;
2pub mod config;
3
4use super::AssetTrait;
5use argument::{Argument, variables::VariablesCount};
6use serde::{Deserialize, Serialize};
7
8#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
9#[serde(default)]
10pub struct Animation {
11    pub shader_code: String,
12    pub arguments: Vec<Argument>,
13}
14
15impl Default for Animation {
16    fn default() -> Self {
17        Self {
18            shader_code: include_str!("black.wgsl").to_string(),
19            arguments: Default::default(),
20        }
21    }
22}
23
24impl Animation {
25    pub fn shader_code_for_getters(&self) -> String {
26        let mut count = VariablesCount::default();
27        let mut code = String::new();
28        for argument in self.arguments.iter() {
29            code += &argument.shader_code_for_getter(count);
30            count += argument.kind.variables().count();
31        }
32        code
33    }
34}
35
36impl AssetTrait for Animation {
37    const DIR_NAME: &'static str = "animations";
38    const NAME: &'static str = "Animation";
39    const SHOW_NAME_IF_SELECTED: bool = true;
40}