Skip to content

Commit

Permalink
Reduce unnecessarily large text canvas textures
Browse files Browse the repository at this point in the history
  • Loading branch information
brianchirls committed May 5, 2015
1 parent 629c613 commit 090e089
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/objects/text.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,11 +151,10 @@ module.exports = (function () {
} else {
lines.push(new Line(text));
}
if (!width) {
width = lines.reduce(function (previous, line) {
return Math.max(previous, line.totalWidth);
});
}

width = lines.reduce(function (previous, line) {
return Math.max(previous, line.totalWidth);
}, 0);
width = Math.min(width, 2048);

height = lines.length * lineHeight;
Expand Down Expand Up @@ -215,6 +214,8 @@ module.exports = (function () {
textHeight = lines.length * lineHeight / resolution;

tex.needsUpdate = true;

mesh.name = text.trim();
}

canvas = document.createElement('canvas');
Expand Down

0 comments on commit 090e089

Please sign in to comment.