aframe - How to defer or load an A-Frame scene programmatically? -


i have a-frame scene want place on page, want load when tell to. means should not rendering or running until emit event or call method.

<body>   <!-- don't play yet. -->   <a-scene>   </a-scene> </body> 

there no built-in + documented way, there feature later. however, there couple ways manually:

pause scene can

this pause scene rendering. however, scene have initialized components , rendered few frames already. not air-tight.

document.queryselector('a-scene').pause(); 

leverage asset system

you can create asset never load until tell to, , set timeout indefinite (later add feature not timeout).

<a-scene>   <a-assets timeout="999999999">     <a-asset-item id="trigger" src="neverloaduntilitellitto.whatever"></a-asset-item>   </a-assets> </a-scene> 

then trigger.

document.queryselector('#trigger').load(); 

inject scene when ready

you keep scene in separate file, template, or string, or using framework concept of views. inject scene dom when ready render. work, air-tight method.


Comments