如何翻译A-Frame动态体 [英] How to translate A-Frame dynamic body

查看:26
本文介绍了如何翻译A-Frame动态体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在制作一个 A-Frame 项目,该项目将允许用户与数学模型进行交互.我正在将 aframe-super-hands-componentaframe-physics-extras 一起使用,以获得良好的睡眠"效果.为了添加一层控制,我试图让用户可以使用控制器的操纵杆将模型拉近/远离控制器,类似于 Oculus Dash 控件(https://youtu.be/sMjlM5vFSA0?t=1m55s).

I'm making an A-Frame project which will allow users to interact with math models. I'm using the aframe-super-hands-component with aframe-physics-extras for its nice "sleep" effect. To add a layer of control, I'm trying to make it so that the user can use a controller's joysticks to bring a model closer/farther away from the controller, similar to the Oculus Dash controls (https://youtu.be/sMjlM5vFSA0?t=1m55s).

但是,当我尝试更新模型的位置时,由于我的模型实体被定义为动态实体,它们不会移动.我知道我可以删除 dynamic-body 组件,移动主体,然后重新附加 dynamic-body,但我想避免这种情况,因为我打算移动tick 中的模型.有没有办法在不破坏 dynamic-body 行为的情况下移动动态物体?

However, when I try to update a model's position, as my model entities are defined as dynamic bodies, they don't move. I know that I can remove the dynamic-body component, move the body, and then reattach dynamic-body, but I want to avoid that as I'm planning to move models in tick. Is there a way I can move a dynamic body without breaking dynamic-body behavior?

这是一个尝试更新框位置示例的链接:https://codepen.io/kchen1250/pen/MBmRYo

Here's a link to an example which tries to update a box's position: https://codepen.io/kchen1250/pen/MBmRYo

推荐答案

您可以使用 dynamic-bodys 同步实体和 dynamic-body 的位置方法 syncToPhysics()

You can sync the position of the entity and the dynamic-body using the dynamic-bodys method syncToPhysics()

el.components["dynamic-body"].syncToPhysics()

就像我在这里所做的那样.<小时>如果您需要,还有一个类似的 syncFromPhysics().

like i did here.


There is also an analogous syncFromPhysics() if you'd ever need it.

这篇关于如何翻译A-Frame动态体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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