@ikijs/mcp 0.29.0 → 0.31.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 +17 -14
- package/dist/{chunk-IG2FZKTW.mjs → chunk-RLBRIAVN.mjs} +660 -123
- package/dist/chunk-RLBRIAVN.mjs.map +1 -0
- package/dist/cli.js +649 -121
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +1 -1
- package/dist/index.d.mts +147 -6
- package/dist/index.d.ts +147 -6
- package/dist/index.js +657 -121
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +9 -1
- package/dist/render-page.global.js +1085 -13
- package/package.json +3 -3
- package/dist/chunk-IG2FZKTW.mjs.map +0 -1
package/dist/index.js
CHANGED
|
@@ -32,13 +32,17 @@ var index_exports = {};
|
|
|
32
32
|
__export(index_exports, {
|
|
33
33
|
autoRigFromLayers: () => autoRigFromLayers,
|
|
34
34
|
checkModelFolds: () => checkModelFolds,
|
|
35
|
+
checkSweep: () => checkSweep,
|
|
35
36
|
composeLayersFromParts: () => composeLayersFromParts,
|
|
36
37
|
createIkiMcpServer: () => createIkiMcpServer,
|
|
37
38
|
describeIki: () => describeIki,
|
|
38
39
|
describeIkiAt: () => describeIkiAt,
|
|
40
|
+
describeRigPlan: () => describeRigPlan,
|
|
39
41
|
formatFoldReport: () => formatFoldReport,
|
|
40
42
|
formatMeasureReport: () => formatMeasureReport,
|
|
41
43
|
formatPhysicsReport: () => formatPhysicsReport,
|
|
44
|
+
formatRigPlanReport: () => formatRigPlanReport,
|
|
45
|
+
formatSweepReport: () => formatSweepReport,
|
|
42
46
|
formatTurnReport: () => formatTurnReport,
|
|
43
47
|
listStandardParameters: () => listStandardParameters,
|
|
44
48
|
measureLayers: () => measureLayers,
|
|
@@ -53,8 +57,8 @@ var getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${_
|
|
|
53
57
|
var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
|
|
54
58
|
|
|
55
59
|
// src/tools.ts
|
|
56
|
-
var
|
|
57
|
-
var
|
|
60
|
+
var import_node_fs5 = require("fs");
|
|
61
|
+
var import_node_path5 = __toESM(require("path"));
|
|
58
62
|
var import_format9 = require("@ikijs/format");
|
|
59
63
|
var import_editor3 = require("@ikijs/editor");
|
|
60
64
|
|
|
@@ -1014,6 +1018,7 @@ var HEAD_AND_GAZE = /* @__PURE__ */ new Set([
|
|
|
1014
1018
|
var import_format6 = require("@ikijs/format");
|
|
1015
1019
|
|
|
1016
1020
|
// ../engine/src/land.ts
|
|
1021
|
+
var UNIT_QUAD = [-0.5, -0.5, 0.5, -0.5, -0.5, 0.5, 0.5, 0.5];
|
|
1017
1022
|
function staticDeformers(model) {
|
|
1018
1023
|
return (model.deformers ?? []).map(
|
|
1019
1024
|
(d) => d.kind === "warp" ? { ...d, warps: void 0, warp2d: void 0 } : { ...d, bindings: void 0 }
|
|
@@ -1066,6 +1071,28 @@ function landPart(landing, store, { worlds, grids }) {
|
|
|
1066
1071
|
}
|
|
1067
1072
|
return landed;
|
|
1068
1073
|
}
|
|
1074
|
+
function landParts(model, values, partIds) {
|
|
1075
|
+
const deformers = model.deformers ?? [];
|
|
1076
|
+
const restStore = new ParameterStore(model.parameters);
|
|
1077
|
+
const store = new ParameterStore(model.parameters);
|
|
1078
|
+
for (const [id, value] of Object.entries(values)) store.set(id, value);
|
|
1079
|
+
const { worlds } = resolveDeformers(staticDeformers(model), restStore);
|
|
1080
|
+
const resolved = resolveDeformers(deformers, store);
|
|
1081
|
+
const out = /* @__PURE__ */ new Map();
|
|
1082
|
+
for (const id of partIds) {
|
|
1083
|
+
const part = model.parts.find((p) => p.id === id);
|
|
1084
|
+
if (!part) continue;
|
|
1085
|
+
const landing = landedPart(
|
|
1086
|
+
part,
|
|
1087
|
+
part.mesh?.vertices ?? UNIT_QUAD,
|
|
1088
|
+
deformers,
|
|
1089
|
+
worlds,
|
|
1090
|
+
restStore
|
|
1091
|
+
);
|
|
1092
|
+
out.set(id, Float32Array.from(landPart(landing, store, resolved)));
|
|
1093
|
+
}
|
|
1094
|
+
return out;
|
|
1095
|
+
}
|
|
1069
1096
|
|
|
1070
1097
|
// ../engine/src/folds.ts
|
|
1071
1098
|
var FLIP = 0;
|
|
@@ -1467,7 +1494,6 @@ function stopsOf(model, parameter) {
|
|
|
1467
1494
|
var DISPLACEMENT_PX = 1;
|
|
1468
1495
|
var PINNED_FRAMES = 60;
|
|
1469
1496
|
var TOLERANCE = 1e-9;
|
|
1470
|
-
var UNIT_QUAD = [-0.5, -0.5, 0.5, -0.5, -0.5, 0.5, 0.5, 0.5];
|
|
1471
1497
|
function checkPhysics(model) {
|
|
1472
1498
|
const idle = idleRun(model);
|
|
1473
1499
|
const displace = displacer(model);
|
|
@@ -1754,8 +1780,8 @@ function ratioText(ratio) {
|
|
|
1754
1780
|
}
|
|
1755
1781
|
|
|
1756
1782
|
// src/render-poses.ts
|
|
1757
|
-
var
|
|
1758
|
-
var
|
|
1783
|
+
var import_node_fs4 = require("fs");
|
|
1784
|
+
var import_node_path4 = __toESM(require("path"));
|
|
1759
1785
|
var import_format8 = require("@ikijs/format");
|
|
1760
1786
|
|
|
1761
1787
|
// src/limits.ts
|
|
@@ -2181,16 +2207,351 @@ async function withBrowser(executable, fn) {
|
|
|
2181
2207
|
}
|
|
2182
2208
|
}
|
|
2183
2209
|
|
|
2210
|
+
// src/sweep-report.ts
|
|
2211
|
+
var LADDER_MIN = -30;
|
|
2212
|
+
var LADDER_MAX = 30;
|
|
2213
|
+
var ZERO = -LADDER_MIN;
|
|
2214
|
+
var FLAT_SLOPE = 1e-4;
|
|
2215
|
+
var PARTS = ["face", "eye_L", "eye_R", "nose"];
|
|
2216
|
+
function box(pts, fw) {
|
|
2217
|
+
let x0 = Infinity;
|
|
2218
|
+
let x1 = -Infinity;
|
|
2219
|
+
let y0 = Infinity;
|
|
2220
|
+
let y1 = -Infinity;
|
|
2221
|
+
for (let i = 0; i < pts.length; i += 2) {
|
|
2222
|
+
x0 = Math.min(x0, pts[i]);
|
|
2223
|
+
x1 = Math.max(x1, pts[i]);
|
|
2224
|
+
y0 = Math.min(y0, pts[i + 1]);
|
|
2225
|
+
y1 = Math.max(y1, pts[i + 1]);
|
|
2226
|
+
}
|
|
2227
|
+
return {
|
|
2228
|
+
x: (x0 + x1) / 2 / fw,
|
|
2229
|
+
width: (x1 - x0) / fw,
|
|
2230
|
+
y: (y0 + y1) / 2 / fw
|
|
2231
|
+
};
|
|
2232
|
+
}
|
|
2233
|
+
function nearestVertex(face, fw, x, y) {
|
|
2234
|
+
let best = 0;
|
|
2235
|
+
let bestD = Infinity;
|
|
2236
|
+
for (let i = 0; i < face.length; i += 2) {
|
|
2237
|
+
const d = (face[i] / fw - x) ** 2 + (face[i + 1] / fw - y) ** 2;
|
|
2238
|
+
if (d < bestD) {
|
|
2239
|
+
bestD = d;
|
|
2240
|
+
best = i / 2;
|
|
2241
|
+
}
|
|
2242
|
+
}
|
|
2243
|
+
return best;
|
|
2244
|
+
}
|
|
2245
|
+
function kink(v) {
|
|
2246
|
+
const sMinus = (v[ZERO] - v[ZERO - 5]) / 5;
|
|
2247
|
+
const sPlus = (v[ZERO + 5] - v[ZERO]) / 5;
|
|
2248
|
+
const big = Math.max(Math.abs(sMinus), Math.abs(sPlus));
|
|
2249
|
+
if (big < FLAT_SLOPE) return null;
|
|
2250
|
+
return Math.abs(sPlus - sMinus) / big;
|
|
2251
|
+
}
|
|
2252
|
+
function pop(v) {
|
|
2253
|
+
let steps = 0;
|
|
2254
|
+
for (let i = 0; i + 1 < v.length; i++) steps += Math.abs(v[i + 1] - v[i]);
|
|
2255
|
+
const mean = steps / (v.length - 1);
|
|
2256
|
+
if (mean < 1e-9) return null;
|
|
2257
|
+
let most = 0;
|
|
2258
|
+
for (let i = 1; i + 1 < v.length; i++) {
|
|
2259
|
+
if (Math.abs(i - ZERO) <= 1) continue;
|
|
2260
|
+
most = Math.max(most, Math.abs(v[i + 1] - 2 * v[i] + v[i - 1]));
|
|
2261
|
+
}
|
|
2262
|
+
return most / mean;
|
|
2263
|
+
}
|
|
2264
|
+
function checkSweep(model) {
|
|
2265
|
+
const face = model.parts.find((p) => p.id === "face");
|
|
2266
|
+
if (!face) return { preset: "turn", unavailable: "no face part" };
|
|
2267
|
+
const hasEyes = ["eye_L", "eye_R"].every(
|
|
2268
|
+
(id) => model.parts.some((p) => p.id === id)
|
|
2269
|
+
);
|
|
2270
|
+
if (!hasEyes) {
|
|
2271
|
+
return { preset: "turn", unavailable: "no eye_L and eye_R parts" };
|
|
2272
|
+
}
|
|
2273
|
+
const fw = face.width;
|
|
2274
|
+
const ladder = Array.from(
|
|
2275
|
+
{ length: LADDER_MAX - LADDER_MIN + 1 },
|
|
2276
|
+
(_, i) => landParts(model, { ParamAngleX: LADDER_MIN + i }, PARTS)
|
|
2277
|
+
);
|
|
2278
|
+
const at = (id, i) => ladder[i].get(id);
|
|
2279
|
+
const ids = ["eye_L", "eye_R", ...ladder[0].has("nose") ? ["nose"] : []];
|
|
2280
|
+
const landmarks = ids.map((id) => {
|
|
2281
|
+
const boxes = ladder.map((_, i) => box(at(id, i), fw));
|
|
2282
|
+
const xs = boxes.map((b) => b.x);
|
|
2283
|
+
const plateIndex2 = nearestVertex(
|
|
2284
|
+
at("face", ZERO),
|
|
2285
|
+
fw,
|
|
2286
|
+
boxes[ZERO].x,
|
|
2287
|
+
boxes[ZERO].y
|
|
2288
|
+
);
|
|
2289
|
+
const plate = ladder.map((_, i) => at("face", i)[plateIndex2 * 2] / fw);
|
|
2290
|
+
const lead = (i) => xs[i] - plate[i] - (xs[ZERO] - plate[ZERO]);
|
|
2291
|
+
return {
|
|
2292
|
+
id,
|
|
2293
|
+
amplitude: xs[xs.length - 1] - xs[0],
|
|
2294
|
+
xKink: kink(xs),
|
|
2295
|
+
widthKink: id === "nose" ? null : kink(boxes.map((b) => b.width)),
|
|
2296
|
+
lead: { m30: lead(0), p30: lead(xs.length - 1) },
|
|
2297
|
+
pop: pop(xs)
|
|
2298
|
+
};
|
|
2299
|
+
});
|
|
2300
|
+
const eyes = ["eye_L", "eye_R"].map((id) => box(at(id, ZERO), fw));
|
|
2301
|
+
const plateIndex = nearestVertex(
|
|
2302
|
+
at("face", ZERO),
|
|
2303
|
+
fw,
|
|
2304
|
+
(eyes[0].x + eyes[1].x) / 2,
|
|
2305
|
+
(eyes[0].y + eyes[1].y) / 2
|
|
2306
|
+
);
|
|
2307
|
+
const plateX = (i) => at("face", i)[plateIndex * 2] / fw;
|
|
2308
|
+
return {
|
|
2309
|
+
preset: "turn",
|
|
2310
|
+
unit: "fw",
|
|
2311
|
+
faceWidth: fw,
|
|
2312
|
+
plateAmplitude: plateX(ladder.length - 1) - plateX(0),
|
|
2313
|
+
landmarks
|
|
2314
|
+
};
|
|
2315
|
+
}
|
|
2316
|
+
var fw3 = (v) => {
|
|
2317
|
+
const s = v.toFixed(3);
|
|
2318
|
+
return s === "-0.000" ? "0.000" : s;
|
|
2319
|
+
};
|
|
2320
|
+
var signed = (v) => fw3(v).startsWith("-") ? fw3(v) : `+${fw3(v)}`;
|
|
2321
|
+
var two = (v) => v === null ? "n/a" : v.toFixed(2);
|
|
2322
|
+
function formatSweepReport(report) {
|
|
2323
|
+
if ("unavailable" in report) {
|
|
2324
|
+
return [`SWEEP: unavailable \u2014 ${report.unavailable}`];
|
|
2325
|
+
}
|
|
2326
|
+
return [
|
|
2327
|
+
...report.landmarks.map(
|
|
2328
|
+
(l) => `SWEEP turn ${l.id}: amplitude ${fw3(l.amplitude)} fw, x kink ${two(l.xKink)}, width kink ${two(l.widthKink)}, lead -30 ${signed(l.lead.m30)} fw / +30 ${signed(l.lead.p30)} fw, pop ${two(l.pop)}`
|
|
2329
|
+
),
|
|
2330
|
+
`SWEEP turn plate: amplitude ${fw3(report.plateAmplitude)} fw`
|
|
2331
|
+
];
|
|
2332
|
+
}
|
|
2333
|
+
|
|
2334
|
+
// src/sweep.ts
|
|
2335
|
+
var import_node_fs3 = __toESM(require("fs"));
|
|
2336
|
+
var import_node_path3 = __toESM(require("path"));
|
|
2337
|
+
var SWEEP_CLOCK_HZ = 60;
|
|
2338
|
+
var SWEEP_FPS = 30;
|
|
2339
|
+
var SWEEP_DURATION_S = 3;
|
|
2340
|
+
var SWEEP_WARMUP_S = 0.5;
|
|
2341
|
+
var SWEEP_FRAME_MS = 1e3 / SWEEP_CLOCK_HZ * (1 + 1e-9);
|
|
2342
|
+
var SHEET_THETAS = [-30, -20, -10, -5, 0, 5, 10, 20, 30];
|
|
2343
|
+
var SHEET_MAX_SIDE = 2e3;
|
|
2344
|
+
var SHEET_MARGIN = 8;
|
|
2345
|
+
var SHEET_LABEL_BAND = 24;
|
|
2346
|
+
var KYMOGRAPH_BAND = 3;
|
|
2347
|
+
var SWEEP_PARAMETER = "ParamAngleX";
|
|
2348
|
+
var STEPS = SWEEP_CLOCK_HZ * SWEEP_DURATION_S;
|
|
2349
|
+
var CAPTURE_EVERY = SWEEP_CLOCK_HZ / SWEEP_FPS;
|
|
2350
|
+
var FRAMES = STEPS / CAPTURE_EVERY;
|
|
2351
|
+
var LEG_FROM_S = 0.75;
|
|
2352
|
+
var LEG_TO_S = 2.25;
|
|
2353
|
+
var AMPLITUDE_DEG = 30;
|
|
2354
|
+
function turnTheta(t) {
|
|
2355
|
+
return -AMPLITUDE_DEG * Math.sin(2 * Math.PI * t / SWEEP_DURATION_S);
|
|
2356
|
+
}
|
|
2357
|
+
function eyeRowModelPx(model) {
|
|
2358
|
+
const landed = landParts(model, {}, ["eye_L", "eye_R"]);
|
|
2359
|
+
const l = landed.get("eye_L");
|
|
2360
|
+
const r = landed.get("eye_R");
|
|
2361
|
+
if (!l || !r) return void 0;
|
|
2362
|
+
const centreY = (pts) => {
|
|
2363
|
+
let lo = Infinity;
|
|
2364
|
+
let hi = -Infinity;
|
|
2365
|
+
for (let i = 1; i < pts.length; i += 2) {
|
|
2366
|
+
lo = Math.min(lo, pts[i]);
|
|
2367
|
+
hi = Math.max(hi, pts[i]);
|
|
2368
|
+
}
|
|
2369
|
+
return (lo + hi) / 2;
|
|
2370
|
+
};
|
|
2371
|
+
return model.canvas.height / 2 - (centreY(l) + centreY(r)) / 2;
|
|
2372
|
+
}
|
|
2373
|
+
function physicsOutputIds(model) {
|
|
2374
|
+
const ids = /* @__PURE__ */ new Set();
|
|
2375
|
+
for (const rig of model.physics ?? []) ids.add(rig.output.parameter);
|
|
2376
|
+
for (const chain of model.physicsChains ?? []) {
|
|
2377
|
+
for (const seg of chain.segments) ids.add(seg.output.parameter);
|
|
2378
|
+
}
|
|
2379
|
+
return [...ids];
|
|
2380
|
+
}
|
|
2381
|
+
function sheetFrames(thetas) {
|
|
2382
|
+
const onLeg = [];
|
|
2383
|
+
for (let k = 0; k < FRAMES; k++) {
|
|
2384
|
+
const t = k / SWEEP_FPS;
|
|
2385
|
+
if (t >= LEG_FROM_S && t <= LEG_TO_S) onLeg.push(k);
|
|
2386
|
+
}
|
|
2387
|
+
const picked = [];
|
|
2388
|
+
for (const target2 of SHEET_THETAS) {
|
|
2389
|
+
let best = onLeg[0];
|
|
2390
|
+
for (const k of onLeg) {
|
|
2391
|
+
if (Math.abs(thetas[CAPTURE_EVERY * k] - target2) < Math.abs(thetas[CAPTURE_EVERY * best] - target2)) {
|
|
2392
|
+
best = k;
|
|
2393
|
+
}
|
|
2394
|
+
}
|
|
2395
|
+
if (!picked.includes(best)) picked.push(best);
|
|
2396
|
+
}
|
|
2397
|
+
return picked.sort((a, b) => a - b);
|
|
2398
|
+
}
|
|
2399
|
+
function sheetLabel(theta, t) {
|
|
2400
|
+
const rounded = Math.round(theta * 10) / 10 + 0;
|
|
2401
|
+
const deg = rounded.toFixed(1);
|
|
2402
|
+
const signed2 = rounded > 0 ? `+${deg}` : deg.replace("-", "\u2212");
|
|
2403
|
+
return `\u03B8 ${signed2}\xB0 t ${t.toFixed(2)} s`;
|
|
2404
|
+
}
|
|
2405
|
+
function sweepSpec(model, crop) {
|
|
2406
|
+
const thetas = Array.from(
|
|
2407
|
+
{ length: STEPS },
|
|
2408
|
+
(_, j) => turnTheta(j / SWEEP_CLOCK_HZ)
|
|
2409
|
+
);
|
|
2410
|
+
const dw = crop ? crop.dw : BUST_SIZE;
|
|
2411
|
+
const dh = crop ? crop.dh : BUST_SIZE;
|
|
2412
|
+
const m = SHEET_MARGIN;
|
|
2413
|
+
const b = SHEET_LABEL_BAND;
|
|
2414
|
+
const scale2 = Math.min(
|
|
2415
|
+
1,
|
|
2416
|
+
(SHEET_MAX_SIDE - 2 * m) / (3 * dw),
|
|
2417
|
+
(SHEET_MAX_SIDE - 2 * m - 3 * b) / (3 * dh)
|
|
2418
|
+
);
|
|
2419
|
+
const frames = sheetFrames(thetas);
|
|
2420
|
+
const { width: W, height: H } = model.canvas;
|
|
2421
|
+
const yModel = eyeRowModelPx(model);
|
|
2422
|
+
let row = Math.round(dh / 2);
|
|
2423
|
+
let at = "middle";
|
|
2424
|
+
if (yModel !== void 0) {
|
|
2425
|
+
const y0 = bustPadY(W, H);
|
|
2426
|
+
const s = BUST_SIZE / W;
|
|
2427
|
+
const eyeRow = Math.round(
|
|
2428
|
+
crop ? (y0 + yModel * s - crop.sy) * crop.dh / crop.sh : y0 + yModel * s
|
|
2429
|
+
);
|
|
2430
|
+
if (eyeRow >= 1 && eyeRow <= dh - 2) {
|
|
2431
|
+
row = eyeRow;
|
|
2432
|
+
at = "eye row";
|
|
2433
|
+
}
|
|
2434
|
+
}
|
|
2435
|
+
return {
|
|
2436
|
+
parameter: SWEEP_PARAMETER,
|
|
2437
|
+
frameMs: SWEEP_FRAME_MS,
|
|
2438
|
+
warmup: SWEEP_WARMUP_S * SWEEP_CLOCK_HZ,
|
|
2439
|
+
thetas,
|
|
2440
|
+
captureEvery: CAPTURE_EVERY,
|
|
2441
|
+
frames: FRAMES,
|
|
2442
|
+
frame: { width: dw, height: dh },
|
|
2443
|
+
physicsOutputs: physicsOutputIds(model),
|
|
2444
|
+
sheet: {
|
|
2445
|
+
frames,
|
|
2446
|
+
cell: {
|
|
2447
|
+
w: Math.max(1, Math.floor(dw * scale2)),
|
|
2448
|
+
h: Math.max(1, Math.floor(dh * scale2))
|
|
2449
|
+
},
|
|
2450
|
+
margin: m,
|
|
2451
|
+
labelBand: b,
|
|
2452
|
+
labels: frames.map(
|
|
2453
|
+
(k) => sheetLabel(thetas[CAPTURE_EVERY * k], k / SWEEP_FPS)
|
|
2454
|
+
)
|
|
2455
|
+
},
|
|
2456
|
+
kymograph: { row, band: KYMOGRAPH_BAND, at },
|
|
2457
|
+
crop
|
|
2458
|
+
};
|
|
2459
|
+
}
|
|
2460
|
+
function flipbookHtml(manifest) {
|
|
2461
|
+
const json = JSON.stringify(manifest).replace(/</g, "\\u003c");
|
|
2462
|
+
return `<!doctype html>
|
|
2463
|
+
<html lang="en">
|
|
2464
|
+
<head>
|
|
2465
|
+
<meta charset="utf-8">
|
|
2466
|
+
<title>turn sweep</title>
|
|
2467
|
+
<style>
|
|
2468
|
+
body { font: 14px system-ui, sans-serif; margin: 16px; background: #222; color: #eee; }
|
|
2469
|
+
.row { display: flex; gap: 16px; align-items: flex-start; }
|
|
2470
|
+
img { max-width: 48vw; height: auto; background: #444; }
|
|
2471
|
+
#b { display: none; }
|
|
2472
|
+
#controls { margin: 12px 0; display: flex; gap: 12px; align-items: center; }
|
|
2473
|
+
#scrub { flex: 1; max-width: 640px; }
|
|
2474
|
+
</style>
|
|
2475
|
+
</head>
|
|
2476
|
+
<body>
|
|
2477
|
+
<div class="row"><img id="a" alt="A"><img id="b" alt="B"></div>
|
|
2478
|
+
<div id="controls">
|
|
2479
|
+
<button id="play" type="button">pause</button>
|
|
2480
|
+
<input id="scrub" type="range" min="0" value="0" step="1">
|
|
2481
|
+
<span id="readout"></span>
|
|
2482
|
+
</div>
|
|
2483
|
+
<p>Add <code>?b=<relative dir></code> to the address to show another sweep beside this one; it must be a sweep of the same preset, since frames are matched by file name.</p>
|
|
2484
|
+
<script id="manifest" type="application/json">${json}</script>
|
|
2485
|
+
<script>
|
|
2486
|
+
(function () {
|
|
2487
|
+
var m = JSON.parse(document.getElementById("manifest").textContent);
|
|
2488
|
+
var b = new URLSearchParams(location.search).get("b");
|
|
2489
|
+
var a = document.getElementById("a");
|
|
2490
|
+
var bi = document.getElementById("b");
|
|
2491
|
+
var scrub = document.getElementById("scrub");
|
|
2492
|
+
var readout = document.getElementById("readout");
|
|
2493
|
+
var play = document.getElementById("play");
|
|
2494
|
+
var n = m.frames.length;
|
|
2495
|
+
var i = 0;
|
|
2496
|
+
var playing = true;
|
|
2497
|
+
scrub.max = String(n - 1);
|
|
2498
|
+
if (b) { bi.style.display = "block"; }
|
|
2499
|
+
function show(k) {
|
|
2500
|
+
i = k;
|
|
2501
|
+
var f = m.frames[k];
|
|
2502
|
+
a.src = f.file;
|
|
2503
|
+
if (b) { bi.src = b.replace(/\\/$/, "") + "/" + f.file; }
|
|
2504
|
+
scrub.value = String(k);
|
|
2505
|
+
readout.textContent = "frame " + k + " \\u03b8 " + f.theta.toFixed(1) + "\\u00b0 t " + f.t.toFixed(2) + " s";
|
|
2506
|
+
}
|
|
2507
|
+
play.addEventListener("click", function () {
|
|
2508
|
+
playing = !playing;
|
|
2509
|
+
play.textContent = playing ? "pause" : "play";
|
|
2510
|
+
});
|
|
2511
|
+
scrub.addEventListener("input", function () {
|
|
2512
|
+
playing = false;
|
|
2513
|
+
play.textContent = "play";
|
|
2514
|
+
show(Number(scrub.value));
|
|
2515
|
+
});
|
|
2516
|
+
setInterval(function () { if (playing) { show((i + 1) % n); } }, 1000 / m.fps);
|
|
2517
|
+
show(0);
|
|
2518
|
+
})();
|
|
2519
|
+
</script>
|
|
2520
|
+
</body>
|
|
2521
|
+
</html>
|
|
2522
|
+
`;
|
|
2523
|
+
}
|
|
2524
|
+
function prepareSweepDir(outDir, name) {
|
|
2525
|
+
const dir = import_node_path3.default.join(outDir, name);
|
|
2526
|
+
try {
|
|
2527
|
+
import_node_fs3.default.mkdirSync(dir);
|
|
2528
|
+
} catch (e) {
|
|
2529
|
+
if (e.code !== "EEXIST") {
|
|
2530
|
+
throw new AutoRigInputError(`sweep dir: ${e.message}`);
|
|
2531
|
+
}
|
|
2532
|
+
}
|
|
2533
|
+
const stat = import_node_fs3.default.lstatSync(dir);
|
|
2534
|
+
if (stat.isSymbolicLink()) {
|
|
2535
|
+
throw new AutoRigInputError(`sweep.name names ${dir}, a symbolic link`);
|
|
2536
|
+
}
|
|
2537
|
+
if (!stat.isDirectory()) {
|
|
2538
|
+
throw new AutoRigInputError(`sweep.name names ${dir}, not a directory`);
|
|
2539
|
+
}
|
|
2540
|
+
const real = confineToWorkingDirectory(process.cwd(), dir, "sweep dir", name);
|
|
2541
|
+
return real;
|
|
2542
|
+
}
|
|
2543
|
+
|
|
2184
2544
|
// src/render-poses.ts
|
|
2185
2545
|
var FULL_BODY_VIEW_WIDTH = 2.5;
|
|
2186
2546
|
var BUST_SIZE = 560;
|
|
2187
2547
|
var CROP_WIDTH = 720;
|
|
2188
2548
|
var CROP_MAX_HEIGHT = 8192;
|
|
2189
2549
|
var POSE_NAME = /^[A-Za-z0-9_.-]+$/;
|
|
2550
|
+
var SWEEP_NAME = /^[A-Za-z0-9][A-Za-z0-9_.-]*$/;
|
|
2190
2551
|
function bustPadY(width, height) {
|
|
2191
2552
|
return Math.max(0, (BUST_SIZE - BUST_SIZE * height / width) / 2);
|
|
2192
2553
|
}
|
|
2193
|
-
function planRenders(model, requested) {
|
|
2554
|
+
function planRenders(model, requested, sweep) {
|
|
2194
2555
|
const { width: W, height: H } = model.canvas;
|
|
2195
2556
|
const fullBody = H > W;
|
|
2196
2557
|
const canvas = fullBody ? {
|
|
@@ -2220,40 +2581,49 @@ function planRenders(model, requested) {
|
|
|
2220
2581
|
name,
|
|
2221
2582
|
values
|
|
2222
2583
|
});
|
|
2584
|
+
const toRenderCrop = (crop, label) => {
|
|
2585
|
+
const left = Math.max(crop.x, 0);
|
|
2586
|
+
const top = Math.max(crop.y, 0);
|
|
2587
|
+
const w = Math.min(crop.x + crop.w, W) - left;
|
|
2588
|
+
const h = Math.min(crop.y + crop.h, H) - top;
|
|
2589
|
+
if (!(w > 0 && h > 0)) {
|
|
2590
|
+
throw new AutoRigInputError(
|
|
2591
|
+
`${label} does not overlap the model's ${W}x${H} canvas`
|
|
2592
|
+
);
|
|
2593
|
+
}
|
|
2594
|
+
const dh = Math.round(CROP_WIDTH * h / w);
|
|
2595
|
+
if (dh < 1 || dh > CROP_MAX_HEIGHT) {
|
|
2596
|
+
throw new AutoRigInputError(
|
|
2597
|
+
`${label} meets the canvas in ${w}x${h} model px, which ${CROP_WIDTH} px wide draws ${dh} px tall, outside 1..${CROP_MAX_HEIGHT}`
|
|
2598
|
+
);
|
|
2599
|
+
}
|
|
2600
|
+
return {
|
|
2601
|
+
sx: x0 + left * s,
|
|
2602
|
+
sy: y0 + top * s,
|
|
2603
|
+
sw: w * s,
|
|
2604
|
+
sh: h * s,
|
|
2605
|
+
dw: CROP_WIDTH,
|
|
2606
|
+
dh
|
|
2607
|
+
};
|
|
2608
|
+
};
|
|
2609
|
+
if (sweep && !SWEEP_NAME.test(sweep.name)) {
|
|
2610
|
+
throw new AutoRigInputError(
|
|
2611
|
+
`sweep.name must match ${SWEEP_NAME.source} (it names <outDir>/<name>/): ${JSON.stringify(sweep.name)}`
|
|
2612
|
+
);
|
|
2613
|
+
}
|
|
2614
|
+
const sweepCrop = sweep ? sweep.crop ? toRenderCrop(sweep.crop, "sweep.crop") : squareCrop : void 0;
|
|
2223
2615
|
if (requested) {
|
|
2224
2616
|
if (requested.length === 0) throw new AutoRigInputError("poses is empty");
|
|
2225
2617
|
const poses2 = requested.map((pose, i) => {
|
|
2226
2618
|
checkRequest(requested, i);
|
|
2227
2619
|
if (!pose.crop) return square(pose.name, pose.values);
|
|
2228
|
-
const left = Math.max(pose.crop.x, 0);
|
|
2229
|
-
const top = Math.max(pose.crop.y, 0);
|
|
2230
|
-
const w = Math.min(pose.crop.x + pose.crop.w, W) - left;
|
|
2231
|
-
const h = Math.min(pose.crop.y + pose.crop.h, H) - top;
|
|
2232
|
-
if (!(w > 0 && h > 0)) {
|
|
2233
|
-
throw new AutoRigInputError(
|
|
2234
|
-
`poses[${i}].crop does not overlap the model's ${W}x${H} canvas`
|
|
2235
|
-
);
|
|
2236
|
-
}
|
|
2237
|
-
const dh = Math.round(CROP_WIDTH * h / w);
|
|
2238
|
-
if (dh < 1 || dh > CROP_MAX_HEIGHT) {
|
|
2239
|
-
throw new AutoRigInputError(
|
|
2240
|
-
`poses[${i}].crop meets the canvas in ${w}x${h} model px, which ${CROP_WIDTH} px wide draws ${dh} px tall, outside 1..${CROP_MAX_HEIGHT}`
|
|
2241
|
-
);
|
|
2242
|
-
}
|
|
2243
2620
|
return {
|
|
2244
2621
|
name: pose.name,
|
|
2245
2622
|
values: pose.values,
|
|
2246
|
-
crop: {
|
|
2247
|
-
sx: x0 + left * s,
|
|
2248
|
-
sy: y0 + top * s,
|
|
2249
|
-
sw: w * s,
|
|
2250
|
-
sh: h * s,
|
|
2251
|
-
dw: CROP_WIDTH,
|
|
2252
|
-
dh
|
|
2253
|
-
}
|
|
2623
|
+
crop: toRenderCrop(pose.crop, `poses[${i}].crop`)
|
|
2254
2624
|
};
|
|
2255
2625
|
});
|
|
2256
|
-
return { canvas, view, fullBody, mouth, poses: poses2 };
|
|
2626
|
+
return { canvas, view, fullBody, mouth, poses: poses2, sweepCrop };
|
|
2257
2627
|
}
|
|
2258
2628
|
const bodyAngles = Object.fromEntries(
|
|
2259
2629
|
[
|
|
@@ -2361,7 +2731,7 @@ function planRenders(model, requested) {
|
|
|
2361
2731
|
);
|
|
2362
2732
|
}
|
|
2363
2733
|
}
|
|
2364
|
-
return { canvas, view, fullBody, mouth, poses };
|
|
2734
|
+
return { canvas, view, fullBody, mouth, poses, sweepCrop };
|
|
2365
2735
|
}
|
|
2366
2736
|
function checkRequest(requested, i) {
|
|
2367
2737
|
const { name, values } = requested[i];
|
|
@@ -2393,7 +2763,7 @@ var CAPTURE_MS = 15e3;
|
|
|
2393
2763
|
function readPageScript() {
|
|
2394
2764
|
const url = new URL("../dist/render-page.global.js", importMetaUrl);
|
|
2395
2765
|
try {
|
|
2396
|
-
return (0,
|
|
2766
|
+
return (0, import_node_fs4.readFileSync)(url, "utf8");
|
|
2397
2767
|
} catch (cause) {
|
|
2398
2768
|
throw new Error(
|
|
2399
2769
|
"could not read the render page script; run `pnpm build` in packages/mcp",
|
|
@@ -2401,6 +2771,86 @@ function readPageScript() {
|
|
|
2401
2771
|
);
|
|
2402
2772
|
}
|
|
2403
2773
|
}
|
|
2774
|
+
async function captureSweep(evaluate, model, plan, requested, dir, report) {
|
|
2775
|
+
const spec = sweepSpec(model, plan.sweepCrop);
|
|
2776
|
+
await evaluate(
|
|
2777
|
+
`window.__ikiRender.sweepBegin(${JSON.stringify(spec)})`,
|
|
2778
|
+
CAPTURE_MS
|
|
2779
|
+
);
|
|
2780
|
+
const frames = [];
|
|
2781
|
+
for (let k = 0; k < spec.frames; k++) {
|
|
2782
|
+
const { png, values } = await evaluate(
|
|
2783
|
+
"window.__ikiRender.sweepFrame()",
|
|
2784
|
+
CAPTURE_MS
|
|
2785
|
+
);
|
|
2786
|
+
if (typeof png !== "string" || !png.startsWith(PNG_PREFIX)) {
|
|
2787
|
+
throw new Error(
|
|
2788
|
+
`sweep ${requested.name} frame ${k}: the page returned no PNG`
|
|
2789
|
+
);
|
|
2790
|
+
}
|
|
2791
|
+
const file = `f${String(k).padStart(3, "0")}.png`;
|
|
2792
|
+
writeFileAtomic(
|
|
2793
|
+
import_node_path4.default.join(dir, file),
|
|
2794
|
+
Buffer.from(png.slice(PNG_PREFIX.length), "base64")
|
|
2795
|
+
);
|
|
2796
|
+
frames.push({
|
|
2797
|
+
i: k,
|
|
2798
|
+
file,
|
|
2799
|
+
t: k / SWEEP_FPS,
|
|
2800
|
+
theta: spec.thetas[spec.captureEvery * k],
|
|
2801
|
+
values
|
|
2802
|
+
});
|
|
2803
|
+
}
|
|
2804
|
+
const end = await evaluate("window.__ikiRender.sweepEnd()", CAPTURE_MS);
|
|
2805
|
+
for (const [what, url] of Object.entries(end)) {
|
|
2806
|
+
if (typeof url !== "string" || !url.startsWith(PNG_PREFIX)) {
|
|
2807
|
+
throw new Error(
|
|
2808
|
+
`sweep ${requested.name} ${what}: the page returned no PNG`
|
|
2809
|
+
);
|
|
2810
|
+
}
|
|
2811
|
+
}
|
|
2812
|
+
const sheet = import_node_path4.default.join(dir, "sheet.png");
|
|
2813
|
+
const kymograph = import_node_path4.default.join(dir, "kymograph.png");
|
|
2814
|
+
writeFileAtomic(
|
|
2815
|
+
sheet,
|
|
2816
|
+
Buffer.from(end.sheet.slice(PNG_PREFIX.length), "base64")
|
|
2817
|
+
);
|
|
2818
|
+
writeFileAtomic(
|
|
2819
|
+
kymograph,
|
|
2820
|
+
Buffer.from(end.kymograph.slice(PNG_PREFIX.length), "base64")
|
|
2821
|
+
);
|
|
2822
|
+
const manifest = {
|
|
2823
|
+
version: 1,
|
|
2824
|
+
preset: requested.preset,
|
|
2825
|
+
parameter: spec.parameter,
|
|
2826
|
+
fps: SWEEP_FPS,
|
|
2827
|
+
clockHz: SWEEP_CLOCK_HZ,
|
|
2828
|
+
warmupS: SWEEP_WARMUP_S,
|
|
2829
|
+
durationS: SWEEP_DURATION_S,
|
|
2830
|
+
crop: requested.crop ?? null,
|
|
2831
|
+
frame: spec.frame,
|
|
2832
|
+
kymographRow: { row: spec.kymograph.row, at: spec.kymograph.at },
|
|
2833
|
+
sheet: { frames: spec.sheet.frames, cell: spec.sheet.cell },
|
|
2834
|
+
physicsOutputs: spec.physicsOutputs,
|
|
2835
|
+
frames
|
|
2836
|
+
};
|
|
2837
|
+
const manifestPath = import_node_path4.default.join(dir, "manifest.json");
|
|
2838
|
+
const flipbook = import_node_path4.default.join(dir, "index.html");
|
|
2839
|
+
writeFileAtomic(manifestPath, JSON.stringify(manifest, null, 2) + "\n");
|
|
2840
|
+
writeFileAtomic(flipbook, flipbookHtml(manifest));
|
|
2841
|
+
return {
|
|
2842
|
+
name: requested.name,
|
|
2843
|
+
preset: requested.preset,
|
|
2844
|
+
dir,
|
|
2845
|
+
fps: SWEEP_FPS,
|
|
2846
|
+
frames: spec.frames,
|
|
2847
|
+
manifest: manifestPath,
|
|
2848
|
+
sheet,
|
|
2849
|
+
kymograph,
|
|
2850
|
+
flipbook,
|
|
2851
|
+
report
|
|
2852
|
+
};
|
|
2853
|
+
}
|
|
2404
2854
|
async function renderPoses(input) {
|
|
2405
2855
|
try {
|
|
2406
2856
|
const modelFile = confineToWorkingDirectory(
|
|
@@ -2410,8 +2860,8 @@ async function renderPoses(input) {
|
|
|
2410
2860
|
input.modelPath
|
|
2411
2861
|
);
|
|
2412
2862
|
const outDir = resolveOutputDir(input.outDir);
|
|
2413
|
-
const model = (0, import_format8.loadIkiModel)((0,
|
|
2414
|
-
const plan = planRenders(model, input.poses);
|
|
2863
|
+
const model = (0, import_format8.loadIkiModel)((0, import_node_fs4.readFileSync)(modelFile, "utf8"));
|
|
2864
|
+
const plan = planRenders(model, input.poses, input.sweep);
|
|
2415
2865
|
const browser = findBrowser();
|
|
2416
2866
|
if (!browser) return { ok: false, error: NO_BROWSER_MESSAGE };
|
|
2417
2867
|
const pageScript = readPageScript();
|
|
@@ -2420,7 +2870,9 @@ async function renderPoses(input) {
|
|
|
2420
2870
|
input.poses?.map((p) => p.values)
|
|
2421
2871
|
);
|
|
2422
2872
|
const physics = checkPhysics(model);
|
|
2423
|
-
const
|
|
2873
|
+
const sweepDir = input.sweep ? prepareSweepDir(outDir, input.sweep.name) : void 0;
|
|
2874
|
+
const sweepReport = input.sweep ? checkSweep(model) : void 0;
|
|
2875
|
+
const { failedTextures, poses, sweep } = await withBrowser(
|
|
2424
2876
|
browser,
|
|
2425
2877
|
async (evaluate) => {
|
|
2426
2878
|
await evaluate(pageScript, PAGE_SCRIPT_MS);
|
|
@@ -2437,14 +2889,22 @@ async function renderPoses(input) {
|
|
|
2437
2889
|
if (typeof url !== "string" || !url.startsWith(PNG_PREFIX)) {
|
|
2438
2890
|
throw new Error(`pose ${pose.name}: the page returned no PNG`);
|
|
2439
2891
|
}
|
|
2440
|
-
const file =
|
|
2892
|
+
const file = import_node_path4.default.join(outDir, `${pose.name}.png`);
|
|
2441
2893
|
writeFileAtomic(
|
|
2442
2894
|
file,
|
|
2443
2895
|
Buffer.from(url.slice(PNG_PREFIX.length), "base64")
|
|
2444
2896
|
);
|
|
2445
2897
|
written.push({ name: pose.name, path: file });
|
|
2446
2898
|
}
|
|
2447
|
-
|
|
2899
|
+
const sweep2 = input.sweep && sweepDir && sweepReport ? await captureSweep(
|
|
2900
|
+
evaluate,
|
|
2901
|
+
model,
|
|
2902
|
+
plan,
|
|
2903
|
+
input.sweep,
|
|
2904
|
+
sweepDir,
|
|
2905
|
+
sweepReport
|
|
2906
|
+
) : void 0;
|
|
2907
|
+
return { failedTextures: loaded.failedTextures, poses: written, sweep: sweep2 };
|
|
2448
2908
|
}
|
|
2449
2909
|
);
|
|
2450
2910
|
return {
|
|
@@ -2457,7 +2917,8 @@ async function renderPoses(input) {
|
|
|
2457
2917
|
poses,
|
|
2458
2918
|
modelCanvas: model.canvas,
|
|
2459
2919
|
folds,
|
|
2460
|
-
physics
|
|
2920
|
+
physics,
|
|
2921
|
+
sweep
|
|
2461
2922
|
};
|
|
2462
2923
|
} catch (error) {
|
|
2463
2924
|
if (error instanceof AutoRigInputError || error instanceof import_format8.IkiFormatError) {
|
|
@@ -2565,7 +3026,7 @@ function describeIki(model) {
|
|
|
2565
3026
|
const padY = bustPadY(W, H);
|
|
2566
3027
|
const tenth = (n) => Math.round(n * 10) / 10;
|
|
2567
3028
|
const parts = m.parts.map((p) => {
|
|
2568
|
-
const
|
|
3029
|
+
const box2 = {
|
|
2569
3030
|
x: W / 2 + p.transform.x - p.width / 2,
|
|
2570
3031
|
y: H / 2 - p.transform.y - p.height / 2,
|
|
2571
3032
|
w: p.width,
|
|
@@ -2574,12 +3035,12 @@ function describeIki(model) {
|
|
|
2574
3035
|
const entry = {
|
|
2575
3036
|
id: p.id,
|
|
2576
3037
|
order: p.order,
|
|
2577
|
-
box,
|
|
3038
|
+
box: box2,
|
|
2578
3039
|
bustBox: {
|
|
2579
|
-
x: tenth(
|
|
2580
|
-
y: tenth(padY +
|
|
2581
|
-
w: tenth(
|
|
2582
|
-
h: tenth(
|
|
3040
|
+
x: tenth(box2.x * bustScale),
|
|
3041
|
+
y: tenth(padY + box2.y * bustScale),
|
|
3042
|
+
w: tenth(box2.w * bustScale),
|
|
3043
|
+
h: tenth(box2.h * bustScale)
|
|
2583
3044
|
}
|
|
2584
3045
|
};
|
|
2585
3046
|
if (p.deformer !== void 0) entry.deformer = p.deformer;
|
|
@@ -2649,7 +3110,7 @@ function describeIkiAt(modelPath) {
|
|
|
2649
3110
|
"model path",
|
|
2650
3111
|
modelPath
|
|
2651
3112
|
);
|
|
2652
|
-
return describeIki((0,
|
|
3113
|
+
return describeIki((0, import_node_fs5.readFileSync)(modelFile, "utf8"));
|
|
2653
3114
|
} catch (e) {
|
|
2654
3115
|
if (e instanceof AutoRigInputError) return { ok: false, error: e.message };
|
|
2655
3116
|
throw e;
|
|
@@ -2780,6 +3241,22 @@ var STANDARD_PARAMETER_INFO = [
|
|
|
2780
3241
|
function listStandardParameters() {
|
|
2781
3242
|
return STANDARD_PARAMETER_INFO.map((p) => ({ ...p }));
|
|
2782
3243
|
}
|
|
3244
|
+
function describeRigPlan() {
|
|
3245
|
+
return { fields: [...import_editor3.RIG_PLAN_FIELDS] };
|
|
3246
|
+
}
|
|
3247
|
+
function formatRigPlanReport(r) {
|
|
3248
|
+
const fields = import_editor3.RIG_PLAN_FIELDS.map((f) => {
|
|
3249
|
+
const value = `${f.path}=${r.effective[f.path]}`;
|
|
3250
|
+
const clamp2 = r.clamped.find((c) => c.field === f.path);
|
|
3251
|
+
if (clamp2 !== void 0) {
|
|
3252
|
+
const asked = r.requested[f.group]?.[f.key] ?? f.default;
|
|
3253
|
+
return `${value} (requested ${asked}, clamped at ${clamp2.bound})`;
|
|
3254
|
+
}
|
|
3255
|
+
const cue = r.overriddenBy[f.path];
|
|
3256
|
+
return cue === void 0 ? value : `${value} (fitted by ${cue})`;
|
|
3257
|
+
});
|
|
3258
|
+
return `RIGPLAN: ${fields.join(" ")}`;
|
|
3259
|
+
}
|
|
2783
3260
|
function expectInput(label, fn) {
|
|
2784
3261
|
try {
|
|
2785
3262
|
return fn();
|
|
@@ -2828,6 +3305,9 @@ async function autoRigFromLayers(input) {
|
|
|
2828
3305
|
`quantizeColors must be an integer in 2..256, got ${String(quantizeColors)}`
|
|
2829
3306
|
);
|
|
2830
3307
|
}
|
|
3308
|
+
if (input.style !== void 0) {
|
|
3309
|
+
throw new AutoRigInputError((0, import_editor3.styleRemovedMessage)("style"));
|
|
3310
|
+
}
|
|
2831
3311
|
const turnTargets = input.turnTargets;
|
|
2832
3312
|
if (turnTargets !== void 0) {
|
|
2833
3313
|
if (typeof turnTargets !== "object" || turnTargets === null || Array.isArray(turnTargets)) {
|
|
@@ -2841,7 +3321,7 @@ async function autoRigFromLayers(input) {
|
|
|
2841
3321
|
}
|
|
2842
3322
|
const resolvedLayers = layers.map((layer) => {
|
|
2843
3323
|
const resolved = resolveInputPath(layer.path);
|
|
2844
|
-
return { resolved, fileName: layer.fileName ??
|
|
3324
|
+
return { resolved, fileName: layer.fileName ?? import_node_path5.default.basename(resolved) };
|
|
2845
3325
|
});
|
|
2846
3326
|
const rolePairs = expectInput(
|
|
2847
3327
|
"role parsing",
|
|
@@ -2903,6 +3383,7 @@ async function autoRigFromLayers(input) {
|
|
|
2903
3383
|
)?.denseCore;
|
|
2904
3384
|
let turn;
|
|
2905
3385
|
let patches;
|
|
3386
|
+
let rigPlan;
|
|
2906
3387
|
let model;
|
|
2907
3388
|
try {
|
|
2908
3389
|
model = (0, import_editor3.generateIkiFromLayerSet)(
|
|
@@ -2916,7 +3397,10 @@ async function autoRigFromLayers(input) {
|
|
|
2916
3397
|
onTurnSolved: (report) => {
|
|
2917
3398
|
turn = report;
|
|
2918
3399
|
},
|
|
2919
|
-
...input.
|
|
3400
|
+
...input.rigPlan === void 0 ? {} : { rigPlan: input.rigPlan },
|
|
3401
|
+
onRigPlanResolved: (report) => {
|
|
3402
|
+
rigPlan = report;
|
|
3403
|
+
},
|
|
2920
3404
|
...input.patches === void 0 ? {} : {
|
|
2921
3405
|
patches: input.patches,
|
|
2922
3406
|
onPatchesApplied: (reports) => {
|
|
@@ -2928,7 +3412,7 @@ async function autoRigFromLayers(input) {
|
|
|
2928
3412
|
}
|
|
2929
3413
|
);
|
|
2930
3414
|
} catch (e) {
|
|
2931
|
-
if (!(e instanceof import_editor3.TurnTargetError || e instanceof import_editor3.LayerGeometryError || e instanceof import_editor3.PatchError)) {
|
|
3415
|
+
if (!(e instanceof import_editor3.TurnTargetError || e instanceof import_editor3.LayerGeometryError || e instanceof import_editor3.PatchError || e instanceof import_editor3.RigPlanError)) {
|
|
2932
3416
|
throw e;
|
|
2933
3417
|
}
|
|
2934
3418
|
throw new AutoRigInputError(e.message);
|
|
@@ -2991,7 +3475,8 @@ async function autoRigFromLayers(input) {
|
|
|
2991
3475
|
...turn === void 0 ? {} : { turn },
|
|
2992
3476
|
folds,
|
|
2993
3477
|
physics,
|
|
2994
|
-
...patches === void 0 ? {} : { patches }
|
|
3478
|
+
...patches === void 0 ? {} : { patches },
|
|
3479
|
+
rigPlan
|
|
2995
3480
|
};
|
|
2996
3481
|
} catch (err) {
|
|
2997
3482
|
if (err instanceof AutoRigInputError)
|
|
@@ -3001,8 +3486,8 @@ async function autoRigFromLayers(input) {
|
|
|
3001
3486
|
}
|
|
3002
3487
|
|
|
3003
3488
|
// src/compose.ts
|
|
3004
|
-
var
|
|
3005
|
-
var
|
|
3489
|
+
var import_node_fs7 = __toESM(require("fs"));
|
|
3490
|
+
var import_node_path10 = __toESM(require("path"));
|
|
3006
3491
|
var import_sharp4 = __toESM(require("sharp"));
|
|
3007
3492
|
var import_editor12 = require("@ikijs/editor");
|
|
3008
3493
|
|
|
@@ -3073,18 +3558,18 @@ function boxWithoutStraySpecks(rgba, W, H) {
|
|
|
3073
3558
|
}
|
|
3074
3559
|
|
|
3075
3560
|
// src/measure.ts
|
|
3076
|
-
var
|
|
3077
|
-
var
|
|
3561
|
+
var import_node_fs6 = __toESM(require("fs"));
|
|
3562
|
+
var import_node_path9 = __toESM(require("path"));
|
|
3078
3563
|
|
|
3079
3564
|
// src/measure-arms.ts
|
|
3080
|
-
var
|
|
3565
|
+
var import_node_path6 = __toESM(require("path"));
|
|
3081
3566
|
var import_editor5 = require("@ikijs/editor");
|
|
3082
3567
|
var ARM_ROLES = ["arm_L", "arm_R"];
|
|
3083
3568
|
var CAP_OVERLAP = 0.5;
|
|
3084
3569
|
var px = (v) => `${Number(v.toFixed(1))}`;
|
|
3085
3570
|
async function measured(measurer, absDir, role) {
|
|
3086
3571
|
const fileName = `${role}.png`;
|
|
3087
|
-
const { rgba } = await decodePng(
|
|
3572
|
+
const { rgba } = await decodePng(import_node_path6.default.join(absDir, fileName));
|
|
3088
3573
|
return measurer.add({ role, fileName, rgba });
|
|
3089
3574
|
}
|
|
3090
3575
|
async function armWarnings(absDir, layers) {
|
|
@@ -3234,7 +3719,7 @@ function jointWarnings(pose, arm, stats, a, armLayer, b) {
|
|
|
3234
3719
|
}
|
|
3235
3720
|
|
|
3236
3721
|
// src/measure-lips.ts
|
|
3237
|
-
var
|
|
3722
|
+
var import_node_path7 = __toESM(require("path"));
|
|
3238
3723
|
var import_editor8 = require("@ikijs/editor");
|
|
3239
3724
|
|
|
3240
3725
|
// src/compose-lips.ts
|
|
@@ -3268,7 +3753,7 @@ function components(mask, W, H) {
|
|
|
3268
3753
|
for (let start = 0; start < n; start++) {
|
|
3269
3754
|
if (!mask[start] || label[start] >= 0) continue;
|
|
3270
3755
|
const id = sizes.length;
|
|
3271
|
-
const
|
|
3756
|
+
const box2 = { x0: W, y0: H, x1: -1, y1: -1 };
|
|
3272
3757
|
let size = 0;
|
|
3273
3758
|
let depth = 0;
|
|
3274
3759
|
label[start] = id;
|
|
@@ -3278,10 +3763,10 @@ function components(mask, W, H) {
|
|
|
3278
3763
|
size++;
|
|
3279
3764
|
const px2 = p % W;
|
|
3280
3765
|
const py = (p - px2) / W;
|
|
3281
|
-
|
|
3282
|
-
|
|
3283
|
-
|
|
3284
|
-
|
|
3766
|
+
box2.x0 = Math.min(box2.x0, px2);
|
|
3767
|
+
box2.x1 = Math.max(box2.x1, px2);
|
|
3768
|
+
box2.y0 = Math.min(box2.y0, py);
|
|
3769
|
+
box2.y1 = Math.max(box2.y1, py);
|
|
3285
3770
|
for (let y = Math.max(0, py - 1); y <= Math.min(H - 1, py + 1); y++) {
|
|
3286
3771
|
for (let x = Math.max(0, px2 - 1); x <= Math.min(W - 1, px2 + 1); x++) {
|
|
3287
3772
|
if (x !== px2 && y !== py) continue;
|
|
@@ -3294,7 +3779,7 @@ function components(mask, W, H) {
|
|
|
3294
3779
|
}
|
|
3295
3780
|
}
|
|
3296
3781
|
sizes.push(size);
|
|
3297
|
-
boxes.push(
|
|
3782
|
+
boxes.push(box2);
|
|
3298
3783
|
}
|
|
3299
3784
|
return { label, sizes, boxes };
|
|
3300
3785
|
}
|
|
@@ -3531,14 +4016,14 @@ async function prepInterior(rgba, W, H) {
|
|
|
3531
4016
|
for (let p = 0; p < cw * ch; p++) {
|
|
3532
4017
|
if (label[p] >= 0 && rim[label[p]]) crop[p * 4 + 3] = 0;
|
|
3533
4018
|
}
|
|
3534
|
-
const
|
|
3535
|
-
if (
|
|
4019
|
+
const box2 = drawingBox(crop, cw, ch);
|
|
4020
|
+
if (box2 === null) throw empty;
|
|
3536
4021
|
const sum = [0, 0, 0];
|
|
3537
4022
|
const all = [0, 0, 0];
|
|
3538
4023
|
let dark = 0;
|
|
3539
4024
|
let count = 0;
|
|
3540
|
-
for (let y =
|
|
3541
|
-
for (let x =
|
|
4025
|
+
for (let y = box2.y; y < box2.y + box2.h; y++) {
|
|
4026
|
+
for (let x = box2.x; x < box2.x + box2.w; x++) {
|
|
3542
4027
|
const i = (y * cw + x) * 4;
|
|
3543
4028
|
if (crop[i + 3] < import_editor7.ALPHA_OPAQUE) continue;
|
|
3544
4029
|
count++;
|
|
@@ -3552,7 +4037,7 @@ async function prepInterior(rgba, W, H) {
|
|
|
3552
4037
|
if (count === 0) throw empty;
|
|
3553
4038
|
const [from, over] = dark > 0 ? [sum, dark] : [all, count];
|
|
3554
4039
|
const cavity = from.map((v) => Math.round(v / over));
|
|
3555
|
-
return { png: await cropToBuffer(crop, cw, ch,
|
|
4040
|
+
return { png: await cropToBuffer(crop, cw, ch, box2), cavity };
|
|
3556
4041
|
}
|
|
3557
4042
|
var rawOf = async (png) => (0, import_sharp2.default)(png).ensureAlpha().raw().toBuffer({ resolveWithObject: true });
|
|
3558
4043
|
var encode = (rgba, w, h) => (0, import_sharp2.default)(rgba, { raw: { width: w, height: h, channels: 4 } }).png().toBuffer();
|
|
@@ -3595,8 +4080,8 @@ function enclosedHole(frame, w, h) {
|
|
|
3595
4080
|
`${KEYED_SRC}: the outline is not closed round the opening (the key reached the outside, or the line is broken or too thin at this size) \u2014 regenerate with ONE closed, bolder outline`
|
|
3596
4081
|
);
|
|
3597
4082
|
}
|
|
3598
|
-
const
|
|
3599
|
-
const holeW =
|
|
4083
|
+
const box2 = boxes[main];
|
|
4084
|
+
const holeW = box2.x1 - box2.x0 + 1;
|
|
3600
4085
|
if (holeW < MIN_OPENING_WIDTH * w) {
|
|
3601
4086
|
throw new AutoRigInputError(
|
|
3602
4087
|
`${KEYED_SRC}: the opening is only ${holeW} px wide of the mouth's ${w} \u2014 too small to fold; regenerate with the mouth open wider, or, if its outline is broken (only a small pocket of the opening was enclosed), with ONE closed, bolder outline`
|
|
@@ -3610,7 +4095,7 @@ function enclosedHole(frame, w, h) {
|
|
|
3610
4095
|
`${KEYED_SRC}: the opening is not one connected region (${others.length + 1} holes: teeth or tongue drawn into the green?) \u2014 regenerate with nothing drawn inside the green`
|
|
3611
4096
|
);
|
|
3612
4097
|
}
|
|
3613
|
-
return { label, main, box };
|
|
4098
|
+
return { label, main, box: box2 };
|
|
3614
4099
|
}
|
|
3615
4100
|
function measureLips(layers, w, h) {
|
|
3616
4101
|
const measurer = (0, import_editor7.createLayerSetMeasurer)({ width: w, height: h });
|
|
@@ -3878,15 +4363,15 @@ async function lipWarnings(absDir, layers) {
|
|
|
3878
4363
|
return { warnings };
|
|
3879
4364
|
}
|
|
3880
4365
|
}
|
|
3881
|
-
const
|
|
4366
|
+
const box2 = (m) => ({
|
|
3882
4367
|
x0: m.bboxCx - m.w / 2,
|
|
3883
4368
|
x1: m.bboxCx + m.w / 2,
|
|
3884
4369
|
y0: m.bboxCy - m.h / 2,
|
|
3885
4370
|
y1: m.bboxCy + m.h / 2
|
|
3886
4371
|
});
|
|
3887
|
-
const cavity =
|
|
4372
|
+
const cavity = box2(inner);
|
|
3888
4373
|
for (const role of inside) {
|
|
3889
|
-
const b =
|
|
4374
|
+
const b = box2(layers[role]);
|
|
3890
4375
|
if (b.x0 < cavity.x0 || b.x1 > cavity.x1 || b.y0 < cavity.y0 || b.y1 > cavity.y1) {
|
|
3891
4376
|
warnings.push(
|
|
3892
4377
|
`${role}: its box leaves mouth_inner's \u2014 the cavity clips it away there. Recompose from mouth_keyed.png + mouth_interior.png (free).`
|
|
@@ -3901,7 +4386,7 @@ async function lipWarnings(absDir, layers) {
|
|
|
3901
4386
|
const green = [];
|
|
3902
4387
|
for (const role of import_editor8.LIP_ROLES) {
|
|
3903
4388
|
const fileName = `${role}.png`;
|
|
3904
|
-
const { rgba } = await decodePng(
|
|
4389
|
+
const { rgba } = await decodePng(import_node_path7.default.join(absDir, fileName));
|
|
3905
4390
|
set.set(role, measurer.add({ role, fileName, rgba }));
|
|
3906
4391
|
for (let i = 0; i < rgba.length; i += 4) {
|
|
3907
4392
|
if (rgba[i + 3] >= import_editor8.ALPHA_OPAQUE && rgba[i + 1] - Math.max(rgba[i], rgba[i + 2]) > GREEN_EXCESS) {
|
|
@@ -4005,7 +4490,7 @@ async function lipWarnings(absDir, layers) {
|
|
|
4005
4490
|
}
|
|
4006
4491
|
|
|
4007
4492
|
// src/measure-turn.ts
|
|
4008
|
-
var
|
|
4493
|
+
var import_node_path8 = __toESM(require("path"));
|
|
4009
4494
|
var import_editor9 = require("@ikijs/editor");
|
|
4010
4495
|
var import_editor10 = require("@ikijs/editor");
|
|
4011
4496
|
var DEFAULT_IRIS = { hueMin: 230, hueMax: 300, satMin: 0.22 };
|
|
@@ -4273,14 +4758,14 @@ function farNearWidths(m, turnSign) {
|
|
|
4273
4758
|
return turnSign < 0 ? { far: m.irisL.w, near: m.irisR.w } : { far: m.irisR.w, near: m.irisL.w };
|
|
4274
4759
|
}
|
|
4275
4760
|
function overlaySvg(m) {
|
|
4276
|
-
const
|
|
4761
|
+
const box2 = (b, stroke) => `<rect x="${b.x0}" y="${b.y0}" width="${b.w}" height="${b.h}" fill="none" stroke="${stroke}" stroke-width="3"/>`;
|
|
4277
4762
|
const tick = (x, half, stroke) => `<line x1="${x}" y1="${m.eyeRow - half}" x2="${x}" y2="${m.eyeRow + half}" stroke="${stroke}" stroke-width="3"/>`;
|
|
4278
|
-
return `<svg width="${m.width}" height="${m.height}">` +
|
|
4763
|
+
return `<svg width="${m.width}" height="${m.height}">` + box2(m.irisL, "#ff0000") + box2(m.irisR, "#00c000") + tick(m.head.left, 40, "#0000ff") + tick(m.head.right, 40, "#0000ff") + tick(m.head.cx, 60, "#ff8800") + tick(m.pairCx, 60, "#ff00ff") + "</svg>";
|
|
4279
4764
|
}
|
|
4280
4765
|
async function writeOverlay(debugDir, label, m) {
|
|
4281
|
-
const outPath =
|
|
4766
|
+
const outPath = import_node_path8.default.join(
|
|
4282
4767
|
debugDir,
|
|
4283
|
-
`${label}-${
|
|
4768
|
+
`${label}-${import_node_path8.default.basename(m.file, ".png")}.debug.png`
|
|
4284
4769
|
);
|
|
4285
4770
|
writeFileAtomic(outPath, await encodeOverlayPng(m.file, overlaySvg(m)));
|
|
4286
4771
|
return outPath;
|
|
@@ -4472,7 +4957,7 @@ async function lashOffSclera(eyePath, lashPath) {
|
|
|
4472
4957
|
return { opaque, off };
|
|
4473
4958
|
}
|
|
4474
4959
|
async function measureDir(absDir, noseSpeck) {
|
|
4475
|
-
const files =
|
|
4960
|
+
const files = import_node_fs6.default.readdirSync(absDir).filter((f) => f.endsWith(".png") && !f.startsWith("preview")).sort();
|
|
4476
4961
|
if (files.length === 0) {
|
|
4477
4962
|
throw new AutoRigInputError(`no role layers in ${absDir}`);
|
|
4478
4963
|
}
|
|
@@ -4484,8 +4969,8 @@ async function measureDir(absDir, noseSpeck) {
|
|
|
4484
4969
|
const layers = {};
|
|
4485
4970
|
const empty = [];
|
|
4486
4971
|
for (const f of files) {
|
|
4487
|
-
const role =
|
|
4488
|
-
const m = await layerStats(
|
|
4972
|
+
const role = import_node_path9.default.basename(f, ".png");
|
|
4973
|
+
const m = await layerStats(import_node_path9.default.join(absDir, f));
|
|
4489
4974
|
if (!m) {
|
|
4490
4975
|
empty.push(role);
|
|
4491
4976
|
continue;
|
|
@@ -4563,8 +5048,8 @@ async function measureDir(absDir, noseSpeck) {
|
|
|
4563
5048
|
}
|
|
4564
5049
|
if (lash) {
|
|
4565
5050
|
const { opaque, off } = await lashOffSclera(
|
|
4566
|
-
|
|
4567
|
-
|
|
5051
|
+
import_node_path9.default.join(absDir, `eye_${side}.png`),
|
|
5052
|
+
import_node_path9.default.join(absDir, `lash_${side}.png`)
|
|
4568
5053
|
);
|
|
4569
5054
|
const dTop = lash.marginTop - eye.marginTop;
|
|
4570
5055
|
const faults = [
|
|
@@ -4590,7 +5075,7 @@ async function measureDir(absDir, noseSpeck) {
|
|
|
4590
5075
|
if (noseSpeck !== void 0) {
|
|
4591
5076
|
warnings.push(noseSpeckWarning(noseSpeck, "compose"));
|
|
4592
5077
|
} else if (layers.nose !== void 0) {
|
|
4593
|
-
const nose = await decodePng(
|
|
5078
|
+
const nose = await decodePng(import_node_path9.default.join(absDir, "nose.png"));
|
|
4594
5079
|
const core = (0, import_editor10.denseCoreOf)(nose.rgba, nose.width, nose.height);
|
|
4595
5080
|
if (core !== null) {
|
|
4596
5081
|
const crop = detectAlphaBbox(nose.rgba, nose.width, nose.height);
|
|
@@ -5025,8 +5510,8 @@ async function trimmedPart(role, cfg, partsDir, inMemory, flipSource) {
|
|
|
5025
5510
|
if (inMemory !== void 0) {
|
|
5026
5511
|
img = (0, import_sharp4.default)(inMemory);
|
|
5027
5512
|
} else {
|
|
5028
|
-
const srcPath =
|
|
5029
|
-
if (!
|
|
5513
|
+
const srcPath = import_node_path10.default.join(partsDir, cfg.src);
|
|
5514
|
+
if (!import_node_fs7.default.existsSync(srcPath)) {
|
|
5030
5515
|
if (cfg.optional) return null;
|
|
5031
5516
|
throw new AutoRigInputError(
|
|
5032
5517
|
`missing part source for role "${role}": ${srcPath}` + (role === "mouth" ? " \u2014 draw mouth.png (with mouth_open.png), or the lip set's mouth_keyed.png + mouth_interior.png" : "")
|
|
@@ -5043,8 +5528,8 @@ async function trimmedPart(role, cfg, partsDir, inMemory, flipSource) {
|
|
|
5043
5528
|
img = (0, import_sharp4.default)(kept.data, {
|
|
5044
5529
|
raw: { width: keptW, height: keptH, channels: 4 }
|
|
5045
5530
|
});
|
|
5046
|
-
const
|
|
5047
|
-
if (
|
|
5531
|
+
const box2 = boxWithoutStraySpecks(kept.data, keptW, keptH);
|
|
5532
|
+
if (box2 !== null) img = img.extract(box2);
|
|
5048
5533
|
}
|
|
5049
5534
|
if ((cfg.mirror ?? false) !== flipSource) img = img.flop();
|
|
5050
5535
|
const trimmed = await img.png().toBuffer({ resolveWithObject: true });
|
|
@@ -5091,18 +5576,18 @@ function placement2(role, cfg, w, h, canvas) {
|
|
|
5091
5576
|
assertOnCanvas(`layout.${role}.cx/cy`, w, h, left, top, canvas);
|
|
5092
5577
|
return { left, top };
|
|
5093
5578
|
}
|
|
5094
|
-
function nosePlacement(layout, mouthKey,
|
|
5579
|
+
function nosePlacement(layout, mouthKey, box2, w, h, canvas) {
|
|
5095
5580
|
const { cx, cy } = layout.nose;
|
|
5096
|
-
const left = Math.round(cx - (
|
|
5581
|
+
const left = Math.round(cx - (box2.x + box2.w / 2));
|
|
5097
5582
|
let top;
|
|
5098
5583
|
if (cy !== void 0) {
|
|
5099
|
-
top = Math.round(cy - (
|
|
5584
|
+
top = Math.round(cy - (box2.y + box2.h / 2));
|
|
5100
5585
|
} else {
|
|
5101
5586
|
const eyeRow = (layout.eye_L.cy + layout.eye_R.cy) / 2;
|
|
5102
5587
|
const tipRow = Math.round(
|
|
5103
5588
|
eyeRow + NOSE_TIP_AT * (layout[mouthKey].cy - eyeRow)
|
|
5104
5589
|
);
|
|
5105
|
-
top = tipRow - (
|
|
5590
|
+
top = tipRow - (box2.y + box2.h - 1);
|
|
5106
5591
|
}
|
|
5107
5592
|
assertOnCanvas(
|
|
5108
5593
|
cy !== void 0 ? "layout.nose.cx/cy" : `layout.nose.cx/cy (cy unset: its tip row comes from layout.eye_L/eye_R/${mouthKey}.cy)`,
|
|
@@ -5210,8 +5695,8 @@ function detachedAboveWhite(rgba, W, H) {
|
|
|
5210
5695
|
return detached;
|
|
5211
5696
|
}
|
|
5212
5697
|
async function prepEyeSplit(partsDir) {
|
|
5213
|
-
const srcPath =
|
|
5214
|
-
if (!
|
|
5698
|
+
const srcPath = import_node_path10.default.join(partsDir, EYEWHITE_SRC);
|
|
5699
|
+
if (!import_node_fs7.default.existsSync(srcPath)) {
|
|
5215
5700
|
throw new AutoRigInputError(`missing eyewhite source: ${srcPath}`);
|
|
5216
5701
|
}
|
|
5217
5702
|
const { width: W, height: H, rgba: data } = await decodePng(srcPath);
|
|
@@ -5298,7 +5783,7 @@ function hasTransparency(rgba) {
|
|
|
5298
5783
|
return false;
|
|
5299
5784
|
}
|
|
5300
5785
|
async function prepLipSources(partsDir, mirrored) {
|
|
5301
|
-
const has = (name) =>
|
|
5786
|
+
const has = (name) => import_node_fs7.default.existsSync(import_node_path10.default.join(partsDir, name));
|
|
5302
5787
|
const keyed = has(KEYED_SRC);
|
|
5303
5788
|
const interior = has(INTERIOR_SRC);
|
|
5304
5789
|
if (keyed && !interior) {
|
|
@@ -5318,13 +5803,13 @@ async function prepLipSources(partsDir, mirrored) {
|
|
|
5318
5803
|
`${KEYED_SRC}/${INTERIOR_SRC} cannot be composed beside mouth.png/mouth_open.png (the lip set replaces the mouth drawings, and auto_rig_from_layers refuses the mix) \u2014 remove ${legacy.join(" and ")}`
|
|
5319
5804
|
);
|
|
5320
5805
|
}
|
|
5321
|
-
const k = await decodePng(
|
|
5806
|
+
const k = await decodePng(import_node_path10.default.join(partsDir, KEYED_SRC));
|
|
5322
5807
|
const keyedRgba = keyGreen(
|
|
5323
5808
|
hasTransparency(k.rgba) ? k.rgba : keyWhiteToAlpha(k.rgba),
|
|
5324
5809
|
k.width,
|
|
5325
5810
|
k.height
|
|
5326
5811
|
);
|
|
5327
|
-
const i = await decodePng(
|
|
5812
|
+
const i = await decodePng(import_node_path10.default.join(partsDir, INTERIOR_SRC));
|
|
5328
5813
|
const prepared = await prepInterior(
|
|
5329
5814
|
hasTransparency(i.rgba) ? i.rgba : keyBorderWhite(i.rgba, i.width, i.height),
|
|
5330
5815
|
i.width,
|
|
@@ -5341,7 +5826,7 @@ async function composeLayersFromParts(input) {
|
|
|
5341
5826
|
try {
|
|
5342
5827
|
const outDir = resolveOutputDir(input.outDir);
|
|
5343
5828
|
const partsDir = resolveInputDir(input.partsDir);
|
|
5344
|
-
if (
|
|
5829
|
+
if (import_node_fs7.default.realpathSync(partsDir) === outDir) {
|
|
5345
5830
|
throw new AutoRigInputError(
|
|
5346
5831
|
`partsDir and outDir resolve to the same directory (${outDir}): composing would overwrite the source parts`
|
|
5347
5832
|
);
|
|
@@ -5420,7 +5905,7 @@ async function composeLayersFromParts(input) {
|
|
|
5420
5905
|
}
|
|
5421
5906
|
if (key === "arm_L" || key === "arm_R") {
|
|
5422
5907
|
const arm = layout[key];
|
|
5423
|
-
if (!
|
|
5908
|
+
if (!import_node_fs7.default.existsSync(import_node_path10.default.join(partsDir, arm.src))) continue;
|
|
5424
5909
|
const body = placed.find((p) => p.role === "body");
|
|
5425
5910
|
if (body === void 0) {
|
|
5426
5911
|
throw new AutoRigInputError(
|
|
@@ -5463,7 +5948,7 @@ async function composeLayersFromParts(input) {
|
|
|
5463
5948
|
}
|
|
5464
5949
|
if (key === "forearm_pose_L" || key === "forearm_pose_R") {
|
|
5465
5950
|
const pose = layout[key];
|
|
5466
|
-
if (!
|
|
5951
|
+
if (!import_node_fs7.default.existsSync(import_node_path10.default.join(partsDir, pose.src))) continue;
|
|
5467
5952
|
const armRole = key === "forearm_pose_L" ? "arm_L" : "arm_R";
|
|
5468
5953
|
const arm = placed.find((p) => p.role === armRole);
|
|
5469
5954
|
if (arm?.elbow === void 0 || arm.elbowRun === void 0) {
|
|
@@ -5533,11 +6018,11 @@ async function composeLayersFromParts(input) {
|
|
|
5533
6018
|
if (key === "nose") {
|
|
5534
6019
|
noseSpeck = part.nose?.speck;
|
|
5535
6020
|
const { core, bounds } = await coreAndBoundsOf(part.buf);
|
|
5536
|
-
const
|
|
6021
|
+
const box2 = part.nose?.whole ? bounds : core ?? bounds;
|
|
5537
6022
|
({ left, top } = nosePlacement(
|
|
5538
6023
|
layout,
|
|
5539
6024
|
lips === void 0 ? "mouth" : "mouth_inner",
|
|
5540
|
-
|
|
6025
|
+
box2,
|
|
5541
6026
|
part.w,
|
|
5542
6027
|
part.h,
|
|
5543
6028
|
canvas
|
|
@@ -5580,15 +6065,15 @@ async function composeLayersFromParts(input) {
|
|
|
5580
6065
|
);
|
|
5581
6066
|
for (const role of ORDER) {
|
|
5582
6067
|
if (placed.some((p) => p.role === role)) continue;
|
|
5583
|
-
|
|
6068
|
+
import_node_fs7.default.rmSync(import_node_path10.default.join(outDir, `${role}.png`), { force: true });
|
|
5584
6069
|
}
|
|
5585
6070
|
const posed = (role) => role === "forearm_pose_L" || role === "forearm_pose_R";
|
|
5586
6071
|
if (!placed.some((p) => posed(p.role))) {
|
|
5587
|
-
|
|
6072
|
+
import_node_fs7.default.rmSync(import_node_path10.default.join(outDir, "preview-pose.png"), { force: true });
|
|
5588
6073
|
}
|
|
5589
6074
|
const layers = [];
|
|
5590
6075
|
for (const { role, part, left, top } of placed) {
|
|
5591
|
-
const outPath =
|
|
6076
|
+
const outPath = import_node_path10.default.join(outDir, `${role}.png`);
|
|
5592
6077
|
writeFileAtomic(outPath, built.get(role));
|
|
5593
6078
|
layers.push({
|
|
5594
6079
|
role,
|
|
@@ -5619,7 +6104,7 @@ async function composeLayersFromParts(input) {
|
|
|
5619
6104
|
background: { r: 245, g: 245, b: 248, alpha: 1 }
|
|
5620
6105
|
}
|
|
5621
6106
|
}).composite(preview).png().toBuffer();
|
|
5622
|
-
const previewPath =
|
|
6107
|
+
const previewPath = import_node_path10.default.join(outDir, "preview.png");
|
|
5623
6108
|
writeFileAtomic(previewPath, previewPng);
|
|
5624
6109
|
let previewPosePath;
|
|
5625
6110
|
if (placed.some((p) => posed(p.role))) {
|
|
@@ -5648,7 +6133,7 @@ async function composeLayersFromParts(input) {
|
|
|
5648
6133
|
background: { r: 245, g: 245, b: 248, alpha: 1 }
|
|
5649
6134
|
}
|
|
5650
6135
|
}).composite(pose).png().toBuffer();
|
|
5651
|
-
previewPosePath =
|
|
6136
|
+
previewPosePath = import_node_path10.default.join(outDir, "preview-pose.png");
|
|
5652
6137
|
writeFileAtomic(previewPosePath, posePng);
|
|
5653
6138
|
}
|
|
5654
6139
|
return {
|
|
@@ -5694,7 +6179,7 @@ function formatPatchReports(reports) {
|
|
|
5694
6179
|
});
|
|
5695
6180
|
}
|
|
5696
6181
|
function createIkiMcpServer() {
|
|
5697
|
-
const server = new import_mcp.McpServer({ name: "iki", version: "0.
|
|
6182
|
+
const server = new import_mcp.McpServer({ name: "iki", version: "0.31.0" });
|
|
5698
6183
|
server.registerTool(
|
|
5699
6184
|
"validate_iki",
|
|
5700
6185
|
{
|
|
@@ -5766,10 +6251,27 @@ function createIkiMcpServer() {
|
|
|
5766
6251
|
};
|
|
5767
6252
|
}
|
|
5768
6253
|
);
|
|
6254
|
+
server.registerTool(
|
|
6255
|
+
"describe_rig_plan",
|
|
6256
|
+
{
|
|
6257
|
+
description: "Lists the fields of the `rigPlan` input of auto_rig_from_layers: each one's path, default, range, recommended span, step, unit, the poses it shows at, the report reading that shows it and the `turnTargets` cue that fits it when given. The one source of those numbers.",
|
|
6258
|
+
inputSchema: {}
|
|
6259
|
+
},
|
|
6260
|
+
async () => {
|
|
6261
|
+
const { fields } = describeRigPlan();
|
|
6262
|
+
const text = fields.map(
|
|
6263
|
+
(f) => `${f.path} default ${f.default} range ${f.range[0]}..${f.range[1]} recommended ${f.recommended[0]}..${f.recommended[1]} step ${f.step} ${f.unit} \u2014 ${f.what}; shows at ${f.poses.map((p) => JSON.stringify(p)).join(" ")}; cue ${f.cue ?? "none"}; fitted by ${f.fitBy ?? "none"}${f.provisional ? "; provisional" : ""}`
|
|
6264
|
+
).join("\n");
|
|
6265
|
+
return {
|
|
6266
|
+
content: [{ type: "text", text }],
|
|
6267
|
+
structuredContent: { fields }
|
|
6268
|
+
};
|
|
6269
|
+
}
|
|
6270
|
+
);
|
|
5769
6271
|
server.registerTool(
|
|
5770
6272
|
"auto_rig_from_layers",
|
|
5771
6273
|
{
|
|
5772
|
-
description: "Auto-rigs role-named PNG layers (face, eye_L/eye_R and either mouth or the lip set (mouth_inner + lip_lower + lip_upper, a mouth that folds open instead of crossfading) required; iris_L/R, brow_L/R, hair_front, body, arm_L/arm_R, forearm_pose_L/forearm_pose_R, mouth_tongue/mouth_teeth (only with the lip set: drawn under its lips and clipped to mouth_inner), etc. optional; an arm needs the body, a pose forearm needs its arm, and a partial lip set, one mixed with mouth/mouth_open, or mouth_tongue/mouth_teeth without it is refused) 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. The result's `folds` is the written rig's fold report, printed after the path the way render_poses prints it, and report-only: a fold never refuses the rig. The `PHYSICS` lines follow the fold report (the result's `physics`), one per physics rig output \u2014 a spring's, or each chain segment's \u2014 reading ok, frozen or unstable with the step and idle amplitudes, or `PHYSICS: no rigs`; report-only too. `patches` (see its field) adds displacements to existing keyform stops of the freshly generated rig; each op then prints one line between the path and the fold report \u2014 `PATCH <i> <target> at <Param=v \u2026>: <moved> of <of> points (cols a-b, rows c-d), largest move <maxPx> model px`, with `(vertices)` in place of the columns and rows for a mesh part \u2014 and the result's `patches` carries the same reports (`index`, `target`, `at`, `moved`, `of`, `cols`/`rows` for a grid, `maxPx`), present whenever `patches` was passed, `[]` included. An op the input schema accepts but the rig refuses comes back as `INVALID: patches[i]\u2026` and nothing is written; an op with a missing field or a field of the wrong type is the SDK's input validation error.",
|
|
6274
|
+
description: "Auto-rigs role-named PNG layers (face, eye_L/eye_R and either mouth or the lip set (mouth_inner + lip_lower + lip_upper, a mouth that folds open instead of crossfading) required; iris_L/R, brow_L/R, hair_front, body, arm_L/arm_R, forearm_pose_L/forearm_pose_R, mouth_tongue/mouth_teeth (only with the lip set: drawn under its lips and clipped to mouth_inner), etc. optional; an arm needs the body, a pose forearm needs its arm, and a partial lip set, one mixed with mouth/mouth_open, or mouth_tongue/mouth_teeth without it is refused) 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. The result's `folds` is the written rig's fold report, printed after the path the way render_poses prints it, and report-only: a fold never refuses the rig. The `RIGPLAN:` line (the result's `rigPlan`: `effective`, `clamped`, `overriddenBy`) follows the path and precedes the `PATCH` lines. The `PHYSICS` lines follow the fold report (the result's `physics`), one per physics rig output \u2014 a spring's, or each chain segment's \u2014 reading ok, frozen or unstable with the step and idle amplitudes, or `PHYSICS: no rigs`; report-only too. `patches` (see its field) adds displacements to existing keyform stops of the freshly generated rig; each op then prints one line between the path and the fold report \u2014 `PATCH <i> <target> at <Param=v \u2026>: <moved> of <of> points (cols a-b, rows c-d), largest move <maxPx> model px`, with `(vertices)` in place of the columns and rows for a mesh part \u2014 and the result's `patches` carries the same reports (`index`, `target`, `at`, `moved`, `of`, `cols`/`rows` for a grid, `maxPx`), present whenever `patches` was passed, `[]` included. An op the input schema accepts but the rig refuses comes back as `INVALID: patches[i]\u2026` and nothing is written; an op with a missing field or a field of the wrong type is the SDK's input validation error.",
|
|
5773
6275
|
inputSchema: {
|
|
5774
6276
|
layers: import_zod.z.array(
|
|
5775
6277
|
import_zod.z.object({
|
|
@@ -5794,15 +6296,24 @@ function createIkiMcpServer() {
|
|
|
5794
6296
|
}).passthrough().optional().describe(
|
|
5795
6297
|
"What the head turn is fitted to, as `measure_turn_reference` reports it off a front/turned reference pair. `eyeShift` (and the optional `noseShift`/`mouthShift`) is how far that feature slides across the head at full turn, as a fraction of the head's half-width \u2014 a MAGNITUDE: the rig turns both ways, so the sign is ignored. `farEyeRatio` is the far/near eye width at full turn over that same ratio at rest, `silhouetteRatio` the head's half-width turned over at rest. The half-width the shifts are fractions of is measured off the layers themselves, so it is not an input. An omitted field leaves that part of the turn at the profile the rig defaults to. A passed `eyeShift` is fitted by the turn's amount and clamped to the room the art leaves the far eye \u2014 the face plate's edge, or the bangs' side strand over the far iris (the result's `turn.clamped` lists every clamped field, `turn.achieved` what the rig reaches, and `turn.strandOverlap` how much of a far iris the bangs still cover). A passed `silhouetteRatio` is clamped too, only on a face drawn without hair and with ear islands, where narrowing the head that far would no longer cover the far ear's slide. Any other passed target this layer set cannot reach comes back as `INVALID: \u2026` naming the field and the attainable range, since it is a measurement rather than a preference. A field not named here is refused the same way."
|
|
5796
6298
|
),
|
|
5797
|
-
style: import_zod.z.
|
|
5798
|
-
|
|
5799
|
-
|
|
5800
|
-
|
|
5801
|
-
|
|
5802
|
-
|
|
5803
|
-
|
|
6299
|
+
style: import_zod.z.unknown().optional().describe(
|
|
6300
|
+
"Removed in @ikijs/mcp 0.30.0: pass `rigPlan`. Any value here is refused with the field map."
|
|
6301
|
+
),
|
|
6302
|
+
rigPlan: import_zod.z.object({
|
|
6303
|
+
turn: import_zod.z.object({
|
|
6304
|
+
amount: import_zod.z.number().optional(),
|
|
6305
|
+
featureLead: import_zod.z.number().optional(),
|
|
6306
|
+
eyeForeshorten: import_zod.z.number().optional(),
|
|
6307
|
+
noseLead: import_zod.z.number().optional()
|
|
6308
|
+
}).passthrough().optional(),
|
|
6309
|
+
hair: import_zod.z.object({
|
|
6310
|
+
follow: import_zod.z.number().optional(),
|
|
6311
|
+
outlineFollow: import_zod.z.number().optional(),
|
|
6312
|
+
sway: import_zod.z.number().optional()
|
|
6313
|
+
}).passthrough().optional(),
|
|
6314
|
+
eyes: import_zod.z.object({ blink: import_zod.z.number().optional() }).passthrough().optional()
|
|
5804
6315
|
}).passthrough().optional().describe(
|
|
5805
|
-
"Per-character tuning from the profile the rig defaults to: `turn`
|
|
6316
|
+
"Per-character tuning from the profile the rig defaults to, in three groups: `turn` (`amount`, `featureLead`, `eyeForeshorten`, `noseLead`: the last two turn only, the nod untouched, and fitted by `turnTargets.farEyeRatio` / `turnTargets.noseShift` when those are given, which the `RIGPLAN:` line then reports as overridden), `hair` (`follow`, `outlineFollow`, `sway`) and `eyes` (`blink`). `describe_rig_plan` lists every field's default, range, recommended span, step and poses. A value out of range, or a group or key not named there, comes back as `INVALID: rigPlan.<path> \u2026`; an object left out or `{}` is the profile. The result reports what the rig built with as `rigPlan` and a `RIGPLAN:` line."
|
|
5806
6317
|
),
|
|
5807
6318
|
patches: import_zod.z.array(
|
|
5808
6319
|
import_zod.z.object({
|
|
@@ -5820,7 +6331,7 @@ function createIkiMcpServer() {
|
|
|
5820
6331
|
why: import_zod.z.string().optional()
|
|
5821
6332
|
}).passthrough()
|
|
5822
6333
|
).optional().describe(
|
|
5823
|
-
"Displacements ADDED to EXISTING keyform stops of the freshly generated rig, each op `{ target, at, region, by, falloff?, why? }`. They are replayed on every rig of these inputs, over whatever the rig now bakes, so they hold through a layout or `
|
|
6334
|
+
"Displacements ADDED to EXISTING keyform stops of the freshly generated rig, each op `{ target, at, region, by, falloff?, why? }`. They are replayed on every rig of these inputs, over whatever the rig now bakes, so they hold through a layout or `rigPlan` retune; ops on one stop add up, whatever their order. `target` is a feature grid \u2014 `eyeWarp_L`, `eyeWarp_R`, `browWarp_L`, `browWarp_R`, `noseWarp`, `mouthWarp`, whose `at` names both `ParamAngleX` and `ParamAngleY`, each -30, 0 or 30, never both 0 \u2014 or a mesh part with warps (`face`, `hair_front`, \u2026), whose `at` names exactly one parameter at one of that part's warp keyform values, never the parameter's default nor the stop where the rig shuts the part on purpose (`eye_*` and `lash_lower_*` at their `ParamEye*Open` 0, the lip set and its tongue and teeth at `ParamMouthOpenY` 0), which the fold check exempts, nor a `ParamAngleZ` or `ParamBodyAngleZ` stop (they roll the deformers the part hangs under, so a displacement there is turned off the screen axes). The rest pose is the drawn art and no patch changes it. `bodyWarp` and the matrix deformers are not targets, and a patch adds no stop and changes no parameter range. `region` `{ role, x: [from, to], y: [from, to] }` is a rectangle in fractions of the REST layer box (the opaque crop) of `role`, origin top-left, x right, y DOWN, and may reach past the box: the target's points whose REST position lies inside take the whole of `by`, those within `falloff` of it a smooth share, the rest nothing. `by` `{ dx, dy }` and `falloff` are in face widths (the `face` layer's crop width), on screen axes: +dx toward the viewer's right (a character's `_L` side), +dy DOWN. Between stops the engine blends linearly, so a fix at ParamAngleX -30 shows at half strength at -15 and none at rest. `why` is a note the rig ignores. An op this schema accepts but the rig refuses \u2014 an unknown key, target, role or stop, the rest stop or a shut stop, a region running backwards or catching none of the target's points \u2014 comes back as `INVALID: patches[i]\u2026`, listing the keys, targets, stops or roles there are, or where the target's points lie in the role's box, and nothing is written; a missing field or one of the wrong type is refused by the schema itself, as the SDK's input validation error."
|
|
5824
6335
|
)
|
|
5825
6336
|
}
|
|
5826
6337
|
},
|
|
@@ -5834,6 +6345,7 @@ function createIkiMcpServer() {
|
|
|
5834
6345
|
});
|
|
5835
6346
|
const text = r.ok ? [
|
|
5836
6347
|
r.path,
|
|
6348
|
+
formatRigPlanReport(r.rigPlan),
|
|
5837
6349
|
...formatPatchReports(r.patches ?? []),
|
|
5838
6350
|
...formatFoldReport(r.folds, r.canvas),
|
|
5839
6351
|
...formatPhysicsReport(r.physics)
|
|
@@ -5965,7 +6477,7 @@ function createIkiMcpServer() {
|
|
|
5965
6477
|
server.registerTool(
|
|
5966
6478
|
"render_poses",
|
|
5967
6479
|
{
|
|
5968
|
-
description: "Renders a rigged .iki into the character loop's pose PNGs with the real engine, through the installed Chrome, Edge or Chromium run headless (set CHROME_PATH to pick one). The model decides the set: a bust gets 560x560 shots (rest, turns, nod, blinks, gaze, combined \u2014 ParamAngleX/Y/Z all at 30 \u2014 and stress: ParamAngleX/Y/Z all at -30, ParamMouthOpenY 1, both eyes at 0.5, the brows at opposite extremes (ParamBrowLY -1, ParamBrowRY 1, ParamBrowLAngle 1, ParamBrowRAngle -1) and each body angle the model declares at -10); a mouth adds 720x480 mouth crops; a full body (taller than wide) adds the full-canvas body, arm and elbow poses on a 1400-wide canvas, and a model with a pose forearm adds the full-pose-* shots. Given `poses` (see its field), the standard set is not rendered: only those poses are, each crop clamped to the model's canvas. Writes <pose>.png files into outDir, overwriting same-named files in place; returns the written paths one per line, then the model's fold report (the result's `folds`), checked by the engine over its own pose set plus any `poses`, each of which a `FOLD` line names by its settings, not its PNG name: a `FOLD` line per warp deformer or mesh part that flips (ratio <= 0) or collapses (under 0.1) at some pose \u2014 its cell or triangle, the ratio of its area there to at rest, the pose as its parameter settings (`rest` for none) and where it rests, in model space and in model px from the top-left (the layer PNGs' own pixels, not a render's) \u2014 or `FOLDS: none over N poses`, then a `FOLDS expected:` line naming the closures the rig draws on purpose (an eye or the mouth shut), each by part id, ratio and the parameter that shuts it. Report-only: a fold never fails the render. The `PHYSICS` lines follow the fold report (the result's `physics`), one per physics rig output of the model's own rigs \u2014 `poses` do not enter it \u2014 reading ok, frozen or unstable with the step and idle amplitudes, or `PHYSICS: no rigs`; report-only too. Fails with INVALID when no browser is found or an input is refused; a browser that cannot start is a tool error.",
|
|
6480
|
+
description: "Renders a rigged .iki into the character loop's pose PNGs with the real engine, through the installed Chrome, Edge or Chromium run headless (set CHROME_PATH to pick one). The model decides the set: a bust gets 560x560 shots (rest, turns, nod, blinks, gaze, combined \u2014 ParamAngleX/Y/Z all at 30 \u2014 and stress: ParamAngleX/Y/Z all at -30, ParamMouthOpenY 1, both eyes at 0.5, the brows at opposite extremes (ParamBrowLY -1, ParamBrowRY 1, ParamBrowLAngle 1, ParamBrowRAngle -1) and each body angle the model declares at -10); a mouth adds 720x480 mouth crops; a full body (taller than wide) adds the full-canvas body, arm and elbow poses on a 1400-wide canvas, and a model with a pose forearm adds the full-pose-* shots. Given `poses` (see its field), the standard set is not rendered: only those poses are, each crop clamped to the model's canvas. Writes <pose>.png files into outDir, overwriting same-named files in place; returns the written paths one per line, then the model's fold report (the result's `folds`), checked by the engine over its own pose set plus any `poses`, each of which a `FOLD` line names by its settings, not its PNG name: a `FOLD` line per warp deformer or mesh part that flips (ratio <= 0) or collapses (under 0.1) at some pose \u2014 its cell or triangle, the ratio of its area there to at rest, the pose as its parameter settings (`rest` for none) and where it rests, in model space and in model px from the top-left (the layer PNGs' own pixels, not a render's) \u2014 or `FOLDS: none over N poses`, then a `FOLDS expected:` line naming the closures the rig draws on purpose (an eye or the mouth shut), each by part id, ratio and the parameter that shuts it. Report-only: a fold never fails the render. The `PHYSICS` lines follow the fold report (the result's `physics`), one per physics rig output of the model's own rigs \u2014 `poses` do not enter it \u2014 reading ok, frozen or unstable with the step and idle amplitudes, or `PHYSICS: no rigs`; report-only too. Given `sweep`, also renders an eased turn of the head (see its field) and prints its paths and `SWEEP` lines. Fails with INVALID when no browser is found or an input is refused; a browser that cannot start is a tool error.",
|
|
5969
6481
|
inputSchema: {
|
|
5970
6482
|
modelPath: import_zod.z.string().describe(
|
|
5971
6483
|
"Rigged .iki file path (resolved against cwd; must sit under the working directory)."
|
|
@@ -5986,6 +6498,18 @@ function createIkiMcpServer() {
|
|
|
5986
6498
|
})
|
|
5987
6499
|
).optional().describe(
|
|
5988
6500
|
"Caller-named poses rendered INSTEAD of the standard set, each `{ name, values, crop? }`, in order. `name` becomes `<outDir>/<name>.png` and the result's pose name: letters, digits, `_`, `.` and `-` only, unique in the list ignoring case. `values` are parameter settings (every other parameter at its default; an id the model lacks is ignored). `crop` `{ x, y, w, h }` is a rectangle in model px from the top-left \u2014 the frame of describe_iki's boxes and of the `FOLD` lines \u2014 clamped to the model's canvas, then drawn 720 px wide at its own aspect; without one a pose is framed as the standard shots (560x560, the middle square on a full body). Each pose is also added to the fold sweep, after the engine's own poses. An empty list, a bad or repeated name, a non-finite value, or a crop that misses the canvas or would draw under 1 or over 8192 px tall comes back as `INVALID: poses\u2026` and nothing is rendered."
|
|
6501
|
+
),
|
|
6502
|
+
sweep: import_zod.z.object({
|
|
6503
|
+
name: import_zod.z.string(),
|
|
6504
|
+
preset: import_zod.z.literal("turn"),
|
|
6505
|
+
crop: import_zod.z.object({
|
|
6506
|
+
x: import_zod.z.number(),
|
|
6507
|
+
y: import_zod.z.number(),
|
|
6508
|
+
w: import_zod.z.number(),
|
|
6509
|
+
h: import_zod.z.number()
|
|
6510
|
+
}).optional()
|
|
6511
|
+
}).optional().describe(
|
|
6512
|
+
"A turn sweep rendered IN ADDITION to the poses, `{ name, preset: \"turn\", crop? }`: an eased `ParamAngleX` turn (0 to -30 to +30 to 0 over 3 s, sinusoidal) at 30 fps on a 60 Hz physics clock, with the hair physics running and the idle off, every other parameter at its default. `crop` is a rectangle in model px as a pose's, fixed for every frame; without one the frames are framed as the standard shots. Written into `<outDir>/<name>/` (created; `name` starts with a letter or digit, then letters, digits, `_`, `.`, `-`): `fNNN.png` (90 frames), `manifest.json` (each frame's time, angle and effective values), `sheet.png` (nine frames of the -30 to +30 leg, labelled with angle and time, at most 2000 px a side), `kymograph.png` (the eye row of every frame stacked over time), `index.html` (a flipbook to open from disk; add `?b=<relative dir of another sweep>` for two side by side). The text then lists the paths and, after the `PHYSICS` lines, a `SWEEP turn` line per landmark (eyes, nose) from the engine's geometry: amplitude in face widths, the kink of x and of the eye width through angle 0, the lead over the local face plate at each end, and the pop \u2014 report-only, like `FOLD` and `PHYSICS`."
|
|
5989
6513
|
)
|
|
5990
6514
|
}
|
|
5991
6515
|
},
|
|
@@ -5994,8 +6518,16 @@ function createIkiMcpServer() {
|
|
|
5994
6518
|
const r = await renderPoses(args);
|
|
5995
6519
|
const text = r.ok ? [
|
|
5996
6520
|
...r.poses.map((p) => p.path),
|
|
6521
|
+
...r.sweep ? [
|
|
6522
|
+
r.sweep.dir,
|
|
6523
|
+
r.sweep.sheet,
|
|
6524
|
+
r.sweep.kymograph,
|
|
6525
|
+
r.sweep.flipbook,
|
|
6526
|
+
r.sweep.manifest
|
|
6527
|
+
] : [],
|
|
5997
6528
|
...formatFoldReport(r.folds, r.modelCanvas),
|
|
5998
|
-
...formatPhysicsReport(r.physics)
|
|
6529
|
+
...formatPhysicsReport(r.physics),
|
|
6530
|
+
...r.sweep ? formatSweepReport(r.sweep.report) : []
|
|
5999
6531
|
].join("\n") : `INVALID: ${r.error}`;
|
|
6000
6532
|
return { content: [{ type: "text", text }], structuredContent: r };
|
|
6001
6533
|
} catch (err) {
|
|
@@ -6014,13 +6546,17 @@ function createIkiMcpServer() {
|
|
|
6014
6546
|
0 && (module.exports = {
|
|
6015
6547
|
autoRigFromLayers,
|
|
6016
6548
|
checkModelFolds,
|
|
6549
|
+
checkSweep,
|
|
6017
6550
|
composeLayersFromParts,
|
|
6018
6551
|
createIkiMcpServer,
|
|
6019
6552
|
describeIki,
|
|
6020
6553
|
describeIkiAt,
|
|
6554
|
+
describeRigPlan,
|
|
6021
6555
|
formatFoldReport,
|
|
6022
6556
|
formatMeasureReport,
|
|
6023
6557
|
formatPhysicsReport,
|
|
6558
|
+
formatRigPlanReport,
|
|
6559
|
+
formatSweepReport,
|
|
6024
6560
|
formatTurnReport,
|
|
6025
6561
|
listStandardParameters,
|
|
6026
6562
|
measureLayers,
|