How do I delay/defer/control when an A-Frame scene initializes/loads?

岁酱吖の 提交于 2019-12-24 10:06:37

问题


I want to have an A-Frame scene start loading only when I tell it to. Currently if I put <a-scene> in an HTML file, it will start initializing immediately.

<a-scene></a-scene>

回答1:


An A-Frame scene waits for all of its children to initialize before it itself initializes. So it waits for every <a-entity> from the bottom up. Under the hood, <a-entity> is based on <a-node> which handles load order. When <a-node> emits loaded, then the parent nodes can begin loading. <a-entity> emits loaded when it attaches + initializes all of its components.

Therefore, you start a scene on demand:

<a-scene>
  <a-node id="waitOnMe"></a-node>
</a-scene>

document.getElementById('waitOnMe').emit('loaded');  // When you are ready.


来源:https://stackoverflow.com/questions/47363071/how-do-i-delay-defer-control-when-an-a-frame-scene-initializes-loads

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!