Skip to content

Commit

Permalink
insert the gltf mesh name on the entity if there is one
Browse files Browse the repository at this point in the history
  • Loading branch information
mockersf committed Mar 5, 2022
1 parent 6c95b58 commit 4169eb5
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions crates/bevy_gltf/src/loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -545,16 +545,19 @@ fn load_node(
AssetPath::new_ref(load_context.path(), Some(&material_label));

let bounds = primitive.bounding_box();
parent
.spawn_bundle(PbrBundle {
mesh: load_context.get_handle(mesh_asset_path),
material: load_context.get_handle(material_asset_path),
..Default::default()
})
.insert(Aabb::from_min_max(
Vec3::from_slice(&bounds.min),
Vec3::from_slice(&bounds.max),
));
let mut mesh_entity = parent.spawn_bundle(PbrBundle {
mesh: load_context.get_handle(mesh_asset_path),
material: load_context.get_handle(material_asset_path),
..Default::default()
});
mesh_entity.insert(Aabb::from_min_max(
Vec3::from_slice(&bounds.min),
Vec3::from_slice(&bounds.max),
));

if let Some(name) = mesh.name() {
mesh_entity.insert(Name::new(name.to_string()));
}
}
}

Expand Down

0 comments on commit 4169eb5

Please sign in to comment.