[auto] fix step never resetting: check only the triggering axis for reset

stepsReset now checks only the X axis for left/right steps and only
the Z axis for forward/back steps. Previously used Euclidean distance
of both axes, so a persistent offset in the non-triggering axis
prevented reset indefinitely.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
main
name 2026-04-11 13:31:42 -07:00
parent 52d74bfb4e
commit ef3529f950
1 changed files with 10 additions and 4 deletions

View File

@ -171,18 +171,24 @@ function detectStep(
return dx > 0 ? 'step-left' : 'step-right'
}
/** Reset only checks the axis that triggered the step. */
function stepsReset(
worldLandmarks: Landmark3D[],
toeBaseL: { x: number; z: number },
toeBaseR: { x: number; z: number },
cfg: StepConfig,
activeStep: GestureSignal,
): boolean {
const lt = worldLandmarks[31], rt = worldLandmarks[32]
const ldx = lt.x - toeBaseL.x, ldz = lt.z - toeBaseL.z
const rdx = rt.x - toeBaseR.x, rdz = rt.z - toeBaseR.z
const lDist = Math.sqrt(ldx * ldx + ldz * ldz)
const rDist = Math.sqrt(rdx * rdx + rdz * rdz)
return lDist < cfg.reset && rDist < cfg.reset
if (activeStep === 'step-left' || activeStep === 'step-right') {
// Check X axis only
return Math.abs(ldx) < cfg.reset && Math.abs(rdx) < cfg.reset
}
// step-forward / step-back: check Z axis only
return Math.abs(ldz) < cfg.reset && Math.abs(rdz) < cfg.reset
}
export function detectGesture(
@ -386,7 +392,7 @@ export function detectGesture(
// Step detection (toe displacement from calibration baseline)
if (state.heelBaseL && state.heelBaseR && worldLandmarks?.length >= 33) {
if (state.activeStep) {
if (stepsReset(worldLandmarks, state.heelBaseL, state.heelBaseR, stepCfg)) {
if (stepsReset(worldLandmarks, state.heelBaseL, state.heelBaseR, stepCfg, state.activeStep)) {
state.activeStep = null
}
} else {