提交 117b7e18 编写于 作者: 三月三net's avatar 三月三net

太阳系三体模拟器

上级 9ef242fd
......@@ -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):
......
......@@ -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)
......@@ -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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册