Implementing effects. Closes #2 #19

Merged
osiu97 merged 8 commits from effects into main 2026-07-08 21:47:35 +02:00
2 changed files with 10 additions and 5 deletions
Showing only changes of commit 3a4b3ec2d6 - Show all commits
+8 -4
View File
@@ -58,10 +58,14 @@ export const MotionEffects = {
}, },
// Called to determine blending behaviour during queue checks // Called to determine blending behaviour during queue checks
getQueueAction(mode, maxDist, blendThreshold) { getQueueAction(targetMode, nextTargetMode, maxDist, blendThreshold) {
if (mode === 'jumpy') { if (nextTargetMode === 'overshoot_settle') {
// Must physically reach the overshoot point before popping the settle command
if (maxDist <= 10) return { action: 'blend' };
return { action: 'continue' };
} else if (targetMode === 'jumpy') {
if (maxDist <= 5) return { action: 'wait', delay: 100 }; if (maxDist <= 5) return { action: 'wait', delay: 100 };
} else if (mode === 'hesitant') { } else if (targetMode === 'hesitant') {
// Lower blend threshold prevents blasting all speed-change waypoints instantly // Lower blend threshold prevents blasting all speed-change waypoints instantly
if (maxDist <= 30) return { action: 'blend' }; if (maxDist <= 30) return { action: 'blend' };
} else { } else {
@@ -95,7 +99,7 @@ export const MotionEffects = {
} else if (mode === 'erratic') { } else if (mode === 'erratic') {
count = Math.max(count, Math.ceil(distance / 20)); // fewer, larger jumps count = Math.max(count, Math.ceil(distance / 20)); // fewer, larger jumps
} else if (mode === 'hesitant') { } else if (mode === 'hesitant') {
count = Math.max(count, Math.ceil(distance / 15)); // ensure we get middle waypoints for speed changes count = Math.max(count, Math.ceil(distance / 15)); // ensure enough waypoints for speed changes
} }
return Math.max(1, count); return Math.max(1, count);
}, },
+2 -1
View File
@@ -95,7 +95,8 @@ async function executeQueue() {
const maxDist = Math.max(dist1, dist2); const maxDist = Math.max(dist1, dist2);
if (motionQueue.length > 0) { if (motionQueue.length > 0) {
const queueAction = MotionEffects.getQueueAction(target.mode, maxDist, CONFIG.BLEND_THRESHOLD_STEPS); const nextTarget = motionQueue[0];
const queueAction = MotionEffects.getQueueAction(target.mode, nextTarget.mode, maxDist, CONFIG.BLEND_THRESHOLD_STEPS);
if (queueAction.action === 'wait') { if (queueAction.action === 'wait') {
clearInterval(queueCheckInterval); clearInterval(queueCheckInterval);
setTimeout(executeQueue, queueAction.delay); setTimeout(executeQueue, queueAction.delay);