我想让一个圆环沿着两个轴旋转:Ox和Oz。我希望通过鼠标调整 dat.gui
的滑块来应用此旋转。
我已经用以下方式定义了这个 torus
:
var geometryTorus = new THREE.TorusGeometry( radius, 2*widthLine, 100, 100 );
var materialLine = new THREE.MeshBasicMaterial( { color: 0xffff00 } );
torus = new THREE.Mesh( geometryTorus, materialLine );
scene.add(torus);
我的问题是绕
Ox 轴
旋转正常,但绕 Oz 轴
旋转不行。我通过调用以下函数对圆环进行旋转:
// Change great circle parameters
function changeGreatCircle(thetax, thetaz) {
// Update rotation angles
torus.rotation.x = thetax;
torus.rotation.z = thetaz;
}
对于上面的函数,我调用
render('init')
函数,在其中计算摄像机的位置。如何使这个圆环沿着
Oz轴
旋转?为什么它沿着Ox轴
旋转而不是沿着Oz轴
旋转?如果有人能给出提示,那就太好了。
谢谢。
更新1:
我找到了解决方案,因为我没有考虑到
Euler角度
,即2次旋转(绕X
和Y
轴)的顺序。解决方案是设置torus.rotation.order = 'ZXY';
。