Skip to main content

Class: MaterialXLoader

A loader for the MaterialX format.

The node materials loaded with this loader can only be used with WebGPURenderer. Besides plain .mtlx documents, the loader accepts .mtlx.zip archives that bundle a document with its textures.

const loader = new MaterialXLoader().setPath( SAMPLE_PATH );
const { materials } = await loader.loadAsync( 'standard_surface_brass_tiled.mtlx' );

Extends​

  • "three/webgpu"

Indexable​

[key: string]: any

Constructors​

Constructor​

new MaterialXLoader(manager?): MaterialXLoader

Constructs a new MaterialX loader.

Parameters​

manager?​

any

The loading manager.

Returns​

MaterialXLoader

Overrides​

Loader.constructor

Properties​

manager​

manager: any


path​

path: string

Methods​

dispose()​

dispose(): this

Frees the resources of the last loaded archive.

Returns​

this


load()​

load(url, onLoad, onProgress?, onError?, options?): this

Starts loading from the given URL and passes the loaded MaterialX asset to the onLoad() callback.

Parameters​

url​

string

onLoad​

(result) => void

onProgress?​

(event) => void

onError?​

(err) => void

options?​

MaterialXLoaderParseOptions = {}

Returns​

this


loadAsync()​

loadAsync(url, onProgress?, options?): Promise<MaterialXParseResult>

Async version of MaterialXLoader#load. The progress callback can be omitted and the parse options passed as the second argument instead.

Parameters​

url​

string

onProgress?​

MaterialXLoaderParseOptions | ((event) => void)

options?​

MaterialXLoaderParseOptions = {}

Returns​

Promise<MaterialXParseResult>


parse()​

parse(text, options?): MaterialXParseResult

Parses the given MaterialX document and returns the resulting materials together with the translation log.

Parameters​

text​

string

options?​

MaterialXLoaderParseOptions = {}

Returns​

MaterialXParseResult


parseBuffer()​

parseBuffer(data, url?, options?): MaterialXParseResult

Parses a raw MaterialX document or a .mtlx.zip archive and returns the resulting materials.

Parameters​

data​

string | ArrayBuffer | Uint8Array<ArrayBufferLike>

url?​

string = ''

options?​

MaterialXLoaderParseOptions = {}

Returns​

MaterialXParseResult