spine-parts 2.25.0 → 2.25.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spine-parts",
3
- "version": "2.25.0",
3
+ "version": "2.25.1",
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
  "bin": {
package/src/assemble.ts CHANGED
@@ -6049,8 +6049,8 @@ function assembleParts(input: AssembleInput, targets?: ReadonlySet<string>, befo
6049
6049
  });
6050
6050
  refuseIfAny(empty);
6051
6051
  const placed: PlacedPart[] = order.map((d) => ('plan' in d ? planned[d.plan] : 'cut' in d ? cutPlaced[d.cut] : 'limb' in d ? limbPlaced[d.limb] : cut[d.patch]) as PlacedPart);
6052
- const artFiles = new Set(placed.map(p => `${p.record.name}.png`));
6053
- for (const p of placed) if (p.record.depth !== undefined && artFiles.has(p.record.depth.image)) refuseIfAny([{ code: 'DEPTH_SHEET_UNAMBIGUOUS', object: p.record.depth.image, detail: 'collides with a part artwork filename; choose noncolliding part names before sheet emission' }]);
6052
+ const artFiles = new Map<string, string>(); for (const p of placed) { const k = `${p.record.name}.png`.toLowerCase(), prev = artFiles.get(k); if (prev !== undefined) refuseIfAny([{ code: 'DEPTH_SHEET_UNAMBIGUOUS', object: `${p.record.name}.png`, detail: `part "${prev}" ("${prev}.png") and part "${p.record.name}" ("${p.record.name}.png") collides with a part artwork filename; choose noncolliding part names before sheet emission` }]); artFiles.set(k, p.record.name); }
6053
+ for (const p of placed) if (p.record.depth !== undefined && artFiles.has(p.record.depth.image.toLowerCase())) refuseIfAny([{ code: 'DEPTH_SHEET_UNAMBIGUOUS', object: p.record.depth.image, detail: `part "${p.record.name}" sheet "${p.record.depth.image}" and part "${artFiles.get(p.record.depth.image.toLowerCase())}" ("${artFiles.get(p.record.depth.image.toLowerCase())}.png") collides with a part artwork filename; choose noncolliding part names before sheet emission` }]);
6054
6054
 
6055
6055
 
6056
6056
  const regionSupport = new Map<string, Mask>();
package/src/build.ts CHANGED
@@ -866,15 +866,15 @@ export function assembleStage(input: AssembleStageInput, outs: AssembleOutputs,
866
866
  ];
867
867
  const assetIndices = new Map<string, number>();
868
868
  emittedAssets.forEach((file, index) => {
869
- const previous = assetIndices.get(file);
869
+ const previous = assetIndices.get(file.toLowerCase());
870
870
  if (previous !== undefined) {
871
871
  altProblems.push({
872
872
  code: 'DEPTH_SHEET_UNAMBIGUOUS',
873
873
  object: file,
874
- detail: `output assets[${previous}] and [${index}] require the same filename; choose distinct base, alternate and sheet names`,
874
+ detail: `output assets[${previous}] ("${emittedAssets[previous]}") and [${index}] ("${file}") require the same filename; choose distinct base, alternate and sheet names`,
875
875
  });
876
876
  } else {
877
- assetIndices.set(file, index);
877
+ assetIndices.set(file.toLowerCase(), index);
878
878
  }
879
879
  });
880
880
  const outputFiles = new Set([
package/src/check.ts CHANGED
@@ -145,7 +145,7 @@ import {
145
145
  type ChainEdge,
146
146
  type WorldBox,
147
147
  } from './instruments.ts';
148
- import { type AlternatePartsRecord, FRONT_SUFFIX, type LimbRecord, type PartRecord, type PartsFile, readParts } from './parts.ts';
148
+ import { type AlternatePartsRecord, FRONT_SUFFIX, type LimbRecord, partImageReference, type PartRecord, type PartsFile, readParts } from './parts.ts';
149
149
  import { ARM_SPLIT_MIGRATION, poseRigBonesForDrawn, type RigBone, SETS_FILE, writtenShares } from './rig.ts';
150
150
  import { TURN_BONE, turnConstraintName, turnTwin } from './turn.ts';
151
151
  import { ROOT_BONE, loadConfigWithBytes, type Point } from './config.ts';
@@ -706,7 +706,7 @@ export function readCheckInputs(rigDir: string, partsHome?: string, sourcePath?:
706
706
  }
707
707
  if (parts !== null) {
708
708
  for (const p of parts.parts) {
709
- const png = join(partsDir, `${p.name}.png`);
709
+ const png = join(home, partImageReference(p).path);
710
710
  if (!existsSync(png)) {
711
711
  problems.push({ code: 'CHECK_PART_PNG_PRESENT', object: `part "${p.name}"`, detail: `${png} does not exist; parts.json lists it` });
712
712
  continue;
@@ -718,7 +718,7 @@ export function readCheckInputs(rigDir: string, partsHome?: string, sourcePath?:
718
718
  }
719
719
  for (const alt of parts.alternates ?? []) {
720
720
  for (const r of alt.records) {
721
- const png = join(partsDir, `${alt.name}_${r.name}.png`);
721
+ const png = join(home, partImageReference(r, alt.name).path);
722
722
  if (!existsSync(png)) {
723
723
  problems.push({ code: 'CHECK_PART_PNG_PRESENT', object: `set "${alt.name}" part "${r.name}"`, detail: `${png} does not exist; parts.json lists it` });
724
724
  continue;
@@ -1382,7 +1382,7 @@ export function resolvePlacedAlpha(placements: readonly ReferencePlacement[], pa
1382
1382
  const readRaw = (png: string): Raster => {
1383
1383
  const hit = rawCache.get(png);
1384
1384
  if (hit !== undefined) return hit;
1385
- const img = readPng(join(partsDir, `${png}.png`));
1385
+ const img = readPng(join(dirname(partsDir), png));
1386
1386
  rawCache.set(png, img);
1387
1387
  return img;
1388
1388
  };
@@ -1512,7 +1512,7 @@ export function setPlacements(parts: PartsFile, alt: AlternatePartsRecord, slotO
1512
1512
  }
1513
1513
  }
1514
1514
  }
1515
- const entry: PlacedIslandEntry = { name: islSlot, png: p.name, box: p, islandIndex: k, islandCount: islandSlots.length, at };
1515
+ const entry: PlacedIslandEntry = { name: islSlot, png: partImageReference(p).path, box: p, islandIndex: k, islandCount: islandSlots.length, at };
1516
1516
  if (!reordered) {
1517
1517
  const list = inlineIslands.get(p.name) ?? [];
1518
1518
  list.push(entry);
@@ -1543,11 +1543,11 @@ export function setPlacements(parts: PartsFile, alt: AlternatePartsRecord, slotO
1543
1543
  const rec = byName.get(name);
1544
1544
  const islandSlots = rec === undefined ? partIslandSlots(name, slotOrder) : [name];
1545
1545
  if (islandSlots.length > 1) {
1546
- out.push({ name, png: name, box: base, islandIndex: 0, islandCount: islandSlots.length });
1546
+ out.push({ name, png: partImageReference(base).path, box: base, islandIndex: 0, islandCount: islandSlots.length });
1547
1547
  for (const isl of inlineIslands.get(name) ?? []) pushIsland(isl);
1548
1548
  return;
1549
1549
  }
1550
- out.push({ name, png: rec === undefined ? name : `${alt.name}_${rec.name}`, box: rec ?? base });
1550
+ out.push({ name, png: rec === undefined ? partImageReference(base).path : partImageReference(rec, alt.name).path, box: rec ?? base });
1551
1551
  };
1552
1552
  const baseOf = new Map(parts.parts.map((p) => [p.name, p]));
1553
1553
  for (const p of parts.parts) {
@@ -1861,7 +1861,7 @@ export function seamDrawingSignature(input: {
1861
1861
  /** File-only rig-image padding checks after the parts loader has validated each PNG against its record. */
1862
1862
  export function boundaryColourSizeProblems(inp: CheckInputs): Problem[] {
1863
1863
  if (inp.parts === null) return [];
1864
- const records = new Set(inp.parts.parts.map(p => p.name));
1864
+ const records = new Map(inp.parts.parts.map(p => [p.name, p]));
1865
1865
  const imagesDir = typeof inp.rig.images === 'string' ? resolve(inp.rigDir, inp.rig.images) : join(inp.rigDir, 'images');
1866
1866
  const problems: Problem[] = [];
1867
1867
  const seen = new Set<string>();
@@ -1874,9 +1874,9 @@ export function boundaryColourSizeProblems(inp: CheckInputs): Problem[] {
1874
1874
  if (!seamImageSource(source) || seen.has(source.image)) continue;
1875
1875
  const image = source.image;
1876
1876
  seen.add(image);
1877
- const name = image.replace(/\.png$/, '');
1878
- const partPng = join(inp.partsDir, `${name}.png`), rigPng = join(imagesDir, image);
1879
- if (!records.has(name) || !existsSync(partPng) || !existsSync(rigPng)) continue;
1877
+ const name = image.replace(/\.png$/, ''), record = records.get(name);
1878
+ const partPng = record === undefined ? '' : join(dirname(inp.partsDir), partImageReference(record).path), rigPng = join(imagesDir, image);
1879
+ if (record === undefined || !existsSync(partPng) || !existsSync(rigPng)) continue;
1880
1880
  let src: Raster, rigImg: Raster;
1881
1881
  try { src = readPng(partPng); rigImg = readPng(rigPng); }
1882
1882
  catch { continue; }
@@ -6664,7 +6664,7 @@ export function runCheck(rigDir: string, outDir: string, rigc: RigcRunner, parts
6664
6664
  const parts = ready.parts;
6665
6665
  seams = take(() => resolveSeams(file, parts === null ? null : parts.parts.map((p) => p.name), ready.noParts, (n) => {
6666
6666
  const rec = (parts as PartsFile).parts.find((p) => p.name === n) as PartRecord;
6667
- return placedArt(rec.x, rec.y, readPng(join(ready.partsDir, `${n}.png`)));
6667
+ return placedArt(rec.x, rec.y, readPng(join(dirname(ready.partsDir), partImageReference(rec).path)));
6668
6668
  }));
6669
6669
  }
6670
6670
  if (wb !== null) take(() => resolveWindBand(wb, ready));
@@ -6678,7 +6678,7 @@ export function runCheck(rigDir: string, outDir: string, rigc: RigcRunner, parts
6678
6678
  // Read source support before rendering; no output/sidecar for undeclared builds.
6679
6679
  if (reqFile?.cut_material !== undefined && (set !== undefined || allSets)) refuseIfAny([{code: 'CHECK_CUT_MATERIAL_MEASURED', object: 'cut_material', detail: 'source evidence binds base assembly only; run check on its base parts without --set/--all-sets; alternate-set coverage requires its own original source instrument'}]);
6680
6680
  const cutMaterialProblems: Problem[] = [];
6681
- const cutMaterial = reqFile?.cut_material === undefined ? null : checkJointMaterial(reqFile.cut_material, inp.parts, name => readPng(join(inp.partsDir, `${name}.png`)), cutMaterialProblems, inp.parts === null ? undefined : readMaterialSources(dirname(inp.partsDir), inp.parts));
6681
+ const cutMaterial = reqFile?.cut_material === undefined ? null : checkJointMaterial(reqFile.cut_material, inp.parts, name => readPng(join(dirname(inp.partsDir), partImageReference((inp.parts as PartsFile).parts.find(p => p.name === name) as PartRecord).path)), cutMaterialProblems, inp.parts === null ? undefined : readMaterialSources(dirname(inp.partsDir), inp.parts));
6682
6682
  // A measured material failure is a check bar; unavailable data is a refusal.
6683
6683
  const rigcEntry = readRigcEntry(requireRigcVersion(rigc));
6684
6684
  /**
@@ -7035,7 +7035,7 @@ export function runCheck(rigDir: string, outDir: string, rigc: RigcRunner, parts
7035
7035
  const png = (name: string): Raster => {
7036
7036
  const hit = pngs.get(name);
7037
7037
  if (hit !== undefined) return hit;
7038
- const r = readPng(join(inp.partsDir, `${name}.png`));
7038
+ const r = readPng(join(dirname(inp.partsDir), partImageReference(parts.parts.find((p) => p.name === name) as PartRecord).path));
7039
7039
  pngs.set(name, r);
7040
7040
  return r;
7041
7041
  };
@@ -8333,7 +8333,7 @@ function tipLine(inp: FullInputs, geometryPath: string, frames: number, problems
8333
8333
  const rises = excepted.rises.includes(p.name);
8334
8334
  const rests = excepted.rests.includes(p.name);
8335
8335
  const [rootHalf, tipHalf] = rises ? ['lower', 'upper'] : ['upper', 'lower'];
8336
- const art = placedArt(p.x, p.y, readPng(join(inp.partsDir, `${p.name}.png`)));
8336
+ const art = placedArt(p.x, p.y, readPng(join(dirname(inp.partsDir), partImageReference(p).path)));
8337
8337
  const shown = poses.map((f) => f.get(p.name) ?? null);
8338
8338
  const w = halfTravels(art, p, inp.stage, shown, rises ? 'up' : 'down');
8339
8339
  // Issue #987: the halves are read in the frame of the bone the part hangs from; the world reading rides beside them.
@@ -8862,7 +8862,7 @@ export function stillLine(inp: FullInputs, idle: FrameSet, geo: IdleGeometry | n
8862
8862
  const H = inp.parts.rig_size[1];
8863
8863
  const W = inp.parts.rig_size[0];
8864
8864
  const poses = attachmentPoses(geometryPath, idle.written);
8865
- const top = topmostIndex(inp.parts, (i) => readPng(join(inp.partsDir, `${inp.parts.parts[i].name}.png`)));
8865
+ const top = topmostIndex(inp.parts, (i) => readPng(join(dirname(inp.partsDir), partImageReference(inp.parts.parts[i]).path)));
8866
8866
  const index = new Map(inp.parts.parts.map((p, i) => [p.name, i]));
8867
8867
  const record = new Map(inp.parts.parts.map((p) => [p.name, p]));
8868
8868
  const slots = (Array.isArray(inp.rig.slots) ? inp.rig.slots : []).filter(isRecord).map((sl) => ({ name: String(sl.name), bone: typeof sl.bone === 'string' ? sl.bone : undefined }));
@@ -8872,7 +8872,7 @@ export function stillLine(inp: FullInputs, idle: FrameSet, geo: IdleGeometry | n
8872
8872
  let a = arts.get(name);
8873
8873
  if (a === undefined) {
8874
8874
  const p = record.get(name) as PartRecord;
8875
- a = placedArt(p.x, p.y, readPng(join(inp.partsDir, `${name}.png`)));
8875
+ a = placedArt(p.x, p.y, readPng(join(dirname(inp.partsDir), partImageReference(p).path)));
8876
8876
  arts.set(name, a);
8877
8877
  }
8878
8878
  return a;
@@ -4,7 +4,7 @@ import { existsSync, readFileSync, writeFileSync } from 'node:fs';
4
4
  import { dirname, join } from 'node:path';
5
5
  import { edgeLength } from './length.ts';
6
6
  import { canonicalInward, CUT_MATERIAL_SOURCES, CUT_MATERIAL_SPEC, type MaterialSource, type Point } from './cutmaterial.ts';
7
- import type { PartsFile } from './parts.ts';
7
+ import { partImageReference, type PartsFile } from './parts.ts';
8
8
  import { refuseIfAny } from './errors.ts';
9
9
  const sha=(data:Uint8Array|string):string=>createHash('sha256').update(data).digest('hex');
10
10
  const hash=(path:string):string=>sha(readFileSync(path));
@@ -15,7 +15,7 @@ export function writeMaterialSources(partsPath:string,partsDir:string,parts:Part
15
15
  const emitted=sources.filter(s=>parts.parts.some(p=>p.name===s.part));
16
16
  writeFileSync(join(dirname(partsPath),CUT_MATERIAL_SOURCES),JSON.stringify({
17
17
  spec:CUT_MATERIAL_SPEC,parts_sha256:hash(partsPath),
18
- images:parts.parts.map(p=>({part:p.name,sha256:hash(join(partsDir,`${p.name}.png`))})),
18
+ images:parts.parts.map(p=>({part:p.name,sha256:hash(join(dirname(partsDir),partImageReference(p).path))})),
19
19
  sources_sha256:sha(JSON.stringify(emitted)),sources:emitted,
20
20
  },null,2)+'\n');
21
21
  }
@@ -32,10 +32,11 @@ export function readMaterialSources(home:string,parts:PartsFile):MaterialSource[
32
32
  if(raw.images.length!==parts.parts.length)return fail('image bindings do not cover every emitted base part');
33
33
  const seen=new Set<string>();
34
34
  for(const binding of raw.images){
35
- if(!record(binding)||typeof binding.part!=='string'||!digest(binding.sha256)||seen.has(binding.part)||!parts.parts.some(p=>p.name===binding.part))return fail('image bindings require each named base part exactly once and its SHA-256');
35
+ const part=record(binding)&&typeof binding.part==='string'?parts.parts.find(p=>p.name===binding.part):undefined;
36
+ if(!record(binding)||typeof binding.part!=='string'||!digest(binding.sha256)||seen.has(binding.part)||part===undefined)return fail('image bindings require each named base part exactly once and its SHA-256');
36
37
  if(Object.keys(binding).some(k=>!['part','sha256'].includes(k)))return fail('image binding has an unknown field');
37
38
  seen.add(binding.part);
38
- const file=join(home,'parts',`${binding.part}.png`);
39
+ const file=join(home,partImageReference(part).path);
39
40
  if(!existsSync(file)||hash(file)!==binding.sha256)return fail(`source-edge binding for part "${binding.part}" differs from its emitted PNG`);
40
41
  }
41
42
  const sources=new Set<string>();
@@ -8,7 +8,7 @@ import { basename, dirname, join, relative, resolve, sep } from 'node:path';
8
8
  import { loadConfigAndAnimations, parseConfig } from './config.ts';
9
9
  import { depthReading, readSourceDepth } from './depthsheets.ts';
10
10
  import { alphaSupport, depthMapFail as fail, floatBox, integrateNormals, mapToSheet, readNumericMap, type NumericMap } from './depthmaps.ts';
11
- import { readParts } from './parts.ts';
11
+ import { depthImageReference, partImageReference, readParts } from './parts.ts';
12
12
  import { readPartSet } from './propose.ts';
13
13
  import { decodePngBytes, encodePngBytes } from './raster/png.ts';
14
14
  import { resize } from './raster/resize.ts';
@@ -98,7 +98,7 @@ function preparedParts(partsDir: string, recipe: DepthRecipe): { manifest: Prepa
98
98
  }
99
99
  if (!alphaSupport(art).some(Boolean)) fail('DEPTH_MAP_SUPPORT', part.name, 'has no alpha>=128 pixels; a supported part is required');
100
100
  const bytes = encodePngBytes(input), file = `${part.name}.png`; images.set(file, bytes);
101
- parts.push({ part: part.name, crop: [part.x, part.y, part.w, part.h], sourceSha256: hash(readFileSync(join(partsDir, 'parts', file))), input: file, inputSha256: hash(bytes), size: [art.width, art.height], upscaled: [w, h], upscale, padding: pad, inputSize: [input.width, input.height] });
101
+ parts.push({ part: part.name, crop: [part.x, part.y, part.w, part.h], sourceSha256: hash(readFileSync(join(partsDir, partImageReference(part).path))), input: file, inputSha256: hash(bytes), size: [art.width, art.height], upscaled: [w, h], upscale, padding: pad, inputSize: [input.width, input.height] });
102
102
  }
103
103
  return { manifest: { spec: 'rig-parts-depth-inputs/1', partsSha256: hash(readFileSync(join(partsDir, 'parts.json'))), recipeSha256: hash(text(recipe)), background: 128, alpha: 128, parts }, images };
104
104
  }
@@ -185,12 +185,12 @@ export function applyDepth(input: { parts: string; manifest: string; config: str
185
185
  };
186
186
  collect(input.parts, '');
187
187
  for (const p of file.parts) {
188
- const name = p.name, bytes = readFileSync(join(input.parts, 'parts', `${name}.png`)), art = decodePngBytes(bytes, name), rec = recs.find(r => r.name === name) as Obj;
188
+ const name = p.name, bytes = readFileSync(join(input.parts, partImageReference(p).path)), art = decodePngBytes(bytes, name), rec = recs.find(r => r.name === name) as Obj;
189
189
  writes.set(`${name}.png`, bytes);
190
190
  const declaration = Object.hasOwn(recipe.parts, name) ? recipe.parts[name] : undefined;
191
191
  if (declaration === undefined) {
192
- if (recipe.clear.includes(name)) { if (p.depth !== undefined) retained.delete(`parts/${p.depth.image}`); delete rec.depth; }
193
- else if (p.depth !== undefined) { readSourceDepth(join(input.parts, 'parts', p.depth.image), art, null); writes.set(p.depth.image, readFileSync(join(input.parts, 'parts', p.depth.image))); }
192
+ if (recipe.clear.includes(name)) { if (p.depth !== undefined) retained.delete(depthImageReference(p.depth).path); delete rec.depth; }
193
+ else if (p.depth !== undefined) { const depthPath = join(input.parts, depthImageReference(p.depth).path); readSourceDepth(depthPath, art, null); writes.set(p.depth.image, readFileSync(depthPath)); }
194
194
  continue;
195
195
  }
196
196
  const g = recipe.groups[declaration.group], target = declaration.group === 'head' ? turn : object(turn.body, 'config.turn.body');
@@ -213,7 +213,7 @@ export function applyDepth(input: { parts: string; manifest: string; config: str
213
213
  const { sheet, reading } = mapToSheet(values, art, declaration.median, declaration.relief, g.near, g.zScale, name), image = `${name}_depth.png`, sheetBytes = encodePngBytes(sheet);
214
214
  if (file.parts.some(p => `${p.name}.png` === image)) fail('DEPTH_GROUP_BINDING', name, `sheet filename ${image} collides with artwork; use noncolliding part names`);
215
215
  writes.set(image, sheetBytes);
216
- if (p.depth !== undefined) retained.delete(`parts/${p.depth.image}`);
216
+ if (p.depth !== undefined) retained.delete(depthImageReference(p.depth).path);
217
217
  rec.depth = { image, near: g.near, zScale: g.zScale, sources: [{ from: p.from, image: basename(declaration.map), sha256: hash(mapBytes), crop: [0, 0, art.width, art.height], reading: depthReading(sheet, art, null) }] };
218
218
  rows.push({ part: name, group: declaration.group, source: declaration.source, frame: declaration.frame, sourceSha256: prepared.sourceSha256, mapSha256: hash(mapBytes), inputSha256: prepared.inputSha256, sheetSha256: hash(sheetBytes), median: declaration.median, relief: declaration.relief, near: g.near, zScale: g.zScale, pivot: g.pivot, ...reading, sign: normal?.sign ?? 1, ...(normal === undefined ? {} : { integration: { stride: 2, iterations: normal.iterations, residual: normal.residual, coreMinusRim: normal.coreMinusRim, maxIterations: 3000, atol: 1e-6, btol: 1e-6 } }) });
219
219
  }
@@ -4,7 +4,7 @@ import { readFileSync, writeFileSync } from 'node:fs';
4
4
  import { dirname, join } from 'node:path';
5
5
  import { COVERED_ALPHA, ERROR_LIMIT, coveredMask, errorMask, holeBorders, type PlacedPart } from './assemble.ts';
6
6
  import { PartsError, type Problem } from './errors.ts';
7
- import { readParts } from './parts.ts';
7
+ import { partImageReference, readParts } from './parts.ts';
8
8
  import { connectedComponents } from './raster/components.ts';
9
9
  import { decodePngBytes } from './raster/png.ts';
10
10
  import { newMask, type Raster } from './raster/types.ts';
@@ -184,7 +184,7 @@ export function diffComponentsCommand(args: string[]): void {
184
184
  };
185
185
  const partsPath = flags.get('--parts')!;
186
186
  const parts = readParts(partsPath);
187
- const placed = parts.parts.map(record => ({ record, image: diffPng(bytes(join(dirname(partsPath), 'parts', `${record.name}.png`)).bytes, record.name) }));
187
+ const placed = parts.parts.map(record => ({ record, image: diffPng(bytes(join(dirname(partsPath), partImageReference(record).path)).bytes, record.name) }));
188
188
  const stack = bytes(flags.get('--stack')!), painting = bytes(flags.get('--painting')!);
189
189
  const reference = diffPng(painting.bytes, painting.path);
190
190
  if (parts.rig_size[0] !== reference.width || parts.rig_size[1] !== reference.height) inputFailure('parts.rig_size', `is ${parts.rig_size[0]}x${parts.rig_size[1]}; painting ${reference.width}x${reference.height} is required, with no resampling`);
package/src/meshdraft.ts CHANGED
@@ -72,7 +72,7 @@ import { PartsError, type Problem, problemLine } from './errors.ts';
72
72
  import { IDLE_FPS } from './motion.ts';
73
73
  import { type ContourBridges, FAINT_ALPHA } from './contour.ts';
74
74
  import { ART_ALPHA, DUST_MAX_PX, DUST_MAX_SHARE, isDust, dustOf, type DustReading } from './mesh.ts';
75
- import { type PartsFile, readParts } from './parts.ts';
75
+ import { partImageReference, type PartsFile, readParts } from './parts.ts';
76
76
  import { readPng } from './raster/png.ts';
77
77
  import type { Raster } from './raster/types.ts';
78
78
  import { buildRig, type IdleKeys, type MeshAttachment, rigJsonText, type RigSpec } from './rig.ts';
@@ -852,7 +852,7 @@ export function meshDraftStage(input: MeshDraftInput, rigc: RigcRunner, checkBin
852
852
  if ('code' in rules) throw new PartsError([rules]);
853
853
  const images = new Map<string, Raster>();
854
854
  for (const p of parts.parts) {
855
- const png = join(input.parts, 'parts', `${p.name}.png`);
855
+ const png = join(input.parts, partImageReference(p).path);
856
856
  if (existsSync(png)) images.set(p.name, readPng(png));
857
857
  }
858
858
  log(`rig-parts mesh-draft: ${cfg.key}, figure ${rules.height} px (rows ${rules.top}..${rules.bottom}): tolerance and margin T = max(1, round(${rules.height} / ${TOLERANCE_FIGURE_DIVISOR})) = ${rules.tolerance}, spacing and longest outline edge S = round(${rules.height} / ${FIGURE_GRID_DIVISOR}) = ${rules.spacing}`);
package/src/parts.ts CHANGED
@@ -777,7 +777,7 @@ function checkParts(raw: unknown, path: string): PartsFile {
777
777
  }
778
778
  if ('parts' in o && !(Array.isArray(o.parts) && o.parts.length > 0)) fail('PARTS_FIELD_TYPE', `${path} field "parts"`, `is ${show(o.parts)}; a non-empty array is required`);
779
779
  if (Array.isArray(o.parts)) {
780
- const seen = new Map<string, number>();
780
+ const seen = new Map<string, { index: number; name: string }>();
781
781
  o.parts.forEach((p, i) => {
782
782
  const at = `${path} parts[${i}]`;
783
783
  if (typeof p !== 'object' || p === null || Array.isArray(p)) {
@@ -796,8 +796,8 @@ function checkParts(raw: unknown, path: string): PartsFile {
796
796
  }
797
797
  if (!isPartName(r.name)) {
798
798
  fail('PARTS_FIELD_TYPE', `${label} field "name"`, `is ${show(r.name)}; a file-name-safe part name is required`);
799
- } else if (seen.has(r.name)) fail('PARTS_NAME_UNIQUE', label, `appears at parts[${seen.get(r.name)}] and parts[${i}]`);
800
- else seen.set(r.name, i);
799
+ } else if (seen.has(r.name.toLowerCase())) fail('PARTS_NAME_UNIQUE', label, `appears at parts[${seen.get(r.name.toLowerCase())!.index}] ("${seen.get(r.name.toLowerCase())!.name}") and parts[${i}] ("${r.name}")`);
800
+ else seen.set(r.name.toLowerCase(), { index: i, name: r.name });
801
801
  const from = typeof r.from === 'string' ? readFrom(r.from) : null;
802
802
  if (from === null) fail('PARTS_FROM_KNOWN', `${label} field "from"`, `is ${show(r.from)}; "<full|head>:<v3 tag>", "<full|head>:author:<label>" for a layer the author made, or "painting:<the part's own name>" for a patch, is required`);
803
803
  else if (from.run === 'painting' && from.patch !== r.name) {