pixi-effects 0.30.1 → 0.32.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/CHANGELOG.md +33 -0
- package/README.md +6 -5
- package/ai/chat-template.html +3 -3
- package/ai/tools/check.mjs +42 -2
- package/ai/tools/render.mjs +34 -4
- package/ai/tools/varArgs.mjs +75 -0
- package/dist/{Base-Ne74ztNl.d.ts → Base-CXsMdmJB.d.ts} +1 -1
- package/dist/{Base-CB1_FPZD.d.cts → Base-pNq6sVGl.d.cts} +1 -1
- package/dist/Composition-LNMKWXSL.cjs +16 -0
- package/dist/{Composition-MUKR3FYD.cjs.map → Composition-LNMKWXSL.cjs.map} +1 -1
- package/dist/Composition-RF7QOEXT.js +7 -0
- package/dist/{Composition-RJGA7KDU.js.map → Composition-RF7QOEXT.js.map} +1 -1
- package/dist/Controller.cjs +42 -1
- package/dist/Controller.cjs.map +1 -1
- package/dist/Controller.d.cts +10 -2
- package/dist/Controller.d.ts +10 -2
- package/dist/Controller.js +42 -1
- package/dist/Controller.js.map +1 -1
- package/dist/{Movie-DdnpLpw1.d.cts → Movie-CL6SsAWe.d.cts} +90 -3
- package/dist/{Movie-C2rZFkrO.d.ts → Movie-f0tQG9y5.d.ts} +90 -3
- package/dist/Spans-NQGKVMR5.cjs +55 -0
- package/dist/Spans-NQGKVMR5.cjs.map +1 -0
- package/dist/Spans-SDXABOV6.js +53 -0
- package/dist/Spans-SDXABOV6.js.map +1 -0
- package/dist/{blendModes-RIVZXL5A.js → blendModes-MVRLG3T7.js} +4 -4
- package/dist/{blendModes-RIVZXL5A.js.map → blendModes-MVRLG3T7.js.map} +1 -1
- package/dist/{blendModes-ETMYWATF.cjs → blendModes-VTKDXWEN.cjs} +5 -5
- package/dist/{blendModes-ETMYWATF.cjs.map → blendModes-VTKDXWEN.cjs.map} +1 -1
- package/dist/{chunk-ZAXYPXKW.js → chunk-AW5NPDE4.js} +1367 -1150
- package/dist/chunk-AW5NPDE4.js.map +1 -0
- package/dist/{chunk-RCVZX2JP.js → chunk-C5BNHVKK.js} +36 -3
- package/dist/chunk-C5BNHVKK.js.map +1 -0
- package/dist/{chunk-WHNADXXG.cjs → chunk-CRUDOKSD.cjs} +91 -91
- package/dist/chunk-CRUDOKSD.cjs.map +1 -0
- package/dist/{chunk-A3Q3SDSH.js → chunk-D5BFQVKL.js} +6 -6
- package/dist/chunk-D5BFQVKL.js.map +1 -0
- package/dist/{chunk-LYOKH7KE.cjs → chunk-FCGYJCVO.cjs} +36 -3
- package/dist/chunk-FCGYJCVO.cjs.map +1 -0
- package/dist/{chunk-CRQFDY7E.js → chunk-FCMOREIS.js} +467 -58
- package/dist/chunk-FCMOREIS.js.map +1 -0
- package/dist/{chunk-HREBQAY4.cjs → chunk-K3MAEKFM.cjs} +493 -84
- package/dist/chunk-K3MAEKFM.cjs.map +1 -0
- package/dist/{chunk-4KB3GUEK.js → chunk-QFNS6BFL.js} +4 -4
- package/dist/{chunk-4KB3GUEK.js.map → chunk-QFNS6BFL.js.map} +1 -1
- package/dist/{chunk-ZVUO325O.cjs → chunk-QHDN6TF5.cjs} +1382 -1160
- package/dist/chunk-QHDN6TF5.cjs.map +1 -0
- package/dist/{chunk-2DXPTKQZ.cjs → chunk-Z437UWI4.cjs} +5 -5
- package/dist/{chunk-2DXPTKQZ.cjs.map → chunk-Z437UWI4.cjs.map} +1 -1
- package/dist/index.cjs +33 -33
- package/dist/index.d.cts +5 -5
- package/dist/index.d.ts +5 -5
- package/dist/index.js +5 -5
- package/dist/loader.css +1 -1
- package/dist/present.cjs +5 -5
- package/dist/present.d.cts +2 -2
- package/dist/present.d.ts +2 -2
- package/dist/present.js +5 -5
- package/dist/three.cjs +6 -6
- package/dist/three.d.cts +2 -2
- package/dist/three.d.ts +2 -2
- package/dist/three.js +2 -2
- package/dist/{types-BzIB65Vk.d.ts → types-CavnUvd5.d.cts} +28 -1
- package/dist/{types-BzIB65Vk.d.cts → types-CavnUvd5.d.ts} +28 -1
- package/docs/api.md +28 -1
- package/docs/dsl.md +46 -5
- package/llms-full.txt +136 -10
- package/package.json +83 -20
- package/skills/pixi-effects/SKILL.md +1 -1
- package/skills/pixi-effects/reference/cheatsheet.md +5 -2
- package/skills/pixi-effects/reference/pitfalls.md +5 -1
- package/skills/pixi-effects/reference/recipes.md +52 -0
- package/skills/pixi-effects/template.html +6 -6
- package/dist/Composition-MUKR3FYD.cjs +0 -16
- package/dist/Composition-RJGA7KDU.js +0 -7
- package/dist/chunk-A3Q3SDSH.js.map +0 -1
- package/dist/chunk-CRQFDY7E.js.map +0 -1
- package/dist/chunk-HREBQAY4.cjs.map +0 -1
- package/dist/chunk-LYOKH7KE.cjs.map +0 -1
- package/dist/chunk-RCVZX2JP.js.map +0 -1
- package/dist/chunk-WHNADXXG.cjs.map +0 -1
- package/dist/chunk-ZAXYPXKW.js.map +0 -1
- package/dist/chunk-ZVUO325O.cjs.map +0 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
var
|
|
3
|
+
var chunkCRUDOKSD_cjs = require('./chunk-CRUDOKSD.cjs');
|
|
4
|
+
var chunkQHDN6TF5_cjs = require('./chunk-QHDN6TF5.cjs');
|
|
5
|
+
var chunkZ437UWI4_cjs = require('./chunk-Z437UWI4.cjs');
|
|
6
|
+
var chunkFCGYJCVO_cjs = require('./chunk-FCGYJCVO.cjs');
|
|
7
7
|
var chunkTWZNOUM7_cjs = require('./chunk-TWZNOUM7.cjs');
|
|
8
8
|
var pixi_js = require('pixi.js');
|
|
9
9
|
var mediabunny = require('mediabunny');
|
|
@@ -1485,8 +1485,8 @@ function expandTransitions(spec) {
|
|
|
1485
1485
|
}
|
|
1486
1486
|
const transitions = out.transitions;
|
|
1487
1487
|
const sequences = out.sequences ?? [];
|
|
1488
|
-
const remap = out.duration !== void 0 ?
|
|
1489
|
-
const parentDuration = remap ?
|
|
1488
|
+
const remap = out.duration !== void 0 ? chunkQHDN6TF5_cjs.timeRemapOf(out) : null;
|
|
1489
|
+
const parentDuration = remap ? chunkQHDN6TF5_cjs.contentLength(remap, out.duration) : out.duration ?? Infinity;
|
|
1490
1490
|
const compW = out.width;
|
|
1491
1491
|
const compH = out.height;
|
|
1492
1492
|
const threeDByName = new Set(sequences.filter((s) => s.name && s.threeD).map((s) => s.name));
|
|
@@ -1554,16 +1554,16 @@ function expandTransitions(spec) {
|
|
|
1554
1554
|
if (toUses > 1) {
|
|
1555
1555
|
throw new Error(`pixi-effects: ${tag} sequence "${t.to}" is used as \`to\` in more than one transition`);
|
|
1556
1556
|
}
|
|
1557
|
-
const tStart =
|
|
1557
|
+
const tStart = chunkQHDN6TF5_cjs.resolveAt(t.at, parentDuration);
|
|
1558
1558
|
const tEnd = tStart + t.duration;
|
|
1559
1559
|
const fromSeq = fromEntry.seq;
|
|
1560
|
-
const fromStart =
|
|
1560
|
+
const fromStart = chunkQHDN6TF5_cjs.resolveAt(fromSeq.at, parentDuration);
|
|
1561
1561
|
const fromEnd = fromStart + (fromSeq.duration ?? parentDuration);
|
|
1562
1562
|
if (tStart < fromStart - EPS || tEnd > fromEnd + EPS) {
|
|
1563
1563
|
throw new Error(`pixi-effects: ${tag} window [${tStart}, ${tEnd}] is not covered by \`from\` "${t.from}" (lives [${fromStart}, ${fromEnd}], so it ends at ${fromEnd})`);
|
|
1564
1564
|
}
|
|
1565
1565
|
const toSeq = toEntry.seq;
|
|
1566
|
-
const toStart =
|
|
1566
|
+
const toStart = chunkQHDN6TF5_cjs.resolveAt(toSeq.at, parentDuration);
|
|
1567
1567
|
const toEnd = toStart + (toSeq.duration ?? parentDuration);
|
|
1568
1568
|
if (tStart < toStart - EPS || tEnd > toEnd + EPS) {
|
|
1569
1569
|
throw new Error(`pixi-effects: ${tag} window [${tStart}, ${tEnd}] is not covered by \`to\` "${t.to}" (lives [${toStart}, ${toEnd}], so it starts at ${toStart})`);
|
|
@@ -1623,7 +1623,7 @@ function wrapAsFullComposition(seq, compW, compH) {
|
|
|
1623
1623
|
delete inner.at;
|
|
1624
1624
|
delete inner.duration;
|
|
1625
1625
|
const m = inner.mask;
|
|
1626
|
-
const carriesMatte = m !== void 0 &&
|
|
1626
|
+
const carriesMatte = m !== void 0 && chunkCRUDOKSD_cjs.maskSourceOf(m).kind === "refs";
|
|
1627
1627
|
if (carriesMatte) delete inner.mask;
|
|
1628
1628
|
return {
|
|
1629
1629
|
...carriesMatte ? { mask: m } : {},
|
|
@@ -1925,9 +1925,9 @@ function inspectScene(root, frame, time, canvas, opts = {}) {
|
|
|
1925
1925
|
onCanvas = inter === 0 && area > 0 ? "none" : inter >= area - 1e-6 ? "full" : "partial";
|
|
1926
1926
|
if (area === 0) onCanvas = "none";
|
|
1927
1927
|
}
|
|
1928
|
-
const keys =
|
|
1928
|
+
const keys = chunkFCGYJCVO_cjs.collectPropKeys(seq.spec);
|
|
1929
1929
|
const carried = carriers.some((c) => {
|
|
1930
|
-
const k =
|
|
1930
|
+
const k = chunkFCGYJCVO_cjs.collectPropKeys(c.spec);
|
|
1931
1931
|
return (c.spec.keyframes ?? []).length > 0 && (k.has("x") || k.has("y") || k.has("rotation") || k.has("scale"));
|
|
1932
1932
|
});
|
|
1933
1933
|
const moving = parentMoving || carried || (seq.spec.keyframes ?? []).length > 0 && (keys.has("x") || keys.has("y"));
|
|
@@ -1942,7 +1942,7 @@ function inspectScene(root, frame, time, canvas, opts = {}) {
|
|
|
1942
1942
|
layers.push(info);
|
|
1943
1943
|
let shown = bounds ? clip(bounds, view) : null;
|
|
1944
1944
|
const maskTarget = seq.maskSequence?.target;
|
|
1945
|
-
const maskSrc =
|
|
1945
|
+
const maskSrc = chunkCRUDOKSD_cjs.maskSourceOf(seq.spec.mask);
|
|
1946
1946
|
if (shown && maskTarget && !(maskSrc.kind === "inline" && maskSrc.invert)) {
|
|
1947
1947
|
const m = maskTarget.getBounds();
|
|
1948
1948
|
shown = clip(shown, { x: m.x, y: m.y, width: m.width, height: m.height });
|
|
@@ -1951,7 +1951,7 @@ function inspectScene(root, frame, time, canvas, opts = {}) {
|
|
|
1951
1951
|
const group = parentScene ?? (name !== void 0 && blending.has(name) ? name : void 0);
|
|
1952
1952
|
if (group) scene.set(info, group);
|
|
1953
1953
|
if (zero || seq.showsNothingYet) scaledToNothing.add(info);
|
|
1954
|
-
if (seq instanceof
|
|
1954
|
+
if (seq instanceof chunkCRUDOKSD_cjs.CompositionSequence) walk2(seq, prefix + label + "/", insideThreeD || threeD, visible, group, moving, zero);
|
|
1955
1955
|
});
|
|
1956
1956
|
};
|
|
1957
1957
|
walk2(root, "", false, true);
|
|
@@ -1998,6 +1998,8 @@ var round = (n) => Math.round(n * 1e6) / 1e6;
|
|
|
1998
1998
|
var family = (name) => name.replace(/\d+/g, "#");
|
|
1999
1999
|
function detailOf(seq) {
|
|
2000
2000
|
const s = seq.spec;
|
|
2001
|
+
const spans = chunkQHDN6TF5_cjs.spansMeta.get(seq.spec)?.preview;
|
|
2002
|
+
if (spans) return spans.length > 60 ? spans.slice(0, 57) + "\u2026" : spans;
|
|
2001
2003
|
if (typeof s.text === "string") return s.text.length > 60 ? s.text.slice(0, 57) + "\u2026" : s.text;
|
|
2002
2004
|
if (typeof s.asset === "string") return `asset \u201C${s.asset}\u201D`;
|
|
2003
2005
|
if (typeof s.sfx === "string") return `sfx \u201C${s.sfx}\u201D`;
|
|
@@ -2012,10 +2014,10 @@ function walk(comp, parentStart, parentEnd, depth, prefix, rows, transitions, lo
|
|
|
2012
2014
|
const start = parentStart + (seq.at ?? 0);
|
|
2013
2015
|
const end = Math.min(parentEnd, seq.duration !== void 0 ? start + seq.duration : parentEnd);
|
|
2014
2016
|
const span = end - start;
|
|
2015
|
-
const keys = (seq.spec.keyframes ?? []).map((kf) => round(start +
|
|
2017
|
+
const keys = (seq.spec.keyframes ?? []).map((kf) => round(start + chunkQHDN6TF5_cjs.resolveAt(kf.at, span))).sort((a, b) => a - b).slice(0, MAX_KEYS);
|
|
2016
2018
|
const row = { path: prefix + name, name, type: seq.spec.type, depth, start: round(start), end: round(end), keys, detail: detailOf(seq), ...local ? { local } : {} };
|
|
2017
2019
|
const inner = [];
|
|
2018
|
-
const isComp = seq instanceof
|
|
2020
|
+
const isComp = seq instanceof chunkCRUDOKSD_cjs.CompositionSequence;
|
|
2019
2021
|
if (isComp) {
|
|
2020
2022
|
const label = seq.remapLabel();
|
|
2021
2023
|
walk(seq, label ? 0 : start, label ? seq.contentSpan : end, depth + 1, prefix + name + "/", inner, transitions, label ? `${name} ${label}` : local);
|
|
@@ -2173,6 +2175,124 @@ function sheetLayout(n, columns, cellW, srcW, srcH, labelH) {
|
|
|
2173
2175
|
return { cols, rows, cellW, cellH, width: cols * cellW, height: rows * (cellH + labelH), positions };
|
|
2174
2176
|
}
|
|
2175
2177
|
|
|
2178
|
+
// src/core/vars.ts
|
|
2179
|
+
var RESERVED_NAMES = ["w", "h", "W", "H", "GW", "GH", "t", "d", "T", "contain", "cover", "value", ...chunkQHDN6TF5_cjs.EXPRESSION_NAMES];
|
|
2180
|
+
var NAME = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
2181
|
+
var isPlain = (v) => !!v && typeof v === "object" && (Object.getPrototypeOf(v) === Object.prototype || Object.getPrototypeOf(v) === null);
|
|
2182
|
+
function normalizeVars(raw, where, warn = (m) => console.warn(m)) {
|
|
2183
|
+
if (raw === void 0) return {};
|
|
2184
|
+
if (!isPlain(raw)) {
|
|
2185
|
+
warn(`pixi-effects: ${where}: vars must be an object of names and values ({ title: 'NORD', shift: 40 }); ignored`);
|
|
2186
|
+
return {};
|
|
2187
|
+
}
|
|
2188
|
+
const out = {};
|
|
2189
|
+
for (const [name, value] of Object.entries(raw)) {
|
|
2190
|
+
if (!NAME.test(name)) {
|
|
2191
|
+
warn(`pixi-effects: ${where}: "${name}" is not a name for a variable (letters, digits and _, not starting with a digit); ignored`);
|
|
2192
|
+
continue;
|
|
2193
|
+
}
|
|
2194
|
+
if (RESERVED_NAMES.includes(name)) {
|
|
2195
|
+
warn(`pixi-effects: ${where}: "${name}" is reserved (an expression word, a function, PI or the {value} counter); choose another name; ignored`);
|
|
2196
|
+
continue;
|
|
2197
|
+
}
|
|
2198
|
+
if (typeof value === "boolean") {
|
|
2199
|
+
warn(`pixi-effects: ${where}: variable "${name}" is a boolean; write 0 or 1 (a variable is a number or a string); ignored`);
|
|
2200
|
+
continue;
|
|
2201
|
+
}
|
|
2202
|
+
if (typeof value === "number" && Number.isFinite(value)) out[name] = value;
|
|
2203
|
+
else if (typeof value === "string") out[name] = value;
|
|
2204
|
+
else warn(`pixi-effects: ${where}: variable "${name}" must be a number or a string, got ${JSON.stringify(value)}; ignored`);
|
|
2205
|
+
}
|
|
2206
|
+
return out;
|
|
2207
|
+
}
|
|
2208
|
+
function numericVars(vars) {
|
|
2209
|
+
const out = {};
|
|
2210
|
+
for (const [k, v] of Object.entries(vars)) if (typeof v === "number") out[k] = v;
|
|
2211
|
+
return out;
|
|
2212
|
+
}
|
|
2213
|
+
var TOKEN = /\{([A-Za-z_][A-Za-z0-9_]*)\}/g;
|
|
2214
|
+
function substitute(s, vars) {
|
|
2215
|
+
return s.replace(TOKEN, (whole, name) => Object.prototype.hasOwnProperty.call(vars, name) ? String(vars[name]) : whole);
|
|
2216
|
+
}
|
|
2217
|
+
function applyVars(spec, vars) {
|
|
2218
|
+
if (Object.keys(vars).length === 0) return spec;
|
|
2219
|
+
const walk2 = (v) => {
|
|
2220
|
+
if (typeof v === "string") return substitute(v, vars);
|
|
2221
|
+
if (Array.isArray(v)) return v.map(walk2);
|
|
2222
|
+
if (isPlain(v)) {
|
|
2223
|
+
const o = {};
|
|
2224
|
+
for (const [k, x] of Object.entries(v)) o[k] = walk2(x);
|
|
2225
|
+
return o;
|
|
2226
|
+
}
|
|
2227
|
+
return v;
|
|
2228
|
+
};
|
|
2229
|
+
return walk2(spec);
|
|
2230
|
+
}
|
|
2231
|
+
var escapeRe = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
2232
|
+
function lintVars(spec, vars) {
|
|
2233
|
+
const declared = Object.keys(vars);
|
|
2234
|
+
const strings = [];
|
|
2235
|
+
const walk2 = (v) => {
|
|
2236
|
+
if (typeof v === "string") strings.push(v);
|
|
2237
|
+
else if (Array.isArray(v)) v.forEach(walk2);
|
|
2238
|
+
else if (isPlain(v)) Object.values(v).forEach(walk2);
|
|
2239
|
+
};
|
|
2240
|
+
walk2(spec);
|
|
2241
|
+
const out = [];
|
|
2242
|
+
for (const name of declared) {
|
|
2243
|
+
const word = new RegExp(`(?<![A-Za-z0-9_.])${escapeRe(name)}(?![A-Za-z0-9_])`);
|
|
2244
|
+
if (!strings.some((s) => word.test(s))) out.push(`pixi-effects: vars: variable "${name}" is declared but nothing uses it (write {${name}} in a string, or "${name}" in an expression); a typo on one side?`);
|
|
2245
|
+
}
|
|
2246
|
+
const seen = /* @__PURE__ */ new Set();
|
|
2247
|
+
for (const s of strings) {
|
|
2248
|
+
for (const m of s.matchAll(TOKEN)) {
|
|
2249
|
+
const name = m[1];
|
|
2250
|
+
if (seen.has(name) || Object.prototype.hasOwnProperty.call(vars, name) || RESERVED_NAMES.includes(name) || declared.length === 0) continue;
|
|
2251
|
+
seen.add(name);
|
|
2252
|
+
const guess = chunkTWZNOUM7_cjs.suggestName(name, declared);
|
|
2253
|
+
out.push(`pixi-effects: vars: {${name}} is not a declared variable${guess ? ` \u2014 did you mean "${guess}"?` : ` (declared: ${declared.join(", ")})`}`);
|
|
2254
|
+
}
|
|
2255
|
+
}
|
|
2256
|
+
return out;
|
|
2257
|
+
}
|
|
2258
|
+
|
|
2259
|
+
// src/core/mixCache.ts
|
|
2260
|
+
var ids = /* @__PURE__ */ new WeakMap();
|
|
2261
|
+
var nextId = 1;
|
|
2262
|
+
var idOf = (o) => {
|
|
2263
|
+
let n = ids.get(o);
|
|
2264
|
+
if (!n) {
|
|
2265
|
+
n = nextId++;
|
|
2266
|
+
ids.set(o, n);
|
|
2267
|
+
}
|
|
2268
|
+
return n;
|
|
2269
|
+
};
|
|
2270
|
+
function mixKey(audios, duration, sampleRate) {
|
|
2271
|
+
const parts = [];
|
|
2272
|
+
for (const a of audios) {
|
|
2273
|
+
if (a.warp || a.sourceMap) return null;
|
|
2274
|
+
const what = a.buffer ? `b${idOf(a.buffer)}` : a.synth ? `s${a.synth.key}` : null;
|
|
2275
|
+
if (what === null) return null;
|
|
2276
|
+
parts.push([what, a.loop, a.start, a.end, a.initialVolume, a.volumeKeyframes.map((k) => [k.time, k.value])]);
|
|
2277
|
+
}
|
|
2278
|
+
return JSON.stringify([duration, sampleRate, parts]);
|
|
2279
|
+
}
|
|
2280
|
+
var MixCache = class {
|
|
2281
|
+
key = null;
|
|
2282
|
+
buffer = null;
|
|
2283
|
+
extra;
|
|
2284
|
+
get(key) {
|
|
2285
|
+
if (key === null || key !== this.key || !this.buffer) return null;
|
|
2286
|
+
return { buffer: this.buffer, extra: this.extra };
|
|
2287
|
+
}
|
|
2288
|
+
/** Keep this mix for `key`; a null key (not comparable) keeps nothing. */
|
|
2289
|
+
set(key, buffer, extra) {
|
|
2290
|
+
this.key = key;
|
|
2291
|
+
this.buffer = key === null ? null : buffer;
|
|
2292
|
+
this.extra = extra;
|
|
2293
|
+
}
|
|
2294
|
+
};
|
|
2295
|
+
|
|
2176
2296
|
// src/core/startWhenRunning.ts
|
|
2177
2297
|
function startWhenRunning(ctx, start, gesture) {
|
|
2178
2298
|
if (ctx.state === "running") {
|
|
@@ -2456,6 +2576,7 @@ var Movie = class {
|
|
|
2456
2576
|
_quiet = 0;
|
|
2457
2577
|
_volume = 1;
|
|
2458
2578
|
_muted = false;
|
|
2579
|
+
_loop = false;
|
|
2459
2580
|
isPlaying = false;
|
|
2460
2581
|
currentFrame = 0;
|
|
2461
2582
|
totalFrames = 0;
|
|
@@ -2477,6 +2598,21 @@ var Movie = class {
|
|
|
2477
2598
|
}
|
|
2478
2599
|
_rootContainer = null;
|
|
2479
2600
|
_raf = null;
|
|
2601
|
+
/** The variables now, and the names that were declared (a `setVars` of any other name is refused). */
|
|
2602
|
+
_vars = {};
|
|
2603
|
+
_declared = /* @__PURE__ */ new Set();
|
|
2604
|
+
/** The composition as the author wrote it (before `{name}` is replaced): a rebuild starts from it. */
|
|
2605
|
+
_composition;
|
|
2606
|
+
/** True once `resize()` was called: the size of the movie then replaces an explicit `width` / `height` of the composition. */
|
|
2607
|
+
_resized = false;
|
|
2608
|
+
_mixCache = new MixCache();
|
|
2609
|
+
_rebuildRun = null;
|
|
2610
|
+
_rebuildNext = null;
|
|
2611
|
+
/** > 0 while a rebuild stops and restarts playback: `play` / `pause` are not announced then (a player's button must not flicker). */
|
|
2612
|
+
_silent = 0;
|
|
2613
|
+
/** render() / peek() in flight: a rebuild does not swap the composition under them. */
|
|
2614
|
+
_busy = 0;
|
|
2615
|
+
_idleWaiters = [];
|
|
2480
2616
|
/** What went into the mix, and its peak before limiting — kept for inspectAudio(). */
|
|
2481
2617
|
_audioSources = [];
|
|
2482
2618
|
_mixStats = null;
|
|
@@ -2552,7 +2688,7 @@ var Movie = class {
|
|
|
2552
2688
|
return this._audioContext;
|
|
2553
2689
|
}
|
|
2554
2690
|
async init(options = {}) {
|
|
2555
|
-
chunkTWZNOUM7_cjs.warnUnknownOptions("movie.init()", options, ["width", "height", "duration", "frameRate", "background", "canvas", "assets", "composition", "poster", "motionBlur", "loader"]);
|
|
2691
|
+
chunkTWZNOUM7_cjs.warnUnknownOptions("movie.init()", options, ["width", "height", "duration", "frameRate", "background", "canvas", "assets", "composition", "vars", "poster", "motionBlur", "loader", "loop"]);
|
|
2556
2692
|
this._initState = "pending";
|
|
2557
2693
|
try {
|
|
2558
2694
|
this.width = options.width ?? 1920;
|
|
@@ -2563,11 +2699,18 @@ var Movie = class {
|
|
|
2563
2699
|
const poster = normalizePoster(options.poster, this.duration, this.frameRate);
|
|
2564
2700
|
this.poster = poster.seconds;
|
|
2565
2701
|
this.motionBlur = resolveMotionBlur(options.motionBlur, "movie.init()");
|
|
2566
|
-
this.
|
|
2702
|
+
this._loop = options.loop === true;
|
|
2703
|
+
this._vars = normalizeVars(options.vars, "movie.init()");
|
|
2704
|
+
this._declared = new Set(Object.keys(this._vars));
|
|
2705
|
+
this._composition = options.composition;
|
|
2706
|
+
this._resized = false;
|
|
2707
|
+
for (const w of lintVars(options.composition, this._vars)) console.warn(w);
|
|
2708
|
+
this._mixCache.set(null, null);
|
|
2709
|
+
this.stops = normalizeStops(applyVars(options.composition, this._vars)?.stops, this.duration, this.frameRate);
|
|
2567
2710
|
this._posterFrame = poster.frame;
|
|
2568
2711
|
this.background = options.background ?? "#000000";
|
|
2569
|
-
this.timeline =
|
|
2570
|
-
|
|
2712
|
+
this.timeline = chunkQHDN6TF5_cjs.createTimeline({ paused: true, defaults: { ease: "none" } });
|
|
2713
|
+
chunkQHDN6TF5_cjs.lengthen(this.timeline, this.duration);
|
|
2571
2714
|
const baseAppOptions = {
|
|
2572
2715
|
width: this.width,
|
|
2573
2716
|
height: this.height,
|
|
@@ -2586,7 +2729,6 @@ var Movie = class {
|
|
|
2586
2729
|
this.app = new pixi_js.Application();
|
|
2587
2730
|
await this.app.init({ ...baseAppOptions, preference: "webgl" });
|
|
2588
2731
|
}
|
|
2589
|
-
if (chunk2DXPTKQZ_cjs.usesAdvancedBlend(options.composition)) await chunk2DXPTKQZ_cjs.enableAdvancedBlend(this.app.renderer);
|
|
2590
2732
|
const root = new pixi_js.Container();
|
|
2591
2733
|
root.cullable = true;
|
|
2592
2734
|
root.cullableChildren = true;
|
|
@@ -2610,51 +2752,13 @@ var Movie = class {
|
|
|
2610
2752
|
assetsSeen = n;
|
|
2611
2753
|
}
|
|
2612
2754
|
});
|
|
2613
|
-
const
|
|
2614
|
-
width: this.width,
|
|
2615
|
-
height: this.height,
|
|
2616
|
-
duration: this.duration,
|
|
2617
|
-
frameRate: this.frameRate,
|
|
2618
|
-
onLayerBuilt: async () => {
|
|
2619
|
-
lp.tick();
|
|
2620
|
-
await lp.yieldIfDue();
|
|
2621
|
-
}
|
|
2622
|
-
};
|
|
2623
|
-
const seededComposition = options.composition ? {
|
|
2624
|
-
...options.composition,
|
|
2625
|
-
width: options.composition.width ?? this.width,
|
|
2626
|
-
height: options.composition.height ?? this.height,
|
|
2627
|
-
duration: options.composition.duration ?? this.duration
|
|
2628
|
-
} : void 0;
|
|
2629
|
-
await chunkZVUO325O_cjs.ensureFilterLibrary(seededComposition);
|
|
2630
|
-
const userComposition = seededComposition ? expandTransitions(seededComposition) : void 0;
|
|
2631
|
-
const rootSeqSpec = {
|
|
2632
|
-
type: "composition",
|
|
2633
|
-
width: this.width,
|
|
2634
|
-
height: this.height,
|
|
2635
|
-
duration: this.duration,
|
|
2636
|
-
...userComposition
|
|
2637
|
-
};
|
|
2638
|
-
if (userComposition) carryTransitionWindows(userComposition, rootSeqSpec);
|
|
2639
|
-
const composition = new chunkWHNADXXG_cjs.CompositionSequence(rootSeqSpec, null, rootShape);
|
|
2640
|
-
lp.begin("build", countLayers(rootSeqSpec));
|
|
2641
|
-
await composition.build();
|
|
2755
|
+
const composition = await this._construct(this._composition, this._vars, this.width, this.height, lp);
|
|
2642
2756
|
this._rootSequence = composition;
|
|
2643
2757
|
if (composition.target) root.addChild(composition.target);
|
|
2644
2758
|
composition.bindTimeline(this.timeline);
|
|
2645
2759
|
this._timeFilters = collectTimeFilters(composition);
|
|
2646
|
-
const audios = [];
|
|
2647
|
-
composition.collectAudio(audios, 0);
|
|
2648
2760
|
lp.begin("sound", 1);
|
|
2649
|
-
|
|
2650
|
-
this.audioBuffer = await mixdown(audios, this.duration, audioContext.sampleRate, async (done) => {
|
|
2651
|
-
lp.part(done);
|
|
2652
|
-
await lp.yieldIfDue();
|
|
2653
|
-
});
|
|
2654
|
-
lp.tick();
|
|
2655
|
-
if (this.audioBuffer) this._mixStats = limitMix(this.audioBuffer, audios);
|
|
2656
|
-
}
|
|
2657
|
-
this._audioSources = audios;
|
|
2761
|
+
await this._mixSound(composition, audioContext, lp);
|
|
2658
2762
|
lp.begin("frames", 0);
|
|
2659
2763
|
this.timeline.time(this._timeOf(0));
|
|
2660
2764
|
await this._awaitVideoFrames();
|
|
@@ -2677,6 +2781,254 @@ var Movie = class {
|
|
|
2677
2781
|
throw err;
|
|
2678
2782
|
}
|
|
2679
2783
|
}
|
|
2784
|
+
/**
|
|
2785
|
+
* Build the composition tree for these variables and this size, off stage: `{name}` replaced, the root shape (with the numeric variables for the
|
|
2786
|
+
* expressions), transitions expanded, every layer built. Used by `init` and by `rebuild`.
|
|
2787
|
+
*/
|
|
2788
|
+
async _construct(composition, vars, width, height, lp, sizeWins = this._resized) {
|
|
2789
|
+
const spec = applyVars(composition, vars);
|
|
2790
|
+
const rootShape = {
|
|
2791
|
+
width,
|
|
2792
|
+
height,
|
|
2793
|
+
duration: this.duration,
|
|
2794
|
+
frameRate: this.frameRate,
|
|
2795
|
+
vars: numericVars(vars),
|
|
2796
|
+
...lp ? { onLayerBuilt: async () => {
|
|
2797
|
+
lp.tick();
|
|
2798
|
+
await lp.yieldIfDue();
|
|
2799
|
+
} } : {}
|
|
2800
|
+
};
|
|
2801
|
+
const seededComposition = spec ? {
|
|
2802
|
+
...spec,
|
|
2803
|
+
width: sizeWins ? width : spec.width ?? width,
|
|
2804
|
+
height: sizeWins ? height : spec.height ?? height,
|
|
2805
|
+
duration: spec.duration ?? this.duration
|
|
2806
|
+
} : void 0;
|
|
2807
|
+
await chunkQHDN6TF5_cjs.ensureFilterLibrary(seededComposition);
|
|
2808
|
+
if (chunkZ437UWI4_cjs.usesAdvancedBlend(seededComposition)) await chunkZ437UWI4_cjs.enableAdvancedBlend(this.app.renderer);
|
|
2809
|
+
const userComposition = seededComposition ? expandTransitions(seededComposition) : void 0;
|
|
2810
|
+
const rootSeqSpec = {
|
|
2811
|
+
type: "composition",
|
|
2812
|
+
width,
|
|
2813
|
+
height,
|
|
2814
|
+
duration: this.duration,
|
|
2815
|
+
...userComposition
|
|
2816
|
+
};
|
|
2817
|
+
if (userComposition) carryTransitionWindows(userComposition, rootSeqSpec);
|
|
2818
|
+
const sequence = new chunkCRUDOKSD_cjs.CompositionSequence(rootSeqSpec, null, rootShape);
|
|
2819
|
+
lp?.begin("build", countLayers(rootSeqSpec));
|
|
2820
|
+
try {
|
|
2821
|
+
await sequence.build();
|
|
2822
|
+
} catch (err) {
|
|
2823
|
+
safeRun(() => sequence.destroy());
|
|
2824
|
+
throw err;
|
|
2825
|
+
}
|
|
2826
|
+
return sequence;
|
|
2827
|
+
}
|
|
2828
|
+
/** Make the sound of a built composition: the same mix as last time when the sounds are the same (`'reused'`), else mix it. */
|
|
2829
|
+
async _mixSound(sequence, audioContext, lp) {
|
|
2830
|
+
const audios = [];
|
|
2831
|
+
sequence.collectAudio(audios, 0);
|
|
2832
|
+
let status = "none";
|
|
2833
|
+
if (audios.length === 0) {
|
|
2834
|
+
this.audioBuffer = null;
|
|
2835
|
+
this._mixStats = null;
|
|
2836
|
+
this._mixCache.set(null, null);
|
|
2837
|
+
} else {
|
|
2838
|
+
const key = mixKey(audios, this.duration, audioContext.sampleRate);
|
|
2839
|
+
const hit = this._mixCache.get(key);
|
|
2840
|
+
if (hit) {
|
|
2841
|
+
this.audioBuffer = hit.buffer;
|
|
2842
|
+
this._mixStats = hit.extra;
|
|
2843
|
+
status = "reused";
|
|
2844
|
+
} else {
|
|
2845
|
+
this.audioBuffer = await mixdown(audios, this.duration, audioContext.sampleRate, lp ? async (done) => {
|
|
2846
|
+
lp.part(done);
|
|
2847
|
+
await lp.yieldIfDue();
|
|
2848
|
+
} : void 0);
|
|
2849
|
+
this._mixStats = this.audioBuffer ? limitMix(this.audioBuffer, audios) : null;
|
|
2850
|
+
this._mixCache.set(key, this.audioBuffer, this._mixStats);
|
|
2851
|
+
status = "mixed";
|
|
2852
|
+
}
|
|
2853
|
+
lp?.tick();
|
|
2854
|
+
}
|
|
2855
|
+
this._audioSources = audios;
|
|
2856
|
+
return status;
|
|
2857
|
+
}
|
|
2858
|
+
/** The variables now (a copy; change them with `setVars()`). */
|
|
2859
|
+
get vars() {
|
|
2860
|
+
return { ...this._vars };
|
|
2861
|
+
}
|
|
2862
|
+
/**
|
|
2863
|
+
* Change variables and rebuild at the same time. Only the declared names (`movie.init({ vars })`) are accepted; another name says which one it
|
|
2864
|
+
* looks like and is ignored. Values it already has change nothing: no rebuild (`unchanged: true`).
|
|
2865
|
+
*/
|
|
2866
|
+
async setVars(changes) {
|
|
2867
|
+
this._requireReady("setVars");
|
|
2868
|
+
return this.rebuild({ vars: changes }, "vars");
|
|
2869
|
+
}
|
|
2870
|
+
/** Make the movie `width` x `height` pixels (the canvas, and `W` / `H` / `GW` / `GH` in every expression) and rebuild at the same time. */
|
|
2871
|
+
async resize(width, height) {
|
|
2872
|
+
this._requireReady("resize");
|
|
2873
|
+
return this.rebuild({ width, height }, "resize");
|
|
2874
|
+
}
|
|
2875
|
+
/**
|
|
2876
|
+
* Build the composition again, with what `change` replaces (variables, the composition, the size), and put the movie back where it was: the
|
|
2877
|
+
* same frame, playing or not, the poster if that was shown. The new composition is built first: when that fails the old one stays, `error` is
|
|
2878
|
+
* emitted and the promise rejects. The sound is mixed again only when it changed (`audio: 'reused'` otherwise). Calls that arrive while a
|
|
2879
|
+
* rebuild runs are joined into one more rebuild (the latest values win), so a slider can call it on every move.
|
|
2880
|
+
*/
|
|
2881
|
+
async rebuild(change = {}, reason = "rebuild") {
|
|
2882
|
+
this._requireReady("rebuild");
|
|
2883
|
+
chunkTWZNOUM7_cjs.warnUnknownOptions("movie.rebuild()", change, ["composition", "vars", "width", "height"]);
|
|
2884
|
+
if (this._rebuildRun) {
|
|
2885
|
+
if (!this._rebuildNext) {
|
|
2886
|
+
let resolve, reject;
|
|
2887
|
+
const promise = new Promise((res, rej) => {
|
|
2888
|
+
resolve = res;
|
|
2889
|
+
reject = rej;
|
|
2890
|
+
});
|
|
2891
|
+
this._rebuildNext = { change: {}, reason, promise, resolve, reject };
|
|
2892
|
+
}
|
|
2893
|
+
const next = this._rebuildNext;
|
|
2894
|
+
next.change = { ...next.change, ...change, vars: { ...next.change.vars ?? {}, ...change.vars ?? {} } };
|
|
2895
|
+
if (reason !== "vars") next.reason = reason;
|
|
2896
|
+
return next.promise;
|
|
2897
|
+
}
|
|
2898
|
+
return this._runRebuild(change, reason);
|
|
2899
|
+
}
|
|
2900
|
+
_runRebuild(change, reason) {
|
|
2901
|
+
const run = this._doRebuild(change, reason);
|
|
2902
|
+
this._rebuildRun = run;
|
|
2903
|
+
const settled = () => {
|
|
2904
|
+
if (this._rebuildRun === run) this._rebuildRun = null;
|
|
2905
|
+
const next = this._rebuildNext;
|
|
2906
|
+
if (next && this._initState === "ready") {
|
|
2907
|
+
this._rebuildNext = null;
|
|
2908
|
+
this._runRebuild(next.change, next.reason).then(next.resolve, next.reject);
|
|
2909
|
+
} else if (next) {
|
|
2910
|
+
this._rebuildNext = null;
|
|
2911
|
+
next.reject(new Error("pixi-effects: the movie was destroyed before the rebuild could run"));
|
|
2912
|
+
}
|
|
2913
|
+
};
|
|
2914
|
+
run.then(settled, settled);
|
|
2915
|
+
return run;
|
|
2916
|
+
}
|
|
2917
|
+
async _doRebuild(change, reason) {
|
|
2918
|
+
const started = performance.now();
|
|
2919
|
+
const root = this._rootContainer, app = this.app;
|
|
2920
|
+
if (!root || !app) throw new Error("pixi-effects: movie.rebuild() needs a ready movie \u2014 await movie.init(...) first");
|
|
2921
|
+
const who = `movie.${reason === "vars" ? "setVars" : "rebuild"}()`;
|
|
2922
|
+
let sequence = null;
|
|
2923
|
+
const alive = () => {
|
|
2924
|
+
if (this._initState !== "ready") throw new Error("pixi-effects: the movie was destroyed while it was being rebuilt");
|
|
2925
|
+
};
|
|
2926
|
+
try {
|
|
2927
|
+
const vars = { ...this._vars };
|
|
2928
|
+
let changed = false;
|
|
2929
|
+
if (change.vars !== void 0) {
|
|
2930
|
+
const given = normalizeVars(change.vars, who);
|
|
2931
|
+
for (const [name, value] of Object.entries(given)) {
|
|
2932
|
+
if (!this._declared.has(name)) {
|
|
2933
|
+
const guess = chunkTWZNOUM7_cjs.suggestName(name, [...this._declared]);
|
|
2934
|
+
console.warn(`pixi-effects: ${who}: "${name}" is not a declared variable${guess ? ` \u2014 did you mean "${guess}"?` : ""} (declared in movie.init({ vars }): ${[...this._declared].join(", ") || "none"}); ignored`);
|
|
2935
|
+
continue;
|
|
2936
|
+
}
|
|
2937
|
+
if (vars[name] !== value) {
|
|
2938
|
+
vars[name] = value;
|
|
2939
|
+
changed = true;
|
|
2940
|
+
}
|
|
2941
|
+
}
|
|
2942
|
+
}
|
|
2943
|
+
for (const [k, v] of [["width", change.width], ["height", change.height]]) {
|
|
2944
|
+
if (v !== void 0 && !(Number.isFinite(v) && v >= 1)) throw new Error(`pixi-effects: movie.rebuild(): ${k} must be a number of pixels (1 or more), got ${JSON.stringify(v)}`);
|
|
2945
|
+
}
|
|
2946
|
+
const width = change.width ?? this.width, height = change.height ?? this.height;
|
|
2947
|
+
const sizeChanged = width !== this.width || height !== this.height;
|
|
2948
|
+
const composition = change.composition ?? this._composition;
|
|
2949
|
+
if (change.composition !== void 0) for (const w of lintVars(change.composition, vars)) console.warn(w);
|
|
2950
|
+
changed = changed || sizeChanged || change.composition !== void 0 || reason === "rebuild";
|
|
2951
|
+
if (!changed) return { reason, ms: 0, audio: "none", frame: this.currentFrame, playing: this.isPlaying, unchanged: true };
|
|
2952
|
+
sequence = await this._construct(composition, vars, width, height, void 0, this._resized || sizeChanged);
|
|
2953
|
+
alive();
|
|
2954
|
+
const timeline = chunkQHDN6TF5_cjs.createTimeline({ paused: true, defaults: { ease: "none" } });
|
|
2955
|
+
chunkQHDN6TF5_cjs.lengthen(timeline, this.duration);
|
|
2956
|
+
sequence.bindTimeline(timeline);
|
|
2957
|
+
const hadSound = this.audioBuffer !== null;
|
|
2958
|
+
const audio = await this._mixSound(sequence, this._ensureAudioContext());
|
|
2959
|
+
const soundChanged = audio === "mixed" || audio === "none" && hadSound;
|
|
2960
|
+
while (this._busy > 0) {
|
|
2961
|
+
await new Promise((r) => this._idleWaiters.push(r));
|
|
2962
|
+
}
|
|
2963
|
+
alive();
|
|
2964
|
+
const wasPlaying = this.isPlaying, frame = this.currentFrame, wasAtPoster = this._atPoster;
|
|
2965
|
+
const oldSize = { w: this.width, h: this.height }, oldResized = this._resized;
|
|
2966
|
+
const goOn = wasPlaying && !soundChanged;
|
|
2967
|
+
this._silent++;
|
|
2968
|
+
try {
|
|
2969
|
+
if (goOn) this._cancelUntil();
|
|
2970
|
+
else this.pause();
|
|
2971
|
+
if (sizeChanged) {
|
|
2972
|
+
try {
|
|
2973
|
+
this.width = width;
|
|
2974
|
+
this.height = height;
|
|
2975
|
+
this._resized = true;
|
|
2976
|
+
app.renderer.resize(width, height);
|
|
2977
|
+
root.cullArea = new pixi_js.Rectangle(0, 0, width, height);
|
|
2978
|
+
} catch (e) {
|
|
2979
|
+
this.width = oldSize.w;
|
|
2980
|
+
this.height = oldSize.h;
|
|
2981
|
+
this._resized = oldResized;
|
|
2982
|
+
safeRun(() => app.renderer.resize(oldSize.w, oldSize.h));
|
|
2983
|
+
root.cullArea = new pixi_js.Rectangle(0, 0, oldSize.w, oldSize.h);
|
|
2984
|
+
if (wasPlaying && !goOn) this.play();
|
|
2985
|
+
throw e;
|
|
2986
|
+
}
|
|
2987
|
+
}
|
|
2988
|
+
const old = this._rootSequence, oldTimeline = this.timeline;
|
|
2989
|
+
if (old?.target) root.removeChild(old.target);
|
|
2990
|
+
if (sequence.target) root.addChild(sequence.target);
|
|
2991
|
+
this._rootSequence = sequence;
|
|
2992
|
+
this.timeline = timeline;
|
|
2993
|
+
this._timeFilters = collectTimeFilters(sequence);
|
|
2994
|
+
const unmute = muteBoundTextureWarning();
|
|
2995
|
+
try {
|
|
2996
|
+
safeRun(() => old?.destroy());
|
|
2997
|
+
} finally {
|
|
2998
|
+
unmute();
|
|
2999
|
+
}
|
|
3000
|
+
safeRun(() => oldTimeline?.kill());
|
|
3001
|
+
this._vars = vars;
|
|
3002
|
+
this._composition = composition;
|
|
3003
|
+
this.stops = normalizeStops(applyVars(composition, vars)?.stops, this.duration, this.frameRate);
|
|
3004
|
+
sequence = null;
|
|
3005
|
+
} finally {
|
|
3006
|
+
this._silent--;
|
|
3007
|
+
}
|
|
3008
|
+
try {
|
|
3009
|
+
if (wasAtPoster) await this._showPoster();
|
|
3010
|
+
else await this._quietly(() => this.gotoFrame(frame, true));
|
|
3011
|
+
} catch (e) {
|
|
3012
|
+
console.warn("pixi-effects: could not draw the frame after a rebuild:", e);
|
|
3013
|
+
this._emitError("playback", e);
|
|
3014
|
+
}
|
|
3015
|
+
if (wasPlaying && !goOn && this._initState === "ready" && !this.isPlaying) {
|
|
3016
|
+
this._silent++;
|
|
3017
|
+
try {
|
|
3018
|
+
this.play();
|
|
3019
|
+
} finally {
|
|
3020
|
+
this._silent--;
|
|
3021
|
+
}
|
|
3022
|
+
}
|
|
3023
|
+
const report = { reason, ms: Math.round((performance.now() - started) * 10) / 10, audio, frame, playing: wasPlaying };
|
|
3024
|
+
this.emit("rebuilt", report);
|
|
3025
|
+
return report;
|
|
3026
|
+
} catch (err) {
|
|
3027
|
+
if (sequence) safeRun(() => sequence.destroy());
|
|
3028
|
+
this._emitError("rebuild", err);
|
|
3029
|
+
throw err;
|
|
3030
|
+
}
|
|
3031
|
+
}
|
|
2680
3032
|
async gotoFrame(frame, force = false) {
|
|
2681
3033
|
if (this._initState !== "ready") return;
|
|
2682
3034
|
this._cancelUntil();
|
|
@@ -2989,13 +3341,30 @@ var Movie = class {
|
|
|
2989
3341
|
*/
|
|
2990
3342
|
async peek(fn) {
|
|
2991
3343
|
this._requireReady("peek");
|
|
2992
|
-
this.
|
|
2993
|
-
|
|
3344
|
+
return this._exclusive(async () => {
|
|
3345
|
+
this.pause();
|
|
3346
|
+
const back = this.currentFrame, wasAtPoster = this._atPoster;
|
|
3347
|
+
try {
|
|
3348
|
+
return await this._quietly(fn);
|
|
3349
|
+
} finally {
|
|
3350
|
+
if (wasAtPoster) await this._showPoster();
|
|
3351
|
+
else await this._quietly(() => this.gotoFrame(back, true));
|
|
3352
|
+
}
|
|
3353
|
+
});
|
|
3354
|
+
}
|
|
3355
|
+
/** Run `fn` as the only thing that moves the composition: waits for a rebuild in flight, and holds the next one's swap until `fn` is done. */
|
|
3356
|
+
async _exclusive(fn) {
|
|
3357
|
+
while (this._rebuildRun) await this._rebuildRun.catch(() => {
|
|
3358
|
+
});
|
|
3359
|
+
this._busy++;
|
|
2994
3360
|
try {
|
|
2995
|
-
return await
|
|
3361
|
+
return await fn();
|
|
2996
3362
|
} finally {
|
|
2997
|
-
if (
|
|
2998
|
-
|
|
3363
|
+
if (--this._busy === 0) {
|
|
3364
|
+
const waiting = this._idleWaiters;
|
|
3365
|
+
this._idleWaiters = [];
|
|
3366
|
+
waiting.forEach((w) => w());
|
|
3367
|
+
}
|
|
2999
3368
|
}
|
|
3000
3369
|
}
|
|
3001
3370
|
_settleUntil(landed) {
|
|
@@ -3029,6 +3398,7 @@ var Movie = class {
|
|
|
3029
3398
|
if (this.currentFrame >= this.totalFrames) this.currentFrame = 0;
|
|
3030
3399
|
const wasPlaying = this.isPlaying;
|
|
3031
3400
|
this.isPlaying = true;
|
|
3401
|
+
const startFrame = this.currentFrame;
|
|
3032
3402
|
const startTime = performance.now() - this.currentFrame / this.frameRate * 1e3;
|
|
3033
3403
|
let inFlight = false;
|
|
3034
3404
|
const tick = (time) => {
|
|
@@ -3038,7 +3408,7 @@ var Movie = class {
|
|
|
3038
3408
|
return;
|
|
3039
3409
|
}
|
|
3040
3410
|
const elapsed = (time - startTime) / 1e3;
|
|
3041
|
-
const frame = Math.floor(elapsed * this.frameRate);
|
|
3411
|
+
const frame = Math.max(startFrame, Math.floor(elapsed * this.frameRate));
|
|
3042
3412
|
if (this._until !== null && frame >= this._until) {
|
|
3043
3413
|
void this._arriveUntil();
|
|
3044
3414
|
return;
|
|
@@ -3052,6 +3422,18 @@ var Movie = class {
|
|
|
3052
3422
|
inFlight = false;
|
|
3053
3423
|
});
|
|
3054
3424
|
this._raf = requestAnimationFrame(tick);
|
|
3425
|
+
} else if (this._loop && this._untilWaiters.length === 0) {
|
|
3426
|
+
this._silent++;
|
|
3427
|
+
try {
|
|
3428
|
+
this.pause();
|
|
3429
|
+
this._goto(0).catch((err) => {
|
|
3430
|
+
console.warn("pixi-effects: gotoFrame failed at the loop:", err);
|
|
3431
|
+
this._emitError("playback", err);
|
|
3432
|
+
});
|
|
3433
|
+
this.play();
|
|
3434
|
+
} finally {
|
|
3435
|
+
this._silent--;
|
|
3436
|
+
}
|
|
3055
3437
|
} else {
|
|
3056
3438
|
const toEnd = this._untilWaiters;
|
|
3057
3439
|
this._untilWaiters = [];
|
|
@@ -3080,7 +3462,7 @@ var Movie = class {
|
|
|
3080
3462
|
this.audioSource.start(0, Math.min(this.currentFrame / this.frameRate, buffer.duration));
|
|
3081
3463
|
}, typeof window !== "undefined" ? window : void 0);
|
|
3082
3464
|
}
|
|
3083
|
-
if (!wasPlaying) this.emit("play");
|
|
3465
|
+
if (!wasPlaying && !this._silent) this.emit("play");
|
|
3084
3466
|
}
|
|
3085
3467
|
pause() {
|
|
3086
3468
|
const wasPlaying = this.isPlaying;
|
|
@@ -3103,7 +3485,7 @@ var Movie = class {
|
|
|
3103
3485
|
this.gainNode.disconnect();
|
|
3104
3486
|
this.gainNode = null;
|
|
3105
3487
|
}
|
|
3106
|
-
if (wasPlaying) this.emit("pause");
|
|
3488
|
+
if (wasPlaying && !this._silent) this.emit("pause");
|
|
3107
3489
|
this._cancelUntil();
|
|
3108
3490
|
}
|
|
3109
3491
|
set volume(v) {
|
|
@@ -3129,10 +3511,23 @@ var Movie = class {
|
|
|
3129
3511
|
this.muted = !this.muted;
|
|
3130
3512
|
return this.muted;
|
|
3131
3513
|
}
|
|
3514
|
+
/**
|
|
3515
|
+
* At the end of an ordinary `play()` the movie goes back to the start and plays on (no `ended`, no `pause` / `play` events at the wrap; the sound
|
|
3516
|
+
* starts again). Default false. `playUntil()` and `render()` ignore it. Can be changed at any time; `loopchange` says so.
|
|
3517
|
+
*/
|
|
3518
|
+
set loop(v) {
|
|
3519
|
+
const next = !!v;
|
|
3520
|
+
if (next === this._loop) return;
|
|
3521
|
+
this._loop = next;
|
|
3522
|
+
this.emit("loopchange", { loop: next });
|
|
3523
|
+
}
|
|
3524
|
+
get loop() {
|
|
3525
|
+
return this._loop;
|
|
3526
|
+
}
|
|
3132
3527
|
async render(options) {
|
|
3133
3528
|
chunkTWZNOUM7_cjs.warnUnknownOptions("movie.render()", options, ["format", "video", "audio", "motionBlur", "range", "scale", "draft"]);
|
|
3134
3529
|
try {
|
|
3135
|
-
return await this._quietly(() => exportFrames(this, options));
|
|
3530
|
+
return await this._exclusive(() => this._quietly(() => exportFrames(this, options)));
|
|
3136
3531
|
} catch (err) {
|
|
3137
3532
|
this._emitError("render", err);
|
|
3138
3533
|
throw err;
|
|
@@ -3150,6 +3545,7 @@ var Movie = class {
|
|
|
3150
3545
|
this.audioBuffer = null;
|
|
3151
3546
|
this._audioSources = [];
|
|
3152
3547
|
this._mixStats = null;
|
|
3548
|
+
this._mixCache.set(null, null);
|
|
3153
3549
|
safeRun(() => this._audioContext?.close().catch(() => {
|
|
3154
3550
|
}));
|
|
3155
3551
|
this._audioContext = null;
|
|
@@ -3157,6 +3553,17 @@ var Movie = class {
|
|
|
3157
3553
|
}
|
|
3158
3554
|
};
|
|
3159
3555
|
var END_MARGIN = 1e-4;
|
|
3556
|
+
function muteBoundTextureWarning() {
|
|
3557
|
+
const original = console.warn;
|
|
3558
|
+
const ours = (...args) => {
|
|
3559
|
+
if (args.some((a) => /destroyed while still bound/.test(String(a)))) return;
|
|
3560
|
+
original.apply(console, args);
|
|
3561
|
+
};
|
|
3562
|
+
console.warn = ours;
|
|
3563
|
+
return () => {
|
|
3564
|
+
if (console.warn === ours) console.warn = original;
|
|
3565
|
+
};
|
|
3566
|
+
}
|
|
3160
3567
|
var clampFrame = (f, last) => Math.max(0, Math.min(Math.round(f), last));
|
|
3161
3568
|
function encodeCanvas(canvas, type, as, quality) {
|
|
3162
3569
|
if (as === "dataURL") return Promise.resolve(canvas.toDataURL(type, quality));
|
|
@@ -3185,7 +3592,9 @@ function countLayers(spec) {
|
|
|
3185
3592
|
for (const s of spec?.sequences ?? []) {
|
|
3186
3593
|
const mask = s.mask;
|
|
3187
3594
|
n += 1 + countLayers(s);
|
|
3188
|
-
const
|
|
3595
|
+
const spans = s.spans;
|
|
3596
|
+
if (Array.isArray(spans)) n += spans.length;
|
|
3597
|
+
const src = chunkCRUDOKSD_cjs.maskSourceOf(mask);
|
|
3189
3598
|
if (src.kind === "inline") n += 1 + countLayers(src.spec);
|
|
3190
3599
|
}
|
|
3191
3600
|
return n;
|
|
@@ -3243,8 +3652,8 @@ function splitText(text, style = {}, opts = {}) {
|
|
|
3243
3652
|
|
|
3244
3653
|
// src/presets/_ease.ts
|
|
3245
3654
|
function parseEase2(name) {
|
|
3246
|
-
|
|
3247
|
-
return
|
|
3655
|
+
chunkQHDN6TF5_cjs.checkEase(name, "a preset");
|
|
3656
|
+
return chunkQHDN6TF5_cjs.parseEase(name);
|
|
3248
3657
|
}
|
|
3249
3658
|
|
|
3250
3659
|
// src/presets/kenBurns.ts
|
|
@@ -3379,17 +3788,17 @@ function orbit(opts) {
|
|
|
3379
3788
|
throw new Error("pixi-effects: orbit() cannot combine `radius` with `dollyZoom` \u2014 the radius follows the animated fov");
|
|
3380
3789
|
}
|
|
3381
3790
|
const [cx, cy] = opts.center ?? [width / 2, height / 2];
|
|
3382
|
-
const fixedR = opts.radius ??
|
|
3791
|
+
const fixedR = opts.radius ?? chunkQHDN6TF5_cjs.homeDistance(height, fov ?? chunkQHDN6TF5_cjs.DEFAULT_FOV);
|
|
3383
3792
|
const start = opts.start ?? -degrees / 2;
|
|
3384
3793
|
const steps = Math.max(1, Math.round(duration * stepsPerSecond));
|
|
3385
3794
|
const easeFn = parseEase2(ease);
|
|
3386
3795
|
const dollyEase = dolly ? parseEase2(dolly.ease ?? ease) : null;
|
|
3387
3796
|
const pos = (i) => {
|
|
3388
3797
|
const p = i / steps;
|
|
3389
|
-
const a = (start + degrees * easeFn(p)) *
|
|
3798
|
+
const a = (start + degrees * easeFn(p)) * chunkQHDN6TF5_cjs.DEG;
|
|
3390
3799
|
if (!dolly) return { x: cx + fixedR * Math.sin(a), z: fixedR * Math.cos(a) };
|
|
3391
3800
|
const f = dolly.from + (dolly.to - dolly.from) * dollyEase(p);
|
|
3392
|
-
const R =
|
|
3801
|
+
const R = chunkQHDN6TF5_cjs.homeDistance(height, f);
|
|
3393
3802
|
return { x: cx + R * Math.sin(a), z: R * Math.cos(a), fov: f };
|
|
3394
3803
|
};
|
|
3395
3804
|
const keyframes = [];
|
|
@@ -3444,7 +3853,7 @@ function particles(opts) {
|
|
|
3444
3853
|
const round2 = (v) => Math.round(v * 1e6) / 1e6;
|
|
3445
3854
|
const out = [];
|
|
3446
3855
|
for (let i = 0; i < count; i++) {
|
|
3447
|
-
const r =
|
|
3856
|
+
const r = chunkQHDN6TF5_cjs.random(seed * 1000003 + i * 7919 + 17);
|
|
3448
3857
|
const pick = ([a2, b]) => a2 + r() * (b - a2);
|
|
3449
3858
|
const born = at + r() * emit;
|
|
3450
3859
|
const lifetime = pick(life);
|
|
@@ -3457,7 +3866,7 @@ function particles(opts) {
|
|
|
3457
3866
|
const turn = spin ? pick(spin) : 0;
|
|
3458
3867
|
const startAngle = spin ? r() * 360 : 0;
|
|
3459
3868
|
const swayAmp = sway?.amp ?? 0, swayFreq = sway?.freq ?? 1;
|
|
3460
|
-
const n0 = sway ?
|
|
3869
|
+
const n0 = sway ? chunkQHDN6TF5_cjs.noise(0, seed * 1000003 + i) : 0;
|
|
3461
3870
|
const at_ = (t) => {
|
|
3462
3871
|
const axis = (p0, v0, acc) => {
|
|
3463
3872
|
if (drag > 0) {
|
|
@@ -3466,7 +3875,7 @@ function particles(opts) {
|
|
|
3466
3875
|
}
|
|
3467
3876
|
return p0 + v0 * t + 0.5 * acc * t * t;
|
|
3468
3877
|
};
|
|
3469
|
-
const sw = sway ? swayAmp * (
|
|
3878
|
+
const sw = sway ? swayAmp * (chunkQHDN6TF5_cjs.noise(t * swayFreq, seed * 1000003 + i) - n0) : 0;
|
|
3470
3879
|
return { x: axis(x0, vx, wind) + sw, y: axis(y0, vy, gravity) };
|
|
3471
3880
|
};
|
|
3472
3881
|
const kfs = [];
|
|
@@ -3528,7 +3937,7 @@ function followPath(opts) {
|
|
|
3528
3937
|
if (steps > MAX_STEPS) throw new Error(`followPath(): ${steps} samples is too many (max ${MAX_STEPS}); lower frameRate or duration`);
|
|
3529
3938
|
const segments = [];
|
|
3530
3939
|
let total = 0;
|
|
3531
|
-
for (const line of
|
|
3940
|
+
for (const line of chunkQHDN6TF5_cjs.flattenSvgPath(d)) {
|
|
3532
3941
|
const p = line.closed ? [...line.pts, line.pts[0], line.pts[1]] : line.pts;
|
|
3533
3942
|
for (let i = 2; i < p.length; i += 2) {
|
|
3534
3943
|
const len = Math.hypot(p[i] - p[i - 2], p[i + 1] - p[i - 1]);
|
|
@@ -3682,7 +4091,7 @@ function distances(n, from, grid, seed) {
|
|
|
3682
4091
|
if (n === 0) return [];
|
|
3683
4092
|
if (from === "random") {
|
|
3684
4093
|
const order = Array.from({ length: n }, (_, i) => i);
|
|
3685
|
-
const r =
|
|
4094
|
+
const r = chunkQHDN6TF5_cjs.random(seed);
|
|
3686
4095
|
for (let i = n - 1; i > 0; i--) {
|
|
3687
4096
|
const j = Math.floor(r() * (i + 1));
|
|
3688
4097
|
[order[i], order[j]] = [order[j], order[i]];
|
|
@@ -3744,7 +4153,7 @@ function wiggle(opts) {
|
|
|
3744
4153
|
to[n] = p.around;
|
|
3745
4154
|
return;
|
|
3746
4155
|
}
|
|
3747
|
-
const off = (
|
|
4156
|
+
const off = (chunkQHDN6TF5_cjs.rand(seed * 7919 + pi * 104729 + s * 31 + 1) * 2 - 1) * p.amp;
|
|
3748
4157
|
to[n] = typeof p.around === "number" ? p.around + off : `(${p.around}) ${off < 0 ? "-" : "+"} ${Math.abs(off)}`;
|
|
3749
4158
|
});
|
|
3750
4159
|
out.push({ at: at + s * stepLen, to, duration: stepLen, ease });
|
|
@@ -4202,5 +4611,5 @@ exports.splitText = splitText;
|
|
|
4202
4611
|
exports.stagger = stagger;
|
|
4203
4612
|
exports.wiggle = wiggle;
|
|
4204
4613
|
exports.withFade = withFade;
|
|
4205
|
-
//# sourceMappingURL=chunk-
|
|
4206
|
-
//# sourceMappingURL=chunk-
|
|
4614
|
+
//# sourceMappingURL=chunk-K3MAEKFM.cjs.map
|
|
4615
|
+
//# sourceMappingURL=chunk-K3MAEKFM.cjs.map
|