gpt4 book ai didi

javascript - 如何在 three.js 中设置 Z 坐标系?

转载 作者:可可西里 更新时间:2023-11-01 02:40:51 25 4
gpt4 key购买 nike

在three.js中,Y轴代表上下,Z轴代表前进和后退。但我希望 Z 轴表示上下,Y 轴表示向前和向后。这是一张显示我想要的图像:

我想改变整个坐标系,如果我绕 y 轴旋转网格,它会遵循新坐标系而不是传统坐标系。

现在,我搜索了堆栈溢出并找到了这个链接:

  1. Three.JS rotate projection so that the y axis becomes the z-axis .它不起作用。
  2. THREEJS: Matrix from Z-Up Coordinate System to Y-Up Coordinate System .此方法仅更改对象或网格的 y 和 z 顶点,但如果我围绕 y 轴旋转它,它会围绕传统的 y 轴旋转。我还必须将矩阵应用于旋转矩阵,使其像新坐标系一样旋转。
  3. Changing a matrix from right-handed to left-handed coordinate system
  4. Reorienting axes in three.js fails when webpage is refreshed .这也行不通。

有什么方法可以让 three.js 像 Z 向上坐标系一样工作吗?

最佳答案

您可以使用以下方式设置相机的向上矢量

camera.up.set(0,0,1);

然后,它就会像您期望的那样工作。

关于javascript - 如何在 three.js 中设置 Z 坐标系?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44630265/

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