Three.js-查找摄像机的当前LookAt吗? [英] Three.js - Find the current LookAt of a camera?

查看:681
本文介绍了Three.js-查找摄像机的当前LookAt吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要读取(提取)场景中摄像机的当前lookAt。我看过以下帖子,但无法从相机中获取lookAt。

I need to read (extract) the current lookAt of a camera in the scene. I have seen the following post but I could not get the lookAt from camera.

three.js设置并读取相机外观向量

感谢您的帮助。

推荐答案

lookAt 不能作为矢量使用,实际上是 THREE.Object3D 中的方法,如您所见此处。该方法用于创建应用于对象的旋转矩阵,以更改对象的旋转(方向)。

lookAt is not available as a vector, it is actually a method in THREE.Object3D as you can see here. The method is used to create a rotation matrix that is applied to the object to change the rotation (the direction) of the object.

因此,如果您想知道对象的当前方向(lookAt)是您必须从对象的旋转中提取此信息。

So if you want to know what the current direction (lookAt) of the object is you have to extract this information from the object's rotation.

在局部空间中,照相机沿z轴向下看。如果将摄像机旋转应用于该矢量,则结果为 lookAt 或摄像机的方向。

In local space a camera is looking down the z-axis. If you apply the camera rotation to that vector the result is the lookAt or direction of the camera.

var vector = new THREE.Vector3( 0, 0, -1 );
vector.applyQuaternion( camera.quaternion );

还请类似问题的答案

这篇关于Three.js-查找摄像机的当前LookAt吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆