@@ -82,10 +82,11 @@ impl MapTextManager {
8282 let indices = & [ 0 , 1 , 2 , 1 , 2 , 3 ] ;
8383 Mesh :: new ( context, vertices, indices, texture)
8484 } ;
85+ let move_speed = 1.0 ;
8586 self . visible_labels_list . insert ( self . last_label_id , MapText {
8687 pos : command. pos . clone ( ) ,
8788 mesh : mesh,
88- move_helper : MoveHelper :: new ( & from, & to, 1.0 ) ,
89+ move_helper : MoveHelper :: new ( & from, & to, move_speed ) ,
8990 } ) ;
9091 self . last_label_id += 1 ;
9192 }
@@ -113,9 +114,16 @@ impl MapTextManager {
113114 self . do_commands ( context) ;
114115 let rot_z_mat = Matrix4 :: from ( Matrix3 :: from_angle_z ( camera. get_z_angle ( ) ) ) ;
115116 let rot_x_mat = Matrix4 :: from ( Matrix3 :: from_angle_x ( camera. get_x_angle ( ) ) ) ;
116- context. data . basic_color = [ 0.0 , 0.0 , 0.0 , 1.0 ] ;
117117 for ( _, map_text) in & mut self . visible_labels_list {
118- // TODO: fade to alpha
118+ // TODO: use https://github.com/orhanbalci/rust-easing
119+ let t = 0.8 ;
120+ let p = map_text. move_helper . progress ( ) ;
121+ let alpha = if p > t {
122+ ( 1.0 - p) / ( 1.0 - t)
123+ } else {
124+ 1.0
125+ } ;
126+ context. data . basic_color = [ 0.0 , 0.0 , 0.0 , alpha] ;
119127 let pos = map_text. move_helper . step ( dtime) ;
120128 let tr_mat = Matrix4 :: from_translation ( pos. v ) ;
121129 let mvp = camera. mat ( ) * tr_mat * rot_z_mat * rot_x_mat;
0 commit comments