Hi,
Currently i am using a jquery component progressbar.js for showing the loader. I am using Loading Manager’s events “onProgress” and “OnLoad” to handle the actual loading. But i am facing a problem related to model rendering. Actually once the “OnLoad” event gets call, my progressbar shows 100% and hide but my 3d model still not render. It takes some time and then it gets display in the viewer. Also progressbar doesn’t move smoothly. It starts correctly but suddenly it reaches to 100% which seems not good.
My expectation is like as soon as loading reaches to 100% , my 3D model must be display without any delay.Also the loading should be in sync with object loading of threejs. Can anyone guide me here what i am missing into code ? I am sharing my code snippet here for reference.
Code Snippet:
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);
});
});
Thanks
Avinash