the asset name
the materials by name, each with its properties (Kd,
d, Ke, map_Kd...), or null if none is loaded under that name
// 1. preload the model, its materials and their texture
await loader.preload([
{ name: "fox", type: "obj", src: "models/fox.obj" },
{ name: "fox", type: "mtl", src: "models/fox.mtl" },
{ name: "colormap", type: "image", src: "models/colormap.png" },
]);
// 2. a Mesh with a material: texture, tint and opacity applied for you
const mesh = new Mesh(400, 300, {
model: "fox",
material: "fox",
texture: "colormap",
width: 200,
height: 200,
});
// 3. or read the materials directly
const materials = loader.getMTL("fox");
// materials["colormap"].Kd — [r, g, b] diffuse color (0-1 range)
// materials["colormap"].d — opacity (0-1)
// materials["colormap"].Ke — [r, g, b] emissive color (applied as Mesh.emissive)
// materials["colormap"].map_Kd — resolved texture URL
Get a loaded Wavefront MTL material library (an
"mtl"asset), parsed. Most code never needs it: aMeshtakes the library's name as itsmaterial.