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

查看:34
本文介绍了在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天全站免登陆