Capítulo 185 de 859

Chapter 185: MaterialLoader

Core Idea

Class for loading materials. The files are internally loaded via FileLoader.

This loader does not support node materials. Use NodeMaterialLoader instead.

Key Concepts

  • textures : Object.<string, Texture>: A dictionary holding textures used by the material.

Code Examples

const loader = new THREE.MaterialLoader();
const material = await loader.loadAsync( 'material.json' );
  • What it demonstrates: Typical usage of MaterialLoader.

Reference Tables

Constructor

Signature
new MaterialLoader( manager : LoadingManager )

Properties

PropertyDescription
.textures : Object.<string, Texture>A dictionary holding textures used by the material.

Methods

MethodDescription
.createMaterialFromType( type : string ) : MaterialCreates a material for the given type.
.load( url : string, onLoad : function, onProgress : onProgressCallback, onError : onErrorCallback )Starts loading from the given URL and pass the loaded material to the onLoad() callback.
.parse( json : Object ) : MaterialParses the given JSON object and returns a material.
.setTextures( value : Object ) : MaterialLoaderTextures are not embedded in the material JSON so they have to be injected before the loading process starts.

Key Takeaways

  1. MaterialLoader extends: Loader
  2. Most relevant properties: textures.
  3. Key methods: createMaterialFromType, load, parse, setTextures.

Connects To