让相机自己绕场景转,比手动 move_camera 省事。示例开启环境相机旋转,rate=0.1 缓慢环绕,停止后再把视角切回初始角度。

完整代码

1
2
3
4
5
6
7
8
9
10
11
12
13
from manim import *
class ThreeDCameraRotation(ThreeDScene):
def construct(self):
axes = ThreeDAxes()
circle=Circle()
self.set_camera_orientation(phi=75 * DEGREES, theta=30 * DEGREES)
self.play(*[FadeIn(_o) for _o in [circle, axes]], run_time=1.0)
self.begin_ambient_camera_rotation(rate=0.1)
self.wait()
self.stop_ambient_camera_rotation()
self.move_camera(phi=75 * DEGREES, theta=30 * DEGREES)
self.wait()
self.wait(2.60)

演示视频

下载 Python 脚本

要点

  • begin_ambient_camera_rotation(rate=...) 必须在 ThreeDScene 中调用
  • self.wait() 期间相机会持续旋转,时长决定转过的角度
  • stop_ambient_camera_rotation() 停止后画面保持当前视角

代码来源:Manim Community 官方 Example Gallery 示例 ThreeDCameraRotation(MIT),已在 Manim CE 0.20.1 实跑验证并生成上方视频。