Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Texture2D

The 2D texture asset. It supports mipmap, each level of mipmap use an ImageAsset.

Hierarchy

Index

Constructors

constructor

Properties

__asyncLoadAssets__

__asyncLoadAssets__: boolean = false

__depends__

__depends__: any = null

__nativeDepend__

__nativeDepend__: any = null

__onLoadedInvoked__

__onLoadedInvoked__: boolean = false

Protected _anisotropy

_anisotropy: number = 8

Protected _format

_format: number = PixelFormat.RGBA8888

Protected _gfxTexture

_gfxTexture: Texture | null = null

Protected _height

_height: number = 1

Protected _magFilter

_magFilter: number = Filter.LINEAR

Protected _minFilter

_minFilter: number = Filter.LINEAR

Protected _mipFilter

_mipFilter: number = Filter.NONE

_mipmaps

_mipmaps: ImageAsset[] = []

_native

_native: string = ""

Serializable url for native asset. For internal usage.

default

""

_nativeUrl

_nativeUrl: string = ""

_uuid

_uuid: string

Protected _width

_width: number = 1

Protected _wrapR

_wrapR: number = WrapMode.REPEAT

Protected _wrapS

_wrapS: number = WrapMode.REPEAT

Protected _wrapT

_wrapT: number = WrapMode.REPEAT

loaded

loaded: boolean = true

Whether the asset is loaded or not

Static Filter

Filter: Filter = Filter

The texture filter mode enum

Static PixelFormat

PixelFormat: PixelFormat = PixelFormat

The pixel format enum.

Static WrapMode

WrapMode: WrapMode = WrapMode

The wrap mode enum.

Static preventDeferredLoadDependents

preventDeferredLoadDependents: boolean = false

Indicates whether its dependent native assets can support deferred load if the owner scene (or prefab) is marked as asyncLoadAssets.

default

false

Static preventPreloadNativeObject

preventPreloadNativeObject: boolean = false

Indicates whether its native object should be preloaded from native url.

default

false

Accessors

Private nativeAsset

  • get nativeAsset(): any
  • set nativeAsset(obj: any): void
  • The underlying native asset of this asset if one is available.
    This property can be used to access additional details or functionality releated to the asset.
    This property will be initialized by the loader if _native is available.

    default

    null

    Returns any

  • The underlying native asset of this asset if one is available.
    This property can be used to access additional details or functionality releated to the asset.
    This property will be initialized by the loader if _native is available.

    default

    null

    Parameters

    • obj: any

    Returns void

nativeDep

  • get nativeDep(): undefined | { __isNative__: boolean; ext: string; uuid: string }

height

  • get height(): number

image

isCompressed

  • get isCompressed(): boolean

mipmapLevel

  • get mipmapLevel(): number

mipmaps

  • All levels of mipmap images, be noted, automatically generated mipmaps are not included. When setup mipmap, the size of the texture and pixel format could be modified.

    Returns ImageAsset[]

  • All levels of mipmap images, be noted, automatically generated mipmaps are not included. When setup mipmap, the size of the texture and pixel format could be modified.

    Parameters

    Returns void

nativeUrl

  • get nativeUrl(): string

refCount

  • get refCount(): number

width

  • get width(): number

Methods

Protected assignImage

  • assignImage(image: ImageAsset, level: number, arrayIndex?: undefined | number): void

Protected checkTextureLoaded

  • _checkTextureLoaded(): void

Protected createTexture

  • createTexture(device: Device): void

deserialize

  • deserialize(serializedData: any, handle: any): void

Protected getGFXDevice

  • _getGFXDevice(): Device | null

Protected getGFXFormat

Protected getGFXPixelFormat

  • getGFXPixelFormat(format: any): Format

Protected getGfxTextureCreateInfo

serialize

  • serialize(ctxForExporting: any): any

Protected setGFXFormat

Protected setMipmapLevel

  • setMipmapLevel(value: number): void

Private setRawAsset

  • setRawAsset(filename: string, inLibrary?: boolean): void

Protected textureReady

  • _textureReady(): void

Protected tryDestroyTexture

  • _tryDestroyTexture(): void

Protected tryReset

  • _tryReset(): void

addRef

create

  • create(width: number, height: number, format?: PixelFormat, mipmapLevel?: number): void
  • Reset the current texture with given size, pixel format and mipmap images. After reset, the gfx resource will become invalid, you must use uploadData explicitly to upload the new mipmaps to GPU resources.

    deprecated

    since v1.0 please use reset instead

    Parameters

    • width: number

      Pixel width

    • height: number

      Pixel height

    • Default value format: PixelFormat = PixelFormat.RGBA8888

      Pixel format

    • Default value mipmapLevel: number = 1

      Mipmap level count

    Returns void

Optional createNode

decRef

  • decRef(autoRelease?: boolean): Asset

description

  • description(): string

destroy

  • destroy(): any

getAnisotropy

  • getAnisotropy(): number

getGFXSampler

getGFXTexture

getHash

  • getHash(): number

getHtmlElementObj

  • getHtmlElementObj(): null | HTMLCanvasElement | HTMLImageElement
  • If the level 0 mipmap image is a HTML element, then return it, otherwise return null.

    deprecated

    Please use [[image.data]] instead

    Returns null | HTMLCanvasElement | HTMLImageElement

    HTML element or null

getId

  • getId(): string

getPixelFormat

  • getPixelFormat(): number

Private getSamplerHash

  • getSamplerHash(): number

initialize

  • initialize(): void

onLoaded

  • onLoaded(): void

releaseTexture

  • releaseTexture(): void

reset

  • Reset the current texture with given size, pixel format and mipmap images. After reset, the gfx resource will become invalid, you must use uploadData explicitly to upload the new mipmaps to GPU resources.

    Parameters

    Returns void

Private serialize

  • serialize(): void

setAnisotropy

  • setAnisotropy(anisotropy: number): void

setFilters

setMipFilter

  • setMipFilter(mipFilter: Filter): void

setWrapMode

toString

  • toString(): string

updateImage

  • updateImage(): void

updateMipmaps

  • updateMipmaps(firstLevel?: number, count?: undefined | number): void

uploadData

  • uploadData(source: HTMLCanvasElement | HTMLImageElement | ArrayBufferView | ImageBitmap, level?: number, arrayIndex?: number): void
  • Upload data to the given mipmap level. The size of the image will affect how the mipmap is updated.

    • When the image is an ArrayBuffer, the size of the image must match the mipmap size.
    • If the image size matches the mipmap size, the mipmap data will be updated entirely.
    • If the image size is smaller than the mipmap size, the mipmap will be updated from top left corner.
    • If the image size is larger, an error will be raised

    Parameters

    • source: HTMLCanvasElement | HTMLImageElement | ArrayBufferView | ImageBitmap

      The source image or image data

    • Default value level: number = 0

      Mipmap level to upload the image to

    • Default value arrayIndex: number = 0

      The array index

    Returns void

Static deserialize

  • deserialize(data: any): any

Generated using TypeDoc