Options
All
  • Public
  • Public/Protected
  • All
Menu

Class StandardMaterialTexture

Represents a texture which can have a transform.

Hierarchy

Index

Constructors

constructor

  • new StandardMaterialTexture(baseTexture: BaseTexture<Resource, IAutoDetectOptions>, uvSet?: number): StandardMaterialTexture

Properties

_frame

_frame: Rectangle

This is the area of the BaseTexture image to actually copy to the Canvas / WebGL when rendering, irrespective of the actual frame size or placement (which can be influenced by trimmed texture atlases)

Protected _rotate

_rotate: number

Protected _updateID

_updateID: number

Update ID is observed by sprites and TextureMatrix instances. Call updateUvs() to increment it.

Protected _uvs

_uvs: TextureUvs

The WebGL UV data cache. Can be used as quad UV.

baseTexture

baseTexture: BaseTexture<Resource, IAutoDetectOptions>

The base texture that this texture uses.

defaultAnchor

defaultAnchor: Point

Anchor point that is used as default if sprite is created with this texture. Changing the defaultAnchor at a later point of time will not update Sprite's anchor point.

default

{0,0}

noFrame

noFrame: boolean

Does this Texture have any frame data assigned to it?

This mode is enabled automatically if no frame was passed inside constructor.

In this mode texture is subscribed to baseTexture events, and fires update on any change.

Beware, after loading or resize of baseTexture event can fired two times! If you want more control, subscribe on baseTexture itself.

texture.on('update', () => {});

Any assignment of frame switches off noFrame mode.

orig

orig: Rectangle

This is the area of original texture, before it was put in atlas.

textureCacheIds

textureCacheIds: string[]

The ids under which this Texture has been added to the texture cache. This is automatically set as long as Texture.addToCache is used, but may not be set if a Texture is added directly to the TextureCache array.

Optional transform

transform?: TextureTransform

The transform to use for this texture.

trim

trim: Rectangle

This is the trimmed area of original texture, before it was put in atlas Please call updateUvs() after you change coordinates of trim manually.

uvMatrix

uvMatrix: TextureMatrix

Default TextureMatrix instance for this texture. By default, that object is not created because its heavy.

Optional uvSet

uvSet?: number

valid

valid: boolean

This will let the renderer know if the texture is valid. If it's not then it cannot be rendered.

Static prefixed

prefixed: string | boolean

Accessors

frame

  • get frame(): Rectangle
  • set frame(frame: Rectangle): void
  • The frame specifies the region of the base texture that this texture uses. Please call updateUvs() after you change coordinates of frame manually.

    Returns Rectangle

  • The frame specifies the region of the base texture that this texture uses. Please call updateUvs() after you change coordinates of frame manually.

    Parameters

    • frame: Rectangle

    Returns void

height

  • get height(): number
  • The height of the Texture in pixels.

    Returns number

resolution

  • get resolution(): number
  • Returns resolution of baseTexture

    readonly

    Returns number

rotate

  • get rotate(): number
  • set rotate(rotate: number): void
  • Indicates whether the texture is rotated inside the atlas set to 2 to compensate for texture packer rotation set to 6 to compensate for spine packer rotation can be used to rotate or mirror sprites See {@link PIXI.groupD8} for explanation

    Returns number

  • Indicates whether the texture is rotated inside the atlas set to 2 to compensate for texture packer rotation set to 6 to compensate for spine packer rotation can be used to rotate or mirror sprites See {@link PIXI.groupD8} for explanation

    Parameters

    • rotate: number

    Returns void

width

  • get width(): number
  • The width of the Texture in pixels.

    Returns number

Static EMPTY

  • get EMPTY(): Texture<Resource>
  • An empty texture, used often to not have to create multiple empty textures. Can not be destroyed.

    Returns Texture<Resource>

Static WHITE

  • get WHITE(): Texture<CanvasResource>
  • A white texture of 16x16 size, used for graphics and other things Can not be destroyed.

    Returns Texture<CanvasResource>

Methods

addListener

  • Parameters

    • event: string | symbol
    • fn: ListenerFn
    • Optional context: any

    Returns StandardMaterialTexture

castToBaseTexture

  • castToBaseTexture(): BaseTexture<Resource, IAutoDetectOptions>
  • Utility function for BaseTexture|Texture cast.

    Returns BaseTexture<Resource, IAutoDetectOptions>

clone

  • clone(): Texture<Resource>
  • Creates a new texture object that acts the same as this one.

    Returns Texture<Resource>

    • The new texture

destroy

  • destroy(destroyBase?: boolean): void
  • Destroys this texture

    Parameters

    • Optional destroyBase: boolean

    Returns void

emit

  • emit(event: string | symbol, ...args: any[]): boolean
  • Calls each of the listeners registered for a given event.

    Parameters

    • event: string | symbol
    • Rest ...args: any[]

    Returns boolean

eventNames

  • eventNames(): (string | symbol)[]
  • Return an array listing the events for which the emitter has registered listeners.

    Returns (string | symbol)[]

listenerCount

  • listenerCount(event: string | symbol): number
  • Return the number of listeners listening to a given event.

    Parameters

    • event: string | symbol

    Returns number

listeners

  • listeners(event: string | symbol): ListenerFn[]
  • Return the listeners registered for a given event.

    Parameters

    • event: string | symbol

    Returns ListenerFn[]

off

  • Parameters

    • event: string | symbol
    • Optional fn: ListenerFn
    • Optional context: any
    • Optional once: boolean

    Returns StandardMaterialTexture

on

  • Add a listener for a given event.

    Parameters

    • event: string | symbol
    • fn: ListenerFn
    • Optional context: any

    Returns StandardMaterialTexture

Protected onBaseTextureUpdated

  • onBaseTextureUpdated(baseTexture: BaseTexture<Resource, IAutoDetectOptions>): void
  • Called when the base texture is updated

    Parameters

    • baseTexture: BaseTexture<Resource, IAutoDetectOptions>

      The base texture.

    Returns void

once

  • Add a one-time listener for a given event.

    Parameters

    • event: string | symbol
    • fn: ListenerFn
    • Optional context: any

    Returns StandardMaterialTexture

removeAllListeners

  • Remove all listeners, or those of the specified event.

    Parameters

    • Optional event: string | symbol

    Returns StandardMaterialTexture

removeListener

  • Remove the listeners of a given event.

    Parameters

    • event: string | symbol
    • Optional fn: ListenerFn
    • Optional context: any
    • Optional once: boolean

    Returns StandardMaterialTexture

update

  • update(): void
  • Updates this texture on the gpu.

    Calls the TextureResource update.

    If you adjusted frame manually, please call updateUvs() instead.

    Returns void

updateUvs

  • updateUvs(): void
  • Updates the internal WebGL UV cache. Use it after you change frame or trim of the texture. Call it after changing the frame

    Returns void

Static addToCache

  • addToCache(texture: Texture<Resource>, id: string): void
  • Adds a Texture to the global TextureCache. This cache is shared across the whole PIXI object.

    Parameters

    • texture: Texture<Resource>

      The Texture to add to the cache.

    • id: string

      The id that the Texture will be stored against.

    Returns void

Static from

  • from<R, RO>(source: TextureSource | TextureSource[], options?: IBaseTextureOptions<RO>, strict?: boolean): Texture<R>
  • Helper function that creates a new Texture based on the source you provide. The source can be - frame id, image url, video url, canvas element, video element, base texture

    Type parameters

    • R: Resource<R> = Resource

    • RO = any

    Parameters

    • source: TextureSource | TextureSource[]
      •   Source or array of sources to create texture from
        
    • Optional options: IBaseTextureOptions<RO>

      See {@link PIXI.BaseTexture}'s constructor for options.

    • Optional strict: boolean

    Returns Texture<R>

    The newly created texture

Static fromBuffer

  • fromBuffer(buffer: Float32Array | Uint8Array, width: number, height: number, options?: IBaseTextureOptions<ISize>): Texture<BufferResource>
  • Create a new Texture with a BufferResource from a Float32Array. RGBA values are floats from 0 to 1.

    Parameters

    • buffer: Float32Array | Uint8Array

      The optional array to use, if no data is provided, a new Float32Array is created.

    • width: number

      Width of the resource

    • height: number

      Height of the resource

    • Optional options: IBaseTextureOptions<ISize>

      See {@link PIXI.BaseTexture}'s constructor for options.

    Returns Texture<BufferResource>

    • The resulting new BaseTexture

Static fromLoader

  • fromLoader<R>(source: string | HTMLImageElement | HTMLCanvasElement, imageUrl: string, name?: string, options?: IBaseTextureOptions<any>): Promise<Texture<R>>
  • Create a texture from a source and add to the cache.

    Type parameters

    • R: Resource<R> = Resource

    Parameters

    • source: string | HTMLImageElement | HTMLCanvasElement

      The input source.

    • imageUrl: string

      File name of texture, for cache and resolving resolution.

    • Optional name: string

      Human readable name for the texture cache. If no name is specified, only imageUrl will be used as the cache ID.

    • Optional options: IBaseTextureOptions<any>

    Returns Promise<Texture<R>>

    • Output texture

Static fromURL

  • fromURL<R, RO>(url: string | string[], options?: IBaseTextureOptions<RO>): Promise<Texture<R>>
  • Useful for loading textures via URLs. Use instead of Texture.from because it does a better job of handling failed URLs more effectively. This also ignores PIXI.settings.STRICT_TEXTURE_CACHE. Works for Videos, SVGs, Images.

    Type parameters

    • R: Resource<R> = Resource

    • RO = any

    Parameters

    • url: string | string[]

      The remote URL or array of URLs to load.

    • Optional options: IBaseTextureOptions<RO>

      Optional options to include

    Returns Promise<Texture<R>>

    • A Promise that resolves to a Texture.

Static removeFromCache

  • removeFromCache(texture: string | Texture<Resource>): null | Texture<Resource>
  • Remove a Texture from the global TextureCache.

    Parameters

    • texture: string | Texture<Resource>

      id of a Texture to be removed, or a Texture instance itself

    Returns null | Texture<Resource>

    • The Texture that was removed

Generated using TypeDoc