Skip to main content

Class: DataTexture

数据纹理对象,常用于结构化数据的纹理对象。

代码实例:

const texture = new DataTexture(renderer, opt);

Hierarchy

Table of contents

Constructors

Properties

Accessors

Methods

Constructors

constructor

new DataTexture(renderer, options?): DataTexture

Parameters

NameType
rendererany
optionsPartial<DataTextureOptions>

Returns

DataTexture

Overrides

Texture.constructor

Defined in

src/core/DataTexture.ts:24

Properties

renderer

renderer: Renderer

Inherited from

Texture.renderer

Defined in

src/core/Base.ts:7


needsUpdate

needsUpdate: boolean = true

设置纹理是否需要更新,一般我们会在纹理数据或者配置变更时将此配置项设置为 true 这样会在下一次渲染时应用对应的纹理数据和配置。

Overrides

Texture.needsUpdate

Defined in

src/core/DataTexture.ts:22


id

id: string

Inherited from

Texture.id

Defined in

src/core/Resource.ts:21


name

name: WithUndef<string>

Inherited from

Texture.name

Defined in

src/core/Resource.ts:23


userData

userData: any

Inherited from

Texture.userData

Defined in

src/core/Resource.ts:25


byteLength

byteLength: number

Inherited from

Texture.byteLength

Defined in

src/core/Resource.ts:28


options

options: Partial<DataTextureOptions>

Inherited from

Texture.options

Defined in

src/core/Resource.ts:30


textureUnit

textureUnit: number = 0

设置纹理单位

Inherited from

Texture.textureUnit

Defined in

src/core/Texture.ts:151


image

image: any

纹理数据

Inherited from

Texture.image

Defined in

src/core/Texture.ts:156


width

width: number

纹理宽度

Inherited from

Texture.width

Defined in

src/core/Texture.ts:161


height

height: number

纹理高度

Inherited from

Texture.height

Defined in

src/core/Texture.ts:166


target

target: number

texImage2D target

Inherited from

Texture.target

Defined in

src/core/Texture.ts:171

Accessors

gl

get gl(): WebGLRenderingContext | WebGL2RenderingContext

获取 webgl 实例

Returns

WebGLRenderingContext | WebGL2RenderingContext

Inherited from

Texture.gl

Defined in

src/core/Base.ts:16


rendererState

get rendererState(): State

获取渲染状态

Returns

State

Inherited from

Texture.rendererState

Defined in

src/core/Base.ts:23


handle

get handle(): any

Returns

any

Inherited from

Texture.handle

Defined in

src/core/Resource.ts:47

Methods

swapHandle

swapHandle(handle): void

交换为新的 handle(一般我们会用在虚拟 webgl 环境中)

Parameters

NameType
handleany

Returns

void

Inherited from

Texture.swapHandle

Defined in

src/core/Resource.ts:55


restoreHandle

restoreHandle(): void

恢复为原有 handle

Returns

void

Inherited from

Texture.restoreHandle

Defined in

src/core/Resource.ts:63


delete

delete(«destructured»?): DataTexture

Parameters

NameTypeDefault value
«destructured»Object{}
› deleteChildrenundefined | booleanfalse

Returns

DataTexture

Inherited from

Texture.delete

Defined in

src/core/Resource.ts:74


setData

setData(image, width?, height?): void

设置纹理数据

Parameters

NameTypeDescription
imageany纹理数据
widthnumber纹理宽度,默认为原始宽度
heightnumber纹理高度,默认为原始高度

Returns

void

Inherited from

Texture.setData

Defined in

src/core/Texture.ts:219


setOptions

setOptions(options): void

设置纹理配置(默认进行合并)

Parameters

NameTypeDescription
optionsPartial<DataTextureOptions>配置项

Returns

void

Inherited from

Texture.setOptions

Defined in

src/core/Texture.ts:230


fromSrc

fromSrc(url): Promise<unknown>

从 Url 设置纹理对象的数据,会默认标记为需要更新 needsUpdate = true

Parameters

NameType
urlstring

Returns

Promise<unknown>

Inherited from

Texture.fromSrc

Defined in

src/core/Texture.ts:241


update

update(units?): void

更新纹理数据或者纹理相关配置

Parameters

NameTypeDefault valueDescription
unitsnumber0纹理单位,默认为 0

Returns

void

Inherited from

Texture.update

Defined in

src/core/Texture.ts:260


bind

bind(unit?): void

绑定纹理

Parameters

NameTypeDescription
unitnumber纹理单位,默认为 this.textureUnit

Returns

void

Inherited from

Texture.bind

Defined in

src/core/Texture.ts:458


unbind

unbind(): void

解绑纹理

Returns

void

Inherited from

Texture.unbind

Defined in

src/core/Texture.ts:468


destroy

destroy(): void

销毁纹理

Returns

void

Inherited from

Texture.destroy

Defined in

src/core/Texture.ts:477


removeStats

removeStats(): void

移除相关状态

Returns

void

Inherited from

Texture.removeStats

Defined in

src/core/Texture.ts:485


toString

toString(): string

获取字符串数据

Returns

string

Inherited from

Texture.toString

Defined in

src/core/Texture.ts:511