pixi-effects 0.21.0 → 0.25.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. package/CHANGELOG.md +46 -0
  2. package/README.md +9 -7
  3. package/ai/SKILL.md +5 -3
  4. package/ai/chat-template.html +3 -3
  5. package/ai/reference/cheatsheet.md +10 -7
  6. package/ai/reference/pitfalls.md +19 -3
  7. package/ai/reference/recipes.md +161 -0
  8. package/ai/template.html +5 -5
  9. package/ai/tools/check.mjs +21 -3
  10. package/dist/{Base-CzfLGoDr.d.ts → Base-BgnRXbtJ.d.ts} +1 -1
  11. package/dist/{Base-wYJQ2g5Q.d.cts → Base-DHVKqA46.d.cts} +1 -1
  12. package/dist/Composition-2GJSCHPP.cjs +16 -0
  13. package/dist/{Composition-2UFPSNVN.cjs.map → Composition-2GJSCHPP.cjs.map} +1 -1
  14. package/dist/Composition-C4FSWJZF.js +7 -0
  15. package/dist/{Composition-BVI236ZR.js.map → Composition-C4FSWJZF.js.map} +1 -1
  16. package/dist/Controller.cjs +2 -2
  17. package/dist/Controller.d.cts +2 -2
  18. package/dist/Controller.d.ts +2 -2
  19. package/dist/Controller.js +1 -1
  20. package/dist/{Movie-mtX9AkQ-.d.cts → Movie-CTpN1wYL.d.cts} +3 -1
  21. package/dist/{Movie-CgYwa5QG.d.ts → Movie-FM5m67V0.d.ts} +3 -1
  22. package/dist/Presenter.cjs +2 -2
  23. package/dist/Presenter.d.cts +2 -2
  24. package/dist/Presenter.d.ts +2 -2
  25. package/dist/Presenter.js +1 -1
  26. package/dist/blendModes-G3NOAU3T.js +90 -0
  27. package/dist/blendModes-G3NOAU3T.js.map +1 -0
  28. package/dist/blendModes-YV43K6E7.cjs +94 -0
  29. package/dist/blendModes-YV43K6E7.cjs.map +1 -0
  30. package/dist/chunk-3DLYAPK7.cjs +141 -0
  31. package/dist/chunk-3DLYAPK7.cjs.map +1 -0
  32. package/dist/chunk-AXZUKNXF.js +132 -0
  33. package/dist/chunk-AXZUKNXF.js.map +1 -0
  34. package/dist/{chunk-MNM56B3X.js → chunk-BXOCEZ4U.js} +22 -3
  35. package/dist/chunk-BXOCEZ4U.js.map +1 -0
  36. package/dist/{chunk-BPW42X7C.cjs → chunk-DP37TTMO.cjs} +863 -314
  37. package/dist/chunk-DP37TTMO.cjs.map +1 -0
  38. package/dist/chunk-ECA2WNRX.cjs +289 -0
  39. package/dist/chunk-ECA2WNRX.cjs.map +1 -0
  40. package/dist/{chunk-DDIXIWXK.js → chunk-PRZ4U6JN.js} +835 -290
  41. package/dist/chunk-PRZ4U6JN.js.map +1 -0
  42. package/dist/chunk-SY27HZC5.cjs +1727 -0
  43. package/dist/chunk-SY27HZC5.cjs.map +1 -0
  44. package/dist/chunk-TLYTYBWX.js +282 -0
  45. package/dist/chunk-TLYTYBWX.js.map +1 -0
  46. package/dist/{chunk-WTRKDIKH.cjs → chunk-TWZNOUM7.cjs} +22 -3
  47. package/dist/chunk-TWZNOUM7.cjs.map +1 -0
  48. package/dist/chunk-XS6GSJCN.js +1724 -0
  49. package/dist/chunk-XS6GSJCN.js.map +1 -0
  50. package/dist/index.cjs +227 -74
  51. package/dist/index.cjs.map +1 -1
  52. package/dist/index.d.cts +5 -5
  53. package/dist/index.d.ts +5 -5
  54. package/dist/index.js +167 -14
  55. package/dist/index.js.map +1 -1
  56. package/dist/loader.css +1 -1
  57. package/dist/{music-CFEC7HKL.js → music-AF4VTFAF.js} +3 -3
  58. package/dist/{music-CFEC7HKL.js.map → music-AF4VTFAF.js.map} +1 -1
  59. package/dist/{music-UAN7DXK4.cjs → music-KB7YZLHP.cjs} +7 -7
  60. package/dist/{music-UAN7DXK4.cjs.map → music-KB7YZLHP.cjs.map} +1 -1
  61. package/dist/{sfx-EX4PUBMV.cjs → sfx-2O6UQEUP.cjs} +8 -8
  62. package/dist/{sfx-EX4PUBMV.cjs.map → sfx-2O6UQEUP.cjs.map} +1 -1
  63. package/dist/{sfx-U3GM2MED.js → sfx-VUKARHDX.js} +3 -3
  64. package/dist/{sfx-U3GM2MED.js.map → sfx-VUKARHDX.js.map} +1 -1
  65. package/dist/three.cjs +7 -6
  66. package/dist/three.cjs.map +1 -1
  67. package/dist/three.d.cts +2 -2
  68. package/dist/three.d.ts +2 -2
  69. package/dist/three.js +3 -2
  70. package/dist/three.js.map +1 -1
  71. package/dist/{types-YmUaViL1.d.ts → types-CoT0ypcx.d.cts} +66 -7
  72. package/dist/{types-YmUaViL1.d.cts → types-CoT0ypcx.d.ts} +66 -7
  73. package/docs/dsl.md +180 -6
  74. package/llms-full.txt +375 -19
  75. package/package.json +1 -1
  76. package/dist/Composition-2UFPSNVN.cjs +0 -14
  77. package/dist/Composition-BVI236ZR.js +0 -5
  78. package/dist/chunk-6JJC37ZD.cjs +0 -790
  79. package/dist/chunk-6JJC37ZD.cjs.map +0 -1
  80. package/dist/chunk-BPW42X7C.cjs.map +0 -1
  81. package/dist/chunk-DDIXIWXK.js.map +0 -1
  82. package/dist/chunk-MNM56B3X.js.map +0 -1
  83. package/dist/chunk-NGYGFGDS.js +0 -788
  84. package/dist/chunk-NGYGFGDS.js.map +0 -1
  85. package/dist/chunk-WTRKDIKH.cjs.map +0 -1
@@ -1,6 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var chunkWTRKDIKH_cjs = require('./chunk-WTRKDIKH.cjs');
3
+ var chunkECA2WNRX_cjs = require('./chunk-ECA2WNRX.cjs');
4
+ var chunkTWZNOUM7_cjs = require('./chunk-TWZNOUM7.cjs');
4
5
  var PIXI = require('pixi.js');
5
6
  var gsap = require('gsap');
6
7
 
@@ -500,7 +501,7 @@ function checkEase(ease, where) {
500
501
  console.warn(`pixi-effects: ${where}: "${ease}" is a family, not an ease \u2014 write ${ease.toLowerCase()}.out, ${ease.toLowerCase()}.in or ${ease.toLowerCase()}.inOut`);
501
502
  return;
502
503
  }
503
- const guess = chunkWTRKDIKH_cjs.suggestName(ease, EASE_NAMES);
504
+ const guess = chunkTWZNOUM7_cjs.suggestName(ease, EASE_NAMES);
504
505
  console.warn(`pixi-effects: ${where}: unknown ease "${ease}"${guess ? ` \u2014 did you mean "${guess}"?` : ""} (GSAP would run it as its default ease, power1.out). Examples: ${EASE_NAMES.slice(0, 7).join(", ")}, back.out(1.7), elastic.out(1, 0.3), steps(8)`);
505
506
  }
506
507
 
@@ -548,8 +549,8 @@ function partitionProps(props) {
548
549
  for (const k of Object.keys(props)) {
549
550
  const m = k.match(/^filters\.([^.]+)\.(.+)$/);
550
551
  if (m) {
551
- const [, name, sub] = m;
552
- (filterProps[name] ??= {})[sub] = props[k];
552
+ const [, name, sub2] = m;
553
+ (filterProps[name] ??= {})[sub2] = props[k];
553
554
  } else {
554
555
  ownProps[k] = props[k];
555
556
  }
@@ -561,10 +562,10 @@ function splitRouted(props, routers) {
561
562
  const rest = {};
562
563
  const routed = [];
563
564
  for (const k of Object.keys(props)) {
564
- const dot = k.indexOf(".");
565
- const router = dot > 0 ? routers[k.slice(0, dot)] : void 0;
565
+ const dot2 = k.indexOf(".");
566
+ const router = dot2 > 0 ? routers[k.slice(0, dot2)] : void 0;
566
567
  if (router) {
567
- const hit = router(k.slice(dot + 1));
568
+ const hit = router(k.slice(dot2 + 1));
568
569
  if (hit) routed.push({ target: hit.target, prop: hit.prop, key: k, value: props[k] });
569
570
  } else {
570
571
  rest[k] = props[k];
@@ -1110,7 +1111,7 @@ var GRAIN_KEYS = ["amount", "size", "seed", "fps", "color"];
1110
1111
  var GrainFilter = class extends PIXI.Filter {
1111
1112
  _fps;
1112
1113
  constructor(options = {}) {
1113
- chunkWTRKDIKH_cjs.warnUnknownOptions("grain filter", options, GRAIN_KEYS);
1114
+ chunkTWZNOUM7_cjs.warnUnknownOptions("grain filter", options, GRAIN_KEYS);
1114
1115
  const { amount = 0.08, size = 1.5, seed = 0, fps = 24, color = 0 } = options;
1115
1116
  super({
1116
1117
  glProgram: PIXI.GlProgram.from({ vertex: GL_VERTEX, fragment: GL_FRAGMENT2, name: "grain-filter" }),
@@ -1165,10 +1166,238 @@ var GrainFilter = class extends PIXI.Filter {
1165
1166
  this.u.uFrame = this._fps > 0 ? Math.floor(t * this._fps + 1e-3) : 0;
1166
1167
  }
1167
1168
  };
1169
+ var WARP_KINDS = ["wave", "haze"];
1170
+ var OPTION_KEYS = ["kind", "strength", "scale", "speed", "angle", "seed"];
1171
+ var DEG = Math.PI / 180;
1172
+ var HASH_GL2 = `
1173
+ uint hash(uint x) { x ^= x >> 16; x *= 0x7feb352du; x ^= x >> 15; x *= 0x846ca68bu; x ^= x >> 16; return x; }
1174
+ float lattice(ivec2 p, uint k) {
1175
+ uint h = hash(uint(p.x) + hash(uint(p.y) + hash(k)));
1176
+ return float(h >> 8) / 16777215.0;
1177
+ }
1178
+ float valueNoise(vec2 q, uint k) {
1179
+ vec2 i = floor(q);
1180
+ vec2 f = fract(q);
1181
+ vec2 u = f * f * (3.0 - 2.0 * f);
1182
+ ivec2 p = ivec2(i);
1183
+ float a = lattice(p, k), b = lattice(p + ivec2(1, 0), k), c = lattice(p + ivec2(0, 1), k), d = lattice(p + ivec2(1, 1), k);
1184
+ return mix(mix(a, b, u.x), mix(c, d, u.x), u.y);
1185
+ }`;
1186
+ var GL_VERTEX2 = `#version 300 es
1187
+ precision highp float;
1188
+ in vec2 aPosition;
1189
+ out vec2 vTextureCoord;
1190
+ uniform highp vec4 uInputSize;
1191
+ uniform highp vec4 uOutputFrame;
1192
+ uniform highp vec4 uOutputTexture;
1193
+ void main(void) {
1194
+ vec2 position = aPosition * uOutputFrame.zw + uOutputFrame.xy;
1195
+ position.x = position.x * (2.0 / uOutputTexture.x) - 1.0;
1196
+ position.y = position.y * (2.0 * uOutputTexture.z / uOutputTexture.y) - uOutputTexture.z;
1197
+ gl_Position = vec4(position, 0.0, 1.0);
1198
+ vTextureCoord = aPosition * (uOutputFrame.zw * uInputSize.zw);
1199
+ }`;
1200
+ var GL_FRAGMENT3 = `#version 300 es
1201
+ precision highp float;
1202
+ precision highp int;
1203
+ in vec2 vTextureCoord;
1204
+ uniform sampler2D uTexture;
1205
+ uniform highp vec4 uInputSize;
1206
+ uniform highp vec4 uInputClamp;
1207
+ uniform float uStrength;
1208
+ uniform float uScale;
1209
+ uniform float uSpeed;
1210
+ uniform float uAngle;
1211
+ uniform float uSeed;
1212
+ uniform float uMode;
1213
+ uniform float uTime;
1214
+ out vec4 finalColor;
1215
+ ${HASH_GL2}
1216
+ void main(void) {
1217
+ vec2 pos = vTextureCoord * uInputSize.xy;
1218
+ vec2 off;
1219
+ if (uMode < 0.5) {
1220
+ float phase = dot(pos, vec2(cos(uAngle), sin(uAngle))) / uScale - uSpeed * uTime;
1221
+ float s = uStrength * sin(6.28318530718 * phase);
1222
+ off = vec2(-sin(uAngle), cos(uAngle)) * s;
1223
+ } else {
1224
+ uint k = hash(uint(uSeed));
1225
+ vec2 p = vec2(pos.x / uScale, pos.y / uScale - uSpeed * uTime);
1226
+ off = uStrength * 2.0 * vec2(valueNoise(p, k) - 0.5, valueNoise(p + vec2(37.2, 17.8), k) - 0.5);
1227
+ }
1228
+ vec2 suv = clamp(vTextureCoord + off * uInputSize.zw, uInputClamp.xy, uInputClamp.zw);
1229
+ finalColor = texture(uTexture, suv);
1230
+ }`;
1231
+ var WGSL_SOURCE3 = `
1232
+ struct GlobalFilterUniforms {
1233
+ uInputSize: vec4<f32>,
1234
+ uInputPixel: vec4<f32>,
1235
+ uInputClamp: vec4<f32>,
1236
+ uOutputFrame: vec4<f32>,
1237
+ uGlobalFrame: vec4<f32>,
1238
+ uOutputTexture: vec4<f32>,
1239
+ };
1240
+ struct WarpUniforms {
1241
+ uStrength: f32,
1242
+ uScale: f32,
1243
+ uSpeed: f32,
1244
+ uAngle: f32,
1245
+ uSeed: f32,
1246
+ uMode: f32,
1247
+ uTime: f32,
1248
+ };
1249
+ @group(0) @binding(0) var<uniform> gfu: GlobalFilterUniforms;
1250
+ @group(0) @binding(1) var uTexture: texture_2d<f32>;
1251
+ @group(0) @binding(2) var uSampler : sampler;
1252
+ @group(1) @binding(0) var<uniform> warpUniforms : WarpUniforms;
1253
+
1254
+ struct VSOutput {
1255
+ @builtin(position) position: vec4<f32>,
1256
+ @location(0) uv : vec2<f32>,
1257
+ };
1258
+ fn filterVertexPosition(aPosition : vec2<f32>) -> vec4<f32> {
1259
+ var position = aPosition * gfu.uOutputFrame.zw + gfu.uOutputFrame.xy;
1260
+ position.x = position.x * (2.0 / gfu.uOutputTexture.x) - 1.0;
1261
+ position.y = position.y * (2.0 * gfu.uOutputTexture.z / gfu.uOutputTexture.y) - gfu.uOutputTexture.z;
1262
+ return vec4<f32>(position, 0.0, 1.0);
1263
+ }
1264
+ fn filterTextureCoord(aPosition : vec2<f32>) -> vec2<f32> {
1265
+ return aPosition * (gfu.uOutputFrame.zw * gfu.uInputSize.zw);
1266
+ }
1267
+ @vertex
1268
+ fn mainVertex(
1269
+ @location(0) aPosition : vec2<f32>,
1270
+ ) -> VSOutput {
1271
+ return VSOutput(
1272
+ filterVertexPosition(aPosition),
1273
+ filterTextureCoord(aPosition),
1274
+ );
1275
+ }
1276
+
1277
+ fn hash(xIn: u32) -> u32 {
1278
+ var x = xIn;
1279
+ x = x ^ (x >> 16u); x = x * 0x7feb352du; x = x ^ (x >> 15u); x = x * 0x846ca68bu; x = x ^ (x >> 16u);
1280
+ return x;
1281
+ }
1282
+ fn lattice(p: vec2<i32>, k: u32) -> f32 {
1283
+ let h = hash(u32(p.x) + hash(u32(p.y) + hash(k)));
1284
+ return f32(h >> 8u) / 16777215.0;
1285
+ }
1286
+ fn valueNoise(q: vec2<f32>, k: u32) -> f32 {
1287
+ let i = floor(q);
1288
+ let f = fract(q);
1289
+ let u = f * f * (3.0 - 2.0 * f);
1290
+ let p = vec2<i32>(i);
1291
+ let a = lattice(p, k);
1292
+ let b = lattice(p + vec2<i32>(1, 0), k);
1293
+ let c = lattice(p + vec2<i32>(0, 1), k);
1294
+ let d = lattice(p + vec2<i32>(1, 1), k);
1295
+ return mix(mix(a, b, u.x), mix(c, d, u.x), u.y);
1296
+ }
1297
+
1298
+ @fragment
1299
+ fn mainFragment(@location(0) uv : vec2<f32>) -> @location(0) vec4<f32> {
1300
+ let pos = uv * gfu.uInputSize.xy;
1301
+ var off = vec2<f32>(0.0);
1302
+ if (warpUniforms.uMode < 0.5) {
1303
+ let phase = dot(pos, vec2<f32>(cos(warpUniforms.uAngle), sin(warpUniforms.uAngle))) / warpUniforms.uScale - warpUniforms.uSpeed * warpUniforms.uTime;
1304
+ let s = warpUniforms.uStrength * sin(6.28318530718 * phase);
1305
+ off = vec2<f32>(-sin(warpUniforms.uAngle), cos(warpUniforms.uAngle)) * s;
1306
+ } else {
1307
+ let k = hash(u32(warpUniforms.uSeed));
1308
+ let p = vec2<f32>(pos.x / warpUniforms.uScale, pos.y / warpUniforms.uScale - warpUniforms.uSpeed * warpUniforms.uTime);
1309
+ off = warpUniforms.uStrength * 2.0 * vec2<f32>(valueNoise(p, k) - 0.5, valueNoise(p + vec2<f32>(37.2, 17.8), k) - 0.5);
1310
+ }
1311
+ let suv = clamp(uv + off * gfu.uInputSize.zw, gfu.uInputClamp.xy, gfu.uInputClamp.zw);
1312
+ return textureSampleLevel(uTexture, uSampler, suv, 0.0);
1313
+ }`;
1314
+ var WarpFilter = class extends PIXI.Filter {
1315
+ constructor(options = {}) {
1316
+ chunkTWZNOUM7_cjs.warnUnknownOptions("warp filter", options, OPTION_KEYS);
1317
+ let { kind = "wave", strength = 6, scale = 80, speed = 0.5, angle = 0, seed = 0 } = options;
1318
+ if (!WARP_KINDS.includes(kind)) {
1319
+ const guess = chunkTWZNOUM7_cjs.suggestName(String(kind), WARP_KINDS);
1320
+ console.warn(`pixi-effects: warp: kind ${JSON.stringify(kind)} is not supported${guess ? `; did you mean "${guess}"?` : ""} (use ${WARP_KINDS.join(" or ")}); wave is used`);
1321
+ kind = "wave";
1322
+ }
1323
+ if (!(strength >= 0 && strength <= 200)) {
1324
+ console.warn(`pixi-effects: warp: strength ${strength} is not a number from 0 to 200: it is the largest shift in pixels (8 is a clear ripple); ${strength > 200 ? "200" : "0"} is used`);
1325
+ strength = strength > 200 ? 200 : 0;
1326
+ }
1327
+ if (!(seed >= 0)) {
1328
+ console.warn(`pixi-effects: warp: seed ${seed} must be 0 or more (an integer that picks the haze pattern); 0 is used`);
1329
+ seed = 0;
1330
+ }
1331
+ if (!(scale > 0)) {
1332
+ console.warn(`pixi-effects: warp: scale ${scale} must be above 0: it is the wavelength in pixels (80 is the default); 1 is used`);
1333
+ scale = 1;
1334
+ }
1335
+ super({
1336
+ glProgram: PIXI.GlProgram.from({ vertex: GL_VERTEX2, fragment: GL_FRAGMENT3, name: "warp-filter" }),
1337
+ gpuProgram: PIXI.GpuProgram.from({ vertex: { source: WGSL_SOURCE3, entryPoint: "mainVertex" }, fragment: { source: WGSL_SOURCE3, entryPoint: "mainFragment" } }),
1338
+ resources: {
1339
+ warpUniforms: new PIXI.UniformGroup({
1340
+ uStrength: { value: strength, type: "f32" },
1341
+ uScale: { value: scale, type: "f32" },
1342
+ uSpeed: { value: speed, type: "f32" },
1343
+ uAngle: { value: angle * DEG, type: "f32" },
1344
+ uSeed: { value: Math.floor(seed), type: "f32" },
1345
+ uMode: { value: kind === "haze" ? 1 : 0, type: "f32" },
1346
+ uTime: { value: 0, type: "f32" }
1347
+ })
1348
+ }
1349
+ });
1350
+ this.padding = Math.ceil(strength);
1351
+ }
1352
+ get u() {
1353
+ return this.resources.warpUniforms.uniforms;
1354
+ }
1355
+ get kind() {
1356
+ return this.u.uMode === 1 ? "haze" : "wave";
1357
+ }
1358
+ set kind(v) {
1359
+ this.u.uMode = v === "haze" ? 1 : 0;
1360
+ }
1361
+ get strength() {
1362
+ return this.u.uStrength;
1363
+ }
1364
+ set strength(v) {
1365
+ this.u.uStrength = v;
1366
+ this.padding = Math.ceil(Math.max(0, v));
1367
+ }
1368
+ get scale() {
1369
+ return this.u.uScale;
1370
+ }
1371
+ set scale(v) {
1372
+ this.u.uScale = Math.max(v, 1e-3);
1373
+ }
1374
+ get speed() {
1375
+ return this.u.uSpeed;
1376
+ }
1377
+ set speed(v) {
1378
+ this.u.uSpeed = v;
1379
+ }
1380
+ get angle() {
1381
+ return this.u.uAngle / DEG;
1382
+ }
1383
+ set angle(v) {
1384
+ this.u.uAngle = v * DEG;
1385
+ }
1386
+ get seed() {
1387
+ return this.u.uSeed;
1388
+ }
1389
+ set seed(v) {
1390
+ this.u.uSeed = v >= 0 ? Math.floor(v) : 0;
1391
+ }
1392
+ /** The movie calls this with the time (s) of the frame it is about to draw. */
1393
+ setTime(t) {
1394
+ this.u.uTime = t;
1395
+ }
1396
+ };
1168
1397
 
1169
1398
  // src/filters/named.ts
1170
1399
  var CORE = { blur: "BlurFilter", noise: "NoiseFilter", alpha: "AlphaFilter" };
1171
- var CORE_TYPES = [...Object.keys(CORE), "colorMatrix", "grain"];
1400
+ var CORE_TYPES = [...Object.keys(CORE), "colorMatrix", "grain", "warp"];
1172
1401
  var LIBRARY_TYPES = [
1173
1402
  "adjustment",
1174
1403
  "advancedBloom",
@@ -1218,7 +1447,7 @@ function isNamedFilterType(t) {
1218
1447
  return !NOT_NAMED.has(t);
1219
1448
  }
1220
1449
  function unknownType(t) {
1221
- const guess = chunkWTRKDIKH_cjs.suggestName(t, FILTER_TYPES);
1450
+ const guess = chunkTWZNOUM7_cjs.suggestName(t, FILTER_TYPES);
1222
1451
  return new Error(`pixi-effects: unknown filter type "${t}"${guess ? ` \u2014 did you mean "${guess}"?` : ""} (valid: ${[...FILTER_TYPES, "chromaKey", "custom"].join(", ")})`);
1223
1452
  }
1224
1453
  var library = null;
@@ -1267,7 +1496,7 @@ function colorMatrix(params) {
1267
1496
  const preset = params.preset;
1268
1497
  if (preset !== void 0) {
1269
1498
  if (!MATRIX_PRESETS.includes(preset)) {
1270
- const guess = chunkWTRKDIKH_cjs.suggestName(preset, MATRIX_PRESETS);
1499
+ const guess = chunkTWZNOUM7_cjs.suggestName(preset, MATRIX_PRESETS);
1271
1500
  throw new Error(`pixi-effects: colorMatrix preset "${preset}" is not one of ${MATRIX_PRESETS.join(", ")}${guess ? ` \u2014 did you mean "${guess}"?` : ""}`);
1272
1501
  }
1273
1502
  f[preset === "grayscale" ? "desaturate" : preset].call(f);
@@ -1286,6 +1515,7 @@ function colorGradientParams(params) {
1286
1515
  function createNamedFilter(type, params) {
1287
1516
  if (lower(type) === "colormatrix") return colorMatrix(params);
1288
1517
  if (lower(type) === "grain") return new GrainFilter(params);
1518
+ if (lower(type) === "warp") return new WarpFilter(params);
1289
1519
  const core = Object.entries(CORE).find(([k]) => lower(k) === lower(type));
1290
1520
  if (core) return new PIXI__namespace[core[1]](params);
1291
1521
  if (!isLibraryType(type)) throw unknownType(type);
@@ -1429,269 +1659,6 @@ var NullSequence = class extends Sequence {
1429
1659
  this.buildFilters();
1430
1660
  }
1431
1661
  };
1432
-
1433
- // src/space/specKeys.ts
1434
- function collectPropKeys(spec) {
1435
- const out = /* @__PURE__ */ new Set();
1436
- for (const k of Object.keys(spec.initial ?? {})) out.add(k);
1437
- for (const kf of spec.keyframes ?? []) {
1438
- for (const bag of [kf.set, kf.to, kf.from]) {
1439
- for (const k of Object.keys(bag ?? {})) out.add(k);
1440
- }
1441
- }
1442
- return out;
1443
- }
1444
-
1445
- // src/core/layerKeys.ts
1446
- var COMMON = ["type", "name", "parent", "at", "duration", "initial", "keyframes", "filters", "filterArea", "mask", "maskInverted", "blendMode", "threeD", "hideBehindCamera"];
1447
- var VIDEO = [...COMMON, "asset", "loop", "audio", "volume", "speed"];
1448
- var IMAGE = [...COMMON, "asset", "colorSpace"];
1449
- var TEXT = [...COMMON, "text", "format", "style", "colorSpace", "fillGradient"];
1450
- var AUDIO = [...COMMON, "volume", "asset", "loop", "sfx", "music", "speed"];
1451
- var COMPOSITION = [...COMMON, "width", "height", "sequences", "transitions", "speed"];
1452
- var CAMERA = [...COMMON];
1453
- var NULL = [...COMMON];
1454
- var SHAPE = [...COMMON, "shape", "fillGradient", "colorSpace", "strokeCap", "strokeJoin"];
1455
- var TRIM = ["trimStart", "trimEnd", "trimEach"];
1456
- var RECT = [...SHAPE, ...TRIM, "width", "height", "cornerRadius", "anchorX", "anchorY"];
1457
- var CIRCLE = [...SHAPE, ...TRIM, "radius", "anchorX", "anchorY"];
1458
- var ELLIPSE = [...SHAPE, ...TRIM, "radiusX", "radiusY", "anchorX", "anchorY"];
1459
- var ARC = [...SHAPE, "radius", "innerRadius", "startAngle", "endAngle"];
1460
- var LINE = [...SHAPE, ...TRIM, "from", "to"];
1461
- var POLYGON = [...SHAPE, ...TRIM, "points", "open"];
1462
- var PATH = [...SHAPE, ...TRIM, "d", "morphTo", "morph", "morphPoints"];
1463
- var SHAPES = { rect: RECT, circle: CIRCLE, ellipse: ELLIPSE, arc: ARC, line: LINE, polygon: POLYGON, path: PATH };
1464
- var BY_TYPE = { video: VIDEO, image: IMAGE, text: TEXT, audio: AUDIO, composition: COMPOSITION, camera: CAMERA, null: NULL };
1465
- function kindName(spec) {
1466
- return spec.type === "shape" && spec.shape ? `${spec.shape} shape` : `${spec.type} layer`;
1467
- }
1468
- function layerKeys(spec) {
1469
- if (spec.type === "shape") return spec.shape && SHAPES[spec.shape] || null;
1470
- return BY_TYPE[spec.type] ?? null;
1471
- }
1472
- function kindsWithKey(key) {
1473
- const out = [];
1474
- for (const [shape, keys] of Object.entries(SHAPES)) if (keys.includes(key)) out.push(`${shape} shape`);
1475
- for (const [type, keys] of Object.entries(BY_TYPE)) if (keys.includes(key)) out.push(`${type} layer`);
1476
- return out;
1477
- }
1478
- var PROP_KEYS = /* @__PURE__ */ new Set([
1479
- // transform and look (GSAP + PixiPlugin names)
1480
- "x",
1481
- "y",
1482
- "z",
1483
- "alpha",
1484
- "rotation",
1485
- "rotationX",
1486
- "rotationY",
1487
- "width",
1488
- "height",
1489
- "visible",
1490
- "autoAlpha",
1491
- "scale",
1492
- "scaleX",
1493
- "scaleY",
1494
- "anchor",
1495
- "anchorX",
1496
- "anchorY",
1497
- "pivot",
1498
- "pivotX",
1499
- "pivotY",
1500
- "skew",
1501
- "skewX",
1502
- "skewY",
1503
- "position",
1504
- "positionX",
1505
- "positionY",
1506
- "tint",
1507
- "colorize",
1508
- "colorizeAmount",
1509
- "blur",
1510
- "blurX",
1511
- "blurY",
1512
- "blurPadding",
1513
- // shapes
1514
- "fillColor",
1515
- "fillAlpha",
1516
- "strokeColor",
1517
- "strokeAlpha",
1518
- "strokeWidth",
1519
- "lineColor",
1520
- "lineAlpha",
1521
- "cornerRadius",
1522
- "radius",
1523
- "radiusX",
1524
- "radiusY",
1525
- "innerRadius",
1526
- "startAngle",
1527
- "endAngle",
1528
- "trimStart",
1529
- "trimEnd",
1530
- "trimEach",
1531
- "morph",
1532
- "fillGradient",
1533
- "strokeCap",
1534
- "strokeJoin",
1535
- // text, audio, video
1536
- "fill",
1537
- "value",
1538
- "visibleChars",
1539
- "text",
1540
- "volume",
1541
- "time",
1542
- // camera
1543
- "lookAtX",
1544
- "lookAtY",
1545
- "lookAtZ",
1546
- "fov",
1547
- "focus",
1548
- "aperture",
1549
- "offsetX",
1550
- "offsetY",
1551
- "offsetZ",
1552
- "lookOffsetX",
1553
- "lookOffsetY",
1554
- "lookOffsetZ"
1555
- ]);
1556
- var STYLE_KEYS = [
1557
- "fontSize",
1558
- "fontFamily",
1559
- "fontWeight",
1560
- "fontStyle",
1561
- "fontVariant",
1562
- "fill",
1563
- "stroke",
1564
- "dropShadow",
1565
- "letterSpacing",
1566
- "lineHeight",
1567
- "leading",
1568
- "align",
1569
- "wordWrap",
1570
- "wordWrapWidth",
1571
- "breakWords",
1572
- "whiteSpace",
1573
- "padding",
1574
- "textBaseline",
1575
- "trim",
1576
- "lineJoin",
1577
- "miterLimit",
1578
- "filters",
1579
- "tagStyles"
1580
- ];
1581
-
1582
- // src/core/lint.ts
1583
- var defaultWarn = (m) => console.warn(m);
1584
- function describeLayer(spec) {
1585
- return spec.name ? `layer "${spec.name}"` : `unnamed ${spec.type} layer`;
1586
- }
1587
- function lintTiming(spec, parentDuration, warn = defaultWarn) {
1588
- const who = describeLayer(spec);
1589
- const at = spec.at ?? 0;
1590
- if (at >= parentDuration) {
1591
- warn(`pixi-effects: ${who} starts at ${at}s, after its composition ends (${parentDuration}s), so it is never visible`);
1592
- }
1593
- if (spec.type === "audio" && (spec.sfx !== void 0 || spec.music !== void 0) && spec.duration === void 0) return;
1594
- const duration = spec.duration ?? parentDuration;
1595
- (spec.keyframes ?? []).forEach((kf, i) => {
1596
- const kat = kf.at ?? 0;
1597
- if (kat >= duration) {
1598
- warn(
1599
- `pixi-effects: ${who}: keyframes[${i}] starts at ${kat}s, after the layer ends (duration ${duration}s), so it never plays. Keyframe \`at\` is measured from the start of this layer, not from the start of the composition.`,
1600
- "late-keyframe"
1601
- );
1602
- }
1603
- });
1604
- }
1605
- function summarizeWarnings(messages, shown = 3) {
1606
- if (messages.length <= shown) return messages;
1607
- return [...messages.slice(0, shown), `pixi-effects: ${messages.length - shown} more layers with the same problem (the same loop or helper is probably building them): fix the ones above and these go away.`];
1608
- }
1609
- function lintText(spec, warn = defaultWarn) {
1610
- if (spec.type !== "text") return;
1611
- const strings = [spec.text ?? "", ...(spec.keyframes ?? []).map((kf) => String(kf.set?.text ?? ""))];
1612
- const hasPlaceholder = strings.some((t) => t.includes("{value}"));
1613
- if (hasPlaceholder && !collectPropKeys(spec).has("value")) {
1614
- warn(`pixi-effects: ${describeLayer(spec)}: the text has a {value} placeholder but nothing sets or animates \`value\`, so it prints 0. Set initial: { value: \u2026 } or animate it; {value} is reserved for counters (there is no way to print a literal "{value}").`);
1615
- }
1616
- if (collectPropKeys(spec).has("value") && !hasPlaceholder) {
1617
- warn(`pixi-effects: ${describeLayer(spec)}: \`value\` is set or animated but the text has no {value} placeholder, so nothing shows it. Use text: '{value}' (or e.g. '{value} users').`);
1618
- }
1619
- }
1620
- var REMAPPABLE = /* @__PURE__ */ new Set(["video", "audio", "composition"]);
1621
- var REMAP_NAMES = /* @__PURE__ */ new Set(["time", "timeRemap", "reverse"]);
1622
- var TIME_BAGS = ["set", "to", "from"];
1623
- function lintRemap(spec, warn) {
1624
- const s = spec;
1625
- const who = describeLayer(spec);
1626
- const kfs = s.keyframes ?? [];
1627
- const bags = [s.initial, ...kfs.flatMap((kf) => TIME_BAGS.map((b) => kf[b]))];
1628
- const timeInInitial = !!s.initial && s.initial.time !== void 0;
1629
- const timeInKeyframes = kfs.some((kf) => TIME_BAGS.some((b) => kf[b] && kf[b].time !== void 0));
1630
- const timed = timeInInitial || timeInKeyframes;
1631
- if (bags.some((bag) => bag && bag.speed !== void 0)) {
1632
- warn(`pixi-effects: ${who}: speed is a fixed setting, not an animatable property: write it on the layer (speed: 2); to change the speed over time, animate time (keyframes: [{ at: 0, from: { time: 0 }, to: { time: 4 }, duration: 2, ease: 'power2.in' }])`);
1633
- }
1634
- if (!REMAPPABLE.has(spec.type)) {
1635
- if (timed) warn(`pixi-effects: ${who}: "time" only works on video, audio and composition layers; put this layer in a composition and remap that (it is ignored here)`);
1636
- return;
1637
- }
1638
- if (s.reverse !== void 0) warn(`pixi-effects: ${who}: "reverse" is not a key: write speed: -1 to play backward`);
1639
- if (s.timeRemap !== void 0) warn(`pixi-effects: ${who}: "timeRemap" is not a key: animate time in keyframes (from / to / set), or write speed`);
1640
- if (s.time !== void 0) warn(`pixi-effects: ${who}: "time" belongs in initial or keyframes (initial: { time: 2 }), not on the layer`);
1641
- if (spec.type === "audio" && (s.sfx !== void 0 || s.music !== void 0) && (s.speed !== void 0 || timed)) {
1642
- warn(`pixi-effects: ${who}: speed and time do not apply to a synthesised sound (sfx, music); change an sfx's pitch with pitch (semitones), or put it in a composition and remap that`);
1643
- return;
1644
- }
1645
- if (s.speed !== void 0 && (typeof s.speed !== "number" || !Number.isFinite(s.speed) || s.speed === 0)) {
1646
- warn(`pixi-effects: ${who}: speed ${JSON.stringify(s.speed)} cannot be used: write a number other than 0 (negative plays backward); to hold a moment, key time to the same value twice`);
1647
- }
1648
- if (s.speed !== void 0 && timeInKeyframes) {
1649
- warn(`pixi-effects: ${who}: speed and keyframed time are both set; time wins and speed is ignored. Use one of them`);
1650
- }
1651
- if (timeInInitial && typeof s.initial.time !== "number") {
1652
- warn(`pixi-effects: ${who}: initial.time must be a number of seconds, got ${JSON.stringify(s.initial.time)}`);
1653
- }
1654
- kfs.forEach((kf, i) => {
1655
- for (const b of TIME_BAGS) {
1656
- const v = kf[b]?.time;
1657
- if (v !== void 0 && typeof v !== "number" && typeof v !== "string") warn(`pixi-effects: ${who}: keyframes[${i}].${b}.time must be a number of seconds, got ${JSON.stringify(v)}`);
1658
- }
1659
- });
1660
- }
1661
- function lintKeys(spec, warn = defaultWarn) {
1662
- const who = describeLayer(spec);
1663
- const valid = layerKeys(spec);
1664
- if (valid) {
1665
- for (const key of Object.keys(spec)) {
1666
- if (valid.includes(key) || spec[key] === void 0) continue;
1667
- if (REMAPPABLE.has(spec.type) && REMAP_NAMES.has(key)) continue;
1668
- const guess = chunkWTRKDIKH_cjs.suggestName(key, valid.filter((k) => k !== "type"));
1669
- const owners = kindsWithKey(key);
1670
- const belongs = owners.length ? ` (it belongs to ${owners.slice(0, 3).join(", ")})` : "";
1671
- const hint = guess ? ` \u2014 did you mean "${guess}"?${belongs}` : belongs;
1672
- warn(`pixi-effects: ${who}: "${key}" is not a ${kindName(spec)} key${hint}. Valid keys: ${valid.join(", ")}`);
1673
- }
1674
- }
1675
- lintRemap(spec, warn);
1676
- const said = /* @__PURE__ */ new Set();
1677
- const bags = [spec.initial, ...(spec.keyframes ?? []).flatMap((kf) => [kf.set, kf.to, kf.from])];
1678
- for (const bag of bags) {
1679
- for (const key of Object.keys(bag ?? {})) {
1680
- if (bag[key] === void 0) continue;
1681
- if (PROP_KEYS.has(key) || key.includes(".") || /^gradient/i.test(key) || said.has(key) || key === "speed") continue;
1682
- said.add(key);
1683
- const guess = chunkWTRKDIKH_cjs.suggestName(key, [...PROP_KEYS]);
1684
- warn(`pixi-effects: ${who}: "${key}" is not an animatable property${guess ? ` \u2014 did you mean "${guess}"?` : ""} (in initial, set, to or from). See the cheatsheet for the properties of this kind of layer`);
1685
- }
1686
- }
1687
- if (spec.type === "text" && spec.style && typeof spec.style === "object") {
1688
- for (const key of Object.keys(spec.style)) {
1689
- if (STYLE_KEYS.includes(key) || spec.style[key] === void 0) continue;
1690
- const guess = chunkWTRKDIKH_cjs.suggestName(key, STYLE_KEYS);
1691
- warn(`pixi-effects: ${who}: style.${key} is not a text style key${guess ? ` \u2014 did you mean "${guess}"?` : ""} (it is ignored). Keys: ${STYLE_KEYS.join(", ")}`);
1692
- }
1693
- }
1694
- }
1695
1662
  var BAGS = ["set", "to", "from"];
1696
1663
  function timeRemapOf(spec, prop = "time") {
1697
1664
  const hasInitial = !!spec.initial && "time" in spec.initial;
@@ -1804,7 +1771,7 @@ function clockTable(remap, prop, duration, at, scope, to) {
1804
1771
  }
1805
1772
 
1806
1773
  // src/space/math.ts
1807
- var DEG = Math.PI / 180;
1774
+ var DEG2 = Math.PI / 180;
1808
1775
  var DEFAULT_FOV = 40;
1809
1776
  var MIN_FOV = 1;
1810
1777
  var MAX_FOV = 179;
@@ -1814,7 +1781,7 @@ function clampFov(fov) {
1814
1781
  return Math.min(MAX_FOV, Math.max(MIN_FOV, fov));
1815
1782
  }
1816
1783
  function homeDistance(compHeight, fovDeg) {
1817
- return compHeight / 2 / Math.tan(clampFov(fovDeg) * DEG / 2);
1784
+ return compHeight / 2 / Math.tan(clampFov(fovDeg) * DEG2 / 2);
1818
1785
  }
1819
1786
  function homeCamera(compW, compH, fov = DEFAULT_FOV) {
1820
1787
  return {
@@ -1868,7 +1835,7 @@ function cameraBasis(cam, compW, compH) {
1868
1835
  fx,
1869
1836
  fy,
1870
1837
  fz,
1871
- focal: compH / 2 / Math.tan(clampFov(cam.fov) * DEG / 2),
1838
+ focal: compH / 2 / Math.tan(clampFov(cam.fov) * DEG2 / 2),
1872
1839
  halfW: compW / 2,
1873
1840
  halfH: compH / 2
1874
1841
  };
@@ -1968,10 +1935,14 @@ function focusProblems(camera, siblings) {
1968
1935
  for (const name of focusNames(camera, known)) {
1969
1936
  if (said.has(name)) continue;
1970
1937
  said.add(name);
1971
- const hit = siblings.find((s) => s.name === name);
1972
- if (!hit) out.push({ kind: "missing", name, hint: chunkWTRKDIKH_cjs.suggestName(name, threeD) });
1938
+ const same = siblings.filter((s) => s.name === name);
1939
+ const hit = same.find((s) => s.threeD) ?? same[0];
1940
+ if (!hit) out.push({ kind: "missing", name, hint: chunkTWZNOUM7_cjs.suggestName(name, threeD) });
1973
1941
  else if (!hit.threeD) out.push({ kind: "not-threeD", name });
1974
- else if (movesZ(hit)) out.push({ kind: "moving", name });
1942
+ else {
1943
+ if (same.length > 1) out.push({ kind: "duplicate", name, count: same.length });
1944
+ if (movesZ(hit)) out.push({ kind: "moving", name });
1945
+ }
1975
1946
  }
1976
1947
  return out;
1977
1948
  }
@@ -1981,8 +1952,12 @@ var CameraSequence = class extends Sequence {
1981
1952
  compH = 0;
1982
1953
  warnedFov = false;
1983
1954
  warnedLookAt = false;
1955
+ warnedAperture = false;
1984
1956
  /** True when the camera writes `focus` or `aperture` anywhere: depth of field is on. */
1985
1957
  dof = false;
1958
+ /** True when the camera writes any fog key anywhere: depth fog is on (nothing is made for a camera without fog). */
1959
+ fog = false;
1960
+ fogC = null;
1986
1961
  zOfName = null;
1987
1962
  layerNames = /* @__PURE__ */ new Set();
1988
1963
  async build() {
@@ -2004,10 +1979,25 @@ var CameraSequence = class extends Sequence {
2004
1979
  carrier.aperture = DEFAULT_APERTURE;
2005
1980
  carrier.offsetX = carrier.offsetY = carrier.offsetZ = 0;
2006
1981
  carrier.lookOffsetX = carrier.lookOffsetY = carrier.lookOffsetZ = 0;
1982
+ carrier.fogNear = home.z;
1983
+ carrier.fogFar = home.z * 3;
1984
+ carrier.fogColor = "#000000";
1985
+ carrier.fogAmount = 1;
2007
1986
  this.target = carrier;
2008
- const keys = collectPropKeys(this.spec);
1987
+ const keys = chunkECA2WNRX_cjs.collectPropKeys(this.spec);
2009
1988
  this.autoZ = !keys.has("z");
2010
1989
  this.dof = keys.has("focus") || keys.has("aperture");
1990
+ this.fog = keys.has("fogNear") || keys.has("fogFar") || keys.has("fogColor") || keys.has("fogAmount");
1991
+ }
1992
+ /** The aperture to use now: off unless depth of field is on and the value is a number of 0 or more (said once if it is not). */
1993
+ apertureNow(a) {
1994
+ if (!this.dof) return 0;
1995
+ if (!(a >= 0) && !this.warnedAperture) {
1996
+ this.warnedAperture = true;
1997
+ const who = this.spec.name ? ` "${this.spec.name}"` : "";
1998
+ console.warn(`pixi-effects: camera${who}: aperture ${a} is not a number of 0 or more; depth of field is off (it is the lens diameter in px: 30 is the default, 0 turns it off)`);
1999
+ }
2000
+ return a > 0 ? a : 0;
2011
2001
  }
2012
2002
  /** Called by the composition once its children exist: how a layer name in `focus` becomes the z of that layer. */
2013
2003
  resolveFocusNames(zOf, names = /* @__PURE__ */ new Set()) {
@@ -2042,9 +2032,23 @@ var CameraSequence = class extends Sequence {
2042
2032
  lookAtZ: c.lookAtZ + c.lookOffsetZ,
2043
2033
  fov,
2044
2034
  focus: Number.isFinite(c.focus) ? c.focus : 0,
2045
- aperture: this.dof && c.aperture > 0 ? c.aperture : 0
2035
+ aperture: this.apertureNow(c.aperture)
2046
2036
  };
2047
2037
  }
2038
+ /** The fog now (colour as 0..1 channels, distances, 0..1 amount), or null when the camera writes no fog key. */
2039
+ fogState() {
2040
+ if (!this.fog) return null;
2041
+ const c = this.target;
2042
+ const fc = this.fogC ??= new PIXI.Color();
2043
+ try {
2044
+ fc.setValue(c.fogColor);
2045
+ } catch {
2046
+ fc.setValue(0);
2047
+ }
2048
+ const [r, g, b] = fc.toArray();
2049
+ const amount = Number.isFinite(c.fogAmount) ? Math.min(1, Math.max(0, c.fogAmount)) : 1;
2050
+ return { r, g, b, near: c.fogNear, far: c.fogFar, amount };
2051
+ }
2048
2052
  /** Lifespan on the global timeline (valid after bindTimeline). */
2049
2053
  window() {
2050
2054
  const start = this.absoluteStart ?? this.at;
@@ -2052,6 +2056,160 @@ var CameraSequence = class extends Sequence {
2052
2056
  }
2053
2057
  };
2054
2058
 
2059
+ // src/space/lighting.ts
2060
+ var LIGHT_KINDS = ["ambient", "point", "spot", "parallel"];
2061
+ var FALLOFFS = ["none", "smooth", "inverseSquare"];
2062
+ var LIGHT_PROPS = ["x", "y", "z", "lookAtX", "lookAtY", "lookAtZ", "intensity", "color", "coneAngle", "coneFeather", "radius", "falloffDistance", "shadowDarkness", "shadowDiffusion"];
2063
+ var MAX_LIGHTS = 8;
2064
+ var MAX_CASTERS = 4;
2065
+ var SHADOW_TAPS = 16;
2066
+ var FALLOFF_ID = { none: 0, smooth: 1, inverseSquare: 2 };
2067
+ var KIND_ID = { point: 1, spot: 2, parallel: 3 };
2068
+ function smoothstep(e0, e1, x) {
2069
+ const t = Math.min(1, Math.max(0, (x - e0) / (e1 - e0)));
2070
+ return t * t * (3 - 2 * t);
2071
+ }
2072
+ var DEG3 = Math.PI / 180;
2073
+ function norm(v) {
2074
+ const l = Math.hypot(v.x, v.y, v.z) || 1;
2075
+ return { x: v.x / l, y: v.y / l, z: v.z / l };
2076
+ }
2077
+ var dot = (a, b) => a.x * b.x + a.y * b.y + a.z * b.z;
2078
+ var sub = (a, b) => ({ x: a.x - b.x, y: a.y - b.y, z: a.z - b.z });
2079
+ function coneCos(l) {
2080
+ const half = Math.min(179, Math.max(0, l.coneAngle)) * DEG3 / 2;
2081
+ const inner = half * (1 - Math.min(1, Math.max(0, l.coneFeather)));
2082
+ const cosOuter = Math.cos(half);
2083
+ const cosInner = Math.max(Math.cos(inner), cosOuter + 1e-4);
2084
+ return { cosOuter, cosInner };
2085
+ }
2086
+ function packLights(lights) {
2087
+ const pos = new Float32Array(4 * MAX_LIGHTS), dir = new Float32Array(4 * MAX_LIGHTS), col = new Float32Array(4 * MAX_LIGHTS), fall = new Float32Array(4 * MAX_LIGHTS), shadow = new Float32Array(4 * MAX_LIGHTS);
2088
+ const ambient = [0, 0, 0];
2089
+ let n = 0;
2090
+ for (const l of lights) {
2091
+ if (l.kind === "ambient") {
2092
+ ambient[0] += l.r * l.intensity;
2093
+ ambient[1] += l.g * l.intensity;
2094
+ ambient[2] += l.b * l.intensity;
2095
+ continue;
2096
+ }
2097
+ if (n >= MAX_LIGHTS) continue;
2098
+ const d = norm({ x: l.lookAtX - l.x, y: l.lookAtY - l.y, z: l.lookAtZ - l.z });
2099
+ const { cosOuter, cosInner } = coneCos(l);
2100
+ pos.set([l.x, l.y, l.z, KIND_ID[l.kind]], 4 * n);
2101
+ dir.set([d.x, d.y, d.z, cosOuter], 4 * n);
2102
+ col.set([l.r * l.intensity, l.g * l.intensity, l.b * l.intensity, cosInner], 4 * n);
2103
+ fall.set([FALLOFF_ID[l.falloff], l.radius, l.falloffDistance, l.castsShadows ? 1 : 0], 4 * n);
2104
+ shadow.set([l.castsShadows ? l.shadowDarkness : 0, l.shadowDiffusion, 0, 0], 4 * n);
2105
+ n++;
2106
+ }
2107
+ return { count: n, ambient, pos, dir, col, fall, shadow };
2108
+ }
2109
+ function shadeReference(p, n, cam, lights) {
2110
+ let N = norm(n);
2111
+ if (dot(N, sub(cam, p)) < 0) N = { x: -N.x, y: -N.y, z: -N.z };
2112
+ const out = [0, 0, 0];
2113
+ for (const l of lights) {
2114
+ if (l.kind === "ambient") {
2115
+ out[0] += l.r * l.intensity;
2116
+ out[1] += l.g * l.intensity;
2117
+ out[2] += l.b * l.intensity;
2118
+ continue;
2119
+ }
2120
+ const dirLA = norm({ x: l.lookAtX - l.x, y: l.lookAtY - l.y, z: l.lookAtZ - l.z });
2121
+ let L;
2122
+ let dist = 0;
2123
+ if (l.kind === "parallel") L = { x: -dirLA.x, y: -dirLA.y, z: -dirLA.z };
2124
+ else {
2125
+ const d = sub({ x: l.x, y: l.y, z: l.z }, p);
2126
+ dist = Math.hypot(d.x, d.y, d.z);
2127
+ L = { x: d.x / dist, y: d.y / dist, z: d.z / dist };
2128
+ }
2129
+ const ndl = Math.max(0, dot(N, L));
2130
+ let att = 1;
2131
+ if (l.kind !== "parallel") {
2132
+ if (l.falloff === "smooth") att = 1 - smoothstep(l.radius, l.radius + Math.max(l.falloffDistance, 1e-3), dist);
2133
+ else if (l.falloff === "inverseSquare") att = Math.min(1, l.radius * l.radius / Math.max(dist * dist, 1e-6));
2134
+ }
2135
+ let cone = 1;
2136
+ if (l.kind === "spot") {
2137
+ const { cosOuter, cosInner } = coneCos(l);
2138
+ cone = smoothstep(cosOuter, cosInner, -dot(L, dirLA));
2139
+ }
2140
+ const k = l.intensity * ndl * att * cone;
2141
+ out[0] += l.r * k;
2142
+ out[1] += l.g * k;
2143
+ out[2] += l.b * k;
2144
+ }
2145
+ return out;
2146
+ }
2147
+ function lightLevel(frame, cam, lights) {
2148
+ const mid = { x: frame.o.x + 0.5 * frame.u.x + 0.5 * frame.v.x, y: frame.o.y + 0.5 * frame.u.y + 0.5 * frame.v.y, z: frame.o.z + 0.5 * frame.u.z + 0.5 * frame.v.z };
2149
+ const n = { x: frame.u.y * frame.v.z - frame.u.z * frame.v.y, y: frame.u.z * frame.v.x - frame.u.x * frame.v.z, z: frame.u.x * frame.v.y - frame.u.y * frame.v.x };
2150
+ const m = shadeReference(mid, n, cam, lights);
2151
+ return 0.2126 * m[0] + 0.7152 * m[1] + 0.0722 * m[2];
2152
+ }
2153
+ var LightSequence = class extends Sequence {
2154
+ color = new PIXI.Color();
2155
+ async build() {
2156
+ const w = this.parent?.width ?? this.root.width;
2157
+ const h = this.parent?.height ?? this.root.height;
2158
+ if (this.duration === void 0) this.duration = this.parent?.duration ?? this.root.duration;
2159
+ const c = new PIXI.Container();
2160
+ c.x = w * 0.3;
2161
+ c.y = h * 0.2;
2162
+ c.z = homeDistance(h, 40) * 0.6;
2163
+ c.lookAtX = w / 2;
2164
+ c.lookAtY = h / 2;
2165
+ c.lookAtZ = 0;
2166
+ c.intensity = 1;
2167
+ c.color = "#ffffff";
2168
+ c.coneAngle = 90;
2169
+ c.coneFeather = 0.5;
2170
+ c.radius = 500;
2171
+ c.falloffDistance = 500;
2172
+ c.shadowDarkness = 1;
2173
+ c.shadowDiffusion = 0;
2174
+ this.target = c;
2175
+ }
2176
+ state() {
2177
+ const c = this.target;
2178
+ try {
2179
+ this.color.setValue(c.color);
2180
+ } catch {
2181
+ this.color.setValue(16777215);
2182
+ }
2183
+ const [r, g, b] = this.color.toArray();
2184
+ return {
2185
+ // a kind or falloff nobody knows is the default the warning promises (the shader must never see an unknown id)
2186
+ kind: LIGHT_KINDS.includes(this.spec.kind) ? this.spec.kind : "point",
2187
+ x: c.x,
2188
+ y: c.y,
2189
+ z: c.z,
2190
+ lookAtX: c.lookAtX,
2191
+ lookAtY: c.lookAtY,
2192
+ lookAtZ: c.lookAtZ,
2193
+ r,
2194
+ g,
2195
+ b,
2196
+ intensity: Number.isFinite(c.intensity) ? Math.max(0, c.intensity) : 1,
2197
+ coneAngle: c.coneAngle,
2198
+ coneFeather: c.coneFeather,
2199
+ falloff: FALLOFFS.includes(this.spec.falloff) ? this.spec.falloff : "none",
2200
+ radius: c.radius,
2201
+ falloffDistance: c.falloffDistance,
2202
+ castsShadows: !!this.spec.castsShadows,
2203
+ shadowDarkness: Math.min(1, Math.max(0, c.shadowDarkness)),
2204
+ shadowDiffusion: Math.max(0, c.shadowDiffusion)
2205
+ };
2206
+ }
2207
+ window() {
2208
+ const start = this.absoluteStart ?? this.at;
2209
+ return { start, end: start + (this.duration ?? 0) };
2210
+ }
2211
+ };
2212
+
2055
2213
  // src/core/revertibleSet.ts
2056
2214
  function revertibleSet(timeline, at, read, write, value) {
2057
2215
  let p = 0;
@@ -2411,7 +2569,7 @@ function validateGradientKeyframes(spec, who, warn = (m) => console.warn(m), kin
2411
2569
  const p = value;
2412
2570
  for (const k of Object.keys(p)) {
2413
2571
  if (PATCH_KEYS.includes(k)) continue;
2414
- const guess = chunkWTRKDIKH_cjs.suggestName(k, PATCH_KEYS.filter((x) => x !== "type"));
2572
+ const guess = chunkTWZNOUM7_cjs.suggestName(k, PATCH_KEYS.filter((x) => x !== "type"));
2415
2573
  say(`fillGradient.${k} is not a gradient property${guess ? ` \u2014 did you mean "${guess}"?` : ""} (valid: ${PATCH_KEYS.join(", ")}); it is ignored`);
2416
2574
  }
2417
2575
  if (p.type !== void 0 && start && p.type !== start.type) say("fillGradient.type cannot change over time (linear <-> radial); it is ignored");
@@ -2421,8 +2579,8 @@ function validateGradientKeyframes(spec, who, warn = (m) => console.warn(m), kin
2421
2579
  }
2422
2580
  } else if (/^fillGradient\./i.test(key) || /^gradient/i.test(key)) {
2423
2581
  const tail = key.replace(/^fillGradient\./i, "").replace(/^gradient/i, "");
2424
- const sub = tail ? tail[0].toLowerCase() + tail.slice(1) : "angle";
2425
- say(`"${key}" is not an animatable property: write fillGradient: { ${PATCH_KEYS.includes(sub) ? sub : "angle"} } (the whole gradient is one object) in the keyframe's to / from / set`);
2582
+ const sub2 = tail ? tail[0].toLowerCase() + tail.slice(1) : "angle";
2583
+ say(`"${key}" is not an animatable property: write fillGradient: { ${PATCH_KEYS.includes(sub2) ? sub2 : "angle"} } (the whole gradient is one object) in the keyframe's to / from / set`);
2426
2584
  }
2427
2585
  }
2428
2586
  }
@@ -2619,7 +2777,7 @@ var TextSequence = class extends Sequence {
2619
2777
  this.intrinsicWidth = text.width;
2620
2778
  this.intrinsicHeight = text.height;
2621
2779
  }
2622
- validateGradientKeyframes(this.spec, describeLayer(this.spec), void 0, "text");
2780
+ validateGradientKeyframes(this.spec, chunkECA2WNRX_cjs.describeLayer(this.spec), void 0, "text");
2623
2781
  const gradientSpec = this.spec.fillGradient ?? initialProps.fillGradient;
2624
2782
  if (gradientSpec) {
2625
2783
  this._grad = { grad: gradStateFrom(gradientSpec) };
@@ -2655,7 +2813,7 @@ var TextSequence = class extends Sequence {
2655
2813
  bindTextKeyframes(timeline, keyframes, this.duration, origin, () => this._template, (t) => {
2656
2814
  this._template = t;
2657
2815
  refresh();
2658
- }, describeLayer(this.spec));
2816
+ }, chunkECA2WNRX_cjs.describeLayer(this.spec));
2659
2817
  }
2660
2818
  };
2661
2819
  function runSuperWithStrippedSpec(inst, strippedSpec, timeline, offset) {
@@ -2800,16 +2958,16 @@ var AudioSequence = class extends Sequence {
2800
2958
  const playable = this._remap && this._remap.timeKfs.length > 0 ? Infinity : (data.duration ?? Infinity) / constant;
2801
2959
  if (!spec.loop && Number.isFinite(playable) && this.duration > playable + 0.05) {
2802
2960
  console.warn(
2803
- `pixi-effects: ${describeLayer(spec)}: audio asset "${spec.asset}" plays for ${playable.toFixed(1)}s (${data.duration.toFixed(1)}s at speed ${constant}) but the layer lasts ${this.duration.toFixed(1)}s, so it goes silent after ${playable.toFixed(1)}s. Add loop: true, or shorten the layer's duration.`
2961
+ `pixi-effects: ${chunkECA2WNRX_cjs.describeLayer(spec)}: audio asset "${spec.asset}" plays for ${playable.toFixed(1)}s (${data.duration.toFixed(1)}s at speed ${constant}) but the layer lasts ${this.duration.toFixed(1)}s, so it goes silent after ${playable.toFixed(1)}s. Add loop: true, or shorten the layer's duration.`
2804
2962
  );
2805
2963
  }
2806
2964
  }
2807
2965
  async _buildSfx(spec) {
2808
- const who = describeLayer(spec);
2966
+ const who = chunkECA2WNRX_cjs.describeLayer(spec);
2809
2967
  const raw = spec;
2810
2968
  if (raw.asset !== void 0) console.warn(`pixi-effects: ${who}: has both asset and sfx \u2014 the sfx plays; remove one`);
2811
2969
  if (raw.loop) console.warn(`pixi-effects: ${who}: loop has no effect on an sfx \u2014 to repeat it, add one audio layer per hit (a JS loop)`);
2812
- const { resolveSfx, renderSfx, sfxKey } = await import('./sfx-EX4PUBMV.cjs');
2970
+ const { resolveSfx, renderSfx, sfxKey } = await import('./sfx-2O6UQEUP.cjs');
2813
2971
  const sfx = resolveSfx(spec.sfx, spec.duration, who);
2814
2972
  if (!sfx) return;
2815
2973
  this.duration = sfx.length;
@@ -2824,11 +2982,11 @@ var AudioSequence = class extends Sequence {
2824
2982
  });
2825
2983
  }
2826
2984
  async _buildMusic(spec) {
2827
- const who = describeLayer(spec);
2985
+ const who = chunkECA2WNRX_cjs.describeLayer(spec);
2828
2986
  const raw = spec;
2829
2987
  if (raw.asset !== void 0) console.warn(`pixi-effects: ${who}: has both asset and music \u2014 the music plays; remove one`);
2830
2988
  if (raw.sfx !== void 0) console.warn(`pixi-effects: ${who}: has both sfx and music \u2014 the music plays; remove one`);
2831
- const { resolveMusic, renderMusic, musicLength, musicKey } = await import('./music-UAN7DXK4.cjs');
2989
+ const { resolveMusic, renderMusic, musicLength, musicKey } = await import('./music-KB7YZLHP.cjs');
2832
2990
  const music = resolveMusic(spec.music, who);
2833
2991
  if (!music) return;
2834
2992
  const natural = musicLength(music);
@@ -2858,7 +3016,7 @@ var AudioSequence = class extends Sequence {
2858
3016
  out.push({
2859
3017
  ...sourceMap ? { sourceMap } : {},
2860
3018
  ...this._audioBuffer ? { buffer: this._audioBuffer } : { synth: this._synth },
2861
- layer: describeLayer(this.spec),
3019
+ layer: chunkECA2WNRX_cjs.describeLayer(this.spec),
2862
3020
  source: this._source,
2863
3021
  loop: !this._synth && !!this.spec.loop,
2864
3022
  start: t0,
@@ -3078,7 +3236,7 @@ var VideoSequence = class extends Sequence {
3078
3236
  out.push({
3079
3237
  ...sourceMap ? { sourceMap } : {},
3080
3238
  buffer: this._audioBuffer,
3081
- layer: describeLayer(this.spec),
3239
+ layer: chunkECA2WNRX_cjs.describeLayer(this.spec),
3082
3240
  source: `video "${this.spec.asset}"`,
3083
3241
  loop: !!this.spec.loop,
3084
3242
  start: baseTime + this.at,
@@ -3307,7 +3465,7 @@ function morphAt(pairs, t) {
3307
3465
  }
3308
3466
 
3309
3467
  // src/sequences/Shape.ts
3310
- var STYLE_KEYS2 = ["fillColor", "fillAlpha", "strokeColor", "strokeAlpha", "strokeWidth"];
3468
+ var STYLE_KEYS = ["fillColor", "fillAlpha", "strokeColor", "strokeAlpha", "strokeWidth"];
3311
3469
  var COLOR_KEYS = /* @__PURE__ */ new Set(["fillColor", "strokeColor"]);
3312
3470
  var TRIM_KEYS = ["trimStart", "trimEnd"];
3313
3471
  var GEOMETRY_KEYS_BY_SHAPE = {
@@ -3333,7 +3491,7 @@ var ShapeSequence = class extends Sequence {
3333
3491
  // by `Container.onRender`.
3334
3492
  _drawGeometry = () => {
3335
3493
  };
3336
- _liveKeys = new Set(STYLE_KEYS2);
3494
+ _liveKeys = new Set(STYLE_KEYS);
3337
3495
  async build() {
3338
3496
  const graphics = new PIXI.Graphics({ label: this.spec.name });
3339
3497
  graphics.cullable = true;
@@ -3346,20 +3504,20 @@ var ShapeSequence = class extends Sequence {
3346
3504
  for (const k of geomKeys) this._liveKeys.add(k);
3347
3505
  seedGeometry(this._state, this.spec, scope);
3348
3506
  seedStyle(this._state, this.spec.initial ?? {}, scope);
3349
- seedStrokeStyle(this._state, this.spec, this.spec.initial ?? {}, describeLayer(this.spec));
3507
+ seedStrokeStyle(this._state, this.spec, this.spec.initial ?? {}, chunkECA2WNRX_cjs.describeLayer(this.spec));
3350
3508
  if (this.spec.shape === "arc") {
3351
3509
  this._state.startAngle ??= 0;
3352
3510
  this._state.endAngle ??= 360;
3353
3511
  const top = this.spec, ini = this.spec.initial ?? {};
3354
3512
  if ("trimStart" in top || "trimEnd" in top || "trimStart" in ini || "trimEnd" in ini) {
3355
- console.warn(`pixi-effects: ${describeLayer(this.spec)}: trimStart / trimEnd do not apply to an arc: animate its endAngle (and startAngle) instead`);
3513
+ console.warn(`pixi-effects: ${chunkECA2WNRX_cjs.describeLayer(this.spec)}: trimStart / trimEnd do not apply to an arc: animate its endAngle (and startAngle) instead`);
3356
3514
  }
3357
3515
  } else {
3358
3516
  this._state.trimStart ??= 0;
3359
3517
  this._state.trimEnd ??= 1;
3360
3518
  }
3361
3519
  const gradientSpec = this.spec.fillGradient ?? this.spec.initial?.fillGradient;
3362
- validateGradientKeyframes(this.spec, describeLayer(this.spec));
3520
+ validateGradientKeyframes(this.spec, chunkECA2WNRX_cjs.describeLayer(this.spec));
3363
3521
  if (gradientSpec) {
3364
3522
  if (hasGradientKeys(this.spec.keyframes)) {
3365
3523
  this._grad = { grad: gradStateFrom(gradientSpec) };
@@ -3401,9 +3559,9 @@ var ShapeSequence = class extends Sequence {
3401
3559
  }
3402
3560
  /** The prepared morph between `d` and `morphTo`, or null (and a warning when the spec asked for one that cannot work). */
3403
3561
  _setupMorph() {
3404
- const who = describeLayer(this.spec);
3562
+ const who = chunkECA2WNRX_cjs.describeLayer(this.spec);
3405
3563
  const top = this.spec;
3406
- const wanted = this.spec.shape === "path" && (this._state.morph !== void 0 || collectPropKeys(this.spec).has("morph"));
3564
+ const wanted = this.spec.shape === "path" && (this._state.morph !== void 0 || chunkECA2WNRX_cjs.collectPropKeys(this.spec).has("morph"));
3407
3565
  if (this.spec.shape !== "path") {
3408
3566
  if ("morphTo" in top) console.warn(`pixi-effects: ${who}: morphTo only works on a path shape (shape: 'path'); ignored`);
3409
3567
  return null;
@@ -3527,7 +3685,7 @@ function seedStrokeStyle(state, spec, initial, who) {
3527
3685
  }
3528
3686
  }
3529
3687
  function seedStyle(state, initial, scope) {
3530
- for (const k of STYLE_KEYS2) {
3688
+ for (const k of STYLE_KEYS) {
3531
3689
  const v = initial[k];
3532
3690
  if (v === void 0) continue;
3533
3691
  state[k] = COLOR_KEYS.has(k) ? v : numOrZero(v, scope);
@@ -3621,7 +3779,7 @@ function drawEllipseFromState(g, s) {
3621
3779
  const ay = s.anchorY ?? 0.5;
3622
3780
  g.ellipse((0.5 - ax) * 2 * rx, (0.5 - ay) * 2 * ry, rx, ry);
3623
3781
  }
3624
- var DEG2 = Math.PI / 180;
3782
+ var DEG4 = Math.PI / 180;
3625
3783
  function drawArcFromState(g, s) {
3626
3784
  const r = s.radius ?? 0;
3627
3785
  const ri = Math.max(0, Math.min(s.innerRadius ?? 0, r));
@@ -3636,7 +3794,7 @@ function drawArcFromState(g, s) {
3636
3794
  }
3637
3795
  endDeg = startDeg + Math.sign(endDeg - startDeg) * 359.999;
3638
3796
  }
3639
- const a0 = startDeg * DEG2, a1 = endDeg * DEG2;
3797
+ const a0 = startDeg * DEG4, a1 = endDeg * DEG4;
3640
3798
  const ccw = a1 < a0;
3641
3799
  if (filled) g.moveTo(r * Math.cos(a0), r * Math.sin(a0));
3642
3800
  g.arc(0, 0, r, a0, a1, ccw);
@@ -3818,11 +3976,396 @@ function numOrZero(v, scope) {
3818
3976
  return 0;
3819
3977
  }
3820
3978
 
3979
+ // src/core/glShared.ts
3980
+ var shared = null;
3981
+ var generation = 0;
3982
+ var refs = 0;
3983
+ var unavailable = false;
3984
+ function create() {
3985
+ if (typeof document === "undefined") return null;
3986
+ const canvas = document.createElement("canvas");
3987
+ const gl = canvas.getContext("webgl2", { alpha: true, premultipliedAlpha: true, preserveDrawingBuffer: true, antialias: false });
3988
+ if (!gl) return null;
3989
+ const made = { gl, canvas, generation: ++generation };
3990
+ canvas.addEventListener("webglcontextlost", (e) => {
3991
+ e.preventDefault();
3992
+ if (shared === made) shared = null;
3993
+ });
3994
+ return made;
3995
+ }
3996
+ function currentGl() {
3997
+ if (shared) return shared;
3998
+ if (unavailable) return null;
3999
+ shared = create();
4000
+ if (!shared) unavailable = true;
4001
+ return shared;
4002
+ }
4003
+ function acquireGl() {
4004
+ refs++;
4005
+ return currentGl();
4006
+ }
4007
+ function releaseGl() {
4008
+ refs = Math.max(0, refs - 1);
4009
+ if (refs === 0 && shared) {
4010
+ const lose = shared.gl.getExtension?.("WEBGL_lose_context");
4011
+ try {
4012
+ lose?.loseContext();
4013
+ } catch {
4014
+ }
4015
+ shared = null;
4016
+ }
4017
+ }
4018
+
4019
+ // src/core/shaderChecks.ts
4020
+ var SHADER_BUILTINS = ["iResolution", "iTime", "iFrame"];
4021
+ var SHADER_MISSING = ["iMouse", "iChannel0", "iChannel1", "iChannel2", "iChannel3", "iDate", "iTimeDelta", "iSampleRate"];
4022
+ var IDENT = /^[A-Za-z_][A-Za-z0-9_]*$/;
4023
+ var HEX = /^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/;
4024
+ var RESERVED = new Set(`attribute const uniform varying break continue do for while if else in out inout float int void bool true false discard return
4025
+ mat2 mat3 mat4 mat2x2 mat2x3 mat2x4 mat3x2 mat3x3 mat3x4 mat4x2 mat4x3 mat4x4 vec2 vec3 vec4 ivec2 ivec3 ivec4 bvec2 bvec3 bvec4 uvec2 uvec3 uvec4 uint
4026
+ sampler2D sampler3D samplerCube sampler2DShadow samplerCubeShadow sampler2DArray sampler2DArrayShadow isampler2D isampler3D isamplerCube isampler2DArray
4027
+ usampler2D usampler3D usamplerCube usampler2DArray struct layout centroid flat smooth precision invariant highp mediump lowp
4028
+ sample patch subroutine common partition active asm class union enum typedef template this resource goto inline noinline public static extern external
4029
+ interface long short double half fixed unsigned superp input output hvec2 hvec3 hvec4 fvec2 fvec3 fvec4 dvec2 dvec3 dvec4 filter sizeof cast namespace using`.split(/\s+/));
4030
+ var isIdent = (name) => IDENT.test(name) && !name.startsWith("gl_") && !name.includes("__") && !RESERVED.has(name) && !SHADER_BUILTINS.includes(name);
4031
+ function uniformType(v) {
4032
+ if (typeof v === "number") return Number.isFinite(v) ? "float" : null;
4033
+ if (typeof v === "string") return HEX.test(v) ? "vec3" : null;
4034
+ if (Array.isArray(v) && v.length >= 2 && v.length <= 4 && v.every((n) => typeof n === "number" && Number.isFinite(n))) return `vec${v.length}`;
4035
+ return null;
4036
+ }
4037
+ function uniformFloats(v) {
4038
+ if (typeof v === "number") return [v];
4039
+ if (typeof v === "string") {
4040
+ const h = v.length === 4 ? v.slice(1).replace(/./g, (c) => c + c) : v.slice(1);
4041
+ return [0, 2, 4].map((i) => parseInt(h.slice(i, i + 2), 16) / 255);
4042
+ }
4043
+ return v.slice();
4044
+ }
4045
+ function uniformDecls(uniforms) {
4046
+ let out = "";
4047
+ for (const [name, v] of Object.entries(uniforms ?? {})) {
4048
+ const type = uniformType(v);
4049
+ if (type && isIdent(name)) out += `uniform ${type} ${name};
4050
+ `;
4051
+ }
4052
+ return out;
4053
+ }
4054
+ var HEAD = `#version 300 es
4055
+ #line 100001
4056
+ precision highp float;
4057
+ precision highp int;
4058
+ uniform vec3 iResolution;
4059
+ uniform float iTime;
4060
+ uniform int iFrame;
4061
+ out vec4 pe_out;
4062
+ `;
4063
+ var FOOT = (transparent) => `
4064
+ #line 200001
4065
+ void main() { vec4 c = vec4(0.0, 0.0, 0.0, 1.0); mainImage(c, gl_FragCoord.xy); ${transparent ? "pe_out = vec4(c.rgb * c.a, c.a);" : "pe_out = vec4(c.rgb, 1.0);"} }
4066
+ `;
4067
+ function wrapFragment(user, uniforms, transparent) {
4068
+ const prefix = HEAD + uniformDecls(uniforms) + "#line 1\n";
4069
+ return { source: prefix + user + FOOT(transparent), userLine: prefix.split("\n").length };
4070
+ }
4071
+ function glslErrors(log) {
4072
+ const out = [];
4073
+ for (const raw of (log ?? "").split("\n")) {
4074
+ const line = raw.trim();
4075
+ if (!line) continue;
4076
+ const angle = /^ERROR:\s*\d+:(\d+):\s*(.*)$/.exec(line);
4077
+ const mesa = /^\d+:(\d+)\(\d+\):\s*(?:error|warning):\s*(.*)$/.exec(line);
4078
+ const hit = angle ?? mesa;
4079
+ if (!hit) {
4080
+ out.push(line);
4081
+ continue;
4082
+ }
4083
+ const n = Number(hit[1]);
4084
+ if (n >= 200001) out.push(`in the main() made for you, which calls mainImage: ${hit[2]} (write void mainImage(out vec4 fragColor, in vec2 fragCoord))`);
4085
+ else if (n >= 100001) out.push(`in the declarations made from your uniforms: ${hit[2]} (a uniform name GLSL does not allow, such as a reserved word?)`);
4086
+ else out.push(`line ${n}: ${hit[2]}`);
4087
+ }
4088
+ return out;
4089
+ }
4090
+ var stripComments = (code) => code.replace(/\/\*[\s\S]*?\*\//g, " ").replace(/\/\/.*$/gm, " ");
4091
+ function shaderProblems(spec) {
4092
+ const out = [];
4093
+ const raw = spec;
4094
+ if (typeof raw.fragment !== "string" || raw.fragment.trim() === "") {
4095
+ out.push("fragment is the GLSL of the shader: write { type: 'shader', fragment: 'void mainImage(out vec4 fragColor, in vec2 fragCoord) { fragColor = vec4(fragCoord / iResolution.xy, 0.0, 1.0); }' }");
4096
+ } else {
4097
+ const code = stripComments(raw.fragment);
4098
+ if (!/\bvoid\s+mainImage\s*\(/.test(code)) {
4099
+ out.push("there is no mainImage: write void mainImage(out vec4 fragColor, in vec2 fragCoord) { \u2026 } (Shadertoy style; the layer calls it for every pixel)" + (/\bvoid\s+main\s*\(/.test(code) ? " and not main()" : ""));
4100
+ } else {
4101
+ if (/\bvoid\s+main\s*\(/.test(code)) out.push("main() is written for you (it calls your mainImage): remove your main()");
4102
+ if (!/\bvoid\s+mainImage\s*\(\s*(?:out|inout)\s+(?:(?:highp|mediump|lowp)\s+)?vec4\s+\w+\s*,\s*(?:in\s+)?(?:(?:highp|mediump|lowp)\s+)?vec2\s+\w+\s*\)/.test(code)) {
4103
+ out.push("the signature of mainImage must be void mainImage(out vec4 fragColor, in vec2 fragCoord): the colour parameter is out (without out the layer draws black and nothing says why) and the position is a vec2");
4104
+ }
4105
+ }
4106
+ if (/^\s*#version\b/m.test(code)) out.push("#version is added for you (GLSL ES 3.00): remove it");
4107
+ if (/\bgl_FragColor\b/.test(code)) out.push("gl_FragColor does not exist here: write the colour into the fragColor parameter of mainImage");
4108
+ if (/\btexture2D\s*\(|\btextureCube\s*\(/.test(code)) out.push("texture2D is GLSL ES 1.00: this is GLSL ES 3.00, write texture(\u2026) (and note that this version has no textures to read)");
4109
+ if (/\b(?:varying|attribute)\b/.test(code)) out.push("varying and attribute are not used in a fragment-only shader: remove them");
4110
+ for (const b of SHADER_BUILTINS) {
4111
+ if (new RegExp(`\\buniform\\s+\\w+\\s+${b}\\b`).test(code)) out.push(`${b} is declared for you: remove your uniform ${b}`);
4112
+ }
4113
+ const missing = SHADER_MISSING.filter((n) => new RegExp(`\\b${n}\\b`).test(code));
4114
+ if (missing.length) out.push(`${missing.join(", ")} ${missing.length > 1 ? "are" : "is"} not provided in this version (the shader has iResolution, iTime, iFrame and your uniforms); the shader will not compile`);
4115
+ if (/\bwhile\s*\(/.test(code)) out.push("a while loop may never end and a GPU cannot be stopped: use a for loop with a constant bound");
4116
+ const consts = new Set([...code.matchAll(/\bconst\s+(?:int|float|uint)\s+(\w+)/g)].map((m) => m[1]).concat([...code.matchAll(/#define\s+(\w+)/g)].map((m) => m[1])));
4117
+ const constant = (expr) => {
4118
+ const rest = expr.replace(/\d+\.?\d*(?:[eE][-+]?\d+)?[uUfF]?|\.\d+(?:[eE][-+]?\d+)?[fF]?|[A-Za-z_]\w*/g, (t) => /^[A-Za-z_]/.test(t) && !consts.has(t) ? "?" : "");
4119
+ return /^[\s+\-*/%()]*$/.test(rest);
4120
+ };
4121
+ for (const m of code.matchAll(/\bfor\s*\(\s*(?:int|float|uint)\s+\w+\s*=\s*[^;]+;\s*\w+\s*(?:<=|>=|<|>|!=)\s*([^;]+?)\s*;/g)) {
4122
+ const bound = m[1];
4123
+ const ands = bound.split("&&"), ors = bound.split("||");
4124
+ const ok = ors.length > 1 ? ors.every((part) => constant(part.split("&&")[0].replace(/<.*$/, ""))) : ands.length > 1 ? ands.some(constant) || constant(ands[0]) : constant(bound);
4125
+ if (!ok) {
4126
+ out.push(`a for loop with the bound "${bound}" may run for ever: use a constant bound (a number or a const) and break out early`);
4127
+ break;
4128
+ }
4129
+ }
4130
+ }
4131
+ if (raw.uniforms !== void 0) {
4132
+ if (raw.uniforms === null || typeof raw.uniforms !== "object" || Array.isArray(raw.uniforms)) {
4133
+ out.push("uniforms is an object of names to values: { speed: 1, tint: '#ff8040', pos: [0.5, 0.5] }");
4134
+ } else {
4135
+ for (const [name, v] of Object.entries(raw.uniforms)) {
4136
+ if (!isIdent(name)) out.push(`uniform "${name}" is not a name GLSL can use (letters, digits and _, not starting with a digit; not a GLSL keyword or reserved word such as sample, smooth, filter, input; not iResolution / iTime / iFrame)`);
4137
+ else if (uniformType(v) === null) out.push(`uniform "${name}": ${JSON.stringify(v)} is not a number, 2 to 4 numbers or a '#rrggbb' colour`);
4138
+ }
4139
+ }
4140
+ }
4141
+ if (raw.resolution !== void 0 && !(typeof raw.resolution === "number" && raw.resolution > 0 && raw.resolution <= 2)) {
4142
+ out.push(`resolution ${JSON.stringify(raw.resolution)} is not a number above 0 and at most 2 (0.5 draws a quarter of the pixels and scales up); 1 is used`);
4143
+ }
4144
+ if (raw.transparent !== void 0 && typeof raw.transparent !== "boolean") out.push("transparent is true or false (true uses the shader's alpha; the default draws opaque)");
4145
+ return out;
4146
+ }
4147
+
4148
+ // src/sequences/Shader.ts
4149
+ var VERT = `#version 300 es
4150
+ void main() { vec2 p = vec2(float((gl_VertexID << 1) & 2), float(gl_VertexID & 2)); gl_Position = vec4(p * 2.0 - 1.0, 0.0, 1.0); }`;
4151
+ var ShaderSequence = class extends Sequence {
4152
+ prog = null;
4153
+ progGeneration = -1;
4154
+ w = 1;
4155
+ h = 1;
4156
+ c2d = null;
4157
+ fps = 30;
4158
+ failed = false;
4159
+ warnedNoGl = false;
4160
+ acquired = false;
4161
+ warnedPaths = /* @__PURE__ */ new Set();
4162
+ /** The current value of every uniform: what keyframes move (`uniforms.speed`, `uniforms.tint.0`). */
4163
+ carrier = {};
4164
+ /** How many components each vector uniform has (a scalar is not listed). */
4165
+ dims = {};
4166
+ get shaderSpec() {
4167
+ return this.spec;
4168
+ }
4169
+ pathRouters() {
4170
+ return { uniforms: (path) => this.resolveUniform(path) };
4171
+ }
4172
+ async build() {
4173
+ const spec = this.shaderSpec;
4174
+ const who = chunkECA2WNRX_cjs.describeLayer(spec);
4175
+ for (const m of shaderProblems(spec)) console.warn(`pixi-effects: ${who}: ${m}`);
4176
+ if (this.duration === void 0) this.duration = this.parent?.duration ?? this.root.duration;
4177
+ const scope = buildScope(this, this.parent, this.root);
4178
+ const width = resolveDim(spec.width, scope) ?? this.parent?.width ?? this.root.width;
4179
+ const height = resolveDim(spec.height, scope) ?? this.parent?.height ?? this.root.height;
4180
+ const res = typeof spec.resolution === "number" && spec.resolution > 0 && spec.resolution <= 2 ? spec.resolution : 1;
4181
+ this.w = Math.max(1, Math.round(width * res));
4182
+ this.h = Math.max(1, Math.round(height * res));
4183
+ this.fps = this.root.frameRate ?? 30;
4184
+ for (const [name, v] of Object.entries(spec.uniforms ?? {})) {
4185
+ if (uniformType(v) === null) continue;
4186
+ if (typeof v === "number") this.carrier[name] = v;
4187
+ else {
4188
+ const f = uniformFloats(v);
4189
+ this.carrier[name] = Object.fromEntries(f.map((x, i) => [String(i), x]));
4190
+ this.dims[name] = f.length;
4191
+ }
4192
+ }
4193
+ this.c2d = document.createElement("canvas");
4194
+ this.c2d.width = this.w;
4195
+ this.c2d.height = this.h;
4196
+ const sprite = new PIXI.Sprite({ texture: PIXI.Texture.from(this.c2d), label: spec.name });
4197
+ sprite.width = width;
4198
+ sprite.height = height;
4199
+ this.target = sprite;
4200
+ this.intrinsicWidth = width;
4201
+ this.intrinsicHeight = height;
4202
+ this.buildFilters();
4203
+ if (typeof spec.fragment === "string" && spec.fragment.trim() !== "") this.acquire();
4204
+ else this.failed = true;
4205
+ this.drawAt(0);
4206
+ }
4207
+ async awaitFrameAt(local) {
4208
+ this.drawAt(Math.max(0, Math.min(local, this.duration ?? local)));
4209
+ }
4210
+ /** Resolve `uniforms.speed` / `uniforms.tint.0` for the keyframe pipeline; a name or index nobody has is said once and dropped. */
4211
+ resolveUniform(path) {
4212
+ const segs = path.split(".");
4213
+ const name = segs[0];
4214
+ const slot = this.carrier[name];
4215
+ const warn = (why) => {
4216
+ if (this.warnedPaths.has(path)) return;
4217
+ this.warnedPaths.add(path);
4218
+ console.warn(`pixi-effects: ${chunkECA2WNRX_cjs.describeLayer(this.spec)}: keyframe path uniforms.${path} ${why}; skipped`);
4219
+ };
4220
+ if (slot === void 0) {
4221
+ const guess = chunkTWZNOUM7_cjs.suggestName(name, Object.keys(this.carrier));
4222
+ warn(`names no uniform "${name}"${guess ? `; did you mean "${guess}"?` : ""} (declare it in uniforms with a starting value)`);
4223
+ return null;
4224
+ }
4225
+ if (typeof slot === "number") {
4226
+ if (segs.length !== 1) {
4227
+ warn(`has more than a name, but "${name}" is a single number`);
4228
+ return null;
4229
+ }
4230
+ return { target: this.carrier, prop: name };
4231
+ }
4232
+ const n = this.dims[name];
4233
+ const index = segs.length === 2 ? Number(segs[1]) : NaN;
4234
+ if (!Number.isInteger(index) || index < 0 || index >= n) {
4235
+ warn(`must name a component of "${name}" (0 to ${n - 1}): 'uniforms.${name}.0'`);
4236
+ return null;
4237
+ }
4238
+ return { target: slot, prop: String(index) };
4239
+ }
4240
+ acquire() {
4241
+ const sh = acquireGl();
4242
+ this.acquired = true;
4243
+ if (!sh) {
4244
+ this.noGl();
4245
+ return;
4246
+ }
4247
+ this.compile();
4248
+ }
4249
+ noGl() {
4250
+ this.failed = true;
4251
+ if (!this.warnedNoGl) {
4252
+ this.warnedNoGl = true;
4253
+ console.warn(`pixi-effects: ${chunkECA2WNRX_cjs.describeLayer(this.spec)}: this browser has no WebGL2, so the shader cannot run; the layer is drawn as a checkerboard`);
4254
+ }
4255
+ }
4256
+ compile() {
4257
+ const sh = currentGl();
4258
+ if (!sh) {
4259
+ this.noGl();
4260
+ return;
4261
+ }
4262
+ const { gl } = sh;
4263
+ const spec = this.shaderSpec;
4264
+ const make = (type, src) => {
4265
+ const s = gl.createShader(type);
4266
+ gl.shaderSource(s, src);
4267
+ gl.compileShader(s);
4268
+ return s;
4269
+ };
4270
+ const vs = make(gl.VERTEX_SHADER, VERT);
4271
+ const fs = make(gl.FRAGMENT_SHADER, wrapFragment(spec.fragment, spec.uniforms ?? {}, !!spec.transparent).source);
4272
+ const p = gl.createProgram();
4273
+ gl.attachShader(p, vs);
4274
+ gl.attachShader(p, fs);
4275
+ gl.linkProgram(p);
4276
+ const ok = gl.getProgramParameter(p, gl.LINK_STATUS);
4277
+ const log = ok ? "" : gl.getShaderInfoLog(fs) || gl.getProgramInfoLog(p) || "";
4278
+ gl.deleteShader(vs);
4279
+ gl.deleteShader(fs);
4280
+ if (!ok) {
4281
+ gl.deleteProgram(p);
4282
+ this.failed = true;
4283
+ this.prog = null;
4284
+ console.warn(`pixi-effects: ${chunkECA2WNRX_cjs.describeLayer(this.spec)}: the fragment shader did not compile (the line numbers are the lines of your code):
4285
+ ${glslErrors(log).join("\n")}
4286
+ The layer is drawn as a checkerboard until it is fixed.`);
4287
+ return;
4288
+ }
4289
+ this.prog = p;
4290
+ this.progGeneration = sh.generation;
4291
+ }
4292
+ drawAt(local) {
4293
+ const c = this.c2d;
4294
+ if (!c) return;
4295
+ const ctx2 = c.getContext("2d");
4296
+ if (!ctx2) return;
4297
+ let sh = this.failed ? null : currentGl();
4298
+ if (sh && this.progGeneration !== sh.generation) {
4299
+ this.compile();
4300
+ sh = this.failed ? null : currentGl();
4301
+ }
4302
+ if (!sh || !this.prog) {
4303
+ const s = 32;
4304
+ for (let y = 0; y < c.height; y += s) for (let x = 0; x < c.width; x += s) {
4305
+ ctx2.fillStyle = x / s + y / s & 1 ? "#ff00ff" : "#220022";
4306
+ ctx2.fillRect(x, y, s, s);
4307
+ }
4308
+ } else {
4309
+ const { gl, canvas } = sh;
4310
+ if (canvas.width !== this.w || canvas.height !== this.h) {
4311
+ canvas.width = this.w;
4312
+ canvas.height = this.h;
4313
+ }
4314
+ gl.viewport(0, 0, this.w, this.h);
4315
+ gl.useProgram(this.prog);
4316
+ gl.uniform3f(gl.getUniformLocation(this.prog, "iResolution"), this.w, this.h, 1);
4317
+ gl.uniform1f(gl.getUniformLocation(this.prog, "iTime"), local);
4318
+ gl.uniform1i(gl.getUniformLocation(this.prog, "iFrame"), Math.round(local * this.fps));
4319
+ for (const [name, v] of Object.entries(this.carrier)) {
4320
+ const loc = gl.getUniformLocation(this.prog, name);
4321
+ if (typeof v === "number") {
4322
+ gl.uniform1f(loc, v);
4323
+ continue;
4324
+ }
4325
+ const n = this.dims[name];
4326
+ const comps = Array.from({ length: n }, (_, i) => v[String(i)] ?? 0);
4327
+ if (n === 2) gl.uniform2fv(loc, comps);
4328
+ else if (n === 3) gl.uniform3fv(loc, comps);
4329
+ else gl.uniform4fv(loc, comps);
4330
+ }
4331
+ gl.clearColor(0, 0, 0, 0);
4332
+ gl.clear(gl.COLOR_BUFFER_BIT);
4333
+ gl.drawArrays(gl.TRIANGLES, 0, 3);
4334
+ ctx2.clearRect(0, 0, c.width, c.height);
4335
+ ctx2.drawImage(canvas, 0, 0);
4336
+ }
4337
+ this.target?.texture.source.update();
4338
+ }
4339
+ destroy() {
4340
+ const texture = this.target?.texture;
4341
+ if (this.prog) {
4342
+ const sh = currentGl();
4343
+ if (sh && this.progGeneration === sh.generation) sh.gl.deleteProgram(this.prog);
4344
+ this.prog = null;
4345
+ }
4346
+ if (this.acquired) {
4347
+ this.acquired = false;
4348
+ releaseGl();
4349
+ }
4350
+ if (this.c2d) {
4351
+ this.c2d.width = this.c2d.height = 1;
4352
+ this.c2d = null;
4353
+ }
4354
+ super.destroy();
4355
+ texture?.destroy(true);
4356
+ }
4357
+ };
4358
+ function resolveDim(v, scope) {
4359
+ if (v === void 0) return void 0;
4360
+ if (typeof v === "number") return v;
4361
+ return evaluateExpr(v, scope);
4362
+ }
4363
+
3821
4364
  // src/core/Composition.ts
3822
4365
  var _CompositionSequence = null;
3823
4366
  async function getCompositionSequence() {
3824
4367
  if (!_CompositionSequence) {
3825
- _CompositionSequence = (await import('./Composition-2UFPSNVN.cjs')).CompositionSequence;
4368
+ _CompositionSequence = (await import('./Composition-2GJSCHPP.cjs')).CompositionSequence;
3826
4369
  }
3827
4370
  return _CompositionSequence;
3828
4371
  }
@@ -3833,6 +4376,8 @@ var staticTypes = {
3833
4376
  video: VideoSequence,
3834
4377
  shape: ShapeSequence,
3835
4378
  camera: CameraSequence,
4379
+ light: LightSequence,
4380
+ shader: ShaderSequence,
3836
4381
  null: NullSequence
3837
4382
  };
3838
4383
  var registry2 = {};
@@ -3862,12 +4407,19 @@ async function buildSequenceTree(specs, parent, root) {
3862
4407
 
3863
4408
  exports.CameraSequence = CameraSequence;
3864
4409
  exports.DEFAULT_FOV = DEFAULT_FOV;
3865
- exports.DEG = DEG;
4410
+ exports.DEG = DEG2;
4411
+ exports.FALLOFFS = FALLOFFS;
4412
+ exports.LIGHT_KINDS = LIGHT_KINDS;
4413
+ exports.LIGHT_PROPS = LIGHT_PROPS;
4414
+ exports.LightSequence = LightSequence;
3866
4415
  exports.MANY_BLURRED = MANY_BLURRED;
3867
4416
  exports.MAX_BLUR = MAX_BLUR;
4417
+ exports.MAX_CASTERS = MAX_CASTERS;
4418
+ exports.MAX_LIGHTS = MAX_LIGHTS;
3868
4419
  exports.MIN_BLUR = MIN_BLUR;
3869
4420
  exports.NEAR = NEAR;
3870
4421
  exports.NullSequence = NullSequence;
4422
+ exports.SHADOW_TAPS = SHADOW_TAPS;
3871
4423
  exports.Sequence = Sequence;
3872
4424
  exports.bindClock = bindClock;
3873
4425
  exports.blurRadius = blurRadius;
@@ -3876,9 +4428,7 @@ exports.buildSequenceTree = buildSequenceTree;
3876
4428
  exports.cameraBasis = cameraBasis;
3877
4429
  exports.checkEase = checkEase;
3878
4430
  exports.clockTable = clockTable;
3879
- exports.collectPropKeys = collectPropKeys;
3880
4431
  exports.contentLength = contentLength;
3881
- exports.describeLayer = describeLayer;
3882
4432
  exports.ensureFilterLibrary = ensureFilterLibrary;
3883
4433
  exports.evaluateExpr = evaluateExpr;
3884
4434
  exports.flattenSvgPath = flattenSvgPath;
@@ -3886,10 +4436,10 @@ exports.focusProblems = focusProblems;
3886
4436
  exports.homeCamera = homeCamera;
3887
4437
  exports.homeDistance = homeDistance;
3888
4438
  exports.layerInitialZ = layerInitialZ;
3889
- exports.lintKeys = lintKeys;
3890
- exports.lintText = lintText;
3891
- exports.lintTiming = lintTiming;
4439
+ exports.layerToWorld = layerToWorld;
4440
+ exports.lightLevel = lightLevel;
3892
4441
  exports.noise = noise;
4442
+ exports.packLights = packLights;
3893
4443
  exports.projectLayer = projectLayer;
3894
4444
  exports.projectPoint = projectPoint;
3895
4445
  exports.rand = rand;
@@ -3897,7 +4447,6 @@ exports.random = random;
3897
4447
  exports.registerSequenceType = registerSequenceType;
3898
4448
  exports.remapOf = remapOf;
3899
4449
  exports.resolveAt = resolveAt;
3900
- exports.summarizeWarnings = summarizeWarnings;
3901
4450
  exports.timeRemapOf = timeRemapOf;
3902
- //# sourceMappingURL=chunk-BPW42X7C.cjs.map
3903
- //# sourceMappingURL=chunk-BPW42X7C.cjs.map
4451
+ //# sourceMappingURL=chunk-DP37TTMO.cjs.map
4452
+ //# sourceMappingURL=chunk-DP37TTMO.cjs.map