在动态体内禁用光线投射物理

Disable raycaster physics inside dynamic-body

我需要一些关于 AFRAME 的帮助,我是新手,遇到了一个问题。

我有下一个代码。

<a-entity dynamic-body id="a-pibot" collada-model="#model-pibot" scale="5 5 5" rotation="0 -5 0" position="2.14 0.1 -0.12">
      <a-entity id="secondaryCamera" position="0.1 0.02 0" rotation="-20 -90 0">
        <!-- Create a second third-person camera which cant be controlled, the Pibot camera -->
        <a-camera spectator="canvas:#spectatorDiv;" active="false" wasd-controls-enabled="false" look-controls-enabled="false"></a-camera>
      </a-entity>
      <a-entity id="positionSensor" dynamic-body="shape:none;" raycaster="enabled: true; far: 1; showLine: true; direction: 1 0 0; interval: 40;"  rotation="0 5 0" position="0.0 0.03 0.0" line="color: yellow; opacity: 0.8;"></a-entity>
    </a-entity>

基本上是一个应用物理的机器人模型,机器人有一个摄像头和一个光线投射器,我需要禁用光线投射器组件的物理但我不知道如何。

有人可以帮助我吗?

谢谢大家!

您不能禁用 dynamic-body 在子实体上的传播,因此您可以像这样使您的 raycaster "follow" 成为 pibot:

AFRAME.registerComponent("foo", {
  init: function() {
    this.pibot = document.querySelector(#pibot)
  },
  tick: function() {
    this.el.setAttribute("position", pibot.getAttribute("position"))
  }
})

HTML

就像我一样here