mirror of
https://github.com/bevyengine/bevy
synced 2024-11-26 06:30:19 +00:00
Log errors when loading textures from a gltf file (#2260)
When loading a gltf, if there is an error loading textures, it is completely ignored. This can happen for example when loading a file with `jpg` textures without the `jpeg` Bevy feature enabled. This PR adds `warn` logs for the few cases that can happen when loading a texture. Other possible fix would be to break on first error and returning, making the asset loading failed
This commit is contained in:
parent
fe32a60577
commit
7835c92647
1 changed files with 8 additions and 2 deletions
|
@ -4,6 +4,7 @@ use bevy_asset::{
|
||||||
};
|
};
|
||||||
use bevy_core::Name;
|
use bevy_core::Name;
|
||||||
use bevy_ecs::world::World;
|
use bevy_ecs::world::World;
|
||||||
|
use bevy_log::warn;
|
||||||
use bevy_math::Mat4;
|
use bevy_math::Mat4;
|
||||||
use bevy_pbr::prelude::{PbrBundle, StandardMaterial};
|
use bevy_pbr::prelude::{PbrBundle, StandardMaterial};
|
||||||
use bevy_render::{
|
use bevy_render::{
|
||||||
|
@ -49,7 +50,7 @@ pub enum GltfError {
|
||||||
BufferFormatUnsupported,
|
BufferFormatUnsupported,
|
||||||
#[error("invalid image mime type: {0}")]
|
#[error("invalid image mime type: {0}")]
|
||||||
InvalidImageMimeType(String),
|
InvalidImageMimeType(String),
|
||||||
#[error("{0}")]
|
#[error("You may need to add the feature for the file format: {0}")]
|
||||||
ImageError(#[from] TextureError),
|
ImageError(#[from] TextureError),
|
||||||
#[error("failed to load an asset path: {0}")]
|
#[error("failed to load an asset path: {0}")]
|
||||||
AssetIoError(#[from] AssetIoError),
|
AssetIoError(#[from] AssetIoError),
|
||||||
|
@ -262,7 +263,12 @@ async fn load_gltf<'a, 'b>(
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.filter_map(|result| result.ok())
|
.filter_map(|res| {
|
||||||
|
if let Err(err) = res.as_ref() {
|
||||||
|
warn!("Error loading GLTF texture: {}", err);
|
||||||
|
}
|
||||||
|
res.ok()
|
||||||
|
})
|
||||||
.for_each(|(texture, label)| {
|
.for_each(|(texture, label)| {
|
||||||
load_context.set_labeled_asset(&label, LoadedAsset::new(texture));
|
load_context.set_labeled_asset(&label, LoadedAsset::new(texture));
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue