wasm-module: add get_angles_yaw_delta

This commit is contained in:
2026-03-07 14:38:19 -08:00
parent 3d8b5a0dfe
commit 890e5c1905
2 changed files with 18 additions and 0 deletions

View File

@@ -55,6 +55,8 @@ pub struct PlaybackState{
mouse_pos:v0::Vector2,
// EventType::Output
jump_count:u32,
angles:v0::Vector3,
angles_delta:glam::Vec3,
// EventType::Sound
// EventType::World
// EventType::Gravity
@@ -77,6 +79,8 @@ impl PlaybackState{
game_controls:v0::GameControls::empty(),
mouse_pos:v0::Vector2{x:0.0,y:0.0},
jump_count:0,
angles:v0::Vector3{x:0.0,y:0.0,z:0.0},
angles_delta:glam::Vec3::ZERO,
gravity:v0::Vector3{x:0.0,y:0.0,z:0.0},
runs:HashMap::new(),
style:v0::Style::Autohop,
@@ -91,9 +95,15 @@ impl PlaybackState{
self.runs.get(&mode)
}
fn push_output(&mut self,event:&v0::OutputEvent){
// Jumps may occur during a substep
if event.tick_info.contains(v0::TickInfo::Jump){
self.jump_count+=1;
}
// Game tick "end", i.e. not a sub-step
if event.tick_info.contains(v0::TickInfo::TickEnd){
self.angles_delta=glam::vec3(event.angles.x,event.angles.y,event.angles.z)-glam::vec3(self.angles.x,self.angles.y,self.angles.z);
self.angles=event.angles;
}
}
fn push_input(&mut self,event:&v0::InputEvent){
self.game_controls=event.game_controls;
@@ -276,4 +286,7 @@ impl PlaybackState{
pub const fn get_gravity(&self)->v0::Vector3{
self.gravity
}
pub const fn get_angles_delta(&self)->glam::Vec3{
self.angles_delta
}
}

View File

@@ -190,4 +190,9 @@ impl PlaybackHead{
let angles=self.head.get_angles(&bot.bot,time);
angles.to_array().to_vec()
}
/// Returns the camera angles yaw delta between the last game tick and the most recent game tick.
#[wasm_bindgen]
pub fn get_angles_yaw_delta(&self)->f32{
self.head.state().get_angles_delta().y
}
}