Sending an ArrayBuffer via postMessage and marking it as transferable might be worth investigating, since it would significantly lower the memory footprint due to
zero-copy transfer
no need to instantiate a typed array in subData
Buffer.prototype.subData = function subData() {
var gl = this.gl;
var data = [];
// to prevent against maximum call-stack issue.
for (var i = 0, chunk = 10000; i < this.data.length; i += chunk)
data = Array.prototype.concat.apply(data, this.data.slice(i, i + chunk));
this.buffer = this.buffer || gl.createBuffer();
gl.bindBuffer(this.target, this.buffer);
gl.bufferData(this.target, new this.type(data), gl.STATIC_DRAW);
};
Also
// to prevent against maximum call-stack issue.
for (var i = 0, chunk = 10000; i < this.data.length; i += chunk)
data = Array.prototype.concat.apply(data, this.data.slice(i, i + chunk));
should be removed IMO. It seems very excessive in terms of memory footprint and execution time.
Sending an ArrayBuffer via
postMessage
and marking it as transferable might be worth investigating, since it would significantly lower the memory footprint due tosubData
Also
should be removed IMO. It seems very excessive in terms of memory footprint and execution time.