Options
All
  • Public
  • Public/Protected
  • All
Menu

Class SimpleTexture

简单贴图基类。 简单贴图内部创建了 GFX 贴图和该贴图上的 GFX 贴图视图。 简单贴图允许指定不同的 Mipmap 层级。

Hierarchy

Implements

Index

Constructors

constructor

Properties

Protected _anisotropy

_anisotropy: number = 8

_callbackTable

_callbackTable: any = createMap(true)

IEventTarget 实现,它们将被 applyMixins 在 EventTarget 中用相同的实现覆盖

Protected _flipY

_flipY: boolean = false

Protected _format

_format: number = PixelFormat.RGBA8888

Protected _gfxTexture

_gfxTexture: GFXTexture | null = null

Protected _gfxTextureView

_gfxTextureView: GFXTextureView | null = null

Protected _height

_height: number = 0

Protected _magFilter

_magFilter: number = Filter.LINEAR

Protected _minFilter

_minFilter: number = Filter.LINEAR

Protected _mipFilter

_mipFilter: number = Filter.NONE

Private _mipmapLevel

_mipmapLevel: number = 1

Protected _name

_name: string

_native

_native: string = ""

用于本机资产的可序列化URL。供内部使用。

default

""

_objFlags

_objFlags: number

Protected _premultiplyAlpha

_premultiplyAlpha: boolean = false

_uuid

_uuid: string

内部使用。

Protected _width

_width: number = 0

Protected _wrapR

_wrapR: number = WrapMode.REPEAT

Protected _wrapS

_wrapS: number = WrapMode.REPEAT

Protected _wrapT

_wrapT: number = WrapMode.REPEAT

loaded

loaded: boolean = true

该资源是否已经成功加载。

Static Filter

Filter: Filter = Filter

Static PixelFormat

PixelFormat: PixelFormat = PixelFormat

Static WrapMode

WrapMode: WrapMode = WrapMode

Static preventDeferredLoadDependents

preventDeferredLoadDependents: boolean = false

当场景或 Prefab 被标记为 asyncLoadAssets,禁止延迟加载该资源所依赖的其它 RawAsset。

property

{Boolean} preventDeferredLoadDependents

default

false

static

Static preventPreloadNativeObject

preventPreloadNativeObject: boolean = false

禁止预加载原生对象。

property

{Boolean} preventPreloadNativeObject

default

false

static

Accessors

Private nativeAsset

  • get nativeAsset(): any
  • set nativeAsset(obj: any): void

height

  • get height(): number

isCompressed

  • get isCompressed(): boolean

isValid

  • get isValid(): boolean
  • 表示该对象是否可用(被 destroy 后将不可用)。
    当一个对象的 destroy 调用以后,会在这一帧结束后才真正销毁。
    因此从下一帧开始 isValid 就会返回 false,而当前帧内 isValid 仍然会是 true。
    如果希望判断当前帧是否调用过 destroy,请使用 cc.isValid(obj, true),不过这往往是特殊的业务需求引起的,通常情况下不需要这样。

    property

    {Boolean} isValid

    default

    true

    readonly
    example
    import * as cc from 'cc';
    var node = new cc.Node();
    cc.log(node.isValid);    // true
    node.destroy();
    cc.log(node.isValid);    // true, still valid in this frame
    // after a frame...
    cc.log(node.isValid);    // false, destroyed in the end of last frame

    Returns boolean

mipmapLevel

  • get mipmapLevel(): number

name

  • get name(): string
  • set name(value: string): void

nativeUrl

  • get nativeUrl(): string
  • 返回该资源对应的目标平台资源的 URL,如果没有将返回一个空字符串。

    property

    nativeUrl

    type

    {String}

    readonly

    Returns string

width

  • get width(): number

Methods

Protected assignImage

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

Protected checkTextureLoaded

  • _checkTextureLoaded(): void

Protected createTexture

deserialize

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

destroyImmediate

  • _destroyImmediate(): void

destruct

  • _destruct(): void
  • Clear all references in the instance.

    NOTE: this method will not clear the getter or setter functions which defined in the instance of CCObject. You can override the _destruct method if you need, for example: _destruct: function () { for (var key in this) { if (this.hasOwnProperty(key)) { switch (typeof this[key]) { case 'string': this[key] = ''; break; case 'object': case 'function': this[key] = null; break; } } }

    Returns void

Protected getGFXDevice

Protected getGFXFormat

  • _getGFXFormat(): number

Protected getGfxTextureCreateInfo

Protected getGfxTextureViewCreateInfo

serialize

  • serialize(exporting?: any): any

Protected setGFXFormat

Protected setMipmapLevel

  • setMipmapLevel(value: number): void
  • Set mipmap level of this texture. The value is passes as presumed info to this._getGfxTextureCreateInfo().

    Parameters

    • value: number

      The mipmap level.

    Returns void

Private setRawAsset

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

Protected textureReady

  • _textureReady(): void

Protected tryDestroyTexture

  • _tryDestroyTexture(): void

Protected tryReset

  • _tryReset(): void

Optional createNode

destroy

  • destroy(): boolean

dispatchEvent

  • dispatchEvent(event: Event): void

emit

  • emit(key: string, ...args: any[]): void

getAnisotropy

  • getAnisotropy(): number

getGFXSampler

getGFXTexture

getGFXTextureView

getId

  • getId(): string

getPixelFormat

  • getPixelFormat(): number

Private getSamplerHash

  • getSamplerHash(): number

hasEventListener

  • hasEventListener(key: string, callback?: Function | undefined, target?: Object | undefined): boolean

hasPremultipliedAlpha

  • hasPremultipliedAlpha(): boolean

off

  • off(type: string, callback?: Function | undefined, target?: Object | undefined): void

on

  • on(type: string, callback: Function, target?: Object | undefined): Function | undefined

once

  • once(type: string, callback: Function, target?: Object | undefined): Function | undefined

removeAll

  • removeAll(keyOrTarget?: string | Object | undefined): void

Private serialize

  • serialize(): void

setAnisotropy

  • setAnisotropy(anisotropy: number): void

setFilters

setFlipY

  • setFlipY(flipY: boolean): void

setMipFilter

  • setMipFilter(mipFilter: Filter): void

setPremultiplyAlpha

  • setPremultiplyAlpha(premultiply: boolean): void

setWrapMode

targetOff

  • targetOff(keyOrTarget?: string | Object | undefined): void

toString

  • toString(): string
  • 返回对象的字符串表示形式。
    Asset 对象将会重写 Object 对象的 toString() 方法。
    当资源要表示为文本值时或在字符串连接时引用时,
    JavaScript 会自动调用 toString() 方法。

    对于原始类型的资源,它将返回this.nativeUrl
    否则,返回空字符串。
    子类可能会覆盖此方法。

    method

    toString

    Returns string

updateImage

  • updateImage(): void

updateMipmaps

  • updateMipmaps(firstLevel?: number, count?: undefined | number): void
  • 更新指定层级范围内的 Mipmap。当 Mipmap 数据发生了改变时应调用此方法提交更改。 若指定的层级范围超出了实际已有的层级范围,只有覆盖的那些层级范围会被更新。

    Parameters

    • Default value firstLevel: number = 0

      起始层级。

    • Optional count: undefined | number

      层级数量。

    Returns void

uploadData

  • uploadData(source: HTMLCanvasElement | HTMLImageElement | ArrayBufferView, level?: number, arrayIndex?: number): void
  • 上传图像数据到指定层级的 Mipmap 中。 图像的尺寸影响 Mipmap 的更新范围:

    • 当图像是 ArrayBuffer 时,图像的尺寸必须和 Mipmap 的尺寸一致;否则,
    • 若图像的尺寸与 Mipmap 的尺寸相同,上传后整个 Mipmap 的数据将与图像数据一致;
    • 若图像的尺寸小于指定层级 Mipmap 的尺寸(不管是长或宽),则从贴图左上角开始,图像尺寸范围内的 Mipmap 会被更新;
    • 若图像的尺寸超出了指定层级 Mipmap 的尺寸(不管是长或宽),都将引起错误。

    Parameters

    • source: HTMLCanvasElement | HTMLImageElement | ArrayBufferView

      图像数据源。

    • Default value level: number = 0

      Mipmap 层级。

    • Default value arrayIndex: number = 0

      数组索引。

    Returns void

Static deferredDestroy

  • _deferredDestroy(): void

Static deserialize

  • deserialize(data: any): any

Static isRawAssetType

  • isRawAssetType(ctor: Function): boolean

Generated using TypeDoc