Class: BasePrepare

PIXI.prepare.BasePrepare

The prepare manager provides functionality to upload content to the GPU. BasePrepare handles basic queuing functionality and is extended by PIXI.prepare.WebGLPrepare and PIXI.prepare.CanvasPrepare to provide preparation capabilities specific to their respective renderers.

new PIXI.prepare.BasePrepare (renderer) abstract

Name Type Description
renderer PIXI.SystemRenderer

A reference to the current renderer

Example
// Create a sprite
const sprite = new PIXI.Sprite.fromImage('something.png');

// Load object into GPU
app.renderer.plugins.prepare.upload(sprite, () => {

    //Texture(s) has been uploaded to GPU
    app.stage.addChild(sprite);

})

Methods

add (item)PIXI.CanvasPrepare

Manually add an item to the uploading queue.

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

Object to add to the queue

Returns:
Type Description
PIXI.CanvasPrepare Instance of plugin for chaining.

destroy ()

Destroys the plugin, don't use after this.

register (addHook, uploadHook)PIXI.BasePrepare Deprecated : since version 4.4.2

Name Type Description
addHook function optional

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

uploadHook function optional

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

See:
Returns:
Type Description
PIXI.BasePrepare Instance of plugin for chaining.

registerFindHook (addHook)PIXI.BasePrepare

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
PIXI.BasePrepare Instance of plugin for chaining.

registerUploadHook (uploadHook)PIXI.BasePrepare

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
PIXI.BasePrepare Instance of plugin for chaining.

upload (item, done)

Upload all the textures and graphics to the GPU.

Name Type 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