在three.js中将向量从全局空间转换为局部向量 [英] Translate a vector from global space to local vector in three.js

查看:151
本文介绍了在three.js中将向量从全局空间转换为局部向量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在场景中有旋转对象时,如何将全局矢量转换到该旋转对象的局部空间中,以便在全局矢量的同一位置渲染它们?

With a rotated object in my scene, how can I translate a global vector into the local space of that rotated object, so that they are rendered in the same spot of the global vector?

例如,旋转的但位于全局原点的多维数据集。现在,我想为每个全局尺寸(x,y,z)渲染线,但是将它们作为子级添加到旋转的多维数据集而不是全局场景中。 如何计算并在three.js中实现这些矢量的旋转,以便它们对齐?

Take for example a cube that is rotated but at the global origin. Now I would like to render lines for each global dimension (x, y, z), but added as children to the rotated cube, not the global scene. How do I calculate and in three.js implement the rotation of those vectors so they will line up?

推荐答案

您要添加一个对象作为父对象的子对象,以使子对象的世界位置和方向不变。

You want to add an object as a child of a parent object such that the world position and orientation of the child do not change.

您可以使用以下模式进行操作:

You can do that using the following pattern:

parent.attach( object );

three.js r.107

three.js r.107

这篇关于在three.js中将向量从全局空间转换为局部向量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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