feat: animate helicopter using simple_heading_animation with full 3-axis rotation

This commit is contained in:
2025-10-02 11:25:40 +02:00
parent 978c3c3936
commit 030df64fc1

View File

@@ -17,6 +17,8 @@ mod util;
mod mesh;
mod scene_graph;
use scene_graph::SceneNode;
mod toolbox;
use toolbox::simple_heading_animation;
use glutin::event::{
DeviceEvent,
@@ -438,6 +440,16 @@ fn main() {
let projection: glm::Mat4 =
glm::perspective(window_aspect_ratio, std::f32::consts::PI / 4.0, 1.0, 1000.0);
// Animate helicopter root via simple_heading_animation
let heading = simple_heading_animation(elapsed);
{
let mut hr_pin = heli_root.as_mut();
unsafe {
let node = hr_pin.get_unchecked_mut();
node.position = glm::vec3(heading.x, 0.0, heading.z);
node.rotation = glm::vec3(heading.roll, heading.pitch, heading.yaw);
}
}
// Update rotor rotations
{
let mut mr_pin = main_rotor_node.as_mut();