简体   繁体   中英

dynamically load aframe entities

I´m building an aframe application, which can dynamically load s from a webservice based on user interaction. These entities are available in text-form. What I need is a way to inject these into the aframe DOM, so that the entities are immediately visible. Is there a way to accomplish this? Neither Google nor the Aframe documentation could help me yet.

You can create and configure the entities individually using document.createElement / setAttribute / appendChild . There's a section in the docs devoted to it.

You can also manipulate the innerHTML value directly:

el.innerHMTL = "<a-entity> <a-sphere></a-sphere> <a-light></a-light> </a-entity>"

None of the above it is A-Frame specific, you just use the regular DOM APIs to compose your scene

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM