Class: PrepareSystem

PrepareSystem

The prepare system provides renderer-specific plugins for pre-rendering DisplayObjects. This is useful for asynchronously preparing and uploading to the GPU assets, textures, graphics waiting to be displayed.

Do not instantiate this plugin directly. It is available from the renderer.prepare property.

new PrepareSystem () overrides

Example

 import 'pixi.js/prepare';
 import { Application, Graphics } from 'pixi.js';

 // Create a new application (prepare will be auto-added to renderer)
 const app = new Application();
 await app.init();
 document.body.appendChild(app.view);

 // Don't start rendering right away
 app.stop();

 // Create a display object
 const rect = new Graphics()
     .beginFill(0x00ff00)
     .drawRect(40, 40, 200, 200);

 // Add to the stage
 app.stage.addChild(rect);

 // Don't start rendering until the graphic is uploaded to the GPU
 app.renderer.prepare.upload(app.stage, () => {
     app.start();
 });

Extends

Implements

Methods

destroy () void

Destroys the plugin, don't use after this.

Inherited Properties

From class PrepareBase

queue PrepareQueueItem[] protected inherited

The queue to process over a async timer

renderer Renderer protected inherited

Reference to the renderer

resolves ((value: void | PromiseLike<void>) => void)[] protected inherited

Collection of callbacks to call when the uploads are finished

timeout number protected inherited

Timeout id for next processing call

Inherited Methods

From class PrepareUpload

uploadGraphicsContext (graphicsContext) void protected inherited

Resolve the given graphics context and return an item for the queue

Name Type Description
graphicsContext GraphicsContext

uploadQueueItem (item) void protected inherited

Upload the given queue item

Name Type Description
item PrepareQueueItem

From class PrepareQueue

resolveContainerQueueItem (container, queue) void protected inherited

Resolve the given container and return an item for the queue

Name Type Description
container Container
queue PrepareQueueItem[]

resolveGraphicsContextQueueItem (graphicsContext) PrepareQueueItem | null protected inherited

Resolve the given graphics context and return an item for the queue

Name Type Description
graphicsContext GraphicsContext
Returns:
Type Description
PrepareQueueItem | null

resolveQueueItem (source, queue) void protected inherited

Resolve the given resource type and return an item for the queue

Name Type Description
source PrepareSourceItem
queue PrepareQueueItem[]

From class PrepareBase

add (resource) this inherited

Add a textures or graphics resource to the queue

Name Type Description
resource PrepareSourceItem | PrepareSourceItem<Array>
Returns:
Type Description
this

dedupeQueue () void inherited

eliminate duplicates before processing

getQueue () Array<PrepareQueueItem> inherited

Return a copy of the queue

Returns:
Type Description
Array<PrepareQueueItem> The queue

upload (resource) Promise<void> inherited

Upload all the textures and graphics to the GPU (optionally add more resources to the queue first)

Name Type Attributes Description
resource PrepareSourceItem | PrepareSourceItem<Array> | unknown <optional>
Returns:
Type Description
Promise<void>