问题标签 [3d-rendering]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
12 浏览

math - 相机在 3d 空间中无法正确移动

我目前正在研究在 3d 空间中移动相机。我希望它只在 x 和 z 轴(水平)上移动。到目前为止,当相机的旋转全部为零时它是正确移动的,但是当我改变它的值时,相机开始表现得有点奇怪,朝着错误的方向移动。我正在使用 SFML,但我认为这是导致问题的数学。这很奇怪,因为我移动相机的代码与我之前编写的项目之一相同,但该项目运行良好。
这是限制旋转的代码:

我用来移动相机的代码:

如果有人可以帮助我解决这个问题,我将不胜感激。

对于任何想知道的人,这是我用来将 3d 坐标转换为屏幕坐标的代码: