Skip to main content

gltforge_unity/
unity_node_transform.rs

1/// The local transform of a Unity node, pre-converted to Unity's left-handed coordinate system.
2///
3/// Regardless of whether the source glTF node used a `matrix` or TRS properties,
4/// this always holds a decomposed TRS ready to hand to `UnityEngine.Transform`.
5pub struct UnityNodeTransform {
6    /// Local position — X negated relative to glTF.
7    pub position: [f32; 3],
8
9    /// Local rotation as a unit quaternion `[x, y, z, w]` — X and W negated relative to glTF.
10    pub rotation: [f32; 4],
11
12    /// Local scale — unchanged from glTF.
13    pub scale: [f32; 3],
14}
15
16pub const IDENTITY: UnityNodeTransform = UnityNodeTransform {
17    position: [0.0, 0.0, 0.0],
18    rotation: [0.0, 0.0, 0.0, 1.0],
19    scale: [1.0, 1.0, 1.0],
20};
21
22impl Default for UnityNodeTransform {
23    fn default() -> Self {
24        IDENTITY
25    }
26}