@ikijs/mcp 0.27.0 → 0.28.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 +1 -1
- package/dist/{chunk-7POOGY7U.mjs → chunk-D2OLX5S7.mjs} +93 -32
- package/dist/chunk-D2OLX5S7.mjs.map +1 -0
- package/dist/cli.js +147 -90
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +1 -1
- package/dist/index.d.mts +4 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +147 -90
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/render-page.global.js +6 -1
- package/package.json +4 -4
- package/dist/chunk-7POOGY7U.mjs.map +0 -1
package/README.md
CHANGED
|
@@ -86,7 +86,7 @@ Renders a rigged `.iki` into the pose PNGs the character loop reviews, with the
|
|
|
86
86
|
- **What is written** — the model decides the set. A bust gets 560 × 560 shots: `rest`, `turn-m30`, `turn-p30`, `turn-15`, `nod-15`, `blink`, `blink-half`, `gaze`, `combined` (`ParamAngleX`/`Y`/`Z` all at 30), `stress` (`ParamAngleX`/`Y`/`Z` all at −30, `ParamMouthOpenY` 1, `ParamEyeLOpen` and `ParamEyeROpen` 0.5, `ParamBrowLY` −1, `ParamBrowRY` 1, `ParamBrowLAngle` 1, `ParamBrowRAngle` −1, and each of `ParamBodyAngleX`/`Y`/`Z` the model declares at −10: moves that each look fine alone, stacked). A model with a `mouth` or `mouth_inner` adds 720 × 480 mouth crops (`mouth-open-*-form-*`, `mouth-laugh`, `mouth-surprised`, `mouth-turn-p30-half`). A full body (canvas taller than wide) shoots the same squares from the model's top (the head), centred horizontally, and adds whole-canvas `full-*` shots (body, arm and elbow poses) at 1400 px wide; one with a pose forearm (`ParamArmPoseR`) adds the `full-pose-*` shots.
|
|
87
87
|
- **Result** — the text is the written paths, one per line, then the model's fold report, then its physics report. `failedTextures` lists the atlas pages the engine could not load; their parts are missing from the renders. `structuredContent` is `{ ok: true, outDir, canvas, fullBody, mouth?, failedTextures, poses: [{ name, path }], modelCanvas, folds, physics }`. A missing model, an `outDir` that is missing or outside the working directory, or a file that is not a valid model returns `{ ok: false, error }` with `INVALID: …` text.
|
|
88
88
|
- **Folds** — `folds` is the engine's `checkFolds` over its own pose set (`foldPoses`: rest, each parameter alone at its min and max, and the corners of the head and body angles crossed with the eyes, the mouth, the arms and the elbows), not over the rendered shots: `{ poses, thresholds: { flip: 0, collapse: 0.1 }, targets, offenders }`, one target per warp deformer (its grid cells) and per mesh part (its triangles), each `{ target: { kind, id }, kind, worst?, expected? }`: `worst` and `expected` are the least ratio of an area at a pose to the same at rest over the poses that are not, and that are, a by-design closure (below), each with its cell or triangle, its pose and its rest point; `kind` (`flip`, `collapse` or `ok`) is read off `worst` alone, and `offenders` are the targets that are not `ok`. The text prints one `FOLD` line per offender, worst first — `flip` (ratio ≤ 0) or `collapse` (under 0.1), `deformer` or `part`, its id, `cell (col,row)` or `triangle i`, the ratio (two significant figures under 0.01, so a flip never reads `-0.00`), the pose in brackets as its sorted `id=value` settings (`rest` for none), and where it sits at rest in model space and in model px from the top-left of `modelCanvas` (the layer PNGs' own pixels, not a render's) — or `FOLDS: none over N poses`. Then, when one folds, a `FOLDS expected:` line names the closures the auto-rig draws on purpose, each by part id, ratio and the parameter that shuts it: `eye_L` and `lash_lower_L` while `ParamEyeLOpen` is 0, `eye_R` and `lash_lower_R` while `ParamEyeROpen` is 0, and the lip set (`mouth_inner`, `mouth_tongue`, `mouth_teeth`, `lip_lower`, `lip_upper`) while `ParamMouthOpenY` is 0, read as each pose's effective value, its default included. The sweep covers the engine's pose set plus the caller's `poses`; a caller's pose is named in the `FOLD` lines by its sorted `id=value` settings (`rest` when empty), never by its PNG name, so a host reproduces any fold by setting those parameters on a player. Report-only: a fold never fails the render.
|
|
89
|
-
- **Physics** — `physics` is the engine's `checkPhysics` over the model's own rigs (`poses` do not enter it): `{ thresholds: { displacementPx: 1, pinnedFrames: 60 }, targets, offenders }`, one target per `model.physics` rig, then one per chain segment, in model order, each `{ rig, input, output, drives, kind, why?, step, idle }`. `rig` is `{ kind: "spring", id }` or `{ kind: "chain", id, segment }`; `input` is the spring
|
|
89
|
+
- **Physics** — `physics` is the engine's `checkPhysics` over the model's own rigs (`poses` do not enter it): `{ thresholds: { displacementPx: 1, pinnedFrames: 60 }, targets, offenders }`, one target per `model.physics` rig, then one per chain segment, in model order, each `{ rig, input, output, drives, kind, why?, step, idle }`. `rig` is `{ kind: "spring", id }` or `{ kind: "chain", id, segment }`; `input` is every input parameter of the spring, in rig order, or every parameter that turns the chain's anchor; `output` is the driven parameter; `drives` lists what reads it, the parts then the deformers (`{ kind, id }`); `kind` is `ok`, `frozen` or `unstable`, and `why`, present when it is not `ok`, is one phrase naming the window it came from; `offenders` are the targets that are not `ok`, unstable first. Each output is excited through the engine's real drivers on a 60 Hz clock. The step holds a fresh rig's input at its far end — the end farther from its default — for 5 s; a spring steps each input that has a range alone, in its own run, and a chain each parameter that turns its anchor, and either reports the run moving the parts most among those that are not unstable. A `lag` input's step peaks at once at its bound, −scale × weight (less one sub-step), and its `final` reads rest: the bound is what a one-frame step shows, and a gradual turn swings less. The idle runs every rig and chain together behind the procedural idle, on a seeded rng, for 30 s. `step` is `{ values, peak, at, final, displacementPx }`: the setting held, the output's largest signed displacement from rest and when, in seconds, its value at the end of the window, and the largest vertex move of any part in model px with the output alone at every value the step emitted. `idle` is `{ peak, at, displacementPx }`, its peak a size, since the sway goes both ways, and its move taken at every value the idle emitted. A target is `unstable` when a spring's one-sub-step map has a spectral radius over 1 (exact, in closed form) or sits on its undamped boundary `dt²k/m = 4`, when a driver's finiteness guard fires (`why` says how often), or when the raw output stays outside its range for 60 consecutive frames (1 s), in either window. A chain's update is nonlinear, so it gets no radius verdict: a chain that grows yet stays finite and inside its range trips none of these, which is deferred to a later slice, and shows in the numbers only. A target is `frozen` when it drives nothing, none of its spring's inputs has a range, nothing turns its chain's anchor, or the step moves the parts under 1 model px. The amplitudes are numbers only: however little the idle moves an output, that never flags. The text prints one `PHYSICS` line per target after the fold lines — its kind, the rig (`id`, or `id/segment [inputs]` for a chain segment) and `input -> output`; then `step`, its setting as sorted `id=value` pairs (`rest` for none), the peak and when, the final value and the move, with the ids it drives in parentheses; then `idle`, its peak, when and move; and ` — <why>` when it is not `ok` — or `PHYSICS: no rigs`. Parameter values and seconds print to two decimals and px to one, rounded down, so a frozen 0.96 px never reads 1.0. Report-only: nothing here refuses a rig or fails a render.
|
|
90
90
|
|
|
91
91
|
## Usage
|
|
92
92
|
|
|
@@ -473,6 +473,10 @@ var SWAY_Y_AMP_DEG = 1.6;
|
|
|
473
473
|
var SWAY_Y_PERIOD_MS = 7300;
|
|
474
474
|
var SWAY_Z_AMP_DEG = 1.1;
|
|
475
475
|
var SWAY_Z_PERIOD_MS = 11300;
|
|
476
|
+
var AMBIENT_AMP_A = 0.6;
|
|
477
|
+
var AMBIENT_PERIOD_A_MS = 2900;
|
|
478
|
+
var AMBIENT_AMP_B = 0.4;
|
|
479
|
+
var AMBIENT_PERIOD_B_MS = 4300;
|
|
476
480
|
function blinkEnvelope(phase) {
|
|
477
481
|
const ms = phase * BLINK_DURATION_MS;
|
|
478
482
|
if (ms <= 0) return 1;
|
|
@@ -504,7 +508,8 @@ var IdleMotion = class {
|
|
|
504
508
|
StandardParameter.EyeballY,
|
|
505
509
|
StandardParameter.AngleX,
|
|
506
510
|
StandardParameter.AngleY,
|
|
507
|
-
StandardParameter.AngleZ
|
|
511
|
+
StandardParameter.AngleZ,
|
|
512
|
+
StandardParameter.AmbientSway
|
|
508
513
|
];
|
|
509
514
|
sink;
|
|
510
515
|
rng;
|
|
@@ -568,6 +573,7 @@ var IdleMotion = class {
|
|
|
568
573
|
this.sink(StandardParameter.AngleX, this.swayX());
|
|
569
574
|
this.sink(StandardParameter.AngleY, this.swayY());
|
|
570
575
|
this.sink(StandardParameter.AngleZ, this.swayZ());
|
|
576
|
+
this.sink(StandardParameter.AmbientSway, this.ambientSway());
|
|
571
577
|
}
|
|
572
578
|
// ---------------------------------------------------------------------------
|
|
573
579
|
// Private helpers
|
|
@@ -581,6 +587,7 @@ var IdleMotion = class {
|
|
|
581
587
|
this.sink(StandardParameter.AngleX, 0);
|
|
582
588
|
this.sink(StandardParameter.AngleY, 0);
|
|
583
589
|
this.sink(StandardParameter.AngleZ, 0);
|
|
590
|
+
this.sink(StandardParameter.AmbientSway, 0);
|
|
584
591
|
}
|
|
585
592
|
/** Returns the current eye-open value (0..1) and advances blink state. */
|
|
586
593
|
advanceBlink() {
|
|
@@ -616,6 +623,11 @@ var IdleMotion = class {
|
|
|
616
623
|
swayZ() {
|
|
617
624
|
return SWAY_Z_AMP_DEG * Math.sin(2 * Math.PI * this.clockMs / SWAY_Z_PERIOD_MS);
|
|
618
625
|
}
|
|
626
|
+
/** Ambient sway (-1..1), pure function of the internal clock. */
|
|
627
|
+
ambientSway() {
|
|
628
|
+
const t = 2 * Math.PI * this.clockMs;
|
|
629
|
+
return AMBIENT_AMP_A * Math.sin(t / AMBIENT_PERIOD_A_MS) + AMBIENT_AMP_B * Math.sin(t / AMBIENT_PERIOD_B_MS);
|
|
630
|
+
}
|
|
619
631
|
/** Ease gaze current toward target; pick a new target on the internal clock. */
|
|
620
632
|
advanceGaze(dt) {
|
|
621
633
|
if (this.clockMs >= this.nextGazeRetargetMs) {
|
|
@@ -631,6 +643,9 @@ var IdleMotion = class {
|
|
|
631
643
|
};
|
|
632
644
|
|
|
633
645
|
// ../engine/src/physics-motion.ts
|
|
646
|
+
import {
|
|
647
|
+
physicsInputs
|
|
648
|
+
} from "@ikijs/format";
|
|
634
649
|
function signedNormalized(value, param) {
|
|
635
650
|
const rest = clamp(param.default, param.min, param.max);
|
|
636
651
|
const den = Math.max(Math.abs(param.max - rest), Math.abs(rest - param.min));
|
|
@@ -648,6 +663,7 @@ var PhysicsMotion = class {
|
|
|
648
663
|
resets;
|
|
649
664
|
resetCounts;
|
|
650
665
|
rigs;
|
|
666
|
+
inputs;
|
|
651
667
|
read;
|
|
652
668
|
sink;
|
|
653
669
|
params;
|
|
@@ -656,10 +672,17 @@ var PhysicsMotion = class {
|
|
|
656
672
|
clock = new FixedStepClock();
|
|
657
673
|
constructor(rigs, params, read, sink) {
|
|
658
674
|
this.rigs = rigs;
|
|
675
|
+
this.inputs = rigs.map(
|
|
676
|
+
(rig) => physicsInputs(rig).map(({ parameter, weight, mode }) => ({
|
|
677
|
+
parameter,
|
|
678
|
+
weight,
|
|
679
|
+
lag: mode === "lag"
|
|
680
|
+
}))
|
|
681
|
+
);
|
|
659
682
|
this.read = read;
|
|
660
683
|
this.sink = sink;
|
|
661
684
|
this.params = new Map(params.map((p) => [p.id, p]));
|
|
662
|
-
this.state = rigs.map(() => ({ x: 0, v: 0 }));
|
|
685
|
+
this.state = rigs.map(() => ({ x: 0, v: 0, lag: 0 }));
|
|
663
686
|
this.drivenParameterIds = rigs.map((rig) => rig.output.parameter);
|
|
664
687
|
this.resetCounts = rigs.map(() => 0);
|
|
665
688
|
this.resets = this.resetCounts;
|
|
@@ -668,8 +691,12 @@ var PhysicsMotion = class {
|
|
|
668
691
|
* Advance every rig to the given wall-clock timestamp (milliseconds).
|
|
669
692
|
*
|
|
670
693
|
* First call: seed each spring to rest AT its current target (so a model
|
|
671
|
-
* loaded with a nonzero input does not kick
|
|
672
|
-
* return without integrating —
|
|
694
|
+
* loaded with a nonzero input does not kick: a lag input emits rest, a follow
|
|
695
|
+
* input its value), emit that output, and return without integrating —
|
|
696
|
+
* mirroring IdleMotion's first-frame behavior.
|
|
697
|
+
*
|
|
698
|
+
* A non-finite `nowMs` after that is a dropped frame: every rig re-emits its
|
|
699
|
+
* last output from its stored state without reading its inputs.
|
|
673
700
|
*
|
|
674
701
|
* Subsequent calls: {@link FixedStepClock} folds the clamped frame delta into
|
|
675
702
|
* its accumulator and returns how many {@link FIXED_DT_S} sub-steps are due;
|
|
@@ -682,35 +709,52 @@ var PhysicsMotion = class {
|
|
|
682
709
|
this.clock.advance(nowMs);
|
|
683
710
|
for (let i = 0; i < this.rigs.length; i++) {
|
|
684
711
|
const st = this.state[i];
|
|
685
|
-
|
|
712
|
+
const { target: target2, lag } = this.targetFor(i);
|
|
713
|
+
st.x = target2;
|
|
686
714
|
st.v = 0;
|
|
715
|
+
st.lag = lag;
|
|
687
716
|
this.emit(i, st);
|
|
688
717
|
}
|
|
689
718
|
return;
|
|
690
719
|
}
|
|
720
|
+
if (!Number.isFinite(nowMs)) {
|
|
721
|
+
for (let i = 0; i < this.rigs.length; i++) this.emit(i, this.state[i]);
|
|
722
|
+
return;
|
|
723
|
+
}
|
|
691
724
|
const steps = this.clock.advance(nowMs);
|
|
692
|
-
const targets = this.rigs.map((
|
|
725
|
+
const targets = this.rigs.map((_, i) => this.targetFor(i));
|
|
693
726
|
for (let s = 0; s < steps; s++) {
|
|
694
727
|
for (let i = 0; i < this.rigs.length; i++) {
|
|
695
|
-
this.step(this.rigs[i], this.state[i], targets[i]);
|
|
728
|
+
this.step(this.rigs[i], this.state[i], targets[i].target);
|
|
696
729
|
}
|
|
697
730
|
}
|
|
698
731
|
for (let i = 0; i < this.rigs.length; i++) {
|
|
699
732
|
const st = this.state[i];
|
|
733
|
+
const { target: target2, lag } = targets[i];
|
|
700
734
|
if (!Number.isFinite(st.x) || !Number.isFinite(st.v)) {
|
|
701
|
-
st.x = Number.isFinite(
|
|
735
|
+
st.x = Number.isFinite(target2) ? target2 : 0;
|
|
702
736
|
st.v = 0;
|
|
703
737
|
this.resetCounts[i]++;
|
|
704
738
|
}
|
|
739
|
+
st.lag = lag;
|
|
705
740
|
this.emit(i, st);
|
|
706
741
|
}
|
|
707
742
|
}
|
|
708
|
-
/**
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
743
|
+
/**
|
|
744
|
+
* Rig `index`'s spring target `T` = Σ signed-normalized input value × weight,
|
|
745
|
+
* and `L`, the lag inputs' share of it. Reads each input once.
|
|
746
|
+
*/
|
|
747
|
+
targetFor(index) {
|
|
748
|
+
let target2 = 0;
|
|
749
|
+
let lag = 0;
|
|
750
|
+
for (const input of this.inputs[index]) {
|
|
751
|
+
const param = this.params.get(input.parameter);
|
|
752
|
+
const value = this.read(input.parameter);
|
|
753
|
+
const share = (param ? signedNormalized(value, param) : 0) * input.weight;
|
|
754
|
+
target2 += share;
|
|
755
|
+
if (input.lag) lag += share;
|
|
756
|
+
}
|
|
757
|
+
return { target: target2, lag };
|
|
714
758
|
}
|
|
715
759
|
/** One semi-implicit (symplectic) Euler sub-step of FIXED_DT_S seconds. */
|
|
716
760
|
step(rig, st, target2) {
|
|
@@ -718,12 +762,12 @@ var PhysicsMotion = class {
|
|
|
718
762
|
st.v += accel * FIXED_DT_S;
|
|
719
763
|
st.x += st.v * FIXED_DT_S;
|
|
720
764
|
}
|
|
721
|
-
/** Write outputDefault + x * scale onto the output param via the sink. */
|
|
765
|
+
/** Write outputDefault + (x − L) * scale onto the output param via the sink. */
|
|
722
766
|
emit(index, st) {
|
|
723
767
|
const rig = this.rigs[index];
|
|
724
768
|
const outParam = this.params.get(rig.output.parameter);
|
|
725
769
|
const outDefault = outParam ? clamp(outParam.default, outParam.min, outParam.max) : 0;
|
|
726
|
-
const value = outDefault + st.x * rig.output.scale;
|
|
770
|
+
const value = outDefault + (st.x - st.lag) * rig.output.scale;
|
|
727
771
|
const finite = Number.isFinite(value);
|
|
728
772
|
if (!finite) this.resetCounts[index]++;
|
|
729
773
|
this.sink(rig.output.parameter, finite ? value : outDefault);
|
|
@@ -1199,6 +1243,11 @@ function classify(worst) {
|
|
|
1199
1243
|
return "ok";
|
|
1200
1244
|
}
|
|
1201
1245
|
|
|
1246
|
+
// ../engine/src/physics-check.ts
|
|
1247
|
+
import {
|
|
1248
|
+
physicsInputs as physicsInputs2
|
|
1249
|
+
} from "@ikijs/format";
|
|
1250
|
+
|
|
1202
1251
|
// ../engine/src/physics-runs.ts
|
|
1203
1252
|
var FRAME_MS = FIXED_DT_S * 1e3 * (1 + 1e-9);
|
|
1204
1253
|
var STEP_FRAMES = 300;
|
|
@@ -1377,26 +1426,34 @@ function checkPhysics(model) {
|
|
|
1377
1426
|
};
|
|
1378
1427
|
const param = (id) => model.parameters.find((p) => p.id === id);
|
|
1379
1428
|
const springs = (model.physics ?? []).map((rig) => {
|
|
1380
|
-
const
|
|
1429
|
+
const inputs = physicsInputs2(rig).map((i) => param(i.parameter));
|
|
1430
|
+
const ids = inputs.map((p) => p.id);
|
|
1381
1431
|
const output = param(rig.output.parameter);
|
|
1382
|
-
const
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
values
|
|
1390
|
-
|
|
1432
|
+
const ranged = inputs.flatMap((input) => {
|
|
1433
|
+
const far = farEnd(input);
|
|
1434
|
+
return far === void 0 ? [] : [{ [input.id]: far }];
|
|
1435
|
+
});
|
|
1436
|
+
const settings = ranged.length === 0 ? [{}] : ranged;
|
|
1437
|
+
const steps = settings.map((values) => {
|
|
1438
|
+
const reading = stepRun(model, [rig], [], values).get(output.id);
|
|
1439
|
+
const setting = inputs.length === 1 ? [] : Object.entries(values).map(([id, v]) => `${id}=${v}`);
|
|
1440
|
+
return {
|
|
1441
|
+
name: ["the step", ...setting].join(" "),
|
|
1442
|
+
reading,
|
|
1443
|
+
displacementPx: displace(output, reading.values),
|
|
1444
|
+
values
|
|
1445
|
+
};
|
|
1446
|
+
});
|
|
1391
1447
|
const atIdle = idleExcitation(output);
|
|
1448
|
+
const clean = steps.filter((s) => !unstableWhy(output, [s]));
|
|
1392
1449
|
return target(model, {
|
|
1393
1450
|
rig: { kind: "spring", id: rig.id },
|
|
1394
|
-
input:
|
|
1451
|
+
input: ids,
|
|
1395
1452
|
output,
|
|
1396
|
-
step,
|
|
1453
|
+
step: mostMoving(clean.length > 0 ? clean : steps),
|
|
1397
1454
|
idle: atIdle,
|
|
1398
|
-
unstable: springWhy(rig) ?? unstableWhy(output, [
|
|
1399
|
-
inert:
|
|
1455
|
+
unstable: springWhy(rig) ?? unstableWhy(output, [...steps, atIdle]),
|
|
1456
|
+
inert: ranged.length === 0 ? `${ids.join(", ")} ${ids.length === 1 ? "has" : "have"} no range` : void 0
|
|
1400
1457
|
});
|
|
1401
1458
|
});
|
|
1402
1459
|
const chains = (model.physicsChains ?? []).flatMap((chain) => {
|
|
@@ -2621,6 +2678,10 @@ var STANDARD_PARAMETER_INFO = [
|
|
|
2621
2678
|
id: StandardParameter4.Breath,
|
|
2622
2679
|
description: "Idle breath (0 .. 1), cycled by the host."
|
|
2623
2680
|
},
|
|
2681
|
+
{
|
|
2682
|
+
id: StandardParameter4.AmbientSway,
|
|
2683
|
+
description: "Ambient sway (-1 .. 1): a slow zero-mean drift the idle writes for physics rigs to follow (the auto-rig's hair in idle). Not a wind: no bias. Stays procedural under a declared Idle group, as Breath does."
|
|
2684
|
+
},
|
|
2624
2685
|
{
|
|
2625
2686
|
id: StandardParameter4.BrowLeftY,
|
|
2626
2687
|
description: "Left brow raise/lower (-1 .. 1)."
|
|
@@ -5644,7 +5705,7 @@ function formatPatchReports(reports) {
|
|
|
5644
5705
|
});
|
|
5645
5706
|
}
|
|
5646
5707
|
function createIkiMcpServer() {
|
|
5647
|
-
const server = new McpServer({ name: "iki", version: "0.
|
|
5708
|
+
const server = new McpServer({ name: "iki", version: "0.28.0" });
|
|
5648
5709
|
server.registerTool(
|
|
5649
5710
|
"validate_iki",
|
|
5650
5711
|
{
|
|
@@ -5978,4 +6039,4 @@ export {
|
|
|
5978
6039
|
formatPhysicsReport,
|
|
5979
6040
|
createIkiMcpServer
|
|
5980
6041
|
};
|
|
5981
|
-
//# sourceMappingURL=chunk-
|
|
6042
|
+
//# sourceMappingURL=chunk-D2OLX5S7.mjs.map
|