THREE.JS,忽略父级的轮换 [英] THREE.JS, ignore parent's rotation

查看:78
本文介绍了THREE.JS,忽略父级的轮换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图让子对象跟随父对象的位置并表现得像一个正常的孩子,但是我希望它保持旋转不变.

I'm trying to make child object follow parent's position and behave like a normal child, however I want it to keep it's rotation unchanged.

在不影响性能的情况下做到这一点的最佳方法是什么(我已经在运行 2 个工人并拥有大量对象的 CPU 预算很紧)?有没有可以让独生子女的位置受到影响的设置?

What's the best way to do that without affecting performance(I'm tight on cpu budget already running 2 workers and having lots of objects)? Is there a setting which would allow to only child's position being affected?

还有一点很重要,当父节点旋转时,子节点的位置应该跟随旋转.

Also an important thing is that when parent is being rotated then child's position should follow that rotation.

推荐答案

我建议

child.position.copy(object.position);

而不是 WestLangley 的回答中建议的内容:

instead of what is suggested in WestLangley's answer:

child.position.setFromMatrixPosition( object.matrixWorld );

我遇到了后者不准确的问题,导致孩子的位置抖动.

I ran into issues with the latter being inaccurate, causing jitter in position of the child.

请注意,这仅回答了您问题的第一部分,即如何在保持子级旋转不变的情况下跟随父级的位置.

Note that this only answers the first part of your question, namely how to follow the parent's position keeping the child's rotation unchanged.

您的问题的第二部分可能值得澄清,因为我不太清楚.

It might be worth clarifying the second part of your question as it isn't entirely clear to me.

这篇关于THREE.JS,忽略父级的轮换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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