diff --git a/scenes/func.py b/scenes/func.py index 6a93a47e3dcd23d74c7076c58bcb4b74ad1311f1..2264935de5358e801022df1c3b53313db100eec9 100644 --- a/scenes/func.py +++ b/scenes/func.py @@ -64,6 +64,7 @@ def ursina_run(bodies, show_grid=True, show_trail=False, show_name=False, + view_closely=False, save_as_json=None): """ @@ -144,7 +145,9 @@ def ursina_run(bodies, sys.modules["__main__"].update = callback_update if show_trail: UrsinaConfig.show_trail = show_trail - simulator.run(dt, light=light, cosmic_bg=cosmic_bg, show_grid=show_grid, bg_music=bg_music) + simulator.run(dt, light=light, cosmic_bg=cosmic_bg, + show_grid=show_grid, bg_music=bg_music, + view_closely=view_closely) def mpl_run(bodies, dt=SECONDS_PER_WEEK, gif_file_name=None, gif_max_frame=200): diff --git a/scenes/mercury_high_resolution.py b/scenes/mercury_high_resolution.py index b935dbb1923f54c02fa650cce8594617b26e9605..61602a7f3a7325f88cd87e55ba2dbd49b8c93bf7 100644 --- a/scenes/mercury_high_resolution.py +++ b/scenes/mercury_high_resolution.py @@ -22,4 +22,6 @@ if __name__ == '__main__': # 使用 ursina 查看的运行效果 # 常用快捷键: P:运行和暂停 O:重新开始 I:显示天体轨迹 # position = 左-右+、上+下-、前+后- - ursina_run(bodies, SECONDS_PER_DAY, position=(0, 30000, -600000), cosmic_bg="../textures/cosmic1.jpg") + ursina_run(bodies, SECONDS_PER_DAY, position=(0, 30000, -600000), + cosmic_bg="../textures/cosmic1.jpg", + view_closely=True) diff --git a/simulators/ursina_simulator.py b/simulators/ursina_simulator.py index e8f43e5a8022b852e9e34487cc332d369265e052..4cdbf1d9cf627fc2d36d2726cb28fcf430ca5654 100644 --- a/simulators/ursina_simulator.py +++ b/simulators/ursina_simulator.py @@ -163,7 +163,11 @@ class UrsinaSimulator(Simulator): """ # Add skybox from ursina import Sky - Sky(texture=texture).scale = 10000 + sky_scale = 50000 + Sky(texture=texture).scale = sky_scale + # 一定要够大,如果小于 Sky(texture=texture).scale = 50000,宇宙背景就会出现黑色方洞 + if camera.clip_plane_far < sky_scale * 2: + camera.clip_plane_far = sky_scale * 2 # texture = load_texture(texture) # sky_dome = Entity(model='sky_dome', texture=texture, scale=10000, @@ -231,7 +235,14 @@ class UrsinaSimulator(Simulator): def run(self, dt, **kwargs): window.title = '宇宙模拟器' - + view_closely = False + if "view_closely" in kwargs: + view_closely = kwargs["view_closely"] + + if view_closely: + # 设置 camera 的裁剪面和位置 + camera.clip_plane_near = 0.01 + camera.fov = 60 # 设置 camera 的裁剪面和位置 # camera.clip_plane_near = 0.01 # camera.fov = 120