简体   繁体   English

动态加载框架实体

[英]dynamically load aframe entities

I´m building an aframe application, which can dynamically load s from a webservice based on user interaction. 我正在构建一个Aframe应用程序,该应用程序可以基于用户交互从Web服务动态加载。 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. 我需要的是一种将这些注入到aframe DOM中的方法,以使实体立即可见。 Is there a way to accomplish this? 有没有办法做到这一点? Neither Google nor the Aframe documentation could help me yet. Google和Aframe文档都无法帮助我。

You can create and configure the entities individually using document.createElement / setAttribute / appendChild . 您可以使用document.createElement / setAttribute / appendChild单独创建和配置实体。 There's a section in the docs devoted to it. 在文档中有专门的一

You can also manipulate the innerHTML value directly: 您还可以直接操作innerHTML值:

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 以上都不是特定于A-Frame的,您只需使用常规DOM API来组成场景

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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