Jitter Amoothing

This commit is contained in:
2026-07-08 12:26:48 +10:00
parent 2d492baa7d
commit 114e883f5b
2 changed files with 8 additions and 3 deletions
+6 -1
View File
@@ -100,7 +100,12 @@ export class TunedDetector {
* smoothing (kills jitter); moving fast => light smoothing (stays responsive). * smoothing (kills jitter); moving fast => light smoothing (stays responsive).
*/ */
class OneEuro { class OneEuro {
constructor(minCutoff = 1.2, beta = 0.012, dCutoff = 1.0) { // minCutoff: baseline smoothing when still (lower = smoother but laggier).
// beta: how aggressively smoothing backs off as the value moves (higher =
// snappier tracking when you pan the phone, so ghosts follow the camera).
// Tuned for AR panning: keep jitter down when still, but track fast motion
// almost 1:1 so the world doesn't lag behind the camera.
constructor(minCutoff = 1.7, beta = 0.15, dCutoff = 1.0) {
this.minCutoff = minCutoff; this.beta = beta; this.dCutoff = dCutoff; this.minCutoff = minCutoff; this.beta = beta; this.dCutoff = dCutoff;
this.xPrev = null; this.dxPrev = 0; this.tPrev = null; this.xPrev = null; this.dxPrev = 0; this.tPrev = null;
} }
+2 -2
View File
@@ -270,7 +270,7 @@ async function start() {
return; return;
} }
detector = new TunedDetector({ dictionaryName: 'ARUCO_4X4_1000' }).setPreset('forgiving'); detector = new TunedDetector({ dictionaryName: 'ARUCO_4X4_1000' }).setPreset('forgiving');
tracker = new MarkerTracker({ coastMs: 300, smooth: true }); tracker = new MarkerTracker({ coastMs: 120, smooth: true }); // short coast: don't linger on stale pose while panning
await new Promise((res) => { if (video.readyState >= 2) res(); else video.onloadeddata = () => res(); }); await new Promise((res) => { if (video.readyState >= 2) res(); else video.onloadeddata = () => res(); });
sizeAll(); sizeAll();
@@ -327,7 +327,7 @@ function loop(now) {
// 3) animate ghosts: smooth toward server target, apply yaw + idle wobble // 3) animate ghosts: smooth toward server target, apply yaw + idle wobble
const t = now / 1000; const t = now / 1000;
for (const obj of ghostObjs.values()) { for (const obj of ghostObjs.values()) {
obj.group.position.lerp(obj.targetPos, 0.25); // smooth network updates obj.group.position.lerp(obj.targetPos, 0.5); // smooth network updates (snappier follow)
if (obj._yaw != null) { if (obj._yaw != null) {
// face travel/authored yaw, eased // face travel/authored yaw, eased
const cur = obj.group.rotation.y; const cur = obj.group.rotation.y;