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

2019-07-31 02:02发布

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>

标签: aframe
1条回答
等我变得足够好
2楼-- · 2019-07-31 02:46

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.
查看更多
登录 后发表回答