# TextureParser

Class · category: Graphics

Source: https://github.com/playcanvas/engine/blob/970d89f6d3bc6667f4e1f88153abd6e7e82ed52c/src/framework/parsers/texture/texture.js#L14

Interface to a texture parser. Implementations of this interface handle the loading and opening
of texture assets.

## Methods

### load

```ts
load(url: object, callback: ResourceHandlerCallback, asset?: Asset<string>): void
```

Load the texture from the remote URL. When loaded (or failed), use the callback to return an
the raw resource data (or error).

**Parameters**

- `url` (`object`): The URL of the resource to load.
    - `url.load` (`string`): The URL to use for loading the resource.
    - `url.original` (`string`): The original URL useful for identifying the resource type.
- `callback` ([`ResourceHandlerCallback`](https://api.playcanvas.com/engine/types/ResourceHandlerCallback.md)): The callback used when the resource is loaded or
  an error occurs.
- `asset` ([`Asset`](https://api.playcanvas.com/engine/classes/Asset.md)`<string>`, optional): Optional asset that is passed by ResourceLoader.

### open

```ts
open(url: string, data: any, device: GraphicsDevice): Texture
```

Convert raw resource data into a [Texture](https://api.playcanvas.com/engine/classes/Texture.md).

**Parameters**

- `url` (`string`): The URL of the resource to open.
- `data` (`any`): The raw resource data passed by callback from [ResourceHandler#load](https://api.playcanvas.com/engine/classes/ResourceHandler.md#load).
- `device` ([`GraphicsDevice`](https://api.playcanvas.com/engine/classes/GraphicsDevice.md)): The graphics device.

**Returns** [`Texture`](https://api.playcanvas.com/engine/classes/Texture.md): The parsed resource data.
