@rig-c/play 0.0.0-stage → 1.8.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.
@@ -0,0 +1,99 @@
1
+ /**
2
+ * The record the DOM tier draws: one posed moment of a rig, every slot the
3
+ * renderer shows, in draw order.
4
+ *
5
+ * The renderer never needed a skeleton. Per slot it needs the kind, four world
6
+ * corners or world vertices with page UVs and triangles, the bitmap or the
7
+ * page image with its alpha convention, a tint, a blend mode, a clip polygon
8
+ * and a stacking position — and every one of those is a field of a pose that
9
+ * `rig-c/core` computes from the compiled model document, plus that document's
10
+ * `pages` section. This module is the adapter from one to the other
11
+ * (`frameOf`), and these types are the whole of what crosses it.
12
+ *
13
+ * Coordinates are world space, Y up, exactly as the poser computed them; the
14
+ * renderer does the Y flip. Nothing here is rounded or re-ordered.
15
+ */
16
+ export interface PosedFrame {
17
+ /** Every slot that draws, in draw order. */
18
+ order: PosedSlot[];
19
+ }
20
+ /** The four blend modes, spelled as the runtime's enum names them. */
21
+ export type BlendMode = 'Normal' | 'Additive' | 'Multiply' | 'Screen';
22
+ /**
23
+ * A clip polygon in world space and whether it keeps what is outside it.
24
+ *
25
+ * One object per clip in force: every slot a clip covers carries the *same*
26
+ * object, which is how the renderer tells a clip that covers the whole frame
27
+ * (one `clip-path` on the root) from one that covers a range of it.
28
+ */
29
+ export interface PosedClip {
30
+ /** Flat x, y pairs, world space. */
31
+ polygon: number[];
32
+ inverse: boolean;
33
+ /**
34
+ * The clipping attachment's `convex` flag: a polygon that is not convex is
35
+ * clipped against its hull rather than decomposed. The DOM tier's CSS
36
+ * `clip-path` takes the polygon as authored and does not read it; the canvas
37
+ * mode's triangle cut does (`clipThrough` in `rig-c/core`).
38
+ */
39
+ convex: boolean;
40
+ }
41
+ interface PosedSlotCommon {
42
+ /** The slot's name — the renderer keys its element on it. */
43
+ slot: string;
44
+ /** The slot's index in the full draw order (hidden slots included): its z-index. */
45
+ z: number;
46
+ blend: BlendMode;
47
+ /** Slot colour × attachment colour × the player's own colour, r g b a in [0, 1]. */
48
+ tint: [number, number, number, number];
49
+ /** The slot's dark (two-colour) tint, where it carries one. The DOM tier cannot draw it. */
50
+ dark?: [number, number, number];
51
+ /** The clip in force over this slot, where one is. */
52
+ clip?: PosedClip;
53
+ }
54
+ /** A rigid slot: an unpacked region bitmap posed by its four world corners. */
55
+ export interface PosedRegion extends PosedSlotCommon {
56
+ kind: 'region';
57
+ /** The region drawn — the key into the region bitmap map (a sequence frame's own name). */
58
+ region: string;
59
+ /** Four world corners, bottom-left, upper-left, upper-right, bottom-right: x0 y0 … x3 y3. */
60
+ corners: number[];
61
+ /**
62
+ * The page the region sits on — the key into the page image map. The DOM tier
63
+ * draws the region's own bitmap and never reads it; the canvas mode samples
64
+ * the page through `uvs`.
65
+ */
66
+ page: string;
67
+ /** Whether the page's texels are premultiplied by their alpha. */
68
+ pma: boolean;
69
+ /**
70
+ * The region's page UVs at its four corners, in the corners' order (u, v
71
+ * pairs, the page spanning [0, 1]) — the runtime's region UVs, a 90°-packed
72
+ * region's turn included. The same array object from frame to frame for the
73
+ * same region.
74
+ */
75
+ uvs: number[];
76
+ }
77
+ /** A deform slot: world vertices over page UVs, rastered from the page image. */
78
+ export interface PosedMesh extends PosedSlotCommon {
79
+ kind: 'mesh';
80
+ /** The page drawn — the key into the page image map. */
81
+ page: string;
82
+ /** Whether the page's texels are premultiplied by their alpha. */
83
+ pma: boolean;
84
+ /** World vertices, flat x, y pairs. */
85
+ vertices: number[];
86
+ /**
87
+ * Page UVs, flat u, v pairs, the page spanning [0, 1]. The same array object
88
+ * from frame to frame for the same region and attachment, so the renderer
89
+ * can tell a mesh whose texture did not change by identity.
90
+ */
91
+ uvs: number[];
92
+ /** Triangle indices into `vertices`, three per triangle. Stable by identity like `uvs`. */
93
+ triangles: number[];
94
+ /** The sequence frame drawn (0 for an attachment with no series). */
95
+ sequence: number;
96
+ }
97
+ export type PosedSlot = PosedRegion | PosedMesh;
98
+ export {};
99
+ //# sourceMappingURL=posedFrame.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"posedFrame.d.ts","sourceRoot":"","sources":["../src/posedFrame.ts"],"names":[],"mappings":"AAiBA;;;;;;;;;;;;;;GAcG;AACH,MAAM,WAAW,UAAU;IACzB,4CAA4C;IAC5C,KAAK,EAAE,SAAS,EAAE,CAAC;CACpB;AAED,sEAAsE;AACtE,MAAM,MAAM,SAAS,GAAG,QAAQ,GAAG,UAAU,GAAG,UAAU,GAAG,QAAQ,CAAC;AAEtE;;;;;;GAMG;AACH,MAAM,WAAW,SAAS;IACxB,oCAAoC;IACpC,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,OAAO,EAAE,OAAO,CAAC;IACjB;;;;;OAKG;IACH,MAAM,EAAE,OAAO,CAAC;CACjB;AAED,UAAU,eAAe;IACvB,6DAA6D;IAC7D,IAAI,EAAE,MAAM,CAAC;IACb,oFAAoF;IACpF,CAAC,EAAE,MAAM,CAAC;IACV,KAAK,EAAE,SAAS,CAAC;IACjB,oFAAoF;IACpF,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IACvC,4FAA4F;IAC5F,IAAI,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,sDAAsD;IACtD,IAAI,CAAC,EAAE,SAAS,CAAC;CAClB;AAED,+EAA+E;AAC/E,MAAM,WAAW,WAAY,SAAQ,eAAe;IAClD,IAAI,EAAE,QAAQ,CAAC;IACf,2FAA2F;IAC3F,MAAM,EAAE,MAAM,CAAC;IACf,6FAA6F;IAC7F,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB;;;;OAIG;IACH,IAAI,EAAE,MAAM,CAAC;IACb,kEAAkE;IAClE,GAAG,EAAE,OAAO,CAAC;IACb;;;;;OAKG;IACH,GAAG,EAAE,MAAM,EAAE,CAAC;CACf;AAED,iFAAiF;AACjF,MAAM,WAAW,SAAU,SAAQ,eAAe;IAChD,IAAI,EAAE,MAAM,CAAC;IACb,wDAAwD;IACxD,IAAI,EAAE,MAAM,CAAC;IACb,kEAAkE;IAClE,GAAG,EAAE,OAAO,CAAC;IACb,uCAAuC;IACvC,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB;;;;OAIG;IACH,GAAG,EAAE,MAAM,EAAE,CAAC;IACd,2FAA2F;IAC3F,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,qEAAqE;IACrE,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,MAAM,SAAS,GAAG,WAAW,GAAG,SAAS,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,64 @@
1
1
  {
2
2
  "name": "@rig-c/play",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "1.8.0",
4
+ "description": "Plays skeleton.model.json written by rigc build as plain DOM elements — rigid slots as <img> posed by CSS matrix, deform meshes on small per-part canvases — or as one canvas.",
5
+ "type": "module",
6
+ "license": "MIT",
7
+ "author": "firejune",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "https://github.com/firejune/rig-play.git"
11
+ },
12
+ "homepage": "https://github.com/firejune/rig-play#readme",
13
+ "funding": {
14
+ "type": "github",
15
+ "url": "https://github.com/sponsors/firejune"
16
+ },
17
+ "bugs": "https://github.com/firejune/rig-play/issues",
18
+ "keywords": [
19
+ "rigc",
20
+ "rig-c",
21
+ "skeletal-animation",
22
+ "mesh-deformation",
23
+ "dom",
24
+ "css-transform",
25
+ "renderer",
26
+ "2d",
27
+ "animation",
28
+ "character-animation"
29
+ ],
30
+ "main": "./dist/index.js",
31
+ "types": "./dist/index.d.ts",
32
+ "exports": {
33
+ ".": {
34
+ "types": "./dist/index.d.ts",
35
+ "import": "./dist/index.js"
36
+ }
37
+ },
38
+ "files": [
39
+ "dist",
40
+ "NOTICE.md"
41
+ ],
42
+ "sideEffects": false,
43
+ "scripts": {
44
+ "predev": "bash scripts/fetch-assets.sh",
45
+ "dev": "vite",
46
+ "prebuild": "bash scripts/fetch-assets.sh",
47
+ "build": "tsc --noEmit && vite build",
48
+ "build:lib": "rm -rf dist && node scripts/build-lib.mjs dist",
49
+ "prepublishOnly": "npm run build:lib",
50
+ "preview": "vite preview",
51
+ "test": "playwright test",
52
+ "bench": "bash scripts/fetch-assets.sh && node scripts/bench.mjs",
53
+ "bench:dev": "bash scripts/fetch-assets.sh && vite --config bench/vite.config.ts",
54
+ "bench:build": "bash scripts/fetch-assets.sh && vite build --config bench/vite.config.ts",
55
+ "fetch-assets": "bash scripts/fetch-assets.sh"
56
+ },
57
+ "devDependencies": {
58
+ "@playwright/test": "1.62.1",
59
+ "@types/node": "^22",
60
+ "rig-c": "2.39.0",
61
+ "typescript": "^5.6.0",
62
+ "vite": "^6.0.0"
63
+ }
64
+ }