From ef6e4c8e3922db90d89b82afe7a3f0d55e316c17 Mon Sep 17 00:00:00 2001 From: march3 Date: Sun, 17 Dec 2023 19:57:02 +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?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sim_scenes/featured/earth_seasons_1.py | 4 ++-- sim_scenes/featured/earth_seasons_2.py | 4 ++-- sim_scenes/featured/earth_seasons_3.py | 6 +++--- sim_scenes/featured/earth_seasons_base.py | 7 ++++--- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/sim_scenes/featured/earth_seasons_1.py b/sim_scenes/featured/earth_seasons_1.py index 0d8c5a0..a273209 100644 --- a/sim_scenes/featured/earth_seasons_1.py +++ b/sim_scenes/featured/earth_seasons_1.py @@ -19,7 +19,7 @@ class EarthSeasonsSim(EarthSeasonsSimBase): super(EarthSeasonsSim, self).__init__(sun_transparent=False, show_sphere_sky=False, look_at_earth=False, - exit_at_total_days=400, + # exit_at_total_days=400, earth_cn_size_factor=1.01, show_name=False) @@ -33,4 +33,4 @@ if __name__ == '__main__': 摄像机以侧视图(秋分侧)看太阳和地球(四季和24节气) """ sim = EarthSeasonsSim() - sim.run((3 * AU, AU, 0)) + sim.run(init_position=(3 * AU, AU, 0), speed_factor=10.0) diff --git a/sim_scenes/featured/earth_seasons_2.py b/sim_scenes/featured/earth_seasons_2.py index c9d7aa6..471ab2d 100644 --- a/sim_scenes/featured/earth_seasons_2.py +++ b/sim_scenes/featured/earth_seasons_2.py @@ -19,7 +19,7 @@ class EarthSeasonsSim(EarthSeasonsSimBase): super(EarthSeasonsSim, self).__init__(sun_transparent=False, show_sphere_sky=False, look_at_earth=False, - exit_at_total_days=400, + # exit_at_total_days=400, earth_cn_size_factor=1.01, show_name=False) @@ -33,4 +33,4 @@ if __name__ == '__main__': 摄像机以侧视图(夏至侧)看太阳和地球(四季和24节气) """ sim = EarthSeasonsSim() - sim.run((0, AU, -3 * AU)) + sim.run(init_position=(0, AU, -3 * AU), speed_factor=10.0) diff --git a/sim_scenes/featured/earth_seasons_3.py b/sim_scenes/featured/earth_seasons_3.py index 3b6aaeb..0308d42 100644 --- a/sim_scenes/featured/earth_seasons_3.py +++ b/sim_scenes/featured/earth_seasons_3.py @@ -13,13 +13,13 @@ from sim_scenes.func import camera_look_at class EarthSeasonsSim(EarthSeasonsSimBase): - window_size = (1920 / 3, 1080 / 3) + window_size = (1920 / 2, 1080 / 2) def __init__(self): super(EarthSeasonsSim, self).__init__(sun_transparent=False, show_sphere_sky=False, look_at_earth=False, - exit_at_total_days=400, + # exit_at_total_days=400, earth_cn_size_factor=1.01, show_name=False) @@ -33,4 +33,4 @@ if __name__ == '__main__': 摄像机以俯视图看太阳和地球(四季和24节气) """ sim = EarthSeasonsSim() - sim.run((0, 4 * AU, 0)) + sim.run(init_position=(0, 4 * AU, 0), speed_factor=10.0) diff --git a/sim_scenes/featured/earth_seasons_base.py b/sim_scenes/featured/earth_seasons_base.py index 29ad0a4..883e47c 100644 --- a/sim_scenes/featured/earth_seasons_base.py +++ b/sim_scenes/featured/earth_seasons_base.py @@ -152,7 +152,7 @@ class EarthSeasonsSimBase(UniverseSimScenes): from ursina import application, invoke def delay_app_start(): import time - time.sleep(8.0) + time.sleep(8.0 / self.speed_factor) self.wait_days_count = 0 application.paused = False @@ -199,7 +199,8 @@ class EarthSeasonsSimBase(UniverseSimScenes): # print(camera.rotation_y) - def run(self, init_position=(0, 0, 0)): + def run(self, init_position=(0, 0, 0), speed_factor=1.0): + self.speed_factor = speed_factor # 订阅事件后,上面2个函数功能才会起作用 # 运行前会触发 on_ready UrsinaEvent.on_ready_subscription(self.on_ready) @@ -210,7 +211,7 @@ class EarthSeasonsSimBase(UniverseSimScenes): # 使用 ursina 查看的运行效果 # 常用快捷键: P:运行和暂停 O:重新开始 I:显示天体轨迹 # position = 左-右+、上+下-、前+后- - ursina_run(self.bodies, SECONDS_PER_DAY, + ursina_run(self.bodies, SECONDS_PER_DAY * speed_factor, position=init_position, # 摄像机和太阳是相同位置 show_name=self.show_name, show_grid=False, -- GitLab