Skip to main content

Class: Texture3D

纹理 一般在 webgl 中会将纹理用于贴图,或者作为 renderTarget 代码示例:

const texture = new ve.Texture3D(renderer, {
generateMipmaps: true,
flipY: true,
});

const image = new Image();

image.onload = () => {
texture.setData(image, image.width, image.height);
};

image.src = './assets/posx.jpg';

Hierarchy

Table of contents

Constructors

Properties

Accessors

Methods

Constructors

constructor

new Texture3D(renderer, options?): Texture3D

Parameters

NameTypeDescription
rendererRendererRenderer 对象
optionsPartial<Texture3DOptions>配置项

Returns

Texture3D

Overrides

Texture.constructor

Defined in

src/core/Texture3D.ts:94

Properties

renderer

renderer: Renderer

Inherited from

Texture.renderer

Defined in

src/core/Base.ts:7


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<Texture3DOptions>

Inherited from

Texture.options

Defined in

src/core/Resource.ts:30


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


needsUpdate

needsUpdate: boolean = false

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

Overrides

Texture.needsUpdate

Defined in

src/core/Texture3D.ts:76


textureUnit

textureUnit: number = 0

设置纹理单位

Overrides

Texture.textureUnit

Defined in

src/core/Texture3D.ts:81


depth

depth: number

纹理深度

Defined in

src/core/Texture3D.ts:86

Accessors

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


gl

get gl(): WebGL2RenderingContext

获取 webgl 实例

Returns

WebGL2RenderingContext

Overrides

Texture.gl

Defined in

src/core/Texture3D.ts:126

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»?): Texture3D

Parameters

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

Returns

Texture3D

Inherited from

Texture.delete

Defined in

src/core/Resource.ts:74


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


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


setData

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

设置纹理数据

Parameters

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

Returns

void

Overrides

Texture.setData

Defined in

src/core/Texture3D.ts:137


setOptions

setOptions(options): void

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

Parameters

NameTypeDescription
optionsPartial<Texture3DOptions>配置项

Returns

void

Overrides

Texture.setOptions

Defined in

src/core/Texture3D.ts:149


update

update(units?): void

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

Parameters

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

Returns

void

Overrides

Texture.update

Defined in

src/core/Texture3D.ts:161


removeStats

removeStats(): void

移除相关状态

Returns

void

Overrides

Texture.removeStats

Defined in

src/core/Texture3D.ts:341


toString

toString(): string

获取字符串数据

Returns

string

Overrides

Texture.toString

Defined in

src/core/Texture3D.ts:350