本文介绍了A-sphere在鼠标悬停时显示文本或将文本附加到a-sphere的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以向a-sphere或a-box添加文本?还是在a球体上的鼠标上方显示一个文本框?我已经看到了在A帧中,但这并不是我想要的。我的想法是用文本或文本框标记一个球体或一个盒子。

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.

推荐答案

<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>

这篇关于A-sphere在鼠标悬停时显示文本或将文本附加到a-sphere的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-19 07:56