spine-rigc 2.52.0 → 2.54.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -601,7 +601,7 @@ commands take it and what its default is.
601
601
  | `repack <dir> --out <dir> --keep-pages` | **`skeleton.model.json` alone, for the pages already in place** — for a player that reads the document beside an atlas and pages that already shipped. The same read and stage rules, then `build --atlas-in` over the input atlas in place of the lift and the pack; it writes the document, and nothing else, only after its `pages` are shown to state the atlas as it stands, the rebuilt skeleton byte-identical to the one on disk (so `spine.sha256` names it — no acceptance flag here) and the gate green. `--out` is usually the build's own directory and must not already hold a `skeleton.model.json`; a page or region line the document has no field for is refused by name ([AUTHORING §0.4](docs/AUTHORING.md)) |
602
602
  | `ingest <skeleton.json> --out <dir>` | `build` run backwards: reads a Spine 4.3 skeleton and writes the rig spec and motion spec that **rebuild it**, plus a findings report naming everything it could not carry. a skeleton that declares no stage is carried as declaring none, `--stage x,y,w,h` adds a box to one — and is refused, rather than ignored, beside one that declares a box — and `--images <dir>` writes the spec's own images directory — the opposite direction from `build --images`, which overrides it — so the rebuild carries no flag at all |
603
603
  | `explain --rig … --motion …` | the compiled rig as a table — every bone with its resolved parent, the slots in draw order, every timeline key by key. Writes nothing. What to reach for when a rig compiles and still looks wrong |
604
- | `render --candidate <dir>` | PNG frames plus a contact sheet, in `render/`. `--hide <slot,…>` or `--slot <slot,…>` draws part of the rig on the **same grid** as the whole, so the two frames overlay and the difference is the part; `frames.json` records the subset and `check` refuses such a set as a reference. `--geometry` adds a `geometry.json` per set: every frame's bone world transforms and skinned attachment vertices, with the rest geometry, on the frames' own grid. `--folds` adds a `folds.json` per set and prints one line per mesh with a triangle turned over against the setup pose: the frames, the worst frame's count and which triangles, their world box and their setup-pose area |
604
+ | `render --candidate <dir>` | PNG frames plus a contact sheet, in `render/`. `--hide <slot,…>` or `--slot <slot,…>` draws part of the rig on the **same grid** as the whole, so the two frames overlay and the difference is the part; `frames.json` records the subset and `check` refuses such a set as a reference. `--geometry` adds a `geometry.json` per set: every frame's bone world transforms and skinned attachment vertices, with the rest geometry, on the frames' own grid. `--folds` adds a `folds.json` per set and prints one line per mesh with a triangle turned over against the setup pose: the frames, the worst frame's count and which triangles, their world box and their setup-pose area. `--environment <schedule.json>` draws the rig under the wind and gravity its physics answers, in time — the same frames on the core and on spine-core; an inspection of the response the rig states, not a scene |
605
605
  | `preview --candidate <dir>` | one self-contained `.html` that plays it, headed by the line `validate <dir>` prints for it and the rigc version — a refused candidate is still previewed, and its header says so in the gate's words. Repeat `--candidate` for one page with a pane per candidate, in the order given; a green `build` ends by naming this command for its own `--out` |
606
606
  | `vote --candidate a --candidate b` | one `.html` that asks a human which; `vote --record <file>` checks the answer into `votes.jsonl` |
607
607
  | `pose --images <dir> --frame <png>` | reads part placements **out of** a picture |
package/docs/AUTHORING.md CHANGED
@@ -246,6 +246,7 @@ What the flags mean:
246
246
  | `--show`, `--dim`, `--at`, `--zoom` | `inspect` only — what it draws, whether the art is faded, which times of `--animation` it poses and the bone, slot or folds it frames to; §13 says each, with the refusals |
247
247
  | `--geometry` | `render` only: also write a `geometry.json` into each frame directory — per frame, every bone's world transform and every slot's region or mesh vertices in world units after skinning, plus each attachment's rest geometry and topology, on the frames' own grid and viewport. Every other file is byte for byte what the render writes without it. Refused with `--slot`/`--hide`, because the geometry is the whole pose whatever is drawn — **§8.2** |
248
248
  | `--folds` | `render` only: also read which mesh triangles **fold** — turn over against the setup pose — and write a `folds.json` into each frame directory: per mesh, the frames with a folded triangle, the worst frame's count and which triangles, by index, with their world box and setup-pose area. One printed line per mesh that folds; a triangle degenerate or inverted at the setup pose is said once and never counted. A reading, not a gate. Every other file is byte for byte what the render writes without it, `geometry.json` included. Refused with `--slot`/`--hide`, for `--geometry`'s reason — **§8.3** |
249
+ | `--environment` | `render` only: the wind and gravity the rig's physics constraints answer, in time — a schedule file `{ "spec": "rigc-environment/1", "steps": [{ "t": <seconds>, "wind"?: [x, y], "gravity"?: [x, y] }, …] }`, x right and **y down**, each step holding from its `t` until the next. Both posers set each change before the step that poses the first frame at or after its `t`, and draw the same frames, `geometry.json` and `frames.json` (`RE01`). `frames.json` and `geometry.json` record it, and the framing reads it. A malformed file, a half no physics constraint answers, two steps on one frame and a step after every set's last frame are refused by name, exit 2, nothing written; `check` refuses a frame set drawn under one as a reference. Without it every file is the bytes it always was. An inspection of the response the rig states, not a scene — **§8.4** |
249
250
  | `--poser` | `render`, `inspect`, `check` and `explain`: `core` or `spine` — on `render`, `inspect` and `check`, which implementation poses the frames (on `check`, the candidate's; the reference side is pixels either way). By default a **rigc build** (the `skeleton.model.json` `build` writes; its atlas, when one is named or present, the one beside it) is posed by rigc's own core and a **Spine export** by spine-core; the render prints a `poser` line saying which and why, and so does the check report (`check.json`'s `poser`, and the pictures' `frames.json` under `--out`; `bench --frames` prints the same line). A concave or an inverse clip is posed by the core, and so is a build rendered with no `--skin` whose default skin names a skin-required bone or constraint, or whose skins name no `default` one — posed as a fresh skeleton is, no skin's bones or constraints applied (the default skin's included) and every slot resolved through the default skin alone, so the second draws nothing and stops at `there is nothing to draw` (exit 2) under either poser (issue #1051). Where the input cannot carry the core, or the core refuses it, the render poses it through spine-core and the `poser` line says why, in one of these words: `no skeleton.model.json beside` (a Spine export) · `is not beside` (`--atlas` names an atlas outside the build's directory) · `does not describe` (a model document whose bones, slots or animations are not the skeleton's) · `is not the skeleton.json` (a `skeleton.json` whose SHA-256 is not the `spine.sha256` its model document records — edited or replaced after the build — both digests named) · `the polygon is not simple` (a clip polygon two of whose edges cross or touch, the slot named) · `depends on the runtime's previous pass` (a constraint moves a posed bone from a bone that a constraint writes into while that bone is inactive, all four named) · `--poser spine` (asked for). Any other refusal of the core's — an unreadable model document among them — reads `the core refused` and then the core's own words. `--poser core` on an input that cannot carry it is refused in the same words (exit 2, nothing written); `--poser spine` forces the runtime. A fallback whose pair the runtime cannot load — another build's `skeleton.json` or atlas beside this build's document, or an export beside an atlas it was not exported with — is not drawn: it is refused `… does not load against <the atlas>: spine-core draws this pair (<why>) and could not resolve it — "<the runtime's own words>"` — or, where the atlas names a page that is not there, `nothing at <the page>: …` — exit 2, nothing written, on `render`, `render --geometry`, `check` and `bench --frames` alike; under `--poser core` the same pair is that flag's refusal, in the words above (`RC18`; the `--candidate` row says what to change). The repository's selftest renders one probe per reason above and holds this list to the lines they print (`RC09`). Both posers draw the same frames, geometry and framing box to the bit on every corpus (issue #968), and `check` through either writes the same report, `check.json` and pictures but for the poser it names on every tree row. A rigc build the core poses reads nothing through spine-core on `render`, `render --geometry` and `check`, `--texture-from` included (and the check `bench --frames` folds in; `bench`'s own `validate`, like `build`'s, is the runtime's round trip by design): its bone tree, slot list and slot roster come off its model document; so do the order its animations and skins are listed in, its stage and its pages' `scale:` lines, on a `rigc-compiled/3` document (`editorOrder`, `stage`, `pages`) — a `/2` or `/1` document states none of those, so they come off its own `skeleton.json` and atlas, and the `poser` line then says `a rigc-compiled/2 document, which does not state the order its skins and animations are listed in or its stage, read from` and names both files; where each region sits and the page images it draws off the document's `pages` (a `rigc-compiled/1` document's off the atlas beside it, and the `poser` line then says `a rigc-compiled/1 document, which does not state where each region sits on its page: that is read from` and names the atlas); and a `--texture-from` atlas off rigc's own atlas reader. The runtime is loaded for a Spine export, `--poser spine` and a fallback the `poser` line names; a run that cannot load it there is refused naming the input and why it needs the runtime (exit 1; `RC11`, `RC13`, `RC34`). On the entry that links none of spine-core — the installed `rigc` without the runtime beside it, `bun cli_core.ts` in a clone — that refusal ends on the route to the entry that does (``the entry that links it runs them — installed, the same `rigc` once @esotericsoftware/spine-core is installed beside the package; from a source checkout, `bun cli.ts` ``); a runtime that is installed and fails to load is refused without it, since installing it is not what that reader has to do. On `explain` the flag chooses the `DEFORM` block's survey (§4.11.2): `core`, the default, reads the skeleton's structure — its deform timelines and their keys, curves and slots, the skin each is keyed under, the sliders — off the model document the compile writes and poses it through the core, and spine-core is not touched (`RC15`); `spine` parses and poses the Spine skeleton through spine-core. The two are the same survey to the byte on every corpus row (`DM12`). Where the core refuses the document, the survey falls back to spine-core and the block says so on a line of its own (`read and posed through spine-core: …`); `--poser core` there is refused instead (exit 2), and a run that cannot load the runtime where it needs it is refused naming the survey and why (exit 1), ending on the same route where the entry links none of it |
250
251
  | `--record` | `vote` only: a saved vote to check against its ballot and append to the ledger, instead of writing a ballot. This is the command's second mode; it takes no `--candidate` |
251
252
  | `--ballot` | `vote --record` only: the ballot the vote answers (default `ballot.html`). Its embedded manifest is what the vote is checked against, so the ballot file is the record of the question |
@@ -3119,7 +3120,7 @@ beside it say how a distance becomes a share.
3119
3120
  | --- | --- |
3120
3121
  | `cell` | **required.** The lattice's square, in the part's pixels — a whole number of at least 1. No default: it is a length on this art, and how fine a mesh the part needs is not something rigc can read off it |
3121
3122
  | `bones` | **required, at least one entry.** Which segments may pull the part. An entry is one of three forms, below |
3122
- | `falloff` | **required**, because `radius` is: `{ "power"?, "radius", "maxBones"?, "minWeight"? }` |
3123
+ | `falloff` | **required unless `influence` is stated**, because `radius` is: `{ "power"?, "radius", "maxBones"?, "minWeight"? }`. Stated beside `influence`, refused — the two are two models of one share |
3123
3124
  | `radius` | **required.** Added to every distance before the power is taken, in the part's pixels, so a vertex ON a segment has a finite pull and the blend between two segments is about this wide. Positive |
3124
3125
  | `power` | the exponent a pull falls off by: `w = 1 / (d + radius)^power`. Positive. Default `2` |
3125
3126
  | `maxBones` | at most this many bones pull one vertex — the strongest ones. A whole number of at least 1. Default `4` |
@@ -3127,6 +3128,8 @@ beside it say how a distance becomes a share.
3127
3128
  | `alpha` | the alpha at or above which a pixel counts as art, `1`..`255`. Default `1` — `contour`'s own |
3128
3129
  | `anchor` | where the **slot bone** sits in the part's pixels, `[x, y]`, y down. Default the window's centre — the placement every generator on this route uses (the ⭐ above). State it when the art is not drawn centred on its bone: unlike a pinned generator, this one's weights depend on where the art is relative to the bones |
3129
3130
 
3131
+ | `influence` | instead of `falloff`: a pull that **reaches zero** at its own `radius` — `{ "radius", "across", "max", "shape" }`, every field required. Below |
3132
+
3130
3133
  **The three forms of a `bones` entry**, each resolved by name against the rig:
3131
3134
 
3132
3135
  | Entry | Its segment(s) |
@@ -3154,6 +3157,70 @@ of each segment, the strongest `maxBones` kept and normalised, any share under
3154
3157
  `minWeight` dropped, the rest normalised again — so every vertex closes at 1 by
3155
3158
  construction. The emitted mesh is a weighted one, bound by name.
3156
3159
 
3160
+ ##### `influence` — a vertex follows every link near it (cloth)
3161
+
3162
+ `falloff`'s pull, `1 / (d + radius)^power`, is positive at **every** distance: a
3163
+ wider blend needs a larger `radius`, which flattens the blend everywhere at once,
3164
+ and a blend only ends where `minWeight` drops a share. A cloth surface wants the
3165
+ other model — each vertex blends the springs of the chains around it, so the
3166
+ sheet bends as one surface rather than as strips — and that needs a pull that
3167
+ falls to **exactly zero** at a stated distance. `influence` is that model.
3168
+
3169
+ ```json
3170
+ "generator": {
3171
+ "kind": "segments",
3172
+ "cell": 8,
3173
+ "bones": [["skirt_0_0", "skirt_0_1", "skirt_0_2"], ["skirt_1_0", "skirt_1_1", "skirt_1_2"]],
3174
+ "influence": { "radius": 40, "across": true, "max": 6, "shape": "smooth" }
3175
+ }
3176
+ ```
3177
+
3178
+ | Field | Meaning |
3179
+ | --- | --- |
3180
+ | `radius` | **required.** How far a link reaches, in the part's pixels (on this route, the skeleton's units): a link whose segment is `radius` or farther from a vertex never pulls it. Positive. No default — a length on this art |
3181
+ | `across` | **required.** `true`: every link of every `bones` entry within `radius` pulls. `false`: only the links of **one** entry — the entry holding the link nearest the vertex, the earlier entry on a tie — so a chain moves its own strip and nothing across. No default: whether a chain may pull its neighbour's cloth is the decision |
3182
+ | `max` | **required.** At most this many links pull one vertex — the strongest; equal pulls keep the order `bones` first names their bones. A whole number of at least 1 |
3183
+ | `shape` | **required.** How a pull falls from 1 at `d = 0` to 0 at `d = radius`, with `x = d / radius`: `"linear"` is `1 - x`; `"smooth"` is `1 - x²(3 - 2x)`, which also arrives at both ends with zero slope, so a link enters and leaves a vertex's blend without a crease |
3184
+
3185
+ Per vertex, in order: `d` is the distance to each link's **segment** — its
3186
+ nearest point, the reading `falloff` takes — at the setup pose; with `across:
3187
+ false` only the nearest entry's links stay; each link with `d < radius` pulls
3188
+ `shape(d / radius)` (a bone two segments name keeps the nearer, and a link whose
3189
+ pull is not above 0 in doubles — a hair inside the reach — pulls nothing); the
3190
+ strongest `max` are kept and normalised; a share the 6-decimal grid would write
3191
+ as 0 is dropped and the rest normalised again; the strongest closes the vertex
3192
+ at exactly 1. **The distance is to the segment, not to the bone's origin**,
3193
+ because a vertex on the middle of a link *is* on that link: an origin distance
3194
+ would put it half a link away, and hand the joint at the link's tip to the child
3195
+ whose origin sits there.
3196
+
3197
+ 🔸 **One bone order by construction.** Every vertex lists its bones in the order
3198
+ `bones` names them, so the attachment has one order and
3199
+ `A52_WEIGHTED_VERTICES_SHARE_ONE_BONE_ORDER` holds without the compiler's
3200
+ ascending rewrite (§5.2) moving a byte — the order in the file is the spec's.
3201
+
3202
+ `build` prints a `reach` line under the `influence` line: the block as stated,
3203
+ how many vertices had **more links in reach than `max`** — the vertices the cap
3204
+ dropped a link from — and the most links in reach at one vertex (`widest`),
3205
+ which is the `max` that would drop none:
3206
+
3207
+ ```
3208
+ influence max 6 bone(s) per vertex, mean 4.87, 0 of 450 vertices (0.00%) on a single bone
3209
+ reach radius 40px, smooth, across entries, max 6: 146 of 450 vertices had more links in reach than max (widest 10)
3210
+ ```
3211
+
3212
+ ⚠️ **What a tight cap costs, measured.** On the selftest's `skirt_probe`
3213
+ (`fixtures/public.ts`: six chains of five links, a physics constraint on every
3214
+ link, the hip swayed) with `radius: 40`, `rotate` physics on and `render --folds`
3215
+ at 30 fps, `max: 2` turned 106 of the 816 triangles over on its worst frame and
3216
+ `max: 6` turned 4; `max: 6` with `radius: 20` (no vertex capped) turned 105, and
3217
+ `across: false` 91. With the physics removed the same sway folds none at either
3218
+ cap. So on that piece the folds followed how many neighbouring links a vertex
3219
+ blends — a narrow reach and a tight cap over a wide reach both fold — and a
3220
+ wide reach with a cap that drops few links folded least. One piece and one
3221
+ sway: it says what to look at with `render --folds` on your own, not what `max`
3222
+ your cloth needs.
3223
+
3157
3224
  `build` and `explain` print what it measured, under the mesh's line. This is
3158
3225
  the selftest's own `segments_probe` (`fixtures/public.ts` in the repository) —
3159
3226
  one 96x64 plate of two islands under two two-link chains, `cell: 8`,
@@ -3199,6 +3266,9 @@ rows.
3199
3266
  | a chain link at its next link's origin | `… the two bones share their setup origin (…), so the link has no length and no direction to weight along` |
3200
3267
  | an empty chain, a span with a malformed end, an entry of none of the three forms | `is an empty chain`; `both ends are [x, y] in the part's pixels`; `an entry is a bone name, a chain as a list of bone names, or { "bone", "from", "to" }` |
3201
3268
  | no `falloff`, a `radius` or `power` at or below 0, a malformed `anchor`, a `cell` under 1, no `image` | each named by its field — `radius` has no default because it is a length on this art |
3269
+ | both `falloff` and `influence` | `the "segments" generator states both "falloff" and "influence" … a mesh is weighted by one of them: remove the other` |
3270
+ | an `influence` field absent or out of range — `radius` at or below 0, `across` not a boolean, `max` not a whole number of at least 1, `shape` not `"linear"` or `"smooth"` | each named with the value found and the one required: `"influence.max" is 0; it is how many links may pull one vertex …`, `"influence.shape" is "cubic"; one of "linear", "smooth" …` |
3271
+ | a vertex no link reaches under `influence` | `vertex 0, at (0, 0) in the part's pixels, is reached by no link — the nearest is "skirt_0_0" at 17.8885, and "influence.radius" is 4` — **refused, not handed the nearest link**: raise `radius` over that distance, or name a segment nearer that part of the art |
3202
3272
  | a part on a packed page that declares a `scale:` | refused: `cell` and `radius` are the part's pixels and this generator does not convert them to a page's texels. Build from the loose part, or a pack at scale 1 |
3203
3273
 
3204
3274
  #### 3.4.8 A skin that switches bones and constraints on
@@ -4931,6 +5001,35 @@ file can be read; it is a **key** outside its bound that `build` refuses (§4.4)
4931
5001
  number: a non-number would reach the file as `null`, which the runtime reads as
4932
5002
  **zero**, so `"mass": "heavy"` would ship a constraint that never settles.
4933
5003
 
5004
+ 🧮 **Each value inside its bound is not enough: the step has to settle**
5005
+ (issue #1416). With `step = 1 / fps`, a constraint that drives anything must
5006
+ satisfy
5007
+
5008
+ strength · massInverse · step² < 2 · (1 + damping^(60 · step))
5009
+
5010
+ strictly, where `massInverse` is `1 / mass`. Each substep of the integrator is a
5011
+ linear map whose two eigenvalues lie inside the unit circle exactly then; at or
5012
+ past it the offset never dies out, and past it any push — wind, gravity, a key,
5013
+ the bone moving — grows without limit. [measured] on 270 generated rigs, all 115
5014
+ past the line ran past 10⁶ units under a unit gust (most with no gust at all),
5015
+ all 145 under it stayed bounded, and the 10 exactly on it were still growing or
5016
+ swinging their tip the bone's full length when a 6 s walk ended, spine-core
5017
+ identically — and every one of the 270 passed every gate before this clause.
5018
+ The runtime's defaults
5019
+ (`strength` 100, `mass` 1, `damping` 0.85) sit far under it at 60 fps (0.028
5020
+ against 3.70) and over it at `fps: 5` (4.00 against 2.28). `A23` refuses the
5021
+ setup values, and — for each animation that keys `strength`, `mass` or `damping`
5022
+ on the constraint — the largest strength, the lightest mass and the smallest
5023
+ damping that animation can pose, read together (a value the animation keys first
5024
+ after t = 0 includes the setup value, which is what plays before that key). That
5025
+ joint is an upper bound: an animation that raises strength and mass together is
5026
+ judged at its stiffest strength against its lightest mass. **To fix it, lower
5027
+ `strength`, raise `mass`, raise `fps` or raise `damping`** — the first three move
5028
+ the left side down, the last moves the right side up (a higher `damping` number
5029
+ keeps more velocity per step, yet it is what widens the bound: from 2 at `0` to
5030
+ 4 at `1`); the refusal prints both sides so you can see how far each lever has
5031
+ to go.
5032
+
4934
5033
  ⚠️ **What `rigc render` draws a spring with is not a player's clock to the bit.** A
4935
5034
  constraint integrates whole steps of `1 / fps` and shows the rest as a lag weight, so
4936
5035
  a frame lasting a whole number of steps (12, 20, 30 or 60 fps against the default
@@ -4977,6 +5076,10 @@ poses, to the bit (`CO56`). Two consequences an author has to know:
4977
5076
  value: that would make the export pose differently in the runtime than in
4978
5077
  the core.
4979
5078
 
5079
+ To look at the response before a player exists, `render --environment` (§8.4)
5080
+ draws the rig under a schedule of those same four numbers, on the core and on
5081
+ spine-core alike.
5082
+
4980
5083
  Moving the rig is the consumer's too: `physicsTranslate(x, y)` and
4981
5084
  `physicsRotate(x, y, degrees)` on a live track are the runtime's methods of
4982
5085
  those names — the whole rig moved or turned since the last pose, in the
@@ -6632,7 +6735,7 @@ Fix A00 and run it again.
6632
6735
  | <a id="A20_MESH_WEIGHTS_COHERENT"></a>`A20_MESH_WEIGHTS_COHERENT` | both ◑ | a weighted vertex with no bone, a negative weight, a bone index out of range, or weights that do not sum to 1. On a rig spec's `"boneIndexing": "raw"` mesh an index out of range or a run that does not decode is refused at compile first (§5.1, issue #917), so here it names a skeleton rigc did not compile. Under `rig-play` also: an unweighted mesh, a binding at weight 0, or **a bone the mesh declares that no vertex binds** — `mesh "x" declares bone "grip_b" and none of its 25 vertices binds it; the weights reference "box", "grip_a"`. Those three are one sentence about rigc's own generators: the bone set a generated mesh declares is the bone set its weights reference, so a `controls` or `chain` name that moves nothing is a defect where a foreign mesh's is not. Fix the rig spec's `controls`/`chain`, a `segments` generator's `bones` (its `influence` line names a bone no vertex binds), or the manifest's `control_bones`. **SKIP** when the skeleton carries no mesh attachment |
6633
6736
  | <a id="A21_MESH_RIM_PINNED"></a>`A21_MESH_RIM_PINNED` | archetype | a generated ring's rim, a ribbon's entry row, or a contour's outline (which is all of it) is not pinned to its anchor bone at weight 1. **SKIPs** by name on authored or linked geometry and on a `segments` mesh, whose outline is weighted by distance like the rest of it — none of them claims a pinned rim |
6634
6737
  | <a id="A22_MESH_UVS_IN_UNIT_RANGE"></a>`A22_MESH_UVS_IN_UNIT_RANGE` | both | a mesh UV outside its region, or a UV array that disagrees with the vertex count. **SKIP** when the skeleton carries no mesh attachment |
6635
- | <a id="A23_PHYSICS_CONSTRAINT_EFFECTIVE"></a>`A23_PHYSICS_CONSTRAINT_EFFECTIVE` | both | a physics constraint that drives no component, rests at `mix: 0` with **no timeline in any animation keying that `mix` above 0**, has `mass: 0`, has `strength` at or below 0 — `0` says `nothing pulls it back`, below 0 says the offset `is pushed away and grows with every step`, both read off the row's `outside` arms, which the key's refusal quotes too — or has `damping` outside `[0, 1]`, which says `` physics "C" has damping 1.5; must be inside [0, 1] — the per-step decay is `damping ** (60 * step)`, and the runtime runs this value finitely, so refusing it is rigc's call rather than the runtime's: above 1 every velocity grows on every step and the offset diverges ``, the bound read off the row the key's refusal reads; `1` and `0` are inside, since both are finite at every rate — **at rest, and on every physics timeline key**. The timeline arm reads each key through the runtime's own `PhysicsConstraint*Timeline.set`, so a keyed `mass` is judged as the `massInverse` it becomes, and the detail names the animation, the constraint, the key time, the value and the bound. Two differences between the two arms, and the runtime is the reason for both: a **key** of `mix: 0` is accepted, because `update` opens with `if (mix === 0) return;` and muting a constraint for a stretch is what a mix timeline is for — the editor's own `sack-pro` example keys it there on 24 of its 36 mix keys — and a **key** of `strength: 0` is accepted, because it releases the constraint for the span with `damping` and `inertia` still applied and the next key pulls the offset back, measured through spine-core at no NaN, a coast to a limit and a return in 54 steps. As a **setup** value `strength: 0` is still refused by the arm above, and `mix: 0` is refused only when nothing keys it above 0. The `mix` branch above is why `mix` is the one setup value a key can answer for: at rest the constraint is **inert** rather than broken, so a rig that rests muted and is keyed above 0 is refused by nothing, while a rig resting at `mass: 0` is `massInverse` Infinity before anything plays and no key reaches back into that. The detail of the refusal says both halves and how many animations were searched: `` physics "C" has mix 0 and none of the 3 animations keys its mix above 0; the runtime runs this value finitely, so refusing it is rigc's call rather than the runtime's: at 0 `update` returns before it does anything (`PhysicsConstraint.js:109-111`), so the constraint is muted — rest it above 0, or key its mix above 0 in an animation ``. ⚠️ Every reason A23 prints for a setup value is that value's row `basis` arm (§4.4's table) — an arithmetic arm names its expression (`physics "C" has massInverse Infinity; mass must be > 0 — at 0 …`), a behavioural one says it is rigc's call and what the value does. A setup `mix` **below** 0 is told the jiggle is applied inverted, not that it is muted: such a constraint is measured moving its bone by exactly the opposite of a positive mix. The search counts the unnamed global timeline for every constraint whose own `mixGlobal` is set, reads each key through the runtime's accessor, counts every sample of a Bezier between two keys as a value the timeline poses — so two keys of 0 joined by a curve lifted above 0 are a rescue, measured to move the bone — and takes an animation a slider applies like any other. It is the one reading `A36` and `A37` use as well. `inertia`, `wind`, `gravity` and the top of `mix` are bounded nowhere, at rest or keyed. `ingest` does not carry a constraint that drives no component into the spec it writes: it omits it with its timelines and reports `PHYSICS_DRIVES_NOTHING` ([INGEST §2.0](INGEST.md)), so this sentence is met on a file, never on a decompiled rebuild. 🦴 **A lever drive on a bone with no lever** (issue #1195): a constraint driving `rotate`, `shearX` or `scaleX` on a bone whose `length` is 0 (or states none) is refused, at rest, with one sentence per reading. `rotate` and `shearX` chase the bone's tip, so with no tip the solver aims the bone at a **world** direction — measured through rigc's poser on a chain held still for 3 s, a length-0 bone turns 53.204° from a 90° rest and holds there, where length 0.01 moves 0.0000: `` physics "C" drives rotate on bone "B" whose length is 0 — with no tip the solver aims the bone at world angle 0 and holds it there; give "B" a length or drive x/y instead ``. The rest angle is not read: a bone resting at world 0° does not move, but only until a key or a parent turns it. `scaleX` divides the motion along the bone by its length and adds nothing at 0, so the drive does nothing: `` physics "C" drives scaleX on bone "B" whose length is 0, which the solver divides the motion by, so it drives nothing; give "B" a length ``. Fix in the **rig spec**: give the bone its `length` (§3.2), measured off the art it carries, or, for the first sentence, drive the constraint in `x`/`y` in the **motion spec** instead. `x` and `y` read the bone's origin and never its tip, so a constraint driving only those on a length-0 bone is not refused; the editor's own example exports carry them there. The Spine editor's export drops `rotate`, `scaleX` and `shearX` from a physics constraint on a zero-length bone and keeps them on any bone with a length — measured on 4.3.23 and 4.3.26, issue #1196 — so what this clause refuses is also what the editor would silently lose. **SKIP** when the skeleton declares no physics constraint — the same sentence `A36` and `A37` print for their own constraint types |
6738
+ | <a id="A23_PHYSICS_CONSTRAINT_EFFECTIVE"></a>`A23_PHYSICS_CONSTRAINT_EFFECTIVE` | both | a physics constraint that drives no component, rests at `mix: 0` with **no timeline in any animation keying that `mix` above 0**, has `mass: 0`, has `strength` at or below 0 — `0` says `nothing pulls it back`, below 0 says the offset `is pushed away and grows with every step`, both read off the row's `outside` arms, which the key's refusal quotes too — or has `damping` outside `[0, 1]`, which says `` physics "C" has damping 1.5; must be inside [0, 1] — the per-step decay is `damping ** (60 * step)`, and the runtime runs this value finitely, so refusing it is rigc's call rather than the runtime's: above 1 every velocity grows on every step and the offset diverges ``, the bound read off the row the key's refusal reads; `1` and `0` are inside, since both are finite at every rate — **at rest, and on every physics timeline key**. The timeline arm reads each key through the runtime's own `PhysicsConstraint*Timeline.set`, so a keyed `mass` is judged as the `massInverse` it becomes, and the detail names the animation, the constraint, the key time, the value and the bound. Two differences between the two arms, and the runtime is the reason for both: a **key** of `mix: 0` is accepted, because `update` opens with `if (mix === 0) return;` and muting a constraint for a stretch is what a mix timeline is for — the editor's own `sack-pro` example keys it there on 24 of its 36 mix keys — and a **key** of `strength: 0` is accepted, because it releases the constraint for the span with `damping` and `inertia` still applied and the next key pulls the offset back, measured through spine-core at no NaN, a coast to a limit and a return in 54 steps. As a **setup** value `strength: 0` is still refused by the arm above, and `mix: 0` is refused only when nothing keys it above 0. The `mix` branch above is why `mix` is the one setup value a key can answer for: at rest the constraint is **inert** rather than broken, so a rig that rests muted and is keyed above 0 is refused by nothing, while a rig resting at `mass: 0` is `massInverse` Infinity before anything plays and no key reaches back into that. The detail of the refusal says both halves and how many animations were searched: `` physics "C" has mix 0 and none of the 3 animations keys its mix above 0; the runtime runs this value finitely, so refusing it is rigc's call rather than the runtime's: at 0 `update` returns before it does anything (`PhysicsConstraint.js:109-111`), so the constraint is muted — rest it above 0, or key its mix above 0 in an animation ``. ⚠️ Every reason A23 prints for a setup value is that value's row `basis` arm (§4.4's table) — an arithmetic arm names its expression (`physics "C" has massInverse Infinity; mass must be > 0 — at 0 …`), a behavioural one says it is rigc's call and what the value does. A setup `mix` **below** 0 is told the jiggle is applied inverted, not that it is muted: such a constraint is measured moving its bone by exactly the opposite of a positive mix. The search counts the unnamed global timeline for every constraint whose own `mixGlobal` is set, reads each key through the runtime's accessor, counts every sample of a Bezier between two keys as a value the timeline poses — so two keys of 0 joined by a curve lifted above 0 are a rescue, measured to move the bone — and takes an animation a slider applies like any other. It is the one reading `A36` and `A37` use as well. `inertia`, `wind`, `gravity` and the top of `mix` are bounded nowhere, at rest or keyed. `ingest` does not carry a constraint that drives no component into the spec it writes: it omits it with its timelines and reports `PHYSICS_DRIVES_NOTHING` ([INGEST §2.0](INGEST.md)), so this sentence is met on a file, never on a decompiled rebuild. 🦴 **A lever drive on a bone with no lever** (issue #1195): a constraint driving `rotate`, `shearX` or `scaleX` on a bone whose `length` is 0 (or states none) is refused, at rest, with one sentence per reading. `rotate` and `shearX` chase the bone's tip, so with no tip the solver aims the bone at a **world** direction — measured through rigc's poser on a chain held still for 3 s, a length-0 bone turns 53.204° from a 90° rest and holds there, where length 0.01 moves 0.0000: `` physics "C" drives rotate on bone "B" whose length is 0 — with no tip the solver aims the bone at world angle 0 and holds it there; give "B" a length or drive x/y instead ``. The rest angle is not read: a bone resting at world 0° does not move, but only until a key or a parent turns it. `scaleX` divides the motion along the bone by its length and adds nothing at 0, so the drive does nothing: `` physics "C" drives scaleX on bone "B" whose length is 0, which the solver divides the motion by, so it drives nothing; give "B" a length ``. Fix in the **rig spec**: give the bone its `length` (§3.2), measured off the art it carries, or, for the first sentence, drive the constraint in `x`/`y` in the **motion spec** instead. `x` and `y` read the bone's origin and never its tip, so a constraint driving only those on a length-0 bone is not refused; the editor's own example exports carry them there. The Spine editor's export drops `rotate`, `scaleX` and `shearX` from a physics constraint on a zero-length bone and keeps them on any bone with a length — measured on 4.3.23 and 4.3.26, issue #1196 — so what this clause refuses is also what the editor would silently lose. 🧮 **A step that does not settle** (issue #1416): a constraint that drives anything, every value inside its own row, is refused when `strength·massInverse·step² ≥ 2·(1 + damping^(60·step))` with `step = 1 / fps` — the integrator's step map then has an eigenvalue on or outside the unit circle, and [measured] of 270 generated rigs, all 115 past the bound ran past 10⁶ units under a unit gust, all 145 under it stayed bounded, and the 10 exactly on it were still growing or swinging their tip the bone's full length when a 6 s walk ended. It reads the setup values, and for each animation keying `strength`, `mass` or `damping` on the constraint, the stiffest strength, the lightest mass and the smallest damping that animation poses (each key, each Bézier sample, and the setup value where the animation keys that value first after t = 0), judged together — an upper bound on any pose the animation reaches. Both sides are formed in the runtime's own order (`m = step · massInverse`, `damping ** (60 · step)`) and printed apart: `` physics "C" has strength 100, mass 1 (massInverse 1), fps 5, damping 0.85 — strength·massInverse·step² = 4.0000 must be < 2·(1 + damping^(60·step)) = 2.2845: at or past that bound the step stops settling — one step can multiply the offset by 2.807 every 1/5 s — so a push (wind, gravity, a key, the bone moving) never dies out, and past the bound it grows without limit; lower strength, raise mass, raise fps or raise damping ``; a keyed combination opens `` animation "A" can pose physics "C" at strength … `` and names the key each value came from. Fix in the **motion spec**'s physics table or its keys (§4.6). **SKIP** when the skeleton declares no physics constraint — the same sentence `A36` and `A37` print for their own constraint types |
6636
6739
  | <a id="A24_AXIS_SPACE_STROKE"></a>`A24_AXIS_SPACE_STROKE` | archetype | a bone under the rig's `axisBone` was keyed with a screen-space Y component, or the axis bone itself was keyed. **SKIP** when the rig declares no axis bone, and also when no animation keys that bone or anything under it |
6637
6740
  | <a id="A25_DETACHED_BONE_PARENTAGE"></a>`A25_DETACHED_BONE_PARENTAGE` | archetype | a bone the rig declares `detached` is a descendant of the bone it must never hang under |
6638
6741
  | <a id="A26_SLOT_DRAW_ORDER"></a>`A26_SLOT_DRAW_ORDER` | archetype | the emitted slots are not the rig's slot table — a slot is out of order, is not in the table at all, or is in the table and missing from the skeleton (§3.3). **SKIP** when the rig declares no canonical slot order. ⚠️ A skeleton with **no** slot beside a rig that declares some is **not** a skip, and it is the one rule in this family where an empty loop is not a vacuous pass: the completeness clause reads it as every declared slot lost and names them |
@@ -7487,6 +7590,100 @@ worst frame framed to it:
7487
7590
  fills the folded triangles at that pose, frames the picture to their box, and lists
7488
7591
  them with the same box and area in its legend (§13).
7489
7592
 
7593
+ ### 8.4 The world the physics answers — `render --environment`
7594
+
7595
+ A physics constraint's `wind` and `gravity` are its **response** (§4.6); the world
7596
+ it responds to — the two directions spine-core keeps on its `Skeleton` — belongs to
7597
+ whoever plays the rig. A render has no player, so without this flag it draws every
7598
+ frame in the runtime's initial world, wind `[1, 0]` and gravity `[0, 1]`.
7599
+ `--environment` hands it one:
7600
+
7601
+ ```bash
7602
+ bun cli.ts render --candidate path/to/spine --environment gust.json [--animation …] [--geometry] [--poser core|spine]
7603
+ ```
7604
+
7605
+ ```json
7606
+ {
7607
+ "spec": "rigc-environment/1",
7608
+ "steps": [
7609
+ { "t": 0, "wind": [0, 0] },
7610
+ { "t": 1, "wind": [1.5, -0.4] },
7611
+ { "t": 2, "wind": [0, 0] }
7612
+ ]
7613
+ }
7614
+ ```
7615
+
7616
+ **What a step means.** From its `t`, in seconds, until the next step, the world is
7617
+ changed by the halves it states — `wind`, `gravity`, or both — and a half it leaves
7618
+ out keeps the one standing, as a live track's `setEnvironment` keeps it. Both are
7619
+ the runtime's own fields in the runtime's convention: x to the right, **y down** (a
7620
+ positive y pulls toward the bottom of the frame, as gravity `[0, 1]` does). Before
7621
+ the first step the world is the runtime's initial one, so a calm start is stated —
7622
+ `"wind": [0, 0]` at `t` 0 — rather than assumed. Each set starts the schedule at its
7623
+ own frame 0.
7624
+
7625
+ **When it lands.** A step's change is set before the step that poses the first
7626
+ frame `i` whose time `i / fps` is at or after its `t`, so the physics integrates the
7627
+ new world over that frame's whole interval and the frame before it is untouched.
7628
+ Frame 0 is the reset pose; a step at `t` 0 is set before it. A `t` that is a frame's
7629
+ own time — `k / fps` — lands on frame `k`.
7630
+
7631
+ **Both posers, one world.** The core sets each change on its physics before the
7632
+ walk's step; spine-core's poser sets the same values on its `Skeleton` (`windX,
7633
+ windY, gravityX, gravityY`) before the same update. The repository's selftest
7634
+ renders three rigs — one answering wind and gravity on every branch of the physics
7635
+ step, gallery/look with its whip answering wind, and a fixture answering gravity
7636
+ alone — under a calm → gust → calm schedule through both, and holds every PNG,
7637
+ `geometry.json` and `frames.json` equal (`RE01`); holds that the gust moves the rig
7638
+ from its own frame and no earlier (`RE02`); and plants on the core the readings the
7639
+ mapping rejects — the schedule ignored, its y read up, each change a frame late or
7640
+ early — each red against spine-core (`RE03`).
7641
+
7642
+ **The files.** `frames.json` and each `geometry.json` record the schedule as
7643
+ `environment`, its steps as read, `t`, `wind`, `gravity` in that order. The
7644
+ framing reads it too: a gust can carry a coat past the box a still rig fills, so
7645
+ the box is the box of what the frames under the schedule draw — and the grid can
7646
+ differ from the same render without the flag. Compare the two in world units, in
7647
+ `geometry.json`. Without the flag nothing is set and every file is the bytes it
7648
+ always was; the runtime's own world stated at `t` 0 draws the same pixels and
7649
+ geometry as no flag at all (`RE04`). `check` poses its candidate in no world but
7650
+ the runtime's, so a frame set drawn under a schedule is refused as a reference by
7651
+ name rather than scored.
7652
+
7653
+ **Refused by name**, exit 2, nothing written — each is a render that would print a
7654
+ plausible frame set showing nothing the schedule asked for (`RE05`):
7655
+
7656
+ - a path with nothing at it: `--environment <path>: nothing at <abs path>`;
7657
+ - a file that is not one: `not JSON — …`, `the file holds <what>, not an object …`,
7658
+ `"spec" is <found>; render reads "rigc-environment/1"`, `the file names "<key>",
7659
+ which is not one of [spec, steps]`, `"steps" is <found>, not a non-empty array …`;
7660
+ - an entry, by its index: `entry <i> of "steps" names "<key>", which is not one of
7661
+ [t, wind, gravity]`; `…'s "t" is <found>, not a finite time in seconds at or above
7662
+ 0`; `…'s "t" is <found>, not after entry <i-1>'s <t> — steps are listed in
7663
+ ascending time, each holding until the next`; `…'s "wind" is <found>, not a pair
7664
+ of finite numbers [x, y] (x to the right, y down)` (`gravity` alike; a number the
7665
+ JSON reader makes infinite, `1e999`, is shown as `Infinity`); `… states neither
7666
+ "wind" nor "gravity", so it changes nothing`;
7667
+ - a schedule this rig would not draw: a skeleton with no animation (its one frame
7668
+ is the setup pose, where no physics step runs) or no physics constraint; a half
7669
+ the schedule changes that no physics constraint answers — `entry <i> changes
7670
+ wind, and no physics constraint answers it — [<names>] each state wind 0 and no
7671
+ animation keys it`; two steps on one frame of the render's grid —
7672
+ `entries [<i>, <j>] (t …) land on one frame at <fps> fps — frame <k>, t=…s — so
7673
+ entry <i> would never be posed`; and a step after the last frame of every set
7674
+ drawn.
7675
+
7676
+ **What it is, and what it is not.** It is an inspection of the response the rig
7677
+ states — what the Spine export carries, posed in a world you chose, on either
7678
+ poser. It is not a scene: when a gust blows, how strong, and what else moves is the
7679
+ consumer's to compose, and a schedule here is a probe of the object, not a
7680
+ direction of it. Moving the rig is left out on purpose: `physicsTranslate` and
7681
+ `physicsRotate` are a displacement since the last pose, which a step held over a
7682
+ span would have to restate as a velocity — a second meaning the live track does
7683
+ not have — and a render draws the rig where it stands, so the picture would show
7684
+ a coat trailing a rig that never moves. The live track holds both to spine-core
7685
+ (`CO56`), and a player forwards them as §4.6 says.
7686
+
7490
7687
  ---
7491
7688
 
7492
7689
  ## 9. Checking against the frames — `rigc check`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spine-rigc",
3
- "version": "2.52.0",
3
+ "version": "2.54.0",
4
4
  "description": "AI-authored 2D rigging and animation, verified before it is written. rigc compiles a rig spec into skeleton data in the Spine 4.3 format, gates it with named assertions held to a spine-core round trip's verdicts, and emits nothing that fails. Ships as an agent skill.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -24,7 +24,9 @@ import {
24
24
  physicsKeyRefusal,
25
25
  physicsOutsideSays,
26
26
  physicsRuleFor,
27
+ physicsStepStability,
27
28
  type PhysicsPoseRule,
29
+ type PhysicsStepStability,
28
30
  } from '../../timelines.ts';
29
31
 
30
32
  /**
@@ -165,6 +167,9 @@ export function a23PhysicsConstraintEffective({ fail, skip, stats }: Verdicts, f
165
167
  });
166
168
  }
167
169
  let mutedUntilKeyed = 0;
170
+ // Each constraint whose setup values the stability clause read, by position — the
171
+ // floor every animation's combination is taken from below.
172
+ const setupCombos = new Map<number, StabilityCombo>();
168
173
  facts.constraints.forEach((constraint, index) => {
169
174
  const physics = constraint.physics;
170
175
  if (physics === undefined) return;
@@ -245,6 +250,24 @@ export function a23PhysicsConstraintEffective({ fail, skip, stats }: Verdicts, f
245
250
  if (physics.step <= 0 || !Number.isFinite(physics.step)) {
246
251
  fail('A23_PHYSICS_CONSTRAINT_EFFECTIVE', `${where} has step ${physics.step} (fps must be > 0)`);
247
252
  }
253
+ // --- the step itself has to settle (issue #1416, part B) ------------------
254
+ //
255
+ // The rows above judge each value against its own interval; this is the one
256
+ // joint condition, `physicsStepStability`'s. It is read only where the rows
257
+ // it combines all hold — a value its own row refuses is named there, and a
258
+ // second line about the same number would be the same fault twice — and
259
+ // only on a constraint that drives something, which the first clause names
260
+ // otherwise.
261
+ if (components.length && stableInputs(pose, physics.step)) {
262
+ const setupCombo: StabilityCombo = {
263
+ strength: { value: pose.strength, from: 'setup' },
264
+ massInverse: { value: pose.massInverse, from: 'setup' },
265
+ damping: { value: pose.damping, from: 'setup' },
266
+ };
267
+ const at = physicsStepStability(pose.strength, pose.massInverse, pose.damping, physics.step);
268
+ if (!at.stable) fail('A23_PHYSICS_CONSTRAINT_EFFECTIVE', `${where} has ${runawaySays(setupCombo, physics.step, at)}`);
269
+ setupCombos.set(index, setupCombo);
270
+ }
248
271
  });
249
272
  // What the PASS would otherwise not say: this rig rests with physics off
250
273
  // on that many constraints and an animation is what switches them on. A
@@ -302,4 +325,155 @@ export function a23PhysicsConstraintEffective({ fail, skip, stats }: Verdicts, f
302
325
  }
303
326
  }
304
327
  stats.physicsTimelineKeys = keysRead;
328
+
329
+ // --- the step has to settle on every pose an animation reaches (#1416) ----
330
+ //
331
+ // 🔑 **Which combinations are read.** Per animation and per constraint its
332
+ // `strength`, `mass` or `damping` timelines reach (a named one, or each a
333
+ // global one reaches): the LARGEST strength, the LARGEST massInverse and the
334
+ // SMALLEST damping that animation can pose on that constraint, judged
335
+ // together. A value's candidates are every key and every Bézier sample of
336
+ // every such timeline, as the pose field it lands in (`posed`) — and the
337
+ // setup value as well wherever the animation keys that value not at all, or
338
+ // keys it first after t = 0, because before its first key a timeline poses the
339
+ // setup value. Each extreme is exact for its own value: the runtime moves
340
+ // a value linearly between those points, `massInverse` is monotone in the
341
+ // mass it inverts, and the bound is monotone in damping.
342
+ //
343
+ // ⚠️ The JOINT is an upper bound rather than a time-aligned pose: an
344
+ // animation that raises strength while it raises mass, so the ratio holds,
345
+ // is judged at the larger strength against the smaller mass. That is the
346
+ // conservative direction — no pose this animation reaches is less stable
347
+ // than the combination read — and it was chosen over evaluating the three
348
+ // curves at shared times because the facts carry each curve's values and
349
+ // not its sample times, and because a single held key crossing the bound is
350
+ // already a runaway. A line names which key or setup supplied each value, so
351
+ // a refusal of that kind says so.
352
+ //
353
+ // A combination equal to the setup's is not repeated: the setup line names
354
+ // it already. A value its own row refuses is left out of the extremes — it
355
+ // was named above, by its key.
356
+ const keyed = new Map<string, Map<number, Partial<Record<StabilityWord, Candidate[]>>>>();
357
+ for (const timeline of facts.timelines) {
358
+ if (timeline.kind !== 'physics' || !isStabilityWord(timeline.word)) continue;
359
+ const rule = physicsRuleFor(timeline.word);
360
+ if (rule === undefined) continue;
361
+ const word = timeline.word;
362
+ const values = timeline.channelValues(0);
363
+ const firstTime = timeline.frames[0]?.time ?? 0;
364
+ const candidates: Candidate[] = [];
365
+ // `channelValues` lists each key and then the Bézier samples of the segment
366
+ // it opens, so the next key's value is that key and anything else is the
367
+ // curve leaving the key before it.
368
+ let next = 0;
369
+ for (const value of values) {
370
+ const frame = timeline.frames[next];
371
+ const isKey = frame !== undefined && frame.value === value;
372
+ if (isKey) next++;
373
+ const posedValue = timeline.posed === undefined ? rule.toPose(value) : timeline.posed(value);
374
+ if (physicsKeyRefusal(rule, value, posedValue) !== null) continue;
375
+ candidates.push({
376
+ value: posedValue,
377
+ from: isKey ? `the key at t=${frame.time.toFixed(6)}s` : `the curve after the key at t=${(timeline.frames[next - 1]?.time ?? 0).toFixed(6)}s`,
378
+ });
379
+ }
380
+ const byConstraint = keyed.get(timeline.animation) ?? new Map<number, Partial<Record<StabilityWord, Candidate[]>>>();
381
+ keyed.set(timeline.animation, byConstraint);
382
+ for (const index of timeline.reach) {
383
+ const setup = setupCombos.get(index);
384
+ if (setup === undefined) continue;
385
+ const slot = byConstraint.get(index) ?? {};
386
+ byConstraint.set(index, slot);
387
+ const list = slot[word] ?? [];
388
+ list.push(...candidates);
389
+ // Before the first key the timeline poses the setup value.
390
+ if (firstTime > 0) list.push(setup[STABILITY_FIELD[word]]);
391
+ slot[word] = list;
392
+ }
393
+ }
394
+ for (const [animation, byConstraint] of keyed) {
395
+ for (const [index, slot] of byConstraint) {
396
+ const setup = setupCombos.get(index);
397
+ const physics = facts.constraints[index]?.physics;
398
+ if (setup === undefined || physics === undefined) continue;
399
+ const pick = (word: StabilityWord, worse: (a: number, b: number) => boolean): Candidate => {
400
+ const list = slot[word];
401
+ // A value this animation never keys, or keys only with values refused above, stays at setup.
402
+ if (list === undefined || list.length === 0) return setup[STABILITY_FIELD[word]];
403
+ return list.reduce((best, one) => (worse(one.value, best.value) ? one : best));
404
+ };
405
+ const combo: StabilityCombo = {
406
+ strength: pick('strength', (a, b) => a > b),
407
+ massInverse: pick('mass', (a, b) => a > b),
408
+ damping: pick('damping', (a, b) => a < b),
409
+ };
410
+ if (combo.strength.value === setup.strength.value && combo.massInverse.value === setup.massInverse.value && combo.damping.value === setup.damping.value) continue;
411
+ const at = physicsStepStability(combo.strength.value, combo.massInverse.value, combo.damping.value, physics.step);
412
+ if (at.stable) continue;
413
+ fail(
414
+ 'A23_PHYSICS_CONSTRAINT_EFFECTIVE',
415
+ `animation "${animation}" can pose physics "${facts.constraints[index]?.name ?? `#${index}`}" at ${runawaySays(combo, physics.step, at)}`,
416
+ );
417
+ }
418
+ }
419
+ }
420
+
421
+ /** The three timelines whose values the stability clause combines. */
422
+ type StabilityWord = 'strength' | 'mass' | 'damping';
423
+ const STABILITY_FIELD: Record<StabilityWord, keyof StabilityCombo> = { strength: 'strength', mass: 'massInverse', damping: 'damping' };
424
+ function isStabilityWord(word: string): word is StabilityWord {
425
+ return word === 'strength' || word === 'mass' || word === 'damping';
426
+ }
427
+
428
+ /** One value the stability clause read, and where it came from: `setup`, or a key or curve of the animation. */
429
+ interface Candidate {
430
+ readonly value: number;
431
+ readonly from: string;
432
+ }
433
+
434
+ /** The three pose values the stability clause judges together. */
435
+ interface StabilityCombo {
436
+ readonly strength: Candidate;
437
+ readonly massInverse: Candidate;
438
+ readonly damping: Candidate;
439
+ }
440
+
441
+ /** Whether every value the stability clause combines is inside its own row, so the joint condition is the only one left to read. */
442
+ function stableInputs(pose: PhysicsSetup, step: number): boolean {
443
+ if (!(step > 0) || !Number.isFinite(step)) return false;
444
+ return PHYSICS_POSE_RULES.every((rule) => rule.timeline === 'mix' || rule.poseOk(pose[rule.field]));
445
+ }
446
+
447
+ /** A number as an author typed it: `1 / (1 / 45)` prints 45 rather than its last-bit neighbour. */
448
+ function plain(value: number): string {
449
+ return String(Number(value.toPrecision(12)));
450
+ }
451
+
452
+ /**
453
+ * The stability clause's sentence: the four authored numbers, `k` and the bound
454
+ * as the runtime forms them, what the step does at that pose, and the four
455
+ * levers that move it back under the bound.
456
+ */
457
+ function runawaySays(combo: StabilityCombo, step: number, at: PhysicsStepStability): string {
458
+ const src = (c: Candidate): string => (c.from === 'setup' ? '' : ` (${c.from})`);
459
+ const fps = plain(1 / step);
460
+ const places = apart(at.k, at.bound, 4);
461
+ return (
462
+ `strength ${combo.strength.value}${src(combo.strength)}, mass ${plain(1 / combo.massInverse.value)} (massInverse ${combo.massInverse.value})${src(combo.massInverse)}, ` +
463
+ `fps ${fps}, damping ${combo.damping.value}${src(combo.damping)} — strength·massInverse·step² = ${at.k.toFixed(places)} must be < ` +
464
+ `2·(1 + damping^(60·step)) = ${at.bound.toFixed(places)}: at or past that bound the step stops settling — one step can ` +
465
+ `multiply the offset by ${at.growth.toFixed(apart(at.growth, 1, 3))} every 1/${fps} s — so a push (wind, gravity, a key, the ` +
466
+ 'bone moving) never dies out, and past the bound it grows without limit; lower strength, raise mass, raise fps or raise damping'
467
+ );
468
+ }
469
+
470
+ /**
471
+ * The fewest decimal places, from `min`, at which `a` and `b` print apart — so
472
+ * a value one part in 10⁹ past the bound does not print as equal to it. Two
473
+ * equal numbers print at `min`.
474
+ */
475
+ function apart(a: number, b: number, min: number): number {
476
+ if (a === b) return min;
477
+ for (let places = min; places < 17; places++) if (a.toFixed(places) !== b.toFixed(places)) return places;
478
+ return 17;
305
479
  }
package/src/check.ts CHANGED
@@ -1286,6 +1286,18 @@ export function checkAgainstFrames(options: CheckOptions): CheckReport {
1286
1286
  `${options.skin === undefined ? 'with no --skin' : `with --skin ${JSON.stringify(options.skin)}`}.`,
1287
1287
  );
1288
1288
  }
1289
+ // A frame set drawn under `render --environment` (issue #1416) is a picture of the rig in a world `check` does not
1290
+ // pose: it poses the candidate under the runtime's own wind and gravity, so the score would be a number about the
1291
+ // difference between two worlds. Refused by name, as a subset is, rather than scored.
1292
+ const referenceEnvironment = located.sidecar?.environment;
1293
+ if (referenceEnvironment !== undefined) {
1294
+ throw new CheckError(
1295
+ `${FRAMES_SIDECAR} records that these frames were rendered under an environment schedule (\`rigc render ` +
1296
+ `--environment\`, ${Array.isArray(referenceEnvironment) ? referenceEnvironment.length : 0} step(s)), and check poses the candidate ` +
1297
+ "under none — the runtime's own wind [1, 0] and gravity [0, 1] — so the comparison would be a number about the " +
1298
+ 'difference between two worlds. Render the reference frames without --environment.',
1299
+ );
1300
+ }
1289
1301
  if (referenceSkin === null && options.skin !== undefined) {
1290
1302
  notes.push(
1291
1303
  `the candidate is posed under skin ${JSON.stringify(options.skin)} and the reference frames record no skin ` +