spine-rigc 1.9.1 → 1.9.3
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 +28 -4375
- package/docs/AUTHORING.md +2 -2
- package/package.json +1 -1
- package/src/assertions/bodies/a10.ts +116 -0
- package/src/assertions/bodies/a13.ts +3 -3
- package/src/assertions/bodies/a14.ts +3 -3
- package/src/assertions/bodies/a15.ts +5 -5
- package/src/assertions/bodies/a22.ts +3 -3
- package/src/assertions/bodies/a34.ts +133 -0
- package/src/assertions/bodies/a40.ts +128 -0
- package/src/assertions/facts/animated_bones.ts +4 -2
- package/src/assertions/facts/constraint_targets.ts +56 -0
- package/src/assertions/facts/mesh_attachments.ts +33 -4
- package/src/assertions/facts/slider_composition.ts +78 -0
- package/src/assertions/facts/stepped_poses.ts +74 -0
- package/src/assertions/model/animated_bones.ts +13 -5
- package/src/assertions/model/bone_timelines.ts +5 -3
- package/src/assertions/model/constraint_targets.ts +82 -0
- package/src/assertions/model/declared.ts +127 -0
- package/src/assertions/model/index.ts +81 -39
- package/src/assertions/model/mesh_attachments.ts +31 -2
- package/src/assertions/model/parse.ts +9 -1
- package/src/assertions/model/runtime_timelines.ts +78 -0
- package/src/assertions/model/slider_composition.ts +193 -0
- package/src/assertions/model/stepped_poses.ts +90 -0
- package/src/bonedist.ts +22 -11
- package/src/check.ts +3 -2
- package/src/checkpics.ts +1 -1
- package/src/cli/core_commands.ts +1532 -0
- package/src/cli/shared.ts +1935 -0
- package/src/cli/spine_commands.ts +1141 -0
- package/src/core/additive.ts +458 -0
- package/src/core/constraints.ts +38 -5
- package/src/core/constraints_physics.ts +42 -9
- package/src/core/constraints_slider.ts +136 -6
- package/src/core/index.ts +27 -3
- package/src/core/raw.ts +77 -16
- package/src/core/skins.ts +28 -3
- package/src/core/walk.ts +175 -0
- package/src/correspondence.ts +15 -0
- package/src/deformbuild.ts +60 -0
- package/src/deformmeasure.ts +20 -48
- package/src/deformreport.ts +2 -2
- package/src/framing.ts +1 -1
- package/src/nonfinite.ts +54 -0
- package/src/pose.ts +1 -1
- package/src/preview.ts +1 -1
- package/src/region_joins.ts +54 -0
- package/src/render.ts +243 -2808
- package/src/render_core.ts +19 -31
- package/src/render_shared.ts +2887 -0
- package/src/slots.ts +1 -1
- package/src/spine_side.ts +123 -0
- package/src/validate.ts +443 -548
- package/src/assertions/facts/skin_meshes.ts +0 -49
- package/src/assertions/model/skin_meshes.ts +0 -90
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The model side's supply of `SteppedPoseFacts` (issue #1025, cut 4c-5a of
|
|
3
|
+
* step 4c of #380): every pose A10 reads, posed by rigc's core.
|
|
4
|
+
*
|
|
5
|
+
* - **The roster**: the document's bones, and its animations in the file's
|
|
6
|
+
* order (`fileAnimationOrder`, `src/compile.ts`), each with
|
|
7
|
+
* `CoreAnimationTimelines.duration` — the last key of every timeline as
|
|
8
|
+
* float32, the value `tools/pose_oracle.ts compare` holds equal to
|
|
9
|
+
* spine-core's on its `animations` roster.
|
|
10
|
+
* - **The setup pose and each animation's walk**: the core's looping walk
|
|
11
|
+
* (`src/core/walk.ts` — `poseWalkSetup`, `poseLoopingWalk`), which reads
|
|
12
|
+
* A10's recipe as measured and returns a value that is not finite in place
|
|
13
|
+
* rather than refusing it. It is held equal to spine-core's walk at
|
|
14
|
+
* tolerance 0 by `tools/core_gate.ts`'s walk block and the selftest's
|
|
15
|
+
* `CO25`, and the poses A10 asks for here are compared with spine-core's on
|
|
16
|
+
* every call with a model in hand (`VF13`).
|
|
17
|
+
* - **A bone's mode**: the mode the core's bone timelines pose at the time
|
|
18
|
+
* (`posedBones`, a fresh non-looping track: the time held at the duration),
|
|
19
|
+
* folded as the runtime's lookup folds it (`foldInheritMode`). `readModel`
|
|
20
|
+
* refuses a setup `inheritMode` and an `inherit` key that fold to no mode by
|
|
21
|
+
* name, so on this side every bone of every pose holds one and the answer is
|
|
22
|
+
* `null` — derived from the pose rather than assumed, so a reader that
|
|
23
|
+
* started admitting such a spelling would show up here as a bone with none.
|
|
24
|
+
* - **Under no skin set**, as `validate()` poses (`noSkinView`, the view
|
|
25
|
+
* measured in issue #1051: no skin's bones or constraints applied, a slot
|
|
26
|
+
* looked up in the default skin alone).
|
|
27
|
+
*
|
|
28
|
+
* Links nothing from the runtime.
|
|
29
|
+
*/
|
|
30
|
+
import { fileAnimationOrder } from '../../compile.ts';
|
|
31
|
+
import { foldInheritMode, type CompiledDocument } from '../../core/index.ts';
|
|
32
|
+
import { posedBones } from '../../core/animation.ts';
|
|
33
|
+
import { poseLoopingWalk, poseWalkSetup, type WalkPose } from '../../core/walk.ts';
|
|
34
|
+
import { noSkinView } from '../../render_core.ts';
|
|
35
|
+
import type { ModelBone } from '../../model.ts';
|
|
36
|
+
import type { SteppedFrame, SteppedPoseFacts } from '../facts/stepped_poses.ts';
|
|
37
|
+
import type { ReadDocument } from './parse.ts';
|
|
38
|
+
|
|
39
|
+
/** A bone's posed mode as the facts spell it: `null` for a mode, else the value held. */
|
|
40
|
+
const modeOf = (bone: ModelBone): string | null => (foldInheritMode(bone.inheritMode ?? 'normal') === null ? String(bone.inheritMode) : null);
|
|
41
|
+
|
|
42
|
+
/** A channel the walk computed; a slot row holds `null` only where a rounding wrote one, which the walk does not. */
|
|
43
|
+
const channel = (v: number | null): number => (v === null ? Number.NaN : v);
|
|
44
|
+
|
|
45
|
+
/** One walk pose as A10 reads it, each bone's mode taken from `posed` (the bones the timelines posed at the pose's time). */
|
|
46
|
+
function frameOf(pose: WalkPose, posed: readonly ModelBone[]): SteppedFrame {
|
|
47
|
+
const modes = new Map(posed.map((b) => [b.name, modeOf(b)]));
|
|
48
|
+
return {
|
|
49
|
+
bones: pose.bones.map((b) => ({ name: b.name, a: b.a, b: b.b, c: b.c, d: b.d, worldX: b.worldX, worldY: b.worldY, inherit: modes.get(b.name) ?? null })),
|
|
50
|
+
drawn: pose.drawn.map((d) => ({ slot: d.slot, attachment: d.attachment, vertices: d.vertices })),
|
|
51
|
+
slots: pose.slots.map((row) => ({
|
|
52
|
+
name: row[0],
|
|
53
|
+
colour: [channel(row[2]), channel(row[3]), channel(row[4]), channel(row[5])] as const,
|
|
54
|
+
dark: row[6] === null ? null : ([channel(row[6][0]), channel(row[6][1]), channel(row[6][2])] as const),
|
|
55
|
+
})),
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export function modelSteppedPoses(read: ReadDocument): SteppedPoseFacts {
|
|
60
|
+
let view: CompiledDocument | null = null;
|
|
61
|
+
const viewOf = (): CompiledDocument => (view ??= noSkinView(read.doc));
|
|
62
|
+
const animationOf = (name: string) => {
|
|
63
|
+
const anim = viewOf().animations.find((a) => a.name === name);
|
|
64
|
+
if (anim === undefined) throw new Error(`internal: the model side was asked to pose animation "${name}", which the document does not hold`);
|
|
65
|
+
return anim;
|
|
66
|
+
};
|
|
67
|
+
return {
|
|
68
|
+
boneCount: read.doc.bones.length,
|
|
69
|
+
steppedAnimations: fileAnimationOrder(read.doc).flatMap((name) => {
|
|
70
|
+
const anim = read.doc.animations.find((a) => a.name === name);
|
|
71
|
+
return anim === undefined ? [] : [{ name, duration: anim.timelines.duration }];
|
|
72
|
+
}),
|
|
73
|
+
hasAnimation: (name) => read.doc.animations.some((a) => a.name === name),
|
|
74
|
+
hasBone: (name) => read.doc.bones.some((b) => b.name === name),
|
|
75
|
+
posedInherit: (animation, bone, time) => {
|
|
76
|
+
const anim = animationOf(animation);
|
|
77
|
+
const t = time < anim.timelines.duration ? time : anim.timelines.duration;
|
|
78
|
+
const posed = posedBones(viewOf(), anim.timelines, t).find((b) => b.name === bone);
|
|
79
|
+
return posed === undefined ? undefined : modeOf(posed);
|
|
80
|
+
},
|
|
81
|
+
// The document's stated mode — asked only of a bone posing none, which the reader leaves this side no document to hold.
|
|
82
|
+
statedInherit: (name) => `${JSON.stringify(read.doc.bones.find((b) => b.name === name)?.inheritMode)}`,
|
|
83
|
+
setup: () => frameOf(poseWalkSetup(viewOf()), viewOf().bones),
|
|
84
|
+
walk: (animation, step, frames) => {
|
|
85
|
+
const anim = animationOf(animation);
|
|
86
|
+
const poses = poseLoopingWalk(viewOf(), animation, new Array<number>(frames).fill(step));
|
|
87
|
+
return poses.slice(1).map((pose) => frameOf(pose, posedBones(viewOf(), anim.timelines, pose.animationTime)));
|
|
88
|
+
},
|
|
89
|
+
};
|
|
90
|
+
}
|
package/src/bonedist.ts
CHANGED
|
@@ -77,21 +77,20 @@
|
|
|
77
77
|
*/
|
|
78
78
|
import { readFileSync } from 'node:fs';
|
|
79
79
|
import {
|
|
80
|
-
|
|
80
|
+
loadPosedSkeleton,
|
|
81
81
|
PROTOCOL_FPS,
|
|
82
82
|
sampleAnimation,
|
|
83
83
|
sampleSetupPose,
|
|
84
84
|
type BoneSnapshot,
|
|
85
85
|
type Posable,
|
|
86
86
|
} from './render.ts';
|
|
87
|
+
import { BONEDIST_SPEC, IDENTITY_CORRESPONDENCE } from './correspondence.ts';
|
|
87
88
|
|
|
88
89
|
export class BoneDistError extends Error {}
|
|
89
90
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
/** What `--bones identity` is spelled as, where a file path would go. */
|
|
94
|
-
export const IDENTITY_CORRESPONDENCE = 'identity';
|
|
91
|
+
// `BONEDIST_SPEC` and `IDENTITY_CORRESPONDENCE` are `./correspondence.ts`'s since issue #1052: the CLI's help names
|
|
92
|
+
// both, and an entry that links nothing of the runtime prints that help. Re-exported here.
|
|
93
|
+
export { BONEDIST_SPEC, IDENTITY_CORRESPONDENCE };
|
|
95
94
|
|
|
96
95
|
/** How many bones the report's per-bone table shows before it says "and N more". */
|
|
97
96
|
export const BONE_TABLE_ROWS = 8;
|
|
@@ -184,7 +183,7 @@ export interface SkeletonSize {
|
|
|
184
183
|
degenerate: boolean;
|
|
185
184
|
}
|
|
186
185
|
|
|
187
|
-
function skeletonSize(posable: Posable): SkeletonSize {
|
|
186
|
+
function skeletonSize(posable: Pick<Posable, 'data'>): SkeletonSize {
|
|
188
187
|
const setup = sampleSetupPose(posable.data, { bones: true }).at(0);
|
|
189
188
|
const bones = setup?.bones ?? [];
|
|
190
189
|
const rootData = posable.data.bones.find((b) => b.parent === null) ?? posable.data.bones.at(0);
|
|
@@ -338,10 +337,17 @@ export interface BoneDistReport {
|
|
|
338
337
|
export interface BoneDistOptions {
|
|
339
338
|
candidateSkeleton: string;
|
|
340
339
|
candidateAtlas: string;
|
|
341
|
-
|
|
340
|
+
/**
|
|
341
|
+
* Where the candidate's atlas pages are. Not read since issue #1042: no
|
|
342
|
+
* figure here samples a pixel, so no page is opened, and a pair whose pages
|
|
343
|
+
* are elsewhere measures the same. Kept optional so a caller that passes it
|
|
344
|
+
* still compiles.
|
|
345
|
+
*/
|
|
346
|
+
candidateAtlasDir?: string;
|
|
342
347
|
referenceSkeleton: string;
|
|
343
348
|
referenceAtlas: string;
|
|
344
|
-
|
|
349
|
+
/** The reference's, as `candidateAtlasDir` — not read. */
|
|
350
|
+
referenceAtlasDir?: string;
|
|
345
351
|
/** A correspondence file path, or `identity`. */
|
|
346
352
|
bones: string;
|
|
347
353
|
fps?: number;
|
|
@@ -398,8 +404,13 @@ function extremesOf(values: number[]): Extremes {
|
|
|
398
404
|
export function boneDistance(options: BoneDistOptions): BoneDistReport {
|
|
399
405
|
const fps = options.fps ?? PROTOCOL_FPS;
|
|
400
406
|
if (!Number.isFinite(fps) || fps <= 0) throw new BoneDistError('fps must be a positive number');
|
|
401
|
-
|
|
402
|
-
|
|
407
|
+
// Each side through spine-core, refused by name where its skeleton does not load against its atlas (issue #1042),
|
|
408
|
+
// and without its page images: nothing here samples a pixel (`loadPosedSkeleton`).
|
|
409
|
+
const posedFor = (side: 'candidate' | 'reference', skeleton: string, atlas: string): Pick<Posable, 'data'> => ({
|
|
410
|
+
data: loadPosedSkeleton(skeleton, atlas, `bonedist's ${side}: every bone's world transform is read off spine-core's pose of it`),
|
|
411
|
+
});
|
|
412
|
+
const candidate = posedFor('candidate', options.candidateSkeleton, options.candidateAtlas);
|
|
413
|
+
const reference = posedFor('reference', options.referenceSkeleton, options.referenceAtlas);
|
|
403
414
|
|
|
404
415
|
const candidateBoneNames = candidate.data.bones.map((b) => b.name);
|
|
405
416
|
const referenceBoneNames = new Set(reference.data.bones.map((b) => b.name));
|
package/src/check.ts
CHANGED
|
@@ -92,13 +92,14 @@ import {
|
|
|
92
92
|
type FramesSidecar,
|
|
93
93
|
type FrameSet,
|
|
94
94
|
type MakeCorePoser,
|
|
95
|
-
type Posable,
|
|
96
95
|
type PoseOptions,
|
|
97
96
|
type Poser,
|
|
98
97
|
type PoserName,
|
|
99
98
|
type TextureSubstitution,
|
|
100
99
|
type Viewport,
|
|
101
|
-
} from './
|
|
100
|
+
} from './render_shared.ts';
|
|
101
|
+
// The one name here that is the runtime's: a candidate's pages, read off the shape spine-core's loader returns.
|
|
102
|
+
import type { Posable } from './render.ts';
|
|
102
103
|
import {
|
|
103
104
|
applyFit,
|
|
104
105
|
boxHeight,
|
package/src/checkpics.ts
CHANGED
|
@@ -48,7 +48,7 @@ import {
|
|
|
48
48
|
type Framing,
|
|
49
49
|
type FrameCheck,
|
|
50
50
|
} from './check.ts';
|
|
51
|
-
import { FRAMES_SIDECAR, FRAMES_SPEC } from './
|
|
51
|
+
import { FRAMES_SIDECAR, FRAMES_SPEC } from './render_shared.ts';
|
|
52
52
|
import { isContent } from './framing.ts';
|
|
53
53
|
import { isAttributable } from './slots.ts';
|
|
54
54
|
import { encodePng, Plate, type RGBA } from '../tools/plate.ts';
|