К основному содержанию
скилл CX Codex

pixijs-scene-gif — скилл для Claude Code: что делает и как установить

Обучает агента загружать и воспроизводить анимации GIF в PixiJS v8 через GifSprite и GifSource. Пригодится при переносе гифок на сцену без ручной нарезки на спрайты.

Установить в Claude Code · Через Skills CLI (Vercel) Все способы и платформы ↓
npx skills add pixijs/pixijs-skills --skill pixijs-scene-gif -a claude-code
Открыть на GitHub

Что делает pixijs-scene-gif

Скилл содержит правила работы с расширением pixi.js/gif. Он напоминает агенту делать обязательный побочный импорт import 'pixi.js/gif', чтобы загрузчик Assets.load распознавал файлы .gif и возвращал объект GifSource, а не обычную текстуру.

Класс GifSprite расширяет Sprite и служит конечным узлом сцены, поэтому внутрь него нельзя вкладывать дочерние элементы. Для группировки нескольких объектов потребуется родительский Container. Конструктор поддерживает параметры autoPlay, loop, колбэки onComplete, onLoop и onFrameChange, а скорость воспроизведения настраивается множителем animationSpeed.

Формат GIF декодирует каждый кадр в отдельную текстуру canvas, поэтому для тяжёлых сцен с длинными анимациями это повод проверить переход на AnimatedSprite со спрайтшитом ради лучшего батчинга на GPU.

Какие задачи решает

  • загрузить анимированный GIF через Assets.load в PixiJS v8
  • управлять воспроизведением кадров и скоростью через GifSprite
  • настроить повторы и колбэки завершения анимации
  • передать параметры разрешения и scaleMode при чтении GIF

Примеры запросов агенту

  • Покажи, как загрузить animation.gif в PixiJS v8 и зациклить воспроизведение через GifSprite
  • Добавь обработчик onComplete для GifSprite и останови анимацию на пятом кадре

Как установить pixijs-scene-gif

1Через Skills CLI (Vercel)

npx skills add pixijs/pixijs-skills --skill pixijs-scene-gif -a claude-code

2Вручную: положить файлы

~/.claude/skills/pixijs-scene-gif/SKILL.md

Папка скилла целиком; для одного проекта — .claude/skills/pixijs-scene-gif/

По шагам, с командами для каждой платформы: Как установить скилл в Claude Code: пять способов

Из того же набора25

pixijs-scene-dom-container Подсказывает агенту, как накладывать HTML-элементы на canvas PixiJS v8 через DOMContainer и DOMPipe. Пригодится, когда нужны поля ввода, iframe или видео поверх сцены. CX Codex +1 5 700установок pixijs-blend-modes Скилл подсказывает агенту, как смешивать объекты PixiJS v8 через blendMode: стандартные режимы, продвинутые и порядок для батчинга. CX Codex +1 5 700установок pixijs-color Скилл по классу Color в PixiJS v8. Помогает переводить форматы цвета, настраивать tint и альфу, а также оптимизировать вызовы в циклах рендера через Color.shared и буферы. CX Codex +1 5 700установок pixijs-create Скилл ведёт агента через создание нового проекта PixiJS v8 или подключение библиотеки к уже существующему: шаблоны, пакетные менеджеры, настройка TypeScript. CX Codex +1 5 700установок pixijs-custom-rendering Помогает писать кастомные шейдеры, юниформы, фильтры и батчеры в PixiJS v8 — на GLSL и WGSL, под WebGL и WebGPU. CX Codex +1 5 700установок pixijs-accessibility Скилл настраивает поддержку скринридеров и навигацию с клавиатуры в PixiJS v8 через оверлей shadow DOM. CX Codex +1 5 500установок pixijs-migration-v8 Скилл проводит код PixiJS с v7 на v8 и ищет типичные поломки после обновления. Нужен при замене устаревших API и импортов. CX Codex +1 5 300установок pixijs-html-source Учит агента превращать живой DOM-элемент или его снимок в текстуру PixiJS v8 через экспериментальный HTML-in-Canvas. CX Codex +1 4 500установок

Похожие

pixijs-rendering gamedev-skills Скилл для сборки слоя рендера на PixiJS v8: асинхронный Application, загрузка текстур, сцена на Container, тикер и события указателя. CX Codex +1 5 400установок pixijs-2d freshtechbro Скилл обучает агента создавать 2D-графику на PixiJS с WebGL и WebGPU: анимировать спрайты, выводить частицы и рисовать векторные фигуры на холсте. CX Codex +1 2 500установок slack-gif-creator nexu-io Создаёт анимированные GIF для Slack и проверяет ограничения размера. Пригодится, когда агенту нужно подготовить реакцию или короткую анимацию. CX Codex +1 2 700установок gif-sticker-maker MiniMax-AI Скилл конвертирует фотографию в 4 анимированных GIF-стикера в стиле Funko Pop с подписями. Подойдёт, если нужны забавные стикеры с эмоциями, аватары или наборы для месседжеров. CX Codex +1 2 000установок threejs-scene-setup gamedev-skills Настраивает базовую сцену three.js и помогает найти причины пустого или чёрного canvas. Нужен при старте проекта, ресайзе, цикле рендеринга и OrbitControls. CX Codex +1 5 500установок video-to-gif zc277584121 Делает из видео несколько GIF с разными настройками и складывает их в одну папку, чтобы вы глазами выбрали подходящий. CX Codex +1 3 900установок

Рядом в теме «Фронтенд и UI»

Всё по теме «Фронтенд и UI» →

Вопросы о pixijs-scene-gif

Как установить pixijs-scene-gif в Claude Code?

Выполните в терминале команду npx skills add pixijs/pixijs-skills --skill pixijs-scene-gif -a claude-code.

Что делает скилл pixijs-scene-gif?

Он предоставляет ИИ-ассистенту шаблоны кода и спецификацию параметров для работы с модулем pixi.js/gif, включая загрузку GifSource и управление экземплярами GifSprite.

Почему для длинных анимаций советуют AnimatedSprite вместо GifSprite?

Каждый кадр GIF декодируется в отдельную текстуру canvas и расходует больше видеопамяти. AnimatedSprite использует единый атлас спрайтшита и эффективнее объединяет вызовы отрисовки.

Исходный текст

SKILL.md · MIT
---
name: pixijs-scene-gif
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."
license: MIT
---

`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.

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.

## Quick Start

```ts
import "pixi.js/gif";
import { GifSprite } from "pixi.js/gif";

const source = await Assets.load("animation.gif");

const gif = new GifSprite({
  source,
  autoPlay: true,
  loop: true,
  animationSpeed: 1,
});

gif.anchor.set(0.5);
gif.x = app.screen.width / 2;
gif.y = app.screen.height / 2;

app.stage.addChild(gif);
```

> [!NOTE]
> 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.

**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).

## Constructor options

`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`.

Leaf-specific options added by `GifSpriteOptions`:

| Option           | Type                              | Default    | Description                                                                                                                |
| ---------------- | --------------------------------- | ---------- | -------------------------------------------------------------------------------------------------------------------------- |
| `source`         | `GifSource`                       | —          | Required. The parsed GIF data returned by `Assets.load('file.gif')`. Can be shared across multiple `GifSprite` instances.  |
| `autoPlay`       | `boolean`                         | `true`     | Start playback immediately on construction. If `false`, you must call `gif.play()` to begin.                               |
| `loop`           | `boolean`                         | `true`     | Repeat the animation on reaching the last frame. When `false`, the sprite stops at the final frame and fires `onComplete`. |
| `animationSpeed` | `number`                          | `1`        | Multiplier on the GIF's native frame timing. `2` runs at double speed; `0.5` runs at half.                                 |
| `autoUpdate`     | `boolean`                         | `true`     | Connect playback to `Ticker.shared`. Set to `false` to drive updates yourself via `gif.update(ticker)`.                    |
| `fps`            | `number`                          | `30`       | Fallback frame rate for GIFs that do not specify per-frame delays.                                                         |
| `onComplete`     | `() => void \| null`              | `null`     | Called when a non-looping animation reaches the last frame.                                                                |
| `onLoop`         | `() => void \| null`              | `null`     | Called each time a looping animation wraps around.                                                                         |
| `onFrameChange`  | `(frame: number) => void \| null` | `null`     | Called every time the displayed frame index changes.                                                                       |
| `scaleMode`      | `SCALE_MODE`                      | `'linear'` | Deprecated since 8.13.0 — pass `scaleMode` via `Assets.load(..., { data: { scaleMode } })` instead.                        |

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.

## Core Patterns

### Setup and the side-effect import

```ts
import "pixi.js/gif";
import { Assets } from "pixi.js";
import { GifSprite } from "pixi.js/gif";

const source = await Assets.load("animation.gif");
const gif = new GifSprite({ source });
```

`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`.

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.

### Playback control

```ts
const gif = new GifSprite({ source });

gif.play();
gif.stop();

gif.currentFrame = 5;
gif.animationSpeed = 2;
gif.animationSpeed = 0.5;

gif.playing; // read-only
gif.progress; // 0-1 playback position
gif.totalFrames; // number of frames
gif.duration; // total duration in ms
```

`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.

### Loading options

```ts
const source = await Assets.load({
  src: "animation.gif",
  data: {
    fps: 12,
    scaleMode: "nearest",
    resolution: 2,
  },
});

const fromDataUri = await Assets.load("data:image/gif;base64,R0lGODlh...");
```

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.

### Callbacks

```ts
const gif = new GifSprite({
  source,
  loop: false,
  onComplete: () => console.log("animation finished"),
  onLoop: () => console.log("loop completed"),
  onFrameChange: (frame) => console.log("now on frame", frame),
});
```

- `onComplete` fires when a non-looping animation reaches the last frame.
- `onLoop` fires each time a looping animation wraps around.
- `onFrameChange` fires every time the displayed frame changes.

### Manual update mode

```ts
const gif = new GifSprite({ source, autoUpdate: false });

app.ticker.add((ticker) => {
  gif.update(ticker);
});
```

`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).

### Sharing source data and cloning

```ts
const source = await Assets.load("animation.gif");

const gif1 = new GifSprite({ source, autoPlay: true });
const gif2 = new GifSprite({ source, autoPlay: false });

const gif3 = gif1.clone();
gif3.animationSpeed = 0.5;
```

`GifSource` can be shared across multiple `GifSprite` instances; each sprite has independent playback state. `clone()` copies all playback settings but creates an independent instance.

## Common Mistakes

### [HIGH] Not importing pixi.js/gif

Wrong:

```ts
import { Assets } from "pixi.js";
const gif = await Assets.load("animation.gif");
```

Correct:

```ts
import "pixi.js/gif";
import { Assets } from "pixi.js";
const source = await Assets.load("animation.gif");
```

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.


### [MEDIUM] Expecting Assets.load to return a Texture

Wrong:

```ts
const texture = await Assets.load("animation.gif");
const sprite = new Sprite(texture);
```

Correct:

```ts
const source = await Assets.load("animation.gif");
const gif = new GifSprite({ source });
```

`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]`.


### [MEDIUM] GIF memory not released on destroy

Wrong:

```ts
gif.destroy();
// GifSource and frame textures remain in memory
```

Correct:

```ts
gif.destroy(true);
// or
await Assets.unload("animation.gif");
```

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.


### [LOW] Do not nest children inside a GifSprite

`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`:

```ts
const group = new Container();
group.addChild(gif, label);
```


## API Reference

- [GifSprite](https://pixijs.download/release/docs/gif.GifSprite.html.md)
- [GifSpriteOptions](https://pixijs.download/release/docs/gif.GifSpriteOptions.html.md)
- [GifSource](https://pixijs.download/release/docs/gif.GifSource.html.md)
- [GifAsset](https://pixijs.download/release/docs/gif.GifAsset.html.md)
- [GifBufferOptions](https://pixijs.download/release/docs/gif.GifBufferOptions.html.md)
- [GifFrame](https://pixijs.download/release/docs/gif.GifFrame.html.md)

© pixijs · MIT · pixijs/pixijs-skills

Смотрите также

Спонсоры проекта

Компании, которые помогают держать аналитику открытой