diff --git a/src/main.rs b/src/main.rs index 4f66950..e37b8c4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -376,6 +376,7 @@ fn main() { // The main rendering loop let first_frame_time = std::time::Instant::now(); let mut previous_frame_time = first_frame_time; + let mut door_slide = 0.0f32; loop { // Compute time passed since the previous frame and since the start of the program let now = std::time::Instant::now(); @@ -428,6 +429,7 @@ fn main() { // clamp pitch to avoid flipping let pitch_limit = std::f32::consts::FRAC_PI_2 - 0.01; cam_pitch = cam_pitch.clamp(-pitch_limit, pitch_limit); + door_slide = if keys.contains(&O) { 2.0 } else { 0.0 }; } // Handle mouse movement. delta contains the x and y movement of the mouse since last frame in pixels if let Ok(mut delta) = mouse_delta.lock() { @@ -474,6 +476,14 @@ fn main() { (&mut (*node.children[3]).rotation).x = elapsed * 10.0; } } + // Animate door sliding + { + let mut pin = root.as_mut(); + let node = unsafe { pin.get_unchecked_mut() }; + unsafe { + (*node.children[1]).position.z = door_slide; + } + } } // Draw scene via scene graph