adds some workers work
This commit is contained in:
parent
5d143d4270
commit
50fa5c356e
@ -276,29 +276,44 @@ BallRenderer.prototype = {
|
||||
},
|
||||
|
||||
colorize: function () {
|
||||
// if (!this.colorWorkers){
|
||||
// this.initColorWorkers();
|
||||
// }
|
||||
// this.colorWorkers[0].postMessage([this.pointLayer, 123]);
|
||||
var grad = this.gradientData;
|
||||
if(!this.heatmapLayer) this.heatmapLayer = new Uint8ClampedArray(this.size * 4);
|
||||
for (var i = this.pointLayer.length-4, alpha; i>=0; i-=4){
|
||||
alpha = this.pointLayer[i+3] * 4; // get gradient color from opacity value
|
||||
if (!this.colorWorkers){
|
||||
this.initColorWorkers();
|
||||
}
|
||||
for(k in this.colorWorkers){
|
||||
this.colorWorkers[k].postMessage([this.pointLayer,k, 3]);
|
||||
}
|
||||
|
||||
if (alpha>0) {
|
||||
this.heatmapLayer[i] = grad[alpha]; // R
|
||||
this.heatmapLayer[i + 1] = grad[alpha + 1]; // G
|
||||
this.heatmapLayer[i + 2] = grad[alpha + 2]; // B
|
||||
this.heatmapLayer[i + 3] = alpha; // A
|
||||
}
|
||||
}
|
||||
var grad = this.gradientData;
|
||||
this.heatmapLayer = new Uint8ClampedArray(this.size * 4);
|
||||
// while(Object.keys(this.loadedColorizedChunks).length < this.colorWorkers.length){
|
||||
// console.log(Object.keys(this.loadedColorizedChunks).length)
|
||||
// }
|
||||
// var i = 0;
|
||||
// while(i<=this.colorWorkers.length){
|
||||
// this.heatmapLayer += this.loadedColorizedChunks[i];
|
||||
// }
|
||||
// for (var i = this.pointLayer.length-4, alpha; i>=0; i-=4){
|
||||
// alpha = this.pointLayer[i+3] * 4; // get gradient color from opacity value
|
||||
// if (alpha>0) {
|
||||
// this.heatmapLayer[i] = grad[alpha]; // R
|
||||
// this.heatmapLayer[i + 1] = grad[alpha + 1]; // G
|
||||
// this.heatmapLayer[i + 2] = grad[alpha + 2]; // B
|
||||
// this.heatmapLayer[i + 3] = alpha; // A
|
||||
// }
|
||||
// }
|
||||
},
|
||||
|
||||
initColorWorkers: function(){
|
||||
var workerCount = 3
|
||||
this.colorWorkers = [];
|
||||
if(!this.loadedColorizedChunks) this.loadedColorizedChunks = {};
|
||||
for (var i = 0; i < workerCount; i++) {
|
||||
this.colorWorkers.push(work(require('./colorWorker.js')));
|
||||
var worker = work(require('./colorWorker.js'));
|
||||
worker.grad = this.gradientData;
|
||||
worker.onmessage = function(data){
|
||||
this.loadedColorizedChunks[data.data[0]] = data.data[1];
|
||||
}
|
||||
this.colorWorkers.push(worker);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user