# Class: TextureView

**`Advanced`**

A TextureView allows you to specify exactly how a `TextureSource` should be interpreted by the GPU.
This is particularly useful for advanced 3D rendering where you might need to view a depth/stencil
texture as purely a 'depth-only' or 'stencil-only' view.

It implements `BindResource` so it can be passed directly into a `BindGroup` or `Shader`.

## Extends

- `EventEmitter`\<\{ `change`: `TextureView`; `destroy`: `TextureView`; \}\>

## Implements

- [`BindResource`](rendering.BindResource.html.md)

## Constructors

### Constructor

> **new TextureView**(`source`, `viewDescriptor`): `TextureView`

#### Parameters

##### source

[`TextureSource`](rendering.TextureSource.html.md)

The texture source to view.

##### viewDescriptor

`GPUTextureViewDescriptor`

The WebGPU texture view descriptor.

#### Returns

`TextureView`

#### Overrides

`EventEmitter<{ change: TextureView; destroy: TextureView; }>.constructor`

## Properties

### \_resourceId

> `readonly` **\_resourceId**: `number`

Unique ID for this resource.

#### Implementation of

`BindResource._resourceId`

***

### \_resourceType

> `readonly` **\_resourceType**: `"textureView"` = `'textureView'`

The type of resource this is (for BindGroup compatibility).

#### Implementation of

`BindResource._resourceType`

***

### source

> `readonly` **source**: [`TextureSource`](rendering.TextureSource.html.md)

The underlying texture source.

***

### viewDescriptor

> `readonly` **viewDescriptor**: `GPUTextureViewDescriptor`

The WebGPU texture view descriptor.

## Accessors

### destroyed

#### Get Signature

> **get** **destroyed**(): `boolean`

Returns whether the underlying source is destroyed.

##### Returns

`boolean`

#### Implementation of

`BindResource.destroyed`

## Methods

### destroy()

> **destroy**(): `void`

Destroys the view and cleans up event listeners.

#### Returns

`void`
