effect modifications

This commit is contained in:
osiu97
2026-07-08 21:35:38 +02:00
parent 3a4b3ec2d6
commit ebc634b4ee
+17 -9
View File
@@ -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 };
},