I'm am trying to set loading counter for gltf file. Problem is that, my file is gltf, not glb, so I have three files (.gltf .bin .jpg). When I set onProgress callback for gltf file, it does not handle those files (.bin and .jpg), so I get 100% on the start of loading. How can I set onProgress callback to calculate all three files?
const gltfLoader = new GLTFLoader();
// Show loader while the glTF is loading
document.getElementById('loader').style.display = 'block';
// Hide loader when done
function hideLoader() {
const loaderContainer = document.getElementById('loader');
loaderContainer.style.display = 'none';
}
// LOADING ELEMENTS FROM GLTF //
gltfLoader.load('./Model/Model.gltf', function (gltf) {
scene.add(gltf.scene);
// Hide the loader when loading completes
hideLoader();
function (xhr) {
// Update progress percentage
const loaderText = document.getElementById('loader-text');
let progress = 0;
if (xhr.total && xhr.total > 0) {
progress = Math.round((xhr.loaded / xhr.total) * 100);
}
loaderText.textContent = `${progress}%`;
},
function (error) {
// Handle loading error
console.error('An error occurred while loading the model:', error);
}
);