Wavefront OBJ (.obj) is a human-readable, text-based format for defining 3D geometry. It can describe a polygon mesh with vertices, faces, and normals. Because the geometry is readable as text, a small model can be written in an editor, though larger models are typically exported from modeling software. section 7.1
Listing 7.1 Definition of a 3D cube in OBJ file format
# Vertices v -1.0 -1.0 1.0 v 1.0 -1.0 1.0 v 1.0 1.0 1.0 v -1.0 1.0 1.0 v -1.0 -1.0 -1.0 v 1.0 -1.0 -1.0 v 1.0 1.0 -1.0 v -1.0 1.0 -1.0 # Face normals vn 0.0 0.0 1.0 # Front face normal vn 1.0 0.0 0.0 # Right face normal vn 0.0 0.0 -1.0 # Back face normal vn -1.0 0.0 0.0 # Left face normal vn 0.0 1.0 0.0 # Top face normal vn 0.0 -1.0 0.0 # Bottom face normal # Faces (format: vertex//normal) f 1//1 2//1 3//1 4//1 # Front face f 2//2 6//2 7//2 3//2 # Right face f 6//3 5//3 8//3 7//3 # Back face f 5//4 1//4 4//4 8//4 # Left face f 4//5 3//5 7//5 8//5 # Top face f 5//6 6//6 2//6 1//6 # Bottom face
The cube listing makes the file structure concrete: `v` lines give vertex coordinates, `vn` lines give normals, and `f` lines assemble faces using vertex and normal references. section 7.1
An exported OBJ model can be inspected in an OBJ viewer or loaded into a web page with Three.js. For web delivery, account for loading time: the browser must download the whole OBJ file before rendering any polygon, then convert its text geometry for the GPU. Larger files can therefore take longer to appear. section 7.2.1
