hud-10 (rev2): verify the hand switch with injected synthetic XR input sources

Adds the on-device verification for ADDENDUM 11 and a diagnostics nit
(stats.activeSrc reports '(none)' while no candidate is picked).

There is no official way to fake hand input on a Quest for a WebXR page: Meta's
simulator is a desktop tool for Unity/Unreal native apps, adb has no XR input
injection and CDP has no WebXR domain (WebXR.enable does not exist). So the test
injects synthetic input sources whose targetRaySpace is a real XRRigidTransform
offset reference space of the live session, and drives a press through the real
gamepad path (rising edge on gamepad.buttons[0]) - the same pointerDown(src, frame,
...) the select event reaches. XRSession.prototype.inputSources is overridden for
the test and restored after.

Measured in a live immersive-vr session:
  initial            pointer hand:left  HIT 0.22,0.50
  right press        pointer hand:right HIT 0.78,0.50  activeSrc hand:right
  right release      pointer hand:right HIT 0.78,0.50  (sticky)
  left press         pointer hand:left  HIT 0.22,0.50
  right press, right hand off panel -> pressAt "MISS (not aiming at the panel)"
                                       (did NOT fall back to the left hand's position)
This commit is contained in:
2026-10-12 20:29:51 +08:00
parent 2459b999c6
commit 5eb679f6ca
4 changed files with 53 additions and 5 deletions
+24 -2
View File
@@ -1163,5 +1163,27 @@ passing the source from the `select` event. Consequences on device:
with the acting hand's ray, and the choice sticks afterwards (`state.stats.activeSrc`).
`pointerUp`/session end reset it.
`pickPointerCand` is pure and unit-tested against the built bundle; the reported case
(guide on the left, right hand pinches) now yields `hand:right` and stays there.
### Verification
There is no official way to fake hand input on a Quest for a WebXR page: Meta's
simulator (the only "simulate aim/poke/pinch/grab" tool in the docs) is a desktop
tool for Unity/Unreal native apps, `adb` has no input-injection for XR, and CDP has
no WebXR domain. So the live check injected **synthetic input sources** from the page:
each `targetRaySpace` is a real `XRRigidTransform` offset reference space of the live
session, and a press is driven through the real gamepad path (a rising edge on
`gamepad.buttons[0]`), which reaches the same `pointerDown(src, frame, …)` the
`select` event uses. `XRSession.prototype.inputSources` is overridden for the test and
restored afterwards.
Measured in a live `immersive-vr` session:
```
initial pointer hand:left HIT 0.22,0.50 activeSrc hand:left
right hand press pointer hand:right HIT 0.78,0.50 activeSrc hand:right lastActivate gamepad:right
right hand release pointer hand:right HIT 0.78,0.50 (sticky)
left hand press pointer hand:left HIT 0.22,0.50 activeSrc hand:left
right press, right hand NOT on panel
pressAt "MISS (not aiming at the panel)" <- did NOT use the left hand's position
```
`pickPointerCand` is also extracted from the built bundle and unit-tested (9 cases).