hud-10 (rev3): cursor on the guide line; a press is attributed to the acting hand
ADDENDUM 11b, both reported against ADDENDUM 11. 1. The cursor drifted off the guide line, worse near the panel edge. panelHit() clamps an off-panel intersection to the border and flags it via inBounds, but updatePointer() published that clamped nx,ny as pointer.hit, so the ring was drawn on the border while the beam ended at the true (off-panel) intersection. pointer.hit is now published only when inBounds; distance is still published so an edge-aimed beam reaches the plane (beamLength no longer requires p.hit). Near-misses still summon the bar, but no longer press. 2. A right-hand press could still act at the left hand's position, for three separate reasons: the activate cooldown was global (a gamepad edge from one hand swallowed the other hand's select - now per input source); a missing ray fell back to another hand (with a preferKey the acting source now owns the shot and a missing candidate MISSes); and a null frame skipped re-attribution entirely (now falls back to S.lastFrame and MISSes if the acting source yields no pointer). New diagnostics: stats.pressSrc, stats.pressPtr. Verified with injected synthetic input sources: both on panel, right press pressSrc hand:right pressAt 0.78,0.50 seek 79.5% left press then right 100ms pressSrc hand:right pressAt 0.78,0.50 (not swallowed) both off panel state.pointer.hit = null (no clamped cursor) off panel, right press pressPtr "hand:right nohit" MISS (no hit on the panel)
This commit is contained in:
+45
-2
@@ -5,7 +5,7 @@
|
||||
> + 7 唤出门限/前面板精简 + 7b 锁按钮与「锁定」面板模式 + 8/8b 画面搬迁(实时拖动)
|
||||
> + 9 rAF 代理修复(VR 内字幕不再冻结)+ 普通/双目字幕自动识别
|
||||
> + 10 原生(SRT 等)字幕由插件自绘到 HUD;布局覆盖不再持久化
|
||||
> + 11 指针跟随正在操作/瞄准的那只手)
|
||||
> + 11 指针跟随正在操作/瞄准的那只手;11b 光标落在引导线上 + 点击归属操作手)
|
||||
>
|
||||
> ⚠️ **Jellyfin web 注册了 service worker**(`serviceworker.js`,scope `/web/`),会把
|
||||
> `index.html` 缓存在 SW cache 里。重新部署后如果只是普通刷新,浏览器可能仍用旧的
|
||||
@@ -417,7 +417,7 @@ subMode / subCanvasSize / subCrop / subTex / subOpacity / subPlacement
|
||||
subLockAngle / subAngleDeg / subTextDeg / subYOverZ ← ADDENDUM 6
|
||||
subLayout / subDual / subEyeW / subCopyND / subCenterInk ← ADDENDUM 9
|
||||
subSource / subNativeText ← ADDENDUM 10
|
||||
activeSrc ← ADDENDUM 11
|
||||
activeSrc / pressSrc / pressPtr ← ADDENDUM 11
|
||||
ctlSubsOn / ctlSubDist / ctlSubAngle / ctlSubLock ← 控制条实际画出的值
|
||||
ctlLock / ctlMode / ctlHold / pressAt / lastActivate ← ADDENDUM 7/7b 锁、面板保持与唤出判定
|
||||
videoYaw / videoPitch / videoRotMode / videoTransformWritable ← ADDENDUM 8/8b 画面搬迁
|
||||
@@ -687,3 +687,46 @@ Object.defineProperty(XRSession.prototype,'inputSources',{configurable:true,get:
|
||||
|
||||
> `XRInputSourceEvent('select', …)` 构造器要求真实 `XRInputSource`,所以无法伪造 select 事件;
|
||||
> 但 select 与 gamepad 共用 `pointerDown`,已被上面覆盖。
|
||||
|
||||
---
|
||||
|
||||
## 16. ADDENDUM 11b — 光标落在引导线上;点击归属操作那只手(已部署 `3d3b5f`)
|
||||
|
||||
针对 ADDENDUM 11 实测后反馈的两点。
|
||||
|
||||
### 16.1 光标偏离引导线(越靠边缘越明显)
|
||||
|
||||
`panelHit()` 会把**打在面板外**的交点**夹取到边框**,并用 `inBounds` 标出来;但
|
||||
`updatePointer()` 把夹取后的 `nx,ny` 当 `pointer.hit` 发布了。于是光标环画在**面板边框**上,
|
||||
而光束末端在**真实交点**(面板之外)——射线越偏离面板,两者差得越远,与反馈完全一致。
|
||||
|
||||
现在 **只有 `hit.inBounds` 才发布 `pointer.hit`**:光标只在射线真正打在面板上时出现,必然落在
|
||||
光束上。只要射线与面板平面相交就仍然发布 `distance`,且 `beamLength()` 不再要求 `p.hit`,
|
||||
所以瞄边缘时引导线仍指到面板平面。擦边仍能**唤出**控制条(宽判 `panelHit(...,0.5,0.9)` 未动),
|
||||
但擦边不再能**按下**。
|
||||
|
||||
### 16.2 右手点击仍会落在左手位置
|
||||
|
||||
三个独立原因,全部修掉:
|
||||
|
||||
- **冷却是全局的**:`ACTIVATE_COOLDOWN_MS`(250ms) 会压掉 250ms 内的任意一次按下,所以一只手的
|
||||
gamepad 抖动会**吃掉另一只手的 `select`**,动作随即用了第一只手的位置。现改为**按输入源分别
|
||||
计时**(`lastActivateByKey`):同一次捏合产生的 gamepad+select 仍会去重,但绝不会吃掉另一只手。
|
||||
- **取不到射线时静默回退到另一只手**:现在只要给了 `preferKey`(正在操作的那个源),它就
|
||||
**独占这次射击**;若它不在候选里,`pick` 返回 `null`,这次按下算 **MISS**。
|
||||
- **`frame` 为空时根本没重新归属**:`pointerDown()` 原来写 `if (frame) updatePointer(...)`,
|
||||
frame 为空时就沿用上一帧的指针(可能是另一只手)。现在回退到 `S.lastFrame`,且若仍算不出指针,
|
||||
直接记 `MISS (acting source has no ray)`。
|
||||
|
||||
新增诊断:`stats.pressSrc`(本次按下归属的源)、`stats.pressPtr`(`hand:right HIT` /
|
||||
`hand:right nohit` / `(no ray)`)。
|
||||
|
||||
### 16.3 实测(注入合成输入源,活动会话)
|
||||
|
||||
```
|
||||
都在面板上,右手按下 pressSrc hand:right pressPtr "hand:right HIT" pressAt 0.78,0.50 seek 79.5%
|
||||
左手按下后 100ms 右手按下 pressSrc hand:right pressAt 0.78,0.50 (右手没被吃掉)
|
||||
两只手都在面板外 state.pointer.hit = null (不再夹取光标)
|
||||
面板外右手按下 pressSrc hand:right pressPtr "hand:right nohit"
|
||||
pressAt "MISS (no hit on the panel)" (没有用左手位置)
|
||||
```
|
||||
|
||||
@@ -1187,3 +1187,52 @@ right press, right hand NOT on panel
|
||||
```
|
||||
|
||||
`pickPointerCand` is also extracted from the built bundle and unit-tested (9 cases).
|
||||
|
||||
# ADDENDUM 11b — the cursor sits ON the guide line; a press is attributed to the acting hand
|
||||
|
||||
Two follow-ups reported against ADDENDUM 11.
|
||||
|
||||
## 1. The cursor drifted off the guide line, worse near the panel edge
|
||||
|
||||
`panelHit()` clamps an intersection that misses the panel to the border and returns
|
||||
`inBounds` to say so, but `updatePointer()` published that clamped `nx,ny` as
|
||||
`pointer.hit`. The cursor ring was therefore drawn **on the panel border** while the
|
||||
beam ended at the true intersection, which is off the panel: the further off the panel
|
||||
the ray pointed, the larger the gap — exactly as reported.
|
||||
|
||||
`pointer.hit` is now published **only when `hit.inBounds`** the cursor exists only where
|
||||
the ray really meets the panel, so it always lies on the beam. `distance` is still
|
||||
published whenever the ray meets the panel plane, and `beamLength()` no longer requires
|
||||
`p.hit`, so an edge-aimed beam still reaches the plane. Near-misses keep summoning the
|
||||
bar (the wide `panelHit(...,0.5,0.9)` check is unchanged), but they no longer press.
|
||||
|
||||
## 2. A right-hand press could still act at the left hand's position
|
||||
|
||||
Three separate causes, all fixed:
|
||||
|
||||
- **The cooldown was global.** `ACTIVATE_COOLDOWN_MS` (250 ms) suppressed *any* press
|
||||
within 250 ms of the previous one, so a stray gamepad edge from one hand swallowed the
|
||||
other hand's `select` — and the action then used the first hand's pointer. The cooldown
|
||||
is now **per input source** (`lastActivateByKey`), so it still de-duplicates the
|
||||
gamepad/`select` pair of one pinch but never eats the other hand's press.
|
||||
- **A missing ray silently fell back to the other hand.** If the acting source's ray
|
||||
could not be resolved, `pickPointerCand` skipped to the next candidate. Now, when a
|
||||
`preferKey` (the acting source) is supplied, it **owns the shot**: if it is not among
|
||||
the candidates the pick is `null` and the press MISSES.
|
||||
- **A null frame meant no re-attribution at all.** `pointerDown()` did
|
||||
`if (frame) updatePointer(...)`, so with no frame the per-frame pointer (possibly the
|
||||
other hand) was used silently. It now falls back to `S.lastFrame`, and when the acting
|
||||
source still yields no pointer it reports `MISS (acting source has no ray)`.
|
||||
|
||||
New diagnostics: `stats.pressSrc` (the source key the press was attributed to) and
|
||||
`stats.pressPtr` (`hand:right HIT` / `hand:right nohit` / `(no ray)`).
|
||||
|
||||
## Verification (injected synthetic input sources, live session)
|
||||
|
||||
```
|
||||
both hands on panel, right press pressSrc hand:right pressPtr "hand:right HIT" pressAt 0.78,0.50 seek 79.5%
|
||||
left press then right 100 ms later pressSrc hand:right pressAt 0.78,0.50 (right not swallowed)
|
||||
both hands off panel state.pointer.hit = null (no clamped cursor)
|
||||
both off panel, right press pressSrc hand:right pressPtr "hand:right nohit"
|
||||
pressAt "MISS (no hit on the panel)" (did NOT use the left hand)
|
||||
```
|
||||
|
||||
Vendored
+41
-6
@@ -3271,8 +3271,11 @@
|
||||
return d > 0 ? d : null;
|
||||
}
|
||||
|
||||
// ADDENDUM 11b: the beam reaches the panel plane whenever the ray meets it,
|
||||
// even when the intersection is off the panel (there is simply no cursor then).
|
||||
// Previously it fell back to a fixed length without a hit, so an edge-aimed
|
||||
// beam stopped short of the plane while the cursor was clamped to the border.
|
||||
function beamLength(p) {
|
||||
if (!p.hit) return BEAM_L_DEFAULT;
|
||||
var d = num(p.distance);
|
||||
if (d == null) d = panelDistance(p);
|
||||
if (d == null || !(d > BEAM_L_MIN)) return BEAM_L_DEFAULT;
|
||||
@@ -5247,6 +5250,7 @@
|
||||
panelPose = null;
|
||||
pointer = { visible: false, beam: false, source: 'none', origin: { x: 0, y: 0, z: 0 }, dir: { x: 0, y: 0, z: -1 }, hit: null };
|
||||
activeSrcKey = null; // ADDENDUM 11: fresh hand choice every session
|
||||
lastActivateByKey = {};
|
||||
S.pointer = null;
|
||||
S.session = null;
|
||||
S.refSpace = null;
|
||||
@@ -5448,11 +5452,14 @@
|
||||
// cands [{ key, onPanel, ... }] in runtime order
|
||||
// preferKey the source that is acting right now (select / gamepad press)
|
||||
// activeKey the source that acted last
|
||||
// Order: acting -> last-active-while-on-panel -> any-on-panel -> last-active -> first.
|
||||
// When `preferKey` is given the acting source OWNS the shot: if it is not among
|
||||
// the candidates (no resolvable ray) we return null so the press MISSES rather
|
||||
// than silently reusing another hand's pointer. Otherwise:
|
||||
// last-active-while-on-panel -> any-on-panel -> last-active -> first.
|
||||
function pickPointerCand(cands, preferKey, activeKey) {
|
||||
if (preferKey) return candByKey(cands, preferKey);
|
||||
if (!cands || !cands.length) return null;
|
||||
var i, c;
|
||||
if (preferKey) { c = candByKey(cands, preferKey); if (c) return c; }
|
||||
if (activeKey) {
|
||||
c = candByKey(cands, activeKey);
|
||||
if (c && c.onPanel) return c;
|
||||
@@ -5516,7 +5523,13 @@
|
||||
source: (pick.src.hand ? 'hand' : 'controller') + ':' + pick.src.handedness,
|
||||
origin: pick.ray.origin,
|
||||
dir: pick.ray.dir,
|
||||
hit: pick.hit ? { nx: pick.hit.nx, ny: pick.hit.ny } : null,
|
||||
// ADDENDUM 11b: only a hit that is really ON the panel becomes the
|
||||
// cursor. panelHit() clamps an off-panel intersection to the border, and
|
||||
// drawing the cursor at that clamped point while the beam ended at the
|
||||
// true intersection made the two drift apart - the further off the panel
|
||||
// the ray pointed, the worse the gap. `distance` is still published so the
|
||||
// beam still reaches the panel plane.
|
||||
hit: (pick.hit && pick.hit.inBounds) ? { nx: pick.hit.nx, ny: pick.hit.ny } : null,
|
||||
distance: pick.hit ? pick.hit.distance : null,
|
||||
pressed: performance.now() < pressUntil
|
||||
};
|
||||
@@ -5876,6 +5889,10 @@
|
||||
* ------------------------------------------------------------------ */
|
||||
var ACTIVATE_COOLDOWN_MS = 250;
|
||||
var lastActivate = 0;
|
||||
// ADDENDUM 11b: the cooldown is per INPUT SOURCE, not global. With hands, a
|
||||
// stray gamepad edge from one hand used to swallow the other hand's `select`
|
||||
// within 250 ms, so the click silently used the first hand's position.
|
||||
var lastActivateByKey = {};
|
||||
var padPrev = new WeakMap();
|
||||
|
||||
/* ---------------- grab & drag the subtitle strip ---------------- *
|
||||
@@ -6020,15 +6037,33 @@
|
||||
function pointerDown(src, frame, via) {
|
||||
if (!S.session) return;
|
||||
var now = performance.now();
|
||||
if (now - lastActivate < ACTIVATE_COOLDOWN_MS) return; // dedupe select+gamepad
|
||||
var actKey = srcKey(src) || (via || '?');
|
||||
if (now - (lastActivateByKey[actKey] || 0) < ACTIVATE_COOLDOWN_MS) return;
|
||||
lastActivateByKey[actKey] = now;
|
||||
lastActivate = now;
|
||||
S.stats.lastActivate = (via || '?') + (src && src.handedness ? ':' + src.handedness : '');
|
||||
S.stats.pressSrc = actKey;
|
||||
|
||||
// Captured BEFORE show(): when the control bar is already up, a pinch belongs
|
||||
// to the bar, so it must not also yank the subtitles.
|
||||
var barWasShown = NS.Controls && NS.Controls.isVisible ? !!NS.Controls.isVisible() : false;
|
||||
|
||||
if (frame) { try { updatePointer(frame, src); } catch (e) {} }
|
||||
// ADDENDUM 11b: attribute the shot to the acting source. If its ray cannot be
|
||||
// resolved, MISS - never fall back to whatever hand the per-frame pointer was
|
||||
// on, which is exactly how a right-hand pinch ended up landing on the left
|
||||
// hand's position.
|
||||
frame = frame || S.lastFrame;
|
||||
if (src) {
|
||||
if (frame) { try { updatePointer(frame, src); } catch (e) {} }
|
||||
if (!pointer || !pointer.visible) {
|
||||
S.stats.pressAt = 'MISS (acting source has no ray)';
|
||||
S.stats.pressPtr = '(no ray)';
|
||||
return;
|
||||
}
|
||||
S.stats.pressPtr = pointer.source + (pointer.hit ? ' HIT' : ' nohit');
|
||||
} else if (frame) {
|
||||
try { updatePointer(frame); } catch (e) {}
|
||||
}
|
||||
|
||||
// 1) grabbing the subtitle strip wins, but only while the bar is down
|
||||
if (frame && !barWasShown) {
|
||||
|
||||
+4
-1
@@ -1532,8 +1532,11 @@
|
||||
return d > 0 ? d : null;
|
||||
}
|
||||
|
||||
// ADDENDUM 11b: the beam reaches the panel plane whenever the ray meets it,
|
||||
// even when the intersection is off the panel (there is simply no cursor then).
|
||||
// Previously it fell back to a fixed length without a hit, so an edge-aimed
|
||||
// beam stopped short of the plane while the cursor was clamped to the border.
|
||||
function beamLength(p) {
|
||||
if (!p.hit) return BEAM_L_DEFAULT;
|
||||
var d = num(p.distance);
|
||||
if (d == null) d = panelDistance(p);
|
||||
if (d == null || !(d > BEAM_L_MIN)) return BEAM_L_DEFAULT;
|
||||
|
||||
+37
-5
@@ -851,6 +851,7 @@
|
||||
panelPose = null;
|
||||
pointer = { visible: false, beam: false, source: 'none', origin: { x: 0, y: 0, z: 0 }, dir: { x: 0, y: 0, z: -1 }, hit: null };
|
||||
activeSrcKey = null; // ADDENDUM 11: fresh hand choice every session
|
||||
lastActivateByKey = {};
|
||||
S.pointer = null;
|
||||
S.session = null;
|
||||
S.refSpace = null;
|
||||
@@ -1052,11 +1053,14 @@
|
||||
// cands [{ key, onPanel, ... }] in runtime order
|
||||
// preferKey the source that is acting right now (select / gamepad press)
|
||||
// activeKey the source that acted last
|
||||
// Order: acting -> last-active-while-on-panel -> any-on-panel -> last-active -> first.
|
||||
// When `preferKey` is given the acting source OWNS the shot: if it is not among
|
||||
// the candidates (no resolvable ray) we return null so the press MISSES rather
|
||||
// than silently reusing another hand's pointer. Otherwise:
|
||||
// last-active-while-on-panel -> any-on-panel -> last-active -> first.
|
||||
function pickPointerCand(cands, preferKey, activeKey) {
|
||||
if (preferKey) return candByKey(cands, preferKey);
|
||||
if (!cands || !cands.length) return null;
|
||||
var i, c;
|
||||
if (preferKey) { c = candByKey(cands, preferKey); if (c) return c; }
|
||||
if (activeKey) {
|
||||
c = candByKey(cands, activeKey);
|
||||
if (c && c.onPanel) return c;
|
||||
@@ -1120,7 +1124,13 @@
|
||||
source: (pick.src.hand ? 'hand' : 'controller') + ':' + pick.src.handedness,
|
||||
origin: pick.ray.origin,
|
||||
dir: pick.ray.dir,
|
||||
hit: pick.hit ? { nx: pick.hit.nx, ny: pick.hit.ny } : null,
|
||||
// ADDENDUM 11b: only a hit that is really ON the panel becomes the
|
||||
// cursor. panelHit() clamps an off-panel intersection to the border, and
|
||||
// drawing the cursor at that clamped point while the beam ended at the
|
||||
// true intersection made the two drift apart - the further off the panel
|
||||
// the ray pointed, the worse the gap. `distance` is still published so the
|
||||
// beam still reaches the panel plane.
|
||||
hit: (pick.hit && pick.hit.inBounds) ? { nx: pick.hit.nx, ny: pick.hit.ny } : null,
|
||||
distance: pick.hit ? pick.hit.distance : null,
|
||||
pressed: performance.now() < pressUntil
|
||||
};
|
||||
@@ -1480,6 +1490,10 @@
|
||||
* ------------------------------------------------------------------ */
|
||||
var ACTIVATE_COOLDOWN_MS = 250;
|
||||
var lastActivate = 0;
|
||||
// ADDENDUM 11b: the cooldown is per INPUT SOURCE, not global. With hands, a
|
||||
// stray gamepad edge from one hand used to swallow the other hand's `select`
|
||||
// within 250 ms, so the click silently used the first hand's position.
|
||||
var lastActivateByKey = {};
|
||||
var padPrev = new WeakMap();
|
||||
|
||||
/* ---------------- grab & drag the subtitle strip ---------------- *
|
||||
@@ -1624,15 +1638,33 @@
|
||||
function pointerDown(src, frame, via) {
|
||||
if (!S.session) return;
|
||||
var now = performance.now();
|
||||
if (now - lastActivate < ACTIVATE_COOLDOWN_MS) return; // dedupe select+gamepad
|
||||
var actKey = srcKey(src) || (via || '?');
|
||||
if (now - (lastActivateByKey[actKey] || 0) < ACTIVATE_COOLDOWN_MS) return;
|
||||
lastActivateByKey[actKey] = now;
|
||||
lastActivate = now;
|
||||
S.stats.lastActivate = (via || '?') + (src && src.handedness ? ':' + src.handedness : '');
|
||||
S.stats.pressSrc = actKey;
|
||||
|
||||
// Captured BEFORE show(): when the control bar is already up, a pinch belongs
|
||||
// to the bar, so it must not also yank the subtitles.
|
||||
var barWasShown = NS.Controls && NS.Controls.isVisible ? !!NS.Controls.isVisible() : false;
|
||||
|
||||
if (frame) { try { updatePointer(frame, src); } catch (e) {} }
|
||||
// ADDENDUM 11b: attribute the shot to the acting source. If its ray cannot be
|
||||
// resolved, MISS - never fall back to whatever hand the per-frame pointer was
|
||||
// on, which is exactly how a right-hand pinch ended up landing on the left
|
||||
// hand's position.
|
||||
frame = frame || S.lastFrame;
|
||||
if (src) {
|
||||
if (frame) { try { updatePointer(frame, src); } catch (e) {} }
|
||||
if (!pointer || !pointer.visible) {
|
||||
S.stats.pressAt = 'MISS (acting source has no ray)';
|
||||
S.stats.pressPtr = '(no ray)';
|
||||
return;
|
||||
}
|
||||
S.stats.pressPtr = pointer.source + (pointer.hit ? ' HIT' : ' nohit');
|
||||
} else if (frame) {
|
||||
try { updatePointer(frame); } catch (e) {}
|
||||
}
|
||||
|
||||
// 1) grabbing the subtitle strip wins, but only while the bar is down
|
||||
if (frame && !barWasShown) {
|
||||
|
||||
Reference in New Issue
Block a user