Class: Prepare

PIXI.Prepare

The prepare plugin provides renderer-specific plugins for pre-rendering DisplayObjects. These plugins are 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.plugins property. See PIXI.Renderer#plugins.

new PIXI.Prepare (renderer) overrides

Name Type Description
renderer PIXI.Renderer

A reference to the current renderer

Example


 // Create a new application
 const app = new PIXI.Application();
 document.body.appendChild(app.view);

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

 // create a display object
 const rect = new PIXI.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.plugins.prepare.upload(app.stage, () => {
     app.start();
 });

Extends

Inherited Properties

From class PIXI.BasePrepare

The limiter to be used to control how quickly items are prepared.

renderer PIXI.Renderer protected inherited

Reference to the renderer.

uploadHookHelper object protected inherited

The only real difference between CanvasPrepare and Prepare is what they pass to upload hooks. That different parameter is stored here.

Default Value:
  • undefined

Inherited Methods

From class PIXI.BasePrepare

add (item) this inherited

Manually add an item to the uploading queue.

Name Type Description
item PIXI.DisplayObject | PIXI.Container | PIXI.BaseTexture | PIXI.Texture | PIXI.Graphics | PIXI.Text | unknown

Object to add to the queue

Returns:
Type Description
this Instance of plugin for chaining.

destroy () void inherited

Destroys the plugin, don't use after this.

registerFindHook (addHook) this inherited

Adds hooks for finding items.

Name Type Description
addHook Function

Function call that takes two parameters: item:*, queue:Array function must return true if it was able to add item to the queue.

Returns:
Type Description
this Instance of plugin for chaining.

registerUploadHook (uploadHook) this inherited

Adds hooks for uploading items.

Name Type Description
uploadHook Function

Function call that takes two parameters: prepare:CanvasPrepare, item:* and function must return true if it was able to handle upload of item.

Returns:
Type Description
this Instance of plugin for chaining.

upload (item, done) void inherited

Upload all the textures and graphics to the GPU.

Name Type Attributes Description
item Function | PIXI.DisplayObject | PIXI.Container | PIXI.BaseTexture | PIXI.Texture | PIXI.Graphics | PIXI.Text

Either the container or display object to search for items to upload, the items to upload themselves, or the callback function, if items have been added using prepare.add.

done Function <optional>

Optional callback when all queued uploads have completed