diff --git a/sim_scenes/solar_system/halley_comet_sim.py b/sim_scenes/solar_system/halley_comet_sim.py index ecfb96155252e1521156fb4c850050b5a07915e6..857b6867c0acd6523afeb7509248d26806eecbdd 100644 --- a/sim_scenes/solar_system/halley_comet_sim.py +++ b/sim_scenes/solar_system/halley_comet_sim.py @@ -13,8 +13,9 @@ from ursina import camera, application from bodies import Sun, Mercury, Venus, Earth, Mars, Jupiter, Saturn, Uranus, Neptune, Pluto from common.celestial_data_service import get_init_pos_vels, init_bodies_pos_vels from common.consts import SECONDS_PER_YEAR, AU +from common.func import calculate_distance from objs import HalleComet, Obj -from sim_scenes.func import camera_look_at, two_bodies_colliding +from sim_scenes.func import camera_look_at, two_bodies_colliding, create_text_panel from sim_scenes.func import ursina_run, create_sphere_sky from simulators.ursina.ursina_event import UrsinaEvent @@ -34,7 +35,7 @@ class HalleyCometSim: 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, rotate_angle=0), # 地球放大 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 倍 Jupiter(size_scale=1.68e3, distance_scale=1), # 木星放大 680 倍,距离缩小到真实距离的 0.72 Saturn(size_scale=1.68e3, distance_scale=1), # 土星放大 680 倍,距离缩小到真实距离的 0.52 @@ -55,16 +56,17 @@ class HalleyCometSim: # 每76.1年环绕太阳一周的周期彗星 # 3.335, 0, 10.7 73 # 3.33, 0, 10.7 73 - - self.halley_comet = HalleComet(# size_scale=4e7, - size_scale=1e8, - init_velocity=[3.33, 0, 10.65], # [3.33, 0, 10.6] < ? <[3.34, 0, 10.7] - init_position=[0, 0.5 * AU, -10 * AU]) \ + # [3.33, 0, 10.65] 71 + # [3.33, 0, 10.655] 68 + # [3.33, 0, 10.66] 69 + self.halley_comet = HalleComet( # size_scale=4e7, + size_scale=1e8, + init_velocity=[3.33, 0, 10.699], # [3.33, 0, 10.6] < ? <[3.34, 0, 10.7] + init_position=[0, 0.5 * AU, -10 * AU]) \ .set_light_disable(True) self.bodies.append(self.halley_comet) - def build(self): self.build_solar_system() self.build_halley_comet() @@ -80,7 +82,7 @@ class HalleyCometSim: create_sphere_sky(scale=200000) application.time_scale = 5 - + self.text_panel = create_text_panel() def on_timer_changed(self, time_data): """ @@ -94,7 +96,8 @@ class HalleyCometSim: self.halley_comet.planet.rotation_y += 1 # 摄像机始终看向二向箔 # camera_look_at(self.halley_comet) - + d = calculate_distance(self.halley_comet.position, self.sun.position) + self.text_panel.text = "哈雷彗星距离太阳:%.3f AU" % (d / AU) if __name__ == '__main__':