简体   繁体   中英

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

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.

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");
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM