https://github.com/bevyengine/bevy/pull/15524
Handle<Scene> → SceneRoot( Handle<Scene> )
Handle<Mesh> → Mesh3d( Handle<Mesh> )
Handle<Material<T>> → MeshMaterial3d( Handle<Material<T>> )
Use SceneInstanceReady as trigger ! Not as an event .read() …
(This means they will be ‘pushed’ instead of ‘polled’ )
.add_observer(handle_material_overrides_when_scene_ready)
...
fn handle_material_overrides_when_scene_ready(
scene_instance_evt_trigger: Trigger<SceneInstanceReady> ,
material_override_request_query: Query<&MaterialOverrideWhenSceneReadyComponent >,
mut commands: Commands,
parent_query : Query<&Parent>,
){
let trig_entity = scene_instance_evt_trigger.entity();
let Some(parent_entity) = parent_query.get(trig_entity).ok().map( |p| p.get() ) else {return};
// need to check parent !?
let Some(mat_override_request) = material_override_request_query.get(parent_entity).ok() else {return};
let material_override = mat_override_request.material_override.clone() ;
if let Some(mut cmd) = commands.get_entity( trig_entity ) {
cmd.try_insert(
MaterialOverrideComponent {
material_override
}
);
}
}
https://github.com/bevyengine/bevy/blob/main/examples/3d/mesh_ray_cast.rs