use super::*;
impl crate::asset::AssetManager {
pub fn install_obj_mesh(
&mut self,
device: &wgpu::Device,
file_path: &str,
vertices: Vec<Vertex>,
_aabb: gizmo_math::Aabb,
) -> Mesh {
let mesh = Mesh::new_indexed(
device,
&vertices,
Vec3::ZERO,
format!("obj:{file_path}"),
);
self.mesh_cache.insert(file_path.to_string(), mesh.clone());
mesh
}
pub fn load_obj(&mut self, device: &wgpu::Device, file_path_or_uuid: &str) -> Mesh {
let file_path = match self.resolve_path_from_meta_source(file_path_or_uuid) {
Ok(p) => p,
Err(e) => {
tracing::error!("[AssetManager] ERROR: {e}");
return self.loading_placeholder_mesh(device);
}
};
let cache_key = self
.get_uuid(&file_path)
.map(|id| id.to_string())
.unwrap_or_else(|| file_path.clone());
if let Some(cached) = self.mesh_cache.get(&cache_key) {
return cached.clone();
}
let (vertices, aabb) = match decode_obj_vertices_for_async(&file_path) {
Ok(v) => v,
Err(e) => {
tracing::error!("[AssetManager] OBJ load failed: {file_path} — {e}");
let vbuf = device.create_buffer_init(&wgpu::util::BufferInitDescriptor {
label: Some("Fallback VBuf (not found)"),
contents: &[],
usage: wgpu::BufferUsages::VERTEX,
});
return Mesh::empty(Arc::new(vbuf), format!("obj:missing_{file_path}"));
}
};
self.install_obj_mesh(device, &cache_key, vertices, aabb)
}
}