正 Z 轴在 threejs 中向内移动吗? Camera.near 和 camera.far 的行为很有趣

Is positive Z axis going inward in threejs? Camera.near and camera.far behaves funny

我试图只渲染 3d 对象的一部分。在正交相机中,我希望 camera.near 为 2.0,camera.far 为 1.5,然后迭代并给出 camera.near = 1.5 和 camera.far = 1.0。等等。但它不起作用。当我将较小的值 (2) 传递给 camera.near 并将较大的值 (10) 传递给 camera.far 时,它会起作用。但我想要的恰恰相反。我以为 Z 轴从屏幕向外。

Three.js 中的 z 轴为正“出来”。

然而:事情看起来很有趣的原因是当您设置视图矩阵时,您实际上将 near/far 平面指定为与观察者的 距离。 这是来自 OpenGL spec:

Parameters

nearVal, farVal
Specify the distances to the nearer and farther depth clipping planes. These values are negative if the plane is to be behind the viewer.

仅供参考,当您使用透视矩阵时,两个值始终为正。