Options
All
  • Public
  • Public/Protected
  • All
Menu

Module asset

Index

Type aliases

CreateNodeCallback

CreateNodeCallback: (error: Error | null, node: Node) => void
param

null or the error info

param

the created node or null

Type declaration

    • (error: Error | null, node: Node): void
    • Parameters

      • error: Error | null
      • node: Node

      Returns void

IBArray

IBArray: Uint8Array | Uint16Array | Uint32Array
en

Array views for index buffer

zh

允许存储索引的数组视图。

ITextureCubeCreateInfo

ITextureCubeCreateInfo: ITexture2DCreateInfo

ImageSource

ImageSource: HTMLCanvasElement | HTMLImageElement | IMemoryImageSource
en

The image source, can be HTML canvas, image type or image in memory data

zh

图像资源的原始图像源。可以来源于 HTML 元素也可以来源于内存。

LoadCallback

LoadCallback: (error: string, data: Asset) => void

Type declaration

    • (error: string, data: Asset): void
    • Parameters

      • error: string
      • data: Asset

      Returns void

LoadImageCallback

LoadImageCallback<T>: (this: T | undefined, error: Error | null | undefined, asset?: ImageAsset) => void

Type parameters

  • T

Type declaration

    • (this: T | undefined, error: Error | null | undefined, asset?: ImageAsset): void
    • Parameters

      • this: T | undefined
      • error: Error | null | undefined
      • Optional asset: ImageAsset

      Returns void

PresumedGFXTextureInfo

PresumedGFXTextureInfo: Pick<IGFXTextureInfo, "usage" | "flags" | "format" | "levelCount">

Variables

Let CUSTOM_PIXEL_FORMAT

CUSTOM_PIXEL_FORMAT: number = 1024

Const INSET_BOTTOM

INSET_BOTTOM: 3 = 3

Const INSET_LEFT

INSET_LEFT: 0 = 0

Const INSET_RIGHT

INSET_RIGHT: 2 = 2

Const INSET_TOP

INSET_TOP: 1 = 1

Const OptimizationPolicy

OptimizationPolicy: { AUTO: number; MULTI_INSTANCE: number; SINGLE_INSTANCE: number } = Enum({/*** @en The optimization policy is automatically chosen based on the number of instantiations.* When you first create an instance, the behavior is the same as SINGLE_INSTANCE. MULTI_INSTANCE will be automatically used after multiple creation.* @zh 根据创建次数自动调整优化策略。初次创建实例时,行为等同 SINGLE_INSTANCE,多次创建后将自动采用 MULTI_INSTANCE。*/AUTO: 0,/*** @en Optimize for single instance creation.<br>* This option skips code generation for this prefab.* When this prefab will usually create only one instances, please select this option.* @zh 优化单次创建性能。<br>* 该选项会跳过针对这个 prefab 的代码生成优化操作。当该 prefab 加载后,一般只会创建一个实例时,请选择此项。*/SINGLE_INSTANCE: 1,/*** @en Optimize for creating instances multiple times.<br>* This option enables code generation for this prefab.* When this prefab will usually create multiple instances, please select this option.* It is also recommended to select this option if the prefab instance in the scene has Auto Sync enabled and there are multiple instances in the scene.* @zh 优化多次创建性能。<br>* 该选项会启用针对这个 prefab 的代码生成优化操作。当该 prefab 加载后,一般会创建多个实例时,请选择此项。如果该 prefab 在场景中的节点启用了自动关联,并且在场景中有多份实例,也建议选择此项。*/MULTI_INSTANCE: 2,})
en

An enumeration used with the Prefab.optimizationPolicy to specify how to optimize the instantiate operation.

zh

Prefab 创建实例所用的优化策略,配合 Prefab.optimizationPolicy 使用。

Type declaration

  • AUTO: number
    en

    The optimization policy is automatically chosen based on the number of instantiations. When you first create an instance, the behavior is the same as SINGLE_INSTANCE. MULTI_INSTANCE will be automatically used after multiple creation.

    zh

    根据创建次数自动调整优化策略。初次创建实例时,行为等同 SINGLE_INSTANCE,多次创建后将自动采用 MULTI_INSTANCE。

  • MULTI_INSTANCE: number
    en

    Optimize for creating instances multiple times.
    This option enables code generation for this prefab. When this prefab will usually create multiple instances, please select this option. It is also recommended to select this option if the prefab instance in the scene has Auto Sync enabled and there are multiple instances in the scene.

    zh

    优化多次创建性能。
    该选项会启用针对这个 prefab 的代码生成优化操作。当该 prefab 加载后,一般会创建多个实例时,请选择此项。如果该 prefab 在场景中的节点启用了自动关联,并且在场景中有多份实例,也建议选择此项。

  • SINGLE_INSTANCE: number
    en

    Optimize for single instance creation.
    This option skips code generation for this prefab. When this prefab will usually create only one instances, please select this option.

    zh

    优化单次创建性能。
    该选项会跳过针对这个 prefab 的代码生成优化操作。当该 prefab 加载后,一般只会创建一个实例时,请选择此项。

Const _colorAttachment

_colorAttachment: GFXColorAttachment = new GFXColorAttachment()

Const _depthStencilAttachment

_depthStencilAttachment: GFXDepthStencilAttachment = new GFXDepthStencilAttachment()

Let _libraryBase

_libraryBase: string = ""

Let _rawAssetsBase

_rawAssetsBase: string = ""

Const _regions

_regions: GFXBufferTextureCopy[] = [{buffStride: 0,buffTexHeight: 0,texOffset: {x: 0,y: 0,z: 0,},texExtent: {width: 1,height: 1,depth: 1,},texSubres: {mipLevel: 0,baseArrayLayer: 0,layerCount: 1,},}]

Const _uuidToRawAsset

_uuidToRawAsset: any = createMap(true)

Const globalEmptyMeshBuffer

globalEmptyMeshBuffer: Uint8Array = new Uint8Array()

Const idGenerator

idGenerator: IDGenerator = new IDGenerator('Tex')

Const isLittleEndian

isLittleEndian: any = sys.isLittleEndian

Const temp_uvs

temp_uvs: IUV[] = [{ u: 0, v: 0 }, { u: 0, v: 0 }, { u: 0, v: 0 }, { u: 0, v: 0 }]

Const v3_1

v3_1: Vec3 = new Vec3()

Const v3_2

v3_2: Vec3 = new Vec3()

Functions

RawAssetEntry

  • RawAssetEntry(url: any, type: any): void

forEachFace

getGlobalDevice

Private cacheImage

canGenerateMipmap

  • canGenerateMipmap(device: GFXDevice, w: number, h: number): false | true | 0

fetchImageSource

  • fetchImageSource(imageSource: ImageSource): null | ArrayBufferView | HTMLCanvasElement | HTMLImageElement

getComponentByteLength

  • getComponentByteLength(format: GFXFormat): number

getIndexStrideCtor

  • getIndexStrideCtor(stride: number): Uint8ArrayConstructor | Uint16ArrayConstructor | Uint32ArrayConstructor
  • Parameters

    • stride: number

    Returns Uint8ArrayConstructor | Uint16ArrayConstructor | Uint32ArrayConstructor

getMipLevel

  • getMipLevel(width: number, height: number): number

getOffset

  • getOffset(attributes: IGFXAttribute[], attributeIndex: number): number

getReader

  • getReader(dataView: DataView, format: GFXFormat): null | (Anonymous function)

getWriter

  • getWriter(dataView: DataView, format: GFXFormat): null | (Anonymous function)

isNativeImage

  • isNativeImage(imageSource: ImageSource): imageSource is HTMLCanvasElement | HTMLImageElement

isPOT

  • isPOT(n: number): false | true | 0

isScene

  • isScene(asset: any): boolean

Private loadImage

  • Load an image asset with the given url.

    Type parameters

    • T: object

    Parameters

    • url: string

      The url of the image

    • Optional callback: LoadImageCallback<T>

      Callback for receiving the loaded asset

    • Optional target: T

      The callee of the callback function

    Returns ImageAsset

    The ImageAsset, it could be in the loading process, the callback will tell whether the loading process succeed or failed.

Private postLoadImage

  • postLoadImage(imageAsset: ImageAsset, callback?: Function): void

Object literals

Const AssetLibrary

AssetLibrary: object
en

The asset library which manages load or unload assets in project.

zh

管理项目中加载/卸载资源的资源库。

Private uuidToAsset

uuidToAsset: {}

这里保存所有已经加载的场景资源,防止同一个资源在内存中加载出多份拷贝。

这里用不了WeakMap,在浏览器中所有加载过的资源都只能手工调用 unloadAsset 释放。

参考: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap https://github.com/TooTallNate/node-weak

Type declaration

Private getAssetInfoInRuntime

  • getAssetInfoInRuntime(uuid: any, result?: any): any
  • Gets asset information in runtime environment.

    Parameters

    • uuid: any

      The asset uuid

    • Optional result: any

      The result object containing url and raw mark

    Returns any

    Return value equals the result

Private queryAssetInfoInEditor

  • queryAssetInfoInEditor(uuid: any, callback: any): void
  • Gets asset information in editor environment asynchronously.

    Parameters

    • uuid: any

      The asset uuid

    • callback: any

      Callback for retrieving the result

    Returns void

uuidInSettings

  • uuidInSettings(uuid: any): boolean

Private getAssetByUuid

  • getAssetByUuid(uuid: any): any

getLibUrlNoExt

  • getLibUrlNoExt(uuid: any, inRawAssetsDir?: undefined | false | true): string
  • Gets the url of the asset in library, without extension

    Parameters

    • uuid: any

      The asset uuid

    • Optional inRawAssetsDir: undefined | false | true

      Indicates whether the asset is in raw assets' sub directory

    Returns string

init

  • init(options: any): void

loadAsset

  • loadAsset(uuid: String, callback: LoadCallback, options?: any): void

Private loadJson

parseUuidInEditor

  • parseUuidInEditor(url: any): undefined | string

queryAssetInfo

  • queryAssetInfo(uuid: any, callback: any): void

Const windowInfo

windowInfo: object

height

height: number = 1

renderPassInfo

renderPassInfo: { colorAttachments: GFXColorAttachment[]; depthStencilAttachment: GFXDepthStencilAttachment } = passInfo

Type declaration

width

width: number = 1

Const passInfo

passInfo: object

colorAttachments

colorAttachments: GFXColorAttachment[] = [_colorAttachment]

depthStencilAttachment

depthStencilAttachment: GFXDepthStencilAttachment = _depthStencilAttachment

Generated using TypeDoc