Build production-ready editor authoring workflows
CI / Format, lint, test, build (push) Waiting to run

This commit is contained in:
Rbanh committed 2026-07-11 12:41:04 -04:00
1 parent cc1fa6ea3b
commit 0553a85220
163 files changed
+34547 -1565

No files matched your search

+8 -4
View File
@@ -120,6 +120,7 @@ impl AssetThumbnailCache {
model_path: String,
mesh_label: String,
material_label: Option<String>,
requires_scene_instance: bool,
studio: &mut ThumbnailStudio,
) {
if matches!(
@@ -132,14 +133,16 @@ impl AssetThumbnailCache {
if !self.model_source_ready(&key, &model_path) {
return;
}
if studio.enqueue_source(
key.clone(),
let source = if requires_scene_instance {
ThumbnailJobSource::Model { model_path }
} else {
ThumbnailJobSource::MeshSubAsset {
model_path,
mesh_label,
material_label,
},
) {
}
};
if studio.enqueue_source(key.clone(), source) {
self.studio_pending.insert(key);
}
}
@@ -292,6 +295,7 @@ pub fn kind_icon(kind: &EditorAssetKind) -> egui_phosphor_icons::Icon {
EditorAssetKind::Model => icons::CUBE_TRANSPARENT,
EditorAssetKind::Texture => icons::IMAGE,
EditorAssetKind::Material => icons::PAINT_BRUSH,
EditorAssetKind::AudioClip => icons::WAVEFORM,
EditorAssetKind::Level => icons::MAP_TRIFOLD,
EditorAssetKind::Prefab => icons::PACKAGE,
EditorAssetKind::PostProcessVolume => icons::CAMERA,
+3 -1
View File
@@ -12,7 +12,9 @@ pub use cache::{
AssetThumbnailCache, AssetThumbnailsPlugin, ThumbnailCacheSnapshot, ThumbnailState,
};
pub use job::{ThumbnailJob, ThumbnailJobSource};
pub use sources::{FbxThumbnailSource, GltfThumbnailSource, ThumbnailModelSource};
pub use sources::{
gltf_skinned_primitive_labels, FbxThumbnailSource, GltfThumbnailSource, ThumbnailModelSource,
};
pub use studio::{
model_file_exists, model_scene_asset_path, ThumbnailStudio, ThumbnailStudioPlugin,
};
@@ -1,5 +1,6 @@
//! glTF/GLB fast-path texture extraction for asset browser thumbnails.
use std::collections::HashSet;
use std::path::Path;
/// Returns an asset-server path for the first base-color texture referenced by a glTF/GLB file.
@@ -64,6 +65,32 @@ pub fn validate_gltf_dependencies(model_asset_path: &str) -> Result<(), String>
Ok(())
}
/// Returns primitive labels that cannot be rendered without their source skin hierarchy.
pub fn gltf_skinned_primitive_labels(model_asset_path: &str) -> HashSet<String> {
let model_path = Path::new(model_asset_path);
if !is_gltf_path(model_path) {
return HashSet::new();
}
let Ok(gltf) = gltf::Gltf::open(model_path) else {
return HashSet::new();
};
gltf.meshes()
.flat_map(|mesh| {
let mesh_index = mesh.index();
mesh.primitives()
.filter(|primitive| {
primitive.attributes().any(|(semantic, _)| {
matches!(
semantic,
gltf::Semantic::Joints(_) | gltf::Semantic::Weights(_)
)
})
})
.map(move |primitive| format!("Mesh{mesh_index}/Primitive{}", primitive.index()))
})
.collect()
}
pub struct GltfThumbnailSource;
fn is_gltf_path(path: &Path) -> bool {
@@ -137,4 +164,16 @@ mod tests {
fs::remove_dir_all(directory).unwrap();
}
#[test]
fn committed_robot_fixture_identifies_skinned_primitives() {
let path =
Path::new(env!("CARGO_MANIFEST_DIR")).join("../../assets/models/robot_expressive.glb");
let labels = gltf_skinned_primitive_labels(path.to_str().unwrap());
assert!(labels.contains("Mesh12/Primitive0"));
assert!(labels.contains("Mesh13/Primitive0"));
assert!(!labels.contains("Mesh0/Primitive0"));
assert!(!labels.contains("Mesh999/Primitive0"));
}
}
@@ -4,7 +4,7 @@ mod fbx;
pub(crate) mod gltf;
pub use fbx::FbxThumbnailSource;
pub use gltf::GltfThumbnailSource;
pub use gltf::{gltf_skinned_primitive_labels, GltfThumbnailSource};
use bevy::prelude::*;
@@ -11,7 +11,7 @@ use bevy::mesh::VertexAttributeValues;
use bevy::prelude::*;
use bevy::render::render_resource::TextureFormat;
use bevy_egui::EguiUserTextures;
use shared::{material_from_desc, ModelRef};
use shared::{material_from_desc, standard_material_asset_path, ModelRef};
use super::cache::AssetThumbnailCache;
use super::job::{ThumbnailJob, ThumbnailJobSource};
@@ -413,7 +413,7 @@ fn spawn_thumbnail_job_content(
commands,
mesh_storage,
root,
asset_server.load(labeled_asset_path(
asset_server.load(standard_material_asset_path(
&asset_server_path(model_path),
material_label,
)),
@@ -437,7 +437,7 @@ fn spawn_mesh_subasset_preview(
let source_path = asset_server_path(model_path);
let mesh: Handle<Mesh> = asset_server.load(labeled_asset_path(&source_path, mesh_label));
let material = if let Some(material_label) = material_label {
asset_server.load(labeled_asset_path(&source_path, material_label))
asset_server.load(standard_material_asset_path(&source_path, material_label))
} else {
materials.add(StandardMaterial {
base_color: Color::srgb(0.72, 0.72, 0.75),