GIANT & MINI / STUDY / LEVEL 2 OF 5

Telling
each other.

Level 1 needs three things about every other player: are they a giant or a mini, where is their origin, and where are their head and hands. A headset already shares its head and hands through the course framework's clientState. But clientState sends nothing for a browser that is not in immersive mode, and I have one headset, so the second player is usually a laptop. Each client therefore also broadcasts a small object of its own, about sixteen times a second, into one global variable that only it writes. A counter in that object lets everyone else notice when the sender has gone quiet.

I sendwindow.giantMiniPose_<my id> = {mode, origin, head, hands, seq}
→
you readhead from clientState if I wear a headset, else from my message
⇒
seq stopsthree seconds later I am no longer drawn

I am the giant. Who is at my desk?

a simulated second client

Their messages over the last 12 seconds (now is at the right edge; the band is the 3 s a message keeps them alive)

What arrived

the last message

        

Packing, and noticing silence

players.js

Matrices are rounded to four decimals to keep the message small. seq goes up by one with every message. The freshness check remembers, for each player, the last seq it saw and when: a new number resets the clock, the same number for three seconds means they are gone.


      

Reading the others

players.js

The scene hands this function three small functions, so it can be tested without a network: what client id published, what clientState has for them, and whether they are still fresh.


      

Sending on a timer, not in the frame loop

giantMini.js

A laptop whose browser window is covered draws no frames at all. If sending lived in the frame loop, the laptop's giant would vanish for the mini the moment the laptop user looked away. A timer keeps running in the background, slowed to about one tick a second, which the three-second rule allows.


      
    

What you should be able to explain

  1. One writer per variable. Every client writes only giantMiniPose_<its own id>. Two clients can never overwrite each other, so no merging is needed.
  2. Why two sources for the head. clientState.head(id) exists only while that client is in immersive VR. It is used when it is there; the broadcast head covers laptops. The label in the picture tells you which one is in use.
  3. The stand-in. A laptop giant has no body in the room, and its camera is nearly two metres from the desk, which a mini would see as twenty-odd metres away. So it sends a made-up body standing at the desk edge, marked standIn. Minis draw it. Giants do not, because it stands exactly where a real giant stands and would look like their own body.
  4. Leaving. Closing the tab sends nothing. Nobody is told. The others notice only because seq stops changing.

Exercises: ① Set the sending to once a second. The mini on a laptop moves in jumps but stays. Why does the mini in a headset still move smoothly? ② Set it to every 5 s. For how long out of each 5 s is the player visible? ③ Close the tab and count: how long until the body disappears, and which line decides it?