THREE.js:您可以对Three.js强制执行不同的操作顺序吗? [英] THREE.js: Can you force a different order of operations for three.js?

查看:165
本文介绍了THREE.js:您可以对Three.js强制执行不同的操作顺序吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

看到此问题: Threejs变换矩阵排序

我正在绘制行星的轨道,并且在更改惯性参考系时遇到问题(我选择将three.js世界坐标与所查看的行星的惯性参考系对齐).但是我需要强制three.js按以下所示的顺序应用操作,以便正确显示轨道(当前轨道位于世界(0,0,0)并疯狂旋转).

I'm drawing the orbits of the planets and having problem with changing inertial reference frames (I chose to align the three.js world coordinates with the viewed planet's inertial reference frame). But I need to force three.js to apply operations in the order shown below so the orbit is properly displayed (presently the orbit stays at world (0,0,0) and spins crazily).

执行此操作的常规方法(物理方法)是按顺序执行以下操作: 1.椭圆的零位和旋转.

The normal (physics) way to do this is to do the following in order: 1. zero position and rotation of the ellipse.

ellipse.position.set(0,0,0);
ellipse.rotation.set(0,0,0);

2.应用方向余弦矩阵(改变参考系的矩阵).

2. Apply Direction Cosine Matrix (matrix which changes reference frame).

ellipse.applyMatrix(DCM);

3.将轨道平移到以运行物体为中心,其中r是行星的半径向量.

3. Translate orbit to be centered on orbiting body, where r is the radius vector of the planet.

ellipse.translateX(r.x);
ellipse.translateY(r.y);
ellipse.translateZ(r.z);

4.旋转椭圆.

ellipse.rotateZ(RAAN); // RAAN : right angle of ascending node
ellipse.rotateX(inc);  // inc  : orbit inclination
ellipse.rotateZ(ArgP); // ArgP : Argument of Periapsis.

5.调整中心点和焦点之间的差异.

5. Adjust for difference between center and focal point.

ellipse.translateX(-c);

6.利润.

所以我不确定在three.js中是否存在我不熟悉的某种命令流,或者node.js是否引起异步问题.

So I'm not sure if there's some kind of command flow in three.js that I'm not familiar with, or if node.js is causing asynchronous problems.

推荐答案

好的.我刚刚发布了这篇文章,但是为以后遇到相同问题的任何人找到了解决方案.如果您要以不同于three.js的方式应用操作(如本文所示:

Okay. I just posted this, but found the solution for anyone who has the same problem in the future. If you want to apply things in a different order of operations than three.js wants you to (as seen in this post: Threejs Transform Matrix ordering). Then you must use the applyMatrix function between each operation that you wish to do in a specific order.

以上面的示例为例:

ellipse.position.set(0,0,0);
ellipse.rotation.set(0,0,0);
ellipse.updateMatrix();

ellipse.applyMatrix(DCM);
ellipse.updateMatrix();

ellipse.translateX(r.x);
ellipse.translateY(r.y);
ellipse.translateZ(r.z);
ellipse.updateMatrix();

ellipse.rotateZ(RAAN); // RAAN : right angle of ascending node
ellipse.rotateX(inc);  // inc  : orbit inclination
ellipse.rotateZ(ArgP); // ArgP : Argument of Periapsis.
ellipse.updateMatrix();

ellipse.translateX(-c);
ellipse.updateMatrix();

这篇关于THREE.js:您可以对Three.js强制执行不同的操作顺序吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆