オプション
家 Skill その他 pixijs-application

pixijs-application

pixijs/pixijs pixijs/pixijs

PixiJS v8 アプリケーションの作成および設定を行う際に、このスキルを活用してください。新しい Application() および非同期の app.init() オプション(width、height、background、antialias、resolution、autoDensity、preference、resizeTo、 autoStart、sharedTicker、canvas、useBackBuffer、powerPreference、eventFeatures、accessibilityOptions、gcActive、bezierSmoothness、レンダラーごとの webgl/webgpu/canvasOptions の上書き)、app.stage/renderer/canvas/screen/domContainerRoot へのアクセス、 ResizePlugin、TickerPlugin、CullerPlugin(cullable、cullArea)、ExtensionType.Application によるカスタム ApplicationPlugin の作成、start/stop ライフサイクル、および releaseGlobalResources を伴う app.destroy()。 トリガー対象:Application、app.init、app.stage、app.renderer、app.canvas、app.screen、app.domContainerRoot、ApplicationOptions、ApplicationPlugin、ExtensionType.Application、resizeTo、preference、autoStart、sharedTicker、useBackBuffer、powerPreference、skipExtensionImports、preferWebGLVersion、preserveDrawingBuffer、cullable、CullerPlugin、app.start、app.stop、app.destroy、rele

...すべて拡張します
50
更新された時間 2026年8月4日

Applicationは、レンダラー、ルートステージコンテナ、キャンバス、およびTicker/Resizeプラグインを所有する利便性を高めるラッパーです。v8では、コンストラクタは引数を受け取りません。すべての設定は、asyncapp.init()呼び出しに渡され、そこでautoDetectRendererを介してレンダラーがインスタンス化されます。

クイックスタート

import{Application}from "pixi.js";constapp =new Application();awaitapp.init({
  resizeTo:window,
  background:"#1099bb",
 antialias:true,
  preference:"webgl",
  autoDensity:true,
  resolution:window.devicePixelRatio,
});document.body.appendChild(app.canvas);

関連スキル: pixijs-core-concepts(レンダラー、レンダリングパイプライン)、pixijs-ticker(レンダリングループの詳細)、pixijs-scene-containerapp.stage の操作)、pixijs-environments(ブラウザ以外の環境)。

主要なパターン

ライフサイクル: construct、init、render、destroy

import{Application}from "pixi.js";constapp =new Application();awaitapp.init({width:800,height:600});
document.body.appendChild(app.canvas);// ... シーンを実行。ティッカーが自動的に app.render() を呼び出します ...app.destroy(
  {removeView:true,releaseGlobalResources:true},
  {children:true,texture:true,textureSource:true},
);
  • new Application()はインスタンスを割り当てますが、何も生成しません。ここで渡されたオプションは無視され、V8 の非推奨警告が表示されます。
  • app.init(options)は非同期です。レンダラーを構築し、プラグインを接続します。app.canvasapp.renderer、またはapp.screen を使用するには、この処理が完了している必要があります。
  • TickerPlugin は、init が解決されると(autoStart: false の場合を除き)、毎フレームapp.render()を呼び出します。
  • app.destroy(rendererDestroyOptions, stageDestroyOptions)— 最初の引数はrenderer.destroy() に転送されます。DOM からキャンバスを削除するには、trueまたは{ removeView: true }を渡してください。releaseGlobalResources: true を追加すると、同じタブ内でアプリを破棄して再作成する際に、グローバルプール(バッチ、テクスチャキャッシュ)が解放されます。これを省略すると、再初期化後にちらつきやテクスチャの古さが生じる主な原因となります(pixijs-performance を参照)。

主な初期化オプション

awaitapp.init({
  width:800,
  height:600,
  background:0x1099bb,
  backgroundAlpha:1,  antialias:true,
  resolution:window.devicePixelRatio,
 autoDensity:true,  preference:"webgpu",  autoStart:true,
  sharedTicker:false,  resizeTo:window,  canvas:document.querySelector("#game-canvas")as HTMLCanvasElement,
});

各オプション(ビュー/キャンバス、背景、レンダラー設定(配列形式を含む)、ティッカー、リサイズ、カリング、イベント、アクセシビリティ、WebGL/WebGPU コンテキストフラグ)について、 グラフィックス・ベジエの滑らかさ、GC、およびレンダラーごとのオーバーライド(webgl/webgpu/canvasOptions)については、references/application-options.mdを参照してください。

アプリケーションのプロパティ

app.stage;// ルートコンテナ。すべての表示オブジェクトをここに追加します
app.renderer;// WebGL/WebGPU/Canvas レンダラーのインスタンス
app.canvas;// HTMLCanvasElement (DOM への挿入は自身で行う)
app.screen;// 可視領域を表す CSS ピクセル単位の矩形
app.domContainerRoot;// DOMContainer オーバーレイを保持する HTMLDivElement

app.stageは単純なコンテナです。シーングラフの詳細(トランスフォーム、addChild、destroy)については、pixijs-scene-container を参照してください。 レンダラーレベルの操作(extract、generateTexture、カスタムシステム)については、pixijs-core-conceptsおよびpixijs-custom-rendering を参照してください。app.domContainerRootは、

であり、レンダラーがDOMContainerオーバーレイをホストするために使用します。シーンノードに DOM 要素を固定する必要がある場合は、app.canvasの隣にこれを追加してください(pixijs-scene-dom-container を参照)。

ResizePlugin

初期化時にresizeTo を設定するか(あるいは後でapp.resizeTo を再割り当てして)、プラグインがresizeイベントをリッスンし、ターゲット要素のクライアントサイズを引数としてrenderer.resize() を呼び出すようにします。高 DPI 出力には、autoDensity: trueおよびresolution: window.devicePixelRatioと組み合わせて使用してください。

awaitapp.init({resizeTo:window});app.resizeTo=document.querySelector("#game-container")as HTMLElement;app.resize();// ターゲットの現在のサイズに即座にリサイズ
app.queueResize();// リサイズを次のアニメーションフレームまで延期
app.cancelResize();// 保留中の queueResize をキャンセル

このプラグインは、キャンバスをターゲットに合わせ続けます。app.screenおよびapp.canvas.width/height はそれに応じて更新されます。リサイズ後にこれらを読み取り、UI を配置してください。

  • app.resize()— 即時かつ同期的なリサイズ。
  • app.queueResize()— 次のフレームまで遅延させることで、頻繁な呼び出しを統合します。window.resizeリスナーでは、冗長な処理を避けるために内部的に使用されます。
  • app.cancelResize()— キューに入れられたリサイズをキャンセルします。queueResize をトリガーした独自のレイアウトコードを解除する前に、これを呼び出してください。

Ticker の基本

TickerPlugin はapp.tickerを作成し、そこにapp.render() を UPDATE_PRIORITY.LOW で登録します。app.start()/app.stop()でループを制御し、app.ticker.add/app.ticker.addOnce でコールバックを追加します:

app.ticker.add((ticker) =>{
  sprite.rotation+=0.01* ticker.deltaTime;
});app.ticker.addOnce(() =>{
 console.log("次のフレームで一度実行され、その後自身を削除します");
});app.stop();// レンダリングループを一時停止(例:タブが非表示になった場合)
app.start();// 再開

コールバックにはTickerインスタンスが渡されます。フレームレートに依存しない乗数(60fps では約 1.0)についてはticker.deltaTime を、実際のミリ秒数についてはticker.deltaMS を、現在のフレームレートについてはticker.FPS を参照してください。 優先順位、FPSの上限設定、onRender、共有ティッカーとプライベートティッカーの違い、およびV8のコールバックシグネチャの変更については、pixijs-tickerを参照してください。

手動のレンダリングループ

awaitapp.init({autoStart:false,width:800,height:600});
document.body.appendChild(app.canvas);function frame() {
  updateScene();
  app.render();
 requestAnimationFrame(frame);
}
frame();

autoStart: false を指定すると、TickerPlugin によるティッカーの自動起動が防止されます。app.render() を自分で呼び出してください(同じ効果を得るにはapp.renderer.render({ container: app.stage })を使用しても構いません)。登録済みのティッカーコールバックを依然として実行したい場合は、ループ内でapp.render() の前にapp.ticker.update() を呼び出してください。

CullerPlugin(オプトイン)

CullerPlugin は、app.renderer.screen の範囲外にあるコンテナのレンダリングをスキップします。デフォルトでは登録されていないため、アプリを作成する前に以下のように追加してください:

import{
  Application,
  Container,
  Sprite,
  extensions,
  CullerPlugin,
  Rectangle,
}from "pixi.js";extensions.add(CullerPlugin);constapp =new Application();
awaitapp.init({width:800,height:600});constworld =new Container();
world.cullable=true;// このコンテナは、その境界が画面外に出たときにカリングされます
world.cullableChildren=true;// デフォルト。子要素 への再帰処理をスキップするには `false` を設定consttile =Sprite.from("tile.png");
tile.cullable=true;
world.addChild(tile);
app.stage.addChild(world);

`cullable` が設定されていない限り、コンテナはカリングされません。子要素の境界の計算にコストがかかる場合は、`container.cullArea = new Rectangle(x, y, w, h)` と指定して、デフォルトの境界チェックを上書きしてください。 このプラグインはapp.render()をラップしているため、Culler.shared.cull(app.stage, app.renderer.screen)が毎フレーム実行されます。カリングが有効になるタイミングについては、pixijs-performance を参照してください。

カスタムアプリケーションプラグイン

static initstatic destroy、およびstatic extension = ExtensionType.Application を定義したクラスを登録することで、Application を拡張します。両方のメソッドはthis がApplication インスタンスにバインドされた状態で呼び出されるため、this.rendererおよびthis.stageを利用できます。

import{
  Application,
  ExtensionType,
  extensions,
  type ApplicationOptions,
}from "pixi.js";class FpsOverlay{
 public staticextension =ExtensionType.Application;  public static init(this:Application,options:Partial<ApplicationOptions>) {
    // レンダラーが作成された後、app.init() 内で実行される
   // `this` にプロパティやメソッドを紐付けて、アプリ上で利用可能にする
  }  public static destroy(this:Application) {
    // app.destroy() 内で実行される — 紐付けたものをすべて破棄する
  }
}extensions.add(FpsOverlay);

プラグインは登録順に初期化され、逆の順序で破棄されます。プラグインに型付きオプションを追加するには、PixiMixins.ApplicationOptions を拡張します:

declare global{
  namespace PixiMixins{
    interface ApplicationOptions{
      fpsOverlay?: {visible?:boolean};
    }
  }
}awaitapp.init({fpsOverlay: {visible:true} });

組み込みのResizePluginTickerPlugin、およびオプションのCullerPluginはすべて、この同じ契約を使用しています。skipExtensionImports: true を設定する場合は、必要な組み込みプラグインを自分で登録してください(extensions.add(ResizePlugin, TickerPlugin))。

よくある間違い

[重大] コンストラクタへのオプションの渡し方

誤った例:

constapp =new Application({width:800,height:600});
document.body.appendChild(app.canvas);

正しい例:

constapp =new Application();
awaitapp.init({width:800,height:600});
document.body.appendChild(app.canvas);

V8 では、Applicationコンストラクタは引数を受け取りません。そこに渡されたオプションは無視され、非推奨の警告がログに出力されます。レンダラーは、非同期のinit()呼び出し内でのみ作成されます。

[HIGH] app.canvas の代わりに app.view を使用している

誤り:

document.body.appendChild(app.view);

正しい方法:

document.body.appendChild(app.canvas);

v8 では、app.view は app.canvasに名称変更されました。旧来のゲッターは引き続き機能しますが、非推奨の警告が表示されます。

[MEDIUM] init が解決される前に app.canvas または app.renderer を操作する

誤り:

constapp =new Application();
document.body.appendChild(app.canvas);
app.init({width:800,height:600});

正しい例:

constapp =new Application();
awaitapp.init({width:800,height:600});
document.body.appendChild(app.canvas);

app.rendererapp.canvas、およびapp.screenは、init()のプロミスが解決されて初めて値が設定されます。それ以前にこれらにアクセスすると、undefined が返されます。

APIリファレンス

GitHubで見る

Application is the convenience wrapper that owns a renderer, a root stage Container, a canvas, and the Ticker/Resize plugins. In v8 the constructor takes no arguments; all configuration is passed to the async app.init() call which instantiates the renderer via autoDetectRenderer.

Quick Start

import { Application } from "pixi.js";const app = new Application();await app.init({
  resizeTo: window,
  background: "#1099bb",
  antialias: true,
  preference: "webgl",
  autoDensity: true,
  resolution: window.devicePixelRatio,
});document.body.appendChild(app.canvas);

Related skills: pixijs-core-concepts (renderers, render pipeline), pixijs-ticker (render loop detail), pixijs-scene-container (working with app.stage), pixijs-environments (non-browser setups).

Core Patterns

Lifecycle: construct, init, render, destroy

import { Application } from "pixi.js";const app = new Application();await app.init({ width: 800, height: 600 });
document.body.appendChild(app.canvas);// ... run scene, ticker drives app.render() automatically ...app.destroy(
  { removeView: true, releaseGlobalResources: true },
  { children: true, texture: true, textureSource: true },
);
  • new Application() allocates the instance but creates nothing. Options passed here are ignored with a v8 deprecation warning.
  • app.init(options) is async. It builds the renderer, wires up plugins, and must complete before you can use app.canvas, app.renderer, or app.screen.
  • The TickerPlugin calls app.render() every frame once init resolves (unless autoStart: false).
  • app.destroy(rendererDestroyOptions, stageDestroyOptions) — the first argument forwards to renderer.destroy(). Pass true or { removeView: true } to remove the canvas from the DOM. Add releaseGlobalResources: true to drain global pools (batches, texture caches) when tearing down and re-creating an app in the same tab; omitting it is the usual cause of flickering and stale textures after a re-init (see pixijs-performance).

Key init options

await app.init({
  width: 800,
  height: 600,
  background: 0x1099bb,
  backgroundAlpha: 1,  antialias: true,
  resolution: window.devicePixelRatio,
  autoDensity: true,  preference: "webgpu",  autoStart: true,
  sharedTicker: false,  resizeTo: window,  canvas: document.querySelector("#game-canvas") as HTMLCanvasElement,
});

For every option — view/canvas, background, renderer preference (including the array form), ticker, resize, culler, events, accessibility, WebGL/WebGPU context flags, Graphics bezier smoothness, GC, and per-renderer overrides (webgl / webgpu / canvasOptions) — see references/application-options.md.

Application properties

app.stage; // root Container; add all display objects here
app.renderer; // the WebGL/WebGPU/Canvas renderer instance
app.canvas; // the HTMLCanvasElement (insert it into the DOM yourself)
app.screen; // Rectangle describing the visible area in CSS pixels
app.domContainerRoot; // HTMLDivElement that holds DOMContainer overlays

app.stage is a plain Container. For scene graph detail (transforms, addChild, destroy) see pixijs-scene-container. For renderer-level operations (extract, generateTexture, custom systems) see pixijs-core-concepts and pixijs-custom-rendering. app.domContainerRoot is the <div> that the renderer uses to host DOMContainer overlays; append it next to app.canvas when you need DOM elements pinned to scene nodes (see pixijs-scene-dom-container).

ResizePlugin

Set resizeTo at init (or reassign app.resizeTo later) to have the plugin listen for the resize event and call renderer.resize() with the target element's client size. Combine with autoDensity: true and resolution: window.devicePixelRatio for high-DPI output.

await app.init({ resizeTo: window });app.resizeTo = document.querySelector("#game-container") as HTMLElement;app.resize(); // immediate resize to the target's current size
app.queueResize(); // defer the resize to the next animation frame
app.cancelResize(); // drop a pending queueResize

The plugin keeps the canvas matched to the target. app.screen and app.canvas.width/height update in response; read them after the resize to place UI.

  • app.resize() — immediate synchronous resize.
  • app.queueResize() — coalesces rapid calls by deferring to the next frame; internally used by the window.resize listener to avoid redundant work.
  • app.cancelResize() — cancels a queued resize. Call this before tearing down your own layout code that triggered queueResize.

Ticker basics

The TickerPlugin creates app.ticker and registers app.render() on it at UPDATE_PRIORITY.LOW. Control the loop with app.start()/app.stop() and add callbacks with app.ticker.add / app.ticker.addOnce:

app.ticker.add((ticker) => {
  sprite.rotation += 0.01 * ticker.deltaTime;
});app.ticker.addOnce(() => {
  console.log("runs once on the next frame, then removes itself");
});app.stop(); // pause the render loop (e.g. tab hidden)
app.start(); // resume

The callback receives the Ticker instance; read ticker.deltaTime for a frame-rate-independent multiplier (~1.0 at 60fps), ticker.deltaMS for real milliseconds, or ticker.FPS for the current frame rate. See pixijs-ticker for priorities, FPS capping, onRender, shared vs private tickers, and the v8 callback signature change.

Manual render loop

await app.init({ autoStart: false, width: 800, height: 600 });
document.body.appendChild(app.canvas);function frame() {
  updateScene();
  app.render();
  requestAnimationFrame(frame);
}
frame();

autoStart: false prevents the TickerPlugin from starting the ticker automatically. Call app.render() yourself (or app.renderer.render({ container: app.stage }) for the same effect). If you still want registered ticker callbacks to fire, call app.ticker.update() inside your loop before app.render().

CullerPlugin (opt-in)

The CullerPlugin skips rendering containers that fall outside app.renderer.screen. It isn't registered by default; add it before creating your app:

import {
  Application,
  Container,
  Sprite,
  extensions,
  CullerPlugin,
  Rectangle,
} from "pixi.js";extensions.add(CullerPlugin);const app = new Application();
await app.init({ width: 800, height: 600 });const world = new Container();
world.cullable = true; // this container is culled when its bounds leave the screen
world.cullableChildren = true; // default; set `false` to skip recursing into childrenconst tile = Sprite.from("tile.png");
tile.cullable = true;
world.addChild(tile);
app.stage.addChild(world);

Containers are not culled unless cullable is set. Override the default bounds check with container.cullArea = new Rectangle(x, y, w, h) when child bounds are expensive to compute. The plugin wraps app.render() so Culler.shared.cull(app.stage, app.renderer.screen) runs before every frame. See pixijs-performance for when culling pays off.

Custom Application plugins

Extend Application by registering a class with static init, static destroy, and static extension = ExtensionType.Application. Both methods are called with this bound to the Application instance, so this.renderer and this.stage are available.

import {
  Application,
  ExtensionType,
  extensions,
  type ApplicationOptions,
} from "pixi.js";class FpsOverlay {
  public static extension = ExtensionType.Application;  public static init(this: Application, options: Partial<ApplicationOptions>) {
    // runs inside app.init() after the renderer is created
    // attach props/methods to `this` to expose them on the app
  }  public static destroy(this: Application) {
    // runs inside app.destroy() — tear down anything you attached
  }
}extensions.add(FpsOverlay);

Plugins initialize in registration order and destroy in reverse. To add typed options for your plugin, extend PixiMixins.ApplicationOptions:

declare global {
  namespace PixiMixins {
    interface ApplicationOptions {
      fpsOverlay?: { visible?: boolean };
    }
  }
}await app.init({ fpsOverlay: { visible: true } });

The built-in ResizePlugin, TickerPlugin, and opt-in CullerPlugin all use this same contract. If you set skipExtensionImports: true, register the built-ins you need yourself (extensions.add(ResizePlugin, TickerPlugin)).

Common Mistakes

[CRITICAL] Passing options to the constructor

Wrong:

const app = new Application({ width: 800, height: 600 });
document.body.appendChild(app.canvas);

Correct:

const app = new Application();
await app.init({ width: 800, height: 600 });
document.body.appendChild(app.canvas);

In v8 the Application constructor takes no arguments. Options passed there are ignored and log a deprecation warning; the renderer is only created inside the async init() call.

[HIGH] Using app.view instead of app.canvas

Wrong:

document.body.appendChild(app.view);

Correct:

document.body.appendChild(app.canvas);

app.view was renamed to app.canvas in v8. The old getter still works but emits a deprecation warning.

[MEDIUM] Touching app.canvas or app.renderer before init resolves

Wrong:

const app = new Application();
document.body.appendChild(app.canvas);
app.init({ width: 800, height: 600 });

Correct:

const app = new Application();
await app.init({ width: 800, height: 600 });
document.body.appendChild(app.canvas);

app.renderer, app.canvas, and app.screen are only populated once the init() promise resolves. Accessing them earlier returns undefined.

API Reference

すべてのファイル

0件のファイル

pixijs-applicationをインストール

スキルファイルをダウンロードし、.claude/skills/ ディレクトリに解凍してください。

ZIPをダウンロード

リポジトリをクローンし、スキルファイルをプロジェクトにコピーしてください。

git clone https://github.com/pixijs/pixijs/tree/dev/skills/pixijs-application # Copy the skill folder to .claude/skills/ or .codex/skills/

コピー コピー
クイックセットアップ: skill フォルダを .claude/skills/ にコピーしてください。Claude が自動的にそのスキルを検出して使用します。
リポジトリ pixijs/pixijs

関連スキル

multica-creating-agents
更新された時間 2026年8月12日
tilemaps
更新された時間 2026年8月4日
v4-new-features
更新された時間 2026年8月4日
agent-github-pr-manager
更新された時間 2026年8月3日
OR