Skip to content

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

Edit arms in Studio and show full-body support per avatar

shinshin86d6939487f577
diff --git a/docs/agent-guide.ja.md b/docs/agent-guide.ja.md
index c1441f8..2013870 100644
--- a/docs/agent-guide.ja.md
+++ b/docs/agent-guide.ja.md
@@ -171,6 +171,43 @@ Studio の「衣服」で線を追加・削除し、頂点をドラッグして
腰のひねりを加える場合は、`twist` を3〜6度から試してください。指定範囲は `0..15` 度です。乗せ替えと保持中に、肩が一部逆向きに回り、頭の正面形状が保たれ、足と衣服の付け根が離れないことを確認してください。省略または `0` なら従来の出力を保ちます。Studio の「脚・体重移動」で調整でき、レイヤーの再構築は不要です。
+## 任意 — 下ろした腕の動き
+
+両腕を体から離して下ろし、腕と胴体の間に透明な隙間がある画像にだけ `rig.arms` を設定してください。
+腕が体に触れている、体の前にある、腰に手を当てている、腕を組んでいる画像や、胸から上の画像では省略します。
+表現できるのは小さな振りと肘の曲げです。腕を上げたり、腕の後ろに隠れた部分を補ったりはできません。
+ネイティブランタイムは現在 `arms` とそのパラメータを無視します。この機能には WebGL ランタイムを使ってください。
+
+前の手順の座標校正と拡大グリッドを使います。画像左右の `shoulder` を袖の内側の脇に近い位置、
+`elbow` を肘、`wrist` を手の付け根に置き、y 座標がこの順に増えるようにしてください。
+各腕の `split` は脇の少し下から指先より下まで、透明な隙間を通る線にします。
+画像左の腕では肘・手首より右側、画像右の腕では左側に置きます。
+布がある場合は `base_cloth.png` も確認してください。スカートを除いた画像の腕の輪郭と切り抜きの残りが、動かせる範囲に影響します。
+線を肌・袖・ブレスレットの上に置かないでください。
+
+最初は既定値の `swing: 4`、`bend: 6`(度)、`inward: 0.4` を使います。
+下書きを検証し、腕の重ね合わせ画像を確認してからポーズを描き出してください。
+
+```sh
+npm run validate-rig -- projects/<name>/rig.draft.json
+uv run tools/overlay.py projects/<name> --rig rig.draft.json --part arms --zoom --out projects/<name>/work/overlay-arms.png
+npm run render-poses -- projects/<name>
+```
+
+描き出すときは、構築済みプロジェクトの `rig.json` にも同じ腕の設定を入れてください。
+Studio の「体」から「腕」を選び、関節の点と左右の境界線を調整します。
+辺のダブルクリックで点を追加でき、Alt を押しながら点をクリックすると削除できます。
+待機動作を止め、4 つの腕スライダーで動きを確認してください。これらの編集にはレイヤーの再構築は不要です。
+保存後に開き直し、変更が残っていることを確認してください。
+「全身の対応状況」には、設定がなくても脚・腕・布の状態を表示します。未設定の部位は通常の動きのままです。
+
+`rest`、7 種類の腕の固定ポーズ、`arm-cycle-0..9`、`arm-idle-0..10` をすべて確認します。
+静止時の絵が変わらず、袖がつながり、肘が滑らかに曲がり、手がスカートに隠れないことが合格条件です。
+衣服が手首を隠す場合は動きの上限を下げてください。腕を動かすと元のブレスレットや袖の断片が現れる場合は、切り抜き画像を直します。
+Live では「体の動きを認識」を有効にし、腕の力を抜いた姿勢を登録します。
+左右反転の両方を試し、片側の手首や肘を隠したときに、その部位が滑らかに待機動作に戻ることを確認してください。
+上限と追跡の仕様は [Rig fields](rig-fields.md#optional-hanging-arms) を参照してください。
+
## ステップ7 — 引き渡す
ユーザーに次のことを伝えてください。
diff --git a/docs/agent-guide.md b/docs/agent-guide.md
index bace0c6..9f3a2c9 100644
--- a/docs/agent-guide.md
+++ b/docs/agent-guide.md
@@ -286,6 +286,48 @@ over a five-second cycle: a 0.9-second smooth S transition and a 1.6-second hold
in each half-cycle. Rigs without `legs` retain their previous output. The slider
accepts the full `-1..1` parameter range.
+## Optional — Hanging arms
+
+Add `rig.arms` only when both arms hang clear of the body with a transparent gap.
+Omit it when arms touch or lie in front of the body, with hands on hips or crossed
+arms, and for bust-up art. This feature permits small swings and elbow bends, not
+raised arms or reconstruction behind them. The native runtime currently ignores
+`arms` and its parameters; this feature uses the WebGL runtime.
+
+Use the coordinate calibration and zoomed grids from the earlier steps. Place each
+image-side `shoulder` inside the sleeve near the armpit, `elbow` on the joint and
+`wrist` at the hand attachment, with increasing y. Trace that arm's `split` down
+the transparent gap, starting just below the armpit and ending below the fingertips.
+The image-left split stays on the right of its elbow and wrist; mirror this for the
+image-right arm. Check `base_cloth.png` too when cloth is present: its bare arm
+silhouette and any cutout remnants determine where the mesh can move cleanly.
+Do not place a split through visible skin, sleeves or bracelets.
+
+Start with defaults `swing: 4`, `bend: 6` (degrees) and `inward: 0.4`. Validate, then
+inspect an arms overlay before rendering:
+
+```sh
+npm run validate-rig -- projects/<name>/rig.draft.json
+uv run tools/overlay.py projects/<name> --rig rig.draft.json --part arms --zoom --out projects/<name>/work/overlay-arms.png
+npm run render-poses -- projects/<name>
+```
+
+Use a built project with the same arms data in `rig.json` when rendering. In Studio,
+select **Arms** in **Body**, edit the joint handles and both split lines (double-click
+to add a vertex; Alt-click to remove one), and pause idle to test the four arm sliders.
+These edits do not require rebuilding layers. Save and reopen to verify persistence.
+The body section's **Full-body support** summary lists Legs / Arms / Cloth even when
+all are absent; unset parts keep the standard motion.
+
+Inspect `rest`, all seven fixed arm poses, every `arm-cycle-0..9` and every
+`arm-idle-0..10` frame. At rest the drawing must stay identical. Sleeves must stay
+attached, elbows must bend smoothly, and hands must not disappear into the skirt.
+Reduce limits if clothing occludes the wrist. Fix cutout remnants in the artwork
+when a swing reveals old bracelet or sleeve fragments. In Live, use **Track body
+movement** and calibrate relaxed arms; check both Mirror settings and hide one wrist
+or elbow to confirm that side returns smoothly to idle. See [Rig fields](rig-fields.md#optional-hanging-arms)
+for limits and tracking behaviour.
+
## Step 7 — Hand over
Tell the person:
diff --git a/docs/agent-guide.zh.md b/docs/agent-guide.zh.md
index 2f02861..e1ec855 100644
--- a/docs/agent-guide.zh.md
+++ b/docs/agent-guide.zh.md
@@ -171,6 +171,42 @@ uv run tools/build-sprites.py projects/<name>
需要骨盆扭转时,可从 `twist` 为3–6度开始,允许范围为 `0..15` 度。检查重心转移与保持期间,肩部部分反向转动、头部保持正面形状、双脚固定且衣物连接处不断开。省略或设为 `0` 保留原输出。Studio 的“双腿”面板可调整此项,无需重建图层。
+## 可选 — 下垂手臂的动作
+
+仅当双臂自然下垂、与身体之间有透明间隙时添加 `rig.arms`。
+手臂贴着身体、位于身体前方、双手叉腰、交叉手臂或只有上半身特写时,应省略此项。
+该功能只支持小幅摆动和弯肘,不会抬高手臂或补画手臂后面被遮挡的部分。
+原生运行时目前忽略 `arms` 及其参数;此功能使用 WebGL 运行时。
+
+使用前面步骤的坐标校准和放大网格。将图像两侧的 `shoulder` 放在袖内靠近腋下的位置,
+`elbow` 放在肘关节,`wrist` 放在手的连接处,y 坐标依次递增。
+每侧的 `split` 从腋下稍下方沿透明间隙延伸到指尖下方。
+图像左臂的分界线应位于肘和腕的右侧,右臂则相反。
+存在衣物图层时也要检查 `base_cloth.png`:去除裙子后的手臂轮廓和切图残留会影响可移动的范围。
+分界线不能穿过皮肤、袖子或手镯。
+
+从默认值 `swing: 4`、`bend: 6`(度)和 `inward: 0.4` 开始。
+验证草稿并查看手臂叠加图后,再渲染姿态:
+
+```sh
+npm run validate-rig -- projects/<name>/rig.draft.json
+uv run tools/overlay.py projects/<name> --rig rig.draft.json --part arms --zoom --out projects/<name>/work/overlay-arms.png
+npm run render-poses -- projects/<name>
+```
+
+渲染时,已构建项目的 `rig.json` 也应包含相同手臂设置。
+在 Studio 的“身体”中选择“手臂”,调整关节控制点与两侧分界线。
+双击边添加顶点,Alt 点击顶点删除。暂停待机动作,用四个手臂滑块检查动作。
+这些编辑不需要重建图层。保存并重新打开,确认设置保留。
+“全身支持情况”即使在全部未设置时也会列出双腿、手臂和衣物;未设置的部位保持默认动作。
+
+检查 `rest`、七种固定手臂姿态,以及全部 `arm-cycle-0..9` 和 `arm-idle-0..10` 帧。
+静止时图像应保持一致,袖子不能断开,弯肘要平滑,手不能消失到裙子后面。
+衣物遮住手腕时,降低动作上限;摆臂露出旧手镯或袖子的碎片时,修正切图。
+在 Live 中开启“追踪身体动作”,放松手臂后校准。
+检查镜像开关的两种状态,遮住一侧手腕或肘部,确认对应部位平滑返回待机动作。
+范围与追踪行为见 [Rig fields](rig-fields.md#optional-hanging-arms)。
+
## 第 7 步 —— 交付
告诉用户:
diff --git a/docs/rig-fields.md b/docs/rig-fields.md
index 2eaeed8..075a021 100644
--- a/docs/rig-fields.md
+++ b/docs/rig-fields.md
@@ -259,3 +259,49 @@ slider, then save the rig to persist the geometry and tuning.
`weight-shift-0..9` over one five-second cycle when `legs` is present.
For planted rigs, the chest drive lags the pelvis by approximately 0.1–0.2s; head stabilization follows one spring later and preserves intentional head gestures. Independent idle body noise is reduced to 35% without changing random-number consumption.
+
+
+## Optional hanging arms
+
+Use `arms` for front-facing, hanging arms separated from the body by a transparent gap.
+Omit it for arms touching or in front of the torso, hands on hips, crossed arms, and
+bust-up illustrations. This is a small deformation of the original drawing; it does
+not reconstruct hidden skin or clothing, raise the arms, or resolve cloth collisions.
+Without `arms`, the avatar keeps its existing deformation. The native runtime currently
+ignores `arms` and its parameters; use the WebGL runtime for this feature.
+
+| Field | Meaning |
+| --- | --- |
+| `arms.left`, `arms.right` | Image-left and image-right arms. Each has the source-pixel points `shoulder`, `elbow`, `wrist` and its own `split` polyline. All points must be inside the image, with shoulder y < elbow y < wrist y. |
+| `arms.left.shoulder`, `arms.right.shoulder` | Upper-arm pivot `[x,y]`, inside the sleeve near the armpit. Motion fades to zero at the shoulder to keep the sleeve attached. |
+| `arms.left.elbow`, `arms.right.elbow` | Elbow pivot `[x,y]`. Upper arm and forearm motion blend around this joint. |
+| `arms.left.wrist`, `arms.right.wrist` | Wrist `[x,y]`; the hand follows the forearm. |
+| `arms.left.split`, `arms.right.split` | At least two source points with strictly increasing y, tracing the transparent gap from just below the armpit to below the fingertips. The left split must be to the right of its elbow and wrist; the right split must be to their left. With cloth cutouts, check the actual `base_cloth.png` gap too. Keep the line clear of visible arm pixels and allow room for mesh cells around narrow gaps. |
+| `arms.swing` | Optional upper-arm rotation limit in degrees, `0..10`, default `4`. |
+| `arms.bend` | Optional additional elbow flexion limit in degrees, `0..12`, default `6`. Negative flexion is not allowed. |
+| `arms.inward` | Optional `0..1` fraction of the swing limit allowed towards the body, default `0.4`. |
+
+New parameters, all defaulting to `0`, are `armSwingL` / `armSwingR` (`-1..1`, positive
+outwards) and `elbowBendL` / `elbowBendR` (`0..1`). L/R refer to the image sides. The
+existing `armAngle` / `handAngle` parameters still control the separate chin-hand rig.
+Zero arm parameters add exactly zero deformation. During idle, arms partly counter the
+torso inclination with a damped delay and a small breathing motion.
+
+In Studio, **Body → Arms** exposes both joint chains, editable split lines and tuning.
+Joint, split and tuning edits recalculate weights without rebuilding image layers.
+The four arm pose sliders appear only when `arms` is set. **Full-body support** lists
+Legs / Arms / Cloth as set or not set; parts not set keep the standard motion.
+
+Live shows which body parts the loaded avatar supports. **Track body movement** follows
+visible elbows and wrists relative to the calibrated posture. Mirror swaps their image
+sides. Each hidden elbow releases that side, while a hidden wrist releases only elbow
+bend: hold the last pose for 500 ms, then fade to idle with a 200 ms time constant.
+A 90-degree extra elbow bend maps to about `0.6` at normal sensitivity, with a camera
+tracking cap of `0.75`. Tracking uses image-plane angles, so depth-only movement may
+not produce the same response. Calibrate with relaxed, visible arms.
+
+`render-poses` adds `arms-out`, `arms-in`, `elbows-bent`, `arm-left`, `arm-right`,
+`arms-body-left`, `arms-body-right`, `arm-cycle-0..9` and `arm-idle-0..10` when `arms`
+is present. Inspect sleeves, elbows, wrists and skirt edges in every frame. Reduce
+`swing`, `bend` or `inward` if the hand enters clothing; segmentation remnants in
+cut-out cloth must be corrected in the artwork rather than by increasing motion.
diff --git a/e2e/arms.spec.ts b/e2e/arms.spec.ts
new file mode 100644
index 0000000..d1aa8f7
--- /dev/null
+++ b/e2e/arms.spec.ts
@@ -0,0 +1,100 @@
+import { test, expect } from '@playwright/test';
+import { cp, mkdir, mkdtemp, readFile, rm, writeFile } from 'node:fs/promises';
+import { basename, join, resolve } from 'node:path';
+import { dismissGuide, samplePresent, sampleSkipReason } from './sample';
+
+test.beforeEach(() => { test.skip(!samplePresent, sampleSkipReason); });
+
+test('bust-up sample explains missing full-body support and has no arm sliders', async ({ page }, testInfo) => {
+ await page.goto('/'); await dismissGuide(page);
+ await expect(page.getByTestId('preview-status')).toHaveAttribute('data-state', 'ready');
+ const summary = page.getByTestId('full-body-support');
+ await summary.scrollIntoViewIfNeeded();
+ await expect(summary).toContainText('Full-body support');
+ for (const part of ['legs', 'arms', 'cloth']) await expect(page.getByTestId(`support-${part}`)).toHaveAttribute('data-state', 'unset');
+ await expect(page.getByTestId('part-arms')).toBeDisabled();
+ for (const label of ['Image-left arm swing', 'Image-right arm swing', 'Image-left elbow bend', 'Image-right elbow bend'])
+ await expect(page.getByRole('slider', { name: label, exact: true })).toHaveCount(0);
+ await page.screenshot({ path: testInfo.outputPath('bust-support-en.png') });
+ await page.getByRole('button', { name: '日本語', exact: true }).click();
+ await expect(summary).toContainText('全身の対応状況'); await expect(summary).toContainText('未設定の部位は通常の動きのままです。');
+ await page.getByRole('button', { name: '简体中文', exact: true }).click();
+ await expect(summary).toContainText('全身支持情况'); await expect(summary).toContainText('未设置的部位保持默认动作。');
+});
+
+test('arm joints, split vertices and default tuning edit the preview without rebuild and persist', async ({ page }, testInfo) => {
+ test.setTimeout(90_000);
+ await mkdir('projects', { recursive: true });
+ const directory = await mkdtemp(resolve('projects/arms-check-'));
+ try {
+ await cp(resolve('samples/miko-qipao'), directory, { recursive: true });
+ const rigPath = join(directory, 'rig.json'), rig = JSON.parse(await readFile(rigPath, 'utf8'));
+ rig.arms = {
+ left: { shoulder: [250, 650], elbow: [200, 800], wrist: [150, 950], split: [[265, 680], [235, 800], [200, 1030]] },
+ right: { shoulder: [1004, 650], elbow: [1054, 800], wrist: [1104, 950], split: [[989, 680], [1019, 800], [1054, 1030]] },
+ };
+ await writeFile(rigPath, JSON.stringify(rig));
+ const open = async () => {
+ await page.goto('/'); await dismissGuide(page); await page.locator('.open-menu > summary').click();
+ await page.getByTestId(`project-${basename(directory)}`).click();
+ await expect(page.getByTestId('preview-status')).toHaveAttribute('data-state', 'ready');
+ await page.getByTestId('part-arms').click();
+ await page.locator('.inspector details').evaluateAll(nodes => nodes.forEach(node => { (node as HTMLDetailsElement).open = true; }));
+ };
+ await open();
+ await expect(page.getByTestId('support-arms')).toHaveAttribute('data-state', 'set');
+ await expect(page.getByTestId('support-legs')).toHaveAttribute('data-state', 'unset');
+ for (const [field, value] of [['swing', '4'], ['bend', '6'], ['inward', '0.4']])
+ await expect(page.getByRole('spinbutton', { name: `arms.${field}`, exact: true })).toHaveValue(value);
+ // Showing defaults must not silently modify the rig.
+ expect(JSON.parse(await readFile(rigPath, 'utf8')).arms.swing).toBeUndefined();
+ for (const side of ['left', 'right']) for (const joint of ['shoulder', 'elbow', 'wrist'])
+ await expect(page.getByRole('spinbutton', { name: `arms.${side}.${joint}.0`, exact: true })).toBeAttached();
+ await page.getByTestId('idle-toggle').click();
+ await expect(page.getByTestId('preview-status')).toHaveAttribute('data-state', 'ready');
+ const preview = page.getByTestId('preview'), pixels = () => preview.evaluate(n => (n as HTMLCanvasElement).toDataURL());
+ const rest = await pixels();
+ await page.getByRole('slider', { name: 'Image-left arm swing', exact: true }).fill('0.7');
+ await page.getByRole('slider', { name: 'Image-right elbow bend', exact: true }).fill('0.5');
+ await expect.poll(pixels).not.toBe(rest);
+ const editor = page.getByTestId('editor');
+ const position = async (px: number, py: number) => {
+ const box = (await editor.boundingBox())!, scale = Number(await editor.getAttribute('data-scale'));
+ return { x: box.x + Number(await editor.getAttribute('data-offset-x')) + px * scale,
+ y: box.y + Number(await editor.getAttribute('data-offset-y')) + py * scale, scale };
+ };
+ const beforeDrag = await pixels(), revision = Number(await preview.getAttribute('data-revision'));
+ const elbow = await position(200, 800);
+ await page.mouse.move(elbow.x, elbow.y); await page.mouse.down();
+ await page.mouse.move(elbow.x + 10 * elbow.scale, elbow.y + 8 * elbow.scale, { steps: 4 }); await page.mouse.up();
+ await expect(page.getByRole('spinbutton', { name: 'arms.left.elbow.0', exact: true })).toHaveValue('210');
+ await expect.poll(async () => Number(await preview.getAttribute('data-revision'))).toBeGreaterThan(revision);
+ await expect.poll(pixels).not.toBe(beforeDrag);
+ await page.getByTestId('part-arms').click();
+ const middle = await position(250, 740); await page.mouse.dblclick(middle.x, middle.y);
+ await page.locator('.inspector details').evaluateAll(nodes => nodes.forEach(node => { (node as HTMLDetailsElement).open = true; }));
+ await expect(page.getByRole('spinbutton', { name: 'arms.left.split.3.0', exact: true })).toBeAttached();
+ const vertex = await position(250, 740); await page.keyboard.down('Alt'); await page.mouse.click(vertex.x, vertex.y); await page.keyboard.up('Alt');
+ await page.getByTestId('part-arms').click();
+ await page.locator('.inspector details').evaluateAll(nodes => nodes.forEach(node => { (node as HTMLDetailsElement).open = true; }));
+ await expect(page.getByRole('spinbutton', { name: 'arms.left.split.3.0', exact: true })).toHaveCount(0);
+ for (const [field, value] of [['swing', '3'], ['bend', '4'], ['inward', '0.25'], ['left.split.0.0', '267']])
+ await page.getByRole('spinbutton', { name: `arms.${field}`, exact: true }).fill(value);
+ await expect(page.getByTestId('stale-banner')).toHaveCount(0);
+ await page.getByRole('button', { name: 'Save rig', exact: true }).click();
+ await expect.poll(async () => JSON.parse(await readFile(rigPath, 'utf8')).arms.left.elbow).toEqual([210, 808]);
+ await expect.poll(async () => JSON.parse(await readFile(rigPath, 'utf8')).arms.inward).toBe(.25);
+ await open();
+ await expect(page.getByRole('spinbutton', { name: 'arms.swing', exact: true })).toHaveValue('3');
+ await expect(page.getByRole('spinbutton', { name: 'arms.left.split.0.0', exact: true })).toHaveValue('267');
+ await expect(page.getByTestId('stale-banner')).toHaveCount(0);
+ await page.getByTestId('full-body-support').scrollIntoViewIfNeeded();
+ await page.screenshot({ path: testInfo.outputPath('arm-editor-en.png') });
+ await page.getByRole('button', { name: '日本語', exact: true }).click();
+ await expect(page.getByRole('slider', { name: '画像左の腕の振り', exact: true })).toBeAttached();
+ await expect(page.getByTestId('full-body-support')).toContainText('設定済み');
+ await page.getByRole('button', { name: '简体中文', exact: true }).click();
+ await expect(page.getByRole('slider', { name: '图像右肘弯曲', exact: true })).toBeAttached();
+ await expect(page.getByTestId('full-body-support')).toContainText('已设置');
+ } finally { await rm(directory, { recursive: true, force: true }); }
+});
diff --git a/src/editor/PartList.tsx b/src/editor/PartList.tsx
index 79a2481..26646cc 100644
--- a/src/editor/PartList.tsx
+++ b/src/editor/PartList.tsx
@@ -37,7 +37,14 @@ export function PartList({ rig, visible, selected, onSelect, onFocus, onVisible
<details className="parts-disclosure" open><summary className="parts-title">{t.parts}</summary>
{SECTIONS.map(s => s.key === 'advanced'
? <details key={s.key} className="part-section advanced-section"><summary>{t[s.key]}</summary>{section(s.groups)}</details>
- : <section key={s.key} className="part-section"><h3>{t[s.key]}</h3>{section(s.groups)}</section>)}
+ : <section key={s.key} className="part-section"><h3>{t[s.key]}</h3>{s.key === 'bodySection' && <div className="full-body-support" data-testid="full-body-support">
+ <h4>{t.fullBodySupport}</h4><dl>{(['legs', 'arms', 'cloth'] as const).map(group => {
+ const present = partPresent(rig, group);
+ return <div key={group} data-testid={`support-${group}`} data-state={present ? 'set' : 'unset'}>
+ <dt>{{ legs: t.supportLegs, arms: t.supportArms, cloth: t.supportCloth }[group]}</dt><dd>{present ? t.supportSet : t.supportNotSet}</dd>
+ </div>;
+ })}</dl>{(['legs', 'arms', 'cloth'] as const).some(group => !partPresent(rig, group)) && <p>{t.supportHint}</p>}
+ </div>}{section(s.groups)}</section>)}
</details>
</aside>;
}
diff --git a/src/editor/Preview.tsx b/src/editor/Preview.tsx
index 7719487..8c8a466 100644
--- a/src/editor/Preview.tsx
+++ b/src/editor/Preview.tsx
@@ -18,6 +18,12 @@ const sliders = [
{ id: 'weightShift', label: 'weightShift', min: -1, max: 1, def: 0 },
{ id: 'bodyAngleZ', label: 'bodyTilt', min: -10, max: 10, def: 0 },
] as const;
+const armSliders = [
+ { id: 'armSwingL', label: 'armSwingL', min: -1, max: 1, def: 0 },
+ { id: 'armSwingR', label: 'armSwingR', min: -1, max: 1, def: 0 },
+ { id: 'elbowBendL', label: 'elbowBendL', min: 0, max: 1, def: 0 },
+ { id: 'elbowBendR', label: 'elbowBendR', min: 0, max: 1, def: 0 },
+] as const;
type Vowel = 'a' | 'i' | 'u' | 'e' | 'o' | 'n';
type Lip = { kind: 'hold'; vowel: Vowel } | { kind: 'text'; text: string; speed: number; loop: boolean; source: 'user' | 'sample' } | null;
export function Preview({ projectKey, rig, assets, lipSync, onLipSyncChange, hasMouthSprites, onDrawMouth }: { projectKey: string; rig: Rig; assets?: Record<string, string>; lipSync?: AudioSettings; onLipSyncChange(value: AudioSettings): void; hasMouthSprites: boolean; onDrawMouth?: () => void }) {
@@ -147,7 +153,7 @@ export function Preview({ projectKey, rig, assets, lipSync, onLipSyncChange, has
</div>
<div className="pose-test" id="pose-panel" role="tabpanel" aria-labelledby="pose-tab" hidden={tab !== 'pose'}>
<div className="sliders">
- {sliders.map(slider => (
+ {(rig.arms ? [...sliders, ...armSliders] : sliders).map(slider => (
<label key={slider.id}>{t[slider.label]}
<input type="range" aria-label={t[slider.label]} min={slider.min} max={slider.max} step="0.05"
disabled={slider.id === 'mouthOpen' && lip !== null}
diff --git a/src/editor/RigFields.tsx b/src/editor/RigFields.tsx
index 2cdfd1d..85558f8 100644
--- a/src/editor/RigFields.tsx
+++ b/src/editor/RigFields.tsx
@@ -1,5 +1,5 @@
import { clothGrid, sampleLine } from '../../packages/runtime/src/engine/cloth-grid.js';
-import type { Cloth, Point, Rig } from 'mesh-avatar';
+import { ARM_DEFAULTS, type Cloth, type Point, type Rig } from 'mesh-avatar';
import { getAt } from './model';
import { NumericField } from './NumericField';
import { useI18n } from './i18n';
@@ -10,7 +10,7 @@ export function RigFields({ rig, path, scope = path, onChange }: {
rig: Rig; path: string; scope?: string; onChange: (path: string, value: unknown) => void;
}) {
const { t, title } = useI18n();
- const label = title(path.startsWith('legs.split') ? path : path === scope ? path.split('.').at(-1)! : path.slice(scope.length + 1));
+ const label = path.startsWith('arms.') ? title(path).replace(`${title('arms')} · `, '') : title(path.startsWith('legs.split') ? path : 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={label} value={value} onChange={number => onChange(path, number)} />;
if (!value || typeof value !== 'object') return null;
@@ -20,10 +20,10 @@ export function RigFields({ rig, path, scope = path, onChange }: {
value={number} onChange={next => onChange(`${path}.${index}`, next)} />)}
</div><small>{path}</small></div>;
}
- const fields = /^cloth\.\d+$/.test(path) ? { ...CLOTH_DEFAULTS, ...value } : path === 'legs' ? { ...LEG_DEFAULTS, ...value } : value;
+ const fields = /^cloth\.\d+$/.test(path) ? { ...CLOTH_DEFAULTS, ...value } : path === 'legs' ? { ...LEG_DEFAULTS, ...value } : path === 'arms' ? { ...ARM_DEFAULTS, ...value } : value;
const children = Object.entries(fields).map(([key, child]) =>
- (/^cloth\.\d+$/.test(path) && Object.hasOwn(CLOTH_DEFAULTS, key)) || (path === 'legs' && Object.hasOwn(LEG_DEFAULTS, key))
- ? <NumericField key={key} path={`${path}.${key}`} label={title(key)} value={child as number} onChange={number => onChange(`${path}.${key}`, number)} />
+ (/^cloth\.\d+$/.test(path) && Object.hasOwn(CLOTH_DEFAULTS, key)) || (path === 'legs' && Object.hasOwn(LEG_DEFAULTS, key)) || (path === 'arms' && Object.hasOwn(ARM_DEFAULTS, key))
+ ? <NumericField key={key} path={`${path}.${key}`} label={path === 'arms' ? title(`arms.${key}`).replace(`${title('arms')} · `, '') : title(key)} value={child as number} onChange={number => onChange(`${path}.${key}`, number)} />
: <RigFields key={key} rig={rig} path={`${path}.${key}`} scope={scope} onChange={onChange} />);
if (/^cloth\.\d+$/.test(path)) {
diff --git a/src/editor/i18n-zh.ts b/src/editor/i18n-zh.ts
index 4358ff0..672137e 100644
--- a/src/editor/i18n-zh.ts
+++ b/src/editor/i18n-zh.ts
@@ -18,6 +18,8 @@ export const uiZh = {
savedTo: '已保存到', saveError: '项目保存失败。编辑内容仍保留在页面中,请重试。', revealError: '无法打开项目文件夹。', copyError: '无法复制路径。',
help: '使用帮助', close: '关闭帮助', language: '界面语言', english: 'English', japanese: '日本語', chinese: '简体中文', enCode: 'EN', jaCode: 'JA', zhCode: '中文',
parts: '部件', faceSection: '面部', hairSection: '头发与饰品', bodySection: '身体', advanced: '高级设置',
+ fullBodySupport: '全身支持情况', supportSet: '已设置', supportNotSet: '未设置', supportHint: '未设置的部位保持默认动作。', supportLegs: '双腿', supportArms: '手臂', supportCloth: '衣物',
+ armSwingL: '图像左臂摆动', armSwingR: '图像右臂摆动', elbowBendL: '图像左肘弯曲', elbowBendR: '图像右肘弯曲',
notPresent: '当前绑定中没有此部件', show: '显示辅助线', hide: '隐藏辅助线', showAll: '全部显示', hideAll: '全部隐藏',
source: '原图与绑定', canvas: '绑定编辑画布', fit: '适应画布', zoom: '缩放', zoomOut: '缩小', zoomIn: '放大', actualSize: '恢复到 100%', fitPart: '定位选中部件', wheelMode: '鼠标滚轮', wheelAuto: '缩放', wheelPan: '滚动平移',
pickHint: '选择左侧部件,或点击图上的控制点', dragHint: '拖动控制点调整位置',
@@ -94,6 +96,7 @@ export const workflowZh: typeof workflowEn = {
};
export const partsZh: Record<PartGroup, [string, string, string]> = {
+ arms: ['手臂', '自然下垂手臂的小幅动作。', '仅用于手臂与身体之间有透明间隙的图片。设置图像左右的肩、肘、腕关节,在两侧间隙中描出分界线。'],
legs: ['双腿', '双脚固定时的重心转移。', '设置骨盆及图像左右的髋、膝、踝关节,描出双腿分界线,再检查左右重心转移。'],
cloth: ['布料', '裙摆和垂布的摆动。', '调整腰线与下摆控制点,再调整频率、阻尼和风力。'],
head: ['头部转动', '转头或倾斜时跟随动作的区域。', '把中心放在面部中央,椭圆应覆盖包括头发在内的整个头部。'],
diff --git a/src/editor/i18n.tsx b/src/editor/i18n.tsx
index f32a6af..750fb13 100644
--- a/src/editor/i18n.tsx
+++ b/src/editor/i18n.tsx
@@ -26,6 +26,8 @@ const en = {
savedTo: 'Saved to', saveError: 'Could not save the project. Your edits are still in the editor; try again.', revealError: 'Could not open the project folder.', copyError: 'Could not copy the path.',
help: 'Help', close: 'Close help', language: 'Language', english: 'English', japanese: '日本語', chinese: '简体中文', enCode: 'EN', jaCode: 'JA', zhCode: '中文',
parts: 'Parts', faceSection: 'Face', hairSection: 'Hair & accessories', bodySection: 'Body', advanced: 'Advanced',
+ fullBodySupport: 'Full-body support', supportSet: 'Set', supportNotSet: 'Not set', supportHint: 'Parts not set keep the standard motion.', supportLegs: 'Legs', supportArms: 'Arms', supportCloth: 'Cloth',
+ armSwingL: 'Image-left arm swing', armSwingR: 'Image-right arm swing', elbowBendL: 'Image-left elbow bend', elbowBendR: 'Image-right elbow bend',
notPresent: 'Not in this rig', show: 'Show overlay', hide: 'Hide overlay', showAll: 'Show all', hideAll: 'Hide all',
source: 'Source & rig', canvas: 'Rig editor canvas', fit: 'Fit', zoom: 'Zoom', zoomOut: 'Zoom out', zoomIn: 'Zoom in', actualSize: 'Reset to 100%', fitPart: 'Fit selected part', wheelMode: 'Mouse wheel', wheelAuto: 'Zoom', wheelPan: 'Scroll to pan',
pickHint: 'Pick a part on the left, or click a dot', dragHint: 'Drag dots to move them',
@@ -74,6 +76,8 @@ const ja: typeof en = {
savedTo: '保存しました:', saveError: 'プロジェクトを保存できませんでした。編集内容は画面に残っています。もう一度お試しください。', revealError: 'プロジェクトのフォルダを開けませんでした。', copyError: 'パスをコピーできませんでした。',
help: 'ヘルプ', close: 'ヘルプを閉じる', language: '言語', english: '英語', japanese: '日本語', chinese: '简体中文', enCode: '英語', jaCode: '日本語', zhCode: '中文',
parts: 'パーツ', faceSection: '顔', hairSection: '髪・飾り', bodySection: '体', advanced: '詳細設定',
+ fullBodySupport: '全身の対応状況', supportSet: '設定済み', supportNotSet: '未設定', supportHint: '未設定の部位は通常の動きのままです。', supportLegs: '脚', supportArms: '腕', supportCloth: '布',
+ armSwingL: '画像左の腕の振り', armSwingR: '画像右の腕の振り', elbowBendL: '画像左の肘の曲げ', elbowBendR: '画像右の肘の曲げ',
notPresent: 'この設定にはありません', show: 'ガイドを表示', hide: 'ガイドを非表示', showAll: 'すべて表示', hideAll: 'すべて非表示',
source: '元画像と動く範囲', canvas: '動く範囲の編集キャンバス', fit: '全体表示', zoom: '表示倍率', zoomOut: '縮小', zoomIn: '拡大', actualSize: '100% に戻す', fitPart: '選択中のパーツに合わせる', wheelMode: 'マウスのホイール', wheelAuto: '拡大・縮小', wheelPan: 'スクロールで移動',
pickHint: '左のパーツか、画像の点を選んでください', dragHint: '点をドラッグして位置を調整',
@@ -106,10 +110,11 @@ const ja: typeof en = {
};
const zh: typeof en = { ...workflowZh, ...uiZh };
export const dictionaries = { en, ja, zh };
-export type PartGroup = 'head' | 'eyes' | 'mouth' | 'face' | 'cheeks' | 'strands' | 'buns' | 'accessories' | 'body' | 'hand' | 'legs' | 'cloth' | 'mesh' | 'view';
+export type PartGroup = 'head' | 'eyes' | 'mouth' | 'face' | 'cheeks' | 'strands' | 'buns' | 'accessories' | 'body' | 'hand' | 'legs' | 'arms' | 'cloth' | 'mesh' | 'view';
const partText: Record<Language, Record<PartGroup, [string, string, string]>> = {
zh: partsZh,
en: {
+ arms: ['Arms', 'Small motions of hanging arms.', 'Use only when a transparent gap separates the arms from the body. Place image-left/right shoulder, elbow and wrist joints and trace each boundary in the gap.'],
legs: ['Legs', 'Planted feet and weight transfer.', 'Place the pelvis and image-left/right hip, knee and ankle joints. Trace the split between the legs, then test both weight-shift directions.'],
cloth: ['Cloth', 'Skirts and draped fabric.', 'Place the waist and hem handles, then adjust swing, damping and wind.'],
head: ['Head turn', 'Area that moves when the face turns or tilts.', 'Place the centre in the middle of the face; the circle should cover the whole head including hair.'],
@@ -126,6 +131,7 @@ const partText: Record<Language, Record<PartGroup, [string, string, string]>> =
view: ['Framing', 'Preview margins.', 'Adjust the margins so the head and accessories stay inside the preview.'],
},
ja: {
+ arms: ['腕', '体から離して下ろした腕の小さな動き。', '腕と胴体の間に透明な隙間がある画像に使います。画像左右の肩・肘・手首を合わせ、それぞれの隙間に境界線を置いてください。'],
legs: ['脚・体重移動', '足を接地させたまま体重を移す動き。', '骨盤と画像左右の股関節・膝・足首を合わせ、脚の境界線を置いてから左右の体重移動を確認してください。'],
cloth: ['布・スカート', 'スカートや垂れ布の揺れ。', '腰と裾の点を合わせ、周期・減衰・風の強さを調整してください。'],
head: ['頭の向き', '顔を振ったり傾けたりするときに動く範囲。', '中心を顔の真ん中に置き、円が髪を含む頭全体を覆うように調整してください。'],
@@ -177,6 +183,11 @@ const fieldText: Record<string, [string, string]> = {
eyeCell: ['Eye cell size', '目の格子幅'], spriteCell: ['Drawing cell size', '差し替え画像の格子幅'],
padTop: ['Top margin', '上の余白'], padSide: ['Side margin', '左右の余白'], gazeCenter: ['Gaze centre', '視線の中心'], start: ['Start', '始点'], end: ['End', '終点'],
};
+const armFieldText: Record<Language, Record<string, string>> = {
+ en: { left: 'Image-left arm', right: 'Image-right arm', shoulder: 'Shoulder', split: 'Arm boundary', swing: 'Upper-arm swing limit (degrees)', bend: 'Elbow bend limit (degrees)', inward: 'Inward swing fraction' },
+ ja: { left: '画像左の腕', right: '画像右の腕', shoulder: '肩', split: '腕の境界線', swing: '上腕の振りの上限 (度)', bend: '肘の曲げの上限 (度)', inward: '内側に振れる割合' },
+ zh: { left: '图像左臂', right: '图像右臂', shoulder: '肩关节', split: '手臂分界线', swing: '上臂摆动上限 (度)', bend: '手肘弯曲上限 (度)', inward: '向内摆动比例' },
+};
export function fieldTitle(path: string, language: Language) {
const t = dictionaries[language];
const parts = partText[language];
@@ -188,6 +199,7 @@ export function fieldTitle(path: string, language: Language) {
if (key === 'accessories') return t.accessory;
if (key in parts) return parts[key as PartGroup][0];
}
+ if (path.startsWith('arms.') && armFieldText[language][key]) return armFieldText[language][key];
if (key === 'split' && path.startsWith('legs.')) return { en: 'Leg boundary', ja: '脚の境界線', zh: '双腿分界线' }[language];
return language === 'zh' ? fieldsZh[key] ?? key : fieldText[key]?.[language === 'en' ? 0 : 1] ?? key;
}).join(' · ');
diff --git a/src/editor/model.ts b/src/editor/model.ts
index bd880cd..2d3bf40 100644
--- a/src/editor/model.ts
+++ b/src/editor/model.ts
@@ -102,7 +102,7 @@ export function buildOverlay(rig: Rig): { handles: Handle[]; shapes: Shape[] } {
if (value.length >= 2 && value.every(p => Array.isArray(p) && p.length === 2 && p.every(v => typeof v === 'number'))) {
const points = value as Point[];
const closed = ['opening', 'roi', 'outline', 'background'].includes(key);
- const editable = /^cloth\.\d+\.(seams|tiers)\.\d+$/.test(path) || closed || ['nodes', 'jaw', 'waist', 'hem', ...(group === 'legs' ? ['split'] : [])].includes(key);
+ const editable = /^cloth\.\d+\.(seams|tiers)\.\d+$/.test(path) || closed || ['nodes', 'jaw', 'waist', 'hem', ...(['legs', 'arms'].includes(group) ? ['split'] : [])].includes(key);
if (group !== 'cheeks') shapes.push({ item: path, group, kind: 'line', points, closed, editable });
points.forEach((point, index) => {
const item = group === 'strands' ? path.split('.').slice(0, 2).join('.') : path;
@@ -174,6 +174,12 @@ export function buildOverlay(rig: Rig): { handles: Handle[]; shapes: Shape[] } {
shapes.push({ item: `legs.${side}`, group: 'legs', kind: 'line', points: [rig.legs.pelvis, leg.hip, leg.knee, leg.ankle] });
}
}
+ if (rig.arms) {
+ for (const side of ['left', 'right'] as const) {
+ const arm = rig.arms[side];
+ shapes.push({ item: `arms.${side}`, group: 'arms', kind: 'line', points: [arm.shoulder, arm.elbow, arm.wrist] });
+ }
+ }
rig.cloth?.forEach((c, index) => {
try {
const g = clothGrid(c), point = (r: number, k: number): Point => [g.rest[(r * g.cols + k) * 2], g.rest[(r * g.cols + k) * 2 + 1]];
diff --git a/src/editor/parts.ts b/src/editor/parts.ts
index 554d28c..ce9a9f1 100644
--- a/src/editor/parts.ts
+++ b/src/editor/parts.ts
@@ -1,15 +1,15 @@
import type { Rig } from 'mesh-avatar';
import type { PartGroup } from './i18n';
-export const GROUPS: PartGroup[] = ['head', 'eyes', 'mouth', 'face', 'cheeks', 'strands', 'buns', 'accessories', 'body', 'hand', 'legs', 'cloth', 'mesh', 'view'];
+export const GROUPS: PartGroup[] = ['head', 'eyes', 'mouth', 'face', 'cheeks', 'strands', 'buns', 'accessories', 'body', 'hand', 'legs', 'arms', 'cloth', 'mesh', 'view'];
export const PART_COLORS: Record<PartGroup, string> = {
head: '#159447', body: '#7c4dce', face: '#d72c68', eyes: '#0098a8', mouth: '#ea671a',
cheeks: '#d05383', strands: '#ca9b00', accessories: '#cf3030', hand: '#6c55d8',
- buns: '#ba31ad', legs: '#16847e', cloth: '#e040a0', mesh: '#5a6a7c', view: '#2b69d5',
+ buns: '#ba31ad', legs: '#16847e', arms: '#b26916', cloth: '#e040a0', mesh: '#5a6a7c', view: '#2b69d5',
};
export const SECTIONS = [
{ key: 'faceSection', groups: ['head', 'eyes', 'mouth', 'face', 'cheeks'] },
{ key: 'hairSection', groups: ['strands', 'buns', 'accessories'] },
- { key: 'bodySection', groups: ['body', 'hand', 'legs', 'cloth'] },
+ { key: 'bodySection', groups: ['body', 'hand', 'legs', 'arms', 'cloth'] },
{ key: 'advanced', groups: ['mesh', 'view'] },
] as const;
export function partPresent(rig: Rig, group: PartGroup) {
diff --git a/src/editor/style.css b/src/editor/style.css
index 3a3dd96..686e760 100644
--- a/src/editor/style.css
+++ b/src/editor/style.css
@@ -307,3 +307,11 @@ main:has(.stale) .editor-panel, main:has(.stale) .parts-panel { height: calc(100
.audio-file-picker { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.audio-file-picker button { font-size: 12px; padding: 6px 10px; }
.audio-file-picker span { flex: 1; min-width: 0; overflow-wrap: anywhere; font-size: 11px; color: var(--muted); }
+
+.full-body-support { margin: 0 16px 8px; padding: 8px; background: var(--canvas); border-radius: 6px; font-size: 11px; }
+.full-body-support h4 { margin: 0 0 6px; font-size: inherit; font-weight: 600; }
+.full-body-support dl { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; margin: 0; }
+.full-body-support dt { color: var(--muted); }
+.full-body-support dd { margin: 3px 0 0; font-weight: 500; }
+.full-body-support [data-state="set"] dd { color: #187747; }
+.full-body-support p { margin: 7px 0 0; line-height: 1.5; color: var(--muted); }
diff --git a/tests/editor.test.ts b/tests/editor.test.ts
index 8edc2f4..564333c 100644
--- a/tests/editor.test.ts
+++ b/tests/editor.test.ts
@@ -69,3 +69,34 @@ test('leg joints and the editable split update weights without invalidating imag
expect(layerSignature(rig)).toBe(baseline);
expect(validateRig(rig)).toEqual([]);
});
+
+test('arm handles, bone chains and editable splits preserve validation and image-layer signatures', async () => {
+ const { layerSignature } = await import('../src/editor/stale');
+ const { fieldTitle } = await import('../src/editor/i18n');
+ const { partPresent } = await import('../src/editor/parts');
+ let rig = parseRig(fixture);
+ expect(partPresent(rig, 'arms')).toBe(false);
+ rig.arms = {
+ left: { shoulder: [250, 650], elbow: [200, 800], wrist: [150, 950], split: [[265, 680], [235, 800], [200, 1030]] },
+ right: { shoulder: [1004, 650], elbow: [1054, 800], wrist: [1104, 950], split: [[989, 680], [1019, 800], [1054, 1030]] },
+ };
+ expect(partPresent(rig, 'arms')).toBe(true);
+ const signature = layerSignature(rig), overlay = buildOverlay(rig);
+ for (const side of ['left', 'right']) for (const joint of ['shoulder', 'elbow', 'wrist'])
+ expect(overlay.handles.some(h => h.id === `arms.${side}.${joint}`)).toBe(true);
+ expect(overlay.shapes.filter(s => /^arms\.(left|right)$/.test(s.item))).toHaveLength(2);
+ expect(overlay.handles.find(h => h.id === 'arms.left.split.0')?.vertex).toEqual({ path: 'arms.left.split', index: 0, closed: false });
+ rig = moveHandle(rig, overlay.handles.find(h => h.id === 'arms.left.elbow')!, [210, 808]);
+ rig = changeVertex(rig, 'arms.left.split', 1, [250, 740], false);
+ expect(rig.arms!.left.elbow).toEqual([210, 808]); expect(rig.arms!.left.split).toHaveLength(4);
+ while (rig.arms!.left.split.length > 2) rig = changeVertex(rig, 'arms.left.split', 1, null, false);
+ expect(changeVertex(rig, 'arms.left.split', 0, null, false).arms!.left.split).toHaveLength(2);
+ expect(layerSignature(rig)).toBe(signature); expect(validateRig(rig)).toEqual([]);
+ expect(fieldTitle('arms.left.split', 'en')).toBe('Arms · Image-left arm · Arm boundary');
+ expect(fieldTitle('arms.swing', 'en')).toBe('Arms · Upper-arm swing limit (degrees)');
+ expect(fieldTitle('arms.bend', 'ja')).toContain('肘の曲げの上限 (度)');
+ expect(fieldTitle('arms.right.shoulder', 'zh')).toContain('图像右臂');
+ // Contextual labels must not replace the existing cloth or leg meanings.
+ expect(fieldTitle('cloth.0.swing', 'en')).toContain('Frequency multiplier');
+ expect(fieldTitle('legs.left', 'en')).toContain('Image-left leg');
+});
diff --git a/tools/overlay.py b/tools/overlay.py
index 1619eda..90ba62b 100644
--- a/tools/overlay.py
+++ b/tools/overlay.py
@@ -98,6 +98,10 @@ def geometry(rig):
for group, value in rig.items():
if group not in ("version", "image"):
walk(value, group, group)
+ if rig.get("arms"):
+ for side in ("left", "right"):
+ arm = rig["arms"][side]
+ add("arms", f"arms.{side}.bones", [arm["shoulder"], arm["elbow"], arm["wrist"]])
if "gazeCenter" not in rig["view"]:
add(
"view",
@@ -150,6 +154,8 @@ def overlay(project, rig_name, part, zoom, output):
color = colours[group]
if len(mapped) > 1:
draw.line(mapped + ([mapped[0]] if closed else []), fill=color, width=2)
+ if label.endswith(".bones"):
+ continue # Joint points already carry their own labels.
# Ellipse sampling has no user node indices; polylines do.
sampled_ellipse = len(points) in (33, 64)
for i, (x, y) in enumerate(mapped if not sampled_ellipse else mapped[:1]):
diff --git a/tools/test_agent_tools.py b/tools/test_agent_tools.py
index 4bdcd56..26714ed 100644
--- a/tools/test_agent_tools.py
+++ b/tools/test_agent_tools.py
@@ -116,6 +116,27 @@ class AgentToolsTest(unittest.TestCase):
Image.new("RGB", (100, 100)).save(wrong)
self.assertEqual(self.cli("new-project", wrong, name, "--force").returncode, 1)
+ def test_arms_overlay_includes_bones_joint_points_and_split(self):
+ overlay = module("overlay")
+ self.rig["view"] = {"gazeCenter": [50, 10]}
+ self.rig["arms"] = {
+ "left": {"shoulder": [25, 30], "elbow": [20, 50], "wrist": [15, 70], "split": [[30, 40], [25, 80]]},
+ "right": {"shoulder": [75, 30], "elbow": [80, 50], "wrist": [85, 70], "split": [[70, 40], [75, 80]]},
+ }
+ shapes = {path: points for group, path, points, _ in overlay.geometry(self.rig) if group == "arms"}
+ for side in ("left", "right"):
+ arm = self.rig["arms"][side]
+ self.assertEqual(shapes[f"arms.{side}.bones"], [arm["shoulder"], arm["elbow"], arm["wrist"]])
+ self.assertEqual(shapes[f"arms.{side}.split"], arm["split"])
+ for joint in ("shoulder", "elbow", "wrist"):
+ self.assertEqual(shapes[f"arms.{side}.{joint}"], [arm[joint]])
+ (self.project / "rig.json").write_text(json.dumps(self.rig))
+ output = self.project / "arms-overlay.png"
+ result = self.cli("overlay", self.project, "--part", "arms", "--out", output)
+ self.assertEqual(result.returncode, 0, result.stderr)
+ with Image.open(output) as image:
+ self.assertEqual(image.size, (100, 100))
+
def test_variants_cover_only_regions_and_missing_variants_are_clean(self):
eyes, mouth = edit_masks(self.rig, (100, 100))
self.assertEqual(int(eyes[0][30, 20]), 1)