Corrected a few bugs
This commit is contained in:
parent
09f6c2028f
commit
84288fec8b
|
@ -56,6 +56,12 @@ function partialSort(items, k, comparator) {
|
||||||
*/
|
*/
|
||||||
geo.MeshStreamer = function(path) {
|
geo.MeshStreamer = function(path) {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* array of array telling if the jth face of the ith mesh has already been sent
|
||||||
|
* @type{Boolean[][]}
|
||||||
|
*/
|
||||||
|
this.meshFaces = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* array of booleans telling if the ith vertex has already been sent
|
* array of booleans telling if the ith vertex has already been sent
|
||||||
* @type {Boolean[]}
|
* @type {Boolean[]}
|
||||||
|
@ -186,6 +192,17 @@ geo.MeshStreamer.prototype.start = function(socket) {
|
||||||
|
|
||||||
self.mesh = cont.availableMeshes[path];
|
self.mesh = cont.availableMeshes[path];
|
||||||
|
|
||||||
|
self.meshFaces = new Array(self.mesh.meshes.length);
|
||||||
|
|
||||||
|
for (var i = 0; i < self.meshFaces.length; i++) {
|
||||||
|
|
||||||
|
self.meshFaces[i] = {
|
||||||
|
counter: 0,
|
||||||
|
array: new Array(self.mesh.meshes[i].faces.length)
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
var regex = /.*\.\..*/;
|
var regex = /.*\.\..*/;
|
||||||
var filePath = path.substring(1, path.length);
|
var filePath = path.substring(1, path.length);
|
||||||
|
|
||||||
|
@ -326,7 +343,7 @@ geo.MeshStreamer.prototype.nextElements = function(_camera, force) {
|
||||||
|
|
||||||
var currentMesh = this.mesh.meshes[meshIndex];
|
var currentMesh = this.mesh.meshes[meshIndex];
|
||||||
|
|
||||||
if (currentMesh.isFinished()) {
|
if (this.isFinished(meshIndex)) {
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -340,7 +357,7 @@ geo.MeshStreamer.prototype.nextElements = function(_camera, force) {
|
||||||
|
|
||||||
var currentFace = currentMesh.faces[faceIndex];
|
var currentFace = currentMesh.faces[faceIndex];
|
||||||
|
|
||||||
if (currentFace.sent) {
|
if (this.meshFaces[meshIndex].array[faceIndex] === true) {
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -500,7 +517,9 @@ geo.MeshStreamer.prototype.nextElements = function(_camera, force) {
|
||||||
}
|
}
|
||||||
|
|
||||||
data.push(currentFace.toList());
|
data.push(currentFace.toList());
|
||||||
currentFace.sent = true;
|
// this.meshFaces[meshIndex] = this.meshFaces[meshIndex] || [];
|
||||||
|
this.meshFaces[meshIndex].array[faceIndex] = true;
|
||||||
|
this.meshFaces[meshIndex].counter++;
|
||||||
currentMesh.faceIndex++;
|
currentMesh.faceIndex++;
|
||||||
|
|
||||||
sent++;
|
sent++;
|
||||||
|
@ -517,4 +536,10 @@ geo.MeshStreamer.prototype.nextElements = function(_camera, force) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
geo.MeshStreamer.prototype.isFinished = function(i) {
|
||||||
|
|
||||||
|
return this.meshFaces[i].counter === this.meshFaces[i].array.length;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = geo;
|
module.exports = geo;
|
||||||
|
|
|
@ -4,6 +4,7 @@ var geo = require('./geo/MeshStreamer.js');
|
||||||
module.exports = function(io) {
|
module.exports = function(io) {
|
||||||
io.on('connection', function(socket) {
|
io.on('connection', function(socket) {
|
||||||
|
|
||||||
|
console.log("New MeshStreamer");
|
||||||
var streamer = new geo.MeshStreamer();
|
var streamer = new geo.MeshStreamer();
|
||||||
|
|
||||||
streamer.start(socket);
|
streamer.start(socket);
|
||||||
|
|
Loading…
Reference in New Issue