ak_vis/visuals/
atom_visual.rs

1use crate::AtomMaterial;
2use bevy::color::Color;
3
4#[derive(Clone, Copy, Debug, PartialEq, Eq)]
5pub struct AtomIdentity {
6    pub atom_index: usize,
7    pub image_offset: [i32; 3],
8}
9
10pub struct AtomVisual {
11    pub atom_identity: AtomIdentity,
12    pub position: [f32; 3],
13    pub color: Color,
14    pub material: AtomMaterial,
15    pub radius: f32,
16}
17
18impl AtomVisual {
19    pub fn new(atom_index: usize, position: [f64; 3], color: Color, radius: f32) -> Self {
20        Self::new_with_identity(
21            AtomIdentity {
22                atom_index,
23                image_offset: [0, 0, 0],
24            },
25            position,
26            color,
27            radius,
28        )
29    }
30
31    pub fn new_with_identity(
32        atom_identity: AtomIdentity,
33        position: [f64; 3],
34        color: Color,
35        radius: f32,
36    ) -> Self {
37        let position_f32: [f32; 3] = [position[0] as f32, position[1] as f32, position[2] as f32];
38        AtomVisual {
39            atom_identity,
40            position: position_f32,
41            color,
42            material: AtomMaterial::default(),
43            radius,
44        }
45    }
46
47    pub fn atom_index(&self) -> usize {
48        self.atom_identity.atom_index
49    }
50
51    pub fn x(&self) -> f32 {
52        self.position[0]
53    }
54
55    pub fn y(&self) -> f32 {
56        self.position[1]
57    }
58
59    pub fn z(&self) -> f32 {
60        self.position[2]
61    }
62}