three.js progress bar example
var manager = new THREE.LoadingManager();
manager.onStart = function (item, loaded, total) {
console.log('Loading started');
};
manager.onLoad = function () {
console.log('Loading complete');
bar.destroy();
};
manager.onProgress = function (item, loaded, total) {
console.log(item, loaded, total);
console.log('Loaded:', Math.round(loaded / total * 100, 2) + '%')
bar.animate(1.0);
};
manager.onError = function (url) {
console.log('Error loading');
};
//3D MTL & Object Loading
var mtlLoader = new MTLLoader(manager);
mtlLoader.setPath('media/' + this.missionId + '/3D/Model/');
mtlLoader.load('threed.mtl', function(materials) {
materials.preload();
materials.materials.texture.map.magFilter = THREE.NearestFilter;
materials.materials.texture.map.minFilter = THREE.LinearFilter;
//var manager = new THREE.LoadingManager();
OBJLoader(THREE);
var objLoader = new THREE.OBJLoader(manager);
objLoader.setMaterials(materials);
objLoader.setPath('media/' + scope.missionId + '/3D/Model/');
objLoader.load('threed.obj', function(object) {
object.traverse(function(child) {
if (child instanceof THREE.Mesh) {
scope.objects.push(child);
}
});
scope.scene.add(object);
console.log('Object::', object);
});
});