@awayjs/stage
Version:
Stage for AwayJS
52 lines (51 loc) • 1.63 kB
JavaScript
var StatsWebGL = /** @class */ (function () {
function StatsWebGL() {
this.counter = {
index: 0,
vertex: 0,
vao: 0,
texture: 0,
renderTarget: 0,
program: 0,
pbo: 0,
total: 0
};
this.memory = {
index: 0,
vertex: 0,
texture: 0,
renderTarget: 0,
pbo: 0,
get total() {
return this.index + this.vertex + this.texture + this.renderTarget + this.pbo;
}
};
}
StatsWebGL.prototype.toTableLikeMB = function () {
var report = {};
for (var key in this.counter) {
report[key] = {
count: this.counter[key],
memory: (this.memory[key] || 0) / (1024 * 1024)
};
}
return report;
};
StatsWebGL.prototype.toString = function () {
var table = this.toTableLikeMB();
var records = [
"\n".concat('type'.padStart(16, ' '), " | ").concat('count'.padStart(5), " | ").concat('mem MB'.padStart(6), "\n")
];
for (var key in table) {
records.push(
// eslint-disable-next-line max-len
"".concat(key.padStart(16), " | ").concat(table[key].count.toFixed().padStart(5), " | ").concat(table[key].memory.toFixed(4).padStart(8)));
}
return records.join('\n') + '\n';
};
StatsWebGL.prototype.toTableConsole = function () {
console.table(this.toTableLikeMB());
};
return StatsWebGL;
}());
export { StatsWebGL };