from manim import *
import numpy as np
def head(cn, en):
    t = Text(cn, font="STLiti", font_size=27).to_edge(UP)
    s = Text(en, font="Consolas", font_size=20, color=YELLOW).next_to(t, DOWN, buff=0.10)
    return VGroup(t, s)
def foot(cn):
    return Text(cn, font="STLiti", font_size=20, color=YELLOW).to_edge(DOWN)
class ThreeDCameraDemo(ThreeDScene):
    def construct(self):
        self.set_camera_orientation(phi=70 * DEGREES, theta=-45 * DEGREES)
        self.add_fixed_in_frame_mobjects(head("三维相机：绕场景旋转", "begin_ambient_camera_rotation"))
        axes = ThreeDAxes(x_length=6, y_length=6, z_length=4,
                          axis_config={"color": GREY_B})
        ball = Sphere(radius=1.1, resolution=(16, 16)).set_fill(BLUE, opacity=0.55)
        ring = Circle(radius=2.3, color=YELLOW).set_stroke(width=3)
        self.add(axes, ball, ring)
        self.begin_ambient_camera_rotation(rate=0.22)
        self.wait(3.4)
        self.stop_ambient_camera_rotation()
        self.add_fixed_in_frame_mobjects(foot("三维场景靠相机角度变化展示空间关系"))
        self.wait(2.6)
