在ThreeJS中获取对象的全局旋转位置

时间:2018-06-05 09:59:24

标签: three.js

就像我们有getWorldPosition()一样,有没有办法可以得到一个物体的绝对旋转角度。当对象在另一个对象下时,这将是相关的;两者都可以旋转。

由于

1 个答案:

答案 0 :(得分:1)

您可以在对象上使用matrixWorld属性,并使用Euler上的setFromRotationMatrix函数来获取角度:

// make sure the matrix world is up to date
obj.updateMatrixWorld();

// extract the rotation matrix
const rotMat = new THREE.Matrix4();
obj.matrixWorld.extractRotation(rotMat);

// extract the rotation
const euler = new THREE.Euler();
euler.setFromRotationMatrix(rotMat);

quaternions

有相同的功能

希望有所帮助!

相关问题