Importing from 3D file formats
At the beginning of this chapter, we listed a number of formats that are supported by Three.js. In this section, we’ll quickly walk through a few examples of those formats.
The OBJ and MTL formats
OBJ and MTL are companion formats and are often used together. An OBJ file defines the geometry, and an MTL file defines the materials that are used. Both OBJ and MTL are text-based formats. A part of an OBJ file looks like this:
v -0.032442 0.010796 0.025935 v -0.028519 0.013697 0.026201 v -0.029086 0.014533 0.021409 usemtl Material s 1 f 2731 2735 2736 2732 f 2732 2736 3043 3044
An MTL file defines materials, as follows:
newmtl Material Ns 56.862745 Ka 0.000000 0.000000 ...