Options
All
  • Public
  • Public/Protected
  • All
Menu

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 {@link PIXI.CanvasRenderer#plugins} or {@link PIXI.Renderer#plugins}.

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(); });

memberof

PIXI

Hierarchy

Index

Constructors

constructor

Properties

addHooks

addHooks: any[]

completes

completes: any[]

Protected queue

queue: any[]

Protected renderer

ticking

ticking: boolean

Protected uploadHookHelper

uploadHookHelper: any

uploadHooks

uploadHooks: any[]

Methods

add

  • Manually add an item to the uploading queue.

    Parameters

    Returns Prepare

    Instance of plugin for chaining.

destroy

  • destroy(): void
  • Destroys the plugin, don't use after this.

    Returns void

Private prepareItems

  • prepareItems(): void
  • Actually prepare items. This is handled outside of the tick because it will take a while and we do NOT want to block the current animation frame from rendering.

    Returns void

registerFindHook

  • registerFindHook(addHook: IFindHook): Prepare
  • Adds hooks for finding items.

    Parameters

    • addHook: IFindHook

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

    Returns Prepare

    Instance of plugin for chaining.

registerUploadHook

  • registerUploadHook(uploadHook: IUploadHook): Prepare
  • Adds hooks for uploading items.

    Parameters

    • uploadHook: IUploadHook

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

    Returns Prepare

    Instance of plugin for chaining.

Private tick

  • tick(): void
  • Handle tick update

    Returns void

upload

  • Upload all the textures and graphics to the GPU.

    Parameters

    • item: IDisplayObjectExtended | IUploadHook | IFindHook | (() => void)

      - 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.

    • Optional done: () => void
        • (): void
        • Returns void

    Returns void

Generated using TypeDoc