| Crates.io | bevy_gltf_trait |
| lib.rs | bevy_gltf_trait |
| version | 0.5.0 |
| created_at | 2024-07-08 11:08:02.538398+00 |
| updated_at | 2025-11-02 02:35:27.811871+00 |
| description | Customizable Bevy Engine GLTF loading |
| homepage | |
| repository | https://github.com/dekirisu/bevy_gltf_trait |
| max_upload_size | |
| id | 1295654 |
| size | 331,786 |
This is a fork of bevy /crates/bevy_gltf, that doesn't change any functionalities, but provides several possibilities to customize the conversion between gltf and bevy interns on load using the trait GltfTrait.
fn main(){
let mut app = App::new();
app.add_plugins((
DefaultPlugins,
// Use your modified Gltf-Loader
GltfPlugin::<BlueGltf>::default()
));
app.run();
}
// Define your modified Gltf-Loader
#[derive(Reflect,Clone,Default)]
struct BlueGltf;
impl GltfTrait for BlueGltf {
// Set Extensions for this custom loader
const EXTENSIONS: &'static [&'static str] = &["gltf", "glb"];
// Should morphs be loaded?
const ENABLE_MORPHS: bool = true;
// App access
fn on_app (_app:&mut App){}
// What Material should the Entities use?
type Material = StandardMaterial;
// How to translate from gltf::Material and bevy::StandardMaterial to your choice?
// e.g.: all base-colors shall be blue!
fn convert_material (mut convert:GltfTraitMaterial) -> Self::Material {
convert.material.base_color = Color::srgb(0.,0.,1.);
convert.material.base_color_texture = None;
convert.material
}
// Edit the entity of a mesh
fn on_mesh (_edit:GltfTraitEntity){}
// Edit meshes
fn edit_mesh (_edit:GltfTraitMesh){}
// Edit the entity or Transform of any light
fn on_light_parent (_edit:GltfTraitParent){}
// Edit the entity or component of a DirectionalLight
fn edit_directional_light (_edit:GltfTraitLight<DirectionalLight>){}
// Edit the entity or component of a PointLight
fn edit_point_light (_edit:GltfTraitLight<PointLight>){}
// Edit the entity or component of a SpotLight
fn edit_spot_light (_edit:GltfTraitLight<SpotLight>){}
// Edit the entity or Transform of a set of meshes
fn on_mesh_parent (_edit:GltfTraitParent){}
// Edit the entity or Transform of a set of skinned meshes
fn on_skinned_mesh_parent (_edit:GltfTraitParent){}
// Edit the entity of a skinned mesh
fn on_skinned_mesh (_edit:GltfTraitEntity){}
}
on_app to .register_type() themThe original way of adding the plugin changes to:
fn main(){
let mut app = App::new();
app.add_plugins((
MinimalPlugins,
GltfPlugin::<()>::default(),
));
app.run();
}
| Bevy | This |
|---|---|
| 0.17 | 0.5 |
| 0.16 | 0.4 |
| 0.15 | 0.2 |
| 0.14 | 0.1 |