Replies: 1 comment
-
Events bubble from children to parents. Note that there is only one event listener for all meshes in the scene. This is because the events from the children (e.g. the goggles) bubble to the root of the scene.
It does. When you click on the goggles, the event bubbles to the root, and triggers the event listener, which prints to the console: info!("Clicked on entity {:?}", event.target);
In that case, you need to write a callback that highlights everything in the scene. // on the scene root
OnPointer::<Click>::run_callback(highlight_everything)
fn highlight_everything(
In(event): In<ListenedEvent<Click>>,
mut materials: ResMut<Assets<StandardMaterial>>,
meshes: Query<&Handle<StandardMaterial>>,
) -> Bubble {
for mesh in meshes.iter() {
// highlight the mesh
}
Bubble::Up
} |
Beta Was this translation helpful? Give feedback.
-
When we run this gltf example, if we click on the helmet leather, the goggle, the breathing mask, etc., we see in the console that different entities of this
FlightHelmet.gltf
scene was clicked.But my understanding, which could be completely wrong, of the example's comment was that clicking on any of these entities in the scene would bubble to the scene level? So that the entire scene (top helmet leather, goggle, tube, mask, and the wooden stand) would be considered clicked and highlighted?
If my understanding is wrong, how could I go about highlighting this entire scene when one of its entities was clicked or hovered? Thanks for your time!
Beta Was this translation helpful? Give feedback.
All reactions