Model loading · function

parseObj

Parse an OBJ. materials is the parsed .mtl, if the caller resolved one.

Explained in Importing models.

function parseObj(text: string, materials?: Map<string, ObjMaterial>):
import { parseObj } from '@driftengine/assets';

Parameters

ParameterTypeDescription
textstring
materials?Map<string, ObjMaterial>

In depth

Faces with more than three vertices are triangulated as a fan. That is correct for the convex polygons OBJ files actually contain, and the format offers nothing that would let a reader do better for a concave one.