diff --git a/bouncy_frontend/src/app.css b/bouncy_frontend/src/app.css index cd51d39..8450e48 100644 --- a/bouncy_frontend/src/app.css +++ b/bouncy_frontend/src/app.css @@ -112,6 +112,15 @@ button.wide { max-width: 450px; } +button.full-width { + margin: 5px auto; + width: 100%; +} + +button.short { + height: 50px; +} + button.locked { background-color: var(--theme-neutral-gray); color: var(--theme-neutral-dark); diff --git a/bouncy_frontend/src/lib/components/editor/PoseInputForm.svelte b/bouncy_frontend/src/lib/components/editor/PoseInputForm.svelte index 50aa23a..8bf468d 100644 --- a/bouncy_frontend/src/lib/components/editor/PoseInputForm.svelte +++ b/bouncy_frontend/src/lib/components/editor/PoseInputForm.svelte @@ -1,5 +1,9 @@ -
+
{#each bodyParts as part, index} -
+
+ + -

- -

+ +

Dance Evaluation

diff --git a/bouncy_instructor/src/public/skeleton.rs b/bouncy_instructor/src/public/skeleton.rs index 39eb550..5a6f036 100644 --- a/bouncy_instructor/src/public/skeleton.rs +++ b/bouncy_instructor/src/public/skeleton.rs @@ -26,6 +26,14 @@ use wasm_bindgen::prelude::wasm_bindgen; #[wasm_bindgen(js_name = "Skeleton")] #[derive(Clone, Copy, Debug)] pub struct Skeleton { + // TODO: pub fields with wasm_bindgen are error-prone, as something like + // `skeleton.left.arm.angle = 5` on the JS side allocates a new side, and a + // new segment, before changing the angle on the segment, leaving the angle + // on the original skeleton untouched. + // I think I should ensure the JS side only does reads. But even that is not + // ideal, thinking of the performance hit of allocations on every read. + // I need a deep think about this to decide what's the best way out of this + // situation. pub left: Side, pub right: Side, pub hip: Segment, @@ -70,6 +78,21 @@ pub struct Cartesian2d { pub y: f32, } +#[wasm_bindgen] +#[derive(Clone, Copy, PartialEq)] +pub enum SkeletonField { + LeftThigh, + LeftShin, + LeftArm, + LeftForearm, + LeftFoot, + RightThigh, + RightShin, + RightArm, + RightForearm, + RightFoot, +} + #[wasm_bindgen] impl Skeleton { pub fn resting(sideway: bool) -> Self { @@ -107,6 +130,22 @@ impl Skeleton { pub fn debug_string(&self) -> String { format!("{self:?}") } + + #[wasm_bindgen(js_name = "setAngle")] + pub fn set_angle(&mut self, field: SkeletonField, value: f32) { + match field { + SkeletonField::LeftThigh => self.left.thigh.angle = value, + SkeletonField::LeftShin => self.left.shin.angle = value, + SkeletonField::LeftArm => self.left.arm.angle = value, + SkeletonField::LeftForearm => self.left.forearm.angle = value, + SkeletonField::LeftFoot => self.left.foot.angle = value, + SkeletonField::RightThigh => self.right.thigh.angle = value, + SkeletonField::RightShin => self.right.shin.angle = value, + SkeletonField::RightArm => self.right.arm.angle = value, + SkeletonField::RightForearm => self.right.forearm.angle = value, + SkeletonField::RightFoot => self.right.foot.angle = value, + } + } } impl Skeleton {