From e77a06ecb253ab80ed0b19a505d1f312b2218967 Mon Sep 17 00:00:00 2001 From: march3 Date: Sat, 21 Oct 2023 20:47:23 +0800 Subject: [PATCH] =?UTF-8?q?Python=E8=B6=85=E4=BA=BA-=E5=AE=87=E5=AE=99?= =?UTF-8?q?=E6=A8=A1=E6=8B=9F=E5=99=A8(=E4=BB=A3=E7=A0=81=E5=A4=87?= =?UTF-8?q?=E4=BB=BD=EF=BC=8C=E5=90=8E=E9=9D=A2=E8=BF=9B=E8=A1=8C=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E7=9A=84=E6=B8=85=E7=90=86)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sim_scenes/tri_bodies/two_way_foil.py | 31 +++++++++++++++++---------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/sim_scenes/tri_bodies/two_way_foil.py b/sim_scenes/tri_bodies/two_way_foil.py index 2aed45d..6b280a4 100644 --- a/sim_scenes/tri_bodies/two_way_foil.py +++ b/sim_scenes/tri_bodies/two_way_foil.py @@ -82,13 +82,13 @@ class TwoWayFoilSim: self.sun, # 太阳放大 80 倍 Mercury(size_scale=4e3, distance_scale=1.3), # 水星放大 4000 倍,距离放大 1.3 倍 Venus(size_scale=4e3, distance_scale=1.3), # 金星放大 4000 倍,距离放大 1.3 倍 - Earth(size_scale=4e3, distance_scale=1.3), # 地球放大 4000 倍,距离放大 1.3 倍 + Earth(size_scale=4e3, distance_scale=1.3, rotate_angle=0), # 地球放大 4000 倍,距离放大 1.3 倍 Mars(size_scale=4e3, distance_scale=1.2), # 火星放大 4000 倍,距离放大 1.2 倍 # Asteroids(size_scale=1e2, parent=self.sun), # 小行星模拟(仅 ursina 模拟器支持) Jupiter(size_scale=0.68e3, distance_scale=0.72), # 木星放大 680 倍,距离缩小到真实距离的 0.72 Saturn(size_scale=0.68e3, distance_scale=0.52), # 土星放大 680 倍,距离缩小到真实距离的 0.52 - Uranus(size_scale=0.8e3, distance_scale=0.36), # 天王星放大 800 倍,距离缩小到真实距离的 0.36 - Neptune(size_scale=1e3, distance_scale=0.27), # 海王星放大 1000 倍,距离缩小到真实距离的 0.27 + Uranus(size_scale=1.5e3, distance_scale=0.36), # 天王星放大 1500 倍,距离缩小到真实距离的 0.36 + Neptune(size_scale=1.5e3, distance_scale=0.27), # 海王星放大 1500 倍,距离缩小到真实距离的 0.27 Pluto(size_scale=10e3, distance_scale=0.23), # 冥王星放大 10000 倍,距离缩小到真实距离的 0.23(从太阳系的行星中排除) ] # endregion @@ -169,14 +169,24 @@ class TwoWayFoilSim: def flatten_animation(self, body, flatten_body): def flatten_update(planet, flatten_planet): def warp(): - planet.scale_y /= 1.05 + planet.init_update() # time.sleep(0.2) - if planet.scale_y < 10: - planet.enabled = False - flatten_planet.enabled = True + if planet.scale_y > planet.init_scale_y / 20: + planet.scale_y_v /= 1.01 + # planet.enabled = False + # flatten_planet.enabled = True + # planet.update = planet.init_update + # elif planet.scale_y < planet.init_scale_y / 1.01: + # planet.set_light_off(True) + planet.set_light_off(True) + planet.scale_y = planet.scale_y_v return warp + body.planet.rotation_speed /= 20 + body.planet.scale_y_v = body.planet.scale_y + body.planet.init_scale_y = body.planet.scale_y + body.planet.init_update = body.planet.update body.planet.update = flatten_update(body.planet, flatten_body.planet) # for i in range(10): @@ -236,13 +246,12 @@ class TwoWayFoilSim: two_way_delay_times = [0.5, # 太阳 0.5, 0.8, 1.0, # 水星 金星 地球 1.2, 2.0, 3.0, # 火星 木星 土星 - 4.0, 5.0, 6.5] # 天王星 海王星 冥王星 + 4.0, 4.5, 5.5] # 天王星 海王星 冥王星 for idx, b in enumerate(self.three_dim_bodies): if hasattr(b, "two_way_time"): if b.two_way_time is not None: if time.time() - b.two_way_time > two_way_delay_times[idx]: - t = threading.Thread(target=self.flatten_animation, args=[b, b.two_dim]) - t.start() + self.flatten_animation(b, b.two_dim) # b.planet.enabled = False # b.two_dim.planet.enabled = True b.two_way_time = None @@ -257,7 +266,7 @@ class TwoWayFoilSim: def on_timer_changed(self, time_data): self.two_way_foil.planet.rotation_x += 0.1 - self.two_way_foil.planet.rotation_y += 0.8 + self.two_way_foil.planet.rotation_y += 1 # self.two_way_foil.planet.rotation_z += 10 camera_look_at(self.two_way_foil) self.current_stage() -- GitLab