Turn one illustration into an animated 2D mesh avatar with a coding agent and a local editor
Switch drawn eyes in a paused preview
shinshin860e94b84f7a80
diff --git a/e2e/paused-eyes.spec.ts b/e2e/paused-eyes.spec.tsnew file mode 100644index 0000000..af60154--- /dev/null+++ b/e2e/paused-eyes.spec.ts@@ -0,0 +1,29 @@+import { expect, test, type Page } from '@playwright/test';+import { createHash } from 'node:crypto';+import { dismissGuide, samplePresent, sampleSkipReason } from './sample';++const snapshot = async (page: Page) => createHash('sha256').update(await page.getByTestId('preview').evaluate(c => (c as HTMLCanvasElement).toDataURL())).digest('hex');+async function ready(page: Page, revision: string | null) {+ if (revision) await expect(page.getByTestId('preview')).not.toHaveAttribute('data-revision', revision);+ await expect(page.getByTestId('preview-status')).toHaveAttribute('data-state', 'ready');+}++test('a paused preview switches drawn eyes as the Eyes open slider moves', async ({ page }) => {+ test.skip(!samplePresent, sampleSkipReason);+ await page.goto('/'); await dismissGuide(page); await ready(page, null);+ let revision = await page.getByTestId('preview').getAttribute('data-revision');+ await page.getByTestId('idle-toggle').click(); await ready(page, revision);+ const open = await snapshot(page);+ // Drag down through the half-closed drawing to fully closed, as a person would.+ const slider = page.getByRole('slider', { name: 'Eyes open', exact: true });+ for (const value of ['0.9', '0.7', '0.5', '0.3', '0.1', '0']) await slider.fill(value);+ const viaSlider = await snapshot(page);+ expect(viaSlider).not.toBe(open);+ // Rebuilding the paused preview at the same pose runs its fixed warm-up: the reference image.+ revision = await page.getByTestId('preview').getAttribute('data-revision');+ await page.getByTestId('idle-toggle').click(); await ready(page, revision);+ revision = await page.getByTestId('preview').getAttribute('data-revision');+ await page.getByTestId('idle-toggle').click(); await ready(page, revision);+ await expect(slider).toHaveValue('0');+ expect(await snapshot(page)).toBe(viaSlider);+});diff --git a/src/engine/sprites.js b/src/engine/sprites.jsindex e64b3d2..34db3ce 100644--- a/src/engine/sprites.js+++ b/src/engine/sprites.js@@ -131,7 +131,9 @@ export function createSpriteModule(engine, rig) {const st = eyeState[i];const want = eyeSprite(open, smile) ?? 'open';if (want !== st.cur) { st.prev = st.cur; st.cur = want; st.t = 0; }- st.t = Math.min(1, st.t + dt / EYE_FADE_SEC);+ // A redraw without elapsed time (a paused preview moving a slider) shows the target+ // frame at once; otherwise the fade would stay at its first frame.+ st.t = dt > 0 ? Math.min(1, st.t + dt / EYE_FADE_SEC) : 1;const k = sstep(0, 1, st.t);const show = (name, alpha) => {if (name === 'open' || alpha <= 0.001) return;