pixi-effects 0.40.0 → 0.41.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 (57) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/README.md +5 -5
  3. package/ai/chat-template.html +3 -3
  4. package/ai/tools/check.mjs +19 -2
  5. package/dist/Composition-N6BOROJ2.cjs +16 -0
  6. package/dist/{Composition-C3UEVHQG.cjs.map → Composition-N6BOROJ2.cjs.map} +1 -1
  7. package/dist/Composition-YGBQX3HZ.js +7 -0
  8. package/dist/{Composition-KRWH72MA.js.map → Composition-YGBQX3HZ.js.map} +1 -1
  9. package/dist/Controller.d.cts +1 -1
  10. package/dist/Controller.d.ts +1 -1
  11. package/dist/{Movie-CG6Jy1tx.d.ts → Movie-CwqRLOzE.d.ts} +47 -1
  12. package/dist/{Movie-CMq4KFmc.d.cts → Movie-DWtxRiJ2.d.cts} +47 -1
  13. package/dist/{Spans-TWO4VN5H.js → Spans-6L2ZVECX.js} +4 -4
  14. package/dist/{Spans-TWO4VN5H.js.map → Spans-6L2ZVECX.js.map} +1 -1
  15. package/dist/{Spans-APNJHCYO.cjs → Spans-XTIWYSNO.cjs} +9 -9
  16. package/dist/{Spans-APNJHCYO.cjs.map → Spans-XTIWYSNO.cjs.map} +1 -1
  17. package/dist/{chunk-27PYJ4JY.cjs → chunk-3HZV3UHU.cjs} +67 -63
  18. package/dist/chunk-3HZV3UHU.cjs.map +1 -0
  19. package/dist/{chunk-LMWXR5OC.js → chunk-4QVQ5UJJ.js} +4 -4
  20. package/dist/{chunk-LMWXR5OC.js.map → chunk-4QVQ5UJJ.js.map} +1 -1
  21. package/dist/{chunk-26Z544SH.js → chunk-ICI6ACHY.js} +7 -3
  22. package/dist/chunk-ICI6ACHY.js.map +1 -0
  23. package/dist/{chunk-LEL7UNYQ.cjs → chunk-RN5FWGGM.cjs} +136 -39
  24. package/dist/chunk-RN5FWGGM.cjs.map +1 -0
  25. package/dist/{chunk-7EI2N7WO.cjs → chunk-X62H3RBG.cjs} +4 -4
  26. package/dist/{chunk-7EI2N7WO.cjs.map → chunk-X62H3RBG.cjs.map} +1 -1
  27. package/dist/{chunk-CT5CZVT5.js → chunk-Y2N6U3X5.js} +101 -4
  28. package/dist/chunk-Y2N6U3X5.js.map +1 -0
  29. package/dist/index.cjs +33 -33
  30. package/dist/index.d.cts +1 -1
  31. package/dist/index.d.ts +1 -1
  32. package/dist/index.js +3 -3
  33. package/dist/loader.css +1 -1
  34. package/dist/present.cjs +3 -3
  35. package/dist/present.d.cts +1 -1
  36. package/dist/present.d.ts +1 -1
  37. package/dist/present.js +3 -3
  38. package/dist/three.cjs +52 -6
  39. package/dist/three.cjs.map +1 -1
  40. package/dist/three.d.cts +16 -1
  41. package/dist/three.d.ts +16 -1
  42. package/dist/three.js +49 -3
  43. package/dist/three.js.map +1 -1
  44. package/docs/api.md +17 -0
  45. package/docs/dsl.md +1 -1
  46. package/llms-full.txt +44 -3
  47. package/package.json +1 -1
  48. package/skills/pixi-effects/SKILL.md +2 -2
  49. package/skills/pixi-effects/reference/cheatsheet.md +1 -0
  50. package/skills/pixi-effects/reference/recipes.md +23 -0
  51. package/skills/pixi-effects/template.html +6 -6
  52. package/dist/Composition-C3UEVHQG.cjs +0 -16
  53. package/dist/Composition-KRWH72MA.js +0 -7
  54. package/dist/chunk-26Z544SH.js.map +0 -1
  55. package/dist/chunk-27PYJ4JY.cjs.map +0 -1
  56. package/dist/chunk-CT5CZVT5.js.map +0 -1
  57. package/dist/chunk-LEL7UNYQ.cjs.map +0 -1
@@ -1,5 +1,5 @@
1
- import { CompositionSequence, maskSourceOf } from './chunk-26Z544SH.js';
2
- import { EXPRESSION_NAMES, createTimeline, lengthen, ensureFilterLibrary, checkEase, parseEase, homeDistance, DEFAULT_FOV, random, noise, flattenSvgPath, trimPolylines, rand, DEG, timeRemapOf, contentLength, resolveAt, parseSpring, springDuration, spansMeta } from './chunk-LMWXR5OC.js';
1
+ import { CompositionSequence, maskSourceOf } from './chunk-ICI6ACHY.js';
2
+ import { EXPRESSION_NAMES, createTimeline, lengthen, ensureFilterLibrary, checkEase, parseEase, homeDistance, DEFAULT_FOV, random, noise, flattenSvgPath, trimPolylines, rand, DEG, timeRemapOf, contentLength, resolveAt, parseSpring, springDuration, spansMeta } from './chunk-4QVQ5UJJ.js';
3
3
  import { analyzeAudio, fft, resampleThrough, playSpan } from './chunk-UHNSL2KJ.js';
4
4
  import { usesAdvancedBlend, enableAdvancedBlend } from './chunk-VNP7QCJE.js';
5
5
  import { describeLayer } from './chunk-32MMNDDN.js';
@@ -1729,6 +1729,80 @@ function inspectScene(root, frame, time, canvas, opts = {}) {
1729
1729
  return { frame, time, canvas, summary: { layers: layers.length, visible: layers.filter((l) => l.visible).length }, issues, layers: listed };
1730
1730
  }
1731
1731
 
1732
+ // src/core/pick.ts
1733
+ function pointInQuad(q, x, y) {
1734
+ let pos = 0, neg = 0;
1735
+ for (let i = 0; i < 4; i++) {
1736
+ const ax = q[i * 2], ay = q[i * 2 + 1], bx = q[(i + 1) % 4 * 2], by = q[(i + 1) % 4 * 2 + 1];
1737
+ const cross = (bx - ax) * (y - ay) - (by - ay) * (x - ax);
1738
+ if (cross > 0) pos++;
1739
+ else if (cross < 0) neg++;
1740
+ }
1741
+ return pos === 0 || neg === 0;
1742
+ }
1743
+ function orderOf(node) {
1744
+ const key = [];
1745
+ for (let n = node; n && n.parent; n = n.parent) {
1746
+ key.unshift([n.zIndex ?? 0, Math.max(0, n.parent.children?.indexOf(n) ?? 0)]);
1747
+ }
1748
+ return key;
1749
+ }
1750
+ var above = (a, b) => {
1751
+ for (let i = 0; i < Math.min(a.length, b.length); i++) {
1752
+ if (a[i][0] !== b[i][0]) return b[i][0] - a[i][0];
1753
+ if (a[i][1] !== b[i][1]) return b[i][1] - a[i][1];
1754
+ }
1755
+ return b.length - a.length;
1756
+ };
1757
+ function pickScene(root, x, y, opts = {}) {
1758
+ const found = [];
1759
+ const wanted = (name, path) => {
1760
+ if (opts.ignore && (opts.ignore.includes(path) || name !== void 0 && opts.ignore.includes(name))) return false;
1761
+ if (opts.only && !(opts.only.includes(path) || name !== void 0 && opts.only.includes(name))) return false;
1762
+ return true;
1763
+ };
1764
+ const inside = (b, p) => p.x >= b.x && p.x <= b.x + b.width && p.y >= b.y && p.y <= b.y + b.height;
1765
+ const walk2 = (comp, prefix, parentVisible) => {
1766
+ comp.layers().forEach(({ seq, display, threeD, carriers, quad }, i) => {
1767
+ const d = display;
1768
+ if (!d) return;
1769
+ const t = seq.target;
1770
+ const name = seq.spec.name;
1771
+ const path = prefix + (name ?? `${seq.spec.type}#${i}`);
1772
+ const alpha = (t?.alpha ?? 1) * carriers.reduce((a, c) => a * (c.target?.alpha ?? 1), 1);
1773
+ const alive = (threeD ? d.visible : t?.renderable ?? true) && carriers.every((c) => c.target?.renderable ?? true);
1774
+ const visible = parentVisible && alive && alpha > 0;
1775
+ if (!visible) return;
1776
+ const isComposition = seq instanceof CompositionSequence;
1777
+ if (isComposition && !threeD) {
1778
+ walk2(seq, path + "/", visible);
1779
+ return;
1780
+ }
1781
+ if (!wanted(name, path)) return;
1782
+ const point = { x, y };
1783
+ let hit = null;
1784
+ if (threeD) {
1785
+ if (quad && pointInQuad(quad, d.toLocal(point).x, d.toLocal(point).y)) hit = { name, path, type: seq.spec.type, kind: "card", point };
1786
+ } else {
1787
+ const local = d.toLocal(point);
1788
+ const lb = d.getLocalBounds();
1789
+ if (inside(lb, local)) {
1790
+ const three = typeof seq.pickAt === "function" ? seq.pickAt((local.x - lb.x) / lb.width, (local.y - lb.y) / lb.height) : void 0;
1791
+ if (three) hit = { name, path, type: seq.spec.type, kind: "three", point, three };
1792
+ else if (three === void 0 && (typeof d.containsPoint !== "function" || d.containsPoint(local))) hit = { name, path, type: seq.spec.type, kind: "flat", point, local: { x: local.x - lb.x, y: local.y - lb.y } };
1793
+ }
1794
+ }
1795
+ if (!hit) return;
1796
+ const maskTarget = seq.maskSequence?.target;
1797
+ const maskSrc = maskSourceOf(seq.spec.mask);
1798
+ if (maskTarget && !(maskSrc.kind === "inline" && maskSrc.invert) && !inside(maskTarget.getBounds(), point)) return;
1799
+ found.push({ hit, order: orderOf(d) });
1800
+ });
1801
+ };
1802
+ walk2(root, "", true);
1803
+ return found.sort((a, b) => above(a.order, b.order)).map((f) => f.hit);
1804
+ }
1805
+
1732
1806
  // src/core/timelineChart.ts
1733
1807
  var GROUP_MIN = 4;
1734
1808
  var MAX_KEYS = 200;
@@ -2986,6 +3060,29 @@ var Movie = class {
2986
3060
  * Where every layer is drawn at `frame` (canvas pixels, visibility) plus `issues` — text that is off
2987
3061
  * the canvas, cut by an edge, empty, or overlapping other text. Seeks there and stays there.
2988
3062
  */
3063
+ /**
3064
+ * What is under the canvas point (x, y) (canvas pixels: the movie's own `width` x `height`; `canvasPoint(event)` makes them from a pointer event) at the frame on screen: the layer on
3065
+ * top, or null. A flat layer is hit by its own shape, a `threeD` card by its projected quad, a `three` layer by a ray through its camera (`hit.three` has the object). It reads the
3066
+ * frame as the last draw left it, so after `await movie.snapshot(frame)` or any seek it answers for that frame. `opts.only` / `opts.ignore`: layer names or paths.
3067
+ */
3068
+ pick(x, y, opts = {}) {
3069
+ return this.pickAll(x, y, opts)[0] ?? null;
3070
+ }
3071
+ /** Every layer under the canvas point, the one on top first (see `pick`). */
3072
+ pickAll(x, y, opts = {}) {
3073
+ warnUnknownOptions("movie.pick()", opts, ["only", "ignore"]);
3074
+ this._requireReady("pick");
3075
+ if (!Number.isFinite(x) || !Number.isFinite(y)) throw new Error(`pixi-effects: movie.pick(x, y) needs two numbers (canvas pixels), got ${x}, ${y}. For a pointer event: movie.pick(...movie.canvasPoint(event))`);
3076
+ return pickScene(this._rootSequence, x, y, opts);
3077
+ }
3078
+ /** A pointer event's place in canvas pixels (the canvas may be shown larger or smaller than its own size): `movie.pick(...movie.canvasPoint(event))`. */
3079
+ canvasPoint(event) {
3080
+ this._requireReady("canvasPoint");
3081
+ const canvas = this.app?.canvas;
3082
+ if (!canvas) throw new Error("pixi-effects: movie.canvasPoint needs the movie's canvas");
3083
+ const r = canvas.getBoundingClientRect();
3084
+ return [(event.clientX - r.left) * this.width / (r.width || this.width), (event.clientY - r.top) * this.height / (r.height || this.height)];
3085
+ }
2989
3086
  async inspect(frame = this.currentFrame, opts = { layers: "visible" }) {
2990
3087
  warnUnknownOptions("movie.inspect()", opts, ["layers"]);
2991
3088
  this._requireReady("inspect");
@@ -4485,5 +4582,5 @@ function withFade(spec, opts) {
4485
4582
  }
4486
4583
 
4487
4584
  export { Movie, animateText, audioEnvelope, bpmEnvelope, cameraPath, computeEnvelope, dismissLoader, failLoader, followPath, kenBurns, measureText, musicBuffer, musicEnvelope, musicEvents, orbit, parseEase2 as parseEase, particles, react, resolveLoader, samplePath, splitText, stagger, wiggle, withFade };
4488
- //# sourceMappingURL=chunk-CT5CZVT5.js.map
4489
- //# sourceMappingURL=chunk-CT5CZVT5.js.map
4585
+ //# sourceMappingURL=chunk-Y2N6U3X5.js.map
4586
+ //# sourceMappingURL=chunk-Y2N6U3X5.js.map