Class: Resource

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

new PIXI.Resource (width, height)

Name Type Attributes Default Description
width number <optional>
0

Width of the resource

height number <optional>
0

Height of the resource

Members

destroyed boolean

If resource has been destroyed

Default Value:
  • false

height number

The height of the resource.

valid boolean

Has been validated

width number

The width of the resource.

_height number protected

Internal height of the resource

_width number protected

Internal width of the resource

internal boolean protected

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

Methods

PIXI.Resource.test (source, extension) boolean static

Abstract, used to auto-detect resource type

Name Type Attributes Description
source unknown

The source object

extension string <optional>

The extension of source, if set

Returns:
Type Description
boolean

bind (baseTexture) void

Bind to a parent BaseTexture

Name Type Description
baseTexture PIXI.BaseTexture

Parent texture

destroy () void

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

resize (width, height) void

Trigger a resize event

Name Type Description
width number

X dimension

height number

Y dimension

style (renderer, baseTexture, glTexture) boolean

Set the style, optional to override

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 (baseTexture) void

Unbind to a parent BaseTexture

Name Type Description
baseTexture PIXI.BaseTexture

Parent texture

update () void

Has been updated trigger event

upload (renderer, baseTexture, glTexture) boolean abstract

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

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

dispose () void protected

Clean up anything, this happens when destroying is ready.

load () Promise<void> protected

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

Returns:
Type Description
Promise<void> Handle the validate event