Skip to content

Commit

Permalink
poc: list poses in UI
Browse files Browse the repository at this point in the history
  • Loading branch information
jakmeier committed Oct 15, 2024
1 parent 11cc9b1 commit 5583c30
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 27 deletions.
50 changes: 25 additions & 25 deletions bouncy_frontend/src/lib/instructor/bouncy_instructor.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,31 +75,6 @@ export function dances(): (DanceWrapper)[];
export function danceBuilderFromDance(dance_id: string): DanceBuilder;
/**
*/
export enum DetectionState {
/**
* Neutral state, not detecting anything.
*/
Init = 1,
/**
* Dance is positioning themselves, detecting the idle position.
*/
Positioning = 2,
/**
* About to go over to live tracking, playing a countdown audio.
*/
CountDown = 3,
/**
* Tracking current movements.
*/
LiveTracking = 4,
/**
* No longer tracking but the results of the previous tracking are
* available.
*/
TrackingDone = 5,
}
/**
*/
export enum DetectionFailureReason {
/**
* The last match was too recent to have another match.
Expand Down Expand Up @@ -128,6 +103,31 @@ export enum DetectionFailureReason {
}
/**
*/
export enum DetectionState {
/**
* Neutral state, not detecting anything.
*/
Init = 1,
/**
* Dance is positioning themselves, detecting the idle position.
*/
Positioning = 2,
/**
* About to go over to live tracking, playing a countdown audio.
*/
CountDown = 3,
/**
* Tracking current movements.
*/
LiveTracking = 4,
/**
* No longer tracking but the results of the previous tracking are
* available.
*/
TrackingDone = 5,
}
/**
*/
export enum SkeletonField {
LeftThigh = 0,
LeftShin = 1,
Expand Down
5 changes: 3 additions & 2 deletions bouncy_frontend/src/routes/+layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
StepWrapper,
init,
PoseWrapper,
poses,
} from '$lib/instructor/bouncy_instructor';

// This is the root layout, hence it defines prerendering for the entire app default.
Expand Down Expand Up @@ -152,8 +153,8 @@ async function loadCollectionAssets() {
* @returns {PoseWrapper[]}
*/
function lookupPoses(filter) {
poses
return [];
// TODO: filtering
return poses();
}


Expand Down
35 changes: 35 additions & 0 deletions bouncy_frontend/src/routes/editor/+page.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,40 @@
<script>
import Svg from '$lib/components/avatar/Svg.svelte';
import SvgAvatar from '$lib/components/avatar/SvgAvatar.svelte';
import VideoToStep from '$lib/components/editor/VideoToStep.svelte';
import { LEFT_RIGHT_COLORING_LIGHT } from '$lib/constants';
/** @type {import('./$types').PageData} */
export let data;
const poses = data.lookupPoses();
</script>

<div class="poses">
{#each poses as pose}
<div class="pose">
<p>{pose.name('en')}</p>
<div class="avatar">
<Svg width={200} height={200} orderByZ>
<SvgAvatar
skeleton={pose.skeleton()}
width={200}
height={200}
style={LEFT_RIGHT_COLORING_LIGHT}
></SvgAvatar>
</Svg>
</div>
</div>
{/each}
</div>

<VideoToStep></VideoToStep>

<style>
.poses {
display: flex;
flex-wrap: wrap;
}
.pose {
max-width: 200px;
}
</style>
4 changes: 4 additions & 0 deletions bouncy_instructor/src/intern/content_collection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ pub(crate) struct ContentCollection {
}

impl ContentCollection {
pub(crate) fn poses(&self) -> &[PoseWrapper] {
&self.poses
}

pub(crate) fn step(&self, id: &str) -> Option<&StepWrapper> {
self.steps.iter().find(|step| step.definition().id == id)
}
Expand Down
6 changes: 6 additions & 0 deletions bouncy_instructor/src/public.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ pub use tracker::{DetectionFailureReason, DetectionResult, PoseHint, Tracker};
pub use ui_event::AudioEffect;

pub(crate) use parsing::{dance_file, pose_file, step_file};
use wrapper::pose_wrapper::PoseWrapper;

use super::STATE;
use crate::intern::lfsr;
Expand Down Expand Up @@ -92,6 +93,11 @@ pub fn parse_course_string(data: &str, lang: &str) -> Result<Course, JsValue> {
Ok(course)
}

#[wasm_bindgen]
pub fn poses() -> Vec<PoseWrapper> {
STATE.with_borrow(|state| state.global_db.poses().to_vec())
}

#[wasm_bindgen]
pub fn steps() -> Vec<StepWrapper> {
STATE.with_borrow(|state| state.global_db.steps().cloned().collect())
Expand Down

0 comments on commit 5583c30

Please sign in to comment.