dolly/drivers/
rotation.rs1use std::marker::PhantomData;
2
3use glam::Quat;
4
5use crate::{
6 driver::RigDriver, handedness::Handedness, rig::RigUpdateParams, transform::Transform,
7};
8
9#[derive(Debug)]
11pub struct Rotation {
12 pub rotation: mint::Quaternion<f32>,
13}
14
15impl Default for Rotation {
16 fn default() -> Self {
17 Self {
18 rotation: Quat::default().into(),
19 }
20 }
21}
22
23impl Rotation {
24 pub fn new<Q>(rotation: Q) -> Self
25 where
26 Q: Into<mint::Quaternion<f32>>,
27 {
28 let rotation = rotation.into();
29
30 Self { rotation }
31 }
32}
33
34impl<H: Handedness> RigDriver<H> for Rotation {
35 fn update(&mut self, params: RigUpdateParams<H>) -> Transform<H> {
36 Transform {
37 position: params.parent.position,
38 rotation: self.rotation,
39 phantom: PhantomData,
40 }
41 }
42}