Skip to content

Commit

Permalink
Read map_kd in wavefront mtl parser
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Oom committed May 6, 2024
1 parent fce389a commit 9baef1b
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions wavefront/src/mtl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ where
materials.last_mut().unwrap().transparency = x;
} else if let Ok((_, _)) = tagged("specularroughness", float, trimmed) {
// TODO: not supported
} else if let Ok((_, _)) = tagged("map_kd", rest, trimmed) {
// TODO: not supported
} else if let Ok((_, x)) = tagged("map_kd", rest, trimmed) {
materials.last_mut().unwrap().diffuse_map = x.to_string();
} else {
panic!("Unexpected line: \"{line}\"");
}
Expand Down Expand Up @@ -222,7 +222,10 @@ mod tests {
mtl_test("newmtl m1\nspecularroughness 1.").materials.len(),
1
);
assert_eq!(mtl_test("newmtl m1\nmap_kd todo").materials.len(), 1);
assert_eq!(
mtl_test("newmtl m1\nmap_kd file.png").materials[0].diffuse_map,
"file.png"
);
}

#[test]
Expand Down

0 comments on commit 9baef1b

Please sign in to comment.