A-sphere 在鼠标悬停时显示文本或将文本附加到 a-sphere
A-sphere show text on mouse over or attach a text to a-sphere
是否可以向 a-sphere 或 a-box 添加文本?或者可能会在鼠标悬停在球体上时显示文本框?我在 A 帧中看到了 example,但这并不是我想要的。我的想法是用文本或文本框标记一个球体或一个盒子。
<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-box 添加文本?或者可能会在鼠标悬停在球体上时显示文本框?我在 A 帧中看到了 example,但这并不是我想要的。我的想法是用文本或文本框标记一个球体或一个盒子。
<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>