pixi-effects 0.41.0 → 0.42.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.42.0
4
+
5
+ Interaction on top of `pick`: hover, dragging, a hit that looks at the picture, and a fix for a false warning that every rebuilt page with a `three` layer showed since 0.40.0. Nothing breaks.
6
+
7
+ - **Fixed (found by an AI trial of the interactive features): a rebuilt `three` layer said the browser had taken its WebGL context.** `setVars`, `resize` and `rebuild` destroy the old layers; a three layer lets its context go with `forceContextLoss()`, and the loss event that follows was reported by the "the browser took this layer's WebGL context away" warning added in 0.40.0, though it was the layer's own doing. A page whose three layer changed a variable on a click showed a false warning. The layer now knows it is closing (`tests/three/budget.test.ts`; `tests/films/three-budget` rebuilds in Chrome and fails without the fix).
8
+ - **New: `movie.hover({ onEnter, onLeave })`.** Which layer the pointer is over (in a `three` layer, which object), as callbacks on top of `pick`: `onEnter(hit)` when the layer under the pointer changes to another, `onLeave(hit)` for the one it left (also when the pointer leaves the picture or the returned stop function is called). While the pointer rests inside it is asked again on every frame, so a picture that moves under a still pointer is followed (a runner leaves the pointer with no pointer event in between: tested in real Chrome). `{ only, ignore }`, `cursor: true` (or a CSS cursor). A page-side tool: an exported video has no pointer.
9
+ - **New: `pick` looks at the picture (`{ alpha }`), and an object of a `three` layer can be dragged (`hit.three.grab`, `movie.redraw()`).** `movie.pick(x, y, { alpha: 0.1 })` leaves out a pixel of an image, a video or a `canvas` layer whose alpha is at or below it (a transparent corner of a logo, the clear part of a drawn circle); off by default, nothing is read without it; shapes are hit by their outline, text and `shader` layers by their box (a shader's WebGL picture cannot be read back safely); a picture that cannot be read (another origin) stays a hit with one warning. `hit.three.grab('screen' | 'floor' | 'wall' | [nx, ny, nz])` fixes a plane through the point taken and `grab.move(x, y)` returns where the pointer's ray meets it and the `delta` from the point taken (null where it never does): the object follows the pointer exactly (checked in real Chrome on a wall and on a floor seen in perspective). `movie.redraw()` draws the paused frame again, quietly, for a layer that reads the page's own state. `pick`'s `only` / `ignore` take a group's name for everything in it (a card and its label: `only: ['card']`), as well as layer names and paths.
10
+ - **Recipes and docs, from three fresh-AI trials of `pick`, `hover` and dragging** (a fox that stops when clicked, a card dragged onto a zone that lights, a logo clicked by its picture and a cube dragged along a floor; each page checked in a real browser): the recipes `pick-click`, `drag-drop` (a flat layer, a zone that lights by a variable alpha, the grab and grabbing cursors, `touch-action: none`) and `drag-3d` (with a floor variant) are complete pages whose code is tested (`tests/films/drag-recipe`, `drag3d`, `interact`, `pick`); SKILL.md says how to test an interactive page with pointer events (`check` does not click); the `vars` doc says a rebuild runs a three layer's `setup` again, so a 3D drag keeps the object's place in the page and calls `redraw()`.
11
+
3
12
  ## 0.41.0
4
13
 
5
14
  `movie.pick` (what is under a point of the canvas) and a better fit of the light falloff in a `three` layer. Nothing breaks.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # pixi-effects
2
2
 
3
- > **Status**: experimental — current release `0.41.0`. The API may still change between minor versions; see the [CHANGELOG](./CHANGELOG.md) for what each release changed.
3
+ > **Status**: experimental — current release `0.42.0`. The API may still change between minor versions; see the [CHANGELOG](./CHANGELOG.md) for what each release changed.
4
4
 
5
5
  **[Gallery →](https://yjmtmtk.github.io/pixi-effects/examples/gallery/)** · 43 pieces written as plain data by AI models · **[For AI →](https://yjmtmtk.github.io/pixi-effects/for-ai.html)** · what an AI reads and runs · **[Playground →](https://yjmtmtk.github.io/pixi-effects/examples/playground.html)** in the browser.
6
6
 
@@ -49,8 +49,8 @@ Drop the imports into an [importmap](https://developer.mozilla.org/docs/Web/HTML
49
49
  "imports": {
50
50
  "pixi.js": "https://esm.sh/pixi.js@8.22.0?bundle-deps",
51
51
  "mediabunny": "https://esm.sh/mediabunny",
52
- "pixi-effects": "https://cdn.jsdelivr.net/npm/pixi-effects@0.41.0/dist/index.js",
53
- "pixi-effects/controller": "https://cdn.jsdelivr.net/npm/pixi-effects@0.41.0/dist/Controller.js"
52
+ "pixi-effects": "https://cdn.jsdelivr.net/npm/pixi-effects@0.42.0/dist/index.js",
53
+ "pixi-effects/controller": "https://cdn.jsdelivr.net/npm/pixi-effects@0.42.0/dist/Controller.js"
54
54
  }
55
55
  }
56
56
  </script>
@@ -61,7 +61,7 @@ Drop the imports into an [importmap](https://developer.mozilla.org/docs/Web/HTML
61
61
  </script>
62
62
  ```
63
63
 
64
- Load the `dist/` files **as they are** (jsDelivr's `/npm/…/dist/…`, or unpkg's `https://unpkg.com/pixi-effects@0.41.0/dist/index.js`) rather than a CDN-rebundled build such as `esm.sh/pixi-effects` or jsDelivr's `+esm`: the entries (`pixi-effects`, `…/controller`, `…/three`) share internal chunks, which only works when each file is served untouched.
64
+ Load the `dist/` files **as they are** (jsDelivr's `/npm/…/dist/…`, or unpkg's `https://unpkg.com/pixi-effects@0.42.0/dist/index.js`) rather than a CDN-rebundled build such as `esm.sh/pixi-effects` or jsDelivr's `+esm`: the entries (`pixi-effects`, `…/controller`, `…/three`) share internal chunks, which only works when each file is served untouched.
65
65
 
66
66
  > **Using three.js?** Add two more entries (`three` and `pixi-effects/three`) to this importmap — see [Adding three.js](#adding-threejs-optional) below.
67
67
  >
@@ -78,7 +78,7 @@ Add two more entries to the importmap above: three.js itself, and the `pixi-effe
78
78
  "...": "(everything from the importmap above)",
79
79
  "three": "https://esm.sh/three@0.178.0",
80
80
  "three/addons/": "https://cdn.jsdelivr.net/npm/three@0.178.0/examples/jsm/",
81
- "pixi-effects/three": "https://cdn.jsdelivr.net/npm/pixi-effects@0.41.0/dist/three.js"
81
+ "pixi-effects/three": "https://cdn.jsdelivr.net/npm/pixi-effects@0.42.0/dist/three.js"
82
82
  }
83
83
  }
84
84
  </script>
@@ -59,9 +59,9 @@
59
59
  "imports": {
60
60
  "pixi.js": "https://cdn.jsdelivr.net/npm/pixi.js@8.22.0/dist/pixi.min.mjs",
61
61
  "mediabunny": "https://cdn.jsdelivr.net/npm/mediabunny@1.61.3/+esm",
62
- "pixi-effects": "https://cdn.jsdelivr.net/npm/pixi-effects@0.41.0/dist/index.js",
63
- "pixi-effects/controller": "https://cdn.jsdelivr.net/npm/pixi-effects@0.41.0/dist/Controller.js",
64
- "pixi-effects/present": "https://cdn.jsdelivr.net/npm/pixi-effects@0.41.0/dist/present.js"
62
+ "pixi-effects": "https://cdn.jsdelivr.net/npm/pixi-effects@0.42.0/dist/index.js",
63
+ "pixi-effects/controller": "https://cdn.jsdelivr.net/npm/pixi-effects@0.42.0/dist/Controller.js",
64
+ "pixi-effects/present": "https://cdn.jsdelivr.net/npm/pixi-effects@0.42.0/dist/present.js"
65
65
  }
66
66
  }
67
67
  </script>
@@ -1,4 +1,4 @@
1
- import { M as Movie } from './Movie-DWtxRiJ2.cjs';
1
+ import { M as Movie } from './Movie-BHGhg-fJ.cjs';
2
2
  import 'pixi.js';
3
3
  import './soundEntry-DT13DNt8.cjs';
4
4
  import './types-DIh93lFb.cjs';
@@ -1,4 +1,4 @@
1
- import { M as Movie } from './Movie-CwqRLOzE.js';
1
+ import { M as Movie } from './Movie-CBVFZ1kg.js';
2
2
  import 'pixi.js';
3
3
  import './soundEntry-DT13DNt8.js';
4
4
  import './types-DIh93lFb.js';
@@ -259,15 +259,45 @@ interface PickHit {
259
259
  point: [number, number, number];
260
260
  distance: number;
261
261
  object3d?: unknown;
262
+ /**
263
+ * Drag what the ray met: `grab(plane)` fixes a plane through the hit point (`'screen'` facing the camera, the default; `'floor'`; `'wall'`; or a normal `[x, y, z]`), and `move(x, y)` takes the pointer
264
+ * in canvas pixels and gives where its ray meets that plane (`point`) and how far that is from the hit point (`delta`): move the object by it. null where the ray never meets the plane.
265
+ */
266
+ grab?: (plane?: 'screen' | 'floor' | 'wall' | [number, number, number]) => {
267
+ move: (x: number, y: number) => {
268
+ point: [number, number, number];
269
+ delta: [number, number, number];
270
+ } | null;
271
+ };
262
272
  };
263
273
  }
264
274
  interface PickOptions {
265
- /** Only these layers can be hit (by `name` or by `path`). */
275
+ /**
276
+ * Look at the picture, not the box: a pixel of an image, a video or a `canvas` layer whose alpha is at or below this (0..1; `0.1` leaves out what is nearly clear) is not a hit.
277
+ * Off by default (the box is the picture, and nothing is read). Shapes are always hit by their outline, text and `shader` layers by their box; a picture that cannot be read (from another origin) stays a hit.
278
+ */
279
+ alpha?: number;
280
+ /** Only these layers can be hit (by `name` or by `path`; a group's name stands for everything in it). */
266
281
  only?: string[];
267
- /** These layers cannot be hit (by `name` or by `path`). */
282
+ /** These layers cannot be hit (by `name` or by `path`; a group's name stands for everything in it). */
268
283
  ignore?: string[];
269
284
  }
270
285
 
286
+ /**
287
+ * `movie.hover({ onEnter, onLeave })`: which layer (or which object of a three layer) the pointer is over, as two callbacks. It is a page-side tool on top of `movie.pick`: it listens to the
288
+ * canvas, asks `pick` where the pointer is, and calls `onEnter(hit)` when the layer under it changes to another and `onLeave(hit)` for the one it left. While the pointer rests inside the
289
+ * picture it asks again on every frame, so a layer that runs away from a still pointer is left. Nothing here is part of the video: an exported file has no pointer.
290
+ */
291
+
292
+ interface HoverOptions extends PickOptions {
293
+ /** The layer (or, in a `three` layer, the object) the pointer has just come onto. */
294
+ onEnter?: (hit: PickHit) => void;
295
+ /** The one it has just left (also when the pointer leaves the picture, or `stop()` is called). */
296
+ onLeave?: (hit: PickHit) => void;
297
+ /** A CSS cursor to show while something is hovered (`true` is `'pointer'`); it goes back when nothing is. */
298
+ cursor?: string | boolean;
299
+ }
300
+
271
301
  /** One layer (or a run of similar layers) on the timeline. Times are in seconds, absolute (from the start of the movie). */
272
302
  interface TimelineRow {
273
303
  /** `parent/child` for a layer inside a composition. */
@@ -645,6 +675,11 @@ declare class Movie {
645
675
  private _runRebuild;
646
676
  private _doRebuild;
647
677
  gotoFrame(frame: number, force?: boolean): Promise<void>;
678
+ /**
679
+ * Draw the frame on screen again, quietly (no `seeking` / `seeked`). For a paused movie when something outside it that a layer reads has changed: a `three` layer whose `update` reads the page's own
680
+ * state (a dragged object's place) shows it after `await movie.redraw()`. A playing movie needs no call: the next frame draws it.
681
+ */
682
+ redraw(): Promise<void>;
648
683
  /** Run `fn` with `seeking` / `seeked` silenced: the movie is moving its own playhead, not answering a seek. */
649
684
  private _quietly;
650
685
  private _emitError;
@@ -719,6 +754,12 @@ declare class Movie {
719
754
  pick(x: number, y: number, opts?: PickOptions): PickHit | null;
720
755
  /** Every layer under the canvas point, the one on top first (see `pick`). */
721
756
  pickAll(x: number, y: number, opts?: PickOptions): PickHit[];
757
+ /**
758
+ * Which layer the pointer is over, as callbacks: `onEnter(hit)` when the layer (or, in a `three` layer, the object) under the pointer changes to another, `onLeave(hit)` for the one it
759
+ * left (also when the pointer leaves the picture). While the pointer rests inside, it is asked again on every frame, so a picture that moves under a still pointer is followed.
760
+ * `{ only, ignore }` as for `pick`; `cursor: true` (or a CSS cursor) shows it while something is hovered. Returns the function that stops it. A page-side tool: an exported video has no pointer.
761
+ */
762
+ hover(opts?: HoverOptions): () => void;
722
763
  /** 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))`. */
723
764
  canvasPoint(event: {
724
765
  clientX: number;
@@ -814,4 +855,4 @@ declare class Movie {
814
855
  destroy(): Promise<void>;
815
856
  }
816
857
 
817
- export { type ContactSheetOptions as C, type FontReport as F, type InspectOptions as I, type LayerInfo as L, Movie as M, type OnionSkinOptions as O, type PickHit as P, type RebuildOptions as R, type SnapshotOptions as S, type ThumbnailOptions as T, type VolumeEvent as V, type MotionBlurSpec as a, type FrameEvent as b, type InspectReport as c, type IssueGroup as d, type LoadProgressState as e, type LoadStage as f, type LoaderOption as g, type LoopEvent as h, type MotionBlurOptions as i, type MovieErrorEvent as j, type MovieOptions as k, type PickOptions as l, type ProgressEvent as m, type RebuildReason as n, type RebuildReport as o, type RenderOptions as p, type ReviewOptions as q, type ReviewReport as r, type TimelineData as s, type TimelineHtmlOptions as t, type TimelineRow as u, type TimelineSvgOptions as v, type TimelineTransition as w, dismissLoader as x, failLoader as y, resolveLoader as z };
858
+ export { type ContactSheetOptions as C, type FontReport as F, type HoverOptions as H, type InspectOptions as I, type LayerInfo as L, Movie as M, type OnionSkinOptions as O, type PickHit as P, type RebuildOptions as R, type SnapshotOptions as S, type ThumbnailOptions as T, type VolumeEvent as V, type MotionBlurSpec as a, type FrameEvent as b, type InspectReport as c, type IssueGroup as d, type LoadProgressState as e, type LoadStage as f, type LoaderOption as g, type LoopEvent as h, type MotionBlurOptions as i, type MovieErrorEvent as j, type MovieOptions as k, type PickOptions as l, type ProgressEvent as m, type RebuildReason as n, type RebuildReport as o, type RenderOptions as p, type ReviewOptions as q, type ReviewReport as r, type TimelineData as s, type TimelineHtmlOptions as t, type TimelineRow as u, type TimelineSvgOptions as v, type TimelineTransition as w, dismissLoader as x, failLoader as y, resolveLoader as z };
@@ -259,15 +259,45 @@ interface PickHit {
259
259
  point: [number, number, number];
260
260
  distance: number;
261
261
  object3d?: unknown;
262
+ /**
263
+ * Drag what the ray met: `grab(plane)` fixes a plane through the hit point (`'screen'` facing the camera, the default; `'floor'`; `'wall'`; or a normal `[x, y, z]`), and `move(x, y)` takes the pointer
264
+ * in canvas pixels and gives where its ray meets that plane (`point`) and how far that is from the hit point (`delta`): move the object by it. null where the ray never meets the plane.
265
+ */
266
+ grab?: (plane?: 'screen' | 'floor' | 'wall' | [number, number, number]) => {
267
+ move: (x: number, y: number) => {
268
+ point: [number, number, number];
269
+ delta: [number, number, number];
270
+ } | null;
271
+ };
262
272
  };
263
273
  }
264
274
  interface PickOptions {
265
- /** Only these layers can be hit (by `name` or by `path`). */
275
+ /**
276
+ * Look at the picture, not the box: a pixel of an image, a video or a `canvas` layer whose alpha is at or below this (0..1; `0.1` leaves out what is nearly clear) is not a hit.
277
+ * Off by default (the box is the picture, and nothing is read). Shapes are always hit by their outline, text and `shader` layers by their box; a picture that cannot be read (from another origin) stays a hit.
278
+ */
279
+ alpha?: number;
280
+ /** Only these layers can be hit (by `name` or by `path`; a group's name stands for everything in it). */
266
281
  only?: string[];
267
- /** These layers cannot be hit (by `name` or by `path`). */
282
+ /** These layers cannot be hit (by `name` or by `path`; a group's name stands for everything in it). */
268
283
  ignore?: string[];
269
284
  }
270
285
 
286
+ /**
287
+ * `movie.hover({ onEnter, onLeave })`: which layer (or which object of a three layer) the pointer is over, as two callbacks. It is a page-side tool on top of `movie.pick`: it listens to the
288
+ * canvas, asks `pick` where the pointer is, and calls `onEnter(hit)` when the layer under it changes to another and `onLeave(hit)` for the one it left. While the pointer rests inside the
289
+ * picture it asks again on every frame, so a layer that runs away from a still pointer is left. Nothing here is part of the video: an exported file has no pointer.
290
+ */
291
+
292
+ interface HoverOptions extends PickOptions {
293
+ /** The layer (or, in a `three` layer, the object) the pointer has just come onto. */
294
+ onEnter?: (hit: PickHit) => void;
295
+ /** The one it has just left (also when the pointer leaves the picture, or `stop()` is called). */
296
+ onLeave?: (hit: PickHit) => void;
297
+ /** A CSS cursor to show while something is hovered (`true` is `'pointer'`); it goes back when nothing is. */
298
+ cursor?: string | boolean;
299
+ }
300
+
271
301
  /** One layer (or a run of similar layers) on the timeline. Times are in seconds, absolute (from the start of the movie). */
272
302
  interface TimelineRow {
273
303
  /** `parent/child` for a layer inside a composition. */
@@ -645,6 +675,11 @@ declare class Movie {
645
675
  private _runRebuild;
646
676
  private _doRebuild;
647
677
  gotoFrame(frame: number, force?: boolean): Promise<void>;
678
+ /**
679
+ * Draw the frame on screen again, quietly (no `seeking` / `seeked`). For a paused movie when something outside it that a layer reads has changed: a `three` layer whose `update` reads the page's own
680
+ * state (a dragged object's place) shows it after `await movie.redraw()`. A playing movie needs no call: the next frame draws it.
681
+ */
682
+ redraw(): Promise<void>;
648
683
  /** Run `fn` with `seeking` / `seeked` silenced: the movie is moving its own playhead, not answering a seek. */
649
684
  private _quietly;
650
685
  private _emitError;
@@ -719,6 +754,12 @@ declare class Movie {
719
754
  pick(x: number, y: number, opts?: PickOptions): PickHit | null;
720
755
  /** Every layer under the canvas point, the one on top first (see `pick`). */
721
756
  pickAll(x: number, y: number, opts?: PickOptions): PickHit[];
757
+ /**
758
+ * Which layer the pointer is over, as callbacks: `onEnter(hit)` when the layer (or, in a `three` layer, the object) under the pointer changes to another, `onLeave(hit)` for the one it
759
+ * left (also when the pointer leaves the picture). While the pointer rests inside, it is asked again on every frame, so a picture that moves under a still pointer is followed.
760
+ * `{ only, ignore }` as for `pick`; `cursor: true` (or a CSS cursor) shows it while something is hovered. Returns the function that stops it. A page-side tool: an exported video has no pointer.
761
+ */
762
+ hover(opts?: HoverOptions): () => void;
722
763
  /** 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))`. */
723
764
  canvasPoint(event: {
724
765
  clientX: number;
@@ -814,4 +855,4 @@ declare class Movie {
814
855
  destroy(): Promise<void>;
815
856
  }
816
857
 
817
- export { type ContactSheetOptions as C, type FontReport as F, type InspectOptions as I, type LayerInfo as L, Movie as M, type OnionSkinOptions as O, type PickHit as P, type RebuildOptions as R, type SnapshotOptions as S, type ThumbnailOptions as T, type VolumeEvent as V, type MotionBlurSpec as a, type FrameEvent as b, type InspectReport as c, type IssueGroup as d, type LoadProgressState as e, type LoadStage as f, type LoaderOption as g, type LoopEvent as h, type MotionBlurOptions as i, type MovieErrorEvent as j, type MovieOptions as k, type PickOptions as l, type ProgressEvent as m, type RebuildReason as n, type RebuildReport as o, type RenderOptions as p, type ReviewOptions as q, type ReviewReport as r, type TimelineData as s, type TimelineHtmlOptions as t, type TimelineRow as u, type TimelineSvgOptions as v, type TimelineTransition as w, dismissLoader as x, failLoader as y, resolveLoader as z };
858
+ export { type ContactSheetOptions as C, type FontReport as F, type HoverOptions as H, type InspectOptions as I, type LayerInfo as L, Movie as M, type OnionSkinOptions as O, type PickHit as P, type RebuildOptions as R, type SnapshotOptions as S, type ThumbnailOptions as T, type VolumeEvent as V, type MotionBlurSpec as a, type FrameEvent as b, type InspectReport as c, type IssueGroup as d, type LoadProgressState as e, type LoadStage as f, type LoaderOption as g, type LoopEvent as h, type MotionBlurOptions as i, type MovieErrorEvent as j, type MovieOptions as k, type PickOptions as l, type ProgressEvent as m, type RebuildReason as n, type RebuildReport as o, type RenderOptions as p, type ReviewOptions as q, type ReviewReport as r, type TimelineData as s, type TimelineHtmlOptions as t, type TimelineRow as u, type TimelineSvgOptions as v, type TimelineTransition as w, dismissLoader as x, failLoader as y, resolveLoader as z };
@@ -1730,6 +1730,23 @@ function inspectScene(root, frame, time, canvas, opts = {}) {
1730
1730
  }
1731
1731
 
1732
1732
  // src/core/pick.ts
1733
+ var scratch;
1734
+ var saidBlind = /* @__PURE__ */ new Set();
1735
+ var readResourceAlpha = (resource, x, y) => {
1736
+ try {
1737
+ if (scratch === void 0) {
1738
+ const c = document.createElement("canvas");
1739
+ c.width = c.height = 1;
1740
+ scratch = c.getContext("2d", { willReadFrequently: true });
1741
+ }
1742
+ if (!scratch) return null;
1743
+ scratch.clearRect(0, 0, 1, 1);
1744
+ scratch.drawImage(resource, x, y, 1, 1, 0, 0, 1, 1);
1745
+ return scratch.getImageData(0, 0, 1, 1).data[3] / 255;
1746
+ } catch {
1747
+ return null;
1748
+ }
1749
+ };
1733
1750
  function pointInQuad(q, x, y) {
1734
1751
  let pos = 0, neg = 0;
1735
1752
  for (let i = 0; i < 4; i++) {
@@ -1754,11 +1771,14 @@ var above = (a, b) => {
1754
1771
  }
1755
1772
  return b.length - a.length;
1756
1773
  };
1757
- function pickScene(root, x, y, opts = {}) {
1774
+ function pickScene(root, x, y, opts = {}, deps = {}) {
1775
+ if (opts.alpha !== void 0 && !(opts.alpha >= 0 && opts.alpha <= 1)) throw new Error(`pixi-effects: pick: alpha must be a number from 0 to 1 (a pixel at or below it is not a hit), got ${opts.alpha}`);
1776
+ const readAlpha = deps.readAlpha ?? readResourceAlpha;
1758
1777
  const found = [];
1778
+ const names = (list, name, path) => list.some((e) => e === path || name !== void 0 && e === name || path.startsWith(e + "/") || path.split("/").slice(0, -1).includes(e));
1759
1779
  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;
1780
+ if (opts.ignore && names(opts.ignore, name, path)) return false;
1781
+ if (opts.only && !names(opts.only, name, path)) return false;
1762
1782
  return true;
1763
1783
  };
1764
1784
  const inside = (b, p) => p.x >= b.x && p.x <= b.x + b.width && p.y >= b.y && p.y <= b.y + b.height;
@@ -1788,8 +1808,34 @@ function pickScene(root, x, y, opts = {}) {
1788
1808
  const lb = d.getLocalBounds();
1789
1809
  if (inside(lb, local)) {
1790
1810
  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 } };
1811
+ if (three) {
1812
+ const planeOf = seq.dragPlane;
1813
+ if (planeOf) {
1814
+ three.grab = (plane = "screen") => {
1815
+ const along = planeOf.call(seq, three.point, plane);
1816
+ return { move: (cx, cy) => {
1817
+ const lp = d.toLocal({ x: cx, y: cy });
1818
+ const b = d.getLocalBounds();
1819
+ return along((lp.x - b.x) / b.width, (lp.y - b.y) / b.height);
1820
+ } };
1821
+ };
1822
+ }
1823
+ hit = { name, path, type: seq.spec.type, kind: "three", point, three };
1824
+ } else if (three === void 0 && (typeof d.containsPoint !== "function" || d.containsPoint(local))) {
1825
+ let opaque = true;
1826
+ const tex = opts.alpha !== void 0 && seq.spec.type !== "shader" ? d.texture : void 0;
1827
+ if (tex?.source?.resource) {
1828
+ const res = tex.source.resolution ?? 1;
1829
+ const a = readAlpha(tex.source.resource, (tex.frame.x + (local.x - lb.x) / lb.width * tex.frame.width) * res, (tex.frame.y + (local.y - lb.y) / lb.height * tex.frame.height) * res);
1830
+ if (a === null) {
1831
+ if (!saidBlind.has(path)) {
1832
+ saidBlind.add(path);
1833
+ console.warn(`pixi-effects: pick: the picture of layer "${path}" cannot be read for { alpha } (a picture from another origin: load it with crossorigin="anonymous" or from the same site), so the box counts as the picture`);
1834
+ }
1835
+ } else opaque = a > opts.alpha;
1836
+ }
1837
+ if (opaque) hit = { name, path, type: seq.spec.type, kind: "flat", point, local: { x: local.x - lb.x, y: local.y - lb.y } };
1838
+ }
1793
1839
  }
1794
1840
  }
1795
1841
  if (!hit) return;
@@ -1803,6 +1849,82 @@ function pickScene(root, x, y, opts = {}) {
1803
1849
  return found.sort((a, b) => above(a.order, b.order)).map((f) => f.hit);
1804
1850
  }
1805
1851
 
1852
+ // src/core/hover.ts
1853
+ var keyOf = (h) => h ? `${h.path}${h.three ? `#${h.three.object}` : ""}` : null;
1854
+ function startHover(host, opts = {}) {
1855
+ const { canvas } = host;
1856
+ const request = host.requestFrame ?? ((fn) => requestAnimationFrame(fn));
1857
+ const cancel = host.cancelFrame ?? ((id) => cancelAnimationFrame(id));
1858
+ const cursor = opts.cursor === true ? "pointer" : opts.cursor || "";
1859
+ const pickOpts = {};
1860
+ if (opts.only) pickOpts.only = opts.only;
1861
+ if (opts.ignore) pickOpts.ignore = opts.ignore;
1862
+ let current = null;
1863
+ let last = null;
1864
+ let loop = null;
1865
+ let said = false;
1866
+ const call = (fn, hit) => {
1867
+ if (!fn) return;
1868
+ try {
1869
+ fn(hit);
1870
+ } catch (err) {
1871
+ if (!said) {
1872
+ said = true;
1873
+ console.warn("pixi-effects: movie.hover: a handler threw (said once) \u2014", err);
1874
+ }
1875
+ }
1876
+ };
1877
+ const setCursor = (on) => {
1878
+ if (cursor) canvas.style.cursor = on ? cursor : "";
1879
+ };
1880
+ const evaluate = () => {
1881
+ if (!last) return;
1882
+ const [x, y] = host.point(last);
1883
+ const hit = host.pick(x, y, pickOpts);
1884
+ if (keyOf(hit) === keyOf(current)) {
1885
+ current = hit ?? current;
1886
+ return;
1887
+ }
1888
+ const was = current;
1889
+ current = hit;
1890
+ if (was) call(opts.onLeave, was);
1891
+ if (hit) call(opts.onEnter, hit);
1892
+ setCursor(!!hit);
1893
+ };
1894
+ const tick = () => {
1895
+ loop = null;
1896
+ if (last) {
1897
+ evaluate();
1898
+ loop = request(tick);
1899
+ }
1900
+ };
1901
+ const onMove = (event) => {
1902
+ last = event;
1903
+ evaluate();
1904
+ if (loop === null) loop = request(tick);
1905
+ };
1906
+ const onLeave = () => {
1907
+ last = null;
1908
+ if (loop !== null) {
1909
+ cancel(loop);
1910
+ loop = null;
1911
+ }
1912
+ const was = current;
1913
+ current = null;
1914
+ if (was) call(opts.onLeave, was);
1915
+ setCursor(false);
1916
+ };
1917
+ canvas.addEventListener("pointermove", onMove);
1918
+ canvas.addEventListener("pointerdown", onMove);
1919
+ canvas.addEventListener("pointerleave", onLeave);
1920
+ return () => {
1921
+ canvas.removeEventListener("pointermove", onMove);
1922
+ canvas.removeEventListener("pointerdown", onMove);
1923
+ canvas.removeEventListener("pointerleave", onLeave);
1924
+ onLeave();
1925
+ };
1926
+ }
1927
+
1806
1928
  // src/core/timelineChart.ts
1807
1929
  var GROUP_MIN = 4;
1808
1930
  var MAX_KEYS = 200;
@@ -2857,6 +2979,14 @@ var Movie = class {
2857
2979
  await this._goto(frame);
2858
2980
  this.emit("seeked", { frame: this.currentFrame, totalFrames: this.totalFrames });
2859
2981
  }
2982
+ /**
2983
+ * Draw the frame on screen again, quietly (no `seeking` / `seeked`). For a paused movie when something outside it that a layer reads has changed: a `three` layer whose `update` reads the page's own
2984
+ * state (a dragged object's place) shows it after `await movie.redraw()`. A playing movie needs no call: the next frame draws it.
2985
+ */
2986
+ async redraw() {
2987
+ this._requireReady("redraw");
2988
+ await this._quietly(() => this.gotoFrame(this.currentFrame, true));
2989
+ }
2860
2990
  /** Run `fn` with `seeking` / `seeked` silenced: the movie is moving its own playhead, not answering a seek. */
2861
2991
  async _quietly(fn) {
2862
2992
  this._quiet++;
@@ -3070,11 +3200,23 @@ var Movie = class {
3070
3200
  }
3071
3201
  /** Every layer under the canvas point, the one on top first (see `pick`). */
3072
3202
  pickAll(x, y, opts = {}) {
3073
- warnUnknownOptions("movie.pick()", opts, ["only", "ignore"]);
3203
+ warnUnknownOptions("movie.pick()", opts, ["only", "ignore", "alpha"]);
3074
3204
  this._requireReady("pick");
3075
3205
  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
3206
  return pickScene(this._rootSequence, x, y, opts);
3077
3207
  }
3208
+ /**
3209
+ * Which layer the pointer is over, as callbacks: `onEnter(hit)` when the layer (or, in a `three` layer, the object) under the pointer changes to another, `onLeave(hit)` for the one it
3210
+ * left (also when the pointer leaves the picture). While the pointer rests inside, it is asked again on every frame, so a picture that moves under a still pointer is followed.
3211
+ * `{ only, ignore }` as for `pick`; `cursor: true` (or a CSS cursor) shows it while something is hovered. Returns the function that stops it. A page-side tool: an exported video has no pointer.
3212
+ */
3213
+ hover(opts = {}) {
3214
+ warnUnknownOptions("movie.hover()", opts, ["onEnter", "onLeave", "cursor", "only", "ignore"]);
3215
+ this._requireReady("hover");
3216
+ const canvas = this.app?.canvas;
3217
+ if (!canvas) throw new Error("pixi-effects: movie.hover needs the movie's canvas");
3218
+ return startHover({ canvas, pick: (x, y, o) => this.pick(x, y, o), point: (e) => this.canvasPoint(e) }, opts);
3219
+ }
3078
3220
  /** 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
3221
  canvasPoint(event) {
3080
3222
  this._requireReady("canvasPoint");
@@ -4582,5 +4724,5 @@ function withFade(spec, opts) {
4582
4724
  }
4583
4725
 
4584
4726
  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 };
4585
- //# sourceMappingURL=chunk-Y2N6U3X5.js.map
4586
- //# sourceMappingURL=chunk-Y2N6U3X5.js.map
4727
+ //# sourceMappingURL=chunk-NFJKBWYO.js.map
4728
+ //# sourceMappingURL=chunk-NFJKBWYO.js.map