Cleaned stuff, improved progress bar

This commit is contained in:
Thomas FORGIONE 2015-07-07 14:40:32 +02:00
parent 505e43023a
commit da2a972492
8 changed files with 27 additions and 34 deletions

View File

@ -42,7 +42,7 @@ geo.MeshContainer = function(path, callback) {
* Number of elements to stream in the mesh * Number of elements to stream in the mesh
* @type {Number} * @type {Number}
*/ */
this.numberOfElements = -1; this.numberOfFaces = 0;
this.callback = callback; this.callback = callback;
@ -75,8 +75,6 @@ geo.MeshContainer.prototype.loadFromFile = function(path) {
if (line[0] === 'v') { if (line[0] === 'v') {
self.numberOfElements++;
if (line[1] === 't') { if (line[1] === 't') {
// Texture coord // Texture coord
@ -93,14 +91,6 @@ geo.MeshContainer.prototype.loadFromFile = function(path) {
} else { } else {
// Just a simple vertex // Just a simple vertex
// if (currentMesh === undefined) {
// // Chances are that we won't use any material in this case
// currentMesh = new geo.Mesh();
// self.meshes.push(currentMesh);
// }
var vertex = new geo.Vertex(line); var vertex = new geo.Vertex(line);
vertex.index = self.vertices.length; vertex.index = self.vertices.length;
self.vertices.push(vertex); self.vertices.push(vertex);
@ -109,7 +99,7 @@ geo.MeshContainer.prototype.loadFromFile = function(path) {
} else if (line[0] === 'f') { } else if (line[0] === 'f') {
self.numberOfElements++; self.numberOfFaces++;
// Create mesh if it doesn't exist // Create mesh if it doesn't exist
if (currentMesh === undefined) { if (currentMesh === undefined) {
@ -126,6 +116,7 @@ geo.MeshContainer.prototype.loadFromFile = function(path) {
if (faces.length === 2) { if (faces.length === 2) {
self.numberOfFaces++;
faces[1].index = self.faces.length; faces[1].index = self.faces.length;
faces[1].meshIndex = self.meshes.length - 1; faces[1].meshIndex = self.meshes.length - 1;
self.faces.push(faces[1]); self.faces.push(faces[1]);
@ -134,8 +125,6 @@ geo.MeshContainer.prototype.loadFromFile = function(path) {
} else if (line[0] === 'u') { } else if (line[0] === 'u') {
self.numberOfElements++;
// usemtl // usemtl
// If a current mesh exists, finish it // If a current mesh exists, finish it

View File

@ -253,7 +253,7 @@ geo.MeshStreamer.prototype.nextMaterials = function() {
var data = []; var data = [];
data.push(['g', this.mesh.numberOfElements]); data.push(['g', this.mesh.numberOfFaces]);
for (var i = 0; i < this.mesh.meshes.length; i++) { for (var i = 0; i < this.mesh.meshes.length; i++) {

View File

@ -15,7 +15,7 @@ var main_section = document.getElementById('main-section');
// } // }
// }; // };
var container_size = { var container_size = {
width: function() { return 1024; }, width: function() { return 1134; },
height: function() { return 768; } height: function() { return 768; }
}; };

View File

@ -15,7 +15,7 @@ var main_section = document.getElementById('main-section');
// }; // };
var container_size = { var container_size = {
width: function() { return 1024; }, width: function() { return 1134; },
height: function() { return 768; } height: function() { return 768; }
}; };

View File

@ -4,7 +4,7 @@ var isFullscreen = false;
var main_section = document.getElementById('main-section'); var main_section = document.getElementById('main-section');
var container_size = { var container_size = {
width: function() { return 1024; }, width: function() { return 1134; },
height: function() { return 768; } height: function() { return 768; }
}; };

View File

@ -69,7 +69,7 @@ var _parseList = function(arr) {
ret.type = "global"; ret.type = "global";
ret.index = null; ret.index = null;
ret.numberOfElements = arr[1]; ret.numberOfFaces = arr[1];
} }
@ -189,13 +189,13 @@ var ProgressiveLoader = function(path, scene, camera, callback, log) {
* Number of total elements for loading * Number of total elements for loading
* @type{Number} * @type{Number}
*/ */
this.numberOfElements = -1; this.numberOfFaces = -1;
/** /**
* Number of elements received * Number of elements received
* @type {Number} * @type {Number}
*/ */
this.numberOfElementsReceived = -1; this.numberOfFacesReceived = 0;
/** /**
* Modulus indicator (not to log too often) * Modulus indicator (not to log too often)
@ -205,6 +205,8 @@ var ProgressiveLoader = function(path, scene, camera, callback, log) {
this.log = log; this.log = log;
r = this;
}; };
/** /**
@ -250,10 +252,8 @@ ProgressiveLoader.prototype.initIOCallbacks = function() {
for (var i = 0; i < arr.length; i++) { for (var i = 0; i < arr.length; i++) {
self.numberOfElementsReceived++; if (typeof self.log === 'function' && self.numberOfFacesReceived % self.modulus === 0) {
self.log(self.numberOfFacesReceived, self.numberOfFaces);
if (typeof self.log === 'function' && self.numberOfElementsReceived % self.modulus === 0) {
self.log(self.numberOfElementsReceived, self.numberOfElements);
} }
var elt = _parseList(arr[i]); var elt = _parseList(arr[i]);
@ -286,8 +286,6 @@ ProgressiveLoader.prototype.initIOCallbacks = function() {
} else if (elt.type === 'usemtl') { } else if (elt.type === 'usemtl') {
// Must create new mesh
// Create mesh material // Create mesh material
var material; var material;
@ -333,6 +331,8 @@ ProgressiveLoader.prototype.initIOCallbacks = function() {
} else if (elt.type === 'face') { } else if (elt.type === 'face') {
self.numberOfFacesReceived++;
if (!self.meshes[elt.mesh].added) { if (!self.meshes[elt.mesh].added) {
self.meshes[elt.mesh].added = true; self.meshes[elt.mesh].added = true;
@ -368,8 +368,8 @@ ProgressiveLoader.prototype.initIOCallbacks = function() {
} else if (elt.type === 'global') { } else if (elt.type === 'global') {
self.numberOfElements = elt.numberOfElements; self.numberOfFaces = elt.numberOfFaces;
self.modulus = Math.floor(self.numberOfElements / 200); self.modulus = Math.floor(self.numberOfFaces / 200);
} }
@ -381,7 +381,8 @@ ProgressiveLoader.prototype.initIOCallbacks = function() {
this.socket.on('disconnect', function() { this.socket.on('disconnect', function() {
console.log('Finished !'); console.log('Finished !');
self.log(self.numberOfElements, self.numberOfElements); if (typeof self.log === 'function')
self.log(self.numberOfFacesReceived, self.numberOfFaces);
self.finished = true; self.finished = true;
}); });
}; };

View File

@ -2,7 +2,10 @@ L3D.LogFunction = function(a,b) {
var val = 100*a/b; var val = 100*a/b;
$('.progress-bar').css('width', val+'%').attr('aria-valuenow', val); $('.progress-bar').css('width', val+'%').attr('aria-valuenow', val);
$('#percentage').html(Math.floor(10*val)/10 + '%'); $('#percentage').html(Math.floor(10*val)/10 + '%');
} if (a === b) {
setTimeout(function() {$('.progress').hide(1000);}, 1000);
}
};
L3D.addLight = function(scene) { L3D.addLight = function(scene) {
var directional_light = new THREE.DirectionalLight(0xdddddd); var directional_light = new THREE.DirectionalLight(0xdddddd);

View File

@ -7,18 +7,18 @@ body {
-o-user-select:none; -o-user-select:none;
} }
html, body { /*html, body {
height: 100%; height: 100%;
} }
#main-section { #main-section {
min-height: 100%; min-height: 100%;
} }*/
#container { #container {
position: absolute; position: absolute;
margin: 0 auto; margin: 0 auto;
min-height: 100%; /*min-height: 100%;*/
} }
.panel-heading a:after { .panel-heading a:after {