diff --git a/bodies/body.py b/bodies/body.py index abdbad814d76c0c85c5cf80f2ec63acf662961b3..3f20dd4a359ec400ba82f818b138c08d0ac3a335 100644 --- a/bodies/body.py +++ b/bodies/body.py @@ -371,12 +371,15 @@ class Body(metaclass=ABCMeta): except Exception as e: err_msg = f"{json_file} 格式错误:" + str(e) raise Exception(err_msg) + is_fixed_star = False if "is_fixed_star" in body_data: if body_data["is_fixed_star"]: - body_data.pop("is_fixed_star") - body = FixedStar(**body_data) - else: + is_fixed_star = True + if is_fixed_star: + body_data.pop("is_fixed_star") body = FixedStar(**body_data) + else: + body = Body(**body_data) bodies.append(body) if "params" in json_data: params = json_data["params"] diff --git a/data/gravity_slingshot.json b/data/gravity_slingshot.json index 7cce92b9a972cfdbd646eb2d1757bd65e96c59a7..b0f9ffaf65f20f024fab127e8d445a4cb4978ea7 100644 --- a/data/gravity_slingshot.json +++ b/data/gravity_slingshot.json @@ -24,7 +24,12 @@ "distance_scale": 1.0, "rotation_speed": 0.613, "ignore_mass": false, - "is_fixed_star": true + "is_fixed_star": true, + "trail_color": [ + 170, + 98, + 25 + ] }, { "name": "地球", @@ -50,15 +55,22 @@ "distance_scale": 1.0, "rotation_speed": 15, "ignore_mass": false, - "is_fixed_star": false + "is_fixed_star": false, + "trail_color": [ + 1, + 89, + 162 + ] } ], "params": { "dt": 2592000, "position": [ 0, - 149597870.7, - -448793612.09999996 - ] + 74798935.35, + -598391482.8 + ], + "show_trail": true, + "show_name": false } } \ No newline at end of file diff --git a/data/sun.json b/data/sun.json index e1b503f3e3d2c65c8299c07d90d9356afcc8331f..2c8e66fc79c25b090d88830686a0c9836fce60e3 100644 --- a/data/sun.json +++ b/data/sun.json @@ -32,7 +32,7 @@ "position": [ 0, 149597870.7, - -448793612.09999996 + -598391482.8 ] } } \ No newline at end of file diff --git a/data/sun_earth.json b/data/sun_earth.json index a1e15ed6a04771879739dc16f8f83df7f948e11a..c75e11365b92a80ec5761344f84064d2e8fe5af5 100644 --- a/data/sun_earth.json +++ b/data/sun_earth.json @@ -24,7 +24,12 @@ "distance_scale": 1.0, "rotation_speed": 0.613, "ignore_mass": false, - "is_fixed_star": true + "is_fixed_star": true, + "trail_color": [ + 170, + 98, + 25 + ] }, { "name": "地球", @@ -50,7 +55,12 @@ "distance_scale": 1, "rotation_speed": 15, "ignore_mass": false, - "is_fixed_star": false + "is_fixed_star": false, + "trail_color": [ + 1, + 89, + 162 + ] } ], "params": { @@ -58,7 +68,9 @@ "position": [ 0, 149597870.7, - -448793612.09999996 - ] + -598391482.8 + ], + "show_trail": true, + "show_name": false } } \ No newline at end of file diff --git a/data/tri_bodies_perfect_01.json b/data/tri_bodies_perfect_01.json index 7750c2bb6dac43346085482361f17c9bb8b8b127..fe7bdf2686f1b33c2993d1d9e955ef88f572f616 100644 --- a/data/tri_bodies_perfect_01.json +++ b/data/tri_bodies_perfect_01.json @@ -117,6 +117,8 @@ 0, 149597870.7, -1495978707.0 - ] + ], + "show_trail": true, + "show_name": false } } \ No newline at end of file diff --git a/data/tri_bodies_perfect_02.json b/data/tri_bodies_perfect_02.json index 586b9ac63f8e8abe199f8e3c6143bcead483f3d0..fb8348623a29aa6dc6f84a4265adb2f3b87fceac 100644 --- a/data/tri_bodies_perfect_02.json +++ b/data/tri_bodies_perfect_02.json @@ -94,6 +94,8 @@ 0, 149597870.7, -1495978707.0 - ] + ], + "show_trail": true, + "show_name": false } } \ No newline at end of file diff --git a/data/tri_bodies_perfect_03.json b/data/tri_bodies_perfect_03.json index c99e421a9705e0382df82ad97a3f5f10fa88bf6a..b56337e4261c6d7734986074c0c8dbd3756a3c02 100644 --- a/data/tri_bodies_perfect_03.json +++ b/data/tri_bodies_perfect_03.json @@ -94,6 +94,8 @@ 0, 149597870.7, -1495978707.0 - ] + ], + "show_trail": true, + "show_name": false } } \ No newline at end of file diff --git a/sim_scenes/ursina_json_sim.py b/sim_scenes/ursina_json_sim.py index 879099d1ebe807d04da36039319cd010e7aa25c1..d965f082beb56138cc308f7389c9bc2665e658b2 100644 --- a/sim_scenes/ursina_json_sim.py +++ b/sim_scenes/ursina_json_sim.py @@ -33,7 +33,7 @@ if __name__ == '__main__': dt = params["dt"] if "dt" in params else SECONDS_PER_YEAR position = params["position"] if "position" in params else (0, 0, 0) - show_trail = params["show_trail"] if "show_trail" in params else True + show_trail = params["show_trail"] if "show_trail" in params else False # 使用 ursina 查看的运行效果 # 常用快捷键: P:运行和暂停 O:重新开始 I:显示天体轨迹