From ebc634b4eea27b3775558bbe89c2d29f681bbd01 Mon Sep 17 00:00:00 2001 From: osiu97 Date: Wed, 8 Jul 2026 21:35:38 +0200 Subject: [PATCH] effect modifications --- web/js/motion-effects.js | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/web/js/motion-effects.js b/web/js/motion-effects.js index 043f47b..3fa26a3 100644 --- a/web/js/motion-effects.js +++ b/web/js/motion-effects.js @@ -35,19 +35,27 @@ export const MotionEffects = { let newHasHesitated = hasHesitated; if (target.mode === 'hesitant') { - if (target.fraction >= 0.4 && hasHesitated === false) { + if (target.fraction >= 0.35 && hasHesitated === false) { // Slow down massively instead of stopping if (BLE.isConnected()) { - try { await BLE.write(`SPD:${Math.floor(Math.max(50, Settings.speed * 0.2))}`); } catch(e){} + try { await BLE.write(`SPD:${Math.floor(Math.max(30, Settings.speed * 0.1))}`); } catch(e){} } newHasHesitated = true; // Started hesitation - } else if (target.fraction >= 0.7 && hasHesitated === true) { - // Speed back up + } else if (target.fraction >= 0.55 && hasHesitated === true) { + // Speed back up aggressively if (BLE.isConnected()) { - try { await BLE.write(`SPD:${Settings.speed}`); } catch(e){} + try { await BLE.write(`SPD:${Math.floor(Settings.speed * 1.2)}`); } catch(e){} } newHasHesitated = 2; // Finished hesitation } + } else if (target.mode === 'erratic') { + // Aggressive speed changes randomly during the move + if (Math.random() > 0.4) { + if (BLE.isConnected()) { + const spd = Math.floor(Math.max(30, Settings.speed * (0.1 + Math.random() * 1.5))); + try { await BLE.write(`SPD:${spd}`); } catch(e){} + } + } } else if (target.mode === 'overshoot_settle') { delay = 200; // Brief pause before returning if (BLE.isConnected()) { @@ -108,13 +116,13 @@ export const MotionEffects = { applyPerturbation(px, py, nx, ny, fraction, distance, mode) { if (mode === 'snaky') { const cycles = Math.max(1, Math.floor(distance / 50)); - const offset = Math.sin(fraction * Math.PI * 2 * cycles) * 15; + const offset = Math.sin(fraction * Math.PI * 2 * cycles) * 30; // 30mm amplitude px += nx * offset; py += ny * offset; } else if (mode === 'erratic') { - // Meaningful jumps - px += (Math.random() - 0.5) * 20; - py += (Math.random() - 0.5) * 20; + // Meaningful, aggressive jumps + px += (Math.random() - 0.5) * 40; + py += (Math.random() - 0.5) * 40; } return { px, py }; },