diff --git a/simulators/ursina/ui/control_handler.py b/simulators/ursina/ui/control_handler.py index 1029caecba4aa95bec61b18340b87edc2bc82c80..a6fefe4918ca3e2492edf5723495c177b9a792a9 100644 --- a/simulators/ursina/ui/control_handler.py +++ b/simulators/ursina/ui/control_handler.py @@ -227,10 +227,17 @@ class ControlHandler(EventHandler): elif key == '-' or key == "- up": self.slider_decrease(self.ui.slider_run_speed_factor) elif key == 'n': + import math + # min=0.01, max=20 # # ', up' < > '. up' n m - self.slider_decrease(self.ui.slider_control_speed_factor, 10) + self.ui.slider_control_speed_factor.current_step = self.ui.slider_control_speed_factor.value/2 + self.slider_decrease(self.ui.slider_control_speed_factor, self.ui.slider_control_speed_factor.current_step) + + print(self.ui.slider_control_speed_factor.current_step) elif key == 'm': - self.slider_increase(self.ui.slider_control_speed_factor, 10) + self.ui.slider_control_speed_factor.current_step = self.ui.slider_control_speed_factor.value + self.slider_increase(self.ui.slider_control_speed_factor, self.ui.slider_control_speed_factor.current_step) + print(self.ui.slider_control_speed_factor.current_step) def slider_increase(self, slider, step=50): """ @@ -239,7 +246,7 @@ class ControlHandler(EventHandler): @param step: @return: """ - run_speed_factor = slider.value + slider.step * step + run_speed_factor = slider.value + step if run_speed_factor > slider.max: run_speed_factor = slider.max slider.value = run_speed_factor @@ -252,7 +259,7 @@ class ControlHandler(EventHandler): @param step: @return: """ - value = slider.value - slider.step * step + value = slider.value - step if value < slider.min: value = slider.min slider.value = value diff --git a/simulators/ursina/ui/control_ui.py b/simulators/ursina/ui/control_ui.py index 8c744bdfd0c821f6f1bf4773cb85d32bfe7862bb..de545d102164ea1a6ded166a141bca18bc1c83b1 100644 --- a/simulators/ursina/ui/control_ui.py +++ b/simulators/ursina/ui/control_ui.py @@ -30,10 +30,11 @@ class ControlUI(UiPanel): self.no_trail_button_text = "○ " self.trail_button_text = "○--" - self.slider_body_spin_factor = UiSlider(text='自转速度', min=0.01, max=30, default=1) + self.slider_body_spin_factor = UiSlider(text='自转速度', min=0.01, max=5, default=1) self.slider_body_size_factor = UiSlider(text='天体缩放', min=0.1, max=100, step=0.1, default=1) self.slider_run_speed_factor = UiSlider(text="运行速度", min=0.01, max=80, default=1) - self.slider_control_speed_factor = UiSlider(text="控制速度", min=0.01, max=20, default=application.time_scale) + self.slider_control_speed_factor = UiSlider(text="控制速度", min=0.01, max=20, + step=0.1, default=application.time_scale) self.slider_trail_length = UiSlider(text="拖尾长度", min=30, max=500, step=10, default=UrsinaConfig.trail_length) self.on_off_switch = SwithButton((self.pause_button_text, diff --git a/simulators/views/ursina_view.py b/simulators/views/ursina_view.py index b68de624cc8fd41a537b8d3019f50c4412fd53d2..00503fccf2120f45b52c4ae483a3205eb13eef67 100644 --- a/simulators/views/ursina_view.py +++ b/simulators/views/ursina_view.py @@ -285,9 +285,16 @@ class Planet(Entity): self.clear_trails() if hasattr(self, "name_text"): - # 计算相机和实体之间的距离 - distance = (camera.world_position - self.world_position).length() - # 根据距离设置文本缩放比例 + d = (camera.world_position - self.name_text.world_position).length() + + if d < self.scale_x * 1.22: + self.name_text.visible = False + else: + self.name_text.visible = True + # print(d, self.name_text.text, self.scale_x ,self.scale_x*1.23) + # # 计算相机和实体之间的距离 + # distance = (camera.world_position - self.world_position).length() + # # 根据距离设置文本缩放比例 # self.name_text.scale = distance / 10 def follow_parent(self):