rig-play 1.9.0 → 1.9.1
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 +8 -1
- package/dist/CanvasRenderer.d.ts +3 -0
- package/dist/CanvasRenderer.d.ts.map +1 -1
- package/dist/DomRenderer.d.ts +12 -0
- package/dist/DomRenderer.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +28 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -607,6 +607,12 @@ onto shared pages instead. Both play here, unchanged:
|
|
|
607
607
|
mesh once (no reallocation), so it is fine to expose as a user setting.
|
|
608
608
|
- `renderer.triangleExpand` — how far (canvas px) each triangle edge's clip is
|
|
609
609
|
moved outward to close antialiased mesh seams (default 0.5). Also re-rasters every mesh once when changed.
|
|
610
|
+
- `renderer.meshSourceRect` — what a canvas2d mesh triangle is drawn from:
|
|
611
|
+
`'page'` (the whole page) or `'triangle'` (a sub-rect covering its clip). Both
|
|
612
|
+
draw the same picture; the default is `'triangle'` on Linux WebKit, which
|
|
613
|
+
garbles whole-page draws, and `'page'` elsewhere, because macOS Safari ran the
|
|
614
|
+
sub-rect 12–15% slower (#25). Also on `CanvasRenderer` for its canvas2d
|
|
615
|
+
fallback. Re-rasters every mesh once when changed.
|
|
610
616
|
- `renderer.clipping` — apply the clips the frame carries (default `true`).
|
|
611
617
|
Which slots a clip covers is decided where the frame is made — the player's
|
|
612
618
|
adapter walks the draw order the way the runtime's draw loop does (one clip in
|
|
@@ -872,7 +878,8 @@ scenes (floors 0.585–1.553%, Chromium and WebKit). The DOM tier's two mesh
|
|
|
872
878
|
backends get the same A/B (`?backend=canvas2d` against `?backend=webgl`, at most
|
|
873
879
|
0.5%). Hairline seams are guarded by a deterministic canary (`?expand=0` must
|
|
874
880
|
change the canvas2d raster), the canvas2d source sub-rect by another (expand 32
|
|
875
|
-
against 8
|
|
881
|
+
against 8, forced to the sub-rect), the two source rects by an A/B that must
|
|
882
|
+
match exactly, and counter tests pin the dirty-skip / grow-only-backing /
|
|
876
883
|
clip-counter invariants plus the region corner order (BL, UL, UR, BR) and the
|
|
877
884
|
turned-region UVs, read off rig-c's pose against hand-written numbers.
|
|
878
885
|
|
package/dist/CanvasRenderer.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type MeshSourceRect } from './DomRenderer.js';
|
|
1
2
|
import type { PosedFrame } from './posedFrame.js';
|
|
2
3
|
/** What actually drew the last frame of a `CanvasRenderer`. */
|
|
3
4
|
export type CanvasBackend = 'webgl' | 'canvas2d';
|
|
@@ -69,6 +70,8 @@ export declare class CanvasRenderer {
|
|
|
69
70
|
viewport: CanvasViewport | null;
|
|
70
71
|
/** The backend to draw with: 'webgl' (default) through the shared context, or 'canvas2d' to force the fallback. */
|
|
71
72
|
backend: CanvasBackend;
|
|
73
|
+
/** What the canvas2d fallback draws each mesh triangle from — as `DomRenderer.meshSourceRect`, with the same default. */
|
|
74
|
+
meshSourceRect: MeshSourceRect;
|
|
72
75
|
/** What drew the last frame (or would have, had it not been reused). */
|
|
73
76
|
backendActive: CanvasBackend;
|
|
74
77
|
/** The visible canvas — the renderer's one element in the root. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CanvasRenderer.d.ts","sourceRoot":"","sources":["../src/CanvasRenderer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"CanvasRenderer.d.ts","sourceRoot":"","sources":["../src/CanvasRenderer.ts"],"names":[],"mappings":"AAEA,OAAO,EAA+C,KAAK,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAGpG,OAAO,KAAK,EAAwB,UAAU,EAAa,MAAM,iBAAiB,CAAC;AAEnF,+DAA+D;AAC/D,MAAM,MAAM,aAAa,GAAG,OAAO,GAAG,UAAU,CAAC;AAEjD,4EAA4E;AAC5E,MAAM,WAAW,cAAc;IAC7B,CAAC,EA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vC,sFAAsF;IACtF,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA+B;IACvD,yGAAyG;IACzG,OAAO,CAAC,GAAG,CAAyB;IACpC,OAAO,CAAC,SAAS,CAAM;IACvB,OAAO,CAAC,OAAO,CAAiB;IAChC,OAAO,CAAC,OAAO,CAAyB;IACxC,OAAO,CAAC,QAAQ,CAAiB;IAEjC;;;;;;OAMG;gBAEgB,IAAI,EAAE,WAAW,EACjB,KAAK,EAAE,WAAW,CAAC,MAAM,EAAE,gBAAgB,CAAC;IAgB/D,uGAAuG;IACvG;;;;;;;;OAQG;IACH,cAAc,IAAI,MAAM;IAKxB,OAAO,CAAC,GAAG,EAAE,cAAc,GAAG,IAAI;IAIlC,uBAAuB;IACvB,MAAM,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI;IAuD/B,+GAA+G;IAC/G,OAAO,IAAI,IAAI;IAYf,OAAO,CAAC,MAAM;IAkBd,OAAO,CAAC,OAAO;IAUf,oFAAoF;IACpF,OAAO,CAAC,WAAW;IAkBnB,uGAAuG;IACvG,OAAO,CAAC,gBAAgB;IAqExB,iFAAiF;IACjF,OAAO,CAAC,UAAU;IAalB,OAAO,CAAC,MAAM,CAAa;IAE3B;;;OAGG;IACH,OAAO,CAAC,QAAQ;IA4BhB,+CAA+C;IAC/C,OAAO,CAAC,aAAa;IAmErB,OAAO,CAAC,MAAM;CAmEf"}
|
package/dist/DomRenderer.d.ts
CHANGED
|
@@ -2,6 +2,12 @@ import { type RegionImage } from './DomTexture.js';
|
|
|
2
2
|
import type { PosedFrame } from './posedFrame.js';
|
|
3
3
|
/** Rasterizer used for the mesh (deform) tier. */
|
|
4
4
|
export type MeshBackend = 'canvas2d' | 'webgl';
|
|
5
|
+
/**
|
|
6
|
+
* What a canvas2d mesh triangle is drawn from: `'triangle'`, a source sub-rect
|
|
7
|
+
* of the page covering the triangle's clip, or `'page'`, the whole page. Both
|
|
8
|
+
* draw the same picture under the same clip; they differ in cost by engine.
|
|
9
|
+
*/
|
|
10
|
+
export type MeshSourceRect = 'triangle' | 'page';
|
|
5
11
|
/**
|
|
6
12
|
* Renders a posed frame (`PosedFrame`) as DOM, split by slot kind:
|
|
7
13
|
*
|
|
@@ -88,6 +94,12 @@ export declare class DomRenderer {
|
|
|
88
94
|
* to see them.
|
|
89
95
|
*/
|
|
90
96
|
triangleExpand: number;
|
|
97
|
+
/**
|
|
98
|
+
* What the canvas2d mesh backend draws each triangle from (`MeshSourceRect`):
|
|
99
|
+
* by default the sub-rect on Linux WebKit and the whole page elsewhere.
|
|
100
|
+
* Re-rasters every mesh once when changed.
|
|
101
|
+
*/
|
|
102
|
+
meshSourceRect: MeshSourceRect;
|
|
91
103
|
/**
|
|
92
104
|
* Mesh-canvas backing-store pixels per CSS pixel. Defaults to the device
|
|
93
105
|
* pixel ratio. If the caller scales the root element, fold that scale in
|
|
@@ -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;
|
|
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;AAE/C;;;;GAIG;AACH,MAAM,MAAM,cAAc,GAAG,UAAU,GAAG,MAAM,CAAC;AA8KjD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,qBAAa,WAAW;IA2I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AAuB;IAC5C,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;IAmJlB;;;;;;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;IAoDZ,OAAO,CAAC,IAAI;CAWb"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { type CanvasBackend, CanvasRenderer, type CanvasViewport } from './CanvasRenderer.js';
|
|
2
|
-
export { DomRenderer, type MeshBackend } from './DomRenderer.js';
|
|
2
|
+
export { DomRenderer, type MeshBackend, type MeshSourceRect } from './DomRenderer.js';
|
|
3
3
|
export { type PageLayout, type PageRegion, type RegionEncoding, type RegionImage, revokeRegions, type UnpackRegionsOptions, unpackRegions } from './DomTexture.js';
|
|
4
4
|
export { type LoadModelOptions, loadModel, type ModelAssets, type ModelDocument, type RegionLoading } from './loadModel.js';
|
|
5
5
|
export { type AdjustableBones, type BoneAdjust, type BoneLocals, type BoneWorld, type PlayOptions, type PoseBounds, type QueueOptions, type RenderMode, type RigComplete, type RigEvent, RigPlayer, type RigPlayerOptions, type SlotFilter, type TrackEntry } from './player.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAE,cAAc,EAAE,KAAK,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC9F,OAAO,EAAE,WAAW,EAAE,KAAK,WAAW,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAE,cAAc,EAAE,KAAK,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC9F,OAAO,EAAE,WAAW,EAAE,KAAK,WAAW,EAAE,KAAK,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACtF,OAAO,EAAE,KAAK,UAAU,EAAE,KAAK,UAAU,EAAE,KAAK,cAAc,EAAE,KAAK,WAAW,EAAE,aAAa,EAAE,KAAK,oBAAoB,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACnK,OAAO,EAAE,KAAK,gBAAgB,EAAE,SAAS,EAAE,KAAK,WAAW,EAAE,KAAK,aAAa,EAAE,KAAK,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC5H,OAAO,EAAE,KAAK,eAAe,EAAE,KAAK,UAAU,EAAE,KAAK,UAAU,EAAE,KAAK,SAAS,EAAE,KAAK,WAAW,EAAE,KAAK,UAAU,EAAE,KAAK,YAAY,EAAE,KAAK,UAAU,EAAE,KAAK,WAAW,EAAE,KAAK,QAAQ,EAAE,SAAS,EAAE,KAAK,gBAAgB,EAAE,KAAK,UAAU,EAAE,KAAK,UAAU,EAAE,MAAM,aAAa,CAAC;AACjR,YAAY,EACV,SAAS,EACT,SAAS,EACT,UAAU,EACV,SAAS,EACT,WAAW,EACX,SAAS,GACV,MAAM,iBAAiB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -6842,6 +6842,10 @@ function getMeshGlBlitter() {
|
|
|
6842
6842
|
}
|
|
6843
6843
|
return shared && !shared.lost ? shared : null;
|
|
6844
6844
|
}
|
|
6845
|
+
function defaultMeshSourceRect(userAgent = typeof navigator === "object" ? navigator.userAgent : "") {
|
|
6846
|
+
const linuxWebKit = /AppleWebKit/.test(userAgent) && /Linux|X11/.test(userAgent) && !/Android|Chrome|Chromium|CriOS|Edg/.test(userAgent);
|
|
6847
|
+
return linuxWebKit ? "triangle" : "page";
|
|
6848
|
+
}
|
|
6845
6849
|
const regionVertices = new Float32Array(8);
|
|
6846
6850
|
const SVG_NS = "http://www.w3.org/2000/svg";
|
|
6847
6851
|
let tintFilterSeq = 0;
|
|
@@ -6965,6 +6969,12 @@ class DomRenderer {
|
|
|
6965
6969
|
* to see them.
|
|
6966
6970
|
*/
|
|
6967
6971
|
triangleExpand = 0.5;
|
|
6972
|
+
/**
|
|
6973
|
+
* What the canvas2d mesh backend draws each triangle from (`MeshSourceRect`):
|
|
6974
|
+
* by default the sub-rect on Linux WebKit and the whole page elsewhere.
|
|
6975
|
+
* Re-rasters every mesh once when changed.
|
|
6976
|
+
*/
|
|
6977
|
+
meshSourceRect = defaultMeshSourceRect();
|
|
6968
6978
|
/**
|
|
6969
6979
|
* Mesh-canvas backing-store pixels per CSS pixel. Defaults to the device
|
|
6970
6980
|
* pixel ratio. If the caller scales the root element, fold that scale in
|
|
@@ -7238,7 +7248,7 @@ class DomRenderer {
|
|
|
7238
7248
|
const ratio = this.pixelRatio;
|
|
7239
7249
|
const uvs = slot.uvs;
|
|
7240
7250
|
const triangles = slot.triangles;
|
|
7241
|
-
let dirty = view.meshUvs !== uvs || view.meshTriangles !== triangles || view.meshPage !== page || view.meshSequenceIndex !== sequenceIndex || view.meshExpand !== this.triangleExpand || view.meshVertexCount !== count || view.meshBackendDrawn !== this.meshBackendActive;
|
|
7251
|
+
let dirty = view.meshUvs !== uvs || view.meshTriangles !== triangles || view.meshPage !== page || view.meshSequenceIndex !== sequenceIndex || view.meshExpand !== this.triangleExpand || view.meshSourceRect !== this.meshSourceRect || view.meshVertexCount !== count || view.meshBackendDrawn !== this.meshBackendActive;
|
|
7242
7252
|
const needW = Math.max(1, Math.round(w * ratio));
|
|
7243
7253
|
const needH = Math.max(1, Math.round(h * ratio));
|
|
7244
7254
|
const ratioChanged = view.meshRatio !== ratio;
|
|
@@ -7278,6 +7288,7 @@ class DomRenderer {
|
|
|
7278
7288
|
view.meshPage = page;
|
|
7279
7289
|
view.meshSequenceIndex = sequenceIndex;
|
|
7280
7290
|
view.meshExpand = this.triangleExpand;
|
|
7291
|
+
view.meshSourceRect = this.meshSourceRect;
|
|
7281
7292
|
view.meshVertexCount = count;
|
|
7282
7293
|
view.meshBackendDrawn = this.meshBackendActive;
|
|
7283
7294
|
if (this.meshBackendActive === "webgl") {
|
|
@@ -7410,7 +7421,7 @@ class DomRenderer {
|
|
|
7410
7421
|
* class of offset the `uv * size` addressing removes.
|
|
7411
7422
|
*/
|
|
7412
7423
|
drawTriangle(ctx, img, x0, y0, u0, v0, x1, y1, u1, v1, x2, y2, u2, v2) {
|
|
7413
|
-
drawTexturedTriangle(ctx, img, this.triangleExpand, x0, y0, u0, v0, x1, y1, u1, v1, x2, y2, u2, v2);
|
|
7424
|
+
drawTexturedTriangle(ctx, img, this.triangleExpand, this.meshSourceRect, x0, y0, u0, v0, x1, y1, u1, v1, x2, y2, u2, v2);
|
|
7414
7425
|
}
|
|
7415
7426
|
// --- clipping tier ---------------------------------------------------------
|
|
7416
7427
|
/**
|
|
@@ -7636,6 +7647,7 @@ class DomRenderer {
|
|
|
7636
7647
|
meshPage: null,
|
|
7637
7648
|
meshSequenceIndex: -1,
|
|
7638
7649
|
meshExpand: -1,
|
|
7650
|
+
meshSourceRect: "",
|
|
7639
7651
|
meshVertexCount: -1,
|
|
7640
7652
|
meshBackendDrawn: "",
|
|
7641
7653
|
meshVertices: new Float64Array(0),
|
|
@@ -7654,7 +7666,7 @@ class DomRenderer {
|
|
|
7654
7666
|
this.setClipPath(view, "");
|
|
7655
7667
|
}
|
|
7656
7668
|
}
|
|
7657
|
-
function drawTexturedTriangle(ctx, img, expand, x0, y0, u0, v0, x1, y1, u1, v1, x2, y2, u2, v2) {
|
|
7669
|
+
function drawTexturedTriangle(ctx, img, expand, sourceRect, x0, y0, u0, v0, x1, y1, u1, v1, x2, y2, u2, v2) {
|
|
7658
7670
|
const corners = offsetTriangle(x0, y0, x1, y1, x2, y2, expand);
|
|
7659
7671
|
const px0 = corners[0], py0 = corners[1];
|
|
7660
7672
|
const px1 = corners[2], py1 = corners[3];
|
|
@@ -7677,6 +7689,14 @@ function drawTexturedTriangle(ctx, img, expand, x0, y0, u0, v0, x1, y1, u1, v1,
|
|
|
7677
7689
|
const d = (eu1 * ey2 - eu2 * ey1) * det;
|
|
7678
7690
|
const e = x0 - a * u0 - c * v0;
|
|
7679
7691
|
const f = y0 - b * u0 - d * v0;
|
|
7692
|
+
if (sourceRect === "page") {
|
|
7693
|
+
ctx.save();
|
|
7694
|
+
ctx.transform(a, b, c, d, e, f);
|
|
7695
|
+
ctx.clip();
|
|
7696
|
+
ctx.drawImage(img, 0, 0);
|
|
7697
|
+
ctx.restore();
|
|
7698
|
+
return;
|
|
7699
|
+
}
|
|
7680
7700
|
let minU = Math.min(u0, u1, u2);
|
|
7681
7701
|
let maxU = Math.max(u0, u1, u2);
|
|
7682
7702
|
let minV = Math.min(v0, v1, v2);
|
|
@@ -7768,6 +7788,8 @@ class CanvasRenderer {
|
|
|
7768
7788
|
viewport = null;
|
|
7769
7789
|
/** The backend to draw with: 'webgl' (default) through the shared context, or 'canvas2d' to force the fallback. */
|
|
7770
7790
|
backend = "webgl";
|
|
7791
|
+
/** What the canvas2d fallback draws each mesh triangle from — as `DomRenderer.meshSourceRect`, with the same default. */
|
|
7792
|
+
meshSourceRect = defaultMeshSourceRect();
|
|
7771
7793
|
/** What drew the last frame (or would have, had it not been reused). */
|
|
7772
7794
|
backendActive = "webgl";
|
|
7773
7795
|
/** The visible canvas — the renderer's one element in the root. */
|
|
@@ -7941,7 +7963,8 @@ class CanvasRenderer {
|
|
|
7941
7963
|
this.nextSig = grown;
|
|
7942
7964
|
}
|
|
7943
7965
|
};
|
|
7944
|
-
need(
|
|
7966
|
+
need(9);
|
|
7967
|
+
sig[n++] = this.meshSourceRect === "triangle" ? 1 : 0;
|
|
7945
7968
|
sig[n++] = this.left;
|
|
7946
7969
|
sig[n++] = this.top;
|
|
7947
7970
|
sig[n++] = this.backingW;
|
|
@@ -8156,6 +8179,7 @@ class CanvasRenderer {
|
|
|
8156
8179
|
ctx,
|
|
8157
8180
|
source,
|
|
8158
8181
|
0.5,
|
|
8182
|
+
this.meshSourceRect,
|
|
8159
8183
|
X(vertices[i0]),
|
|
8160
8184
|
Y(vertices[i0 + 1]),
|
|
8161
8185
|
uvs[i0] * uw,
|