rig-parts 2.52.0 → 2.53.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 +6 -4
- package/docs/AUTHORING.md +321 -55
- package/docs/STABILITY.md +108 -12
- package/package.json +1 -1
- package/src/assemble.ts +155 -63
- package/src/build.ts +62 -15
- package/src/check.ts +67 -32
- package/src/checkrow.ts +2 -0
- package/src/comfy/plate.ts +6 -0
- package/src/comfy/seethrough.ts +59 -5
- package/src/editedparts.ts +3 -0
- package/src/layers.ts +7 -3
- package/src/motion.ts +1 -0
- package/src/paintingedges.ts +56 -24
- package/src/parts.ts +196 -4
- package/src/partscheck.ts +50 -9
- package/src/partvisibility.ts +380 -0
- package/src/plate.ts +93 -14
- package/src/platecomponents.ts +269 -0
- package/src/raster/warp.ts +21 -4
- package/src/requirements.ts +6 -2
- package/src/runstamp.ts +2 -2
- package/src/scene.ts +70 -9
- package/src/sourceexposure.ts +309 -0
- package/src/sourcestates.ts +126 -0
- package/src/takelayers.ts +6 -1
- package/src/takeregion.ts +11 -5
- package/src/visibility.ts +384 -0
package/src/plate.ts
CHANGED
|
@@ -7,8 +7,7 @@
|
|
|
7
7
|
* inpainting run, lives in `src/comfy/plate.ts` and carries the graphs this
|
|
8
8
|
* file builds.
|
|
9
9
|
*
|
|
10
|
-
* 🔒 **The mask comes from a source, never a hand polygon.**
|
|
11
|
-
* read, and nothing else:
|
|
10
|
+
* 🔒 **The mask comes from a source, never a hand polygon.**
|
|
12
11
|
*
|
|
13
12
|
* - `seethrough:<dir>`: a See-through run in the wrapper form (`layers.json`
|
|
14
13
|
* and `parts/`), the figure being every drawn layer's alpha above
|
|
@@ -18,13 +17,14 @@
|
|
|
18
17
|
* (opaque white inside the figure, opaque black outside);
|
|
19
18
|
* - `matte:<dir>`: a model mask whose receipt binds both raw and final masks
|
|
20
19
|
* to the exact painting bytes and the recorded threshold/transform;
|
|
20
|
+
* - `classified:<manifest.json>`: an assemble scene mask with explicitly
|
|
21
|
+
* labeled outside-parts components and declared prop pixels excluded;
|
|
21
22
|
* - `--occluder <png>` (`--mode occluder`, issue #1230): a declared RGBA
|
|
22
23
|
* image of what stands in front of the character, on the painting's grid,
|
|
23
24
|
* the mask being its alpha above 0 (enclosed holes filled under `--holes`).
|
|
24
25
|
*
|
|
25
|
-
* The
|
|
26
|
-
*
|
|
27
|
-
* refuses before it writes anything or reaches a box.
|
|
26
|
+
* The source must match the painting grid or define a verified mapping to it.
|
|
27
|
+
* With no source the command refuses before it writes anything or reaches a box.
|
|
28
28
|
*
|
|
29
29
|
* The receipt (`rig-parts-plate-receipt/1`) names the painting, the mask, the
|
|
30
30
|
* model, every parameter, the graph, the GPU and the output, with the sha256
|
|
@@ -42,6 +42,7 @@ import { PartsError, type Problem } from './errors.ts';
|
|
|
42
42
|
import type { Graph } from './graphs.ts';
|
|
43
43
|
import { type LayerSet, OPAQUE_ALPHA_ABOVE, readWrapperLayers } from './layers.ts';
|
|
44
44
|
import { FIGURE_MASK_FILE, PAINTING_IN_RIG_FILE } from './parts.ts';
|
|
45
|
+
import { readClassifiedPlateMask } from './platecomponents.ts';
|
|
45
46
|
import { decodePngBytes, encodePngBytes } from './raster/png.ts';
|
|
46
47
|
import { fillHoles } from './raster/morph.ts';
|
|
47
48
|
import { newMask, newRaster, type Raster } from './raster/types.ts';
|
|
@@ -64,7 +65,12 @@ export const CORE_GRID_TRANSFORM_KEYS = ['source', 'padded', 'pad', 'pad_fill',
|
|
|
64
65
|
|
|
65
66
|
export type PlateMode = 'background' | 'foreground' | 'occluder';
|
|
66
67
|
export type PlateGraph = 'lama' | 'core';
|
|
67
|
-
export type MaskSource = 'seethrough' | 'figure-mask' | 'matte' | 'occluder';
|
|
68
|
+
export type MaskSource = 'seethrough' | 'figure-mask' | 'matte' | 'classified' | 'occluder';
|
|
69
|
+
|
|
70
|
+
interface PlateMaskClassification {
|
|
71
|
+
manifest_sha256: string;
|
|
72
|
+
prop_clips: Array<{ id: string; clipped_px: number }>;
|
|
73
|
+
}
|
|
68
74
|
|
|
69
75
|
export interface CoreGridTransform {
|
|
70
76
|
source: [number, number];
|
|
@@ -94,6 +100,7 @@ export interface PlateReceipt {
|
|
|
94
100
|
/** `--mode occluder` only: the declared occluder image the mask is read from. */
|
|
95
101
|
occluder?: { path: string; sha256: string };
|
|
96
102
|
mask: { source: MaskSource; from: string; path: string; sha256: string };
|
|
103
|
+
mask_classification?: PlateMaskClassification;
|
|
97
104
|
model: { name: string; checkpoint_sha256: string; checkpoint_sha256_from: 'declared' } | null;
|
|
98
105
|
params: Record<string, string | number | boolean>;
|
|
99
106
|
graph: string;
|
|
@@ -132,13 +139,16 @@ export function coreCfg(value: number | string | undefined, graph: PlateGraph):
|
|
|
132
139
|
return n;
|
|
133
140
|
}
|
|
134
141
|
|
|
135
|
-
/** `--mask-from <source>:<
|
|
142
|
+
/** `--mask-from <source>:<path>`, parsed; an absent or unknown source is refused by name. */
|
|
136
143
|
export function parseMaskFrom(value: string | undefined): { source: MaskSource; dir: string } {
|
|
137
144
|
if (value === undefined) {
|
|
138
|
-
fail('PLATE_MASK_SOURCE', '--mask-from',
|
|
145
|
+
fail('PLATE_MASK_SOURCE', '--mask-from',
|
|
146
|
+
'is absent; a source mask is required — seethrough:<run dir> (run comfy seethrough on the painting), ' +
|
|
147
|
+
'figure-mask:<assemble rig dir> (run assemble with config.scene), matte:<matte out dir> (run comfy matte), ' +
|
|
148
|
+
'or classified:<manifest.json> (declare roles for the assemble mask); a hand-drawn mask is not taken');
|
|
139
149
|
}
|
|
140
|
-
const m = /^(seethrough|figure-mask|matte):(.+)$/.exec(value);
|
|
141
|
-
if (m === null) fail('PLATE_MASK_SOURCE', '--mask-from', `is ${JSON.stringify(value)}; seethrough:<dir>, figure-mask:<dir> or
|
|
150
|
+
const m = /^(seethrough|figure-mask|matte|classified):(.+)$/.exec(value);
|
|
151
|
+
if (m === null) fail('PLATE_MASK_SOURCE', '--mask-from', `is ${JSON.stringify(value)}; seethrough:<dir>, figure-mask:<dir>, matte:<dir> or classified:<manifest.json> is required`);
|
|
142
152
|
return { source: m[1] as MaskSource, dir: m[2] };
|
|
143
153
|
}
|
|
144
154
|
|
|
@@ -147,6 +157,7 @@ export interface FigureMask {
|
|
|
147
157
|
width: number;
|
|
148
158
|
height: number;
|
|
149
159
|
inside: Uint8Array;
|
|
160
|
+
classification?: ReturnType<typeof readClassifiedPlateMask>['classification'];
|
|
150
161
|
}
|
|
151
162
|
|
|
152
163
|
function maskRecord(path: string, code: string, remedy = 're-run assemble'): { record: Record<string, unknown>; bytes: Uint8Array } {
|
|
@@ -266,6 +277,13 @@ function bindFigureSource(dir: string, parts: Record<string, unknown>, partsByte
|
|
|
266
277
|
* writes, and a mask with no figure pixel.
|
|
267
278
|
*/
|
|
268
279
|
export function readSourceMask(source: MaskSource, dir: string, width: number, height: number, painting?: Raster, paintingBytes?: Uint8Array): FigureMask {
|
|
280
|
+
if (source === 'classified') {
|
|
281
|
+
const mask = readClassifiedPlateMask(dir, width, height, paintingBytes);
|
|
282
|
+
if (!mask.inside.includes(1)) {
|
|
283
|
+
fail('PLATE_MASK_EMPTY', `classified:${dir}`, 'holds no figure pixel after excluding the declared props; verify the component roles');
|
|
284
|
+
}
|
|
285
|
+
return mask;
|
|
286
|
+
}
|
|
269
287
|
if (!existsSync(dir) || !statSync(dir).isDirectory()) {
|
|
270
288
|
fail('PLATE_MASK_SOURCE', `${source}:${dir}`, `is not a directory; ${source === 'seethrough' ? 'a See-through run directory (from `rig-parts comfy seethrough`)' : source === 'matte' ? 'a comfy matte directory with receipt.json, model-mask.png and mask.png' : 'an assemble output directory with parts.json and figure_rig.png'} is required`);
|
|
271
289
|
}
|
|
@@ -388,6 +406,23 @@ export function growMask(mask: FigureMask, r: number): FigureMask {
|
|
|
388
406
|
return { width: W, height: H, inside: out };
|
|
389
407
|
}
|
|
390
408
|
|
|
409
|
+
/** Clip declared prop pixels from the final background mask, on the painting grid before graph padding. */
|
|
410
|
+
export function clipClassifiedProps(source: FigureMask, grown?: FigureMask): PlateMaskClassification | undefined {
|
|
411
|
+
const classification = source.classification;
|
|
412
|
+
if (classification === undefined) return undefined;
|
|
413
|
+
return {
|
|
414
|
+
manifest_sha256: classification.manifest_sha256,
|
|
415
|
+
prop_clips: classification.props.map(({ id, indices }) => {
|
|
416
|
+
let clipped_px = 0;
|
|
417
|
+
if (grown !== undefined) for (const index of indices) {
|
|
418
|
+
clipped_px += grown.inside[index];
|
|
419
|
+
grown.inside[index] = 0;
|
|
420
|
+
}
|
|
421
|
+
return { id, clipped_px };
|
|
422
|
+
}),
|
|
423
|
+
};
|
|
424
|
+
}
|
|
425
|
+
|
|
391
426
|
/** The mask as the PNG written beside the plate and uploaded to the box: opaque white inside, opaque black outside (LoadImageMask reads its red channel). */
|
|
392
427
|
export function maskImage(mask: FigureMask): Raster {
|
|
393
428
|
const r = newRaster(mask.width, mask.height);
|
|
@@ -562,15 +597,18 @@ export function cropCoreGrid(padded: Raster, transform: CoreGridTransform): Rast
|
|
|
562
597
|
// ---------------------------------------------------------------------------
|
|
563
598
|
|
|
564
599
|
/** The receipt's key order: occluder mode binds the occluder, an off-grid `core` run its `grid_transform`. */
|
|
565
|
-
export function receiptKeys(occluder: boolean, gridTransform: boolean): readonly string[] {
|
|
600
|
+
export function receiptKeys(occluder: boolean, gridTransform: boolean, classified = false): readonly string[] {
|
|
566
601
|
if (occluder) return gridTransform ? PLATE_RECEIPT_OCCLUDER_GRID_TRANSFORM_KEYS : PLATE_RECEIPT_OCCLUDER_KEYS;
|
|
567
|
-
|
|
602
|
+
const keys = gridTransform ? PLATE_RECEIPT_GRID_TRANSFORM_KEYS : PLATE_RECEIPT_KEYS;
|
|
603
|
+
return classified ? keys.flatMap(key => key === 'mask' ? [key, 'mask_classification'] : [key]) : keys;
|
|
568
604
|
}
|
|
569
605
|
|
|
570
606
|
/** The receipt's JSON text, its keys in `PLATE_RECEIPT_KEYS` (or `PLATE_RECEIPT_GRID_TRANSFORM_KEYS` when `grid_transform` is present) order. */
|
|
571
607
|
export function receiptText(r: PlateReceipt): string {
|
|
572
608
|
const ordered: Record<string, unknown> = {};
|
|
573
|
-
for (const k of receiptKeys(r.mode === 'occluder', r.grid_transform !== undefined
|
|
609
|
+
for (const k of receiptKeys(r.mode === 'occluder', r.grid_transform !== undefined, r.mask.source === 'classified')) {
|
|
610
|
+
ordered[k] = (r as unknown as Record<string, unknown>)[k];
|
|
611
|
+
}
|
|
574
612
|
return `${JSON.stringify(ordered, null, 2)}\n`;
|
|
575
613
|
}
|
|
576
614
|
|
|
@@ -579,6 +617,20 @@ export function receiptPath(receiptDir: string, path: string): string {
|
|
|
579
617
|
return relative(resolve(receiptDir), resolve(path)).split('\\').join('/');
|
|
580
618
|
}
|
|
581
619
|
|
|
620
|
+
function validMaskClassification(value: unknown): value is PlateMaskClassification {
|
|
621
|
+
const digest = (v: unknown): v is string => typeof v === 'string' && /^[0-9a-f]{64}$/.test(v);
|
|
622
|
+
if (typeof value !== 'object' || value === null || !('manifest_sha256' in value) || !digest(value.manifest_sha256) ||
|
|
623
|
+
!('prop_clips' in value) || !Array.isArray(value.prop_clips) || Object.keys(value).join(',') !== 'manifest_sha256,prop_clips') return false;
|
|
624
|
+
const seen = new Set<string>();
|
|
625
|
+
return value.prop_clips.every((clip: unknown) => {
|
|
626
|
+
if (typeof clip !== 'object' || clip === null || !('id' in clip) || !digest(clip.id) || seen.has(clip.id) ||
|
|
627
|
+
!('clipped_px' in clip) || typeof clip.clipped_px !== 'number' || !Number.isSafeInteger(clip.clipped_px) ||
|
|
628
|
+
clip.clipped_px < 0 || Object.keys(clip).join(',') !== 'id,clipped_px') return false;
|
|
629
|
+
seen.add(clip.id);
|
|
630
|
+
return true;
|
|
631
|
+
});
|
|
632
|
+
}
|
|
633
|
+
|
|
582
634
|
/**
|
|
583
635
|
* Every problem between a receipt and the bytes on disk: its spec and key
|
|
584
636
|
* order, each of the painting, mask and output whose sha256 is not that of
|
|
@@ -599,9 +651,33 @@ export function verifyPlateReceipt(receiptFile: string): Problem[] {
|
|
|
599
651
|
}
|
|
600
652
|
if (r.spec !== PLATE_RECEIPT_SPEC) problems.push({ code: 'PLATE_RECEIPT_SPEC', object: receiptFile, detail: `has spec ${JSON.stringify(r.spec)}; "${PLATE_RECEIPT_SPEC}" is required` });
|
|
601
653
|
const keys = Object.keys(r).join(',');
|
|
602
|
-
const
|
|
654
|
+
const mask = r.mask as { source?: unknown; from?: unknown } | undefined;
|
|
655
|
+
const classified = mask?.source === 'classified';
|
|
656
|
+
const expectedKeys = receiptKeys(r.mode === 'occluder', 'grid_transform' in r, classified);
|
|
603
657
|
if (keys !== expectedKeys.join(',')) problems.push({ code: 'PLATE_RECEIPT_KEYS', object: receiptFile, detail: `has keys ${keys}; ${expectedKeys.join(',')} in that order is required` });
|
|
604
658
|
const base = dirname(receiptFile);
|
|
659
|
+
if (classified) {
|
|
660
|
+
const classification = r.mask_classification;
|
|
661
|
+
const from = mask?.from;
|
|
662
|
+
if (!validMaskClassification(classification) || typeof from !== 'string' || from === '') {
|
|
663
|
+
problems.push({
|
|
664
|
+
code: 'PLATE_RECEIPT_KEYS', object: `${receiptFile} mask_classification`,
|
|
665
|
+
detail: 'requires a manifest path, its lowercase SHA-256, and per-prop id and clipped_px counts',
|
|
666
|
+
});
|
|
667
|
+
} else {
|
|
668
|
+
const manifest = join(base, from);
|
|
669
|
+
let found: string | undefined;
|
|
670
|
+
try { found = sha256(readFileSync(manifest)); } catch { /* checked below */ }
|
|
671
|
+
if (found === undefined) {
|
|
672
|
+
problems.push({ code: 'PLATE_RECEIPT_FILE', object: manifest, detail: 'cannot read the classified plate manifest named by mask.from' });
|
|
673
|
+
} else if (found !== classification.manifest_sha256) {
|
|
674
|
+
problems.push({
|
|
675
|
+
code: 'PLATE_RECEIPT_HASH', object: manifest,
|
|
676
|
+
detail: `has sha256 ${found}; mask_classification declares ${classification.manifest_sha256}`,
|
|
677
|
+
});
|
|
678
|
+
}
|
|
679
|
+
}
|
|
680
|
+
}
|
|
605
681
|
let paintingRaster: Raster | undefined;
|
|
606
682
|
for (const field of r.mode === 'occluder' ? ['painting', 'occluder', 'mask', 'output'] as const : ['painting', 'mask', 'output'] as const) {
|
|
607
683
|
const f = r[field] as { path?: unknown; sha256?: unknown } | undefined;
|
|
@@ -689,6 +765,7 @@ export interface PlateWrite {
|
|
|
689
765
|
graph: string;
|
|
690
766
|
gpu: string | null;
|
|
691
767
|
gridTransform?: CoreGridTransform;
|
|
768
|
+
maskClassification?: PlateMaskClassification | undefined;
|
|
692
769
|
/** `--mode occluder` only: the occluder file, bound into the receipt by path and sha256. */
|
|
693
770
|
occluder?: { path: string; bytes: Uint8Array };
|
|
694
771
|
}
|
|
@@ -716,6 +793,7 @@ export function publishPlate(w: PlateWrite): PlateReceipt {
|
|
|
716
793
|
painting: { path: receiptPath(w.out, w.paintingPath), sha256: sha256(w.paintingBytes) },
|
|
717
794
|
...(w.occluder === undefined ? {} : { occluder: { path: receiptPath(w.out, w.occluder.path), sha256: sha256(w.occluder.bytes) } }),
|
|
718
795
|
mask: { source: w.source, from: receiptPath(w.out, w.sourceDir), path: PLATE_MASK_FILE, sha256: mask.sha256 },
|
|
796
|
+
...(w.maskClassification === undefined ? {} : { mask_classification: w.maskClassification }),
|
|
719
797
|
model: w.model,
|
|
720
798
|
params: w.params,
|
|
721
799
|
graph: w.graph,
|
|
@@ -777,6 +855,7 @@ export function runForeground(run: ForegroundRun): PlateReceipt {
|
|
|
777
855
|
source: from.source,
|
|
778
856
|
sourceDir: from.dir,
|
|
779
857
|
mask,
|
|
858
|
+
maskClassification: clipClassifiedProps(mask),
|
|
780
859
|
plate: foregroundMatte(painting.raster, mask),
|
|
781
860
|
model: null,
|
|
782
861
|
params: { mask_alpha_above: OPAQUE_ALPHA_ABOVE },
|
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { readFileSync, realpathSync } from 'node:fs';
|
|
3
|
+
import { basename, dirname, join, posix, resolve, win32 } from 'node:path';
|
|
4
|
+
import { isDeepStrictEqual } from 'node:util';
|
|
5
|
+
import { PartsError, refuseIfAny, type Problem } from './errors.ts';
|
|
6
|
+
import { OPAQUE_ALPHA_ABOVE } from './layers.ts';
|
|
7
|
+
import { readBinaryMask } from './maskvalues.ts';
|
|
8
|
+
import { FIGURE_MASK_FILE, partImageReference, readPartsManifest, type PartsFile } from './parts.ts';
|
|
9
|
+
import { connectedComponents } from './raster/components.ts';
|
|
10
|
+
import { decodePngBytes } from './raster/png.ts';
|
|
11
|
+
import type { Raster } from './raster/types.ts';
|
|
12
|
+
|
|
13
|
+
const SPEC = 'rig-parts-plate-components/1';
|
|
14
|
+
const MANIFEST_FIELDS = ['spec', 'parts_dir', 'painting_sha256', 'figure_mask_sha256', 'parts_manifest_sha256', 'components'];
|
|
15
|
+
|
|
16
|
+
function sourceFailure(object: string, detail: string): never {
|
|
17
|
+
throw new PartsError([{ code: 'PLATE_COMPONENT_SOURCE', object, detail }]);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function readSource<T>(object: string, want: string, read: () => T): T {
|
|
21
|
+
try { return read(); }
|
|
22
|
+
catch (error) {
|
|
23
|
+
const message = (error instanceof Error ? error.message : String(error)).replace(/[\r\n]+/g, ' | ');
|
|
24
|
+
return sourceFailure(object, `${want} required (${message})`);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function record(value: unknown): value is Record<string, unknown> {
|
|
29
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function jsonObject(bytes: Uint8Array, path: string): Record<string, unknown> {
|
|
33
|
+
const value: unknown = readSource(path, 'valid UTF-8 JSON', () =>
|
|
34
|
+
JSON.parse(new TextDecoder('utf-8', { fatal: true, ignoreBOM: true }).decode(bytes)));
|
|
35
|
+
if (!record(value)) sourceFailure(path, 'a JSON object is required');
|
|
36
|
+
return value;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function digest(value: unknown): value is string {
|
|
40
|
+
return typeof value === 'string' && /^[a-f0-9]{64}$/.test(value);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function sha256(bytes: Uint8Array | string): string {
|
|
44
|
+
return createHash('sha256').update(bytes).digest('hex');
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function checkDigest(object: string, actual: string, expected: unknown, field: string): void {
|
|
48
|
+
if (actual !== expected) sourceFailure(object, `sha256 is ${actual}; ${field} requires ${JSON.stringify(expected)}`);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function relativePath(value: unknown): value is string {
|
|
52
|
+
return typeof value === 'string' && value.trim() !== '' && !/[\\\0]/.test(value) &&
|
|
53
|
+
!posix.isAbsolute(value) && win32.parse(value).root === '';
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function assembleOutputs(stampPath: string, paintingSha: string): Map<string, string> {
|
|
57
|
+
const stamp = jsonObject(readSource(stampPath, 'readable assemble run.json', () => readFileSync(stampPath)), stampPath);
|
|
58
|
+
if (stamp.spec !== 'rig-run/1' || stamp.command !== 'assemble') {
|
|
59
|
+
sourceFailure(stampPath, `spec is ${JSON.stringify(stamp.spec)}, command is ${JSON.stringify(stamp.command)}; rig-run/1 assemble is required`);
|
|
60
|
+
}
|
|
61
|
+
if (!Array.isArray(stamp.inputs) || !Array.isArray(stamp.outputs)) {
|
|
62
|
+
sourceFailure(stampPath, 'assemble inputs and outputs arrays are required');
|
|
63
|
+
}
|
|
64
|
+
const inputs: unknown[] = stamp.inputs;
|
|
65
|
+
const sources = inputs.filter((entry): entry is Record<string, unknown> => record(entry) && entry.role === 'source');
|
|
66
|
+
if (sources.length !== 1) sourceFailure(stampPath, `found ${sources.length} inputs with role "source"; exactly one is required`);
|
|
67
|
+
checkDigest(stampPath, paintingSha, sources[0].sha256, 'the assemble source input');
|
|
68
|
+
|
|
69
|
+
const rows: unknown[] = stamp.outputs;
|
|
70
|
+
const outputs = new Map<string, string>();
|
|
71
|
+
for (const [i, entry] of rows.entries()) {
|
|
72
|
+
if (!record(entry) || !relativePath(entry.path) || entry.path === '.' || entry.path === '..' || entry.path.startsWith('../') ||
|
|
73
|
+
entry.path.endsWith('/') || posix.normalize(entry.path) !== entry.path || !digest(entry.sha256)) {
|
|
74
|
+
sourceFailure(stampPath, `outputs[${i}] is ${JSON.stringify(entry)}; a canonical run-relative path and lowercase SHA-256 are required`);
|
|
75
|
+
}
|
|
76
|
+
if (outputs.has(entry.path)) sourceFailure(stampPath, `outputs repeats ${JSON.stringify(entry.path)}; exactly one entry per path is required`);
|
|
77
|
+
outputs.set(entry.path, entry.sha256);
|
|
78
|
+
}
|
|
79
|
+
return outputs;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function decode(bytes: Uint8Array, path: string): Raster {
|
|
83
|
+
return readSource(path, 'decodable PNG', () => decodePngBytes(bytes, path));
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function checkGrid(object: string, actualW: number, actualH: number, width: number, height: number, frame: string): void {
|
|
87
|
+
if (actualW !== width || actualH !== height) {
|
|
88
|
+
sourceFailure(object, `is ${actualW}x${actualH}; ${frame} requires ${width}x${height}`);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function readBoundParts(path: string, bytes: Uint8Array): PartsFile {
|
|
93
|
+
const bound = jsonObject(bytes, path);
|
|
94
|
+
// The shared validator reads by path and returns the parsed object unchanged.
|
|
95
|
+
// Compare that validated value with the hashed snapshot before using any field.
|
|
96
|
+
const checked = readSource(path, 'valid parts.json', () => readPartsManifest(path));
|
|
97
|
+
if (!isDeepStrictEqual(checked, bound)) sourceFailure(path, 'changed between the stamped byte read and manifest validation; re-run assemble');
|
|
98
|
+
return checked;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
interface Component {
|
|
102
|
+
id: string;
|
|
103
|
+
indices: number[];
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function classify(path: string, labels: readonly unknown[], width: number, height: number, inside: Uint8Array, uncovered: Uint8Array): Component[] {
|
|
107
|
+
const { labels: regions, stats } = connectedComponents({ width, height, data: uncovered }, 8);
|
|
108
|
+
const indicesByLabel: number[][] = stats.map(() => []);
|
|
109
|
+
for (let i = 0; i < regions.length; i++) {
|
|
110
|
+
if (regions[i] !== 0) indicesByLabel[regions[i]].push(i);
|
|
111
|
+
}
|
|
112
|
+
const components = stats.slice(1).map(({ label, left, top, width, height, area }) => {
|
|
113
|
+
const indices = indicesByLabel[label];
|
|
114
|
+
// The row-major scan produces ascending indices. JSON is ASCII for this integer array.
|
|
115
|
+
return { id: sha256(JSON.stringify(indices)), indices, box: [left, top, width, height], area };
|
|
116
|
+
}).sort((a, b) => a.indices[0] - b.indices[0]);
|
|
117
|
+
const known = new Set(components.map(component => component.id));
|
|
118
|
+
const roles = new Map<string, 'background-prop' | 'figure-accessory'>();
|
|
119
|
+
const seen = new Set<string>();
|
|
120
|
+
const problems: Problem[] = [];
|
|
121
|
+
const issue = (object: string, detail: string): void => { problems.push({ code: 'PLATE_COMPONENT_ROLE', object, detail }); };
|
|
122
|
+
for (const [i, row] of labels.entries()) {
|
|
123
|
+
const at = `${path} components[${i}]`;
|
|
124
|
+
if (!record(row) || Object.keys(row).some(key => key !== 'id' && key !== 'role')) {
|
|
125
|
+
sourceFailure(at, `is ${JSON.stringify(row)}; a component object with id and role fields is required`);
|
|
126
|
+
}
|
|
127
|
+
if (!digest(row.id) || !known.has(row.id)) {
|
|
128
|
+
issue(at, `unknown component ID ${JSON.stringify(row.id) ?? 'absent'}; an inventoried SHA-256 ID is required`);
|
|
129
|
+
continue;
|
|
130
|
+
}
|
|
131
|
+
if (seen.has(row.id)) {
|
|
132
|
+
issue(at, `duplicate component ID ${row.id}; exactly one label is required`);
|
|
133
|
+
roles.delete(row.id);
|
|
134
|
+
} else if (row.role !== 'background-prop' && row.role !== 'figure-accessory') {
|
|
135
|
+
issue(at, `component ${row.id} has role ${JSON.stringify(row.role) ?? 'absent'}; "background-prop" or "figure-accessory" is required`);
|
|
136
|
+
} else {
|
|
137
|
+
roles.set(row.id, row.role);
|
|
138
|
+
}
|
|
139
|
+
seen.add(row.id);
|
|
140
|
+
}
|
|
141
|
+
const missing = components.filter(component => !roles.has(component.id));
|
|
142
|
+
for (const { id, box, area } of missing) {
|
|
143
|
+
issue(path, `component ${id} needs one valid role; painting box [x,y,w,h] ${JSON.stringify(box)}, ${area} px`);
|
|
144
|
+
}
|
|
145
|
+
if (problems.length > 0) {
|
|
146
|
+
for (const { id, box, area } of components) {
|
|
147
|
+
if (roles.has(id)) issue(path, `component ${id}: painting box [x,y,w,h] ${JSON.stringify(box)}, ${area} px`);
|
|
148
|
+
}
|
|
149
|
+
issue(path, `assign one role per component in the manifest: "components": ${JSON.stringify(components.map(({ id }) => ({ id, role: '' })))}`);
|
|
150
|
+
}
|
|
151
|
+
refuseIfAny(problems);
|
|
152
|
+
|
|
153
|
+
const props: Component[] = [];
|
|
154
|
+
for (const { id, indices } of components) {
|
|
155
|
+
if (roles.get(id) !== 'background-prop') continue;
|
|
156
|
+
for (const i of indices) inside[i] = 0;
|
|
157
|
+
props.push({ id, indices });
|
|
158
|
+
}
|
|
159
|
+
return props;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/** Read the primary painting's scene mask, withholding explicitly labeled background props. */
|
|
163
|
+
export function readClassifiedPlateMask(manifestPath: string, width: number, height: number, paintingBytes: Uint8Array | undefined): {
|
|
164
|
+
width: number;
|
|
165
|
+
height: number;
|
|
166
|
+
inside: Uint8Array;
|
|
167
|
+
classification: { manifest_sha256: string; props: Component[] };
|
|
168
|
+
} {
|
|
169
|
+
const declarationBytes = readSource(manifestPath, 'readable component manifest', () => readFileSync(manifestPath));
|
|
170
|
+
const declaration = jsonObject(declarationBytes, manifestPath);
|
|
171
|
+
const extra = Object.keys(declaration).filter(key => !MANIFEST_FIELDS.includes(key));
|
|
172
|
+
const missing = MANIFEST_FIELDS.filter(key => !Object.hasOwn(declaration, key));
|
|
173
|
+
if (extra.length > 0 || missing.length > 0) {
|
|
174
|
+
sourceFailure(manifestPath, `unknown fields ${JSON.stringify(extra)}, missing fields ${JSON.stringify(missing)}; requires ${MANIFEST_FIELDS.join(', ')}`);
|
|
175
|
+
}
|
|
176
|
+
if (declaration.spec !== SPEC) sourceFailure(manifestPath, `spec is ${JSON.stringify(declaration.spec)}; ${SPEC} is required`);
|
|
177
|
+
if (!relativePath(declaration.parts_dir)) {
|
|
178
|
+
sourceFailure(manifestPath, `parts_dir is ${JSON.stringify(declaration.parts_dir)}; a directory path relative to the manifest is required`);
|
|
179
|
+
}
|
|
180
|
+
for (const key of ['painting_sha256', 'figure_mask_sha256', 'parts_manifest_sha256']) {
|
|
181
|
+
if (!digest(declaration[key])) sourceFailure(manifestPath, `${key} is ${JSON.stringify(declaration[key])}; a lowercase SHA-256 is required`);
|
|
182
|
+
}
|
|
183
|
+
if (!Array.isArray(declaration.components)) sourceFailure(manifestPath, 'components must be an array of {id, role} objects');
|
|
184
|
+
if (paintingBytes === undefined) sourceFailure(manifestPath, 'painting bytes are absent; the original assemble source PNG is required');
|
|
185
|
+
const painting = Uint8Array.from(paintingBytes);
|
|
186
|
+
const paintingSha = sha256(painting);
|
|
187
|
+
checkDigest(manifestPath, paintingSha, declaration.painting_sha256, 'painting_sha256');
|
|
188
|
+
const native = decode(painting, 'source painting');
|
|
189
|
+
checkGrid('source painting', native.width, native.height, width, height, 'the requested painting grid');
|
|
190
|
+
|
|
191
|
+
const requestedDir = resolve(dirname(manifestPath), declaration.parts_dir);
|
|
192
|
+
const partsDir = readSource(requestedDir, 'accessible parts_dir', () => realpathSync(requestedDir));
|
|
193
|
+
const stampPath = join(dirname(partsDir), 'run.json');
|
|
194
|
+
const outputs = assembleOutputs(stampPath, paintingSha);
|
|
195
|
+
const stamped = (key: string, manifestSha?: unknown, field?: string): Uint8Array => {
|
|
196
|
+
const path = join(partsDir, key);
|
|
197
|
+
const stampKey = `${basename(partsDir)}/${key}`;
|
|
198
|
+
if (!outputs.has(stampKey)) sourceFailure(stampPath, `outputs is missing ${JSON.stringify(stampKey)}; exactly one entry is required`);
|
|
199
|
+
const bytes = readSource(path, 'readable assemble output', () => readFileSync(path));
|
|
200
|
+
const actual = sha256(bytes);
|
|
201
|
+
checkDigest(path, actual, outputs.get(stampKey), `the assemble output ${JSON.stringify(stampKey)}`);
|
|
202
|
+
if (field !== undefined) checkDigest(path, actual, manifestSha, field);
|
|
203
|
+
return bytes;
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
const partsPath = join(partsDir, 'parts.json');
|
|
207
|
+
const parts = readBoundParts(partsPath, stamped('parts.json', declaration.parts_manifest_sha256, 'parts_manifest_sha256'));
|
|
208
|
+
const [W, H] = parts.rig_size;
|
|
209
|
+
const scale = parts.scale_rig_per_source;
|
|
210
|
+
checkGrid(partsPath, W, H, Math.trunc(width * scale), Math.trunc(height * scale), `painting grid ${width}x${height} at scale ${scale}`);
|
|
211
|
+
// Assemble removes the single-run margins while warping layers onto rig_size.
|
|
212
|
+
if (parts.single_run_pad !== undefined) {
|
|
213
|
+
checkGrid(`${partsPath} single_run_pad.file_size`, ...parts.single_run_pad.file_size, width, height, 'the native painting grid');
|
|
214
|
+
}
|
|
215
|
+
const scene = parts.scene;
|
|
216
|
+
if (scene === undefined) sourceFailure(partsPath, `missing scene.figure_mask; assemble with config.scene to emit ${FIGURE_MASK_FILE}`);
|
|
217
|
+
if (scene.figure_alpha_above !== OPAQUE_ALPHA_ABOVE) {
|
|
218
|
+
sourceFailure(partsPath, `scene.figure_alpha_above is ${scene.figure_alpha_above}; ${OPAQUE_ALPHA_ABOVE} is required`);
|
|
219
|
+
}
|
|
220
|
+
const figurePath = join(partsDir, FIGURE_MASK_FILE);
|
|
221
|
+
const figure = decode(stamped(FIGURE_MASK_FILE, declaration.figure_mask_sha256, 'figure_mask_sha256'), figurePath);
|
|
222
|
+
checkGrid(figurePath, figure.width, figure.height, W, H, 'parts.json rig_size');
|
|
223
|
+
const rigInside = readBinaryMask(figure, detail => sourceFailure(figurePath, detail));
|
|
224
|
+
const figurePx = rigInside.reduce((sum, cell) => sum + cell, 0);
|
|
225
|
+
if (figurePx !== scene.figure_px) sourceFailure(figurePath, `has ${figurePx} white px; parts.json scene.figure_px requires ${scene.figure_px}`);
|
|
226
|
+
|
|
227
|
+
const coverage = new Uint8Array(W * H);
|
|
228
|
+
for (const part of parts.parts) {
|
|
229
|
+
const { x, y, w, h } = part;
|
|
230
|
+
const { path: key } = partImageReference(part);
|
|
231
|
+
const path = join(partsDir, key);
|
|
232
|
+
const image = decode(stamped(key), path);
|
|
233
|
+
checkGrid(path, image.width, image.height, w, h, 'the part box in parts.json');
|
|
234
|
+
for (let row = 0; row < h; row++) {
|
|
235
|
+
const ry = y + row;
|
|
236
|
+
if (ry < 0 || ry >= H) continue;
|
|
237
|
+
for (let col = 0; col < w; col++) {
|
|
238
|
+
const rx = x + col;
|
|
239
|
+
if (rx < 0 || rx >= W) continue;
|
|
240
|
+
if (image.data[(row * w + col) * 4 + 3] > OPAQUE_ALPHA_ABOVE) coverage[ry * W + rx] = 1;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
for (const alternate of parts.alternates ?? []) {
|
|
245
|
+
for (const part of alternate.records) {
|
|
246
|
+
const { path } = partImageReference(part, alternate.name);
|
|
247
|
+
const image = decode(stamped(path), join(partsDir, path));
|
|
248
|
+
checkGrid(path, image.width, image.height, part.w, part.h, 'the alternate part box in parts.json');
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
const inside = new Uint8Array(width * height);
|
|
253
|
+
const uncovered = new Uint8Array(inside.length);
|
|
254
|
+
// Same inverse pixel-centre map as assemble.cutFillMask. Both masks sample
|
|
255
|
+
// the same rig pixel, using actual dimensions after scale truncation.
|
|
256
|
+
const rigX = Array.from({ length: width }, (_, x) => Math.min(W - 1, Math.floor((x + 0.5) * W / width)));
|
|
257
|
+
for (let y = 0; y < height; y++) {
|
|
258
|
+
const rigRow = Math.min(H - 1, Math.floor((y + 0.5) * H / height)) * W;
|
|
259
|
+
for (let x = 0; x < width; x++) {
|
|
260
|
+
const src = y * width + x;
|
|
261
|
+
const rig = rigRow + rigX[x];
|
|
262
|
+
inside[src] = rigInside[rig];
|
|
263
|
+
if (inside[src] === 1 && coverage[rig] === 0) uncovered[src] = 1;
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
if (!inside.includes(1)) sourceFailure(figurePath, 'holds no figure pixel on the native painting grid; a nonempty scene figure is required');
|
|
267
|
+
const props = classify(manifestPath, declaration.components, width, height, inside, uncovered);
|
|
268
|
+
return { width, height, inside, classification: { manifest_sha256: sha256(declarationBytes), props } };
|
|
269
|
+
}
|
package/src/raster/warp.ts
CHANGED
|
@@ -120,20 +120,37 @@ export function warpAffine(src: FloatImage, map: ScaleTranslate, width: number,
|
|
|
120
120
|
return out;
|
|
121
121
|
}
|
|
122
122
|
|
|
123
|
-
/**
|
|
124
|
-
export function
|
|
123
|
+
/** Visit the in-bounds nonzero taps of the same quantized filter as warpAffine. */
|
|
124
|
+
export function visitWarpSupport(
|
|
125
|
+
src: Pick<Mask, 'width' | 'height'>, map: ScaleTranslate, width: number, height: number, filter: WarpFilter,
|
|
126
|
+
visit: (pixel: number, taps: readonly number[]) => void,
|
|
127
|
+
): void {
|
|
125
128
|
const xs = positions(width, map.sx, map.tx, 'x'), ys = positions(height, map.sy, map.ty, 'y');
|
|
126
|
-
const
|
|
129
|
+
const taps: number[] = [];
|
|
127
130
|
for (let y = 0; y < height; y++) for (let x = 0; x < width; x++) {
|
|
128
131
|
const [ix, fx] = xs[x], [iy, fy] = ys[y];
|
|
129
132
|
const firstX = fx !== 0 && filter === 'bicubic' ? -1 : 0;
|
|
130
133
|
const firstY = fy !== 0 && filter === 'bicubic' ? -1 : 0;
|
|
131
134
|
const lastX = fx !== 0 ? filter === 'bicubic' ? 2 : 1 : 0;
|
|
132
135
|
const lastY = fy !== 0 ? filter === 'bicubic' ? 2 : 1 : 0;
|
|
136
|
+
taps.length = 0;
|
|
133
137
|
for (let dy = firstY; dy <= lastY; dy++) for (let dx = firstX; dx <= lastX; dx++) {
|
|
134
138
|
const sx = ix + dx, sy = iy + dy;
|
|
135
|
-
if (sx >= 0 && sy >= 0 && sx < src.width && sy < src.height
|
|
139
|
+
if (sx >= 0 && sy >= 0 && sx < src.width && sy < src.height) taps.push(sy * src.width + sx);
|
|
136
140
|
}
|
|
141
|
+
visit(y * width + x, taps);
|
|
137
142
|
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/** Exact nonzero quantized tap support, without cancellation between taps. */
|
|
146
|
+
export function warpSupport(src: Mask, map: ScaleTranslate, width: number, height: number, filter: WarpFilter): Mask {
|
|
147
|
+
const out = newMask(width, height);
|
|
148
|
+
visitWarpSupport(src, map, width, height, filter, (p, taps) => {
|
|
149
|
+
for (const q of taps) {
|
|
150
|
+
if (src.data[q] !== 1) continue;
|
|
151
|
+
out.data[p] = 1;
|
|
152
|
+
break;
|
|
153
|
+
}
|
|
154
|
+
});
|
|
138
155
|
return out;
|
|
139
156
|
}
|
package/src/requirements.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { setupPaintingProblems, type SetupPainting } from './setuppainting.ts';
|
|
|
2
2
|
import { jointMaterialProblems, type JointMaterial } from './cutmaterial.ts';
|
|
3
3
|
import { fixedSkeletonProblems, type FixedSkeleton } from './artjoints.ts';
|
|
4
4
|
import { boundaryColourProblems, type BoundaryColour } from './boundarycolour.ts';
|
|
5
|
+
import { sourceExposureProblems, type SourceExposure } from './sourceexposure.ts';
|
|
5
6
|
import { behindSeamsProblems, type BehindSeams } from './behindseams.ts';
|
|
6
7
|
import { motionSeamProblems, type MotionSeamDeclaration } from './motionseams.ts';
|
|
7
8
|
/**
|
|
@@ -217,6 +218,8 @@ export interface RequirementsFile {
|
|
|
217
218
|
boundary_colour?: BoundaryColour;
|
|
218
219
|
/** Issue #1314: required behind-part seam readings when declared; an absent threshold is unmeasured, never defaulted. */
|
|
219
220
|
behind_seams?: BehindSeams;
|
|
221
|
+
/** Issue #1473: the limit on recorded-hidden or undecided source texels a pose shows; without it `check` reports a measurement. */
|
|
222
|
+
source_exposure?: SourceExposure;
|
|
220
223
|
}
|
|
221
224
|
|
|
222
225
|
/**
|
|
@@ -360,7 +363,7 @@ export function readRequirements(path: string): RequirementsFile {
|
|
|
360
363
|
problems.push({ code: 'REQUIREMENTS_SELF_TARGET', object: `${label} field "target"`, detail });
|
|
361
364
|
};
|
|
362
365
|
if (raw.spec !== REQUIREMENTS_SPEC) field(`${at} field "spec"`, `is ${JSON.stringify(raw.spec)}; ${JSON.stringify(REQUIREMENTS_SPEC)} is required`);
|
|
363
|
-
for (const k of Object.keys(raw)) if (!['spec', 'fps', 'targets', 'requirements', ...EXCEPTION_LISTS, 'may_fold', 'fixed_skeleton', 'cut_material', 'setup_painting', 'pinholes', 'seam_over_motion', 'motion_seams', 'boundary_colour', 'behind_seams'].includes(k) && !freeKey(k, raw[k])) field(`${at} field "${k}"`, 'is not a field this format reads (spec, fps, targets, requirements, not_planted, not_swinging, rises, rests, may_fold, fixed_skeleton, cut_material, setup_painting, pinholes, seam_over_motion, motion_seams, boundary_colour, behind_seams; note or *_note as a string; x-<name> as a record)');
|
|
366
|
+
for (const k of Object.keys(raw)) if (!['spec', 'fps', 'targets', 'requirements', ...EXCEPTION_LISTS, 'may_fold', 'fixed_skeleton', 'cut_material', 'setup_painting', 'pinholes', 'seam_over_motion', 'motion_seams', 'boundary_colour', 'behind_seams', 'source_exposure'].includes(k) && !freeKey(k, raw[k])) field(`${at} field "${k}"`, 'is not a field this format reads (spec, fps, targets, requirements, source_exposure, not_planted, not_swinging, rises, rests, may_fold, fixed_skeleton, cut_material, setup_painting, pinholes, seam_over_motion, motion_seams, boundary_colour, behind_seams; note or *_note as a string; x-<name> as a record)');
|
|
364
367
|
if ('motion_seams' in raw) {
|
|
365
368
|
// Shape uses the shared reader; actual names resolve against the rig and parts below.
|
|
366
369
|
const names = new Set<string>();
|
|
@@ -372,6 +375,7 @@ export function readRequirements(path: string): RequirementsFile {
|
|
|
372
375
|
if ('pinholes' in raw) problems.push(...pinholesProblems(raw.pinholes, `${at} pinholes`));
|
|
373
376
|
if ('seam_over_motion' in raw) problems.push(...seamOverMotionProblems(raw.seam_over_motion, `${at} seam_over_motion`));
|
|
374
377
|
if ('boundary_colour' in raw) problems.push(...boundaryColourProblems(raw.boundary_colour, `${at} boundary_colour`));
|
|
378
|
+
if ('source_exposure' in raw) problems.push(...sourceExposureProblems(raw.source_exposure, `${at} source_exposure`));
|
|
375
379
|
if ('behind_seams' in raw) problems.push(...behindSeamsProblems(raw.behind_seams, `${at} behind_seams`));
|
|
376
380
|
if ('setup_painting' in raw) problems.push(...setupPaintingProblems(raw.setup_painting, `${at} setup_painting`));
|
|
377
381
|
if ('cut_material' in raw) problems.push(...jointMaterialProblems(raw.cut_material, `${at} cut_material`));
|
|
@@ -561,7 +565,7 @@ export function readRequirements(path: string): RequirementsFile {
|
|
|
561
565
|
}
|
|
562
566
|
const fps = finite(raw.fps) ? raw.fps : undefined;
|
|
563
567
|
refuseIfAny(problems);
|
|
564
|
-
return { path: at, fps, targets, requirements, not_planted: lists.not_planted, not_swinging: lists.not_swinging, rises: lists.rises, rests: lists.rests, may_fold: mayFold, ...(raw.motion_seams === undefined ? {} : { motion_seams: raw.motion_seams as MotionSeamDeclaration[] }), ...(raw.fixed_skeleton === undefined ? {} : { fixed_skeleton: raw.fixed_skeleton as FixedSkeleton }), ...(raw.cut_material === undefined ? {} : { cut_material: raw.cut_material as JointMaterial[] }), ...(raw.setup_painting === undefined ? {} : { setup_painting: raw.setup_painting as SetupPainting }), ...(raw.pinholes === undefined ? {} : { pinholes: { required: (raw.pinholes as PinholesDeclaration).required } }), ...(raw.seam_over_motion === undefined ? {} : { seam_over_motion: { required: (raw.seam_over_motion as SeamOverMotionDeclaration).required } }), ...(raw.boundary_colour === undefined ? {} : { boundary_colour: { max_step_excess: (raw.boundary_colour as BoundaryColour).max_step_excess } }), ...(raw.behind_seams === undefined ? {} : { behind_seams: raw.behind_seams as BehindSeams }) };
|
|
568
|
+
return { path: at, fps, targets, requirements, not_planted: lists.not_planted, not_swinging: lists.not_swinging, rises: lists.rises, rests: lists.rests, may_fold: mayFold, ...(raw.motion_seams === undefined ? {} : { motion_seams: raw.motion_seams as MotionSeamDeclaration[] }), ...(raw.fixed_skeleton === undefined ? {} : { fixed_skeleton: raw.fixed_skeleton as FixedSkeleton }), ...(raw.cut_material === undefined ? {} : { cut_material: raw.cut_material as JointMaterial[] }), ...(raw.setup_painting === undefined ? {} : { setup_painting: raw.setup_painting as SetupPainting }), ...(raw.pinholes === undefined ? {} : { pinholes: { required: (raw.pinholes as PinholesDeclaration).required } }), ...(raw.seam_over_motion === undefined ? {} : { seam_over_motion: { required: (raw.seam_over_motion as SeamOverMotionDeclaration).required } }), ...(raw.boundary_colour === undefined ? {} : { boundary_colour: { max_step_excess: (raw.boundary_colour as BoundaryColour).max_step_excess } }), ...(raw.behind_seams === undefined ? {} : { behind_seams: raw.behind_seams as BehindSeams }), ...(raw.source_exposure === undefined ? {} : { source_exposure: { max_px: (raw.source_exposure as SourceExposure).max_px } }) };
|
|
565
569
|
}
|
|
566
570
|
|
|
567
571
|
// ---------------------------------------------------------------------------
|
package/src/runstamp.ts
CHANGED
|
@@ -204,9 +204,9 @@ export function assembleOutputFiles(outDir: string, result: AssembleResult): str
|
|
|
204
204
|
...(result.edgeResiduals === undefined ? [] : [`rig/${EDGE_RESIDUAL_FILE}`]),
|
|
205
205
|
...(result.paintingEdges?.allocation === undefined ? [] : [`rig/${PAINTING_ALLOCATION_FILE}`, ...writtenAllocationReports(outDir)]),
|
|
206
206
|
...(existsSync(join(outDir, 'rig', CUT_MATERIAL_SOURCES)) ? [`rig/${CUT_MATERIAL_SOURCES}`] : []),
|
|
207
|
-
...result.parts.parts.flatMap((p) => [`rig/parts/${p.name}.png`, ...(p.depth === undefined ? [] : [`rig/parts/${p.depth.image}`])]),
|
|
207
|
+
...result.parts.parts.flatMap((p) => [`rig/parts/${p.name}.png`, ...(p.depth === undefined ? [] : [`rig/parts/${p.depth.image}`]), ...(p.source_state_map === undefined ? [] : [`rig/parts/${p.source_state_map.image}`])]),
|
|
208
208
|
...(result.parts.alternates ?? []).flatMap((alt) =>
|
|
209
|
-
alt.records.flatMap((p) => [`rig/parts/${alt.name}_${p.name}.png`, ...(p.depth === undefined ? [] : [`rig/parts/${p.depth.image}`])]),
|
|
209
|
+
alt.records.flatMap((p) => [`rig/parts/${alt.name}_${p.name}.png`, ...(p.depth === undefined ? [] : [`rig/parts/${p.depth.image}`]), ...(p.source_state_map === undefined ? [] : [`rig/parts/${p.source_state_map.image}`])]),
|
|
210
210
|
),
|
|
211
211
|
'render/recomposite_rig.png',
|
|
212
212
|
`render/${ERROR_MAP_FILE}`,
|