本文介绍了三.js 透视相机当前角度(以度为单位)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
对于一个项目,我使用了 PerspectiveCamera,它使用 r69 的 vrcontrols 进行旋转.在某一点上,我需要当前的视角度数(相机正在看的方向的水平和垂直度数).我将如何获得这些?
For a project I use a PerspectiveCamera which gets rotated using the vrcontrols from r69. At one point I require the current viewing angle degrees (horizontal & vertical degrees at which direction the camera is looking at). How would I acquire those?
推荐答案
您想要的也称为欧拉角.Three.js euler 有一个内置函数可以从四元数设置它们.
What you want are also called euler angles. Three.js eulers have a built in function to set them from a quaternion.
var quat = new THREE.Quaternion();
var euler = new THREE.Euler();
euler.setFromQuaternion(quat);
alert('X in degrees: ' + euler.x + '\n' +'Y in degrees: ' + euler.y + '\n' + 'Z in degrees: ' + euler.z);
这篇关于三.js 透视相机当前角度(以度为单位)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!