use oxideav_mesh3d::{Mesh3DDecoder, Result, Scene3D};
use crate::{mtl, obj};
#[derive(Debug, Default)]
pub struct ObjDecoder {
_private: (),
}
impl ObjDecoder {
pub fn new() -> Self {
Self::default()
}
}
impl Mesh3DDecoder for ObjDecoder {
fn decode(&mut self, bytes: &[u8]) -> Result<Scene3D> {
let text = std::str::from_utf8(bytes)
.map_err(|_| oxideav_mesh3d::Error::invalid("OBJ input contained non-UTF-8 bytes"))?;
obj::parse_obj(text)
}
}
#[derive(Debug, Default)]
pub struct MtlDecoder {
_private: (),
}
impl MtlDecoder {
pub fn new() -> Self {
Self::default()
}
}
impl Mesh3DDecoder for MtlDecoder {
fn decode(&mut self, bytes: &[u8]) -> Result<Scene3D> {
let text = std::str::from_utf8(bytes)
.map_err(|_| oxideav_mesh3d::Error::invalid("MTL input contained non-UTF-8 bytes"))?;
mtl::parse_mtl_with_scene(text)
}
}