Class: DataTexture
数据纹理对象,常用于结构化数据的纹理对象。
代码实例:
const texture = new DataTexture(renderer, opt);
Hierarchy
-
↳
DataTexture
Table of contents
Constructors
Properties
Accessors
Methods
- swapHandle
- restoreHandle
- delete
- setData
- setOptions
- fromSrc
- update
- bind
- unbind
- destroy
- removeStats
- toString
Constructors
constructor
• new DataTexture(renderer
, options?
): DataTexture
Parameters
Name | Type |
---|---|
renderer | any |
options | Partial <DataTextureOptions > |
Returns
Overrides
Defined in
Properties
renderer
• renderer: Renderer
Inherited from
Defined in
needsUpdate
• needsUpdate: boolean
= true
设置纹理是否需要更新,一般我们会在纹理数据或者配置变更时将此配置项设置为 true
这样会在下一次渲染时应用对应的纹理数据和配置。
Overrides
Defined in
id
• id: string
Inherited from
Defined in
name
• name: WithUndef
<string
>
Inherited from
Defined in
userData
• userData: any
Inherited from
Defined in
byteLength
• byteLength: number
Inherited from
Defined in
options
• options: Partial
<DataTextureOptions
>
Inherited from
Defined in
textureUnit
• textureUnit: number
= 0
设置纹理单位
Inherited from
Defined in
image
• image: any
纹理数据
Inherited from
Defined in
width
• width: number
纹理宽度
Inherited from
Defined in
height
• height: number
纹理高度
Inherited from
Defined in
target
• target: number
texImage2D
target
Inherited from
Defined in
Accessors
gl
• get
gl(): WebGLRenderingContext
| WebGL2RenderingContext
获取 webgl
实例
Returns
WebGLRenderingContext
| WebGL2RenderingContext
Inherited from
Texture.gl
Defined in
rendererState
• get
rendererState(): State
获取渲染状态
Returns
Inherited from
Texture.rendererState
Defined in
handle
• get
handle(): any
Returns
any
Inherited from
Texture.handle
Defined in
Methods
swapHandle
▸ swapHandle(handle
): void
交换为新的 handle
(一般我们会用在虚拟 webgl 环境中)
Parameters
Name | Type |
---|---|
handle | any |
Returns
void
Inherited from
Defined in
restoreHandle
▸ restoreHandle(): void
恢复为原有 handle
Returns
void
Inherited from
Defined in
delete
▸ delete(«destructured»?
): DataTexture
Parameters
Name | Type | Default value |
---|---|---|
«destructured» | Object | {} |
› deleteChildren | undefined | boolean | false |
Returns
Inherited from
Defined in
setData
▸ setData(image
, width?
, height?
): void
设置纹理数据
Parameters
Name | Type | Description |
---|---|---|
image | any | 纹理数据 |
width | number | 纹理宽度,默认为原始宽度 |
height | number | 纹理高度,默认为原始高度 |
Returns
void
Inherited from
Defined in
setOptions
▸ setOptions(options
): void
设置纹理配置(默认进行合并)
Parameters
Name | Type | Description |
---|---|---|
options | Partial <DataTextureOptions > | 配置项 |
Returns
void
Inherited from
Defined in
fromSrc
▸ fromSrc(url
): Promise
<unknown
>
从 Url 设置纹理对象的数据,会默认标记为需要更新 needsUpdate = true
Parameters
Name | Type |
---|---|
url | string |
Returns
Promise
<unknown
>
Inherited from
Defined in
update
▸ update(units?
): void
更新纹理数据或者纹理相关配置
Parameters
Name | Type | Default value | Description |
---|---|---|---|
units | number | 0 | 纹理单位,默认为 0 |
Returns
void
Inherited from
Defined in
bind
▸ bind(unit?
): void
绑定纹理
Parameters
Name | Type | Description |
---|---|---|
unit | number | 纹理单位,默认为 this.textureUnit |
Returns
void
Inherited from
Defined in
unbind
▸ unbind(): void
解绑纹理
Returns
void
Inherited from
Defined in
destroy
▸ destroy(): void
销毁纹理
Returns
void
Inherited from
Defined in
removeStats
▸ removeStats(): void
移除相关状态
Returns
void
Inherited from
Defined in
toString
▸ toString(): string
获取字符串数据
Returns
string