MaterialLoader

A loader for loading a Material in JSON format.

Constructor

MaterialLoader( manager )

manager — The loadingManager for the loader to use. Default is THREE.DefaultLoadingManager.
Creates a new MaterialLoader.

Methods

.load ( url, onLoad, onProgress, onError )

url — required
onLoad — Will be called when load completes. The argument will be the loaded Material.
onProgress — Will be called while load progresses. The argument will be the progress event.
onError — Will be called when load errors.
Begin loading from url and return the Material object that will contain the data.

.parse ( json )

json — The json object containing the parameters of the Material.
Parse a JSON structure and create a new Material of the type json.type with parameters defined in the json object.

Example

// instantiate a loader var loader = new THREE.MaterialLoader(); // load a resource loader.load( // resource URL 'path/to/material.json', // Function when resource is loaded function ( material ) { object.material = material; }, // Function called when download progresses function ( xhr ) { console.log( (xhr.loaded / xhr.total * 100) + '% loaded' ); }, // Function called when download errors function ( xhr ) { console.log( 'An error happened' ); } );

Source

src/loaders/MaterialLoader.js
Edit