1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
use crate::define_animation;
use crate::core::Animation;

define_animation!(FromPoint, FromPointAnimation, point: Vertex = [0.0, 0.0, 0.0]);

impl Animation for FromPointAnimation
{
    fn set_progress(&mut self, progress: f32)
    {
        self.data.progress = progress
    }

    fn get_progress(&self) -> f32
    {
        self.data.progress
    }

    fn get_vertices(&self) -> Vec<Vertex>
    {
        let mut vertices = Vec::with_capacity(self.tessellation.vertices.len());
        let point = self.data.point;
        let progress = (self.data.func)(self.data.progress);
        for vertex in self.tessellation.vertices.iter()
        {
            let dx = vertex[0] - point[0];
            let dy = vertex[1] - point[1];
            let dz = vertex[2] - point[2];
            vertices.push([dx * progress, dy * progress, dz * progress])
        }
        vertices
    }

    fn get_indices(&self) -> Indices
    {
        self.tessellation.indices.clone()
    }

    fn get_colors(&self) -> Vec<Color>
    {
        self.tessellation.colors.clone()
    }
}