How can I add a loading effect before all assets are loaded?

匆匆过客 提交于 2019-12-12 22:52:52

问题


I need to display a loading effect before all assets (image or video) are loaded in a frame. Anyone can help on this? I need JavaScript code in details if possible.


回答1:


See the asset management system: https://aframe.io/docs/0.3.0/core/asset-management-system.html

With that, you have a way to determine when all your resources have been fetched. <a-assets> will emit a loaded event, which you can wait on and show something in the meantime.

<a-scene>
  <a-assets timeout="10000">
    <img id="waitingonme">
  </a-assets>
</a-scene>

document.querySelector('a-assets').addEventListener('loaded', function () {
  console.log("OK LOADED");
});


来源:https://stackoverflow.com/questions/39586429/how-can-i-add-a-loading-effect-before-all-assets-are-loaded

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