Skip to content

Commit a1e3c5c

Browse files
committed
load names of lights from gltf (#3553)
# Objective - Load names of lights from gltf ## Solution - Load names of lights from gltf Co-authored-by: François <[email protected]>
1 parent 0bae5bb commit a1e3c5c

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

crates/bevy_gltf/src/loader.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,7 @@ fn load_node(
556556
if let Some(light) = gltf_node.light() {
557557
match light.kind() {
558558
gltf::khr_lights_punctual::Kind::Directional => {
559-
parent.spawn_bundle(DirectionalLightBundle {
559+
let mut entity = parent.spawn_bundle(DirectionalLightBundle {
560560
directional_light: DirectionalLight {
561561
color: Color::from(light.color()),
562562
// NOTE: KHR_punctual_lights defines the intensity units for directional
@@ -566,9 +566,12 @@ fn load_node(
566566
},
567567
..Default::default()
568568
});
569+
if let Some(name) = light.name() {
570+
entity.insert(Name::new(name.to_string()));
571+
}
569572
}
570573
gltf::khr_lights_punctual::Kind::Point => {
571-
parent.spawn_bundle(PointLightBundle {
574+
let mut entity = parent.spawn_bundle(PointLightBundle {
572575
point_light: PointLight {
573576
color: Color::from(light.color()),
574577
// NOTE: KHR_punctual_lights defines the intensity units for point lights in
@@ -581,6 +584,9 @@ fn load_node(
581584
},
582585
..Default::default()
583586
});
587+
if let Some(name) = light.name() {
588+
entity.insert(Name::new(name.to_string()));
589+
}
584590
}
585591
gltf::khr_lights_punctual::Kind::Spot {
586592
inner_cone_angle: _inner_cone_angle,

0 commit comments

Comments
 (0)