pixijs-application
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 생성, 시작/중지 라이프사이클, 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
...모든 것을 확장하십시오Application은 렌더러, 루트 스테이지 컨테이너, 캔버스, 그리고 Ticker/Resize 플러그인을 소유하는 편의 래퍼입니다. v8에서는 생성자가 인수를 받지 않으며, 모든 구성은 async app.init() 호출로 전달되어 autoDetectRenderer를 통해 렌더러를 인스턴스화합니다.
빠른 시작
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);
관련 기술: pixijs-core-concepts (렌더러, 렌더링 파이프라인), pixijs-ticker (렌더링 루프 상세 내용), pixijs-scene-container ( app.stage 사용법), pixijs-environments (브라우저 외 환경 설정).
핵심 패턴
라이프사이클: 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);// ... 씬 실행, 티커가 app.render()를 자동으로 호출합니다 ...app.destroy(
{ removeView: true, releaseGlobalResources: true },
{ children: true, texture: true, textureSource: true },
);
new Application()은 인스턴스를 할당하지만 아무것도 생성하지 않습니다. 여기에 전달된 옵션은 V8의 사용 중단 경고와 함께 무시됩니다.app.init(options)는 비동기입니다. 이 메서드는 렌더러를 구축하고 플러그인을 연결하며,app.canvas,app.renderer또는app.screen을사용하기 전에 이 과정이 완료되어야 합니다.- TickerPlugin은 init이 해결되면 매 프레임마다
app.render()를호출합니다(autoStart: false인 경우제외). app.destroy(rendererDestroyOptions, stageDestroyOptions)— 첫 번째 인수는renderer.destroy()로 전달됩니다. DOM에서 캔버스를 제거하려면true또는{ removeView: true }를 전달하십시오.releaseGlobalResources: true를추가하면 동일한 탭에서 앱을 해체하고 다시 생성할 때 전역 풀(배치, 텍스처 캐시)을 비울 수 있습니다. 이를 생략하면 재초기화 후 깜빡임이나 텍스처가 제대로 업데이트되지 않는 현상이 발생하는 일반적인 원인입니다(pixijs-performance참조).
주요 초기화 옵션
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,
});
모든 옵션(뷰/캔버스, 배경, 렌더러 기본 설정(배열 형식 포함), 티커, 크기 조정, 컬러, 이벤트, 접근성, 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
초기화 시 이 플러그인은 캔버스가 대상과 일치하도록 유지합니다. TickerPlugin은 콜백은 CullerPlugin은 플러그인은 등록 순서대로 초기화되고, 그 역순으로 해제됩니다. 플러그인에 타입이 지정된 옵션을 추가하려면 내장된 잘못된 예: 올바른 방법: V8에서 잘못된 예: 올바른 방법: v8에서 잘못된 예: 올바른 방법: Related skills: 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 ( Set The plugin keeps the canvas matched to the target. The TickerPlugin creates The callback receives the The CullerPlugin skips rendering containers that fall outside Containers are not culled unless Extend Plugins initialize in registration order and destroy in reverse. To add typed options for your plugin, extend The built-in Wrong: Correct: In v8 the Wrong: Correct: Wrong: Correct: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()를 호출하도록 하세요. 고해상도(high-DPI) 출력을 위해 autoDensity: true 및 resolution: window.devicePixelRatio와 함께 사용하세요.await app.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 기본 사항
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를 참조하십시오.수동 렌더링 루프
await app.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 (선택적 사용)
app.renderer.screen 범위를 벗어난 컨테이너의 렌더링을 건너뜁니다. 이 플러그인은 기본적으로 등록되어 있지 않으므로, 앱을 생성하기 전에 다음 코드를 추가하십시오: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; // 이 컨테이너의 경계가 화면 밖으로 나가면 컬링됩니다
world.cullableChildren = true; // 기본값;자식 요소에 대한 재귀 처리를 건너뛰려면 `false`로 설정하세요.const tile = 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를 참조하십시오.사용자 정의 애플리케이션 플러그인
정적 init, 정적 destroy 및 static extension = ExtensionType.Application을 가진 클래스를 등록하여 Application을 확장합니다. 두 메서드 모두 this가 Application 인스턴스에 바인딩된 상태로 호출되므로 this.renderer 및 this.stage를 사용할 수 있습니다.import {
Application,
ExtensionType,
extensions,
type ApplicationOptions,
} from "pixi.js";class FpsOverlay {
public static extension = 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 };
}
}
}await app.init({ fpsOverlay: { visible: true } });
ResizePlugin, TickerPlugin 및 선택적 CullerPlugin은 모두 이 동일한 계약(contract)을 사용합니다. skipExtensionImports: true를 설정했다면, 필요한 내장 플러그인을 직접 등록해야 합니다(extensions.add(ResizePlugin, TickerPlugin)).흔히 저지르는 실수
[중요] 생성자에 옵션 전달
const app = new Application({ width: 800, height: 600 });
document.body.appendChild(app.canvas);
const app = new Application();
await app.init({ width: 800, height: 600 });
document.body.appendChild(app.canvas);
Application 생성자는 인수를 받지 않습니다. 생성자에 전달된 옵션은 무시되며 사용 중단 경고가 기록됩니다. 렌더러는 비동기 init() 호출 내에서만 생성됩니다.[HIGH] app.canvas 대신 app.view 사용
document.body.appendChild(app.view);
document.body.appendChild(app.canvas);
app.view는 app.canvas 로 이름이 변경되었습니다. 기존 게터는 여전히 작동하지만, 더 이상 사용되지 않을 예정이라는 경고가 표시됩니다.[중간 난이도] init이 해결되기 전에 app.canvas 또는 app.renderer에 접근하는 경우
const app = new Application();
document.body.appendChild(app.canvas);
app.init({ width: 800, height: 600 });
const app = new Application();
await app.init({ width: 800, height: 600 });
document.body.appendChild(app.canvas);
app.renderer, app.canvas 및 app.screen은 init() 프로미스가 해결된 후에야 값이 할당됩니다. 그 이전에 접근하면 undefined가 반환됩니다.API 참조
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);
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.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,
});
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
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
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
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
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)
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);
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
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);
PixiMixins.ApplicationOptions:declare global {
namespace PixiMixins {
interface ApplicationOptions {
fpsOverlay?: { visible?: boolean };
}
}
}await app.init({ fpsOverlay: { visible: true } });
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
const app = new Application({ width: 800, height: 600 });
document.body.appendChild(app.canvas);
const app = new Application();
await app.init({ width: 800, height: 600 });
document.body.appendChild(app.canvas);
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
document.body.appendChild(app.view);
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
const app = new Application();
document.body.appendChild(app.canvas);
app.init({ width: 800, height: 600 });
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/
복사
관련 스킬





집
