showing results for - "three js progress bar example"
Karl
24 Mar 2016
1    var manager = new THREE.LoadingManager();
2
3    manager.onStart = function (item, loaded, total) {
4        console.log('Loading started');
5    };
6
7    manager.onLoad = function () {
8        console.log('Loading complete');            
9        bar.destroy();
10    };
11
12    manager.onProgress = function (item, loaded, total) {            
13        console.log(item, loaded, total);
14        console.log('Loaded:', Math.round(loaded / total * 100, 2) + '%')
15        bar.animate(1.0);
16    };
17
18    manager.onError = function (url) {
19        console.log('Error loading');
20    };
21
22    //3D MTL & Object Loading
23    var mtlLoader = new MTLLoader(manager);
24    mtlLoader.setPath('media/' + this.missionId + '/3D/Model/');
25    mtlLoader.load('threed.mtl', function(materials) {
26
27        materials.preload();
28        materials.materials.texture.map.magFilter = THREE.NearestFilter;
29        materials.materials.texture.map.minFilter = THREE.LinearFilter;
30
31        //var manager = new THREE.LoadingManager();
32        OBJLoader(THREE);
33        var objLoader = new THREE.OBJLoader(manager);
34        objLoader.setMaterials(materials);
35        objLoader.setPath('media/' + scope.missionId + '/3D/Model/');
36        objLoader.load('threed.obj', function(object) {
37
38            object.traverse(function(child) {
39                if (child instanceof THREE.Mesh) {
40                    scope.objects.push(child);
41                }
42            });
43
44            scope.scene.add(object);
45            console.log('Object::', object);
46        });
47
48    });
49