AI CHOREOGRAPHY / STUDY / LEVEL 1 OF 7
Time becomes
a pose.
The coach never "decides" what to do next. Every frame the game reads the clock and computes which pose it is right now from one line of arithmetic. Because the answer depends only on the time, every headset that shares the time sees the same pose, with no animation data sent anywhere. This page runs the game's own coachRoutine.js.
The coach, facing you
handa is on your left, b on your rightA bigger hand means that hand reaches forward, toward you. The game stores each hand as [outward, up, forward] in metres, relative to the head.
Control time
paused- beat
- 0.60 s
- one pose lasts
- 1.20 s
- k (pose number)
- 0
- index in the list
- 0
- u (beats into pose)
- 0
- slide-in progress
- 0
Change one line yourself
runs only on this pageThis is the game's formula for the pose number. Change 2 * beat to 4 * beat, press run, and drag the time: each pose now lasts twice as long. Try Math.floor(time / beat) too. The real game is not affected.
Running the game's original formula.
The real code
coachRoutine.jsThe whole routine is data: two lists of 8 poses, and two one-line functions (highlighted).
Where the scene uses it
coach.jsEvery frame: the pose number k, how far into the pose we are (u), and the slide from the previous pose to this one.
What you should be able to explain
- beat is how many seconds one beat lasts: 0.6 s in Dance (100 beats per minute), 0.75 s in Fitness. Each pose lasts two beats.
k = Math.floor(time / (2 × beat)). Dividing by the length of one pose counts how many poses fit into the time so far;Math.floorrounds down to a whole number.- Wrapping with modulo. The list has 8 poses, so pose 8 is list entry 0 again.
((k % n) + n) % nalso works for negativek: the game asks for posek − 1to slide from, which is −1 at the very start. - Slide in, then hold.
ucounts beats into the current pose (0 to 2). During the first 0.7 beat the coach eases from the previous pose (easeis a smoothstep: slow, fast, slow), then holds still, which gives you time to match it.
Exercises: ① In Dance mode, stop the time at 2.5 s. Predict k, the list index and u before looking. ② Why can two players in different rooms see exactly the same pose without sending any pose data? ③ Change the formula so each pose lasts one beat. Is the dance still followable?