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