//! Model file sources for the thumbnail render studio.

mod fbx;
pub(crate) mod gltf;

pub use fbx::FbxThumbnailSource;
pub use gltf::{gltf_skinned_primitive_labels, GltfThumbnailSource};

use bevy::prelude::*;

/// Spawns untextured or scene-root preview content under `root` for the thumbnail studio.
pub trait ThumbnailModelSource: Send + Sync {
    fn spawn_preview(
        &self,
        commands: &mut Commands,
        meshes: &mut Assets<Mesh>,
        materials: &mut Assets<StandardMaterial>,
        root: Entity,
        catalog_path: &str,
    ) -> bool;
}

pub fn source_for_extension(path: &str) -> Option<&'static dyn ThumbnailModelSource> {
    if path.ends_with(".fbx") {
        Some(&FbxThumbnailSource)
    } else {
        None
    }
}

pub fn uses_scene_root(path: &str) -> bool {
    !path.ends_with(".fbx")
}
