LogoPixi’VN
pixi-jsClasses

Class: TextureSource<T>

Defined in: node_modules/pixi.js/lib/rendering/renderers/shared/texture/sources/TextureSource.d.ts:89

A TextureSource stores the information that represents an image. All textures have require TextureSource, which contains information about the source. Therefore you can have many textures all using a single TextureSource (eg a sprite sheet)

This is an class is extended depending on the source of the texture. Eg if you are using an an image as your resource, then an ImageSource is used.

Advanced

Extends

  • EventEmitter<{ change: BindResource; destroy: TextureSource; error: Error; resize: TextureSource; styleChange: TextureSource; unload: TextureSource; update: TextureSource; updateMipmaps: TextureSource; }>

Extended by

Type Parameters

T

T extends Record<string, any> = any

Implements

Constructors

Constructor

> new TextureSource<T>(options?): TextureSource<T>

Defined in: node_modules/pixi.js/lib/rendering/renderers/shared/texture/sources/TextureSource.d.ts:220

Parameters

options?

TextureSourceOptions<T>

options for creating a new TextureSource

Returns

TextureSource<T>

Overrides

EventEmitter.constructor

Properties

_batchTick

> protected _batchTick: number

Defined in: node_modules/pixi.js/lib/rendering/renderers/shared/texture/sources/TextureSource.d.ts:203

Used by the batcher to build texture batches. faster to have the variable here!


_gcData?

> optional _gcData?: GCData

Defined in: node_modules/pixi.js/lib/rendering/renderers/shared/texture/sources/TextureSource.d.ts:105

GC tracking data, undefined if not being tracked

Implementation of

GCable._gcData


_gcLastUsed

> _gcLastUsed: number

Defined in: node_modules/pixi.js/lib/rendering/renderers/shared/texture/sources/TextureSource.d.ts:107

Internal

Implementation of

GCable._gcLastUsed


_gpuData

> _gpuData: Record<number, GlTexture | GPUTextureGpuData>

Defined in: node_modules/pixi.js/lib/rendering/renderers/shared/texture/sources/TextureSource.d.ts:103

Internal

Implementation of

GCable._gpuData


_resolution

> _resolution: number

Defined in: node_modules/pixi.js/lib/rendering/renderers/shared/texture/sources/TextureSource.d.ts:132

Internal


_resourceId

> _resourceId: number

Defined in: node_modules/pixi.js/lib/rendering/renderers/shared/texture/sources/TextureSource.d.ts:123

Internal

i unique resource id, used by the bind group systems. This can change if the texture is resized or its resource changes

Implementation of

BindResource._resourceId


_resourceType

> readonly _resourceType: "textureSource" = "textureSource"

Defined in: node_modules/pixi.js/lib/rendering/renderers/shared/texture/sources/TextureSource.d.ts:117

Internal

The resource type used by this TextureSource. This is used by the bind groups to determine how to handle this resource.

Implementation of

BindResource._resourceType


_textureBindLocation

> protected _textureBindLocation: number

Defined in: node_modules/pixi.js/lib/rendering/renderers/shared/texture/sources/TextureSource.d.ts:208

A temporary batch location for the texture batching. Here for performance reasons only!


_touched

> protected _touched: number

Defined in: node_modules/pixi.js/lib/rendering/renderers/shared/texture/sources/TextureSource.d.ts:198

Used by automatic texture Garbage Collection, stores last GC tick when it was bound

Implementation of

BindResource._touched


alphaMode

> alphaMode: ALPHA_MODES

Defined in: node_modules/pixi.js/lib/rendering/renderers/shared/texture/sources/TextureSource.d.ts:181

the alpha mode of the texture


antialias

> antialias: boolean

Defined in: node_modules/pixi.js/lib/rendering/renderers/shared/texture/sources/TextureSource.d.ts:188

Only really affects RenderTextures. Should we use antialiasing for this texture. It will look better, but may impact performance as a Blit operation will be required to resolve the texture.


arrayLayerCount

> arrayLayerCount: number

Defined in: node_modules/pixi.js/lib/rendering/renderers/shared/texture/sources/TextureSource.d.ts:179

how many array layers this texture has (WebGPU depthOrArrayLayers)


autoGarbageCollect

> autoGarbageCollect: boolean

Defined in: node_modules/pixi.js/lib/rendering/renderers/shared/texture/sources/TextureSource.d.ts:211

If true, the Garbage Collector will unload this texture if it is not used after a period of time

Implementation of

GCable.autoGarbageCollect


autoGenerateMipmaps

> autoGenerateMipmaps: boolean

Defined in: node_modules/pixi.js/lib/rendering/renderers/shared/texture/sources/TextureSource.d.ts:171

Should we auto generate mipmaps for this texture? This will automatically generate mipmaps for this texture when uploading to the GPU. Mipmapped textures take up more memory, but can look better when scaled down.

For performance reasons, it is recommended to NOT use this with RenderTextures, as they are often updated every frame. If you do, make sure to call updateMipmaps after you update the texture.


destroyed

> readonly destroyed: boolean

Defined in: node_modules/pixi.js/lib/rendering/renderers/shared/texture/sources/TextureSource.d.ts:193

Has the source been destroyed?

Implementation of

BindResource.destroyed


dimension

> dimension: TEXTURE_DIMENSIONS

Defined in: node_modules/pixi.js/lib/rendering/renderers/shared/texture/sources/TextureSource.d.ts:175

how many dimensions does this texture have? currently v8 only supports 2d


format

> format: TEXTURE_FORMATS

Defined in: node_modules/pixi.js/lib/rendering/renderers/shared/texture/sources/TextureSource.d.ts:173

the format that the texture data has


height

> height: number

Defined in: node_modules/pixi.js/lib/rendering/renderers/shared/texture/sources/TextureSource.d.ts:146

the height of this texture source, accounting for resolution eg pixelHeight 200, resolution 2, then height will be 100


isPowerOfTwo

> isPowerOfTwo: boolean

Defined in: node_modules/pixi.js/lib/rendering/renderers/shared/texture/sources/TextureSource.d.ts:209


label

> label: string

Defined in: node_modules/pixi.js/lib/rendering/renderers/shared/texture/sources/TextureSource.d.ts:111

optional label, can be used for debugging


mipLevelCount

> mipLevelCount: number

Defined in: node_modules/pixi.js/lib/rendering/renderers/shared/texture/sources/TextureSource.d.ts:162

The number of mip levels to generate for this texture. this is overridden if autoGenerateMipmaps is true. it is read only!


options

> protected readonly options: TextureSourceOptions<T>

Defined in: node_modules/pixi.js/lib/rendering/renderers/shared/texture/sources/TextureSource.d.ts:99


pixelHeight

> pixelHeight: number

Defined in: node_modules/pixi.js/lib/rendering/renderers/shared/texture/sources/TextureSource.d.ts:136

the pixel height of this texture source. This is the REAL pure number, not accounting resolution


pixelWidth

> pixelWidth: number

Defined in: node_modules/pixi.js/lib/rendering/renderers/shared/texture/sources/TextureSource.d.ts:134

the pixel width of this texture source. This is the REAL pure number, not accounting resolution


resource

> resource: T

Defined in: node_modules/pixi.js/lib/rendering/renderers/shared/texture/sources/TextureSource.d.ts:151

the resource that will be uploaded to the GPU. This is where we get our pixels from eg an ImageBimt / Canvas / Video etc


sampleCount

> sampleCount: number

Defined in: node_modules/pixi.js/lib/rendering/renderers/shared/texture/sources/TextureSource.d.ts:157

Internal

The number of samples of a multisample texture. This is always 1 for non-multisample textures. To enable multisample for a texture, set antialias to true


uid

> readonly uid: number

Defined in: node_modules/pixi.js/lib/rendering/renderers/shared/texture/sources/TextureSource.d.ts:109

unique id for this Texture source


uploadMethodId

> uploadMethodId: string

Defined in: node_modules/pixi.js/lib/rendering/renderers/shared/texture/sources/TextureSource.d.ts:130

Internal

this is how the backends know how to upload this texture to the GPU It changes depending on the resource type. Classes that extend TextureSource should override this property.


viewDimension

> viewDimension: TEXTURE_VIEW_DIMENSIONS

Defined in: node_modules/pixi.js/lib/rendering/renderers/shared/texture/sources/TextureSource.d.ts:177

how this texture is viewed/sampled by shaders (WebGPU view dimension)


width

> width: number

Defined in: node_modules/pixi.js/lib/rendering/renderers/shared/texture/sources/TextureSource.d.ts:141

the width of this texture source, accounting for resolution eg pixelWidth 200, resolution 2, then width will be 100


defaultOptions

> static defaultOptions: TextureSourceOptions

Defined in: node_modules/pixi.js/lib/rendering/renderers/shared/texture/sources/TextureSource.d.ts:101

The default options used when creating a new TextureSource. override these to add your own defaults


from

> static from: (resource) => TextureSource

Defined in: node_modules/pixi.js/lib/rendering/renderers/shared/texture/sources/TextureSource.d.ts:307

A helper function that creates a new TextureSource based on the resource you provide.

Parameters

resource

TextureResourceOrOptions

The resource to create the texture source from.

Returns

TextureSource


prefixed

> static prefixed: string | boolean

Defined in: node_modules/eventemitter3/index.d.ts:9

Inherited from

EventEmitter.prefixed

Accessors

addressMode

Get Signature

> get addressMode(): WRAP_MODE

Defined in: node_modules/pixi.js/lib/rendering/renderers/shared/texture/sources/TextureSource.d.ts:230

setting this will set wrapModeU, wrapModeV and wrapModeW all at once!

Returns

WRAP_MODE

Set Signature

> set addressMode(value): void

Defined in: node_modules/pixi.js/lib/rendering/renderers/shared/texture/sources/TextureSource.d.ts:231

Parameters
value

WRAP_MODE

Returns

void


lodMaxClamp

Get Signature

> get lodMaxClamp(): number

Defined in: node_modules/pixi.js/lib/rendering/renderers/shared/texture/sources/TextureSource.d.ts:248

Specifies the minimum and maximum levels of detail, respectively, used internally when sampling a texture.

Returns

number

Set Signature

> set lodMaxClamp(value): void

Defined in: node_modules/pixi.js/lib/rendering/renderers/shared/texture/sources/TextureSource.d.ts:249

Parameters
value

number

Returns

void


lodMinClamp

Get Signature

> get lodMinClamp(): number

Defined in: node_modules/pixi.js/lib/rendering/renderers/shared/texture/sources/TextureSource.d.ts:245

Specifies the minimum and maximum levels of detail, respectively, used internally when sampling a texture.

Returns

number

Set Signature

> set lodMinClamp(value): void

Defined in: node_modules/pixi.js/lib/rendering/renderers/shared/texture/sources/TextureSource.d.ts:246

Parameters
value

number

Returns

void


magFilter

Get Signature

> get magFilter(): SCALE_MODE

Defined in: node_modules/pixi.js/lib/rendering/renderers/shared/texture/sources/TextureSource.d.ts:236

Specifies the sampling behavior when the sample footprint is smaller than or equal to one texel.

Returns

SCALE_MODE

Set Signature

> set magFilter(value): void

Defined in: node_modules/pixi.js/lib/rendering/renderers/shared/texture/sources/TextureSource.d.ts:237

Parameters
value

SCALE_MODE

Returns

void


maxAnisotropy

Get Signature

> get maxAnisotropy(): number

Defined in: node_modules/pixi.js/lib/rendering/renderers/shared/texture/sources/TextureSource.d.ts:228

Returns

number

Set Signature

> set maxAnisotropy(value): void

Defined in: node_modules/pixi.js/lib/rendering/renderers/shared/texture/sources/TextureSource.d.ts:227

Specifies the maximum anisotropy value clamp used by the sampler.

Parameters
value

number

Returns

void


minFilter

Get Signature

> get minFilter(): SCALE_MODE

Defined in: node_modules/pixi.js/lib/rendering/renderers/shared/texture/sources/TextureSource.d.ts:239

Specifies the sampling behavior when the sample footprint is larger than one texel.

Returns

SCALE_MODE

Set Signature

> set minFilter(value): void

Defined in: node_modules/pixi.js/lib/rendering/renderers/shared/texture/sources/TextureSource.d.ts:240

Parameters
value

SCALE_MODE

Returns

void


mipmapFilter

Get Signature

> get mipmapFilter(): SCALE_MODE

Defined in: node_modules/pixi.js/lib/rendering/renderers/shared/texture/sources/TextureSource.d.ts:242

Specifies behavior for sampling between mipmap levels.

Returns

SCALE_MODE

Set Signature

> set mipmapFilter(value): void

Defined in: node_modules/pixi.js/lib/rendering/renderers/shared/texture/sources/TextureSource.d.ts:243

Parameters
value

SCALE_MODE

Returns

void


repeatMode

Get Signature

> get repeatMode(): WRAP_MODE

Defined in: node_modules/pixi.js/lib/rendering/renderers/shared/texture/sources/TextureSource.d.ts:233

setting this will set wrapModeU, wrapModeV and wrapModeW all at once!

Returns

WRAP_MODE

Set Signature

> set repeatMode(value): void

Defined in: node_modules/pixi.js/lib/rendering/renderers/shared/texture/sources/TextureSource.d.ts:234

Parameters
value

WRAP_MODE

Returns

void


resolution

Get Signature

> get resolution(): number

Defined in: node_modules/pixi.js/lib/rendering/renderers/shared/texture/sources/TextureSource.d.ts:271

the resolution of the texture. Changing this number, will not change the number of pixels in the actual texture but will the size of the texture when rendered.

changing the resolution of this texture to 2 for example will make it appear twice as small when rendered (as pixel density will have increased)

Returns

number

Set Signature

> set resolution(resolution): void

Defined in: node_modules/pixi.js/lib/rendering/renderers/shared/texture/sources/TextureSource.d.ts:272

Parameters
resolution

number

Returns

void


resourceHeight

Get Signature

> get resourceHeight(): number

Defined in: node_modules/pixi.js/lib/rendering/renderers/shared/texture/sources/TextureSource.d.ts:263

the height of the resource. This is the REAL pure number, not accounting resolution

Returns

number


resourceWidth

Get Signature

> get resourceWidth(): number

Defined in: node_modules/pixi.js/lib/rendering/renderers/shared/texture/sources/TextureSource.d.ts:261

the width of the resource. This is the REAL pure number, not accounting resolution

Returns

number


scaleMode

Get Signature

> get scaleMode(): SCALE_MODE

Defined in: node_modules/pixi.js/lib/rendering/renderers/shared/texture/sources/TextureSource.d.ts:296

setting this will set magFilter,minFilter and mipmapFilter all at once!

Returns

SCALE_MODE

Set Signature

> set scaleMode(value): void

Defined in: node_modules/pixi.js/lib/rendering/renderers/shared/texture/sources/TextureSource.d.ts:294

Parameters
value

SCALE_MODE

Returns

void


source

Get Signature

> get source(): TextureSource

Defined in: node_modules/pixi.js/lib/rendering/renderers/shared/texture/sources/TextureSource.d.ts:222

returns itself

Returns

TextureSource


style

Get Signature

> get style(): TextureStyle

Defined in: node_modules/pixi.js/lib/rendering/renderers/shared/texture/sources/TextureSource.d.ts:224

the style of the texture

Returns

TextureStyle

Set Signature

> set style(value): void

Defined in: node_modules/pixi.js/lib/rendering/renderers/shared/texture/sources/TextureSource.d.ts:225

Parameters
value

TextureStyle

Returns

void


wrapMode

Get Signature

> get wrapMode(): WRAP_MODE

Defined in: node_modules/pixi.js/lib/rendering/renderers/shared/texture/sources/TextureSource.d.ts:293

Returns

WRAP_MODE

Set Signature

> set wrapMode(value): void

Defined in: node_modules/pixi.js/lib/rendering/renderers/shared/texture/sources/TextureSource.d.ts:292

Parameters
value

WRAP_MODE

Returns

void

Methods

addListener()

> addListener<T>(event, fn, context?): this

Defined in: node_modules/eventemitter3/index.d.ts:45

Type Parameters

T

T extends "error" | "update" | "change" | "resize" | "destroy" | "unload" | "styleChange" | "updateMipmaps"

Parameters

event

T

fn

(...args) => void

context?

any

Returns

this

Inherited from

EventEmitter.addListener


destroy()

> destroy(): void

Defined in: node_modules/pixi.js/lib/rendering/renderers/shared/texture/sources/TextureSource.d.ts:254

Destroys this texture source

Returns

void


emit()

> emit<T>(event, ...args): boolean

Defined in: node_modules/eventemitter3/index.d.ts:32

Calls each of the listeners registered for a given event.

Type Parameters

T

T extends "error" | "update" | "change" | "resize" | "destroy" | "unload" | "styleChange" | "updateMipmaps"

Parameters

event

T

args

...ArgumentMap<{ change: BindResource; destroy: TextureSource; error: Error; resize: TextureSource; styleChange: TextureSource; unload: TextureSource; update: TextureSource; updateMipmaps: TextureSource; }>[Extract<T, "error" | "update" | "change" | "resize" | "destroy" | "unload" | "styleChange" | "updateMipmaps">]

Returns

boolean

Inherited from

EventEmitter.emit


eventNames()

> eventNames(): ("error" | "update" | "change" | "resize" | "destroy" | "unload" | "styleChange" | "updateMipmaps")[]

Defined in: node_modules/eventemitter3/index.d.ts:15

Return an array listing the events for which the emitter has registered listeners.

Returns

("error" | "update" | "change" | "resize" | "destroy" | "unload" | "styleChange" | "updateMipmaps")[]

Inherited from

EventEmitter.eventNames


listenerCount()

> listenerCount(event): number

Defined in: node_modules/eventemitter3/index.d.ts:27

Return the number of listeners listening to a given event.

Parameters

event

"error" | "update" | "change" | "resize" | "destroy" | "unload" | "styleChange" | "updateMipmaps"

Returns

number

Inherited from

EventEmitter.listenerCount


listeners()

> listeners<T>(event): (...args) => void[]

Defined in: node_modules/eventemitter3/index.d.ts:20

Return the listeners registered for a given event.

Type Parameters

T

T extends "error" | "update" | "change" | "resize" | "destroy" | "unload" | "styleChange" | "updateMipmaps"

Parameters

event

T

Returns

(...args) => void[]

Inherited from

EventEmitter.listeners


off()

> off<T>(event, fn?, context?, once?): this

Defined in: node_modules/eventemitter3/index.d.ts:69

todo

Type Parameters

T

T extends "error" | "update" | "change" | "resize" | "destroy" | "unload" | "styleChange" | "updateMipmaps"

Parameters

event

T

fn?

(...args) => void

context?

any

once?

boolean

Returns

this

Implementation of

BindResource.off

Inherited from

EventEmitter.off


on()

> on<T>(event, fn, context?): this

Defined in: node_modules/eventemitter3/index.d.ts:40

Add a listener for a given event.

Type Parameters

T

T extends "error" | "update" | "change" | "resize" | "destroy" | "unload" | "styleChange" | "updateMipmaps"

Parameters

event

T

fn

(...args) => void

context?

any

Returns

this

Implementation of

BindResource.on

Inherited from

EventEmitter.on


once()

> once<T>(event, fn, context?): this

Defined in: node_modules/eventemitter3/index.d.ts:54

Add a one-time listener for a given event.

Type Parameters

T

T extends "error" | "update" | "change" | "resize" | "destroy" | "unload" | "styleChange" | "updateMipmaps"

Parameters

event

T

fn

(...args) => void

context?

any

Returns

this

Inherited from

EventEmitter.once


removeAllListeners()

> removeAllListeners(event?): this

Defined in: node_modules/eventemitter3/index.d.ts:79

Remove all listeners, or those of the specified event.

Parameters

event?

"error" | "update" | "change" | "resize" | "destroy" | "unload" | "styleChange" | "updateMipmaps"

Returns

this

Inherited from

EventEmitter.removeAllListeners


removeListener()

> removeListener<T>(event, fn?, context?, once?): this

Defined in: node_modules/eventemitter3/index.d.ts:63

Remove the listeners of a given event.

Type Parameters

T

T extends "error" | "update" | "change" | "resize" | "destroy" | "unload" | "styleChange" | "updateMipmaps"

Parameters

event

T

fn?

(...args) => void

context?

any

once?

boolean

Returns

this

Inherited from

EventEmitter.removeListener


resize()

> resize(width?, height?, resolution?): boolean

Defined in: node_modules/pixi.js/lib/rendering/renderers/shared/texture/sources/TextureSource.d.ts:280

Resize the texture, this is handy if you want to use the texture as a render texture

Parameters

width?

number

the new width of the texture

height?

number

the new height of the texture

resolution?

number

the new resolution of the texture

Returns

boolean

  • if the texture was resized

unload()

> unload(): void

Defined in: node_modules/pixi.js/lib/rendering/renderers/shared/texture/sources/TextureSource.d.ts:259

This will unload the Texture source from the GPU. This will free up the GPU memory As soon as it is required fore rendering, it will be re-uploaded.

Returns

void

Implementation of

GCable.unload


update()

> update(): void

Defined in: node_modules/pixi.js/lib/rendering/renderers/shared/texture/sources/TextureSource.d.ts:252

call this if you have modified the texture outside of the constructor

Returns

void


updateMipmaps()

> updateMipmaps(): void

Defined in: node_modules/pixi.js/lib/rendering/renderers/shared/texture/sources/TextureSource.d.ts:291

Lets the renderer know that this texture has been updated and its mipmaps should be re-generated. This is only important for RenderTexture instances, as standard Texture instances will have their mipmaps generated on upload. You should call this method after you make any change to the texture

The reason for this is is can be quite expensive to update mipmaps for a texture. So by default, We want you, the developer to specify when this action should happen.

Generally you don't want to have mipmaps generated on Render targets that are changed every frame,

Returns

void


test()

> static test(_resource): any

Defined in: node_modules/pixi.js/lib/rendering/renderers/shared/texture/sources/TextureSource.d.ts:302

Parameters

_resource

any

Returns

any