Fixed bug in Web Worker that was preventing all features from being processed when using a single batch

0.1
Robin Hawkes 2014-02-14 23:15:38 +00:00
rodzic 1e1458cbaa
commit 56d96bdf48
4 zmienionych plików z 17 dodań i 12 usunięć

Wyświetl plik

@ -30,6 +30,7 @@
var city = new VIZI.City();
city.init({
coords: [-0.01924, 51.50358] // Canary Wharf
// coords: [-0.1159894466, 51.5045487479] // London Eye
// coords: [-73.984762, 40.7516199] // Empire State
});
</script>

Wyświetl plik

@ -81,7 +81,7 @@
// Skip duplicate features
_.each(features, function(feature) {
if (self.processedIds[feature.id]) {
VIZI.Log("Skipping duplicated feature");
VIZI.Log("Skipping duplicated feature:", feature.id);
return;
}

Wyświetl plik

@ -137,7 +137,7 @@
});
if (dupe) {
VIZI.Log("Skipping feature as it has duplicate coordinates", coordinates);
VIZI.Log("Skipping feature as it has duplicate coordinates", element.id, coordinates);
return;
}

Wyświetl plik

@ -196,21 +196,25 @@
// 4 batches or below seems to stop the model.faces typed array from converting to a normal array
// Ideal 8 batches, if odd then subtract difference to make featuresPerBatch division clean
// var batches = 8 - (features.length % 8);
// Use one batch while testing tile-loading feature
var batches = 1;
var featuresPerBatch = Math.ceil(features.length / batches);
// Use all features while testing tile-loading
// var featuresPerBatch = Math.ceil(features.length / batches);
var batchPromises = [];
var i = batches;
while (i--) {
var startIndex = i * featuresPerBatch;
startIndex = (startIndex < 0) ? 0 : startIndex;
// var i = batches;
// while (i--) {
// var startIndex = i * featuresPerBatch;
// startIndex = (startIndex < 0) ? 0 : startIndex;
var featuresBatch = features.splice(startIndex, featuresPerBatch-1);
// var featuresBatch = features.splice(startIndex, featuresPerBatch-1);
batchPromises.push(this.workerPromise(worker, featuresBatch));
}
// batchPromises.push(this.workerPromise(worker, featuresBatch));
// }
// Process all features in one go while testing tile-loading
batchPromises.push(this.workerPromise(worker, features));
var loader = new THREE.JSONLoader();
var material = new THREE.MeshLambertMaterial({vertexColors: THREE.VertexColors});