pixi-effects 0.19.0 → 0.21.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 +41 -0
- package/README.md +6 -6
- package/ai/SKILL.md +3 -2
- package/ai/chat-template.html +3 -3
- package/ai/reference/cheatsheet.md +10 -9
- package/ai/reference/pitfalls.md +8 -0
- package/ai/reference/recipes.md +77 -0
- package/ai/template.html +5 -5
- package/ai/tools/check.mjs +16 -4
- package/dist/{Base-B4WbUJO2.d.ts → Base-CzfLGoDr.d.ts} +9 -1
- package/dist/{Base-i88XXaiP.d.cts → Base-wYJQ2g5Q.d.cts} +9 -1
- package/dist/Composition-2UFPSNVN.cjs +14 -0
- package/dist/{Composition-KYNPRWK3.cjs.map → Composition-2UFPSNVN.cjs.map} +1 -1
- package/dist/Composition-BVI236ZR.js +5 -0
- package/dist/{Composition-QBKEEJBV.js.map → Composition-BVI236ZR.js.map} +1 -1
- package/dist/Controller.cjs +2 -2
- package/dist/Controller.d.cts +2 -2
- package/dist/Controller.d.ts +2 -2
- package/dist/Controller.js +1 -1
- package/dist/{Movie-8IrqL3kO.d.ts → Movie-CgYwa5QG.d.ts} +10 -2
- package/dist/{Movie-CpmdNadg.d.cts → Movie-mtX9AkQ-.d.cts} +10 -2
- package/dist/Presenter.cjs +2 -2
- package/dist/Presenter.d.cts +2 -2
- package/dist/Presenter.d.ts +2 -2
- package/dist/Presenter.js +1 -1
- package/dist/{chunk-CTZRFSVU.cjs → chunk-6JJC37ZD.cjs} +326 -41
- package/dist/chunk-6JJC37ZD.cjs.map +1 -0
- package/dist/{chunk-VTBT6NNE.cjs → chunk-BPW42X7C.cjs} +385 -32
- package/dist/chunk-BPW42X7C.cjs.map +1 -0
- package/dist/{chunk-YRXTKOV5.js → chunk-DDIXIWXK.js} +366 -25
- package/dist/chunk-DDIXIWXK.js.map +1 -0
- package/dist/{chunk-DKGG7WD4.js → chunk-MNM56B3X.js} +6 -3
- package/dist/chunk-MNM56B3X.js.map +1 -0
- package/dist/{chunk-B3YB2TNY.js → chunk-NGYGFGDS.js} +304 -19
- package/dist/chunk-NGYGFGDS.js.map +1 -0
- package/dist/{chunk-UQBGW5DO.cjs → chunk-WTRKDIKH.cjs} +6 -3
- package/dist/chunk-WTRKDIKH.cjs.map +1 -0
- package/dist/index.cjs +215 -91
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +156 -32
- package/dist/index.js.map +1 -1
- package/dist/loader.css +1 -1
- package/dist/{music-4HDFULNR.js → music-CFEC7HKL.js} +3 -3
- package/dist/{music-4HDFULNR.js.map → music-CFEC7HKL.js.map} +1 -1
- package/dist/{music-3OF5C6X5.cjs → music-UAN7DXK4.cjs} +7 -7
- package/dist/{music-3OF5C6X5.cjs.map → music-UAN7DXK4.cjs.map} +1 -1
- package/dist/{sfx-MZJZXYY3.cjs → sfx-EX4PUBMV.cjs} +8 -8
- package/dist/{sfx-MZJZXYY3.cjs.map → sfx-EX4PUBMV.cjs.map} +1 -1
- package/dist/{sfx-S37DDC66.js → sfx-U3GM2MED.js} +3 -3
- package/dist/{sfx-S37DDC66.js.map → sfx-U3GM2MED.js.map} +1 -1
- 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-bzLJ7aUx.d.ts → types-YmUaViL1.d.cts} +24 -0
- package/dist/{types-bzLJ7aUx.d.cts → types-YmUaViL1.d.ts} +24 -0
- package/docs/dsl.md +62 -2
- package/llms-full.txt +160 -13
- package/package.json +3 -1
- package/dist/Composition-KYNPRWK3.cjs +0 -14
- package/dist/Composition-QBKEEJBV.js +0 -5
- package/dist/chunk-B3YB2TNY.js.map +0 -1
- package/dist/chunk-CTZRFSVU.cjs.map +0 -1
- package/dist/chunk-DKGG7WD4.js.map +0 -1
- package/dist/chunk-UQBGW5DO.cjs.map +0 -1
- package/dist/chunk-VTBT6NNE.cjs.map +0 -1
- package/dist/chunk-YRXTKOV5.js.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var chunkBPW42X7C_cjs = require('./chunk-BPW42X7C.cjs');
|
|
4
|
+
var chunkWTRKDIKH_cjs = require('./chunk-WTRKDIKH.cjs');
|
|
5
5
|
var pixi_js = require('pixi.js');
|
|
6
6
|
var gsap = require('gsap');
|
|
7
7
|
|
|
@@ -47,6 +47,91 @@ function assignDepthOrder(items) {
|
|
|
47
47
|
}
|
|
48
48
|
return out;
|
|
49
49
|
}
|
|
50
|
+
var DISC_TAPS = 48;
|
|
51
|
+
var GL_VERTEX = `#version 300 es
|
|
52
|
+
in vec2 aPosition;
|
|
53
|
+
out vec2 vTextureCoord;
|
|
54
|
+
uniform vec4 uInputSize;
|
|
55
|
+
uniform vec4 uOutputFrame;
|
|
56
|
+
uniform vec4 uOutputTexture;
|
|
57
|
+
void main(void) {
|
|
58
|
+
vec2 position = aPosition * uOutputFrame.zw + uOutputFrame.xy;
|
|
59
|
+
position.x = position.x * (2.0 / uOutputTexture.x) - 1.0;
|
|
60
|
+
position.y = position.y * (2.0 * uOutputTexture.z / uOutputTexture.y) - uOutputTexture.z;
|
|
61
|
+
gl_Position = vec4(position, 0.0, 1.0);
|
|
62
|
+
vTextureCoord = aPosition * (uOutputFrame.zw * uInputSize.zw);
|
|
63
|
+
}`;
|
|
64
|
+
var GL_FRAGMENT = `#version 300 es
|
|
65
|
+
precision highp float;
|
|
66
|
+
in vec2 vTextureCoord;
|
|
67
|
+
uniform sampler2D uTexture;
|
|
68
|
+
uniform vec4 uInputSize;
|
|
69
|
+
uniform float uRadius;
|
|
70
|
+
out vec4 finalColor;
|
|
71
|
+
void main(void) {
|
|
72
|
+
vec4 acc = vec4(0.0);
|
|
73
|
+
for (int i = 0; i < ${DISC_TAPS}; i++) {
|
|
74
|
+
float r = sqrt((float(i) + 0.5) / ${DISC_TAPS}.0) * uRadius;
|
|
75
|
+
float a = float(i) * 2.39996323;
|
|
76
|
+
acc += texture(uTexture, vTextureCoord + vec2(cos(a), sin(a)) * r * uInputSize.zw);
|
|
77
|
+
}
|
|
78
|
+
finalColor = acc / ${DISC_TAPS}.0;
|
|
79
|
+
}`;
|
|
80
|
+
var WGSL = `
|
|
81
|
+
struct GlobalFilterUniforms {
|
|
82
|
+
uInputSize: vec4<f32>, uInputPixel: vec4<f32>, uInputClamp: vec4<f32>,
|
|
83
|
+
uOutputFrame: vec4<f32>, uGlobalFrame: vec4<f32>, uOutputTexture: vec4<f32>,
|
|
84
|
+
};
|
|
85
|
+
struct DiscUniforms { uRadius: f32 };
|
|
86
|
+
@group(0) @binding(0) var<uniform> gfu: GlobalFilterUniforms;
|
|
87
|
+
@group(0) @binding(1) var uTexture: texture_2d<f32>;
|
|
88
|
+
@group(0) @binding(2) var uSampler : sampler;
|
|
89
|
+
@group(1) @binding(0) var<uniform> disc : DiscUniforms;
|
|
90
|
+
struct VSOutput { @builtin(position) position: vec4<f32>, @location(0) uv : vec2<f32> };
|
|
91
|
+
fn filterVertexPosition(aPosition : vec2<f32>) -> vec4<f32> {
|
|
92
|
+
var position = aPosition * gfu.uOutputFrame.zw + gfu.uOutputFrame.xy;
|
|
93
|
+
position.x = position.x * (2.0 / gfu.uOutputTexture.x) - 1.0;
|
|
94
|
+
position.y = position.y * (2.0 * gfu.uOutputTexture.z / gfu.uOutputTexture.y) - gfu.uOutputTexture.z;
|
|
95
|
+
return vec4<f32>(position, 0.0, 1.0);
|
|
96
|
+
}
|
|
97
|
+
fn filterTextureCoord(aPosition : vec2<f32>) -> vec2<f32> {
|
|
98
|
+
return aPosition * (gfu.uOutputFrame.zw * gfu.uInputSize.zw);
|
|
99
|
+
}
|
|
100
|
+
@vertex
|
|
101
|
+
fn mainVertex(@location(0) aPosition : vec2<f32>) -> VSOutput {
|
|
102
|
+
return VSOutput(filterVertexPosition(aPosition), filterTextureCoord(aPosition));
|
|
103
|
+
}
|
|
104
|
+
@fragment
|
|
105
|
+
fn mainFragment(@location(0) uv : vec2<f32>) -> @location(0) vec4<f32> {
|
|
106
|
+
var acc = vec4<f32>(0.0);
|
|
107
|
+
for (var i = 0; i < ${DISC_TAPS}; i++) {
|
|
108
|
+
let r = sqrt((f32(i) + 0.5) / ${DISC_TAPS}.0) * disc.uRadius;
|
|
109
|
+
let a = f32(i) * 2.39996323;
|
|
110
|
+
acc += textureSampleLevel(uTexture, uSampler, uv + vec2<f32>(cos(a), sin(a)) * r * gfu.uInputSize.zw, 0.0);
|
|
111
|
+
}
|
|
112
|
+
return acc / ${DISC_TAPS}.0;
|
|
113
|
+
}`;
|
|
114
|
+
var DiscBlurFilter = class extends pixi_js.Filter {
|
|
115
|
+
constructor(radius = 8) {
|
|
116
|
+
super({
|
|
117
|
+
glProgram: pixi_js.GlProgram.from({ vertex: GL_VERTEX, fragment: GL_FRAGMENT, name: "disc-blur" }),
|
|
118
|
+
gpuProgram: pixi_js.GpuProgram.from({ vertex: { source: WGSL, entryPoint: "mainVertex" }, fragment: { source: WGSL, entryPoint: "mainFragment" } }),
|
|
119
|
+
resources: { disc: new pixi_js.UniformGroup({ uRadius: { value: radius, type: "f32" } }) }
|
|
120
|
+
});
|
|
121
|
+
this.radius = radius;
|
|
122
|
+
}
|
|
123
|
+
/** Blur radius in pixels. The padding follows it, so the blurred edge is not cut off. */
|
|
124
|
+
get radius() {
|
|
125
|
+
return this.resources.disc.uniforms.uRadius;
|
|
126
|
+
}
|
|
127
|
+
set radius(v) {
|
|
128
|
+
const r = Math.max(0, v);
|
|
129
|
+
this.resources.disc.uniforms.uRadius = r;
|
|
130
|
+
this.padding = Math.ceil(r) + 2;
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
// src/space/Layer3D.ts
|
|
50
135
|
var MAX_TEXTURE_SIZE = 4096;
|
|
51
136
|
var SUPERSAMPLE = 2;
|
|
52
137
|
var MAX_TEXTURE_PIXELS = 2048 * 2048;
|
|
@@ -65,8 +150,8 @@ function readLayerTransform(target) {
|
|
|
65
150
|
x: c.x,
|
|
66
151
|
y: c.y,
|
|
67
152
|
z: c.z ?? 0,
|
|
68
|
-
rotationX: (c.rotationX ?? 0) *
|
|
69
|
-
rotationY: (c.rotationY ?? 0) *
|
|
153
|
+
rotationX: (c.rotationX ?? 0) * chunkBPW42X7C_cjs.DEG,
|
|
154
|
+
rotationY: (c.rotationY ?? 0) * chunkBPW42X7C_cjs.DEG,
|
|
70
155
|
rotationZ: c.rotation,
|
|
71
156
|
scaleX: c.scale.x,
|
|
72
157
|
scaleY: c.scale.y,
|
|
@@ -100,6 +185,10 @@ var Layer3D = class {
|
|
|
100
185
|
retired = [];
|
|
101
186
|
size = null;
|
|
102
187
|
warnedBehind = false;
|
|
188
|
+
/** Depth-of-field blur radius (px) from the last `setBlur`; 0 = no filter. */
|
|
189
|
+
blur = 0;
|
|
190
|
+
blurFilter = null;
|
|
191
|
+
blendWas = "normal";
|
|
103
192
|
update(host, basis) {
|
|
104
193
|
this.flushRetired();
|
|
105
194
|
const target = this.seq.target;
|
|
@@ -111,19 +200,19 @@ var Layer3D = class {
|
|
|
111
200
|
if (!(needW >= 1 && needH >= 1) || !Number.isFinite(bounds.x) || !Number.isFinite(bounds.y)) return this.hide();
|
|
112
201
|
const size = this.sizeFor(needW, needH);
|
|
113
202
|
const frame = { x: bounds.x - pad, y: bounds.y - pad, width: size.w, height: size.h };
|
|
114
|
-
const projected =
|
|
203
|
+
const projected = chunkBPW42X7C_cjs.projectLayer(readLayerTransform(target), frame, basis);
|
|
115
204
|
this.depth = projected.depth;
|
|
116
205
|
if (!projected.visible) {
|
|
117
206
|
if (!this.warnedBehind) {
|
|
118
207
|
this.warnedBehind = true;
|
|
119
208
|
if (this.seq.spec.hideBehindCamera) return this.hide();
|
|
120
|
-
if (projected.depth >
|
|
209
|
+
if (projected.depth > chunkBPW42X7C_cjs.NEAR) {
|
|
121
210
|
console.warn(
|
|
122
|
-
`pixi-effects: ${
|
|
211
|
+
`pixi-effects: ${chunkBPW42X7C_cjs.describeLayer(this.seq.spec)}: part of it (a corner) reaches the camera plane (z = ${(target.z ?? 0).toFixed(0)}, rotationX ${(target.rotationX ?? 0).toFixed(0)}\xB0, rotationY ${(target.rotationY ?? 0).toFixed(0)}\xB0), and a layer is hidden whole when any corner is at or behind it. Tilt it less (rotationX / rotationY), make it smaller, or keep the camera further away from it (the default camera sits at z = (height/2)/tan(fov/2), about 989 for 720p at fov 40).`
|
|
123
212
|
);
|
|
124
213
|
} else {
|
|
125
214
|
console.warn(
|
|
126
|
-
`pixi-effects: ${
|
|
215
|
+
`pixi-effects: ${chunkBPW42X7C_cjs.describeLayer(this.seq.spec)} is at or behind the camera plane (z = ${(target.z ?? 0).toFixed(0)}) and is hidden. If that is unintended, lower its z or move the camera back (the default camera sits at z = (height/2)/tan(fov/2), about 989 for 720p at fov 40).`
|
|
127
216
|
);
|
|
128
217
|
}
|
|
129
218
|
}
|
|
@@ -140,7 +229,37 @@ var Layer3D = class {
|
|
|
140
229
|
this.display.geometry.setCorners(...projected.corners);
|
|
141
230
|
this.display.visible = true;
|
|
142
231
|
}
|
|
232
|
+
/**
|
|
233
|
+
* Depth-of-field blur on the projected mesh (screen space), so a tilted or scaled layer blurs by the size it is drawn at.
|
|
234
|
+
* A radius under MIN_BLUR removes the filter: a sharp layer costs nothing. A blend mode moves to the filter while it is on
|
|
235
|
+
* (a filtered object blends as a whole), and comes back when it goes.
|
|
236
|
+
*/
|
|
237
|
+
setBlur(radius) {
|
|
238
|
+
const d = this.display;
|
|
239
|
+
const r = radius > chunkBPW42X7C_cjs.MIN_BLUR ? Math.min(radius, chunkBPW42X7C_cjs.MAX_BLUR) : 0;
|
|
240
|
+
this.blur = r;
|
|
241
|
+
if (r === 0) {
|
|
242
|
+
if (this.blurFilter) {
|
|
243
|
+
d.filters = null;
|
|
244
|
+
d.blendMode = this.blendWas;
|
|
245
|
+
this.blurFilter.destroy();
|
|
246
|
+
this.blurFilter = null;
|
|
247
|
+
}
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
if (!this.blurFilter) {
|
|
251
|
+
this.blurFilter = new DiscBlurFilter(r);
|
|
252
|
+
this.blendWas = d.blendMode ?? "normal";
|
|
253
|
+
if (this.blendWas !== "normal" && this.blendWas !== "inherit") {
|
|
254
|
+
this.blurFilter.blendMode = this.blendWas;
|
|
255
|
+
d.blendMode = "normal";
|
|
256
|
+
}
|
|
257
|
+
d.filters = [this.blurFilter];
|
|
258
|
+
}
|
|
259
|
+
this.blurFilter.radius = r;
|
|
260
|
+
}
|
|
143
261
|
destroy() {
|
|
262
|
+
this.setBlur(0);
|
|
144
263
|
this.display.destroy();
|
|
145
264
|
this.rt?.destroy(true);
|
|
146
265
|
this.rt = null;
|
|
@@ -192,6 +311,7 @@ var Layer3D = class {
|
|
|
192
311
|
// src/space/lint.ts
|
|
193
312
|
var defaultWarn = (m) => console.warn(m);
|
|
194
313
|
var FOV_HINT = `perspective is the camera's "fov" \u2014 add a { type: "camera" } layer and set fov in its initial / keyframes`;
|
|
314
|
+
var DOF_HINT = `depth of field is the camera's "focus" (the plane that is sharp: a layer name or a z) and "aperture" (how shallow: 0 = off, 30 = default) \u2014 put them in the camera's initial / keyframes`;
|
|
195
315
|
var LAYER_ALIASES = {
|
|
196
316
|
rotateX: 'did you mean "rotationX"?',
|
|
197
317
|
rotateY: 'did you mean "rotationY"?',
|
|
@@ -205,14 +325,20 @@ var LAYER_ALIASES = {
|
|
|
205
325
|
};
|
|
206
326
|
var CAMERA_ALIASES = {
|
|
207
327
|
pointOfInterest: 'did you mean "lookAtX / lookAtY / lookAtZ"?',
|
|
208
|
-
lookAt: 'did you mean "lookAtX / lookAtY / lookAtZ"?'
|
|
328
|
+
lookAt: 'did you mean "lookAtX / lookAtY / lookAtZ"?',
|
|
329
|
+
depthOfField: DOF_HINT,
|
|
330
|
+
dof: DOF_HINT,
|
|
331
|
+
focalDistance: DOF_HINT,
|
|
332
|
+
focusDistance: DOF_HINT,
|
|
333
|
+
fStop: DOF_HINT,
|
|
334
|
+
blurAmount: DOF_HINT
|
|
209
335
|
};
|
|
210
|
-
var CAMERA_PROPS = ["x", "y", "z", "fov", "lookAtX", "lookAtY", "lookAtZ", "offsetX", "offsetY", "offsetZ", "lookOffsetX", "lookOffsetY", "lookOffsetZ"];
|
|
336
|
+
var CAMERA_PROPS = ["x", "y", "z", "fov", "focus", "aperture", "lookAtX", "lookAtY", "lookAtZ", "offsetX", "offsetY", "offsetZ", "lookOffsetX", "lookOffsetY", "lookOffsetZ"];
|
|
211
337
|
var NEEDS_THREE_D = ["z", "rotationX", "rotationY"];
|
|
212
338
|
var SKEW_KEYS = ["skew", "skewX", "skewY"];
|
|
213
339
|
function lintSequence(spec, warn = defaultWarn) {
|
|
214
|
-
const who =
|
|
215
|
-
const keys =
|
|
340
|
+
const who = chunkBPW42X7C_cjs.describeLayer(spec);
|
|
341
|
+
const keys = chunkBPW42X7C_cjs.collectPropKeys(spec);
|
|
216
342
|
const explained = /* @__PURE__ */ new Set();
|
|
217
343
|
for (const k of keys) {
|
|
218
344
|
const hint = LAYER_ALIASES[k] ?? (spec.type === "camera" ? CAMERA_ALIASES[k] : void 0);
|
|
@@ -251,6 +377,19 @@ function lintSequence(spec, warn = defaultWarn) {
|
|
|
251
377
|
}
|
|
252
378
|
}
|
|
253
379
|
}
|
|
380
|
+
function lintFocus(camera, siblings, warn = defaultWarn) {
|
|
381
|
+
if (camera.type !== "camera") return;
|
|
382
|
+
const who = chunkBPW42X7C_cjs.describeLayer(camera);
|
|
383
|
+
for (const p of chunkBPW42X7C_cjs.focusProblems(camera, siblings)) {
|
|
384
|
+
if (p.kind === "missing") {
|
|
385
|
+
warn(`pixi-effects: ${who}: focus: no layer named "${p.name}"${p.hint ? `; did you mean "${p.hint}"?` : ""} (the z = 0 plane is used). Write a threeD layer's name or a z number`);
|
|
386
|
+
} else if (p.kind === "not-threeD") {
|
|
387
|
+
warn(`pixi-effects: ${who}: focus "${p.name}" is not a threeD layer, so it has no depth (the z = 0 plane is used). Write a threeD layer's name or a z number`);
|
|
388
|
+
} else {
|
|
389
|
+
warn(`pixi-effects: ${who}: focus "${p.name}" reads only the first z of that layer; its z moves later and the focus does not follow. Animate focus itself with numbers to follow it`);
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
}
|
|
254
393
|
|
|
255
394
|
// src/core/blend.ts
|
|
256
395
|
var MODES = ["normal", "add", "screen", "multiply"];
|
|
@@ -258,7 +397,7 @@ function applyBlendMode(spec, display) {
|
|
|
258
397
|
const mode = spec.blendMode;
|
|
259
398
|
if (mode === void 0) return;
|
|
260
399
|
if (!MODES.includes(mode)) {
|
|
261
|
-
console.warn(`pixi-effects: ${
|
|
400
|
+
console.warn(`pixi-effects: ${chunkBPW42X7C_cjs.describeLayer(spec)}: blendMode "${mode}" is not supported (use ${MODES.join(", ")})`);
|
|
262
401
|
return;
|
|
263
402
|
}
|
|
264
403
|
const filters = display.filters;
|
|
@@ -270,18 +409,47 @@ function applyBlendMode(spec, display) {
|
|
|
270
409
|
}
|
|
271
410
|
|
|
272
411
|
// src/sequences/Composition.ts
|
|
273
|
-
var CompositionSequence = class extends
|
|
412
|
+
var CompositionSequence = class extends chunkBPW42X7C_cjs.Sequence {
|
|
274
413
|
_innerContainer = null;
|
|
275
414
|
_compositionShape = null;
|
|
276
415
|
_children = [];
|
|
277
416
|
_cameras = [];
|
|
278
417
|
_layers3d = [];
|
|
418
|
+
_dofSaid = { behind: false, many: false };
|
|
279
419
|
/** Drawn children in stack order (cameras and target-less sequences excluded). */
|
|
280
420
|
_visual = [];
|
|
281
421
|
/** Layers drawn inside a null layer (`parent`): they are not in the composition's own stack. */
|
|
282
422
|
_nested = [];
|
|
283
423
|
/** The null layer each parented layer is drawn inside. */
|
|
284
424
|
_parentOf = /* @__PURE__ */ new Map();
|
|
425
|
+
/** Set when this composition's own time is remapped: the children live on `_inner` in LOCAL time, driven by `_clock`. */
|
|
426
|
+
_inner = null;
|
|
427
|
+
_clock = null;
|
|
428
|
+
_remap = null;
|
|
429
|
+
_childBase = 0;
|
|
430
|
+
_contentSpan = 0;
|
|
431
|
+
/** Where the children's time starts: the composition's absolute start, or 0 when their time is local (remapped). */
|
|
432
|
+
get childBase() {
|
|
433
|
+
return this._childBase;
|
|
434
|
+
}
|
|
435
|
+
/** How long the children's time runs: the composition's duration, or its content length when its time is remapped. */
|
|
436
|
+
get contentSpan() {
|
|
437
|
+
return this._contentSpan;
|
|
438
|
+
}
|
|
439
|
+
/** The time the children live in at movie time `t`: the movie's own, or this composition's local clock when it is remapped. */
|
|
440
|
+
childTime(t) {
|
|
441
|
+
return this._clock ? this._clock.time : t;
|
|
442
|
+
}
|
|
443
|
+
/** The clock reader for filters that want the time (grain), or null when the children run on the movie's time. */
|
|
444
|
+
localClock() {
|
|
445
|
+
return this._clock ? () => this._clock.time : null;
|
|
446
|
+
}
|
|
447
|
+
/** How the time is remapped, for the timeline chart: `×0.5`, `×-1`, `time keyframes`, or null. */
|
|
448
|
+
remapLabel() {
|
|
449
|
+
const r = this._remap;
|
|
450
|
+
if (!r) return null;
|
|
451
|
+
return r.timeKfs.length ? "time keyframes" : `\xD7${r.speed ?? 1}`;
|
|
452
|
+
}
|
|
285
453
|
async build() {
|
|
286
454
|
const width = this.spec.width ?? this.parent?.width ?? this.root.width;
|
|
287
455
|
const height = this.spec.height ?? this.parent?.height ?? this.root.height;
|
|
@@ -300,23 +468,36 @@ var CompositionSequence = class extends chunkVTBT6NNE_cjs.Sequence {
|
|
|
300
468
|
this.intrinsicWidth = width;
|
|
301
469
|
this.intrinsicHeight = height;
|
|
302
470
|
this._innerContainer = inner;
|
|
303
|
-
|
|
471
|
+
const base = chunkBPW42X7C_cjs.timeRemapOf(this.spec);
|
|
472
|
+
const span = base ? chunkBPW42X7C_cjs.contentLength(base, this.duration) : this.duration;
|
|
473
|
+
this._remap = base ? chunkBPW42X7C_cjs.remapOf(this.spec, "time", span) : null;
|
|
474
|
+
this._contentSpan = span;
|
|
475
|
+
this._compositionShape = { width, height, duration: span };
|
|
304
476
|
const lateKeyframes = [];
|
|
305
477
|
for (const s of this.spec.sequences ?? []) {
|
|
306
478
|
lintSequence(s);
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
479
|
+
lintFocus(s, this.spec.sequences ?? []);
|
|
480
|
+
chunkBPW42X7C_cjs.lintTiming(s, span, (message, kind) => kind === "late-keyframe" ? lateKeyframes.push(message) : console.warn(message));
|
|
481
|
+
chunkBPW42X7C_cjs.lintText(s);
|
|
482
|
+
chunkBPW42X7C_cjs.lintKeys(s);
|
|
310
483
|
}
|
|
311
|
-
for (const message of
|
|
312
|
-
this._children = await
|
|
484
|
+
for (const message of chunkBPW42X7C_cjs.summarizeWarnings(lateKeyframes)) console.warn(message);
|
|
485
|
+
this._children = await chunkBPW42X7C_cjs.buildSequenceTree(
|
|
313
486
|
this.spec.sequences ?? [],
|
|
314
487
|
this._compositionShape,
|
|
315
488
|
this.root
|
|
316
489
|
);
|
|
317
490
|
this._resolveParents();
|
|
491
|
+
const layerNames = new Set(this._children.map((c) => c.spec.name).filter((n) => !!n));
|
|
492
|
+
for (const cam of this._children) {
|
|
493
|
+
if (!(cam instanceof chunkBPW42X7C_cjs.CameraSequence)) continue;
|
|
494
|
+
cam.resolveFocusNames((name) => {
|
|
495
|
+
const hit = this._children.find((c) => c.spec.name === name && c.spec.threeD);
|
|
496
|
+
return hit ? chunkBPW42X7C_cjs.layerInitialZ(hit.spec, hit.scope()) : void 0;
|
|
497
|
+
}, layerNames);
|
|
498
|
+
}
|
|
318
499
|
for (const child of this._children) {
|
|
319
|
-
if (child instanceof
|
|
500
|
+
if (child instanceof chunkBPW42X7C_cjs.CameraSequence) {
|
|
320
501
|
this._cameras.push(child);
|
|
321
502
|
continue;
|
|
322
503
|
}
|
|
@@ -331,7 +512,7 @@ var CompositionSequence = class extends chunkVTBT6NNE_cjs.Sequence {
|
|
|
331
512
|
this._visual.push({ seq: child, layer });
|
|
332
513
|
applyBlendMode(child.spec, layer.display);
|
|
333
514
|
if (maskSpec) {
|
|
334
|
-
console.warn(`pixi-effects: ${
|
|
515
|
+
console.warn(`pixi-effects: ${chunkBPW42X7C_cjs.describeLayer(child.spec)}: mask is not supported on threeD layers yet; ignored`);
|
|
335
516
|
}
|
|
336
517
|
continue;
|
|
337
518
|
}
|
|
@@ -341,7 +522,7 @@ var CompositionSequence = class extends chunkVTBT6NNE_cjs.Sequence {
|
|
|
341
522
|
applyBlendMode(child.spec, child.target);
|
|
342
523
|
if (maskSpec) {
|
|
343
524
|
const lifetime = maskSpec.at === void 0 ? { at: child.at, duration: maskSpec.duration ?? child.duration } : {};
|
|
344
|
-
const built = await
|
|
525
|
+
const built = await chunkBPW42X7C_cjs.buildSequenceTree([{ ...maskSpec, ...lifetime }], this._compositionShape, this.root);
|
|
345
526
|
const maskSeq = built[0];
|
|
346
527
|
if (maskSeq?.target) {
|
|
347
528
|
into.addChild(maskSeq.target);
|
|
@@ -372,20 +553,79 @@ var CompositionSequence = class extends chunkVTBT6NNE_cjs.Sequence {
|
|
|
372
553
|
}
|
|
373
554
|
this.buildFilters();
|
|
374
555
|
}
|
|
556
|
+
displayProps() {
|
|
557
|
+
const r = this._remap;
|
|
558
|
+
return r ? { initial: r.restInitial, keyframes: r.restKfs } : super.displayProps();
|
|
559
|
+
}
|
|
375
560
|
bindTimeline(timeline, offset = 0) {
|
|
376
561
|
super.bindTimeline(timeline, offset);
|
|
377
|
-
const
|
|
562
|
+
const remap = this._remap;
|
|
563
|
+
const childOffset = remap ? 0 : offset + this.at;
|
|
564
|
+
this._childBase = childOffset;
|
|
565
|
+
const target = remap ? gsap.gsap.timeline({ paused: true, defaults: { ease: "none" } }) : timeline;
|
|
378
566
|
for (const child of this._children) {
|
|
379
567
|
const own = gsap.gsap.timeline({ defaults: { ease: "none" } });
|
|
380
568
|
child.bindTimeline(own, childOffset);
|
|
381
569
|
child.maskSequence?.bindTimeline(own, childOffset);
|
|
382
|
-
|
|
570
|
+
target.add(own, 0);
|
|
383
571
|
}
|
|
572
|
+
if (remap) this._bindClock(timeline, target, remap, offset);
|
|
384
573
|
const overlap = findOverlap(this._cameras.map((c) => c.window()));
|
|
385
574
|
if (overlap) {
|
|
386
575
|
console.warn(`pixi-effects: cameras #${overlap[0] + 1} and #${overlap[1] + 1} overlap in time; the top-most one wins`);
|
|
387
576
|
}
|
|
388
577
|
}
|
|
578
|
+
/** Drive the local timeline `inner` from the clock, and put the clock's tweens on the outer `timeline`. */
|
|
579
|
+
_bindClock(timeline, inner, remap, offset) {
|
|
580
|
+
let last = NaN;
|
|
581
|
+
let cur = 0;
|
|
582
|
+
const clock = {
|
|
583
|
+
get time() {
|
|
584
|
+
return cur;
|
|
585
|
+
},
|
|
586
|
+
set time(v) {
|
|
587
|
+
cur = v;
|
|
588
|
+
if (v === last) return;
|
|
589
|
+
last = v;
|
|
590
|
+
inner.time(v);
|
|
591
|
+
}
|
|
592
|
+
};
|
|
593
|
+
this._inner = inner;
|
|
594
|
+
this._clock = clock;
|
|
595
|
+
const scope = this.scope();
|
|
596
|
+
if (remap.start !== void 0 && remap.timeKfs.length === 0) clock.time = remap.start;
|
|
597
|
+
chunkBPW42X7C_cjs.bindClock(timeline, clock, "time", remap, this.duration, offset + this.at, scope);
|
|
598
|
+
inner.time(inner.duration());
|
|
599
|
+
inner.time(0);
|
|
600
|
+
last = NaN;
|
|
601
|
+
this._warnUnreachable(chunkBPW42X7C_cjs.clockTable(remap, "time", this.duration, offset + this.at, scope, offset + this.at + this.duration), offset + this.at, offset + this.at + this.duration);
|
|
602
|
+
}
|
|
603
|
+
/**
|
|
604
|
+
* A child the clock never dwells in is never visible: say so. Its `at` is in THIS composition's local time, so the usual mistake is
|
|
605
|
+
* writing it in the outer time (or forgetting that speed 0.5 reaches only half as far). Decided by dwell, not by the clock's end
|
|
606
|
+
* points: a clock that arrives at the child's `at` and HOLDS there shows it for the whole hold; one that only touches it in a single
|
|
607
|
+
* instant (speed 0.5, a child at exactly the farthest local time) does not.
|
|
608
|
+
*/
|
|
609
|
+
_warnUnreachable(table, from, to) {
|
|
610
|
+
const remap = this._remap;
|
|
611
|
+
const how = remap.timeKfs.length ? "time keyframes" : `speed ${remap.speed ?? 1}`;
|
|
612
|
+
const span = this._contentSpan;
|
|
613
|
+
const EPS = 1e-9;
|
|
614
|
+
for (const child of this._children) {
|
|
615
|
+
const at = child.at;
|
|
616
|
+
if (at >= span) continue;
|
|
617
|
+
const end = Math.min(at + (child.duration ?? span), span);
|
|
618
|
+
let dwell = 0;
|
|
619
|
+
for (let t = from; t <= to && dwell < 2; t += 1e-3) {
|
|
620
|
+
const v = table.at(t);
|
|
621
|
+
if (v >= at - EPS && v < end + EPS) dwell++;
|
|
622
|
+
}
|
|
623
|
+
if (dwell >= 2) continue;
|
|
624
|
+
console.warn(
|
|
625
|
+
`pixi-effects: ${chunkBPW42X7C_cjs.describeLayer(child.spec)} starts at ${at}s of ${chunkBPW42X7C_cjs.describeLayer(this.spec)}'s own time, but its clock only reaches ${Number(table.min.toFixed(3))}\u2013${Number(table.max.toFixed(3))}s (${how}), so it is never visible. Layers inside a remapped composition are placed in that composition's local time.`
|
|
626
|
+
);
|
|
627
|
+
}
|
|
628
|
+
}
|
|
389
629
|
/**
|
|
390
630
|
* Drawn children in stack order, with the display object that stands in for each (the mesh for a threeD layer).
|
|
391
631
|
* Null layers draw nothing and are left out; the layers inside them follow, with the null layers that carry them.
|
|
@@ -396,26 +636,27 @@ var CompositionSequence = class extends chunkVTBT6NNE_cjs.Sequence {
|
|
|
396
636
|
for (let p = this._parentOf.get(seq); p; p = this._parentOf.get(p)) out.push(p);
|
|
397
637
|
return out;
|
|
398
638
|
};
|
|
399
|
-
return [...this._visual.map((v) => v.seq), ...this._nested].filter((seq) => !(seq instanceof
|
|
639
|
+
return [...this._visual.map((v) => v.seq), ...this._nested].filter((seq) => !(seq instanceof chunkBPW42X7C_cjs.NullSequence)).map((seq) => {
|
|
400
640
|
const layer = this._visual.find((v) => v.seq === seq)?.layer ?? null;
|
|
401
641
|
return {
|
|
402
642
|
seq,
|
|
403
643
|
display: layer?.display ?? seq.target,
|
|
404
644
|
threeD: layer !== null,
|
|
405
|
-
carriers: carriersOf(seq)
|
|
645
|
+
carriers: carriersOf(seq),
|
|
646
|
+
depthBlur: layer?.blur ?? 0
|
|
406
647
|
};
|
|
407
648
|
});
|
|
408
649
|
}
|
|
409
650
|
/** Match every `parent: 'name'` to a null layer; anything that cannot work is said out loud and drawn unparented. */
|
|
410
651
|
_resolveParents() {
|
|
411
|
-
const nulls = this._children.filter((c) => c instanceof
|
|
652
|
+
const nulls = this._children.filter((c) => c instanceof chunkBPW42X7C_cjs.NullSequence);
|
|
412
653
|
const nullNames = nulls.map((n) => n.spec.name).filter((n) => !!n);
|
|
413
654
|
const warned = /* @__PURE__ */ new Set();
|
|
414
655
|
for (const child of this._children) {
|
|
415
656
|
const want = child.spec.parent;
|
|
416
657
|
if (want === void 0) continue;
|
|
417
|
-
const who =
|
|
418
|
-
if (child instanceof
|
|
658
|
+
const who = chunkBPW42X7C_cjs.describeLayer(child.spec);
|
|
659
|
+
if (child instanceof chunkBPW42X7C_cjs.CameraSequence) {
|
|
419
660
|
console.warn(`pixi-effects: ${who}: a camera cannot have a parent; ignored`);
|
|
420
661
|
continue;
|
|
421
662
|
}
|
|
@@ -425,11 +666,11 @@ var CompositionSequence = class extends chunkVTBT6NNE_cjs.Sequence {
|
|
|
425
666
|
}
|
|
426
667
|
const same = this._children.filter((c) => c.spec.name === want);
|
|
427
668
|
if (same.length === 0) {
|
|
428
|
-
const hint =
|
|
669
|
+
const hint = chunkWTRKDIKH_cjs.suggestName(want, nullNames);
|
|
429
670
|
console.warn(`pixi-effects: ${who}: parent "${want}": no layer with that name${hint ? `; did you mean "${hint}"?` : ""} (the layer is drawn without a parent)`);
|
|
430
671
|
continue;
|
|
431
672
|
}
|
|
432
|
-
const holder = same.find((c) => c instanceof
|
|
673
|
+
const holder = same.find((c) => c instanceof chunkBPW42X7C_cjs.NullSequence);
|
|
433
674
|
if (!holder) {
|
|
434
675
|
console.warn(`pixi-effects: ${who}: parent "${want}" is a ${same[0].spec.type} layer; only { type: 'null' } layers can be parents (the layer is drawn without a parent)`);
|
|
435
676
|
continue;
|
|
@@ -463,17 +704,20 @@ var CompositionSequence = class extends chunkVTBT6NNE_cjs.Sequence {
|
|
|
463
704
|
for (const child of this._children) child.syncFrame();
|
|
464
705
|
}
|
|
465
706
|
updateSpace(t, host) {
|
|
466
|
-
|
|
707
|
+
const childT = this.childTime(t);
|
|
708
|
+
for (const child of this._children) child.updateSpace(childT, host);
|
|
467
709
|
if (this._layers3d.length === 0 || !this._compositionShape) return;
|
|
468
710
|
const { width, height } = this._compositionShape;
|
|
469
|
-
const compEnd =
|
|
711
|
+
const compEnd = this._childBase + (this.duration ?? 0);
|
|
470
712
|
const active = pickActiveCamera(
|
|
471
|
-
this._cameras.map((
|
|
472
|
-
|
|
713
|
+
this._cameras.map((cam2) => ({ cam: cam2, ...cam2.window() })),
|
|
714
|
+
childT,
|
|
473
715
|
compEnd
|
|
474
716
|
);
|
|
475
|
-
const
|
|
717
|
+
const cam = active ? active.cam.state() : chunkBPW42X7C_cjs.homeCamera(width, height);
|
|
718
|
+
const basis = chunkBPW42X7C_cjs.cameraBasis(cam, width, height);
|
|
476
719
|
for (const layer of this._layers3d) layer.update(host, basis);
|
|
720
|
+
this._applyDepthOfField(cam, basis);
|
|
477
721
|
const order = assignDepthOrder(
|
|
478
722
|
this._visual.map((v, i) => ({ stackIndex: i, threeD: v.layer !== null, depth: v.layer?.depth ?? 0 }))
|
|
479
723
|
);
|
|
@@ -481,12 +725,53 @@ var CompositionSequence = class extends chunkVTBT6NNE_cjs.Sequence {
|
|
|
481
725
|
if (v.layer) v.layer.display.zIndex = order[i];
|
|
482
726
|
});
|
|
483
727
|
}
|
|
728
|
+
/** Depth of field: each threeD layer is blurred by how far its depth is from the focal plane (a pure function of the camera and the layers). */
|
|
729
|
+
_applyDepthOfField(cam, basis) {
|
|
730
|
+
const aperture = cam.aperture ?? 0;
|
|
731
|
+
if (!(aperture > 0)) {
|
|
732
|
+
for (const l of this._layers3d) l.setBlur(0);
|
|
733
|
+
return;
|
|
734
|
+
}
|
|
735
|
+
const focusDepth = chunkBPW42X7C_cjs.projectPoint(basis, { x: cam.lookAtX, y: cam.lookAtY, z: cam.focus ?? 0 }).depth;
|
|
736
|
+
if (!(focusDepth > chunkBPW42X7C_cjs.NEAR)) {
|
|
737
|
+
if (!this._dofSaid.behind) {
|
|
738
|
+
this._dofSaid.behind = true;
|
|
739
|
+
console.warn(`pixi-effects: ${chunkBPW42X7C_cjs.describeLayer(this.spec)}: the camera's focus (z = ${(cam.focus ?? 0).toFixed(0)}) is at or behind the camera, so nothing is blurred. Put focus in front of the camera (a z below the camera's z)`);
|
|
740
|
+
}
|
|
741
|
+
for (const l of this._layers3d) l.setBlur(0);
|
|
742
|
+
return;
|
|
743
|
+
}
|
|
744
|
+
let blurred = 0;
|
|
745
|
+
for (const l of this._layers3d) {
|
|
746
|
+
l.setBlur(l.display.visible ? chunkBPW42X7C_cjs.blurRadius(aperture, basis.focal, l.depth, focusDepth) : 0);
|
|
747
|
+
if (l.blur > 0) blurred++;
|
|
748
|
+
}
|
|
749
|
+
if (blurred >= chunkBPW42X7C_cjs.MANY_BLURRED && !this._dofSaid.many) {
|
|
750
|
+
this._dofSaid.many = true;
|
|
751
|
+
console.warn(`pixi-effects: ${chunkBPW42X7C_cjs.describeLayer(this.spec)}: ${blurred} layers are blurred by depth of field at once; each costs a filter pass per frame (WebGPU more). Merge the far layers or lower aperture`);
|
|
752
|
+
}
|
|
753
|
+
}
|
|
484
754
|
collectAudio(out, baseTime) {
|
|
485
755
|
super.collectAudio(out, baseTime);
|
|
486
|
-
const
|
|
487
|
-
|
|
756
|
+
const remap = this._remap;
|
|
757
|
+
if (!remap) {
|
|
758
|
+
const childBase = baseTime + this.at;
|
|
759
|
+
for (const child of this._children) child.collectAudio(out, childBase);
|
|
760
|
+
return;
|
|
761
|
+
}
|
|
762
|
+
const inner = [];
|
|
763
|
+
for (const child of this._children) child.collectAudio(inner, 0);
|
|
764
|
+
const lo = baseTime + this.at, hi = lo + this.duration;
|
|
765
|
+
const table = chunkBPW42X7C_cjs.clockTable(remap, "time", this.duration, lo, this.scope(), hi);
|
|
766
|
+
for (const d of inner) {
|
|
767
|
+
const prev = d.warp;
|
|
768
|
+
out.push({ ...d, warp: (t) => t < lo || t > hi ? NaN : prev ? prev(table.at(t)) : table.at(t) });
|
|
769
|
+
}
|
|
488
770
|
}
|
|
489
771
|
destroy() {
|
|
772
|
+
this._inner?.kill();
|
|
773
|
+
this._inner = null;
|
|
774
|
+
this._clock = null;
|
|
490
775
|
for (const l of this._layers3d) l.destroy();
|
|
491
776
|
this._layers3d = [];
|
|
492
777
|
for (const c of this._children) c.destroy();
|
|
@@ -501,5 +786,5 @@ function frameOf(child) {
|
|
|
501
786
|
}
|
|
502
787
|
|
|
503
788
|
exports.CompositionSequence = CompositionSequence;
|
|
504
|
-
//# sourceMappingURL=chunk-
|
|
505
|
-
//# sourceMappingURL=chunk-
|
|
789
|
+
//# sourceMappingURL=chunk-6JJC37ZD.cjs.map
|
|
790
|
+
//# sourceMappingURL=chunk-6JJC37ZD.cjs.map
|