Skip to content

RendererPlugin

Defined in: renderer/src/RendererPlugin.ts:98

RendererPlugin wraps PixiJS v8 behind the YAGE plugin interface.

  • Plugin
  • RendererAdapter

new RendererPlugin(config): RendererPlugin

Defined in: renderer/src/RendererPlugin.ts:178

RendererConfig

RendererPlugin

drawingEnabled: boolean = true

Defined in: renderer/src/RendererPlugin.ts:101

Whether automatic canvas and render-target drawing is enabled.


fx: EffectsHost

Defined in: renderer/src/RendererPlugin.ts:156

Screen-scope effects host — .fx.addEffect(...) attaches a filter to app.stage, so it persists across scene transitions and composites everything the renderer draws (every scene, every layer). Common use: screen-wide post-process like vignette or chromatic aberration.

The handle survives scene changes; remove it explicitly when no longer wanted, or it lives until the renderer plugin is destroyed.


readonly name: "renderer" = "renderer"

Defined in: renderer/src/RendererPlugin.ts:99

Unique plugin name.

Plugin.name


readonly version: "4.0.0" = "4.0.0"

Defined in: renderer/src/RendererPlugin.ts:102

Semantic version string.

Plugin.version

get application(): Application

Defined in: renderer/src/RendererPlugin.ts:465

The PixiJS Application instance.

Application


get canvas(): HTMLCanvasElement

Defined in: renderer/src/RendererPlugin.ts:470

The canvas element.

HTMLCanvasElement

RendererAdapter.canvas


get canvasSize(): object

Defined in: renderer/src/RendererPlugin.ts:493

Current canvas size in CSS pixels. Changes on host resize under responsive fit.

object

height: number

width: number


get croppedVirtualRects(): readonly VirtualRect[]

Defined in: renderer/src/RendererPlugin.ts:688

Rectangles of virtual space that are currently off-screen — the complement of visibleVirtualRect inside virtualSize. Use these for effects that need to reason about cropped regions (e.g. fog-of-war overlays at the visible boundary).

Empty under letterbox / expand / stretch. Under cover, returns 1–2 strips.

readonly VirtualRect[]


get extendedVirtualRects(): readonly VirtualRect[]

Defined in: renderer/src/RendererPlugin.ts:730

Rectangles of the visible canvas OUTSIDE the declared virtual rect — the letterbox/expand “bars” expressed in virtual-space pixels.

Populated under letterbox and expand whenever aspect mismatches; empty under cover and stretch. Under expand these are the play-adjacent strips the game is expected to draw into (fog, parallax, HUD).

Under letterbox they only report where the background-color bars land. Every scene layer is clipped to the virtual rect under that mode, so content placed at these coordinates on a scene layer is invisible. To draw in the bars, parent a container directly on renderer.application.stage and position it in canvas pixels.

readonly VirtualRect[]


get fit(): RendererFitOptions

Defined in: renderer/src/RendererPlugin.ts:498

Current fit configuration.

RendererFitOptions


get isFullscreen(): boolean

Defined in: renderer/src/RendererPlugin.ts:860

Whether the renderer’s host element is currently the fullscreen element. Reads live from the DOM, so this stays accurate when the user exits fullscreen via Esc or the browser UI.

boolean


get orientation(): OrientationType | null

Defined in: renderer/src/RendererPlugin.ts:872

Current device orientation. Returns null when neither the screen.orientation API nor the legacy window.orientation angle is available — typical of headless tests and very old browsers.

OrientationType | null


get sceneRenderTrees(): SceneRenderTreeProvider

Defined in: renderer/src/RendererPlugin.ts:735

The per-scene render tree provider.

SceneRenderTreeProvider


get virtualCanvasRect(): VirtualRect

Defined in: renderer/src/RendererPlugin.ts:699

Where the declared virtual rectangle sits on the canvas, in CSS pixels. Use for DOM overlays positioned over the play area, cropping screenshots to gameplay, or mapping CSS-coord hit regions. The rect may extend past the canvas (negative coords, dimensions larger than canvasSize) under cover.

VirtualRect


get virtualSize(): object

Defined in: renderer/src/RendererPlugin.ts:488

Virtual resolution size.

object

height: number

width: number


get visibleCanvasRect(): VirtualRect

Defined in: renderer/src/RendererPlugin.ts:711

Full canvas extent expressed in virtual-space pixels — unlike visibleVirtualRect, not clamped to the declared virtual rect. Under letterbox / expand on an off-aspect host this extends past virtualSize on the unscaled axis (useful for drawing backdrops that fill the bars). Under cover it equals visibleVirtualRect; under stretch it equals the virtual rect.

VirtualRect


get visibleVirtualRect(): VirtualRect

Defined in: renderer/src/RendererPlugin.ts:676

Sub-rectangle of the declared virtual space that is actually on-screen. Use this to anchor HUD / UI that must stay inside the play area; use visibleCanvasRect if your HUD is allowed to live in the bars. Gameplay queries should stay on virtualSize.

Under letterbox / expand / stretch this equals the full virtual rect. Under cover the long axis is cropped by the canvas edges.

VirtualRect

RendererAdapter.visibleVirtualRect


get worldRoot(): DisplayContainer

Defined in: renderer/src/RendererPlugin.ts:483

The container that carries the responsive-fit transform — the natural parent for things that should live inside the virtual play area (transition overlays scoped to the play rect, world-space HUD, etc.). Children operate in virtual-space pixels.

Use app.stage instead when the geometry must cover the canvas including letterbox / expand bars (full-screen dip-to-color overlays).

DisplayContainer

canvasToVirtual(x, y): Vec2

Defined in: renderer/src/RendererPlugin.ts:524

Convert CSS pixels relative to the canvas top-left into virtual-space pixels. Inverts the stage transform currently applied by the fit controller.

number

number

Vec2

RendererAdapter.canvasToVirtual


captureCanvas(): HTMLCanvasElement

Defined in: renderer/src/RendererPlugin.ts:814

Capture the current stage and pending targets without advancing time.

HTMLCanvasElement


createRenderTarget(source, options): RenderTargetHandle

Defined in: renderer/src/RendererPlugin.ts:792

Create an offscreen buffer that draws source into a texture the game owns and redraws on its own schedule — the repeatable counterpart of createTexture, with control over when the buffer refreshes and how many texels it gets.

Composite the result by showing target.texture (a SpriteComponent, a mask, a filter input). See RenderTargetHandle for the coordinate space the source is drawn in and the reasons to keep it out of the live scene graph.

DisplayContainer

RenderTargetOptions

RenderTargetHandle


createTexture(draw, size?): TextureResource

Defined in: renderer/src/RendererPlugin.ts:755

Bake a texture once by drawing into a temporary graphics context. The result never changes again; for a buffer the game redraws, use createRenderTarget.

With size, the texture measures exactly that region of the drawing, starting at (0, 0): a 4-frame strip of 32-pixel cells is width: 128, height: 32 however much of each cell the drawing covers. Without it the texture is the drawn bounds, so its top-left corner is the first pixel drawn rather than (0, 0), and a drawing that starts at (10, 4) bakes shifted by that much.

The pixels live only on the GPU, with no image to reload from. Calling update() on the returned texture’s source re-uploads it empty and everything drawn from it turns transparent.

(graphics) => void

CreateTextureOptions

TextureResource


dispatchPointerEvent(type, point, button?): void

Defined in: renderer/src/RendererPlugin.ts:633

Deliver a pointer event at virtual-space point, so Pixi hit-tests and delivers it the way it does for a person clicking: a @yagejs/ui button runs its onClick, and stacking order, a disabled button’s pointer mode and clipping all apply. button is the mouse button a press or a release carries; a move omits it and reports whichever buttons a press left held.

The event goes to the canvas, never to the window: Pixi renames a pointer-up whose composed path starts elsewhere to pointerupoutside, which skips a button’s click path. It bubbles, because @yagejs/input listens for pointer-up on the window in the bubble phase — so the engine receives the same event and applies it at the next drain, one frame after the handler has already run.

One primary mouse pointer, id SYNTHETIC_POINTER_ID. Multi-touch is not reachable this way.

RendererPointerEventType

number

number

0 | 2 | 1

void

RendererAdapter.dispatchPointerEvent


exitFullscreen(): Promise<void>

Defined in: renderer/src/RendererPlugin.ts:849

Exit fullscreen. No-op if the page isn’t currently fullscreen.

Promise<void>


hasRenderedFrame(): boolean

Defined in: renderer/src/RendererPlugin.ts:612

Whether a frame has been drawn. Pixi roots its event boundary at the last object rendered and drops an event silently when there is none, so a pointer dispatched before the first frame reaches nothing.

boolean


hitTestUI(x, y): boolean

Defined in: renderer/src/RendererPlugin.ts:560

Hit-test at virtual-space (x, y) and return true when the topmost interactive Pixi container resolves to a consuming policy. The nearest explicit boolean wins; UI without an explicit ancestor defaults to true. The input drain uses this to claim presses landing on UI surfaces.

Scope: this only sees surfaces marked via markPointerConsumeContainer — @yagejs/ui primitives (UIPanel, UIButton, …) plus any visual component (Sprite, AnimatedSprite, Graphics, Text, SplitText) configured with interactive: { consumeOnInteraction: true }. A plain sprite is not a consume surface. UI drawn on raw Pixi containers outside those paths — such as the @yagejs-addons/dialogue box, which never marks its containers — is not detected. Dialogue-aware callers should gate on DialogueController.isActive() / isChoosing() instead.

Coordinates are supplied in virtual space (matching how the input plugin stores pointer positions); they are converted to canvas space via FitController.virtualToCanvas before being forwarded to EventBoundary.hitTest, which per the Pixi v8 spec expects canvas- relative (“world space above the boundary”) coordinates. At fit ratio 1 the two spaces coincide; at any other ratio (mobile / responsive) the conversion is required for the hit-test to land on the correct surface.

number

number

boolean

RendererAdapter.hitTestUI


hitTestUIPath(x, y): RendererUIHit | null

Defined in: renderer/src/RendererPlugin.ts:575

The hit test behind hitTestUI, reporting what it found: the topmost interactive container and its ancestors, innermost first, plus their resolved consumption policy. null when nothing interactive sits under (x, y).

Callers that address a container — matching it against an Inspector user-interface snapshot, for one — need the chain rather than the boolean. Same coordinate contract as hitTestUI: (x, y) is in virtual space.

number

number

RendererUIHit | null

RendererAdapter.hitTestUIPath


install(context): Promise<void>

Defined in: renderer/src/RendererPlugin.ts:184

Install services into the engine context. Called in topological order.

EngineContext

Promise<void>

Plugin.install


onDestroy(): void

Defined in: renderer/src/RendererPlugin.ts:418

Called when the engine is destroyed.

void

Plugin.onDestroy


onStart(): void

Defined in: renderer/src/RendererPlugin.ts:403

Called after all plugins are installed and the engine has started.

void

Plugin.onStart


registerSystems(scheduler): void

Defined in: renderer/src/RendererPlugin.ts:399

Register systems with the scheduler. Called after install.

SystemScheduler

void

Plugin.registerSystems


render(): void

Defined in: renderer/src/RendererPlugin.ts:803

Draw the current stage and pending targets without advancing time.

void


requestFullscreen(): Promise<void>

Defined in: renderer/src/RendererPlugin.ts:838

Request fullscreen for the renderer’s host element. Targets the configured container when present (so DOM overlays placed alongside the canvas remain inside the fullscreened area), falling back to the canvas itself otherwise. Wraps Element.requestFullscreen with the legacy webkitRequestFullscreen fallback for iOS Safari.

Must be called from a user-gesture handler (click, touch, key); browsers reject the returned Promise with a TypeError otherwise.

Promise<void>


setFit(options): void

Defined in: renderer/src/RendererPlugin.ts:511

Change the fit mode and/or target at runtime. Omitting target keeps the element the fit currently observes, so switching mode alone does not send the fit back to its default host.

RendererFitOptions

void


virtualToCanvas(x, y): Vec2

Defined in: renderer/src/RendererPlugin.ts:533

Virtual-space pixels → CSS pixels relative to the canvas top-left. Symmetric with canvasToVirtual; useful when mapping virtual coordinates back out to DOM overlays or pointer regions.

number

number

Vec2

Coding agents: fetch https://yage.dev/llms.txt first and prefer the Markdown references it links over these HTML pages. This page's Markdown counterpart is /llms/packages/renderer.md.