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

pixijs-scene-dom-container — скилл для Claude Code: HTML поверх canvas

Подсказывает агенту, как накладывать HTML-элементы на canvas PixiJS v8 через DOMContainer и DOMPipe. Пригодится, когда нужны поля ввода, iframe или видео поверх сцены.

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

Что делает pixijs-scene-dom-container

Скилл описывает DOMContainer — контейнер, который ставит HTML-элемент над canvas PixiJS и каждый кадр переписывает его CSS-трансформ из графа сцены. Позиция, масштаб, поворот и прозрачность родителя уходят в style.opacity и transform, так что элемент едет за спрайтом без ручной синхронизации. Внутри разобраны конструктор DOMContainerOptions с полями element и anchor, работа с общим корнем app.domContainerRoot и очистка через destroy().

В браузерной сборке pixi.js нужный DOMPipe регистрируется сам. Явный import 'pixi.js/dom' нужен только при skipExtensionImports: true или под небраузерным бандлом — без него контейнер импортируется, но рендерер его не обработает. Это первое место, где всё ломается у людей с кастомной сборкой.

DOMContainer помечен EXPERIMENTAL в PixiJS v8, поэтому API может поменяться между минорными версиями. Он наследует ViewContainer и остаётся листом: вложить в него дочерние объекты PixiJS нельзя, HTML-содержимое кладите внутрь самого элемента. В Web Worker скилл тоже не поможет — там нет DOM. Скилл опирается на знание pixijs-scene-core-concepts.

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

  • поставить поле ввода поверх canvas и не ловить рассинхрон позиции
  • вывести iframe или видео, привязанное к объекту сцены
  • сделать декоративный HTML-оверлей, сквозь который клики доходят до canvas
  • разобраться, почему DOMContainer не рендерится в кастомной сборке
  • отвязать элемент от сцены и вернуть его в обычный DOM

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

  • Добавь DOMContainer с input поверх canvas PixiJS, отцентрируй его через anchor 0.5
  • Почему мой DOMContainer не отрисовывается при skipExtensionImports: true?
  • Сделай HTML-панель со счётом поверх сцены и отключи на ней pointer-events

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

1Через Skills CLI (Vercel)

npx skills add pixijs/pixijs-skills --skill pixijs-scene-dom-container -a claude-code

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

~/.claude/skills/pixijs-scene-dom-container/SKILL.md

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

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

Вопросы о pixijs-scene-dom-container

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

Выполните npx skills add pixijs/pixijs-skills --skill pixijs-scene-dom-container -a claude-code. Файл скилла появится по пути ~/.claude/skills/pixijs-scene-dom-container/SKILL.md.

Что делает pixijs-scene-dom-container?

Объясняет агенту, как накладывать HTML-элементы на canvas PixiJS v8 через DOMContainer: трансформы из графа сцены, anchor, синхронизация видимости и обработка pointer-events.

Можно ли вкладывать объекты PixiJS внутрь DOMContainer?

Нет. DOMContainer наследует ViewContainer и работает как лист. HTML-содержимое кладите внутрь самого элемента, а несколько контейнеров оборачивайте в обычный Container.

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

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

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

> `DOMContainer` is marked EXPERIMENTAL in PixiJS v8. The API may change between minor releases.

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.

## Quick Start

```ts
import "pixi.js/dom";

const input = document.createElement("input");
input.type = "text";
input.placeholder = "Enter name...";

const dom = new DOMContainer({
  element: input,
  anchor: 0.5,
});
dom.position.set(app.screen.width / 2, app.screen.height / 2);

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

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

## Constructor options

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

| Option    | Type                  | Default                         | Description                                                                                                                                                                    |
| --------- | --------------------- | ------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `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.                        |
| `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. |

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

## Core Patterns

### Setup and the side-effect import

```ts
import "pixi.js/dom";
import { DOMContainer } from "pixi.js";
```

Or use the combined import that registers the pipe and re-exports the class:

```ts
import { DOMContainer } from "pixi.js/dom";
```

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.

### Transforms, anchor, and alpha

```ts
const dom = new DOMContainer({
  element: document.createElement("div"),
  anchor: 0.5,
});
dom.position.set(400, 300);
dom.scale.set(1.5);
dom.rotation = Math.PI / 8;
dom.alpha = 0.5;
```

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.

If no `element` is provided, a `<div>` is created by default.

### Styling the element directly

```ts
const panel = document.createElement("div");
panel.innerHTML = "<h2>Score</h2><p>1500</p>";
panel.style.color = "white";
panel.style.fontFamily = "Arial";
panel.style.pointerEvents = "none";

const dom = new DOMContainer({ element: panel });
dom.position.set(50, 50);
app.stage.addChild(dom);
```

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.

### Visibility and cleanup

```ts
dom.visible = false;
dom.visible = true;

dom.destroy();
```

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:

```ts
const element = dom.element;
dom.destroy();
document.body.appendChild(element);
```

### The DOM container root

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.

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

```ts
document.body.appendChild(app.canvas);
document.body.appendChild(app.domContainerRoot);
```

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.

## Common Mistakes

### [MEDIUM] Missing the pixi.js/dom import in custom builds

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:

```ts
await app.init({ skipExtensionImports: true });
// Now you must add this yourself:
import "pixi.js/dom";
```

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.


### [MEDIUM] Expecting filters, masks, or blend modes to affect DOM elements

Wrong:

```ts
const dom = new DOMContainer();
dom.filters = [new BlurFilter()];
```

Correct:

```ts
dom.element.style.filter = "blur(4px)";
```

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.


### [MEDIUM] Do not nest children inside a DOMContainer

Wrong:

```ts
const dom = new DOMContainer();
dom.addChild(new Sprite(texture));
```

Correct:

```ts
const group = new Container();
group.addChild(dom, new Sprite(texture));
```

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


### [LOW] Forgetting to set anchor for centered positioning

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

```ts
const dom = new DOMContainer({ element: myElement, anchor: 0.5 });
dom.position.set(400, 300);
```


## API Reference

- [DOMContainer](https://pixijs.download/release/docs/scene.DOMContainer.html.md)
- [DOMContainerOptions](https://pixijs.download/release/docs/scene.DOMContainerOptions.html.md)
- [ViewContainer](https://pixijs.download/release/docs/scene.ViewContainer.html.md)
- [Container](https://pixijs.download/release/docs/scene.Container.html.md)

© pixijs · MIT · pixijs/pixijs-skills

Похожие скиллы

Всё по теме «Фронтенд и UI» →
pixijs-2d freshtechbro Скилл обучает агента создавать 2D-графику на PixiJS с WebGL и WebGPU: анимировать спрайты, выводить частицы и рисовать векторные фигуры на холсте. CX Codex +1 2 500установок pixijs-rendering gamedev-skills Скилл для сборки слоя рендера на PixiJS v8: асинхронный Application, загрузка текстур, сцена на Container, тикер и события указателя. CX Codex +1 5 400установок expo-dom expo Запускает веб-код в webview на нативных платформах и рендерит как есть на вебе. Позволяет использовать веб-библиотеки вроде recharts или react-syntax-highlighter в Expo без переписывания. CX Codex +1 21 000установок threejs-scene-setup gamedev-skills Настраивает базовую сцену three.js и помогает найти причины пустого или чёрного canvas. Нужен при старте проекта, ресайзе, цикле рендеринга и OrbitControls. CX Codex +1 5 500установок typescript-data-visualization-engineering официальный OpenAI Помогает проектировать архитектуру визуализации данных на TypeScript: от строгих схем и разделения слоёв до подбора библиотек вроде D3, Three.js или Canvas. CX Codex GP ChatGPT 9установок globe-particles MengTo Создаёт трёхмерную визуализацию сферы и орбитального кольца из светящихся частиц на WebGL и Three.js. Пригодится для космических тем и витрин данных. CX Codex +1 1 400установок

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

pixijs-scene-text Скилл учит нейросеть работать с текстом в PixiJS v8. Он помогает выбрать подходящий класс рендеринга и не тратить ресурсы на перерисовку канваса каждый кадр. CX Codex +1 5 800установок pixijs-scene-core-concepts Объясняет, как устроено дерево сцены PixiJS v8: контейнеры, листья, трансформы и порядок отрисовки. Пригодится, когда агент пишет код на PixiJS. CX Codex +1 5 900установок pixijs-math Скилл для работы с координатами, матрицами, фигурами и проверкой попаданий в PixiJS v8. Пригодится, когда нужно перевести точку между системами координат или собрать хит-зону. CX Codex +1 5 900установок pixijs-scene-mesh Помогает настраивать кастомную 2D-геометрию в PixiJS v8 через Mesh, MeshPlane, MeshRope и PerspectiveMesh. Пригодится при анимации вершин, деформации текстур и рисовании путей. 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установок

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

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