Skip to main content

gltf_reader/
node.rs

1use alloc::borrow::Cow;
2use alloc::vec::Vec;
3use ownable::IntoOwned;
4use serde::Deserialize;
5
6use crate::camera::Camera;
7use crate::mesh::Mesh;
8use crate::skin::Skin;
9use crate::{Extensions, Extras, Idx};
10
11/// A node in the node hierarchy.
12#[derive(Debug, Clone, Deserialize, IntoOwned)]
13pub struct Node<'a> {
14    /// The user-defined name of this object.
15    #[serde(borrow)]
16    pub name: Option<Cow<'a, str>>,
17
18    /// The indices of this node's children.
19    #[serde(default)]
20    pub children: Vec<Idx<Node<'static>>>,
21
22    /// The index of the camera referenced by this node.
23    pub camera: Option<Idx<Camera<'static>>>,
24    /// The index of the mesh in this node.
25    pub mesh: Option<Idx<Mesh<'static>>>,
26    /// The index of the skin referenced by this node.
27    pub skin: Option<Idx<Skin<'static>>>,
28    /// The weights of the instantiated morph target.
29    pub weights: Option<Vec<f32>>,
30
31    /// A 4x4 transformation matrix stored in column-major order.
32    pub matrix: Option<[f32; 16]>,
33    /// The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar.
34    pub rotation: Option<[f32; 4]>,
35    /// The node’s non-uniform scale, given as the scaling factors along the x, y, and z axes.
36    pub scale: Option<[f32; 3]>,
37    /// The node's translation along the x, y, and z axes.
38    pub translation: Option<[f32; 3]>,
39
40    #[serde(borrow)]
41    pub extensions: Option<Extensions<'a>>,
42    #[serde(borrow)]
43    pub extras: Option<Extras<'a>>,
44}