Skip to content

Commit 1e7d7c0

Browse files
committed
y_adjust
1 parent 49d50bf commit 1e7d7c0

File tree

1 file changed

+9
-25
lines changed

1 file changed

+9
-25
lines changed

shaders/src/shaders/loading_repeating_circles.rs

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ struct RotatingCircleResult {
419419
fn rotating_discrete_circle(
420420
center: Vec2,
421421
radius: f32,
422-
t: f32,
422+
start_angle: f32,
423423
num_circles: i32,
424424
cirle_index: i32,
425425
) -> RotatingCircleResult {
@@ -428,7 +428,7 @@ fn rotating_discrete_circle(
428428
// base angle for this circle index
429429
let base_angle = angle_step * cirle_index as f32;
430430
// total rotation angle
431-
let angle = base_angle + t * TWO_PI;
431+
let angle = base_angle + start_angle;
432432
// compute offset from center
433433
let offset = vec2(angle.cos(), angle.sin()) * radius;
434434
// return world‐space position
@@ -529,28 +529,19 @@ impl Inputs {
529529
let middle_circle_start_radius = start_radius + H;
530530
let middle_circle_radius = mix(middle_circle_start_radius, target_radius, t_middle);
531531
let middle_circle_start_position = bottom_middle - Vec2::new(0.0, H);
532-
let middle_circle_position = mix(middle_circle_start_position, center, t_middle);
532+
let mut middle_circle_position = mix(middle_circle_start_position, center, t_middle);
533533
let middle_circle_moved_distance =
534534
(middle_circle_start_position - middle_circle_position).length();
535535
let outer_circle_outer_radius = (middle_circle_start_radius + target_radius)
536536
- (middle_circle_radius + middle_circle_moved_distance);
537537
let trail_angular_extent = mix(0.0, angle_between_circles, t_trail);
538538
let outer_circle_fade = mix(1.0, 0.4, t_trail);
539539

540-
let target_rotating_circle = rotating_discrete_circle(
541-
bottom_middle - Vec2::new(0.0, H),
542-
start_radius + H,
543-
0.0,
544-
num_circles,
545-
3,
546-
);
540+
// y adjust to follow the middle circle
541+
middle_circle_position.y -=
542+
(middle_circle_position.y + middle_circle_radius) * (1.0 - t_master);
547543

548-
let m_start_circle = sdf_circle_outline(
549-
uv,
550-
target_rotating_circle.position,
551-
target_radius,
552-
target_stroke,
553-
);
544+
let m_start_circle = sdf_circle_outline(uv, Vec2::ZERO, target_radius, target_stroke);
554545
debug_red_alpha = debug_red_alpha.max(m_start_circle);
555546
let m_middle_circle_path = sdf_circle_outline(
556547
uv,
@@ -565,18 +556,10 @@ impl Inputs {
565556
let outer_discrete_circle = rotating_discrete_circle(
566557
middle_circle_position,
567558
middle_circle_radius,
568-
-t_rotation * 5.0,
559+
-t_rotation * TWO_PI * 5.0,
569560
num_circles,
570561
i,
571562
);
572-
let m = sdf_circle_outline(
573-
uv,
574-
outer_discrete_circle.position - vec2(0.1, 0.0),
575-
outer_circle_outer_radius,
576-
target_stroke,
577-
);
578-
// Combine masks using max to create a single mask.
579-
//combined_mask = combined_mask.max(m);
580563

581564
let outer_circle_inner_radius = (outer_circle_outer_radius - target_stroke / 2.0).max(0.0);
582565
let outer_circle_outer_radius = outer_circle_outer_radius + target_stroke / 2.0;
@@ -606,6 +589,7 @@ impl Inputs {
606589

607590
let color_background = Vec4::ONE;
608591
let color_black = Vec4::new(0.0, 0.0, 0.0, black_alpha);
592+
//debug_red_alpha = 0.0;
609593
let color_red = Vec4::new(1.0, 0.0, 0.0, debug_red_alpha * 0.5);
610594
let color_blue = Vec4::new(0.0, 0.0, 1.0, debug_blue_alpha * 0.5);
611595

0 commit comments

Comments
 (0)