Skip to content

Turn one illustration into an animated 2D mesh avatar with a coding agent and a local editor

Move lighting into a collapsed section and add menu icons

shinshin864909edc21c37
diff --git a/e2e/lighting.spec.ts b/e2e/lighting.spec.ts
index 7c116a0..67322c4 100644
--- a/e2e/lighting.spec.ts
+++ b/e2e/lighting.spec.ts
@@ -95,19 +95,25 @@ test('lighting is lazy, changes brightness with position, preserves alpha, shado
expect(errors).toEqual([]); expect(outside).toEqual([]);
});
-test('editor remembers lighting, hides the handle outside its tab, and resets in all languages', async ({ context, page }) => {
+test('editor remembers lighting, keeps the section closed by default, hides the handle while closed, and resets in all languages', async ({ context, page }) => {
const outside = await guard(context);
await page.goto('/'); await expect(page.getByTestId('preview-status')).toHaveAttribute('data-state', 'ready'); await dismissGuide(page);
await expect(page.getByTestId('preview-status')).toHaveAttribute('data-state', 'ready');
await expect(page.getByRole('button', { name: 'Light position', exact: true })).toHaveCount(0);
- await page.getByRole('tab', { name: 'Lighting', exact: true }).click();
+ const section = page.getByTestId('lighting-section');
+ await expect(section).not.toHaveAttribute('open', '');
+ await expect(page.getByRole('tab', { name: 'Lighting' })).toHaveCount(0);
+ await section.locator('summary').click();
await page.getByRole('checkbox', { name: 'Enable lighting' }).check();
const handle = page.getByRole('button', { name: 'Light position', exact: true });
await handle.focus(); await handle.press('ArrowRight');
await expect(handle).toHaveCSS('left', /px$/);
await page.getByLabel('Shading', { exact: true }).selectOption('cel');
+ await expect(section.locator('.lighting-on')).toBeVisible();
+ await section.locator('summary').click(); await expect(handle).toHaveCount(0);
await page.reload(); await expect(page.getByTestId('preview-status')).toHaveAttribute('data-state', 'ready');
- await page.getByRole('tab', { name: 'Lighting', exact: true }).click();
+ await expect(section).not.toHaveAttribute('open', '');
+ await section.locator('summary').click();
await expect(page.getByRole('checkbox', { name: 'Enable lighting' })).toBeChecked();
await expect(page.getByLabel('Shading', { exact: true })).toHaveValue('cel');
await page.getByRole('button', { name: '日本語', exact: true }).click();
@@ -129,6 +135,8 @@ test('live drag updates matching streams without a camera, and OBS URLs carry ev
receiveLighting('unrelated-project', () => Object.assign(window, { wrongProject: true }));
});
const before = hash(await image(stream, 'canvas'));
+ await expect(page.getByRole('button', { name: 'Light position', exact: true })).toHaveCount(0);
+ await page.getByTestId('lighting-section').locator('summary').click();
await page.getByRole('checkbox', { name: 'Enable lighting' }).check();
const handle = page.getByRole('button', { name: 'Light position', exact: true }), bounds = await page.locator('canvas').boundingBox();
await handle.hover(); await page.mouse.down();
diff --git a/src/editor/Icon.tsx b/src/editor/Icon.tsx
index 52901a7..a9896d3 100644
--- a/src/editor/Icon.tsx
+++ b/src/editor/Icon.tsx
@@ -11,6 +11,10 @@ const paths = {
copy: 'M8 8h13v13H8V8Z M16 8V3H3v13h5',
live: 'M3 7h12v10H3V7Z M15 10l6-3v10l-6-3',
external: 'M14 4h6v6 M20 4l-9 9 M18 14v6H4V6h6',
+ pose: 'M12 3a2 2 0 1 1 0 4 2 2 0 0 1 0-4Z M5 9l7 1 7-1 M12 10v5 M8 21l4-6 4 6',
+ mouth: 'M3 12c3-4 6-4 9-2 3-2 6-2 9 2-3 5-15 5-18 0Z M3 12h18',
+ brush: 'M4 20h4L19 9l-4-4L4 16v4Z M13 7l4 4',
+ light: 'M12 8a4 4 0 1 1 0 8 4 4 0 0 1 0-8Z M12 2v2 M12 20v2 M4.9 4.9l1.4 1.4 M17.7 17.7l1.4 1.4 M2 12h2 M20 12h2 M4.9 19.1l1.4-1.4 M17.7 6.3l1.4-1.4',
};
export function Icon({ name }: { name: keyof typeof paths }) {
return <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.7"
diff --git a/src/editor/Preview.tsx b/src/editor/Preview.tsx
index 771ca37..84ceb0e 100644
--- a/src/editor/Preview.tsx
+++ b/src/editor/Preview.tsx
@@ -35,7 +35,8 @@ export function Preview({ projectKey, rig, assets, hasMouthSprites, onDrawMouth
const [speed, setSpeed] = useState(7);
const [loop, setLoop] = useState(false);
const [liveMouth, setLiveMouth] = useState(0);
- const [tab, setTab] = useState<'pose' | 'lip' | 'lighting'>('pose');
+ const [tab, setTab] = useState<'pose' | 'lip'>('pose');
+ const [lightingOpen, setLightingOpen] = useState(false);
const skipped = skippedKanaCharacters(text).join(' ');
const controls = useRef({ idle, stress, parameters });
controls.current = { idle, stress, parameters };
@@ -111,18 +112,16 @@ export function Preview({ projectKey, rig, assets, hasMouthSprites, onDrawMouth
<div className="panel-title"><h2>{t.preview}</h2><span role="status" data-testid="preview-status" data-state={status}>{t[status]}</span></div>
<div className="lighting-preview"><canvas ref={canvas} data-testid="preview" data-revision={revision} className="preview-canvas"
style={{ aspectRatio: `${rig.image.width * (1 + 2 * rig.view.padSide)} / ${rig.image.height * (1 + rig.view.padTop)}` }} />
- {tab === 'lighting' && <LightHandle value={lighting} onChange={setLighting} language={language} />}
+ {lightingOpen && <LightHandle value={lighting} onChange={setLighting} language={language} />}
</div>
<div className="preview-tools">
<button className="icon-button" aria-label={idle ? t.pause : t.play} title={idle ? t.pause : t.play}
data-testid="idle-toggle" aria-pressed={idle} onClick={() => setIdle(current => !current)}><Icon name={idle ? 'pause' : 'play'} /></button><span>{t.idle}</span>
</div>
<div className="preview-tabs" role="tablist" aria-label={t.preview}>
- <button id="pose-tab" role="tab" aria-selected={tab === 'pose'} aria-controls="pose-panel" onClick={() => setTab('pose')}>{t.pose}</button>
- <button id="lip-tab" role="tab" aria-selected={tab === 'lip'} aria-controls="lip-panel" onClick={() => setTab('lip')}>{t.lipSync}</button>
- <button id="lighting-tab" role="tab" aria-selected={tab === 'lighting'} aria-controls="lighting-panel" onClick={() => setTab('lighting')}>{lightingText[language].title}</button>
+ <button id="pose-tab" role="tab" aria-selected={tab === 'pose'} aria-controls="pose-panel" onClick={() => setTab('pose')}><Icon name="pose" />{t.pose}</button>
+ <button id="lip-tab" role="tab" aria-selected={tab === 'lip'} aria-controls="lip-panel" onClick={() => setTab('lip')}><Icon name="mouth" />{t.lipSync}</button>
</div>
- <div id="lighting-panel" role="tabpanel" aria-labelledby="lighting-tab" hidden={tab !== 'lighting'}><LightingControls value={lighting} onChange={setLighting} language={language} /></div>
<div className="pose-test" id="pose-panel" role="tabpanel" aria-labelledby="pose-tab" hidden={tab !== 'pose'}>
<div className="sliders">
{sliders.map(slider => (
@@ -162,6 +161,10 @@ export function Preview({ projectKey, rig, assets, hasMouthSprites, onDrawMouth
<div className="sliders lip-live"><label>{t.mouthOpen}<input type="range" aria-label={t.mouthOpen} min="0" max="1" step="0.01" disabled={lip !== null}
value={lip ? liveMouth : parameters.mouthOpen ?? 0} onChange={event => setParameters(current => ({ ...current, mouthOpen: Number(event.target.value) }))} /><output>{(lip ? liveMouth : parameters.mouthOpen ?? 0).toFixed(2)}</output></label></div>
</div>
+ <details className="lighting-section" data-testid="lighting-section" onToggle={event => setLightingOpen(event.currentTarget.open)}>
+ <summary><Icon name="light" />{lightingText[language].title}{lighting.enabled && <span className="lighting-on">ON</span>}</summary>
+ <LightingControls value={lighting} onChange={setLighting} language={language} />
+ </details>
</section>
);
}
diff --git a/src/editor/VariantsPanel.tsx b/src/editor/VariantsPanel.tsx
index 9401cab..65c0f38 100644
--- a/src/editor/VariantsPanel.tsx
+++ b/src/editor/VariantsPanel.tsx
@@ -4,6 +4,7 @@ import { variantNames, projectVariantRequests, ProjectJobError, type LocalProjec
import { AskAgent } from './AskAgent';
import { JobFeedback } from './JobFeedback';
import { CopyButton } from './CopyButton';
+import { Icon } from './Icon';
const labels = ['eyesClosed', 'eyesHalf', 'eyesSmile', 'mouthA', 'mouthAHalf', 'mouthI', 'mouthO'] as const;
export function VariantsPanel({ project, projectPath, assets, rootPath, busy, stale, onRun, mouthRequest, onMouthPresence }: {
@@ -54,7 +55,7 @@ export function VariantsPanel({ project, projectPath, assets, rootPath, busy, st
return value ? t.variantCount.replace('COUNT', String(value)).replace('TOTAL', String(total)) : t.variantMissing;
};
return <details ref={panel} className="panel variants-panel" data-testid="variants-panel" open>
- <summary>{t.variantsTitle}</summary>
+ <summary><Icon name="brush" />{t.variantsTitle}</summary>
<div className="variants-content"><p>{t.variantsHelp}</p>
<div className="variant-choices">
<label><input type="checkbox" checked={eyes} onChange={event => setEyes(event.target.checked)} aria-label={t.targetEyes} /><span>{t.targetEyes}<small>{t.eyesKinds}</small></span><span className="variant-count">{count('eyes_', 3)}</span></label>
diff --git a/src/editor/style.css b/src/editor/style.css
index 3c2e572..9720dec 100644
--- a/src/editor/style.css
+++ b/src/editor/style.css
@@ -110,7 +110,8 @@ main:has(.project-location):has(.stale) .editor-panel { height: calc(100dvh - 21
.sweep-button { width: 100%; font-size: 12px; padding: 6px 12px; }
.lip-sync { padding: 8px 16px; }
.preview-tabs { display: flex; padding: 4px 12px; gap: 4px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
-.preview-tabs button { flex: 1; border: 0; font-size: 12px; padding: 6px; }
+.preview-tabs button { flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px; border: 0; font-size: 12px; padding: 6px; }
+.preview-tabs button svg { width: 16px; height: 16px; }
.preview-tabs button[aria-selected="true"] { color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.vowel-buttons { display: flex; gap: 6px; margin: 10px 0 8px; }
.vowel-buttons button { padding: 5px 8px; flex: 1; }
@@ -173,6 +174,7 @@ main:has(.stale) .editor-panel, main:has(.stale) .parts-panel { height: calc(100
.variants-panel > summary, .new-illustration > summary { display: flex; align-items: center; justify-content: flex-start; cursor: pointer; padding: 12px 16px; font-weight: 600; }
.variants-panel > summary::before, .new-illustration > summary::before { content: '▸'; margin-right: 8px; }
.variants-panel[open] > summary::before, .new-illustration[open] > summary::before { content: '▾'; }
+.variants-panel > summary svg { margin-right: 8px; }
.variants-panel > summary span { margin-left: auto; font-weight: 400; color: var(--muted); }
.variants-content { padding: 0 16px 12px; font-size: 12px; }
.variants-content > p { color: var(--muted); }
diff --git a/src/lighting/lighting.css b/src/lighting/lighting.css
index 94e545d..f49489b 100644
--- a/src/lighting/lighting.css
+++ b/src/lighting/lighting.css
@@ -16,3 +16,11 @@
.lighting-hint { margin: 10px 0 0; color: #546a87; line-height: 1.5; }
.live-controls .lighting-controls { padding: 0; }
.live-preview.lighting-preview { overflow: visible; }
+.lighting-section, .live-lighting { border-top: 1px solid #d5dfeb; }
+.live-lighting { border: 1px solid #d5dfeb; border-radius: 12px; background: white; }
+.lighting-section > summary, .live-lighting > summary { display: flex; align-items: center; gap: 8px; cursor: pointer; padding: 12px 16px; font-weight: 600; }
+.lighting-section > summary::before, .live-lighting > summary::before { content: '▸'; }
+.lighting-section[open] > summary::before, .live-lighting[open] > summary::before { content: '▾'; }
+.lighting-section > summary::-webkit-details-marker, .live-lighting > summary::-webkit-details-marker { display: none; }
+.lighting-section > summary { list-style: none; } .live-lighting > summary { list-style: none; }
+.lighting-on { margin-left: auto; padding: 1px 7px; border-radius: 999px; background: #fff4cc; color: #805000; font-size: 11px; font-weight: 600; }
diff --git a/src/live/LiveApp.tsx b/src/live/LiveApp.tsx
index 518ab85..d1b084a 100644
--- a/src/live/LiveApp.tsx
+++ b/src/live/LiveApp.tsx
@@ -8,11 +8,13 @@ import { viewSettings, streamUrl, backgroundColor } from './settings';
import { FacePose, type TrackingOptions } from './tracking';
import { CameraCapture, MicrophoneCapture, type CameraState, type MicState, type BackgroundTracking } from './media';
import { liveText } from './i18n';
+import { Icon } from '../editor/Icon';
import { createLiveSender, sendLighting } from './relay';
export function LiveApp() {
const { language, setLanguage } = useI18n(), t = liveText[language];
const [settings, setSettings] = useState(() => { const view = viewSettings(location.search); return { ...view, lighting: view.lighting ?? loadLighting(view.project) }; });
+ const [lightingOpen, setLightingOpen] = useState(false);
const [options, setOptions] = useState<TrackingOptions>({ mirror: true, sensitivity: 1, smoothing: 0.35 });
const [cameraState, setCameraState] = useState<CameraState>('stopped');
const [micState, setMicState] = useState<MicState>('micOff');
@@ -84,10 +86,9 @@ export function LiveApp() {
</header>
<div className="live-layout"><section className="live-view"><div className="live-preview checkerboard lighting-preview" style={{ backgroundColor: settings.background, backgroundImage: settings.background === 'transparent' ? undefined : 'none' }}>
<canvas ref={canvas} data-testid="live-avatar" />
- <LightHandle value={settings.lighting} onChange={changeLighting} language={language} />
+ {lightingOpen && <LightHandle value={settings.lighting} onChange={changeLighting} language={language} />}
</div><p role="status" className={viewState === 'projectError' ? 'live-error' : ''}>{t[viewState]} · {settings.project}</p></section>
<aside className="live-controls">
- <section><h2>{lightingText[language].title}</h2><LightingControls value={settings.lighting} onChange={changeLighting} language={language} /></section>
<section><h2>{t.camera}</h2><label>{t.device}<select aria-label={t.camera} value={cameraId} disabled={cameraActive} onChange={event => setCameraId(event.target.value)}><option value="">{t.defaultDevice}</option>{devices.filter(device => device.kind === 'videoinput' && device.deviceId).map((device, i) => <option key={device.deviceId} value={device.deviceId}>{device.label || `${t.camera} ${i + 1}`}</option>)}</select></label>
<div className="live-buttons"><button className="live-primary" disabled={!cameraActive && viewState !== 'ready'} onClick={() => {
setCalibrated(false); pose.current.reset();
@@ -113,7 +114,12 @@ export function LiveApp() {
<div className="live-buttons"><button className="live-primary" onClick={() => { void navigator.clipboard.writeText(url).then(() => setCopyState('copied')).catch(() => setCopyState('copyError')); }}>{t.obs}</button>
<a className="live-open" href={url} target="_blank" rel="noreferrer">{t.openStream}</a></div>
{copyState && <p role="status">{t[copyState]}</p>}<input className="obs-url" aria-label={t.obs} readOnly value={url} onFocus={event => event.target.select()} /><small>{t.obsHelp}</small>
- </section><p className="live-privacy">{t.privacy}</p>
+ </section>
+ <details className="live-lighting" data-testid="lighting-section" onToggle={event => setLightingOpen(event.currentTarget.open)}>
+ <summary><Icon name="light" />{lightingText[language].title}{settings.lighting.enabled && <span className="lighting-on">ON</span>}</summary>
+ <LightingControls value={settings.lighting} onChange={changeLighting} language={language} />
+ </details>
+ <p className="live-privacy">{t.privacy}</p>
</aside></div>
</main>;
}
diff --git a/src/live/live.css b/src/live/live.css
index 0d23355..d694468 100644
--- a/src/live/live.css
+++ b/src/live/live.css
@@ -35,3 +35,9 @@ input[type="color"] { width: 100%; height: 32px; border: 0; padding: 0; }
.live-privacy { color: #546a87; font-size: 12px; margin: 0 4px; }
.live-error { color: #aa2020; }
@media (max-width: 800px) { .live-app { padding: 12px; } .live-layout { grid-template-columns: 1fr; } .live-view { position: static; } .live-preview { height: 55dvh; } .live-header { flex-wrap: wrap; } }
+.live-controls .live-lighting .lighting-controls { padding: 0 16px 16px; }
+.live-controls .live-lighting label { flex-direction: row; align-items: center; justify-content: space-between; gap: 8px; margin: 8px 0; }
+.live-controls .live-lighting .lighting-check { justify-content: flex-start; }
+.live-controls .live-lighting .lighting-slider { display: grid; }
+.live-controls .live-lighting select { width: auto; max-width: 60%; }
+.live-controls .live-lighting input[type="color"] { width: 58px; height: 28px; }