如何在A帧场景初始化/加载时延迟/延迟/控制? [英] How do I delay/defer/control when an A-Frame scene initializes/loads?
问题描述
我想让A帧场景仅在通知时才开始加载.目前,如果我将<a-scene>
放在HTML文件中,它将立即开始初始化.
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>
推荐答案
A帧场景在其自身初始化之前会等待其所有子代初始化.因此,它从下至上等待每个<a-entity>
.在引擎盖下,<a-entity>
基于处理装载顺序的<a-node>
.当<a-node>
发出loaded
时,父节点即可开始加载. <a-entity>
在附加+初始化其所有组件时发出loaded
.
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.
这篇关于如何在A帧场景初始化/加载时延迟/延迟/控制?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!