Three.js旋转了它自己的轴自己的、Three、js

2023-09-09 21:16:34 作者:我知道他不敢自己洗澡

我一直在试图建立一个三维空间中的飞船。它飞​​直线前进。您可以通过滚动飞船改变方向和鼻尖向上和向下。

I've been trying to create a spaceship in a 3D space. It flies straight forward. You can change direction by rolling the spaceship and tip the nose up and down.

当我改变飞船的Z轴角度,它推出符合市场预期。当我改变飞船的X螺旋角,鼻子倾斜向上和向下。当我做这两者的不的正常工作。

When I change the Z angle of the spaceship, it rolls as expected. When I change the X angle of the spaceship, the nose is tipped up and down. When I do both it doesn't work as expected.

看来我的飞船正在旋转全世界的轴,而不是我的飞船的轴。我的意思是,当一个对象被旋转的,所以它的轴吧?那么显然不是。

It appears my spaceship is being rotated over the world's axis, rather than the axes of my spaceship. I mean, when an object gets rotated, so does it's axis' right? Well apparently not.

像往常一样,帮助是多少AP preciated。

As usual, help is much appreciated.

下面是显然不行的演示: http://www.timseve​​rien.nl/随机/ ohnoez /

Here is the demo that clearly doesn't work: http://www.timseverien.nl/random/ohnoez/

推荐答案

查看四元数。在ThreeJS,你想看看这个类THREE.Quaternion。

Check out Quaternions. In ThreeJS, the class you want to look at is THREE.Quaternion.

四元数一般用在飞行模拟风格的游戏,让您在工艺的局部空间旋转,没有得到万向锁。 (这时候,你的两个轴的平行变,而你失去了一个自由度。)

Quaternions are generally used in flight simulation style games, and allow you to rotate in the local space of the craft, without getting "gimbal lock". ( That's when two of your axes become parallel, and you lose a degree of freedom. )

这是一个pretty的好,而且相当有趣,四元数的解释: http://www.isner.com/tutorials/quatSpells/quaternion_spells_14.htm

This is a pretty good, and quite funny, explanation of quaternions: http://www.isner.com/tutorials/quatSpells/quaternion_spells_14.htm

我希望让你在正确的轨道......

I hope that puts you on the right track...