rig-parts 2.74.0 → 2.75.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/cli.ts +30 -7
- package/docs/AUTHORING.md +74 -3
- package/docs/STABILITY.md +65 -2
- package/package.json +1 -1
- package/src/check.ts +21 -19
- package/src/compose-seams.ts +476 -0
- package/src/layers.ts +73 -7
- package/src/scene.ts +46 -4
package/cli.ts
CHANGED
|
@@ -43,7 +43,7 @@ import { proposeHeadBox, type Box } from './src/headbox.ts';
|
|
|
43
43
|
import { headCropPreflight, headCropPreflightLines } from './src/headcroppreflight.ts';
|
|
44
44
|
import { makeInputs } from './src/inputs.ts';
|
|
45
45
|
import { idleKeysOf, isIdleKeys } from './src/rig.ts';
|
|
46
|
-
import { bodyCoreBox, bodyOpaqueBox, CORE_ALPHA, depthSkipLine, exportLayers, figuresPhrase, hiddenLayerLine, implausibleRules, layerCoreBox, layerFigures, layerOpaqueBox, type LayerSet, layerSetDiff, type OpaqueBox, OPAQUE_ALPHA_ABOVE, pct, readLayers, readWrapperLayers, ruleSummary, templateLayerNames, templatePsdBytes, times } from './src/layers.ts';
|
|
46
|
+
import { bodyCoreBox, bodyOpaqueBox, CORE_ALPHA, depthSkipLine, exportLayers, figuresPhrase, hiddenLayerLine, implausibleRules, layerCoreBox, layerFigures, layerOpaqueBox, type LayerSet, layerSetDiff, type OpaqueBox, OPAQUE_ALPHA_ABOVE, pct, readLayers, readLayersForExport, readWrapperLayers, ruleSummary, templateLayerNames, templatePsdBytes, times } from './src/layers.ts';
|
|
47
47
|
import { checkImageSize, choosePerson, KEYPOINTS_SPEC, loadKeypoints, type RigJoints, toRigJoints } from './src/keypoints.ts';
|
|
48
48
|
import { checkPartsStage } from './src/partscheck.ts';
|
|
49
49
|
import { withinPartsPath } from './src/partsfiles.ts';
|
|
@@ -58,6 +58,7 @@ import { checkPainting, DEFAULT_PAINTING_FORM, isPaintingForm, PAINTING_FORMS, p
|
|
|
58
58
|
import { decodePngBytes, readPng, writePng } from './src/raster/png.ts';
|
|
59
59
|
import { REQUIREMENTS_SENTENCE } from './src/requirements.ts';
|
|
60
60
|
import { replacementTreeDigest } from './src/replacementrecord.ts';
|
|
61
|
+
import { clearComposeSeams, readComposeSeamRequest, verifyComposeSeams } from './src/compose-seams.ts';
|
|
61
62
|
import { type ComposeInput, composeStage, IMAGE_SEP, PLATE, PROVENANCES, refusePreviewLoopSeam, SCENE_CAMERA_REPORT_SPEC, SCENE_REPORT_FILE, SCENE_REPORT_SPEC, SCENE_SPEC } from './src/scene.ts';
|
|
62
63
|
import { buildSheet, defaultCaption, type Tile, tilesFrom } from './src/sheet.ts';
|
|
63
64
|
import { loadComparison, requiredProblems, structureLines } from './src/structure.ts';
|
|
@@ -1062,7 +1063,11 @@ usage:
|
|
|
1062
1063
|
|
|
1063
1064
|
rig-parts compose --scene <scene.json> --out <dir> [--requirements <file.json>] [--accept <bar>[,<bar>...]] [--page-size <px>]
|
|
1064
1065
|
[--loop-seam-bar <channel-delta,pixels> --loop-seam-cap <loops>]
|
|
1065
|
-
[--output-profile preview] [--no-extremes]
|
|
1066
|
+
[--output-profile preview] [--no-extremes] [--motion-seams <request.json>]
|
|
1067
|
+
rig-parts compose --verify-motion-seams <compose-out> --motion-seams <request.json>
|
|
1068
|
+
--motion-seams publishes a bound render and its own seam verdict in
|
|
1069
|
+
motion-seams/. The verification mode re-reads the build and PNG bytes
|
|
1070
|
+
and exits 0 for a verified PASS, or 1 for FAIL, SKIP or a mismatch.
|
|
1066
1071
|
The loop seam flags measure the composed idle in check/, as for check.
|
|
1067
1072
|
--no-extremes omits the extra extremes renders. --output-profile preview
|
|
1068
1073
|
also omits published idle_frames/, contact.png and motion_heat.png, and
|
|
@@ -1329,7 +1334,7 @@ const TAKES = {
|
|
|
1329
1334
|
'comfy plate': { valued: ['--mode', '--painting', '--mask-from', '--occluder', '--out', '--graph', '--model', '--checkpoint-sha256', '--seed', '--grow', '--steps', '--cfg', '--prompt', '--negative', '--host', '--wait', '--timeout', '--poll'], switches: ['--holes', '--help'] },
|
|
1330
1335
|
inputs: { valued: ['--source', '--config', '--out'], switches: ['--help'] },
|
|
1331
1336
|
build: { valued: ['--config', '--source', '--full', '--head', '--out', '--seam', '--project', '--page-edges', '--pack-shape', '--page-size', '--requirements', '--idle-keys', '--lead-in', '--alt', '--set', '--environment', '--wind-band'], switches: ['--loop', '--seam-pairs', '--keep-stills', '--all-sets', '--no-extremes', '--help'] },
|
|
1332
|
-
compose: { valued: ['--scene', '--out', '--requirements', '--accept', '--page-size', '--loop-seam-bar', '--loop-seam-cap', '--output-profile'], switches: ['--no-extremes', '--help'] },
|
|
1337
|
+
compose: { valued: ['--scene', '--out', '--requirements', '--accept', '--page-size', '--loop-seam-bar', '--loop-seam-cap', '--output-profile', '--motion-seams', '--verify-motion-seams'], switches: ['--no-extremes', '--help'] },
|
|
1333
1338
|
'mesh-draft': { valued: ['--config', '--parts', '--out', '--requirements', '--idle-keys', '--page-edges', '--pack-shape', '--page-size'], switches: ['--more-triangles', '--help'] },
|
|
1334
1339
|
'mesh-stats': { valued: ['--config', '--parts'], switches: ['--help'] },
|
|
1335
1340
|
remesh: { valued: ['--rig', '--config', '--parts', '--part', '--mesh', '--delta', '--out', '--requirements', '--idle-keys', '--page-edges', '--pack-shape', '--page-size', '--input-check'], switches: ['--record-input-check', '--help'] },
|
|
@@ -1470,7 +1475,10 @@ function cmdLayers(args: string[]): number {
|
|
|
1470
1475
|
if (flags.has('--canvas')) return usage('--canvas belongs to --template');
|
|
1471
1476
|
if (paths.length !== 1) return usage(`layers takes one path; got ${paths.length}`);
|
|
1472
1477
|
try {
|
|
1473
|
-
const
|
|
1478
|
+
const dir = flags.get('--export');
|
|
1479
|
+
const { set, source } = dir === undefined
|
|
1480
|
+
? { set: readLayers(paths[0]), source: undefined }
|
|
1481
|
+
: readLayersForExport(paths[0], version());
|
|
1474
1482
|
printLayerTable(set);
|
|
1475
1483
|
const context = ['--full', '--source', '--config'];
|
|
1476
1484
|
if (context.some(f => flags.has(f))) {
|
|
@@ -1480,9 +1488,8 @@ function cmdLayers(args: string[]): number {
|
|
|
1480
1488
|
const g = { sourceW: source.width, sourceH: source.height, ...proposeFields(cfg) };
|
|
1481
1489
|
for (const w of headGarmentOverlaps(full, set, g, cfg.assemble.plan)) console.log(` ${headGarmentWarning(w)}`);
|
|
1482
1490
|
}
|
|
1483
|
-
const dir = flags.get('--export');
|
|
1484
1491
|
if (dir !== undefined) {
|
|
1485
|
-
const w = exportLayers(set, dir);
|
|
1492
|
+
const w = exportLayers(set, dir, undefined, source);
|
|
1486
1493
|
// The round trip, read now: what was written must read back as what was read.
|
|
1487
1494
|
const back = readWrapperLayers(dir);
|
|
1488
1495
|
const diff = layerSetDiff(set, back);
|
|
@@ -2715,8 +2722,21 @@ function cmdBuild(args: string[]): number {
|
|
|
2715
2722
|
|
|
2716
2723
|
function cmdCompose(args: string[]): number {
|
|
2717
2724
|
const on = new Set<string>();
|
|
2718
|
-
const f = flags(args, 'compose', [
|
|
2725
|
+
const f = flags(args, 'compose', [], on);
|
|
2719
2726
|
if (typeof f === 'string') return usage(f);
|
|
2727
|
+
const seamRequest = f.get('--motion-seams');
|
|
2728
|
+
const verifySeams = f.get('--verify-motion-seams');
|
|
2729
|
+
if (verifySeams !== undefined) {
|
|
2730
|
+
if (seamRequest === undefined || f.size !== 2 || on.size > 0) return usage('--verify-motion-seams takes only --motion-seams <request.json>');
|
|
2731
|
+
try {
|
|
2732
|
+
const verdict = verifyComposeSeams(verifySeams, readComposeSeamRequest(seamRequest));
|
|
2733
|
+
console.log(`bound motion seams: ${verdict.status} — ${verdict.reason}, ${verdict.frameCount} verified frame(s); binding SHA-256 ${verdict.bindingSha256}`);
|
|
2734
|
+
return verdict.status === 'PASS' ? EXIT_OK : EXIT_REFUSED;
|
|
2735
|
+
} catch (err) {
|
|
2736
|
+
return printRefusal(err);
|
|
2737
|
+
}
|
|
2738
|
+
}
|
|
2739
|
+
for (const required of ['--scene', '--out']) if (!f.has(required)) return usage(`compose needs ${required} <value>`);
|
|
2720
2740
|
const profile = f.get('--output-profile');
|
|
2721
2741
|
if (profile !== undefined && profile !== 'preview') return usage(`--output-profile ${JSON.stringify(profile)}; preview is required when this flag is given`);
|
|
2722
2742
|
const outputProfile = profile ?? (on.has('--no-extremes') ? 'no-extremes' : undefined);
|
|
@@ -2724,15 +2744,18 @@ function cmdCompose(args: string[]): number {
|
|
|
2724
2744
|
if (typeof loopSeam === 'string') return usage(loopSeam);
|
|
2725
2745
|
const out = f.get('--out') as string;
|
|
2726
2746
|
clearComposeRun(out);
|
|
2747
|
+
clearComposeSeams(out);
|
|
2727
2748
|
let input: ComposeInput;
|
|
2728
2749
|
try {
|
|
2729
2750
|
const size = parsePageSize(f.get('--page-size'));
|
|
2730
2751
|
const req = f.get('--requirements');
|
|
2731
2752
|
const accept = f.get('--accept');
|
|
2753
|
+
const motionSeams = seamRequest === undefined ? undefined : readComposeSeamRequest(seamRequest);
|
|
2732
2754
|
input = {
|
|
2733
2755
|
scene: f.get('--scene') as string, out, ...(size === undefined ? {} : { pageSize: size }),
|
|
2734
2756
|
...(req === undefined ? {} : { requirements: req }), ...(accept === undefined ? {} : { accept: accept.split(',') }),
|
|
2735
2757
|
...(loopSeam === undefined ? {} : { loopSeam }),
|
|
2758
|
+
...(motionSeams === undefined ? {} : { motionSeams }),
|
|
2736
2759
|
...(outputProfile === undefined ? {} : { outputProfile }),
|
|
2737
2760
|
};
|
|
2738
2761
|
refusePreviewLoopSeam(input);
|
package/docs/AUTHORING.md
CHANGED
|
@@ -4795,6 +4795,13 @@ an inspection and structural-authoring interface:
|
|
|
4795
4795
|
takes as "the manifest's order is the draw order". The export is read back at
|
|
4796
4796
|
once and must reproduce the file's reading — layers, boxes, pixels, order — or
|
|
4797
4797
|
it is refused (`LAYERS_EXPORT_ROUND_TRIP`).
|
|
4798
|
+
The manifest's `source` records the input path as typed, the format, the
|
|
4799
|
+
digest, the Parts version and the export command. For PSD input, compare
|
|
4800
|
+
`source.sha256` against the original PSD bytes. For a wrapper directory or
|
|
4801
|
+
a direct `layers.json` input, compare it against the input manifest bytes.
|
|
4802
|
+
A wrapper re-export records its immediate input manifest. Its digest
|
|
4803
|
+
excludes the PNGs, and later edits to the output do not update the record.
|
|
4804
|
+
Older and hand-written manifests can omit `source`.
|
|
4798
4805
|
2. **Read.** `rig-parts layers work` (the table and its `WARN` lines),
|
|
4799
4806
|
`assemble --full work …` (the part lines, `recomposite vs source`, the
|
|
4800
4807
|
`uncovered hole` and `uncovered:` lines) and `render/recomposite_error_rig.png`
|
|
@@ -4809,6 +4816,10 @@ an inspection and structural-authoring interface:
|
|
|
4809
4816
|
otherwise).
|
|
4810
4817
|
4. **Re-run** from step 2 on `work`.
|
|
4811
4818
|
|
|
4819
|
+
| rule | when it fires | what to correct |
|
|
4820
|
+
| --- | --- | --- |
|
|
4821
|
+
| <a id="LAYERS_EXPORT_SOURCE"></a>`LAYERS_EXPORT_SOURCE` | a wrapper manifest has a malformed `source` block, with the offending field named | re-export from the original input to regenerate the record |
|
|
4822
|
+
|
|
4812
4823
|
**A historical reader control**, not a repair prescription (the selftest's, `fixtures/artist.ts`): a 128-px file whose
|
|
4813
4824
|
right eyewhite was painted half into `back hair` — the 8 x 10 patch at
|
|
4814
4825
|
`[52, 22, 60, 32]`, near-white, behind the face. Assembled from the export:
|
|
@@ -7375,6 +7386,24 @@ and stay absent).
|
|
|
7375
7386
|
| <a id="SCENE_IMAGE_NAME_FREE"></a>`SCENE_IMAGE_NAME_FREE` | two images compose to one file name (`<id>.<file>`: an id `x` with an image `y.cloth.png`, and an id `x.y` with `cloth.png`) | another id |
|
|
7376
7387
|
| <a id="COMPOSE_RIGC_GREEN"></a>`COMPOSE_RIGC_GREEN` | rig-c refused the composed rig; its line is quoted. A field compose carries as written (a constraint's `mix`, a slot's setup attachment) is rigc's to judge | the build whose field it names |
|
|
7377
7388
|
| <a id="COMPOSE_PREVIEW_REQUIRED_CHECK"></a>`COMPOSE_PREVIEW_REQUIRED_CHECK` | `--loop-seam-bar` with `--output-profile preview`. The `loop_seam` record in `check.json` binds the paths and SHA-256 hashes of the first and wrap PNGs under `check/idle_frames/`, which preview removes | `found=preview, required=default or no-extremes`. Use default diagnostics or `--no-extremes` to retain the bound PNGs |
|
|
7389
|
+
| <a id="COMPOSE_MOTION_SEAMS_ANIMATION"></a>`COMPOSE_MOTION_SEAMS_ANIMATION` | the requested take is absent from the packed composed build | use a literal composed take name from that build |
|
|
7390
|
+
| <a id="COMPOSE_MOTION_SEAMS_BINDING"></a>`COMPOSE_MOTION_SEAMS_BINDING` | the report is unreadable or disagrees with the request, its binding digest, the composed check declarations or its inventoried frame readings | use the original report with its request and compose output, or rerun compose to regenerate the bundle |
|
|
7391
|
+
| <a id="COMPOSE_MOTION_SEAMS_BUILD"></a>`COMPOSE_MOTION_SEAMS_BUILD` | the packed candidate is unreadable, differs from the report's source binding, or lacks a matching green gate | use the intact composed output, including its packed pages, scene report and check report |
|
|
7392
|
+
| <a id="COMPOSE_MOTION_SEAMS_CORE"></a>`COMPOSE_MOTION_SEAMS_CORE` | the gate executable cannot report the installed Core version or reports a different version | use the rigc executable from the installed Core dependency |
|
|
7393
|
+
| <a id="COMPOSE_MOTION_SEAMS_FPS"></a>`COMPOSE_MOTION_SEAMS_FPS` | the requested frame rate is invalid, the take and preroll cannot fit Core's sample schedule, or the report or inventory records a different rate | use the expected frame rate and a valid schedule, then produce a new bundle if the request changed |
|
|
7394
|
+
| <a id="COMPOSE_MOTION_SEAMS_INVENTORY"></a>`COMPOSE_MOTION_SEAMS_INVENTORY` | the inventory bytes, frame identities, PNG roster or frame hashes fail validation | use the intact inventory and PNGs from the reported render |
|
|
7395
|
+
| <a id="COMPOSE_MOTION_SEAMS_NOT_JUDGED"></a>`COMPOSE_MOTION_SEAMS_NOT_JUDGED` | compose ran with bound motion seam measurement disabled | supply `--motion-seams <request.json>` to produce and judge a bound frame set |
|
|
7396
|
+
| <a id="COMPOSE_MOTION_SEAMS_REQUEST"></a>`COMPOSE_MOTION_SEAMS_REQUEST` | the request file is unreadable or has an invalid spec, animation name, option or field | supply a valid [bound motion seam request](#bound-composed-motion-seams-issue-1682) |
|
|
7397
|
+
| <a id="COMPOSE_MOTION_SEAMS_SAMPLE"></a>`COMPOSE_MOTION_SEAMS_SAMPLE` | sampling, rendering or publication failed, or Core returned the wrong frame count or missing geometry | correct the cause named by the diagnostic and rerun compose |
|
|
7398
|
+
| <a id="COMPOSE_MOTION_SEAMS_VIEWPORT"></a>`COMPOSE_MOTION_SEAMS_VIEWPORT` | the scene canvas or keyed camera produces an invalid view at the named time | correct the view or supply a valid fixed viewport in the request |
|
|
7399
|
+
| <a id="BODY_ROOT_OPENING"></a>`BODY_ROOT_OPENING` | a body-root frame's visible gap and lower-slot ghost cell count exceeds the one-cell floor | inspect the reported frame and world box for the opening |
|
|
7400
|
+
| <a id="CORE_SEAM_UNREADABLE"></a>`CORE_SEAM_UNREADABLE` | Core refused to measure the pair on the named frame | inspect Core's detail for the drawing or attachment that prevented measurement |
|
|
7401
|
+
| <a id="NO_DECLARED_PAIRS"></a>`NO_DECLARED_PAIRS` | compose check selected no declared motion seam pairs | declare the slots to measure through the compose check inputs |
|
|
7402
|
+
| <a id="NO_SETUP_BAND"></a>`NO_SETUP_BAND` | both slots draw, and the pair shares no setup overlap band on Core's grid | inspect the setup overlap of the declared pair |
|
|
7403
|
+
| <a id="OPENING_WARNING"></a>`OPENING_WARNING` | an explicit or internal-joint pair has a gap or ghost above the one-cell floor | inspect the reported frame to decide whether the opening is intentional |
|
|
7404
|
+
| <a id="REQUIRED_BACKGROUND"></a>`REQUIRED_BACKGROUND` | a required seam has at least one cell open to background | inspect the reported frame and world box for exposed background |
|
|
7405
|
+
| <a id="SLOT_MISSING"></a>`SLOT_MISSING` | the composed poser has no slot with one of the pair's literal names | resolve the declaration against the slots in the packed build |
|
|
7406
|
+
| <a id="SLOT_NOT_DRAWN"></a>`SLOT_NOT_DRAWN` | one or both of the declared slots fail to draw on the named frame | inspect the animation's attachments, visibility and clipping at that time |
|
|
7378
7407
|
| `REQUIREMENTS_*` | the `--requirements` file, as for `check` | as for `check` |
|
|
7379
7408
|
|
|
7380
7409
|
### The command line
|
|
@@ -8515,6 +8544,48 @@ Both files must remain under `check/idle_frames/` for readers to verify the
|
|
|
8515
8544
|
seam evidence after the run. This refusal clears `rig/`, `check/`, `scene.json` and
|
|
8516
8545
|
`compose-run.json` under `--out` before the gate.
|
|
8517
8546
|
|
|
8547
|
+
#### Bound composed motion seams (issue #1682)
|
|
8548
|
+
|
|
8549
|
+
Use `--motion-seams` on the compose command that produces the scene you intend
|
|
8550
|
+
to play. Declare neighbour pairs through the usual compose check inputs, such
|
|
8551
|
+
as a `motion_seams` declaration with `part: "actor:upper"` and
|
|
8552
|
+
`neighbour: "actor:lower"` in the requirements file. The bundle uses the
|
|
8553
|
+
literal resolved slot names and pair classes selected by compose. Write the
|
|
8554
|
+
consumer's sampling choices in `seam-request.json`.
|
|
8555
|
+
|
|
8556
|
+
```json
|
|
8557
|
+
{
|
|
8558
|
+
"spec": "rig-parts-motion-seams-request/1",
|
|
8559
|
+
"animation": "idle",
|
|
8560
|
+
"fps": 24
|
|
8561
|
+
}
|
|
8562
|
+
```
|
|
8563
|
+
|
|
8564
|
+
```sh
|
|
8565
|
+
rig-parts compose --scene scene.json --out composed \
|
|
8566
|
+
--requirements requirements.json --motion-seams seam-request.json
|
|
8567
|
+
rig-parts compose --verify-motion-seams composed --motion-seams seam-request.json
|
|
8568
|
+
```
|
|
8569
|
+
|
|
8570
|
+
The consumer uses `composed/motion-seams/frames/f0000.png` and subsequent PNGs
|
|
8571
|
+
in `composed/motion-seams/inventory.json` order. Its verdict is
|
|
8572
|
+
`composed/motion-seams/report.json`. Verification requires the expected request,
|
|
8573
|
+
the composed build and the exact PNG bytes. Use the verification exit before
|
|
8574
|
+
consuming the PNGs. Keep the bundle and the composed output together.
|
|
8575
|
+
|
|
8576
|
+
Use `preroll` for a positive whole number of Core warm-up loops. Omit it for
|
|
8577
|
+
the render from rest. Use `viewport: [x, y, width, height]` for a fixed,
|
|
8578
|
+
one-pixel-per-world-unit view with a bottom-left origin and whole pixel
|
|
8579
|
+
dimensions. Without a viewport request, the render uses the scene canvas and
|
|
8580
|
+
follows the keyed camera for a take with a camera track. The inventory records
|
|
8581
|
+
the view at each sample. A different frame rate, preroll or viewport requires
|
|
8582
|
+
its own render and verdict. The bundle attests to the PNGs it publishes.
|
|
8583
|
+
|
|
8584
|
+
The stock compose check retains its own result. Its `--loop-seam-bar` and
|
|
8585
|
+
`--loop-seam-cap` still select the separate Core loop-closure evidence.
|
|
8586
|
+
Without `--motion-seams`, the compose console says that bound render frames
|
|
8587
|
+
were not judged. See the [file and verification contract](STABILITY.md#bound-composed-motion-seams).
|
|
8588
|
+
|
|
8518
8589
|
#### Physics clips and scene repeats (issue #1615)
|
|
8519
8590
|
|
|
8520
8591
|
A physics-only side clip typically enters a character build through
|
|
@@ -11199,8 +11270,8 @@ Internal `SeamSupport.drawings` never enters check JSON. Named requirement
|
|
|
11199
11270
|
| `SEAM_OVER_MOTION.required.pairs[].open_frames` | `SEAM_OVER_MOTION.required.pairs[].open_frames`; `characters.*.SEAM_OVER_MOTION.required.pairs[].open_frames` | 'pair' | evidence | [p.a, p.b] | [check.ts:5321](../src/check.ts#L5321) |
|
|
11200
11271
|
| `SEAM_OVER_MOTION.roots.unmeasured` | `SEAM_OVER_MOTION.roots.unmeasured`; `characters.*.SEAM_OVER_MOTION.roots.unmeasured` | 'part' | evidence | [root.part] | [check.ts:5995](../src/check.ts#L5995) |
|
|
11201
11272
|
| `SEAM_OVER_MOTION.rows` | `SEAM_OVER_MOTION.rows`; `characters.*.SEAM_OVER_MOTION.rows` | 'pair'; unique ? 'pair' : 'rig' | finding when motionSeamFinding(want.root !== undefined, p.status, p.banded, opens.length); otherwise evidence; finding when motionSeamFinding(rootNames.has(r.pair), r.status, r.banded, r.opens.length); otherwise evidence | [want.a, want.b]; unique ? [pair.a, pair.b] : [] | [check.ts:5952](../src/check.ts#L5952), [check.ts:6028](../src/check.ts#L6028) |
|
|
11202
|
-
| `SEAM_OVER_MOTION.rows[].cells` | `SEAM_OVER_MOTION.rows[].cells`; `characters.*.SEAM_OVER_MOTION.rows[].cells` | 'pair' | evidence | [want.a, want.b]; subjects | [check.ts:5965](../src/check.ts#L5965), [check.ts:
|
|
11203
|
-
| `SEAM_OVER_MOTION.rows[].joint_contact.reasons` | `SEAM_OVER_MOTION.rows[].joint_contact.reasons`; `characters.*.SEAM_OVER_MOTION.rows[].joint_contact.reasons` | 'pair' | evidence | [want.a, want.b]; subjects | [check.ts:5955](../src/check.ts#L5955), [check.ts:
|
|
11273
|
+
| `SEAM_OVER_MOTION.rows[].cells` | `SEAM_OVER_MOTION.rows[].cells`; `characters.*.SEAM_OVER_MOTION.rows[].cells` | 'pair' | evidence | [want.a, want.b]; subjects | [check.ts:5965](../src/check.ts#L5965), [check.ts:12487](../src/check.ts#L12487) |
|
|
11274
|
+
| `SEAM_OVER_MOTION.rows[].joint_contact.reasons` | `SEAM_OVER_MOTION.rows[].joint_contact.reasons`; `characters.*.SEAM_OVER_MOTION.rows[].joint_contact.reasons` | 'pair' | evidence | [want.a, want.b]; subjects | [check.ts:5955](../src/check.ts#L5955), [check.ts:12478](../src/check.ts#L12478) |
|
|
11204
11275
|
| `SEAM_OVER_MOTION.rows[].pose_at_worst.joints` | `SEAM_OVER_MOTION.rows[].pose_at_worst.joints`; `characters.*.SEAM_OVER_MOTION.rows[].pose_at_worst.joints` | 'rig' | evidence | [] | [motionseampose.ts:53](../src/motionseampose.ts#L53) |
|
|
11205
11276
|
| `SEAM_OVER_MOTION.worlds.*.rows` | `SEAM_OVER_MOTION.worlds.*.rows`; `characters.*.SEAM_OVER_MOTION.worlds.*.rows` | 'pair' | evidence | [want.a, want.b] | [check.ts:5949](../src/check.ts#L5949) |
|
|
11206
11277
|
| `SEAM_OVER_RANGE.joints` | `SEAM_OVER_RANGE.joints`; `characters.*.SEAM_OVER_RANGE.joints` | 'part' | evidence; finding when poses.some(p => p.status === 'FAIL'); otherwise evidence | [j.part] | [check.ts:4983](../src/check.ts#L4983), [check.ts:5029](../src/check.ts#L5029) |
|
|
@@ -11226,7 +11297,7 @@ Internal `SeamSupport.drawings` never enters check JSON. Named requirement
|
|
|
11226
11297
|
| `requirements.lines.* (seam)` | `requirements.lines.*` | 'pair' | finding when line.status === 'FAIL'; otherwise evidence | [r.part, r.neighbour] | [check.ts:8694](../src/check.ts#L8694) |
|
|
11227
11298
|
| `requirements.lines.* (stretch)` | `requirements.lines.*` | part when the supplied mapping resolves a piece; otherwise rig | finding when line.status === 'FAIL'; otherwise evidence | resolved piece for r.slot; otherwise [] | [check.ts:8694](../src/check.ts#L8694) |
|
|
11228
11299
|
| `seam_cells.frames` | `frames` | 'pair' | evidence | [p.a, p.b] | [check.ts:5318](../src/check.ts#L5318) |
|
|
11229
|
-
| `seam_cells.frames[].cells` | `frames[].cells` | part when the supplied mapping resolves a piece; otherwise rig | evidence | resolved piece for cell.setupTop ?? ''; otherwise []; resolved piece for setupTop ?? ''; otherwise [] | [check.ts:5278](../src/check.ts#L5278), [check.ts:
|
|
11300
|
+
| `seam_cells.frames[].cells` | `frames[].cells` | part when the supplied mapping resolves a piece; otherwise rig | evidence | resolved piece for cell.setupTop ?? ''; otherwise []; resolved piece for setupTop ?? ''; otherwise [] | [check.ts:5278](../src/check.ts#L5278), [check.ts:12452](../src/check.ts#L12452) |
|
|
11230
11301
|
| `seam_pairs` | `seam_pairs`; `seam_scope.whole_pairs`; `sets.*.seam_pairs`; `sets.*.seam_scope.whole_pairs`; `characters.*.seam_pairs`; `characters.*.seam_scope.whole_pairs` | subjects.length === 0 ? 'rig' : subjects.length === 1 ? 'part' : 'pair' | evidence | subjects | [check.ts:2909](../src/check.ts#L2909) |
|
|
11231
11302
|
| `seam_scope.changes` | `seam_scope.changes`; `sets.*.seam_scope.changes`; `characters.*.seam_scope.changes` | 'rig' | evidence | [] | [check.ts:2387](../src/check.ts#L2387) |
|
|
11232
11303
|
| `seam_scope.domain.states` | `seam_scope.domain.states`; `sets.*.seam_scope.domain.states`; `characters.*.seam_scope.domain.states` | 'rig' | evidence | [] | [check.ts:2472](../src/check.ts#L2472) |
|
package/docs/STABILITY.md
CHANGED
|
@@ -686,7 +686,7 @@ and do not certify visibility. See the
|
|
|
686
686
|
| `check` | `--rig`, `--out`; optional `--parts`, `--source`, `--page-edges`, `--pack-shape`, `--page-size`, `--requirements`, `--seam-pairs`, `--keep-stills`, `--no-extremes` (issue #829), `--set` or `--all-sets` (issue #454), `--environment` (issue #538, additive), `--wind-band` (issue #590, additive), paired `--loop-seam-bar` and `--loop-seam-cap` (issue #1590), `--json` (issue #904), `--help` (`-h`). Standalone `--clip-stretch` takes one scene path and prints only text (issue #1623). |
|
|
687
687
|
| `loop` | `--frames`, `--out`; optional `--palette`, `--help` (`-h`) |
|
|
688
688
|
| `build` | `--config`, `--source`, `--full`, `--out`; optional `--head` (as for `assemble`), `--seam`, `--project`, `--page-edges`, `--pack-shape`, `--page-size`, `--loop`, `--lead-in`, `--requirements`, `--idle-keys`, `--seam-pairs`, `--keep-stills`, `--no-extremes` (issue #829), `--alt` (as for `assemble`, issue #454), `--set` or `--all-sets` (as for `check`, issue #454), `--environment` (as for `check`, issue #538, additive), `--wind-band` (as for `check`, issue #590, additive), `--help` (`-h`) |
|
|
689
|
-
| `compose` | `--scene`, `--out`; optional `--requirements`, `--accept`, `--page-size`, paired `--loop-seam-bar` and `--loop-seam-cap` (issue #1590), `--output-profile` (`preview`) and `--no-extremes` (issue #1610), `--help` (`-h`) |
|
|
689
|
+
| `compose` | `--scene`, `--out`; optional `--requirements`, `--accept`, `--page-size`, paired `--loop-seam-bar` and `--loop-seam-cap` (issue #1590), `--output-profile` (`preview`) and `--no-extremes` (issue #1610), `--motion-seams` (issue #1682), `--help` (`-h`). Verification takes `--verify-motion-seams` and `--motion-seams` only. |
|
|
690
690
|
| `mesh-draft` | `--config`, `--parts`, `--out`; optional `--requirements`, `--idle-keys` (ctl, direct), `--page-edges` (pot, free), `--pack-shape` (rect, polygon), `--page-size`, `--more-triangles`, `--help` (`-h`) |
|
|
691
691
|
| `mesh-stats` | `--config`, `--parts`; optional `--help` (`-h`) (issue #566, additive: prints, writes nothing) |
|
|
692
692
|
| `remesh` | `--rig`, `--config`, `--parts`, `--part`, `--out`, and one of `--mesh` or `--delta` (issue #526); optional `--requirements`, `--idle-keys` (ctl, direct), `--page-edges` (pot, free), `--pack-shape` (rect, polygon), `--page-size`, `--record-input-check` and `--input-check` (issue #617, additive: without them nothing `remesh` prints or writes changes), `--help` (`-h`) |
|
|
@@ -1263,7 +1263,7 @@ execution in historical evidence is inferred from a current export.
|
|
|
1263
1263
|
| `check/check.json` and the rest of `check/` | `check`, `build`, `compose` | [Check verdict spec](#check-report-rig-parts-check1) followed by the reference's fields in its order (`gate_spine_html_green`, `rigc_entry`, `pack_mode` (with `page_size` under `--page-size` only, issue #1273, additive), `environment` after it under `--environment` only (issues #538, #1554, additive: `path` relative to `check`'s `--out`, `sha256`, `steps`), `loop_max_diff`, the seam figures — `seam_mean`, `seam_px_over_40`, `seam_px_over_80` and, from issue #216, `seam_frame_scale`, the frame scale the bar divides the count by), `loop_physics` after `loop_max_diff` when the rig declares a physics constraint, `seam_border` after the seam figures when `parts.json` declares a scene (issue #242), `seam_pairs` after the seam figures when the seam bar fails or `--seam-pairs` asks (each row's picture under `check/seam/`; `--keep-stills` leaves the setup-pose still and its `frames.json` under `check/setup_still/`), then the judgement lines (`BREATH_VISIBLE`, `BLINK_NO_HOLE`, `CHAIN_LAG`, `TIP_OVER_ROOT`, `STILL_REGIONS_DARK`, `TEXTURE_STRETCH`), `ANIMATIONS_DO_NOT_FOLD` after them when `motion.json` holds an animation, the idle included — on every rig with an idle since issue #333 (issues #320, #363: `status`, `animations`, `fps`, `physics_left_out`, `folding` — each `animation`, `slot`, `attachment`, `frames`, `worst_frame`, `worst_triangles`, `triangles`, `physics_on`, `physics_off`, `physics_constraints`, `declared`, `line` — `folding_undeclared`, `declared_not_folding`, `bar`), `FEET_STAY_LEVEL` after it when a `footwear` part rides a bone that hangs from another and `motion.json` holds an animation (issue #348: `status`, `reason` on a SKIP only, `animations`, `fps`, `physics_left_out`, `bar_degrees`, `bar`, `feet` — each `part`, `bone`, `hangs_from`, `status`, `frames_posed`, `worst`), `LIMB_ONE_BONE` after it (and after `STRESS_OFF_CHAIN` where that is written) when `parts.json` holds a limb segment's part (issue #349: `status`, `parts` — each `part`, `limb`, `bone`, `status`, `others`), `SEAM_OVER_RANGE` after it when a limb record carries a `range` (issue #360: `status`, `frame_scale`, `physics_left_out`, `bar` — `mean`, `rig_px_over_40`, `level` — and `joints`, each `part`, `limb`, `segment`, `joint`, `bone`, `range`, `at`, `radius`, `under_px`, `status`, `poses` — each `degrees`, `status`, `mean`, `px_over_40`, `px_over_80`, `rig_px_over_40`, and `step_px` (`left`, `right`) only on a joint whose cap record carries `short_px` (issue #557, additive) — and `unread` on a joint not read), `SEAM_OVER_MOTION` after it when `parts.json` holds a limb segment or `--requirements` a `seam` (issue #493 retains existing pair warnings; issue #686 gates proven body-root pairs only, on gapOpen plus UNDER-owned ghost: `status` — `WARN`, `CLEAR`, `SKIP` or `FAIL` — `reason` on a SKIP only, `fps`, `floor`, `pairs` — each `pair`, `a`, `b`, `declared`, optional `root` (`limb`, `bone`, `parent`) on a proven body-root pair, and `unread` on a pair not read — `animations`, `warnings`, `rows` — each `pair`, `animation`, `status`, `drawn`, `banded`, `opens`, `px`, `max_px`, `under_floor`, and only on new-root rows stock `gapOpen` plus UNDER-owned `ghostA`/`ghostB` cells selected by resolved per-frame draw order gate their summed count against the unchanged strict one-cell floor on the original raw kind boxes (their union when both kinds contribute), never narrowed partition boxes, while `gapCovered` and OVER-owned ghost cells are excluded (issue #711); `cells` retains partition counts, UNDER owner and counted total, `worst` retains frame/count/cell/box, and `roots` retains status, mode `gap-open+under-ghost`, ghost_owner `resolved-draw-order`, pairs, failed, reason and optional unmeasured bindings; eligible candidates whose valid setup bands are all zero retain a named unmeasured root and SKIP bar, including when no pair is selected; measured root FAIL wins over SKIP, while measured PASS plus an unmeasured root remains SKIP; every eligible body drawing with stock setup `banded > 0` is selected, including both when a parent is shared; issue #708 resolves a body slot on its exact generated turn child to the same named carrier only after unique identity-bone/control/per-part-transform proof, without changing pair identity, setup selection or the direct-carrier path; setup-only observation preserves the authored motion and default drawing, root-free inputs add no setup compile/render, and no animation remains SKIP rather than a measured zero; existing internal pair warnings and their exits are unchanged; issue #941 adds optional `required` only under the requirements file's `seam_over_motion.required: true` — `status` (`PASS` or `FAIL`), `mode` `gap-open`, `bar_px` 0, `pairs` (each `pair`, `class` — `body-root`, `internal-joint` or `explicit` — `frames`, `background_frames`, `max_px`) and `failed` — and with it the key is written even when no pair is declared; issue #591 adds optional `worlds` on physics rigs with readable declared pairs and animations: `default` and `still`, each `wind`, `gravity`, `status` (`REPORTED` or `SKIP`), `reason` on SKIP, `dir` only when rendered (relative to check.json: `seam_motion/default` or `seam_motion/still`, the complete retained render with frames.json and each animation's raw seam.json), and `rows` — pair, animation, status, drawn, banded, `gap` and `ghost`, each `max_px` and `worst` only; worst carries `index`, `px`, `cell`, `box`. Per-frame hits stay in the raw sidecars. These raw reference readings add no bar or warning and leave the custom environment reading unchanged), `CLOTH_SETTLES` after it when the rig declares a physics constraint and has an idle (issue #501, a warning and not a bar: `status` — `WARN` or `CLEAR` — `fps`, `frames`, `duration`, `floor_rig_px_per_s`, `floor`, `levers`, `warnings`, `rows` — each `tip`, `root`, `links`, `point`, `settles_at`, `max_rig_px_per_s`, `min_rig_px_per_s`), `PHYSICS_CONTRIBUTES` after it when the rig declares a physics constraint and has an idle and parts (issue #1320, report-only, no bar and no threshold: `status` — `WARN` when a part under physics reads exactly 0, else `CLEAR`; a named `SKIP` writes no key — `off` (what "physics off" means: the same compiled build posed with the poser's physics off, not the spec with its constraints left out), `points`, `world`, `poser`, `fps`, `frames`, `warnings`, `rows` — each `part`, `constraints`, `external_force`, then `vertices`, `frames_read`, `max_rig_px`, `p95_rig_px`, `mean_rig_px`, `max_of_diagonal`, `moves`, or `unmeasured` with its reason), `RECOMPOSITE_HOLES` (its first figure `declared_scene` when `parts.json` declares a scene), `SETUP_POSE_VS_SOURCE`, `WIND_BAND` after it under `--wind-band` only (issues #590, #1554, additive: `status` `"REPORTED"`, `spec` `"rig-parts-wind-band/1"`, `path` relative to `check`'s `--out`, `sha256`, `steady_wind_only` `true`, `gravity` `[0, 1]`, `min`, `max`, `step`, `steps`, `fps`, `animations`, `max_gap`, `max_ghost`, `holds_from`, `holds_to`, `pairs_holding_all`, and `pairs` — each `pair`, `a`, `b`, `holds_all`, `holds_from`, `holds_to`, `first_break_below`, `first_break_above`, `worst_gap`, `worst_ghost`, `steps`), `skipped` (written when `seam` has no `parts.json`, or when `loop` has no `idle` or omitted physics constraints on a closed physics-off idle, issue #1590), `config` under `build` only (issue #607, additive: `path` as `--config` was typed, `sha256` of the bytes the build read; `check` and `compose` read no config and write none), a `requirements` block under `--requirements` (or `build`'s `config.requirements`) — `file` first from issues #556 and #1554, additive: `path` relative to `check`'s `--out`, `sha256`, `keys` — and `PASS`; `check/build/skeleton.json`, `.atlas` and `.png` are the packed artifact rig-c writes, and `check/build-report.json` (`<out>/build-report.json` under standalone `check`) is rig-c's own `build-report/1` (`--report`) for that primary packed compile, written verbatim by `rigc` beside `check/build/` (and listed in `check/build/run.json`'s `outputs[]` as `../build-report.json`) on a failing compile as on a green one (issue #1394; `rig` keeps no compile report because its gate and `--lead-in` compiles are throwaway scratch runs whose outputs are deleted). Missing stock partitions or resolved owner are named refusals, never zero. No whole-box exemption or consumer compositor remains; internal warnings and reference raw readings are unchanged. |
|
|
1264
1264
|
| `part_support_domains.json` | `assemble`, `build` | optional `rig-parts-support-domains/1` independent cut masks and unavailable reasons, with per-domain config-entry provenance and parts/PNG/payload digests; additive beside parts.json, whose bytes and PNGs are unchanged. Legacy output may omit it. `PART_SUPPORT_REPORT` reads pairs in the assembly placement frame and Unowned in actual setup, never as an acceptance gate. |
|
|
1265
1265
|
| `SETUP_SEAM_TRANSMISSION` in `check.json` | `check`, `build` | written only when a painting is registered on the setup grid (a hash-bound `painting_in_rig` or a declared `setup_painting` source), beside `PART_SUPPORT_REPORT` and before `config`, `requirements` and `PASS` (issue #1634, additive): `{ status: "REPORTED", rows }` sorted by `longest_lighter_run_px` descending, then `under`, then `over`; each row carries `under`, `over`, `longest_lighter_run_px`, `lighter_px`, `world_box`, `edge_length_px`, `sampled_px`, `painting_eligible_px`, `darker_px`, `worst_transmission`, `row_scope` (`"pair"`), `row_kind` (`"evidence"`), `row_subjects` (`[under, over]`). Outside `bar_outcomes`, the warning tally and the exit code; absent without a registered painting |
|
|
1266
|
-
| `layers.json`, `<index>_<name>.png` | `layers --export` | the wrapper form `layers` reads (issue #359): `width`, `height`, then `layers` — each `name`, `filename`, `left`, `top`, `right`, `bottom`, `depth_median` (the input's own; `null` for a PSD, the manifest's order then being the draw order) — drawn layers in draw order, then the hidden-art layers; a PNG's name is its index and its layer's name, and the manifest, not the file name, says which layer it is |
|
|
1266
|
+
| `layers.json`, `<index>_<name>.png` | `layers --export` | the wrapper form `layers` reads (issue #359): `width`, `height`, then `layers` — each `name`, `filename`, `left`, `top`, `right`, `bottom`, `depth_median` (the input's own; `null` for a PSD, the manifest's order then being the draw order) — drawn layers in draw order, then the hidden-art layers; a PNG's name is its index and its layer's name, and the manifest, not the file name, says which layer it is. After `layers`, the CLI writes `source` (issue #1689) with `path` (the non-empty input argument as typed), `sha256` (64 lowercase hex digits), `format` (`psd`, `wrapper-directory` or `layers.json`), `parts_version` (the non-empty producer version string) and `command` (`rig-parts layers --export`). All five fields are required when `source` is present. The digest covers the raw PSD bytes for `psd`, the raw `<input>/layers.json` bytes for `wrapper-directory`, and the raw input file bytes for `layers.json`. The wrapper digest excludes referenced PNGs, and a re-export identifies the immediate input. Exact replays with the same input bytes, path spelling and Parts version write identical manifests. The wrapper reader accepts an absent `source` and checks the shape of a present one, without opening the recorded path or verifying its digest. Malformed values and unknown fields are refused with `LAYERS_EXPORT_SOURCE`. |
|
|
1267
1267
|
| the template `.psd` | `layers --template` | one empty layer per name `templateLayerNames` (`src/layers.ts`) holds, bottom first; the same canvas writes the same bytes |
|
|
1268
1268
|
| `proposal.json`, `render/landmarks*.png` | `propose` | the config's four rig sections, `constraints` with `--cloth` (issue #364: a physics constraint per tree link named `<bone>_physics`, a dangling end's `<bone>_translate`, and a skirt swing's transforms `<swing>_<tree>`), `turn` with `--full`/`--head`, `proposed_rig_scale` (issue #354), and `notes` |
|
|
1269
1269
|
| `basis.json` | `propose` | spec `spine-parts-basis/1` |
|
|
@@ -1283,6 +1283,7 @@ execution in historical evidence is inferred from a current export.
|
|
|
1283
1283
|
| compose output profiles | `compose` | Issue #1610 adds `--no-extremes` to omit only the extremes diagnostic renders, and `--output-profile preview` to also omit `check/idle_frames/`, `check/contact.png` and `check/motion_heat.png`. Preview takes precedence when both flags are given. Preview uses the stock idle render and existing readers. Before preview success, Parts removes the idle render directory, including Core's temporary contact sheet, skips copying the sheet to the check root, and skips generating heat. Each omission has a diagnostic `SKIP` line naming its selected flag. The gate, camera binding and check requirements still apply. Success prints `compose: PREVIEW — checks met; …` or `compose: NO EXTREMES — checks met; …`, respectively, and writes `output_profile` as `"preview"` or `"no-extremes"`. Default compose retains the complete diagnostics and the `compose: PASS — …` line. `COMPOSE_PREVIEW_REQUIRED_CHECK` refuses a valid loop seam pair in preview with `found=preview, required=default or no-extremes`, because the `loop_seam` record in `check.json` binds the paths and hashes of first and wrap PNGs that must remain under `check/idle_frames/`. Compose clears its owned outputs before this refusal. See [Compose output profiles](AUTHORING.md#compose-output-profiles-issue-1610). |
|
|
1284
1284
|
| the scene report | `compose` | spec `spine-parts-scene-report/1`; the plate block carries `sha256` of the plate PNG's bytes after `size` (issue #1183, additive under *What "stable" means here*: a new report key in a minor version, so the spec stays `/1`); `pack_mode` records `page_size` only when `--page-size <px>` is given (issue #1352, additive; without `--page-size`, rigc's default 2048 px page and padding 2 on each side bound any plate or region side to at most 2044 px before `CE_ATLAS_REGION_EXCEEDS_PAGE`). `scene.json` writes [`scene_driven`](#scene-driven-timeline-addresses) immediately after `idle_duration`, then `camera` when present, then the optional `repeats` map in declared order as the final top-level key. |
|
|
1285
1285
|
| `scene_driven` | `compose` | Per-take view flag and scene-authored timeline addresses in `scene.json`. See [Scene-driven timeline addresses](#scene-driven-timeline-addresses). |
|
|
1286
|
+
| `motion-seams/` | `compose` | Opt-in frame PNGs, inventory and independent seam verdict. See [Bound composed motion seams](#bound-composed-motion-seams). |
|
|
1286
1287
|
| `SCENE_CHANNEL_SHARED` | `compose` | Refuses shared bone-axis writes and character constraints that write scene-keyed bones. See [Scene-driven timeline addresses](#scene-driven-timeline-addresses). |
|
|
1287
1288
|
| keyed scene camera | `compose` | optional `camera` in `spine-parts-scene/1` (issue #1596). A camera scene writes `spine-parts-scene-report/2` at the existing `scene.json` path with its keyed camera, sampled coverage and framing verdict, and packed model SHA-256. Scenes without a camera write report /1. Both report specs include `scene_driven` on new writes. The camera path uses Core animation easing and the posed backdrop at each sampled frame. Rig, motion and stock check outputs retain their existing semantics. The compose input receipt stays `rig-compose-run/1`. See [Keyed scene camera](AUTHORING.md#keyed-scene-camera-issue-1596) |
|
|
1288
1289
|
| physics clips and scene repeats | `compose` | Issue #1615 adds `characters[].with_idle` and top-level `repeats` to `spine-parts-scene/1`. Each physics-only side clip requires literal `false` at any character scale or a safe integer count of at least 1 at scale 1. Numeric declarations fold whole periods into `idle` with exact duration equality. Both values retain `<id>:<clip>` subject to the character's scale checks, and the character report row echoes `with_idle` when declared. A scene repeat count is a safe integer of at least 2 on an authored take. Its duration remains the whole take length. Its tracks, deforms and camera keys use the exact duration divided by the count as their period. Repeated camera keys are expanded in report /2, with coverage on the full take clock and per-frame figure measurements. See [Physics clips and scene repeats](AUTHORING.md#physics-clips-and-scene-repeats-issue-1615) |
|
|
@@ -1397,6 +1398,68 @@ Files authors write for this package, each with a spec id the reader holds:
|
|
|
1397
1398
|
name on purpose: they name a file format, not the tool, and a file written before
|
|
1398
1399
|
the rename still reads. They do not change at 1.0.
|
|
1399
1400
|
|
|
1401
|
+
### Bound composed motion seams
|
|
1402
|
+
|
|
1403
|
+
`compose --motion-seams <request.json>` (issue #1682) takes
|
|
1404
|
+
`rig-parts-motion-seams-request/1` with `spec`, a literal composed
|
|
1405
|
+
`animation` name and a finite `fps` at least 1. Optional `preroll` is a
|
|
1406
|
+
positive whole loop count, and optional `viewport` is
|
|
1407
|
+
`[x, y, width, height]` in world units at scale 1 with whole pixel
|
|
1408
|
+
dimensions. An explicit viewport takes precedence over the camera.
|
|
1409
|
+
|
|
1410
|
+
The producer requires the gate version to match the installed
|
|
1411
|
+
`@rig-c/core` package version. It uses that package's Core poser on
|
|
1412
|
+
`check/build/` and samples the requested take once with geometry. The
|
|
1413
|
+
same Core frames supply the PNGs and the seam measurements. Both
|
|
1414
|
+
operations use atlas pages decoded from the exact bytes hashed in `sources`.
|
|
1415
|
+
Compose owns and clears `<out>/motion-seams/` on reruns. The bundle contains
|
|
1416
|
+
these files after a completed reading, including a read with a FAIL verdict.
|
|
1417
|
+
|
|
1418
|
+
| File | Contract |
|
|
1419
|
+
| --- | --- |
|
|
1420
|
+
| `frames/f0000.png`, … | Transparent RGBA PNGs in sample order, with no stride. The endpoint-inclusive count is `round(compiled duration × fps) + 1`. |
|
|
1421
|
+
| `inventory.json` | `rig-parts-motion-seams-frames/1` with `animation`, `fps`, compiled `duration`, `frame_count` and ordered `frames`. Each row has `index`, Core `time` in seconds, `viewport`, relative `path` and SHA-256 of the PNG bytes. |
|
|
1422
|
+
| `report.json` | `rig-parts-motion-seams/1` with `core`, `animation`, `fps`, `frame_count`, `request_sha256`, `sources`, `inventory_sha256`, `required`, `unmeasured_roots`, `pairs`, `verdict` and `binding_sha256`. |
|
|
1423
|
+
|
|
1424
|
+
`sources` binds the raw packed model, skeleton, atlas, named page PNGs,
|
|
1425
|
+
scene report and check report by SHA-256. `inventory_sha256` is the hash of
|
|
1426
|
+
the exact inventory JSON bytes. `request_sha256` hashes the parsed request
|
|
1427
|
+
with keys in the order `spec`, `animation`, `fps`, `preroll`, `viewport`
|
|
1428
|
+
(optional keys omitted). `binding_sha256` hashes the report object with
|
|
1429
|
+
that field omitted and all other keys in file order. The request and
|
|
1430
|
+
report hashes use UTF-8 JSON with one-space indentation and a final LF.
|
|
1431
|
+
|
|
1432
|
+
Each pair carries literal slot names `a` and `b`, its `class`, its
|
|
1433
|
+
`declared` origins from compose check, and one row per inventoried frame.
|
|
1434
|
+
A `MEASURED` row carries the Core `gap`, `ghost`, `gap_open` and
|
|
1435
|
+
`gap_covered` hits. Each hit is `{px, cell, box}` in Core's grid, or
|
|
1436
|
+
`null` for zero cells. A `SKIP` row carries a reason from
|
|
1437
|
+
`SLOT_MISSING`, `SLOT_NOT_DRAWN`, `NO_SETUP_BAND` or `CORE_SEAM_UNREADABLE`.
|
|
1438
|
+
The measurement uses Core's raw seam band. Contact connectivity has its
|
|
1439
|
+
own semantics.
|
|
1440
|
+
|
|
1441
|
+
The existing one-cell floor governs warning openings and body-root
|
|
1442
|
+
failures. A body-root row uses the count of visible gaps plus lower-slot
|
|
1443
|
+
ghost cells, with the contributing raw boxes. A required seam fails on
|
|
1444
|
+
any background gap cell, independent of the warning floor.
|
|
1445
|
+
`verdict` counts measured, skipped, warning and failing pair-frames.
|
|
1446
|
+
A failing frame takes precedence. Incomplete coverage or zero declared
|
|
1447
|
+
pairs yields `SKIP`, or `FAIL` when `required` is true. A `PASS`
|
|
1448
|
+
requires full coverage and preserves explicit and internal-joint warnings.
|
|
1449
|
+
|
|
1450
|
+
`compose --verify-motion-seams <out> --motion-seams <request.json>`
|
|
1451
|
+
requires the recorded Core version and recomputes the binding from the
|
|
1452
|
+
consumer request, inventory and build. It checks frame identities and
|
|
1453
|
+
hashes the exact PNG roster. It checks pair classes and unmeasured roots
|
|
1454
|
+
against compose check, validates each frame's finding or skip reason, and
|
|
1455
|
+
recomputes the aggregate verdict. It prints the bound verdict and digest
|
|
1456
|
+
and exits 0 for a verified PASS. A verified FAIL
|
|
1457
|
+
or SKIP exits 1. FPS, bytes and binding mismatches also exit 1 with
|
|
1458
|
+
`COMPOSE_MOTION_SEAMS_FPS`, `COMPOSE_MOTION_SEAMS_INVENTORY`,
|
|
1459
|
+
`COMPOSE_MOTION_SEAMS_BUILD` or `COMPOSE_MOTION_SEAMS_BINDING`.
|
|
1460
|
+
Consume the inventoried frames from that same output. Compose's check,
|
|
1461
|
+
loop-closure evidence, and acceptance status remain separate.
|
|
1462
|
+
|
|
1400
1463
|
### Scene-driven timeline addresses
|
|
1401
1464
|
|
|
1402
1465
|
Issue #1621 adds `scene_driven` to every new compose `scene.json` report.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rig-parts",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.75.0",
|
|
4
4
|
"description": "AI-authored 2D character parts from one anime painting and its See-through layer decomposition: measured parts, weighted-mesh rig specs, verified through rig-c before anything is written. A CLI for agents that cannot see the image.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
package/src/check.ts
CHANGED
|
@@ -12034,23 +12034,24 @@ function measureOneComposedCharacter(
|
|
|
12034
12034
|
|
|
12035
12035
|
try {
|
|
12036
12036
|
const images = typeof inp.rig.images === 'string' ? resolve(inp.rigDir, inp.rig.images) : inp.rig.images;
|
|
12037
|
-
|
|
12038
|
-
|
|
12039
|
-
|
|
12040
|
-
|
|
12037
|
+
// The composed idle already supplies the named bones, slots and frame
|
|
12038
|
+
// indices. A scoped build is only needed for another raster or animation
|
|
12039
|
+
// set. Keep its atlas packing because the raster checks measure pixels.
|
|
12040
|
+
const charIdle = ctx.idle;
|
|
12041
|
+
let scopedBuild: string | null = null;
|
|
12042
|
+
const ensureScopedBuild = (): string => {
|
|
12043
|
+
if (onlyCharacterInRig) return ctx.buildDir;
|
|
12044
|
+
if (scopedBuild !== null) return scopedBuild;
|
|
12045
|
+
const dir = join(scratchDir, 'build');
|
|
12041
12046
|
const rigFile = join(scratchDir, 'rig.json');
|
|
12042
12047
|
const motionFile = join(scratchDir, 'motion.json');
|
|
12043
12048
|
writeFileSync(rigFile, JSON.stringify({ ...charRig, images }));
|
|
12044
12049
|
writeFileSync(motionFile, JSON.stringify(charMotion));
|
|
12045
|
-
const b = rigc(['build', '--rig', rigFile, '--motion', motionFile, '--out',
|
|
12050
|
+
const b = rigc(['build', '--rig', rigFile, '--motion', motionFile, '--out', dir, ...packedBuildArgs(mode)]);
|
|
12046
12051
|
if (b.status !== 0) refuseIfAny(rigcFailed(`${packedBuildLabel(mode)} (character "${c.id}")`, b, buildGateLines(b.out)));
|
|
12047
|
-
|
|
12048
|
-
|
|
12049
|
-
|
|
12050
|
-
if (ir.status !== 0) refuseIfAny(rigcFailed(`render --animation idle --geometry (character "${c.id}")`, ir, ir.out.split('\n').filter(l => l.includes('FAIL') || l.includes('rigc:'))));
|
|
12051
|
-
charIdle = readFrameSet(charIdleDir);
|
|
12052
|
-
}
|
|
12053
|
-
}
|
|
12052
|
+
scopedBuild = dir;
|
|
12053
|
+
return dir;
|
|
12054
|
+
};
|
|
12054
12055
|
|
|
12055
12056
|
const scaledParts: PartsFile = s === 1
|
|
12056
12057
|
? prefParts
|
|
@@ -12093,9 +12094,10 @@ function measureOneComposedCharacter(
|
|
|
12093
12094
|
const levelProblems: Problem[] = [];
|
|
12094
12095
|
if (feet.length > 0 && charAnimNames.length > 0) {
|
|
12095
12096
|
const levelScratch = join(scratchDir, 'level');
|
|
12096
|
-
|
|
12097
|
-
|
|
12098
|
-
|
|
12097
|
+
if (charStripped === null && charIdle !== null && charAnimNames.length === 1 && charAnimNames[0] === 'idle') {
|
|
12098
|
+
level = levelLine(feet, charRig, [{ animation: 'idle', set: charIdle, geometryPath: join(charIdle.dir, GEOMETRY_FILE) }], IDLE_FPS, 0, levelProblems);
|
|
12099
|
+
} else if (charStripped === null) {
|
|
12100
|
+
const fr = measured(['render', '--candidate', ensureScopedBuild(), '--folds', '--geometry', '--fps', String(IDLE_FPS), '--max', String(FOLD_RENDER_MAX), '--out', levelScratch]);
|
|
12099
12101
|
if (fr.status !== 0) refuseIfAny(rigcFailed(`render --folds --geometry --fps ${IDLE_FPS} (character "${c.id}")`, fr, fr.out.split('\n').filter(l => l.includes('FAIL') || l.includes('rigc:'))));
|
|
12100
12102
|
const sets = readJson(join(levelScratch, 'frames.json'), []);
|
|
12101
12103
|
const listed = sets !== null && Array.isArray(sets.sets) ? sets.sets.filter(isRecord) : [];
|
|
@@ -12112,8 +12114,8 @@ function measureOneComposedCharacter(
|
|
|
12112
12114
|
mkdirSync(keyedDir, { recursive: true });
|
|
12113
12115
|
writeFileSync(join(keyedDir, 'rig.json'), JSON.stringify({ ...charStripped.rig, images }));
|
|
12114
12116
|
writeFileSync(join(keyedDir, 'motion.json'), JSON.stringify(charStripped.motion));
|
|
12115
|
-
const kb = rigc(['build', '--rig', join(keyedDir, 'rig.json'), '--motion', join(keyedDir, 'motion.json'), '--out', join(keyedDir, 'build'),
|
|
12116
|
-
if (kb.status !== 0) refuseIfAny(rigcFailed(
|
|
12117
|
+
const kb = rigc(['build', '--rig', join(keyedDir, 'rig.json'), '--motion', join(keyedDir, 'motion.json'), '--out', join(keyedDir, 'build'), '--profile', 'spine']);
|
|
12118
|
+
if (kb.status !== 0) refuseIfAny(rigcFailed(`build (character "${c.id}" level physics-off)`, kb, buildGateLines(kb.out)));
|
|
12117
12119
|
const frOff = rigc(['render', '--candidate', join(keyedDir, 'build'), '--folds', '--geometry', '--fps', String(IDLE_FPS), '--max', String(FOLD_RENDER_MAX), '--out', join(keyedDir, 'render')]);
|
|
12118
12120
|
if (frOff.status !== 0) refuseIfAny(rigcFailed(`render --folds --geometry (character "${c.id}" level physics-off)`, frOff, frOff.out.split('\n').filter(l => l.includes('FAIL') || l.includes('rigc:'))));
|
|
12119
12121
|
const sets = readJson(join(keyedDir, 'render', 'frames.json'), []);
|
|
@@ -12145,7 +12147,7 @@ function measureOneComposedCharacter(
|
|
|
12145
12147
|
const isoDir = join(scratchDir, 'isolated');
|
|
12146
12148
|
const isolated = (label: string, ps: readonly PartRecord[]): FrameSet => {
|
|
12147
12149
|
const dir = join(isoDir, label);
|
|
12148
|
-
const r = measured(['render', '--candidate',
|
|
12150
|
+
const r = measured(['render', '--candidate', ensureScopedBuild(), '--animation', 'idle', '--fps', String(IDLE_FPS), '--max', String(IDLE_MAX_PX), '--slot', ps.map(p => p.name).join(','), '--out', dir]);
|
|
12149
12151
|
if (r.status !== 0) refuseIfAny(rigcFailed(`render --animation idle --slot ${ps.map(p => p.name).join(',')}`, r, r.out.split('\n').filter(l => l.includes('FAIL') || l.includes('rigc:'))));
|
|
12150
12152
|
return readFrameSet(dir);
|
|
12151
12153
|
};
|
|
@@ -12225,7 +12227,7 @@ function measureOneComposedCharacter(
|
|
|
12225
12227
|
})),
|
|
12226
12228
|
}),
|
|
12227
12229
|
};
|
|
12228
|
-
physics = measurePhysicsContribution(charPhysicsRenderer,
|
|
12230
|
+
physics = measurePhysicsContribution(charPhysicsRenderer, ctx.buildDir, charRig, charMotion, prefParts.parts.map(p => ({
|
|
12229
12231
|
name: p.name,
|
|
12230
12232
|
w: p.w,
|
|
12231
12233
|
h: p.h,
|
|
@@ -0,0 +1,476 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { mkdirSync, readFileSync, readdirSync, rmSync, writeFileSync } from 'node:fs';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
import corePackage from '@rig-c/core/package.json' with { type: 'json' };
|
|
5
|
+
import { decodePng, encodePng } from '@rig-c/core/plate';
|
|
6
|
+
import { assertPng } from '@rig-c/core/png';
|
|
7
|
+
import { type Frame, loadCandidate, type Plate, type Poser, renderFrame, sampleAnimation, throughPoser, type Viewport } from '@rig-c/core/render-shared';
|
|
8
|
+
import { SeamError, seamsOf, type SeamFrame, type SeamHit, type SeamPair } from '@rig-c/core/seam';
|
|
9
|
+
import { type CheckReport, MOTION_SEAM_LINE, motionSeamClass, type MotionSeamClass, type MotionSeamPair, openingOverFloor } from './check.ts';
|
|
10
|
+
import { PartsError } from './errors.ts';
|
|
11
|
+
import { rigJsonText } from './rig.ts';
|
|
12
|
+
|
|
13
|
+
export const COMPOSE_SEAMS_DIR = 'motion-seams';
|
|
14
|
+
export const COMPOSE_SEAMS_REQUEST = 'rig-parts-motion-seams-request/1';
|
|
15
|
+
export const COMPOSE_SEAMS_REPORT = 'rig-parts-motion-seams/1';
|
|
16
|
+
const INVENTORY_SPEC = 'rig-parts-motion-seams-frames/1';
|
|
17
|
+
export const COMPOSE_SEAMS_CORE = corePackage.version;
|
|
18
|
+
const COMPOSE_SEAMS_NOT_JUDGED = 'COMPOSE_MOTION_SEAMS_NOT_JUDGED';
|
|
19
|
+
export const COMPOSE_SEAMS_OFF = `${COMPOSE_SEAMS_NOT_JUDGED} — bound render frames were not judged; use --motion-seams <request.json>`;
|
|
20
|
+
|
|
21
|
+
export interface ComposeSeamRequest {
|
|
22
|
+
spec: typeof COMPOSE_SEAMS_REQUEST;
|
|
23
|
+
animation: string;
|
|
24
|
+
fps: number;
|
|
25
|
+
preroll?: number;
|
|
26
|
+
viewport?: [number, number, number, number];
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
interface FrameRow {
|
|
30
|
+
index: number;
|
|
31
|
+
time: number;
|
|
32
|
+
viewport: Viewport;
|
|
33
|
+
path: string;
|
|
34
|
+
sha256: string;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
interface FrameInventory {
|
|
38
|
+
spec: typeof INVENTORY_SPEC;
|
|
39
|
+
animation: string;
|
|
40
|
+
fps: number;
|
|
41
|
+
duration: number;
|
|
42
|
+
frame_count: number;
|
|
43
|
+
frames: FrameRow[];
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
type MeasuredHit = Pick<SeamHit, 'px' | 'cell' | 'box'>;
|
|
47
|
+
type FrameFinding = 'NONE' | 'OPENING_WARNING' | 'BODY_ROOT_OPENING' | 'REQUIRED_BACKGROUND';
|
|
48
|
+
const SKIP_REASONS = ['SLOT_MISSING', 'SLOT_NOT_DRAWN', 'NO_SETUP_BAND', 'CORE_SEAM_UNREADABLE'] as const;
|
|
49
|
+
type FrameSkipReason = (typeof SKIP_REASONS)[number];
|
|
50
|
+
type FrameReading = { index: number; time: number } & (
|
|
51
|
+
| { status: 'SKIP'; reason: FrameSkipReason; detail?: string }
|
|
52
|
+
| { status: 'MEASURED'; gap: MeasuredHit | null; ghost: MeasuredHit | null;
|
|
53
|
+
gap_open: MeasuredHit | null; gap_covered: MeasuredHit | null;
|
|
54
|
+
root?: MeasuredHit & { under: 'a' | 'b'; under_ghost_px: number };
|
|
55
|
+
finding: FrameFinding }
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
interface PairReading extends SeamPair {
|
|
59
|
+
class: MotionSeamClass;
|
|
60
|
+
declared: string[];
|
|
61
|
+
frames: FrameReading[];
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
interface BundleVerdict {
|
|
65
|
+
status: 'PASS' | 'FAIL' | 'SKIP';
|
|
66
|
+
reason: 'COMPLETE' | 'OPENING' | 'INCOMPLETE' | 'NO_DECLARED_PAIRS';
|
|
67
|
+
measured: number;
|
|
68
|
+
skipped: number;
|
|
69
|
+
warning_frames: number;
|
|
70
|
+
failing_frames: number;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
type ComposeSeamRefusalCode =
|
|
74
|
+
| 'COMPOSE_MOTION_SEAMS_ANIMATION'
|
|
75
|
+
| 'COMPOSE_MOTION_SEAMS_BINDING'
|
|
76
|
+
| 'COMPOSE_MOTION_SEAMS_BUILD'
|
|
77
|
+
| 'COMPOSE_MOTION_SEAMS_FPS'
|
|
78
|
+
| 'COMPOSE_MOTION_SEAMS_INVENTORY'
|
|
79
|
+
| 'COMPOSE_MOTION_SEAMS_REQUEST'
|
|
80
|
+
| 'COMPOSE_MOTION_SEAMS_SAMPLE';
|
|
81
|
+
|
|
82
|
+
function refusal(code: ComposeSeamRefusalCode, object: string, detail: string): never {
|
|
83
|
+
throw new PartsError([{ code, object, detail }]);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function objectOf(value: unknown): Record<string, unknown> {
|
|
87
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value) ? value as Record<string, unknown> : {};
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function bytesAt(path: string, code: ComposeSeamRefusalCode): Buffer {
|
|
91
|
+
try {
|
|
92
|
+
return readFileSync(path);
|
|
93
|
+
} catch (err) {
|
|
94
|
+
return refusal(code, path, `requires readable bytes: ${(err as Error).message}`);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function jsonOf(bytes: Uint8Array, path: string, code: ComposeSeamRefusalCode): Record<string, unknown> {
|
|
99
|
+
try {
|
|
100
|
+
return objectOf(JSON.parse(Buffer.from(bytes).toString('utf8')));
|
|
101
|
+
} catch (err) {
|
|
102
|
+
return refusal(code, path, `requires JSON: ${(err as Error).message}`);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function hash(bytes: string | Uint8Array): string {
|
|
107
|
+
return createHash('sha256').update(bytes).digest('hex');
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function jsonDigest(value: unknown): string {
|
|
111
|
+
return hash(rigJsonText(value));
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export function clearComposeSeams(out: string): void {
|
|
115
|
+
rmSync(join(out, COMPOSE_SEAMS_DIR), { recursive: true, force: true });
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export function readComposeSeamRequest(path: string): ComposeSeamRequest {
|
|
119
|
+
const raw = jsonOf(bytesAt(path, 'COMPOSE_MOTION_SEAMS_REQUEST'), path, 'COMPOSE_MOTION_SEAMS_REQUEST');
|
|
120
|
+
const { spec, animation, fps, preroll, viewport } = raw;
|
|
121
|
+
const extra = Object.keys(raw).filter(key => !['spec', 'animation', 'fps', 'preroll', 'viewport'].includes(key));
|
|
122
|
+
if (extra.length > 0) refusal('COMPOSE_MOTION_SEAMS_REQUEST', path, `has unknown fields ${extra.join(', ')}`);
|
|
123
|
+
if (spec !== COMPOSE_SEAMS_REQUEST || typeof animation !== 'string' || animation.trim() === '') {
|
|
124
|
+
refusal('COMPOSE_MOTION_SEAMS_REQUEST', path, `requires spec "${COMPOSE_SEAMS_REQUEST}" and a literal composed animation name`);
|
|
125
|
+
}
|
|
126
|
+
if (typeof fps !== 'number' || !Number.isFinite(fps) || fps < 1) {
|
|
127
|
+
refusal('COMPOSE_MOTION_SEAMS_FPS', path, `fps is ${JSON.stringify(fps)}; a finite number at least 1 is required`);
|
|
128
|
+
}
|
|
129
|
+
if (preroll !== undefined && (typeof preroll !== 'number' || !Number.isSafeInteger(preroll) || preroll < 1)) {
|
|
130
|
+
refusal('COMPOSE_MOTION_SEAMS_REQUEST', path, `preroll is ${JSON.stringify(preroll)}; omit it or declare a positive whole number of loops`);
|
|
131
|
+
}
|
|
132
|
+
let view: ComposeSeamRequest['viewport'];
|
|
133
|
+
if (viewport !== undefined) {
|
|
134
|
+
if (!Array.isArray(viewport) || viewport.length !== 4 || !viewport.every(v => typeof v === 'number' && Number.isFinite(v)) ||
|
|
135
|
+
!Number.isSafeInteger(viewport[2]) || !Number.isSafeInteger(viewport[3]) || viewport[2] < 1 || viewport[3] < 1) {
|
|
136
|
+
refusal('COMPOSE_MOTION_SEAMS_REQUEST', path, 'viewport requires [x, y, width, height] in world units with positive whole pixel dimensions');
|
|
137
|
+
}
|
|
138
|
+
view = [viewport[0], viewport[1], viewport[2], viewport[3]];
|
|
139
|
+
}
|
|
140
|
+
return { spec, animation, fps, ...(preroll === undefined ? {} : { preroll }), ...(view === undefined ? {} : { viewport: view }) };
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
function openBuild(out: string) {
|
|
144
|
+
const build = join(out, 'check', 'build');
|
|
145
|
+
const model = join(build, 'skeleton.model.json');
|
|
146
|
+
const skeleton = join(build, 'skeleton.json');
|
|
147
|
+
const atlas = join(build, 'skeleton.atlas');
|
|
148
|
+
const checkPath = join(out, 'check', 'check.json');
|
|
149
|
+
const checkBytes = bytesAt(checkPath, 'COMPOSE_MOTION_SEAMS_BUILD');
|
|
150
|
+
const check = jsonOf(checkBytes, checkPath, 'COMPOSE_MOTION_SEAMS_BUILD');
|
|
151
|
+
const model_sha256 = hash(bytesAt(model, 'COMPOSE_MOTION_SEAMS_BUILD'));
|
|
152
|
+
if (check.gate_spine_html_green !== true || objectOf(check.build).model_sha256 !== model_sha256) {
|
|
153
|
+
refusal('COMPOSE_MOTION_SEAMS_BUILD', model, `SHA-256 ${model_sha256} must match the model bound to a green gate in ${checkPath}`);
|
|
154
|
+
}
|
|
155
|
+
const skeletonBytes = bytesAt(skeleton, 'COMPOSE_MOTION_SEAMS_BUILD');
|
|
156
|
+
const atlasBytes = bytesAt(atlas, 'COMPOSE_MOTION_SEAMS_BUILD');
|
|
157
|
+
const { choice, pageNames } = (() => {
|
|
158
|
+
try {
|
|
159
|
+
const candidate = loadCandidate({
|
|
160
|
+
skeletonText: skeletonBytes.toString('utf8'), atlasText: atlasBytes.toString('utf8'), atlasDir: build, label: 'compose motion seams',
|
|
161
|
+
}, { skeleton, atlas }, 'core');
|
|
162
|
+
return { choice: candidate.choice, pageNames: [...candidate.pages.keys()].sort() };
|
|
163
|
+
} catch (err) {
|
|
164
|
+
return refusal('COMPOSE_MOTION_SEAMS_BUILD', build, `requires one Core-readable packed candidate: ${(err as Error).message}`);
|
|
165
|
+
}
|
|
166
|
+
})();
|
|
167
|
+
if (choice.core === null) refusal('COMPOSE_MOTION_SEAMS_BUILD', build, choice.why);
|
|
168
|
+
// Core's candidate loader exposes decoded pages only. Use the exact
|
|
169
|
+
// buffers hashed below as the source of the render and seam textures.
|
|
170
|
+
const pageFiles = pageNames.map(path => ({ path, bytes: bytesAt(join(build, path), 'COMPOSE_MOTION_SEAMS_BUILD') }));
|
|
171
|
+
const sources = {
|
|
172
|
+
model_sha256,
|
|
173
|
+
skeleton_sha256: hash(skeletonBytes),
|
|
174
|
+
atlas_sha256: hash(atlasBytes),
|
|
175
|
+
pages: pageFiles.map(({ path, bytes }) => ({ path, sha256: hash(bytes) })),
|
|
176
|
+
check_sha256: hash(checkBytes),
|
|
177
|
+
scene_sha256: hash(bytesAt(join(out, 'scene.json'), 'COMPOSE_MOTION_SEAMS_BUILD')),
|
|
178
|
+
};
|
|
179
|
+
return { choice, pageFiles, sources, declaration: objectOf(check[MOTION_SEAM_LINE]) };
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
function sampleCount(duration: number, request: ComposeSeamRequest): number {
|
|
183
|
+
const steps = duration * request.fps;
|
|
184
|
+
const count = Math.round(steps) + 1;
|
|
185
|
+
const warmSteps = steps * (request.preroll ?? 0);
|
|
186
|
+
if (!Number.isFinite(duration) || duration < 0 || count + Math.ceil(warmSteps) >= 0xffffffff ||
|
|
187
|
+
(request.preroll !== undefined && count < 2)) {
|
|
188
|
+
refusal('COMPOSE_MOTION_SEAMS_FPS', request.animation, `${duration}s at ${request.fps} fps with preroll ${request.preroll ?? 0} cannot fit a Core sample schedule`);
|
|
189
|
+
}
|
|
190
|
+
return count;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
function framePath(index: number): string {
|
|
194
|
+
return `frames/f${String(index).padStart(4, '0')}.png`;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
function validateInventory(dir: string, inventory: Record<string, unknown>, request: ComposeSeamRequest, duration: number): void {
|
|
198
|
+
if (inventory.fps !== request.fps) refusal('COMPOSE_MOTION_SEAMS_FPS', 'inventory.json', `has ${String(inventory.fps)} fps; consumer requires ${request.fps} fps`);
|
|
199
|
+
const count = sampleCount(duration, request);
|
|
200
|
+
const frames: unknown[] = Array.isArray(inventory.frames) ? inventory.frames : [];
|
|
201
|
+
if (inventory.spec !== INVENTORY_SPEC || inventory.animation !== request.animation || inventory.duration !== duration ||
|
|
202
|
+
inventory.frame_count !== count || frames.length !== count) {
|
|
203
|
+
refusal('COMPOSE_MOTION_SEAMS_INVENTORY', 'inventory.json', `requires "${request.animation}" with ${count} frames at ${request.fps} fps (packed duration ${duration}s); found ${frames.length} rows`);
|
|
204
|
+
}
|
|
205
|
+
let files: string[];
|
|
206
|
+
try {
|
|
207
|
+
files = readdirSync(join(dir, 'frames')).sort();
|
|
208
|
+
} catch (err) {
|
|
209
|
+
return refusal('COMPOSE_MOTION_SEAMS_INVENTORY', 'frames/', `requires the frame directory: ${(err as Error).message}`);
|
|
210
|
+
}
|
|
211
|
+
const expected = frames.map((_, i) => framePath(i).slice('frames/'.length)).sort();
|
|
212
|
+
if (files.length !== expected.length || files.some((name, i) => name !== expected[i])) {
|
|
213
|
+
refusal('COMPOSE_MOTION_SEAMS_INVENTORY', 'frames/', `found ${files.length} entries; the exact ${count} named frame PNGs are required`);
|
|
214
|
+
}
|
|
215
|
+
frames.forEach((value, index) => {
|
|
216
|
+
const row = objectOf(value);
|
|
217
|
+
const path = framePath(index);
|
|
218
|
+
const time = index * (1 / request.fps);
|
|
219
|
+
if (row.path !== path || row.index !== index || row.time !== time) {
|
|
220
|
+
refusal('COMPOSE_MOTION_SEAMS_INVENTORY', path, `requires frame ${index} at ${time}s; found ${String(row.path)} frame ${String(row.index)} at ${String(row.time)}s`);
|
|
221
|
+
}
|
|
222
|
+
const actual = hash(bytesAt(join(dir, path), 'COMPOSE_MOTION_SEAMS_INVENTORY'));
|
|
223
|
+
if (row.sha256 !== actual) refusal('COMPOSE_MOTION_SEAMS_INVENTORY', path, `bytes have SHA-256 ${actual}; inventory requires ${String(row.sha256)}`);
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
function hitOf(hit: SeamHit | undefined): MeasuredHit | null {
|
|
228
|
+
return hit === undefined ? null : { px: hit.px, cell: hit.cell, box: hit.box };
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
function frameFinding(
|
|
232
|
+
kind: MotionSeamClass, required: boolean, gap: MeasuredHit | null, ghost: MeasuredHit | null,
|
|
233
|
+
gapOpen: MeasuredHit | null, root: MeasuredHit | undefined,
|
|
234
|
+
): FrameFinding {
|
|
235
|
+
if (required && gapOpen !== null) return 'REQUIRED_BACKGROUND';
|
|
236
|
+
if (kind === 'body-root') return root !== undefined && openingOverFloor(root) ? 'BODY_ROOT_OPENING' : 'NONE';
|
|
237
|
+
return [gap, ghost].some(hit => hit !== null && openingOverFloor(hit)) ? 'OPENING_WARNING' : 'NONE';
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
function readFrame(pair: MotionSeamPair, kind: MotionSeamClass, read: ReturnType<typeof seamsOf>[number], frame: SeamFrame, required: boolean): FrameReading {
|
|
241
|
+
const id = { index: frame.index, time: frame.time };
|
|
242
|
+
if (read.banded === 0) return { ...id, status: 'SKIP', reason: read.drawn === 0 ? 'SLOT_NOT_DRAWN' : 'NO_SETUP_BAND' };
|
|
243
|
+
const gap = hitOf(read.gap.worst ?? undefined);
|
|
244
|
+
const ghost = hitOf(read.ghost.worst ?? undefined);
|
|
245
|
+
const gap_open = hitOf(read.gapOpen.worst ?? undefined);
|
|
246
|
+
const gap_covered = hitOf(read.gapCovered.worst ?? undefined);
|
|
247
|
+
let root: (MeasuredHit & { under: 'a' | 'b'; under_ghost_px: number }) | undefined;
|
|
248
|
+
if (pair.root !== undefined) {
|
|
249
|
+
const a = frame.attachments.findIndex(attachment => attachment.slot === pair.a);
|
|
250
|
+
const b = frame.attachments.findIndex(attachment => attachment.slot === pair.b);
|
|
251
|
+
const under = a < b ? 'a' : 'b';
|
|
252
|
+
const underGhost = under === 'a' ? read.ghostA.worst : read.ghostB.worst;
|
|
253
|
+
const under_ghost_px = underGhost?.px ?? 0;
|
|
254
|
+
// Keep the existing visible-gap + lower ghost count against the union of
|
|
255
|
+
// the contributing raw boxes. Visibility changes counts, not the floor.
|
|
256
|
+
const bounds = [gap_open === null ? null : gap, underGhost === null ? null : ghost].filter(hit => hit !== null);
|
|
257
|
+
if (bounds.length > 0) root = {
|
|
258
|
+
px: (gap_open?.px ?? 0) + under_ghost_px, cell: bounds[0].cell,
|
|
259
|
+
box: [Math.min(...bounds.map(h => h.box[0])), Math.min(...bounds.map(h => h.box[1])),
|
|
260
|
+
Math.max(...bounds.map(h => h.box[2])), Math.max(...bounds.map(h => h.box[3]))],
|
|
261
|
+
under, under_ghost_px,
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
const finding = frameFinding(kind, required, gap, ghost, gap_open, root);
|
|
265
|
+
return { ...id, status: 'MEASURED', gap, ghost, gap_open, gap_covered, ...(root === undefined ? {} : { root }), finding };
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
function readPairs(
|
|
269
|
+
frames: (Frame & SeamFrame)[], pairs: readonly MotionSeamPair[], required: boolean, poser: Poser, pages: ReadonlyMap<string, Plate>,
|
|
270
|
+
): PairReading[] {
|
|
271
|
+
const rest = poser.rest(undefined, frames.map(frame => frame.attachments));
|
|
272
|
+
const slots = new Set(poser.slots.map(slot => slot.name));
|
|
273
|
+
return pairs.map(pair => {
|
|
274
|
+
const names: SeamPair = { a: pair.a, b: pair.b };
|
|
275
|
+
const kind = motionSeamClass(pair);
|
|
276
|
+
const missing = [names.a, names.b].filter(slot => !slots.has(slot));
|
|
277
|
+
return {
|
|
278
|
+
...names, class: kind, declared: pair.declared,
|
|
279
|
+
frames: frames.map((frame): FrameReading => {
|
|
280
|
+
const { index, time } = frame;
|
|
281
|
+
if (missing.length > 0) return { index, time, status: 'SKIP', reason: 'SLOT_MISSING', detail: missing.join(', ') };
|
|
282
|
+
try {
|
|
283
|
+
const [read] = seamsOf([names], rest, [frame], pages);
|
|
284
|
+
return readFrame(pair, kind, read, frame, required);
|
|
285
|
+
} catch (err) {
|
|
286
|
+
if (!(err instanceof SeamError)) throw err;
|
|
287
|
+
return { index, time, status: 'SKIP', reason: 'CORE_SEAM_UNREADABLE', detail: err.message };
|
|
288
|
+
}
|
|
289
|
+
}),
|
|
290
|
+
};
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
function summarize(pairs: readonly { frames: readonly FrameReading[] }[], required: boolean, unmeasuredRoots: number): BundleVerdict {
|
|
295
|
+
let measured = 0, skipped = 0, warning_frames = 0, failing_frames = 0;
|
|
296
|
+
for (const { frames } of pairs) for (const row of frames) {
|
|
297
|
+
if (row.status === 'SKIP') skipped++;
|
|
298
|
+
else {
|
|
299
|
+
measured++;
|
|
300
|
+
if (row.finding === 'OPENING_WARNING') warning_frames++;
|
|
301
|
+
if (row.finding === 'REQUIRED_BACKGROUND' || row.finding === 'BODY_ROOT_OPENING') failing_frames++;
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
const reason = failing_frames > 0 ? 'OPENING' : pairs.length === 0 ? 'NO_DECLARED_PAIRS'
|
|
305
|
+
: skipped > 0 || unmeasuredRoots > 0 ? 'INCOMPLETE' : 'COMPLETE';
|
|
306
|
+
const status = reason === 'OPENING' || (reason !== 'COMPLETE' && required) ? 'FAIL' : reason === 'COMPLETE' ? 'PASS' : 'SKIP';
|
|
307
|
+
return { status, reason, measured, skipped, warning_frames, failing_frames };
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
function readBoundHit(value: unknown, where: string): MeasuredHit | null {
|
|
311
|
+
if (value === null) return null;
|
|
312
|
+
const { px, cell, box } = objectOf(value);
|
|
313
|
+
if (typeof px !== 'number' || !Number.isSafeInteger(px) || px < 1 ||
|
|
314
|
+
typeof cell !== 'number' || !Number.isFinite(cell) || cell <= 0 ||
|
|
315
|
+
!Array.isArray(box) || box.length !== 4 || !box.every(v => typeof v === 'number' && Number.isFinite(v)) ||
|
|
316
|
+
box[0] >= box[2] || box[1] >= box[3]) {
|
|
317
|
+
refusal('COMPOSE_MOTION_SEAMS_BINDING', where, 'requires a positive cell count and size with a finite world box, or null for zero cells');
|
|
318
|
+
}
|
|
319
|
+
return { px, cell, box: [box[0], box[1], box[2], box[3]] };
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
function readBoundFrame(value: unknown, index: number, fps: number, kind: MotionSeamClass, required: boolean, where: string): FrameReading {
|
|
323
|
+
const row = objectOf(value);
|
|
324
|
+
const time = index * (1 / fps);
|
|
325
|
+
if (row.index !== index || row.time !== time) refusal('COMPOSE_MOTION_SEAMS_BINDING', where, `requires inventoried frame ${index} at ${time}s`);
|
|
326
|
+
if (row.status === 'SKIP') {
|
|
327
|
+
const reason = SKIP_REASONS.find(code => row.reason === code);
|
|
328
|
+
if (reason === undefined || row.finding !== undefined || (row.detail !== undefined && typeof row.detail !== 'string')) {
|
|
329
|
+
refusal('COMPOSE_MOTION_SEAMS_BINDING', where, `skipped frames require a named reason from [${SKIP_REASONS.join(', ')}] and no finding`);
|
|
330
|
+
}
|
|
331
|
+
return { index, time, status: 'SKIP', reason, ...(row.detail === undefined ? {} : { detail: row.detail }) };
|
|
332
|
+
}
|
|
333
|
+
if (row.status !== 'MEASURED' || row.reason !== undefined) refusal('COMPOSE_MOTION_SEAMS_BINDING', where, 'requires a measured row or a named skip');
|
|
334
|
+
const gap = readBoundHit(row.gap, `${where}.gap`);
|
|
335
|
+
const ghost = readBoundHit(row.ghost, `${where}.ghost`);
|
|
336
|
+
const gap_open = readBoundHit(row.gap_open, `${where}.gap_open`);
|
|
337
|
+
const gap_covered = readBoundHit(row.gap_covered, `${where}.gap_covered`);
|
|
338
|
+
if ((gap_open?.px ?? 0) + (gap_covered?.px ?? 0) !== (gap?.px ?? 0)) {
|
|
339
|
+
refusal('COMPOSE_MOTION_SEAMS_BINDING', where, 'gap_open and gap_covered counts must sum to the gap count');
|
|
340
|
+
}
|
|
341
|
+
let root: Extract<FrameReading, { status: 'MEASURED' }>['root'];
|
|
342
|
+
if (row.root !== undefined) {
|
|
343
|
+
const hit = readBoundHit(row.root, `${where}.root`);
|
|
344
|
+
const { under, under_ghost_px } = objectOf(row.root);
|
|
345
|
+
if (kind !== 'body-root' || hit === null || (under !== 'a' && under !== 'b') || typeof under_ghost_px !== 'number' ||
|
|
346
|
+
!Number.isSafeInteger(under_ghost_px) || under_ghost_px < 0 || under_ghost_px > (ghost?.px ?? 0) ||
|
|
347
|
+
hit.px !== (gap_open?.px ?? 0) + under_ghost_px) {
|
|
348
|
+
refusal('COMPOSE_MOTION_SEAMS_BINDING', where, 'body-root counts must match the visible gap and lower-slot ghost counts');
|
|
349
|
+
}
|
|
350
|
+
root = { ...hit, under, under_ghost_px };
|
|
351
|
+
} else if (kind === 'body-root' && gap_open !== null) {
|
|
352
|
+
refusal('COMPOSE_MOTION_SEAMS_BINDING', where, 'a visible body-root gap requires its root reading');
|
|
353
|
+
}
|
|
354
|
+
const finding = frameFinding(kind, required, gap, ghost, gap_open, root);
|
|
355
|
+
if (row.finding !== finding) refusal('COMPOSE_MOTION_SEAMS_BINDING', where, `finding ${String(row.finding)} disagrees with the measured cells; expected ${finding}`);
|
|
356
|
+
return { index, time, status: 'MEASURED', gap, ghost, gap_open, gap_covered, ...(root === undefined ? {} : { root }), finding };
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
export function writeComposeSeams(
|
|
360
|
+
out: string, request: ComposeSeamRequest, report: CheckReport,
|
|
361
|
+
viewOf: (time: number, duration: number) => Viewport,
|
|
362
|
+
) {
|
|
363
|
+
const dir = join(out, COMPOSE_SEAMS_DIR);
|
|
364
|
+
try {
|
|
365
|
+
const { choice, pageFiles, sources } = openBuild(out);
|
|
366
|
+
if (sources.model_sha256 !== report.figures.build.model_sha256) {
|
|
367
|
+
refusal('COMPOSE_MOTION_SEAMS_BUILD', 'check/build', 'the published packed model must match this compose invocation');
|
|
368
|
+
}
|
|
369
|
+
const { pairs: declared, roots, required: requiredBlock } = report.motionSeam;
|
|
370
|
+
const required = requiredBlock !== undefined;
|
|
371
|
+
const unmeasured_roots = roots?.unmeasured ?? [];
|
|
372
|
+
const pages = new Map(pageFiles.map(({ path, bytes }) => {
|
|
373
|
+
try {
|
|
374
|
+
assertPng(bytes, path);
|
|
375
|
+
return [path, decodePng(bytes)] as const;
|
|
376
|
+
} catch (err) {
|
|
377
|
+
return refusal('COMPOSE_MOTION_SEAMS_BUILD', path, `requires a readable packed PNG: ${(err as Error).message}`);
|
|
378
|
+
}
|
|
379
|
+
}));
|
|
380
|
+
mkdirSync(join(dir, 'frames'), { recursive: true });
|
|
381
|
+
const { value } = throughPoser(choice, poser => {
|
|
382
|
+
const take = poser.animations.find(take => take.name === request.animation);
|
|
383
|
+
if (take === undefined) refusal('COMPOSE_MOTION_SEAMS_ANIMATION', request.animation, `the composed build holds [${poser.animations.map(a => a.name).join(', ')}]`);
|
|
384
|
+
const duration = take.duration;
|
|
385
|
+
const count = sampleCount(duration, request);
|
|
386
|
+
const frames = sampleAnimation(poser, request.animation, request.fps, { geometry: true, preroll: request.preroll });
|
|
387
|
+
if (frames.length !== count) refusal('COMPOSE_MOTION_SEAMS_SAMPLE', request.animation, `Core returned ${frames.length} frames; expected ${count}`);
|
|
388
|
+
if (!frames.every((frame): frame is Frame & SeamFrame => frame.attachments !== undefined)) {
|
|
389
|
+
refusal('COMPOSE_MOTION_SEAMS_SAMPLE', request.animation, 'Core geometry is required on every sampled frame');
|
|
390
|
+
}
|
|
391
|
+
const rows = frames.map((frame): FrameRow => {
|
|
392
|
+
const path = framePath(frame.index);
|
|
393
|
+
const viewport = viewOf(frame.time, duration);
|
|
394
|
+
const png = renderFrame(frame, pages, viewport, [0, 0, 0, 0]);
|
|
395
|
+
const data = encodePng(png.width, png.height, png.data);
|
|
396
|
+
writeFileSync(join(dir, path), data);
|
|
397
|
+
return { index: frame.index, time: frame.time, viewport, path, sha256: hash(data) };
|
|
398
|
+
});
|
|
399
|
+
const inventory: FrameInventory = { spec: INVENTORY_SPEC, animation: request.animation, fps: request.fps,
|
|
400
|
+
duration, frame_count: frames.length, frames: rows };
|
|
401
|
+
const pairs = readPairs(frames, declared, required, poser, pages);
|
|
402
|
+
return { inventory, pairs };
|
|
403
|
+
});
|
|
404
|
+
const { inventory, pairs } = value;
|
|
405
|
+
const inventoryText = rigJsonText(inventory);
|
|
406
|
+
writeFileSync(join(dir, 'inventory.json'), inventoryText);
|
|
407
|
+
const inventoryFile = join(dir, 'inventory.json');
|
|
408
|
+
const inventoryBytes = bytesAt(inventoryFile, 'COMPOSE_MOTION_SEAMS_INVENTORY');
|
|
409
|
+
validateInventory(dir, jsonOf(inventoryBytes, inventoryFile, 'COMPOSE_MOTION_SEAMS_INVENTORY'), request, inventory.duration);
|
|
410
|
+
const body = {
|
|
411
|
+
spec: COMPOSE_SEAMS_REPORT, core: COMPOSE_SEAMS_CORE, animation: request.animation, fps: request.fps,
|
|
412
|
+
frame_count: inventory.frame_count, request_sha256: jsonDigest(request), sources, inventory_sha256: hash(inventoryBytes),
|
|
413
|
+
required, unmeasured_roots, pairs, verdict: summarize(pairs, required, unmeasured_roots.length),
|
|
414
|
+
};
|
|
415
|
+
writeFileSync(join(dir, 'report.json'), rigJsonText({ ...body, binding_sha256: jsonDigest(body) }));
|
|
416
|
+
return body;
|
|
417
|
+
} catch (err) {
|
|
418
|
+
clearComposeSeams(out);
|
|
419
|
+
if (err instanceof PartsError) throw err;
|
|
420
|
+
return refusal('COMPOSE_MOTION_SEAMS_SAMPLE', request.animation, (err as Error).message);
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
/** Re-read the packed build and all named PNGs before returning the attested verdict. */
|
|
425
|
+
export function verifyComposeSeams(out: string, request: ComposeSeamRequest) {
|
|
426
|
+
const dir = join(out, COMPOSE_SEAMS_DIR);
|
|
427
|
+
const path = join(dir, 'report.json');
|
|
428
|
+
const { binding_sha256, ...body } = jsonOf(bytesAt(path, 'COMPOSE_MOTION_SEAMS_BINDING'), path, 'COMPOSE_MOTION_SEAMS_BINDING');
|
|
429
|
+
if (body.fps !== request.fps) refusal('COMPOSE_MOTION_SEAMS_FPS', path, `has ${String(body.fps)} fps; consumer requires ${request.fps} fps`);
|
|
430
|
+
if (body.spec !== COMPOSE_SEAMS_REPORT || body.core !== COMPOSE_SEAMS_CORE || body.animation !== request.animation ||
|
|
431
|
+
body.request_sha256 !== jsonDigest(request) || binding_sha256 !== jsonDigest(body)) {
|
|
432
|
+
refusal('COMPOSE_MOTION_SEAMS_BINDING', path, 'the report, consumer request and binding digest must agree');
|
|
433
|
+
}
|
|
434
|
+
const file = join(dir, 'inventory.json');
|
|
435
|
+
const inventoryBytes = bytesAt(file, 'COMPOSE_MOTION_SEAMS_INVENTORY');
|
|
436
|
+
const inventory = jsonOf(inventoryBytes, file, 'COMPOSE_MOTION_SEAMS_INVENTORY');
|
|
437
|
+
if (inventory.fps !== request.fps) refusal('COMPOSE_MOTION_SEAMS_FPS', file, `has ${String(inventory.fps)} fps; consumer requires ${request.fps} fps`);
|
|
438
|
+
if (body.inventory_sha256 !== hash(inventoryBytes) || body.frame_count !== inventory.frame_count) {
|
|
439
|
+
refusal('COMPOSE_MOTION_SEAMS_INVENTORY', file, `inventory bytes and frame count must match ${path}`);
|
|
440
|
+
}
|
|
441
|
+
const { choice, sources, declaration } = openBuild(out);
|
|
442
|
+
if (jsonDigest(body.sources) !== jsonDigest(sources)) refusal('COMPOSE_MOTION_SEAMS_BUILD', path, 'the packed build, scene and check bytes must match the report');
|
|
443
|
+
const { value: duration } = throughPoser(choice, poser => poser.animations.find(take => take.name === request.animation)?.duration);
|
|
444
|
+
if (duration === undefined) refusal('COMPOSE_MOTION_SEAMS_ANIMATION', request.animation, 'the packed build must hold the bound take');
|
|
445
|
+
validateInventory(dir, inventory, request, duration);
|
|
446
|
+
const pairs: unknown[] = Array.isArray(body.pairs) ? body.pairs : [];
|
|
447
|
+
const declared: unknown[] = Array.isArray(declaration.pairs) ? declaration.pairs : [];
|
|
448
|
+
const required = declaration.required !== undefined;
|
|
449
|
+
if (!Array.isArray(body.pairs) || pairs.length !== declared.length || body.required !== required) {
|
|
450
|
+
refusal('COMPOSE_MOTION_SEAMS_BINDING', path, 'the verdict must cover the declared pairs and required mode in the composed check');
|
|
451
|
+
}
|
|
452
|
+
const unmeasuredRoots = objectOf(declaration.roots).unmeasured ?? [];
|
|
453
|
+
if (!Array.isArray(unmeasuredRoots) || jsonDigest(body.unmeasured_roots) !== jsonDigest(unmeasuredRoots)) {
|
|
454
|
+
refusal('COMPOSE_MOTION_SEAMS_BINDING', path, 'the unmeasured roots must match the composed check');
|
|
455
|
+
}
|
|
456
|
+
const readings = pairs.map((value, i) => {
|
|
457
|
+
const pair = objectOf(value);
|
|
458
|
+
const source = objectOf(declared[i]);
|
|
459
|
+
const origins = source.declared;
|
|
460
|
+
if (typeof source.a !== 'string' || typeof source.b !== 'string' || !Array.isArray(origins) || !origins.every(d => typeof d === 'string') ||
|
|
461
|
+
pair.a !== source.a || pair.b !== source.b || jsonDigest(pair.declared) !== jsonDigest(origins)) {
|
|
462
|
+
refusal('COMPOSE_MOTION_SEAMS_BINDING', path, `pairs[${i}] must match the literal names and declarations in the composed check`);
|
|
463
|
+
}
|
|
464
|
+
const kind = motionSeamClass(source as unknown as MotionSeamPair);
|
|
465
|
+
if (pair.class !== kind) refusal('COMPOSE_MOTION_SEAMS_BINDING', path, `pairs[${i}] class ${String(pair.class)} disagrees with the composed check class ${kind}`);
|
|
466
|
+
const frames: unknown[] = Array.isArray(pair.frames) ? pair.frames : [];
|
|
467
|
+
if (frames.length !== inventory.frame_count) refusal('COMPOSE_MOTION_SEAMS_BINDING', path, `pairs[${i}] must cover every inventoried frame in order`);
|
|
468
|
+
return { frames: frames.map((frame, index) =>
|
|
469
|
+
readBoundFrame(frame, index, request.fps, kind, required, `${path} pairs[${i}].frames[${index}]`)) };
|
|
470
|
+
});
|
|
471
|
+
const verdict = summarize(readings, required, unmeasuredRoots.length);
|
|
472
|
+
if (jsonDigest(body.verdict) !== jsonDigest(verdict)) {
|
|
473
|
+
refusal('COMPOSE_MOTION_SEAMS_BINDING', path, `the aggregate verdict disagrees with validated rows: expected ${JSON.stringify(verdict)}`);
|
|
474
|
+
}
|
|
475
|
+
return { status: verdict.status, reason: verdict.reason, frameCount: inventory.frame_count, bindingSha256: binding_sha256 };
|
|
476
|
+
}
|
package/src/layers.ts
CHANGED
|
@@ -195,10 +195,49 @@ function describe(v: unknown): string {
|
|
|
195
195
|
// the wrapper form
|
|
196
196
|
// ---------------------------------------------------------------------------
|
|
197
197
|
|
|
198
|
-
const MANIFEST_KEYS = ['prefix', 'timestamp', 'layers', 'width', 'height'] as const;
|
|
198
|
+
const MANIFEST_KEYS = ['prefix', 'timestamp', 'layers', 'width', 'height', 'source'] as const;
|
|
199
199
|
const MANIFEST_REQUIRED = ['layers', 'width', 'height'] as const;
|
|
200
200
|
const LAYER_KEYS = ['name', 'filename', 'left', 'top', 'right', 'bottom', 'depth_median', 'depth_filename'] as const;
|
|
201
201
|
const LAYER_REQUIRED = ['name', 'filename', 'left', 'top', 'right', 'bottom', 'depth_median'] as const;
|
|
202
|
+
const EXPORT_SOURCE_FORMATS = ['psd', 'wrapper-directory', 'layers.json'] as const;
|
|
203
|
+
const EXPORT_COMMAND = 'rig-parts layers --export';
|
|
204
|
+
|
|
205
|
+
interface LayerExportSource {
|
|
206
|
+
path: string;
|
|
207
|
+
sha256: string;
|
|
208
|
+
format: typeof EXPORT_SOURCE_FORMATS[number];
|
|
209
|
+
parts_version: string;
|
|
210
|
+
command: typeof EXPORT_COMMAND;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
function checkExportSource(value: unknown, manifestPath: string, problems: Problem[]): void {
|
|
214
|
+
const refuse = (field: string, detail: string): void => {
|
|
215
|
+
problems.push({ code: 'LAYERS_EXPORT_SOURCE', object: `${manifestPath} field "${field}"`, detail });
|
|
216
|
+
};
|
|
217
|
+
if (typeof value !== 'object' || value === null || Array.isArray(value)) {
|
|
218
|
+
refuse('source', `is ${describe(value)}; an object is required`);
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
const source = value as Record<string, unknown>;
|
|
222
|
+
const fields = {
|
|
223
|
+
path: 'a non-empty string',
|
|
224
|
+
sha256: '64 lowercase hexadecimal digits',
|
|
225
|
+
format: `one of ${EXPORT_SOURCE_FORMATS.join(', ')}`,
|
|
226
|
+
parts_version: 'a non-empty string',
|
|
227
|
+
command: JSON.stringify(EXPORT_COMMAND),
|
|
228
|
+
} satisfies Record<keyof LayerExportSource, string>;
|
|
229
|
+
for (const key of Object.keys(source)) {
|
|
230
|
+
if (!Object.hasOwn(fields, key)) refuse(`source.${key}`, `is unknown; known keys are ${Object.keys(fields).join(', ')}`);
|
|
231
|
+
}
|
|
232
|
+
const invalid = (key: keyof LayerExportSource): void => {
|
|
233
|
+
refuse(`source.${key}`, `${Object.hasOwn(source, key) ? `is ${describe(source[key])}` : 'is absent'}; required: ${fields[key]}`);
|
|
234
|
+
};
|
|
235
|
+
if (typeof source.path !== 'string' || source.path.length === 0) invalid('path');
|
|
236
|
+
if (typeof source.sha256 !== 'string' || !/^[a-f0-9]{64}$/.test(source.sha256)) invalid('sha256');
|
|
237
|
+
if (typeof source.format !== 'string' || !(EXPORT_SOURCE_FORMATS as readonly string[]).includes(source.format)) invalid('format');
|
|
238
|
+
if (typeof source.parts_version !== 'string' || source.parts_version.length === 0) invalid('parts_version');
|
|
239
|
+
if (source.command !== EXPORT_COMMAND) invalid('command');
|
|
240
|
+
}
|
|
202
241
|
|
|
203
242
|
export interface WrapperManifestReading {
|
|
204
243
|
path: string;
|
|
@@ -292,7 +331,9 @@ export function readWrapperLayers(
|
|
|
292
331
|
if ('layers' in m && !Array.isArray(m.layers)) {
|
|
293
332
|
refuse('LAYERS_FIELD_PRESENT', `${manifestPath} field "layers"`, `is ${describe(m.layers)}; an array is required`);
|
|
294
333
|
}
|
|
295
|
-
|
|
334
|
+
const malformedManifest = problems.length > 0;
|
|
335
|
+
if ('source' in m) checkExportSource(m.source, manifestPath, problems);
|
|
336
|
+
if (malformedManifest) refuseIfAny(problems);
|
|
296
337
|
const W = width as number;
|
|
297
338
|
const H = height as number;
|
|
298
339
|
const entries = m.layers as unknown[];
|
|
@@ -489,6 +530,10 @@ function stubCanvas(): void {
|
|
|
489
530
|
const PSD_RGB = 3;
|
|
490
531
|
|
|
491
532
|
export function readPsdLayers(path: string): LayerSet {
|
|
533
|
+
return readPsdInput(path);
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
function readPsdInput(path: string, recordSource?: (bytes: Buffer) => void): LayerSet {
|
|
492
537
|
const problems: Problem[] = [];
|
|
493
538
|
const refuse = (code: string, object: string, detail: string): void => {
|
|
494
539
|
problems.push({ code, object, detail });
|
|
@@ -500,7 +545,9 @@ export function readPsdLayers(path: string): LayerSet {
|
|
|
500
545
|
stubCanvas();
|
|
501
546
|
let psd;
|
|
502
547
|
try {
|
|
503
|
-
|
|
548
|
+
const bytes = readFileSync(path);
|
|
549
|
+
recordSource?.(bytes);
|
|
550
|
+
psd = readPsd(bytes, {
|
|
504
551
|
useImageData: true,
|
|
505
552
|
skipCompositeImageData: true,
|
|
506
553
|
skipThumbnail: true,
|
|
@@ -605,7 +652,11 @@ export function readPsdLayers(path: string): LayerSet {
|
|
|
605
652
|
|
|
606
653
|
/** Read whichever form `path` is: a `.psd` file, or a wrapper directory / `layers.json`. */
|
|
607
654
|
export function readLayers(path: string, binding?: DepthBinding, readings?: WrapperReadings): LayerSet {
|
|
608
|
-
|
|
655
|
+
return readLayerInput(path, binding, readings);
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
function readLayerInput(path: string, binding?: DepthBinding, readings?: WrapperReadings, recordPsd?: (bytes: Buffer) => void): LayerSet {
|
|
659
|
+
if (/\.psd$/i.test(path)) { const set = readPsdInput(path, recordPsd); return binding === undefined ? set : bindDepthRun(set, binding.run, binding.config, binding.base); }
|
|
609
660
|
if (existsSync(path) && (statSync(path).isDirectory() || basename(path) === 'layers.json')) return readWrapperLayers(path, binding, undefined, readings);
|
|
610
661
|
refuseIfAny([
|
|
611
662
|
{
|
|
@@ -623,6 +674,20 @@ export function readLayers(path: string, binding?: DepthBinding, readings?: Wrap
|
|
|
623
674
|
// the export and the template (issue #359)
|
|
624
675
|
// ---------------------------------------------------------------------------
|
|
625
676
|
|
|
677
|
+
/** Capture the exact PSD or manifest bytes consumed by the export's read. */
|
|
678
|
+
export function readLayersForExport(path: string, partsVersion: string): { set: LayerSet; source: LayerExportSource } {
|
|
679
|
+
const readings: WrapperReadings = { pngs: [] };
|
|
680
|
+
let psdSha256: string | undefined;
|
|
681
|
+
const set = readLayerInput(path, undefined, readings, (bytes) => {
|
|
682
|
+
psdSha256 = createHash('sha256').update(bytes).digest('hex');
|
|
683
|
+
});
|
|
684
|
+
const manifest = readings.manifest;
|
|
685
|
+
const sha256 = psdSha256 ?? manifest?.sha256;
|
|
686
|
+
if (sha256 === undefined) throw new Error('layers export read did not capture its source bytes');
|
|
687
|
+
const format = set.form === 'psd' ? 'psd' : manifest?.givenAsDirectory ? 'wrapper-directory' : 'layers.json';
|
|
688
|
+
return { set, source: { path, sha256, format, parts_version: partsVersion, command: EXPORT_COMMAND } };
|
|
689
|
+
}
|
|
690
|
+
|
|
626
691
|
/**
|
|
627
692
|
* The file a layer is exported to: its index in the manifest, zero-padded to
|
|
628
693
|
* the width of the last index (at least two digits), then its name with every
|
|
@@ -636,7 +701,7 @@ export function exportFileName(index: number, count: number, name: string): stri
|
|
|
636
701
|
}
|
|
637
702
|
|
|
638
703
|
/** The wrapper manifest `exportLayers` writes, as text: fixed key order, two-space indent, a trailing newline. */
|
|
639
|
-
export function exportManifestText(set: LayerSet, binding?: DepthBinding): string {
|
|
704
|
+
export function exportManifestText(set: LayerSet, binding?: DepthBinding, source?: LayerExportSource): string {
|
|
640
705
|
set = bindDepthRun(set, binding?.run ?? 'full', binding?.config, binding?.base ?? '');
|
|
641
706
|
const all: Array<{ name: string; left: number; top: number; right: number; bottom: number; depth: number | null; depthSheet?: SourceDepthSheet }> = [
|
|
642
707
|
...set.layers.map((l) => ({ name: l.name, left: l.left, top: l.top, right: l.right, bottom: l.bottom, depth: l.depth, ...(l.depthSheet === undefined ? {} : { depthSheet: l.depthSheet }) })),
|
|
@@ -646,6 +711,7 @@ export function exportManifestText(set: LayerSet, binding?: DepthBinding): strin
|
|
|
646
711
|
width: set.canvas.w,
|
|
647
712
|
height: set.canvas.h,
|
|
648
713
|
layers: all.map((l, i) => ({ name: l.name, filename: exportFileName(i, all.length, l.name), left: l.left, top: l.top, right: l.right, bottom: l.bottom, depth_median: l.depth, ...(l.depthSheet === undefined ? {} : { depth_filename: exportFileName(i, all.length, `${l.name}_depth`) }) })),
|
|
714
|
+
...(source === undefined ? {} : { source: { path: source.path, sha256: source.sha256, format: source.format, parts_version: source.parts_version, command: source.command } }),
|
|
649
715
|
};
|
|
650
716
|
return `${JSON.stringify(manifest, null, 2)}\n`;
|
|
651
717
|
}
|
|
@@ -666,7 +732,7 @@ export function exportManifestText(set: LayerSet, binding?: DepthBinding): strin
|
|
|
666
732
|
* `parts/<name>.png` the reader also looks for — could be read in place of
|
|
667
733
|
* the one written now. Writes nothing until that has passed.
|
|
668
734
|
*/
|
|
669
|
-
export function exportLayers(set: LayerSet, dir: string, binding?: DepthBinding): { manifest: string; files: string[] } {
|
|
735
|
+
export function exportLayers(set: LayerSet, dir: string, binding?: DepthBinding, source?: LayerExportSource): { manifest: string; files: string[] } {
|
|
670
736
|
if (existsSync(dir) && (!statSync(dir).isDirectory() || readdirSync(dir).length > 0)) {
|
|
671
737
|
refuseIfAny([
|
|
672
738
|
{
|
|
@@ -677,7 +743,7 @@ export function exportLayers(set: LayerSet, dir: string, binding?: DepthBinding)
|
|
|
677
743
|
]);
|
|
678
744
|
}
|
|
679
745
|
set = bindDepthRun(set, binding?.run ?? 'full', binding?.config, binding?.base ?? '');
|
|
680
|
-
const text = exportManifestText(set, binding);
|
|
746
|
+
const text = exportManifestText(set, binding, source);
|
|
681
747
|
const entries = (JSON.parse(text) as { layers: Array<{ filename: string }> }).layers;
|
|
682
748
|
const pixels = [...set.layers.map((l) => l.pixels), ...set.hidden.map((h) => h.pixels)];
|
|
683
749
|
mkdirSync(dir, { recursive: true });
|
package/src/scene.ts
CHANGED
|
@@ -112,7 +112,8 @@ import { documentPageLookup, readModel, type ModelPageRegion } from '@rig-c/core
|
|
|
112
112
|
import { CandidateAtlasError, CandidatePairError, CoreInputError, loadCandidate, PoserChoiceError, projector, renderFrame, SpineRuntimeError, throughPoser, type Piece, type Quad, type Viewport } from '@rig-c/core/render-shared';
|
|
113
113
|
import { deformSliderCombinationProblem, type RigStop } from '@rig-c/core/rig';
|
|
114
114
|
import { checkStage, gateThroughRigc, type Log } from './build.ts';
|
|
115
|
-
import { ACCEPTABLE_BARS, barsNotMet, CHECK_SPEC, type CheckReport, COMPOSE_PREVIEW_LOOP_SEAM_DETAIL, DEFAULT_PACK_SHAPE, DEFAULT_PAGE_EDGES, IDLE_FPS, LOOP_SEAM_BAR_UNMET, type LoopSeamRequest, type PackMode, parsePageSize, requirementsNotPass, type RigcRunner } from './check.ts';
|
|
115
|
+
import { ACCEPTABLE_BARS, barsNotMet, CHECK_SPEC, type CheckReport, COMPOSE_PREVIEW_LOOP_SEAM_DETAIL, DEFAULT_PACK_SHAPE, DEFAULT_PAGE_EDGES, IDLE_FPS, LOOP_SEAM_BAR_UNMET, type LoopSeamRequest, MOTION_SEAM_LINE, type PackMode, parsePageSize, requirementsNotPass, type RigcRunner } from './check.ts';
|
|
116
|
+
import { COMPOSE_SEAMS_CORE, COMPOSE_SEAMS_DIR, COMPOSE_SEAMS_OFF, type ComposeSeamRequest, writeComposeSeams } from './compose-seams.ts';
|
|
116
117
|
import { CONSTRAINT_BONE_FIELDS, editorReceiptProblems, ROOT_BONE } from './config.ts';
|
|
117
118
|
import { cropToSpineY } from './coords.ts';
|
|
118
119
|
import { failLine, PartsError, type Problem, refuseIfAny } from './errors.ts';
|
|
@@ -163,7 +164,7 @@ export const PROVENANCES = ['observed', 'generated', 'unknown'] as const;
|
|
|
163
164
|
export type Provenance = (typeof PROVENANCES)[number];
|
|
164
165
|
|
|
165
166
|
/** Every path `compose` writes under `--out`, relative — and so every path it clears first. */
|
|
166
|
-
export const COMPOSE_OWNS: readonly string[] = ['rig', 'check', SCENE_REPORT_FILE, COMPOSE_RUN_FILE];
|
|
167
|
+
export const COMPOSE_OWNS: readonly string[] = ['rig', 'check', SCENE_REPORT_FILE, COMPOSE_RUN_FILE, COMPOSE_SEAMS_DIR];
|
|
167
168
|
|
|
168
169
|
/** `<id>:<name>`. */
|
|
169
170
|
export function prefixed(id: string, name: string): string {
|
|
@@ -2729,6 +2730,8 @@ export interface ComposeInput {
|
|
|
2729
2730
|
requirements?: string;
|
|
2730
2731
|
/** Declared RGBA loop seam bar and warm-up cap for the composed idle render (issue #1590). */
|
|
2731
2732
|
loopSeam?: LoopSeamRequest;
|
|
2733
|
+
/** Render and judge the same frames on the published, gated composed build. */
|
|
2734
|
+
motionSeams?: ComposeSeamRequest;
|
|
2732
2735
|
/** The selected output profile, absent for the full diagnostics (issue #1610). */
|
|
2733
2736
|
outputProfile?: ComposeRun['output_profile'];
|
|
2734
2737
|
/** `--accept`: the bars every character's own check may fail and still be composed (issue #203). */
|
|
@@ -2746,7 +2749,7 @@ export interface ComposeRunners {
|
|
|
2746
2749
|
export type ComposeStage = 'compose' | 'check';
|
|
2747
2750
|
|
|
2748
2751
|
export interface ComposeResult {
|
|
2749
|
-
stoppedAt: ComposeStage | null;
|
|
2752
|
+
stoppedAt: ComposeStage | 'motion-seams' | null;
|
|
2750
2753
|
composed: ComposedScene | null;
|
|
2751
2754
|
check: CheckReport | null;
|
|
2752
2755
|
}
|
|
@@ -2796,6 +2799,16 @@ export function composeStage(input: ComposeInput, run: ComposeRunners, log: Log)
|
|
|
2796
2799
|
}
|
|
2797
2800
|
mkdirSync(input.out, { recursive: true });
|
|
2798
2801
|
for (const p of COMPOSE_OWNS) rmSync(join(input.out, p), { recursive: true, force: true });
|
|
2802
|
+
if (input.motionSeams !== undefined) {
|
|
2803
|
+
const version = run.rig(['--version']);
|
|
2804
|
+
const found = version.out.trim().split('\n')[0];
|
|
2805
|
+
if (version.status !== 0 || found !== COMPOSE_SEAMS_CORE) {
|
|
2806
|
+
return refused('compose', new PartsError([{
|
|
2807
|
+
code: 'COMPOSE_MOTION_SEAMS_CORE', object: 'rigc --version',
|
|
2808
|
+
detail: `exit ${version.status}, printed ${show(found)}; ${COMPOSE_SEAMS_CORE} is required to gate the bound render`,
|
|
2809
|
+
}]));
|
|
2810
|
+
}
|
|
2811
|
+
}
|
|
2799
2812
|
const mode: PackMode = { pageEdges: DEFAULT_PAGE_EDGES, packShape: DEFAULT_PACK_SHAPE, ...(pageSize === undefined ? {} : { pageSize }) };
|
|
2800
2813
|
log(`rig-parts compose: ${input.scene} -> ${input.out}, page edges ${mode.pageEdges}, pack shape ${mode.packShape}`);
|
|
2801
2814
|
let composed: ReturnType<typeof composeFromFiles>;
|
|
@@ -2935,7 +2948,10 @@ export function composeStage(input: ComposeInput, run: ComposeRunners, log: Log)
|
|
|
2935
2948
|
};
|
|
2936
2949
|
const preview = input.outputProfile === 'preview';
|
|
2937
2950
|
const noExtremes = input.outputProfile !== undefined;
|
|
2938
|
-
const checkLog =
|
|
2951
|
+
const checkLog: Log = line => {
|
|
2952
|
+
const suffix = input.motionSeams === undefined && line.startsWith(` ${MOTION_SEAM_LINE}:`) ? `; ${COMPOSE_SEAMS_OFF}` : '';
|
|
2953
|
+
log(`[check] ${line}${suffix}`);
|
|
2954
|
+
};
|
|
2939
2955
|
if (noExtremes) {
|
|
2940
2956
|
const flag = preview ? '--output-profile preview' : '--no-extremes';
|
|
2941
2957
|
checkLog(` extremes: SKIP — ${flag} omits the extra diagnostic renders`);
|
|
@@ -2965,6 +2981,32 @@ export function composeStage(input: ComposeInput, run: ComposeRunners, log: Log)
|
|
|
2965
2981
|
return refused('compose', new PartsError([{ code: 'SCENE_CAMERA_BACKDROP', object: 'check/build', detail: 'the checked model did not bind to the green camera audit; an exact packed artifact match is required' }]));
|
|
2966
2982
|
}
|
|
2967
2983
|
writeCameraReport();
|
|
2984
|
+
if (input.motionSeams !== undefined) {
|
|
2985
|
+
const request = input.motionSeams;
|
|
2986
|
+
const track = camera?.tracks.get(request.animation);
|
|
2987
|
+
const viewport = request.viewport;
|
|
2988
|
+
const canvas = composed.rig.skeleton;
|
|
2989
|
+
const frameView = (time: number, duration: number): Viewport => {
|
|
2990
|
+
if (viewport !== undefined) {
|
|
2991
|
+
const [x, y, width, height] = viewport;
|
|
2992
|
+
return { minX: x, minY: y, maxX: x + width, maxY: y + height, scale: 1, width, height };
|
|
2993
|
+
}
|
|
2994
|
+
const authored = duration === 0 || time >= duration ? track?.duration ?? 0 : time / duration * (track?.duration ?? 0);
|
|
2995
|
+
const view = cameraViewport(canvas, track?.sample(authored) ?? { pan: [0, 0], zoom: 1 });
|
|
2996
|
+
if (view === null) throw new PartsError([{ code: 'COMPOSE_MOTION_SEAMS_VIEWPORT', object: request.animation,
|
|
2997
|
+
detail: `frame at ${time}s requires a finite, positive view` }]);
|
|
2998
|
+
return view;
|
|
2999
|
+
};
|
|
3000
|
+
try {
|
|
3001
|
+
const { animation, fps, frame_count, verdict } = writeComposeSeams(input.out, request, report, frameView);
|
|
3002
|
+
say(` bound motion seams: ${verdict.status} — ${show(animation)} at ${fps} fps, ${frame_count} frame(s), ${verdict.measured} measured, ${verdict.skipped} skipped, ${verdict.failing_frames} failing pair/frame(s); wrote ${join(input.out, COMPOSE_SEAMS_DIR, 'report.json')}`);
|
|
3003
|
+
} catch (err) {
|
|
3004
|
+
if (!(err instanceof PartsError)) throw err;
|
|
3005
|
+
for (const problem of err.problems) say(failLine(problem));
|
|
3006
|
+
log('compose: stopped at motion-seams; the composed rig and its check were written');
|
|
3007
|
+
return { stoppedAt: 'motion-seams', composed, check: report };
|
|
3008
|
+
}
|
|
3009
|
+
}
|
|
2968
3010
|
// Issue #203: a character taken with an accepted failing bar never makes the scene green, even when the composed
|
|
2969
3011
|
// rig's check passes or skips that bar.
|
|
2970
3012
|
const taken = r.characters.filter((c) => c.accepted !== undefined).map((c) => `"${c.id}" (${(c.accepted as string[]).join(', ')})`);
|