rig-play 1.8.1 → 1.8.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 CHANGED
@@ -103,9 +103,12 @@ default stays `dom`.
103
103
  bounds, interleaved with the rigid `<img>` slots in one stacking context — the DOM
104
104
  handles the bones, a rasterizer handles the warps
105
105
  - ✅ Blend modes via `mix-blend-mode` (additive = `plus-lighter`)
106
- - ✅ Crack-free mesh seams on clip-antialiasing browsers (Safari): each triangle's
107
- clip polygon is expanded 0.5px from its centroid so neighbours overlap — the
108
- texture is continuous across shared edges, so the overlap is invisible
106
+ - ✅ Crack-free mesh seams on the canvas2d backend: canvas2d antialiases each
107
+ triangle's clip edge, so two triangles sharing an edge each leave it partly
108
+ transparent and the background shows through as a hairline — plainest over a
109
+ light background behind light art (#104). Each edge of a triangle's clip
110
+ polygon is moved 0.5px outward along its own normal so neighbours overlap —
111
+ the texture is continuous across shared edges, so the overlap is invisible
109
112
  (`?expand=0` shows the cracks for comparison)
110
113
  - ✅ RGB tinting (skeleton × slot × attachment color) via an SVG `feColorMatrix`
111
114
  reference filter per element — an exact channel multiply that works identically on
@@ -587,8 +590,8 @@ onto shared pages instead. Both play here, unchanged:
587
590
  heavy deforming scenes on Safari want `'webgl'` (see Measured above). Falls back
588
591
  to canvas2d automatically when WebGL is unavailable. Switching re-rasters every
589
592
  mesh once (no reallocation), so it is fine to expose as a user setting.
590
- - `renderer.triangleExpand` — clip overdraw in px that closes antialiased mesh
591
- seams (default 0.5). Also re-rasters every mesh once when changed.
593
+ - `renderer.triangleExpand` — how far (canvas px) each triangle edge's clip is
594
+ moved outward to close antialiased mesh seams (default 0.5). Also re-rasters every mesh once when changed.
592
595
  - `renderer.clipping` — apply the clips the frame carries (default `true`).
593
596
  Which slots a clip covers is decided where the frame is made — the player's
594
597
  adapter walks the draw order the way the runtime's draw loop does (one clip in
@@ -82,9 +82,10 @@ export declare class DomRenderer {
82
82
  /** Triangles rasterized last frame. */
83
83
  triangleCount: number;
84
84
  /**
85
- * How far (px) each triangle's clip polygon is expanded from its centroid.
86
- * Closes antialiased-clip cracks between adjacent triangles (Safari);
87
- * set to 0 to see them.
85
+ * How far (canvas px) each edge of a triangle's clip polygon is moved
86
+ * outward along its normal. Closes the antialiased-clip cracks between
87
+ * adjacent triangles, through which the background shows (#104); set to 0
88
+ * to see them.
88
89
  */
89
90
  triangleExpand: number;
90
91
  /**
@@ -294,9 +295,10 @@ export declare class DomRenderer {
294
295
  * texel of bilinear support is added, and the result is floor/ceil'd to texel
295
296
  * boundaries (so the sub-rect itself resamples nothing) and clamped to the
296
297
  * page. A fixed pad would not do: the texture-space reach of the expansion is
297
- * `triangleExpand` times the local texels-per-canvas-unit, which on the
298
- * demo's own meshes ranges from ~0.26 texels on a typical triangle to ~8.6 on
299
- * a foreshortened one. Under-padding lets the rim of the overdraw sample
298
+ * `triangleExpand` times the local texels-per-canvas-unit (up to
299
+ * `MITRE_LIMIT` times that at a sharp corner), which on the demo's own meshes
300
+ * ranged from ~0.26 texels on a typical triangle to ~8.6 on a foreshortened
301
+ * one. Under-padding lets the rim of the overdraw sample
300
302
  * nothing, which brings back the very seams the overdraw exists to close.
301
303
  *
302
304
  * No half-texel offset is applied to the incoming u/v: the `(i + 0.5) / size`
@@ -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;AAiH/C;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,qBAAa,WAAW;IAmIpB,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,YAAY;IAC7B,OAAO,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6EAA6E;IAC7E,OAAO,CAAC,eAAe,CAAM;IAE7B;;;;;;;;;OASG;gBAEgB,IAAI,EAAE,WAAW,EACjB,YAAY,EAAE,WAAW,CAAC,MAAM,EAAE,WAAW,CAAC,EAC9C,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
@@ -6845,13 +6845,41 @@ function getMeshGlBlitter() {
6845
6845
  const regionVertices = new Float32Array(8);
6846
6846
  const SVG_NS = "http://www.w3.org/2000/svg";
6847
6847
  let tintFilterSeq = 0;
6848
- function expandPoint(x, y, cx, cy, amount) {
6849
- const dx = x - cx;
6850
- const dy = y - cy;
6851
- const len = Math.sqrt(dx * dx + dy * dy);
6852
- if (len < 1e-6) return [x, y];
6853
- const s = amount / len;
6854
- return [x + dx * s, y + dy * s];
6848
+ const MITRE_LIMIT = 4;
6849
+ const offsetCorners = new Float64Array(6);
6850
+ function offsetTriangle(x0, y0, x1, y1, x2, y2, amount) {
6851
+ const out = offsetCorners;
6852
+ out[0] = x0;
6853
+ out[1] = y0;
6854
+ out[2] = x1;
6855
+ out[3] = y1;
6856
+ out[4] = x2;
6857
+ out[5] = y2;
6858
+ const area = (x1 - x0) * (y2 - y0) - (x2 - x0) * (y1 - y0);
6859
+ if (amount === 0 || area === 0) return out;
6860
+ const sign = area > 0 ? 1 : -1;
6861
+ let len = Math.hypot(x1 - x0, y1 - y0);
6862
+ const n0x = (y1 - y0) / len * sign, n0y = -(x1 - x0) / len * sign;
6863
+ len = Math.hypot(x2 - x1, y2 - y1);
6864
+ const n1x = (y2 - y1) / len * sign, n1y = -(x2 - x1) / len * sign;
6865
+ len = Math.hypot(x0 - x2, y0 - y2);
6866
+ const n2x = (y0 - y2) / len * sign, n2y = -(x0 - x2) / len * sign;
6867
+ offsetCorner(out, 0, n2x, n2y, n0x, n0y, amount);
6868
+ offsetCorner(out, 2, n0x, n0y, n1x, n1y, amount);
6869
+ offsetCorner(out, 4, n1x, n1y, n2x, n2y, amount);
6870
+ return out;
6871
+ }
6872
+ function offsetCorner(out, i, ax, ay, bx, by, amount) {
6873
+ const k = amount / (1 + ax * bx + ay * by);
6874
+ let dx = (ax + bx) * k, dy = (ay + by) * k;
6875
+ const reach = Math.hypot(dx, dy);
6876
+ const limit = MITRE_LIMIT * amount;
6877
+ if (reach > limit) {
6878
+ dx *= limit / reach;
6879
+ dy *= limit / reach;
6880
+ }
6881
+ out[i] += dx;
6882
+ out[i + 1] += dy;
6855
6883
  }
6856
6884
  function clipCoord(v) {
6857
6885
  return `${clipNum(v)}px`;
@@ -6931,9 +6959,10 @@ class DomRenderer {
6931
6959
  /** Triangles rasterized last frame. */
6932
6960
  triangleCount = 0;
6933
6961
  /**
6934
- * How far (px) each triangle's clip polygon is expanded from its centroid.
6935
- * Closes antialiased-clip cracks between adjacent triangles (Safari);
6936
- * set to 0 to see them.
6962
+ * How far (canvas px) each edge of a triangle's clip polygon is moved
6963
+ * outward along its normal. Closes the antialiased-clip cracks between
6964
+ * adjacent triangles, through which the background shows (#104); set to 0
6965
+ * to see them.
6937
6966
  */
6938
6967
  triangleExpand = 0.5;
6939
6968
  /**
@@ -7365,9 +7394,10 @@ class DomRenderer {
7365
7394
  * texel of bilinear support is added, and the result is floor/ceil'd to texel
7366
7395
  * boundaries (so the sub-rect itself resamples nothing) and clamped to the
7367
7396
  * page. A fixed pad would not do: the texture-space reach of the expansion is
7368
- * `triangleExpand` times the local texels-per-canvas-unit, which on the
7369
- * demo's own meshes ranges from ~0.26 texels on a typical triangle to ~8.6 on
7370
- * a foreshortened one. Under-padding lets the rim of the overdraw sample
7397
+ * `triangleExpand` times the local texels-per-canvas-unit (up to
7398
+ * `MITRE_LIMIT` times that at a sharp corner), which on the demo's own meshes
7399
+ * ranged from ~0.26 texels on a typical triangle to ~8.6 on a foreshortened
7400
+ * one. Under-padding lets the rim of the overdraw sample
7371
7401
  * nothing, which brings back the very seams the overdraw exists to close.
7372
7402
  *
7373
7403
  * No half-texel offset is applied to the incoming u/v: the `(i + 0.5) / size`
@@ -7624,11 +7654,10 @@ class DomRenderer {
7624
7654
  }
7625
7655
  }
7626
7656
  function drawTexturedTriangle(ctx, img, expand, x0, y0, u0, v0, x1, y1, u1, v1, x2, y2, u2, v2) {
7627
- const cx = (x0 + x1 + x2) / 3;
7628
- const cy = (y0 + y1 + y2) / 3;
7629
- const [px0, py0] = expandPoint(x0, y0, cx, cy, expand);
7630
- const [px1, py1] = expandPoint(x1, y1, cx, cy, expand);
7631
- const [px2, py2] = expandPoint(x2, y2, cx, cy, expand);
7657
+ const corners = offsetTriangle(x0, y0, x1, y1, x2, y2, expand);
7658
+ const px0 = corners[0], py0 = corners[1];
7659
+ const px1 = corners[2], py1 = corners[3];
7660
+ const px2 = corners[4], py2 = corners[5];
7632
7661
  ctx.beginPath();
7633
7662
  ctx.moveTo(px0, py0);
7634
7663
  ctx.lineTo(px1, py1);