Options
All
  • Public
  • Public/Protected
  • All
Menu

Class TextureCube

立方体贴图资源。 立方体贴图资源的每个 Mipmap 层级都为 6 张 ImageAsset,分别代表了立方体贴图的 6 个面。

Hierarchy

Index

Constructors

constructor

Properties

Protected _anisotropy

_anisotropy: number = 8

Protected _format

_format: number = PixelFormat.RGBA8888

Protected _gfxTexture

_gfxTexture: GFXTexture | 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: ITextureCubeMipmap[] = []

Protected _name

_name: string

_native

_native: string = ""

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

default

""

_objFlags

_objFlags: number

_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

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

Static FaceIndex

FaceIndex: FaceIndex = FaceIndex

Static Filter

Filter: Filter = Filter

纹理过滤模式枚举类型

Static PixelFormat

PixelFormat: PixelFormat = PixelFormat

像素格式枚举类型

Static WrapMode

WrapMode: WrapMode = WrapMode

环绕模式枚举类型

Static preventDeferredLoadDependents

preventDeferredLoadDependents: boolean = false

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

default

false

Static preventPreloadNativeObject

preventPreloadNativeObject: boolean = false

禁止预加载原生对象。

default

false

Accessors

Private nativeAsset

  • get nativeAsset(): any
  • set nativeAsset(obj: any): void
  • 此资源的基础资源(如果有)。 此属性可用于访问与资源相关的其他详细信息或功能。
    如果_native可用,则此属性将由加载器初始化。

    default

    null

    Returns any

  • 此资源的基础资源(如果有)。 此属性可用于访问与资源相关的其他详细信息或功能。
    如果_native可用,则此属性将由加载器初始化。

    default

    null

    Parameters

    • obj: any

    Returns void

height

  • get height(): number

image

isCompressed

  • get isCompressed(): boolean

isValid

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

    default

    true

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

    Returns boolean

mipmapLevel

  • get mipmapLevel(): number

mipmaps

name

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

nativeUrl

  • get nativeUrl(): string

width

  • get width(): number

Methods

Protected assignImage

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

Protected checkTextureLoaded

  • _checkTextureLoaded(): void

Protected createTexture

deserialize

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(): any

Protected getGFXPixelFormat

  • getGFXPixelFormat(format: any): any

Protected getGfxTextureCreateInfo

serialize

  • serialize(exporting?: any): { base: any; mipmaps: { back: string; bottom: string; front: string; left: string; right: string; top: string }[] }
  • Parameters

    • Optional exporting: any

    Returns { base: any; mipmaps: { back: string; bottom: string; front: string; left: string; right: string; top: string }[] }

    • base: any
    • mipmaps: { back: string; bottom: string; front: string; left: string; right: string; top: string }[]

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

Optional createNode

destroy

  • destroy(): boolean

emit

  • emit(type: EventType, arg0?: any, arg1?: any, arg2?: any, arg3?: any, arg4?: any): void

getAnisotropy

  • getAnisotropy(): number

getGFXSampler

getGFXTexture

getId

  • getId(): string

getPixelFormat

  • getPixelFormat(): number

Private getSamplerHash

  • getSamplerHash(): number

hasEventListener

  • hasEventListener(type: string, callback?: Function, target?: undefined | object): boolean
  • 检查指定事件是否已注册回调。

    Parameters

    • type: string

      Event type.

    • Optional callback: Function

      Callback function when event triggered.

    • Optional target: undefined | object

      Callback callee.

    Returns boolean

off

  • 删除之前用同类型,回调,目标或 useCapture 注册的事件监听器,如果只传递 type,将会删除 type 类型的所有事件监听器。

    example

    import { log } from 'cc'; // register fire eventListener var callback = eventTarget.on('fire', function () { log("fire in the hole"); }, target); // remove fire event listener eventTarget.off('fire', callback, target); // remove all fire event listeners eventTarget.off('fire');

    Type parameters

    • TFunction: Function

    Parameters

    • type: EventType

      A string representing the event type being removed.

    • Optional callback: TFunction

      The callback to remove.

    • Optional thisArg: any

    Returns void

on

  • on<TFunction>(type: EventType, callback: TFunction, thisArg?: any, once?: undefined | false | true): typeof callback
  • 注册事件目标的特定事件类型回调。这种类型的事件应该被 emit 触发。

    example

    import { log } from 'cc'; eventTarget.on('fire', function () { log("fire in the hole"); }, node);

    Type parameters

    • TFunction: Function

    Parameters

    • type: EventType

      A string representing the event type to listen for.

    • callback: TFunction

      The callback that will be invoked when the event is dispatched. The callback is ignored if it is a duplicate (the callbacks are unique).

    • Optional thisArg: any

      The target (this object) to invoke the callback, can be null

    • Optional once: undefined | false | true

    Returns typeof callback

    • Just returns the incoming callback so you can save the anonymous function easier.

onLoaded

  • onLoaded(): void

once

  • once<TFunction>(type: EventType, callback: TFunction, thisArg?: any): typeof callback
  • 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。

    example

    import { log } from 'cc'; eventTarget.once('fire', function () { log("this is the callback and will be invoked only once"); }, node);

    Type parameters

    • TFunction: Function

    Parameters

    • type: EventType

      A string representing the event type to listen for.

    • callback: TFunction

      The callback that will be invoked when the event is dispatched. The callback is ignored if it is a duplicate (the callbacks are unique).

    • Optional thisArg: any

    Returns typeof callback

releaseTexture

  • releaseTexture(): void

removeAll

  • removeAll(typeOrTarget: string | object): void
  • 移除在特定事件类型中注册的所有回调或在某个目标中注册的所有回调。

    Parameters

    • typeOrTarget: string | object

      The event type or target with which the listeners will be removed

    Returns void

reset

  • 将当前贴图重置为指定尺寸、像素格式以及指定 mipmap 层级。重置后,贴图的像素数据将变为未定义。 mipmap 图像的数据不会自动更新到贴图中,你必须显式调用 uploadData 来上传贴图数据。

    Parameters

    Returns void

Private serialize

  • serialize(): void

setAnisotropy

  • setAnisotropy(anisotropy: number): void

setFilters

setMipFilter

  • setMipFilter(mipFilter: Filter): void

setWrapMode

targetOff

  • targetOff(typeOrTarget: string | object): void
  • 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。

    Parameters

    • typeOrTarget: string | object

      The target to be searched for all related listeners

    Returns 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

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

      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 deferredDestroy

  • _deferredDestroy(): void

Static deserialize

  • deserialize(data: any): any

Static fromTexture2DArray

  • 通过二维贴图数组指定每个 Mipmap 的每个面创建立方体贴图。

    example
    const textures = new Array<Texture2D>(6);
    textures[TextureCube.FaceIndex.front] = frontImage;
    textures[TextureCube.FaceIndex.back] = backImage;
    textures[TextureCube.FaceIndex.left] = leftImage;
    textures[TextureCube.FaceIndex.right] = rightImage;
    textures[TextureCube.FaceIndex.top] = topImage;
    textures[TextureCube.FaceIndex.bottom] = bottomImage;
    const textureCube = TextureCube.fromTexture2DArray(textures);

    Parameters

    • textures: Texture2D[]

      Texture array, the texture count must be multiple of 6. Every 6 textures are 6 faces of a mipmap level. The order should obey FaceIndex order.

    • Optional out: TextureCube

      Output texture cube, if not given, will create a new texture cube.

    Returns TextureCube

    The created texture cube.

Static isRawAssetType

  • isRawAssetType(ctor: Function): boolean

Generated using TypeDoc