Optimization attempt
This commit is contained in:
parent
0272477503
commit
34b312ae3b
|
@ -26,6 +26,10 @@ var ProgressiveLoader = function(res, scene) {
|
|||
// When receiving elements
|
||||
socket.on('elements', function(arr) {
|
||||
|
||||
if (!finished) {
|
||||
socket.emit('next');
|
||||
}
|
||||
|
||||
// Launch this code in async
|
||||
setTimeout(function() {
|
||||
|
||||
|
@ -78,34 +82,19 @@ var ProgressiveLoader = function(res, scene) {
|
|||
|
||||
}
|
||||
|
||||
|
||||
mesh.geometry.computeFaceNormals();
|
||||
mesh.geometry.groupsNeedUpdate = true;
|
||||
mesh.geometry.elementsNeedUpdate = true;
|
||||
mesh.geometry.normalsNeedUpdate = true;
|
||||
|
||||
if (!finished) {
|
||||
socket.emit('next');
|
||||
} else {
|
||||
console.log("Finished");
|
||||
}
|
||||
|
||||
},0);
|
||||
});
|
||||
|
||||
socket.on('finished', function(arg) {
|
||||
socket.on('disconnect', function() {
|
||||
console.log("Finished");
|
||||
finished = true;
|
||||
mesh.faceNumber = arg;
|
||||
//mesh.geometry.computeFaceNormals();
|
||||
mesh.geometry.verticesNeedUpdate = true;
|
||||
mesh.geometry.groupsNeedUpdate = true;
|
||||
mesh.geometry.elementsNeedUpdate = true;
|
||||
mesh.geometry.morphTargetsNeedUpdate = true;
|
||||
mesh.geometry.uvsNeedUpdate = true;
|
||||
mesh.geometry.normalsNeedUpdate = true;
|
||||
mesh.geometry.colorsNeedUpdate = true;
|
||||
mesh.geometry.tangentsNeedUpdate = true;
|
||||
|
||||
// scene.add(mesh);
|
||||
});
|
||||
|
||||
return mesh;
|
||||
|
|
15
socket.js
15
socket.js
|
@ -39,9 +39,9 @@ module.exports = function(io) {
|
|||
|
||||
// console.log(socket.conn.remoteAddress + " connected !");
|
||||
|
||||
// socket.on('disconnect', function() {
|
||||
// console.log(socket.conn.remoteAddress + " disconnected !");
|
||||
// });
|
||||
socket.on('disconnect', function() {
|
||||
console.log(socket.conn.remoteAddress + " disconnected !");
|
||||
});
|
||||
|
||||
socket.on("request", function(res) {
|
||||
// console.log('Asking for static/data/spheres/' + res + '.obj');
|
||||
|
@ -70,12 +70,15 @@ module.exports = function(io) {
|
|||
line = lines[++index];
|
||||
}
|
||||
}
|
||||
if (!line) {
|
||||
socket.emit('finished');
|
||||
}
|
||||
|
||||
socket.emit('elements', toSend);
|
||||
|
||||
if (!line) {
|
||||
// socket.emit('finished');
|
||||
socket.disconnect();
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue