Skip to content

Commit 6cc42c7

Browse files
RuitingMaclaude
andcommitted
Cell: lock flare motion to alpha (drop integration lag)
Previously the path-lit contribution went into dd (angular accel), so the cell's velocity had to integrate up over multiple frames — visually the flare appeared bright a beat before the orbital point caught up and started moving. Now the lit contribution is added directly into the theta integration step: c.theta += (c.thetaDot + Math.sign(c.omegaBase) * curLit * PATH_LIT_VEL) * stepDt; Effective rotation rate is exactly thetaDot + curLit·PATH_LIT_VEL, so the visible motion locks in step with alpha (and inherits the same smoothstep rise / sustain-then-snap fall as the alpha envelope). The contribution doesn't accumulate on c.thetaDot, so when the flare passes the cell snaps back to its natural pendulum motion without needing a separate relaxation phase. PATH_LIT_KICK (2.0 rad/s² accel) → PATH_LIT_VEL (1.0 rad/s velocity). Lower numerical value, gentler effect — was visibly too fast before. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 08916d0 commit 6cc42c7

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

src/components/CellSketch.astro

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@
128128
const PATH_MAX_SPREAD = 3; // perpendicular cells the flare bleeds into
129129
const PATH_SPREAD_DECAY = 0.60; // peak alpha ratio per cell of spread distance
130130
const PATH_SPREAD_STEP_MS = 200; // ms delay per cell of spread distance
131-
const PATH_LIT_KICK = 2.0; // angular accel (rad/s²) per unit lit alpha — drives the cell's pendulum
131+
const PATH_LIT_VEL = 1.0; // extra angular velocity (rad/s) per unit lit alpha — added directly to theta integration so motion locks in step with alpha
132132

133133
// ----- Pre-rendered orbital point sprite (true exp decay) -----
134134
const DOT_HALF = 11;
@@ -548,16 +548,16 @@
548548
const tc = Math.atan2(dy, dx);
549549
dd += -k * Math.sin(c.theta - tc);
550550
}
551-
// Path-lit kick: angular accel proportional to current lit
552-
// alpha, in the cell's natural rotation direction. As the
553-
// flare advances, lit cells spin up; combined with the
554-
// existing momentum→alpha boost in the bbox loop, a lit
555-
// cell visibly rolls and stays bright via positive feedback.
556-
if (curLit > 0) {
557-
dd += Math.sign(c.omegaBase) * curLit * PATH_LIT_KICK;
558-
}
559551
c.thetaDot += dd * stepDt;
560-
c.theta += c.thetaDot * stepDt;
552+
// Path-lit motion: add velocity directly into the theta
553+
// integration step (not into the dd accelerator), so the
554+
// visible rotation rate tracks curLit exactly with no
555+
// first-order integration lag — alpha and motion are
556+
// locked in step. The contribution doesn't accumulate
557+
// on c.thetaDot, so when lit fades the cell returns to
558+
// its natural pendulum motion immediately.
559+
const litVel = curLit > 0 ? Math.sign(c.omegaBase) * curLit * PATH_LIT_VEL : 0;
560+
c.theta += (c.thetaDot + litVel) * stepDt;
561561
}
562562

563563
const px = cx + r * Math.cos(c.theta);

0 commit comments

Comments
 (0)