AI CHOREOGRAPHY / THE AI / LEVEL 5 OF 5

Typing
inside VR.

A web page's text box disappears when you enter immersive VR, and the course's own aiquery demo is typed in the browser console. So the coach has a keyboard made of scene objects: point the beam at a key and pull the trigger. Two problems had to be solved on the way: a button that was too hard to hit, and a prompt board that was blank only in the headset. This page runs the scene's coachKeyboard.js and coachPromptBoard.js.

the beamorigin and direction, from the controller
→
hit the keyboard planet = (z − o.z) / d.z, as for the garden panel
→
which rectangle?the key whose box contains the point
→
edit the textGO calls generateFromText, like the 2D panel

What the headset shows

the mouse is your beam · click = trigger

Seen from the player, slightly simplified: the keyboard floats 60 cm in front of you, the TYPE A PROMPT button and the board stand beside the coach, 1 m away. Dashed outlines are hit areas.

The board

drawn by the real coachPromptBoard.js

Texture units in the headset

The keyboard

coachKeyboard.js

keyAt meets the beam with the keyboard's plane and finds the key's rectangle; each key is widened by 5 mm for a shaky hand. nearBeam is the projection from beamSphere.js: the button 1 m away only needs the beam to pass within 12 cm, like START.


      

Wired into the trigger

coach.js

The keyboard sees every trigger press first. If the beam was on a key, the button, or the plate behind the keys, nothing else happens, so a near miss cannot start a recording on the coach behind. GO calls the same generateFromText as the 2D panel (level 3). While a recording or a round is running, the button stays visible and says why it cannot be used.


      

The board's texture unit

coachPromptBoard.js

      
    

What you should be able to explain

  1. A keyboard is just more scene objects. Cubes with labels, a hit test, and a text buffer. Nothing about it is special to text: the same pattern makes any panel of buttons in VR.
  2. Hit areas must suit the distance. A 6 cm button 1.4 m away is smaller than the wobble of a hand-held beam. The first version required the beam to land inside the box exactly, so presses seemed to do nothing. A radius test, like START's, fixed it.
  3. Texture units are shared. A GPU has a few numbered slots for textures. The framework puts each texture in a slot once and assumes it stays. In the headset, the renderer that draws the controller models fills the low slots every frame, so a board in slot 1 showed someone else's texture. Slot 11 is used by nobody else.
  4. Desktop is not VR. The board looked fine on the computer because no controller models are drawn there. Some bugs only appear in the headset, so test there.

Exercises: ① Switch the hit area to the first version and try to hit TYPE A PROMPT quickly. ② Type "swim", then GO: where does each status message come from? ③ Why can't the keyboard type Chinese, while the board can show it?