pixi-effects 0.20.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.
Files changed (45) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/README.md +6 -6
  3. package/ai/SKILL.md +2 -2
  4. package/ai/chat-template.html +3 -3
  5. package/ai/reference/cheatsheet.md +6 -6
  6. package/ai/reference/pitfalls.md +3 -0
  7. package/ai/reference/recipes.md +25 -0
  8. package/ai/template.html +5 -5
  9. package/ai/tools/check.mjs +1 -1
  10. package/dist/Composition-2UFPSNVN.cjs +14 -0
  11. package/dist/{Composition-LL2XXU5N.cjs.map → Composition-2UFPSNVN.cjs.map} +1 -1
  12. package/dist/Composition-BVI236ZR.js +5 -0
  13. package/dist/{Composition-6PA4C4TV.js.map → Composition-BVI236ZR.js.map} +1 -1
  14. package/dist/Controller.d.cts +1 -1
  15. package/dist/Controller.d.ts +1 -1
  16. package/dist/{Movie-CBxGH5ms.d.ts → Movie-CgYwa5QG.d.ts} +2 -0
  17. package/dist/{Movie-CzzJw8A-.d.cts → Movie-mtX9AkQ-.d.cts} +2 -0
  18. package/dist/Presenter.d.cts +1 -1
  19. package/dist/Presenter.d.ts +1 -1
  20. package/dist/{chunk-FFYA3UBU.cjs → chunk-6JJC37ZD.cjs} +216 -38
  21. package/dist/chunk-6JJC37ZD.cjs.map +1 -0
  22. package/dist/{chunk-NO26HWR7.cjs → chunk-BPW42X7C.cjs} +94 -5
  23. package/dist/chunk-BPW42X7C.cjs.map +1 -0
  24. package/dist/{chunk-DQHXVNOI.js → chunk-DDIXIWXK.js} +88 -6
  25. package/dist/chunk-DDIXIWXK.js.map +1 -0
  26. package/dist/{chunk-TSPMKV2F.js → chunk-NGYGFGDS.js} +187 -9
  27. package/dist/chunk-NGYGFGDS.js.map +1 -0
  28. package/dist/index.cjs +30 -29
  29. package/dist/index.cjs.map +1 -1
  30. package/dist/index.d.cts +1 -1
  31. package/dist/index.d.ts +1 -1
  32. package/dist/index.js +5 -4
  33. package/dist/index.js.map +1 -1
  34. package/dist/loader.css +1 -1
  35. package/dist/three.cjs +5 -5
  36. package/dist/three.js +1 -1
  37. package/docs/dsl.md +40 -2
  38. package/llms-full.txt +76 -10
  39. package/package.json +1 -1
  40. package/dist/Composition-6PA4C4TV.js +0 -5
  41. package/dist/Composition-LL2XXU5N.cjs +0 -14
  42. package/dist/chunk-DQHXVNOI.js.map +0 -1
  43. package/dist/chunk-FFYA3UBU.cjs.map +0 -1
  44. package/dist/chunk-NO26HWR7.cjs.map +0 -1
  45. package/dist/chunk-TSPMKV2F.js.map +0 -1
@@ -1544,6 +1544,8 @@ var PROP_KEYS = /* @__PURE__ */ new Set([
1544
1544
  "lookAtY",
1545
1545
  "lookAtZ",
1546
1546
  "fov",
1547
+ "focus",
1548
+ "aperture",
1547
1549
  "offsetX",
1548
1550
  "offsetY",
1549
1551
  "offsetZ",
@@ -1912,12 +1914,77 @@ function projectLayer(t, frame, b) {
1912
1914
  const origin = projectPoint(b, { x: t.x, y: t.y, z: t.z });
1913
1915
  return { corners, depth: origin.depth, visible };
1914
1916
  }
1917
+
1918
+ // src/space/focus.ts
1919
+ var DEFAULT_APERTURE = 30;
1920
+ var MIN_BLUR = 0.05;
1921
+ var MAX_BLUR = 32;
1922
+ var MANY_BLURRED = 20;
1923
+ function blurRadius(aperture, focal, depth, focusDepth) {
1924
+ if (!(aperture > 0) || !(focal > 0) || !(depth > 0) || !(focusDepth > 0)) return 0;
1925
+ const r = aperture * focal * Math.abs(1 / depth - 1 / focusDepth) / 2;
1926
+ return Math.min(r, MAX_BLUR);
1927
+ }
1928
+ var SCOPE_NAMES = /* @__PURE__ */ new Set(["w", "h", "W", "H", "GW", "GH", "contain", "cover", "t", "d", "T"]);
1929
+ function looksLikeLayerName(s) {
1930
+ return /^[A-Za-z_][\w-]*$/.test(s) && !SCOPE_NAMES.has(s);
1931
+ }
1932
+ var isName = (v, known) => typeof v === "string" && (known.has(v) || looksLikeLayerName(v));
1933
+ function focusNames(props, known) {
1934
+ const out = [];
1935
+ const read = (bag) => {
1936
+ const v = bag?.focus;
1937
+ if (isName(v, known)) out.push(v);
1938
+ };
1939
+ read(props.initial);
1940
+ for (const kf of props.keyframes ?? []) for (const bag of [kf.set, kf.to, kf.from]) read(bag);
1941
+ return out;
1942
+ }
1943
+ function withFocusResolved(props, zOf, known = /* @__PURE__ */ new Set()) {
1944
+ if (focusNames(props, known).length === 0) return props;
1945
+ const fix = (bag) => {
1946
+ const v = bag?.focus;
1947
+ if (!bag || !isName(v, known)) return bag;
1948
+ return { ...bag, focus: zOf(v) ?? 0 };
1949
+ };
1950
+ return {
1951
+ ...props,
1952
+ initial: fix(props.initial),
1953
+ keyframes: props.keyframes?.map((kf) => ({ ...kf, set: fix(kf.set), to: fix(kf.to), from: fix(kf.from) }))
1954
+ };
1955
+ }
1956
+ function layerInitialZ(spec, scope) {
1957
+ const z = spec.initial?.z;
1958
+ if (typeof z === "number") return z;
1959
+ if (typeof z === "string") return evaluateExpr(z, scope);
1960
+ return 0;
1961
+ }
1962
+ var movesZ = (spec) => (spec.keyframes ?? []).some((kf) => [kf.set, kf.to, kf.from].some((bag) => bag && "z" in bag));
1963
+ function focusProblems(camera, siblings) {
1964
+ const out = [];
1965
+ const said = /* @__PURE__ */ new Set();
1966
+ const threeD = siblings.filter((s) => s.threeD && s.name).map((s) => s.name);
1967
+ const known = new Set(siblings.map((s) => s.name).filter((n) => !!n));
1968
+ for (const name of focusNames(camera, known)) {
1969
+ if (said.has(name)) continue;
1970
+ 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) });
1973
+ else if (!hit.threeD) out.push({ kind: "not-threeD", name });
1974
+ else if (movesZ(hit)) out.push({ kind: "moving", name });
1975
+ }
1976
+ return out;
1977
+ }
1915
1978
  var CameraSequence = class extends Sequence {
1916
1979
  /** True when `z` is never specified anywhere: z then follows `fov`. */
1917
1980
  autoZ = true;
1918
1981
  compH = 0;
1919
1982
  warnedFov = false;
1920
1983
  warnedLookAt = false;
1984
+ /** True when the camera writes `focus` or `aperture` anywhere: depth of field is on. */
1985
+ dof = false;
1986
+ zOfName = null;
1987
+ layerNames = /* @__PURE__ */ new Set();
1921
1988
  async build() {
1922
1989
  const compW = this.parent?.width ?? this.root.width;
1923
1990
  this.compH = this.parent?.height ?? this.root.height;
@@ -1933,10 +2000,23 @@ var CameraSequence = class extends Sequence {
1933
2000
  carrier.lookAtY = home.lookAtY;
1934
2001
  carrier.lookAtZ = home.lookAtZ;
1935
2002
  carrier.fov = home.fov;
2003
+ carrier.focus = 0;
2004
+ carrier.aperture = DEFAULT_APERTURE;
1936
2005
  carrier.offsetX = carrier.offsetY = carrier.offsetZ = 0;
1937
2006
  carrier.lookOffsetX = carrier.lookOffsetY = carrier.lookOffsetZ = 0;
1938
2007
  this.target = carrier;
1939
- this.autoZ = !collectPropKeys(this.spec).has("z");
2008
+ const keys = collectPropKeys(this.spec);
2009
+ this.autoZ = !keys.has("z");
2010
+ this.dof = keys.has("focus") || keys.has("aperture");
2011
+ }
2012
+ /** Called by the composition once its children exist: how a layer name in `focus` becomes the z of that layer. */
2013
+ resolveFocusNames(zOf, names = /* @__PURE__ */ new Set()) {
2014
+ this.zOfName = zOf;
2015
+ this.layerNames = names;
2016
+ }
2017
+ displayProps() {
2018
+ const base = super.displayProps();
2019
+ return this.zOfName ? withFocusResolved(base, this.zOfName, this.layerNames) : base;
1940
2020
  }
1941
2021
  /** The camera's state at the current timeline position. */
1942
2022
  state() {
@@ -1960,7 +2040,9 @@ var CameraSequence = class extends Sequence {
1960
2040
  lookAtX: c.lookAtX + c.lookOffsetX,
1961
2041
  lookAtY: c.lookAtY + c.lookOffsetY,
1962
2042
  lookAtZ: c.lookAtZ + c.lookOffsetZ,
1963
- fov
2043
+ fov,
2044
+ focus: Number.isFinite(c.focus) ? c.focus : 0,
2045
+ aperture: this.dof && c.aperture > 0 ? c.aperture : 0
1964
2046
  };
1965
2047
  }
1966
2048
  /** Lifespan on the global timeline (valid after bindTimeline). */
@@ -3740,7 +3822,7 @@ function numOrZero(v, scope) {
3740
3822
  var _CompositionSequence = null;
3741
3823
  async function getCompositionSequence() {
3742
3824
  if (!_CompositionSequence) {
3743
- _CompositionSequence = (await import('./Composition-LL2XXU5N.cjs')).CompositionSequence;
3825
+ _CompositionSequence = (await import('./Composition-2UFPSNVN.cjs')).CompositionSequence;
3744
3826
  }
3745
3827
  return _CompositionSequence;
3746
3828
  }
@@ -3781,10 +3863,14 @@ async function buildSequenceTree(specs, parent, root) {
3781
3863
  exports.CameraSequence = CameraSequence;
3782
3864
  exports.DEFAULT_FOV = DEFAULT_FOV;
3783
3865
  exports.DEG = DEG;
3866
+ exports.MANY_BLURRED = MANY_BLURRED;
3867
+ exports.MAX_BLUR = MAX_BLUR;
3868
+ exports.MIN_BLUR = MIN_BLUR;
3784
3869
  exports.NEAR = NEAR;
3785
3870
  exports.NullSequence = NullSequence;
3786
3871
  exports.Sequence = Sequence;
3787
3872
  exports.bindClock = bindClock;
3873
+ exports.blurRadius = blurRadius;
3788
3874
  exports.buildScope = buildScope;
3789
3875
  exports.buildSequenceTree = buildSequenceTree;
3790
3876
  exports.cameraBasis = cameraBasis;
@@ -3796,13 +3882,16 @@ exports.describeLayer = describeLayer;
3796
3882
  exports.ensureFilterLibrary = ensureFilterLibrary;
3797
3883
  exports.evaluateExpr = evaluateExpr;
3798
3884
  exports.flattenSvgPath = flattenSvgPath;
3885
+ exports.focusProblems = focusProblems;
3799
3886
  exports.homeCamera = homeCamera;
3800
3887
  exports.homeDistance = homeDistance;
3888
+ exports.layerInitialZ = layerInitialZ;
3801
3889
  exports.lintKeys = lintKeys;
3802
3890
  exports.lintText = lintText;
3803
3891
  exports.lintTiming = lintTiming;
3804
3892
  exports.noise = noise;
3805
3893
  exports.projectLayer = projectLayer;
3894
+ exports.projectPoint = projectPoint;
3806
3895
  exports.rand = rand;
3807
3896
  exports.random = random;
3808
3897
  exports.registerSequenceType = registerSequenceType;
@@ -3810,5 +3899,5 @@ exports.remapOf = remapOf;
3810
3899
  exports.resolveAt = resolveAt;
3811
3900
  exports.summarizeWarnings = summarizeWarnings;
3812
3901
  exports.timeRemapOf = timeRemapOf;
3813
- //# sourceMappingURL=chunk-NO26HWR7.cjs.map
3814
- //# sourceMappingURL=chunk-NO26HWR7.cjs.map
3902
+ //# sourceMappingURL=chunk-BPW42X7C.cjs.map
3903
+ //# sourceMappingURL=chunk-BPW42X7C.cjs.map