Class: BasePrepare

PIXI.BasePrepare

The prepare manager provides functionality to upload content to the GPU.

BasePrepare handles basic queuing functionality and is extended by PIXI.Prepare and PIXI.CanvasPrepare to provide preparation capabilities specific to their respective renderers.

new PIXI.BasePrepare (renderer)

Name Type Description
renderer PIXI.IRenderer

A reference to the current renderer

Example


 // Create a sprite
 const sprite = PIXI.Sprite.from('something.png');

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

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

 })

Members

addHooks Array<Function>

Collection of additional hooks for finding assets.

completes Array<Function>

Callback to call after completed.

ticking boolean

If prepare is ticking (running).

uploadHooks Array<Function>

Collection of additional hooks for processing assets.

queue Array<any> protected

Collection of items to uploads at once.

renderer PIXI.IRenderer protected

Reference to the renderer.

uploadHookHelper any protected

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

Methods

add (item) this

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

Destroys the plugin, don't use after this.

registerFindHook (addHook) this

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

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) Promise<void>

Upload all the textures and graphics to the GPU.

Name Type Attributes Description
item PIXI.DisplayObject | PIXI.Container | PIXI.BaseTexture | PIXI.Texture | PIXI.Graphics | PIXI.Text <optional>

Container or display object to search for items to upload or the items to upload themselves, or optionally ommitted, if items have been added using prepare.add.

Returns:
Type Description
Promise<void>