PIXI.Resource

class Resource

Base resource class for textures that manages validation and uploading, depending on its type.

Uploading of a base texture to the GPU is required.

Constructor


new PIXI.Resource(width: number, height: number) → {}
Parameters:
Name Type Default Description
width number 0

Width of the resource

height number 0

Height of the resource

Summary


Properties from Resource

boolean
destroyed = false
number
height
boolean
internal
string
src

The url of the resource

boolean
valid
number
width
number
protected _height

Internal height of the resource.

number
protected _width

Internal width of the resource.

Methods from Resource

boolean
static test(_source: unknown, _extension: string)
void
bind(baseTexture: PIXI.BaseTexture)
void
destroy()
void
dispose()

Clean up anything, this happens when destroying is ready.

void
resize(width: number, height: number)
boolean
style(_renderer: PIXI.Renderer, _baseTexture: PIXI.BaseTexture, _glTexture: PIXI.GLTexture)
void
unbind(baseTexture: PIXI.BaseTexture)
void
update()

Has been updated trigger event.

boolean
upload(renderer: PIXI.Renderer, baseTexture: PIXI.BaseTexture, glTexture: PIXI.GLTexture)
Promise<PIXI.Resource>
protected load()

Public Properties


destroyed Resource.ts:18
destroyed: boolean = false

If resource has been destroyed.

height Resource.ts:161
height: number

The height of the resource.

internal Resource.ts:25
internal: boolean

true if resource is created by BaseTexture useful for doing cleanup with BaseTexture destroy and not cleaning up resources that were created externally.

src Resource.ts:15
src: string

The url of the resource

valid Resource.ts:123
valid: boolean

Has been validated

width Resource.ts:152
width: number

The width of the resource.

Protected Properties


_height Resource.ts:36
protected _height: number

Internal height of the resource.

_width Resource.ts:33
protected _width: number

Internal width of the resource.

Public Methods


test Resource.ts:217
static test(_source: unknown, _extension: string) → {boolean}

Abstract, used to auto-detect resource type.

Parameters:
Name Type Attributes Description
_source unknown

The source object

_extension string

<optional>

The extension of source, if set

Returns:
Type Description
boolean
bind Resource.ts:79
bind(baseTexture: PIXI.BaseTexture) → {void}

Bind to a parent BaseTexture

Parameters:
Name Type Description
baseTexture PIXI.BaseTexture

Parent texture

Returns:
Type Description
void
destroy Resource.ts:197
destroy() → {void}

Call when destroying resource, unbind any BaseTexture object before calling this method, as reference counts are maintained internally.

Returns:
Type Description
void
dispose Resource.ts:191
dispose() → {void}

Clean up anything, this happens when destroying is ready.

Returns:
Type Description
void
resize Resource.ts:108
resize(width: number, height: number) → {void}

Trigger a resize event

Parameters:
Name Type Description
width number

X dimension

height number

Y dimension

Returns:
Type Description
void
style Resource.ts:179
style(_renderer: PIXI.Renderer, _baseTexture: PIXI.BaseTexture, _glTexture: PIXI.GLTexture) → {boolean}

Set the style, optional to override

Parameters:
Name Type Description
_renderer PIXI.Renderer

yeah, renderer!

_baseTexture PIXI.BaseTexture

the texture

_glTexture PIXI.GLTexture

texture instance for this webgl context

Returns:
Type Description
boolean
  • true is success
unbind Resource.ts:97
unbind(baseTexture: PIXI.BaseTexture) → {void}

Unbind to a parent BaseTexture

Parameters:
Name Type Description
baseTexture PIXI.BaseTexture

Parent texture

Returns:
Type Description
void
update Resource.ts:132
update() → {void}

Has been updated trigger event.

Returns:
Type Description
void
upload Resource.ts:170
upload(renderer: PIXI.Renderer, baseTexture: PIXI.BaseTexture, glTexture: PIXI.GLTexture) → {boolean}

Uploads the texture or returns false if it cant for some reason. Override this.

Parameters:
Name Type Description
renderer PIXI.Renderer

yeah, renderer!

baseTexture PIXI.BaseTexture

the texture

glTexture PIXI.GLTexture

texture instance for this webgl context

Returns:
Type Description
boolean
  • true is success

Protected Methods


load Resource.ts:141
protected load() → {Promise<PIXI.Resource>}

This can be overridden to start preloading a resource or do any other prepare step.

Returns:
Type Description
Promise<PIXI.Resource>

Handle the validate event


Powered by webdoc!