spine-rigc 1.5.3 → 1.6.2
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 +2 -1
- package/cli.ts +131 -403
- package/docs/AUTHORING.md +63 -14
- package/docs/INGEST.md +1 -0
- package/docs/MOTION.md +1 -0
- package/package.json +1 -1
- package/src/atlas.ts +25 -0
- package/src/check.ts +113 -24
- package/src/checkpics.ts +2 -0
- package/src/compile.ts +641 -506
- package/src/core/animation.ts +982 -0
- package/src/core/clipping.ts +696 -0
- package/src/core/constraints.ts +1721 -0
- package/src/core/constraints_path.ts +942 -0
- package/src/core/constraints_physics.ts +830 -0
- package/src/core/constraints_slider.ts +505 -0
- package/src/core/deform.ts +613 -0
- package/src/core/draw_order.ts +125 -0
- package/src/core/events.ts +135 -0
- package/src/core/hooks.ts +249 -0
- package/src/core/index.ts +1103 -0
- package/src/core/raw.ts +347 -0
- package/src/core/skins.ts +104 -0
- package/src/core/uvs.ts +448 -0
- package/src/core/vertices.ts +490 -0
- package/src/core/world.ts +233 -0
- package/src/deformmeasure.ts +337 -73
- package/src/deformreport.ts +370 -0
- package/src/depth.ts +101 -2
- package/src/emit_spine.ts +860 -0
- package/src/mesh.ts +24 -15
- package/src/model.ts +958 -0
- package/src/render.ts +649 -143
- package/src/render_core.ts +582 -0
- package/src/rig.ts +34 -6
- package/src/transform.ts +26 -4
- package/src/types.ts +18 -0
- package/src/validate.ts +30 -2
package/src/mesh.ts
CHANGED
|
@@ -42,6 +42,7 @@
|
|
|
42
42
|
* Everything here is pure and integer-stable: same manifest in, same floats out
|
|
43
43
|
* (assertion A18 recompiles and compares bytes).
|
|
44
44
|
*/
|
|
45
|
+
import type { ModelBinding, ModelVertices } from './model.ts';
|
|
45
46
|
|
|
46
47
|
export interface MeshSpecInput {
|
|
47
48
|
/** Polygon in part-local pixels, y down, in manifest order. */
|
|
@@ -1567,44 +1568,52 @@ export function buildContourMesh(input: ContourSpecInput): MeshGeometry {
|
|
|
1567
1568
|
};
|
|
1568
1569
|
}
|
|
1569
1570
|
|
|
1570
|
-
/**
|
|
1571
|
+
/**
|
|
1572
|
+
* One bone a weighted vertex can bind to: its NAME, and its world inverse.
|
|
1573
|
+
*
|
|
1574
|
+
* It carried the bone's index into the emitted bone array until issue #917; the
|
|
1575
|
+
* index is the Spine emitter's now (`emitVertices` in `src/emit_spine.ts`), so a
|
|
1576
|
+
* binding made here names its bone and survives a bone inserted ahead of it.
|
|
1577
|
+
*/
|
|
1571
1578
|
export interface MeshBoneRef {
|
|
1572
|
-
|
|
1579
|
+
name: string;
|
|
1573
1580
|
/** Spine world point -> this bone's local space, at the setup pose. */
|
|
1574
1581
|
toBind: (worldX: number, worldY: number) => [number, number];
|
|
1575
1582
|
}
|
|
1576
1583
|
|
|
1577
1584
|
/**
|
|
1578
|
-
*
|
|
1579
|
-
*
|
|
1585
|
+
* Bind a generated mesh's vertices to their bones by name: per vertex, one
|
|
1586
|
+
* `{ bone, x, y, weight }` per influence, `x, y` the vertex in that bone's LOCAL
|
|
1587
|
+
* setup space and `weight` on the generator's grid (`r6`).
|
|
1580
1588
|
*
|
|
1581
1589
|
* Bind coordinates are in each bone's LOCAL space, so a rotated bone needs a real
|
|
1582
1590
|
* inverse transform — see `src/transform.ts` for why the old "world minus origin"
|
|
1583
1591
|
* shortcut had to go and what it would have failed like.
|
|
1584
1592
|
*
|
|
1585
|
-
*
|
|
1586
|
-
*
|
|
1587
|
-
*
|
|
1593
|
+
* Returned as the model's `ModelVertices`, weighted, and not as Spine's run: the
|
|
1594
|
+
* run's bone INDEX is written by the Spine emitter at emission (issue #917), and
|
|
1595
|
+
* the encoding it chooses by a length comparison alone is said here outright.
|
|
1596
|
+
* The caller puts the numbers on the float32 grid, as it did the run's.
|
|
1588
1597
|
*/
|
|
1589
|
-
export function
|
|
1598
|
+
export function bindWeightedVertices(
|
|
1590
1599
|
geometry: MeshGeometry,
|
|
1591
1600
|
/** Part-local pixel -> Spine world. */
|
|
1592
1601
|
toWorld: (x: number, y: number) => [number, number],
|
|
1593
1602
|
bones: { anchor: MeshBoneRef; controls: MeshBoneRef[] },
|
|
1594
|
-
):
|
|
1595
|
-
const
|
|
1603
|
+
): Extract<ModelVertices, { weighted: true }> {
|
|
1604
|
+
const bindings: ModelBinding[][] = [];
|
|
1596
1605
|
geometry.points.forEach(([px, py], i) => {
|
|
1597
1606
|
const [wx, wy] = toWorld(px, py);
|
|
1598
|
-
const
|
|
1599
|
-
|
|
1600
|
-
for (const { bone, control, weight } of vw) {
|
|
1607
|
+
const vertex: ModelBinding[] = [];
|
|
1608
|
+
for (const { bone, control, weight } of geometry.weights[i]) {
|
|
1601
1609
|
const ref = bone === 'anchor' ? bones.anchor : bones.controls[control ?? 0];
|
|
1602
1610
|
if (!ref) throw new MeshError(`vertex ${i} binds to control bone ${control ?? 0}, which the rig does not have`);
|
|
1603
1611
|
const [bx, by] = ref.toBind(wx, wy);
|
|
1604
|
-
|
|
1612
|
+
vertex.push({ bone: ref.name, x: bx, y: by, weight: r6(weight) });
|
|
1605
1613
|
}
|
|
1614
|
+
bindings.push(vertex);
|
|
1606
1615
|
});
|
|
1607
|
-
return
|
|
1616
|
+
return { weighted: true, bindings };
|
|
1608
1617
|
}
|
|
1609
1618
|
|
|
1610
1619
|
// ---------------------------------------------------------------------------
|