AI CHOREOGRAPHY / STUDY / LEVEL 2 OF 7
Placing the
targets.
A pose says "left hand up, 30 cm above the head". But whose left, and where is "up from the head" in the room? The game builds a small coordinate frame around you every frame: which way is forward (toward the coach), which way is right, and how tall you are. Then it turns the pose into two points in the room. Walk around the coach below and watch the targets follow you.
Top view of the room
f = your forward, r = your rightYou
the ghost player in coach.js- f (forward)
- r (right)
- aIsLeft
- size
- left target (x, y, z)
- right target (x, y, z)
What you see
the coach from your position; dashed rings are where your hands must goThe real code
coach.jsThe body frame (built once per frame from your head position), then the lines that pick each hand's pose and place it in the room. This page runs a copy of exactly these lines, because the scene itself needs a headset.
What you should be able to explain
- A local coordinate frame.
fpoints from your head to the coach with the height removed, so looking up or down does not tilt it.r = [−f.z, 0, f.x]isfturned 90° to the right. Together with "up" they form three axes around you. - toWorld. A pose value
[x, y, z]means "x metres along r, y up, z along f", starting at your head:head + r·x + up·y + f·z. This is a change of basis;toBodydoes the reverse with dot products. - Mirroring. You copy the coach like a mirror: the hand that appears on your left is the one your left hand copies, so its outward value is negated (
−1 ×). From behind, the coach's other hand appears on your left, andaIsLeftflips to swap them. - Scaling to the player.
size = standH ÷ 1.65, clamped between 0.6 and 1.2, so a tall player's targets are higher and wider, and a child's are closer.standHis the highest head position seen recently, which is why a squat does not shrink the targets.
Exercises: ① Walk in a circle around the coach. Do the targets always stay in front of you? ② Press "Walk behind the coach" and watch aIsLeft and the labels. Why is swapping the right thing to do? ③ Set your height to 1.2 m, then 2.0 m. Which target numbers change, and by how much?