From 6cc0a4a364a5b6c028b812dc14f1b13bb15a2713 Mon Sep 17 00:00:00 2001 From: march3 Date: Tue, 25 Jul 2023 15:11:08 +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 --- .../solar_system/solar_system_reality.py | 3 +++ simulators/ursina/entities/planet.py | 20 ++++++++++++------- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/sim_scenes/solar_system/solar_system_reality.py b/sim_scenes/solar_system/solar_system_reality.py index f0fc2d0..0dc84b6 100644 --- a/sim_scenes/solar_system/solar_system_reality.py +++ b/sim_scenes/solar_system/solar_system_reality.py @@ -142,6 +142,9 @@ if __name__ == '__main__': Neptune(name="海王星", size_scale=10e2), # 海王星 ] + earth = bodies[3] + earth.rotate_axis_color = (255, 255, 50) + names = get_bodies_names(bodies) names = names.replace("Asteroids,", "") diff --git a/simulators/ursina/entities/planet.py b/simulators/ursina/entities/planet.py index 39cf14c..35ab447 100644 --- a/simulators/ursina/entities/planet.py +++ b/simulators/ursina/entities/planet.py @@ -7,7 +7,7 @@ # python_version :3.8 # ============================================================================== # pip install -i http://pypi.douban.com/simple/ --trusted-host=pypi.douban.com ursina -from ursina import application,Entity, camera, color, Vec3, Text, load_texture, destroy, PointLight +from ursina import application, Entity, camera, color, Vec3, Text, load_texture, destroy, PointLight from simulators.ursina.entities.entity_utils import create_name_text, create_trails, clear_trails, create_rings, \ trail_init, create_fixed_star_lights @@ -196,8 +196,9 @@ class Planet(Entity): # 1.0 0.006373216398060322 0.006373216398060322 if hasattr(self.body, "rotate_axis_scale"): line_scale = self.body.rotate_axis_scale * line_scale - create_line(from_pos, to_pos, parent=self.main_entity, - len_scale=line_scale, color=line_color, thickness=2) + + self.rotate_axis_line = create_line(from_pos, to_pos, parent=self.main_entity, + len_scale=line_scale, color=line_color, thickness=2) def change_body_scale(self): if hasattr(self.body, "torus_stars") or hasattr(self.body, "torus_zone"): @@ -206,6 +207,11 @@ class Planet(Entity): else: self.scale = self.init_scale * UrsinaConfig.body_size_factor + if hasattr(self, "rotate_axis_line"): + if not hasattr(self, "rotate_axis_init_scale"): + self.rotate_axis_init_scale = self.rotate_axis_line.scale + self.rotate_axis_line.scale = self.rotate_axis_init_scale * UrsinaConfig.body_size_factor + def update(self): self.change_body_scale() @@ -319,7 +325,7 @@ class Planet(Entity): delattr(self, "label_name") else: self.label_name = create_label(parent=self, - label=self.body.name, - pos=Vec3(-0.5, -0.5, -0.5), - color=color.red) - self.label_name.set_light_off() \ No newline at end of file + label=self.body.name, + pos=Vec3(-0.5, -0.5, -0.5), + color=color.red) + self.label_name.set_light_off() -- GitLab