easy_gltf/scene/model/
vertex.rs

1use cgmath::*;
2
3/// Represents the 3 vertices of a triangle.
4pub type Triangle = [Vertex; 3];
5
6/// Represents the 2 vertices of a line.
7pub type Line = [Vertex; 2];
8
9/// Contains a position, normal and texture coordinates vectors.
10#[repr(C)]
11#[derive(Clone, Copy, Debug, PartialEq)]
12pub struct Vertex {
13    /// Position
14    pub position: Vector3<f32>,
15    /// Normalized normal
16    pub normal: Vector3<f32>,
17    /// Tangent normal
18    /// The w component is the handedness of the tangent basis (can be -1 or 1)
19    pub tangent: Vector4<f32>,
20    /// Texture coordinates
21    pub tex_coords: Vector2<f32>,
22    /// Vertex color, known to be compatible with Blender 4 exported models
23    #[cfg(feature = "vertex-color")]
24    pub color: Vector4<u16>, // Blender exported glTF uses componentType 5123 (UNSIGNED_SHORT)
25}
26
27impl Default for Vertex {
28    fn default() -> Self {
29        Vertex {
30            position: Zero::zero(),
31            normal: Zero::zero(),
32            tangent: Zero::zero(),
33            tex_coords: Zero::zero(),
34            #[cfg(feature = "vertex-color")]
35            color: Vector4::new(1, 1, 1, 1),
36        }
37    }
38}