|
@@ -190,7 +190,7 @@ export class TextSprite extends THREE.Object3D{
|
|
|
if (this.textBorderThick) {
|
|
|
context.strokeStyle = 'rgba(' + this.textBorderColor.r + ',' + this.textBorderColor.g + ',' + this.textBorderColor.b + ',' + this.textBorderColor.a + ')'
|
|
|
context.lineWidth = this.textBorderThick * r
|
|
|
- context.strokeText(this.text[i], x, y)
|
|
|
+ context.strokeText(texts[i], x, y)
|
|
|
}
|
|
|
|
|
|
|
|
@@ -307,6 +307,10 @@ function breakLinesForCanvas(text, context, width, font) {
|
|
|
return result;
|
|
|
} //'使用很寻常的二分查找,如果某一个位置之前的文字宽度小于等于设定的宽度,并且它之后一个字之前的文字宽度大于设定的宽度,那么这个位置就是文本的换行点。上面只是找到一个换行点,对于输入的一段文本,需要循环查找,直到不存在这样的换行点为止, 完整的代码如下',
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+//待改进:breakLinesForCanvas后的lineSpace稍小于预设的[]换行的lineSpace, 用于测量标签
|
|
|
+
|
|
|
/*
|
|
|
function wrapText(text, maxWidth) {
|
|
|
// 创建一个 canvas 元素来测量文本宽度
|