Skip to content

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

Add bilingual editor copy and shared part metadata

shinshin864c7692a0722e
diff --git a/src/editor/Icon.tsx b/src/editor/Icon.tsx
new file mode 100644
index 0000000..3dee311
--- /dev/null
+++ b/src/editor/Icon.tsx
@@ -0,0 +1,14 @@
+const paths = {
+ eye: 'M2 12s3-7 10-7 10 7 10 7-3 7-10 7S2 12 2 12Z M15 12a3 3 0 1 1-6 0 3 3 0 0 1 6 0Z',
+ hidden: 'M3 3l18 18 M9 5.5A12 12 0 0 1 12 5c7 0 10 7 10 7a18 18 0 0 1-4 4 M6 7c-3 2-4 5-4 5s3 7 10 7c2 0 3.5-.4 5-1.2',
+ save: 'M5 3h12l4 4v14H3V3h2Z M7 3v6h10V3 M7 21v-8h10v8',
+ undo: 'M9 4 3 10l6 6 M3 10h11a7 7 0 0 1 7 7v3',
+ redo: 'm15 4 6 6-6 6 M21 10H10a7 7 0 0 0-7 7v3',
+ play: 'm8 4 12 8-12 8V4Z', pause: 'M7 4v16 M17 4v16',
+ help: 'M9 8a3 3 0 1 1 5 2c-2 1-2 2-2 4 M12 18h.01 M22 12a10 10 0 1 1-20 0 10 10 0 0 1 20 0Z',
+ chevron: 'm7 10 5 5 5-5', close: 'm6 6 12 12 M6 18 18 6',
+};
+export function Icon({ name }: { name: keyof typeof paths }) {
+ return <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.7"
+ strokeLinecap="round" strokeLinejoin="round" aria-hidden="true"><path d={paths[name]} /></svg>;
+}
diff --git a/src/editor/i18n.tsx b/src/editor/i18n.tsx
new file mode 100644
index 0000000..67dbcf1
--- /dev/null
+++ b/src/editor/i18n.tsx
@@ -0,0 +1,150 @@
+import { createContext, useContext, useEffect, useState, type ReactNode } from 'react';
+
+export type Language = 'en' | 'ja';
+export const LANGUAGE_KEY = 'mesh-avatar-language';
+export const GUIDE_KEY = 'mesh-avatar-guide-seen';
+export function readPreference(key: string) {
+ try { return localStorage.getItem(key); } catch { return null; }
+}
+export function savePreference(key: string, value: string) {
+ try { localStorage.setItem(key, value); } catch { /* The editor also works without storage. */ }
+}
+
+const en = {
+ product: 'Mesh Avatar Studio', subtitle: 'Shape the motion in your illustration',
+ tools: 'Project tools', openProject: 'Open project', openRig: 'Open rig.json…', openFolder: 'Open image folder…',
+ rigFile: 'Open rig file', folderFiles: 'Open image folder files', save: 'Save rig', undo: 'Undo', redo: 'Redo',
+ help: 'Help', close: 'Close help', language: 'Language', english: 'English', japanese: '日本語', enCode: 'EN', jaCode: 'JA',
+ parts: 'Parts', faceSection: 'Face', hairSection: 'Hair & accessories', bodySection: 'Body', advanced: 'Advanced',
+ 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',
+ pickHint: 'Pick a part on the left, or click a dot', dragHint: 'Drag dots to move them',
+ lineHint: 'Drag dots · double-click a line to add a dot · Alt-click a dot to remove it',
+ panHint: 'Scroll to zoom · Space-drag to pan', noDots: 'Edit the values in the selected part card',
+ preview: 'Live preview', idle: 'Idle motion', play: 'Play idle motion', pause: 'Pause idle motion',
+ pose: 'Pose test', reset: 'Reset', sweep: 'Sweep angles', stopSweep: 'Stop sweep',
+ sweepTip: 'Swings the head through its full range to find tears',
+ turn: 'Turn left/right', look: 'Look up/down', tilt: 'Tilt', eyeOpen: 'Eyes open', mouthOpen: 'Mouth open', bodyTilt: 'Body tilt',
+ loading: 'Loading local assets…', updating: 'Updating preview…', ready: 'Engine ready', previewError: 'Preview could not load',
+ selection: 'Selected part', selectedItem: 'Selected rig item', selectPart: 'Select a part to edit it', tip: 'Tip',
+ guideTitle: 'Three steps to your first edit', guide1: 'Pick a part on the left', guide2: 'Drag its dots on the image',
+ guide3: 'Watch the preview on the right', gotIt: 'Got it', shortcuts: 'Keyboard & mouse', guideAgain: 'Show the guide again',
+ shortcutUndo: 'Undo / redo', shortcutSave: 'Save rig', shortcutPan: 'Pan the image', shortcutZoom: 'Zoom the image',
+ shortcutVertex: 'Add / remove a dot', spaceDrag: 'Space + drag', wheel: 'Scroll', vertexKeys: 'Double-click a line / Alt-click a dot',
+ stale: 'Outlines changed — cut-out images will be rebuilt by the layer builder (coming later). Preview still uses the old images.',
+ changedParts: 'Changed parts', checking: 'Checking for sample images…', emptyTitle: 'Open a project',
+ emptyHelp: 'Open rig.json and an image folder to begin. Sample images are installed separately.',
+ invalidRig: 'Could not open the rig file. Check the JSON and these field paths:',
+ invalidFolder: 'Could not open this folder. Include source.png, rig.json, layers.json and every cut-out image.',
+ invalidValue: 'Check the values at these field paths:', point: 'point', node: 'node', strand: 'Strand', eye: 'Eye',
+ accessory: 'Accessory', x: 'x', y: 'y', px: 'px',
+};
+const ja: typeof en = {
+ product: 'Mesh Avatar Studio', subtitle: 'イラストの動く範囲を調整',
+ tools: 'プロジェクト操作', openProject: 'プロジェクトを開く', openRig: '設定ファイルを開く…', openFolder: '画像フォルダーを開く…',
+ rigFile: '設定ファイルを開く', folderFiles: '画像フォルダーのファイルを開く', save: '設定を保存', undo: '元に戻す', redo: 'やり直す',
+ help: 'ヘルプ', close: 'ヘルプを閉じる', language: '言語', english: '英語', japanese: '日本語', enCode: '英語', jaCode: '日本語',
+ parts: 'パーツ', faceSection: '顔', hairSection: '髪・飾り', bodySection: '体', advanced: '詳細設定',
+ notPresent: 'この設定にはありません', show: 'ガイドを表示', hide: 'ガイドを非表示', showAll: 'すべて表示', hideAll: 'すべて非表示',
+ source: '元画像と動く範囲', canvas: '動く範囲の編集キャンバス', fit: '全体表示', zoom: '表示倍率',
+ pickHint: '左のパーツか、画像の点を選んでください', dragHint: '点をドラッグして位置を調整',
+ lineHint: '点をドラッグ · 線をダブルクリックで点を追加 · ⌥+点をクリックで削除',
+ panHint: 'スクロールで拡大・縮小 · スペース+ドラッグで移動', noDots: '右の選択パーツ欄で数値を調整',
+ preview: '動きのプレビュー', idle: '待機中の動き', play: '待機中の動きを再生', pause: '待機中の動きを一時停止',
+ pose: 'ポーズ確認', reset: 'リセット', sweep: '角度を連続確認', stopSweep: '連続確認を停止',
+ sweepTip: '頭を最大角度まで動かし、画像の隙間や破れを確認します',
+ turn: '顔を左右に向ける', look: '顔を上下に向ける', tilt: '頭を傾ける', eyeOpen: '目の開き', mouthOpen: '口の開き', bodyTilt: '体を傾ける',
+ loading: '画像を読み込み中…', updating: 'プレビューを更新中…', ready: 'プレビューの準備完了', previewError: 'プレビューを読み込めませんでした',
+ selection: '選択パーツ', selectedItem: '選択するパーツ', selectPart: 'パーツを選んで編集してください', tip: '調整のコツ',
+ guideTitle: '最初の編集は3ステップ', guide1: '左の一覧からパーツを選ぶ', guide2: '画像の点をドラッグする',
+ guide3: '右のプレビューで動きを見る', gotIt: 'わかりました', shortcuts: 'キーボード・マウス操作', guideAgain: '使い方をもう一度表示',
+ shortcutUndo: '元に戻す/やり直す', shortcutSave: '設定を保存', shortcutPan: '画像を移動', shortcutZoom: '画像を拡大・縮小',
+ shortcutVertex: '点を追加/削除', spaceDrag: 'スペース+ドラッグ', wheel: 'スクロール', vertexKeys: '線をダブルクリック/⌥+点をクリック',
+ stale: '輪郭が変更されました。切り抜き画像の再生成機能は今後追加予定です。プレビューには変更前の画像を使っています。',
+ changedParts: '変更されたパーツ', checking: 'サンプル画像を確認中…', emptyTitle: 'プロジェクトを開く',
+ emptyHelp: '設定ファイルと画像フォルダーを開いてください。サンプル画像は別途用意が必要です。',
+ invalidRig: '設定ファイルを開けませんでした。JSONの形式と次の項目を確認してください:',
+ invalidFolder: 'フォルダーを開けませんでした。source.png、rig.json、layers.json とすべての切り抜き画像を用意してください。',
+ invalidValue: '次の項目の数値を確認してください:', point: '点', node: '節点', strand: '髪の束', eye: '目',
+ accessory: '飾り', x: '横', y: '縦', px: '画素',
+};
+export const dictionaries = { en, ja };
+export type PartGroup = 'head' | 'eyes' | 'mouth' | 'face' | 'cheeks' | 'strands' | 'buns' | 'accessories' | 'body' | 'hand' | 'mesh' | 'view';
+const partText: Record<Language, Record<PartGroup, [string, string, string]>> = {
+ en: {
+ 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.'],
+ eyes: ['Eyes', 'Outline of each eye opening; drives blinking and gaze.', 'Trace the opening inside the eyelashes. Add dots where the contour changes direction.'],
+ mouth: ['Mouth', 'Closed-mouth line and the area for drawn mouth shapes.', 'Align the line with the closed mouth, and keep the surrounding area close to the lips.'],
+ face: ['Face features', 'Soft regions for nose, ears, brows and jaw.', 'Keep each region centred on its feature; adjust its size for a smooth transition.'],
+ cheeks: ['Blush', 'Where the blush appears.', 'Place one dot on each cheek, below the eyes.'],
+ strands: ['Hair strands', 'Lines that sway with physics.', 'Follow each strand from its root to its tip. Keep the root close to the scalp.'],
+ buns: ['Hair buns', 'Regions that bob as a whole.', 'Fit each circle around a bun without including the face.'],
+ accessories: ['Accessories', 'Pendulum parts such as tassels.', 'Place the pivot where the accessory attaches and the tip at its lowest point.'],
+ body: ['Body', 'Breathing and body sway.', 'Keep the rotation pivot low and place the breathing region over the chest.'],
+ hand: ['Hand', 'Hand outline and arm joints.', 'Trace the hand outline, then place the wrist and elbow joints.'],
+ mesh: ['Mesh', 'Mesh density.', 'Smaller cells add detail around the face but take more time to render.'],
+ view: ['Framing', 'Preview margins.', 'Adjust the margins so the head and accessories stay inside the preview.'],
+ },
+ ja: {
+ head: ['頭の向き', '顔を振ったり傾けたりするときに動く範囲。', '中心を顔の真ん中に置き、円が髪を含む頭全体を覆うように調整してください。'],
+ eyes: ['目', '目の開口部の輪郭。まばたきと視線に使う。', 'まつ毛の内側に沿って輪郭を置き、曲がる場所に点を追加してください。'],
+ mouth: ['口', '閉じた口の線と、口の形の差し替え範囲。', '線を閉じた口に合わせ、周囲の範囲を唇の近くに収めてください。'],
+ face: ['顔のパーツ', '鼻・耳・眉・あごの影響範囲。', '各範囲をパーツの中心に合わせ、大きさを調整して動きをなじませてください。'],
+ cheeks: ['頬', '頬の赤みが出る位置。', '左右の頬の、目より下に点を置いてください。'],
+ strands: ['髪の束', '物理演算で揺れる髪の線。', '根元から毛先へ線を置き、根元は頭皮の近くに合わせてください。'],
+ buns: ['お団子', 'まとまって揺れる範囲。', '顔を含めず、お団子を囲むように円を合わせてください。'],
+ accessories: ['飾り', '房飾りなどの振り子。', '付け根に支点を置き、いちばん下に先端を合わせてください。'],
+ body: ['体', '呼吸と体の揺れ。', '回転の支点を低い位置に置き、呼吸の範囲を胸に合わせてください。'],
+ hand: ['手', '手の輪郭と腕の関節。', '手の輪郭をなぞってから、手首と肘の位置を合わせてください。'],
+ mesh: ['メッシュ', 'メッシュの細かさ。', '格子を細かくすると顔の表現が細かくなりますが、描画の負荷が増えます。'],
+ view: ['表示範囲', 'プレビューの余白。', '頭や飾りがプレビューからはみ出さないように余白を調整してください。'],
+ },
+};
+const fieldText: Record<string, [string, string]> = {
+ image: ['Source image', '元画像'],
+ center: ['centre', '中心'], pivot: ['pivot', '支点'], rx: ['horizontal radius', '横の半径'], ry: ['vertical radius', '縦の半径'],
+ cx: ['Centre X', '中心の横位置'], cy: ['Centre Y', '中心の縦位置'], shiftX: ['Horizontal travel', '横の移動量'], shiftY: ['Vertical travel', '縦の移動量'],
+ pivotX: ['Pivot X', '支点の横位置'], pivotY: ['Pivot Y', '支点の縦位置'], maxRoll: ['Maximum tilt', '最大の傾き'],
+ weightBand: ['Head blend range', '頭の影響範囲'], turnBand: ['Turn blend range', '顔の向きの影響範囲'], breathBand: ['Breathing range', '呼吸の影響範囲'],
+ rollBand: ['Body tilt range', '体の傾きの影響範囲'], chest: ['Chest', '胸'], shoulders: ['Shoulders', '肩'],
+ nose: ['Nose', '鼻'], eyeA: ['First eye', '目の1番目'], eyeB: ['Second eye', '目の2番目'], earL: ['Left ear', '左耳'], earR: ['Right ear', '右耳'],
+ brow: ['Brows', '眉'], jaw: ['Jaw', 'あご'], band: ['Blend range', '影響範囲'], bunL: ['Left bun', '左のお団子'], bunR: ['Right bun', '右のお団子'],
+ opening: ['opening', '開口部'], roi: ['cut-out region', '切り抜き範囲'], x0: ['Left edge', '左端'], x1: ['Right edge', '右端'], y0: ['Top edge', '上端'], y1: ['Bottom edge', '下端'],
+ top: ['Upper lid curve', '上まぶたの曲線'], bot: ['Lower lid curve', '下まぶたの曲線'], angle: ['Angle', '角度'], halfLen: ['Half length', '長さの半分'],
+ bow: ['Curve depth', '曲線の深さ'], area: ['Drawing area', '差し替え範囲'], nodes: ['nodes', '節点'], sigma: ['Sway width', '揺れの幅'],
+ k: ['Sway strength', '揺れの強さ'], max: ['Maximum sway', '最大の揺れ'], tip: ['Tip', '先端'], split: ['Joint split', '関節の分割位置'],
+ box: ['Cut-out box', '切り抜き枠'], color: ['Colour mask', '色のマスク'], redness: ['Red threshold', '赤の比率'], minRed: ['Minimum red', '赤の最小値'],
+ outline: ['Outline', '輪郭'], jawRange: ['Jaw range', 'あごの範囲'], background: ['Background patch', '背景の補完範囲'],
+ elbow: ['Elbow', '肘'], wrist: ['Wrist', '手首'], knuckle: ['Knuckle', '指の付け根'], contact: ['Contact point', '接点'],
+ forearmShare: ['Forearm movement', '前腕の移動割合'], armBand: ['Arm blend range', '腕の影響範囲'], wristBand: ['Wrist blend range', '手首の影響範囲'],
+ handBand: ['Hand blend range', '手の影響範囲'], fingerXBand: ['Finger horizontal range', '指の横範囲'], fingerYBand: ['Finger vertical range', '指の縦範囲'], pinBand: ['Pinned range', '固定範囲'],
+ baseCell: ['Base cell size', '全体の格子幅'], fine: ['Fine mesh region', '細かい格子の範囲'], cell: ['Cell size', '格子幅'],
+ handCell: ['Hand cell size', '手の格子幅'], tasselCell: ['Accessory cell size', '飾りの格子幅'], eyeBallCell: ['Iris cell size', '瞳の格子幅'],
+ eyeCell: ['Eye cell size', '目の格子幅'], spriteCell: ['Drawing cell size', '差し替え画像の格子幅'],
+ padTop: ['Top margin', '上の余白'], padSide: ['Side margin', '左右の余白'], gazeCenter: ['Gaze centre', '視線の中心'], start: ['Start', '始点'], end: ['End', '終点'],
+};
+export function fieldTitle(path: string, language: Language) {
+ const t = dictionaries[language];
+ const parts = partText[language];
+ return path.split('.').map((key, i) => {
+ if (/^\d+$/.test(key)) return String(Number(key) + 1);
+ if (i === 0) {
+ if (key === 'eyes') return t.eye;
+ if (key === 'strands') return t.strand;
+ if (key === 'accessories') return t.accessory;
+ if (key in parts) return parts[key as PartGroup][0];
+ }
+ return fieldText[key]?.[language === 'en' ? 0 : 1] ?? key;
+ }).join(' · ');
+}
+const Context = createContext({ language: 'en' as Language, setLanguage: (_: Language) => { void _; } });
+export function I18nProvider({ children }: { children: ReactNode }) {
+ const [language, setLanguage] = useState<Language>(() => readPreference(LANGUAGE_KEY) === 'ja' ? 'ja' : 'en');
+ useEffect(() => { document.documentElement.lang = language; savePreference(LANGUAGE_KEY, language); }, [language]);
+ return <Context.Provider value={{ language, setLanguage }}>{children}</Context.Provider>;
+}
+export function useI18n() {
+ const context = useContext(Context);
+ return { ...context, t: dictionaries[context.language], parts: partText[context.language],
+ title: (path: string) => fieldTitle(path, context.language) };
+}
diff --git a/src/editor/parts.ts b/src/editor/parts.ts
new file mode 100644
index 0000000..56da560
--- /dev/null
+++ b/src/editor/parts.ts
@@ -0,0 +1,18 @@
+import type { Rig } from '../rig/types';
+import type { PartGroup } from './i18n';
+export const GROUPS: PartGroup[] = ['head', 'eyes', 'mouth', 'face', 'cheeks', 'strands', 'buns', 'accessories', 'body', 'hand', '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', 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'] },
+ { key: 'advanced', groups: ['mesh', 'view'] },
+] as const;
+export function partPresent(rig: Rig, group: PartGroup) {
+ const value = rig[group];
+ return !!value && (Array.isArray(value) ? value.length > 0 : typeof value !== 'object' || Object.keys(value).length > 0);
+}