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:
+27
-1
@@ -660,4 +660,30 @@ HUD 把两只眼的字幕并排显示。找这个 bug 花的时间比写检测
|
||||
(引导线在左手 → 右手捏合)现在得到 `hand:right` 并保持;另有「左手接管」「操作手不在
|
||||
面板上、另一只手在瞄 → 跟随瞄准手」「都没瞄 → 保持上次操作手」等 9 个用例全过。
|
||||
|
||||
> 真机复核需要戴上手(当时 `inputSources` 为空、没有手部源,无法现场触发)。
|
||||
**验证手法(重要,可复用)**:官方文档里只有 **Meta XR Simulator** 能模拟 aim/poke/pinch/grab,
|
||||
但它是**开发机上的桌面工具**,面向 Unity/Unreal 原生应用;`adb` 没有 XR 输入注入,CDP 也没有
|
||||
WebXR 域(`WebXR.enable` 不存在)。所以改成**从页面注入合成输入源**:
|
||||
|
||||
```js
|
||||
// 每个 targetRaySpace 都是本会话真实的 XRRigidTransform 偏移参考空间
|
||||
var off = (await session.requestReferenceSpace('local'))
|
||||
.getOffsetReferenceSpace(new XRRigidTransform({x:±0.2, y:-0.34, z:-1.0}));
|
||||
window.__FAKE = [ {handedness:'left', targetRayMode:'tracked-pointer', hand:{}, targetRaySpace:off,
|
||||
gamepad:{buttons:[{pressed:false,value:0}]}} , /* right */ ];
|
||||
Object.defineProperty(XRSession.prototype,'inputSources',{configurable:true,get:function(){return window.__FAKE;}});
|
||||
// 触发:window.__FAKE[1].gamepad.buttons[0].pressed = true → pollGamepads 上升沿 → pointerDown(src,frame,'gamepad')
|
||||
```
|
||||
|
||||
走的是**真实**的 `pointerDown(src, frame, …)`(和 `select` 同一条路径),测完把
|
||||
`inputSources` 描述符还原。实测(`immersive-vr` 活动会话):
|
||||
|
||||
```
|
||||
初始 pointer hand:left HIT 0.22,0.50 activeSrc hand:left
|
||||
右手按下 pointer hand:right HIT 0.78,0.50 activeSrc hand:right
|
||||
右手松开 pointer hand:right HIT 0.78,0.50 (粘滞保持)
|
||||
左手按下 pointer hand:left HIT 0.22,0.50 activeSrc hand:left
|
||||
右手没瞄面板时按下 pressAt "MISS (not aiming at the panel)" ← 没有偷用左手位置
|
||||
```
|
||||
|
||||
> `XRInputSourceEvent('select', …)` 构造器要求真实 `XRInputSource`,所以无法伪造 select 事件;
|
||||
> 但 select 与 gamepad 共用 `pointerDown`,已被上面覆盖。
|
||||
|
||||
+24
-2
@@ -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).
|
||||
|
||||
Vendored
+1
-1
@@ -5528,7 +5528,7 @@
|
||||
if (NS.Controls && NS.Controls.setPointer) {
|
||||
try { NS.Controls.setPointer(next); } catch (e) {}
|
||||
}
|
||||
S.stats.activeSrc = activeSrcKey || '(none)';
|
||||
S.stats.activeSrc = next.visible ? (activeSrcKey || '(none)') : '(none)';
|
||||
S.stats.pointer = next.source +
|
||||
(next.hit ? ' HIT ' + next.hit.nx.toFixed(2) + ',' + next.hit.ny.toFixed(2) : ' (no hit)');
|
||||
S.stats.inputSources = srcs.map(function (s) {
|
||||
|
||||
+1
-1
@@ -1132,7 +1132,7 @@
|
||||
if (NS.Controls && NS.Controls.setPointer) {
|
||||
try { NS.Controls.setPointer(next); } catch (e) {}
|
||||
}
|
||||
S.stats.activeSrc = activeSrcKey || '(none)';
|
||||
S.stats.activeSrc = next.visible ? (activeSrcKey || '(none)') : '(none)';
|
||||
S.stats.pointer = next.source +
|
||||
(next.hit ? ' HIT ' + next.hit.nx.toFixed(2) + ',' + next.hit.ny.toFixed(2) : ' (no hit)');
|
||||
S.stats.inputSources = srcs.map(function (s) {
|
||||
|
||||
Reference in New Issue
Block a user