Skip to main content
Version: 0.11.0

UeObjLoader

A .obj model loader. Supports vertex positions, normals, UVs, vertex colors, material groups, usemtl references, and .mtl material libraries.


Constructor​

new UeObjLoader()

Properties​

NameTypeDescription
flipUVBooleanIf true, UVs are flipped vertically (default true)
reverseWindingBooleanIf true, triangle winding is reversed (default false)
materialsStructDictionary of materials loaded from an .mtl file

Methods​

Method SignatureDescription
load(fname)Loads and parses an .obj file from disk. Returns the root UeMesh.
setMaterials(materials)Assigns a struct of materials (from UeMtlLoader) to enable usemtl.

Example​

var mtlLoader = new UeMtlLoader();
var materials = mtlLoader.load("models/car.mtl");

var objLoader = new UeObjLoader();
objLoader.setMaterials(materials);

var mesh = objLoader.load("models/car.obj");
scene.add(mesh);

Notes​

  • Faces are triangulated automatically if needed.

  • The loader uses the global.UE_VFORMAT_PNUTC vertex format.

  • Since OBJ files do not natively store tangent data, default tangents (1, 0, 0, 1) are generated for compatibility with PBR shaders.

  • Materials are not loaded automatically; use UeMtlLoader.

  • No vertex deduplication is performed (each face defines separate vertices).

  • Supports color-per-vertex if .obj includes RGB values in v.