TextureLoader - Verge3D User Manual - Soft8Soft
Description: Learn how to use TextureLoader in your interactive 3D apps made with Verge3D

Loader →

# TextureLoader

Class for loading a texture. This uses the ImageLoader internally for loading files.

## Code Example

`const texture = new v3d.TextureLoader().load('mytexture.jpg'); // immediately use the texture for material creation const material = new v3d.MeshBasicMaterial({ map: texture });`

## Code Example with Callbacks

`// instantiate a loader const loader = new v3d.TextureLoader(); // load a resource loader.load( // resource URL 'mytexture.webp', // onLoad callback function(texture) { // in this example we create the material when the texture is loaded const material = new v3d.MeshBasicMaterial({ map: texture }); }, // onProgress callback currently not supported undefined, // onError callback function(err) { console.error('An error happened.'); } );`

## Constructor

### TextureLoader(manager : LoadingManager)

manager — The loadingManager for the loader to use. Default is v3d.DefaultLoadingManager.

Creates a new TextureLoader.

## Properties

See the base Loader class for inherited properties.

## Methods

See the base Loader class for inherited methods.

### # .load(url : String, onLoad : Function, onProgress : Function, onError : Function) → Texture

- url — the path or URL to the file. This can also be a Data URL.
- onLoad (optional) — will be called when load completes. The argument will be the loaded texture.
- onProgress (optional) — this callback function is currently not supported.
- onError (optional) — will be called when load errors.

Begin loading from the given URL and pass the fully loaded texture to onLoad. The method also returns a new texture object which can directly be used for material creation. If you do it this way, the texture may pop up in your scene once the respective loading process is finished.

## Source

For more info on how to obtain the source code of this module see this page.