rig-play 1.8.2 → 1.9.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
@@ -38,7 +38,21 @@ links to either earlier name keep working.
38
38
 
39
39
  ### Measured
40
40
 
41
- Measured on the 0.x line, on the spineboy exports it then played (PoC, Apple silicon —
41
+ **The element mode's mesh backend is `'webgl'` by default since 1.9 (#109)**, read off
42
+ macOS Safari on 2026-10-13 (1.8.2, gallery rig `look-packed`: 4 meshes, 464
43
+ triangles, `sweep`; the demo's stats line after a 30 s settle; the Mac was also
44
+ serving the builds, so absolute fps is low and only the comparison is the point —
45
+ readings verbatim on #25):
46
+
47
+ | macOS Safari | 1 rig | 10 rigs (4,640 triangles) |
48
+ | --- | --: | --: |
49
+ | canvas2d mesh backend | 21–26 fps | 2–3 fps |
50
+ | webgl mesh backend | 60 fps | 58 fps |
51
+
52
+ Nothing is claimed here for mobile browsers: no phone or tablet has been measured
53
+ on the 1.x line.
54
+
55
+ The numbers below are older: measured on the 0.x line, on the spineboy exports it then played (PoC, Apple silicon —
42
56
  headless and on-device numbers are labeled, they do **not** substitute for each other).
43
57
  The renderer tiers they describe carried over; they have not been re-measured since the
44
58
  player moved to rigc's model (#60):
@@ -150,8 +164,8 @@ default stays `dom`.
150
164
  37 fps, meshed ×10 = 3–4 fps with JS flat at ~4–5 ms — put the real cost in the
151
165
  GPU process: Safari antialiases canvas2d **clip paths**, so the per-triangle clip
152
166
  mapping pays a per-triangle AA-mask tax (the same AA that caused the seam cracks)
153
- - ✅ Optional WebGL blit backend for the mesh tier: `renderer.meshBackend =
154
- 'webgl'` (default stays `'canvas2d'`). All dirty meshes are shelf-packed into
167
+ - ✅ WebGL blit backend for the mesh tier, the default since 1.9 (#109;
168
+ `renderer.meshBackend = 'canvas2d'` keeps the 2d raster). All dirty meshes are shelf-packed into
155
169
  **one shared offscreen WebGL context** (module-level — browsers cap contexts at
156
170
  ~16), drawn as textured triangles with premultiplied alpha, then rect-blitted
157
171
  onto the same per-part canvases with an unclipped `drawImage` — cheap on Safari.
@@ -586,9 +600,10 @@ onto shared pages instead. Both play here, unchanged:
586
600
  (Σ width × height), computed on demand. This is what `pixelRatio` moves
587
601
  quadratically, and the cheapest way to see an oversampling stage; the demo
588
602
  prints it in the stats line as `backing N Mpx`.
589
- - `renderer.meshBackend` — `'canvas2d'` (default) or `'webgl'`; same output, but
590
- heavy deforming scenes on Safari want `'webgl'` (see Measured above). Falls back
591
- to canvas2d automatically when WebGL is unavailable. Switching re-rasters every
603
+ - `renderer.meshBackend` — `'webgl'` (default since 1.9) or `'canvas2d'`; same
604
+ output, and on macOS Safari webgl holds 58–60 fps where canvas2d reads 2–26
605
+ (see Measured above). Falls back to canvas2d automatically when WebGL is
606
+ unavailable or the shared context is lost; `meshBackendActive` says which drew. Switching re-rasters every
592
607
  mesh once (no reallocation), so it is fine to expose as a user setting.
593
608
  - `renderer.triangleExpand` — how far (canvas px) each triangle edge's clip is
594
609
  moved outward to close antialiased mesh seams (default 0.5). Also re-rasters every mesh once when changed.
@@ -643,6 +658,30 @@ on-device (Chromium, dpr 2, stage under `scale(0.25)`, ~2.2 M CSS px on screen):
643
658
  | 92 meshes | `devicePixelRatio` (2) | 141.1 Mpx | 36–39 |
644
659
  | 92 meshes | `dpr × zoom` (0.5) | 9.1 Mpx | 60–61 |
645
660
 
661
+ ## Coming from 1.8: meshes draw through WebGL by default
662
+
663
+ From 1.9 the element mode rasterizes its meshes through the one shared WebGL
664
+ context unless told otherwise (`DomRenderer.meshBackend` defaults to `'webgl'`,
665
+ #109). The picture is the same within the parity suite's bounds, the API is
666
+ unchanged, and canvas2d is still drawn wherever WebGL is unavailable or the
667
+ context is lost. What a caller can notice:
668
+
669
+ - The page holds one more WebGL context (one for every mesh of every player, not
670
+ one per player). A page already near the browser's cap of about 16 live
671
+ contexts can lose its oldest one when this one is created.
672
+ - `meshBackendActive` reads `'webgl'` where it read `'canvas2d'`.
673
+ - Frame cost moves from the page to the GPU blit (see *Measured*).
674
+
675
+ To keep 1.8's raster, set it back, up front or on a live player:
676
+
677
+ ```ts
678
+ const player = new RigPlayer(root, assets, { meshBackend: 'canvas2d' });
679
+ // or, on a renderer you hold:
680
+ renderer.meshBackend = 'canvas2d';
681
+ ```
682
+
683
+ The canvas mode was already webgl by default and does not change.
684
+
646
685
  ## Coming from spine-html 0.8
647
686
 
648
687
  This is not a drop-in upgrade. 0.8 drew a Spine export (`.json` or `.skel`, plus its
@@ -695,7 +734,7 @@ name, and unloading is still elements first, bitmaps second.
695
734
  | `renderer.pixelRatio` | `player.renderer.pixelRatio` | On both renderers. Carried over when `player.mode` changes. |
696
735
  | `renderer.syncPixelRatio()` | `player.renderer.syncPixelRatio()` | On both renderers, the same meaning and the same deadband (since 1.3.0; before it, DOM mode only). |
697
736
  | `renderer.meshBackingPixels` | `DomRenderer.meshBackingPixels` | DOM mode only. |
698
- | `renderer.meshBackend`, `meshBackendActive`, type `MeshBackend` | `DomRenderer.meshBackend`, `meshBackendActive`, type `MeshBackend` | Same values (`'canvas2d'` default, `'webgl'`). Also settable up front as `RigPlayerOptions.meshBackend`. |
737
+ | `renderer.meshBackend`, `meshBackendActive`, type `MeshBackend` | `DomRenderer.meshBackend`, `meshBackendActive`, type `MeshBackend` | Same values; the default is `'webgl'` since 1.9 (`'canvas2d'` before). Also settable up front as `RigPlayerOptions.meshBackend`. |
699
738
  | `renderer.triangleExpand` | `DomRenderer.triangleExpand` | Same default (0.5). |
700
739
  | `renderer.clipping` | `player.renderer.clipping` | On both renderers. Carried over when `player.mode` changes. |
701
740
  | `clipCount`, `clipSkipCount`, `clipWriteCount` | same names on `DomRenderer` | `clipSkipCount` counts less than it did: a second clip met while one is in force, and a clip on an inactive bone, no longer reach the frame, so they are not counted. |
@@ -97,9 +97,9 @@ export declare class DomRenderer {
97
97
  */
98
98
  pixelRatio: number;
99
99
  /**
100
- * Rasterizer for the mesh (deform) tier. 'canvas2d' (default) maps each
101
- * triangle with clip+transform+drawImage directly on the per-part canvas.
102
- * 'webgl' rasterizes every dirty mesh into one shared offscreen WebGL
100
+ * Rasterizer for the mesh (deform) tier. 'canvas2d' maps each triangle
101
+ * with clip+transform+drawImage directly on the per-part canvas. 'webgl'
102
+ * (default) rasterizes every dirty mesh into one shared offscreen WebGL
103
103
  * canvas and rect-blits each mesh back onto its per-part canvas — the DOM
104
104
  * structure and all element-level behavior (z-index interleave, tint
105
105
  * filter, mix-blend-mode, dirty-skip) are identical, only the raster step
@@ -108,7 +108,8 @@ export declare class DomRenderer {
108
108
  * process that rAF-limits heavy scenes; GL rasterizes shared edges
109
109
  * seamlessly (no clip, no crack overdraw) and the blit is an unclipped
110
110
  * rect copy. Falls back to 'canvas2d' when WebGL is unavailable or the
111
- * shared context is lost — see meshBackendActive.
111
+ * shared context is lost — see meshBackendActive. The default since 1.9
112
+ * (#109); before it, 'canvas2d'. Set 'canvas2d' to keep the 2d raster.
112
113
  */
113
114
  meshBackend: MeshBackend;
114
115
  /** Backend that actually rasterized the mesh tier during the last render(). */
@@ -1 +1 @@
1
- {"version":3,"file":"DomRenderer.d.ts","sourceRoot":"","sources":["../src/DomRenderer.ts"],"names":[],"mappings":"AACA,OAAO,EAAmB,KAAK,WAAW,EAAuB,MAAM,iBAAiB,CAAC;AAEzF,OAAO,KAAK,EAAwB,UAAU,EAAqC,MAAM,iBAAiB,CAAC;AAE3G,kDAAkD;AAClD,MAAM,MAAM,WAAW,GAAG,UAAU,GAAG,OAAO,CAAC;AA4J/C;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,qBAAa,WAAW;IAoIpB,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,YAAY;IAC7B,OAAO,CAAC,QAAQ,CAAC,KAAK;IArIxB;;;;;;;;;;;;;;;;;;;OAmBG;IACH,QAAQ,UAAQ;IAChB,8EAA8E;IAC9E,SAAS,SAAK;IACd;;;;;OAKG;IACH,aAAa,SAAK;I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AC9C,KAAK,GAAE,WAAW,CAAC,MAAM,EAAE,gBAAgB,CAAa;IAG3E;;;;;;;;;;;OAWG;IACH,IAAI,iBAAiB,IAAI,MAAM,CAM9B;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAmCG;IACH,cAAc,IAAI,MAAM;IAKxB;;;;OAIG;IACH,MAAM,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI;IAqE/B;;;;;;;;;;;;;;;;;OAiBG;IACH,OAAO,IAAI,IAAI;IAiBf,OAAO,CAAC,YAAY;IAwCpB,OAAO,CAAC,UAAU;IAiJlB;;;;;;OAMG;IACH,OAAO,CAAC,UAAU;IAWlB,sEAAsE;IACtE,OAAO,CAAC,eAAe;IAuCvB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2DG;IACH,OAAO,CAAC,YAAY;IAWpB;;;;;;;;;;;;;OAaG;IACH,OAAO,CAAC,OAAO;IAmCf;;;;;;;;;;OAUG;IACH,OAAO,CAAC,SAAS;IAoDjB,OAAO,CAAC,WAAW;IAOnB,yEAAyE;IACzE,OAAO,CAAC,YAAY;IAUpB,OAAO,CAAC,aAAa;IAUrB,OAAO,CAAC,eAAe;IAUvB,OAAO,CAAC,YAAY;IAOpB,OAAO,CAAC,WAAW;IA4CnB,OAAO,CAAC,aAAa;IAyBrB,OAAO,CAAC,IAAI;IAmDZ,OAAO,CAAC,IAAI;CAWb"}
package/dist/index.js CHANGED
@@ -6974,9 +6974,9 @@ class DomRenderer {
6974
6974
  */
6975
6975
  pixelRatio = typeof devicePixelRatio === "number" ? devicePixelRatio : 1;
6976
6976
  /**
6977
- * Rasterizer for the mesh (deform) tier. 'canvas2d' (default) maps each
6978
- * triangle with clip+transform+drawImage directly on the per-part canvas.
6979
- * 'webgl' rasterizes every dirty mesh into one shared offscreen WebGL
6977
+ * Rasterizer for the mesh (deform) tier. 'canvas2d' maps each triangle
6978
+ * with clip+transform+drawImage directly on the per-part canvas. 'webgl'
6979
+ * (default) rasterizes every dirty mesh into one shared offscreen WebGL
6980
6980
  * canvas and rect-blits each mesh back onto its per-part canvas — the DOM
6981
6981
  * structure and all element-level behavior (z-index interleave, tint
6982
6982
  * filter, mix-blend-mode, dirty-skip) are identical, only the raster step
@@ -6985,11 +6985,12 @@ class DomRenderer {
6985
6985
  * process that rAF-limits heavy scenes; GL rasterizes shared edges
6986
6986
  * seamlessly (no clip, no crack overdraw) and the blit is an unclipped
6987
6987
  * rect copy. Falls back to 'canvas2d' when WebGL is unavailable or the
6988
- * shared context is lost — see meshBackendActive.
6988
+ * shared context is lost — see meshBackendActive. The default since 1.9
6989
+ * (#109); before it, 'canvas2d'. Set 'canvas2d' to keep the 2d raster.
6989
6990
  */
6990
- meshBackend = "canvas2d";
6991
+ meshBackend = "webgl";
6991
6992
  /** Backend that actually rasterized the mesh tier during the last render(). */
6992
- meshBackendActive = "canvas2d";
6993
+ meshBackendActive = "webgl";
6993
6994
  views = /* @__PURE__ */ new Map();
6994
6995
  /** Counts render() calls: the stamp a view drawn this frame carries (`SlotView.drawnIn`). */
6995
6996
  frameNumber = 0;