TextureLoader

TextureLoader

A Loader class which helps with loading video and image textures

Constructor

new TextureLoader()

Members

(static) loader :TextureLoader

A global reference to the singleton texture loader

Type:

cache :Map.<string, {tex: PIXI.BaseTexture, time: number}>

The cached mapping of textures

Type:
  • Map.<string, {tex: PIXI.BaseTexture, time: number}>

CACHE_TTL :number

The duration in milliseconds for which a texture will remain cached

Type:
  • number

Methods

(static) loadSceneTextures(scene, optionsopt) → {Promise.<Array.<void>>}

Load all the textures which are required for a particular Scene

Parameters:
Name Type Attributes Default Description
scene Scene

The Scene to load

options object <optional>
{}

Additional options that configure texture loading

Properties
Name Type Attributes Default Description
expireCache boolean <optional>
true

Destroy other expired textures

Returns:
Type
Promise.<Array.<void>>

expireCache()

Expire (and destroy) textures from the cache which have not been used for more than CACHE_TTL milliseconds.

getCache(src) → {PIXI.BaseTexture}

Retrieve a texture from the texture cache

Parameters:
Name Type Description
src string

The source URL

Returns:

The cached texture, or undefined

Type
PIXI.BaseTexture

(async) load(sources, optionsopt) → {Promise.<Array.<void>>}

Load an Array of provided source URL paths

Parameters:
Name Type Attributes Default Description
sources Array.<string>

The source URLs to load

options object <optional>
{}

Additional options which modify loading

Properties
Name Type Attributes Default Description
message string <optional>

The status message to display in the load bar

expireCache boolean <optional>
false

Expire other cached textures?

Returns:

A Promise which resolves once all textures are loaded

Type
Promise.<Array.<void>>

(async) loadImageTexture(src) → {Promise.<PIXI.BaseTexture>}

Load an image texture from a provided source url

Parameters:
Name Type Description
src string
Returns:
Type
Promise.<PIXI.BaseTexture>

(async) loadTexture(src) → {Promise.<PIXI.BaseTexture>}

Load a single texture on-demand from a given source URL path

Parameters:
Name Type Description
src string

The source texture path to load

Returns:

The loaded texture object

Type
Promise.<PIXI.BaseTexture>

(async) loadVideoTexture(src) → {Promise.<PIXI.BaseTexture>}

Load a video texture from a provided source url

Parameters:
Name Type Description
src string
Returns:
Type
Promise.<PIXI.BaseTexture>

setCache(src, tex)

Add an image url to the texture cache

Parameters:
Name Type Description
src string

The source URL

tex PIXI.BaseTexture

The loaded base texture