// TODO: only run when knob has changed
only run when knob has changed
only run when knob has changed
fn modify_angle(
    globals: Res<Globals>,
    other_globals: Res<OtherGlobals>,
    mut my_shaders_params: ResMut<Assets<KnobShader>>,
    mut commands: Commands,
    mut query: Query<
        (
            &Handle<KnobShader>,
            Option<&LinearKnob<f64>>,
            Option<&LinearKnob<i64>>,
        ),
        With<RotatingKnob>,
    >,
) {
    for (mut knob_shader_handle, maybe_knob_f64, maybe_knpb_i64) in query.iter_mut() {
        let shader_params = my_shaders_params.get_mut(knob_shader_handle).unwrap();
        if let Some(knob) = maybe_knob_f64 {
            // println!("value: {:?}", knob.get_angle());
            // println!("bounds: {:?}", shader_params.bounds);
            let knob_angle = knob.get_angle() as f32;
            shader_params.angle = knob_angle;
        } else if let Some(knob) = maybe_knpb_i64 {
            // println!("bounds: {:?}", shader_params.bounds);
            // println!("value: {:?}", knob.get_angle());
            let knob_angle = knob.get_angle() as f32;
            shader_params.angle = knob_angle;
        }
    }
}
fn modify_angle ( globals : Res < Globals > , other_globals : Res < OtherGlobals > , mut my_shaders_params : ResMut < Assets < KnobShader > > , mut commands : Commands , mut query : Query < ( & Handle < KnobShader > , Option < & LinearKnob < f64 > > , Option < & LinearKnob < i64 > > , ) , With < RotatingKnob > , > , ) { for ( mut knob_shader_handle , maybe_knob_f64 , maybe_knpb_i64 ) in query . iter_mut ( ) { let shader_params = my_shaders_params . get_mut ( knob_shader_handle ) . unwrap ( ) ; if let Some ( knob ) = maybe_knob_f64 { // println!("value: {:?}", knob.get_angle()); // println!("bounds: {:?}", shader_params.bounds); let knob_angle = knob . get_angle ( ) as f32 ; shader_params . angle = knob_angle ; } else if let Some ( knob ) = maybe_knpb_i64 { // println!("bounds: {:?}", shader_params.bounds); // println!("value: {:?}", knob.get_angle()); let knob_angle = knob . get_angle ( ) as f32 ; shader_params . angle = knob_angle ; } } }
TODO: only run when knob has changed
TODO : only run when knob has changed
globals
Res<Globals>
other_globals
Res<OtherGlobals>
my_shaders_params
ResMut<Assets<KnobShader>>
commands
Commands
query
Query<
        (
            &Handle<KnobShader>,
            Option<&LinearKnob<f64>>,
            Option<&LinearKnob<i64>>,
        ),
        With<RotatingKnob>,
    >