Skip to content

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

Enlarge avatar preview and simplify part editing

shinshin86964646f8670f
diff --git a/e2e/editor.spec.ts b/e2e/editor.spec.ts
index 8ca3c3b..a494dbe 100644
--- a/e2e/editor.spec.ts
+++ b/e2e/editor.spec.ts
@@ -44,7 +44,7 @@ test('opens a validated rig and rejects malformed files without replacing the pr
const edited = structuredClone(fixture);
edited.head.cx = 645;
await page.getByLabel('Open rig file', { exact: true }).setInputFiles({ name: 'rig.json', mimeType: 'application/json', buffer: Buffer.from(JSON.stringify(edited)) });
- await page.getByLabel('Selected rig item').selectOption('head');
+ await page.getByTestId('part-head').click();
await expect(page.getByRole('spinbutton', { name: 'head.cx', exact: true })).toHaveValue('645');
await page.getByLabel('Open rig file', { exact: true }).setInputFiles({ name: 'invalid.json', mimeType: 'application/json', buffer: Buffer.from('{"version":1}') });
await expect(page.getByRole('alert')).toContainText('rig.image');
@@ -67,8 +67,8 @@ test('rebuilds from cached assets, marks cut-outs stale, and sweeps angles', asy
await expect.poll(async () => Number(await canvas.getAttribute('data-revision'))).toBeGreaterThan(revision);
await page.getByRole('slider', { name: 'Turn left/right', exact: true }).focus();
await page.getByRole('slider', { name: 'Turn left/right', exact: true }).press('End');
- await page.getByLabel('Selected rig item').selectOption('eyes');
- await page.getByText(`Eye · 1 · opening (${fixture.eyes[0].opening.length})`, { exact: true }).click();
+ await page.getByTestId('part-eyes').click();
+ await page.getByText(`1 · opening (${fixture.eyes[0].opening.length})`, { exact: true }).click();
await page.getByRole('spinbutton', { name: 'eyes.0.opening.0.0', exact: true }).fill('451');
await expect(page.getByText(/Outlines changed/)).toBeVisible();
await expect.poll(async () => Number(await canvas.getAttribute('data-revision'))).toBeGreaterThan(revision + 1);
@@ -99,6 +99,6 @@ test('opens a local image folder without the installed sample', async ({ page })
await page.getByLabel('Open image folder files', { exact: true }).setInputFiles(fileURLToPath(new URL('../samples/miko-qipao/', import.meta.url)));
await expect(page.getByText('Engine ready', { exact: true })).toBeVisible();
await expect(page.getByTestId('editor')).toBeVisible();
- await page.getByLabel('Selected rig item').selectOption('head');
+ await page.getByTestId('part-head').click();
await expect(page.getByRole('spinbutton', { name: 'head.cx', exact: true })).toHaveValue('615');
});
diff --git a/e2e/preview-editing.spec.ts b/e2e/preview-editing.spec.ts
index 6f265b8..ff4ce3e 100644
--- a/e2e/preview-editing.spec.ts
+++ b/e2e/preview-editing.spec.ts
@@ -37,7 +37,7 @@ test('strand and head drags change inspector, saved JSON and frozen preview pixe
expect(hash(await preview.screenshot())).toBe(hash(before));
revision = Number(await preview.getAttribute('data-revision'));
await drag(page, [445, 340], [40, -10]);
- await page.getByText(`Strand · 1 · nodes (${fixture.strands[0].nodes.length})`, { exact: true }).click();
+ await page.getByText(`nodes (${fixture.strands[0].nodes.length})`, { exact: true }).click();
await expect(page.getByRole('spinbutton', { name: 'strands.0.nodes.2.0', exact: true })).toHaveValue('485');
await expect(page.getByRole('spinbutton', { name: 'strands.0.nodes.2.1', exact: true })).toHaveValue('330');
await expect.poll(async () => Number(await preview.getAttribute('data-revision'))).toBeGreaterThan(revision);
@@ -95,8 +95,8 @@ test('angle sliders retain the rendered pose after rebuilding and stopping a swe
await expect.poll(async () => Number(await preview.getAttribute('data-revision'))).toBeGreaterThan(revision);
const front = hash(await preview.screenshot());
await page.getByRole('slider', { name: 'Turn left/right', exact: true }).press('End');
- await page.getByLabel('Selected rig item').selectOption('eyes');
- await page.getByText(`Eye · 1 · opening (${fixture.eyes[0].opening.length})`, { exact: true }).click();
+ await page.getByTestId('part-eyes').click();
+ await page.getByText(`1 · opening (${fixture.eyes[0].opening.length})`, { exact: true }).click();
revision = Number(await preview.getAttribute('data-revision'));
await page.getByRole('spinbutton', { name: 'eyes.0.opening.0.0', exact: true }).fill('451');
await expect.poll(async () => Number(await preview.getAttribute('data-revision'))).toBeGreaterThan(revision);
@@ -106,7 +106,7 @@ test('angle sliders retain the rendered pose after rebuilding and stopping a swe
const point = page.locator('.point-field').first();
await expect(point.getByRole('spinbutton')).toHaveCount(2);
await page.screenshot({ path: 'docs/screenshots/inspector-points-angle.png' });
- await page.getByLabel('Selected rig item').selectOption('head');
+ await page.getByTestId('part-head').click();
await page.screenshot({ path: 'docs/screenshots/selected-band-lines.png' });
await page.getByRole('button', { name: 'Sweep angles', exact: true }).click();
await page.waitForTimeout(700);
diff --git a/e2e/usability.spec.ts b/e2e/usability.spec.ts
index aac7a2f..436726c 100644
--- a/e2e/usability.spec.ts
+++ b/e2e/usability.spec.ts
@@ -96,9 +96,9 @@ test('handles have human names and line editing, zoom, pan and fit remain availa
await page.getByTestId('part-strands').click();
const middle = await canvasPoint(page, 485, 190);
await page.mouse.dblclick(middle.x, middle.y);
- await expect(page.getByText('Strand · 1 · nodes (5)', { exact: true })).toBeVisible();
+ await expect(page.getByText('nodes (5)', { exact: true })).toBeVisible();
await page.keyboard.down('Alt'); await page.mouse.click(middle.x, middle.y); await page.keyboard.up('Alt');
- await expect(page.getByText('Strand · 1 · nodes (4)', { exact: true })).toBeVisible();
+ await expect(page.getByText('nodes (4)', { exact: true })).toBeVisible();
const scale = Number(await canvas.getAttribute('data-scale'));
await page.mouse.wheel(0, -200);
await expect.poll(async () => Number(await canvas.getAttribute('data-scale'))).toBeGreaterThan(scale);
@@ -145,12 +145,19 @@ for (const [width, height] of [[1440, 900], [1280, 800]]) for (const language of
await expect(page.locator('.part-tip')).toBeVisible();
await expect(page.locator('.pose-test')).toHaveAttribute('open', '');
expect(await page.evaluate(() => document.documentElement.scrollWidth)).toBeLessThanOrEqual(width);
- for (const selector of ['.parts-panel', '.editor-panel', '.preview-panel', '.inspector']) {
+ for (const selector of ['.parts-panel', '.editor-panel', '.preview-panel']) {
const box = (await page.locator(selector).boundingBox())!;
expect(box.x).toBeGreaterThanOrEqual(0);
expect(box.x + box.width).toBeLessThanOrEqual(width);
expect(box.y + box.height).toBeLessThanOrEqual(height);
}
+ const preview = (await page.getByTestId('preview').boundingBox())!;
+ expect(preview.height).toBeGreaterThanOrEqual(width === 1440 ? 360 : 300);
+ const pose = (await page.locator('.pose-test').boundingBox())!;
+ expect(pose.y + pose.height).toBeLessThanOrEqual(height);
+ await expect(page.locator('.inspector select')).toHaveCount(0);
+ const field = page.getByRole('spinbutton', { name: 'head.cx', exact: true });
+ await expect(field.locator('..').locator('span')).toHaveText(language === 'ja' ? '中心の横位置' : 'Centre X');
if (language === 'ja') {
const english = await page.locator('main').evaluate(main => {
const walker = document.createTreeWalker(main, NodeFilter.SHOW_TEXT);
@@ -167,5 +174,7 @@ for (const [width, height] of [[1440, 900], [1280, 800]]) for (const language of
expect(english).toEqual([]);
}
await page.screenshot({ path: `docs/screenshots/ui-${language}-${width}x${height}.png` });
+ await field.scrollIntoViewIfNeeded();
+ await page.screenshot({ path: `docs/screenshots/ui-${language}-${width}x${height}-fields.png` });
});
}
diff --git a/playwright.config.ts b/playwright.config.ts
index e19d78d..fbded78 100644
--- a/playwright.config.ts
+++ b/playwright.config.ts
@@ -4,6 +4,8 @@ const baseURL = `http://127.0.0.1:${port}`;
export default defineConfig({
testDir: 'e2e',
+ // Canvas previews share GPU resources; bound concurrent browser rendering.
+ workers: 2,
use: {
baseURL,
viewport: { width: 1440, height: 1000 },
diff --git a/src/editor/App.tsx b/src/editor/App.tsx
index 8c7a955..d77d410 100644
--- a/src/editor/App.tsx
+++ b/src/editor/App.tsx
@@ -9,7 +9,7 @@ import { RigHistory, downloadRig } from './history';
import { openImageFolder, sampleImagesAvailable } from './project';
import { layerSignature } from './stale';
import { RigFields } from './RigFields';
-import { GROUPS, partPresent } from './parts';
+import { GROUPS } from './parts';
import { PartList } from './PartList';
import { GUIDE_KEY, I18nProvider, readPreference, savePreference, useI18n, type PartGroup } from './i18n';
import { FirstGuide, GuideSteps, Help } from './Guide';
@@ -137,14 +137,7 @@ function Workspace() {
<div className="right-column">
<Preview rig={rig} assets={assets} />
<aside className="panel inspector">
- <div className="selection-heading"><h2>{selectedPart?.[0] ?? t.selection}</h2>
- <select aria-label={t.selectedItem} value={selected ?? ''} onChange={event => event.target.value ? selectPart(event.target.value) : setSelected(null)}>
- <option value="">{t.selectPart}</option>
- {GROUPS.map(group => <option key={group} value={group} disabled={!partPresent(rig, group)}>{parts[group][0]}</option>)}
- {(rig.strands ?? []).map((_, i) => <option key={i} value={`strands.${i}`}>{title(`strands.${i}`)}</option>)}
- {selected && !GROUPS.includes(selected as PartGroup) && !/^strands\.\d+$/.test(selected) && <option value={selected}>{title(selected)}</option>}
- </select>
- </div>
+ <div className="selection-heading"><h2>{selectedPart?.[0] ?? t.selection}</h2></div>
{errorNotice}
{selectedPart ? <><p className="part-description">{selectedPart[1]}</p><p className="part-tip"><strong>{t.tip}</strong> {selectedPart[2]}</p>
<div className="fields">{selected && <RigFields rig={rig} path={selected} onChange={(path, value) => update(setAt(rig, path, value))} />}</div></>
diff --git a/src/editor/RigFields.tsx b/src/editor/RigFields.tsx
index 96c29c1..2b37111 100644
--- a/src/editor/RigFields.tsx
+++ b/src/editor/RigFields.tsx
@@ -3,20 +3,21 @@ import { getAt } from './model';
import { NumericField } from './NumericField';
import { useI18n } from './i18n';
-export function RigFields({ rig, path, onChange }: {
- rig: Rig; path: string; onChange: (path: string, value: number) => void;
+export function RigFields({ rig, path, scope = path, onChange }: {
+ rig: Rig; path: string; scope?: string; onChange: (path: string, value: number) => void;
}) {
const { t, title } = useI18n();
+ const label = title(path === scope ? path.split('.').at(-1)! : path.slice(scope.length + 1));
const value = getAt(rig, path);
- if (typeof value === 'number') return <NumericField path={path} label={title(path)} value={value} onChange={number => onChange(path, number)} />;
+ if (typeof value === 'number') return <NumericField path={path} label={label} value={value} onChange={number => onChange(path, number)} />;
if (!value || typeof value !== 'object') return null;
if (Array.isArray(value) && value.length === 2 && value.every(v => typeof v === 'number') && !/band$/i.test(path)) {
- return <div className="point-field"><span>{title(path)}</span><div className="point-inputs">
+ return <div className="point-field"><span>{label}</span><div className="point-inputs">
{value.map((number, index) => <NumericField key={index} path={`${path}.${index}`} label={index === 0 ? t.x : t.y}
value={number} onChange={next => onChange(`${path}.${index}`, next)} />)}
</div><small>{path}</small></div>;
}
- const children = Object.entries(value).map(([key]) => <RigFields key={key} rig={rig} path={`${path}.${key}`} onChange={onChange} />);
- if (Array.isArray(value)) return <details open={path === 'eyes' || path === 'strands'}><summary>{title(path)} ({value.length})</summary><div className="fields">{children}</div></details>;
+ const children = Object.entries(value).map(([key]) => <RigFields key={key} rig={rig} path={`${path}.${key}`} scope={scope} onChange={onChange} />);
+ if (Array.isArray(value)) return <details open={path === 'eyes' || path === 'strands'}><summary>{label} ({value.length})</summary><div className="fields">{children}</div></details>;
return <>{children}</>;
}
diff --git a/src/editor/style.css b/src/editor/style.css
index 88cd9b1..40b1603 100644
--- a/src/editor/style.css
+++ b/src/editor/style.css
@@ -35,11 +35,11 @@ button.primary:hover { color: white; background: #1d4ed8; }
summary::-webkit-details-marker { display: none; }
.project-menu { position: absolute; right: 0; top: calc(100% + 8px); z-index: 5; min-width: 220px; padding: 8px; border: 1px solid var(--line); border-radius: var(--radius); background: white; box-shadow: 0 8px 24px #24334818; }
.project-menu button { display: block; width: 100%; border: 0; text-align: left; }
-.workspace { display: grid; grid-template-columns: 240px minmax(0, 1fr) 380px; gap: 12px; height: calc(100dvh - 96px); min-height: 560px; }
+.workspace { display: grid; grid-template-columns: 240px minmax(0, 1fr) 420px; gap: 12px; align-items: start; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); min-width: 0; }
.panel-title { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; gap: 8px; border-bottom: 1px solid var(--line); min-height: 44px; }
.panel-title span { font-size: 12px; color: var(--muted); }
-.parts-panel { overflow-y: auto; padding-bottom: 8px; }
+.parts-panel { overflow-y: auto; padding-bottom: 8px; max-height: calc(100dvh - 96px); }
.parts-title { padding: 12px 16px; border-bottom: 1px solid var(--line); font-size: 14px; font-weight: 600; cursor: pointer; }
.part-section { position: relative; padding-top: 8px; }
.part-section h3, .advanced-section > summary { padding: 0 16px 8px; color: var(--muted); font-size: 12px; font-weight: 600; }
@@ -49,14 +49,14 @@ summary::-webkit-details-marker { display: none; }
.part-row.is-absent { opacity: .55; }
.part-select { flex: 1; min-width: 0; display: grid; grid-template-columns: 10px minmax(0, 1fr); gap: 8px; text-align: left; padding: 6px 8px; border: 0; background: transparent; }
.part-select strong { display: block; font-size: 13px; font-weight: 600; line-height: 18px; }
-.part-select small { display: block; font-size: 12px; color: var(--muted); line-height: 15px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
+.part-select small { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; font-size: 12px; color: var(--muted); line-height: 15px; margin-top: 2px; overflow: hidden; }
.part-swatch { width: 10px; height: 10px; border-radius: 3px; margin-top: 4px; }
.part-eye { border: 0; width: 28px; height: 32px; padding: 5px; background: transparent; color: var(--muted); margin-top: 2px; }
.advanced-section { margin-top: 8px; border-top: 1px solid var(--line); }
.advanced-section > summary { cursor: pointer; list-style-position: inside; padding-bottom: 4px; }
.advanced-section .section-eye { top: 32px; }
.advanced-section .part-rows { padding-top: 28px; }
-.editor-panel { display: flex; flex-direction: column; overflow: hidden; }
+.editor-panel { display: flex; flex-direction: column; overflow: hidden; height: calc(100dvh - 96px); min-height: 560px; }
.canvas-stage { flex: 1; min-height: 0; position: relative; }
.canvas-content { height: 100%; display: flex; flex-direction: column; }
.canvas-surface { flex: 1; position: relative; min-height: 0; }
@@ -68,7 +68,7 @@ summary::-webkit-details-marker { display: none; }
.handle-tooltip { position: absolute; z-index: 2; pointer-events: none; max-width: 210px; background: var(--ink); color: white; padding: 6px 8px; border-radius: 6px; font-size: 12px; box-shadow: 0 2px 8px #0002; }
.right-column { display: flex; flex-direction: column; gap: 12px; min-height: 0; }
.preview-panel { overflow: hidden; flex-shrink: 0; }
-.preview-canvas { display: block; height: clamp(150px, 20vh, 180px); width: auto; max-width: 100%; margin: 0 auto; }
+.preview-canvas { display: block; height: 360px; width: auto; max-width: 100%; margin: 0 auto; }
.preview-tools { display: flex; align-items: center; gap: 8px; padding: 2px 16px; border-top: 1px solid var(--line); font-size: 12px; }
.preview-tools .icon-button { width: 28px; height: 28px; border: 0; color: var(--accent); }
.pose-test { border-top: 1px solid var(--line); position: relative; padding: 8px 16px; }
@@ -79,9 +79,8 @@ summary::-webkit-details-marker { display: none; }
.sliders input { min-width: 0; width: 100%; accent-color: var(--accent); margin: 0; }
.sliders output { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.sweep-button { width: 100%; font-size: 12px; padding: 6px 12px; }
-.inspector { flex: 1; min-height: 160px; overflow: auto; padding: 16px; }
+.inspector { min-height: 160px; max-height: 400px; overflow: auto; padding: 16px; }
.selection-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
-.selection-heading select { max-width: 180px; min-width: 0; border: 1px solid var(--line); border-radius: 6px; padding: 4px; color: var(--muted); font-size: 12px; }
.part-description { font-size: 12px; color: var(--muted); }
.part-tip { font-size: 12px; background: #f3f6fa; padding: 8px; border-radius: 8px; line-height: 1.5; }
.part-tip strong { display: block; color: var(--ink); margin-bottom: 2px; }
@@ -110,16 +109,21 @@ summary::-webkit-details-marker { display: none; }
.error { color: #a12828; background: #fff1f1; padding: 8px; font-size: 12px; white-space: pre-wrap; }
.stale { color: #7c4b05; background: #fff6dd; padding: 8px 16px; font-size: 12px; border: 1px solid #f0dcaa; border-radius: 8px; margin-bottom: 12px; }
.stale small { display: block; margin-top: 4px; font-size: 12px; }
-main:has(.stale) .workspace { height: calc(100dvh - 180px); }
+main:has(.stale) .editor-panel, main:has(.stale) .parts-panel { height: calc(100dvh - 180px); }
.empty-project { padding: 48px 24px; text-align: center; }
+@media (min-width: 1200px) and (max-width: 1350px) {
+ .workspace { grid-template-columns: 240px minmax(0, 1fr) 380px; }
+ .preview-canvas { height: 300px; }
+}
@media (max-width: 1199px) {
- .workspace { grid-template-columns: 220px minmax(0, 1fr); height: auto; align-items: start; }
+ .workspace { grid-template-columns: 220px minmax(0, 1fr); }
.editor-panel { height: 650px; }
.parts-panel { max-height: 650px; }
.parts-title { cursor: pointer; }
.right-column { grid-column: 2; display: grid; grid-template-columns: 1fr 1fr; align-items: start; }
.inspector { max-height: 650px; }
- main:has(.stale) .workspace { height: auto; }
+ .preview-canvas { height: 240px; }
+ main:has(.stale) .editor-panel { height: 650px; }
}
@media (max-width: 760px) {
main { padding: 8px; }