Capítulo 195 de 859

Chapter 195: OBJLoader

Core Idea

A loader for the OBJ format.

The OBJ format is a simple data-format that represents 3D geometry in a human readable format as the position of each vertex, the UV position of each texture coordinate vertex, vertex normals, and the faces that make each polygon defined as a list of vertices, and texture vertices.

Key Concepts

  • materials : MaterialCreator: A reference to a material creator.

Code Examples

const loader = new OBJLoader();
const object = await loader.loadAsync( 'models/monster.obj' );
scene.add( object );
  • What it demonstrates: Typical usage of OBJLoader.

Reference Tables

Constructor

Signature
new OBJLoader( manager : LoadingManager )

Properties

PropertyDescription
.materials : MaterialCreatorA reference to a material creator.

Methods

MethodDescription
.load( url : string, onLoad : function, onProgress : onProgressCallback, onError : onErrorCallback )Starts loading from the given URL and passes the loaded OBJ asset to the onLoad() callback.
.parse( text : string ) : GroupParses the given OBJ data and returns the resulting group.
.setMaterials( materials : MaterialCreator ) : OBJLoaderSets the material creator for this OBJ. This object is loaded via MTLLoader.

Key Takeaways

  1. OBJLoader extends: Loader
  2. Most relevant properties: materials.
  3. Key methods: load, parse, setMaterials.

Connects To