Search code examples
htmlchataframe

Is there a way to make site-visitor-editable text in aframe?


I'm making a networked VR website using Aframe, and I'm trying to make a way for users to communicate via a simple line of editable text using the

<a-text>

entity. is there a way to do this, and if not, can anyone recommend ways to build a simple chat in Aframe?

<a-text value="Now Interactable" geometry="primitive:plane" size="5 5 5"></a-text>

makes the text generated interactable, but I don't know how to make it editable.


Solution

  • You can edit the <a-text> using setAttribute("value", "sometext").

    how you will provide the text (custom vr keyboard, or a typical html form) is totally up to you. Also sending the text value to other multiplayer clients is a different story.

    Anyway, on whatever event just do

    document.querySelector("a-text").setAttribute("value", newText)
    

    working fiddle here.