@docyrus/animaguru 0.6.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/NOTICE.md +256 -0
- package/README.md +241 -0
- package/dist/animaguru.js +27338 -0
- package/package.json +37 -0
- package/skills/animaguru/SKILL.md +115 -0
- package/skills/animaguru-advertising/SKILL.md +25 -0
- package/skills/animaguru-advertising/references/brand-bumper.md +11 -0
- package/skills/animaguru-advertising/references/comparison.md +11 -0
- package/skills/animaguru-advertising/references/creator-testimonial.md +11 -0
- package/skills/animaguru-advertising/references/editorial-advertorial.md +11 -0
- package/skills/animaguru-advertising/references/game-reward.md +11 -0
- package/skills/animaguru-advertising/references/offer-promotion.md +11 -0
- package/skills/animaguru-advertising/references/product-launch.md +11 -0
- package/skills/animaguru-advertising/references/product-proof.md +11 -0
- package/skills/animaguru-analog-film-tape/SKILL.md +29 -0
- package/skills/animaguru-analog-film-tape/references/recipe.md +23 -0
- package/skills/animaguru-animated-data-visualization/SKILL.md +39 -0
- package/skills/animaguru-animated-data-visualization/references/data-contract.md +16 -0
- package/skills/animaguru-animated-data-visualization/references/variants.md +17 -0
- package/skills/animaguru-art-deco-motion/SKILL.md +29 -0
- package/skills/animaguru-art-deco-motion/references/recipe.md +22 -0
- package/skills/animaguru-ascii-crt/SKILL.md +29 -0
- package/skills/animaguru-ascii-crt/references/recipe.md +22 -0
- package/skills/animaguru-blueprint-drafting/SKILL.md +29 -0
- package/skills/animaguru-blueprint-drafting/references/recipe.md +22 -0
- package/skills/animaguru-cartoon-character-animation/SKILL.md +35 -0
- package/skills/animaguru-cartoon-character-animation/references/variants.md +17 -0
- package/skills/animaguru-cutout-animation/SKILL.md +33 -0
- package/skills/animaguru-cutout-animation/references/production-recipe.md +37 -0
- package/skills/animaguru-cutout-animation/references/variants.md +17 -0
- package/skills/animaguru-cutout-animation/references/visual-style.md +34 -0
- package/skills/animaguru-dark-tech-stage/SKILL.md +29 -0
- package/skills/animaguru-dark-tech-stage/references/recipe.md +23 -0
- package/skills/animaguru-diagram-formula-motion/SKILL.md +36 -0
- package/skills/animaguru-diagram-formula-motion/references/variants.md +17 -0
- package/skills/animaguru-engraved-relief-print/SKILL.md +29 -0
- package/skills/animaguru-engraved-relief-print/references/recipe.md +24 -0
- package/skills/animaguru-flat-vector-motion/SKILL.md +35 -0
- package/skills/animaguru-flat-vector-motion/references/variants.md +17 -0
- package/skills/animaguru-general-video/SKILL.md +20 -0
- package/skills/animaguru-general-video/references/ambient-loop.md +11 -0
- package/skills/animaguru-general-video/references/music-lyrics.md +11 -0
- package/skills/animaguru-general-video/references/short-film.md +11 -0
- package/skills/animaguru-general-video/references/titles-event.md +11 -0
- package/skills/animaguru-general-video/references/visual-essay.md +11 -0
- package/skills/animaguru-generative-light-signal/SKILL.md +29 -0
- package/skills/animaguru-generative-light-signal/references/recipe.md +23 -0
- package/skills/animaguru-glass-mosaic/SKILL.md +29 -0
- package/skills/animaguru-glass-mosaic/references/recipe.md +23 -0
- package/skills/animaguru-halftone-editorial/SKILL.md +29 -0
- package/skills/animaguru-halftone-editorial/references/recipe.md +23 -0
- package/skills/animaguru-holographic-scan/SKILL.md +29 -0
- package/skills/animaguru-holographic-scan/references/recipe.md +22 -0
- package/skills/animaguru-interface-motion/SKILL.md +36 -0
- package/skills/animaguru-interface-motion/references/screen-mapping.md +16 -0
- package/skills/animaguru-interface-motion/references/variants.md +17 -0
- package/skills/animaguru-isometric-worlds/SKILL.md +35 -0
- package/skills/animaguru-isometric-worlds/references/variants.md +17 -0
- package/skills/animaguru-kinetic-typography/SKILL.md +35 -0
- package/skills/animaguru-kinetic-typography/references/variants.md +17 -0
- package/skills/animaguru-miniature-diorama/SKILL.md +29 -0
- package/skills/animaguru-miniature-diorama/references/recipe.md +23 -0
- package/skills/animaguru-painterly-depth-animation/SKILL.md +35 -0
- package/skills/animaguru-painterly-depth-animation/references/variants.md +17 -0
- package/skills/animaguru-paper-popup/SKILL.md +29 -0
- package/skills/animaguru-paper-popup/references/recipe.md +22 -0
- package/skills/animaguru-photo-footage-editorial/SKILL.md +29 -0
- package/skills/animaguru-photo-footage-editorial/references/recipe.md +23 -0
- package/skills/animaguru-pixel-art-animation/SKILL.md +36 -0
- package/skills/animaguru-pixel-art-animation/references/variants.md +17 -0
- package/skills/animaguru-portal-zoom/SKILL.md +29 -0
- package/skills/animaguru-portal-zoom/references/recipe.md +21 -0
- package/skills/animaguru-risograph-print/SKILL.md +29 -0
- package/skills/animaguru-risograph-print/references/recipe.md +23 -0
- package/skills/animaguru-sand-drawing/SKILL.md +29 -0
- package/skills/animaguru-sand-drawing/references/recipe.md +21 -0
- package/skills/animaguru-shadow-theatre/SKILL.md +29 -0
- package/skills/animaguru-shadow-theatre/references/recipe.md +23 -0
- package/skills/animaguru-silkscreen-poster/SKILL.md +29 -0
- package/skills/animaguru-silkscreen-poster/references/recipe.md +22 -0
- package/skills/animaguru-stop-motion-objects/SKILL.md +29 -0
- package/skills/animaguru-stop-motion-objects/references/recipe.md +23 -0
- package/skills/animaguru-studio-product-reveal/SKILL.md +29 -0
- package/skills/animaguru-studio-product-reveal/references/recipe.md +23 -0
- package/skills/animaguru-video/SKILL.md +79 -0
- package/skills/animaguru-whiteboard-line-drawing/SKILL.md +34 -0
- package/skills/animaguru-whiteboard-line-drawing/references/variants.md +17 -0
- package/templates/video/AGENTS.md +34 -0
- package/templates/video/CLAUDE.md +19 -0
- package/templates/video/README.md +101 -0
- package/templates/video/VIDEO-STYLE-NOTICES.txt +54 -0
- package/templates/video/film.config.json +10 -0
- package/templates/video/gitignore +11 -0
- package/templates/video/index.html +14 -0
- package/templates/video/package.json +28 -0
- package/templates/video/public/brand/logo-mark.svg +5 -0
- package/templates/video/scripts/build.mjs +12 -0
- package/templates/video/scripts/export-html.mjs +12 -0
- package/templates/video/scripts/export-mp4.mjs +209 -0
- package/templates/video/scripts/html-export-plugin.mjs +35 -0
- package/templates/video/scripts/html-export.mjs +54 -0
- package/templates/video/scripts/install-example.mjs +32 -0
- package/templates/video/scripts/review-analysis.mjs +29 -0
- package/templates/video/scripts/review-audio.mjs +24 -0
- package/templates/video/scripts/review.mjs +37 -0
- package/templates/video/scripts/starter-film.sha256 +1 -0
- package/templates/video/shared/locales/en/export.json +10 -0
- package/templates/video/shared/locales/en/film.json +42 -0
- package/templates/video/shared/locales/en/player.json +31 -0
- package/templates/video/shared/locales/en/style-studies.json +168 -0
- package/templates/video/shared/locales/en/timeline.json +33 -0
- package/templates/video/src/assets.ts +4 -0
- package/templates/video/src/download.ts +27 -0
- package/templates/video/src/exporter.ts +70 -0
- package/templates/video/src/film-resources.ts +29 -0
- package/templates/video/src/film.ts +132 -0
- package/templates/video/src/main.ts +219 -0
- package/templates/video/src/resource-timeline.ts +193 -0
- package/templates/video/src/review.ts +50 -0
- package/templates/video/src/studies/film.ts +26 -0
- package/templates/video/src/studies/media.ts +46 -0
- package/templates/video/src/studies/model.ts +60 -0
- package/templates/video/src/studies/pixi-renderer.ts +121 -0
- package/templates/video/src/studies/scenes.ts +410 -0
- package/templates/video/src/studies/timing.ts +53 -0
- package/templates/video/src/studies/variants.ts +39 -0
- package/templates/video/src/style.css +111 -0
- package/templates/video/src/timeline-model.ts +55 -0
- package/templates/video/style-source-provenance.json +11 -0
- package/templates/video/tsconfig.json +15 -0
- package/templates/video/vite.config.mjs +9 -0
- package/vendor/pixijs-skills/LICENSE +21 -0
- package/vendor/pixijs-skills/provenance.json +79 -0
- package/vendor/pixijs-skills/skills/pixijs/SKILL.md +66 -0
- package/vendor/pixijs-skills/skills/pixijs/references/index.md +136 -0
- package/vendor/pixijs-skills/skills/pixijs-accessibility/SKILL.md +224 -0
- package/vendor/pixijs-skills/skills/pixijs-application/SKILL.md +293 -0
- package/vendor/pixijs-skills/skills/pixijs-application/references/application-options.md +314 -0
- package/vendor/pixijs-skills/skills/pixijs-assets/SKILL.md +303 -0
- package/vendor/pixijs-skills/skills/pixijs-assets/references/background.md +137 -0
- package/vendor/pixijs-skills/skills/pixijs-assets/references/bundles.md +122 -0
- package/vendor/pixijs-skills/skills/pixijs-assets/references/caching.md +143 -0
- package/vendor/pixijs-skills/skills/pixijs-assets/references/compressed-textures.md +120 -0
- package/vendor/pixijs-skills/skills/pixijs-assets/references/fonts.md +205 -0
- package/vendor/pixijs-skills/skills/pixijs-assets/references/gif.md +171 -0
- package/vendor/pixijs-skills/skills/pixijs-assets/references/manifests.md +175 -0
- package/vendor/pixijs-skills/skills/pixijs-assets/references/progress.md +142 -0
- package/vendor/pixijs-skills/skills/pixijs-assets/references/resolution.md +142 -0
- package/vendor/pixijs-skills/skills/pixijs-assets/references/spritesheet.md +119 -0
- package/vendor/pixijs-skills/skills/pixijs-assets/references/svg.md +132 -0
- package/vendor/pixijs-skills/skills/pixijs-assets/references/video.md +158 -0
- package/vendor/pixijs-skills/skills/pixijs-blend-modes/SKILL.md +215 -0
- package/vendor/pixijs-skills/skills/pixijs-color/SKILL.md +299 -0
- package/vendor/pixijs-skills/skills/pixijs-core-concepts/SKILL.md +132 -0
- package/vendor/pixijs-skills/skills/pixijs-core-concepts/references/render-loop.md +216 -0
- package/vendor/pixijs-skills/skills/pixijs-core-concepts/references/renderers.md +287 -0
- package/vendor/pixijs-skills/skills/pixijs-create/SKILL.md +276 -0
- package/vendor/pixijs-skills/skills/pixijs-custom-rendering/SKILL.md +405 -0
- package/vendor/pixijs-skills/skills/pixijs-custom-rendering/references/advanced-gpu.md +244 -0
- package/vendor/pixijs-skills/skills/pixijs-custom-rendering/references/uniform-types.md +94 -0
- package/vendor/pixijs-skills/skills/pixijs-environments/SKILL.md +243 -0
- package/vendor/pixijs-skills/skills/pixijs-events/SKILL.md +387 -0
- package/vendor/pixijs-skills/skills/pixijs-filters/SKILL.md +300 -0
- package/vendor/pixijs-skills/skills/pixijs-html-source/SKILL.md +228 -0
- package/vendor/pixijs-skills/skills/pixijs-math/SKILL.md +489 -0
- package/vendor/pixijs-skills/skills/pixijs-migration-v8/SKILL.md +415 -0
- package/vendor/pixijs-skills/skills/pixijs-performance/SKILL.md +489 -0
- package/vendor/pixijs-skills/skills/pixijs-scene-container/SKILL.md +345 -0
- package/vendor/pixijs-skills/skills/pixijs-scene-core-concepts/SKILL.md +243 -0
- package/vendor/pixijs-skills/skills/pixijs-scene-core-concepts/references/constructor-options.md +155 -0
- package/vendor/pixijs-skills/skills/pixijs-scene-core-concepts/references/container-hierarchy.md +232 -0
- package/vendor/pixijs-skills/skills/pixijs-scene-core-concepts/references/layers.md +145 -0
- package/vendor/pixijs-skills/skills/pixijs-scene-core-concepts/references/masking.md +129 -0
- package/vendor/pixijs-skills/skills/pixijs-scene-core-concepts/references/render-groups.md +140 -0
- package/vendor/pixijs-skills/skills/pixijs-scene-core-concepts/references/scene-management.md +169 -0
- package/vendor/pixijs-skills/skills/pixijs-scene-core-concepts/references/transforms.md +198 -0
- package/vendor/pixijs-skills/skills/pixijs-scene-dom-container/SKILL.md +193 -0
- package/vendor/pixijs-skills/skills/pixijs-scene-gif/SKILL.md +233 -0
- package/vendor/pixijs-skills/skills/pixijs-scene-graphics/SKILL.md +576 -0
- package/vendor/pixijs-skills/skills/pixijs-scene-mesh/SKILL.md +141 -0
- package/vendor/pixijs-skills/skills/pixijs-scene-mesh/references/mesh-perspective.md +189 -0
- package/vendor/pixijs-skills/skills/pixijs-scene-mesh/references/mesh-plane.md +159 -0
- package/vendor/pixijs-skills/skills/pixijs-scene-mesh/references/mesh-rope.md +176 -0
- package/vendor/pixijs-skills/skills/pixijs-scene-mesh/references/mesh-simple.md +144 -0
- package/vendor/pixijs-skills/skills/pixijs-scene-mesh/references/mesh.md +213 -0
- package/vendor/pixijs-skills/skills/pixijs-scene-particle-container/SKILL.md +323 -0
- package/vendor/pixijs-skills/skills/pixijs-scene-sprite/SKILL.md +120 -0
- package/vendor/pixijs-skills/skills/pixijs-scene-sprite/references/animated-sprite.md +262 -0
- package/vendor/pixijs-skills/skills/pixijs-scene-sprite/references/nineslice-sprite.md +202 -0
- package/vendor/pixijs-skills/skills/pixijs-scene-sprite/references/sprite.md +181 -0
- package/vendor/pixijs-skills/skills/pixijs-scene-sprite/references/tiling-sprite.md +216 -0
- package/vendor/pixijs-skills/skills/pixijs-scene-text/SKILL.md +136 -0
- package/vendor/pixijs-skills/skills/pixijs-scene-text/references/bitmap-text.md +232 -0
- package/vendor/pixijs-skills/skills/pixijs-scene-text/references/html-text.md +192 -0
- package/vendor/pixijs-skills/skills/pixijs-scene-text/references/split-bitmap-text.md +187 -0
- package/vendor/pixijs-skills/skills/pixijs-scene-text/references/split-text.md +168 -0
- package/vendor/pixijs-skills/skills/pixijs-scene-text/references/text.md +311 -0
- package/vendor/pixijs-skills/skills/pixijs-ticker/SKILL.md +292 -0
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: pixijs-scene-dom-container
|
|
3
|
+
description: "Use this skill when overlaying HTML elements on the PixiJS v8 canvas. Covers DOMContainer with element, anchor, and scene-graph-driven CSS transforms, the pixi.js/dom side-effect import, DOMPipe registration, visibility sync, pointer-events handling. Triggers on: DOMContainer, pixi.js/dom, DOMPipe, HTML overlay, input on canvas, iframe overlay, DOMContainerOptions, element, anchor, constructor options."
|
|
4
|
+
license: MIT
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
`DOMContainer` positions an HTML element over the PixiJS canvas and drives its CSS transform from the scene graph. Use it for native inputs, iframes, videos, or rich HTML that needs to follow a display object's position. The default `pixi.js` browser bundle registers the `DOMPipe` automatically; custom builds add a side-effect `import 'pixi.js/dom'`.
|
|
8
|
+
|
|
9
|
+
> `DOMContainer` is marked EXPERIMENTAL in PixiJS v8. The API may change between minor releases.
|
|
10
|
+
|
|
11
|
+
Assumes familiarity with `pixijs-scene-core-concepts`. `DOMContainer` extends `ViewContainer`, so it's a leaf: do not nest PixiJS children inside it. Nest DOM content inside the HTML element itself, or wrap multiple `DOMContainer` instances in a `Container`. Not available in Web Workers; a worker has no DOM to overlay.
|
|
12
|
+
|
|
13
|
+
## Quick Start
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import "pixi.js/dom";
|
|
17
|
+
|
|
18
|
+
const input = document.createElement("input");
|
|
19
|
+
input.type = "text";
|
|
20
|
+
input.placeholder = "Enter name...";
|
|
21
|
+
|
|
22
|
+
const dom = new DOMContainer({
|
|
23
|
+
element: input,
|
|
24
|
+
anchor: 0.5,
|
|
25
|
+
});
|
|
26
|
+
dom.position.set(app.screen.width / 2, app.screen.height / 2);
|
|
27
|
+
|
|
28
|
+
app.stage.addChild(dom);
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
**Related skills:** `pixijs-scene-core-concepts` (scene graph basics), `pixijs-scene-container` (wrap multiple DOM overlays), `pixijs-events` (pointer handling on canvas vs DOM), `pixijs-accessibility` (screen-reader overlays).
|
|
32
|
+
|
|
33
|
+
## Constructor options
|
|
34
|
+
|
|
35
|
+
All `Container` options (`position`, `scale`, `tint`, `label`, `filters`, `zIndex`, etc.) are also valid here — see `skills/pixijs-scene-core-concepts/references/constructor-options.md`.
|
|
36
|
+
|
|
37
|
+
Leaf-specific options added by `DOMContainerOptions`:
|
|
38
|
+
|
|
39
|
+
| Option | Type | Default | Description |
|
|
40
|
+
| --------- | --------------------- | ------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
41
|
+
| `element` | `HTMLElement` | `document.createElement('div')` | The HTML element the container drives. Any element is valid: `input`, `textarea`, `iframe`, `video`, `div`, etc. If omitted, a bare `<div>` is created. |
|
|
42
|
+
| `anchor` | `PointData \| number` | `0` | Origin of the element relative to its own dimensions. `0` is top-left, `0.5` centers, `1` is bottom-right. A single number sets both axes; `{ x, y }` sets each independently. |
|
|
43
|
+
|
|
44
|
+
`tint`, `filters`, `mask`, and `blendMode` are accepted (inherited from `Container`) but have no visual effect — DOM elements live outside the WebGL/WebGPU pipeline. Style the element via CSS for those effects.
|
|
45
|
+
|
|
46
|
+
## Core Patterns
|
|
47
|
+
|
|
48
|
+
### Setup and the side-effect import
|
|
49
|
+
|
|
50
|
+
```ts
|
|
51
|
+
import "pixi.js/dom";
|
|
52
|
+
import { DOMContainer } from "pixi.js";
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Or use the combined import that registers the pipe and re-exports the class:
|
|
56
|
+
|
|
57
|
+
```ts
|
|
58
|
+
import { DOMContainer } from "pixi.js/dom";
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
The default `pixi.js` browser bundle already imports `pixi.js/dom` for you via `browserAll.ts`, so `DOMContainer` works out of the box in a typical browser app. You only need the explicit `import 'pixi.js/dom'` line when you set `skipExtensionImports: true` (custom builds) or when running under a non-browser bundle.
|
|
62
|
+
|
|
63
|
+
### Transforms, anchor, and alpha
|
|
64
|
+
|
|
65
|
+
```ts
|
|
66
|
+
const dom = new DOMContainer({
|
|
67
|
+
element: document.createElement("div"),
|
|
68
|
+
anchor: 0.5,
|
|
69
|
+
});
|
|
70
|
+
dom.position.set(400, 300);
|
|
71
|
+
dom.scale.set(1.5);
|
|
72
|
+
dom.rotation = Math.PI / 8;
|
|
73
|
+
dom.alpha = 0.5;
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Transforms on the `DOMContainer` propagate to the element as CSS `transform`. `anchor` shifts the element's origin relative to its own dimensions: `0` is top-left, `0.5` centers, `1` is bottom-right. A single number sets both axes; an object `{ x, y }` sets each independently. `alpha` (including inherited parent alpha) is written to the element's `style.opacity` every frame.
|
|
77
|
+
|
|
78
|
+
If no `element` is provided, a `<div>` is created by default.
|
|
79
|
+
|
|
80
|
+
### Styling the element directly
|
|
81
|
+
|
|
82
|
+
```ts
|
|
83
|
+
const panel = document.createElement("div");
|
|
84
|
+
panel.innerHTML = "<h2>Score</h2><p>1500</p>";
|
|
85
|
+
panel.style.color = "white";
|
|
86
|
+
panel.style.fontFamily = "Arial";
|
|
87
|
+
panel.style.pointerEvents = "none";
|
|
88
|
+
|
|
89
|
+
const dom = new DOMContainer({ element: panel });
|
|
90
|
+
dom.position.set(50, 50);
|
|
91
|
+
app.stage.addChild(dom);
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
PixiJS does not interfere with CSS styling on the element. The shared root `<div>` is set to `pointer-events: none`, and each attached element defaults to `pointer-events: auto`. Override to `none` on purely decorative overlays so the canvas still receives clicks underneath them.
|
|
95
|
+
|
|
96
|
+
### Visibility and cleanup
|
|
97
|
+
|
|
98
|
+
```ts
|
|
99
|
+
dom.visible = false;
|
|
100
|
+
dom.visible = true;
|
|
101
|
+
|
|
102
|
+
dom.destroy();
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
Setting `visible = false` or removing the `DOMContainer` from the scene graph detaches the element from the DOM. Restoring visibility re-attaches it. `destroy()` removes the element from its parent node and nulls internal references; the HTML element itself is preserved, so you can re-attach it elsewhere:
|
|
106
|
+
|
|
107
|
+
```ts
|
|
108
|
+
const element = dom.element;
|
|
109
|
+
dom.destroy();
|
|
110
|
+
document.body.appendChild(element);
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### The DOM container root
|
|
114
|
+
|
|
115
|
+
The DOMPipe uses a shared root `<div>` with `z-index: 1000` that hosts every attached element. It's exposed as `app.domContainerRoot` (an `HTMLDivElement`). All `DOMContainer` elements render above canvas content; you can't interleave DOM elements between PixiJS draw calls.
|
|
116
|
+
|
|
117
|
+
On the first render that has an attached `DOMContainer`, the pipe automatically appends the root to the canvas's parent node. Append it yourself next to `app.canvas` if you need explicit, stable placement in the DOM tree (for example, when the canvas shares a wrapper with other layered content):
|
|
118
|
+
|
|
119
|
+
```ts
|
|
120
|
+
document.body.appendChild(app.canvas);
|
|
121
|
+
document.body.appendChild(app.domContainerRoot);
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
The root uses absolute positioning and its transform is recomputed from the canvas `getBoundingClientRect()` via a `ResizeObserver`, so CSS-scaled canvases stay aligned without extra work.
|
|
125
|
+
|
|
126
|
+
## Common Mistakes
|
|
127
|
+
|
|
128
|
+
### [MEDIUM] Missing the pixi.js/dom import in custom builds
|
|
129
|
+
|
|
130
|
+
The default browser bundle auto-registers `DOMPipe`, so most apps do not need an explicit import. It is only required when you opt out of auto-imports:
|
|
131
|
+
|
|
132
|
+
```ts
|
|
133
|
+
await app.init({ skipExtensionImports: true });
|
|
134
|
+
// Now you must add this yourself:
|
|
135
|
+
import "pixi.js/dom";
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
Without registration under a custom build, `DOMContainer` is still importable but the renderer has no pipe to process it; elements never synchronize with the scene graph and never appear.
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
### [MEDIUM] Expecting filters, masks, or blend modes to affect DOM elements
|
|
142
|
+
|
|
143
|
+
Wrong:
|
|
144
|
+
|
|
145
|
+
```ts
|
|
146
|
+
const dom = new DOMContainer();
|
|
147
|
+
dom.filters = [new BlurFilter()];
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
Correct:
|
|
151
|
+
|
|
152
|
+
```ts
|
|
153
|
+
dom.element.style.filter = "blur(4px)";
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
DOM elements are HTML overlays positioned via CSS transforms; they exist outside the WebGL/WebGPU pipeline. PixiJS filters, masks, and blend modes have no effect on them. Use CSS filters and CSS `mix-blend-mode` on the element directly.
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
### [MEDIUM] Do not nest children inside a DOMContainer
|
|
160
|
+
|
|
161
|
+
Wrong:
|
|
162
|
+
|
|
163
|
+
```ts
|
|
164
|
+
const dom = new DOMContainer();
|
|
165
|
+
dom.addChild(new Sprite(texture));
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
Correct:
|
|
169
|
+
|
|
170
|
+
```ts
|
|
171
|
+
const group = new Container();
|
|
172
|
+
group.addChild(dom, new Sprite(texture));
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
`DOMContainer` extends `ViewContainer`, which sets `allowChildren = false`. It is a leaf in the PixiJS scene graph. For PixiJS children, wrap the `DOMContainer` alongside them in a plain `Container`. For nested HTML, nest inside the element itself (`element.appendChild(...)`).
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
### [LOW] Forgetting to set anchor for centered positioning
|
|
179
|
+
|
|
180
|
+
The default anchor is `(0, 0)`, placing the element's top-left corner at the container's position. For centering a UI element on its scene-graph position, set `anchor: 0.5`:
|
|
181
|
+
|
|
182
|
+
```ts
|
|
183
|
+
const dom = new DOMContainer({ element: myElement, anchor: 0.5 });
|
|
184
|
+
dom.position.set(400, 300);
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
## API Reference
|
|
189
|
+
|
|
190
|
+
- [DOMContainer](https://pixijs.download/release/docs/scene.DOMContainer.html.md)
|
|
191
|
+
- [DOMContainerOptions](https://pixijs.download/release/docs/scene.DOMContainerOptions.html.md)
|
|
192
|
+
- [ViewContainer](https://pixijs.download/release/docs/scene.ViewContainer.html.md)
|
|
193
|
+
- [Container](https://pixijs.download/release/docs/scene.Container.html.md)
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: pixijs-scene-gif
|
|
3
|
+
description: "Use this skill when displaying animated GIFs in PixiJS v8. Covers the pixi.js/gif side-effect import, Assets.load returning a GifSource, GifSprite playback (play/stop/currentFrame/animationSpeed), autoPlay/loop options, onComplete/onLoop/onFrameChange callbacks, GifSource sharing, clone, destroy. Triggers on: GifSprite, GifSource, pixi.js/gif, animationSpeed, currentFrame, autoPlay, onComplete, onFrameChange, constructor options, GifSpriteOptions."
|
|
4
|
+
license: MIT
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
`GifSprite` plays an animated GIF as a display object. `Assets.load('animation.gif')` returns a `GifSource` (not a `Texture`), and you wrap that in a `GifSprite`. Requires a side-effect `import 'pixi.js/gif'` to register the loader extension.
|
|
8
|
+
|
|
9
|
+
Assumes familiarity with `pixijs-scene-core-concepts`. `GifSprite` extends `Sprite`, so it is a leaf: do not nest children inside it. Wrap multiple `GifSprite` instances in a `Container` to group them.
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import "pixi.js/gif";
|
|
15
|
+
import { GifSprite } from "pixi.js/gif";
|
|
16
|
+
|
|
17
|
+
const source = await Assets.load("animation.gif");
|
|
18
|
+
|
|
19
|
+
const gif = new GifSprite({
|
|
20
|
+
source,
|
|
21
|
+
autoPlay: true,
|
|
22
|
+
loop: true,
|
|
23
|
+
animationSpeed: 1,
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
gif.anchor.set(0.5);
|
|
27
|
+
gif.x = app.screen.width / 2;
|
|
28
|
+
gif.y = app.screen.height / 2;
|
|
29
|
+
|
|
30
|
+
app.stage.addChild(gif);
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
> [!NOTE]
|
|
34
|
+
> GIFs decode every frame into a separate canvas texture. For performance-critical animations with many frames, prefer a spritesheet with `AnimatedSprite` — it uses a single atlas texture and batches better on the GPU.
|
|
35
|
+
|
|
36
|
+
**Related skills:** `pixijs-scene-core-concepts` (scene graph basics), `pixijs-scene-sprite` (`AnimatedSprite` for spritesheet-based animation), `pixijs-assets` (`Assets.load`, caching, unloading), `pixijs-ticker` (frame timing), `pixijs-performance` (texture memory).
|
|
37
|
+
|
|
38
|
+
## Constructor options
|
|
39
|
+
|
|
40
|
+
`GifSpriteOptions` extends `Omit<SpriteOptions, 'texture'>`; `texture` is managed internally (set from `source.textures[0]` and swapped per frame). All other `Sprite` options (`anchor`, `scale`, `tint`, `roundPixels`, etc.) are valid, and all `Container` options (`position`, `scale`, `tint`, `label`, `filters`, `zIndex`, etc.) are also valid here — see `skills/pixijs-scene-core-concepts/references/constructor-options.md`.
|
|
41
|
+
|
|
42
|
+
Leaf-specific options added by `GifSpriteOptions`:
|
|
43
|
+
|
|
44
|
+
| Option | Type | Default | Description |
|
|
45
|
+
| ---------------- | --------------------------------- | ---------- | -------------------------------------------------------------------------------------------------------------------------- |
|
|
46
|
+
| `source` | `GifSource` | — | Required. The parsed GIF data returned by `Assets.load('file.gif')`. Can be shared across multiple `GifSprite` instances. |
|
|
47
|
+
| `autoPlay` | `boolean` | `true` | Start playback immediately on construction. If `false`, you must call `gif.play()` to begin. |
|
|
48
|
+
| `loop` | `boolean` | `true` | Repeat the animation on reaching the last frame. When `false`, the sprite stops at the final frame and fires `onComplete`. |
|
|
49
|
+
| `animationSpeed` | `number` | `1` | Multiplier on the GIF's native frame timing. `2` runs at double speed; `0.5` runs at half. |
|
|
50
|
+
| `autoUpdate` | `boolean` | `true` | Connect playback to `Ticker.shared`. Set to `false` to drive updates yourself via `gif.update(ticker)`. |
|
|
51
|
+
| `fps` | `number` | `30` | Fallback frame rate for GIFs that do not specify per-frame delays. |
|
|
52
|
+
| `onComplete` | `() => void \| null` | `null` | Called when a non-looping animation reaches the last frame. |
|
|
53
|
+
| `onLoop` | `() => void \| null` | `null` | Called each time a looping animation wraps around. |
|
|
54
|
+
| `onFrameChange` | `(frame: number) => void \| null` | `null` | Called every time the displayed frame index changes. |
|
|
55
|
+
| `scaleMode` | `SCALE_MODE` | `'linear'` | Deprecated since 8.13.0 — pass `scaleMode` via `Assets.load(..., { data: { scaleMode } })` instead. |
|
|
56
|
+
|
|
57
|
+
The constructor also accepts a bare `GifSource` as its sole argument (`new GifSprite(source)`), which is shorthand for `new GifSprite({ source })` using the defaults above.
|
|
58
|
+
|
|
59
|
+
## Core Patterns
|
|
60
|
+
|
|
61
|
+
### Setup and the side-effect import
|
|
62
|
+
|
|
63
|
+
```ts
|
|
64
|
+
import "pixi.js/gif";
|
|
65
|
+
import { Assets } from "pixi.js";
|
|
66
|
+
import { GifSprite } from "pixi.js/gif";
|
|
67
|
+
|
|
68
|
+
const source = await Assets.load("animation.gif");
|
|
69
|
+
const gif = new GifSprite({ source });
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
`pixi.js/gif` calls `extensions.add(GifAsset)`, registering `.gif` with the asset loader. Without it, `Assets.load` does not recognize GIF files. `GifSprite` and `GifSource` are exported from `pixi.js/gif`, not `pixi.js`.
|
|
73
|
+
|
|
74
|
+
Importing a named export from `pixi.js/gif` also triggers the side effect, so a bare `import 'pixi.js/gif'` is only needed when you don't import anything from that path.
|
|
75
|
+
|
|
76
|
+
### Playback control
|
|
77
|
+
|
|
78
|
+
```ts
|
|
79
|
+
const gif = new GifSprite({ source });
|
|
80
|
+
|
|
81
|
+
gif.play();
|
|
82
|
+
gif.stop();
|
|
83
|
+
|
|
84
|
+
gif.currentFrame = 5;
|
|
85
|
+
gif.animationSpeed = 2;
|
|
86
|
+
gif.animationSpeed = 0.5;
|
|
87
|
+
|
|
88
|
+
gif.playing; // read-only
|
|
89
|
+
gif.progress; // 0-1 playback position
|
|
90
|
+
gif.totalFrames; // number of frames
|
|
91
|
+
gif.duration; // total duration in ms
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
`autoPlay: true` (default) starts playback immediately; `loop: true` (default) repeats. `animationSpeed` is a multiplier on the GIF's native frame timing. `currentFrame` is zero-based.
|
|
95
|
+
|
|
96
|
+
### Loading options
|
|
97
|
+
|
|
98
|
+
```ts
|
|
99
|
+
const source = await Assets.load({
|
|
100
|
+
src: "animation.gif",
|
|
101
|
+
data: {
|
|
102
|
+
fps: 12,
|
|
103
|
+
scaleMode: "nearest",
|
|
104
|
+
resolution: 2,
|
|
105
|
+
},
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
const fromDataUri = await Assets.load("data:image/gif;base64,R0lGODlh...");
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
Options in `data` are passed to `GifSource.from`. `fps` sets the fallback frame delay for GIFs that don't specify timing. `scaleMode` and `resolution` control the canvas textures created for each frame. The loader matches both `.gif` file extensions and `data:image/gif` URIs.
|
|
112
|
+
|
|
113
|
+
### Callbacks
|
|
114
|
+
|
|
115
|
+
```ts
|
|
116
|
+
const gif = new GifSprite({
|
|
117
|
+
source,
|
|
118
|
+
loop: false,
|
|
119
|
+
onComplete: () => console.log("animation finished"),
|
|
120
|
+
onLoop: () => console.log("loop completed"),
|
|
121
|
+
onFrameChange: (frame) => console.log("now on frame", frame),
|
|
122
|
+
});
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
- `onComplete` fires when a non-looping animation reaches the last frame.
|
|
126
|
+
- `onLoop` fires each time a looping animation wraps around.
|
|
127
|
+
- `onFrameChange` fires every time the displayed frame changes.
|
|
128
|
+
|
|
129
|
+
### Manual update mode
|
|
130
|
+
|
|
131
|
+
```ts
|
|
132
|
+
const gif = new GifSprite({ source, autoUpdate: false });
|
|
133
|
+
|
|
134
|
+
app.ticker.add((ticker) => {
|
|
135
|
+
gif.update(ticker);
|
|
136
|
+
});
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
`autoUpdate: false` disconnects from `Ticker.shared`. You call `gif.update(ticker)` yourself, passing any `Ticker` instance. Useful when animation should be driven by a private ticker (e.g., a pause-aware game ticker).
|
|
140
|
+
|
|
141
|
+
### Sharing source data and cloning
|
|
142
|
+
|
|
143
|
+
```ts
|
|
144
|
+
const source = await Assets.load("animation.gif");
|
|
145
|
+
|
|
146
|
+
const gif1 = new GifSprite({ source, autoPlay: true });
|
|
147
|
+
const gif2 = new GifSprite({ source, autoPlay: false });
|
|
148
|
+
|
|
149
|
+
const gif3 = gif1.clone();
|
|
150
|
+
gif3.animationSpeed = 0.5;
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
`GifSource` can be shared across multiple `GifSprite` instances; each sprite has independent playback state. `clone()` copies all playback settings but creates an independent instance.
|
|
154
|
+
|
|
155
|
+
## Common Mistakes
|
|
156
|
+
|
|
157
|
+
### [HIGH] Not importing pixi.js/gif
|
|
158
|
+
|
|
159
|
+
Wrong:
|
|
160
|
+
|
|
161
|
+
```ts
|
|
162
|
+
import { Assets } from "pixi.js";
|
|
163
|
+
const gif = await Assets.load("animation.gif");
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
Correct:
|
|
167
|
+
|
|
168
|
+
```ts
|
|
169
|
+
import "pixi.js/gif";
|
|
170
|
+
import { Assets } from "pixi.js";
|
|
171
|
+
const source = await Assets.load("animation.gif");
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
The GIF loader extension must be registered before loading. Without the side-effect import, the loader does not recognize `.gif` files and the load either fails or returns raw data.
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
### [MEDIUM] Expecting Assets.load to return a Texture
|
|
178
|
+
|
|
179
|
+
Wrong:
|
|
180
|
+
|
|
181
|
+
```ts
|
|
182
|
+
const texture = await Assets.load("animation.gif");
|
|
183
|
+
const sprite = new Sprite(texture);
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
Correct:
|
|
187
|
+
|
|
188
|
+
```ts
|
|
189
|
+
const source = await Assets.load("animation.gif");
|
|
190
|
+
const gif = new GifSprite({ source });
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
`Assets.load` on a GIF returns a `GifSource` containing frame textures and timing data. Pass the source to `GifSprite`; for a single still frame, read `source.textures[0]`.
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
### [MEDIUM] GIF memory not released on destroy
|
|
197
|
+
|
|
198
|
+
Wrong:
|
|
199
|
+
|
|
200
|
+
```ts
|
|
201
|
+
gif.destroy();
|
|
202
|
+
// GifSource and frame textures remain in memory
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
Correct:
|
|
206
|
+
|
|
207
|
+
```ts
|
|
208
|
+
gif.destroy(true);
|
|
209
|
+
// or
|
|
210
|
+
await Assets.unload("animation.gif");
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
GIF frames hold decoded pixel data as individual canvas textures. `gif.destroy()` (or `destroy(false)`) destroys the sprite but keeps the `GifSource` intact. Pass `true` to also destroy the source. For shared sources, only destroy when the last consumer is done, or call `Assets.unload` to let the asset cache handle it.
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
### [LOW] Do not nest children inside a GifSprite
|
|
217
|
+
|
|
218
|
+
`GifSprite` extends `Sprite`, which sets `allowChildren = false`. It is a leaf. To group a GIF with other display objects, wrap them all in a plain `Container`:
|
|
219
|
+
|
|
220
|
+
```ts
|
|
221
|
+
const group = new Container();
|
|
222
|
+
group.addChild(gif, label);
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
## API Reference
|
|
227
|
+
|
|
228
|
+
- [GifSprite](https://pixijs.download/release/docs/gif.GifSprite.html.md)
|
|
229
|
+
- [GifSpriteOptions](https://pixijs.download/release/docs/gif.GifSpriteOptions.html.md)
|
|
230
|
+
- [GifSource](https://pixijs.download/release/docs/gif.GifSource.html.md)
|
|
231
|
+
- [GifAsset](https://pixijs.download/release/docs/gif.GifAsset.html.md)
|
|
232
|
+
- [GifBufferOptions](https://pixijs.download/release/docs/gif.GifBufferOptions.html.md)
|
|
233
|
+
- [GifFrame](https://pixijs.download/release/docs/gif.GifFrame.html.md)
|