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.

clockseconds, shared by every player
→
k = poseIndex(clock, beat)which pose number, counting from the start of time
→
poseAt(poses, k)wraps around the 8-pose list
→
slide in, then holdthe first 0.7 beat eases from the previous pose

The coach, facing you

hand a is on your left, b on your right

A 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 page

This 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.js

The whole routine is data: two lists of 8 poses, and two one-line functions (highlighted).


      

Where the scene uses it

coach.js

Every 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

  1. 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.
  2. k = Math.floor(time / (2 × beat)). Dividing by the length of one pose counts how many poses fit into the time so far; Math.floor rounds down to a whole number.
  3. Wrapping with modulo. The list has 8 poses, so pose 8 is list entry 0 again. ((k % n) + n) % n also works for negative k: the game asks for pose k − 1 to slide from, which is −1 at the very start.
  4. Slide in, then hold. u counts beats into the current pose (0 to 2). During the first 0.7 beat the coach eases from the previous pose (ease is 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?