1

I am trying this in aframe 0.8.2 but any version is fine.

I tried using the solution here In AR.js When Load Model ,Show A Loading Screen

I want to add something like Center Circle/ Center Atom from pace.js i.e. https://github.hubspot.com/pace/docs/welcome/

<!DOCTYPE html>
<html lang="en">
   <head>
      <title>Hello!</title>
      <meta charset="utf-8">
      <meta http-equiv="X-UA-Compatible" content="IE=edge">
      <script type="text/javascript" src="https://aframe.io/releases/0.8.2/aframe.min.js"></script>
      <script type="text/javascript" src="https://cdn.rawgit.com/jeromeetienne/AR.js/1.7.2/aframe/build/aframe-ar.min.js"></script>
      <script type="text/javascript" src="https://cdn.rawgit.com/donmccurdy/aframe-extras/v6.0.0/dist/aframe-extras.min.js"></script>
      <script src="https://unpkg.com/aframe-animation-component@5.1.2/dist/aframe-animation-component.min.js"></script>
     <script>
     AFRAME.registerComponent('loader', {
       init: function() {
         let loader = document.querySelector("#loadingEl")
         this.el.addEventListener('model-loaded', e => {
           console.log('loaded')
           loader.setAttribute("visible", "false")
         })
       }
     })
     </script>
   </head>
   <body>
      <a-scene vr-mode-ui="enabled: false" artoolkit='sourceType: webcam; detectionMode: mono; maxDetectionRate: 90;' arjs='debugUIEnabled: false;detectionMode: mono_and_matrix; matrixCodeType: 3x3;'>
         <a-assets>
            <a-entity src="https://cdn.glitch.com/a5ca03d3-3024-44dc-9256-0b75c4247613%2Fscene.gltf?v=1563255364433" id="model"></a-entity>
         </a-assets>
         <a-marker preset="hiro">
            <a-box id="loadingEl"></a-box>
            <a-entity gltf-model="#model" material='transparent:true;shader:flat;side:double;metelness:2' scale="0.04 0.04 0.04" loader></a-entity>
         </a-marker>
         <a-entity camera></a-entity>
         <a-entity shadow="cast: true"></a-entity>
      </a-scene>
      <script>
         // Workaround for an AR.js bug (https://github.com/jeromeetienne/AR.js/issues/410)
         const sceneEl = document.querySelector('a-scene');
         sceneEl.addEventListener('loaded', () => {
           sceneEl.camera = new THREE.PerspectiveCamera();
           scene.add( camera );
         });
      </script>
   </body>
</html>
Karan Sethi
  • 223
  • 1
  • 14

1 Answers1

3

If you have multiple models, you can count them using the model-loaded event.

If you have a big model and you want to see how much of it is loaded... then its a longer story. As far as I know the gtlf loading progress is omitted (source code here), so you would need to use a custom version of the gltf-model component - replacing

}, undefined /* onProgress */, function gltfFailed (error) {

with, for example

}, function gltfProgress(xhr) {
   emit("model-progress", {progress: ( xhr.loaded / xhr.total * 100 ) })
}, function gltfFailed (error) {

and check the updates with

this.el.addEventListener("model-progress", e => {
  console.log(e.progress)
})
Piotr Adam Milewski
  • 14,150
  • 3
  • 21
  • 42