3D 场景一转,普通文字会跟着转、甚至转到背面看不见。示例用 add_fixed_in_frame_mobjects 把文字钉在屏幕上,再放到左上角,坐标轴怎么转它都不动。
完整代码
1 2 3 4 5 6 7 8 9 10 11
| from manim import * class FixedInFrameMObjectTest(ThreeDScene): def construct(self): axes = ThreeDAxes() self.set_camera_orientation(phi=75 * DEGREES, theta=-45 * DEGREES) text3d = Text("This is a 3D text") self.add_fixed_in_frame_mobjects(text3d) text3d.to_corner(UL) self.play(*[FadeIn(_o) for _o in [axes]], run_time=1.0) self.wait() self.wait(3.60)
|
演示视频
下载 Python 脚本
要点
add_fixed_in_frame_mobjects(mob) 之后对象不再受相机旋转影响
- 固定后的对象仍可用
to_corner 等二维布局方法定位
ThreeDScene 的相机朝向用 set_camera_orientation(phi=, theta=) 设置
代码来源:Manim Community 官方 Example Gallery 示例 FixedInFrameMObjectTest(MIT),已在 Manim CE 0.20.1 实跑验证并生成上方视频。
主观感受,仅供参考。本文采用 本文采用 CC BY-NC-SA 4.0 许可 协议,
完整转载请注明来自
数学动画引擎。