Build production-ready editor authoring workflows
CI / Format, lint, test, build (push) Waiting to run
CI / Format, lint, test, build (push) Waiting to run
This commit is contained in:
1 parent
cc1fa6ea3b
commit
0553a85220
163 files changed
+34547
-1565
No files matched your search
@@ -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::*;
|
||||
|
||||
|
||||
Reference in new issue
Block a user