@ikijs/mcp 0.19.1 → 0.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -7
- package/dist/{chunk-RBQJ5FJA.mjs → chunk-6F4ZP5S4.mjs} +289 -34
- package/dist/chunk-6F4ZP5S4.mjs.map +1 -0
- package/dist/cli.js +296 -47
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +1 -1
- package/dist/index.d.mts +21 -3
- package/dist/index.d.ts +21 -3
- package/dist/index.js +296 -47
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +3 -3
- package/dist/chunk-RBQJ5FJA.mjs.map +0 -1
package/dist/index.js
CHANGED
|
@@ -421,6 +421,22 @@ var STANDARD_PARAMETER_INFO = [
|
|
|
421
421
|
{
|
|
422
422
|
id: import_format.StandardParameter.ElbowRight,
|
|
423
423
|
description: "Right elbow, degrees; positive bends the forearm toward the body (the flexion of a hanging arm), negative a little outward (mirrored on the left)."
|
|
424
|
+
},
|
|
425
|
+
{
|
|
426
|
+
id: import_format.StandardParameter.ArmPoseLeft,
|
|
427
|
+
description: "Left pose-forearm switch, 0..1; 0 the hanging forearm, 1 the drawn pose forearm, between them a crossfade of the two. Declared by auto-rigged models with a pose forearm."
|
|
428
|
+
},
|
|
429
|
+
{
|
|
430
|
+
id: import_format.StandardParameter.ArmPoseRight,
|
|
431
|
+
description: "Right pose-forearm switch, 0..1; 0 the hanging forearm, 1 the drawn pose forearm, between them a crossfade of the two. Declared by auto-rigged models with a pose forearm."
|
|
432
|
+
},
|
|
433
|
+
{
|
|
434
|
+
id: import_format.StandardParameter.ArmPoseAngleLeft,
|
|
435
|
+
description: "Left pose forearm's own small rotation about the elbow, degrees; positive tips the raised hand outward, away from the body (mirrored on the right)."
|
|
436
|
+
},
|
|
437
|
+
{
|
|
438
|
+
id: import_format.StandardParameter.ArmPoseAngleRight,
|
|
439
|
+
description: "Right pose forearm's own small rotation about the elbow, degrees; positive tips the raised hand outward, away from the body (mirrored on the left)."
|
|
424
440
|
}
|
|
425
441
|
];
|
|
426
442
|
function listStandardParameters() {
|
|
@@ -636,7 +652,7 @@ async function autoRigFromLayers(input) {
|
|
|
636
652
|
var import_node_fs3 = __toESM(require("fs"));
|
|
637
653
|
var import_node_path6 = __toESM(require("path"));
|
|
638
654
|
var import_sharp3 = __toESM(require("sharp"));
|
|
639
|
-
var
|
|
655
|
+
var import_editor8 = require("@ikijs/editor");
|
|
640
656
|
|
|
641
657
|
// src/measure.ts
|
|
642
658
|
var import_node_fs2 = __toESM(require("fs"));
|
|
@@ -713,10 +729,96 @@ function capWarning(arm, g, body) {
|
|
|
713
729
|
return `${arm}: its shoulder cap reaches ${px(overlap)} px under the torso's edge on its pivot row (y=${row}), under half its radius (${px(need)} px) \u2014 a gap opens beside the shoulder once the arm raises. Move layout.${arm}.cx ${Math.ceil(need - overlap)} px toward the body (free).`;
|
|
714
730
|
}
|
|
715
731
|
|
|
732
|
+
// src/measure-forearm-pose.ts
|
|
733
|
+
var import_editor4 = require("@ikijs/editor");
|
|
734
|
+
var POSE_ROLES = ["forearm_pose_L", "forearm_pose_R"];
|
|
735
|
+
var ARM_OF = {
|
|
736
|
+
forearm_pose_L: "arm_L",
|
|
737
|
+
forearm_pose_R: "arm_R"
|
|
738
|
+
};
|
|
739
|
+
var POSE_PIVOT_TOLERANCE = 2;
|
|
740
|
+
var POSE_WIDTH_TOLERANCE = 0.1;
|
|
741
|
+
var POSE_LENGTH_TOLERANCE = 0.15;
|
|
742
|
+
function bottomRowY(layer) {
|
|
743
|
+
const painted = layer.rowRuns?.flatMap((runs, k2) => runs.length > 0 ? [k2] : []) ?? [];
|
|
744
|
+
const k = painted.at(-1) ?? layer.bbox.h - 1;
|
|
745
|
+
return layer.canvasH / 2 - (layer.bbox.y + k + 0.5);
|
|
746
|
+
}
|
|
747
|
+
async function forearmPoseWarnings(absDir, layers) {
|
|
748
|
+
const warnings = [];
|
|
749
|
+
for (const pose of POSE_ROLES) {
|
|
750
|
+
const stats = layers[pose];
|
|
751
|
+
if (stats === void 0) continue;
|
|
752
|
+
const arm = ARM_OF[pose];
|
|
753
|
+
const armStats = layers[arm];
|
|
754
|
+
if (armStats === void 0) {
|
|
755
|
+
warnings.push(
|
|
756
|
+
`${pose}: no ${arm} layer \u2014 a pose forearm hangs from its arm's elbow, and auto_rig_from_layers refuses it.`
|
|
757
|
+
);
|
|
758
|
+
continue;
|
|
759
|
+
}
|
|
760
|
+
if (stats.canvasW !== armStats.canvasW || stats.canvasH !== armStats.canvasH) {
|
|
761
|
+
warnings.push(
|
|
762
|
+
`${pose}: its canvas ${stats.canvasW}x${stats.canvasH} differs from ${arm}'s ${armStats.canvasW}x${armStats.canvasH} \u2014 auto_rig_from_layers refuses layers of different sizes; recompose them together.`
|
|
763
|
+
);
|
|
764
|
+
continue;
|
|
765
|
+
}
|
|
766
|
+
if (layers.body === void 0) continue;
|
|
767
|
+
const measurer = (0, import_editor4.createLayerSetMeasurer)({
|
|
768
|
+
width: stats.canvasW,
|
|
769
|
+
height: stats.canvasH
|
|
770
|
+
});
|
|
771
|
+
let a;
|
|
772
|
+
let armLayer;
|
|
773
|
+
try {
|
|
774
|
+
armLayer = await measured(measurer, absDir, arm);
|
|
775
|
+
a = (0, import_editor4.armGeometry)(armLayer, arm === "arm_R" ? Infinity : -Infinity);
|
|
776
|
+
} catch (err) {
|
|
777
|
+
if (err instanceof import_editor4.LayerGeometryError) continue;
|
|
778
|
+
throw err;
|
|
779
|
+
}
|
|
780
|
+
const b = (0, import_editor4.forearmPoseGeometry)(await measured(measurer, absDir, pose));
|
|
781
|
+
warnings.push(...jointWarnings(pose, arm, stats, a, armLayer, b));
|
|
782
|
+
}
|
|
783
|
+
return warnings;
|
|
784
|
+
}
|
|
785
|
+
function jointWarnings(pose, arm, stats, a, armLayer, b) {
|
|
786
|
+
const warnings = [];
|
|
787
|
+
const key = `layout.${pose}`;
|
|
788
|
+
const dx = a.elbow.x - b.pivot.x;
|
|
789
|
+
const dy = a.elbow.y - b.pivot.y;
|
|
790
|
+
const off = Math.hypot(dx, dy);
|
|
791
|
+
if (off > POSE_PIVOT_TOLERANCE) {
|
|
792
|
+
warnings.push(
|
|
793
|
+
`${pose}: its elbow end is ${px(off)} px off ${arm}'s elbow \u2014 the raised forearm detaches from the arm at the joint once it swaps in. Remove ${key}.cx/cy from the layout so it stays pinned on the elbow through later arm retunes (free), or set ${key}.cx to ${Math.round(stats.bboxCx + 0.5 + dx)} and ${key}.cy to ${Math.round(stats.bboxCy + 0.5 - dy)} (free).`
|
|
794
|
+
);
|
|
795
|
+
}
|
|
796
|
+
const armRun = a.seamRun[1] - a.seamRun[0];
|
|
797
|
+
const poseRun = 2 * b.radius;
|
|
798
|
+
const widthRatio = poseRun / armRun;
|
|
799
|
+
const widthBad = Math.abs(widthRatio - 1) > POSE_WIDTH_TOLERANCE;
|
|
800
|
+
if (widthBad) {
|
|
801
|
+
warnings.push(
|
|
802
|
+
`${pose}: its elbow end is ${px(poseRun)} px wide, ${Math.round(Math.abs(widthRatio - 1) * 100)}% off ${arm}'s elbow run (${px(armRun)} px) \u2014 the sleeve steps at the joint once it swaps in. Set ${key}.w to ${Math.round(stats.w / widthRatio)} (free).`
|
|
803
|
+
);
|
|
804
|
+
}
|
|
805
|
+
const armLen = a.elbow.y - bottomRowY(armLayer);
|
|
806
|
+
const poseLen = b.top - b.pivot.y;
|
|
807
|
+
const lengthRatio = poseLen / armLen;
|
|
808
|
+
if (Math.abs(lengthRatio - 1) > POSE_LENGTH_TOLERANCE) {
|
|
809
|
+
const fix = 1 / lengthRatio;
|
|
810
|
+
const freeFix = Math.abs(widthRatio * fix - 1) <= POSE_WIDTH_TOLERANCE;
|
|
811
|
+
warnings.push(
|
|
812
|
+
`${pose}: its length from the elbow end to the hand is ${px(poseLen)} px against ${arm}'s ${px(armLen)} px from its elbow to its hand \u2014 ` + (freeFix ? `the raised hand reaches the wrong height. Set ${key}.w to ${Math.round(stats.w * fix)} (free)` + (widthBad ? `, which fixes the width too.` : `.`) : `the raised hand reaches the wrong height, and no single w fits both its length and its width. Regenerate forearm_pose.png with the forearm and hand as long as the hanging arm's below its elbow. Billed.`)
|
|
813
|
+
);
|
|
814
|
+
}
|
|
815
|
+
return warnings;
|
|
816
|
+
}
|
|
817
|
+
|
|
716
818
|
// src/measure-turn.ts
|
|
717
819
|
var import_node_path4 = __toESM(require("path"));
|
|
718
|
-
var import_editor4 = require("@ikijs/editor");
|
|
719
820
|
var import_editor5 = require("@ikijs/editor");
|
|
821
|
+
var import_editor6 = require("@ikijs/editor");
|
|
720
822
|
var DEFAULT_IRIS = { hueMin: 230, hueMax: 300, satMin: 0.22 };
|
|
721
823
|
var IRIS_V_MIN = 0.18;
|
|
722
824
|
var IRIS_V_MAX = 0.95;
|
|
@@ -866,7 +968,7 @@ async function measureTurnImage(filePath, iris) {
|
|
|
866
968
|
let transparent = false;
|
|
867
969
|
if (hasAlpha) {
|
|
868
970
|
for (let i = 0; i < n; i++) {
|
|
869
|
-
if (rgba[i * 4 + 3] <
|
|
971
|
+
if (rgba[i * 4 + 3] < import_editor5.ALPHA_OPAQUE) {
|
|
870
972
|
transparent = true;
|
|
871
973
|
break;
|
|
872
974
|
}
|
|
@@ -877,7 +979,7 @@ async function measureTurnImage(filePath, iris) {
|
|
|
877
979
|
const fg = new Uint8Array(n);
|
|
878
980
|
const value = new Float32Array(n);
|
|
879
981
|
for (let i = 0; i < n; i++) {
|
|
880
|
-
if (rgba[i * 4 + 3] <
|
|
982
|
+
if (rgba[i * 4 + 3] < import_editor5.ALPHA_OPAQUE) continue;
|
|
881
983
|
const [hue, s, v] = rgbToHsv(rgba[i * 4], rgba[i * 4 + 1], rgba[i * 4 + 2]);
|
|
882
984
|
if (maskMode === "alpha") {
|
|
883
985
|
fg[i] = 1;
|
|
@@ -943,12 +1045,12 @@ async function measureTurnImage(filePath, iris) {
|
|
|
943
1045
|
}
|
|
944
1046
|
const [irisL, irisR] = best.pair;
|
|
945
1047
|
const eyeRow = Math.round((irisL.cy + irisR.cy) / 2);
|
|
946
|
-
const { left, right } = (0,
|
|
1048
|
+
const { left, right } = (0, import_editor5.foregroundSpan)(
|
|
947
1049
|
fg,
|
|
948
1050
|
width,
|
|
949
1051
|
height,
|
|
950
|
-
eyeRow -
|
|
951
|
-
eyeRow +
|
|
1052
|
+
eyeRow - import_editor5.HEAD_BAND,
|
|
1053
|
+
eyeRow + import_editor5.HEAD_BAND
|
|
952
1054
|
);
|
|
953
1055
|
if (right <= left) {
|
|
954
1056
|
throw new AutoRigInputError(
|
|
@@ -972,7 +1074,7 @@ async function measureTurnImage(filePath, iris) {
|
|
|
972
1074
|
left,
|
|
973
1075
|
right,
|
|
974
1076
|
cx: (left + right) / 2,
|
|
975
|
-
half: (0,
|
|
1077
|
+
half: (0, import_editor5.headHalfOf)({ left, right })
|
|
976
1078
|
},
|
|
977
1079
|
pairCx: (irisL.cx + irisR.cx) / 2,
|
|
978
1080
|
eyeGap: irisR.cx - irisL.cx
|
|
@@ -1154,7 +1256,7 @@ async function layerStats(filePath) {
|
|
|
1154
1256
|
};
|
|
1155
1257
|
}
|
|
1156
1258
|
var pct = (v) => `${(v * 100).toFixed(0)}%`;
|
|
1157
|
-
var isArm = (role) => ARM_ROLES.includes(role);
|
|
1259
|
+
var isArm = (role) => ARM_ROLES.includes(role) || POSE_ROLES.includes(role);
|
|
1158
1260
|
function noseSpeckWarning({ core, part }, source) {
|
|
1159
1261
|
const [found, consequence] = source === "compose" ? [
|
|
1160
1262
|
`the source part's dense core is ${core.w}x${core.h} in its ${part.w}x${part.h} trimmed part`,
|
|
@@ -1163,7 +1265,7 @@ function noseSpeckWarning({ core, part }, source) {
|
|
|
1163
1265
|
`the layer's dense core is ${core.w}x${core.h} in its ${part.w}x${part.h} crop`,
|
|
1164
1266
|
`auto_rig_from_layers turns and tilts the nose about its whole crop instead`
|
|
1165
1267
|
];
|
|
1166
|
-
return `nose: ${found} \u2014 under ${
|
|
1268
|
+
return `nose: ${found} \u2014 under ${import_editor6.SPECK_CORE_FRACTION} of its width or height, a speck: a lone nostril mark or highlight at alpha >= 128, not the drawing, so ${consequence}. Regenerate the nose with its shading painted denser, so the drawing itself reaches alpha 128. Billed.`;
|
|
1167
1269
|
}
|
|
1168
1270
|
async function lashOffSclera(eyePath, lashPath) {
|
|
1169
1271
|
const eye = await decodePng(eyePath);
|
|
@@ -1240,6 +1342,7 @@ async function measureDir(absDir, noseSpeck) {
|
|
|
1240
1342
|
}
|
|
1241
1343
|
}
|
|
1242
1344
|
warnings.push(...await armWarnings(absDir, layers));
|
|
1345
|
+
warnings.push(...await forearmPoseWarnings(absDir, layers));
|
|
1243
1346
|
for (const side of ["L", "R"]) {
|
|
1244
1347
|
const eye = layers[`eye_${side}`];
|
|
1245
1348
|
const iris = layers[`iris_${side}`];
|
|
@@ -1296,10 +1399,10 @@ async function measureDir(absDir, noseSpeck) {
|
|
|
1296
1399
|
warnings.push(noseSpeckWarning(noseSpeck, "compose"));
|
|
1297
1400
|
} else if (layers.nose !== void 0) {
|
|
1298
1401
|
const nose = await decodePng(import_node_path5.default.join(absDir, "nose.png"));
|
|
1299
|
-
const core = (0,
|
|
1402
|
+
const core = (0, import_editor6.denseCoreOf)(nose.rgba, nose.width, nose.height);
|
|
1300
1403
|
if (core !== null) {
|
|
1301
1404
|
const crop = detectAlphaBbox(nose.rgba, nose.width, nose.height);
|
|
1302
|
-
if ((0,
|
|
1405
|
+
if ((0, import_editor6.isSpeckCore)(core, crop))
|
|
1303
1406
|
warnings.push(noseSpeckWarning({ core, part: crop }, "layer"));
|
|
1304
1407
|
}
|
|
1305
1408
|
}
|
|
@@ -1358,12 +1461,12 @@ function formatMeasureReport(result) {
|
|
|
1358
1461
|
|
|
1359
1462
|
// src/compose-arms.ts
|
|
1360
1463
|
var import_sharp2 = __toESM(require("sharp"));
|
|
1361
|
-
var
|
|
1464
|
+
var import_editor7 = require("@ikijs/editor");
|
|
1362
1465
|
var ARM_WIDTH = 0.4;
|
|
1363
1466
|
var SHOULDER_DROP = 0.12;
|
|
1364
1467
|
async function armPlacement(role, cfg, part, body) {
|
|
1365
1468
|
const { data } = await (0, import_sharp2.default)(part.buf).ensureAlpha().raw().toBuffer({ resolveWithObject: true });
|
|
1366
|
-
const layer = (0,
|
|
1469
|
+
const layer = (0, import_editor7.createLayerSetMeasurer)({ width: part.w, height: part.h }).add({
|
|
1367
1470
|
role,
|
|
1368
1471
|
fileName: "arm.png",
|
|
1369
1472
|
rgba: data
|
|
@@ -1373,28 +1476,62 @@ async function armPlacement(role, cfg, part, body) {
|
|
|
1373
1476
|
`layout.${role}: arm.png is empty after alpha threshold once resized`
|
|
1374
1477
|
);
|
|
1375
1478
|
}
|
|
1376
|
-
let
|
|
1479
|
+
let g;
|
|
1377
1480
|
try {
|
|
1378
|
-
|
|
1379
|
-
layer,
|
|
1380
|
-
role === "arm_R" ? Infinity : -Infinity
|
|
1381
|
-
));
|
|
1481
|
+
g = (0, import_editor7.armGeometry)(layer, role === "arm_R" ? Infinity : -Infinity);
|
|
1382
1482
|
} catch (err) {
|
|
1383
|
-
if (err instanceof
|
|
1483
|
+
if (err instanceof import_editor7.LayerGeometryError) {
|
|
1384
1484
|
throw new AutoRigInputError(`layout.${role}: ${err.message}`);
|
|
1385
1485
|
}
|
|
1386
1486
|
throw err;
|
|
1387
1487
|
}
|
|
1388
|
-
const pivotX = shoulder.x + part.w / 2;
|
|
1389
|
-
const pivotY = part.h / 2 - shoulder.y;
|
|
1488
|
+
const pivotX = g.shoulder.x + part.w / 2;
|
|
1489
|
+
const pivotY = part.h / 2 - g.shoulder.y;
|
|
1390
1490
|
const cornerX = role === "arm_R" ? body.left : body.left + body.w;
|
|
1391
1491
|
const cornerY = body.top + SHOULDER_DROP * body.h;
|
|
1492
|
+
const left = Math.round(
|
|
1493
|
+
cfg.cx === void 0 ? cornerX - pivotX : cfg.cx - part.w / 2
|
|
1494
|
+
);
|
|
1495
|
+
const top = Math.round(
|
|
1496
|
+
cfg.cy === void 0 ? cornerY - pivotY : cfg.cy - part.h / 2
|
|
1497
|
+
);
|
|
1498
|
+
return {
|
|
1499
|
+
left,
|
|
1500
|
+
top,
|
|
1501
|
+
elbow: {
|
|
1502
|
+
x: left + g.elbow.x + part.w / 2,
|
|
1503
|
+
y: top + part.h / 2 - g.elbow.y
|
|
1504
|
+
},
|
|
1505
|
+
elbowRun: g.seamRun[1] - g.seamRun[0]
|
|
1506
|
+
};
|
|
1507
|
+
}
|
|
1508
|
+
async function poseGeometryOf(role, png, size, when) {
|
|
1509
|
+
const { data } = await (0, import_sharp2.default)(png).ensureAlpha().raw().toBuffer({ resolveWithObject: true });
|
|
1510
|
+
const layer = (0, import_editor7.createLayerSetMeasurer)({
|
|
1511
|
+
width: size.w,
|
|
1512
|
+
height: size.h
|
|
1513
|
+
}).add({ role, fileName: "forearm_pose.png", rgba: data });
|
|
1514
|
+
if (layer === null) {
|
|
1515
|
+
throw new AutoRigInputError(
|
|
1516
|
+
`layout.${role}: forearm_pose.png is empty after alpha threshold${when}`
|
|
1517
|
+
);
|
|
1518
|
+
}
|
|
1519
|
+
return (0, import_editor7.forearmPoseGeometry)(layer);
|
|
1520
|
+
}
|
|
1521
|
+
async function forearmPoseWidth(role, trimmed, elbowRun) {
|
|
1522
|
+
const g = await poseGeometryOf(role, trimmed.data, trimmed, "");
|
|
1523
|
+
return Math.max(1, Math.round(trimmed.w * elbowRun / (2 * g.radius)));
|
|
1524
|
+
}
|
|
1525
|
+
async function forearmPosePlacement(role, cfg, part, elbow) {
|
|
1526
|
+
const { pivot } = await poseGeometryOf(role, part.buf, part, " once resized");
|
|
1527
|
+
const pivotX = pivot.x + part.w / 2;
|
|
1528
|
+
const pivotY = part.h / 2 - pivot.y;
|
|
1392
1529
|
return {
|
|
1393
1530
|
left: Math.round(
|
|
1394
|
-
cfg.cx === void 0 ?
|
|
1531
|
+
cfg.cx === void 0 ? elbow.x - pivotX : cfg.cx - part.w / 2
|
|
1395
1532
|
),
|
|
1396
1533
|
top: Math.round(
|
|
1397
|
-
cfg.cy === void 0 ?
|
|
1534
|
+
cfg.cy === void 0 ? elbow.y - pivotY : cfg.cy - part.h / 2
|
|
1398
1535
|
)
|
|
1399
1536
|
};
|
|
1400
1537
|
}
|
|
@@ -1484,7 +1621,15 @@ var DEFAULT_LAYOUT = {
|
|
|
1484
1621
|
// prettier-ignore
|
|
1485
1622
|
brow_L: { src: "brow.png", cx: 645, cy: 405, w: 105, mirror: false },
|
|
1486
1623
|
brow_R: { src: "brow.png", cx: 455, cy: 405, w: 105, mirror: true },
|
|
1487
|
-
hair_front: { src: "hair_front.png", cx: 550, cy: 425, w: 660 }
|
|
1624
|
+
hair_front: { src: "hair_front.png", cx: 550, cy: 425, w: 660 },
|
|
1625
|
+
// The pose forearms, one drawing for both: forearm_pose_R (screen left)
|
|
1626
|
+
// takes forearm_pose.png as drawn and forearm_pose_L mirrors it, like the
|
|
1627
|
+
// arms. The rig draws them above the face and the hair, so they come last.
|
|
1628
|
+
// No cx/cy/w defaults: an unset `w` scales the forearm's elbow end to the
|
|
1629
|
+
// placed arm's elbow run, an unset `cx` or `cy` pins its elbow-end pivot
|
|
1630
|
+
// on the arm's elbow (ArmLayout). OPTIONAL and opt-in, like the arms.
|
|
1631
|
+
forearm_pose_L: { src: "forearm_pose.png", optional: true, mirror: true },
|
|
1632
|
+
forearm_pose_R: { src: "forearm_pose.png", optional: true, mirror: false }
|
|
1488
1633
|
};
|
|
1489
1634
|
var LOWER_LASH = { lash_lower_L: "eye_L", lash_lower_R: "eye_R" };
|
|
1490
1635
|
var LOWER_LASH_SRC = "eyewhite_lash_lower.png";
|
|
@@ -1509,7 +1654,9 @@ var ORDER = [
|
|
|
1509
1654
|
"lash_R",
|
|
1510
1655
|
"brow_L",
|
|
1511
1656
|
"brow_R",
|
|
1512
|
-
"hair_front"
|
|
1657
|
+
"hair_front",
|
|
1658
|
+
"forearm_pose_L",
|
|
1659
|
+
"forearm_pose_R"
|
|
1513
1660
|
];
|
|
1514
1661
|
var PART_FILES = [
|
|
1515
1662
|
...new Set(
|
|
@@ -1627,18 +1774,18 @@ function keyWhiteToAlpha(rgba) {
|
|
|
1627
1774
|
async function coreAndBoundsOf(png) {
|
|
1628
1775
|
const { data, info } = await (0, import_sharp3.default)(png).ensureAlpha().raw().toBuffer({ resolveWithObject: true });
|
|
1629
1776
|
return {
|
|
1630
|
-
core: (0,
|
|
1777
|
+
core: (0, import_editor6.denseCoreOf)(data, info.width, info.height),
|
|
1631
1778
|
bounds: { x: 0, y: 0, w: info.width, h: info.height }
|
|
1632
1779
|
};
|
|
1633
1780
|
}
|
|
1634
1781
|
async function hasCoverage(png) {
|
|
1635
1782
|
const { data, info } = await (0, import_sharp3.default)(png).ensureAlpha().raw().toBuffer({ resolveWithObject: true });
|
|
1636
|
-
return (0,
|
|
1783
|
+
return (0, import_editor8.detectAlphaBbox)(data, info.width, info.height) !== null;
|
|
1637
1784
|
}
|
|
1638
1785
|
async function noseSizingOf(png) {
|
|
1639
1786
|
const { core, bounds } = await coreAndBoundsOf(png);
|
|
1640
1787
|
if (core === null) return { box: bounds, whole: true };
|
|
1641
|
-
if ((0,
|
|
1788
|
+
if ((0, import_editor6.isSpeckCore)(core, bounds)) {
|
|
1642
1789
|
return {
|
|
1643
1790
|
box: bounds,
|
|
1644
1791
|
whole: true,
|
|
@@ -1650,7 +1797,7 @@ async function noseSizingOf(png) {
|
|
|
1650
1797
|
}
|
|
1651
1798
|
return { box: core, whole: false };
|
|
1652
1799
|
}
|
|
1653
|
-
async function
|
|
1800
|
+
async function trimmedPart(role, cfg, partsDir, inMemory, flipSource) {
|
|
1654
1801
|
let img;
|
|
1655
1802
|
if (inMemory !== void 0) {
|
|
1656
1803
|
img = (0, import_sharp3.default)(inMemory);
|
|
@@ -1678,7 +1825,14 @@ async function partBuffer(role, cfg, partsDir, inMemory, flipSource, canvas) {
|
|
|
1678
1825
|
}
|
|
1679
1826
|
if ((cfg.mirror ?? false) !== flipSource) img = img.flop();
|
|
1680
1827
|
const trimmed = await img.png().toBuffer({ resolveWithObject: true });
|
|
1681
|
-
|
|
1828
|
+
return {
|
|
1829
|
+
data: trimmed.data,
|
|
1830
|
+
w: trimmed.info.width,
|
|
1831
|
+
h: trimmed.info.height
|
|
1832
|
+
};
|
|
1833
|
+
}
|
|
1834
|
+
async function sizedPart(role, cfg, trimmed, canvas) {
|
|
1835
|
+
const { w: trimmedW, h: trimmedH } = trimmed;
|
|
1682
1836
|
const nose = role === "nose" ? await noseSizingOf(trimmed.data) : void 0;
|
|
1683
1837
|
const sized = nose?.box ?? { x: 0, y: 0, w: trimmedW, h: trimmedH };
|
|
1684
1838
|
const width = Math.round(trimmedW * cfg.w / sized.w);
|
|
@@ -1697,6 +1851,10 @@ async function partBuffer(role, cfg, partsDir, inMemory, flipSource, canvas) {
|
|
|
1697
1851
|
nose
|
|
1698
1852
|
};
|
|
1699
1853
|
}
|
|
1854
|
+
async function partBuffer(role, cfg, partsDir, inMemory, flipSource, canvas) {
|
|
1855
|
+
const trimmed = await trimmedPart(role, cfg, partsDir, inMemory, flipSource);
|
|
1856
|
+
return trimmed === null ? null : sizedPart(role, cfg, trimmed, canvas);
|
|
1857
|
+
}
|
|
1700
1858
|
function assertOnCanvas(source, w, h, left, top, canvas) {
|
|
1701
1859
|
if (left + w <= 0 || top + h <= 0 || left >= canvas.width || top >= canvas.height) {
|
|
1702
1860
|
throw new AutoRigInputError(
|
|
@@ -1769,7 +1927,7 @@ function boxWithoutStraySpecks(rgba, W, H) {
|
|
|
1769
1927
|
while (depth > 0) {
|
|
1770
1928
|
const p = stack[--depth];
|
|
1771
1929
|
size++;
|
|
1772
|
-
if (rgba[p * 4 + 3] >=
|
|
1930
|
+
if (rgba[p * 4 + 3] >= import_editor8.ALPHA_OPAQUE) opaque = true;
|
|
1773
1931
|
const px2 = p % W;
|
|
1774
1932
|
const py = (p - px2) / W;
|
|
1775
1933
|
setLeft = Math.min(setLeft, px2);
|
|
@@ -1810,7 +1968,7 @@ function detachedAboveWhite(rgba, W, H) {
|
|
|
1810
1968
|
for (let p = 0; p < n; p++) {
|
|
1811
1969
|
const alpha = rgba[p * 4 + 3];
|
|
1812
1970
|
if (alpha > 0 && luma(rgba, p * 4) >= EYE_LASH_LUMA)
|
|
1813
|
-
ink[p] = alpha >=
|
|
1971
|
+
ink[p] = alpha >= import_editor8.ALPHA_OPAQUE ? 2 : 1;
|
|
1814
1972
|
}
|
|
1815
1973
|
const label = new Int32Array(n).fill(-1);
|
|
1816
1974
|
const stack = new Int32Array(n);
|
|
@@ -1993,12 +2151,17 @@ async function composeLayersFromParts(input) {
|
|
|
1993
2151
|
mirrored.has(arm.src),
|
|
1994
2152
|
canvas
|
|
1995
2153
|
);
|
|
1996
|
-
const { left: left2, top: top2 } = await armPlacement(
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2154
|
+
const { left: left2, top: top2, elbow, elbowRun } = await armPlacement(
|
|
2155
|
+
key,
|
|
2156
|
+
arm,
|
|
2157
|
+
part2,
|
|
2158
|
+
{
|
|
2159
|
+
left: body.left,
|
|
2160
|
+
top: body.top,
|
|
2161
|
+
w: body.part.w,
|
|
2162
|
+
h: body.part.h
|
|
2163
|
+
}
|
|
2164
|
+
);
|
|
2002
2165
|
const unset = ["cx", "cy"].filter(
|
|
2003
2166
|
(field) => arm[field] === void 0
|
|
2004
2167
|
);
|
|
@@ -2010,6 +2173,58 @@ async function composeLayersFromParts(input) {
|
|
|
2010
2173
|
top2,
|
|
2011
2174
|
canvas
|
|
2012
2175
|
);
|
|
2176
|
+
placed.push({ role, part: part2, left: left2, top: top2, elbow, elbowRun });
|
|
2177
|
+
continue;
|
|
2178
|
+
}
|
|
2179
|
+
if (key === "forearm_pose_L" || key === "forearm_pose_R") {
|
|
2180
|
+
const pose = layout[key];
|
|
2181
|
+
if (!import_node_fs3.default.existsSync(import_node_path6.default.join(partsDir, pose.src))) continue;
|
|
2182
|
+
const armRole = key === "forearm_pose_L" ? "arm_L" : "arm_R";
|
|
2183
|
+
const arm = placed.find((p) => p.role === armRole);
|
|
2184
|
+
if (arm?.elbow === void 0 || arm.elbowRun === void 0) {
|
|
2185
|
+
throw new AutoRigInputError(
|
|
2186
|
+
"forearm_pose.png: a pose forearm needs arm.png \u2014 the composer pins it on the arm's elbow, and auto_rig_from_layers hangs it from the arm"
|
|
2187
|
+
);
|
|
2188
|
+
}
|
|
2189
|
+
const trimmed = await trimmedPart(
|
|
2190
|
+
role,
|
|
2191
|
+
pose,
|
|
2192
|
+
partsDir,
|
|
2193
|
+
void 0,
|
|
2194
|
+
mirrored.has(pose.src)
|
|
2195
|
+
);
|
|
2196
|
+
const w = pose.w ?? await forearmPoseWidth(key, trimmed, arm.elbowRun);
|
|
2197
|
+
let part2;
|
|
2198
|
+
try {
|
|
2199
|
+
part2 = await sizedPart(role, { ...pose, w }, trimmed, canvas);
|
|
2200
|
+
} catch (err) {
|
|
2201
|
+
if (pose.w === void 0 && err instanceof AutoRigInputError) {
|
|
2202
|
+
throw new AutoRigInputError(
|
|
2203
|
+
err.message.replace(
|
|
2204
|
+
`layout.${role}.w:`,
|
|
2205
|
+
`layout.${role}.w (unset: scaled to ${armRole}'s elbow run):`
|
|
2206
|
+
)
|
|
2207
|
+
);
|
|
2208
|
+
}
|
|
2209
|
+
throw err;
|
|
2210
|
+
}
|
|
2211
|
+
const { left: left2, top: top2 } = await forearmPosePlacement(
|
|
2212
|
+
key,
|
|
2213
|
+
pose,
|
|
2214
|
+
part2,
|
|
2215
|
+
arm.elbow
|
|
2216
|
+
);
|
|
2217
|
+
const unset = ["cx", "cy"].filter(
|
|
2218
|
+
(field) => pose[field] === void 0
|
|
2219
|
+
);
|
|
2220
|
+
assertOnCanvas(
|
|
2221
|
+
unset.length === 0 ? `layout.${key}.cx/cy` : `layout.${key}.cx/cy (${unset.join("/")} unset: its elbow-end pivot hangs on the elbow of layout.${armRole}'s placed arm)`,
|
|
2222
|
+
part2.w,
|
|
2223
|
+
part2.h,
|
|
2224
|
+
left2,
|
|
2225
|
+
top2,
|
|
2226
|
+
canvas
|
|
2227
|
+
);
|
|
2013
2228
|
placed.push({ role, part: part2, left: left2, top: top2 });
|
|
2014
2229
|
continue;
|
|
2015
2230
|
}
|
|
@@ -2053,6 +2268,10 @@ async function composeLayersFromParts(input) {
|
|
|
2053
2268
|
if (placed.some((p) => p.role === role)) continue;
|
|
2054
2269
|
import_node_fs3.default.rmSync(import_node_path6.default.join(outDir, `${role}.png`), { force: true });
|
|
2055
2270
|
}
|
|
2271
|
+
const posed = (role) => role === "forearm_pose_L" || role === "forearm_pose_R";
|
|
2272
|
+
if (!placed.some((p) => posed(p.role))) {
|
|
2273
|
+
import_node_fs3.default.rmSync(import_node_path6.default.join(outDir, "preview-pose.png"), { force: true });
|
|
2274
|
+
}
|
|
2056
2275
|
const layers = [];
|
|
2057
2276
|
const preview = [];
|
|
2058
2277
|
for (const { role, part, left, top } of placed) {
|
|
@@ -2067,7 +2286,7 @@ async function composeLayersFromParts(input) {
|
|
|
2067
2286
|
left,
|
|
2068
2287
|
top
|
|
2069
2288
|
});
|
|
2070
|
-
preview.push({ input: part.buf, left, top });
|
|
2289
|
+
if (!posed(role)) preview.push({ input: part.buf, left, top });
|
|
2071
2290
|
}
|
|
2072
2291
|
const previewPng = await (0, import_sharp3.default)({
|
|
2073
2292
|
create: {
|
|
@@ -2079,12 +2298,42 @@ async function composeLayersFromParts(input) {
|
|
|
2079
2298
|
}).composite(preview).png().toBuffer();
|
|
2080
2299
|
const previewPath = import_node_path6.default.join(outDir, "preview.png");
|
|
2081
2300
|
writeFileAtomic(previewPath, previewPng);
|
|
2301
|
+
let previewPosePath;
|
|
2302
|
+
if (placed.some((p) => posed(p.role))) {
|
|
2303
|
+
const pose = [];
|
|
2304
|
+
for (const { role, part, left, top, elbow } of placed) {
|
|
2305
|
+
const armPosed = elbow !== void 0 && placed.some(
|
|
2306
|
+
(p) => p.role === (role === "arm_L" ? "forearm_pose_L" : "forearm_pose_R")
|
|
2307
|
+
);
|
|
2308
|
+
if (!armPosed) {
|
|
2309
|
+
pose.push({ input: part.buf, left, top });
|
|
2310
|
+
continue;
|
|
2311
|
+
}
|
|
2312
|
+
const rows = Math.min(part.h, Math.max(1, Math.round(elbow.y - top)));
|
|
2313
|
+
pose.push({
|
|
2314
|
+
input: await (0, import_sharp3.default)(part.buf).extract({ left: 0, top: 0, width: part.w, height: rows }).png().toBuffer(),
|
|
2315
|
+
left,
|
|
2316
|
+
top
|
|
2317
|
+
});
|
|
2318
|
+
}
|
|
2319
|
+
const posePng = await (0, import_sharp3.default)({
|
|
2320
|
+
create: {
|
|
2321
|
+
width: canvas.width,
|
|
2322
|
+
height: canvas.height,
|
|
2323
|
+
channels: 4,
|
|
2324
|
+
background: { r: 245, g: 245, b: 248, alpha: 1 }
|
|
2325
|
+
}
|
|
2326
|
+
}).composite(pose).png().toBuffer();
|
|
2327
|
+
previewPosePath = import_node_path6.default.join(outDir, "preview-pose.png");
|
|
2328
|
+
writeFileAtomic(previewPosePath, posePng);
|
|
2329
|
+
}
|
|
2082
2330
|
return {
|
|
2083
2331
|
ok: true,
|
|
2084
2332
|
outDir,
|
|
2085
2333
|
layers,
|
|
2086
2334
|
skipped,
|
|
2087
2335
|
preview: previewPath,
|
|
2336
|
+
...previewPosePath === void 0 ? {} : { previewPose: previewPosePath },
|
|
2088
2337
|
measure: await measureDir(outDir, noseSpeck)
|
|
2089
2338
|
};
|
|
2090
2339
|
} catch (err) {
|
|
@@ -2098,7 +2347,7 @@ async function composeLayersFromParts(input) {
|
|
|
2098
2347
|
var import_mcp = require("@modelcontextprotocol/sdk/server/mcp.js");
|
|
2099
2348
|
var import_zod = require("zod");
|
|
2100
2349
|
function createIkiMcpServer() {
|
|
2101
|
-
const server = new import_mcp.McpServer({ name: "iki", version: "0.
|
|
2350
|
+
const server = new import_mcp.McpServer({ name: "iki", version: "0.20.0" });
|
|
2102
2351
|
server.registerTool(
|
|
2103
2352
|
"validate_iki",
|
|
2104
2353
|
{
|
|
@@ -2163,7 +2412,7 @@ function createIkiMcpServer() {
|
|
|
2163
2412
|
server.registerTool(
|
|
2164
2413
|
"auto_rig_from_layers",
|
|
2165
2414
|
{
|
|
2166
|
-
description: "Auto-rigs role-named PNG layers (face, eye_L/eye_R, mouth required; iris_L/R, brow_L/R, hair_front, body, arm_L/arm_R, etc. optional; an arm needs the body) into a renderable .iki written to disk. Pass full-canvas PNG file paths; returns the output path + summary (the model is NOT inlined). Filenames map to roles unless `fileName` is given.",
|
|
2415
|
+
description: "Auto-rigs role-named PNG layers (face, eye_L/eye_R, mouth required; iris_L/R, brow_L/R, hair_front, body, arm_L/arm_R, forearm_pose_L/forearm_pose_R, etc. optional; an arm needs the body, and a pose forearm needs its arm) into a renderable .iki written to disk. Pass full-canvas PNG file paths; returns the output path + summary (the model is NOT inlined). Filenames map to roles unless `fileName` is given.",
|
|
2167
2416
|
inputSchema: {
|
|
2168
2417
|
layers: import_zod.z.array(
|
|
2169
2418
|
import_zod.z.object({
|
|
@@ -2218,13 +2467,13 @@ function createIkiMcpServer() {
|
|
|
2218
2467
|
server.registerTool(
|
|
2219
2468
|
"compose_layers_from_parts",
|
|
2220
2469
|
{
|
|
2221
|
-
description: "Composes AI-generated part PNGs into canvas-aligned, role-named PNG layers on disk, ready for auto_rig_from_layers (the eyewhite split, alpha-trim/white-key, and placement pipeline the character-generation skill needs), with the same geometry report measure_layers returns standalone included inline. face, mouth, eyewhite, iris, brow, hair_front are required; hair_back, body, mouth_open, blush (one blush.png makes the blush_L/blush_R pair) and nose are optional \u2014 without a nose layer the head still turns on the rig's default profile, but it has no nose to lead the turn, and `auto_rig_from_layers` fits no turn to the art (`turnTargets` is inert, no `turn` report). One arm.png \u2014 the arm on the screen LEFT, drawn hanging with its shoulder at the top \u2014 makes both arms of a full body: arm_R takes it as drawn and arm_L mirrored. The arms are opt-in: without arm.png the compose is a bust's and `skipped` never lists them. arm.png needs body.png, and each arm is hung on the body's shoulder by default (see `layout`). The inline report carries the full-body checks too: a body whose feet a tall canvas's bottom cuts off, an arm without a body,
|
|
2470
|
+
description: "Composes AI-generated part PNGs into canvas-aligned, role-named PNG layers on disk, ready for auto_rig_from_layers (the eyewhite split, alpha-trim/white-key, and placement pipeline the character-generation skill needs), with the same geometry report measure_layers returns standalone included inline. face, mouth, eyewhite, iris, brow, hair_front are required; hair_back, body, mouth_open, blush (one blush.png makes the blush_L/blush_R pair) and nose are optional \u2014 without a nose layer the head still turns on the rig's default profile, but it has no nose to lead the turn, and `auto_rig_from_layers` fits no turn to the art (`turnTargets` is inert, no `turn` report). One arm.png \u2014 the arm on the screen LEFT, drawn hanging with its shoulder at the top \u2014 makes both arms of a full body: arm_R takes it as drawn and arm_L mirrored. The arms are opt-in: without arm.png the compose is a bust's and `skipped` never lists them. arm.png needs body.png, and each arm is hung on the body's shoulder by default (see `layout`). One forearm_pose.png \u2014 the arm's forearm raised, on the screen LEFT, standing up from its elbow with the hand at the top \u2014 makes both pose forearms (forearm_pose_R as drawn, forearm_pose_L mirrored): each is scaled so its elbow end is as wide as its arm's elbow run and pinned on that arm's elbow (see `layout`), and it needs arm.png. With one, preview-pose.png shows the switch at 1 as the rig draws it (the hanging forearms hidden below the elbow, the pose forearms over everything) while preview.png stays the rest pose; without one it is removed. The inline report carries the full-body checks too: a body whose feet a tall canvas's bottom cuts off, an arm without a body, an arm whose shoulder cap does not reach under the torso's edge, and a pose forearm without its arm or off its arm's elbow in pivot, width or length. A nose whose dense core is a speck \u2014 under a quarter of its trimmed part's width or height, such as a lone nostril mark or highlight \u2014 is sized and placed whole, and the inline report warns of it. A light mark drawn detached above the eye white, such as a double-eyelid crease, is dropped from the sclera (the iris's clip); dark strokes there stay lash ink. The eyewhite's dark lower lid \u2014 its line and lashes \u2014 becomes lash_lower_L/lash_lower_R, drawn over the iris; a white with none writes none and lists them in `skipped`.",
|
|
2222
2471
|
inputSchema: {
|
|
2223
2472
|
partsDir: import_zod.z.string().describe(
|
|
2224
2473
|
"Directory of the source part PNGs (resolved against cwd)."
|
|
2225
2474
|
),
|
|
2226
2475
|
outDir: import_zod.z.string().describe(
|
|
2227
|
-
"Existing directory to write the role layer PNGs + preview.png into (resolved against cwd; must already exist; confined to the working directory). Reused across runs: a role this run does not write \u2014 one it skips, or an arm once arm.png is gone \u2014 has its stale PNG from an earlier run deleted."
|
|
2476
|
+
"Existing directory to write the role layer PNGs + preview.png (and preview-pose.png when there is a forearm_pose.png) into (resolved against cwd; must already exist; confined to the working directory). Reused across runs: a role this run does not write \u2014 one it skips, or an arm or pose forearm once arm.png or forearm_pose.png is gone, preview-pose.png included \u2014 has its stale PNG from an earlier run deleted."
|
|
2228
2477
|
),
|
|
2229
2478
|
layout: import_zod.z.record(
|
|
2230
2479
|
import_zod.z.string(),
|
|
@@ -2235,10 +2484,10 @@ function createIkiMcpServer() {
|
|
|
2235
2484
|
h: import_zod.z.number()
|
|
2236
2485
|
}).partial()
|
|
2237
2486
|
).optional().describe(
|
|
2238
|
-
"Per-role override merged over the built-in defaults, keyed by role \u2014 hair_back, body, arm_L, arm_R, face, blush_L, blush_R, nose, mouth, mouth_open, eye_L, eye_R, iris_L, iris_R, lash_L, lash_R, brow_L, brow_R, hair_front \u2014 e.g. `{ eye_L: { cx: 660 } }`. `w` is an integer in 1..1100 (the canvas width) and `h` in 1..canvasHeight; omit `h` to keep the part's own aspect, set it to stretch. The defaults of the face's features \u2014 blush, nose, mouth, mouth_open, eyes, irises, lashes, brows \u2014 are proportions of the face: an override of face.cx, face.cy or face.w carries them with it (scaled by the width; face.h stretches the face alone), while a feature's own override names canvas px. The nose is sized and placed by its dense core (its pixels at alpha >= 128, the drawing inside a soft nose's feather), not its whole part: `w`/`h` size the core, `cx` centres it, and a set `cy` centres its rows. A nose whose core is a speck \u2014 under a quarter of the trimmed part's width or height, such as a lone nostril mark or highlight \u2014 is sized and placed whole instead, and the report warns of it. Its `cy` defaults to unset, which lands the core's bottom row (the tip) 0.66 of the way from the eye row down to the mouth's, so the nose follows a retuned eye or mouth row. eye_L/lash_L and eye_R/lash_R are cut from one eyewhite into one frame, so each pair must land on the same frame \u2014 a pair set to land apart is rejected. lash_lower_L/lash_lower_R are cut from it too and have no key: they land on their eye's frame. arm_L/arm_R have no cx/cy/w defaults: an unset `w` is 0.4 of the placed body's width, and an unset `cx` or `cy` hangs the arm's shoulder pivot \u2014 the one auto_rig_from_layers turns it about \u2014 on the body box's shoulder corner on that axis: its left edge for arm_R, its right edge for arm_L, 0.12 of its height under its top. A set one centres the arm as for every other role."
|
|
2487
|
+
"Per-role override merged over the built-in defaults, keyed by role \u2014 hair_back, body, arm_L, arm_R, face, blush_L, blush_R, nose, mouth, mouth_open, eye_L, eye_R, iris_L, iris_R, lash_L, lash_R, brow_L, brow_R, hair_front, forearm_pose_L, forearm_pose_R \u2014 e.g. `{ eye_L: { cx: 660 } }`. `w` is an integer in 1..1100 (the canvas width) and `h` in 1..canvasHeight; omit `h` to keep the part's own aspect, set it to stretch. The defaults of the face's features \u2014 blush, nose, mouth, mouth_open, eyes, irises, lashes, brows \u2014 are proportions of the face: an override of face.cx, face.cy or face.w carries them with it (scaled by the width; face.h stretches the face alone), while a feature's own override names canvas px. The nose is sized and placed by its dense core (its pixels at alpha >= 128, the drawing inside a soft nose's feather), not its whole part: `w`/`h` size the core, `cx` centres it, and a set `cy` centres its rows. A nose whose core is a speck \u2014 under a quarter of the trimmed part's width or height, such as a lone nostril mark or highlight \u2014 is sized and placed whole instead, and the report warns of it. Its `cy` defaults to unset, which lands the core's bottom row (the tip) 0.66 of the way from the eye row down to the mouth's, so the nose follows a retuned eye or mouth row. eye_L/lash_L and eye_R/lash_R are cut from one eyewhite into one frame, so each pair must land on the same frame \u2014 a pair set to land apart is rejected. lash_lower_L/lash_lower_R are cut from it too and have no key: they land on their eye's frame. arm_L/arm_R have no cx/cy/w defaults: an unset `w` is 0.4 of the placed body's width, and an unset `cx` or `cy` hangs the arm's shoulder pivot \u2014 the one auto_rig_from_layers turns it about \u2014 on the body box's shoulder corner on that axis: its left edge for arm_R, its right edge for arm_L, 0.12 of its height under its top. A set one centres the arm as for every other role. forearm_pose_L/forearm_pose_R have no cx/cy/w defaults either: an unset `w` scales the forearm so its elbow end (the shoulder rule run from its bottom) is as wide as the placed arm's elbow run, and an unset `cx` or `cy` pins that elbow end's pivot on the arm's elbow \u2014 the one auto_rig_from_layers hangs it from."
|
|
2239
2488
|
),
|
|
2240
2489
|
mirrorParts: import_zod.z.array(import_zod.z.string()).optional().describe(
|
|
2241
|
-
"Part files to flip left-right as they are read, e.g. `[\"eyewhite.png\"]`. The composer reads eyewhite.png as the eye on the screen LEFT (lash wing at the image's left end, lash-free tear duct at its right), brow.png as the brow on the screen RIGHT (thick head at the image's left end, tail at its right), blush.png as the blush on the screen LEFT (outer end, toward the face's edge, at the image's left end, inner end at its right),
|
|
2490
|
+
"Part files to flip left-right as they are read, e.g. `[\"eyewhite.png\"]`. The composer reads eyewhite.png as the eye on the screen LEFT (lash wing at the image's left end, lash-free tear duct at its right), brow.png as the brow on the screen RIGHT (thick head at the image's left end, tail at its right), blush.png as the blush on the screen LEFT (outer end, toward the face's edge, at the image's left end, inner end at its right), arm.png as the arm on the screen LEFT (the character's right, hanging, its shoulder at the image's top), and forearm_pose.png as the raised forearm on the screen LEFT (standing up from its elbow, the hand at the image's top, the thumb toward the body at the image's right); a part drawn the other way round is fixed here for free. It flips the source, so every role cut from it flips together and an eye's sclera and lash stay in one frame."
|
|
2242
2491
|
),
|
|
2243
2492
|
canvasHeight: import_zod.z.number().optional().describe(
|
|
2244
2493
|
"The canvas's height in px: an even integer in 1100..4096, default 1100 (a square bust canvas; at 1100 every output is byte-identical to leaving it out). The width stays 1100. The canvas grows downward: every default and every override keeps its canvas px from the top-left, so the head lands where it does on a bust and a full body gets room below. An odd height is refused \u2014 model space is centred on the canvas, so it would put the head on a half pixel \u2014 and it is checked before any part decodes."
|
|
@@ -2266,7 +2515,7 @@ function createIkiMcpServer() {
|
|
|
2266
2515
|
server.registerTool(
|
|
2267
2516
|
"measure_layers",
|
|
2268
2517
|
{
|
|
2269
|
-
description: "Reports read-only geometry checks over an already-composed layers directory \u2014 the same checks compose_layers_from_parts returns inline (iris ratio/offset, eye aspect, cropped/cut edges, a nose whose dense core is a speck of its crop, missing optional roles, a body whose feet a tall canvas's bottom cuts off, an arm without a body, an arm whose shoulder cap does not reach under the torso's edge on its shoulder pivot's row). Every preview*.png is skipped. Use to re-check a layers dir without recomposing. Its nose check reads the composed file against its crop, which is what auto_rig_from_layers acts on. Compose's inline report does the same unless the composer found the source part's core a speck, which it reports instead \u2014 so a speck that resampling erased from the layer shows there and not here.",
|
|
2518
|
+
description: "Reports read-only geometry checks over an already-composed layers directory \u2014 the same checks compose_layers_from_parts returns inline (iris ratio/offset, eye aspect, cropped/cut edges, a nose whose dense core is a speck of its crop, missing optional roles, a body whose feet a tall canvas's bottom cuts off, an arm without a body, an arm whose shoulder cap does not reach under the torso's edge on its shoulder pivot's row, a pose forearm without its arm or whose elbow end is off its arm's elbow in pivot, width or length). Every preview*.png is skipped. Use to re-check a layers dir without recomposing. Its nose check reads the composed file against its crop, which is what auto_rig_from_layers acts on. Compose's inline report does the same unless the composer found the source part's core a speck, which it reports instead \u2014 so a speck that resampling erased from the layer shows there and not here.",
|
|
2270
2519
|
inputSchema: {
|
|
2271
2520
|
layersDir: import_zod.z.string().describe(
|
|
2272
2521
|
"Directory of role-named layer PNGs (resolved against cwd)."
|