spine-html 1.22.0 → 1.22.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 -0
- package/dist/MeshGlBlitter.d.ts +25 -0
- package/dist/MeshGlBlitter.d.ts.map +1 -1
- package/dist/index.js +37 -15
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
<a href="LICENSE"><img src="https://img.shields.io/badge/license-MIT-38BDF8.svg?style=flat-square" alt="license" /></a>
|
|
9
9
|
</p>
|
|
10
10
|
|
|
11
|
+
# @rig-c/play
|
|
12
|
+
|
|
11
13
|
`@rig-c/play` plays the rigs [rigc](https://github.com/rig-c/core) builds — the
|
|
12
14
|
compiled model document `rigc build` writes, `skeleton.model.json` — as **plain
|
|
13
15
|
DOM**: one absolutely-positioned `<img>` per rigid slot, posed with a single CSS
|
package/dist/MeshGlBlitter.d.ts
CHANGED
|
@@ -23,6 +23,16 @@
|
|
|
23
23
|
* grows quantized and never shrinks, mirroring the per-part backing policy
|
|
24
24
|
* (reallocating GPU surfaces per frame is a Safari killer).
|
|
25
25
|
*
|
|
26
|
+
* It only ever holds a size the browser granted in full. The WebGL spec lets
|
|
27
|
+
* the browser hand back a drawing buffer smaller than the canvas's
|
|
28
|
+
* width × height, and Chromium does once the area passes its cap (5760 ×
|
|
29
|
+
* 5760 for an 8192 × 8192 request, measured): drawing and reading back
|
|
30
|
+
* through the canvas's size then copies the wrong texels into every part —
|
|
31
|
+
* rectangles of another part's texture, cloth cut along straight edges, on a
|
|
32
|
+
* zoomed-in stage (rig-c/review#332). So a growth the browser does not grant
|
|
33
|
+
* in full is undone, that area is not asked for again, and the batch is
|
|
34
|
+
* declined to the caller's canvas2d path, as a batch past `maxSize` always was.
|
|
35
|
+
*
|
|
26
36
|
* Page textures are the one thing here with a lifetime, and since this object
|
|
27
37
|
* outlives every renderer they are reference-counted: a renderer retains each
|
|
28
38
|
* page it queues a job for and releases them in dispose(), and the last
|
|
@@ -127,6 +137,11 @@ declare class MeshGlBlitter {
|
|
|
127
137
|
*/
|
|
128
138
|
private textures;
|
|
129
139
|
private readonly maxSize;
|
|
140
|
+
/**
|
|
141
|
+
* The smallest drawing-buffer area the browser has refused to grant in full
|
|
142
|
+
* (see the module comment); a growth to this area or more is not attempted.
|
|
143
|
+
*/
|
|
144
|
+
private refusedArea;
|
|
130
145
|
private vertexData;
|
|
131
146
|
/** Per-job packed rect origins, filled by flush(). */
|
|
132
147
|
private packX;
|
|
@@ -138,6 +153,16 @@ declare class MeshGlBlitter {
|
|
|
138
153
|
* cannot fit) so the caller can rasterize the batch on the canvas2d path.
|
|
139
154
|
*/
|
|
140
155
|
flush(jobs: MeshBlitJob[]): boolean;
|
|
156
|
+
/**
|
|
157
|
+
* Makes the drawing buffer hold at least `width` × `height`, growing it
|
|
158
|
+
* grow-only and quantized, and returns whether it does — as granted, not as
|
|
159
|
+
* asked. A growth the browser grants only in part is undone (the previous
|
|
160
|
+
* size was granted in full) and its area remembered, so a zoom held past
|
|
161
|
+
* the cap declines each frame without reallocating the buffer twice per
|
|
162
|
+
* frame. Resizing clears the buffer, which is fine: every rect is cleared
|
|
163
|
+
* and redrawn anyway.
|
|
164
|
+
*/
|
|
165
|
+
private reserve;
|
|
141
166
|
/**
|
|
142
167
|
* Draws one player's frame (the canvas render mode) into a rect of the
|
|
143
168
|
* offscreen buffer and blits it onto `job.canvas`, whose full backing is
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MeshGlBlitter.d.ts","sourceRoot":"","sources":["../src/MeshGlBlitter.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"MeshGlBlitter.d.ts","sourceRoot":"","sources":["../src/MeshGlBlitter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AAEH,OAAO,KAAK,EAAE,SA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AQ;IAMhB,OAAO,CAAC,OAAO;IAYf;;;;;;;;;;OAUG;IACH,OAAO,CAAC,UAAU;CAuCnB;AAID;;;;GAIG;AACH,wBAAgB,gBAAgB,IAAI,aAAa,GAAG,IAAI,CASvD"}
|
package/dist/index.js
CHANGED
|
@@ -7015,6 +7015,11 @@ class MeshGlBlitter {
|
|
|
7015
7015
|
*/
|
|
7016
7016
|
textures = /* @__PURE__ */ new WeakMap();
|
|
7017
7017
|
maxSize;
|
|
7018
|
+
/**
|
|
7019
|
+
* The smallest drawing-buffer area the browser has refused to grant in full
|
|
7020
|
+
* (see the module comment); a growth to this area or more is not attempted.
|
|
7021
|
+
*/
|
|
7022
|
+
refusedArea = Number.POSITIVE_INFINITY;
|
|
7018
7023
|
vertexData = new Float32Array(8192);
|
|
7019
7024
|
/** Per-job packed rect origins, filled by flush(). */
|
|
7020
7025
|
packX = [];
|
|
@@ -7095,14 +7100,7 @@ class MeshGlBlitter {
|
|
|
7095
7100
|
if (job.height > shelfH) shelfH = job.height;
|
|
7096
7101
|
if (shelfY + job.height + GUTTER > height) height = shelfY + job.height + GUTTER;
|
|
7097
7102
|
}
|
|
7098
|
-
if (
|
|
7099
|
-
if (width > this.canvas.width || height > this.canvas.height) {
|
|
7100
|
-
this.canvas.width = Math.min(this.maxSize, Math.ceil(width / GROW_STEP) * GROW_STEP);
|
|
7101
|
-
this.canvas.height = Math.min(
|
|
7102
|
-
this.maxSize,
|
|
7103
|
-
Math.ceil(Math.max(height, this.canvas.height) / GROW_STEP) * GROW_STEP
|
|
7104
|
-
);
|
|
7105
|
-
}
|
|
7103
|
+
if (!this.reserve(width, height)) return false;
|
|
7106
7104
|
const bufH = this.canvas.height;
|
|
7107
7105
|
this.bindMesh();
|
|
7108
7106
|
let floats = 0;
|
|
@@ -7156,6 +7154,36 @@ class MeshGlBlitter {
|
|
|
7156
7154
|
}
|
|
7157
7155
|
return true;
|
|
7158
7156
|
}
|
|
7157
|
+
/**
|
|
7158
|
+
* Makes the drawing buffer hold at least `width` × `height`, growing it
|
|
7159
|
+
* grow-only and quantized, and returns whether it does — as granted, not as
|
|
7160
|
+
* asked. A growth the browser grants only in part is undone (the previous
|
|
7161
|
+
* size was granted in full) and its area remembered, so a zoom held past
|
|
7162
|
+
* the cap declines each frame without reallocating the buffer twice per
|
|
7163
|
+
* frame. Resizing clears the buffer, which is fine: every rect is cleared
|
|
7164
|
+
* and redrawn anyway.
|
|
7165
|
+
*/
|
|
7166
|
+
reserve(width, height) {
|
|
7167
|
+
const canvas = this.canvas;
|
|
7168
|
+
const gl = this.gl;
|
|
7169
|
+
if (width > this.maxSize || height > this.maxSize) return false;
|
|
7170
|
+
if (width > canvas.width || height > canvas.height) {
|
|
7171
|
+
const w = Math.min(this.maxSize, Math.ceil(Math.max(width, canvas.width) / GROW_STEP) * GROW_STEP);
|
|
7172
|
+
const h = Math.min(this.maxSize, Math.ceil(Math.max(height, canvas.height) / GROW_STEP) * GROW_STEP);
|
|
7173
|
+
if (w * h >= this.refusedArea) return false;
|
|
7174
|
+
const previousW = canvas.width;
|
|
7175
|
+
const previousH = canvas.height;
|
|
7176
|
+
canvas.width = w;
|
|
7177
|
+
canvas.height = h;
|
|
7178
|
+
if (gl.drawingBufferWidth < w || gl.drawingBufferHeight < h) {
|
|
7179
|
+
this.refusedArea = Math.min(this.refusedArea, w * h);
|
|
7180
|
+
canvas.width = previousW;
|
|
7181
|
+
canvas.height = previousH;
|
|
7182
|
+
return false;
|
|
7183
|
+
}
|
|
7184
|
+
}
|
|
7185
|
+
return gl.drawingBufferWidth === canvas.width && gl.drawingBufferHeight === canvas.height;
|
|
7186
|
+
}
|
|
7159
7187
|
/**
|
|
7160
7188
|
* Draws one player's frame (the canvas render mode) into a rect of the
|
|
7161
7189
|
* offscreen buffer and blits it onto `job.canvas`, whose full backing is
|
|
@@ -7165,13 +7193,7 @@ class MeshGlBlitter {
|
|
|
7165
7193
|
flushFrame(job) {
|
|
7166
7194
|
const gl = this.gl;
|
|
7167
7195
|
if (this.lost || gl.isContextLost()) return false;
|
|
7168
|
-
|
|
7169
|
-
const height = job.height + GUTTER * 2;
|
|
7170
|
-
if (width > this.maxSize || height > this.maxSize) return false;
|
|
7171
|
-
if (width > this.canvas.width || height > this.canvas.height) {
|
|
7172
|
-
this.canvas.width = Math.min(this.maxSize, Math.ceil(Math.max(width, this.canvas.width) / GROW_STEP) * GROW_STEP);
|
|
7173
|
-
this.canvas.height = Math.min(this.maxSize, Math.ceil(Math.max(height, this.canvas.height) / GROW_STEP) * GROW_STEP);
|
|
7174
|
-
}
|
|
7196
|
+
if (!this.reserve(job.width + GUTTER * 2, job.height + GUTTER * 2)) return false;
|
|
7175
7197
|
const bufW = this.canvas.width;
|
|
7176
7198
|
const bufH = this.canvas.height;
|
|
7177
7199
|
gl.viewport(0, 0, bufW, bufH);
|