GLTF Loader Loading Manager firing onProgress function twice!

For some reason, in console log, i see onProgress fired twice. I have one GLTF model to load but load manager is treating it like I have two models. if I add another model it will do the same, it will load total 4 models but in reality, it is two.

Here is my console log:

Here is my code:

let manager = new THREE.LoadingManager();
manager.onStart = function ( url, itemsLoaded, itemsTotal ) {

console.log( 'Started loading file: ' + url + '.\nLoaded ' + itemsLoaded + ' of ' + itemsTotal + ' files.' );

};

manager.onLoad = function ( ) {

console.log( 'Loading complete!');

};

manager.onProgress = function ( url, itemsLoaded, itemsTotal ) {

console.log( 'Loading file: ' + url + '.\nLoaded ' + itemsLoaded + ' of ' + itemsTotal + ' files.' );

};

manager.onError = function ( url ) {

console.log( 'There was an error loading ' + url );

};

this.loader = new GLTFLoader(manager);


this.loader.load(model1, (gltf) => {


  gltf.scene.traverse(function(child) {

    
   


      child.material = mat;   
      let pos = gltf.scene.children[0].children[0].geometry.attributes.position;

           let count = pos.count/3
           let bary = []
           for (let index = 0; index < count; index++) {
            bary.push(0,0,1, 0,1,0, 1,0,0)
           }
            bary = new Float32Array(bary)
           gltf.scene.children[0].children[0].geometry.setAttribute('barycentric', new THREE.BufferAttribute(bary,3))
   
  }
  );
  

  

  this.supamesh = gltf.scene.children[0].children[0]
  this.supamesh.geometry.center();
  this.scene.add(this.supamesh);


  
  


 })

The model may contain embedded resources that get counted toward loading as well — onProgress can be called multiple times per model. If you want to count the number of models that have fully loaded, it would be best to use the onLoad callback for that instead.

1 Like

Thank you, just wanted to know why it happening.

Docs say that .onLoad : This function will be called when all loading is completed. I also see that behavior in my setup where onLoad called at the very end where all models are loaded.

It seams broken or I misunderstanding something. I can not figure out how to get progress per model URL that I provide to the loader.

GLB files should be loaded as one piece. I don’t quite understand why onProgress is called twice per file.