3not3
3not3

Reputation: 536

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

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.

Upvotes: 0

Views: 758

Answers (1)

ngokevin
ngokevin

Reputation: 13233

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

Upvotes: 1

Related Questions