Skip to content

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

Document creating an avatar with a coding agent

shinshin8612b05ff74d43
diff --git a/AGENTS.md b/AGENTS.md
new file mode 100644
index 0000000..9927f05
--- /dev/null
+++ b/AGENTS.md
@@ -0,0 +1,27 @@
+# Mesh Avatar Studio
+
+This repository contains a local editor and a data-driven WebGL mesh avatar engine.
+To create an avatar from an illustration, follow [docs/agent-guide.md](docs/agent-guide.md)
+in order, including coordinate calibration, zoomed grids, overlays and pose review.
+Field meanings are in [docs/rig-fields.md](docs/rig-fields.md).
+
+- Keep user images and all derived files in `projects/`. Never commit, upload or copy them
+ outside this repository. Ask the user before sending an image to any external service.
+- `projects/` and scratch `work/` are ignored. Do not stage them or bypass their ignore rules.
+- Keep `samples/` and `reference/` unchanged when preparing another illustration.
+- Visually inspect generated images before reporting success; report remaining defects.
+
+Use Node.js 22.17+ and Python 3.10+ with `uv`. Run:
+
+```sh
+npm run lint
+npm test
+npm run build
+npm run e2e
+uv run --with numpy --with pillow --with opencv-python-headless tools/test_build_layers.py
+uv run tools/test_agent_tools.py
+```
+
+The numerical deformation regression must remain 0 px (physics has floating-point tolerance).
+Use `npm run validate-rig -- projects/<name>/rig.draft.json` before building and
+`npm run render-poses -- projects/<name>` to produce local review images.
diff --git a/CLAUDE.md b/CLAUDE.md
new file mode 100644
index 0000000..43c994c
--- /dev/null
+++ b/CLAUDE.md
@@ -0,0 +1 @@
diff --git a/README.md b/README.md
index fa1ed06..d6594f4 100644
--- a/README.md
+++ b/README.md
@@ -6,16 +6,26 @@ fields; and test face angles, eye and mouth openings, breathing and secondary mo
## Run
-Requires Node.js 20.19+ or 22.12+.
+The editor requires Node.js 20.19+ or 22.12+. The agent command-line tools require 22.17+.
```sh
npm install
npm run dev
```
-Open the local URL printed by Vite. Use **Open rig** to load `rig.json`, then **Open image folder**
-to choose the folder containing your source and pre-cut assets. The folder may include its own
-`rig.json`; if present, it is loaded along with the images. Processing stays in the browser.
+Open the local URL printed by Vite. Choose **Open project** and select a project from the local
+list, or use **Browse for a project folder…** to select its folder. A project contains
+`rig.json`, `source.png` and `built/`. **Load rig.json only…** replaces the rig without loading images.
+The header shows a listed project's path; copy the full path or open its folder in your file manager.
+**Save rig** and Ctrl/Cmd+S save a listed project directly to `rig.json`, keeping the previous
+file as `rig.json.bak`. The sample is read-only, and browser-picked folders use a JSON download.
+Local project access is available only through the development server on 127.0.0.1; a static
+build keeps the folder picker and download workflow. Images stay on this machine.
+**Recent** keeps up to ten opened projects in this browser and can reopen the last project
+on start. Remove individual entries, clear the history, or disable automatic reopening in
+the project menu. Supported browsers retain a directory handle for picked folders and may
+ask for permission again; other browsers show **Browse again**. Image data is never stored
+in this history.
```text
project/
@@ -37,17 +47,100 @@ Source and cut-out images are not bundled. If you have the matching miko-qipao s
The app loads the sample automatically when its images are available. Otherwise it opens an
empty workspace. The included JSON files describe geometry and asset rectangles.
+## Create an avatar with your coding agent
+
+Give your illustration to a coding agent working in this repository and ask it to follow
+[the agent guide](docs/agent-guide.md). The agent calibrates its coordinate reading, prepares
+the rig with zoomed grids, builds local layers and reviews fixed poses before handing the
+project back for editing. Images and generated files stay in the ignored `projects/` folder.
+The guide recommends these setups:
+
+| Agent | Model |
+|---|---|
+| Claude Code | Claude Opus 5.5 |
+| Codex | GPT-6.1 Sol |
+
+The empty workspace offers a copyable project request. In **Drawn variants**, check
+**Eyes**, **Mouth**, or both to show a request for the current project. Open Codex in the
+displayed repository folder and paste the message. The development server automatically
+loads changed sprites into the current view.
+
+## Create a project from a new illustration
+
+The layer builder requires Python 3.10+ and [uv](https://docs.astral.sh/uv/).
+It runs locally with NumPy, Pillow and OpenCV; these are build tools, not browser dependencies.
+The other Python tools declare dependencies inline for bare `uv run`. The validator and
+pose renderer use Node.js 22.17+; install Node dependencies with `npm ci` and Chromium with
+`npx playwright install chromium` if needed. [Rig field descriptions](docs/rig-fields.md)
+explain coordinates and placement.
+
+1. Create a project folder and put your illustration in `source.png`. A PNG with a transparent
+ background works. Use a copy of your artwork when experimenting.
+2. Prepare `rig.draft.json`. Use `samples/miko-qipao/rig.json` as a schema example, set `image.width`
+ and `image.height` to your image dimensions, and place the geometry in source-image pixels.
+ Trace each eye's `opening` inside the lashes and its enclosing `roi` around the lash and lid
+ strokes. Place hair strand `nodes` from root to tip. Remove `hand`, `buns` and `accessories`
+ if absent; keep the required head, body, face, mouth, cheeks, mesh and view settings.
+ The eye fields `x0`, `x1`, `top` and `bot` can be omitted from the draft.
+3. From the repository root, build the layers:
+
+ ```sh
+ uv run --with numpy --with pillow --with opencv-python-headless tools/build-layers.py /path/to/project --rig rig.draft.json
+ ```
+
+ This writes `rig.json` with 24 sampled points for each eye's top and bottom curves, plus
+ `built/base.png`, `built/hairmask.png`, the four `eye{i}_ball/lash/low/crease.png` layers per
+ eye, and `built/layers.json`. Hand and accessory layers are generated only when present
+ in the rig. The input draft remains unchanged. Existing generated files are replaced;
+ optional drawn sprites are preserved. Without `--rig`, the input is `rig.json`.
+4. In the editor, choose **Open project** and select it from the list, or browse for the whole project
+ folder, including `source.png`, `rig.json` and `built/`. Use **Pose test** to check blinking
+ and face angles, and **Sweep angles** to check the full motion range.
+
+The builder estimates eyelid skin and line colours near each eye's ROI, and hair colours near
+the strand lines and buns. It follows connected colour regions within the head, buns and
+strand areas, using nearby skin and body colours to exclude non-hair pixels. Bright hair
+highlights or hair with several unrelated colours can leave gaps in the inferred mask.
+It does not trace eyes or invent hidden artwork automatically. Incorrect
+outlines can leave eye pixels behind during a blink or include skin in a moving layer. Inspect
+the result and adjust the rig in the editor. For a writable project opened from the local
+list, use **Save and rebuild layers** in the changed-outlines banner. It runs the local
+builder and reloads the preview, keeping selection, zoom and undo history. A failed build
+keeps the previous layers and offers a log. Browser-picked folders still require saving
+the JSON, running the command without `--rig`, and reopening the folder. Keep the original draft separately
+if you want to retain it. Drawn closed-eye and mouth variants are optional.
+
+Accessory colour masks currently use the rig's red-dominance thresholds (`color.redness` and
+`color.minRed`) inside each `box`. Hair and skin estimation assumes reasonably opaque pixels
+around the traced regions; fully translucent artwork or unrelated colours inside an eye ROI
+may need manual retouching. Inpainting approximates the artwork hidden behind hands and eyes.
+
## Editing
- Drag a handle or select an item to edit its numeric fields.
- Double-click a polygon/polyline edge to insert a vertex; Alt-click a vertex to remove it.
- Use the mouse wheel to zoom at the cursor; Space-drag or middle-drag to pan; **Fit** resets the view.
- **Undo** / **Redo** restore edits. Keyboard shortcuts: Ctrl/Cmd+Z, Ctrl/Cmd+Shift+Z and Ctrl/Cmd+S.
-- **Save rig** downloads the current JSON. Dropping a JSON file also loads it.
-- Disable **Idle animation** for a stable pose comparison, or use **Stress test** to sweep angles.
+- **Save rig** saves a listed project, or downloads the JSON for a browser-picked folder.
+ Dropping a JSON file also loads it.
+- Pause **Idle motion** for a stable pose comparison, or use **Sweep angles** to sweep angles.
+- Switch between the **Pose test** and **Lip sync** tabs under the preview. **Lip sync**
+ holds あ・い・う・え・お・ん, or plays kana text at 4–12 morae per second.
+ **Release** / **Stop** return control to the pose sliders. Drawn mouth images are used when
+ available; otherwise the mesh mouth animates. This check does not play audio.
+
+**Drawn variants** shows eye and mouth image counts. Check the drawings you want and
+copy the prepared agent message, which refers to the generation, import and review steps
+in the guide. Changes in the local project's `variants/` and `built/sprites/` directories
+reload in place, keeping unsaved outlines, selection, zoom and undo history. The sample's
+request asks the agent to work on a copy under `projects/`, leaving the original intact.
-Editing a cut-out outline marks the layers stale. Existing image pixels and sampled eye curves
-stay unchanged until the planned layer builder regenerates the assets.
+**If you prepare images yourself** is collapsed by default. Open it to export local masks
+and prompts with `variant-requests.py`, or to drop or choose full-size PNGs with the listed
+filenames. The editor validates dimensions and pixels outside the mask before building
+sprites; rejected imports keep the previous drawings and sprites. Manual export and import
+need a writable project from the development server. The app keeps images local; the
+agent request asks for your permission before sending images to an external generator.
## Verify
@@ -55,6 +148,7 @@ stay unchanged until the planned layer builder regenerates the assets.
npm run lint
npm test
npm run build
+uv run --with numpy --with pillow --with opencv-python-headless tools/test_build_layers.py
npx playwright install chromium
npm run e2e
```
diff --git a/docs/agent-guide.md b/docs/agent-guide.md
new file mode 100644
index 0000000..aca3894
--- /dev/null
+++ b/docs/agent-guide.md
@@ -0,0 +1,199 @@
+# Agent guide: turn one illustration into a mesh avatar
+
+This guide is for a coding agent (Claude Code, Codex, Cursor CLI or similar) working in this
+repository. A person gives you one illustration and asks for an avatar. You build a project
+that the editor can open and that animates cleanly; the person then fine-tunes it in the editor.
+
+Work through the steps in order. Each step ends with a check. Do not skip the checks: the
+quality of the result depends on looking at your own output and correcting it.
+
+## Before you start
+
+### Tools
+Node.js 22.17+, Python 3.10+ with [uv](https://docs.astral.sh/uv/), and Playwright Chromium
+(`npx playwright install chromium`). Run `npm install` once.
+
+### Model
+Reading pixel coordinates from images needs strong vision. These setups are known to work:
+
+| Agent | Model |
+|---|---|
+| Claude Code | Claude Opus 5.5 |
+| Codex | GPT-6.1 Sol |
+
+Tell the person which model you are running as. If it is not listed above, or you do not know,
+say that the result may fall short, name the recommended setups, and ask whether to continue.
+
+### Vision check
+Run the calibration test and report the score to the person:
+
+```sh
+uv run tools/vision-check.py make work/vision-check # writes an image with numbered markers
+# read the image, write your answer as JSON (see the command output for the format), then:
+uv run tools/vision-check.py score work/vision-check answer.json
+```
+
+If the score fails, stop and tell the person: coordinates read by this model are likely to be
+off, and most of the work below would need manual correction.
+
+### The image
+- Ask for a PNG, ideally with a transparent background, roughly front-facing, head and
+ shoulders visible. Warn the person if the face is in strong three-quarter view, if hands
+ or objects cover the face, or if the hair heavily overlaps the face: these limit quality.
+- The image stays on this machine inside `projects/`, which is not committed. Never commit,
+ upload or copy it elsewhere. The only exception is Step 6, and only after the person agrees:
+ generating drawn variants sends the image and a mask to an image generator.
+
+## Step 1 — Create the project
+
+```sh
+uv run tools/new-project.py <path/to/image.png> <name>
+```
+
+This creates `projects/<name>/` with `source.png` and an empty `rig.draft.json` that has the
+image size filled in. Field meanings are in `docs/rig-fields.md`; `samples/miko-qipao/rig.json`
+is a complete example.
+
+## Step 2 — Survey the image
+
+```sh
+uv run tools/grid.py projects/<name> --step 50 --out projects/<name>/work/grid-full.png
+```
+
+Look at the full grid image and write down, in your notes to the person:
+- face centre, top of head (including hair and accessories), chin, neck, shoulders;
+- which optional parts exist: hand near the face, hair buns, hanging accessories
+ (tassels, earrings), long hair over the shoulders;
+- anything the rig cannot represent yet (hats, glasses, objects held in front of the face).
+ Tell the person these will move rigidly with the head or body.
+
+## Step 3 — Draft the rig
+
+Fill `rig.draft.json` part by part. For each part, make a zoomed grid of its region first and
+read coordinates from it — never estimate from the full image alone.
+
+```sh
+uv run tools/grid.py projects/<name> --region x0,y0,x1,y1 --step 10 --out projects/<name>/work/grid-eyes.png
+```
+
+| Part | How to place it |
+|---|---|
+| head | Ellipse covering the whole head including hair and head accessories; centre slightly above the eyes. Pivot at the neck. `weightBand` starts just below the chin and ends near the collarbone. |
+| face | Small ellipses on nose, mouth, each eye, each visible ear, brow, jaw. |
+| eyes | `opening`: polygon along the visible eye white + iris, inside the lashes, 14–20 points, starting at the outer corner. `roi`: polygon 10–20 px outside the lashes and lower lid line. Use a 5 px grid for these. |
+| mouth | Line through the closed mouth (centre, angle, half length, bow) and an ellipse `area` a little larger than the lips. |
+| cheeks | Centre of each blush area. |
+| strands | One polyline per visible hair lock that should sway, root to tip, 4 nodes. Bangs: 3–5 locks. Side hair: 2 per side. |
+| body | Chest ellipse, one ellipse per shoulder, breath band from the upper chest to the bottom. |
+| buns, accessories, hand | Only if present. |
+| mesh, view | Start from the values in `samples/miko-qipao/rig.json`; set `mesh.fine` to a rectangle around the face and hair. |
+
+Leave `eyes[*].x0/x1/top/bot` out of the draft; the layer builder computes them.
+
+Notes:
+- Eye 0 is the eye on the image's left. Angles are in radians.
+- The head ellipse is an area of influence, not a cut-out. When covering all hair and head
+ accessories forces it to touch the top of the shoulders or a collar, cover the hair and
+ accept the small overlap.
+- For eye `roi`, the whole lash and lower lid line must be inside. If widening it would pull
+ in bangs or side hair, keep it tight around the lashes and list that eye as a place to check.
+- Your first draft is unverified until Check 3 passes.
+
+### Check 3
+```sh
+npm run validate-rig -- projects/<name>/rig.draft.json
+uv run tools/overlay.py projects/<name> --rig rig.draft.json --out projects/<name>/work/overlay.png
+uv run tools/overlay.py projects/<name> --rig rig.draft.json --part eyes --zoom --out projects/<name>/work/overlay-eyes.png
+```
+Look at every overlay and fix what is off. Pass when:
+- the head ellipse contains all hair and head accessories, and no shoulder;
+- each eye `opening` follows the eye white edge within about 2 px all around;
+- each `roi` contains the whole lash and lower lid line;
+- the mouth line lies on the drawn mouth;
+- strands lie on hair, not on skin or background.
+
+## Step 4 — Build layers
+
+```sh
+uv run --with numpy --with pillow --with opencv-python-headless tools/build-layers.py projects/<name> --rig rig.draft.json
+```
+
+This writes `projects/<name>/built/` and the complete `projects/<name>/rig.json`.
+
+### Check 4
+Open `built/hairmask.png` and the eye layers: the hair mask covers all hair and no face or
+clothing; each eye ball layer contains the eye white and iris only.
+
+## Step 5 — Review motion
+
+```sh
+npm run render-poses -- projects/<name>
+```
+
+This renders the avatar in fixed poses (rest, half and closed eyes, mouth open, turn left and
+right, look up and down, tilt, body tilt, and a hair sway sequence) into
+`projects/<name>/review/`, with a contact sheet and zoomed eye and mouth crops.
+
+Look at every frame. Pass when:
+- closed eyes are fully closed, with one clean lash line and no leftover iris or white;
+- turning ±30° and tilting do not tear the mesh, cut the chin or ears, or bend accessories;
+- the mouth opens without stretching the chin;
+- hair sways while face and clothing stay still.
+
+Review frames use a wider margin than the editor so the whole image is visible; framing
+differences between the two are expected.
+
+If a frame fails, adjust the related part of the draft, rebuild (Step 4) and render again.
+Stop after three rounds and report what still fails.
+
+Without drawn variants, a closed eye can keep faint fragments of the original upper lash or
+crease above the closed line. If iris and white are gone and only such faint lines remain,
+the rig is good enough: continue to Step 6, which removes them.
+
+## Step 6 — Drawn variants (closed eyes, mouth shapes)
+
+Blinking and talking look much better with drawn variants. Create the requests:
+
+```sh
+uv run tools/variant-requests.py projects/<name>
+```
+
+This writes `projects/<name>/variant-requests/` with, for each variant (closed / half /
+smiling eyes; mouths あ, half あ, い, お): an edit mask, the prompt, and a README.
+
+Ask the person before generating: image generation sends `source.png` and a mask to the
+generator. If they decline, stop here; the avatar still works without variants.
+
+- If you can generate images (for example Codex with image generation), generate each variant
+ from `source.png` and its mask following the prompt, and save it to
+ `projects/<name>/variants/<variant>.png`.
+- Otherwise stop here and tell the person exactly which files to give to an image generator
+ and where to put the results. Continue when they say the files are in place.
+
+In each mask, transparent pixels may change and opaque pixels must stay identical. Many
+generators recompress or shift the whole image; if a variant is rejected for changes outside
+the mask, generate it again, asking explicitly for identical size and untouched pixels outside
+the masked area.
+
+Then:
+```sh
+uv run tools/build-sprites.py projects/<name>
+```
+It rejects variants whose size differs from the source or that change pixels outside the
+mask, and cuts accepted variants into `built/sprites/`. Render the poses again (Step 5).
+
+## Step 7 — Hand over
+
+Tell the person:
+- how to open the project: `npm run dev`, then **Open project** and
+ choose `projects/<name>` from the list or browse for its folder;
+- which parts you are least sure about and should be checked first;
+- what the rig cannot represent in this image;
+- that after editing eye or hand outlines they should save the rig and ask you to rebuild.
+
+## Not acceptable
+- Coordinates estimated from the full image without zoomed grids.
+- Skipping the overlay or pose checks, or reporting success without looking at the images.
+- Eye openings that include lashes or skin; closed eyes that show iris.
+- Committing, uploading or copying the person's image or anything built from it.
+- Editing `samples/` or `reference/` to make a new image work.
diff --git a/docs/rig-fields.md b/docs/rig-fields.md
new file mode 100644
index 0000000..ace693a
--- /dev/null
+++ b/docs/rig-fields.md
@@ -0,0 +1,148 @@
+# Rig fields
+
+Version 1 uses the original `source.png` coordinate system: origin at the top left, x right,
+y down. Coordinates, radii, lengths, grid spacing and bands are **source pixels**; angles are
+**radians**, not the degrees used by the pose sliders. All numbers must be finite. Ellipse
+radii and mesh cell sizes must be positive. A band is `[start, end]` with `start < end`.
+Ellipses are smooth influence regions, not hard cut-out boundaries.
+
+Only `buns`, `strands`, `accessories`, `hand` and `view.gazeCenter` are optional. Omit absent
+optional groups. Required regions must still be placed even if their animation will be small.
+The initial draft has empty eye polygons and is intentionally invalid until they are traced.
+See [agent-guide.md](agent-guide.md) for the process and [rig-mapping.md](rig-mapping.md) for
+the engine mapping. Do not copy the example illustration's coordinates into a new image.
+
+| Field | Meaning, unit and placement |
+|---|---|
+| `version` | Schema version; set to `1`. |
+| `image.width` | Original PNG width, px; exact image dimensions. |
+| `image.height` | Original PNG height, px; exact image dimensions. |
+| `head.cx` | Head influence centre x, px; near the horizontal face centre. |
+| `head.cy` | Head influence centre y, px; slightly above the eyes. |
+| `head.rx` | Horizontal head radius, px; include hair and head accessories. |
+| `head.ry` | Vertical head radius, px; include crown and hair, avoid shoulders where possible. |
+| `head.shiftX` | Maximum horizontal face-turn displacement, px; start around 3–4% of image width. |
+| `head.shiftY` | Maximum vertical face-turn displacement, px; start around 2–3% of image height. |
+| `head.pivotX` | Head roll pivot x, px; centre of the neck. |
+| `head.pivotY` | Head roll pivot y, px; at the neck above the collarbone. |
+| `head.maxRoll` | Roll magnitude at a ±30° head pose, radians; start near `0.15`. |
+| `head.weightBand` | Y range, px, where head influence fades from full to zero; below chin to collarbone. |
+| `head.turnBand` | Y range, px, where face-turn displacement fades; below chin into upper chest. |
+| `body.pivotX` | Body roll pivot x, px; middle of the lower torso. |
+| `body.pivotY` | Body roll pivot y, px; near the bottom of the image. |
+| `body.maxRoll` | Body rotation at a ±10° body pose, radians; start near `0.035`. |
+| `body.breathBand` | Y range, px, where breathing fades to zero; upper chest to bottom. |
+| `body.rollBand` | Y range, px, where body roll fades to zero; upper body to anchored lower torso. |
+| `body.chest.cx` | Chest centre x, px; centre of visible upper torso. |
+| `body.chest.cy` | Chest centre y, px; below neck and above lower torso. |
+| `body.chest.rx` | Chest horizontal radius, px; cover torso inside the arms. |
+| `body.chest.ry` | Chest vertical radius, px; cover breathing region. |
+| `body.shoulders[*].cx` | Shoulder centre x, px; one ellipse per visible shoulder. |
+| `body.shoulders[*].cy` | Shoulder centre y, px; on the visible shoulder. |
+| `body.shoulders[*].rx` | Shoulder horizontal radius, px; cover shoulder width. |
+| `body.shoulders[*].ry` | Shoulder vertical radius, px; cover shoulder height. |
+| `face.nose.cx` | Horizontal centre, px; Nose influence ellipse, px; centre on nose tip, radii around bridge/tip region. |
+| `face.nose.cy` | Vertical centre, px; Nose influence ellipse, px; centre on nose tip, radii around bridge/tip region. |
+| `face.nose.rx` | Horizontal influence radius, px; Nose influence ellipse, px; centre on nose tip, radii around bridge/tip region. |
+| `face.nose.ry` | Vertical influence radius, px; Nose influence ellipse, px; centre on nose tip, radii around bridge/tip region. |
+| `face.mouth.cx` | Horizontal centre, px; Mouth movement influence ellipse, px; centre on lips, extend slightly into surrounding skin. |
+| `face.mouth.cy` | Vertical centre, px; Mouth movement influence ellipse, px; centre on lips, extend slightly into surrounding skin. |
+| `face.mouth.rx` | Horizontal influence radius, px; Mouth movement influence ellipse, px; centre on lips, extend slightly into surrounding skin. |
+| `face.mouth.ry` | Vertical influence radius, px; Mouth movement influence ellipse, px; centre on lips, extend slightly into surrounding skin. |
+| `face.eyeA.cx` | Horizontal centre, px; Image-left eye influence ellipse, px; cover eye and immediate surrounding skin. |
+| `face.eyeA.cy` | Vertical centre, px; Image-left eye influence ellipse, px; cover eye and immediate surrounding skin. |
+| `face.eyeA.rx` | Horizontal influence radius, px; Image-left eye influence ellipse, px; cover eye and immediate surrounding skin. |
+| `face.eyeA.ry` | Vertical influence radius, px; Image-left eye influence ellipse, px; cover eye and immediate surrounding skin. |
+| `face.eyeB.cx` | Horizontal centre, px; Image-right eye influence ellipse, px; cover eye and immediate surrounding skin. |
+| `face.eyeB.cy` | Vertical centre, px; Image-right eye influence ellipse, px; cover eye and immediate surrounding skin. |
+| `face.eyeB.rx` | Horizontal influence radius, px; Image-right eye influence ellipse, px; cover eye and immediate surrounding skin. |
+| `face.eyeB.ry` | Vertical influence radius, px; Image-right eye influence ellipse, px; cover eye and immediate surrounding skin. |
+| `face.earL.cx` | Horizontal centre, px; Image-left ear influence ellipse, px; centre on the ear location, even when hidden. |
+| `face.earL.cy` | Vertical centre, px; Image-left ear influence ellipse, px; centre on the ear location, even when hidden. |
+| `face.earL.rx` | Horizontal influence radius, px; Image-left ear influence ellipse, px; centre on the ear location, even when hidden. |
+| `face.earL.ry` | Vertical influence radius, px; Image-left ear influence ellipse, px; centre on the ear location, even when hidden. |
+| `face.earR.cx` | Horizontal centre, px; Image-right ear influence ellipse, px; centre on the ear location, even when hidden. |
+| `face.earR.cy` | Vertical centre, px; Image-right ear influence ellipse, px; centre on the ear location, even when hidden. |
+| `face.earR.rx` | Horizontal influence radius, px; Image-right ear influence ellipse, px; centre on the ear location, even when hidden. |
+| `face.earR.ry` | Vertical influence radius, px; Image-right ear influence ellipse, px; centre on the ear location, even when hidden. |
+| `face.brow.cx` | Horizontal centre, px; Brow influence ellipse, px; cover the visible eyebrow region, avoiding hair. |
+| `face.brow.cy` | Vertical centre, px; Brow influence ellipse, px; cover the visible eyebrow region, avoiding hair. |
+| `face.brow.rx` | Horizontal influence radius, px; Brow influence ellipse, px; cover the visible eyebrow region, avoiding hair. |
+| `face.brow.ry` | Vertical influence radius, px; Brow influence ellipse, px; cover the visible eyebrow region, avoiding hair. |
+| `face.brow.band` | Y range, px, fading brow movement from full to zero below brow. |
+| `face.jaw.cx` | Horizontal centre, px; Jaw influence ellipse, px; centre just above chin, cover lower jaw. |
+| `face.jaw.cy` | Vertical centre, px; Jaw influence ellipse, px; centre just above chin, cover lower jaw. |
+| `face.jaw.rx` | Horizontal influence radius, px; Jaw influence ellipse, px; centre just above chin, cover lower jaw. |
+| `face.jaw.ry` | Vertical influence radius, px; Jaw influence ellipse, px; centre just above chin, cover lower jaw. |
+| `face.jaw.band` | Y range, px, fading jaw influence from zero to full toward chin. |
+| `buns.bunL.cx` | Horizontal centre, px; Optional image-left bun ellipse, px; include whole bun, exclude ribbons. |
+| `buns.bunL.cy` | Vertical centre, px; Optional image-left bun ellipse, px; include whole bun, exclude ribbons. |
+| `buns.bunL.rx` | Horizontal influence radius, px; Optional image-left bun ellipse, px; include whole bun, exclude ribbons. |
+| `buns.bunL.ry` | Vertical influence radius, px; Optional image-left bun ellipse, px; include whole bun, exclude ribbons. |
+| `buns.bunR.cx` | Horizontal centre, px; Optional image-right bun ellipse, px; include whole bun, exclude ribbons. |
+| `buns.bunR.cy` | Vertical centre, px; Optional image-right bun ellipse, px; include whole bun, exclude ribbons. |
+| `buns.bunR.rx` | Horizontal influence radius, px; Optional image-right bun ellipse, px; include whole bun, exclude ribbons. |
+| `buns.bunR.ry` | Vertical influence radius, px; Optional image-right bun ellipse, px; include whole bun, exclude ribbons. |
+| `eyes` | Exactly two entries: index `0` is image-left, index `1` image-right (not anatomical left/right). |
+| `eyes[*].opening` | Polygon `[x,y]` points, px; trace eye white + iris inside lashes, 14–20 points from outer corner. |
+| `eyes[*].roi` | Polygon `[x,y]` points, px; surround full lashes and lower lid by about 10–20 px, avoid hair. |
+| `eyes[*].x0` | Generated leftmost opening x, px; omit in draft, builder computes it. |
+| `eyes[*].x1` | Generated rightmost opening x, px; omit in draft, builder computes it. |
+| `eyes[*].top` | Generated 24 upper-edge y samples, px, evenly spaced x0→x1; omit in draft. |
+| `eyes[*].bot` | Generated 24 lower-edge y samples, px, evenly spaced x0→x1; omit in draft. |
+| `mouth.cx` | Closed mouth line centre x, px; between lip corners. |
+| `mouth.cy` | Centre y of the straight line through lip corners, px; bow adds curvature. |
+| `mouth.angle` | Angle of lip-corner line, radians; positive slopes down to image-right. |
+| `mouth.halfLen` | Half length of lip-corner line, px; centre to either corner. |
+| `mouth.bow` | Downward curvature at the middle of mouth line, px; zero for a straight line. |
+| `mouth.area.cx` | Mouth sprite influence centre x, px; centre on lips. |
+| `mouth.area.cy` | Mouth sprite influence centre y, px; centre on lips. |
+| `mouth.area.rx` | Mouth edit region horizontal radius, px; slightly beyond corners. |
+| `mouth.area.ry` | Mouth edit region vertical radius, px; allow drawn open mouths without reaching chin. |
+| `mouth.area.angle` | Mouth edit ellipse rotation, radians; follow mouth line. |
+| `cheeks` | Exactly two `[x,y]` blush centres, px; image-left then image-right cheek. |
+| `strands[*].name` | Nonempty label for the hair lock; use distinct readable names. |
+| `strands[*].nodes` | Root-to-tip polyline of `[x,y]` points, px; start with four nodes entirely on hair. |
+| `strands[*].sigma` | Width of strand influence, px; around half the visible lock width. |
+| `strands[*].k` | Positive spring response multiplier, unitless; start near `1`. |
+| `strands[*].max` | Maximum hair displacement, px; start around 7–12. |
+| `accessories[*].name` | Unique safe layer filename stem (letters/digits/underscore/hyphen), not a reserved layer name. |
+| `accessories[*].pivot` | Hanging accessory root `[x,y]`, px; fixed attachment point. |
+| `accessories[*].tip` | Hanging accessory endpoint `[x,y]`, px; bottom of pendant/tassel. |
+| `accessories[*].split` | Split position along two-bone accessory, fraction strictly between 0 and 1; start near `0.4`. |
+| `accessories[*].box` | Integer `[x0,y0,x1,y1]` search rectangle, px; tightly bound accessory, x1/y1 exclusive. |
+| `accessories[*].color.redness` | Minimum `(R-max(G,B))/max(R,1)` ratio, 0–1; builder currently isolates red accessories only. |
+| `accessories[*].color.minRed` | Minimum red channel, 0–255; suppress dark background inside box. |
+| `hand.outline` | Polygon `[x,y]` points, px; trace the entire visible hand/forearm to cut out. |
+| `hand.jaw` | Visible jaw polyline `[x,y]`, px; sample both sides of the hand occlusion for interpolation. |
+| `hand.jawRange` | Increasing x range, px; jaw segment to reconstruct behind hand. |
+| `hand.background` | Polygon `[x,y]` points, px; background-side region behind hand, below jaw. |
+| `hand.elbow` | Elbow pivot `[x,y]`, px; may be outside the visible image. |
+| `hand.wrist` | Wrist pivot `[x,y]`, px; at wrist joint. |
+| `hand.knuckle` | Finger rotation pivot `[x,y]`, px; at knuckle near the face. |
+| `hand.contact` | Fingertip contact `[x,y]`, px; point pinned near chin as head moves. |
+| `hand.forearmShare` | Fraction 0–1 of arm rotation applied to forearm; start near `0.3`. |
+| `hand.armBand` | Y range, px, fading arm rotation to zero toward bottom of arm. |
+| `hand.wristBand` | Y range, px, fading wrist rotation to zero below wrist. |
+| `hand.handBand` | Y range, px, fading head/contact following below hand. |
+| `hand.fingerXBand` | X range, px, increasing finger influence toward image-right. |
+| `hand.fingerYBand` | Y range, px, fading finger influence toward bottom. |
+| `hand.pinBand` | Y range, px, increasing lower arm anchoring toward image bottom. |
+| `mesh.baseCell` | Coarse base-layer cell spacing, px; example `14`. |
+| `mesh.fine.x0` | Face/hair refinement rectangle left x, px; enclose moving features. |
+| `mesh.fine.x1` | Refinement rectangle right x, px; greater than x0. |
+| `mesh.fine.y0` | Refinement rectangle top y, px; above crown/hair. |
+| `mesh.fine.y1` | Refinement rectangle bottom y, px; below chin/hair tips. |
+| `mesh.fine.cell` | Fine base-layer cell spacing, px; example `7`, reduce only when detail needs it. |
+| `mesh.handCell` | Hand-layer cell spacing, px; example `9`. |
+| `mesh.tasselCell` | Hanging-accessory cell spacing, px; example `6`. |
+| `mesh.eyeBallCell` | Eye white/iris layer cell spacing, px; example `4`. |
+| `mesh.eyeCell` | Lash/lid layer cell spacing, px; example `3`. |
+| `mesh.spriteCell` | Drawn eye/mouth sprite cell spacing, px; example `4`. |
+| `view.padTop` | Top viewport margin as fraction of source height; negative crops crown, must be between -1 and 1. |
+| `view.padSide` | Each side viewport margin as fraction of source width; start at `0`, must exceed -0.5. |
+| `view.gazeCenter` | Optional pointer-follow origin `[x,y]`, px; between eyes; defaults to head centre. |
+
+Draft validation accepts omitted `x0/x1/top/bot` only as a complete group; supplying some of
+the four fields is an error. Complete rigs always require all four. Changing eye geometry
+requires rebuilding; old sampled curves cannot reconstruct new image pixels.