spine-html 1.23.0 → 1.25.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/dist/CanvasRenderer.d.ts +3 -0
- package/dist/CanvasRenderer.d.ts.map +1 -1
- package/dist/DomRenderer.d.ts +3 -0
- package/dist/DomRenderer.d.ts.map +1 -1
- package/dist/MeshGlBlitter.d.ts +14 -10
- package/dist/MeshGlBlitter.d.ts.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +103 -56
- package/dist/index.js.map +1 -1
- package/dist/player.d.ts +22 -10
- package/dist/player.d.ts.map +1 -1
- package/package.json +4 -4
package/dist/CanvasRenderer.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { LiveFrame } from './liveFrame.js';
|
|
2
2
|
import { type MeshSourceRect } from './DomRenderer.js';
|
|
3
|
+
import { type WebGLFallbackReason } from './MeshGlBlitter.js';
|
|
3
4
|
import type { PosedFrame } from './posedFrame.js';
|
|
4
5
|
/** What actually drew the last frame of a `CanvasRenderer`. */
|
|
5
6
|
export type CanvasBackend = 'webgl' | 'canvas2d';
|
|
@@ -75,6 +76,8 @@ export declare class CanvasRenderer {
|
|
|
75
76
|
meshSourceRect: MeshSourceRect;
|
|
76
77
|
/** What drew the last frame (or would have, had it not been reused). */
|
|
77
78
|
backendActive: CanvasBackend;
|
|
79
|
+
/** Why the last render selected canvas2d. Null before rendering or when WebGL was selected. */
|
|
80
|
+
backendFallbackReason: WebGLFallbackReason | null;
|
|
78
81
|
/** The visible canvas — the renderer's one element in the root. */
|
|
79
82
|
readonly canvas: HTMLCanvasElement;
|
|
80
83
|
/** Draw calls issued last frame — one per run of one page under one blend. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CanvasRenderer.d.ts","sourceRoot":"","sources":["../src/CanvasRenderer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,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O,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;IAoErB,OAAO,CAAC,MAAM;CAoEf"}
|
package/dist/DomRenderer.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { LiveFrame } from './liveFrame.js';
|
|
2
2
|
import { type AtlasRegion, type RegionImage } from './DomTexture.js';
|
|
3
|
+
import { type WebGLFallbackReason } from './MeshGlBlitter.js';
|
|
3
4
|
import type { PosedFrame } from './posedFrame.js';
|
|
4
5
|
/** Rasterizer used for the mesh (deform) tier. */
|
|
5
6
|
export type MeshBackend = 'canvas2d' | 'webgl';
|
|
@@ -130,6 +131,8 @@ export declare class DomRenderer {
|
|
|
130
131
|
meshBackend: MeshBackend;
|
|
131
132
|
/** Backend that actually rasterized the mesh tier during the last render(). */
|
|
132
133
|
meshBackendActive: MeshBackend;
|
|
134
|
+
/** Why the last render selected canvas2d for meshes. Null before rendering or when WebGL was selected. */
|
|
135
|
+
meshBackendFallbackReason: WebGLFallbackReason | null;
|
|
133
136
|
private readonly views;
|
|
134
137
|
/** Counts render() calls: the stamp a view drawn this frame carries (`SlotView.drawnIn`). */
|
|
135
138
|
private frameNumber;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DomRenderer.d.ts","sourceRoot":"","sources":["../src/DomRenderer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD,OAAO,EAAE,KAAK,WAAW,EAAoC,KAAK,WAAW,EAAuB,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"DomRenderer.d.ts","sourceRoot":"","sources":["../src/DomRenderer.ts"],"names":[],"mappings":"AACA,OAAO,K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B,sEAAsE;IACtE,OAAO,CAAC,eAAe;IAwCvB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;IAuDZ,OAAO,CAAC,IAAI;CAWb"}
|
package/dist/MeshGlBlitter.d.ts
CHANGED
|
@@ -52,6 +52,9 @@
|
|
|
52
52
|
* their reference counts.
|
|
53
53
|
*/
|
|
54
54
|
import type { BlendMode } from './posedFrame.js';
|
|
55
|
+
/** Why a renderer selected Canvas2D for its last render. */
|
|
56
|
+
export type WebGLFallbackReason = 'creation-failed' | 'context-lost' | 'over-grant' | 'not-requested';
|
|
57
|
+
type FlushFallback = 'context-lost' | 'over-grant';
|
|
55
58
|
export interface MeshBlitJob {
|
|
56
59
|
/** Destination per-part canvas; the blit clears its full backing first. */
|
|
57
60
|
canvas: HTMLCanvasElement;
|
|
@@ -156,9 +159,8 @@ declare class MeshGlBlitter {
|
|
|
156
159
|
private packY;
|
|
157
160
|
constructor();
|
|
158
161
|
/**
|
|
159
|
-
* Rasterizes every job and blits it onto its per-part canvas. Returns
|
|
160
|
-
*
|
|
161
|
-
* canvas2d path; a batch's size never sends it there.
|
|
162
|
+
* Rasterizes every job and blits it onto its per-part canvas. Returns null
|
|
163
|
+
* on success, or the reason the caller needs to draw on its canvas2d path.
|
|
162
164
|
*
|
|
163
165
|
* A batch that fits one buffer is one pass, shelf-packed as it always was.
|
|
164
166
|
* One that does not — a zoomed-in stage asks for more than the browser
|
|
@@ -175,7 +177,8 @@ declare class MeshGlBlitter {
|
|
|
175
177
|
* matching sub-rect of the part canvas — so a pixel does not depend on how
|
|
176
178
|
* its job was packed, which pass drew it, or how it was tiled.
|
|
177
179
|
*/
|
|
178
|
-
flush(jobs: MeshBlitJob[]):
|
|
180
|
+
flush(jobs: MeshBlitJob[]): FlushFallback | null;
|
|
181
|
+
private bufferFallback;
|
|
179
182
|
/**
|
|
180
183
|
* Sets the viewport, the two uniforms and the scissor for one piece. The
|
|
181
184
|
* viewport is the job's own rect — or, for a job wider or taller than
|
|
@@ -225,13 +228,12 @@ declare class MeshGlBlitter {
|
|
|
225
228
|
private acquire;
|
|
226
229
|
/**
|
|
227
230
|
* Draws one player's frame (the canvas render mode) and blits it onto
|
|
228
|
-
* `job.canvas`, whose full backing is cleared first. Returns
|
|
229
|
-
*
|
|
230
|
-
*
|
|
231
|
-
*
|
|
232
|
-
* tile re-issuing the frame's runs under its own scissor.
|
|
231
|
+
* `job.canvas`, whose full backing is cleared first. Returns null on success
|
|
232
|
+
* or a canvas2d fallback reason. The frame is one job, drawn into one rect
|
|
233
|
+
* if it fits, otherwise tiled through passes exactly as flush() tiles a mesh.
|
|
234
|
+
* Every tile re-issues the frame's runs under its own scissor.
|
|
233
235
|
*/
|
|
234
|
-
flushFrame(job: FrameJob):
|
|
236
|
+
flushFrame(job: FrameJob): FlushFallback | null;
|
|
235
237
|
/** The mesh tier's layout, [x, y, u, v], and its premultiplied source-over. */
|
|
236
238
|
private bindMesh;
|
|
237
239
|
/** The frame layout: [x, y, u, v, r, g, b, a], and [dr, dg, db] at stride 11. */
|
|
@@ -281,5 +283,7 @@ declare class MeshGlBlitter {
|
|
|
281
283
|
* canvas2d path.
|
|
282
284
|
*/
|
|
283
285
|
export declare function getMeshGlBlitter(): MeshGlBlitter | null;
|
|
286
|
+
/** The reason for a null result from getMeshGlBlitter(). */
|
|
287
|
+
export declare function meshGlUnavailableReason(): 'creation-failed' | 'context-lost';
|
|
284
288
|
export {};
|
|
285
289
|
//# sourceMappingURL=MeshGlBlitter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MeshGlBlitter.d.ts","sourceRoot":"","sources":["../src/MeshGlBlitter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoDG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAgBjD,MAAM,WAAW,WAAW;IAC1B,2EAA2E;IAC3E,MAAM,EAAE,iBAAiB,CAAC;IAC1B,+EAA+E;IAC/E,IAAI,EAAE,gBAAgB,CAAC;IACvB;;;;;OAKG;IACH,GAAG,EAAE,OAAO,CAAC;IACb,mFAAmF;IACnF,QAAQ,EAAE,YAAY,CAAC;IACvB,mDAAmD;IACnD,GAAG,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC;IACvB,gDAAgD;IAChD,SAAS,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC;IAC7B,uCAAuC;IACvC,KAAK,EAAE,MAAM,CAAC;IACd,iFAAiF;IACjF,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;GAGG;AACH,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,gBAAgB,CAAC;IACvB,sCAAsC;IACtC,GAAG,EAAE,OAAO,CAAC;IACb,KAAK,EAAE,SAAS,CAAC;IACjB,8DAA8D;IAC9D,KAAK,EAAE,MAAM,CAAC;IACd,gDAAgD;IAChD,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;;;;;;;GASG;AACH,MAAM,WAAW,QAAQ;IACvB,MAAM,EAAE,iBAAiB,CAAC;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,YAAY,CAAC;IACnB,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC;IACf,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I,EAAE,WAAW,EAAE,GAAG,aAAa,GAAG,IAAI;IA+GhD,OAAO,CAAC,cAAc;IAItB;;;;;;;;;;;;;OAaG;IACH,OAAO,CAAC,UAAU;IAelB;;;;;;;;OAQG;IACH,OAAO,CAAC,IAAI;IA8BZ,gFAAgF;IAChF,OAAO,KAAK,MAAM,GAEjB;IAED,OAAO,KAAK,MAAM,GAEjB;IAED;;;;;;;;OAQG;IACH,OAAO,CAAC,OAAO;IA+Bf;;;;;;;OAOG;IACH,OAAO,CAAC,OAAO;IA2Cf;;;;;;OAMG;IACH,UAAU,CAAC,GAAG,EAAE,QAAQ,GAAG,aAAa,GAAG,IAAI;IA2E/C,+EAA+E;IAC/E,OAAO,CAAC,QAAQ;IAgBhB,iFAAiF;IACjF,OAAO,CAAC,SAAS;IAsBjB,OAAO,CAAC,iBAAiB;IAOzB,OAAO,CAAC,IAAI;IAaZ;;;;;;OAMG;IACH,MAAM,CAAC,IAAI,EAAE,gBAAgB,GAAG,IAAI;IAMpC;;;;;;OAMG;IACH,OAAO,CAAC,IAAI,EAAE,gBAAgB,GAAG,IAAI;IAarC;;;;;OAKG;IACH,OAAO,CAAC,QAAQ;IAMhB,OAAO,CAAC,OAAO;IAYf;;;;;;;;;;OAUG;IACH,OAAO,CAAC,UAAU;CAuCnB;AAID;;;;GAIG;AACH,wBAAgB,gBAAgB,IAAI,aAAa,GAAG,IAAI,CASvD;AAED,4DAA4D;AAC5D,wBAAgB,uBAAuB,IAAI,iBAAiB,GAAG,cAAc,CAE5E"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
export { type CanvasBackend, CanvasRenderer, type CanvasViewport } from './CanvasRenderer.js';
|
|
2
2
|
export { DomRenderer, type MeshBackend, type MeshSourceRect } from './DomRenderer.js';
|
|
3
|
+
export type { WebGLFallbackReason } from './MeshGlBlitter.js';
|
|
3
4
|
export { type AtlasRegion, createAtlasRegions, type PageLayout, type PageRegion, type RegionEncoding, type RegionImage, revokeRegions, type UnpackRegionsOptions, unpackRegions } from './DomTexture.js';
|
|
4
5
|
export { type LoadModelOptions, loadModel, type ModelAssets, type ModelDocument, readSetupMesh, type RegionLoading, type RigSet, type SetupMesh, type SetupMeshTarget } from './loadModel.js';
|
|
5
|
-
export { type AdjustableBones, type BoneAdjust, type BoneAdjustContext, type BoneLocals, type BoneWorld, type PhysicsMotion, type PhysicsMotionScope, type PhysicsParameters, type PhysicsParameterPatch, type PhysicsParameterRead, type PlayOptions, type PoseBounds, type QueueOptions, type RenderMode, type RigComplete, type RigEnvironment, type RigEvent, RigPlayer, type RigPlayerOptions, type SetActivationOptions, type SlotFilter, type SlotIdentity, type SlotIdentityReason, type SlotIdentitySnapshot, type TrackEntry } from './player.js';
|
|
6
|
+
export { type AdjustableBones, type BoneAdjust, type BoneAdjustContext, type BoneLocals, type BoneWorld, type PhysicsMotion, type PhysicsMotionScope, type PhysicsParameters, type PhysicsParameterPatch, type PhysicsParameterRead, type PlayOptions, type PoseBounds, type QueueOptions, type RenderMode, type RigComplete, type RigEnvironment, type RigEnvironmentSchedule, type RigEvent, RigPlayer, type RigPlayerOptions, type SetActivationOptions, type SlotFilter, type SlotIdentity, type SlotIdentityReason, type SlotIdentitySnapshot, type TrackEntry } from './player.js';
|
|
6
7
|
export type { BlendMode, PosedClip, PosedFrame, PosedMesh, PosedRegion, PosedSlot, } from './posedFrame.js';
|
|
7
8
|
export type { LiveFrame, LiveNumbers, LiveAttachment, LiveClip } from './liveFrame.js';
|
|
8
9
|
//# sourceMappingURL=index.d.ts.map
|
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,KAAK,cAAc,E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AK,WAAW,EAAE,kBAAkB,EAAE,KAAK,UAAU,EAAE,KAAK,UAAU,EAAE,KAAK,cAAc,EAAE,KAAK,WAAW,EAAE,aAAa,EAAE,KAAK,oBAAoB,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACzM,OAAO,EAAE,KAAK,gBAAgB,EAAE,SAAS,EAAE,KAAK,WAAW,EAAE,KAAK,aAAa,EAAE,aAAa,EAAE,KAAK,aAAa,EAAE,KAAK,MAAM,EAAE,KAAK,SAAS,EAAE,KAAK,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAC9L,OAAO,EAAE,KAAK,eAAe,EAAE,KAAK,UAAU,EAAE,KAAK,iBAAiB,EAAE,KAAK,UAAU,EAAE,KAAK,SAAS,EAAE,KAAK,aAAa,EAAE,KAAK,kBAAkB,EAAE,KAAK,iBAAiB,EAAE,KAAK,qBAAqB,EAAE,KAAK,oBAAoB,EAAE,KAAK,WAAW,EAAE,KAAK,UAAU,EAAE,KAAK,YAAY,EAAE,KAAK,UAAU,EAAE,KAAK,WAAW,EAAE,KAAK,cAAc,EAAE,KAAK,sBAAsB,EAAE,KAAK,QAAQ,EAAE,SAAS,EAAE,KAAK,gBAAgB,EAAE,KAAK,oBAAoB,EAAE,KAAK,UAAU,EAAE,KAAK,YAAY,EAAE,KAAK,kBAAkB,EAAE,KAAK,oBAAoB,EAAE,KAAK,UAAU,EAAE,MAAM,aAAa,CAAC;AACzjB,YAAY,EACV,SAAS,EACT,SAAS,EACT,UAAU,EACV,SAAS,EACT,WAAW,EACX,SAAS,GACV,MAAM,iBAAiB,CAAC;AAEzB,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -3530,6 +3530,7 @@ function applyConstraints(bones, world, active, records, previous = null, applie
|
|
|
3530
3530
|
if (changed.length > 0) repose(state, changed, inWorld);
|
|
3531
3531
|
snap(i, "after");
|
|
3532
3532
|
}
|
|
3533
|
+
settled?.(state);
|
|
3533
3534
|
return state.world;
|
|
3534
3535
|
}
|
|
3535
3536
|
function planShape(c) {
|
|
@@ -4231,7 +4232,7 @@ function posedBoneStep(doc, timelines, t, plant, constraints, sliders, step) {
|
|
|
4231
4232
|
const setupRecords = constraintRecords(doc);
|
|
4232
4233
|
const records = pathDeformed(doc, posedRecords(setupRecords, constraints, t), timelines, t, plant);
|
|
4233
4234
|
const previous = setupRecords.some((r) => r.kind === "path") ? applyConstraints(doc.bones, (plant.evaluate ?? worldTransforms)(doc.bones, active), active, plant.constraints ? plant.constraints(setupRecords) : setupRecords, null, void 0, void 0, void 0, solverRules(plant.solver)) : null;
|
|
4234
|
-
world = applyConstraints(bones, initialWorld, active, plant.constraints ? plant.constraints(records) : records, previous, sliders, void 0, void 0, solverRules(plant.solver));
|
|
4235
|
+
world = applyConstraints(bones, initialWorld, active, plant.constraints ? plant.constraints(records) : records, previous, sliders, void 0, plant.readLocals === void 0 ? void 0 : (state) => plant.readLocals?.(state.bones, sliders ?? []), solverRules(plant.solver));
|
|
4235
4236
|
if (stage !== void 0) stage.end("constraints");
|
|
4236
4237
|
}
|
|
4237
4238
|
for (const b of bones) if (world.get(b.name) === void 0) throw new CoreInputError(`the evaluator returned no transform for bone "${b.name}"`);
|
|
@@ -4252,7 +4253,7 @@ function steppedLocals(doc, bones, plant, records, physicsKeyed, t, sliders, ste
|
|
|
4252
4253
|
stage.begin("constraints");
|
|
4253
4254
|
}
|
|
4254
4255
|
const stepped = stepPhysicsRecords(records(), physicsKeyed, t, active, step.ctx, step.before);
|
|
4255
|
-
const world = applyConstraints(bones, initialWorld, active, plant.constraints ? plant.constraints(stepped) : stepped, null, sliders, step.ctx, void 0, solverRules(plant.solver));
|
|
4256
|
+
const world = applyConstraints(bones, initialWorld, active, plant.constraints ? plant.constraints(stepped) : stepped, null, sliders, step.ctx, plant.readLocals === void 0 ? void 0 : (state) => plant.readLocals?.(state.bones, sliders ?? []), solverRules(plant.solver));
|
|
4256
4257
|
if (stage !== void 0) stage.end("constraints");
|
|
4257
4258
|
for (const b of bones) if (world.get(b.name) === void 0) throw new CoreInputError(`the evaluator returned no transform for bone "${b.name}"`);
|
|
4258
4259
|
return { bones, world, active, round: plant.round ?? gridRound };
|
|
@@ -4967,7 +4968,7 @@ function poseSetup(doc, plant = {}, physics) {
|
|
|
4967
4968
|
if (bonesWhy === null) {
|
|
4968
4969
|
const active = activeBones(doc);
|
|
4969
4970
|
const records = constraintRecords(doc);
|
|
4970
|
-
setupWorld = applyConstraints(doc.bones, evaluate(doc.bones, active), active, plant.constraints ? plant.constraints(records) : records, null, applied, physics, void 0, solverRules(plant.solver));
|
|
4971
|
+
setupWorld = applyConstraints(doc.bones, evaluate(doc.bones, active), active, plant.constraints ? plant.constraints(records) : records, null, applied, physics, plant.readLocals === void 0 ? void 0 : (state) => plant.readLocals?.(state.bones, applied), solverRules(plant.solver));
|
|
4971
4972
|
const world = setupWorld;
|
|
4972
4973
|
bones = doc.bones.map((b) => {
|
|
4973
4974
|
const t = world.get(b.name);
|
|
@@ -7117,9 +7118,8 @@ class MeshGlBlitter {
|
|
|
7117
7118
|
this.maxSize = Math.floor(side / ALIGN) * ALIGN;
|
|
7118
7119
|
}
|
|
7119
7120
|
/**
|
|
7120
|
-
* Rasterizes every job and blits it onto its per-part canvas. Returns
|
|
7121
|
-
*
|
|
7122
|
-
* canvas2d path; a batch's size never sends it there.
|
|
7121
|
+
* Rasterizes every job and blits it onto its per-part canvas. Returns null
|
|
7122
|
+
* on success, or the reason the caller needs to draw on its canvas2d path.
|
|
7123
7123
|
*
|
|
7124
7124
|
* A batch that fits one buffer is one pass, shelf-packed as it always was.
|
|
7125
7125
|
* One that does not — a zoomed-in stage asks for more than the browser
|
|
@@ -7139,15 +7139,15 @@ class MeshGlBlitter {
|
|
|
7139
7139
|
flush(jobs) {
|
|
7140
7140
|
const gl = this.gl;
|
|
7141
7141
|
this.stats = { jobs: jobs.length, passes: 0, pieces: 0, tiledJobs: 0 };
|
|
7142
|
-
if (this.lost || gl.isContextLost()) return
|
|
7142
|
+
if (this.lost || gl.isContextLost()) return "context-lost";
|
|
7143
7143
|
let width = Math.max(512, this.canvas.width);
|
|
7144
7144
|
for (const job of jobs) width = Math.max(width, job.width + GUTTER * 2);
|
|
7145
7145
|
let pieces = jobs.map((job, i) => ({ job: i, tx: 0, ty: 0, tw: job.width, th: job.height, bx: 0, by: 0, pass: 0 }));
|
|
7146
7146
|
const height = shelfPack(pieces, width, Number.POSITIVE_INFINITY);
|
|
7147
7147
|
if (!this.reserve(width, height)) {
|
|
7148
|
-
if (!this.acquire(width, height)) return
|
|
7148
|
+
if (!this.acquire(width, height)) return this.bufferFallback();
|
|
7149
7149
|
const planned = this.plan(jobs, this.canvas.width, this.canvas.height);
|
|
7150
|
-
if (!planned) return
|
|
7150
|
+
if (!planned) return this.bufferFallback();
|
|
7151
7151
|
pieces = planned;
|
|
7152
7152
|
}
|
|
7153
7153
|
const packX = this.packX = new Array(jobs.length);
|
|
@@ -7199,7 +7199,7 @@ class MeshGlBlitter {
|
|
|
7199
7199
|
}
|
|
7200
7200
|
if (gl.isContextLost()) {
|
|
7201
7201
|
this.markLost();
|
|
7202
|
-
return
|
|
7202
|
+
return "context-lost";
|
|
7203
7203
|
}
|
|
7204
7204
|
for (let k = start; k < end; k++) {
|
|
7205
7205
|
const piece = pieces[k];
|
|
@@ -7226,7 +7226,10 @@ class MeshGlBlitter {
|
|
|
7226
7226
|
ctx.setTransform(1, 0, 0, 1, 0, 0);
|
|
7227
7227
|
ctx.clearRect(0, 0, jobs[i].canvas.width, jobs[i].canvas.height);
|
|
7228
7228
|
}
|
|
7229
|
-
return
|
|
7229
|
+
return null;
|
|
7230
|
+
}
|
|
7231
|
+
bufferFallback() {
|
|
7232
|
+
return this.gl.isContextLost() ? "context-lost" : "over-grant";
|
|
7230
7233
|
}
|
|
7231
7234
|
/**
|
|
7232
7235
|
* Sets the viewport, the two uniforms and the scissor for one piece. The
|
|
@@ -7386,23 +7389,22 @@ class MeshGlBlitter {
|
|
|
7386
7389
|
}
|
|
7387
7390
|
/**
|
|
7388
7391
|
* Draws one player's frame (the canvas render mode) and blits it onto
|
|
7389
|
-
* `job.canvas`, whose full backing is cleared first. Returns
|
|
7390
|
-
*
|
|
7391
|
-
*
|
|
7392
|
-
*
|
|
7393
|
-
* tile re-issuing the frame's runs under its own scissor.
|
|
7392
|
+
* `job.canvas`, whose full backing is cleared first. Returns null on success
|
|
7393
|
+
* or a canvas2d fallback reason. The frame is one job, drawn into one rect
|
|
7394
|
+
* if it fits, otherwise tiled through passes exactly as flush() tiles a mesh.
|
|
7395
|
+
* Every tile re-issues the frame's runs under its own scissor.
|
|
7394
7396
|
*/
|
|
7395
7397
|
flushFrame(job) {
|
|
7396
7398
|
const gl = this.gl;
|
|
7397
7399
|
this.stats = { jobs: 1, passes: 0, pieces: 0, tiledJobs: 0 };
|
|
7398
|
-
if (this.lost || gl.isContextLost()) return
|
|
7400
|
+
if (this.lost || gl.isContextLost()) return "context-lost";
|
|
7399
7401
|
let pieces;
|
|
7400
7402
|
if (this.reserve(job.width + GUTTER * 2, job.height + GUTTER * 2)) {
|
|
7401
7403
|
pieces = [{ job: 0, tx: 0, ty: 0, tw: job.width, th: job.height, bx: GUTTER, by: GUTTER, pass: 0 }];
|
|
7402
7404
|
} else {
|
|
7403
|
-
if (!this.acquire(job.width + GUTTER * 2, job.height + GUTTER * 2)) return
|
|
7405
|
+
if (!this.acquire(job.width + GUTTER * 2, job.height + GUTTER * 2)) return this.bufferFallback();
|
|
7404
7406
|
const planned = this.plan([job], this.canvas.width, this.canvas.height);
|
|
7405
|
-
if (!planned) return
|
|
7407
|
+
if (!planned) return this.bufferFallback();
|
|
7406
7408
|
pieces = planned;
|
|
7407
7409
|
}
|
|
7408
7410
|
const bufH = this.canvas.height;
|
|
@@ -7442,7 +7444,7 @@ class MeshGlBlitter {
|
|
|
7442
7444
|
}
|
|
7443
7445
|
if (gl.isContextLost()) {
|
|
7444
7446
|
this.markLost();
|
|
7445
|
-
return
|
|
7447
|
+
return "context-lost";
|
|
7446
7448
|
}
|
|
7447
7449
|
if (ctx) {
|
|
7448
7450
|
if (!cleared) {
|
|
@@ -7461,7 +7463,7 @@ class MeshGlBlitter {
|
|
|
7461
7463
|
}
|
|
7462
7464
|
this.stats.pieces = pieces.length;
|
|
7463
7465
|
if (ctx && !cleared) ctx.clearRect(0, 0, job.canvas.width, job.canvas.height);
|
|
7464
|
-
return
|
|
7466
|
+
return null;
|
|
7465
7467
|
}
|
|
7466
7468
|
/** The mesh tier's layout, [x, y, u, v], and its premultiplied source-over. */
|
|
7467
7469
|
bindMesh() {
|
|
@@ -7616,6 +7618,9 @@ function getMeshGlBlitter() {
|
|
|
7616
7618
|
}
|
|
7617
7619
|
return shared && !shared.lost ? shared : null;
|
|
7618
7620
|
}
|
|
7621
|
+
function meshGlUnavailableReason() {
|
|
7622
|
+
return shared?.lost ? "context-lost" : "creation-failed";
|
|
7623
|
+
}
|
|
7619
7624
|
function defaultMeshSourceRect(userAgent = typeof navigator === "object" ? navigator.userAgent : "") {
|
|
7620
7625
|
const linuxWebKit = /AppleWebKit/.test(userAgent) && /Linux|X11/.test(userAgent) && !/Android|Chrome|Chromium|CriOS|Edg/.test(userAgent);
|
|
7621
7626
|
return linuxWebKit ? "triangle" : "page";
|
|
@@ -7791,6 +7796,8 @@ class DomRenderer {
|
|
|
7791
7796
|
meshBackend = "webgl";
|
|
7792
7797
|
/** Backend that actually rasterized the mesh tier during the last render(). */
|
|
7793
7798
|
meshBackendActive = "webgl";
|
|
7799
|
+
/** Why the last render selected canvas2d for meshes. Null before rendering or when WebGL was selected. */
|
|
7800
|
+
meshBackendFallbackReason = null;
|
|
7794
7801
|
views = /* @__PURE__ */ new Map();
|
|
7795
7802
|
/** Counts render() calls: the stamp a view drawn this frame carries (`SlotView.drawnIn`). */
|
|
7796
7803
|
frameNumber = 0;
|
|
@@ -7910,6 +7917,7 @@ class DomRenderer {
|
|
|
7910
7917
|
const stamp = ++this.frameNumber;
|
|
7911
7918
|
const blitter = this.meshBackend === "webgl" ? getMeshGlBlitter() : null;
|
|
7912
7919
|
this.meshBackendActive = blitter ? "webgl" : "canvas2d";
|
|
7920
|
+
this.meshBackendFallbackReason = blitter ? null : this.meshBackend === "webgl" ? meshGlUnavailableReason() : "not-requested";
|
|
7913
7921
|
const order = frame2.order;
|
|
7914
7922
|
const first = order.length > 0 ? order[0].clip : void 0;
|
|
7915
7923
|
if (first && !first.inverse && this.clipping && first.polygon.length >= 6) {
|
|
@@ -7930,8 +7938,10 @@ class DomRenderer {
|
|
|
7930
7938
|
for (const view of this.views.values()) if (view.drawnIn !== stamp) this.hide(view);
|
|
7931
7939
|
if (!this.clipOnRoot) this.releaseRootClip();
|
|
7932
7940
|
if (this.pendingJobs.length) {
|
|
7933
|
-
|
|
7941
|
+
const reason = blitter ? blitter.flush(this.pendingJobs) : this.meshBackendFallbackReason;
|
|
7942
|
+
if (reason !== null) {
|
|
7934
7943
|
this.meshBackendActive = "canvas2d";
|
|
7944
|
+
this.meshBackendFallbackReason = reason;
|
|
7935
7945
|
for (let i = 0; i < this.pendingJobs.length; i++) {
|
|
7936
7946
|
const job = this.pendingJobs[i];
|
|
7937
7947
|
this.pendingViews[i].meshBackendDrawn = "canvas2d";
|
|
@@ -8606,6 +8616,8 @@ class CanvasRenderer {
|
|
|
8606
8616
|
meshSourceRect = defaultMeshSourceRect();
|
|
8607
8617
|
/** What drew the last frame (or would have, had it not been reused). */
|
|
8608
8618
|
backendActive = "webgl";
|
|
8619
|
+
/** Why the last render selected canvas2d. Null before rendering or when WebGL was selected. */
|
|
8620
|
+
backendFallbackReason = null;
|
|
8609
8621
|
/** The visible canvas — the renderer's one element in the root. */
|
|
8610
8622
|
canvas;
|
|
8611
8623
|
/** Draw calls issued last frame — one per run of one page under one blend. */
|
|
@@ -8674,6 +8686,7 @@ class CanvasRenderer {
|
|
|
8674
8686
|
this.clipSkipCount = 0;
|
|
8675
8687
|
const blitter = this.backend === "webgl" ? getMeshGlBlitter() : null;
|
|
8676
8688
|
this.backendActive = blitter ? "webgl" : "canvas2d";
|
|
8689
|
+
this.backendFallbackReason = blitter ? null : this.backend === "webgl" ? meshGlUnavailableReason() : "not-requested";
|
|
8677
8690
|
const order = frame2.order;
|
|
8678
8691
|
const view = this.viewport;
|
|
8679
8692
|
if (view) {
|
|
@@ -8703,11 +8716,13 @@ class CanvasRenderer {
|
|
|
8703
8716
|
if (this.backingW === 0 || this.backingH === 0) return;
|
|
8704
8717
|
if (blitter) {
|
|
8705
8718
|
this.buildVertices(order);
|
|
8706
|
-
|
|
8719
|
+
const reason = blitter.flushFrame({ canvas: this.canvas, width: this.backingW, height: this.backingH, data: this.data, stride: this.stride, runs: this.runs });
|
|
8720
|
+
if (reason === null) {
|
|
8707
8721
|
this.blits = 1;
|
|
8708
8722
|
return;
|
|
8709
8723
|
}
|
|
8710
8724
|
this.backendActive = "canvas2d";
|
|
8725
|
+
this.backendFallbackReason = reason;
|
|
8711
8726
|
this.sigLength = -1;
|
|
8712
8727
|
}
|
|
8713
8728
|
this.draw2d(order);
|
|
@@ -13195,12 +13210,13 @@ class RigPlayer {
|
|
|
13195
13210
|
slotFilter = null;
|
|
13196
13211
|
/** `slotFilter` as a predicate; every slot when null. */
|
|
13197
13212
|
draws = () => true;
|
|
13198
|
-
/**
|
|
13199
|
-
adjustHook = (locals, ctx) =>
|
|
13200
|
-
|
|
13213
|
+
/** Reads the current `adjust` and set ease during live evaluation. */
|
|
13214
|
+
adjustHook = (locals, ctx) => this.adjustLocals(locals, ctx, this.easing);
|
|
13215
|
+
adjustLocals(locals, ctx, easing) {
|
|
13216
|
+
if (easing !== null) this.applyEase(easing, locals);
|
|
13201
13217
|
else if (this.drawnPose !== null) for (const [bone2, rotation] of this.drawnPose) locals.bone(bone2).rotation = rotation;
|
|
13202
13218
|
if (this.adjustFn !== null) this.adjustFn(locals, ctx);
|
|
13203
|
-
}
|
|
13219
|
+
}
|
|
13204
13220
|
listeners = {
|
|
13205
13221
|
event: /* @__PURE__ */ new Set(),
|
|
13206
13222
|
complete: /* @__PURE__ */ new Set()
|
|
@@ -13421,11 +13437,11 @@ class RigPlayer {
|
|
|
13421
13437
|
return tracks;
|
|
13422
13438
|
}
|
|
13423
13439
|
/** Stores `raw` and applies the shown set (`activeSet`, or before an ease's swap the composition it eases from). Zero work when none. */
|
|
13424
|
-
setRawPose(raw) {
|
|
13440
|
+
setRawPose(raw, set = this.shownSet()) {
|
|
13441
|
+
const pose = set === null ? raw : applySetToPose(this.view, raw, set);
|
|
13425
13442
|
this.rawPose = raw;
|
|
13426
13443
|
this.heldParameters = null;
|
|
13427
|
-
|
|
13428
|
-
this.pose = set === null ? raw : applySetToPose(this.view, raw, set);
|
|
13444
|
+
this.pose = pose;
|
|
13429
13445
|
this.poseGeneration++;
|
|
13430
13446
|
this.cachedIdentity = null;
|
|
13431
13447
|
}
|
|
@@ -13482,9 +13498,9 @@ class RigPlayer {
|
|
|
13482
13498
|
* standing value, `null` returns both to the start values, and the call
|
|
13483
13499
|
* applies from the next step on, at any time, with no ramp of the player's
|
|
13484
13500
|
* own — the springs are the smoothing. It is the player's, not a track's:
|
|
13485
|
-
* every track and layer answers the same world, and
|
|
13486
|
-
*
|
|
13487
|
-
* environment now standing.
|
|
13501
|
+
* every track and layer answers the same world, and ordinary replays use the
|
|
13502
|
+
* environment as it stands (no history is kept). `seek` accepts a schedule
|
|
13503
|
+
* for that replay alone. Returns the environment now standing.
|
|
13488
13504
|
*/
|
|
13489
13505
|
environment(environment) {
|
|
13490
13506
|
if (environment === null) {
|
|
@@ -13636,15 +13652,20 @@ class RigPlayer {
|
|
|
13636
13652
|
this.setRawPose(raw);
|
|
13637
13653
|
}
|
|
13638
13654
|
/**
|
|
13639
|
-
* Moves a single animation on track 0 to `time
|
|
13640
|
-
*
|
|
13641
|
-
*
|
|
13642
|
-
*
|
|
13655
|
+
* Moves a single animation on track 0 to `time` with the pose and physics
|
|
13656
|
+
* state of reopening at 0 and stepping in `seekStep` increments (the last
|
|
13657
|
+
* one can be shorter). Ordinary seeks reuse snapshots (#141). Events and
|
|
13658
|
+
* completes crossed on the way are not fired.
|
|
13643
13659
|
* It has a meaning for one animation on one track only — the player cannot
|
|
13644
13660
|
* replay when a mix, a second track or a queue was asked for — so after any
|
|
13645
13661
|
* of those it refuses by name; step the player forward instead.
|
|
13662
|
+
* On the oracle, `environmentAt` runs an uncached replay and supplies wind
|
|
13663
|
+
* and gravity at the start of each positive step, including a shorter last
|
|
13664
|
+
* step. On success the resulting physics state continues under the standing
|
|
13665
|
+
* environment. A failed replay leaves the held state in place. The runtime
|
|
13666
|
+
* poser seeks as usual and does not call `environmentAt`.
|
|
13646
13667
|
*/
|
|
13647
|
-
seek(time) {
|
|
13668
|
+
seek(time, environmentAt) {
|
|
13648
13669
|
if (this.animation === null) throw new Error("seek before play: no animation is open");
|
|
13649
13670
|
if (!(time >= 0) || !Number.isFinite(time)) throw new Error(`seek time must be a finite time at or above 0, got ${String(time)}`);
|
|
13650
13671
|
if (this.beyondBase) throw new Error("seek is defined for a single animation on track 0; after a mix, another track, a queue or a clear the player cannot replay to a time — step it forward with frame/advance instead");
|
|
@@ -13658,6 +13679,10 @@ class RigPlayer {
|
|
|
13658
13679
|
this.applyRuntimeTime();
|
|
13659
13680
|
return;
|
|
13660
13681
|
}
|
|
13682
|
+
if (environmentAt !== void 0) {
|
|
13683
|
+
this.seekWithEnvironment(time, environmentAt);
|
|
13684
|
+
return;
|
|
13685
|
+
}
|
|
13661
13686
|
this.easing = null;
|
|
13662
13687
|
const cache = this.ensureSeekCache();
|
|
13663
13688
|
const stepper = this.tracks ?? this.track;
|
|
@@ -13717,6 +13742,22 @@ class RigPlayer {
|
|
|
13717
13742
|
});
|
|
13718
13743
|
}
|
|
13719
13744
|
}
|
|
13745
|
+
seekWithEnvironment(time, environmentAt) {
|
|
13746
|
+
let replaying = true;
|
|
13747
|
+
const { stepper, firstPose } = this.openReplay((locals, ctx) => this.adjustLocals(locals, ctx, replaying ? null : this.easing));
|
|
13748
|
+
const standing = stepper.environment;
|
|
13749
|
+
let rawPose = firstPose;
|
|
13750
|
+
this.replaySteps(stepper, time, (dt) => {
|
|
13751
|
+
stepper.setEnvironment(environmentAt(stepper.trackTime));
|
|
13752
|
+
rawPose = stepper.step(dt);
|
|
13753
|
+
});
|
|
13754
|
+
stepper.setEnvironment(standing);
|
|
13755
|
+
this.setRawPose(rawPose, this.activeSet);
|
|
13756
|
+
this.easing = null;
|
|
13757
|
+
replaying = false;
|
|
13758
|
+
if ("first" in stepper) this.track = stepper;
|
|
13759
|
+
else this.tracks = stepper;
|
|
13760
|
+
}
|
|
13720
13761
|
clearSeekCache() {
|
|
13721
13762
|
this.seekCache = null;
|
|
13722
13763
|
}
|
|
@@ -13728,21 +13769,7 @@ class RigPlayer {
|
|
|
13728
13769
|
if (this.tracks === null && this.track === null) {
|
|
13729
13770
|
this.reopen();
|
|
13730
13771
|
}
|
|
13731
|
-
|
|
13732
|
-
let firstPose;
|
|
13733
|
-
if (mode === "tracks") {
|
|
13734
|
-
const tracks = openTracks(this.view, { reset: "animation", adjust: this.adjustHook, clock: this.clockHook });
|
|
13735
|
-
tracks.setAnimation(0, this.animation, { loop: this.loop, mixDuration: 0 });
|
|
13736
|
-
firstPose = tracks.start();
|
|
13737
|
-
this.applyPhysicsParameters(tracks);
|
|
13738
|
-
this.applyEnvironment(tracks);
|
|
13739
|
-
frontier = tracks;
|
|
13740
|
-
} else {
|
|
13741
|
-
const track = openTrack(this.view, this.animation, { loop: this.loop, reset: "animation", adjust: this.adjustHook, clock: this.clockHook });
|
|
13742
|
-
firstPose = this.initializeSingle(track);
|
|
13743
|
-
this.applyEnvironment(track);
|
|
13744
|
-
frontier = track;
|
|
13745
|
-
}
|
|
13772
|
+
const { stepper: frontier, firstPose } = this.openReplay();
|
|
13746
13773
|
const grid = /* @__PURE__ */ new Map();
|
|
13747
13774
|
grid.set(0, { state: captureStepperState(frontier), rawPose: firstPose, parameters: this.readParameters(frontier) });
|
|
13748
13775
|
this.seekCache = {
|
|
@@ -13754,6 +13781,21 @@ class RigPlayer {
|
|
|
13754
13781
|
};
|
|
13755
13782
|
return this.seekCache;
|
|
13756
13783
|
}
|
|
13784
|
+
/** Opens a separate stepper at pose 0 for a seek, without publishing it. */
|
|
13785
|
+
openReplay(adjust = this.adjustHook) {
|
|
13786
|
+
if (this.tracks !== null) {
|
|
13787
|
+
const tracks = openTracks(this.view, { reset: "animation", adjust, clock: this.clockHook });
|
|
13788
|
+
tracks.setAnimation(0, this.animation, { loop: this.loop, mixDuration: 0 });
|
|
13789
|
+
const firstPose2 = tracks.start();
|
|
13790
|
+
this.applyPhysicsParameters(tracks);
|
|
13791
|
+
this.applyEnvironment(tracks);
|
|
13792
|
+
return { stepper: tracks, firstPose: firstPose2 };
|
|
13793
|
+
}
|
|
13794
|
+
const track = openTrack(this.view, this.animation, { loop: this.loop, reset: "animation", adjust, clock: this.clockHook });
|
|
13795
|
+
const firstPose = this.initializeSingle(track);
|
|
13796
|
+
this.applyEnvironment(track);
|
|
13797
|
+
return { stepper: track, firstPose };
|
|
13798
|
+
}
|
|
13757
13799
|
/** Whatever is open, opened again with track 0's animation as `play` last set it, at pose 0: the single track, or the tracks under `tracks: true`. */
|
|
13758
13800
|
reopen() {
|
|
13759
13801
|
if (this.tracks !== null) {
|
|
@@ -13782,11 +13824,16 @@ class RigPlayer {
|
|
|
13782
13824
|
/** Steps whatever is open forward to `time` in `seekStep` increments, the last one shorter. */
|
|
13783
13825
|
stepTo(time) {
|
|
13784
13826
|
const stepper = this.tracks ?? this.track;
|
|
13827
|
+
this.replaySteps(stepper, time, (dt) => {
|
|
13828
|
+
this.rawPose = stepper.step(dt);
|
|
13829
|
+
});
|
|
13830
|
+
if (this.rawPose !== null) this.setRawPose(this.rawPose);
|
|
13831
|
+
}
|
|
13832
|
+
replaySteps(stepper, time, step) {
|
|
13785
13833
|
const steps = Math.floor(time / this.seekStep);
|
|
13786
|
-
for (let i = 0; i < steps; i++)
|
|
13834
|
+
for (let i = 0; i < steps; i++) step(this.seekStep);
|
|
13787
13835
|
const rest = time - stepper.trackTime;
|
|
13788
|
-
if (rest > 0)
|
|
13789
|
-
if (this.rawPose !== null) this.setRawPose(this.rawPose);
|
|
13836
|
+
if (rest > 0) step(rest);
|
|
13790
13837
|
}
|
|
13791
13838
|
on(type, listener) {
|
|
13792
13839
|
const set = this.listeners[type];
|