@ikijs/mcp 0.34.0 → 0.35.1
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 +3 -3
- package/dist/{chunk-HKJT3Q6G.mjs → chunk-Y36XOSK4.mjs} +227 -54
- package/dist/chunk-Y36XOSK4.mjs.map +1 -0
- package/dist/cli.js +226 -53
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +1 -1
- package/dist/index.d.mts +37 -1
- package/dist/index.d.ts +37 -1
- package/dist/index.js +226 -53
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/render-page.global.js +98 -8
- package/package.json +4 -4
- package/dist/chunk-HKJT3Q6G.mjs.map +0 -1
package/dist/cli.js
CHANGED
|
@@ -449,6 +449,22 @@ function resolveDeformers(deformers, params) {
|
|
|
449
449
|
return { worlds, grids };
|
|
450
450
|
}
|
|
451
451
|
|
|
452
|
+
// ../engine/src/occlusion.ts
|
|
453
|
+
function occlusionAmount(occlusion, value) {
|
|
454
|
+
const { stops } = occlusion;
|
|
455
|
+
const first = stops[0];
|
|
456
|
+
if (value <= first.value) return first.amount;
|
|
457
|
+
for (let i = 1; i < stops.length; i++) {
|
|
458
|
+
const hi = stops[i];
|
|
459
|
+
if (value <= hi.value) {
|
|
460
|
+
const lo = stops[i - 1];
|
|
461
|
+
const t = (value - lo.value) / (hi.value - lo.value);
|
|
462
|
+
return lo.amount * (1 - t) + hi.amount * t;
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
return stops[stops.length - 1].amount;
|
|
466
|
+
}
|
|
467
|
+
|
|
452
468
|
// ../engine/src/idle-motion.ts
|
|
453
469
|
var import_format = require("@ikijs/format");
|
|
454
470
|
|
|
@@ -2356,6 +2372,49 @@ function triangleGrid(posed, indices, bounds) {
|
|
|
2356
2372
|
Math.floor((x - bounds.x0) / cell) + Math.floor((y - bounds.y0) / cell) * cols
|
|
2357
2373
|
) ?? [];
|
|
2358
2374
|
}
|
|
2375
|
+
function paintedUnder(posed, mesh, paint, points) {
|
|
2376
|
+
if (points.length === 0) return [];
|
|
2377
|
+
const bounds = { x0: Infinity, y0: Infinity, x1: -Infinity, y1: -Infinity };
|
|
2378
|
+
for (const [x, y] of points) {
|
|
2379
|
+
bounds.x0 = Math.min(bounds.x0, x);
|
|
2380
|
+
bounds.y0 = Math.min(bounds.y0, y);
|
|
2381
|
+
bounds.x1 = Math.max(bounds.x1, x);
|
|
2382
|
+
bounds.y1 = Math.max(bounds.y1, y);
|
|
2383
|
+
}
|
|
2384
|
+
const find = triangleGrid(posed, mesh.indices, bounds);
|
|
2385
|
+
return points.map(([x, y]) => {
|
|
2386
|
+
for (const t of find(x, y)) {
|
|
2387
|
+
const tri = [
|
|
2388
|
+
mesh.indices[t * 3],
|
|
2389
|
+
mesh.indices[t * 3 + 1],
|
|
2390
|
+
mesh.indices[t * 3 + 2]
|
|
2391
|
+
];
|
|
2392
|
+
const w = locate(posed, tri, x, y);
|
|
2393
|
+
if (!w) continue;
|
|
2394
|
+
let rx = 0;
|
|
2395
|
+
let ry = 0;
|
|
2396
|
+
for (let k = 0; k < 3; k++) {
|
|
2397
|
+
rx += w[k] * mesh.rest[tri[k] * 2];
|
|
2398
|
+
ry += w[k] * mesh.rest[tri[k] * 2 + 1];
|
|
2399
|
+
}
|
|
2400
|
+
return paintedAt(paint, rx, ry);
|
|
2401
|
+
}
|
|
2402
|
+
return false;
|
|
2403
|
+
});
|
|
2404
|
+
}
|
|
2405
|
+
function hiddenSide(occlusion, from, direction) {
|
|
2406
|
+
const at = (v) => occlusionAmount(occlusion, v);
|
|
2407
|
+
const rest = at(from);
|
|
2408
|
+
const marks = occlusion.stops.map((s) => s.value).filter((v) => (v - from) * direction > 0).sort((a, b) => (a - b) * direction);
|
|
2409
|
+
const run2 = [from, ...marks];
|
|
2410
|
+
let leaves = null;
|
|
2411
|
+
let full = rest === 1 ? from : null;
|
|
2412
|
+
for (let i = 0; i + 1 < run2.length; i++) {
|
|
2413
|
+
if (leaves === null && at(run2[i + 1]) !== rest) leaves = run2[i];
|
|
2414
|
+
if (full === null && at(run2[i + 1]) === 1) full = run2[i + 1];
|
|
2415
|
+
}
|
|
2416
|
+
return { leaves, full };
|
|
2417
|
+
}
|
|
2359
2418
|
function posesOf(model, baked, base) {
|
|
2360
2419
|
const byName = new Map(base.map((p) => [p.name, p]));
|
|
2361
2420
|
const add = (values) => {
|
|
@@ -2428,7 +2487,16 @@ function checkCustomGate(model, parts, paints, options = {}) {
|
|
|
2428
2487
|
if (!model.parts.some((p) => p.id === part.id)) {
|
|
2429
2488
|
throw new Error(`custom gate: the model has no part "${part.id}"`);
|
|
2430
2489
|
}
|
|
2431
|
-
|
|
2490
|
+
if (options.poses) return options.poses;
|
|
2491
|
+
const sampledOf = bakedOf(part.id);
|
|
2492
|
+
const occ = model.parts.find((p) => p.id === part.id).occlusion;
|
|
2493
|
+
if (occ !== void 0) {
|
|
2494
|
+
const at = sampledOf.get(occ.parameter) ?? [];
|
|
2495
|
+
sampledOf.set(occ.parameter, [
|
|
2496
|
+
.../* @__PURE__ */ new Set([...at, ...occ.stops.map((s) => s.value)])
|
|
2497
|
+
]);
|
|
2498
|
+
}
|
|
2499
|
+
return posesOf(model, sampledOf, base);
|
|
2432
2500
|
});
|
|
2433
2501
|
const all = new Map(poseSets.flat().map((p) => [p.name, p]));
|
|
2434
2502
|
const reports = parts.map((part, n) => {
|
|
@@ -2513,6 +2581,45 @@ function checkCustomGate(model, parts, paints, options = {}) {
|
|
|
2513
2581
|
const hiddenOn = locatePoints(lowerMesh, hidden).filter(
|
|
2514
2582
|
(l, i) => l !== null && onAnchorMesh[i] !== null
|
|
2515
2583
|
);
|
|
2584
|
+
const occlusion = ownPart.occlusion;
|
|
2585
|
+
const coverParts = [];
|
|
2586
|
+
if (occlusion !== void 0) {
|
|
2587
|
+
for (const role of part.occludedBy ?? []) {
|
|
2588
|
+
for (const id of (0, import_editor3.partIdsOfRole)(role)) {
|
|
2589
|
+
const o = model.parts.find((p) => p.id === id);
|
|
2590
|
+
if (o === void 0 || !occlusion.by.includes(id)) continue;
|
|
2591
|
+
const steady = o.color[3] === 1 && (o.transform.opacity ?? 1) >= 1 && !(o.bindings ?? []).some((b) => b.channel === "opacity");
|
|
2592
|
+
if (!steady) continue;
|
|
2593
|
+
const paint = paints.get(role);
|
|
2594
|
+
if (paint === void 0) {
|
|
2595
|
+
throw new Error(`custom gate: no paint for "${role}"`);
|
|
2596
|
+
}
|
|
2597
|
+
coverParts.push({ id, mesh: restMesh(model, cache, id), paint });
|
|
2598
|
+
}
|
|
2599
|
+
}
|
|
2600
|
+
}
|
|
2601
|
+
const coverIds = new Set(coverParts.map((c) => c.id));
|
|
2602
|
+
const keyParam = occlusion === void 0 ? void 0 : model.parameters.find((p) => p.id === occlusion.parameter);
|
|
2603
|
+
const keyOf = (values) => Math.min(
|
|
2604
|
+
keyParam.max,
|
|
2605
|
+
Math.max(keyParam.min, values[keyParam.id] ?? keyParam.default)
|
|
2606
|
+
);
|
|
2607
|
+
const sampled = keyParam === void 0 ? [] : [
|
|
2608
|
+
.../* @__PURE__ */ new Set([
|
|
2609
|
+
keyParam.default,
|
|
2610
|
+
...poses.map((p) => keyOf(p.values))
|
|
2611
|
+
])
|
|
2612
|
+
].sort((a, b) => a - b);
|
|
2613
|
+
const fullyHidden = (lo, hi) => occlusion.stops.every(
|
|
2614
|
+
(st) => st.value <= lo || st.value >= hi || st.amount === 1
|
|
2615
|
+
) && occlusionAmount(occlusion, lo) === 1 && occlusionAmount(occlusion, hi) === 1;
|
|
2616
|
+
const hiddenAt = (v) => fullyHidden(
|
|
2617
|
+
sampled.filter((x) => x < v).at(-1) ?? v,
|
|
2618
|
+
sampled.find((x) => x > v) ?? v
|
|
2619
|
+
);
|
|
2620
|
+
let leftOut = 0;
|
|
2621
|
+
let leftOutTurning = 0;
|
|
2622
|
+
let readNoTurn = 0;
|
|
2516
2623
|
const stops = bakedOf(part.id);
|
|
2517
2624
|
const worstOf = {
|
|
2518
2625
|
tie: { v: -1, pose: "rest" },
|
|
@@ -2541,21 +2648,54 @@ function checkCustomGate(model, parts, paints, options = {}) {
|
|
|
2541
2648
|
keep(worstOf.rigid, (0, import_editor3.rigidResidual)(restPoints, moved), pose.name);
|
|
2542
2649
|
};
|
|
2543
2650
|
for (const pose of poses) {
|
|
2544
|
-
const
|
|
2651
|
+
const hiding = occlusion !== void 0 && hiddenAt(keyOf(pose.values));
|
|
2652
|
+
const landed = landParts(model, pose.values, [
|
|
2653
|
+
.../* @__PURE__ */ new Set([
|
|
2654
|
+
part.id,
|
|
2655
|
+
anchorId,
|
|
2656
|
+
...hiding && coverIds.size > 0 ? coverIds : []
|
|
2657
|
+
])
|
|
2658
|
+
]);
|
|
2545
2659
|
const partPosed = toCanvas(model, landed.get(part.id));
|
|
2546
2660
|
const anchorPosed = toCanvas(model, landed.get(anchorId));
|
|
2661
|
+
const canvasOf = /* @__PURE__ */ new Map();
|
|
2662
|
+
const underCover = (points, skip) => {
|
|
2663
|
+
const covered = points.map(() => false);
|
|
2664
|
+
if (!hiding) return covered;
|
|
2665
|
+
for (const c of coverParts) {
|
|
2666
|
+
if (c.id === skip) continue;
|
|
2667
|
+
let posed = canvasOf.get(c.id);
|
|
2668
|
+
if (posed === void 0) {
|
|
2669
|
+
posed = toCanvas(model, landed.get(c.id));
|
|
2670
|
+
canvasOf.set(c.id, posed);
|
|
2671
|
+
}
|
|
2672
|
+
const under = paintedUnder(posed, c.mesh, c.paint, points);
|
|
2673
|
+
under.forEach((u, i) => {
|
|
2674
|
+
if (u) covered[i] = true;
|
|
2675
|
+
});
|
|
2676
|
+
}
|
|
2677
|
+
return covered;
|
|
2678
|
+
};
|
|
2547
2679
|
const turning = turns(pose);
|
|
2548
|
-
|
|
2680
|
+
const ringLands = onPart.map(
|
|
2681
|
+
(l) => l === null ? null : landLocated(partPosed, l)
|
|
2682
|
+
);
|
|
2683
|
+
const ringHidden = hiding && ringLands.every((p) => p !== null) && underCover(ringLands).every(Boolean);
|
|
2684
|
+
if (ringHidden) {
|
|
2685
|
+
leftOut++;
|
|
2686
|
+
if (turning) leftOutTurning++;
|
|
2687
|
+
} else if (turning) turningPoses++;
|
|
2688
|
+
else readNoTurn++;
|
|
2549
2689
|
let gap = 0;
|
|
2550
2690
|
for (const i of shared) {
|
|
2551
2691
|
const a = landLocated(partPosed, onPart[i]);
|
|
2552
2692
|
const b = landLocated(anchorPosed, onAnchor[i]);
|
|
2553
2693
|
gap = Math.max(gap, Math.hypot(a[0] - b[0], a[1] - b[1]));
|
|
2554
2694
|
}
|
|
2555
|
-
if (shared.length > 0) {
|
|
2695
|
+
if (shared.length > 0 && !ringHidden) {
|
|
2556
2696
|
keep(turning ? worstOf.slide : worstOf.tie, gap, pose.name);
|
|
2557
2697
|
}
|
|
2558
|
-
if (turning) {
|
|
2698
|
+
if (turning && !ringHidden) {
|
|
2559
2699
|
const at = landLocated(partPosed, tieOnPart);
|
|
2560
2700
|
let nearest = null;
|
|
2561
2701
|
if (at !== null) {
|
|
@@ -2571,43 +2711,18 @@ function checkCustomGate(model, parts, paints, options = {}) {
|
|
|
2571
2711
|
if (hiddenOn.length > 0) {
|
|
2572
2712
|
const lowerPosed = lowerId === part.id ? partPosed : anchorPosed;
|
|
2573
2713
|
const upperPosed = upperId === part.id ? partPosed : anchorPosed;
|
|
2574
|
-
const upperIndices = upperMesh.indices;
|
|
2575
2714
|
const lands = hiddenOn.map((l) => landLocated(lowerPosed, l));
|
|
2576
|
-
const
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
|
|
2583
|
-
bounds.x0 = Math.min(bounds.x0, x);
|
|
2584
|
-
bounds.y0 = Math.min(bounds.y0, y);
|
|
2585
|
-
bounds.x1 = Math.max(bounds.x1, x);
|
|
2586
|
-
bounds.y1 = Math.max(bounds.y1, y);
|
|
2587
|
-
}
|
|
2588
|
-
const find = triangleGrid(upperPosed, upperIndices, bounds);
|
|
2715
|
+
const underUpper = paintedUnder(
|
|
2716
|
+
upperPosed,
|
|
2717
|
+
upperMesh,
|
|
2718
|
+
upperPaint,
|
|
2719
|
+
lands
|
|
2720
|
+
);
|
|
2721
|
+
const underHider = coverIds.has(lowerId) ? lands.map(() => hiding) : underCover(lands, upperId);
|
|
2589
2722
|
let showing = 0;
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
const tri = [
|
|
2594
|
-
upperIndices[t * 3],
|
|
2595
|
-
upperIndices[t * 3 + 1],
|
|
2596
|
-
upperIndices[t * 3 + 2]
|
|
2597
|
-
];
|
|
2598
|
-
const w = locate(upperPosed, tri, at[0], at[1]);
|
|
2599
|
-
if (!w) continue;
|
|
2600
|
-
let rx = 0;
|
|
2601
|
-
let ry = 0;
|
|
2602
|
-
for (let k = 0; k < 3; k++) {
|
|
2603
|
-
rx += w[k] * upperMesh.rest[tri[k] * 2];
|
|
2604
|
-
ry += w[k] * upperMesh.rest[tri[k] * 2 + 1];
|
|
2605
|
-
}
|
|
2606
|
-
covered = paintedAt(upperPaint, rx, ry);
|
|
2607
|
-
break;
|
|
2608
|
-
}
|
|
2609
|
-
if (!covered) showing++;
|
|
2610
|
-
}
|
|
2723
|
+
lands.forEach((_, i) => {
|
|
2724
|
+
if (!underUpper[i] && !underHider[i]) showing++;
|
|
2725
|
+
});
|
|
2611
2726
|
keep(
|
|
2612
2727
|
turning ? worstOf.exposedTurn : worstOf.exposed,
|
|
2613
2728
|
showing,
|
|
@@ -2745,6 +2860,21 @@ function checkCustomGate(model, parts, paints, options = {}) {
|
|
|
2745
2860
|
},
|
|
2746
2861
|
...rigidReading === void 0 ? {} : { rigid: rigidReading },
|
|
2747
2862
|
tip,
|
|
2863
|
+
...occlusion === void 0 ? {} : {
|
|
2864
|
+
hidden: {
|
|
2865
|
+
by: occlusion.by,
|
|
2866
|
+
cover: [...coverIds],
|
|
2867
|
+
parameter: occlusion.parameter,
|
|
2868
|
+
default: keyParam.default,
|
|
2869
|
+
atRest: occlusionAmount(occlusion, keyParam.default),
|
|
2870
|
+
below: hiddenSide(occlusion, keyParam.default, -1),
|
|
2871
|
+
above: hiddenSide(occlusion, keyParam.default, 1),
|
|
2872
|
+
leftOut,
|
|
2873
|
+
leftOutTurning,
|
|
2874
|
+
readNoTurn,
|
|
2875
|
+
poses: poses.length
|
|
2876
|
+
}
|
|
2877
|
+
},
|
|
2748
2878
|
ok
|
|
2749
2879
|
};
|
|
2750
2880
|
});
|
|
@@ -2775,18 +2905,26 @@ function formatCustomGate(report) {
|
|
|
2775
2905
|
lines.push(
|
|
2776
2906
|
`${at} FOLDS: least triangle area ratio ${r.folds.ratio.toFixed(3)} at [${r.folds.pose}] (limit >= ${r.folds.limit}) ${verdict(r.folds.pass, r.folds.reason)}`
|
|
2777
2907
|
);
|
|
2908
|
+
const noTurnLeftOut = r.hidden !== void 0 && r.hidden.readNoTurn === 0 && r.hidden.leftOut > r.hidden.leftOutTurning;
|
|
2778
2909
|
lines.push(
|
|
2779
|
-
`${at} TIE: at the tie and the ring around it, ${r.id} against ${r.anchor}, poses that do not turn the head: max ${both(w, r.tie.px)} at [${r.tie.pose}] (limit <= ${limit(r.tie.limit)}) ${verdict(r.tie.pass, r.tie.reason)}`
|
|
2910
|
+
noTurnLeftOut ? `${at} TIE: every pose that does not turn the head is left out as hidden (see HIDDEN) ${verdict(r.tie.pass, r.tie.reason)}` : `${at} TIE: at the tie and the ring around it, ${r.id} against ${r.anchor}, poses that do not turn the head: max ${both(w, r.tie.px)} at [${r.tie.pose}] (limit <= ${limit(r.tie.limit)}) ${verdict(r.tie.pass, r.tie.reason)}`
|
|
2780
2911
|
);
|
|
2781
2912
|
const s = r.slide;
|
|
2782
2913
|
lines.push(
|
|
2783
|
-
s.turningPoses === 0 ? `${at} SLIDE: no pose turns the head pass` : `${at} SLIDE: poses that turn the head, the same length: max ${both(w, s.slide.px)} at [${s.slide.pose}] (limit <= ${limit(s.slide.limit)}); the tie's distance to the nearest painted point of ${r.anchor} as landed: max ${both(w, s.onAnchor.px)} at [${s.onAnchor.pose}] (limit <= ${limit(s.onAnchor.limit)}) ${verdict(s.pass, s.slide.pass ? s.onAnchor.reason : s.slide.reason)}`
|
|
2914
|
+
s.turningPoses === 0 ? r.hidden !== void 0 && r.hidden.leftOutTurning > 0 ? `${at} SLIDE: every pose that turns the head is left out as hidden (see HIDDEN) pass` : `${at} SLIDE: no pose turns the head pass` : `${at} SLIDE: poses that turn the head, the same length: max ${both(w, s.slide.px)} at [${s.slide.pose}] (limit <= ${limit(s.slide.limit)}); the tie's distance to the nearest painted point of ${r.anchor} as landed: max ${both(w, s.onAnchor.px)} at [${s.onAnchor.pose}] (limit <= ${limit(s.onAnchor.limit)}) ${verdict(s.pass, s.slide.pass ? s.onAnchor.reason : s.slide.reason)}`
|
|
2784
2915
|
);
|
|
2785
2916
|
const e = r.exposed;
|
|
2786
2917
|
const turnText = e.turning === null ? "no pose turns the head" : `max ${e.turning.px2.toFixed(0)} px\xB2 (${e.turning.value.toFixed(5)} face widths\xB2) at [${e.turning.pose}] (reported, no limit)`;
|
|
2787
2918
|
lines.push(
|
|
2788
2919
|
`${at} EXPOSED: ${e.hiddenPx} px of art both ${r.id} and ${r.anchor} paint near the tie, the lower one's hidden at rest; showing where the head does not turn: max ${(e.noTurn.px2 ?? 0).toFixed(0)} px\xB2 (${(e.noTurn.value ?? 0).toFixed(5)} face widths\xB2) at [${e.noTurn.pose}] (limit <= ${e.noTurn.limit} face widths\xB2, ${(e.noTurn.limit * w * w).toFixed(0)} px\xB2) ${verdict(e.pass, e.noTurn.reason)}; where it turns: ${turnText}`
|
|
2789
2920
|
);
|
|
2921
|
+
if (r.hidden) {
|
|
2922
|
+
const h = r.hidden;
|
|
2923
|
+
const side = (name, s2) => h.atRest === 1 ? `${name} ${h.default} the amount is 1 at rest and ${s2.leaves === null ? "stays 1" : `leaves it at ${s2.leaves}`}` : `${name} ${h.default} the amount ${s2.leaves === null ? `never leaves ${h.atRest}` : `leaves ${h.atRest} at ${s2.leaves}`} and ${s2.full === null ? "never reaches 1" : `reaches 1 at ${s2.full}`}`;
|
|
2924
|
+
lines.push(
|
|
2925
|
+
`${at} HIDDEN: hidden by ${h.by.join(",")} on ${h.parameter}, cover from ${h.cover.length === 0 ? "none of them" : h.cover.join(",")}${h.cover.length === h.by.length ? "" : " (the rest fade or are roles not passed, and give none)"}; amount ${h.atRest} at rest; ${side("below", h.below)}; ${side("above", h.above)}; left out of TIE and SLIDE: ${h.leftOut} of ${h.poses} poses (reported, no limit)`
|
|
2926
|
+
);
|
|
2927
|
+
}
|
|
2790
2928
|
if (r.rigid) {
|
|
2791
2929
|
lines.push(
|
|
2792
2930
|
`${at} RIGID: bend against rest: max ${both(w, r.rigid.px)} at [${r.rigid.pose}] (limit <= ${limit(r.rigid.limit)}) ${verdict(r.rigid.pass, r.rigid.reason)}`
|
|
@@ -3890,6 +4028,14 @@ function withoutParts(model, hideParts) {
|
|
|
3890
4028
|
`hideParts[${i}] ${JSON.stringify(id)} masks ${JSON.stringify(kept.id)}, which stays; hide ${JSON.stringify(kept.id)} too`
|
|
3891
4029
|
);
|
|
3892
4030
|
}
|
|
4031
|
+
const occluded = model.parts.find(
|
|
4032
|
+
(p) => !hidden.has(p.id) && p.occlusion?.by.includes(id)
|
|
4033
|
+
);
|
|
4034
|
+
if (occluded) {
|
|
4035
|
+
throw new AutoRigInputError(
|
|
4036
|
+
`hideParts[${i}] ${JSON.stringify(id)} occludes ${JSON.stringify(occluded.id)}, which stays; hide ${JSON.stringify(occluded.id)} too`
|
|
4037
|
+
);
|
|
4038
|
+
}
|
|
3893
4039
|
});
|
|
3894
4040
|
return { ...model, parts: model.parts.filter((p) => !hidden.has(p.id)) };
|
|
3895
4041
|
}
|
|
@@ -4454,7 +4600,9 @@ async function autoRigFromLayers(input) {
|
|
|
4454
4600
|
let measurer;
|
|
4455
4601
|
const crops = [];
|
|
4456
4602
|
const paints = /* @__PURE__ */ new Map();
|
|
4457
|
-
const anchorRoles = new Set(
|
|
4603
|
+
const anchorRoles = new Set(
|
|
4604
|
+
customEntries.flatMap((e) => [e.anchor, ...e.occlusion?.by ?? []])
|
|
4605
|
+
);
|
|
4458
4606
|
for (let i = 0; i < resolvedLayers.length; i++) {
|
|
4459
4607
|
const { resolved, fileName } = resolvedLayers[i];
|
|
4460
4608
|
const png = await decodePng(resolved);
|
|
@@ -4666,11 +4814,12 @@ async function autoRigFromLayers(input) {
|
|
|
4666
4814
|
try {
|
|
4667
4815
|
gate = checkCustomGate(
|
|
4668
4816
|
finalModel,
|
|
4669
|
-
customEntries.map(({ id, anchor, tie, rigid }) => ({
|
|
4817
|
+
customEntries.map(({ id, anchor, tie, rigid, occlusion }) => ({
|
|
4670
4818
|
id,
|
|
4671
4819
|
anchor,
|
|
4672
4820
|
tie,
|
|
4673
|
-
...rigid === void 0 ? {} : { rigid }
|
|
4821
|
+
...rigid === void 0 ? {} : { rigid },
|
|
4822
|
+
...occlusion === void 0 ? {} : { occludedBy: occlusion.by }
|
|
4674
4823
|
})),
|
|
4675
4824
|
paints
|
|
4676
4825
|
);
|
|
@@ -4706,7 +4855,8 @@ async function autoRigFromLayers(input) {
|
|
|
4706
4855
|
triangles: part.mesh.indices.length / 3
|
|
4707
4856
|
},
|
|
4708
4857
|
order: part.order,
|
|
4709
|
-
page: part.texture.index
|
|
4858
|
+
page: part.texture.index,
|
|
4859
|
+
...part.occlusion === void 0 ? {} : { occlusion: part.occlusion }
|
|
4710
4860
|
};
|
|
4711
4861
|
}),
|
|
4712
4862
|
...bakes === void 0 ? {} : { bakes },
|
|
@@ -7645,9 +7795,12 @@ function formatPatchReports(reports) {
|
|
|
7645
7795
|
});
|
|
7646
7796
|
}
|
|
7647
7797
|
function formatCustomPartReports(parts) {
|
|
7648
|
-
return parts.map(
|
|
7649
|
-
|
|
7650
|
-
|
|
7798
|
+
return parts.map((p) => {
|
|
7799
|
+
const line = `CUSTOM ${p.id}: box ${p.box.x},${p.box.y} ${p.box.w}x${p.box.h} px, mesh ${p.mesh.vertices} vertices ${p.mesh.triangles} triangles, order ${p.order}, atlas page ${p.page}`;
|
|
7800
|
+
if (p.occlusion === void 0) return line;
|
|
7801
|
+
const { by, parameter, stops } = p.occlusion;
|
|
7802
|
+
return `${line}, hidden by ${by.join(",")} on ${parameter} at ${stops.map((s) => `${s.value}:${s.amount}`).join(" ")}`;
|
|
7803
|
+
});
|
|
7651
7804
|
}
|
|
7652
7805
|
function formatBakeChecks(bakes) {
|
|
7653
7806
|
return bakes.map(
|
|
@@ -7655,7 +7808,7 @@ function formatBakeChecks(bakes) {
|
|
|
7655
7808
|
);
|
|
7656
7809
|
}
|
|
7657
7810
|
function createIkiMcpServer() {
|
|
7658
|
-
const server = new import_mcp.McpServer({ name: "iki", version: "0.
|
|
7811
|
+
const server = new import_mcp.McpServer({ name: "iki", version: "0.35.1" });
|
|
7659
7812
|
server.registerTool(
|
|
7660
7813
|
"validate_iki",
|
|
7661
7814
|
{
|
|
@@ -7747,7 +7900,7 @@ function createIkiMcpServer() {
|
|
|
7747
7900
|
server.registerTool(
|
|
7748
7901
|
"auto_rig_from_layers",
|
|
7749
7902
|
{
|
|
7750
|
-
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, hair_side_L/hair_side_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, a side lock needs hair_front, 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. With side locks and a `nose` (which `turn` needs) the `HAIRSIDE` lines follow the `PHYSICS` lines (the result's `turn.hairSide`), each naming the lock's role, report-only as well. `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. `customParts` adds parts the rig has no role for (a twin tail, a hairpin), each from a canvas-sized PNG of its own, as an unrigged mesh on `headDeformer` after its `after` role's parts; it needs @ikijs/mcp 0.34.0, and an older server drops the field and returns no `customParts`. The result's `customParts` (`parts`: `id`, rest `box`, `mesh`, `order`, atlas `page`) is present whenever the input was passed, `[]` included, and one `CUSTOM <id>: \u2026` line per part follows the `HAIRSIDE` lines. `bakes` (see its field) moves the custom parts with a parameter and needs `customParts`; each part and parameter it moves then prints one `BAKE <part> <param>: <n> vertices, stops <values>, error <px> px` line after the `CUSTOM` lines (the result's `customParts.bakes`: `part`, `param`, `vertices`, `stops`, `errorPx`), the written model having been landed through the engine, and a stop off by 0.1 px or more comes back as `INVALID: BAKE ERROR <part> <param>=<value>: \u2026`, and a part the bake moves at rest as `INVALID: BAKE ERROR <part> at rest: \u2026`, with nothing written (the rig and the engine disagree: report it as a bug in the packages). Whenever `customParts` was passed, the written model is also measured per custom part (the result's `customParts.gate`: `ok`, `limits`, `parts`, `failed`) and the text ends with its lines, `CUSTOM <id> FOLDS|TIE|SLIDE|EXPOSED|RIGID|TIP: \u2026` then `CUSTOM GATE pass` or `CUSTOM GATE FAIL: <part LINE, \u2026>`, always the last line: a part's least triangle area ratio, its tie's displacement against the anchor where the head does not turn and where it does, the hidden art showing, how far a rigid part bends and where its free end lands, each in px and face widths with its worst pose; `TIP` never fails the gate and the other lines do. The model is written either way; from 0.34.0 on `customParts` always carries `gate` (a gate that throws still writes the file and ends the text `CUSTOM GATE FAIL: gate error: <message>`), so a result without `customParts` is from an older server and was never gated. The custom layers are not role layers: they are left out of the head's width and turn measurements, and an empty or wrong-size one, or an entry the rig refuses, comes back as `INVALID: customParts[i]\u2026` with nothing written. A missing field or one of the wrong type (a `tie` that is not two numbers, say) is refused by the schema itself, as the SDK's input validation error.",
|
|
7903
|
+
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, hair_side_L/hair_side_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, a side lock needs hair_front, 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. With side locks and a `nose` (which `turn` needs) the `HAIRSIDE` lines follow the `PHYSICS` lines (the result's `turn.hairSide`), each naming the lock's role, report-only as well. `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. `customParts` adds parts the rig has no role for (a twin tail, a hairpin), each from a canvas-sized PNG of its own, as an unrigged mesh on `headDeformer` after its `after` role's parts; it needs @ikijs/mcp 0.34.0, and an older server drops the field and returns no `customParts`. A part can declare `occlusion` (hidden where named roles' paint covers it, by an amount keyed on a parameter; it needs 0.35.0, and an older server refuses the key as `INVALID: customParts[i]\u2026`); its `CUSTOM <id>:` line then ends `, hidden by <id>,<id>\u2026 on <parameter> at <value>:<amount> <value>:<amount>\u2026`, and the result's part carries `occlusion` (`by` as the part ids written, `parameter`, `stops`). The result's `customParts` (`parts`: `id`, rest `box`, `mesh`, `order`, atlas `page`) is present whenever the input was passed, `[]` included, and one `CUSTOM <id>: \u2026` line per part follows the `HAIRSIDE` lines. `bakes` (see its field) moves the custom parts with a parameter and needs `customParts`; each part and parameter it moves then prints one `BAKE <part> <param>: <n> vertices, stops <values>, error <px> px` line after the `CUSTOM` lines (the result's `customParts.bakes`: `part`, `param`, `vertices`, `stops`, `errorPx`), the written model having been landed through the engine, and a stop off by 0.1 px or more comes back as `INVALID: BAKE ERROR <part> <param>=<value>: \u2026`, and a part the bake moves at rest as `INVALID: BAKE ERROR <part> at rest: \u2026`, with nothing written (the rig and the engine disagree: report it as a bug in the packages). Whenever `customParts` was passed, the written model is also measured per custom part (the result's `customParts.gate`: `ok`, `limits`, `parts`, `failed`) and the text ends with its lines, `CUSTOM <id> FOLDS|TIE|SLIDE|EXPOSED|RIGID|TIP: \u2026` then `CUSTOM GATE pass` or `CUSTOM GATE FAIL: <part LINE, \u2026>`, always the last line: a part's least triangle area ratio, its tie's displacement against the anchor where the head does not turn and where it does, the hidden art showing, how far a rigid part bends and where its free end lands, each in px and face widths with its worst pose; `TIP` never fails the gate and the other lines do. The model is written either way; from 0.34.0 on `customParts` always carries `gate` (a gate that throws still writes the file and ends the text `CUSTOM GATE FAIL: gate error: <message>`), so a result without `customParts` is from an older server and was never gated. The custom layers are not role layers: they are left out of the head's width and turn measurements, and an empty or wrong-size one, or an entry the rig refuses, comes back as `INVALID: customParts[i]\u2026` with nothing written. A missing field or one of the wrong type (a `tie` that is not two numbers, say) is refused by the schema itself, as the SDK's input validation error.",
|
|
7751
7904
|
inputSchema: {
|
|
7752
7905
|
layers: import_zod.z.array(
|
|
7753
7906
|
import_zod.z.object({
|
|
@@ -7811,10 +7964,30 @@ function createIkiMcpServer() {
|
|
|
7811
7964
|
),
|
|
7812
7965
|
rigid: import_zod.z.boolean().optional().describe(
|
|
7813
7966
|
"The art does not bend (a hairpin, a ribbon): a bake that bends it by more than 0.0025 face widths at a stop, from its best-fit rotation and translation, is refused as `INVALID: bakes\u2026` with nothing written. Give a rigid part one displacement for every control point, or a rotation."
|
|
7967
|
+
),
|
|
7968
|
+
occlusion: import_zod.z.object({
|
|
7969
|
+
by: import_zod.z.array(import_zod.z.string()).describe(
|
|
7970
|
+
"Roles of the set whose paint hides the part (an arm role is its three parts); a non-empty list with no role repeated, each a role of the set. A role with a clipped or meshless part (`iris_L`, `forearm_pose_L`) is refused."
|
|
7971
|
+
),
|
|
7972
|
+
parameter: import_zod.z.string().describe(
|
|
7973
|
+
"Any declared parameter but a physics output (a spring's or a chain segment's)."
|
|
7974
|
+
),
|
|
7975
|
+
stops: import_zod.z.array(
|
|
7976
|
+
import_zod.z.object({
|
|
7977
|
+
value: import_zod.z.number(),
|
|
7978
|
+
amount: import_zod.z.number().describe(
|
|
7979
|
+
"0 to 1: 1 hides the part wherever the roles' paint lies over it."
|
|
7980
|
+
)
|
|
7981
|
+
}).passthrough()
|
|
7982
|
+
).describe(
|
|
7983
|
+
"At least one, `value` strictly ascending and inside the parameter's range. The amount is linear between stops and held before the first and after the last."
|
|
7984
|
+
)
|
|
7985
|
+
}).passthrough().optional().describe(
|
|
7986
|
+
"Hide the part where the named roles' paint covers it, by an amount keyed on a parameter: `{ by, parameter, stops: [{ value, amount }] }`. Cover is where a role's drawn alpha at that pose is at least 0.5, a hard edge; a role that fades (`mouth_open`, a blush, a pose forearm) covers only while drawn at half strength or more. Use the stops as a short switch starting a degree or more past the idle sway, the hiding's progress coming from the part's baked motion. Needs @ikijs/mcp 0.35.0; an older server refuses the key as an unknown key (`INVALID: customParts[i]\u2026`). An unknown key, a bad stop or a part the key cannot be written for comes back as `INVALID: customParts[i].occlusion\u2026` with nothing written."
|
|
7814
7987
|
)
|
|
7815
7988
|
}).passthrough()
|
|
7816
7989
|
).optional().describe(
|
|
7817
|
-
"Parts the auto-rigger has no role for, each `{ id, path, anchor, tie, after, deformer?, rigid? }`. A custom layer is read apart from `layers`: never role-parsed or measured, so its name is free and it does not widen the head the turn is fitted to; it counts toward the layer and pixel limits. All custom parts share one extra atlas page, the last, quantized on a palette of its own, so the other pages keep their bytes. An entry the rig refuses (an unknown key, a bad tie) comes back as `INVALID: customParts[i]\u2026` with nothing written; a missing field or one of the wrong type (a `tie` that is not two numbers, say) is refused by the schema itself, as the SDK's input validation error. `[]` is the same rig as leaving the field out, plus an empty `customParts` in the result."
|
|
7990
|
+
"Parts the auto-rigger has no role for, each `{ id, path, anchor, tie, after, deformer?, rigid?, occlusion? }`. A custom layer is read apart from `layers`: never role-parsed or measured, so its name is free and it does not widen the head the turn is fitted to; it counts toward the layer and pixel limits. All custom parts share one extra atlas page, the last, quantized on a palette of its own, so the other pages keep their bytes. An entry the rig refuses (an unknown key, a bad tie) comes back as `INVALID: customParts[i]\u2026` with nothing written; a missing field or one of the wrong type (a `tie` that is not two numbers, say) is refused by the schema itself, as the SDK's input validation error. `[]` is the same rig as leaving the field out, plus an empty `customParts` in the result."
|
|
7818
7991
|
),
|
|
7819
7992
|
bakes: import_zod.z.object({
|
|
7820
7993
|
targets: import_zod.z.array(
|
|
@@ -8067,7 +8240,7 @@ function createIkiMcpServer() {
|
|
|
8067
8240
|
"More sweeps rendered after `sweep`, each `{ name, preset, crop? }` into its own `<outDir>/<name>/` (files and `crop` as `sweep`'s). Names are distinct from `sweep`'s and from each other's ignoring case, and presets are distinct (at most one of each). `turn` is `sweep`'s. `roll` is the same eased curve on `ParamAngleZ` (0 to -30 to +30 to 0 over 3 s, 90 frames, physics running, idle off); its `sheet.png` is the nine frames nearest the turn sheet's angles on the -30 to +30 leg, labelled with the angle (Z) and time, and it has no kymograph (the eye row moves with the roll). `turn-nod` is the box (0,0) -> (0,-30) -> (-30,-30) -> (-30,+30) -> (+30,+30) -> (+30,-30) -> (0,-30) -> (0,0) of `ParamAngleX` x `ParamAngleY`, each leg eased, 6 s, 180 frames; its `sheet.png` is a 3 x 3 grid BY ANGLE (columns AngleX -30/0/+30, rows AngleY +30/0/-30, rest in the centre, cells labelled X, Y and t) and it has no kymograph. `manifest.json` is version 2 (`parameters`, and per frame `t` and `values`). A sweep dir's earlier frames, sheet, kymograph, manifest and flipbook are cleared first. An empty list, a repeated name or preset, or a bad crop comes back as `INVALID: sweeps...`. A server before 0.32.0 strips `sweeps` and renders the rest. The `SWEEP nod` lines (the eye-pair and iris-pair gap range and the mouth width range along the nod at each turn, in face widths) and `SWEEP corner` lines (the additivity residual per landmark at the four corners, the rest term included; 0 on an additive rig) print once per call whenever `sweep` or `sweeps` was asked for, report-only like `FOLD` and `PHYSICS`. A `roll` adds no `SWEEP` line of its own and changes none: they are read from the model. `roll` needs @ikijs/mcp 0.34.0; an older server refuses it as an input validation error."
|
|
8068
8241
|
),
|
|
8069
8242
|
hideParts: import_zod.z.array(import_zod.z.string()).optional().describe(
|
|
8070
|
-
"Part ids left out of the drawn frames (poses and sweeps); the fold, physics and sweep reports still read the whole model. Use it to render a character without its custom parts, so `measure_turn_reference` reads the rig's own head (a custom part crossing the eye row widens the head it measures, as it does on a drawn reference). An id the model lacks, or one that is the clip mask of a part that stays, comes back as `INVALID: hideParts[i] \u2026` and nothing is rendered. Needs @ikijs/mcp 0.34.0; an older server drops the field and draws every part."
|
|
8243
|
+
"Part ids left out of the drawn frames (poses and sweeps); the fold, physics and sweep reports still read the whole model. Use it to render a character without its custom parts, so `measure_turn_reference` reads the rig's own head (a custom part crossing the eye row widens the head it measures, as it does on a drawn reference). An id the model lacks, or one that is the clip mask of a part that stays, or one a part that stays names in its `occlusion.by` (hide that part too), comes back as `INVALID: hideParts[i] \u2026` and nothing is rendered. Needs @ikijs/mcp 0.34.0; an older server drops the field and draws every part."
|
|
8071
8244
|
)
|
|
8072
8245
|
}
|
|
8073
8246
|
},
|