From 090e0890ca4f5b27fdfacf7fea3d3e8199aaeafd Mon Sep 17 00:00:00 2001 From: Brian Chirls Date: Tue, 5 May 2015 12:00:35 -0400 Subject: [PATCH] Reduce unnecessarily large text canvas textures --- src/objects/text.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/objects/text.js b/src/objects/text.js index cc68b81..13b0a2b 100644 --- a/src/objects/text.js +++ b/src/objects/text.js @@ -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; @@ -215,6 +214,8 @@ module.exports = (function () { textHeight = lines.length * lineHeight / resolution; tex.needsUpdate = true; + + mesh.name = text.trim(); } canvas = document.createElement('canvas');