A-sphere show text on mouse over or attach a text to a-sphere

穿精又带淫゛_ 提交于 2019-12-12 02:26:16

问题


Is it possible to add text to a-sphere or a-box ? or may be show a text box on mouse over on a-sphere? I've seen the example in A-frame, but it is not exactly what I want. My idea is to tag a sphere or a box with a text or text box.


回答1:


<script>
AFRAME.registerComponent('hover-text', {
  schema: {
    value: {default: ''}
  },

  init: function () {
    var data = this.data;
    var el = this.el;

    el.addEventListener('mouseenter', function () {
      el.setAttribute('text', {content: data.content});
    });
  }
});
</script>

<a-entity hover-text="value: I am hovered."></a-entity>


来源:https://stackoverflow.com/questions/42495751/a-sphere-show-text-on-mouse-over-or-attach-a-text-to-a-sphere

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!