from manim import *
class ThreeDAxesSurface(ThreeDScene):
    """3.3 plot_surface 绘制 z = x² + y² 抛物面。
    返回的 Surface 只是被构造出来，必须 self.add / self.play 才会上屏，
    老示例把 graph 算出来就结束，视频因此是全黑的。
    """
    def construct(self):
        self.set_camera_orientation(phi=65 * DEGREES, theta=-50 * DEGREES)
        title = Text("plot_surface 绘制三维曲面", font="STLiti", font_size=32).to_edge(UP)
        self.add_fixed_in_frame_mobjects(title)
        axes = ThreeDAxes(x_range=[-3, 3], y_range=[-3, 3], z_range=[-1, 3],
                          x_length=6, y_length=6, z_length=4)
        surface = axes.plot_surface(
            lambda u, v: u ** 2 + v ** 2, u_range=[-1, 1], v_range=[-1, 1],
            fill_color=BLUE_E, fill_opacity=0.85,
            checkerboard_colors=[BLUE_D, BLUE_E], stroke_width=0.5)
        self.play(FadeIn(title), run_time=0.6)
        self.play(FadeIn(axes), run_time=1.2)
        self.play(FadeIn(surface), run_time=1.8)
        note = Text("z = x² + y²：曲面必须 self.add / self.play 才上屏",
                    font="STLiti", font_size=22, color=YELLOW).to_edge(DOWN)
        self.add_fixed_in_frame_mobjects(note)
        self.play(FadeIn(note), run_time=0.6)
        self.wait(3.0)
