如何将相机自动聚焦在 three.js 中的一个点上?

How to auto focus camera on a point in three.js?

我想知道是否有任何内置功能可以将相机自动对焦到 three.js 中的一个点,以便环境的其余部分变得像我们在这些示例中所拥有的那样相对模糊?

http://alteredqualia.com/xg/examples/animation_physics_level.html http://alteredqualia.com/xg/examples/animation_physics_ammo.html

XG库中启用自动对焦的代码是这样的:

renderer.dofEnabled = false;
renderer.dofAutofocus = true;
renderer.dofAutofocusPoint.set( 0.5, 0.35 );
renderer.dofFocusDistance = 10;
renderer.dofFocusMaxBlur = 0.2;

我不知道 XG 库的历史,但上面链接中的 XG 库似乎是基于 three.js 但我们在 [=26= 中没有任何相机自动对焦或 dofEnabled ].

如果 three.js 中有一些简单的方法可以做到这一点,请告诉我,如果没有,非常感谢您提供有关如何实现它的任何建议。

我不知道,但 XG 库似乎是私有的,代码也被混淆了,所以我无法了解焦点功能是如何实现的。

我刚刚发现,这个效果叫做 "depth of field" (dof) 并且已经使用 MeshDepthMaterial 实现了,在 threejs 网站上有一个例子:

http://threejs.org/examples/webgl_postprocessing_dof.html