From 53dceeb6aafc4a9b1701638ac110dc84785197e9 Mon Sep 17 00:00:00 2001 From: hut Date: Tue, 2 Apr 2024 01:06:33 +0200 Subject: [PATCH] add orbit command --- src/commands.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/commands.rs b/src/commands.rs index 7c31e2d..b91cd77 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -227,6 +227,20 @@ pub fn load_defs( } } } + ["orbit", radius_str, phase_str] => { + if let (Ok(r), Ok(phase)) = (radius_str.parse::(), phase_str.parse::()) { + let phase_deg = phase * PI64 * 2.0; + state.pos = DVec3::new( + state.pos.x + r * phase_deg.cos(), + state.pos.y, + state.pos.z + r * phase_deg.sin(), + ); + } + else { + error!("Can't parse float: {line}"); + continue; + } + } ["sphere", "yes"] => { state.is_sphere = true; }