问题描述
我正在尝试导出一系列转换矩阵以在 ThreeJS 中为对象设置动画.这些转换是从Rhino中提取出来的,一个Z-Up Modeler,需要放到ThreeJS中,也就是Y-Up.我发现了一个类似的问题 在这个网站上,但答案似乎不正确,因为我的转换没有延续.
I am trying to export a series of Transformation Matrices to animate objects in ThreeJS. These transformation are extracted from Rhino, a Z-Up Modeler and need to be placed into ThreeJS, which is Y-Up. I've found a similar question on this site, but the answer does not appear to be correct because my transformations don't carry over.
谁能将下面的通用 4x4 矩阵从 Z-Up 坐标系转换为 Y-Up 坐标系?
Can anyone translate the generic 4x4 matrix below from a Z-Up coordinate system to a Y-Up Coordinate System?
{ a, b, c, d }
{ e, f, g, h }
{ i, j, k, l }
{ m, n, o, p }
推荐答案
好吧,我想我有一个可行的解决方案:
Alright, I think I have a working solution:
如果几何从 Z Up Environment 导出(您没有在设置中翻转 YZ),您可以将其导入 THREEjs 并使用此矩阵更正 YZ 差异(链接):
If the geometry is exported as is from the Z Up Environment (you are not flipping the YZ in your settings), you can import it into THREEjs and correct the YZ Discrepancy with this matrix (link) :
objectid.matrixWorldNeedsUpdate=true;
objectid.matrix.set
(
1, 0, 0, 0,
0, 0, 1, 0,
0, -1, 0, 0,
0, 0, 0, 1
);
objectid.updateMatrixWorld();
经过这个转换,写这个 后,您正在将转换应用于导入的转换.这将翻转第二行和第三行并翻转第二列和第三列:
After this tranformation, wrt this post, you're applying the transition to the imported transformation. This flips the second and third rows AND flips the second and third columns:
{ a, b, c, d }
{ e, f, g, h }
{ i, j, k, l }
{ m, n, o, p }
到
{ a, c, b, d }
{ i, k, j, l }
{ e, g, f, h }
{ m, o, n, p }
当我从 Rhino 导出 OBJ 时,我最初是在翻转 YZ,所以转换是在不同的几何体上执行的.当 YZ 翻转应用于 javascript 端时,它现在可以工作了.
I was originally flipping the YZ when I exported the OBJ from Rhino, so the transformation was performing on different geometry. It's working now when the YZ flip is applied on the javascript side.
这篇关于THREEJS:从 Z-Up 坐标系到 Y-Up 坐标系的矩阵的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!