gpt4 book ai didi

3d - 将 Unity 转换转换为 THREE.js 旋转

转载 作者:行者123 更新时间:2023-12-03 23:58:39 24 4
gpt4 key购买 nike

如何将 THREE.js 相机或对象的旋转与 Unity GameObject 的变换相匹配?

Unity 使用具有 ZXY euler 阶数的左手系统。 THREE.js 使用具有 XYZ euler 阶数的右手系统。

转换需要做哪些转换GameObject.transform.rotation (四元数)到 Object3D.rotation (三。Vector3)?

最佳答案

我们最终解决了这个问题:

假设你得到 qx , qy , qzqw从 Unity 的四元数中,我们在 JavaScript/Three.JS 中应用以下转换:

// convert Quaternion from Left-handed coordinate system to Right-handed

var q = new THREE.Quaternion( -qx, qy, qz, -qw );

var v = new THREE.Euler();
v.setFromQuaternion( q );

v.y += Math.PI; // Y is 180 degrees off

v.z *= -1; // flip Z

object.rotation.copy( v );

这在所有轴旋转和方向上都能正常工作。

三.js r.59

关于3d - 将 Unity 转换转换为 THREE.js 旋转,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18066581/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com