from ursina import *
app = Ursina()
origin = Entity(model='cube', scale=(0.2, 0.2, 0.2))
Entity(model='cube', parent=origin, color=color.red , position=(5, 0, 0), scale=(10, 0.5, 0.5))
Entity(model='cube', parent=origin, color=color.green, position=(0, 5, 0), scale=(0.5, 10, 0.5))
Entity(model='cube', parent=origin, color=color.blue , position=(0, 0, 5), scale=(0.5, 0.5, 10))
x_handle = Entity()
y_handle = Entity()
z_handle = Entity()
# определяем точки на траектории вращения каждой из осей
x_trajectory = [0, 90, 180, 270, 360]
y_trajectory = [0, 90, 180, 270, 360]
z_trajectory = [0, 90, 180, 270, 360]
# определяем время анимации
animation_time = 5
def switch_parent(entity, parent):
old_world_rotation = entity.world_rotation
entity.parent = parent
entity.world_rotation = old_world_rotation
def update():
old_parent = origin.parent
switch_parent(origin, x_handle)
# вращение оси X по траектории
x_start = x_trajectory[0]
x_end = x_trajectory[-1]
x_time = animation_time
x_current = x_handle.rotation_x
x_target = x_trajectory[int(time.time() * 0.5 % len(x_trajectory))]
x_handle.rotation_x = lerp(x_current, x_target, time.dt / x_time)
switch_parent(origin, y_handle)
# вращение оси Y по траектории
y_start = y_trajectory[0]
y_end = y_trajectory[-1]
y_time = animation_time
y_current = y_handle.rotation_y
y_target = y_trajectory[int(time.time() * 0.3 % len(y_trajectory))]
y_handle.rotation_y = lerp(y_current, y_target, time.dt / y_time)
switch_parent(origin, z_handle)
# вращение оси Z по траектории
z_start = z_trajectory[0]
z_end = z_trajectory[-1]
z_time = animation_time
z_current = z_handle.rotation_z
z_target = z_trajectory[int(time.time() * 0.1 % len(z_trajectory))]
z_handle.rotation_z = lerp(z_current, z_target, time.dt / z_time)
switch_parent(origin, old_parent)
app.run()